This repository has been archived by the owner on Jun 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da74a63
commit 32b854b
Showing
3 changed files
with
42 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,12 @@ | ||
const log = console.log | ||
const chalk = require('chalk') | ||
require('shelljs/global') | ||
|
||
const init = require('../libs/init.js') | ||
|
||
module.exports = function initCommand(program) { | ||
program | ||
.command('init') | ||
.option('-t', '--target', 'Init project under a new name and/or directory') | ||
.description('Create a Mean Starter Project in current directory') | ||
.action(option => { | ||
|
||
if (!which('git')) { | ||
log(chalk.red('Sorry, this command requires git')) | ||
exit(1) | ||
} | ||
|
||
let shellStr = 'git clone --progress https://github.com/Nucleus-Inc/MeanStarter.git' | ||
|
||
if (typeof (option) === 'string') { | ||
shellStr += ' ' + option | ||
} | ||
|
||
log(chalk.cyan('Started git repo cloning ...')) | ||
|
||
if (exec(shellStr).code !== 0) { | ||
log(chalk.red.bold('Oops ... Something wrong happened, please try again.')) | ||
exit(1) | ||
} | ||
log(chalk.green.bold('Finish cloning Mean Starter !')) | ||
.command('init [cmd]') | ||
.option('-d, --dir <directory>', 'Target Directory') | ||
.description('Generate Express Lib') | ||
.action((cmd, options) => { | ||
init.initProject(options.dir) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const log = console.log | ||
const chalk = require('chalk') | ||
require('shelljs/global') | ||
|
||
module.exports = { | ||
initProject: (_target) => { | ||
if (!which('git')) { | ||
log(chalk.red('Sorry, this command requires git')) | ||
exit(1) | ||
} | ||
|
||
let dirName = _target || 'MeanStarter' | ||
let gitShell = 'git clone --progress https://github.com/Nucleus-Inc/MeanStarter.git' | ||
let yarnShell = 'cd ' + dirName + '&& yarn install' | ||
|
||
if (_target) { | ||
gitShell += ' ' + _target | ||
} | ||
|
||
log(chalk.cyan('Started git repo cloning ...')) | ||
|
||
if (exec(gitShell).code !== 0) { | ||
log(chalk.red.bold('Oops ... Something wrong happened while cloning the repo.')) | ||
exit(1) | ||
} | ||
|
||
log(chalk.green.bold('Finish cloning Mean Starter !')) | ||
|
||
if (exec(yarnShell).code !== 0) { | ||
log(chalk.red.bold('Oops ... Something wrong happened whily installing dependencies.')) | ||
exit(1) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,4 @@ | |
"ejs": "^2.6.1", | ||
"shelljs": "^0.8.2" | ||
} | ||
} | ||
} |