@zuplo/cli 6.50.12 → 6.50.13

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 CHANGED
@@ -46,7 +46,7 @@ if (gte(process.versions.node, MIN_NODE_VERSION)) {
46
46
  }
47
47
  await warnNodeVersion(cliVersion, RECOMMENDED_NODE_VERSION);
48
48
  if (os.platform() === "win32") {
49
- printWarningToConsole("The Zuplo CLI is not supported on Windows. We recommend using Windows Subsystem for Linux (WSL).");
49
+ printWarningToConsole("Running the Zuplo CLI on Windows is currently in beta. Please report any issues to support@zuplo.com.");
50
50
  }
51
51
  undici.setGlobalDispatcher(undici.getGlobalDispatcher().compose((dispatch) => {
52
52
  return (opts, handler) => {
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;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAKhB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,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;AAC7B,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,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,MAAM,MAAM,kBAAk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C;IACN,MAAM,oCAAoC,CACxC,4CAA4C,gBAAgB,oBAAoB,OAAO,CAAC,QAAQ,CAAC,IAAI;;oFAErB,CACjF,CAAC;AACJ,CAAC","sourcesContent":["import * as dotenv from \"dotenv\";\ndotenv.config();\n\n// Undici must be imported first to set the global dispatcher\n// If fetch is used before undici, the process will crash\n// eslint-disable-next-line import/no-duplicates\nimport undici from \"undici\";\n\nimport { readFileSync } from \"node:fs\";\nimport os from \"node:os\";\nimport { fileURLToPath } from \"node:url\";\nimport { confirm } from \"@inquirer/prompts\";\nimport * as Sentry from \"@sentry/node\";\nimport { gte } from \"semver\";\nimport { hideBin } from \"yargs/helpers\";\nimport yargs from \"yargs/yargs\";\nimport build from \"./cmds/build.js\";\nimport compile from \"./cmds/compile.js\";\nimport convert from \"./cmds/convert.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 project from \"./cmds/project/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 { warnIfOutdatedVersion, warnNodeVersion } from \"./common/outdated.js\";\nimport {\n printCriticalFailureToConsoleAndExit,\n printWarningToConsole,\n} from \"./common/output.js\";\n\n// This allows us to stop the CLI from executing so we can connect the profiler\n// eslint-disable-next-line node/no-process-env\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 if (os.platform() === \"win32\") {\n printWarningToConsole(\n \"The Zuplo CLI is not supported on Windows. We recommend using Windows Subsystem for Linux (WSL).\"\n );\n }\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 // eslint-disable-next-line node/no-process-env\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 .command(compile)\n .command(convert)\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(project)\n .command(tunnel)\n .command(variable)\n .command(build)\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;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAKhB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,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;AAC7B,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,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,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,IAAI;;oFAErB,CACjF,CAAC;AACJ,CAAC","sourcesContent":["import * as dotenv from \"dotenv\";\ndotenv.config();\n\n// Undici must be imported first to set the global dispatcher\n// If fetch is used before undici, the process will crash\n// eslint-disable-next-line import/no-duplicates\nimport undici from \"undici\";\n\nimport { readFileSync } from \"node:fs\";\nimport os from \"node:os\";\nimport { fileURLToPath } from \"node:url\";\nimport { confirm } from \"@inquirer/prompts\";\nimport * as Sentry from \"@sentry/node\";\nimport { gte } from \"semver\";\nimport { hideBin } from \"yargs/helpers\";\nimport yargs from \"yargs/yargs\";\nimport build from \"./cmds/build.js\";\nimport compile from \"./cmds/compile.js\";\nimport convert from \"./cmds/convert.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 project from \"./cmds/project/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 { warnIfOutdatedVersion, warnNodeVersion } from \"./common/outdated.js\";\nimport {\n printCriticalFailureToConsoleAndExit,\n printWarningToConsole,\n} from \"./common/output.js\";\n\n// This allows us to stop the CLI from executing so we can connect the profiler\n// eslint-disable-next-line node/no-process-env\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 if (os.platform() === \"win32\") {\n printWarningToConsole(\n \"Running the Zuplo CLI on Windows is currently in beta. Please report any issues to support@zuplo.com.\"\n );\n }\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 // eslint-disable-next-line node/no-process-env\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 .command(compile)\n .command(convert)\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(project)\n .command(tunnel)\n .command(variable)\n .command(build)\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 +1 @@
1
- {"version":3,"file":"file-system-validator.d.ts","sourceRoot":"","sources":["../../../src/common/validators/file-system-validator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGtE,qBAAa,mCAAoC,SAAQ,KAAK;;CAO7D;AAED,qBAAa,gBAAiB,SAAQ,KAAK;;CAK1C;AAED,qBAAa,gBAAiB,SAAQ,KAAK;;CAO1C;AAED,qBAAa,wBAAyB,SAAQ,KAAK;;CAOlD;AAED,qBAAa,YAAa,SAAQ,KAAK;;CAOtC;AAED,qBAAa,eAAgB,SAAQ,KAAK;;CAOzC;AAED,qBAAa,0BACX,YAAW,cAAc,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;IAEpC,QAAQ,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAazD;AAMD,qBAAa,+BACX,YAAW,cAAc,CAAC;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;IAEpC,QAAQ,CAAC,MAAM,EAAE;QACrB,GAAG,EAAE,MAAM,CAAC;QACZ,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;KACjC,GAAG,OAAO,CAAC,MAAM,CAAC;CA0BpB;AAED,qBAAa,kBAAmB,YAAW,cAAc,CAAC;IAAE,GAA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SAAS;iBACd,MAAM,GAAG,SAAS;EAKhC,CAAC;AAEF,eAAO,MAAM,2BAA2B;SACjC,MAAM;EACuD,CAAC"}
@@ -1,8 +1,7 @@
1
1
  import { existsSync, readdirSync } from "node:fs";
2
- import { join } from "node:path";
3
- import fg from "fast-glob";
2
+ import path from "node:path";
4
3
  import { simpleGit } from "simple-git";
5
- import { TEST_IN_FOLDER } from "../constants.js";
4
+ import { findTestFiles } from "../../test/test-files.js";
6
5
  import { CompositeValidator } from "./lib.js";
7
6
  import { ProjectIsSetValidator } from "./project-name-validator.js";
8
7
  export class GitBranchOrEnvironmentRequiredError extends Error {
@@ -124,8 +123,9 @@ export class ZuploProjectValidator {
124
123
  async validate(options) {
125
124
  const { dir } = options;
126
125
  try {
127
- if (existsSync(`${dir}/config`)) {
128
- const files = readdirSync(join(dir, "config"));
126
+ const dirPath = path.join(path.normalize(dir), "config");
127
+ if (existsSync(dirPath)) {
128
+ const files = readdirSync(dirPath);
129
129
  const existingOASFiles = files.filter((file) => file.endsWith(".oas.json")).length >= 1;
130
130
  if (existingOASFiles === true) {
131
131
  return { ok: true };
@@ -148,7 +148,7 @@ export class ZuploProjectHasTestsValidator {
148
148
  async validate(option) {
149
149
  const { dir } = option;
150
150
  try {
151
- if (fg.sync(`${dir}/${TEST_IN_FOLDER}/**/*.test.ts`).length >= 1) {
151
+ if (findTestFiles(dir).length >= 1) {
152
152
  return { ok: true };
153
153
  }
154
154
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"file-system-validator.js","sourceRoot":"","sources":["../../../src/common/validators/file-system-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,C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IAAI,qBAAqB,EAAE,EAC3B,IAAI,+BAA+B,EAAE,CACtC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,kBAAkB,CAE9D,IAAI,qBAAqB,EAAE,EAAE,IAAI,6BAA6B,EAAE,CAAC,CAAC","sourcesContent":["import { existsSync, readdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport fg from \"fast-glob\";\nimport { simpleGit } from \"simple-git\";\nimport { TEST_IN_FOLDER } from \"../constants.js\";\nimport { CompositeValidator, Result, ValidationRule } from \"./lib.js\";\nimport { ProjectIsSetValidator } from \"./project-name-validator.js\";\n\nexport class GitBranchOrEnvironmentRequiredError extends Error {\n constructor() {\n super(\n \"Invalid arguments: The project directory is not a Git repository, you must specify the `environment` argument.\"\n );\n Object.setPrototypeOf(this, NotAGitRepoError.prototype);\n }\n}\n\nexport class NotAGitRepoError extends Error {\n constructor() {\n super(\"Invalid directory: The project directory is not a Git repository.\");\n Object.setPrototypeOf(this, NotAGitRepoError.prototype);\n }\n}\n\nexport class NotAZuploProject extends Error {\n constructor() {\n super(\n \"Invalid directory: The project directory is not the root of a Zuplo project.\"\n );\n Object.setPrototypeOf(this, NotAZuploProject.prototype);\n }\n}\n\nexport class ZuploProjectMissingTests extends Error {\n constructor() {\n super(\n \"Invalid directory: The project directory does not contain any tests (*.test.ts) in the /tests folder. Create a at least one test of the form some-name.test.ts\"\n );\n Object.setPrototypeOf(this, ZuploProjectMissingTests.prototype);\n }\n}\n\nexport class NoGitCommits extends Error {\n constructor() {\n super(\n \"Invalid Git state: The project directory does not contain any commits. Make a commit before deploying.\"\n );\n Object.setPrototypeOf(this, NoGitCommits.prototype);\n }\n}\n\nexport class NotOnAGitBranch extends Error {\n constructor() {\n super(\n \"Invalid Git state: You are not on a branch. Run `git checkout -b <branch-name>` to create a new branch.\"\n );\n Object.setPrototypeOf(this, NotOnAGitBranch.prototype);\n }\n}\n\nexport class GitVersionControlValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n await simpleGit({ baseDir: dir }).status();\n return { ok: true };\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_err) {\n return {\n ok: false,\n error: new NotAGitRepoError(),\n };\n }\n }\n}\n\n/**\n * Checks if either the current branch is set as the environment or if\n * the environment is explicitly set\n */\nexport class GitBranchOrEnvironmentValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: {\n dir: string;\n environment: string | undefined;\n }): Promise<Result> {\n const { dir, environment } = option;\n if (typeof environment === \"string\") {\n return {\n ok: true,\n };\n }\n try {\n if (await simpleGit({ baseDir: dir }).checkIsRepo()) {\n await simpleGit({ baseDir: dir }).status();\n const git = simpleGit({ baseDir: dir });\n const branch = await git.branch();\n if (branch.current) {\n return {\n ok: true,\n };\n }\n }\n } catch {\n // Ignore\n }\n return {\n ok: false,\n error: new GitBranchOrEnvironmentRequiredError(),\n };\n }\n}\n\nexport class GitCommitValidator implements ValidationRule<{ dir: string }> {\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n const git = simpleGit({ baseDir: dir });\n const commits = await git.log({ maxCount: 1 });\n if (commits.total === 0) {\n return {\n ok: false,\n error: new NoGitCommits(),\n };\n }\n return { ok: true };\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_err) {\n return {\n ok: false,\n error: new NoGitCommits(),\n };\n }\n }\n}\n\nexport class GitBranchValidator implements ValidationRule<{ dir: string }> {\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n const git = simpleGit({ baseDir: dir });\n const branch = await git.branch();\n if (!branch.current) {\n return {\n ok: false,\n error: new NotOnAGitBranch(),\n };\n }\n\n return { ok: true };\n }\n}\n\nexport class ZuploProjectValidator implements ValidationRule<{ dir: string }> {\n async validate(options: { dir: string }): Promise<Result> {\n const { dir } = options;\n try {\n if (existsSync(`${dir}/config`)) {\n const files = readdirSync(join(dir, \"config\"));\n const existingOASFiles =\n files.filter((file) => file.endsWith(\".oas.json\")).length >= 1;\n if (existingOASFiles === true) {\n return { ok: true };\n }\n }\n return {\n ok: false,\n error: new NotAZuploProject(),\n };\n } catch (err) {\n return {\n ok: false,\n error: err,\n };\n }\n }\n}\n\nexport class ZuploProjectHasTestsValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n if (fg.sync(`${dir}/${TEST_IN_FOLDER}/**/*.test.ts`).length >= 1) {\n return { ok: true };\n } else {\n return {\n ok: false,\n error: new ZuploProjectMissingTests(),\n };\n }\n } catch (err) {\n return {\n ok: false,\n error: err,\n };\n }\n }\n}\n\nexport const validDeployDirectoryValidator = new CompositeValidator<{\n dir: string;\n project: string | undefined;\n environment: string | undefined;\n}>(\n new ZuploProjectValidator(),\n new ProjectIsSetValidator(),\n new GitBranchOrEnvironmentValidator()\n);\n\nexport const validTestDirectoryValidator = new CompositeValidator<{\n dir: string;\n}>(new ZuploProjectValidator(), new ZuploProjectHasTestsValidator());\n"]}
1
+ {"version":3,"file":"file-system-validator.js","sourceRoot":"","sources":["../../../src/common/validators/file-system-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAA0B,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,MAAM,OAAO,mCAAoC,SAAQ,KAAK;IAC5D;QACE,KAAK,CACH,gHAAgH,CACjH,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ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ACjE,IAAI,gBAAgB,KAAK,IAAI,EAAE,CAAC;oBAC9B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;gBACtB,CAAC;YACH,CAAC;YACD,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,IAAI,gBAAgB,EAAE;aAC9B,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,GAAG;aACX,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,MAAM,OAAO,6BAA6B;IAGxC,KAAK,CAAC,QAAQ,CAAC,MAAuB;QACpC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;QACvB,IAAI,CAAC;YACH,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;gBACnC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;YACtB,CAAC;iBAAM,CAAC;gBACN,OAAO;oBACL,EAAE,EAAE,KAAK;oBACT,KAAK,EAAE,IAAI,wBAAwB,EAAE;iBACtC,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,GAAG;aACX,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,kBAAkB,CAKjE,IAAI,qBAAqB,EAAE,EAC3B,IAAI,qBAAqB,EAAE,EAC3B,IAAI,+BAA+B,EAAE,CACtC,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,kBAAkB,CAE9D,IAAI,qBAAqB,EAAE,EAAE,IAAI,6BAA6B,EAAE,CAAC,CAAC","sourcesContent":["import { existsSync, readdirSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { simpleGit } from \"simple-git\";\nimport { findTestFiles } from \"../../test/test-files.js\";\nimport { CompositeValidator, Result, ValidationRule } from \"./lib.js\";\nimport { ProjectIsSetValidator } from \"./project-name-validator.js\";\n\nexport class GitBranchOrEnvironmentRequiredError extends Error {\n constructor() {\n super(\n \"Invalid arguments: The project directory is not a Git repository, you must specify the `environment` argument.\"\n );\n Object.setPrototypeOf(this, NotAGitRepoError.prototype);\n }\n}\n\nexport class NotAGitRepoError extends Error {\n constructor() {\n super(\"Invalid directory: The project directory is not a Git repository.\");\n Object.setPrototypeOf(this, NotAGitRepoError.prototype);\n }\n}\n\nexport class NotAZuploProject extends Error {\n constructor() {\n super(\n \"Invalid directory: The project directory is not the root of a Zuplo project.\"\n );\n Object.setPrototypeOf(this, NotAZuploProject.prototype);\n }\n}\n\nexport class ZuploProjectMissingTests extends Error {\n constructor() {\n super(\n \"Invalid directory: The project directory does not contain any tests (*.test.ts) in the /tests folder. Create a at least one test of the form some-name.test.ts\"\n );\n Object.setPrototypeOf(this, ZuploProjectMissingTests.prototype);\n }\n}\n\nexport class NoGitCommits extends Error {\n constructor() {\n super(\n \"Invalid Git state: The project directory does not contain any commits. Make a commit before deploying.\"\n );\n Object.setPrototypeOf(this, NoGitCommits.prototype);\n }\n}\n\nexport class NotOnAGitBranch extends Error {\n constructor() {\n super(\n \"Invalid Git state: You are not on a branch. Run `git checkout -b <branch-name>` to create a new branch.\"\n );\n Object.setPrototypeOf(this, NotOnAGitBranch.prototype);\n }\n}\n\nexport class GitVersionControlValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n await simpleGit({ baseDir: dir }).status();\n return { ok: true };\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_err) {\n return {\n ok: false,\n error: new NotAGitRepoError(),\n };\n }\n }\n}\n\n/**\n * Checks if either the current branch is set as the environment or if\n * the environment is explicitly set\n */\nexport class GitBranchOrEnvironmentValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: {\n dir: string;\n environment: string | undefined;\n }): Promise<Result> {\n const { dir, environment } = option;\n if (typeof environment === \"string\") {\n return {\n ok: true,\n };\n }\n try {\n if (await simpleGit({ baseDir: dir }).checkIsRepo()) {\n await simpleGit({ baseDir: dir }).status();\n const git = simpleGit({ baseDir: dir });\n const branch = await git.branch();\n if (branch.current) {\n return {\n ok: true,\n };\n }\n }\n } catch {\n // Ignore\n }\n return {\n ok: false,\n error: new GitBranchOrEnvironmentRequiredError(),\n };\n }\n}\n\nexport class GitCommitValidator implements ValidationRule<{ dir: string }> {\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n const git = simpleGit({ baseDir: dir });\n const commits = await git.log({ maxCount: 1 });\n if (commits.total === 0) {\n return {\n ok: false,\n error: new NoGitCommits(),\n };\n }\n return { ok: true };\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (_err) {\n return {\n ok: false,\n error: new NoGitCommits(),\n };\n }\n }\n}\n\nexport class GitBranchValidator implements ValidationRule<{ dir: string }> {\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n const git = simpleGit({ baseDir: dir });\n const branch = await git.branch();\n if (!branch.current) {\n return {\n ok: false,\n error: new NotOnAGitBranch(),\n };\n }\n\n return { ok: true };\n }\n}\n\nexport class ZuploProjectValidator implements ValidationRule<{ dir: string }> {\n async validate(options: { dir: string }): Promise<Result> {\n const { dir } = options;\n try {\n const dirPath = path.join(path.normalize(dir), \"config\");\n if (existsSync(dirPath)) {\n const files = readdirSync(dirPath);\n const existingOASFiles =\n files.filter((file) => file.endsWith(\".oas.json\")).length >= 1;\n if (existingOASFiles === true) {\n return { ok: true };\n }\n }\n return {\n ok: false,\n error: new NotAZuploProject(),\n };\n } catch (err) {\n return {\n ok: false,\n error: err,\n };\n }\n }\n}\n\nexport class ZuploProjectHasTestsValidator\n implements ValidationRule<{ dir: string }>\n{\n async validate(option: { dir: string }): Promise<Result> {\n const { dir } = option;\n try {\n if (findTestFiles(dir).length >= 1) {\n return { ok: true };\n } else {\n return {\n ok: false,\n error: new ZuploProjectMissingTests(),\n };\n }\n } catch (err) {\n return {\n ok: false,\n error: err,\n };\n }\n }\n}\n\nexport const validDeployDirectoryValidator = new CompositeValidator<{\n dir: string;\n project: string | undefined;\n environment: string | undefined;\n}>(\n new ZuploProjectValidator(),\n new ProjectIsSetValidator(),\n new GitBranchOrEnvironmentValidator()\n);\n\nexport const validTestDirectoryValidator = new CompositeValidator<{\n dir: string;\n}>(new ZuploProjectValidator(), new ZuploProjectHasTestsValidator());\n"]}
@@ -138,7 +138,7 @@ export async function generateMetadata(argv) {
138
138
  }
139
139
  async function writeGeneratedMetadata(dir, metadata) {
140
140
  try {
141
- mkdirSync(`${dir}/.zuplo`);
141
+ mkdirSync(join(dir, ".zuplo"));
142
142
  }
143
143
  catch (err) {
144
144
  if (err.code === "EEXIST") {
@@ -147,7 +147,7 @@ async function writeGeneratedMetadata(dir, metadata) {
147
147
  throw err;
148
148
  }
149
149
  }
150
- writeFileSync(`${dir}/.zuplo/${DEPLOYER_METADATA_FILE}`, JSON.stringify(metadata, null, 2), {
150
+ writeFileSync(join(dir, ".zuplo", DEPLOYER_METADATA_FILE), JSON.stringify(metadata, null, 2), {
151
151
  flag: "w",
152
152
  });
153
153
  }
@@ -1 +1 @@
1
- {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/deploy/archive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAEL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CA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IACtC,CAAC;SAAM,IAAI,MAAM,EAAE,CAAC;QAClB,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,CAAC,KAAK,CACV,yGAAyG,CAC1G,CAAC;YACF,OAAO,GAAG,SAAS,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM;QACN,OAAO;QACP,GAAG;KACJ,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,sBAAsB,CAAC,GAAW,EAAE,QAA0B;IAC3E,IAAI,CAAC;QACH,SAAS,CAAC,GAAG,GAAG,SAAS,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAE5B,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IACD,aAAa,CACX,GAAG,GAAG,WAAW,sBAAsB,EAAE,EACzC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EACjC;QACE,IAAI,EAAE,GAAG;KACV,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport {\n Stats,\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join, relative, sep } from \"node:path\";\nimport ignore from \"ignore\";\nimport { minimatch } from \"minimatch\";\nimport { simpleGit } from \"simple-git\";\nimport * as tar from \"tar\";\nimport { DEPLOYER_METADATA_FILE } from \"../common/constants.js\";\nimport { logger } from \"../common/logger.js\";\nimport { Arguments } from \"./handler.js\";\n\nexport const ARCHIVE_EXTENSION = \".tar.gz\";\n\nfunction createTempFileWithSuffix(suffix = ARCHIVE_EXTENSION) {\n const tempDir = tmpdir();\n const randomName = randomBytes(16).toString(\"hex\");\n const tempFilePath = join(tempDir, `${randomName}${suffix}`);\n return tempFilePath;\n}\n\nexport async function archive(argv: Arguments) {\n const tarball = createTempFileWithSuffix();\n const dir = argv.dir;\n const ignoreFn = createIgnoreFunction(dir);\n const normalizedDir = join(relative(process.cwd(), dir));\n\n const metadata = await prepareDeployerMetadata(argv);\n\n await tar.create(\n {\n gzip: true,\n file: tarball,\n filter: (path, stat) => {\n const stats = stat as unknown as Stats;\n const normalizedPath = stats.isDirectory()\n ? join(relative(process.cwd(), path), sep) // add / to help the ignore module determine that this is a folder\n : join(relative(process.cwd(), path));\n\n // special case to allow for processing of the root by tar (./)\n if (minimatch(normalizedPath, \"/\", { windowsPathsNoEscape: true })) {\n return true;\n }\n\n if (\n minimatch(normalizedPath, \".zuplo/\", { windowsPathsNoEscape: true })\n ) {\n // Need to return true to allow this to process the entries of the directory\n return true;\n }\n\n if (\n minimatch(normalizedPath, `.zuplo/${DEPLOYER_METADATA_FILE}`, {\n windowsPathsNoEscape: true,\n })\n ) {\n // Now on the second round when it enters the .zuplo folder, we specifically look for this file\n return true;\n }\n\n // We special case the .env files to allow for the self-hosted endpoint to be passed in\n if (normalizedPath === \".env\" || normalizedPath === \".env.zuplo\") {\n if (argv[\"self-hosted-endpoint\"]) {\n return true;\n }\n }\n\n const result = ignoreFn.ignores(normalizedPath);\n logger.trace(`${normalizedPath} ignored: ${result}`);\n\n // The way `tar` interprets true|false is \"opposite\" from ignore\n // When ignore returns true, it means that the .ignore file doesn't want it.\n // When tar return true, it means that we want it.\n return !result;\n },\n },\n [normalizedDir]\n );\n return {\n tarball,\n metadata,\n };\n}\n\n// Note that we do not recursively create an ignore function for each dir\n// We only create one for the top-level of the directory\nexport function createIgnoreFunction(normalizedDir: string) {\n // Most ignore files forget to ignore the .git directory\n\n // Need to do this conversion because of some weird confusion with the d.ts for ignore package in esm\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const baseIgnore = (ignore as any)().add(\".git/\");\n\n if (existsSync(`${normalizedDir}/.zupignore`)) {\n const zupignorePath = `${normalizedDir}/.zupignore`;\n logger.debug(`Using ${zupignorePath} to filter out files`);\n return baseIgnore.add(readFileSync(zupignorePath).toString());\n } else if (existsSync(`${normalizedDir}/.gitignore`)) {\n const gitignorePath = `${normalizedDir}/.gitignore`;\n logger.debug(`Using ${gitignorePath} to filter out files`);\n const gitIgnoreContent = readFileSync(gitignorePath).toString();\n // @NOTE - we should always include the .zuplo folder\n const gitIgnoreContentDotZuploRemoved = gitIgnoreContent.replace(\n /\\.zuplo[/]/,\n \"\"\n );\n return baseIgnore.add(gitIgnoreContentDotZuploRemoved);\n } else {\n logger.debug(\n \"Didn't find a .gitignore or .zupignore file. Defaulting to ignoring .git and node_modules.\"\n );\n return baseIgnore.add(\"node_modules/\");\n }\n}\n\ninterface DeployerMetadata {\n branch: string;\n repoUrl: string | undefined;\n sha: string | undefined;\n}\n\nasync function prepareDeployerMetadata(argv: Arguments) {\n const dir = argv.dir;\n const metadata = await generateMetadata(argv);\n await writeGeneratedMetadata(dir, metadata);\n return metadata;\n}\n\nexport async function generateMetadata(argv: Arguments) {\n const dir = argv.dir;\n const git = simpleGit({ baseDir: dir });\n\n const isRepo = await git.checkIsRepo();\n let branch: string;\n if (argv.environment) {\n branch = argv.environment;\n } else if (isRepo) {\n // Get the current branch from Git\n const status = await git.status();\n if (!status.current) {\n throw new Error(\"Invalid state: Directory is in detached head state.\");\n }\n branch = status.current.trim();\n\n // @NOTE - gitlab returns HEAD as the current branch when running git.status()\n // https://forum.gitlab.com/t/why-i-cant-get-the-branch-name/72462/6\n if (branch === \"HEAD\") {\n // Fetch remote branches to ensure the latest information\n await git.fetch([\"--all\"]);\n\n const branchCommit = await git.branch([\"-a\"]);\n const brancheRef = await git.branch([\n \"-r\",\n \"--contains\",\n branchCommit.current,\n ]);\n if (brancheRef && brancheRef.all && brancheRef.all[0]) {\n const originBranch = brancheRef.all[0];\n const cleanOriginBranch = originBranch.replace(/^origin\\//, \"\");\n if (!cleanOriginBranch) {\n throw new Error(\n \"Invalid state: Directory is in detached head state.\"\n );\n }\n branch = cleanOriginBranch.trim();\n }\n }\n } else {\n throw new Error(\n \"The argument `environment` is required when not in a git repository.\"\n );\n }\n\n // Get the current sha\n let sha: string | undefined;\n let repoUrl: string | undefined;\n if (argv[\"override-repo-url\"]) {\n repoUrl = argv[\"override-repo-url\"];\n } else if (isRepo) {\n sha = (await git.revparse([\"HEAD\"])).trim();\n try {\n repoUrl = (await git.listRemote([\"--get-url\"])).trim();\n } catch {\n logger.debug(\n \"Failed to get the remote URL from the git repository. This can happen if there is no remote configured.\"\n );\n repoUrl = undefined;\n }\n }\n\n return {\n branch,\n repoUrl,\n sha,\n };\n}\n\nasync function writeGeneratedMetadata(dir: string, metadata: DeployerMetadata) {\n try {\n mkdirSync(`${dir}/.zuplo`);\n } catch (err) {\n if (err.code === \"EEXIST\") {\n // this is fine, which means that we don't create it and move on\n } else {\n throw err;\n }\n }\n writeFileSync(\n `${dir}/.zuplo/${DEPLOYER_METADATA_FILE}`,\n JSON.stringify(metadata, null, 2),\n {\n flag: \"w\",\n }\n );\n}\n"]}
1
+ {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/deploy/archive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAEL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,M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AE,CAAC;QAC9B,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACtC,CAAC;SAAM,IAAI,MAAM,EAAE,CAAC;QAClB,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,CAAC,KAAK,CACV,yGAAyG,CAC1G,CAAC;YACF,OAAO,GAAG,SAAS,CAAC;QACtB,CAAC;IACH,CAAC;IAED,OAAO;QACL,MAAM;QACN,OAAO;QACP,GAAG;KACJ,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,sBAAsB,CAAC,GAAW,EAAE,QAA0B;IAC3E,IAAI,CAAC;QACH,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAE5B,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IACD,aAAa,CACX,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,sBAAsB,CAAC,EAC3C,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EACjC;QACE,IAAI,EAAE,GAAG;KACV,CACF,CAAC;AACJ,CAAC","sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport {\n Stats,\n existsSync,\n mkdirSync,\n readFileSync,\n writeFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join, relative, sep } from \"node:path\";\nimport ignore from \"ignore\";\nimport { minimatch } from \"minimatch\";\nimport { simpleGit } from \"simple-git\";\nimport * as tar from \"tar\";\nimport { DEPLOYER_METADATA_FILE } from \"../common/constants.js\";\nimport { logger } from \"../common/logger.js\";\nimport { Arguments } from \"./handler.js\";\n\nexport const ARCHIVE_EXTENSION = \".tar.gz\";\n\nfunction createTempFileWithSuffix(suffix = ARCHIVE_EXTENSION) {\n const tempDir = tmpdir();\n const randomName = randomBytes(16).toString(\"hex\");\n const tempFilePath = join(tempDir, `${randomName}${suffix}`);\n return tempFilePath;\n}\n\nexport async function archive(argv: Arguments) {\n const tarball = createTempFileWithSuffix();\n const dir = argv.dir;\n const ignoreFn = createIgnoreFunction(dir);\n const normalizedDir = join(relative(process.cwd(), dir));\n\n const metadata = await prepareDeployerMetadata(argv);\n\n await tar.create(\n {\n gzip: true,\n file: tarball,\n filter: (path, stat) => {\n const stats = stat as unknown as Stats;\n const normalizedPath = stats.isDirectory()\n ? join(relative(process.cwd(), path), sep) // add / to help the ignore module determine that this is a folder\n : join(relative(process.cwd(), path));\n\n // special case to allow for processing of the root by tar (./)\n if (minimatch(normalizedPath, \"/\", { windowsPathsNoEscape: true })) {\n return true;\n }\n\n if (\n minimatch(normalizedPath, \".zuplo/\", { windowsPathsNoEscape: true })\n ) {\n // Need to return true to allow this to process the entries of the directory\n return true;\n }\n\n if (\n minimatch(normalizedPath, `.zuplo/${DEPLOYER_METADATA_FILE}`, {\n windowsPathsNoEscape: true,\n })\n ) {\n // Now on the second round when it enters the .zuplo folder, we specifically look for this file\n return true;\n }\n\n // We special case the .env files to allow for the self-hosted endpoint to be passed in\n if (normalizedPath === \".env\" || normalizedPath === \".env.zuplo\") {\n if (argv[\"self-hosted-endpoint\"]) {\n return true;\n }\n }\n\n const result = ignoreFn.ignores(normalizedPath);\n logger.trace(`${normalizedPath} ignored: ${result}`);\n\n // The way `tar` interprets true|false is \"opposite\" from ignore\n // When ignore returns true, it means that the .ignore file doesn't want it.\n // When tar return true, it means that we want it.\n return !result;\n },\n },\n [normalizedDir]\n );\n return {\n tarball,\n metadata,\n };\n}\n\n// Note that we do not recursively create an ignore function for each dir\n// We only create one for the top-level of the directory\nexport function createIgnoreFunction(normalizedDir: string) {\n // Most ignore files forget to ignore the .git directory\n\n // Need to do this conversion because of some weird confusion with the d.ts for ignore package in esm\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const baseIgnore = (ignore as any)().add(\".git/\");\n\n if (existsSync(`${normalizedDir}/.zupignore`)) {\n const zupignorePath = `${normalizedDir}/.zupignore`;\n logger.debug(`Using ${zupignorePath} to filter out files`);\n return baseIgnore.add(readFileSync(zupignorePath).toString());\n } else if (existsSync(`${normalizedDir}/.gitignore`)) {\n const gitignorePath = `${normalizedDir}/.gitignore`;\n logger.debug(`Using ${gitignorePath} to filter out files`);\n const gitIgnoreContent = readFileSync(gitignorePath).toString();\n // @NOTE - we should always include the .zuplo folder\n const gitIgnoreContentDotZuploRemoved = gitIgnoreContent.replace(\n /\\.zuplo[/]/,\n \"\"\n );\n return baseIgnore.add(gitIgnoreContentDotZuploRemoved);\n } else {\n logger.debug(\n \"Didn't find a .gitignore or .zupignore file. Defaulting to ignoring .git and node_modules.\"\n );\n return baseIgnore.add(\"node_modules/\");\n }\n}\n\ninterface DeployerMetadata {\n branch: string;\n repoUrl: string | undefined;\n sha: string | undefined;\n}\n\nasync function prepareDeployerMetadata(argv: Arguments) {\n const dir = argv.dir;\n const metadata = await generateMetadata(argv);\n await writeGeneratedMetadata(dir, metadata);\n return metadata;\n}\n\nexport async function generateMetadata(argv: Arguments) {\n const dir = argv.dir;\n const git = simpleGit({ baseDir: dir });\n\n const isRepo = await git.checkIsRepo();\n let branch: string;\n if (argv.environment) {\n branch = argv.environment;\n } else if (isRepo) {\n // Get the current branch from Git\n const status = await git.status();\n if (!status.current) {\n throw new Error(\"Invalid state: Directory is in detached head state.\");\n }\n branch = status.current.trim();\n\n // @NOTE - gitlab returns HEAD as the current branch when running git.status()\n // https://forum.gitlab.com/t/why-i-cant-get-the-branch-name/72462/6\n if (branch === \"HEAD\") {\n // Fetch remote branches to ensure the latest information\n await git.fetch([\"--all\"]);\n\n const branchCommit = await git.branch([\"-a\"]);\n const brancheRef = await git.branch([\n \"-r\",\n \"--contains\",\n branchCommit.current,\n ]);\n if (brancheRef && brancheRef.all && brancheRef.all[0]) {\n const originBranch = brancheRef.all[0];\n const cleanOriginBranch = originBranch.replace(/^origin\\//, \"\");\n if (!cleanOriginBranch) {\n throw new Error(\n \"Invalid state: Directory is in detached head state.\"\n );\n }\n branch = cleanOriginBranch.trim();\n }\n }\n } else {\n throw new Error(\n \"The argument `environment` is required when not in a git repository.\"\n );\n }\n\n // Get the current sha\n let sha: string | undefined;\n let repoUrl: string | undefined;\n if (argv[\"override-repo-url\"]) {\n repoUrl = argv[\"override-repo-url\"];\n } else if (isRepo) {\n sha = (await git.revparse([\"HEAD\"])).trim();\n try {\n repoUrl = (await git.listRemote([\"--get-url\"])).trim();\n } catch {\n logger.debug(\n \"Failed to get the remote URL from the git repository. This can happen if there is no remote configured.\"\n );\n repoUrl = undefined;\n }\n }\n\n return {\n branch,\n repoUrl,\n sha,\n };\n}\n\nasync function writeGeneratedMetadata(dir: string, metadata: DeployerMetadata) {\n try {\n mkdirSync(join(dir, \".zuplo\"));\n } catch (err) {\n if (err.code === \"EEXIST\") {\n // this is fine, which means that we don't create it and move on\n } else {\n throw err;\n }\n }\n writeFileSync(\n join(dir, \".zuplo\", DEPLOYER_METADATA_FILE),\n JSON.stringify(metadata, null, 2),\n {\n flag: \"w\",\n }\n );\n}\n"]}
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/test/handler.ts"],"names":[],"mappings":"AASA,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,iBAyBzC"}
@@ -1,15 +1,17 @@
1
+ import path from "node:path";
1
2
  import esbuild from "esbuild";
2
- import fg from "fast-glob";
3
3
  import { rimrafSync } from "rimraf";
4
4
  import { TEST_IN_FOLDER, TEST_OUT_FOLDER } from "../common/constants.js";
5
5
  import { logger } from "../common/logger.js";
6
6
  import { generateBuildOptionsForTest } from "./esbuild-config.js";
7
7
  import { runTests } from "./invoke-test.js";
8
+ import { findTestFiles } from "./test-files.js";
8
9
  export async function test(argv) {
9
- rimrafSync(`${argv.dir}/${TEST_OUT_FOLDER}`);
10
+ const testDir = path.join(path.normalize(argv.dir), TEST_OUT_FOLDER);
11
+ rimrafSync(testDir);
10
12
  const result = await esbuild.build({
11
13
  ...generateBuildOptionsForTest(argv),
12
- entryPoints: fg.sync(`${argv.dir}/${TEST_IN_FOLDER}/**/*.test.ts`),
14
+ entryPoints: findTestFiles(argv.dir),
13
15
  });
14
16
  if (result.warnings.length > 0) {
15
17
  logger.debug(result.warnings);
@@ -1 +1 @@
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
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/test/handler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAwB,MAAM,SAAS,CAAC;AAC/C,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;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAe;IAExC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,CAAC;IACrE,UAAU,CAAC,OAAO,CAAC,CAAC;IAGpB,MAAM,MAAM,GAAgB,MAAM,OAAO,CAAC,KAAK,CAAC;QAC9C,GAAG,2BAA2B,CAAC,IAAI,CAAC;QACpC,WAAW,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC;KACrC,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 path from \"node:path\";\nimport esbuild, { BuildResult } from \"esbuild\";\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\";\nimport { findTestFiles } from \"./test-files.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 const testDir = path.join(path.normalize(argv.dir), TEST_OUT_FOLDER);\n rimrafSync(testDir);\n\n // 2. Build the test files\n const result: BuildResult = await esbuild.build({\n ...generateBuildOptionsForTest(argv),\n entryPoints: findTestFiles(argv.dir),\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,CAkCpD"}
1
+ {"version":3,"file":"invoke-test.d.ts","sourceRoot":"","sources":["../../src/test/invoke-test.ts"],"names":[],"mappings":"AACA,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"}
@@ -1,3 +1,4 @@
1
+ import path from "node:path";
1
2
  import { execa } from "execa";
2
3
  import { TEST_OUT_FOLDER } from "../common/constants.js";
3
4
  import { logger } from "../common/logger.js";
@@ -16,8 +17,8 @@ export async function runTests(argv) {
16
17
  }
17
18
  const nodeVersion = parseInt(process.versions.node.split(".")[0], 10);
18
19
  const globPattern = nodeVersion >= 21
19
- ? `${argv.dir}/${TEST_OUT_FOLDER}/**/*.test.mjs`
20
- : `${argv.dir}/${TEST_OUT_FOLDER}`;
20
+ ? path.join(argv.dir, TEST_OUT_FOLDER, "**", "*.test.mjs")
21
+ : path.join(argv.dir, TEST_OUT_FOLDER);
21
22
  args.push(globPattern);
22
23
  const nodeProcess = execa(nodeExecutable, args);
23
24
  nodeProcess.stdout?.pipe(process.stdout);
@@ -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,mDAAmD,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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"]}
1
+ {"version":3,"file":"invoke-test.js","sourceRoot":"","sources":["../../src/test/invoke-test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7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AAI,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 path from \"node:path\";\nimport { 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 ? path.join(argv.dir, TEST_OUT_FOLDER, \"**\", \"*.test.mjs\")\n : path.join(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"]}
@@ -0,0 +1,2 @@
1
+ export declare function findTestFiles(dir: string): string[];
2
+ //# sourceMappingURL=test-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-files.d.ts","sourceRoot":"","sources":["../../src/test/test-files.ts"],"names":[],"mappings":"AAIA,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,YAgBxC"}
@@ -0,0 +1,10 @@
1
+ import path from "node:path";
2
+ import fg from "fast-glob";
3
+ import { TEST_IN_FOLDER } from "../common/constants.js";
4
+ export function findTestFiles(dir) {
5
+ const normalizedDir = path.normalize(dir);
6
+ const dirPattern = fg.convertPathToPattern(normalizedDir);
7
+ const testFiles = path.posix.join(dirPattern, TEST_IN_FOLDER, "**", "*.test.ts");
8
+ return fg.sync(testFiles);
9
+ }
10
+ //# sourceMappingURL=test-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-files.js","sourceRoot":"","sources":["../../src/test/test-files.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,UAAU,aAAa,CAAC,GAAW;IAEvC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAG1C,MAAM,UAAU,GAAG,EAAE,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;IAG1D,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAC/B,UAAU,EACV,cAAc,EACd,IAAI,EACJ,WAAW,CACZ,CAAC;IAEF,OAAO,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import path from \"node:path\";\nimport fg from \"fast-glob\";\nimport { TEST_IN_FOLDER } from \"../common/constants.js\";\n\nexport function findTestFiles(dir: string) {\n // Normalize the input directory path for platform-consistency\n const normalizedDir = path.normalize(dir);\n\n // Convert directory to glob pattern\n const dirPattern = fg.convertPathToPattern(normalizedDir);\n\n // Always use forward slashes for glob patterns\n const testFiles = path.posix.join(\n dirPattern,\n TEST_IN_FOLDER,\n \"**\",\n \"*.test.ts\"\n );\n\n return fg.sync(testFiles);\n}\n"]}
@@ -1,2 +1,50 @@
1
- export {};
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { after, before, describe, it } from "node:test";
5
+ import { expect } from "chai";
6
+ import { TEST_IN_FOLDER } from "../common/constants.js";
7
+ import { findTestFiles } from "./test-files.js";
8
+ function createTestFile(filePath) {
9
+ const dir = path.dirname(filePath);
10
+ if (!fs.existsSync(dir)) {
11
+ fs.mkdirSync(dir, { recursive: true });
12
+ }
13
+ fs.writeFileSync(filePath, "// test file");
14
+ }
15
+ describe("findTestFiles", () => {
16
+ const testDir = path.join(os.tmpdir(), "findTestFilesTest");
17
+ const testSubDir = path.join(testDir, TEST_IN_FOLDER);
18
+ const testFilePath = path.join(testSubDir, "example.test.ts");
19
+ before(() => {
20
+ createTestFile(testFilePath);
21
+ });
22
+ after(() => {
23
+ fs.rmSync(testDir, { recursive: true, force: true });
24
+ });
25
+ it("should find test files in the specified directory", () => {
26
+ const result = findTestFiles(testDir);
27
+ const normalizedResult = result.map((p) => path.normalize(p));
28
+ const normalizedExpected = path.normalize(testFilePath);
29
+ expect(normalizedResult).to.include(normalizedExpected);
30
+ });
31
+ it("should return an empty array if no test files are found", () => {
32
+ const emptyDir = path.join(os.tmpdir(), "emptyTestDir");
33
+ fs.mkdirSync(emptyDir, { recursive: true });
34
+ const result = findTestFiles(emptyDir);
35
+ expect(result).to.be.an("array").that.is.empty;
36
+ fs.rmdirSync(emptyDir);
37
+ });
38
+ it("should handle Windows paths correctly", function (t) {
39
+ if (os.platform() !== "win32") {
40
+ t.skip("Skipping Windows-specific test on non-Windows platform");
41
+ return;
42
+ }
43
+ const windowsPath = testDir.replace(/\//g, "\\");
44
+ const result = findTestFiles(windowsPath);
45
+ const normalizedResult = result.map((p) => path.normalize(p));
46
+ const normalizedExpected = path.normalize(testFilePath);
47
+ expect(normalizedResult).to.include(normalizedExpected);
48
+ });
49
+ });
2
50
  //# sourceMappingURL=test-files.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-files.test.js","sourceRoot":"","sources":["../../src/test/test-files.test.ts"],"names":[],"mappings":"","sourcesContent":[""]}
1
+ {"version":3,"file":"test-files.test.js","sourceRoot":"","sources":["../../src/test/test-files.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,SAAS,cAAc,CAAC,QAAgB;IACtC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC7C,CAAC;AAED,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B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C,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC;QAE/C,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,UAAU,CAAC;QACrD,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,OAAO,EAAE,CAAC;YAC9B,CAAC,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;YACjE,OAAO;QACT,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACjD,MAAM,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;QAC1C,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QACxD,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { after, before, describe, it } from \"node:test\";\nimport { expect } from \"chai\";\nimport { TEST_IN_FOLDER } from \"../common/constants.js\";\nimport { findTestFiles } from \"./test-files.js\";\n\n// Helper function to create test files for testing\nfunction createTestFile(filePath: string) {\n const dir = path.dirname(filePath);\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n fs.writeFileSync(filePath, \"// test file\");\n}\n\ndescribe(\"findTestFiles\", () => {\n const testDir = path.join(os.tmpdir(), \"findTestFilesTest\");\n // Use the constant for test folder from constants\n const testSubDir = path.join(testDir, TEST_IN_FOLDER);\n const testFilePath = path.join(testSubDir, \"example.test.ts\");\n\n before(() => {\n createTestFile(testFilePath);\n });\n\n after(() => {\n fs.rmSync(testDir, { recursive: true, force: true });\n });\n\n it(\"should find test files in the specified directory\", () => {\n const result = findTestFiles(testDir);\n // Compare using normalized paths to handle platform differences\n const normalizedResult = result.map((p) => path.normalize(p));\n const normalizedExpected = path.normalize(testFilePath);\n expect(normalizedResult).to.include(normalizedExpected);\n });\n\n it(\"should return an empty array if no test files are found\", () => {\n const emptyDir = path.join(os.tmpdir(), \"emptyTestDir\");\n fs.mkdirSync(emptyDir, { recursive: true });\n\n const result = findTestFiles(emptyDir);\n expect(result).to.be.an(\"array\").that.is.empty;\n\n fs.rmdirSync(emptyDir);\n });\n\n it(\"should handle Windows paths correctly\", function (t) {\n if (os.platform() !== \"win32\") {\n t.skip(\"Skipping Windows-specific test on non-Windows platform\");\n return;\n }\n\n const windowsPath = testDir.replace(/\\//g, \"\\\\\");\n const result = findTestFiles(windowsPath);\n const normalizedResult = result.map((p) => path.normalize(p));\n const normalizedExpected = path.normalize(testFilePath);\n expect(normalizedResult).to.include(normalizedExpected);\n });\n});\n"]}
@@ -1 +1 @@
1
- {"root":["../src/cli.ts","../src/types.d.ts","../src/__tests__/archive-utils.test.ts","../src/__tests__/engine.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__/tsconfig-upgrader.test.ts","../src/build/handler.ts","../src/cmds/build.ts","../src/cmds/compile.ts","../src/cmds/convert.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/project/import-openapi.ts","../src/cmds/project/index.ts","../src/cmds/project/update.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/handler.ts","../src/common/logger.ts","../src/common/models.ts","../src/common/outdated.ts","../src/common/output.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/user-configuration.ts","../src/common/middleware/user-identification.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/ports.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/convert/engine.ts","../src/convert/handler.ts","../src/convert/routes.legacy.ts","../src/delete/handler.ts","../src/delete/poll-deployment.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/editor/assets/index-03352ce7.js","../src/editor/server/cors-plugin.ts","../src/editor/server/server.ts","../src/editor/server/xfs.ts","../src/link/handler.ts","../src/link/populate.ts","../src/list/handler.ts","../src/login/html.ts","../src/login/login.ts","../src/login/server.ts","../src/login/tokens.ts","../src/project/import-openapi/handler.ts","../src/project/import-openapi/interfaces.ts","../src/project/import-openapi/utils.ts","../src/project/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/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.7.3"}
1
+ {"root":["../src/cli.ts","../src/types.d.ts","../src/__tests__/archive-utils.test.ts","../src/__tests__/engine.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__/tsconfig-upgrader.test.ts","../src/build/handler.ts","../src/cmds/build.ts","../src/cmds/compile.ts","../src/cmds/convert.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/project/import-openapi.ts","../src/cmds/project/index.ts","../src/cmds/project/update.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/handler.ts","../src/common/logger.ts","../src/common/models.ts","../src/common/outdated.ts","../src/common/output.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/user-configuration.ts","../src/common/middleware/user-identification.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/ports.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/convert/engine.ts","../src/convert/handler.ts","../src/convert/routes.legacy.ts","../src/delete/handler.ts","../src/delete/poll-deployment.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/editor/assets/index-03352ce7.js","../src/editor/server/cors-plugin.ts","../src/editor/server/server.ts","../src/editor/server/xfs.ts","../src/link/handler.ts","../src/link/populate.ts","../src/list/handler.ts","../src/login/html.ts","../src/login/login.ts","../src/login/server.ts","../src/login/tokens.ts","../src/project/import-openapi/handler.ts","../src/project/import-openapi/interfaces.ts","../src/project/import-openapi/utils.ts","../src/project/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.7.3"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "6.50.12",
3
+ "version": "6.50.13",
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.12",
33
- "@zuplo/openapi-tools": "^6.50.12",
34
- "@zuplo/runtime": "^6.50.12",
32
+ "@zuplo/core": "^6.50.13",
33
+ "@zuplo/openapi-tools": "^6.50.13",
34
+ "@zuplo/runtime": "^6.50.13",
35
35
  "as-table": "^1.0.55",
36
36
  "chalk": "^5.3.0",
37
37
  "chokidar": "^3.5.3",