@appthen/cli 1.1.25 → 1.1.27

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/bin/main.js CHANGED
@@ -215,6 +215,7 @@ program
215
215
  .option('-c, --cwd <cwd>', 'specify the working directory', '.')
216
216
  .option('-q, --quiet', 'be quiet, do not output anything unless get error', false)
217
217
  .option('-vb, --verbose', 'be verbose, output more information', false)
218
+ .option('--nocheck', 'add @ts-nocheck to cloud function files', false)
218
219
  .action(function doSync(command) {
219
220
  var options = command?.opts?.() || {};
220
221
  if (options.cwd) {
@@ -358,5 +359,62 @@ program
358
359
  }
359
360
  });
360
361
 
362
+ /**
363
+ * proxy命令
364
+ * 启动本地代理服务器,解决跨域和私有域接口访问问题
365
+ * 必需参数:
366
+ * --target: 目标地址
367
+ * --port: 监听端口
368
+ * 可选参数:
369
+ * --daemon: 以守护进程方式运行
370
+ * --debug: 调试模式
371
+ * stop: 停止代理服务
372
+ */
373
+ program
374
+ .command('proxy')
375
+ .description('start local proxy server to solve CORS and private network access')
376
+ .requiredOption('--target <target>', 'target server address, e.g. http://localhost:3000')
377
+ .requiredOption('--port <port>', 'local listen port, e.g. 9000')
378
+ .option('--daemon', 'run as daemon process', false)
379
+ .option('--debug', 'debug mode, process will not exit automatically', false)
380
+ .option('--stop', 'stop proxy server', false)
381
+ .on('--help', function () {
382
+ console.log('\n用法示例:');
383
+ console.log(' # 启动本地代理,将9000端口转发到目标服务');
384
+ console.log(' $ yourcli proxy --target http://192.168.1.100:8080 --port 9000');
385
+ console.log('\n # 以守护进程方式运行');
386
+ console.log(' $ yourcli proxy --target http://192.168.1.100:8080 --port 9000 --daemon');
387
+ console.log('\n # 停止代理服务');
388
+ console.log(' $ yourcli proxy --stop');
389
+ console.log('\n参数说明:');
390
+ console.log(' --target 目标服务地址(必填),如 http://localhost:3000');
391
+ console.log(' --port 本地监听端口(必填),如 9000');
392
+ console.log(' --daemon 以守护进程方式运行(可选)');
393
+ console.log(' --debug 调试模式,进程不会自动退出(可选)');
394
+ console.log(' --stop 停止代理服务(可选)');
395
+ })
396
+ .action(async function doProxy(command) {
397
+ const options = command.opts();
398
+ if (options.stop) {
399
+ // 停止代理
400
+ const stopped = require('../dist/index.js').stopProxy();
401
+ if (stopped) {
402
+ console.log('代理服务已停止');
403
+ process.exit(0);
404
+ } else {
405
+ console.log('没有找到运行中的代理服务');
406
+ process.exit(1);
407
+ }
408
+ return;
409
+ }
410
+ // 启动代理
411
+ await require('../dist/index.js').startProxy({
412
+ target: options.target,
413
+ port: options.port,
414
+ daemon: options.daemon,
415
+ debug: options.debug,
416
+ });
417
+ });
418
+
361
419
  // 解析命令行参数
362
420
  program.parse(process.argv);