Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support download npm package #22

Merged
merged 1 commit into from
Feb 26, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions lib/init_command.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,25 @@ module.exports = class Command {

// use local template
let templateDir = yield this.getTemplateDir();

if (!templateDir) {
// list boilerplate
const boilerplateMapping = yield this.fetchBoilerplateMapping();
// ask for boilerplate
let boilerplate;
if (argv.type && boilerplateMapping.hasOwnProperty(argv.type)) {
boilerplate = boilerplateMapping[argv.type];
} else {
boilerplate = yield this.askForBoilerplateType(boilerplateMapping);
// support --package=<npm name>
let pkgName = this.argv.package;
if (!pkgName) {
// list boilerplate
const boilerplateMapping = yield this.fetchBoilerplateMapping();
// ask for boilerplate
let boilerplate;
if (argv.type && boilerplateMapping.hasOwnProperty(argv.type)) {
boilerplate = boilerplateMapping[ argv.type ];
} else {
boilerplate = yield this.askForBoilerplateType(boilerplateMapping);
}
this.log(`use boilerplate: ${boilerplate.name}(${boilerplate.package})`);
pkgName = boilerplate.package;
}
this.log(`use boilerplate: ${boilerplate.name}(${boilerplate.package})`);
// download boilerplate
templateDir = yield this.downloadBoilerplate(boilerplate.package);
templateDir = yield this.downloadBoilerplate(pkgName);
}

// copy template
Expand Down Expand Up @@ -230,6 +236,10 @@ module.exports = class Command {
type: 'string',
description: 'local path to boilerplate',
},
package: {
type: 'string',
description: 'boilerplate package name',
},
registry: {
type: 'string',
description: 'npm registry, support china/npm/custom, default to auto detect',
Expand Down