UNPKG

2.05 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 return new (P || (P = Promise))(function (resolve, reject) {
4 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7 step((generator = generator.apply(thisArg, _arguments || [])).next());
8 });
9};
10Object.defineProperty(exports, "__esModule", { value: true });
11exports.default = (ctx) => {
12 ctx.registerCommand({
13 name: 'init',
14 optionsMap: {
15 '--name [name]': '项目名称',
16 '--description [description]': '项目介绍',
17 '--typescript': '使用TypeScript',
18 '--no-typescript': '使用TypeScript',
19 '--template-source [templateSource]': '项目模板源',
20 '--clone [clone]': '拉取远程模板时使用git clone',
21 '--template [template]': '项目模板',
22 '--css [css]': 'CSS预处理器(sass/less/stylus/none)',
23 '-h, --help': 'output usage information'
24 },
25 fn() {
26 return __awaiter(this, void 0, void 0, function* () {
27 // init project
28 const { appPath } = ctx.paths;
29 const { projectName, templateSource, clone, template, description, typescript, css } = ctx.runOpts;
30 const Project = require('../../create/project').default;
31 const project = new Project({
32 projectName,
33 projectDir: appPath,
34 templateSource,
35 clone,
36 template,
37 description,
38 typescript,
39 css
40 });
41 project.create();
42 });
43 }
44 });
45};