@giteeteam/apps-cli 0.2.6 → 0.2.7

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.
Files changed (2) hide show
  1. package/dist/index.js +23 -16
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
31
31
  var child_process__default = /*#__PURE__*/_interopDefaultLegacy(child_process);
32
32
  var chokidar__default = /*#__PURE__*/_interopDefaultLegacy(chokidar);
33
33
 
34
- var version = "0.2.6";
34
+ var version = "0.2.7";
35
35
 
36
36
  const packageApp = async ({ outputDir, manifest, copyFiles }) => {
37
37
  const { resources } = manifest;
@@ -436,10 +436,11 @@ const watchFiles = async (options) => {
436
436
  // 监听整个文件夹,有一个文件改动,则全部重新build
437
437
  // TODO 解析出文件之间的依赖关系,提升构建速度
438
438
  const watcher = chokidar__default["default"].watch(inputDir);
439
- watcher.on('change', () => {
439
+ console.log(`watch: ${inputDir}`);
440
+ watcher.on('change', path => {
440
441
  clearTimeout(timer);
441
442
  timer = setTimeout(() => {
442
- console.log(`build ${inputDir}`);
443
+ console.log(`${path} has change`);
443
444
  build(functionFiles, inputDir, outputDir);
444
445
  }, 1000);
445
446
  });
@@ -448,7 +449,7 @@ const watchFiles = async (options) => {
448
449
  var _a, _b;
449
450
  const image = {
450
451
  repository: 'registry.baidubce.com/proxima/proxima-apps-runtime-server',
451
- tag: (_a = process.env.IMAGE_TAG) !== null && _a !== void 0 ? _a : '2.7.0-alpha-45',
452
+ tag: (_a = process.env.IMAGE_TAG) !== null && _a !== void 0 ? _a : 'latest',
452
453
  };
453
454
  const containerPort = Number((_b = process.env.CONTAINER_PORT) !== null && _b !== void 0 ? _b : 8455);
454
455
  const containerName = 'cli-dev-apps-runtime-server';
@@ -457,7 +458,7 @@ const tempAppDir = `${tempApp}/server-side`;
457
458
  const containerEnv = {
458
459
  PORT: containerPort,
459
460
  APPS_DIR: '/usr/src/app/apps',
460
- LRU_TTL: 0,
461
+ LRU_TTL: 1,
461
462
  DEBUG: 'runtime*',
462
463
  PARSE_PUBLIC_SERVER_URL: process.env.PARSE_PUBLIC_SERVER_URL,
463
464
  PARSE_SERVER_MASTER_KEY: process.env.PARSE_SERVER_MASTER_KEY,
@@ -473,18 +474,20 @@ const copyManifest = async (appDir) => {
473
474
  await fse__default["default"].copy(manifestFile, targetFile);
474
475
  };
475
476
  var run = async (options) => {
476
- const { inputDir, outputDir } = options;
477
+ const { inputDir, outputDir, server } = options;
477
478
  await fse__default["default"].emptyDir(outputDir);
478
479
  const imageName = `${image.repository}:${image.tag}`;
479
480
  const appDir = path__default["default"].join(outputDir, tempAppDir);
480
481
  const dockerService = new DockerService(imageName);
481
- await dockerService.downloadImage();
482
- await dockerService.runContainer({
483
- port: containerPort,
484
- env: containerEnv,
485
- volume: [`${outputDir}:/usr/src/app/apps`],
486
- name: containerName,
487
- });
482
+ if (server) {
483
+ await dockerService.downloadImage();
484
+ await dockerService.runContainer({
485
+ port: containerPort,
486
+ env: containerEnv,
487
+ volume: [`${outputDir}:/usr/src/app/apps`],
488
+ name: containerName,
489
+ });
490
+ }
488
491
  process.on('SIGINT', async () => {
489
492
  await dockerService.removeContainer(containerName);
490
493
  await fse__default["default"].remove(outputDir);
@@ -492,15 +495,18 @@ var run = async (options) => {
492
495
  });
493
496
  await copyManifest(appDir);
494
497
  await watchFiles({ inputDir, outputDir: appDir });
495
- console.log('You can use this url for test:');
496
- console.log(`POST http://localhost:${containerPort}/v1/apps${tempApp}/functions/:key`);
498
+ if (server) {
499
+ console.log('You can use this url for test:');
500
+ console.log(`POST http://localhost:${containerPort}/v1/apps${tempApp}/functions/:key`);
501
+ }
497
502
  };
498
503
 
499
504
  var dev = async (options) => {
500
- const { input = 'src', output = 'cache' } = options;
505
+ const { input = 'src', output = 'cache', server = true } = options;
501
506
  await run({
502
507
  outputDir: path__default["default"].resolve(output),
503
508
  inputDir: path__default["default"].resolve(input),
509
+ server,
504
510
  });
505
511
  };
506
512
 
@@ -519,5 +525,6 @@ program
519
525
  .command('dev')
520
526
  .option('-i --input [dir]', 'input dir')
521
527
  .option('-o --output [dir]', 'output dir,default cache')
528
+ .option('--no-server', 'no server')
522
529
  .action(dev);
523
530
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giteeteam/apps-cli",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Giteeteam Apps cli",
5
5
  "keywords": [
6
6
  "typescript",
@@ -59,5 +59,5 @@
59
59
  "@types/inquirer": "^8.2.1",
60
60
  "@types/uuid": "^8.3.4"
61
61
  },
62
- "gitHead": "f32eb236ef8765f6788e9906416745043cf76158"
62
+ "gitHead": "3c1344d0154b4671d9477d491c514f02385a1f0d"
63
63
  }