zmp-cli 3.9.1 → 3.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/index.js +0 -0
- package/build/dist/index.dev.js +217 -0
- package/build/index.js +2 -4
- package/config/dist/index.dev.js +48 -0
- package/config/index.js +4 -8
- package/create/index.js +0 -0
- package/create/templates/dist/generate-styles.dev.js +46 -0
- package/create/templates/react/dist/generate-scripts.dev.js +23 -0
- package/create/templates/react-typescript/dist/generate-scripts.dev.js +23 -0
- package/create/utils/generate-package-json.js +1 -1
- package/deploy/dist/index.dev.js +227 -0
- package/deploy/index.js +17 -1
- package/deploy/utils/dist/upload-app.dev.js +113 -0
- package/deploy/utils/upload-app.js +1 -1
- package/dist/index.dev.js +352 -0
- package/index.js +7 -3
- package/login/dist/index.dev.js +223 -0
- package/login/index.js +5 -10
- package/login/utils/dist/zalo-login.dev.js +41 -0
- package/login/utils/zalo-login.js +5 -9
- package/migrate/index.js +0 -0
- package/package.json +3 -4
- package/start/index.js +25 -18
- package/utils/dist/get-app-info.dev.js +54 -0
- package/utils/env.js +8 -1
- package/utils/get-app-info.js +1 -3
package/deploy/index.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = async (
|
|
|
30
30
|
) => {
|
|
31
31
|
const cwd = options.cwd || process.cwd();
|
|
32
32
|
const outputDir = options.outputDir || 'www';
|
|
33
|
-
const apiDomain = config.api_domain
|
|
33
|
+
const apiDomain = config.api_domain;
|
|
34
34
|
const resolvePath = (dir) => {
|
|
35
35
|
return path.join(cwd, dir);
|
|
36
36
|
};
|
|
@@ -41,6 +41,8 @@ module.exports = async (
|
|
|
41
41
|
|
|
42
42
|
const token = envUtils.getEnv(config.env.token);
|
|
43
43
|
const appConfigFilename = config.filename.appConfig;
|
|
44
|
+
const packageJsonFilename = config.filename.packageJson;
|
|
45
|
+
|
|
44
46
|
let appConfigJson;
|
|
45
47
|
try {
|
|
46
48
|
appConfigJson = require(resolvePath(appConfigFilename));
|
|
@@ -48,10 +50,24 @@ module.exports = async (
|
|
|
48
50
|
errorExit(new Error(config.error_msg.app_config_not_found));
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
let packageJson;
|
|
54
|
+
const frameworkVersions = {};
|
|
55
|
+
try {
|
|
56
|
+
packageJson = require(resolvePath(packageJsonFilename));
|
|
57
|
+
const dependencies = packageJson.dependencies;
|
|
58
|
+
Object.entries(dependencies).forEach(([key, value]) => {
|
|
59
|
+
if (key.includes('zmp') || key.includes('react')) {
|
|
60
|
+
frameworkVersions[key] = value;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
} catch (err) {
|
|
64
|
+
// pass
|
|
65
|
+
}
|
|
51
66
|
const dataRequest = {
|
|
52
67
|
appName: appConfigJson.app.title,
|
|
53
68
|
appDesc: options.desc || 'Update app with new version',
|
|
54
69
|
appConfig: JSON.stringify(appConfigJson),
|
|
70
|
+
frameworkVersions: JSON.stringify(frameworkVersions),
|
|
55
71
|
};
|
|
56
72
|
|
|
57
73
|
let nextVersion;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
9
|
+
var Resumable = require('../../utils/resumable');
|
|
10
|
+
|
|
11
|
+
var chalk = require('chalk');
|
|
12
|
+
|
|
13
|
+
var config = require('../../config');
|
|
14
|
+
|
|
15
|
+
var envUtils = require('../../utils/env');
|
|
16
|
+
|
|
17
|
+
var File = require('file-api').File;
|
|
18
|
+
|
|
19
|
+
var FormData = require('form-data');
|
|
20
|
+
|
|
21
|
+
var _ = require('lodash');
|
|
22
|
+
|
|
23
|
+
module.exports = function _callee(data, options, logger) {
|
|
24
|
+
var apiDomain, uploadAppByChunk, apiUploadAppByChunk, appName, appDesc, appBuffer, appConfig, identifier, token, resumable, formData, i;
|
|
25
|
+
return regeneratorRuntime.async(function _callee$(_context) {
|
|
26
|
+
while (1) {
|
|
27
|
+
switch (_context.prev = _context.next) {
|
|
28
|
+
case 0:
|
|
29
|
+
apiDomain = config.api_domain;
|
|
30
|
+
|
|
31
|
+
uploadAppByChunk = function uploadAppByChunk(resumable, bufferData) {
|
|
32
|
+
return new Promise(function (resolve, reject) {
|
|
33
|
+
try {
|
|
34
|
+
var file = new File({
|
|
35
|
+
name: 'www.zip',
|
|
36
|
+
// required
|
|
37
|
+
buffer: bufferData
|
|
38
|
+
});
|
|
39
|
+
resumable.on('fileAdded', function () {
|
|
40
|
+
resumable.upload();
|
|
41
|
+
});
|
|
42
|
+
resumable.on('complete', function () {
|
|
43
|
+
return resolve();
|
|
44
|
+
});
|
|
45
|
+
resumable.on('fileError', function (file, message) {
|
|
46
|
+
return reject(new Error("Error upload app: ".concat(message)));
|
|
47
|
+
});
|
|
48
|
+
resumable.on('cancel', function () {
|
|
49
|
+
return reject(new Error('Error upload app: cancel'));
|
|
50
|
+
});
|
|
51
|
+
resumable.on('fileSuccess', function (file, message) {
|
|
52
|
+
var resData = JSON.parse(message);
|
|
53
|
+
|
|
54
|
+
if (_.isNumber(resData.err) && resData.err < 0) {
|
|
55
|
+
return reject(new Error("Error upload app: ".concat(message)));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return resolve(resData);
|
|
59
|
+
});
|
|
60
|
+
resumable.addFile(file);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
return reject(error);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
apiUploadAppByChunk = "".concat(apiDomain).concat(config.path.uploadAppByChunk);
|
|
68
|
+
appName = data.appName, appDesc = data.appDesc, appBuffer = data.appBuffer, appConfig = data.appConfig, identifier = data.identifier;
|
|
69
|
+
token = envUtils.getEnv(config.env.token);
|
|
70
|
+
resumable = new Resumable(_objectSpread({}, config.resumable_option, {
|
|
71
|
+
target: apiUploadAppByChunk,
|
|
72
|
+
headers: {
|
|
73
|
+
Authorization: "Bearer ".concat(token)
|
|
74
|
+
},
|
|
75
|
+
generateUniqueIdentifier: function generateUniqueIdentifier() {
|
|
76
|
+
return identifier;
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
79
|
+
formData = new FormData();
|
|
80
|
+
formData.append('zipFile', appBuffer);
|
|
81
|
+
formData.append('name', appName);
|
|
82
|
+
formData.append('desc', appDesc);
|
|
83
|
+
formData.append('config', appConfig); // Resumable.js isn't supported!
|
|
84
|
+
|
|
85
|
+
if (resumable.support) {
|
|
86
|
+
_context.next = 15;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
logger.statusError('Does not support upload app');
|
|
91
|
+
_context.next = 20;
|
|
92
|
+
break;
|
|
93
|
+
|
|
94
|
+
case 15:
|
|
95
|
+
i = 0;
|
|
96
|
+
resumable.on('fileProgress', function (file) {
|
|
97
|
+
i = Math.round(file.progress() * 100) % (100 + 1);
|
|
98
|
+
var chunks = new Array(i + 1).join('|');
|
|
99
|
+
logger.statusText("Deploying Your App ".concat(chalk.gray('\n' + chunks + ' ' + Math.round(file.progress() * 100) + '%')));
|
|
100
|
+
});
|
|
101
|
+
_context.next = 19;
|
|
102
|
+
return regeneratorRuntime.awrap(uploadAppByChunk(resumable, appBuffer));
|
|
103
|
+
|
|
104
|
+
case 19:
|
|
105
|
+
return _context.abrupt("return", _context.sent);
|
|
106
|
+
|
|
107
|
+
case 20:
|
|
108
|
+
case "end":
|
|
109
|
+
return _context.stop();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
};
|
|
@@ -7,7 +7,7 @@ const FormData = require('form-data');
|
|
|
7
7
|
const _ = require('lodash');
|
|
8
8
|
|
|
9
9
|
module.exports = async function (data, options, logger) {
|
|
10
|
-
const apiDomain = config.api_domain
|
|
10
|
+
const apiDomain = config.api_domain;
|
|
11
11
|
|
|
12
12
|
const uploadAppByChunk = (resumable, bufferData) => {
|
|
13
13
|
return new Promise((resolve, reject) => {
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/* eslint no-console: off */
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
9
|
+
|
|
10
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
|
|
12
|
+
var chalk = require('chalk');
|
|
13
|
+
|
|
14
|
+
var clear = require('clear');
|
|
15
|
+
|
|
16
|
+
var figlet = require('figlet');
|
|
17
|
+
|
|
18
|
+
var program = require('commander');
|
|
19
|
+
|
|
20
|
+
var logSymbols = require('log-symbols');
|
|
21
|
+
|
|
22
|
+
var fse = require('./utils/fs-extra');
|
|
23
|
+
|
|
24
|
+
var checkUpdate = require('./utils/check-update');
|
|
25
|
+
|
|
26
|
+
var spinner = require('./utils/spinner');
|
|
27
|
+
|
|
28
|
+
var log = require('./utils/log');
|
|
29
|
+
|
|
30
|
+
var getCurrentProject = require('./utils/get-current-project');
|
|
31
|
+
|
|
32
|
+
var getOptions = require('./create/utils/get-options');
|
|
33
|
+
|
|
34
|
+
var getLoginOptions = require('./login/utils/get-options');
|
|
35
|
+
|
|
36
|
+
var getDeployOptions = require('./deploy/utils/get-options');
|
|
37
|
+
|
|
38
|
+
var getMigrateOptions = require('./migrate/utils/get-options');
|
|
39
|
+
|
|
40
|
+
var loginApp = require('./login/index');
|
|
41
|
+
|
|
42
|
+
var createApp = require('./create/index');
|
|
43
|
+
|
|
44
|
+
var startApp = require('./start/index');
|
|
45
|
+
|
|
46
|
+
var buildApp = require('./build/index');
|
|
47
|
+
|
|
48
|
+
var deployApp = require('./deploy/index');
|
|
49
|
+
|
|
50
|
+
var migrateApp = require('./migrate/index');
|
|
51
|
+
|
|
52
|
+
var os = require('os'); // const generateAssets = require('./assets/index');
|
|
53
|
+
// const server = require('./ui/server');
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
var pkg = require('./package.json');
|
|
57
|
+
|
|
58
|
+
var config = require('./config');
|
|
59
|
+
|
|
60
|
+
var cwd = process.cwd();
|
|
61
|
+
var logger = {
|
|
62
|
+
statusStart: function statusStart(text) {
|
|
63
|
+
return spinner.start(text);
|
|
64
|
+
},
|
|
65
|
+
statusDone: function statusDone(text) {
|
|
66
|
+
return spinner.done(text);
|
|
67
|
+
},
|
|
68
|
+
statusText: function statusText(text) {
|
|
69
|
+
return spinner.text(text);
|
|
70
|
+
},
|
|
71
|
+
statusError: function statusError(text) {
|
|
72
|
+
return spinner.error(text);
|
|
73
|
+
},
|
|
74
|
+
text: function text(_text) {
|
|
75
|
+
return log.text(_text);
|
|
76
|
+
},
|
|
77
|
+
error: function error(text) {
|
|
78
|
+
return log.error(text);
|
|
79
|
+
},
|
|
80
|
+
showOnUI: function showOnUI() {}
|
|
81
|
+
};
|
|
82
|
+
/* =============================================
|
|
83
|
+
Header
|
|
84
|
+
============================================= */
|
|
85
|
+
|
|
86
|
+
clear();
|
|
87
|
+
|
|
88
|
+
if (!fse.existsSync(config.root_env())) {
|
|
89
|
+
fse.writeFileSync(config.root_env());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
console.log(chalk.cyan(figlet.textSync('ZMP CLI', {
|
|
93
|
+
horizontalLayout: 'full',
|
|
94
|
+
verticalLayout: 'full'
|
|
95
|
+
})), chalk.cyan("Version: ".concat(pkg.version, "\n")));
|
|
96
|
+
/* =============================================
|
|
97
|
+
Commands
|
|
98
|
+
============================================= */
|
|
99
|
+
|
|
100
|
+
program.version(pkg.version).usage('<command> [options]').command('init').option('--skipUpdate', 'Skip checking for update of zmp-cli').description('Init ZMP project').action(function _callee(options) {
|
|
101
|
+
var currentProject, optsLogin, opts;
|
|
102
|
+
return regeneratorRuntime.async(function _callee$(_context) {
|
|
103
|
+
while (1) {
|
|
104
|
+
switch (_context.prev = _context.next) {
|
|
105
|
+
case 0:
|
|
106
|
+
if (options.skipUpdate) {
|
|
107
|
+
_context.next = 3;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
_context.next = 3;
|
|
112
|
+
return regeneratorRuntime.awrap(checkUpdate());
|
|
113
|
+
|
|
114
|
+
case 3:
|
|
115
|
+
currentProject = getCurrentProject(cwd);
|
|
116
|
+
|
|
117
|
+
if (currentProject) {
|
|
118
|
+
log.text("".concat(logSymbols.error, " ZMP project already set up in current directory"));
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
_context.next = 7;
|
|
123
|
+
return regeneratorRuntime.awrap(getLoginOptions());
|
|
124
|
+
|
|
125
|
+
case 7:
|
|
126
|
+
optsLogin = _context.sent;
|
|
127
|
+
_context.next = 10;
|
|
128
|
+
return regeneratorRuntime.awrap(loginApp(_objectSpread({
|
|
129
|
+
cwd: cwd
|
|
130
|
+
}, optsLogin), logger));
|
|
131
|
+
|
|
132
|
+
case 10:
|
|
133
|
+
_context.next = 12;
|
|
134
|
+
return regeneratorRuntime.awrap(getOptions());
|
|
135
|
+
|
|
136
|
+
case 12:
|
|
137
|
+
opts = _context.sent;
|
|
138
|
+
_context.next = 15;
|
|
139
|
+
return regeneratorRuntime.awrap(createApp(_objectSpread({
|
|
140
|
+
cwd: cwd
|
|
141
|
+
}, opts), logger));
|
|
142
|
+
|
|
143
|
+
case 15:
|
|
144
|
+
process.exit(0);
|
|
145
|
+
|
|
146
|
+
case 16:
|
|
147
|
+
case "end":
|
|
148
|
+
return _context.stop();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
program.usage('<command> [options]').command('login').description('Login ZMP').action(function _callee2() {
|
|
154
|
+
var optsLogin;
|
|
155
|
+
return regeneratorRuntime.async(function _callee2$(_context2) {
|
|
156
|
+
while (1) {
|
|
157
|
+
switch (_context2.prev = _context2.next) {
|
|
158
|
+
case 0:
|
|
159
|
+
_context2.next = 2;
|
|
160
|
+
return regeneratorRuntime.awrap(getLoginOptions());
|
|
161
|
+
|
|
162
|
+
case 2:
|
|
163
|
+
optsLogin = _context2.sent;
|
|
164
|
+
_context2.next = 5;
|
|
165
|
+
return regeneratorRuntime.awrap(loginApp(_objectSpread({
|
|
166
|
+
cwd: cwd
|
|
167
|
+
}, optsLogin), logger));
|
|
168
|
+
|
|
169
|
+
case 5:
|
|
170
|
+
process.exit(0);
|
|
171
|
+
|
|
172
|
+
case 6:
|
|
173
|
+
case "end":
|
|
174
|
+
return _context2.stop();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
program.usage('<command> [options]').command('start').option('-iosH, --ios-host-name <n>', 'Specify server hostname. By default it is os.hostname').option('-P, --port <n>', 'Specify server port. By default it is 3000', parseInt).option('-Z, --zalo-app', 'Preview on Zalo').option('-ios, --ios', 'Run on ios').option('-nF, --no-frame', 'Run without Zalo frame').option('-D, --dev', 'Development environment').description('Start a ZMP project').action(function _callee3(options) {
|
|
180
|
+
var currentProject;
|
|
181
|
+
return regeneratorRuntime.async(function _callee3$(_context3) {
|
|
182
|
+
while (1) {
|
|
183
|
+
switch (_context3.prev = _context3.next) {
|
|
184
|
+
case 0:
|
|
185
|
+
currentProject = getCurrentProject(cwd);
|
|
186
|
+
|
|
187
|
+
if (!currentProject) {
|
|
188
|
+
log.text("".concat(logSymbols.error, " This is not ZMP project"));
|
|
189
|
+
process.exit(1);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (options && options.showMobileUi) {
|
|
193
|
+
try {
|
|
194
|
+
console.log(require.resolve('nw'));
|
|
195
|
+
} catch (e) {
|
|
196
|
+
console.error('NW.js module is not found. Please run "npm install -g nw@sdk"');
|
|
197
|
+
process.exit(e.code);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
_context3.next = 5;
|
|
202
|
+
return regeneratorRuntime.awrap(startApp({
|
|
203
|
+
cwd: cwd,
|
|
204
|
+
port: options && options.port || 3000,
|
|
205
|
+
iosHostName: options && options.iosHostName || os.hostname(),
|
|
206
|
+
showMobileUI: options && options.showMobileUi || false,
|
|
207
|
+
previewOnZalo: options && options.zaloApp || false,
|
|
208
|
+
ios: options && options.ios || false,
|
|
209
|
+
frame: options && (typeof options.frame === 'undefined' || options.frame === null) ? true : options.frame
|
|
210
|
+
}, logger));
|
|
211
|
+
|
|
212
|
+
case 5:
|
|
213
|
+
process.exit(0);
|
|
214
|
+
|
|
215
|
+
case 6:
|
|
216
|
+
case "end":
|
|
217
|
+
return _context3.stop();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
program.usage('<command> [options]').command('build').description('Build a ZMP project').action(function _callee4() {
|
|
223
|
+
var currentProject;
|
|
224
|
+
return regeneratorRuntime.async(function _callee4$(_context4) {
|
|
225
|
+
while (1) {
|
|
226
|
+
switch (_context4.prev = _context4.next) {
|
|
227
|
+
case 0:
|
|
228
|
+
currentProject = getCurrentProject(cwd);
|
|
229
|
+
|
|
230
|
+
if (!currentProject) {
|
|
231
|
+
log.text("".concat(logSymbols.error, " This is not ZMP project"));
|
|
232
|
+
process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
_context4.next = 4;
|
|
236
|
+
return regeneratorRuntime.awrap(buildApp({
|
|
237
|
+
cwd: cwd
|
|
238
|
+
}, logger));
|
|
239
|
+
|
|
240
|
+
case 4:
|
|
241
|
+
process.exit(0);
|
|
242
|
+
|
|
243
|
+
case 5:
|
|
244
|
+
case "end":
|
|
245
|
+
return _context4.stop();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
program.usage('<command> [options]').command('deploy').option('-D, --dev', 'Deploy in Development server').option('-P, --port <n>', 'Specify UI server port. By default it is 3001', parseInt).description('Deploy a ZMP project').action(function _callee5(options) {
|
|
251
|
+
var currentProject, opts;
|
|
252
|
+
return regeneratorRuntime.async(function _callee5$(_context5) {
|
|
253
|
+
while (1) {
|
|
254
|
+
switch (_context5.prev = _context5.next) {
|
|
255
|
+
case 0:
|
|
256
|
+
currentProject = getCurrentProject(cwd);
|
|
257
|
+
_context5.next = 3;
|
|
258
|
+
return regeneratorRuntime.awrap(getDeployOptions(currentProject));
|
|
259
|
+
|
|
260
|
+
case 3:
|
|
261
|
+
opts = _context5.sent;
|
|
262
|
+
if (opts.quit) process.exit(1);
|
|
263
|
+
_context5.next = 7;
|
|
264
|
+
return regeneratorRuntime.awrap(deployApp(_objectSpread({
|
|
265
|
+
cwd: cwd,
|
|
266
|
+
dev: options && options.dev
|
|
267
|
+
}, opts), logger));
|
|
268
|
+
|
|
269
|
+
case 7:
|
|
270
|
+
process.exit(0);
|
|
271
|
+
|
|
272
|
+
case 8:
|
|
273
|
+
case "end":
|
|
274
|
+
return _context5.stop();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
program.usage('<command> [options]').command('migrate').action(function _callee6() {
|
|
280
|
+
var currentProject, opts;
|
|
281
|
+
return regeneratorRuntime.async(function _callee6$(_context6) {
|
|
282
|
+
while (1) {
|
|
283
|
+
switch (_context6.prev = _context6.next) {
|
|
284
|
+
case 0:
|
|
285
|
+
currentProject = getCurrentProject(cwd);
|
|
286
|
+
|
|
287
|
+
if (!currentProject) {
|
|
288
|
+
logger.text("".concat(logSymbols.error, " This is not ZMP project"));
|
|
289
|
+
process.exit(1);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
_context6.next = 4;
|
|
293
|
+
return regeneratorRuntime.awrap(getMigrateOptions());
|
|
294
|
+
|
|
295
|
+
case 4:
|
|
296
|
+
opts = _context6.sent;
|
|
297
|
+
_context6.next = 7;
|
|
298
|
+
return regeneratorRuntime.awrap(migrateApp(_objectSpread({
|
|
299
|
+
cwd: cwd
|
|
300
|
+
}, opts, {}, currentProject), logger));
|
|
301
|
+
|
|
302
|
+
case 7:
|
|
303
|
+
process.exit(0);
|
|
304
|
+
|
|
305
|
+
case 8:
|
|
306
|
+
case "end":
|
|
307
|
+
return _context6.stop();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}); // program
|
|
312
|
+
// .command('assets')
|
|
313
|
+
// .alias('generate-assets')
|
|
314
|
+
// .option('--skipUpdate', 'Skip checking for update of zmp-cli')
|
|
315
|
+
// .option('--ui', 'Launch assets generation UI')
|
|
316
|
+
// .option(
|
|
317
|
+
// '-P, --port <n>',
|
|
318
|
+
// 'Specify UI server port. By default it is 3001',
|
|
319
|
+
// parseInt
|
|
320
|
+
// )
|
|
321
|
+
// .description('Generate ZMP app icons and splash screens')
|
|
322
|
+
// .action(async (options) => {
|
|
323
|
+
// // Check update
|
|
324
|
+
// if (options.skipUpdate === undefined) {
|
|
325
|
+
// await checkUpdate();
|
|
326
|
+
// }
|
|
327
|
+
// const currentProject = getCurrentProject(cwd);
|
|
328
|
+
// if (!currentProject) {
|
|
329
|
+
// log.text(
|
|
330
|
+
// `${logSymbols.error} ZMP project not found in current directory`
|
|
331
|
+
// );
|
|
332
|
+
// process.exit(1);
|
|
333
|
+
// }
|
|
334
|
+
// if (options.ui) {
|
|
335
|
+
// spinner.start('Launching ZMP UI server');
|
|
336
|
+
// server('/assets/', options.port);
|
|
337
|
+
// spinner.end('Launching ZMP UI server');
|
|
338
|
+
// } else {
|
|
339
|
+
// await generateAssets({}, currentProject, logger);
|
|
340
|
+
// process.exit(0);
|
|
341
|
+
// }
|
|
342
|
+
// });
|
|
343
|
+
|
|
344
|
+
program.on('command:*', function (cmd) {
|
|
345
|
+
program.outputHelp();
|
|
346
|
+
log.text("\n Unknown command ".concat(cmd));
|
|
347
|
+
});
|
|
348
|
+
program.parse(process.argv);
|
|
349
|
+
|
|
350
|
+
if (!program.args.length) {
|
|
351
|
+
program.outputHelp();
|
|
352
|
+
}
|
package/index.js
CHANGED
|
@@ -26,8 +26,6 @@ const os = require('os');
|
|
|
26
26
|
const pkg = require('./package.json');
|
|
27
27
|
const config = require('./config');
|
|
28
28
|
|
|
29
|
-
require('dotenv').config({ path: config.root_env() });
|
|
30
|
-
|
|
31
29
|
const cwd = process.cwd();
|
|
32
30
|
|
|
33
31
|
const logger = {
|
|
@@ -117,8 +115,9 @@ program
|
|
|
117
115
|
'Specify server port. By default it is 3000',
|
|
118
116
|
parseInt
|
|
119
117
|
)
|
|
120
|
-
.option('-Z, --zalo-app', 'Preview on
|
|
118
|
+
.option('-Z, --zalo-app', 'Preview on Zalo')
|
|
121
119
|
.option('-ios, --ios', 'Run on ios')
|
|
120
|
+
.option('-nF, --no-frame', 'Run without Zalo frame')
|
|
122
121
|
.option('-D, --dev', 'Development environment')
|
|
123
122
|
.description('Start a ZMP project')
|
|
124
123
|
.action(async (options) => {
|
|
@@ -147,6 +146,11 @@ program
|
|
|
147
146
|
showMobileUI: (options && options.showMobileUi) || false,
|
|
148
147
|
previewOnZalo: (options && options.zaloApp) || false,
|
|
149
148
|
ios: (options && options.ios) || false,
|
|
149
|
+
frame:
|
|
150
|
+
options &&
|
|
151
|
+
(typeof options.frame === 'undefined' || options.frame === null)
|
|
152
|
+
? true
|
|
153
|
+
: options.frame,
|
|
150
154
|
},
|
|
151
155
|
logger
|
|
152
156
|
);
|