1
1
#!/usr/bin/env node
2
- import { Command , Option } from 'commander' ;
2
+ import { Command , Option , Argument } from 'commander' ;
3
3
import { dev } from '../src/commands/dev.mjs' ;
4
4
import { build } from '../src/commands/build.mjs' ;
5
5
import { start } from '../src/commands/start.mjs' ;
6
6
import { test } from '../src/commands/test.mjs' ;
7
+ import { custom , CUSTOM_PART } from '../src/commands/custom.mjs' ;
7
8
import { COMMAND_NAME } from '../src/commands/constant.mjs' ;
8
9
9
10
// eslint-disable-next-line
@@ -66,6 +67,7 @@ program.command(COMMAND_NAME.DEV)
66
67
67
68
program
68
69
. command ( COMMAND_NAME . BUILD )
70
+ . description ( 'Build command' )
69
71
. addOption ( writeToDiskOption )
70
72
. addOption ( sourcemapOption )
71
73
. addOption ( runTasksOption )
@@ -85,6 +87,7 @@ program
85
87
86
88
program
87
89
. command ( COMMAND_NAME . START )
90
+ . description ( 'Start widget server' )
88
91
. addOption ( portOption )
89
92
. addOption ( devServerPortOption )
90
93
. addOption ( projectFolderOption )
@@ -106,6 +109,7 @@ program
106
109
107
110
program
108
111
. command ( COMMAND_NAME . TEST )
112
+ . description ( 'Test widget' )
109
113
. allowUnknownOption ( )
110
114
. action ( async ( options , cmd ) => {
111
115
process . env . NODE_ENV = process . env . NODE_ENV ?? 'test' ;
@@ -117,4 +121,19 @@ program
117
121
await test ( { args, commandArgs : cmd . args , command : COMMAND_NAME . TEST } ) ;
118
122
} ) ;
119
123
124
+ program
125
+ . command ( COMMAND_NAME . CUSTOM )
126
+ . description ( 'Customize template' )
127
+ . addArgument ( new Argument ( '<part>' , 'custom part' ) . choices ( Object . values ( CUSTOM_PART ) ) )
128
+ . addOption ( verboseOption )
129
+ . allowUnknownOption ( )
130
+ . action ( async ( part , options , cmd ) => {
131
+ const args = {
132
+ ...options ,
133
+ part,
134
+ } ;
135
+
136
+ await custom ( { args, commandArgs : cmd . args , command : COMMAND_NAME . CUSTOM } ) ;
137
+ } ) ;
138
+
120
139
program . parse ( process . argv ) ;
0 commit comments