@zuplo/cli 1.138.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -64,3 +64,12 @@ Commands:
64
64
  zup variable update Updates an existing variable for a branch
65
65
 
66
66
  ```
67
+
68
+ # Changelog
69
+
70
+ ## v2
71
+
72
+ - Removes the use of Deno's test runner. We now use the built-in test runner in
73
+ Node.js. All features are preserved; however, the output of `zup test` follows
74
+ the Node.js
75
+ [spec reporter](https://nodejs.org/docs/latest-v18.x/api/test.html#test-reporters).
@@ -1,23 +1,24 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f13aec76-f70a-5053-8b92-7e9a9134dbfc")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5c127662-31c6-5178-a683-322b67f8580c")}catch(e){}}();
3
3
  import { TEST_OUT_FOLDER } from "../common/constants.js";
4
- import { denoTestPrepPlugin } from "./esbuild-plugins/deno-test-prep-plugin.js";
4
+ import { nodeTestPrepPlugin } from "./esbuild-plugins/node-test-prep-plugin.js";
5
5
  export function generateBuildOptionsForTest(argv) {
6
6
  return {
7
7
  outdir: `${argv.dir}/${TEST_OUT_FOLDER}`,
8
+ external: ["chai", "dotenv/config", "node:test"],
9
+ platform: "node",
8
10
  bundle: true,
9
11
  treeShaking: true,
10
12
  format: "esm",
11
13
  outExtension: {
12
- ".js": ".ts",
14
+ ".js": ".mjs",
13
15
  },
14
16
  plugins: [
15
- denoTestPrepPlugin(argv, {
17
+ nodeTestPrepPlugin(argv, {
16
18
  "@zuplo/test": "",
17
- chai: "https://cdn.skypack.dev/chai@4.3.4?dts",
18
19
  }),
19
20
  ],
20
21
  };
21
22
  }
22
23
  //# sourceMappingURL=esbuild-config.js.map
23
- //# debugId=f13aec76-f70a-5053-8b92-7e9a9134dbfc
24
+ //# debugId=5c127662-31c6-5178-a683-322b67f8580c
@@ -0,0 +1,65 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c847b970-590a-5cd3-b907-2b9fad49c028")}catch(e){}}();
3
+ export function nodeTestPrepPlugin(argv, options) {
4
+ const aliases = Object.keys(options);
5
+ const re = new RegExp(`^(${aliases.map((x) => escapeRegExp(x)).join("|")})$`);
6
+ return {
7
+ name: "alias",
8
+ setup(build) {
9
+ build.onResolve({ filter: re }, (args) => {
10
+ if (/@zuplo\/test/.test(args.path)) {
11
+ return {
12
+ path: args.path,
13
+ namespace: "zuplo-url",
14
+ };
15
+ }
16
+ else {
17
+ return {
18
+ path: options[args.path],
19
+ namespace: "zuplo-url",
20
+ external: true,
21
+ };
22
+ }
23
+ });
24
+ build.onLoad({ filter: /.*/, namespace: "zuplo-url" }, (args) => {
25
+ if (/@zuplo\/test/.test(args.path)) {
26
+ return { contents: generateTestContents(argv), loader: "ts" };
27
+ }
28
+ });
29
+ },
30
+ };
31
+ }
32
+ function escapeRegExp(value) {
33
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
34
+ }
35
+ function generateTestContents(argv) {
36
+ return `
37
+ import 'dotenv/config'
38
+ import { after, afterEach, describe, it, before, beforeEach } from "node:test"
39
+
40
+ export class TestHelper {
41
+ static get TEST_URL() {
42
+ const url = "${argv.endpoint}";
43
+ if (url !== "undefined") {
44
+ return url;
45
+ }
46
+
47
+ throw new Error("TEST_URL is not set. Pass --endpoint <URL> to \`zuplo test\` on the CLI to set a value.");
48
+ }
49
+
50
+ static get environment() {
51
+ return process.env;
52
+ }
53
+ }
54
+
55
+ const afterAll = after;
56
+ const beforeAll = before;
57
+
58
+ describe.ignore = describe.skip;
59
+ it.ignore = it.skip;
60
+
61
+ export {afterAll, afterEach, beforeAll, beforeEach, describe, it};
62
+ `;
63
+ }
64
+ //# sourceMappingURL=node-test-prep-plugin.js.map
65
+ //# debugId=c847b970-590a-5cd3-b907-2b9fad49c028
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1ca2f9a0-dd2a-5e05-9db2-0a83d26896ad")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="08888ef0-037c-5716-a727-dd52d53a2f00")}catch(e){}}();
3
3
  import fg from "fast-glob";
4
4
  import { rimrafSync } from "rimraf";
5
5
  import { TEST_IN_FOLDER, TEST_OUT_FOLDER } from "../common/constants.js";
@@ -25,4 +25,4 @@ export async function test(argv) {
25
25
  }
26
26
  }
27
27
  //# sourceMappingURL=handler.js.map
28
- //# debugId=1ca2f9a0-dd2a-5e05-9db2-0a83d26896ad
28
+ //# debugId=08888ef0-037c-5716-a727-dd52d53a2f00
@@ -1,28 +1,27 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a86033b8-649a-53cf-9f24-6b9f118258b4")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="91819abd-e850-5b4f-83ac-b91327da0a26")}catch(e){}}();
3
3
  import { execa } from "execa";
4
4
  import { TEST_OUT_FOLDER } from "../common/constants.js";
5
- import { locateDenoExecutable, MissingDenoExecutableError, } from "../common/deno-utils/locator.js";
6
5
  import { logger } from "../common/logger.js";
6
+ class MissingNodeExecutableError extends Error {
7
+ constructor() {
8
+ super("Missing executable: Cannot locate node executable");
9
+ Object.setPrototypeOf(this, MissingNodeExecutableError.prototype);
10
+ }
11
+ }
7
12
  export async function runTests(argv) {
8
- const denoExecutable = await locateDenoExecutable();
9
- if (denoExecutable) {
10
- const args = [
11
- "test",
12
- "--allow-env",
13
- "--allow-net",
14
- "--allow-read=.env,.env.defaults,.env.example,config/",
15
- "--no-check",
16
- ];
13
+ const nodeExecutable = process.platform === "win32" ? "node.exe" : "node";
14
+ if (nodeExecutable) {
15
+ const args = ["--test", "--test-reporter=spec"];
17
16
  if (argv.filter) {
18
- args.push("--filter", argv.filter);
17
+ args.push("--test-name-pattern", argv.filter);
19
18
  }
20
19
  args.push(`${argv.dir}/${TEST_OUT_FOLDER}`);
21
- const denoProcess = execa(denoExecutable, args);
22
- denoProcess.stdout?.pipe(process.stdout);
23
- denoProcess.stderr?.pipe(process.stderr);
20
+ const nodeProcess = execa(nodeExecutable, args);
21
+ nodeProcess.stdout?.pipe(process.stdout);
22
+ nodeProcess.stderr?.pipe(process.stderr);
24
23
  try {
25
- const result = await denoProcess;
24
+ const result = await nodeProcess;
26
25
  return result;
27
26
  }
28
27
  catch (err) {
@@ -31,8 +30,8 @@ export async function runTests(argv) {
31
30
  }
32
31
  }
33
32
  else {
34
- throw new MissingDenoExecutableError();
33
+ throw new MissingNodeExecutableError();
35
34
  }
36
35
  }
37
36
  //# sourceMappingURL=invoke-test.js.map
38
- //# debugId=a86033b8-649a-53cf-9f24-6b9f118258b4
37
+ //# debugId=91819abd-e850-5b4f-83ac-b91327da0a26
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "1.138.0",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/zuplo/cli",
6
6
  "description": "The command-line interface for Zuplo",
@@ -59,7 +59,6 @@
59
59
  "@sentry/node": "7.69.0",
60
60
  "@swc/core": "1.3.78",
61
61
  "@zuplo/core": "5.2458.0",
62
- "@zuplo/deno-bin": "1.37.1",
63
62
  "@zuplo/pino-pretty-configurations": "^1.5.0",
64
63
  "@zuplo/runtime": "5.2458.0",
65
64
  "chalk": "^5.1.2",
@@ -1,29 +0,0 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8edf8105-ebeb-518f-8885-8891eb778b11")}catch(e){}}();
3
- import { existsSync } from "node:fs";
4
- import { dirname, resolve } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import { logger } from "../logger.js";
7
- export class MissingDenoExecutableError extends Error {
8
- constructor() {
9
- super("Missing executable: Cannot locate deno executable");
10
- Object.setPrototypeOf(this, MissingDenoExecutableError.prototype);
11
- }
12
- }
13
- export async function locateDenoExecutable() {
14
- return locateDeno(dirname(fileURLToPath(import.meta.url)));
15
- }
16
- export async function locateDeno(dir) {
17
- const DENO_EXECUTABLE = process.platform === "win32" ? "deno.exe" : "deno";
18
- if (dir === ".") {
19
- return undefined;
20
- }
21
- const pathToDeno = resolve(dir, "node_modules", "@zuplo/deno-bin", "bin", DENO_EXECUTABLE);
22
- if (await existsSync(pathToDeno)) {
23
- logger.debug(`Path to deno: ${pathToDeno}`);
24
- return pathToDeno;
25
- }
26
- return locateDeno(dirname(dir));
27
- }
28
- //# sourceMappingURL=locator.js.map
29
- //# debugId=8edf8105-ebeb-518f-8885-8891eb778b11
@@ -1,99 +0,0 @@
1
-
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="327f255c-47ca-568f-9b06-a3716ca6b328")}catch(e){}}();
3
- export function denoTestPrepPlugin(argv, options) {
4
- const aliases = Object.keys(options);
5
- const re = new RegExp(`^(${aliases.map((x) => escapeRegExp(x)).join("|")})$`);
6
- return {
7
- name: "alias",
8
- setup(build) {
9
- build.onResolve({ filter: re }, (args) => {
10
- if (/@zuplo\/test/.test(args.path)) {
11
- return {
12
- path: args.path,
13
- namespace: "deno-url",
14
- };
15
- }
16
- else {
17
- return {
18
- path: options[args.path],
19
- namespace: "deno-url",
20
- external: true,
21
- };
22
- }
23
- });
24
- build.onLoad({ filter: /.*/, namespace: "deno-url" }, (args) => {
25
- if (/@zuplo\/test/.test(args.path)) {
26
- return { contents: generateTestContents(argv), loader: "ts" };
27
- }
28
- });
29
- },
30
- };
31
- }
32
- function escapeRegExp(value) {
33
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
34
- }
35
- function generateTestContents(argv) {
36
- return `
37
-
38
- // Load environment variables
39
- import { load } from "https://deno.land/std@0.203.0/dotenv/mod.ts";
40
- await load();
41
-
42
- export class TestHelper {
43
- static get TEST_URL() {
44
- const url = "${argv.endpoint}";
45
- if (url !== "undefined") {
46
- return url;
47
- }
48
-
49
- throw new Error("TEST_URL is not set. Pass --endpoint <URL> to \`zuplo test\` on the CLI to set a value.");
50
- }
51
-
52
- static get environment() {
53
- return Deno.env.toObject();
54
- }
55
- }
56
-
57
- import {
58
- afterAll,
59
- afterEach,
60
- beforeAll,
61
- beforeEach,
62
- describe as originalDescribe,
63
- it,
64
- } from "https://deno.land/std@0.203.0/testing/bdd.ts";
65
-
66
- // We want to be able to disable test sanitizers by default to
67
- // make tests easier/more familiar to write.
68
-
69
- function describe<T>(
70
- name: string,
71
- fn: () => void | Promise<void>,
72
- ): TestSuite<T> {
73
- return originalDescribe(name, {
74
- sanitizeExit: false,
75
- sanitizeOps: false,
76
- sanitizeResources: false,
77
- }, fn);
78
- }
79
-
80
- describe.only = function describeOnly<T>(
81
- name: string,
82
- fn: () => void | Promise<void>,
83
- ): TestSuite<T> {
84
- return originalDescribe.only(name, fn);
85
- };
86
-
87
- describe.ignore = function describeIgnore<T>(
88
- name: string,
89
- fn: () => void | Promise<void>,
90
- ): TestSuite<T> {
91
- return originalDescribe.ignore(name, fn);
92
- };
93
-
94
- export {afterAll, afterEach, beforeAll, beforeEach, describe, it};
95
-
96
- `;
97
- }
98
- //# sourceMappingURL=deno-test-prep-plugin.js.map
99
- //# debugId=327f255c-47ca-568f-9b06-a3716ca6b328