Skip to content

Commit

Permalink
Add ignore and tag template config
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkTangCd committed May 18, 2022
1 parent 56686f7 commit a7a8c2c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
14 changes: 8 additions & 6 deletions commands/init/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ class InitCommand extends Command {
spinner.stop(true);
log.success('Template installed successfully.');
}

const ignore = ['node_modules/**', 'public/**', 'packages/**'];
console.log(this.templateInfo);
const templateIgnore = this.templateInfo.ignore || [];
const ignore = ['node_modules/**', ...templateIgnore];
await this.ejsRender({ ignore });
const { installCommand, startCommand } = this.templateInfo;
// install
Expand Down Expand Up @@ -244,13 +245,14 @@ class InitCommand extends Command {
choices: [{
name: 'Project',
value: TYPE_PROJECT
},
{
name: 'Component',
value: TYPE_COMPONENT
}]
// }, {
// name: 'Component',
// value: TYPE_COMPONENT
// }]
});
log.verbose('type', type);
this.templates = this.templates.filter(template => template.tag.includes(type));

if (type === TYPE_PROJECT) {
const projectNamePrompt = {
Expand Down
23 changes: 20 additions & 3 deletions commands/init/lib/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module.exports = [
version: 'latest',
disabled: false,
installCommand: ["yarn"],
startCommand: []
startCommand: [],
tag: ["project"],
ignore: ["**/packages/**"]
},
{
id: 2,
Expand All @@ -15,7 +17,9 @@ module.exports = [
version: 'latest',
disabled: false,
installCommand: ["yarn"],
startCommand: ["yarn", "run", "dev"]
startCommand: ["yarn", "run", "dev"],
tag: ["project"],
ignore: []
},
{
id: 3,
Expand All @@ -24,6 +28,19 @@ module.exports = [
version: 'latest',
disabled: false,
installCommand: ["yarn"],
startCommand: []
startCommand: [],
tag: ["project"],
ignore: ["**/Truffle/**"]
},
{
id: 4,
name: 'Test-Component',
npmName: 'dapp-cli-component-test',
version: 'latest',
disabled: false,
installCommand: ["yarn"],
startCommand: [],
tag: ["component"],
ignore: []
}
]
4 changes: 2 additions & 2 deletions core/cli/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function registerCommand() {
.name(Object.keys(pkg.bin)[0])
.usage('<command> [options]')
.version(pkg.version)
.option('-d, --debug', 'Is debug mode on?', false);
// .option('-tp, --targetPath <targetPath>', 'Is the local debug file path specified?', '');
.option('-d, --debug', 'Is debug mode on?', false)
.option('-tp, --targetPath <targetPath>', 'Is the local debug file path specified?', '');

program
.command('init [projectName]')
Expand Down

0 comments on commit a7a8c2c

Please sign in to comment.