@@ -30,14 +30,13 @@ exports.run = function (options) {
30
30
type : 'list' ,
31
31
name : 'type' ,
32
32
message : 'config type:' ,
33
- choices : [ 'qunar' , 'hy' ]
33
+ choices : [ 'qunar' , 'hy' , 'xta' , 'none' ]
34
34
} ] ;
35
35
36
36
inquirer . prompt ( questions ) . then ( function ( answers ) {
37
37
answers . name = answers . name || defaultName ;
38
38
39
39
var initTmplPath = sysPath . resolve ( __dirname , '../config/initTmpl/' ) ;
40
- var configFileName = 'ykit.' + answers . type + '.js' ;
41
40
var writePackageJsonStream = void 0 ;
42
41
43
42
// 如果没有package.json,先添加package.json
@@ -46,22 +45,24 @@ exports.run = function (options) {
46
45
}
47
46
48
47
if ( ! writePackageJsonStream ) {
49
- createConfigFile ( ) ;
48
+ createConfigFile ( answers . type ) ;
50
49
installDependencies ( ) ;
51
50
} else {
52
51
writePackageJsonStream . on ( 'finish' , function ( ) {
53
52
log ( 'Successfully created package.json file in ' + cwd ) ;
54
53
55
- createConfigFile ( ) ;
56
- installDependencies ( ) ;
54
+ createConfigFile ( answers . type ) ;
55
+ installDependencies ( answers . type ) ;
57
56
} ) ;
58
57
}
59
58
60
59
function createPakcageJson ( ) {
61
60
return fs . createReadStream ( sysPath . resolve ( initTmplPath , 'package.json' ) ) . pipe ( replaceStream ( '#_name' , answers . name ) ) . pipe ( fs . createWriteStream ( sysPath . resolve ( cwd , 'package.json' ) ) ) ;
62
61
}
63
62
64
- function createConfigFile ( ) {
63
+ function createConfigFile ( configType ) {
64
+ var configFileName = configType !== 'none' ? 'ykit.' + configType + '.js' : 'ykit.js' ;
65
+
65
66
if ( ! fileExists ( './' + configFileName ) ) {
66
67
var stream = fs . createReadStream ( sysPath . resolve ( initTmplPath , 'ykit.common.js' ) ) . pipe ( replaceStream ( '#_name' , answers . name ) ) . pipe ( fs . createWriteStream ( sysPath . resolve ( cwd , configFileName ) ) ) ;
67
68
@@ -71,9 +72,13 @@ exports.run = function (options) {
71
72
}
72
73
}
73
74
74
- function installDependencies ( ) {
75
- var packageName = 'ykit-config-' + answers . type ,
76
- installConfigPackageCmd = 'npm i --save git+ssh://git@gitlab.corp.qunar.com:mfe/ykit-config-' + answers . type + '.git' ;
75
+ function installDependencies ( configType ) {
76
+ if ( configType === 'none' ) {
77
+ return ;
78
+ }
79
+
80
+ var packageName = 'ykit-config-' + configType ,
81
+ installConfigPackageCmd = 'npm i --save git+ssh://git@gitlab.corp.qunar.com:mfe/ykit-config-' + configType + '.git' ;
77
82
78
83
log ( 'Installing ' + packageName + '...' ) ;
79
84
execSync ( installConfigPackageCmd ) ;
0 commit comments