mirror of
https://github.com/filiprojek/nork.git
synced 2024-11-23 01:01:04 +01:00
create project in current directory
package.json updated
This commit is contained in:
parent
ff902c85ac
commit
4de0bce7a1
@ -26,6 +26,7 @@ Options:
|
|||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
create [app-name] create a new project
|
create [app-name] create a new project
|
||||||
|
create [app-name] -i create a new project in current directory
|
||||||
make controller [name] create a new controller
|
make controller [name] create a new controller
|
||||||
make middleware [name] create a new middleware
|
make middleware [name] create a new middleware
|
||||||
make model [name] create a new model
|
make model [name] create a new model
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nork",
|
"name": "nork",
|
||||||
"version": "1.1.4",
|
"version": "1.1.5",
|
||||||
"description": "The best node.js 'framework' :)",
|
"description": "The best node.js 'framework' :)",
|
||||||
"main": "src/app.js",
|
"main": "src/app.js",
|
||||||
"bin": "src/app.js",
|
"bin": "src/app.js",
|
||||||
|
11
src/app.js
11
src/app.js
@ -30,7 +30,7 @@ const logSuccess = (msg = false) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const logHelp = (specific = false, command = false) => {
|
const logHelp = (specific = false, command = false) => {
|
||||||
let spc = 40
|
let spc = 27
|
||||||
|
|
||||||
if (specific) {
|
if (specific) {
|
||||||
// log specific help
|
// log specific help
|
||||||
@ -57,6 +57,7 @@ const logHelp = (specific = false, command = false) => {
|
|||||||
console.log()
|
console.log()
|
||||||
console.log('Commands:')
|
console.log('Commands:')
|
||||||
console.log(pad(' create [app-name]', spc), 'create a new project')
|
console.log(pad(' create [app-name]', spc), 'create a new project')
|
||||||
|
console.log(pad(' create [app-name] -i', spc), 'create a new project in current directory')
|
||||||
console.log(pad(' make controller [name]', spc), 'create a new controller')
|
console.log(pad(' make controller [name]', spc), 'create a new controller')
|
||||||
console.log(pad(' make middleware [name]', spc), 'create a new middleware')
|
console.log(pad(' make middleware [name]', spc), 'create a new middleware')
|
||||||
console.log(pad(' make model [name]', spc), 'create a new model')
|
console.log(pad(' make model [name]', spc), 'create a new model')
|
||||||
@ -77,6 +78,7 @@ const logHelp = (specific = false, command = false) => {
|
|||||||
;(async () => {
|
;(async () => {
|
||||||
if (process.argv[2] == 'create') {
|
if (process.argv[2] == 'create') {
|
||||||
// get info about new project
|
// get info about new project
|
||||||
|
let projectPath
|
||||||
const data = {}
|
const data = {}
|
||||||
const questions = [
|
const questions = [
|
||||||
{
|
{
|
||||||
@ -110,15 +112,16 @@ const logHelp = (specific = false, command = false) => {
|
|||||||
data.author = answers.author
|
data.author = answers.author
|
||||||
|
|
||||||
// copy skeleton to new project
|
// copy skeleton to new project
|
||||||
fs.copySync(path.join(__dirname, './skeletons/express-' + data.lang), process.cwd())
|
process.argv.includes('-i') ? projectPath = process.cwd() : projectPath = path.join(process.cwd(), data.project_name)
|
||||||
|
fs.copySync(path.join(__dirname, './skeletons/express-' + data.lang), projectPath)
|
||||||
|
|
||||||
// edit package.json file
|
// edit package.json file
|
||||||
const pkgJson = require(path.join(process.cwd(), 'package.json'))
|
const pkgJson = require(path.join(projectPath, 'package.json'))
|
||||||
|
|
||||||
pkgJson.name = data.project_name
|
pkgJson.name = data.project_name
|
||||||
pkgJson.author = data.author
|
pkgJson.author = data.author
|
||||||
|
|
||||||
fs.writeFile(path.join(process.cwd(), 'package.json'), JSON.stringify(pkgJson, null, 2), err => {
|
fs.writeFile(path.join(projectPath, 'package.json'), JSON.stringify(pkgJson, null, 2), err => {
|
||||||
if (err) return logError(err)
|
if (err) return logError(err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
"@types/ejs": "^3.0.6",
|
"@types/ejs": "^3.0.6",
|
||||||
"@types/express": "^4.17.11",
|
"@types/express": "^4.17.11",
|
||||||
"@types/fs-extra": "^9.0.12",
|
"@types/fs-extra": "^9.0.12",
|
||||||
"@types/jest": "^26.0.24",
|
"@types/jest": "^27.0.1",
|
||||||
"@types/mongoose": "^5.10.5",
|
"@types/mongoose": "^5.10.5",
|
||||||
"@types/morgan": "^1.9.2",
|
"@types/morgan": "^1.9.2",
|
||||||
"@types/node": "^14.14.41",
|
"@types/node": "^14.14.41",
|
||||||
@ -38,7 +38,7 @@
|
|||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"shelljs": "^0.8.4",
|
"shelljs": "^0.8.4",
|
||||||
"ts-jest": "^27.0.4",
|
"ts-jest": "^27.0.5",
|
||||||
"ts-node": "^9.1.1",
|
"ts-node": "^9.1.1",
|
||||||
"typescript": "^4.2.4"
|
"typescript": "^4.2.4"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user