fix(cli): fix some bugs of create-vant-cli-app

This commit is contained in:
陈嘉涵 2020-01-16 19:28:26 +08:00
parent 5bb9a31e28
commit df6edc4864
7 changed files with 17 additions and 26 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "create-vant-cli-app", "name": "create-vant-cli-app",
"version": "1.0.0", "version": "0.0.1",
"description": "Create Vant Cli App", "description": "Create Vant Cli App",
"main": "lib/index.js", "main": "lib/index.js",
"bin": { "bin": {
@ -14,6 +14,10 @@
"type": "git", "type": "git",
"url": "https://github.com/youzan/vant/tree/dev/packages/create-vant-cli-app" "url": "https://github.com/youzan/vant/tree/dev/packages/create-vant-cli-app"
}, },
"files": [
"lib",
"generators"
],
"keywords": [ "keywords": [
"vant" "vant"
], ],

View File

@ -44,21 +44,21 @@ export class VanGenerator extends Generator {
this.fs.copy(join(TEMPLATES, from), this.destinationPath(to || from)); this.fs.copy(join(TEMPLATES, from), this.destinationPath(to || from));
}; };
const copyTpl = (name: string) => { const copyTpl = (name: string, target?: string) => {
this.fs.copyTpl( this.fs.copyTpl(
join(TEMPLATES, name), join(TEMPLATES, name),
this.destinationPath(name), this.destinationPath(target || name),
this.inputs this.inputs
); );
}; };
copy('.gitignore'); copyTpl('package.json.tpl', 'package.json');
copy('.eslintignore'); copyTpl('vant.config.js');
copy('babel.config.js'); copy('babel.config.js');
copy('gitignore.tpl', '.gitignore');
copy('eslintignore.tpl', '.eslintignore');
copy('src/**/*', 'src'); copy('src/**/*', 'src');
copy('docs/**/*', 'docs'); copy('docs/**/*', 'docs');
copyTpl('package.json');
copyTpl('vant.config.js');
} }
install() { install() {

View File

@ -1,5 +1,7 @@
#!/usr/bin/env node
import inquirer from 'inquirer'; import inquirer from 'inquirer';
import { mkdirSync, existsSync } from 'fs-extra'; import { ensureDir } from 'fs-extra';
import { VanGenerator } from './generator'; import { VanGenerator } from './generator';
const PROMPTS = [ const PROMPTS = [
@ -13,15 +15,10 @@ const PROMPTS = [
export default async function run() { export default async function run() {
const { name } = await inquirer.prompt(PROMPTS); const { name } = await inquirer.prompt(PROMPTS);
if (!existsSync(name)) { ensureDir(name);
mkdirSync(name);
}
const generator = new VanGenerator(name); const generator = new VanGenerator(name);
generator.run();
return new Promise(resolve => {
generator.run(resolve);
});
} }
run(); run();

View File

@ -21,8 +21,7 @@
"lib", "lib",
"site", "site",
"template", "template",
"preset.js", "preset.js"
"generators"
], ],
"keywords": [ "keywords": [
"vant" "vant"
@ -41,7 +40,6 @@
"@types/postcss-load-config": "^2.0.1", "@types/postcss-load-config": "^2.0.1",
"@types/sass": "^1.16.0", "@types/sass": "^1.16.0",
"@types/shelljs": "^0.8.6", "@types/shelljs": "^0.8.6",
"@types/source-map": "^0.5.7",
"@types/webpack": "^4.41.2", "@types/webpack": "^4.41.2",
"@types/webpack-dev-server": "^3.9.0", "@types/webpack-dev-server": "^3.9.0",
"@types/webpack-merge": "^4.1.5" "@types/webpack-merge": "^4.1.5"
@ -124,13 +122,5 @@
"global-require": 0, "global-require": 0,
"import/no-dynamic-require": 0 "import/no-dynamic-require": 0
} }
},
"stylelint": {
"extends": [
"@vant/stylelint-config"
]
},
"prettier": {
"singleQuote": true
} }
} }