@zuplo/cli 1.112.0 → 1.113.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/dist/cmds/dev.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d957865b-71c7-52e9-907e-8620261193ad")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cd26cd84-311b-5031-9a99-53eb489538ba")}catch(e){}}();
3
3
  import { captureEvent } from "../common/analytics/lib.js";
4
4
  import { identify } from "../common/middleware/user-identification.js";
5
5
  import setBlocking from "../common/output.js";
@@ -32,6 +32,10 @@ export default {
32
32
  type: "number",
33
33
  describe: "The port to run the route designer on",
34
34
  default: 9100,
35
+ })
36
+ .option("debug-port", {
37
+ type: "number",
38
+ describe: "The port to run the Chrome inspector on",
35
39
  })
36
40
  .middleware([setBlocking, identify])
37
41
  .check(async (argv) => {
@@ -44,4 +48,4 @@ export default {
44
48
  },
45
49
  };
46
50
  //# sourceMappingURL=dev.js.map
47
- //# debugId=d957865b-71c7-52e9-907e-8620261193ad
51
+ //# debugId=cd26cd84-311b-5031-9a99-53eb489538ba
@@ -0,0 +1,19 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="91c950c6-7387-5ef2-9dbb-0446c03af67f")}catch(e){}}();
3
+ import net from "net";
4
+ export function isPortAvailable(host, port) {
5
+ return new Promise((resolve, reject) => {
6
+ const socket = new net.Socket();
7
+ socket.connect(port, host);
8
+ socket.on("connect", () => {
9
+ socket.destroy();
10
+ resolve(false);
11
+ });
12
+ socket.on("error", (err) => {
13
+ socket.destroy();
14
+ resolve(true);
15
+ });
16
+ });
17
+ }
18
+ //# sourceMappingURL=ports.js.map
19
+ //# debugId=91c950c6-7387-5ef2-9dbb-0446c03af67f
@@ -1,10 +1,11 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="dde8dcee-5646-5949-b230-50ff08e9b24e")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bf35816c-e91e-5014-89aa-1472b78406e4")}catch(e){}}();
3
3
  import { cpSync, existsSync } from "node:fs";
4
4
  import { join, relative, resolve } from "node:path";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import { logger } from "../common/logger.js";
7
- import { printDiagnosticsToConsole } from "../common/output.js";
7
+ import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, } from "../common/output.js";
8
+ import { isPortAvailable } from "../common/utils/ports.js";
8
9
  import { ApiServer } from "../editor/server/server.js";
9
10
  export async function dev(argv) {
10
11
  const sourceDirectory = resolve(join(relative(process.cwd(), argv.dir)));
@@ -30,10 +31,27 @@ export async function dev(argv) {
30
31
  };
31
32
  process.env.__ZUPLO_CONFIG = btoa(JSON.stringify(config));
32
33
  const core = await import("@zuplo/core");
33
- const port = argv.port;
34
+ const zupPort = argv.port;
35
+ const zupEditorPort = argv.editorPort;
36
+ const zupDebugPort = argv.debugPort;
37
+ const isZupPortAvailable = await isPortAvailable("localhost", zupPort);
38
+ if (!isZupPortAvailable) {
39
+ printCriticalFailureToConsoleAndExit(`Port ${zupPort} is already in use. Please specify a different port using --port.`);
40
+ }
41
+ const isZupEditorPortAvailable = await isPortAvailable("localhost", zupEditorPort);
42
+ if (!isZupEditorPortAvailable) {
43
+ printCriticalFailureToConsoleAndExit(`Port ${zupEditorPort} is already in use. Please specify a different port using --editor-port.`);
44
+ }
45
+ if (zupDebugPort) {
46
+ const isZupDebugPortAvailable = await isPortAvailable("localhost", zupDebugPort);
47
+ if (!isZupDebugPortAvailable) {
48
+ printCriticalFailureToConsoleAndExit(`Port ${zupDebugPort} is already in use. Please specify a different port using --debug-port.`);
49
+ }
50
+ }
34
51
  await core.default.startDevServer({
35
52
  sourceDirectory,
36
- port,
53
+ port: zupPort,
54
+ debugPort: argv.debugPort ?? undefined,
37
55
  devServerPort: undefined,
38
56
  generateSourceMaps: true,
39
57
  flags: {
@@ -54,7 +72,7 @@ export async function dev(argv) {
54
72
  printDiagnosticsToConsole("Started local development setup");
55
73
  printDiagnosticsToConsole("Ctrl+C to exit");
56
74
  printDiagnosticsToConsole("");
57
- printDiagnosticsToConsole(`🚀 Zuplo Gateway: http://localhost:${port}`);
75
+ printDiagnosticsToConsole(`🚀 Zuplo Gateway: http://localhost:${zupPort}`);
58
76
  if (argv["start-editor"]) {
59
77
  printDiagnosticsToConsole(`📘 Route Designer: http://localhost:${argv.editorPort}`);
60
78
  }
@@ -77,4 +95,4 @@ export async function dev(argv) {
77
95
  });
78
96
  }
79
97
  //# sourceMappingURL=handler.js.map
80
- //# debugId=dde8dcee-5646-5949-b230-50ff08e9b24e
98
+ //# debugId=bf35816c-e91e-5014-89aa-1472b78406e4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "1.112.0",
3
+ "version": "1.113.0",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/zuplo/cli",
6
6
  "description": "The command-line interface for Zuplo",