@zuplo/cli 6.50.1 → 6.50.4
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/common/constants.d.ts +1 -1
- package/dist/common/constants.d.ts.map +1 -1
- package/dist/common/constants.js +1 -2
- package/dist/common/constants.js.map +1 -1
- package/dist/dev/handler.d.ts +0 -13
- package/dist/dev/handler.d.ts.map +1 -1
- package/dist/dev/handler.js +42 -73
- package/dist/dev/handler.js.map +1 -1
- package/dist/test/esbuild-config.d.ts +1 -1
- package/dist/test/esbuild-config.d.ts.map +1 -1
- package/dist/test/esbuild-config.js +1 -2
- package/dist/test/esbuild-config.js.map +1 -1
- package/dist/test/handler.d.ts +1 -1
- package/dist/test/handler.d.ts.map +1 -1
- package/dist/test/handler.js +6 -50
- package/dist/test/handler.js.map +1 -1
- package/dist/test/invoke-test.d.ts.map +1 -1
- package/dist/test/invoke-test.js +1 -2
- package/dist/test/invoke-test.js.map +1 -1
- package/package.json +4 -4
|
@@ -9,7 +9,7 @@ export declare const MAX_HASH_LENGTH = 7;
|
|
|
9
9
|
export declare const MAX_PRETTY_BRANCH_NAME = 10;
|
|
10
10
|
export declare const ZUPLO_USER_ID_ARGV_KEY = "zuplo-user-id";
|
|
11
11
|
export declare const TEST_IN_FOLDER = "tests";
|
|
12
|
-
export declare const TEST_OUT_FOLDER
|
|
12
|
+
export declare const TEST_OUT_FOLDER = ".zuplo/__tests__";
|
|
13
13
|
export declare const SENTRY_DSN = "https://28220fd3185a1281daff09ade2114dca@o1036703.ingest.sentry.io/4505880249040896";
|
|
14
14
|
export declare const MAX_WAIT_PENDING_TIME_MS = 1000;
|
|
15
15
|
export declare const POST_HOG_CAPTURE_KEY = "phc_LDSwSTOvIjiDDZql2g54Q7xEXoQ0EN9RMYb3STbdz1V";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,wBAAwB,eAAe,CAAC;AACrD,eAAO,MAAM,yBAAyB,QAAQ,CAAC;AAC/C,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAChD,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAGjD,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AACtD,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAGzC,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AAItD,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAGlD,eAAO,MAAM,UAAU,wFACgE,CAAC;AACxF,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAG7C,eAAO,MAAM,oBAAoB,oDACkB,CAAC"}
|
package/dist/common/constants.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
1
|
export const ZUPLO_PREFERRED_JSON_FILE = "zuplo.jsonc";
|
|
3
2
|
export const ZUPLO_FALLBACK_JSON_FILE = "zuplo.json";
|
|
4
3
|
export const ZUPLO_CLI_XDG_FOLDER_NAME = "zup";
|
|
@@ -10,7 +9,7 @@ export const MAX_HASH_LENGTH = 7;
|
|
|
10
9
|
export const MAX_PRETTY_BRANCH_NAME = 10;
|
|
11
10
|
export const ZUPLO_USER_ID_ARGV_KEY = "zuplo-user-id";
|
|
12
11
|
export const TEST_IN_FOLDER = "tests";
|
|
13
|
-
export const TEST_OUT_FOLDER =
|
|
12
|
+
export const TEST_OUT_FOLDER = ".zuplo/__tests__";
|
|
14
13
|
export const SENTRY_DSN = "https://28220fd3185a1281daff09ade2114dca@o1036703.ingest.sentry.io/4505880249040896";
|
|
15
14
|
export const MAX_WAIT_PENDING_TIME_MS = 1000;
|
|
16
15
|
export const POST_HOG_CAPTURE_KEY = "phc_LDSwSTOvIjiDDZql2g54Q7xEXoQ0EN9RMYb3STbdz1V";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,yBAAyB,GAAG,aAAa,CAAC;AACvD,MAAM,CAAC,MAAM,wBAAwB,GAAG,YAAY,CAAC;AACrD,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAC/C,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAC;AAChD,MAAM,CAAC,MAAM,wBAAwB,GAAG,cAAc,CAAC;AACvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAGjD,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAC;AACtD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAGzC,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAC;AAItD,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAGlD,MAAM,CAAC,MAAM,UAAU,GACrB,qFAAqF,CAAC;AACxF,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAG7C,MAAM,CAAC,MAAM,oBAAoB,GAC/B,iDAAiD,CAAC","sourcesContent":["// Configuration\n\nexport const ZUPLO_PREFERRED_JSON_FILE = \"zuplo.jsonc\";\nexport const ZUPLO_FALLBACK_JSON_FILE = \"zuplo.json\";\nexport const ZUPLO_CLI_XDG_FOLDER_NAME = \"zup\";\nexport const ZUPLO_AUTH_FILE_NAME = \"auth.json\";\nexport const ZUPLO_VERSION_CHECK_FILE = \"version.json\";\nexport const ZUPLO_SYSTEM_ENV_VAR = \".env.zuplo\";\n\n// Deployer\nexport const DEPLOYER_METADATA_FILE = \"deployer.json\";\nexport const MAX_HASH_LENGTH = 7;\nexport const MAX_PRETTY_BRANCH_NAME = 10;\n\n// Special keys\nexport const ZUPLO_USER_ID_ARGV_KEY = \"zuplo-user-id\";\n\n// Test\n// Where are the tests located (recursively)\nexport const TEST_IN_FOLDER = \"tests\";\n// Where should we generate the tests\nexport const TEST_OUT_FOLDER = \".zuplo/__tests__\";\n\n// Sentry\nexport const SENTRY_DSN =\n \"https://28220fd3185a1281daff09ade2114dca@o1036703.ingest.sentry.io/4505880249040896\";\nexport const MAX_WAIT_PENDING_TIME_MS = 1000;\n\n// PostHog\nexport const POST_HOG_CAPTURE_KEY =\n \"phc_LDSwSTOvIjiDDZql2g54Q7xEXoQ0EN9RMYb3STbdz1V\";\n"]}
|
package/dist/dev/handler.d.ts
CHANGED
|
@@ -6,17 +6,4 @@ export interface Arguments {
|
|
|
6
6
|
debugPort?: number;
|
|
7
7
|
}
|
|
8
8
|
export declare function dev(argv: Arguments): Promise<void>;
|
|
9
|
-
export declare function runDevServer(argv: {
|
|
10
|
-
dir: string;
|
|
11
|
-
port: number;
|
|
12
|
-
debugPort?: number;
|
|
13
|
-
testMode?: boolean;
|
|
14
|
-
}): Promise<{
|
|
15
|
-
sourceDirectory: string;
|
|
16
|
-
zupPort: number;
|
|
17
|
-
loadedEnvFiles: string[];
|
|
18
|
-
server: {
|
|
19
|
-
stop: () => Promise<void>;
|
|
20
|
-
};
|
|
21
|
-
}>;
|
|
22
9
|
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -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":"AAiBA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,OAAO,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,GAAG,CAAC,IAAI,EAAE,SAAS,iBAgKxC"}
|
package/dist/dev/handler.js
CHANGED
|
@@ -9,54 +9,10 @@ import { isPortAvailable } from "../common/utils/ports.js";
|
|
|
9
9
|
import { handleRuntimeStdio } from "../common/worker-output.js";
|
|
10
10
|
import { ApiServer } from "../editor/server/server.js";
|
|
11
11
|
export async function dev(argv) {
|
|
12
|
-
const { sourceDirectory, zupPort, loadedEnvFiles } = await runDevServer(argv);
|
|
13
|
-
const zupEditorPort = argv.editorPort;
|
|
14
|
-
const isZupEditorPortAvailable = await isPortAvailable("localhost", zupEditorPort);
|
|
15
|
-
if (!isZupEditorPortAvailable) {
|
|
16
|
-
await printCriticalFailureToConsoleAndExit(`Port ${zupEditorPort} is already in use. Please specify a different port using --editor-port.`);
|
|
17
|
-
}
|
|
18
|
-
let editor;
|
|
19
|
-
if (argv["start-editor"]) {
|
|
20
|
-
editor = new ApiServer({
|
|
21
|
-
cliArgs: argv,
|
|
22
|
-
workingDir: sourceDirectory,
|
|
23
|
-
port: argv.editorPort,
|
|
24
|
-
isStandalone: false,
|
|
25
|
-
});
|
|
26
|
-
editor.start().catch((err) => logger.error(err));
|
|
27
|
-
}
|
|
28
|
-
printDiagnosticsToConsole("Started local development setup");
|
|
29
|
-
printDiagnosticsToConsole("Ctrl+C to exit");
|
|
30
|
-
printDiagnosticsToConsole("");
|
|
31
|
-
printDiagnosticsToConsole(`🚀 Zuplo Gateway: http://localhost:${zupPort}`);
|
|
32
|
-
if (argv["start-editor"]) {
|
|
33
|
-
printDiagnosticsToConsole(`📘 Route Designer: http://localhost:${argv.editorPort}`);
|
|
34
|
-
}
|
|
35
|
-
if (loadedEnvFiles.length > 0) {
|
|
36
|
-
printDiagnosticsToConsole(`⚙️ Loaded env files: \n - ${loadedEnvFiles.join(" \n - ")}`);
|
|
37
|
-
}
|
|
38
|
-
printDiagnosticsToConsole("");
|
|
39
|
-
printDiagnosticsToConsole("");
|
|
40
|
-
return new Promise((resolve) => {
|
|
41
|
-
async function exit() {
|
|
42
|
-
printDiagnosticsToConsole("");
|
|
43
|
-
printDiagnosticsToConsole("Stopping local development server...");
|
|
44
|
-
if (argv["start-editor"]) {
|
|
45
|
-
await editor.close();
|
|
46
|
-
}
|
|
47
|
-
resolve();
|
|
48
|
-
}
|
|
49
|
-
process.on("SIGTERM", exit);
|
|
50
|
-
process.on("SIGINT", exit);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
export async function runDevServer(argv) {
|
|
54
|
-
const printMessages = argv.testMode !== true;
|
|
55
12
|
const sourceDirectory = resolve(join(relative(process.cwd(), argv.dir)));
|
|
56
|
-
const buildId = randomUUID();
|
|
57
13
|
const zuploRuntimePath = new URL("../../node_modules/@zuplo/runtime", import.meta.url);
|
|
58
14
|
if (existsSync(zuploRuntimePath)) {
|
|
59
|
-
cpSync(zuploRuntimePath,
|
|
15
|
+
cpSync(zuploRuntimePath, join(sourceDirectory, "node_modules/@zuplo/runtime"), {
|
|
60
16
|
recursive: true,
|
|
61
17
|
dereference: true,
|
|
62
18
|
});
|
|
@@ -76,48 +32,31 @@ export async function runDevServer(argv) {
|
|
|
76
32
|
}
|
|
77
33
|
process.env.ZUPLO_IS_LOCAL_DEVELOPMENT = "true";
|
|
78
34
|
const core = await import("@zuplo/core/cli");
|
|
79
|
-
let buildResult;
|
|
80
|
-
if (argv.testMode) {
|
|
81
|
-
try {
|
|
82
|
-
buildResult = await core.build({
|
|
83
|
-
buildId,
|
|
84
|
-
output: new ConsoleOutput(),
|
|
85
|
-
sourceDirectory,
|
|
86
|
-
command: "test",
|
|
87
|
-
logger,
|
|
88
|
-
deploymentUrl: undefined,
|
|
89
|
-
});
|
|
90
|
-
if (buildResult.status === "Failed") {
|
|
91
|
-
await printCriticalFailureToConsoleAndExit(`Failed to build project. Please check the errors above.`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
catch (err) {
|
|
95
|
-
printDiagnosticsToConsole(`Build error occurred: ${err.message}`);
|
|
96
|
-
}
|
|
97
|
-
printDiagnosticsToConsole(`Starting Developement Server...`);
|
|
98
|
-
}
|
|
99
35
|
const zupPort = argv.port;
|
|
36
|
+
const zupEditorPort = argv.editorPort;
|
|
100
37
|
const zupDebugPort = argv.debugPort;
|
|
101
38
|
const isZupPortAvailable = await isPortAvailable("localhost", zupPort);
|
|
102
39
|
if (!isZupPortAvailable) {
|
|
103
40
|
await printCriticalFailureToConsoleAndExit(`Port ${zupPort} is already in use. Please specify a different port using --port.`);
|
|
104
41
|
}
|
|
42
|
+
const isZupEditorPortAvailable = await isPortAvailable("localhost", zupEditorPort);
|
|
43
|
+
if (!isZupEditorPortAvailable) {
|
|
44
|
+
await printCriticalFailureToConsoleAndExit(`Port ${zupEditorPort} is already in use. Please specify a different port using --editor-port.`);
|
|
45
|
+
}
|
|
105
46
|
if (zupDebugPort) {
|
|
106
47
|
const isZupDebugPortAvailable = await isPortAvailable("localhost", zupDebugPort);
|
|
107
48
|
if (!isZupDebugPortAvailable) {
|
|
108
49
|
await printCriticalFailureToConsoleAndExit(`Port ${zupDebugPort} is already in use. Please specify a different port using --debug-port.`);
|
|
109
50
|
}
|
|
110
51
|
}
|
|
52
|
+
const buildId = randomUUID();
|
|
111
53
|
let firstLoad = true;
|
|
112
|
-
|
|
54
|
+
await core.startDevServer({
|
|
113
55
|
buildId,
|
|
114
56
|
output: new ConsoleOutput(),
|
|
115
57
|
sourceDirectory,
|
|
116
58
|
port: zupPort,
|
|
117
59
|
debugPort: argv.debugPort ?? undefined,
|
|
118
|
-
testMode: argv.testMode,
|
|
119
|
-
metafile: buildResult?.metafile,
|
|
120
|
-
compatibilityDate: buildResult?.compatibilityDate,
|
|
121
60
|
publicZuploEnvironmentVariables: envZuplo
|
|
122
61
|
? {
|
|
123
62
|
ZUPLO_ACCOUNT_NAME: envZuplo.ZUPLO_ACCOUNT_NAME,
|
|
@@ -132,14 +71,44 @@ export async function runDevServer(argv) {
|
|
|
132
71
|
if (firstLoad) {
|
|
133
72
|
firstLoad = false;
|
|
134
73
|
}
|
|
135
|
-
else
|
|
74
|
+
else {
|
|
136
75
|
printDiagnosticsToConsole("Code changed. Server reloaded...");
|
|
137
76
|
}
|
|
138
77
|
},
|
|
139
78
|
});
|
|
140
|
-
|
|
141
|
-
|
|
79
|
+
let editor;
|
|
80
|
+
if (argv["start-editor"]) {
|
|
81
|
+
editor = new ApiServer({
|
|
82
|
+
cliArgs: argv,
|
|
83
|
+
workingDir: sourceDirectory,
|
|
84
|
+
port: argv.editorPort,
|
|
85
|
+
isStandalone: false,
|
|
86
|
+
});
|
|
87
|
+
editor.start().catch((err) => logger.error(err));
|
|
88
|
+
}
|
|
89
|
+
printDiagnosticsToConsole("Started local development setup");
|
|
90
|
+
printDiagnosticsToConsole("Ctrl+C to exit");
|
|
91
|
+
printDiagnosticsToConsole("");
|
|
92
|
+
printDiagnosticsToConsole(`🚀 Zuplo Gateway: http://localhost:${zupPort}`);
|
|
93
|
+
if (argv["start-editor"]) {
|
|
94
|
+
printDiagnosticsToConsole(`📘 Route Designer: http://localhost:${argv.editorPort}`);
|
|
142
95
|
}
|
|
143
|
-
|
|
96
|
+
if (loadedEnvFiles.length > 0) {
|
|
97
|
+
printDiagnosticsToConsole(`⚙️ Loaded env files: \n - ${loadedEnvFiles.join(" \n - ")}`);
|
|
98
|
+
}
|
|
99
|
+
printDiagnosticsToConsole("");
|
|
100
|
+
printDiagnosticsToConsole("");
|
|
101
|
+
return new Promise((resolve) => {
|
|
102
|
+
async function exit() {
|
|
103
|
+
printDiagnosticsToConsole("");
|
|
104
|
+
printDiagnosticsToConsole("Stopping local development server...");
|
|
105
|
+
if (argv["start-editor"]) {
|
|
106
|
+
await editor.close();
|
|
107
|
+
}
|
|
108
|
+
resolve();
|
|
109
|
+
}
|
|
110
|
+
process.on("SIGTERM", exit);
|
|
111
|
+
process.on("SIGINT", exit);
|
|
112
|
+
});
|
|
144
113
|
}
|
|
145
114
|
//# 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":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,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;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAUvD,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAe;IACvC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;IAE9E,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC;IACtC,MAAM,wBAAwB,GAAG,MAAM,eAAe,CACpD,WAAW,EACX,aAAa,CACd,CAAC;IACF,IAAI,CAAC,wBAAwB,EAAE,CAAC;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ync, readFileSync } from \"node:fs\";\nimport { join, relative, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { BuildResult } from \"@zuplo/types\";\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\";\nimport { ApiServer } from \"../editor/server/server.js\";\n\nexport interface Arguments {\n dir: string;\n \"start-editor\": boolean;\n port: number;\n editorPort: number;\n debugPort?: number;\n}\n\nexport async function dev(argv: Arguments) {\n const { sourceDirectory, zupPort, loadedEnvFiles } = await runDevServer(argv);\n\n const zupEditorPort = argv.editorPort;\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 let editor: ApiServer;\n if (argv[\"start-editor\"]) {\n editor = new ApiServer({\n cliArgs: argv,\n workingDir: sourceDirectory,\n port: argv.editorPort,\n isStandalone: false,\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 // eslint-disable-next-line @typescript-eslint/no-misused-promises\n process.on(\"SIGTERM\", exit);\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n process.on(\"SIGINT\", exit);\n });\n}\n\nexport async function runDevServer(argv: {\n dir: string;\n port: number;\n debugPort?: number;\n testMode?: boolean;\n}): Promise<{\n sourceDirectory: string;\n zupPort: number;\n loadedEnvFiles: string[];\n server: { stop: () => Promise<void> };\n}> {\n const printMessages = argv.testMode !== true;\n const sourceDirectory = resolve(join(relative(process.cwd(), argv.dir)));\n const buildId = randomUUID();\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 // 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 new URL(\"./node_modules/@zuplo/runtime\", sourceDirectory),\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 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 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 let buildResult: BuildResult | undefined;\n // If we are in test mode, we need to build the project\n if (argv.testMode) {\n try {\n buildResult = await core.build({\n buildId,\n output: new ConsoleOutput(),\n sourceDirectory,\n command: \"test\",\n logger,\n deploymentUrl: undefined,\n });\n if (buildResult.status === \"Failed\") {\n await printCriticalFailureToConsoleAndExit(\n `Failed to build project. Please check the errors above.`\n );\n }\n } catch (err) {\n printDiagnosticsToConsole(`Build error occurred: ${err.message}`);\n }\n\n printDiagnosticsToConsole(`Starting Developement Server...`);\n }\n\n const zupPort = argv.port;\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 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 let firstLoad = true;\n\n const server = await core.startDevServer({\n buildId,\n output: new ConsoleOutput(),\n sourceDirectory,\n port: zupPort,\n debugPort: argv.debugPort ?? undefined,\n testMode: argv.testMode,\n metafile: buildResult?.metafile,\n compatibilityDate: buildResult?.compatibilityDate,\n publicZuploEnvironmentVariables: envZuplo\n ? {\n ZUPLO_ACCOUNT_NAME: envZuplo.ZUPLO_ACCOUNT_NAME,\n ZUPLO_PROJECT_NAME: envZuplo.ZUPLO_PROJECT_NAME,\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 if (printMessages) {\n printDiagnosticsToConsole(\"Code changed. Server reloaded...\");\n }\n },\n });\n\n if (argv.testMode) {\n printDiagnosticsToConsole(`Development Server started...`);\n }\n\n return { sourceDirectory, zupPort, loadedEnvFiles, server };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/dev/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,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,oCAAoC,EACpC,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAUvD,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAe;IACvC,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAMzE,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,IAAI,CAAC,eAAe,EAAE,6BAA6B,CAAC,EACpD;YACE,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,I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C,CAAC;QACH,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACnD,CAAC;IAED,yBAAyB,CAAC,iCAAiC,CAAC,CAAC;IAC7D,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;IAC5C,yBAAyB,CAAC,EAAE,CAAC,CAAC;IAC9B,yBAAyB,CAAC,sCAAsC,OAAO,EAAE,CAAC,CAAC;IAC3E,IAAI,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;QACzB,yBAAyB,CACvB,uCAAuC,IAAI,CAAC,UAAU,EAAE,CACzD,CAAC;IACJ,CAAC;IACD,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,yBAAyB,CACvB,iCAAiC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CACpE,CAAC;IACJ,CAAC;IACD,yBAAyB,CAAC,EAAE,CAAC,CAAC;IAC9B,yBAAyB,CAAC,EAAE,CAAC,CAAC;IAE9B,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACnC,KAAK,UAAU,IAAI;YACjB,yBAAyB,CAAC,EAAE,CAAC,CAAC;YAC9B,yBAAyB,CAAC,sCAAsC,CAAC,CAAC;YAElE,IAAI,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC;gBACzB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;YACvB,CAAC;YACD,OAAO,EAAE,CAAC;QACZ,CAAC;QAGD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAE5B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable node/no-process-env */\n\nimport { randomUUID } from \"node:crypto\";\nimport { cpSync, existsSync, readFileSync } from \"node:fs\";\nimport { join, relative, 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} from \"../common/output.js\";\nimport { isPortAvailable } from \"../common/utils/ports.js\";\nimport { handleRuntimeStdio } from \"../common/worker-output.js\";\nimport { ApiServer } from \"../editor/server/server.js\";\n\nexport interface Arguments {\n dir: string;\n \"start-editor\": boolean;\n port: number;\n editorPort: number;\n debugPort?: number;\n}\n\nexport async function dev(argv: Arguments) {\n const sourceDirectory = resolve(join(relative(process.cwd(), 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 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 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 ?? undefined,\n publicZuploEnvironmentVariables: envZuplo\n ? {\n ZUPLO_ACCOUNT_NAME: envZuplo.ZUPLO_ACCOUNT_NAME,\n ZUPLO_PROJECT_NAME: envZuplo.ZUPLO_PROJECT_NAME,\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: ApiServer;\n\n if (argv[\"start-editor\"]) {\n editor = new ApiServer({\n cliArgs: argv,\n workingDir: sourceDirectory,\n port: argv.editorPort,\n isStandalone: false,\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 // eslint-disable-next-line @typescript-eslint/no-misused-promises\n process.on(\"SIGTERM\", exit);\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n process.on(\"SIGINT\", exit);\n });\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BuildOptions } from "esbuild";
|
|
2
2
|
import { Arguments } from "./handler.js";
|
|
3
|
-
export declare function generateBuildOptionsForTest(argv:
|
|
3
|
+
export declare function generateBuildOptionsForTest(argv: Arguments): BuildOptions;
|
|
4
4
|
//# sourceMappingURL=esbuild-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-config.d.ts","sourceRoot":"","sources":["../../src/test/esbuild-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"esbuild-config.d.ts","sourceRoot":"","sources":["../../src/test/esbuild-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,CAsBzE"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
1
|
import { TEST_OUT_FOLDER } from "../common/constants.js";
|
|
3
2
|
import { nodeTestPrepPlugin } from "./esbuild-plugins/node-test-prep-plugin.js";
|
|
4
3
|
export function generateBuildOptionsForTest(argv) {
|
|
5
4
|
return {
|
|
6
|
-
outdir:
|
|
5
|
+
outdir: `${argv.dir}/${TEST_OUT_FOLDER}`,
|
|
7
6
|
external: ["chai", "dotenv/config", "node:test"],
|
|
8
7
|
platform: "node",
|
|
9
8
|
sourcemap: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-config.js","sourceRoot":"","sources":["../../src/test/esbuild-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"esbuild-config.js","sourceRoot":"","sources":["../../src/test/esbuild-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAGhF,MAAM,UAAU,2BAA2B,CAAC,IAAe;IACzD,OAAO;QAEL,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,eAAe,EAAE;QACxC,QAAQ,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,WAAW,CAAC;QAChD,QAAQ,EAAE,MAAM;QAChB,SAAS,EAAE,IAAI;QACf,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI;QAEjB,MAAM,EAAE,KAAK;QAEb,YAAY,EAAE;YACZ,KAAK,EAAE,MAAM;SACd;QAED,OAAO,EAAE;YACP,kBAAkB,CAAC,IAAI,EAAE;gBACvB,aAAa,EAAE,EAAE;aAClB,CAAC;SACH;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { BuildOptions } from \"esbuild\";\nimport { TEST_OUT_FOLDER } from \"../common/constants.js\";\nimport { nodeTestPrepPlugin } from \"./esbuild-plugins/node-test-prep-plugin.js\";\nimport { Arguments } from \"./handler.js\";\n\nexport function generateBuildOptionsForTest(argv: Arguments): BuildOptions {\n return {\n // Put it under the .zuplo folder\n outdir: `${argv.dir}/${TEST_OUT_FOLDER}`,\n external: [\"chai\", \"dotenv/config\", \"node:test\"],\n platform: \"node\",\n sourcemap: true,\n bundle: true,\n treeShaking: true,\n // The format needs to be esm for Deno to work with it\n format: \"esm\",\n // Let's keep the extension as .ts since that is what Deno runs\n outExtension: {\n \".js\": \".mjs\",\n },\n // Here is our own plug-in to shim the responses\n plugins: [\n nodeTestPrepPlugin(argv, {\n \"@zuplo/test\": \"\",\n }),\n ],\n };\n}\n"]}
|
package/dist/test/handler.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/test/handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/test/handler.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,SAAS,iBAwBzC"}
|
package/dist/test/handler.js
CHANGED
|
@@ -1,69 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { scheduler } from "node:timers/promises";
|
|
3
|
-
import esbuild, { formatMessages } from "esbuild";
|
|
1
|
+
import esbuild from "esbuild";
|
|
4
2
|
import fg from "fast-glob";
|
|
5
3
|
import { rimrafSync } from "rimraf";
|
|
6
4
|
import { TEST_IN_FOLDER, TEST_OUT_FOLDER } from "../common/constants.js";
|
|
7
5
|
import { logger } from "../common/logger.js";
|
|
8
|
-
import { printCriticalFailureToConsoleAndExit } from "../common/output.js";
|
|
9
|
-
import { runDevServer } from "../dev/handler.js";
|
|
10
6
|
import { generateBuildOptionsForTest } from "./esbuild-config.js";
|
|
11
7
|
import { runTests } from "./invoke-test.js";
|
|
12
8
|
export async function test(argv) {
|
|
13
9
|
rimrafSync(`${argv.dir}/${TEST_OUT_FOLDER}`);
|
|
14
|
-
const testFiles = fg.sync(join(argv.dir, TEST_IN_FOLDER, "**", "*.test.ts"));
|
|
15
|
-
logger.debug(`Found ${testFiles.length} test files in ${join(argv.dir, TEST_IN_FOLDER)}`);
|
|
16
10
|
const result = await esbuild.build({
|
|
17
|
-
...generateBuildOptionsForTest(
|
|
18
|
-
|
|
19
|
-
...argv,
|
|
20
|
-
}),
|
|
21
|
-
entryPoints: testFiles,
|
|
11
|
+
...generateBuildOptionsForTest(argv),
|
|
12
|
+
entryPoints: fg.sync(`${argv.dir}/${TEST_IN_FOLDER}/**/*.test.ts`),
|
|
22
13
|
});
|
|
23
|
-
logger.debug(result);
|
|
24
14
|
if (result.warnings.length > 0) {
|
|
25
15
|
logger.debug(result.warnings);
|
|
26
|
-
const formattedMessages = await formatMessages(result.errors, {
|
|
27
|
-
kind: "warning",
|
|
28
|
-
});
|
|
29
|
-
console.log(formattedMessages);
|
|
30
16
|
}
|
|
31
17
|
if (result.errors.length > 0) {
|
|
32
|
-
logger.error(`Failed to build the test files in ${argv.dir}/${TEST_IN_FOLDER}`);
|
|
33
|
-
const formattedMessages = await formatMessages(result.errors, {
|
|
34
|
-
kind: "error",
|
|
35
|
-
});
|
|
36
|
-
console.log(formattedMessages);
|
|
37
|
-
await printCriticalFailureToConsoleAndExit(`Failed to build the test files in ${argv.dir}/${TEST_IN_FOLDER}`);
|
|
18
|
+
logger.error(result.errors, `Failed to build the test files in ${argv.dir}/${TEST_IN_FOLDER}`);
|
|
38
19
|
}
|
|
39
20
|
else {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
if (!argv.endpoint) {
|
|
44
|
-
try {
|
|
45
|
-
const result = await runDevServer({
|
|
46
|
-
dir: argv.dir,
|
|
47
|
-
port: 9000,
|
|
48
|
-
testMode: true,
|
|
49
|
-
});
|
|
50
|
-
server = result.server;
|
|
51
|
-
}
|
|
52
|
-
catch (err) {
|
|
53
|
-
logger.error(err);
|
|
54
|
-
await printCriticalFailureToConsoleAndExit("Failed to start dev server");
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const testResult = await runTests(argv);
|
|
58
|
-
exitCode = testResult.exitCode;
|
|
59
|
-
}
|
|
60
|
-
finally {
|
|
61
|
-
if (server) {
|
|
62
|
-
await server.stop();
|
|
63
|
-
}
|
|
64
|
-
await scheduler.wait(40000);
|
|
65
|
-
process.exit(exitCode);
|
|
66
|
-
}
|
|
21
|
+
const { exitCode } = await runTests(argv);
|
|
22
|
+
process.exit(exitCode);
|
|
67
23
|
}
|
|
68
24
|
}
|
|
69
25
|
//# sourceMappingURL=handler.js.map
|
package/dist/test/handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/test/handler.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/test/handler.ts"],"names":[],"mappings":"AAAA,OAAO,OAAwB,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQ5C,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAe;IAExC,UAAU,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,eAAe,EAAE,CAAC,CAAC;IAG7C,MAAM,MAAM,GAAgB,MAAM,OAAO,CAAC,KAAK,CAAC;QAC9C,GAAG,2BAA2B,CAAC,IAAI,CAAC;QACpC,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,cAAc,eAAe,CAAC;KACnE,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,CAAC,KAAK,CACV,MAAM,CAAC,MAAM,EACb,qCAAqC,IAAI,CAAC,GAAG,IAAI,cAAc,EAAE,CAClE,CAAC;IACJ,CAAC;SAAM,CAAC;QAEN,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC1C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["import esbuild, { BuildResult } from \"esbuild\";\nimport fg from \"fast-glob\";\nimport { rimrafSync } from \"rimraf\";\nimport { TEST_IN_FOLDER, TEST_OUT_FOLDER } from \"../common/constants.js\";\nimport { logger } from \"../common/logger.js\";\nimport { generateBuildOptionsForTest } from \"./esbuild-config.js\";\nimport { runTests } from \"./invoke-test.js\";\n\nexport interface Arguments {\n dir: string;\n endpoint: string;\n filter: string;\n}\n\nexport async function test(argv: Arguments) {\n // 1. Clean out the folder\n rimrafSync(`${argv.dir}/${TEST_OUT_FOLDER}`);\n\n // 2. Build the test files\n const result: BuildResult = await esbuild.build({\n ...generateBuildOptionsForTest(argv),\n entryPoints: fg.sync(`${argv.dir}/${TEST_IN_FOLDER}/**/*.test.ts`),\n });\n\n if (result.warnings.length > 0) {\n logger.debug(result.warnings);\n }\n\n if (result.errors.length > 0) {\n logger.error(\n result.errors,\n `Failed to build the test files in ${argv.dir}/${TEST_IN_FOLDER}`\n );\n } else {\n // 3. Run `node test`\n const { exitCode } = await runTests(argv);\n process.exit(exitCode);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke-test.d.ts","sourceRoot":"","sources":["../../src/test/invoke-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAS,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"invoke-test.d.ts","sourceRoot":"","sources":["../../src/test/invoke-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAS,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC,CAkCpD"}
|
package/dist/test/invoke-test.js
CHANGED
|
@@ -27,8 +27,7 @@ export async function runTests(argv) {
|
|
|
27
27
|
return result;
|
|
28
28
|
}
|
|
29
29
|
catch (err) {
|
|
30
|
-
|
|
31
|
-
logger.debug(message);
|
|
30
|
+
logger.debug(err);
|
|
32
31
|
return { exitCode: err.exitCode };
|
|
33
32
|
}
|
|
34
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke-test.js","sourceRoot":"","sources":["../../src/test/invoke-test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,MAAM,0BAA2B,SAAQ,KAAK;IAC5C;QACE,KAAK,CAAC,mDA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,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;YACjC,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YAGb,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClB,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC;QACpC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,0BAA0B,EAAE,CAAC;IACzC,CAAC;AACH,CAAC","sourcesContent":["import { ExecaReturnBase, execa } from \"execa\";\nimport { TEST_OUT_FOLDER } from \"../common/constants.js\";\nimport { logger } from \"../common/logger.js\";\nimport { Arguments } from \"./handler.js\";\n\nclass MissingNodeExecutableError extends Error {\n constructor() {\n super(\"Missing executable: Cannot locate node executable\");\n Object.setPrototypeOf(this, MissingNodeExecutableError.prototype);\n }\n}\n\nexport async function runTests(\n argv: Arguments\n): Promise<Pick<ExecaReturnBase<string>, \"exitCode\">> {\n // Assume that \"node\" is in the path\n const nodeExecutable = process.platform === \"win32\" ? \"node.exe\" : \"node\";\n if (nodeExecutable) {\n const args = [\"--test\", \"--test-reporter=spec\", \"--enable-source-maps\"];\n if (argv.filter) {\n args.push(\"--test-name-pattern\", argv.filter);\n }\n\n // Check Node.js version to determine glob pattern\n // See https://github.com/nodejs/node/pull/47653#issuecomment-1692984053\n const nodeVersion = parseInt(process.versions.node.split(\".\")[0], 10);\n const globPattern =\n nodeVersion >= 21\n ? `${argv.dir}/${TEST_OUT_FOLDER}/**/*.test.mjs`\n : `${argv.dir}/${TEST_OUT_FOLDER}`;\n\n args.push(globPattern);\n\n const nodeProcess = execa(nodeExecutable, args);\n nodeProcess.stdout?.pipe(process.stdout);\n nodeProcess.stderr?.pipe(process.stderr);\n try {\n const result = await nodeProcess;\n return result;\n } catch (err) {\n // We do not want to output the err by default since it could be a test failure\n // Test failures are already reported by piping stdout and stderr above\n logger.debug(err);\n return { exitCode: err.exitCode };\n }\n } else {\n throw new MissingNodeExecutableError();\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/cli",
|
|
3
|
-
"version": "6.50.
|
|
3
|
+
"version": "6.50.4",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"type": "module",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"@opentelemetry/api": "^1.8.0",
|
|
30
30
|
"@sentry/node": "^9.10.0",
|
|
31
31
|
"@swc/core": "1.10.18",
|
|
32
|
-
"@zuplo/core": "^6.50.
|
|
33
|
-
"@zuplo/openapi-tools": "^6.50.
|
|
34
|
-
"@zuplo/runtime": "^6.50.
|
|
32
|
+
"@zuplo/core": "^6.50.4",
|
|
33
|
+
"@zuplo/openapi-tools": "^6.50.4",
|
|
34
|
+
"@zuplo/runtime": "^6.50.4",
|
|
35
35
|
"as-table": "^1.0.55",
|
|
36
36
|
"chalk": "^5.3.0",
|
|
37
37
|
"chokidar": "^3.5.3",
|