zmp-cli 3.11.1 → 3.11.3-rc.0

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/build/index.js CHANGED
@@ -80,6 +80,7 @@ module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
80
80
  scopeBehaviour: 'local',
81
81
  },
82
82
  },
83
+ mode: options.mode,
83
84
  build: {
84
85
  target: 'es2015',
85
86
  outDir: path.join(cwd, 'www'),
package/index.js CHANGED
@@ -119,6 +119,7 @@ program
119
119
  .option('-ios, --ios', 'Run on ios')
120
120
  .option('-nF, --no-frame', 'Run without Zalo frame')
121
121
  .option('-D, --dev', 'Development environment')
122
+ .option('-M, --mode <m>', 'Env mode')
122
123
  .description('Start a ZMP project')
123
124
  .action(async (options) => {
124
125
  const currentProject = getCurrentProject(cwd);
@@ -152,6 +153,7 @@ program
152
153
  showMobileUI: (options && options.showMobileUi) || false,
153
154
  previewOnZalo: (options && options.zaloApp) || false,
154
155
  ios: (options && options.ios) || false,
156
+ mode: options && options.mode,
155
157
  frame:
156
158
  options &&
157
159
  (typeof options.frame === 'undefined' || options.frame === null)
@@ -188,6 +190,7 @@ program
188
190
  .usage('<command> [options]')
189
191
  .command('deploy')
190
192
  .option('-D, --dev', 'Deploy in Development server')
193
+ .option('-M, --mode <m>', 'Env mode')
191
194
  .option(
192
195
  '-P, --port <n>',
193
196
  'Specify UI server port. By default it is 3001',
@@ -202,6 +205,7 @@ program
202
205
  {
203
206
  cwd,
204
207
  dev: options && options.dev,
208
+ mode: options && options.mode,
205
209
  ...opts,
206
210
  },
207
211
  logger
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmp-cli",
3
- "version": "3.11.1",
3
+ "version": "3.11.3-rc.0",
4
4
  "description": "ZMP command line utility (CLI)",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -186,7 +186,7 @@ module.exports = function _callee() {
186
186
  app = _context.sent;
187
187
 
188
188
  if (previewOnZalo) {
189
- _context.next = 45;
189
+ _context.next = 47;
190
190
  break;
191
191
  }
192
192
 
@@ -229,6 +229,10 @@ module.exports = function _callee() {
229
229
  server.printUrls();
230
230
 
231
231
  case 45:
232
+ _context.next = 48;
233
+ break;
234
+
235
+ case 47:
232
236
  try {
233
237
  chii.start({
234
238
  port: remoteDebugPort
@@ -245,8 +249,9 @@ module.exports = function _callee() {
245
249
  logger.text("".concat(logSymbols.info, " ").concat(chalk.red("Can not start remote debug server")));
246
250
  }
247
251
 
252
+ case 48:
248
253
  spinner.stop();
249
- _context.next = 49;
254
+ _context.next = 51;
250
255
  return regeneratorRuntime.awrap(new Promise(function () {
251
256
  var previewOnZaloURL = "https://zalo.me/app/link/zapps/".concat(appId, "/?env=TESTING_LOCAL&clientIp=").concat(isIOS ? 'http' : 'https', "://").concat(host, ":").concat(app.config.server.port);
252
257
 
@@ -286,11 +291,11 @@ module.exports = function _callee() {
286
291
  }
287
292
  }));
288
293
 
289
- case 49:
294
+ case 51:
290
295
  return _context.abrupt("return", _context.sent);
291
296
 
292
- case 52:
293
- _context.prev = 52;
297
+ case 54:
298
+ _context.prev = 54;
294
299
  _context.t0 = _context["catch"](15);
295
300
  logger.statusError('Error starting project'); // if (err) logger.error(err.stderr || err);
296
301
 
@@ -298,10 +303,10 @@ module.exports = function _callee() {
298
303
  errorExit(_context.t0);
299
304
  return _context.abrupt("return");
300
305
 
301
- case 58:
306
+ case 60:
302
307
  case "end":
303
308
  return _context.stop();
304
309
  }
305
310
  }
306
- }, null, null, [[15, 52]]);
311
+ }, null, null, [[15, 54]]);
307
312
  };
package/start/index.js CHANGED
@@ -40,6 +40,7 @@ module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
40
40
  const host = isIOS ? iosHostName : 'localhost';
41
41
  const port = options.port;
42
42
  const remoteDebugPort = port - 2;
43
+ const mode = options.mode || (previewOnZalo ? 'production' : 'development');
43
44
  try {
44
45
  if (previewOnZalo) {
45
46
  const hrConfigPath = path.join(cwd, 'hr.config.json');
@@ -104,11 +105,9 @@ module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
104
105
  const server = await createServer({
105
106
  configFile: path.join(cwd, viteConfig),
106
107
  root: cwd,
107
- mode: previewOnZalo ? 'production' : 'development',
108
+ mode,
108
109
  define: {
109
- 'process.env.NODE_ENV': JSON.stringify(
110
- previewOnZalo ? 'production' : 'development'
111
- ),
110
+ 'process.env.NODE_ENV': JSON.stringify(mode),
112
111
  'process.env.previewOnZalo': previewOnZalo,
113
112
  },
114
113
  server: {
@@ -142,33 +141,33 @@ module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
142
141
  info(chalk.green(`Zalo Mini App dev server is running at:\n`));
143
142
  server.printUrls();
144
143
  }
145
- }
146
-
147
- try {
148
- chii.start({
149
- port: remoteDebugPort,
150
- });
151
- logger.text(
152
- chalk.green(
153
- `${logSymbols.info} ${chalk.bold(
154
- `Remote debugging tool is running at: http://localhost:${remoteDebugPort}`
155
- )}`
156
- )
157
- );
158
- if (!isIOS) {
159
- const processAdbReverseRemoteDEbug = require('child_process').spawn(
160
- `adb`,
161
- ['reverse', `tcp:${remoteDebugPort}`, `tcp:${remoteDebugPort}`]
144
+ } else {
145
+ try {
146
+ chii.start({
147
+ port: remoteDebugPort,
148
+ });
149
+ logger.text(
150
+ chalk.green(
151
+ `${logSymbols.info} ${chalk.bold(
152
+ `Remote debugging tool is running at: http://localhost:${remoteDebugPort}`
153
+ )}`
154
+ )
162
155
  );
156
+ if (!isIOS) {
157
+ const processAdbReverseRemoteDEbug = require('child_process').spawn(
158
+ `adb`,
159
+ ['reverse', `tcp:${remoteDebugPort}`, `tcp:${remoteDebugPort}`]
160
+ );
163
161
 
164
- processAdbReverseRemoteDEbug.stderr.on('data', function (data) {
165
- logger.error(data.toString());
166
- });
162
+ processAdbReverseRemoteDEbug.stderr.on('data', function (data) {
163
+ logger.error(data.toString());
164
+ });
165
+ }
166
+ } catch (error) {
167
+ logger.text(
168
+ `${logSymbols.info} ${chalk.red(`Can not start remote debug server`)}`
169
+ );
167
170
  }
168
- } catch (error) {
169
- logger.text(
170
- `${logSymbols.info} ${chalk.red(`Can not start remote debug server`)}`
171
- );
172
171
  }
173
172
 
174
173
  spinner.stop();