File tree Expand file tree Collapse file tree 6 files changed +66
-6
lines changed
Expand file tree Collapse file tree 6 files changed +66
-6
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,11 @@ const pkg = require('./package')
88const cli = cac ( )
99
1010cli . command ( '*' , 'Generate a new project' , input => {
11- const folderName = input [ 0 ] || '.'
11+ if ( input . length === 0 ) {
12+ return cli . showHelp ( )
13+ }
14+
15+ const folderName = input [ 0 ]
1216 const targetPath = path . resolve ( folderName )
1317 console . log ( `> Generating project in ${ targetPath } ` )
1418
Original file line number Diff line number Diff line change @@ -23,6 +23,12 @@ module.exports = {
2323 message : 'Use default manifest.json and icons for PWA' ,
2424 store : true
2525 } ,
26+ unitTest : {
27+ type : 'confirm' ,
28+ default : true ,
29+ message : 'Use Tyu(Jest) to run unit tests' ,
30+ store : true
31+ } ,
2632 username : {
2733 message : `What's your GitHub username` ,
2834 default : ':gitUser:' ,
@@ -40,7 +46,8 @@ module.exports = {
4046 filters : {
4147 'src/pwa.js' : 'pwa' ,
4248 'static/manifest.json' : 'manifest' ,
43- 'static/icons/**' : 'manifest'
49+ 'static/icons/**' : 'manifest' ,
50+ 'src/components/App.test.js' : 'unitTest'
4451 } ,
4552 gitInit : true ,
4653 installDependencies : true ,
Original file line number Diff line number Diff line change 99 "dev" : " poi" ,
1010 "build" : " poi build" ,
1111 "report" : " poi build --bundle-report" ,
12- "serve" : " serve dist --single" ,
13- "test" : " tyu"
12+ "serve" : " serve dist --single" <% if (unitTest) { %> ,
13+ "test" : " tyu" <% } %>
1414 },
1515 "author" : {
1616 "name" : " <%= username %>" ,
2525 "devDependencies" : {
2626 "poi" : " ^9.0.0" ,
2727 "poi-preset-bundle-report" : " ^2.0.0" ,
28- "serve" : " ^6.1.0" ,
29- "tyu" : " ^1.0.4" <% if (pwa) { %>,
28+ "serve" : " ^6.1.0" <% if (unitTest) { %> ,
29+ "tyu" : " ^1.0.4" <% } %><% if (pwa) { %>,
3030 "poi-preset-offline" : " ^9.0.0" <% } %>
3131 }
3232}
Original file line number Diff line number Diff line change @@ -24,4 +24,43 @@ Generated by [AVA](https://ava.li).
2424 'static/icons/android-chrome-192x192.png',
2525 'static/icons/android-chrome-512x512.png',
2626 'static/manifest.json',
27+
28+
29+ ## no unit test
30+
31+ > Snapshot 1
32+
33+ [
34+ '.editorconfig',
35+ '.gitignore',
36+ 'README.md',
37+ 'index.ejs',
38+ 'package.json',
39+ 'poi.config.js',
40+ 'src/components/App.vue',
41+ 'src/index.js',
42+ 'src/polyfills.js',
43+ 'src/pwa.js',
44+ 'static/favicon.ico',
45+ 'static/icons/android-chrome-192x192.png',
46+ 'static/icons/android-chrome-512x512.png',
47+ 'static/manifest.json',
2748 ]
49+
50+ > scripts
51+
52+ {
53+ build: 'poi build',
54+ dev: 'poi',
55+ report: 'poi build --bundle-report',
56+ serve: 'serve dist --single',
57+ }
58+
59+ > devDependencies
60+
61+ {
62+ poi: '^9.0.0',
63+ 'poi-preset-bundle-report': '^2.0.0',
64+ 'poi-preset-offline': '^9.0.0',
65+ serve: '^6.1.0',
66+ }
Original file line number Diff line number Diff line change @@ -8,3 +8,13 @@ test('defaults', async t => {
88 const res = await sao . mockPrompt ( template , { } )
99 t . snapshot ( res . fileList )
1010} )
11+
12+ test ( 'no unit test' , async t => {
13+ const res = await sao . mockPrompt ( template , {
14+ unitTest : false
15+ } )
16+ t . snapshot ( res . fileList )
17+ const pkg = JSON . parse ( res . fileContents ( 'package.json' ) )
18+ t . snapshot ( pkg . scripts , 'scripts' )
19+ t . snapshot ( pkg . devDependencies , 'devDependencies' )
20+ } )
You can’t perform that action at this time.
0 commit comments