From 1382fdaea8f7151fa82ab10fa8a4dbced4510995 Mon Sep 17 00:00:00 2001 From: Filip Rojek Date: Sun, 15 Aug 2021 19:09:33 +0200 Subject: [PATCH] added setup funtion for existing projects --- package.json | 2 +- src/app.js | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index b29ed68..3728e4e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nork", - "version": "1.0.1", + "version": "1.1.0", "description": "The best node.js 'framework' :)", "main": "src/app.js", "bin": "src/app.js", diff --git a/src/app.js b/src/app.js index a683596..a7e38cd 100644 --- a/src/app.js +++ b/src/app.js @@ -63,7 +63,7 @@ const logHelp = (specific = false, command = false) => { console.log(pad(' make:route', spc), 'create a new route') console.log(pad(' make:test', spc), 'create a new test') console.log(pad(' make:view', spc), 'create a new view') - + console.log(pad(' setup', spc), 'set up an existing project for nork') console.log() console.log(' Run', colors.cyan('nork help '), 'for detailed usage of given command.') @@ -77,7 +77,6 @@ const logHelp = (specific = false, command = false) => { ;(async () => { if (process.argv[2] == 'create') { // get info about new project - const data = { lang: 'ts' } const questions = [ { type: 'input', @@ -188,6 +187,22 @@ const logHelp = (specific = false, command = false) => { } } + if (process.argv[2] == 'setup') { + const questions = { + type: 'list', + message: "Pick the technology you're using:", + name: 'lang', + choices: [ + { name: 'Typescript', value: 'ts' }, + { name: 'Javascript', value: 'js' }, + ], + } + let answers = await inquirer.prompt(questions) + + fs.writeJsonSync(path.join(process.cwd(), './norkconfig.json'), answers) + return logSuccess() + } + if (process.argv[2] == '-v' || process.argv[2] == '--version') { const pkgJson = require(path.join(__dirname, '../package.json')) return console.log('nork', pkgJson.version) @@ -200,7 +215,6 @@ const logHelp = (specific = false, command = false) => { return logHelp() } - process.argv.splice(0, 2) logHelp(false, process.argv.join(' ')) })()