@cloudbase/cli 2.7.7-alpha.0 → 2.7.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.
@@ -55,6 +55,7 @@ const toolbox_1 = require("@cloudbase/toolbox");
55
55
  const camelcase_keys_1 = __importDefault(require("camelcase-keys"));
56
56
  const chalk_1 = __importDefault(require("chalk"));
57
57
  const cli_table3_1 = __importDefault(require("cli-table3"));
58
+ const execa_1 = __importDefault(require("execa"));
58
59
  const fs_extra_1 = __importDefault(require("fs-extra"));
59
60
  const inquirer_1 = __importDefault(require("inquirer"));
60
61
  const nodemon_1 = __importDefault(require("nodemon"));
@@ -816,6 +817,7 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
816
817
  logger.info('Initializing server in watch mode. Changes in source files will trigger a restart.');
817
818
  if (!nodemonInstance._firstStartDone) {
818
819
  nodemonInstance._firstStartDone = true;
820
+ this.checkAndRunTsc();
819
821
  this.openDebugApp(type, port, envId, agentId, openDebugPanel !== 'false');
820
822
  }
821
823
  }))
@@ -840,12 +842,33 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
840
842
  }
841
843
  else {
842
844
  (0, functions_framework_1.runCLI)();
843
- if (!process.env.FROM_NODEMON && openDebugPanel) {
844
- this.openDebugApp(type, port, envId, agentId, openDebugPanel !== 'false');
845
+ if (!process.env.FROM_NODEMON) {
846
+ this.checkAndRunTsc();
847
+ if (openDebugPanel) {
848
+ this.openDebugApp(type, port, envId, agentId, openDebugPanel !== 'false');
849
+ }
845
850
  }
846
851
  }
847
852
  });
848
853
  }
854
+ checkAndRunTsc() {
855
+ var _a;
856
+ return __awaiter(this, void 0, void 0, function* () {
857
+ const tsConfigPath = path_1.default.join(process.cwd(), 'tsconfig.json');
858
+ if (yield fs_extra_1.default.exists(tsConfigPath)) {
859
+ const child = (0, execa_1.default)('npx', ['tsc', '-w'], {
860
+ cwd: process.cwd(),
861
+ stdio: 'pipe'
862
+ });
863
+ (_a = child.stderr) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
864
+ console.log(data.toString());
865
+ });
866
+ child.on('exit', (code) => {
867
+ console.log(`子进程退出,退出码 ${code}`);
868
+ });
869
+ }
870
+ });
871
+ }
849
872
  openDebugApp(type, port, envId, agentId, isOpen = true) {
850
873
  return __awaiter(this, void 0, void 0, function* () {
851
874
  let url = `http://127.0.0.1:${port}/cloudrun-run-ui/index.html?type=${type}&envId=${envId}&port=${port}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cli",
3
- "version": "2.7.7-alpha.0",
3
+ "version": "2.7.7",
4
4
  "description": "cli tool for cloudbase",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -151,6 +151,7 @@ export declare class CloudRunRunCommand extends Command {
151
151
  desc: string;
152
152
  };
153
153
  execute(envId: string, logger: Logger, ctx: any, options: any): Promise<void>;
154
+ private checkAndRunTsc;
154
155
  private openDebugApp;
155
156
  private waitForPort;
156
157
  }