@zuplo/cli 6.64.39 → 6.64.40
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/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/cmds/dev.d.ts.map +1 -1
- package/dist/cmds/dev.js +15 -1
- package/dist/cmds/dev.js.map +1 -1
- package/dist/cmds/docs.d.ts +9 -0
- package/dist/cmds/docs.d.ts.map +1 -0
- package/dist/cmds/docs.js +58 -0
- package/dist/cmds/docs.js.map +1 -0
- package/dist/common/utils/prefixed-output.d.ts +11 -0
- package/dist/common/utils/prefixed-output.d.ts.map +1 -0
- package/dist/common/utils/prefixed-output.js +28 -0
- package/dist/common/utils/prefixed-output.js.map +1 -0
- package/dist/common/worker-output.d.ts +5 -10
- package/dist/common/worker-output.d.ts.map +1 -1
- package/dist/common/worker-output.js +125 -116
- package/dist/common/worker-output.js.map +1 -1
- package/dist/compile/handler.d.ts.map +1 -1
- package/dist/compile/handler.js +2 -1
- package/dist/compile/handler.js.map +1 -1
- package/dist/dev/handler.d.ts +2 -0
- package/dist/dev/handler.d.ts.map +1 -1
- package/dist/dev/handler.js +66 -2
- package/dist/dev/handler.js.map +1 -1
- package/dist/docs/handler.d.ts +7 -0
- package/dist/docs/handler.d.ts.map +1 -0
- package/dist/docs/handler.js +67 -0
- package/dist/docs/handler.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -13,6 +13,7 @@ import compile from "./cmds/compile.js";
|
|
|
13
13
|
import deleteZup from "./cmds/delete.js";
|
|
14
14
|
import deploy from "./cmds/deploy.js";
|
|
15
15
|
import dev from "./cmds/dev.js";
|
|
16
|
+
import docs from "./cmds/docs.js";
|
|
16
17
|
import editor from "./cmds/editor.js";
|
|
17
18
|
import link from "./cmds/link.js";
|
|
18
19
|
import list from "./cmds/list.js";
|
|
@@ -81,6 +82,7 @@ if (gte(process.versions.node, MIN_NODE_VERSION)) {
|
|
|
81
82
|
.command(deleteZup)
|
|
82
83
|
.command(deploy)
|
|
83
84
|
.command(dev)
|
|
85
|
+
.command(docs)
|
|
84
86
|
.command(editor)
|
|
85
87
|
.command(list)
|
|
86
88
|
.command(link)
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAG7B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAClC,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAClC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,gBAAgB,MAAM,mCAAmC,CAAC;AACjE,OAAO,GAAG,MAAM,0BAA0B,CAAC;AAC3C,OAAO,OAAO,MAAM,yBAAyB,CAAC;AAC9C,OAAO,OAAO,MAAM,yBAAyB,CAAC;AA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CAAoC,CACxC,4CAA4C,gBAAgB,oBAAoB,OAAO,CAAC,QAAQ,CAAC,IAAI;;oFAErB,CACjF,CAAC;AACJ,CAAC","sourcesContent":["import * as dotenv from \"dotenv\";\n\ndotenv.config();\n\nimport { readFileSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { confirm } from \"@inquirer/prompts\";\nimport * as Sentry from \"@sentry/node\";\nimport { gte } from \"semver\";\n// Undici must be imported first to set the global dispatcher\n// If fetch is used before undici, the process will crash\nimport undici from \"undici\";\nimport { hideBin } from \"yargs/helpers\";\nimport yargs from \"yargs/yargs\";\nimport build from \"./cmds/build.js\";\nimport compile from \"./cmds/compile.js\";\nimport deleteZup from \"./cmds/delete.js\";\nimport deploy from \"./cmds/deploy.js\";\nimport dev from \"./cmds/dev.js\";\nimport editor from \"./cmds/editor.js\";\nimport link from \"./cmds/link.js\";\nimport list from \"./cmds/list.js\";\nimport login from \"./cmds/login.js\";\nimport mtlsCertificates from \"./cmds/mtls-certificates/index.js\";\nimport oas from \"./cmds/open-api/index.js\";\nimport project from \"./cmds/project/index.js\";\nimport proxies from \"./cmds/proxies/index.js\";\nimport source from \"./cmds/source/index.js\";\nimport test from \"./cmds/test.js\";\nimport tunnel from \"./cmds/tunnel/index.js\";\nimport variable from \"./cmds/variable/index.js\";\nimport { shutdownAnalytics } from \"./common/analytics/lib.js\";\nimport { MAX_WAIT_PENDING_TIME_MS, SENTRY_DSN } from \"./common/constants.js\";\nimport { logger } from \"./common/logger.js\";\nimport { logLevel } from \"./common/middleware/logging.js\";\nimport { warnIfOutdatedVersion, warnNodeVersion } from \"./common/outdated.js\";\nimport { printCriticalFailureToConsoleAndExit } from \"./common/output.js\";\n\n// This allows us to stop the CLI from executing so we can connect the profiler\n\n// biome-ignore lint/style/noProcessEnv: Migrated from ESLint\nif (process.env.ZUPLO_CLI_PROFILING) {\n await confirm({ message: \"Continue executing CLI?\", default: true });\n}\n\n// Note: We cannot set this to be higher than 18.0.0 because of the way\n// our documentation works -- we tell them to use npx @zuplo/cli@latest (even in CI/CD jobs)\n// If we set this to be higher than 18.0.0, then we will break them.\n// Instead we set the value in package.json to be engine.node >= 20.0.0, so it will warn\nconst MIN_NODE_VERSION = \"18.0.0\";\nconst RECOMMENDED_NODE_VERSION = \"20.0.0\";\n\nif (gte(process.versions.node, MIN_NODE_VERSION)) {\n let cliVersion: string;\n try {\n const packageJson = JSON.parse(\n readFileSync(\n fileURLToPath(new URL(\"../package.json\", import.meta.url)),\n \"utf-8\"\n )\n );\n cliVersion = packageJson.version;\n } catch (e) {\n cliVersion = \"0.0.0\";\n logger.error(e);\n await printCriticalFailureToConsoleAndExit(\n `Unable to load @zuplo/cli. The package.json is missing or malformed.`\n );\n }\n\n await warnNodeVersion(cliVersion, RECOMMENDED_NODE_VERSION);\n\n undici.setGlobalDispatcher(\n undici.getGlobalDispatcher().compose((dispatch) => {\n return (opts, handler) => {\n opts.headers = {\n ...opts.headers,\n \"user-agent\": `ZuploCLI/${cliVersion}`,\n\n // biome-ignore lint/style/noProcessEnv: Migrated from ESLint\n ...(process.env.ZUPLO_CANARY ? { \"zp-canary\": \"true\" } : {}),\n };\n return dispatch(opts, handler);\n };\n })\n );\n\n Sentry.init({\n dsn: SENTRY_DSN,\n release: cliVersion,\n });\n\n const cli = yargs(hideBin(process.argv))\n // This means that all env vars will have to be prefixed with ZUPLO_\n .env(\"ZUPLO\")\n .option(\"prompt\", {\n type: \"boolean\",\n describe: \"Bypass confirmation prompts\",\n default: true,\n hidden: true,\n })\n .option(\"verbose\", {\n alias: \"v\",\n type: \"count\",\n describe: \"Increase verbosity level (-v, -vv, -vvv)\",\n default: 0,\n })\n .middleware(logLevel)\n .command(compile)\n .command(deleteZup) // delete is a reserved keyword in JavaScript, so we call this function deleteZup\n .command(deploy)\n .command(dev)\n .command(editor)\n .command(list)\n .command(link)\n .command(login)\n .command(test)\n .command(oas)\n .command(mtlsCertificates)\n .command(project)\n .command(source)\n .command(tunnel)\n .command(variable)\n .command(build)\n .command(proxies)\n .command({\n command: \"hello\",\n handler: async () => {\n await fetch(\"https://393b4699ced44cc2ae87e4ad86184a29.api.mockbin.io/\");\n },\n })\n .demandCommand()\n .strictCommands()\n .version(cliVersion)\n .fail(false)\n .help();\n\n try {\n await cli.argv;\n\n // Don't block\n void warnIfOutdatedVersion(cliVersion);\n\n void Sentry.close(MAX_WAIT_PENDING_TIME_MS).then(() => {\n process.exit(0);\n });\n } catch (err) {\n if (err instanceof Error) {\n Sentry.captureException(err);\n }\n await printCriticalFailureToConsoleAndExit(err.message ?? err);\n cli.showHelp();\n } finally {\n await shutdownAnalytics();\n }\n} else {\n await printCriticalFailureToConsoleAndExit(\n `The Zuplo CLI requires at least node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}. Please update your version of node.js.\n\n Consider using a Node.js version manager such as https://github.com/nvm-sh/nvm.`\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAG7B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,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AI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;QACD,MAAM,oCAAoC,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;QAC/D,GAAG,CAAC,QAAQ,EAAE,CAAC;IACjB,CAAC;YAAS,CAAC;QACT,MAAM,iBAAiB,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC;KAAM,CAAC;IACN,MAAM,oCAAoC,CACxC,4CAA4C,gBAAgB,oBAAoB,OAAO,CAAC,QAAQ,CAAC,IAAI;;oFAErB,CACjF,CAAC;AACJ,CAAC","sourcesContent":["import * as dotenv from \"dotenv\";\n\ndotenv.config();\n\nimport { readFileSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { confirm } from \"@inquirer/prompts\";\nimport * as Sentry from \"@sentry/node\";\nimport { gte } from \"semver\";\n// Undici must be imported first to set the global dispatcher\n// If fetch is used before undici, the process will crash\nimport undici from \"undici\";\nimport { hideBin } from \"yargs/helpers\";\nimport yargs from \"yargs/yargs\";\nimport build from \"./cmds/build.js\";\nimport compile from \"./cmds/compile.js\";\nimport deleteZup from \"./cmds/delete.js\";\nimport deploy from \"./cmds/deploy.js\";\nimport dev from \"./cmds/dev.js\";\nimport docs from \"./cmds/docs.js\";\nimport editor from \"./cmds/editor.js\";\nimport link from \"./cmds/link.js\";\nimport list from \"./cmds/list.js\";\nimport login from \"./cmds/login.js\";\nimport mtlsCertificates from \"./cmds/mtls-certificates/index.js\";\nimport oas from \"./cmds/open-api/index.js\";\nimport project from \"./cmds/project/index.js\";\nimport proxies from \"./cmds/proxies/index.js\";\nimport source from \"./cmds/source/index.js\";\nimport test from \"./cmds/test.js\";\nimport tunnel from \"./cmds/tunnel/index.js\";\nimport variable from \"./cmds/variable/index.js\";\nimport { shutdownAnalytics } from \"./common/analytics/lib.js\";\nimport { MAX_WAIT_PENDING_TIME_MS, SENTRY_DSN } from \"./common/constants.js\";\nimport { logger } from \"./common/logger.js\";\nimport { logLevel } from \"./common/middleware/logging.js\";\nimport { warnIfOutdatedVersion, warnNodeVersion } from \"./common/outdated.js\";\nimport { printCriticalFailureToConsoleAndExit } from \"./common/output.js\";\n\n// This allows us to stop the CLI from executing so we can connect the profiler\n\n// biome-ignore lint/style/noProcessEnv: Migrated from ESLint\nif (process.env.ZUPLO_CLI_PROFILING) {\n await confirm({ message: \"Continue executing CLI?\", default: true });\n}\n\n// Note: We cannot set this to be higher than 18.0.0 because of the way\n// our documentation works -- we tell them to use npx @zuplo/cli@latest (even in CI/CD jobs)\n// If we set this to be higher than 18.0.0, then we will break them.\n// Instead we set the value in package.json to be engine.node >= 20.0.0, so it will warn\nconst MIN_NODE_VERSION = \"18.0.0\";\nconst RECOMMENDED_NODE_VERSION = \"20.0.0\";\n\nif (gte(process.versions.node, MIN_NODE_VERSION)) {\n let cliVersion: string;\n try {\n const packageJson = JSON.parse(\n readFileSync(\n fileURLToPath(new URL(\"../package.json\", import.meta.url)),\n \"utf-8\"\n )\n );\n cliVersion = packageJson.version;\n } catch (e) {\n cliVersion = \"0.0.0\";\n logger.error(e);\n await printCriticalFailureToConsoleAndExit(\n `Unable to load @zuplo/cli. The package.json is missing or malformed.`\n );\n }\n\n await warnNodeVersion(cliVersion, RECOMMENDED_NODE_VERSION);\n\n undici.setGlobalDispatcher(\n undici.getGlobalDispatcher().compose((dispatch) => {\n return (opts, handler) => {\n opts.headers = {\n ...opts.headers,\n \"user-agent\": `ZuploCLI/${cliVersion}`,\n\n // biome-ignore lint/style/noProcessEnv: Migrated from ESLint\n ...(process.env.ZUPLO_CANARY ? { \"zp-canary\": \"true\" } : {}),\n };\n return dispatch(opts, handler);\n };\n })\n );\n\n Sentry.init({\n dsn: SENTRY_DSN,\n release: cliVersion,\n });\n\n const cli = yargs(hideBin(process.argv))\n // This means that all env vars will have to be prefixed with ZUPLO_\n .env(\"ZUPLO\")\n .option(\"prompt\", {\n type: \"boolean\",\n describe: \"Bypass confirmation prompts\",\n default: true,\n hidden: true,\n })\n .option(\"verbose\", {\n alias: \"v\",\n type: \"count\",\n describe: \"Increase verbosity level (-v, -vv, -vvv)\",\n default: 0,\n })\n .middleware(logLevel)\n .command(compile)\n .command(deleteZup) // delete is a reserved keyword in JavaScript, so we call this function deleteZup\n .command(deploy)\n .command(dev)\n .command(docs)\n .command(editor)\n .command(list)\n .command(link)\n .command(login)\n .command(test)\n .command(oas)\n .command(mtlsCertificates)\n .command(project)\n .command(source)\n .command(tunnel)\n .command(variable)\n .command(build)\n .command(proxies)\n .command({\n command: \"hello\",\n handler: async () => {\n await fetch(\"https://393b4699ced44cc2ae87e4ad86184a29.api.mockbin.io/\");\n },\n })\n .demandCommand()\n .strictCommands()\n .version(cliVersion)\n .fail(false)\n .help();\n\n try {\n await cli.argv;\n\n // Don't block\n void warnIfOutdatedVersion(cliVersion);\n\n void Sentry.close(MAX_WAIT_PENDING_TIME_MS).then(() => {\n process.exit(0);\n });\n } catch (err) {\n if (err instanceof Error) {\n Sentry.captureException(err);\n }\n await printCriticalFailureToConsoleAndExit(err.message ?? err);\n cli.showHelp();\n } finally {\n await shutdownAnalytics();\n }\n} else {\n await printCriticalFailureToConsoleAndExit(\n `The Zuplo CLI requires at least node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}. Please update your version of node.js.\n\n Consider using a Node.js version manager such as https://github.com/nvm-sh/nvm.`\n );\n}\n"]}
|
package/dist/cmds/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cmds/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAWV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cmds/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAWV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBAsEf,OAAO;;AAzE/B,wBAsFE"}
|
package/dist/cmds/dev.js
CHANGED
|
@@ -31,6 +31,16 @@ export default {
|
|
|
31
31
|
type: "number",
|
|
32
32
|
describe: "The port to run the route designer on",
|
|
33
33
|
default: 9100,
|
|
34
|
+
})
|
|
35
|
+
.option("start-docs", {
|
|
36
|
+
type: "boolean",
|
|
37
|
+
describe: "Start the docs server with the local development setup",
|
|
38
|
+
default: true,
|
|
39
|
+
})
|
|
40
|
+
.option("docs-port", {
|
|
41
|
+
type: "number",
|
|
42
|
+
describe: "The port to run the docs server on",
|
|
43
|
+
default: 9200,
|
|
34
44
|
})
|
|
35
45
|
.option("debug-port", {
|
|
36
46
|
type: "number",
|
|
@@ -44,13 +54,17 @@ export default {
|
|
|
44
54
|
.example([
|
|
45
55
|
[
|
|
46
56
|
"$0 dev",
|
|
47
|
-
"Start the local development server with default settings (port 9000 for API, port 9100 for editor)",
|
|
57
|
+
"Start the local development server with default settings (port 9000 for API, port 9100 for editor, port 9200 for docs)",
|
|
48
58
|
],
|
|
49
59
|
["$0 dev --port 8080", "Start the local server on a custom port"],
|
|
50
60
|
[
|
|
51
61
|
"$0 dev --no-start-editor",
|
|
52
62
|
"Start only the API server without opening the editor",
|
|
53
63
|
],
|
|
64
|
+
[
|
|
65
|
+
"$0 dev --no-start-docs",
|
|
66
|
+
"Start the API server without the docs server",
|
|
67
|
+
],
|
|
54
68
|
[
|
|
55
69
|
"$0 dev --debug-port 9229",
|
|
56
70
|
"Start with Chrome DevTools inspector enabled on port 9229",
|
package/dist/cmds/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/cmds/dev.ts"],"names":[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,EAAE,IAAI;SACd,CAAC;aACD,MAAM,CAAC,YAAY,EAAE;YACpB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,yCAAyC;SACpD,CAAC;aACD,MAAM,CAAC,oCAAoC,EAAE;YAC5C,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,oCAAoC;YAC9C,OAAO,EAAE,KAAK;SACf,CAAC;aACD,OAAO,CAAC;YACP;gBACE,QAAQ;gBACR,wHAAwH;aACzH;YACD,CAAC,oBAAoB,EAAE,yCAAyC,CAAC;YACjE;gBACE,0BAA0B;gBAC1B,sDAAsD;aACvD;YACD;gBACE,wBAAwB;gBACxB,8CAA8C;aAC/C;YACD;gBACE,0BAA0B;gBAC1B,2DAA2D;aAC5D;SACF,CAAC;aACD,UAAU,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;aACnC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACpB,OAAO,MAAM,IAAI,YAAY,CAC3B,IAAI,qBAAqB,EAAE,CAC5B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC;YACjB,IAAI;YACJ,UAAU,EAAE;gBACV,YAAY,EAAG,IAAkB,CAAC,WAAW,CAAC;gBAC9C,oCAAoC,EAAG,IAAkB,CACvD,iCAAiC,CAClC;aACF;YACD,KAAK,EAAE,WAAW;SACnB,CAAC,CAAC;QACH,MAAM,GAAG,CAAC,IAAiB,CAAC,CAAC;IAC/B,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../common/analytics/lib.js\";\nimport { identify } from \"../common/middleware/user-identification.js\";\nimport setBlocking from \"../common/output.js\";\nimport { ZuploProjectValidator } from \"../common/validators/file-system-validator.js\";\nimport { YargsChecker } from \"../common/validators/lib.js\";\nimport { Arguments, dev } from \"../dev/handler.js\";\n\nexport default {\n desc: \"Runs the Zuplo API locally\",\n command: \"dev\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\"$0 dev [options]\")\n .option(\"dir\", {\n type: \"string\",\n describe: \"The directory containing your Zuplo API\",\n default: \".\",\n normalize: true,\n hidden: true,\n })\n .option(\"start-editor\", {\n type: \"boolean\",\n describe: \"Start the editor with the local server\",\n default: true,\n })\n .option(\"port\", {\n type: \"number\",\n describe: \"The port to run the local server on\",\n default: 9000,\n })\n .option(\"editor-port\", {\n type: \"number\",\n describe: \"The port to run the route designer on\",\n default: 9100,\n })\n .option(\"start-docs\", {\n type: \"boolean\",\n describe: \"Start the docs server with the local development setup\",\n default: true,\n })\n .option(\"docs-port\", {\n type: \"number\",\n describe: \"The port to run the docs server on\",\n default: 9200,\n })\n .option(\"debug-port\", {\n type: \"number\",\n describe: \"The port to run the Chrome inspector on\",\n })\n .option(\"unsafely-ignore-certificate-errors\", {\n type: \"boolean\",\n describe: \"Unsafely ignore certificate errors\",\n default: false,\n })\n .example([\n [\n \"$0 dev\",\n \"Start the local development server with default settings (port 9000 for API, port 9100 for editor, port 9200 for docs)\",\n ],\n [\"$0 dev --port 8080\", \"Start the local server on a custom port\"],\n [\n \"$0 dev --no-start-editor\",\n \"Start only the API server without opening the editor\",\n ],\n [\n \"$0 dev --no-start-docs\",\n \"Start the API server without the docs server\",\n ],\n [\n \"$0 dev --debug-port 9229\",\n \"Start with Chrome DevTools inspector enabled on port 9229\",\n ],\n ])\n .middleware([setBlocking, identify])\n .check(async (argv) => {\n return await new YargsChecker<typeof argv>(\n new ZuploProjectValidator()\n ).check(argv);\n });\n },\n handler: async (argv: unknown) => {\n await captureEvent({\n argv,\n properties: {\n \"debug-port\": (argv as Arguments)[\"debugPort\"],\n \"unsafely-ignore-certificate-errors\": (argv as Arguments)[\n \"unsafelyIgnoreCertificateErrors\"\n ],\n },\n event: \"zuplo dev\",\n });\n await dev(argv as Arguments);\n },\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/cmds/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAWV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBAuCf,OAAO;;AA1C/B,wBAqDE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { captureEvent } from "../common/analytics/lib.js";
|
|
2
|
+
import { identify } from "../common/middleware/user-identification.js";
|
|
3
|
+
import setBlocking from "../common/output.js";
|
|
4
|
+
import { ZuploProjectValidator } from "../common/validators/file-system-validator.js";
|
|
5
|
+
import { YargsChecker } from "../common/validators/lib.js";
|
|
6
|
+
import { docs } from "../docs/handler.js";
|
|
7
|
+
export default {
|
|
8
|
+
desc: "Runs the Zuplo docs server locally",
|
|
9
|
+
command: "docs",
|
|
10
|
+
builder: (yargs) => {
|
|
11
|
+
return yargs
|
|
12
|
+
.usage("$0 docs [options]")
|
|
13
|
+
.option("dir", {
|
|
14
|
+
type: "string",
|
|
15
|
+
describe: "The directory containing your Zuplo API",
|
|
16
|
+
default: ".",
|
|
17
|
+
normalize: true,
|
|
18
|
+
hidden: true,
|
|
19
|
+
})
|
|
20
|
+
.option("port", {
|
|
21
|
+
type: "number",
|
|
22
|
+
describe: "The port to run the docs server on",
|
|
23
|
+
default: 9200,
|
|
24
|
+
})
|
|
25
|
+
.option("server-url", {
|
|
26
|
+
type: "string",
|
|
27
|
+
describe: "The URL of the Zuplo API server to use (e.g., https://my-api.zuplo.dev)",
|
|
28
|
+
})
|
|
29
|
+
.example([
|
|
30
|
+
["$0 docs", "Start the docs server with default settings (port 9200)"],
|
|
31
|
+
["$0 docs --port 3000", "Start the docs server on a custom port"],
|
|
32
|
+
[
|
|
33
|
+
"$0 docs --server-url https://my-api.zuplo.dev",
|
|
34
|
+
"Start the docs server pointing to a remote Zuplo API",
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
"$0 docs --server-url http://localhost:9000",
|
|
38
|
+
"Start the docs server pointing to a local Zuplo API",
|
|
39
|
+
],
|
|
40
|
+
])
|
|
41
|
+
.middleware([setBlocking, identify])
|
|
42
|
+
.check(async (argv) => {
|
|
43
|
+
return await new YargsChecker(new ZuploProjectValidator()).check(argv);
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
handler: async (argv) => {
|
|
47
|
+
await captureEvent({
|
|
48
|
+
argv,
|
|
49
|
+
properties: {
|
|
50
|
+
port: argv.port,
|
|
51
|
+
"server-url": argv.serverUrl,
|
|
52
|
+
},
|
|
53
|
+
event: "zuplo docs",
|
|
54
|
+
});
|
|
55
|
+
await docs(argv);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/cmds/docs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AACvE,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAa,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAErD,eAAe;IACb,IAAI,EAAE,oCAAoC;IAC1C,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CAAC,mBAAmB,CAAC;aAC1B,MAAM,CAAC,KAAK,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,yCAAyC;YACnD,OAAO,EAAE,GAAG;YACZ,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,IAAI;SACb,CAAC;aACD,MAAM,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,oCAAoC;YAC9C,OAAO,EAAE,IAAI;SACd,CAAC;aACD,MAAM,CAAC,YAAY,EAAE;YACpB,IAAI,EAAE,QAAQ;YACd,QAAQ,EACN,yEAAyE;SAC5E,CAAC;aACD,OAAO,CAAC;YACP,CAAC,SAAS,EAAE,yDAAyD,CAAC;YACtE,CAAC,qBAAqB,EAAE,wCAAwC,CAAC;YACjE;gBACE,+CAA+C;gBAC/C,sDAAsD;aACvD;YACD;gBACE,4CAA4C;gBAC5C,qDAAqD;aACtD;SACF,CAAC;aACD,UAAU,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;aACnC,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACpB,OAAO,MAAM,IAAI,YAAY,CAC3B,IAAI,qBAAqB,EAAE,CAC5B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC;YACjB,IAAI;YACJ,UAAU,EAAE;gBACV,IAAI,EAAG,IAAkB,CAAC,IAAI;gBAC9B,YAAY,EAAG,IAAkB,CAAC,SAAS;aAC5C;YACD,KAAK,EAAE,YAAY;SACpB,CAAC,CAAC;QACH,MAAM,IAAI,CAAC,IAAiB,CAAC,CAAC;IAChC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../common/analytics/lib.js\";\nimport { identify } from \"../common/middleware/user-identification.js\";\nimport setBlocking from \"../common/output.js\";\nimport { ZuploProjectValidator } from \"../common/validators/file-system-validator.js\";\nimport { YargsChecker } from \"../common/validators/lib.js\";\nimport { Arguments, docs } from \"../docs/handler.js\";\n\nexport default {\n desc: \"Runs the Zuplo docs server locally\",\n command: \"docs\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\"$0 docs [options]\")\n .option(\"dir\", {\n type: \"string\",\n describe: \"The directory containing your Zuplo API\",\n default: \".\",\n normalize: true,\n hidden: true,\n })\n .option(\"port\", {\n type: \"number\",\n describe: \"The port to run the docs server on\",\n default: 9200,\n })\n .option(\"server-url\", {\n type: \"string\",\n describe:\n \"The URL of the Zuplo API server to use (e.g., https://my-api.zuplo.dev)\",\n })\n .example([\n [\"$0 docs\", \"Start the docs server with default settings (port 9200)\"],\n [\"$0 docs --port 3000\", \"Start the docs server on a custom port\"],\n [\n \"$0 docs --server-url https://my-api.zuplo.dev\",\n \"Start the docs server pointing to a remote Zuplo API\",\n ],\n [\n \"$0 docs --server-url http://localhost:9000\",\n \"Start the docs server pointing to a local Zuplo API\",\n ],\n ])\n .middleware([setBlocking, identify])\n .check(async (argv) => {\n return await new YargsChecker<typeof argv>(\n new ZuploProjectValidator()\n ).check(argv);\n });\n },\n handler: async (argv: unknown) => {\n await captureEvent({\n argv,\n properties: {\n port: (argv as Arguments).port,\n \"server-url\": (argv as Arguments).serverUrl,\n },\n event: \"zuplo docs\",\n });\n await docs(argv as Arguments);\n },\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Transform } from "node:stream";
|
|
2
|
+
import { ChalkInstance } from "chalk";
|
|
3
|
+
export interface PrefixedTransformOutputOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
color: ChalkInstance;
|
|
6
|
+
maxPrefixLength?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function createPrefixedTransform(
|
|
9
|
+
options: PrefixedTransformOutputOptions
|
|
10
|
+
): Transform;
|
|
11
|
+
//# sourceMappingURL=prefixed-output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefixed-output.d.ts","sourceRoot":"","sources":["../../../src/common/utils/prefixed-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqB,MAAM,aAAa,CAAC;AAC3D,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE7C,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,aAAa,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,8BAA8B,GACtC,SAAS,CAiCX"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Transform } from "node:stream";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
export function createPrefixedTransform(options) {
|
|
4
|
+
const maxLen = options.maxPrefixLength ?? 10;
|
|
5
|
+
const paddedName = options.name.padEnd(maxLen);
|
|
6
|
+
const prefix = options.color(paddedName) + chalk.gray(" | ");
|
|
7
|
+
let buffer = "";
|
|
8
|
+
return new Transform({
|
|
9
|
+
transform(chunk, _encoding, callback) {
|
|
10
|
+
const data = buffer + chunk.toString();
|
|
11
|
+
const lines = data.split("\n");
|
|
12
|
+
buffer = lines.pop() ?? "";
|
|
13
|
+
for (const line of lines) {
|
|
14
|
+
if (line.trim()) {
|
|
15
|
+
this.push(`${prefix}${line}\n`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
callback();
|
|
19
|
+
},
|
|
20
|
+
flush(callback) {
|
|
21
|
+
if (buffer.trim()) {
|
|
22
|
+
this.push(`${prefix}${buffer}\n`);
|
|
23
|
+
}
|
|
24
|
+
callback();
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=prefixed-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefixed-output.js","sourceRoot":"","sources":["../../../src/common/utils/prefixed-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqB,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAwB,MAAM,OAAO,CAAC;AAQ7C,MAAM,UAAU,uBAAuB,CACrC,OAAuC;IAEvC,MAAM,MAAM,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;IAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE7D,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,OAAO,IAAI,SAAS,CAAC;QACnB,SAAS,CACP,KAAsB,EACtB,SAAyB,EACzB,QAA2B;YAE3B,MAAM,IAAI,GAAG,MAAM,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;YACvC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAE/B,MAAM,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;YAE3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;oBAChB,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,IAAI,CAAC,CAAC;gBAClC,CAAC;YACH,CAAC;YAED,QAAQ,EAAE,CAAC;QACb,CAAC;QACD,KAAK,CAAC,QAA2B;YAC/B,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;gBAClB,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC;YACpC,CAAC;YACD,QAAQ,EAAE,CAAC;QACb,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Transform, TransformCallback } from \"node:stream\";\nimport chalk, { ChalkInstance } from \"chalk\";\n\nexport interface PrefixedTransformOutputOptions {\n name: string;\n color: ChalkInstance;\n maxPrefixLength?: number;\n}\n\nexport function createPrefixedTransform(\n options: PrefixedTransformOutputOptions\n): Transform {\n const maxLen = options.maxPrefixLength ?? 10;\n const paddedName = options.name.padEnd(maxLen);\n const prefix = options.color(paddedName) + chalk.gray(\" | \");\n\n let buffer = \"\";\n\n return new Transform({\n transform(\n chunk: Buffer | string,\n _encoding: BufferEncoding,\n callback: TransformCallback\n ) {\n const data = buffer + chunk.toString();\n const lines = data.split(\"\\n\");\n\n buffer = lines.pop() ?? \"\";\n\n for (const line of lines) {\n if (line.trim()) {\n this.push(`${prefix}${line}\\n`);\n }\n }\n\n callback();\n },\n flush(callback: TransformCallback) {\n if (buffer.trim()) {\n this.push(`${prefix}${buffer}\\n`);\n }\n callback();\n },\n });\n}\n"]}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { Readable } from "node:stream";
|
|
2
|
-
import {
|
|
3
|
-
export declare function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
): void;
|
|
7
|
-
export declare function logConsole(level: LogLevel, data: string): void;
|
|
8
|
-
export declare function logConsoleAsync(
|
|
9
|
-
level: LogLevel,
|
|
10
|
-
data: string
|
|
11
|
-
): Promise<void>;
|
|
2
|
+
import { ChalkInstance } from "chalk";
|
|
3
|
+
export declare function createRuntimeStdioHandler(options?: {
|
|
4
|
+
prefix?: string;
|
|
5
|
+
prefixColor?: ChalkInstance;
|
|
6
|
+
}): (stdout: Readable, stderr: Readable) => void;
|
|
12
7
|
//# sourceMappingURL=worker-output.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-output.d.ts","sourceRoot":"","sources":["../../src/common/worker-output.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"worker-output.d.ts","sourceRoot":"","sources":["../../src/common/worker-output.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAM7C,wBAAgB,yBAAyB,CAAC,OAAO,CAAC,EAAE;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B,IACoC,QAAQ,QAAQ,EAAE,QAAQ,QAAQ,UAwMtE"}
|
|
@@ -1,140 +1,149 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { LogFormatter } from "@zuplo/core/cli";
|
|
3
|
+
import chalk from "chalk";
|
|
3
4
|
const logFormatter = new LogFormatter(async (path) => {
|
|
4
5
|
return readFile(path, { encoding: "utf8" });
|
|
5
6
|
});
|
|
6
|
-
export function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
stdoutAccumulator = fullStreamOutput;
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const lines = currentLogsStr.split("\n");
|
|
47
|
-
for (let line of lines) {
|
|
48
|
-
line = line.trim();
|
|
49
|
-
if (!line)
|
|
50
|
-
continue;
|
|
51
|
-
if (classifiers.isBarf(line)) {
|
|
52
|
-
logConsole("debug", line);
|
|
7
|
+
export function createRuntimeStdioHandler(options) {
|
|
8
|
+
return function handleRuntimeStdio(stdout, stderr) {
|
|
9
|
+
const { prefix, prefixColor } = options ?? {};
|
|
10
|
+
let stdoutAccumulator = "";
|
|
11
|
+
let stderrAccumulator = "";
|
|
12
|
+
const classifiers = {
|
|
13
|
+
isBarf(chunk) {
|
|
14
|
+
const containsLlvmSymbolizerWarning = chunk.includes("Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set");
|
|
15
|
+
const containsRecursiveIsolateLockWarning = chunk.includes("took recursive isolate lock");
|
|
16
|
+
const containsHexStack = /stack:( (0|[a-f\d]{4,})){3,}/.test(chunk);
|
|
17
|
+
return (containsLlvmSymbolizerWarning ||
|
|
18
|
+
containsRecursiveIsolateLockWarning ||
|
|
19
|
+
containsHexStack);
|
|
20
|
+
},
|
|
21
|
+
isAddressInUse(chunk) {
|
|
22
|
+
return chunk.includes("Address already in use; toString() = ");
|
|
23
|
+
},
|
|
24
|
+
isWarning(chunk) {
|
|
25
|
+
return /\.c\+\+:\d+: warning:/.test(chunk);
|
|
26
|
+
},
|
|
27
|
+
isCodeMovedWarning(chunk) {
|
|
28
|
+
return /CODE_MOVED for unknown code block/.test(chunk);
|
|
29
|
+
},
|
|
30
|
+
isAccessViolation(chunk) {
|
|
31
|
+
return chunk.includes("access violation;");
|
|
32
|
+
},
|
|
33
|
+
isZenoLog(chunk) {
|
|
34
|
+
return chunk.startsWith("[ZENO]:");
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
stdout.on("data", (chunk) => {
|
|
38
|
+
const fullStreamOutput = `${stdoutAccumulator}${chunk}`;
|
|
39
|
+
let currentLogsStr = "";
|
|
40
|
+
const lastNewlineIdx = fullStreamOutput.lastIndexOf("\n");
|
|
41
|
+
if (lastNewlineIdx > 0) {
|
|
42
|
+
currentLogsStr = fullStreamOutput.slice(0, lastNewlineIdx);
|
|
43
|
+
stdoutAccumulator = fullStreamOutput.slice(lastNewlineIdx + 1);
|
|
53
44
|
}
|
|
54
|
-
else
|
|
55
|
-
|
|
45
|
+
else {
|
|
46
|
+
stdoutAccumulator = fullStreamOutput;
|
|
47
|
+
return;
|
|
56
48
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
logConsole(
|
|
49
|
+
const lines = currentLogsStr.split("\n");
|
|
50
|
+
for (let line of lines) {
|
|
51
|
+
line = line.trim();
|
|
52
|
+
if (!line)
|
|
53
|
+
continue;
|
|
54
|
+
if (classifiers.isBarf(line)) {
|
|
55
|
+
logConsole("debug", line, prefix, prefixColor);
|
|
56
|
+
}
|
|
57
|
+
else if (classifiers.isWarning(line)) {
|
|
58
|
+
logConsole("warn", line, prefix, prefixColor);
|
|
59
|
+
}
|
|
60
|
+
else if (classifiers.isZenoLog(line)) {
|
|
61
|
+
const levels = ["debug", "info", "warn", "error"];
|
|
62
|
+
const level = levels.find((level) => line.includes(`[${level.toUpperCase()}]`));
|
|
63
|
+
line = line.substring("[ZENO]:".length);
|
|
64
|
+
line = line.substring(`[${level?.toUpperCase()}]`.length);
|
|
65
|
+
if (level) {
|
|
66
|
+
logConsole(level, line, prefix, prefixColor);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
logConsole("info", line, prefix, prefixColor);
|
|
70
|
+
}
|
|
64
71
|
}
|
|
65
72
|
else {
|
|
66
|
-
logConsole("
|
|
73
|
+
logConsole("error", line, prefix, prefixColor);
|
|
67
74
|
}
|
|
68
75
|
}
|
|
76
|
+
});
|
|
77
|
+
stderr.on("data", (chunk) => {
|
|
78
|
+
const fullStreamOutput = `${stderrAccumulator}${chunk}`;
|
|
79
|
+
let currentLogsStr = "";
|
|
80
|
+
const lastNewlineIdx = fullStreamOutput.lastIndexOf("\n");
|
|
81
|
+
if (lastNewlineIdx > 0) {
|
|
82
|
+
currentLogsStr = fullStreamOutput.slice(0, lastNewlineIdx);
|
|
83
|
+
stderrAccumulator = fullStreamOutput.slice(lastNewlineIdx + 1);
|
|
84
|
+
}
|
|
69
85
|
else {
|
|
70
|
-
|
|
86
|
+
stderrAccumulator = fullStreamOutput;
|
|
87
|
+
return;
|
|
71
88
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const address = line.match(/Address already in use; toString\(\) = (.+)\n/)?.[1];
|
|
94
|
-
logConsole("error", `Address already in use (${address}). Please check that you are not already running a server on this address or specify a different port with --port.`);
|
|
95
|
-
logConsole("debug", line);
|
|
96
|
-
}
|
|
97
|
-
else if (classifiers.isAccessViolation(line)) {
|
|
98
|
-
let error = "There was an access violation in the runtime.";
|
|
99
|
-
if (process.platform === "win32") {
|
|
100
|
-
error +=
|
|
101
|
-
"\nOn Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.\n" +
|
|
102
|
-
"Check that you have the latest version installed.\n" +
|
|
103
|
-
"See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.";
|
|
89
|
+
const lines = currentLogsStr.split("\n");
|
|
90
|
+
for (let line of lines) {
|
|
91
|
+
line = line.trim();
|
|
92
|
+
if (!line)
|
|
93
|
+
continue;
|
|
94
|
+
if (classifiers.isBarf(line)) {
|
|
95
|
+
if (classifiers.isAddressInUse(line)) {
|
|
96
|
+
const address = line.match(/Address already in use; toString\(\) = (.+)\n/)?.[1];
|
|
97
|
+
logConsole("error", `Address already in use (${address}). Please check that you are not already running a server on this address or specify a different port with --port.`, prefix, prefixColor);
|
|
98
|
+
logConsole("debug", line, prefix, prefixColor);
|
|
99
|
+
}
|
|
100
|
+
else if (classifiers.isAccessViolation(line)) {
|
|
101
|
+
let error = "There was an access violation in the runtime.";
|
|
102
|
+
if (process.platform === "win32") {
|
|
103
|
+
error +=
|
|
104
|
+
"\nOn Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.\n" +
|
|
105
|
+
"Check that you have the latest version installed.\n" +
|
|
106
|
+
"See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.";
|
|
107
|
+
}
|
|
108
|
+
logConsole("error", error, prefix, prefixColor);
|
|
109
|
+
logConsole("debug", line, prefix, prefixColor);
|
|
104
110
|
}
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
else {
|
|
112
|
+
logConsole("debug", line, prefix, prefixColor);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else if (classifiers.isWarning(line)) {
|
|
116
|
+
logConsole("warn", line, prefix, prefixColor);
|
|
117
|
+
}
|
|
118
|
+
else if (classifiers.isCodeMovedWarning(line)) {
|
|
119
|
+
}
|
|
120
|
+
else if (classifiers.isZenoLog(line)) {
|
|
121
|
+
line = line.substring("[ZENO]:".length);
|
|
122
|
+
line = line.substring("[ERROR]".length);
|
|
123
|
+
logConsole("error", line, prefix, prefixColor);
|
|
107
124
|
}
|
|
108
125
|
else {
|
|
109
|
-
logConsole("
|
|
126
|
+
logConsole("error", line, prefix, prefixColor);
|
|
110
127
|
}
|
|
111
128
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
else if (classifiers.isCodeMovedWarning(line)) {
|
|
116
|
-
}
|
|
117
|
-
else if (classifiers.isZenoLog(line)) {
|
|
118
|
-
line = line.substring("[ZENO]:".length);
|
|
119
|
-
line = line.substring("[ERROR]".length);
|
|
120
|
-
logConsole("error", line);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
logConsole("error", line);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
129
|
+
});
|
|
130
|
+
};
|
|
127
131
|
}
|
|
128
|
-
|
|
129
|
-
void logConsoleAsync(level, data);
|
|
132
|
+
function logConsole(level, data, prefix, prefixColor) {
|
|
133
|
+
void logConsoleAsync(level, data, prefix, prefixColor);
|
|
130
134
|
}
|
|
131
|
-
|
|
135
|
+
async function logConsoleAsync(level, data, prefix, prefixColor) {
|
|
136
|
+
let outputPrefix = "";
|
|
137
|
+
if (prefix && prefixColor) {
|
|
138
|
+
const paddedName = prefix.padEnd(10);
|
|
139
|
+
outputPrefix = prefixColor(paddedName) + chalk.gray(" | ");
|
|
140
|
+
}
|
|
132
141
|
try {
|
|
133
142
|
if (!data) {
|
|
134
143
|
return;
|
|
135
144
|
}
|
|
136
145
|
if (typeof data !== "string") {
|
|
137
|
-
console[level](data);
|
|
146
|
+
console[level](outputPrefix + data);
|
|
138
147
|
return;
|
|
139
148
|
}
|
|
140
149
|
let message = data?.trim();
|
|
@@ -147,23 +156,23 @@ export async function logConsoleAsync(level, data) {
|
|
|
147
156
|
logEntry = JSON.parse(message);
|
|
148
157
|
}
|
|
149
158
|
catch {
|
|
150
|
-
console[level](data);
|
|
159
|
+
console[level](outputPrefix + data);
|
|
151
160
|
return;
|
|
152
161
|
}
|
|
153
162
|
await Promise.all(logEntry.messages.map(async (msg) => {
|
|
154
163
|
const line = await logFormatter.formatStructured(logEntry, msg);
|
|
155
|
-
console[level](line);
|
|
164
|
+
console[level](outputPrefix + line);
|
|
156
165
|
}));
|
|
157
166
|
}
|
|
158
167
|
else {
|
|
159
168
|
message = await logFormatter.formatMessage(message);
|
|
160
169
|
const line = logFormatter.formatLine(level, message);
|
|
161
|
-
console[level](line);
|
|
170
|
+
console[level](outputPrefix + line);
|
|
162
171
|
}
|
|
163
172
|
}
|
|
164
173
|
catch {
|
|
165
174
|
const line = logFormatter.formatLine(level, data);
|
|
166
|
-
console[level](line);
|
|
175
|
+
console[level](outputPrefix + line);
|
|
167
176
|
}
|
|
168
177
|
}
|
|
169
178
|
//# sourceMappingURL=worker-output.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-output.js","sourceRoot":"","sources":["../../src/common/worker-output.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAmB,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAE1E,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;IAC3D,OAAO,Q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O,CAAC,CAAC;YACrD,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAElD,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;AACH,CAAC","sourcesContent":["/** biome-ignore-all lint/suspicious/noConsole: Output */\n\nimport { readFile } from \"node:fs/promises\";\nimport { Readable } from \"node:stream\";\nimport { ConsoleLogEntry, LogFormatter, LogLevel } from \"@zuplo/core/cli\";\n\nconst logFormatter = new LogFormatter(async (path: string) => {\n return readFile(path, { encoding: \"utf8\" });\n});\n\nexport function handleRuntimeStdio(stdout: Readable, stderr: Readable) {\n let stdoutAccumulator = \"\";\n let stderrAccumulator = \"\";\n\n const classifiers = {\n // Is this chunk a big chonky barf from workerd that we want to hijack to cleanup/ignore?\n isBarf(chunk: string) {\n const containsLlvmSymbolizerWarning = chunk.includes(\n \"Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set\"\n );\n const containsRecursiveIsolateLockWarning = chunk.includes(\n \"took recursive isolate lock\"\n );\n // Matches stack traces from workerd\n // - on unix: groups of 9 hex digits separated by spaces\n // - on windows: groups of 12 hex digits, or a single digit 0, separated by spaces\n const containsHexStack = /stack:( (0|[a-f\\d]{4,})){3,}/.test(chunk);\n\n return (\n containsLlvmSymbolizerWarning ||\n containsRecursiveIsolateLockWarning ||\n containsHexStack\n );\n },\n // Is this chunk an Address In Use error?\n isAddressInUse(chunk: string) {\n return chunk.includes(\"Address already in use; toString() = \");\n },\n isWarning(chunk: string) {\n return /\\.c\\+\\+:\\d+: warning:/.test(chunk);\n },\n isCodeMovedWarning(chunk: string) {\n return /CODE_MOVED for unknown code block/.test(chunk);\n },\n isAccessViolation(chunk: string) {\n return chunk.includes(\"access violation;\");\n },\n isZenoLog(chunk: string) {\n return chunk.startsWith(\"[ZENO]:\");\n },\n };\n\n stdout.on(\"data\", (chunk: Buffer | string) => {\n const fullStreamOutput = `${stdoutAccumulator}${chunk}`;\n\n let currentLogsStr = \"\";\n const lastNewlineIdx = fullStreamOutput.lastIndexOf(\"\\n\");\n\n if (lastNewlineIdx > 0) {\n // Extract complete logs up to the last newline\n currentLogsStr = fullStreamOutput.slice(0, lastNewlineIdx);\n // Save the partial/incomplete log for next iteration\n stdoutAccumulator = fullStreamOutput.slice(lastNewlineIdx + 1);\n } else {\n // No complete log found, accumulate entire output\n stdoutAccumulator = fullStreamOutput;\n return;\n }\n\n const lines = currentLogsStr.split(\"\\n\");\n\n for (let line of lines) {\n line = line.trim();\n if (!line) continue;\n\n if (classifiers.isBarf(line)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // there are no known cases to cleanup yet\n // but, as they are identified, we will do that here\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n logConsole(\"debug\", line);\n }\n\n // known case: warnings are not info, log them as such\n else if (classifiers.isWarning(line)) {\n logConsole(\"warn\", line);\n } else if (classifiers.isZenoLog(line)) {\n // Route to the specified logging level\n const levels = [\"debug\", \"info\", \"warn\", \"error\"];\n const level = levels.find((level) =>\n line.includes(`[${level.toUpperCase()}]`)\n );\n // Strip the prefixes for zeno and the zeno logging level\n line = line.substring(\"[ZENO]:\".length);\n line = line.substring(`[${level?.toUpperCase()}]`.length);\n if (level) {\n logConsole(level as LogLevel, line);\n } else {\n logConsole(\"info\", line);\n }\n }\n\n // anything not explicitly handled above should be logged as info (via stdout)\n else {\n logConsole(\"error\", line);\n }\n }\n });\n\n stderr.on(\"data\", (chunk: Buffer | string) => {\n const fullStreamOutput = `${stderrAccumulator}${chunk}`;\n\n let currentLogsStr = \"\";\n const lastNewlineIdx = fullStreamOutput.lastIndexOf(\"\\n\");\n\n if (lastNewlineIdx > 0) {\n // Extract complete logs up to the last newline\n currentLogsStr = fullStreamOutput.slice(0, lastNewlineIdx);\n // Save the partial/incomplete log for next iteration\n stderrAccumulator = fullStreamOutput.slice(lastNewlineIdx + 1);\n } else {\n // No complete log found, accumulate entire output\n stderrAccumulator = fullStreamOutput;\n return;\n }\n\n const lines = currentLogsStr.split(\"\\n\");\n\n for (let line of lines) {\n line = line.trim();\n if (!line) continue;\n\n if (classifiers.isBarf(line)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // known case to cleanup: Address in use errors\n if (classifiers.isAddressInUse(line)) {\n const address = line.match(\n /Address already in use; toString\\(\\) = (.+)\\n/\n )?.[1];\n\n logConsole(\n \"error\",\n `Address already in use (${address}). Please check that you are not already running a server on this address or specify a different port with --port.`\n );\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", line);\n }\n // In the past we have seen Access Violation errors on Windows, which may be caused by an outdated\n // version of the Windows OS or the Microsoft Visual C++ Redistributable.\n // See https://github.com/cloudflare/workers-sdk/issues/6170#issuecomment-2245209918\n else if (classifiers.isAccessViolation(line)) {\n let error = \"There was an access violation in the runtime.\";\n if (process.platform === \"win32\") {\n error +=\n \"\\nOn Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.\\n\" +\n \"Check that you have the latest version installed.\\n\" +\n \"See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.\";\n }\n logConsole(\"error\", error);\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", line);\n }\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n else {\n logConsole(\"debug\", line);\n }\n }\n\n // known case: warnings are not errors, log them as such\n else if (classifiers.isWarning(line)) {\n logConsole(\"warn\", line);\n }\n\n // known case: \"error: CODE_MOVED for unknown code block?\", warning for workerd devs, not application devs\n else if (classifiers.isCodeMovedWarning(line)) {\n // ignore entirely, don't even send it to the debug log file\n }\n\n // Handle Zeno error logs\n else if (classifiers.isZenoLog(line)) {\n // Strip the prefixes\n line = line.substring(\"[ZENO]:\".length);\n line = line.substring(\"[ERROR]\".length);\n logConsole(\"error\", line);\n }\n\n // anything not explicitly handled above should be logged as an error (via stderr)\n else {\n logConsole(\"error\", line);\n }\n }\n });\n}\n\nexport function logConsole(level: LogLevel, data: string) {\n void logConsoleAsync(level, data);\n}\n\n/**\n * This is what is logged when the runtime calls console.log, etc.\n */\nexport async function logConsoleAsync(level: LogLevel, data: string) {\n try {\n if (!data) {\n return;\n }\n\n // This shouldn't happen, but just in case\n if (typeof data !== \"string\") {\n console[level](data);\n return;\n }\n\n let message = data?.trim();\n if (!message || message?.length === 0) {\n return;\n }\n\n // Probably a JSON object\n if (message.startsWith(`{`) && message.endsWith(`}`)) {\n let logEntry: ConsoleLogEntry;\n try {\n logEntry = JSON.parse(message);\n } catch {\n console[level](data);\n return;\n }\n await Promise.all(\n logEntry.messages.map(async (msg) => {\n const line = await logFormatter.formatStructured(logEntry, msg);\n console[level](line);\n })\n );\n } else {\n message = await logFormatter.formatMessage(message);\n\n const line = logFormatter.formatLine(level, message);\n console[level](line);\n }\n } catch {\n const line = logFormatter.formatLine(level, data);\n\n console[level](line);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"worker-output.js","sourceRoot":"","sources":["../../src/common/worker-output.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAmB,YAAY,EAAY,MAAM,iBAAiB,CAAC;AAC1E,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;IAC3D,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,yBAAyB,CAAC,OAGzC;IACC,OAAO,SAAS,kBAAkB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AAyB,CAAC;YAC9B,IAAI,CAAC;gBACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACjC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;gBACpC,OAAO;YACT,CAAC;YACD,MAAM,OAAO,CAAC,GAAG,CACf,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;gBAClC,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;gBAChE,OAAO,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;YACtC,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAEpD,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACrD,OAAO,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAElD,OAAO,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACtC,CAAC;AACH,CAAC","sourcesContent":["/** biome-ignore-all lint/suspicious/noConsole: Output */\n\nimport { readFile } from \"node:fs/promises\";\nimport { Readable } from \"node:stream\";\nimport { ConsoleLogEntry, LogFormatter, LogLevel } from \"@zuplo/core/cli\";\nimport chalk, { ChalkInstance } from \"chalk\";\n\nconst logFormatter = new LogFormatter(async (path: string) => {\n return readFile(path, { encoding: \"utf8\" });\n});\n\nexport function createRuntimeStdioHandler(options?: {\n prefix?: string;\n prefixColor?: ChalkInstance;\n}) {\n return function handleRuntimeStdio(stdout: Readable, stderr: Readable) {\n const { prefix, prefixColor } = options ?? {};\n let stdoutAccumulator = \"\";\n let stderrAccumulator = \"\";\n\n const classifiers = {\n // Is this chunk a big chonky barf from workerd that we want to hijack to cleanup/ignore?\n isBarf(chunk: string) {\n const containsLlvmSymbolizerWarning = chunk.includes(\n \"Not symbolizing stack traces because $LLVM_SYMBOLIZER is not set\"\n );\n const containsRecursiveIsolateLockWarning = chunk.includes(\n \"took recursive isolate lock\"\n );\n // Matches stack traces from workerd\n // - on unix: groups of 9 hex digits separated by spaces\n // - on windows: groups of 12 hex digits, or a single digit 0, separated by spaces\n const containsHexStack = /stack:( (0|[a-f\\d]{4,})){3,}/.test(chunk);\n\n return (\n containsLlvmSymbolizerWarning ||\n containsRecursiveIsolateLockWarning ||\n containsHexStack\n );\n },\n // Is this chunk an Address In Use error?\n isAddressInUse(chunk: string) {\n return chunk.includes(\"Address already in use; toString() = \");\n },\n isWarning(chunk: string) {\n return /\\.c\\+\\+:\\d+: warning:/.test(chunk);\n },\n isCodeMovedWarning(chunk: string) {\n return /CODE_MOVED for unknown code block/.test(chunk);\n },\n isAccessViolation(chunk: string) {\n return chunk.includes(\"access violation;\");\n },\n isZenoLog(chunk: string) {\n return chunk.startsWith(\"[ZENO]:\");\n },\n };\n\n stdout.on(\"data\", (chunk: Buffer | string) => {\n const fullStreamOutput = `${stdoutAccumulator}${chunk}`;\n\n let currentLogsStr = \"\";\n const lastNewlineIdx = fullStreamOutput.lastIndexOf(\"\\n\");\n\n if (lastNewlineIdx > 0) {\n // Extract complete logs up to the last newline\n currentLogsStr = fullStreamOutput.slice(0, lastNewlineIdx);\n // Save the partial/incomplete log for next iteration\n stdoutAccumulator = fullStreamOutput.slice(lastNewlineIdx + 1);\n } else {\n // No complete log found, accumulate entire output\n stdoutAccumulator = fullStreamOutput;\n return;\n }\n\n const lines = currentLogsStr.split(\"\\n\");\n\n for (let line of lines) {\n line = line.trim();\n if (!line) continue;\n\n if (classifiers.isBarf(line)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // there are no known cases to cleanup yet\n // but, as they are identified, we will do that here\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n logConsole(\"debug\", line, prefix, prefixColor);\n }\n\n // known case: warnings are not info, log them as such\n else if (classifiers.isWarning(line)) {\n logConsole(\"warn\", line, prefix, prefixColor);\n } else if (classifiers.isZenoLog(line)) {\n // Route to the specified logging level\n const levels = [\"debug\", \"info\", \"warn\", \"error\"];\n const level = levels.find((level) =>\n line.includes(`[${level.toUpperCase()}]`)\n );\n // Strip the prefixes for zeno and the zeno logging level\n line = line.substring(\"[ZENO]:\".length);\n line = line.substring(`[${level?.toUpperCase()}]`.length);\n if (level) {\n logConsole(level as LogLevel, line, prefix, prefixColor);\n } else {\n logConsole(\"info\", line, prefix, prefixColor);\n }\n }\n\n // anything not explicitly handled above should be logged as info (via stdout)\n else {\n logConsole(\"error\", line, prefix, prefixColor);\n }\n }\n });\n\n stderr.on(\"data\", (chunk: Buffer | string) => {\n const fullStreamOutput = `${stderrAccumulator}${chunk}`;\n\n let currentLogsStr = \"\";\n const lastNewlineIdx = fullStreamOutput.lastIndexOf(\"\\n\");\n\n if (lastNewlineIdx > 0) {\n // Extract complete logs up to the last newline\n currentLogsStr = fullStreamOutput.slice(0, lastNewlineIdx);\n // Save the partial/incomplete log for next iteration\n stderrAccumulator = fullStreamOutput.slice(lastNewlineIdx + 1);\n } else {\n // No complete log found, accumulate entire output\n stderrAccumulator = fullStreamOutput;\n return;\n }\n\n const lines = currentLogsStr.split(\"\\n\");\n\n for (let line of lines) {\n line = line.trim();\n if (!line) continue;\n\n if (classifiers.isBarf(line)) {\n // this is a big chonky barf from workerd that we want to hijack to cleanup/ignore\n\n // CLEANABLE:\n // known case to cleanup: Address in use errors\n if (classifiers.isAddressInUse(line)) {\n const address = line.match(\n /Address already in use; toString\\(\\) = (.+)\\n/\n )?.[1];\n\n logConsole(\n \"error\",\n `Address already in use (${address}). Please check that you are not already running a server on this address or specify a different port with --port.`,\n prefix,\n prefixColor\n );\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", line, prefix, prefixColor);\n }\n // In the past we have seen Access Violation errors on Windows, which may be caused by an outdated\n // version of the Windows OS or the Microsoft Visual C++ Redistributable.\n // See https://github.com/cloudflare/workers-sdk/issues/6170#issuecomment-2245209918\n else if (classifiers.isAccessViolation(line)) {\n let error = \"There was an access violation in the runtime.\";\n if (process.platform === \"win32\") {\n error +=\n \"\\nOn Windows, this may be caused by an outdated Microsoft Visual C++ Redistributable library.\\n\" +\n \"Check that you have the latest version installed.\\n\" +\n \"See https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist.\";\n }\n logConsole(\"error\", error, prefix, prefixColor);\n\n // Log the original error to the debug logs.\n logConsole(\"debug\", line, prefix, prefixColor);\n }\n\n // IGNORABLE:\n // anything else not handled above is considered ignorable\n // so send it to the debug logs which are discarded unless\n // the user explicitly sets a logLevel indicating they care\n else {\n logConsole(\"debug\", line, prefix, prefixColor);\n }\n }\n\n // known case: warnings are not errors, log them as such\n else if (classifiers.isWarning(line)) {\n logConsole(\"warn\", line, prefix, prefixColor);\n }\n\n // known case: \"error: CODE_MOVED for unknown code block?\", warning for workerd devs, not application devs\n else if (classifiers.isCodeMovedWarning(line)) {\n // ignore entirely, don't even send it to the debug log file\n }\n\n // Handle Zeno error logs\n else if (classifiers.isZenoLog(line)) {\n // Strip the prefixes\n line = line.substring(\"[ZENO]:\".length);\n line = line.substring(\"[ERROR]\".length);\n logConsole(\"error\", line, prefix, prefixColor);\n }\n\n // anything not explicitly handled above should be logged as an error (via stderr)\n else {\n logConsole(\"error\", line, prefix, prefixColor);\n }\n }\n });\n };\n}\n\nfunction logConsole(\n level: LogLevel,\n data: string,\n prefix?: string,\n prefixColor?: ChalkInstance\n) {\n void logConsoleAsync(level, data, prefix, prefixColor);\n}\n\n/**\n * This is what is logged when the runtime calls console.log, etc.\n */\nasync function logConsoleAsync(\n level: LogLevel,\n data: string,\n prefix?: string,\n prefixColor?: ChalkInstance\n) {\n let outputPrefix = \"\";\n if (prefix && prefixColor) {\n const paddedName = prefix.padEnd(10);\n outputPrefix = prefixColor(paddedName) + chalk.gray(\" | \");\n }\n\n try {\n if (!data) {\n return;\n }\n\n // This shouldn't happen, but just in case\n if (typeof data !== \"string\") {\n console[level](outputPrefix + data);\n return;\n }\n\n let message = data?.trim();\n if (!message || message?.length === 0) {\n return;\n }\n\n // Probably a JSON object\n if (message.startsWith(`{`) && message.endsWith(`}`)) {\n let logEntry: ConsoleLogEntry;\n try {\n logEntry = JSON.parse(message);\n } catch {\n console[level](outputPrefix + data);\n return;\n }\n await Promise.all(\n logEntry.messages.map(async (msg) => {\n const line = await logFormatter.formatStructured(logEntry, msg);\n console[level](outputPrefix + line);\n })\n );\n } else {\n message = await logFormatter.formatMessage(message);\n\n const line = logFormatter.formatLine(level, message);\n console[level](outputPrefix + line);\n }\n } catch {\n const line = logFormatter.formatLine(level, data);\n\n console[level](outputPrefix + line);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/compile/handler.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/compile/handler.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,SAAS,iBAgF5C"}
|
package/dist/compile/handler.js
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import dotenv from "dotenv";
|
|
6
6
|
import { logger } from "../common/logger.js";
|
|
7
7
|
import { ConsoleOutput, printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, } from "../common/output.js";
|
|
8
|
-
import {
|
|
8
|
+
import { createRuntimeStdioHandler } from "../common/worker-output.js";
|
|
9
9
|
export async function compile(argv) {
|
|
10
10
|
const sourceDirectory = resolve(argv.dir);
|
|
11
11
|
const zuploRuntimePath = new URL("../../node_modules/@zuplo/runtime", import.meta.url);
|
|
@@ -25,6 +25,7 @@ export async function compile(argv) {
|
|
|
25
25
|
const core = await import("@zuplo/core/cli");
|
|
26
26
|
const zupPort = argv.port;
|
|
27
27
|
const buildId = argv["build-id"] || randomUUID();
|
|
28
|
+
const handleRuntimeStdio = createRuntimeStdioHandler();
|
|
28
29
|
try {
|
|
29
30
|
await core.compileWorkerdServer({
|
|
30
31
|
buildId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/compile/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,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AACH,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { cpSync, existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport dotenv from \"dotenv\";\nimport { logger } from \"../common/logger.js\";\nimport {\n ConsoleOutput,\n printCriticalFailureToConsoleAndExit,\n printDiagnosticsToConsole,\n printResultToConsoleAndExitGracefully,\n} from \"../common/output.js\";\nimport { createRuntimeStdioHandler } from \"../common/worker-output.js\";\n\nexport interface Arguments {\n dir: string;\n \"bundled-dir\": string;\n port: number;\n \"binary-name\": string;\n \"build-id\": string;\n}\n\nexport async function compile(argv: Arguments) {\n const sourceDirectory = resolve(argv.dir);\n\n // When we build, we MIGHT need to use the @zuplo/runtime from the node_modules if the user\n // has installed our packages using https://www.npmjs.com/package/zuplo in a global directory\n\n // Try to copy the @zuplo/runtime locally\n const zuploRuntimePath = new URL(\n \"../../node_modules/@zuplo/runtime\",\n import.meta.url\n );\n if (existsSync(zuploRuntimePath)) {\n cpSync(\n zuploRuntimePath,\n join(sourceDirectory, \"node_modules/@zuplo/runtime\"),\n {\n recursive: true,\n dereference: true,\n }\n );\n }\n\n // Set GLOBAL_MODULE_LOCATION to the location of the CLIs node_modules\n // biome-ignore lint/style/noProcessEnv: Migrated from ESLint\n process.env.GLOBAL_MODULE_LOCATION = fileURLToPath(\n new URL(\"../../node_modules\", import.meta.url)\n );\n\n // Check if the user has a .env.zuplo file\n let envZuplo: dotenv.DotenvParseOutput = {};\n const envZuploFile = join(sourceDirectory, \".env.zuplo\");\n if (existsSync(envZuploFile)) {\n const contents = readFileSync(envZuploFile);\n envZuplo = dotenv.parse(contents);\n }\n // Set other variables using __ZUPLO_CONFIG as necessary\n // const config = {\n // };\n // process.env.__ZUPLO_CONFIG = btoa(JSON.stringify(config));\n // Use a dynamic import so that setting process.env has effect\n const core = await import(\"@zuplo/core/cli\");\n\n const zupPort = argv.port;\n\n const buildId = argv[\"build-id\"] || randomUUID();\n\n const handleRuntimeStdio = createRuntimeStdioHandler();\n try {\n await core.compileWorkerdServer({\n buildId,\n output: new ConsoleOutput(),\n sourceDirectory,\n bundledDir: argv[\"bundled-dir\"],\n port: zupPort,\n binaryName: argv[\"binary-name\"],\n publicZuploEnvironmentVariables: envZuplo\n ? {\n // biome-ignore lint/style/useNamingConvention: External API property\n ZUPLO_ACCOUNT_NAME: envZuplo.ZUPLO_ACCOUNT_NAME,\n // biome-ignore lint/style/useNamingConvention: External API property\n ZUPLO_PROJECT_NAME: envZuplo.ZUPLO_PROJECT_NAME,\n // biome-ignore lint/style/useNamingConvention: External API property\n ZUPLO_ENVIRONMENT_TYPE: envZuplo.ZUPLO_ENVIRONMENT_TYPE,\n }\n : // Leave this as undefined to simulate the old behavior\n undefined,\n logger,\n handleRuntimeStdio,\n });\n\n printDiagnosticsToConsole(\"📦 Compiled a self-contained zup binary\");\n await printResultToConsoleAndExitGracefully(\n `The binary is available at ${sourceDirectory}/dist/${argv[\"binary-name\"]}`\n );\n } catch (err) {\n printDiagnosticsToConsole(err.message);\n await printCriticalFailureToConsoleAndExit(\n \"Failed to compile the zup binary\"\n );\n }\n}\n"]}
|
package/dist/dev/handler.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/dev/handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/dev/handler.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+BAA+B,CAAC,EAAE,OAAO,CAAC;CAC3C;AAED,wBAAsB,GAAG,CAAC,IAAI,EAAE,SAAS,iBA2PxC"}
|
package/dist/dev/handler.js
CHANGED
|
@@ -3,11 +3,14 @@ import { cpSync, existsSync, readFileSync } from "node:fs";
|
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { LocalEditorServer } from "@zuplo/editor";
|
|
6
|
+
import chalk from "chalk";
|
|
6
7
|
import dotenv from "dotenv";
|
|
8
|
+
import { execa } from "execa";
|
|
7
9
|
import { logger } from "../common/logger.js";
|
|
8
|
-
import { ConsoleOutput, printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, } from "../common/output.js";
|
|
10
|
+
import { ConsoleOutput, printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printWarningToConsole, } from "../common/output.js";
|
|
9
11
|
import { isPortAvailable } from "../common/utils/ports.js";
|
|
10
|
-
import {
|
|
12
|
+
import { createPrefixedTransform } from "../common/utils/prefixed-output.js";
|
|
13
|
+
import { createRuntimeStdioHandler } from "../common/worker-output.js";
|
|
11
14
|
export async function dev(argv) {
|
|
12
15
|
const sourceDirectory = resolve(argv.dir);
|
|
13
16
|
const zuploRuntimePath = new URL("../../node_modules/@zuplo/runtime", import.meta.url);
|
|
@@ -49,14 +52,32 @@ export async function dev(argv) {
|
|
|
49
52
|
await printCriticalFailureToConsoleAndExit(`Port ${zupDebugPort} is already in use. Please specify a different port using --debug-port.`);
|
|
50
53
|
}
|
|
51
54
|
}
|
|
55
|
+
const docsDirectory = join(sourceDirectory, "docs");
|
|
56
|
+
const hasDocsDirectory = existsSync(docsDirectory);
|
|
57
|
+
if (!hasDocsDirectory) {
|
|
58
|
+
printWarningToConsole(`Warning: docs/ directory not found at ${docsDirectory}. Skipping docs server.`);
|
|
59
|
+
}
|
|
60
|
+
const startDocs = argv["start-docs"] && hasDocsDirectory;
|
|
61
|
+
const docsPort = argv.docsPort;
|
|
62
|
+
if (startDocs) {
|
|
63
|
+
const isDocsPortAvailable = await isPortAvailable("localhost", docsPort);
|
|
64
|
+
if (!isDocsPortAvailable) {
|
|
65
|
+
await printCriticalFailureToConsoleAndExit(`Port ${docsPort} is already in use. Please specify a different port using --docs-port.`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
52
68
|
const buildId = randomUUID();
|
|
53
69
|
let firstLoad = true;
|
|
70
|
+
const handleRuntimeStdio = createRuntimeStdioHandler({
|
|
71
|
+
prefix: "gateway",
|
|
72
|
+
prefixColor: chalk.cyan,
|
|
73
|
+
});
|
|
54
74
|
await core.startDevServer({
|
|
55
75
|
buildId,
|
|
56
76
|
output: new ConsoleOutput(),
|
|
57
77
|
sourceDirectory,
|
|
58
78
|
port: zupPort,
|
|
59
79
|
debugPort: argv.debugPort,
|
|
80
|
+
devPortalPort: startDocs ? docsPort : undefined,
|
|
60
81
|
unsafelyIgnoreCertificateErrors: argv.unsafelyIgnoreCertificateErrors,
|
|
61
82
|
publicZuploEnvironmentVariables: envZuplo
|
|
62
83
|
? {
|
|
@@ -87,6 +108,28 @@ export async function dev(argv) {
|
|
|
87
108
|
});
|
|
88
109
|
editor.start().catch((err) => logger.error(err));
|
|
89
110
|
}
|
|
111
|
+
let docsProcess;
|
|
112
|
+
if (startDocs) {
|
|
113
|
+
const npxExecutable = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
114
|
+
docsProcess = execa(npxExecutable, ["zudoku", "dev", "--zuplo", "--port", String(docsPort)], {
|
|
115
|
+
cwd: docsDirectory,
|
|
116
|
+
env: {
|
|
117
|
+
...process.env,
|
|
118
|
+
FORCE_COLOR: "1",
|
|
119
|
+
ZUPLO_SERVER_URL: `http://localhost:${zupPort}`,
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
const docsStdoutTransform = createPrefixedTransform({
|
|
123
|
+
name: "docs",
|
|
124
|
+
color: chalk.magenta,
|
|
125
|
+
});
|
|
126
|
+
const docsStderrTransform = createPrefixedTransform({
|
|
127
|
+
name: "docs",
|
|
128
|
+
color: chalk.magenta,
|
|
129
|
+
});
|
|
130
|
+
docsProcess.stdout?.pipe(docsStdoutTransform).pipe(process.stdout);
|
|
131
|
+
docsProcess.stderr?.pipe(docsStderrTransform).pipe(process.stderr);
|
|
132
|
+
}
|
|
90
133
|
printDiagnosticsToConsole("Started local development setup");
|
|
91
134
|
printDiagnosticsToConsole("Ctrl+C to exit");
|
|
92
135
|
printDiagnosticsToConsole("");
|
|
@@ -94,6 +137,9 @@ export async function dev(argv) {
|
|
|
94
137
|
if (argv["start-editor"]) {
|
|
95
138
|
printDiagnosticsToConsole(`📘 Route Designer: http://localhost:${argv.editorPort}`);
|
|
96
139
|
}
|
|
140
|
+
if (startDocs) {
|
|
141
|
+
printDiagnosticsToConsole(`📄 Docs Server: http://localhost:${docsPort}`);
|
|
142
|
+
}
|
|
97
143
|
if (loadedEnvFiles.length > 0) {
|
|
98
144
|
printDiagnosticsToConsole(`⚙️ Loaded env files: \n - ${loadedEnvFiles.join(" \n - ")}`);
|
|
99
145
|
}
|
|
@@ -101,15 +147,33 @@ export async function dev(argv) {
|
|
|
101
147
|
printDiagnosticsToConsole("");
|
|
102
148
|
return new Promise((resolve) => {
|
|
103
149
|
async function exit() {
|
|
150
|
+
process.off("SIGTERM", exit);
|
|
151
|
+
process.off("SIGINT", exit);
|
|
104
152
|
printDiagnosticsToConsole("");
|
|
105
153
|
printDiagnosticsToConsole("Stopping local development server...");
|
|
106
154
|
if (argv["start-editor"]) {
|
|
107
155
|
await editor.close();
|
|
108
156
|
}
|
|
157
|
+
if (docsProcess) {
|
|
158
|
+
docsProcess.kill("SIGTERM");
|
|
159
|
+
}
|
|
109
160
|
resolve();
|
|
110
161
|
}
|
|
111
162
|
process.on("SIGTERM", exit);
|
|
112
163
|
process.on("SIGINT", exit);
|
|
164
|
+
if (docsProcess) {
|
|
165
|
+
docsProcess.on("close", (code, signal) => {
|
|
166
|
+
if (signal === "SIGTERM" || signal === "SIGINT") {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (code !== 0) {
|
|
170
|
+
printWarningToConsole(`Docs server exited with code ${code}.`);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
docsProcess.on("error", (err) => {
|
|
174
|
+
printWarningToConsole(`Failed to start docs server: ${err.message}`);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
113
177
|
});
|
|
114
178
|
}
|
|
115
179
|
//# sourceMappingURL=handler.js.map
|
package/dist/dev/handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/dev/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,oCAAoC,EACpC,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAWhE,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAe;IACvC,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAM1C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC9B,mCAAmC,EACnC,MAAM,CAAC,IAAI,CAAC,GAAG,CAChB,CAAC;IACF,IAAI,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACjC,MAAM,CACJ,gBAAgB,EAChB,IA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C","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { cpSync, existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { LocalEditorServer } from \"@zuplo/editor\";\nimport dotenv from \"dotenv\";\nimport { logger } from \"../common/logger.js\";\nimport {\n ConsoleOutput,\n printCriticalFailureToConsoleAndExit,\n printDiagnosticsToConsole,\n} from \"../common/output.js\";\nimport { isPortAvailable } from \"../common/utils/ports.js\";\nimport { handleRuntimeStdio } from \"../common/worker-output.js\";\n\nexport interface Arguments {\n dir: string;\n \"start-editor\": boolean;\n port: number;\n editorPort: number;\n debugPort?: number;\n unsafelyIgnoreCertificateErrors?: boolean;\n}\n\nexport async function dev(argv: Arguments) {\n const sourceDirectory = resolve(argv.dir);\n\n // When we build, we MIGHT need to use the @zuplo/runtime from the node_modules if the user\n // has installed our packages using https://www.npmjs.com/package/zuplo in a global directory\n\n // Try to copy the @zuplo/runtime locally\n const zuploRuntimePath = new URL(\n \"../../node_modules/@zuplo/runtime\",\n import.meta.url\n );\n if (existsSync(zuploRuntimePath)) {\n cpSync(\n zuploRuntimePath,\n join(sourceDirectory, \"node_modules/@zuplo/runtime\"),\n {\n recursive: true,\n dereference: true,\n }\n );\n }\n\n // Set GLOBAL_MODULE_LOCATION to the location of the CLIs node_modules\n // biome-ignore lint/style/noProcessEnv: Migrated from ESLint\n process.env.GLOBAL_MODULE_LOCATION = fileURLToPath(\n new URL(\"../../node_modules\", import.meta.url)\n );\n\n const loadedEnvFiles: string[] = [];\n\n // Check if the user has a .env file\n const envFile = join(sourceDirectory, \".env\");\n if (existsSync(envFile)) {\n loadedEnvFiles.push(\".env\");\n }\n\n // Check if the user has a .env.zuplo file\n let envZuplo: dotenv.DotenvParseOutput | undefined;\n const envZuploFile = join(sourceDirectory, \".env.zuplo\");\n if (existsSync(envZuploFile)) {\n const contents = readFileSync(envZuploFile);\n envZuplo = dotenv.parse(contents);\n loadedEnvFiles.push(\".env.zuplo\");\n }\n\n // Set other variables using __ZUPLO_CONFIG as necessary\n // const config = {\n // };\n // process.env.__ZUPLO_CONFIG = btoa(JSON.stringify(config));\n // biome-ignore lint/style/noProcessEnv: Migrated from ESLint\n process.env.ZUPLO_IS_LOCAL_DEVELOPMENT = \"true\";\n\n // Use a dynamic import so that setting process.env has effect\n const core = await import(\"@zuplo/core/cli\");\n\n const zupPort = argv.port;\n const zupEditorPort = argv.editorPort;\n const zupDebugPort = argv.debugPort;\n\n const isZupPortAvailable = await isPortAvailable(\"localhost\", zupPort);\n if (!isZupPortAvailable) {\n await printCriticalFailureToConsoleAndExit(\n `Port ${zupPort} is already in use. Please specify a different port using --port.`\n );\n }\n\n const isZupEditorPortAvailable = await isPortAvailable(\n \"localhost\",\n zupEditorPort\n );\n if (!isZupEditorPortAvailable) {\n await printCriticalFailureToConsoleAndExit(\n `Port ${zupEditorPort} is already in use. Please specify a different port using --editor-port.`\n );\n }\n\n if (zupDebugPort) {\n const isZupDebugPortAvailable = await isPortAvailable(\n \"localhost\",\n zupDebugPort\n );\n if (!isZupDebugPortAvailable) {\n await printCriticalFailureToConsoleAndExit(\n `Port ${zupDebugPort} is already in use. Please specify a different port using --debug-port.`\n );\n }\n }\n\n const buildId = randomUUID();\n\n let firstLoad = true;\n\n await core.startDevServer({\n buildId,\n output: new ConsoleOutput(),\n sourceDirectory,\n port: zupPort,\n debugPort: argv.debugPort,\n unsafelyIgnoreCertificateErrors: argv.unsafelyIgnoreCertificateErrors,\n publicZuploEnvironmentVariables: envZuplo\n ? {\n // biome-ignore lint/style/useNamingConvention: External API property\n ZUPLO_ACCOUNT_NAME: envZuplo.ZUPLO_ACCOUNT_NAME,\n // biome-ignore lint/style/useNamingConvention: External API property\n ZUPLO_PROJECT_NAME: envZuplo.ZUPLO_PROJECT_NAME,\n // biome-ignore lint/style/useNamingConvention: External API property\n ZUPLO_ENVIRONMENT_TYPE: envZuplo.ZUPLO_ENVIRONMENT_TYPE,\n }\n : // Leave this as undefined to simulate the old behavior\n undefined,\n logger,\n handleRuntimeStdio,\n onReload: () => {\n if (firstLoad) {\n firstLoad = false;\n } else {\n printDiagnosticsToConsole(\"Code changed. Server reloaded...\");\n }\n },\n });\n\n let editor: LocalEditorServer;\n\n if (argv[\"start-editor\"]) {\n editor = new LocalEditorServer({\n sourceDirectory,\n deploymentUrl: `http://localhost:${zupPort}`,\n port: argv.editorPort,\n logger,\n });\n editor.start().catch((err) => logger.error(err));\n }\n\n printDiagnosticsToConsole(\"Started local development setup\");\n printDiagnosticsToConsole(\"Ctrl+C to exit\");\n printDiagnosticsToConsole(\"\");\n printDiagnosticsToConsole(`🚀 Zuplo Gateway: http://localhost:${zupPort}`);\n if (argv[\"start-editor\"]) {\n printDiagnosticsToConsole(\n `📘 Route Designer: http://localhost:${argv.editorPort}`\n );\n }\n if (loadedEnvFiles.length > 0) {\n printDiagnosticsToConsole(\n `⚙️ Loaded env files: \\n - ${loadedEnvFiles.join(\" \\n - \")}`\n );\n }\n printDiagnosticsToConsole(\"\");\n printDiagnosticsToConsole(\"\");\n\n return new Promise<void>((resolve) => {\n async function exit() {\n printDiagnosticsToConsole(\"\");\n printDiagnosticsToConsole(\"Stopping local development server...\");\n\n if (argv[\"start-editor\"]) {\n await editor.close();\n }\n resolve();\n }\n\n process.on(\"SIGTERM\", exit);\n process.on(\"SIGINT\", exit);\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/dev/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK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AW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC9B,CAAC;YAED,OAAO,EAAE,CAAC;QACZ,CAAC;QAGD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC5B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAG3B,IAAI,WAAW,EAAE,CAAC;YAChB,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;gBACvC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;oBAChD,OAAO;gBACT,CAAC;gBAED,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;oBACf,qBAAqB,CAAC,gCAAgC,IAAI,GAAG,CAAC,CAAC;gBACjE,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC9B,qBAAqB,CAAC,gCAAgC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { cpSync, existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { LocalEditorServer } from \"@zuplo/editor\";\nimport chalk from \"chalk\";\nimport dotenv from \"dotenv\";\nimport { ExecaChildProcess, execa } from \"execa\";\nimport { logger } from \"../common/logger.js\";\nimport {\n ConsoleOutput,\n printCriticalFailureToConsoleAndExit,\n printDiagnosticsToConsole,\n printWarningToConsole,\n} from \"../common/output.js\";\nimport { isPortAvailable } from \"../common/utils/ports.js\";\nimport { createPrefixedTransform } from \"../common/utils/prefixed-output.js\";\nimport { createRuntimeStdioHandler } from \"../common/worker-output.js\";\n\nexport interface Arguments {\n dir: string;\n \"start-editor\": boolean;\n \"start-docs\": boolean;\n port: number;\n editorPort: number;\n docsPort: number;\n debugPort?: number;\n unsafelyIgnoreCertificateErrors?: boolean;\n}\n\nexport async function dev(argv: Arguments) {\n const sourceDirectory = resolve(argv.dir);\n\n // When we build, we MIGHT need to use the @zuplo/runtime from the node_modules if the user\n // has installed our packages using https://www.npmjs.com/package/zuplo in a global directory\n\n // Try to copy the @zuplo/runtime locally\n const zuploRuntimePath = new URL(\n \"../../node_modules/@zuplo/runtime\",\n import.meta.url\n );\n if (existsSync(zuploRuntimePath)) {\n cpSync(\n zuploRuntimePath,\n join(sourceDirectory, \"node_modules/@zuplo/runtime\"),\n {\n recursive: true,\n dereference: true,\n }\n );\n }\n\n // Set GLOBAL_MODULE_LOCATION to the location of the CLIs node_modules\n // biome-ignore lint/style/noProcessEnv: Migrated from ESLint\n process.env.GLOBAL_MODULE_LOCATION = fileURLToPath(\n new URL(\"../../node_modules\", import.meta.url)\n );\n\n const loadedEnvFiles: string[] = [];\n\n // Check if the user has a .env file\n const envFile = join(sourceDirectory, \".env\");\n if (existsSync(envFile)) {\n loadedEnvFiles.push(\".env\");\n }\n\n // Check if the user has a .env.zuplo file\n let envZuplo: dotenv.DotenvParseOutput | undefined;\n const envZuploFile = join(sourceDirectory, \".env.zuplo\");\n if (existsSync(envZuploFile)) {\n const contents = readFileSync(envZuploFile);\n envZuplo = dotenv.parse(contents);\n loadedEnvFiles.push(\".env.zuplo\");\n }\n\n // Set other variables using __ZUPLO_CONFIG as necessary\n // const config = {\n // };\n // process.env.__ZUPLO_CONFIG = btoa(JSON.stringify(config));\n // biome-ignore lint/style/noProcessEnv: Migrated from ESLint\n process.env.ZUPLO_IS_LOCAL_DEVELOPMENT = \"true\";\n\n // Use a dynamic import so that setting process.env has effect\n const core = await import(\"@zuplo/core/cli\");\n\n const zupPort = argv.port;\n const zupEditorPort = argv.editorPort;\n const zupDebugPort = argv.debugPort;\n\n const isZupPortAvailable = await isPortAvailable(\"localhost\", zupPort);\n if (!isZupPortAvailable) {\n await printCriticalFailureToConsoleAndExit(\n `Port ${zupPort} is already in use. Please specify a different port using --port.`\n );\n }\n\n const isZupEditorPortAvailable = await isPortAvailable(\n \"localhost\",\n zupEditorPort\n );\n if (!isZupEditorPortAvailable) {\n await printCriticalFailureToConsoleAndExit(\n `Port ${zupEditorPort} is already in use. Please specify a different port using --editor-port.`\n );\n }\n\n if (zupDebugPort) {\n const isZupDebugPortAvailable = await isPortAvailable(\n \"localhost\",\n zupDebugPort\n );\n if (!isZupDebugPortAvailable) {\n await printCriticalFailureToConsoleAndExit(\n `Port ${zupDebugPort} is already in use. Please specify a different port using --debug-port.`\n );\n }\n }\n\n const docsDirectory = join(sourceDirectory, \"docs\");\n const hasDocsDirectory = existsSync(docsDirectory);\n if (!hasDocsDirectory) {\n printWarningToConsole(\n `Warning: docs/ directory not found at ${docsDirectory}. Skipping docs server.`\n );\n }\n\n const startDocs = argv[\"start-docs\"] && hasDocsDirectory;\n const docsPort = argv.docsPort;\n\n if (startDocs) {\n const isDocsPortAvailable = await isPortAvailable(\"localhost\", docsPort);\n if (!isDocsPortAvailable) {\n await printCriticalFailureToConsoleAndExit(\n `Port ${docsPort} is already in use. Please specify a different port using --docs-port.`\n );\n }\n }\n\n const buildId = randomUUID();\n\n let firstLoad = true;\n\n const handleRuntimeStdio = createRuntimeStdioHandler({\n prefix: \"gateway\",\n prefixColor: chalk.cyan,\n });\n await core.startDevServer({\n buildId,\n output: new ConsoleOutput(),\n sourceDirectory,\n port: zupPort,\n debugPort: argv.debugPort,\n devPortalPort: startDocs ? docsPort : undefined,\n unsafelyIgnoreCertificateErrors: argv.unsafelyIgnoreCertificateErrors,\n publicZuploEnvironmentVariables: envZuplo\n ? {\n // biome-ignore lint/style/useNamingConvention: External API property\n ZUPLO_ACCOUNT_NAME: envZuplo.ZUPLO_ACCOUNT_NAME,\n // biome-ignore lint/style/useNamingConvention: External API property\n ZUPLO_PROJECT_NAME: envZuplo.ZUPLO_PROJECT_NAME,\n // biome-ignore lint/style/useNamingConvention: External API property\n ZUPLO_ENVIRONMENT_TYPE: envZuplo.ZUPLO_ENVIRONMENT_TYPE,\n }\n : // Leave this as undefined to simulate the old behavior\n undefined,\n logger,\n handleRuntimeStdio,\n onReload: () => {\n if (firstLoad) {\n firstLoad = false;\n } else {\n printDiagnosticsToConsole(\"Code changed. Server reloaded...\");\n }\n },\n });\n\n let editor: LocalEditorServer;\n\n if (argv[\"start-editor\"]) {\n editor = new LocalEditorServer({\n sourceDirectory,\n deploymentUrl: `http://localhost:${zupPort}`,\n port: argv.editorPort,\n logger,\n });\n editor.start().catch((err) => logger.error(err));\n }\n\n let docsProcess: ExecaChildProcess | undefined;\n\n if (startDocs) {\n const npxExecutable = process.platform === \"win32\" ? \"npx.cmd\" : \"npx\";\n docsProcess = execa(\n npxExecutable,\n [\"zudoku\", \"dev\", \"--zuplo\", \"--port\", String(docsPort)],\n {\n cwd: docsDirectory,\n env: {\n // biome-ignore lint/style/noProcessEnv: Pass through environment\n ...process.env,\n // Ensure that the Zudoku server pipes through colored output even if it's\n // not sending it through a TTY and instead is using the prefixed transform\n // https://force-color.org/\n // biome-ignore lint/style/useNamingConvention: Environment variable naming\n FORCE_COLOR: \"1\",\n // biome-ignore lint/style/useNamingConvention: Environment variable naming\n ZUPLO_SERVER_URL: `http://localhost:${zupPort}`,\n },\n }\n );\n const docsStdoutTransform = createPrefixedTransform({\n name: \"docs\",\n color: chalk.magenta,\n });\n const docsStderrTransform = createPrefixedTransform({\n name: \"docs\",\n color: chalk.magenta,\n });\n docsProcess.stdout?.pipe(docsStdoutTransform).pipe(process.stdout);\n docsProcess.stderr?.pipe(docsStderrTransform).pipe(process.stderr);\n }\n\n printDiagnosticsToConsole(\"Started local development setup\");\n printDiagnosticsToConsole(\"Ctrl+C to exit\");\n printDiagnosticsToConsole(\"\");\n printDiagnosticsToConsole(`🚀 Zuplo Gateway: http://localhost:${zupPort}`);\n if (argv[\"start-editor\"]) {\n printDiagnosticsToConsole(\n `📘 Route Designer: http://localhost:${argv.editorPort}`\n );\n }\n if (startDocs) {\n printDiagnosticsToConsole(`📄 Docs Server: http://localhost:${docsPort}`);\n }\n if (loadedEnvFiles.length > 0) {\n printDiagnosticsToConsole(\n `⚙️ Loaded env files: \\n - ${loadedEnvFiles.join(\" \\n - \")}`\n );\n }\n printDiagnosticsToConsole(\"\");\n printDiagnosticsToConsole(\"\");\n\n return new Promise<void>((resolve) => {\n async function exit() {\n process.off(\"SIGTERM\", exit);\n process.off(\"SIGINT\", exit);\n\n printDiagnosticsToConsole(\"\");\n printDiagnosticsToConsole(\"Stopping local development server...\");\n\n if (argv[\"start-editor\"]) {\n await editor.close();\n }\n if (docsProcess) {\n docsProcess.kill(\"SIGTERM\");\n }\n\n resolve();\n }\n\n // Handle user-initiated shutdown\n process.on(\"SIGTERM\", exit);\n process.on(\"SIGINT\", exit);\n\n // Handle child process exiting and cleanup\n if (docsProcess) {\n docsProcess.on(\"close\", (code, signal) => {\n if (signal === \"SIGTERM\" || signal === \"SIGINT\") {\n return;\n }\n\n if (code !== 0) {\n printWarningToConsole(`Docs server exited with code ${code}.`);\n }\n });\n\n docsProcess.on(\"error\", (err) => {\n printWarningToConsole(`Failed to start docs server: ${err.message}`);\n });\n }\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/docs/handler.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,SAAS,iBAsFzC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printWarningToConsole, } from "../common/output.js";
|
|
5
|
+
import { isPortAvailable } from "../common/utils/ports.js";
|
|
6
|
+
export async function docs(argv) {
|
|
7
|
+
const sourceDirectory = resolve(argv.dir);
|
|
8
|
+
const docsDirectory = join(sourceDirectory, "docs");
|
|
9
|
+
if (!existsSync(docsDirectory)) {
|
|
10
|
+
await printCriticalFailureToConsoleAndExit(`docs/ directory not found at ${docsDirectory}. Please ensure your project has a docs directory.`);
|
|
11
|
+
}
|
|
12
|
+
const docsPort = argv.port;
|
|
13
|
+
const isDocsPortAvailable = await isPortAvailable("localhost", docsPort);
|
|
14
|
+
if (!isDocsPortAvailable) {
|
|
15
|
+
await printCriticalFailureToConsoleAndExit(`Port ${docsPort} is already in use. Please specify a different port using --port.`);
|
|
16
|
+
}
|
|
17
|
+
const env = {
|
|
18
|
+
...process.env,
|
|
19
|
+
FORCE_COLOR: "1",
|
|
20
|
+
};
|
|
21
|
+
if (argv.serverUrl) {
|
|
22
|
+
env.ZUPLO_SERVER_URL = argv.serverUrl;
|
|
23
|
+
}
|
|
24
|
+
const npxExecutable = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
25
|
+
const docsProcess = execa(npxExecutable, ["zudoku", "dev", "--zuplo", "--port", String(docsPort)], {
|
|
26
|
+
cwd: docsDirectory,
|
|
27
|
+
env,
|
|
28
|
+
});
|
|
29
|
+
docsProcess.stdout?.pipe(process.stdout);
|
|
30
|
+
docsProcess.stderr?.pipe(process.stderr);
|
|
31
|
+
printDiagnosticsToConsole("Started docs server");
|
|
32
|
+
printDiagnosticsToConsole("Ctrl+C to exit");
|
|
33
|
+
printDiagnosticsToConsole("");
|
|
34
|
+
printDiagnosticsToConsole(`📄 Docs Server: http://localhost:${docsPort}`);
|
|
35
|
+
if (argv.serverUrl) {
|
|
36
|
+
printDiagnosticsToConsole(`🔗 Using API Server: ${argv.serverUrl}`);
|
|
37
|
+
}
|
|
38
|
+
printDiagnosticsToConsole("");
|
|
39
|
+
return new Promise((resolve) => {
|
|
40
|
+
function exit() {
|
|
41
|
+
process.off("SIGTERM", exit);
|
|
42
|
+
process.off("SIGINT", exit);
|
|
43
|
+
printDiagnosticsToConsole("");
|
|
44
|
+
printDiagnosticsToConsole("Stopping docs server...");
|
|
45
|
+
docsProcess.kill("SIGTERM");
|
|
46
|
+
resolve();
|
|
47
|
+
}
|
|
48
|
+
process.on("SIGTERM", exit);
|
|
49
|
+
process.on("SIGINT", exit);
|
|
50
|
+
docsProcess.on("error", (err) => {
|
|
51
|
+
process.off("SIGTERM", exit);
|
|
52
|
+
process.off("SIGINT", exit);
|
|
53
|
+
printWarningToConsole(`Failed to start docs server: ${err.message}`);
|
|
54
|
+
resolve();
|
|
55
|
+
});
|
|
56
|
+
docsProcess.on("close", (code, signal) => {
|
|
57
|
+
if (signal === "SIGTERM" || signal === "SIGINT") {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
process.off("SIGTERM", exit);
|
|
61
|
+
process.off("SIGINT", exit);
|
|
62
|
+
printWarningToConsole(`Docs server exited with code ${code}.`);
|
|
63
|
+
resolve();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/docs/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EACL,oCAAoC,EACpC,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAQ3D,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAe;IACxC,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAA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AO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC5B,qBAAqB,CAAC,gCAAgC,IAAI,GAAG,CAAC,CAAC;YAC/D,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { execa } from \"execa\";\nimport {\n printCriticalFailureToConsoleAndExit,\n printDiagnosticsToConsole,\n printWarningToConsole,\n} from \"../common/output.js\";\nimport { isPortAvailable } from \"../common/utils/ports.js\";\n\nexport interface Arguments {\n dir: string;\n port: number;\n serverUrl?: string;\n}\n\nexport async function docs(argv: Arguments) {\n const sourceDirectory = resolve(argv.dir);\n const docsDirectory = join(sourceDirectory, \"docs\");\n\n if (!existsSync(docsDirectory)) {\n await printCriticalFailureToConsoleAndExit(\n `docs/ directory not found at ${docsDirectory}. Please ensure your project has a docs directory.`\n );\n }\n\n const docsPort = argv.port;\n\n const isDocsPortAvailable = await isPortAvailable(\"localhost\", docsPort);\n if (!isDocsPortAvailable) {\n await printCriticalFailureToConsoleAndExit(\n `Port ${docsPort} is already in use. Please specify a different port using --port.`\n );\n }\n\n const env: NodeJS.ProcessEnv = {\n // biome-ignore lint/style/noProcessEnv: Required to pass through environment\n ...process.env,\n // Ensure that the Zudoku server pipes through colored output even if it's\n // not sending it through a TTY.\n // https://force-color.org/\n // biome-ignore lint/style/useNamingConvention: Environment variable naming\n FORCE_COLOR: \"1\",\n };\n\n if (argv.serverUrl) {\n env.ZUPLO_SERVER_URL = argv.serverUrl;\n }\n\n const npxExecutable = process.platform === \"win32\" ? \"npx.cmd\" : \"npx\";\n const docsProcess = execa(\n npxExecutable,\n [\"zudoku\", \"dev\", \"--zuplo\", \"--port\", String(docsPort)],\n {\n cwd: docsDirectory,\n env,\n }\n );\n docsProcess.stdout?.pipe(process.stdout);\n docsProcess.stderr?.pipe(process.stderr);\n\n printDiagnosticsToConsole(\"Started docs server\");\n printDiagnosticsToConsole(\"Ctrl+C to exit\");\n printDiagnosticsToConsole(\"\");\n printDiagnosticsToConsole(`📄 Docs Server: http://localhost:${docsPort}`);\n if (argv.serverUrl) {\n printDiagnosticsToConsole(`🔗 Using API Server: ${argv.serverUrl}`);\n }\n printDiagnosticsToConsole(\"\");\n\n return new Promise<void>((resolve) => {\n function exit() {\n process.off(\"SIGTERM\", exit);\n process.off(\"SIGINT\", exit);\n\n printDiagnosticsToConsole(\"\");\n printDiagnosticsToConsole(\"Stopping docs server...\");\n docsProcess.kill(\"SIGTERM\");\n resolve();\n }\n\n process.on(\"SIGTERM\", exit);\n process.on(\"SIGINT\", exit);\n\n docsProcess.on(\"error\", (err) => {\n process.off(\"SIGTERM\", exit);\n process.off(\"SIGINT\", exit);\n printWarningToConsole(`Failed to start docs server: ${err.message}`);\n resolve();\n });\n\n docsProcess.on(\"close\", (code, signal) => {\n if (signal === \"SIGTERM\" || signal === \"SIGINT\") {\n return;\n }\n\n process.off(\"SIGTERM\", exit);\n process.off(\"SIGINT\", exit);\n printWarningToConsole(`Docs server exited with code ${code}.`);\n resolve();\n });\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/cli.ts","../src/internal.ts","../src/types.d.ts","../src/__tests__/archive-utils.test.ts","../src/__tests__/import-openapi-utils.test.ts","../src/__tests__/import-openapi.test.ts","../src/__tests__/oas-test-data.ts","../src/__tests__/outdated.test.ts","../src/__tests__/populate.test.ts","../src/__tests__/tsconfig-upgrader.test.ts","../src/__tests__/integration/delete.integration.test.ts","../src/__tests__/integration/deploy.integration.test.ts","../src/__tests__/integration/jest-mocks-setup.ts","../src/__tests__/integration/jest-setup.ts","../src/__tests__/integration/link.integration.test.ts","../src/__tests__/integration/list.integration.test.ts","../src/__tests__/integration/test-utils.ts","../src/__tests__/integration/tunnel.integration.test.ts","../src/__tests__/integration/variable.integration.test.ts","../src/build/handler.ts","../src/cmds/build.ts","../src/cmds/compile.ts","../src/cmds/delete.ts","../src/cmds/deploy.ts","../src/cmds/dev.ts","../src/cmds/editor.ts","../src/cmds/link.ts","../src/cmds/list.ts","../src/cmds/login.ts","../src/cmds/test.ts","../src/cmds/mtls-certificates/create.ts","../src/cmds/mtls-certificates/delete.ts","../src/cmds/mtls-certificates/describe.ts","../src/cmds/mtls-certificates/disable.ts","../src/cmds/mtls-certificates/index.ts","../src/cmds/mtls-certificates/list.ts","../src/cmds/mtls-certificates/update.ts","../src/cmds/open-api/convert.ts","../src/cmds/open-api/index.ts","../src/cmds/open-api/merge.ts","../src/cmds/open-api/overlay.ts","../src/cmds/project/create.ts","../src/cmds/project/index.ts","../src/cmds/proxies/create.ts","../src/cmds/proxies/delete.ts","../src/cmds/proxies/describe.ts","../src/cmds/proxies/index.ts","../src/cmds/proxies/update.ts","../src/cmds/source/import-openapi.ts","../src/cmds/source/index.ts","../src/cmds/source/migrate.ts","../src/cmds/source/upgrade.ts","../src/cmds/tunnel/create.ts","../src/cmds/tunnel/delete.ts","../src/cmds/tunnel/describe.ts","../src/cmds/tunnel/index.ts","../src/cmds/tunnel/list.ts","../src/cmds/tunnel/rotate-token.ts","../src/cmds/tunnel/services/describe.ts","../src/cmds/tunnel/services/index.ts","../src/cmds/tunnel/services/update.ts","../src/cmds/variable/create.ts","../src/cmds/variable/index.ts","../src/cmds/variable/update.ts","../src/common/alias.ts","../src/common/args.ts","../src/common/constants.ts","../src/common/file-format.ts","../src/common/handler.ts","../src/common/logger.ts","../src/common/models.ts","../src/common/outdated.ts","../src/common/output.ts","../src/common/populate.ts","../src/common/runner.ts","../src/common/settings.ts","../src/common/worker-output.ts","../src/common/analytics/lib.ts","../src/common/api/lib.ts","../src/common/machine-id/lib.ts","../src/common/middleware/authentication.ts","../src/common/middleware/get-account-param.ts","../src/common/middleware/get-environment-param.ts","../src/common/middleware/get-project-param.ts","../src/common/middleware/logging.ts","../src/common/middleware/user-configuration.ts","../src/common/middleware/user-identification.ts","../src/common/middleware/validate-fleet.ts","../src/common/open-api/constants.ts","../src/common/open-api/index.ts","../src/common/open-api/validation.ts","../src/common/upgraders/lib.ts","../src/common/upgraders/package-json-upgrader.ts","../src/common/upgraders/tsconfig-upgrader.ts","../src/common/upgraders/vscode-settings-json-upgrader.ts","../src/common/utils/box.ts","../src/common/utils/branch.ts","../src/common/utils/ports.ts","../src/common/utils/pretty-print-environment-prompt.ts","../src/common/utils/stringify-config.test.ts","../src/common/utils/stringify-config.ts","../src/common/utils/types.ts","../src/common/utils/urls.ts","../src/common/validators/file-system-validator.ts","../src/common/validators/lib.ts","../src/common/validators/project-name-validator.ts","../src/common/xdg/lib.ts","../src/compile/handler.ts","../src/delete/handler.ts","../src/delete/poll-deployment.ts","../src/deploy/archive.test.ts","../src/deploy/archive.ts","../src/deploy/environments.ts","../src/deploy/file-upload.ts","../src/deploy/handler.ts","../src/deploy/poll-deployment.ts","../src/dev/handler.ts","../src/editor/handler.ts","../src/link/handler.ts","../src/list/handler.ts","../src/login/login.ts","../src/login/tokens.ts","../src/mtls-certificates/models.ts","../src/mtls-certificates/create/handler.ts","../src/mtls-certificates/delete/handler.ts","../src/mtls-certificates/describe/handler.ts","../src/mtls-certificates/disable/handler.ts","../src/mtls-certificates/list/handler.ts","../src/mtls-certificates/update/handler.ts","../src/open-api/convert/convert-engine.spec.ts","../src/open-api/convert/convert-engine.ts","../src/open-api/convert/handler.spec.ts","../src/open-api/convert/handler.ts","../src/open-api/merge/ajv.ts","../src/open-api/merge/handler.spec.ts","../src/open-api/merge/handler.ts","../src/open-api/merge/interfaces.ts","../src/open-api/merge/merge-engine.spec.ts","../src/open-api/merge/merge-engine.ts","../src/open-api/merge/utils.ts","../src/open-api/overlay/handler.spec.ts","../src/open-api/overlay/handler.ts","../src/open-api/overlay/overlay-engine.spec.ts","../src/open-api/overlay/overlay-engine.ts","../src/project/create/handler.ts","../src/proxies/models.ts","../src/proxies/create/handler.ts","../src/proxies/delete/handler.ts","../src/proxies/describe/handler.ts","../src/proxies/update/handler.ts","../src/source/migrate/dev-portal/handler.ts","../src/source/migrate/dev-portal/types.ts","../src/source/update/handler.ts","../src/test/esbuild-config.ts","../src/test/handler.ts","../src/test/invoke-test.ts","../src/test/test-files.test.ts","../src/test/test-files.ts","../src/test/esbuild-plugins/node-test-prep-plugin.ts","../src/tunnel/models.ts","../src/tunnel/create/handler.ts","../src/tunnel/delete/handler.ts","../src/tunnel/delete/poll-teardown-operation.ts","../src/tunnel/describe/handler.ts","../src/tunnel/list/handler.ts","../src/tunnel/rotate-token/handler.ts","../src/tunnel/services/describe/handler.ts","../src/tunnel/services/update/handler.ts","../src/tunnel/services/update/poll-provisioning-operations.ts","../src/variable/models.ts","../src/variable/create/handler.ts","../src/variable/update/handler.ts"],"version":"5.8.2"}
|
|
1
|
+
{"root":["../src/cli.ts","../src/internal.ts","../src/types.d.ts","../src/__tests__/archive-utils.test.ts","../src/__tests__/import-openapi-utils.test.ts","../src/__tests__/import-openapi.test.ts","../src/__tests__/oas-test-data.ts","../src/__tests__/outdated.test.ts","../src/__tests__/populate.test.ts","../src/__tests__/tsconfig-upgrader.test.ts","../src/__tests__/integration/delete.integration.test.ts","../src/__tests__/integration/deploy.integration.test.ts","../src/__tests__/integration/jest-mocks-setup.ts","../src/__tests__/integration/jest-setup.ts","../src/__tests__/integration/link.integration.test.ts","../src/__tests__/integration/list.integration.test.ts","../src/__tests__/integration/test-utils.ts","../src/__tests__/integration/tunnel.integration.test.ts","../src/__tests__/integration/variable.integration.test.ts","../src/build/handler.ts","../src/cmds/build.ts","../src/cmds/compile.ts","../src/cmds/delete.ts","../src/cmds/deploy.ts","../src/cmds/dev.ts","../src/cmds/docs.ts","../src/cmds/editor.ts","../src/cmds/link.ts","../src/cmds/list.ts","../src/cmds/login.ts","../src/cmds/test.ts","../src/cmds/mtls-certificates/create.ts","../src/cmds/mtls-certificates/delete.ts","../src/cmds/mtls-certificates/describe.ts","../src/cmds/mtls-certificates/disable.ts","../src/cmds/mtls-certificates/index.ts","../src/cmds/mtls-certificates/list.ts","../src/cmds/mtls-certificates/update.ts","../src/cmds/open-api/convert.ts","../src/cmds/open-api/index.ts","../src/cmds/open-api/merge.ts","../src/cmds/open-api/overlay.ts","../src/cmds/project/create.ts","../src/cmds/project/index.ts","../src/cmds/proxies/create.ts","../src/cmds/proxies/delete.ts","../src/cmds/proxies/describe.ts","../src/cmds/proxies/index.ts","../src/cmds/proxies/update.ts","../src/cmds/source/import-openapi.ts","../src/cmds/source/index.ts","../src/cmds/source/migrate.ts","../src/cmds/source/upgrade.ts","../src/cmds/tunnel/create.ts","../src/cmds/tunnel/delete.ts","../src/cmds/tunnel/describe.ts","../src/cmds/tunnel/index.ts","../src/cmds/tunnel/list.ts","../src/cmds/tunnel/rotate-token.ts","../src/cmds/tunnel/services/describe.ts","../src/cmds/tunnel/services/index.ts","../src/cmds/tunnel/services/update.ts","../src/cmds/variable/create.ts","../src/cmds/variable/index.ts","../src/cmds/variable/update.ts","../src/common/alias.ts","../src/common/args.ts","../src/common/constants.ts","../src/common/file-format.ts","../src/common/handler.ts","../src/common/logger.ts","../src/common/models.ts","../src/common/outdated.ts","../src/common/output.ts","../src/common/populate.ts","../src/common/runner.ts","../src/common/settings.ts","../src/common/worker-output.ts","../src/common/analytics/lib.ts","../src/common/api/lib.ts","../src/common/machine-id/lib.ts","../src/common/middleware/authentication.ts","../src/common/middleware/get-account-param.ts","../src/common/middleware/get-environment-param.ts","../src/common/middleware/get-project-param.ts","../src/common/middleware/logging.ts","../src/common/middleware/user-configuration.ts","../src/common/middleware/user-identification.ts","../src/common/middleware/validate-fleet.ts","../src/common/open-api/constants.ts","../src/common/open-api/index.ts","../src/common/open-api/validation.ts","../src/common/upgraders/lib.ts","../src/common/upgraders/package-json-upgrader.ts","../src/common/upgraders/tsconfig-upgrader.ts","../src/common/upgraders/vscode-settings-json-upgrader.ts","../src/common/utils/box.ts","../src/common/utils/branch.ts","../src/common/utils/ports.ts","../src/common/utils/prefixed-output.ts","../src/common/utils/pretty-print-environment-prompt.ts","../src/common/utils/stringify-config.test.ts","../src/common/utils/stringify-config.ts","../src/common/utils/types.ts","../src/common/utils/urls.ts","../src/common/validators/file-system-validator.ts","../src/common/validators/lib.ts","../src/common/validators/project-name-validator.ts","../src/common/xdg/lib.ts","../src/compile/handler.ts","../src/delete/handler.ts","../src/delete/poll-deployment.ts","../src/deploy/archive.test.ts","../src/deploy/archive.ts","../src/deploy/environments.ts","../src/deploy/file-upload.ts","../src/deploy/handler.ts","../src/deploy/poll-deployment.ts","../src/dev/handler.ts","../src/docs/handler.ts","../src/editor/handler.ts","../src/link/handler.ts","../src/list/handler.ts","../src/login/login.ts","../src/login/tokens.ts","../src/mtls-certificates/models.ts","../src/mtls-certificates/create/handler.ts","../src/mtls-certificates/delete/handler.ts","../src/mtls-certificates/describe/handler.ts","../src/mtls-certificates/disable/handler.ts","../src/mtls-certificates/list/handler.ts","../src/mtls-certificates/update/handler.ts","../src/open-api/convert/convert-engine.spec.ts","../src/open-api/convert/convert-engine.ts","../src/open-api/convert/handler.spec.ts","../src/open-api/convert/handler.ts","../src/open-api/merge/ajv.ts","../src/open-api/merge/handler.spec.ts","../src/open-api/merge/handler.ts","../src/open-api/merge/interfaces.ts","../src/open-api/merge/merge-engine.spec.ts","../src/open-api/merge/merge-engine.ts","../src/open-api/merge/utils.ts","../src/open-api/overlay/handler.spec.ts","../src/open-api/overlay/handler.ts","../src/open-api/overlay/overlay-engine.spec.ts","../src/open-api/overlay/overlay-engine.ts","../src/project/create/handler.ts","../src/proxies/models.ts","../src/proxies/create/handler.ts","../src/proxies/delete/handler.ts","../src/proxies/describe/handler.ts","../src/proxies/update/handler.ts","../src/source/migrate/dev-portal/handler.ts","../src/source/migrate/dev-portal/types.ts","../src/source/update/handler.ts","../src/test/esbuild-config.ts","../src/test/handler.ts","../src/test/invoke-test.ts","../src/test/test-files.test.ts","../src/test/test-files.ts","../src/test/esbuild-plugins/node-test-prep-plugin.ts","../src/tunnel/models.ts","../src/tunnel/create/handler.ts","../src/tunnel/delete/handler.ts","../src/tunnel/delete/poll-teardown-operation.ts","../src/tunnel/describe/handler.ts","../src/tunnel/list/handler.ts","../src/tunnel/rotate-token/handler.ts","../src/tunnel/services/describe/handler.ts","../src/tunnel/services/update/handler.ts","../src/tunnel/services/update/poll-provisioning-operations.ts","../src/variable/models.ts","../src/variable/create/handler.ts","../src/variable/update/handler.ts"],"version":"5.8.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/cli",
|
|
3
|
-
"version": "6.64.
|
|
3
|
+
"version": "6.64.40",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"type": "module",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@opentelemetry/api": "1.9.0",
|
|
30
30
|
"@sentry/node": "9.22.0",
|
|
31
31
|
"@swc/core": "1.10.18",
|
|
32
|
-
"@zuplo/core": "6.64.
|
|
32
|
+
"@zuplo/core": "6.64.40",
|
|
33
33
|
"@zuplo/editor": "~1.0.0",
|
|
34
|
-
"@zuplo/openapi-tools": "6.64.
|
|
35
|
-
"@zuplo/runtime": "6.64.
|
|
34
|
+
"@zuplo/openapi-tools": "6.64.40",
|
|
35
|
+
"@zuplo/runtime": "6.64.40",
|
|
36
36
|
"as-table": "1.0.55",
|
|
37
37
|
"chalk": "5.4.1",
|
|
38
38
|
"chokidar": "3.5.3",
|