11#!/usr/bin/env node
2-
3- const { readdirSync } = require ( 'fs' )
4- const { join, basename } = require ( 'path' )
52const program = require ( 'commander' )
63const log = require ( '../src/log' )
74const init = require ( './init' )
@@ -19,34 +16,41 @@ program
1916 . usage ( '[options] <repository>' )
2017 . description ( 'initialize the project' )
2118 . option ( '-n --app-name [app_name]' , `Set your app name.` )
19+ . option ( '--force' )
2220 . action ( ( repository , option ) => {
2321 if ( ! repository ) program . help ( )
2422
25- const { appName } = option
23+ const { appName, force = false } = option
2624
2725 log . info ( 'initialize project ...' )
2826
29- return init ( appName , repository )
27+ return init ( appName , repository , force )
3028 . then ( ( ) => log . info ( 'initialize complete' ) )
3129 . catch ( err => log . error ( 'program' , 'initialize break' , err ) )
3230 } )
3331
3432program
3533 . command ( 'upgrade' )
3634 . description ( 'upgrade the template' )
37- . action ( ( ) => {
35+ . option ( '--force' )
36+ . action ( ( option ) => {
37+ const { force = false } = option
38+
3839 log . info ( 'prepare upgrade' )
39- upgrade ( )
40+ upgrade ( force )
4041 . then ( ( ) => log . info ( 'upgrade complete' ) )
4142 . catch ( err => log . error ( 'program' , 'upgrade break' , err ) )
4243 } )
4344
4445program
4546 . command ( 'update' )
4647 . description ( 'Update the project with the current version of the template' )
47- . action ( ( ) => {
48+ . option ( '--force' )
49+ . action ( ( option ) => {
50+ const { force = false } = option
51+
4852 log . info ( 'prepare update' )
49- update ( )
53+ update ( force )
5054 . then ( ( ) => log . info ( 'update complete' ) )
5155 . catch ( err => log . error ( 'program' , 'update break' , err ) )
5256 } )
0 commit comments