@zuplo/cli 6.65.6 → 6.65.8

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.
Files changed (55) hide show
  1. package/dist/__tests__/integration/tunnel.integration.test.js +39 -30
  2. package/dist/__tests__/integration/tunnel.integration.test.js.map +1 -1
  3. package/dist/cli.js +2 -0
  4. package/dist/cli.js.map +1 -1
  5. package/dist/cmds/compile.d.ts.map +1 -1
  6. package/dist/cmds/compile.js +2 -0
  7. package/dist/cmds/compile.js.map +1 -1
  8. package/dist/cmds/dev.d.ts.map +1 -1
  9. package/dist/cmds/dev.js +7 -0
  10. package/dist/cmds/dev.js.map +1 -1
  11. package/dist/cmds/docs.d.ts.map +1 -1
  12. package/dist/cmds/docs.js +2 -0
  13. package/dist/cmds/docs.js.map +1 -1
  14. package/dist/cmds/editor.d.ts.map +1 -1
  15. package/dist/cmds/editor.js +3 -1
  16. package/dist/cmds/editor.js.map +1 -1
  17. package/dist/cmds/init.d.ts +10 -0
  18. package/dist/cmds/init.d.ts.map +1 -0
  19. package/dist/cmds/init.js +54 -0
  20. package/dist/cmds/init.js.map +1 -0
  21. package/dist/cmds/mtls-certificates/create.d.ts.map +1 -1
  22. package/dist/cmds/mtls-certificates/create.js +8 -0
  23. package/dist/cmds/mtls-certificates/create.js.map +1 -1
  24. package/dist/cmds/open-api/merge.d.ts.map +1 -1
  25. package/dist/cmds/open-api/merge.js +11 -2
  26. package/dist/cmds/open-api/merge.js.map +1 -1
  27. package/dist/cmds/proxies/create.d.ts.map +1 -1
  28. package/dist/cmds/proxies/create.js +6 -0
  29. package/dist/cmds/proxies/create.js.map +1 -1
  30. package/dist/cmds/proxies/update.d.ts.map +1 -1
  31. package/dist/cmds/proxies/update.js +6 -0
  32. package/dist/cmds/proxies/update.js.map +1 -1
  33. package/dist/cmds/source/import-openapi.d.ts.map +1 -1
  34. package/dist/cmds/source/import-openapi.js +12 -0
  35. package/dist/cmds/source/import-openapi.js.map +1 -1
  36. package/dist/cmds/test.d.ts.map +1 -1
  37. package/dist/cmds/test.js +3 -0
  38. package/dist/cmds/test.js.map +1 -1
  39. package/dist/cmds/tunnel/services/update.d.ts.map +1 -1
  40. package/dist/cmds/tunnel/services/update.js +6 -0
  41. package/dist/cmds/tunnel/services/update.js.map +1 -1
  42. package/dist/common/validators/argument-validators.d.ts +30 -0
  43. package/dist/common/validators/argument-validators.d.ts.map +1 -0
  44. package/dist/common/validators/argument-validators.js +89 -0
  45. package/dist/common/validators/argument-validators.js.map +1 -0
  46. package/dist/common/validators/argument-validators.spec.d.ts +2 -0
  47. package/dist/common/validators/argument-validators.spec.d.ts.map +1 -0
  48. package/dist/common/validators/argument-validators.spec.js +181 -0
  49. package/dist/common/validators/argument-validators.spec.js.map +1 -0
  50. package/dist/init/handler.d.ts +8 -0
  51. package/dist/init/handler.d.ts.map +1 -0
  52. package/dist/init/handler.js +210 -0
  53. package/dist/init/handler.js.map +1 -0
  54. package/dist/tsconfig.tsbuildinfo +1 -1
  55. package/package.json +5 -5
@@ -0,0 +1,54 @@
1
+ import { captureEvent } from "../common/analytics/lib.js";
2
+ import setBlocking from "../common/output.js";
3
+ import { init } from "../init/handler.js";
4
+ export default {
5
+ desc: "Initialize a Zuplo project on the platform (create project and deploy initial environment)",
6
+ command: "init [directory]",
7
+ hidden: true,
8
+ builder: (yargs) => {
9
+ return yargs
10
+ .usage("$0 init [directory] [options]")
11
+ .positional("directory", {
12
+ type: "string",
13
+ describe: "Directory containing the project (defaults to current directory)",
14
+ })
15
+ .option("with-account", {
16
+ type: "string",
17
+ describe: "Pre-select the account name for project creation",
18
+ })
19
+ .option("with-project", {
20
+ type: "string",
21
+ describe: "Pre-select or create a project with this name",
22
+ })
23
+ .option("yes", {
24
+ alias: "y",
25
+ type: "boolean",
26
+ describe: "Use defaults for all prompts",
27
+ })
28
+ .example([
29
+ ["$0 init", "Initialize the current directory with Zuplo platform"],
30
+ [
31
+ "$0 init my-api",
32
+ "Initialize the my-api directory with Zuplo platform",
33
+ ],
34
+ [
35
+ "$0 init --with-account my-account --with-project my-api",
36
+ "Initialize with a specific account and project",
37
+ ],
38
+ ["$0 init -y", "Initialize with all defaults (create project, deploy)"],
39
+ ])
40
+ .middleware([setBlocking]);
41
+ },
42
+ handler: async (argv) => {
43
+ const args = argv;
44
+ const initArgs = {
45
+ dir: args._[1],
46
+ withAccount: args.withAccount,
47
+ withProject: args.withProject,
48
+ yes: args.yes,
49
+ };
50
+ await captureEvent({ argv, event: "zuplo init" });
51
+ await init(initArgs);
52
+ },
53
+ };
54
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cmds/init.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAiB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAEzD,eAAe;IACb,IAAI,EAAE,4FAA4F;IAClG,OAAO,EAAE,kBAAkB;IAC3B,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CAAC,+BAA+B,CAAC;aACtC,UAAU,CAAC,WAAW,EAAE;YACvB,IAAI,EAAE,QAAQ;YACd,QAAQ,EACN,kEAAkE;SACrE,CAAC;aACD,MAAM,CAAC,cAAc,EAAE;YACtB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,kDAAkD;SAC7D,CAAC;aACD,MAAM,CAAC,cAAc,EAAE;YACtB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,+CAA+C;SAC1D,CAAC;aACD,MAAM,CAAC,KAAK,EAAE;YACb,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,QAAQ,EAAE,8BAA8B;SACzC,CAAC;aACD,OAAO,CAAC;YACP,CAAC,SAAS,EAAE,sDAAsD,CAAC;YACnE;gBACE,gBAAgB;gBAChB,qDAAqD;aACtD;YACD;gBACE,yDAAyD;gBACzD,gDAAgD;aACjD;YACD,CAAC,YAAY,EAAE,uDAAuD,CAAC;SACxE,CAAC;aACD,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,IAAI,GAAG,IAKZ,CAAC;QAEF,MAAM,QAAQ,GAAkB;YAC9B,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAuB;YACpC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC;QAEF,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;QAClD,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../common/analytics/lib.js\";\nimport setBlocking from \"../common/output.js\";\nimport { InitArguments, init } from \"../init/handler.js\";\n\nexport default {\n desc: \"Initialize a Zuplo project on the platform (create project and deploy initial environment)\",\n command: \"init [directory]\",\n hidden: true,\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\"$0 init [directory] [options]\")\n .positional(\"directory\", {\n type: \"string\",\n describe:\n \"Directory containing the project (defaults to current directory)\",\n })\n .option(\"with-account\", {\n type: \"string\",\n describe: \"Pre-select the account name for project creation\",\n })\n .option(\"with-project\", {\n type: \"string\",\n describe: \"Pre-select or create a project with this name\",\n })\n .option(\"yes\", {\n alias: \"y\",\n type: \"boolean\",\n describe: \"Use defaults for all prompts\",\n })\n .example([\n [\"$0 init\", \"Initialize the current directory with Zuplo platform\"],\n [\n \"$0 init my-api\",\n \"Initialize the my-api directory with Zuplo platform\",\n ],\n [\n \"$0 init --with-account my-account --with-project my-api\",\n \"Initialize with a specific account and project\",\n ],\n [\"$0 init -y\", \"Initialize with all defaults (create project, deploy)\"],\n ])\n .middleware([setBlocking]);\n },\n handler: async (argv: unknown) => {\n const args = argv as {\n _: (string | number)[];\n withAccount?: string;\n withProject?: string;\n yes?: boolean;\n };\n\n const initArgs: InitArguments = {\n dir: args._[1] as string | undefined,\n withAccount: args.withAccount,\n withProject: args.withProject,\n yes: args.yes,\n };\n\n await captureEvent({ argv, event: \"zuplo init\" });\n await init(initArgs);\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/cmds/mtls-certificates/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAcV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBA6Df,OAAO;;AAhE/B,wBAoEE"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/cmds/mtls-certificates/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAeV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBAoEf,OAAO;;AAvE/B,wBA2EE"}
@@ -5,6 +5,7 @@ import { fetchProject } from "../../common/middleware/get-project-param.js";
5
5
  import { configure } from "../../common/middleware/user-configuration.js";
6
6
  import { identify } from "../../common/middleware/user-identification.js";
7
7
  import setBlocking from "../../common/output.js";
8
+ import { validateFileExists } from "../../common/validators/argument-validators.js";
8
9
  import { create } from "../../mtls-certificates/create/handler.js";
9
10
  export default {
10
11
  desc: "Creates a new mTLS certificate for a project",
@@ -19,10 +20,12 @@ export default {
19
20
  .option("cert", {
20
21
  type: "string",
21
22
  describe: "Path to the PEM-encoded certificate file",
23
+ normalize: true,
22
24
  })
23
25
  .option("key", {
24
26
  type: "string",
25
27
  describe: "Path to the PEM-encoded private key file",
28
+ normalize: true,
26
29
  })
27
30
  .option("environment-type", {
28
31
  type: "array",
@@ -44,6 +47,11 @@ export default {
44
47
  describe: "The project name",
45
48
  })
46
49
  .demandOption(["name", "cert", "key", "environment-type"])
50
+ .check((argv) => {
51
+ validateFileExists(argv.cert, "--cert");
52
+ validateFileExists(argv.key, "--key");
53
+ return true;
54
+ })
47
55
  .example([
48
56
  [
49
57
  "$0 mtls-certificate create --name my_cert --cert ./cert.pem --key ./key.pem --environment-type production",
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/cmds/mtls-certificates/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAC1E,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,eAAe;IACb,IAAI,EAAE,8CAA8C;IACpD,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CACJ,oGAAoG,CACrG;aACA,MAAM,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,6DAA6D;SACxE,CAAC;aACD,MAAM,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,0CAA0C;SACrD,CAAC;aACD,MAAM,CAAC,KAAK,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,0CAA0C;SACrD,CAAC;aACD,MAAM,CAAC,kBAAkB,EAAE;YAC1B,IAAI,EAAE,OAAO;YACb,QAAQ,EACN,2IAA2I;YAC7I,OAAO,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,YAAY,CAAC;SAClD,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,wBAAwB;YAClC,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,QAAQ;SAChB,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,kBAAkB;SAC7B,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,kBAAkB;SAC7B,CAAC;aACD,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;aACzD,OAAO,CAAC;YACP;gBACE,2GAA2G;gBAC3G,wEAAwE;aACzE;YACD;gBACE,wIAAwI;gBACxI,mEAAmE;aACpE;YACD;gBACE,qJAAqJ;gBACrJ,4CAA4C;aAC7C;SACF,CAAC;aACD,UAAU,CAAC;YACV,WAAW;YACX,YAAY;YACZ,SAAS;YACT,YAAY;YACZ,YAAY;YACZ,QAAQ;SACT,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,+BAA+B,EAAE,CAAC,CAAC;QACrE,MAAM,MAAM,CAAC,IAAuB,CAAC,CAAC;IACxC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../common/analytics/lib.js\";\nimport { authenticate } from \"../../common/middleware/authentication.js\";\nimport { fetchAccount } from \"../../common/middleware/get-account-param.js\";\nimport { fetchProject } from \"../../common/middleware/get-project-param.js\";\nimport { configure } from \"../../common/middleware/user-configuration.js\";\nimport { identify } from \"../../common/middleware/user-identification.js\";\nimport setBlocking from \"../../common/output.js\";\nimport { create } from \"../../mtls-certificates/create/handler.js\";\nimport { CreateArguments } from \"../../mtls-certificates/models.js\";\n\nexport default {\n desc: \"Creates a new mTLS certificate for a project\",\n command: \"create\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\n \"$0 mtls-certificates create --name <name> --cert <file> --key <file> --environment <env> [options]\"\n )\n .option(\"name\", {\n type: \"string\",\n describe: \"The name of the certificate (alphanumeric with underscores)\",\n })\n .option(\"cert\", {\n type: \"string\",\n describe: \"Path to the PEM-encoded certificate file\",\n })\n .option(\"key\", {\n type: \"string\",\n describe: \"Path to the PEM-encoded private key file\",\n })\n .option(\"environment-type\", {\n type: \"array\",\n describe:\n \"Environment types where the certificate should be enabled (can be repeated: --environment-type development --environment-type production)\",\n choices: [\"development\", \"preview\", \"production\"],\n })\n .option(\"api-key\", {\n type: \"string\",\n describe: \"The API Key from Zuplo\",\n envVar: \"API_KEY\",\n alias: \"apikey\",\n })\n .option(\"account\", {\n type: \"string\",\n describe: \"The account name\",\n })\n .option(\"project\", {\n type: \"string\",\n describe: \"The project name\",\n })\n .demandOption([\"name\", \"cert\", \"key\", \"environment-type\"])\n .example([\n [\n \"$0 mtls-certificate create --name my_cert --cert ./cert.pem --key ./key.pem --environment-type production\",\n \"Create an mTLS certificate enabled for the production environment type\",\n ],\n [\n \"$0 mtls-certificate create --name dev_cert --cert ./cert.pem --key ./key.pem --environment-type development --environment-type preview\",\n \"Create an mTLS certificate enabled for multiple environment types\",\n ],\n [\n \"$0 mtls-certificate create --name my_cert --cert ./cert.pem --key ./key.pem --environment-type production --account my-account --project my-project\",\n \"Explicitly specify the account and project\",\n ],\n ])\n .middleware([\n setBlocking,\n authenticate,\n configure,\n fetchAccount,\n fetchProject,\n identify,\n ]);\n },\n handler: async (argv: unknown) => {\n await captureEvent({ argv, event: \"zuplo mtls-certificate create\" });\n await create(argv as CreateArguments);\n },\n};\n"]}
1
+ {"version":3,"file":"create.js","sourceRoot":"","sources":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YACjB,KAAK,EAAE,QAAQ;SAChB,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,kBAAkB;SAC7B,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,kBAAkB;SAC7B,CAAC;aACD,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;aACzD,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;YACd,kBAAkB,CAAC,IAAI,CAAC,IAAc,EAAE,QAAQ,CAAC,CAAC;YAClD,kBAAkB,CAAC,IAAI,CAAC,GAAa,EAAE,OAAO,CAAC,CAAC;YAChD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;aACD,OAAO,CAAC;YACP;gBACE,2GAA2G;gBAC3G,wEAAwE;aACzE;YACD;gBACE,wIAAwI;gBACxI,mEAAmE;aACpE;YACD;gBACE,qJAAqJ;gBACrJ,4CAA4C;aAC7C;SACF,CAAC;aACD,UAAU,CAAC;YACV,WAAW;YACX,YAAY;YACZ,SAAS;YACT,YAAY;YACZ,YAAY;YACZ,QAAQ;SACT,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,+BAA+B,EAAE,CAAC,CAAC;QACrE,MAAM,MAAM,CAAC,IAAuB,CAAC,CAAC;IACxC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../common/analytics/lib.js\";\nimport { authenticate } from \"../../common/middleware/authentication.js\";\nimport { fetchAccount } from \"../../common/middleware/get-account-param.js\";\nimport { fetchProject } from \"../../common/middleware/get-project-param.js\";\nimport { configure } from \"../../common/middleware/user-configuration.js\";\nimport { identify } from \"../../common/middleware/user-identification.js\";\nimport setBlocking from \"../../common/output.js\";\nimport { validateFileExists } from \"../../common/validators/argument-validators.js\";\nimport { create } from \"../../mtls-certificates/create/handler.js\";\nimport { CreateArguments } from \"../../mtls-certificates/models.js\";\n\nexport default {\n desc: \"Creates a new mTLS certificate for a project\",\n command: \"create\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\n \"$0 mtls-certificates create --name <name> --cert <file> --key <file> --environment <env> [options]\"\n )\n .option(\"name\", {\n type: \"string\",\n describe: \"The name of the certificate (alphanumeric with underscores)\",\n })\n .option(\"cert\", {\n type: \"string\",\n describe: \"Path to the PEM-encoded certificate file\",\n normalize: true,\n })\n .option(\"key\", {\n type: \"string\",\n describe: \"Path to the PEM-encoded private key file\",\n normalize: true,\n })\n .option(\"environment-type\", {\n type: \"array\",\n describe:\n \"Environment types where the certificate should be enabled (can be repeated: --environment-type development --environment-type production)\",\n choices: [\"development\", \"preview\", \"production\"],\n })\n .option(\"api-key\", {\n type: \"string\",\n describe: \"The API Key from Zuplo\",\n envVar: \"API_KEY\",\n alias: \"apikey\",\n })\n .option(\"account\", {\n type: \"string\",\n describe: \"The account name\",\n })\n .option(\"project\", {\n type: \"string\",\n describe: \"The project name\",\n })\n .demandOption([\"name\", \"cert\", \"key\", \"environment-type\"])\n .check((argv) => {\n validateFileExists(argv.cert as string, \"--cert\");\n validateFileExists(argv.key as string, \"--key\");\n return true;\n })\n .example([\n [\n \"$0 mtls-certificate create --name my_cert --cert ./cert.pem --key ./key.pem --environment-type production\",\n \"Create an mTLS certificate enabled for the production environment type\",\n ],\n [\n \"$0 mtls-certificate create --name dev_cert --cert ./cert.pem --key ./key.pem --environment-type development --environment-type preview\",\n \"Create an mTLS certificate enabled for multiple environment types\",\n ],\n [\n \"$0 mtls-certificate create --name my_cert --cert ./cert.pem --key ./key.pem --environment-type production --account my-account --project my-project\",\n \"Explicitly specify the account and project\",\n ],\n ])\n .middleware([\n setBlocking,\n authenticate,\n configure,\n fetchAccount,\n fetchProject,\n identify,\n ]);\n },\n handler: async (argv: unknown) => {\n await captureEvent({ argv, event: \"zuplo mtls-certificate create\" });\n await create(argv as CreateArguments);\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/cmds/open-api/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAOV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBA2Ef,OAAO;;AA9E/B,wBAkFE"}
1
+ {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/cmds/open-api/merge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAWV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBA0Ff,OAAO;;AA7F/B,wBAiGE"}
@@ -1,4 +1,5 @@
1
1
  import { captureEvent } from "../../common/analytics/lib.js";
2
+ import { isUrl, validateFileExists, } from "../../common/validators/argument-validators.js";
2
3
  import { importOpenApi } from "../../open-api/merge/handler.js";
3
4
  export default {
4
5
  desc: "Merge an OpenAPI file into your Zuplo project",
@@ -69,10 +70,18 @@ export default {
69
70
  ])
70
71
  .check((argv) => {
71
72
  if (!argv.source) {
72
- throw new Error("Source is required");
73
+ throw new Error("--source is required");
73
74
  }
74
75
  if (!argv.destination) {
75
- throw new Error("Destination is required");
76
+ throw new Error("--destination is required");
77
+ }
78
+ const source = argv.source;
79
+ if (!isUrl(source)) {
80
+ validateFileExists(source, "--source");
81
+ }
82
+ const destination = argv.destination;
83
+ if (!destination.endsWith(".oas.json")) {
84
+ throw new Error("--destination: File must end with .oas.json extension");
76
85
  }
77
86
  return true;
78
87
  });
@@ -1 +1 @@
1
- {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/cmds/open-api/merge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAa,aAAa,EAAE,MAA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AA0D;aAC3D;YACD;gBACE,8FAA8F;gBAC9F,sCAAsC;aACvC;YACD;gBACE,mFAAmF;gBACnF,8DAA8D;aAC/D;SACF,CAAC;aACD,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;YACd,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;YACxC,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC7C,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACvD,MAAM,aAAa,CAAC,IAAiB,CAAC,CAAC;IACzC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../common/analytics/lib.js\";\nimport { Arguments, importOpenApi } from \"../../open-api/merge/handler.js\";\n\nexport default {\n desc: \"Merge an OpenAPI file into your Zuplo project\",\n command: \"merge\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\"$0 oas merge --source <file|url> --destination <file> [options]\")\n .option(\"source\", {\n type: \"string\",\n alias: \"s\",\n demandOption: true,\n describe: \"The OpenAPI file to merge (file path or URL)\",\n })\n .option(\"destination\", {\n type: \"string\",\n alias: \"d\",\n default: \"./config/routes.oas.json\",\n describe: \"The destination file name (must end with .oas.json)\",\n })\n .option(\"merge-mode\", {\n type: \"string\",\n alias: \"m\",\n describe: \"The merge mode to use when merging the OpenAPI file\",\n choices: [\"path-method\", \"operation-id\"],\n default: \"path-method\",\n })\n .option(\"prompt\", {\n type: \"boolean\",\n describe: \"Prompt for confirmation before merging\",\n default: false,\n hidden: true,\n })\n .option(\"server-paths\", {\n type: \"boolean\",\n describe: \"Prepend the pathname from the first server URL to all paths\",\n default: true,\n })\n .option(\"prepend-path\", {\n type: \"string\",\n describe:\n \"Directly provide a path to prepend to all paths (e.g., '/v1')\",\n })\n .option(\"watch\", {\n type: \"boolean\",\n describe: \"Watch source file for changes and automatically re-merge\",\n default: false,\n })\n .example([\n [\n \"$0 oas merge --source openapi.yaml --destination ./config/routes.oas.json\",\n \"Merge an OpenAPI file into your Zuplo project\",\n ],\n [\n \"$0 oas merge -s https://api.example.com/openapi.json -d ./config/api.oas.json\",\n \"Merge an OpenAPI file from a URL\",\n ],\n [\n \"$0 oas merge --source openapi.yaml --destination ./config/routes.oas.json --merge-mode operation-id\",\n \"Merge using operation-id instead of path-method matching\",\n ],\n [\n \"$0 oas merge --source openapi.yaml --destination ./config/routes.oas.json --prepend-path /v1\",\n \"Merge and prepend '/v1' to all paths\",\n ],\n [\n \"$0 oas merge --source openapi.yaml --destination ./config/routes.oas.json --watch\",\n \"Watch the source file for changes and automatically re-merge\",\n ],\n ])\n .check((argv) => {\n if (!argv.source) {\n throw new Error(\"Source is required\");\n }\n if (!argv.destination) {\n throw new Error(\"Destination is required\");\n }\n return true;\n });\n },\n handler: async (argv: unknown) => {\n await captureEvent({ argv, event: \"zuplo oas merge\" });\n await importOpenApi(argv as Arguments);\n },\n};\n"]}
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../src/cmds/open-api/merge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EACL,KAAK,EACL,kBAAkB,GACnB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAa,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAE3E,eAAe;IACb,IAAI,EAAE,+CAA+C;IACrD,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CAAC,iEAAiE,CAAC;aACx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C,MAAM,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;YAC1C,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAC/C,CAAC;YAGD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAgB,CAAC;YACrC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnB,kBAAkB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACzC,CAAC;YAGD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAqB,CAAC;YAC/C,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACvC,MAAM,IAAI,KAAK,CACb,uDAAuD,CACxD,CAAC;YACJ,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC,CAAC;QACvD,MAAM,aAAa,CAAC,IAAiB,CAAC,CAAC;IACzC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../common/analytics/lib.js\";\nimport {\n isUrl,\n validateFileExists,\n} from \"../../common/validators/argument-validators.js\";\nimport { Arguments, importOpenApi } from \"../../open-api/merge/handler.js\";\n\nexport default {\n desc: \"Merge an OpenAPI file into your Zuplo project\",\n command: \"merge\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\"$0 oas merge --source <file|url> --destination <file> [options]\")\n .option(\"source\", {\n type: \"string\",\n alias: \"s\",\n demandOption: true,\n describe: \"The OpenAPI file to merge (file path or URL)\",\n })\n .option(\"destination\", {\n type: \"string\",\n alias: \"d\",\n default: \"./config/routes.oas.json\",\n describe: \"The destination file name (must end with .oas.json)\",\n })\n .option(\"merge-mode\", {\n type: \"string\",\n alias: \"m\",\n describe: \"The merge mode to use when merging the OpenAPI file\",\n choices: [\"path-method\", \"operation-id\"],\n default: \"path-method\",\n })\n .option(\"prompt\", {\n type: \"boolean\",\n describe: \"Prompt for confirmation before merging\",\n default: false,\n hidden: true,\n })\n .option(\"server-paths\", {\n type: \"boolean\",\n describe: \"Prepend the pathname from the first server URL to all paths\",\n default: true,\n })\n .option(\"prepend-path\", {\n type: \"string\",\n describe:\n \"Directly provide a path to prepend to all paths (e.g., '/v1')\",\n })\n .option(\"watch\", {\n type: \"boolean\",\n describe: \"Watch source file for changes and automatically re-merge\",\n default: false,\n })\n .example([\n [\n \"$0 oas merge --source openapi.yaml --destination ./config/routes.oas.json\",\n \"Merge an OpenAPI file into your Zuplo project\",\n ],\n [\n \"$0 oas merge -s https://api.example.com/openapi.json -d ./config/api.oas.json\",\n \"Merge an OpenAPI file from a URL\",\n ],\n [\n \"$0 oas merge --source openapi.yaml --destination ./config/routes.oas.json --merge-mode operation-id\",\n \"Merge using operation-id instead of path-method matching\",\n ],\n [\n \"$0 oas merge --source openapi.yaml --destination ./config/routes.oas.json --prepend-path /v1\",\n \"Merge and prepend '/v1' to all paths\",\n ],\n [\n \"$0 oas merge --source openapi.yaml --destination ./config/routes.oas.json --watch\",\n \"Watch the source file for changes and automatically re-merge\",\n ],\n ])\n .check((argv) => {\n if (!argv.source) {\n throw new Error(\"--source is required\");\n }\n if (!argv.destination) {\n throw new Error(\"--destination is required\");\n }\n\n // Validate source is a URL or an existing file\n const source = argv.source as string;\n if (!isUrl(source)) {\n validateFileExists(source, \"--source\");\n }\n\n // Validate destination ends with .oas.json\n const destination = argv.destination as string;\n if (!destination.endsWith(\".oas.json\")) {\n throw new Error(\n \"--destination: File must end with .oas.json extension\"\n );\n }\n\n return true;\n });\n },\n handler: async (argv: unknown) => {\n await captureEvent({ argv, event: \"zuplo oas merge\" });\n await importOpenApi(argv as Arguments);\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/cmds/proxies/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAaV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBA4Cf,OAAO;;AA/C/B,wBAsDE"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/cmds/proxies/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAcV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBAoDf,OAAO;;AAvD/B,wBA8DE"}
@@ -5,6 +5,7 @@ import { configure } from "../../common/middleware/user-configuration.js";
5
5
  import { identify } from "../../common/middleware/user-identification.js";
6
6
  import { validateFleet } from "../../common/middleware/validate-fleet.js";
7
7
  import setBlocking from "../../common/output.js";
8
+ import { validateFileExists } from "../../common/validators/argument-validators.js";
8
9
  import { create } from "../../proxies/create/handler.js";
9
10
  export default {
10
11
  desc: "Creates a new proxy configuration for a fleet",
@@ -19,6 +20,7 @@ export default {
19
20
  .option("configuration-file", {
20
21
  type: "string",
21
22
  describe: "Path to JSON configuration file",
23
+ normalize: true,
22
24
  })
23
25
  .option("api-key", {
24
26
  type: "string",
@@ -32,6 +34,10 @@ export default {
32
34
  })
33
35
  .demandOption(["fleet", "configuration-file"])
34
36
  .demandOption("api-key", "You must provide an API key with --api-key")
37
+ .check((argv) => {
38
+ validateFileExists(argv["configuration-file"], "--configuration-file");
39
+ return true;
40
+ })
35
41
  .example([
36
42
  [
37
43
  "$0 proxies create --fleet fleet_abc123 --configuration-file ./proxy-config.json",
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/cmds/proxies/create.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,YAAY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ACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC;YACjB,IAAI;YACJ,KAAK,EAAE,sBAAsB;SAC9B,CAAC,CAAC;QACH,MAAM,MAAM,CAAC,IAAiB,CAAC,CAAC;IAClC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../common/analytics/lib.js\";\nimport { authenticate } from \"../../common/middleware/authentication.js\";\nimport { fetchAccount } from \"../../common/middleware/get-account-param.js\";\nimport { configure } from \"../../common/middleware/user-configuration.js\";\nimport { identify } from \"../../common/middleware/user-identification.js\";\nimport { validateFleet } from \"../../common/middleware/validate-fleet.js\";\nimport setBlocking from \"../../common/output.js\";\nimport { Arguments, create } from \"../../proxies/create/handler.js\";\n\nexport default {\n desc: \"Creates a new proxy configuration for a fleet\",\n command: \"create\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\n \"$0 proxies create --fleet <fleet-id> --configuration-file <file> [options]\"\n )\n .option(\"fleet\", {\n type: \"string\",\n describe: \"The fleet ID\",\n })\n .option(\"configuration-file\", {\n type: \"string\",\n describe: \"Path to JSON configuration file\",\n })\n .option(\"api-key\", {\n type: \"string\",\n describe: \"The API Key from Zuplo\",\n envVar: \"API_KEY\",\n alias: \"apikey\",\n })\n .option(\"account\", {\n type: \"string\",\n describe: \"The account name\",\n })\n .demandOption([\"fleet\", \"configuration-file\"])\n .demandOption(\"api-key\", \"You must provide an API key with --api-key\")\n .example([\n [\n \"$0 proxies create --fleet fleet_abc123 --configuration-file ./proxy-config.json\",\n \"Create a new proxy configuration for a fleet\",\n ],\n [\n \"$0 proxies create --fleet fleet_abc123 --configuration-file ./config.json --account my-account\",\n \"Explicitly specify the account\",\n ],\n ])\n .middleware([\n setBlocking,\n authenticate,\n configure,\n fetchAccount,\n validateFleet,\n identify,\n ]);\n },\n handler: async (argv: unknown) => {\n await captureEvent({\n argv,\n event: \"zuplo proxies create\",\n });\n await create(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,EAAE,4CAA4C,CAAC;aACrE,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;YACd,kBAAkB,CAChB,IAAI,CAAC,oBAAoB,CAAW,EACpC,sBAAsB,CACvB,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;aACD,OAAO,CAAC;YACP;gBACE,iFAAiF;gBACjF,8CAA8C;aAC/C;YACD;gBACE,gGAAgG;gBAChG,gCAAgC;aACjC;SACF,CAAC;aACD,UAAU,CAAC;YACV,WAAW;YACX,YAAY;YACZ,SAAS;YACT,YAAY;YACZ,aAAa;YACb,QAAQ;SACT,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC;YACjB,IAAI;YACJ,KAAK,EAAE,sBAAsB;SAC9B,CAAC,CAAC;QACH,MAAM,MAAM,CAAC,IAAiB,CAAC,CAAC;IAClC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../common/analytics/lib.js\";\nimport { authenticate } from \"../../common/middleware/authentication.js\";\nimport { fetchAccount } from \"../../common/middleware/get-account-param.js\";\nimport { configure } from \"../../common/middleware/user-configuration.js\";\nimport { identify } from \"../../common/middleware/user-identification.js\";\nimport { validateFleet } from \"../../common/middleware/validate-fleet.js\";\nimport setBlocking from \"../../common/output.js\";\nimport { validateFileExists } from \"../../common/validators/argument-validators.js\";\nimport { Arguments, create } from \"../../proxies/create/handler.js\";\n\nexport default {\n desc: \"Creates a new proxy configuration for a fleet\",\n command: \"create\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\n \"$0 proxies create --fleet <fleet-id> --configuration-file <file> [options]\"\n )\n .option(\"fleet\", {\n type: \"string\",\n describe: \"The fleet ID\",\n })\n .option(\"configuration-file\", {\n type: \"string\",\n describe: \"Path to JSON configuration file\",\n normalize: true,\n })\n .option(\"api-key\", {\n type: \"string\",\n describe: \"The API Key from Zuplo\",\n envVar: \"API_KEY\",\n alias: \"apikey\",\n })\n .option(\"account\", {\n type: \"string\",\n describe: \"The account name\",\n })\n .demandOption([\"fleet\", \"configuration-file\"])\n .demandOption(\"api-key\", \"You must provide an API key with --api-key\")\n .check((argv) => {\n validateFileExists(\n argv[\"configuration-file\"] as string,\n \"--configuration-file\"\n );\n return true;\n })\n .example([\n [\n \"$0 proxies create --fleet fleet_abc123 --configuration-file ./proxy-config.json\",\n \"Create a new proxy configuration for a fleet\",\n ],\n [\n \"$0 proxies create --fleet fleet_abc123 --configuration-file ./config.json --account my-account\",\n \"Explicitly specify the account\",\n ],\n ])\n .middleware([\n setBlocking,\n authenticate,\n configure,\n fetchAccount,\n validateFleet,\n identify,\n ]);\n },\n handler: async (argv: unknown) => {\n await captureEvent({\n argv,\n event: \"zuplo proxies create\",\n });\n await create(argv as Arguments);\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/cmds/proxies/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAaV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBA4Cf,OAAO;;AA/C/B,wBAsDE"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/cmds/proxies/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAcV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBAoDf,OAAO;;AAvD/B,wBA8DE"}
@@ -5,6 +5,7 @@ import { configure } from "../../common/middleware/user-configuration.js";
5
5
  import { identify } from "../../common/middleware/user-identification.js";
6
6
  import { validateFleet } from "../../common/middleware/validate-fleet.js";
7
7
  import setBlocking from "../../common/output.js";
8
+ import { validateFileExists } from "../../common/validators/argument-validators.js";
8
9
  import { update } from "../../proxies/update/handler.js";
9
10
  export default {
10
11
  desc: "Updates an existing proxy configuration for a fleet",
@@ -19,6 +20,7 @@ export default {
19
20
  .option("configuration-file", {
20
21
  type: "string",
21
22
  describe: "Path to JSON configuration file",
23
+ normalize: true,
22
24
  })
23
25
  .option("api-key", {
24
26
  type: "string",
@@ -32,6 +34,10 @@ export default {
32
34
  })
33
35
  .demandOption(["fleet", "configuration-file"])
34
36
  .demandOption("api-key", "You must provide an API key with --api-key")
37
+ .check((argv) => {
38
+ validateFileExists(argv["configuration-file"], "--configuration-file");
39
+ return true;
40
+ })
35
41
  .example([
36
42
  [
37
43
  "$0 proxies update --fleet fleet_abc123 --configuration-file ./proxy-config.json",
@@ -1 +1 @@
1
- {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/cmds/proxies/update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAa,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEpE,eAAe;IACb,IAAI,EAAE,qDAAqD;IAC3D,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CACJ,4EAA4E,CAC7E;aACA,MAAM,CAAC,OAAO,EAAE;YACf,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,cAAc;SACzB,CAAC;aACD,MAAM,CAAC,oBAAoB,EAAE;YAC5B,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,iCAAiC;SAC5C,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,wBAAwB;YAClC,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,QAAQ;SAChB,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,kBAAkB;SAC7B,CAAC;aACD,YAAY,CAAC,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;aAC7C,YAAY,CAAC,SAAS,EAAE,4CAA4C,CAAC;aACrE,OAAO,CAAC;YACP;gBACE,iFAAiF;gBACjF,oDAAoD;aACrD;YACD;gBACE,wGAAwG;gBACxG,gCAAgC;aACjC;SACF,CAAC;aACD,UAAU,CAAC;YACV,WAAW;YACX,YAAY;YACZ,SAAS;YACT,YAAY;YACZ,aAAa;YACb,QAAQ;SACT,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC;YACjB,IAAI;YACJ,KAAK,EAAE,sBAAsB;SAC9B,CAAC,CAAC;QACH,MAAM,MAAM,CAAC,IAAiB,CAAC,CAAC;IAClC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../common/analytics/lib.js\";\nimport { authenticate } from \"../../common/middleware/authentication.js\";\nimport { fetchAccount } from \"../../common/middleware/get-account-param.js\";\nimport { configure } from \"../../common/middleware/user-configuration.js\";\nimport { identify } from \"../../common/middleware/user-identification.js\";\nimport { validateFleet } from \"../../common/middleware/validate-fleet.js\";\nimport setBlocking from \"../../common/output.js\";\nimport { Arguments, update } from \"../../proxies/update/handler.js\";\n\nexport default {\n desc: \"Updates an existing proxy configuration for a fleet\",\n command: \"update\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\n \"$0 proxies update --fleet <fleet-id> --configuration-file <file> [options]\"\n )\n .option(\"fleet\", {\n type: \"string\",\n describe: \"The fleet ID\",\n })\n .option(\"configuration-file\", {\n type: \"string\",\n describe: \"Path to JSON configuration file\",\n })\n .option(\"api-key\", {\n type: \"string\",\n describe: \"The API Key from Zuplo\",\n envVar: \"API_KEY\",\n alias: \"apikey\",\n })\n .option(\"account\", {\n type: \"string\",\n describe: \"The account name\",\n })\n .demandOption([\"fleet\", \"configuration-file\"])\n .demandOption(\"api-key\", \"You must provide an API key with --api-key\")\n .example([\n [\n \"$0 proxies update --fleet fleet_abc123 --configuration-file ./proxy-config.json\",\n \"Update an existing proxy configuration for a fleet\",\n ],\n [\n \"$0 proxies update --fleet fleet_abc123 --configuration-file ./updated-config.json --account my-account\",\n \"Explicitly specify the account\",\n ],\n ])\n .middleware([\n setBlocking,\n authenticate,\n configure,\n fetchAccount,\n validateFleet,\n identify,\n ]);\n },\n handler: async (argv: unknown) => {\n await captureEvent({\n argv,\n event: \"zuplo proxies update\",\n });\n await update(argv as Arguments);\n },\n};\n"]}
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/cmds/proxies/update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAa,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAEpE,eAAe;IACb,IAAI,EAAE,qDAAqD;IAC3D,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CACJ,4EAA4E,CAC7E;aACA,MAAM,CAAC,OAAO,EAAE;YACf,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,cAAc;SACzB,CAAC;aACD,MAAM,CAAC,oBAAoB,EAAE;YAC5B,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,iCAAiC;YAC3C,SAAS,EAAE,IAAI;SAChB,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,wBAAwB;YAClC,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,QAAQ;SAChB,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,kBAAkB;SAC7B,CAAC;aACD,YAAY,CAAC,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;aAC7C,YAAY,CAAC,SAAS,EAAE,4CAA4C,CAAC;aACrE,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;YACd,kBAAkB,CAChB,IAAI,CAAC,oBAAoB,CAAW,EACpC,sBAAsB,CACvB,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;aACD,OAAO,CAAC;YACP;gBACE,iFAAiF;gBACjF,oDAAoD;aACrD;YACD;gBACE,wGAAwG;gBACxG,gCAAgC;aACjC;SACF,CAAC;aACD,UAAU,CAAC;YACV,WAAW;YACX,YAAY;YACZ,SAAS;YACT,YAAY;YACZ,aAAa;YACb,QAAQ;SACT,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC;YACjB,IAAI;YACJ,KAAK,EAAE,sBAAsB;SAC9B,CAAC,CAAC;QACH,MAAM,MAAM,CAAC,IAAiB,CAAC,CAAC;IAClC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../common/analytics/lib.js\";\nimport { authenticate } from \"../../common/middleware/authentication.js\";\nimport { fetchAccount } from \"../../common/middleware/get-account-param.js\";\nimport { configure } from \"../../common/middleware/user-configuration.js\";\nimport { identify } from \"../../common/middleware/user-identification.js\";\nimport { validateFleet } from \"../../common/middleware/validate-fleet.js\";\nimport setBlocking from \"../../common/output.js\";\nimport { validateFileExists } from \"../../common/validators/argument-validators.js\";\nimport { Arguments, update } from \"../../proxies/update/handler.js\";\n\nexport default {\n desc: \"Updates an existing proxy configuration for a fleet\",\n command: \"update\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\n \"$0 proxies update --fleet <fleet-id> --configuration-file <file> [options]\"\n )\n .option(\"fleet\", {\n type: \"string\",\n describe: \"The fleet ID\",\n })\n .option(\"configuration-file\", {\n type: \"string\",\n describe: \"Path to JSON configuration file\",\n normalize: true,\n })\n .option(\"api-key\", {\n type: \"string\",\n describe: \"The API Key from Zuplo\",\n envVar: \"API_KEY\",\n alias: \"apikey\",\n })\n .option(\"account\", {\n type: \"string\",\n describe: \"The account name\",\n })\n .demandOption([\"fleet\", \"configuration-file\"])\n .demandOption(\"api-key\", \"You must provide an API key with --api-key\")\n .check((argv) => {\n validateFileExists(\n argv[\"configuration-file\"] as string,\n \"--configuration-file\"\n );\n return true;\n })\n .example([\n [\n \"$0 proxies update --fleet fleet_abc123 --configuration-file ./proxy-config.json\",\n \"Update an existing proxy configuration for a fleet\",\n ],\n [\n \"$0 proxies update --fleet fleet_abc123 --configuration-file ./updated-config.json --account my-account\",\n \"Explicitly specify the account\",\n ],\n ])\n .middleware([\n setBlocking,\n authenticate,\n configure,\n fetchAccount,\n validateFleet,\n identify,\n ]);\n },\n handler: async (argv: unknown) => {\n await captureEvent({\n argv,\n event: \"zuplo proxies update\",\n });\n await update(argv as Arguments);\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"import-openapi.d.ts","sourceRoot":"","sources":["../../../src/cmds/source/import-openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;;qBASV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBAuBf,OAAO;;AA3B/B,wBAmCE"}
1
+ {"version":3,"file":"import-openapi.d.ts","sourceRoot":"","sources":["../../../src/cmds/source/import-openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;;qBAaV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBAwCf,OAAO;;AA5C/B,wBAoDE"}
@@ -1,5 +1,6 @@
1
1
  import { captureEvent } from "../../common/analytics/lib.js";
2
2
  import { printDiagnosticsToConsole } from "../../common/output.js";
3
+ import { isUrl, validateFileExists, } from "../../common/validators/argument-validators.js";
3
4
  import { importOpenApi } from "../../open-api/merge/handler.js";
4
5
  export default {
5
6
  desc: "Import an OpenAPI file into your Zuplo project (use 'oas merge' instead)",
@@ -23,6 +24,17 @@ export default {
23
24
  describe: "The merge mode to use when importing the OpenAPI file",
24
25
  choices: ["path-method", "operation-id"],
25
26
  default: "path-method",
27
+ })
28
+ .check((argv) => {
29
+ const source = argv.source;
30
+ if (!isUrl(source)) {
31
+ validateFileExists(source, "--source");
32
+ }
33
+ const destination = argv.destination;
34
+ if (!destination.endsWith(".oas.json")) {
35
+ throw new Error("--destination: File must end with .oas.json extension");
36
+ }
37
+ return true;
26
38
  });
27
39
  },
28
40
  handler: async (argv) => {
@@ -1 +1 @@
1
- {"version":3,"file":"import-openapi.js","sourceRoot":"","sources":["../../../src/cmds/source/import-openapi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAa,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAE3E,eAAe;IACb,IAAI,EAAE,0EAA0E;IAChF,OAAO,EAAE,gBAAgB;IACzB,UAAU,EAAE,+BAA+B;IAC3C,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CACJ,yEAAyE,CAC1E;aACA,MAAM,CAAC,QAAQ,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,4BAA4B;YACtC,SAAS,EAAE,CAAC,YAAY,CAAC;SAC1B,CAAC;aACD,MAAM,CAAC,aAAa,EAAE;YACrB,IAAI,EAAE,QAAQ;YACd,QAAQ,EACN,+EAA+E;SAClF,CAAC;aACD,YAAY,CAAC,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;aACvC,MAAM,CAAC,YAAY,EAAE;YACpB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,uDAAuD;YACjE,OAAO,EAAE,CAAC,aAAa,EAAE,cAAc,CAAC;YACxC,OAAO,EAAE,aAAa;SACvB,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,yBAAyB,CACvB,6FAA6F,CAC9F,CAAC;QACF,yBAAyB,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,6BAA6B,EAAE,CAAC,CAAC;QACnE,MAAM,aAAa,CAAC,IAAiB,CAAC,CAAC;IACzC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../common/analytics/lib.js\";\nimport { printDiagnosticsToConsole } from \"../../common/output.js\";\nimport { Arguments, importOpenApi } from \"../../open-api/merge/handler.js\";\n\nexport default {\n desc: \"Import an OpenAPI file into your Zuplo project (use 'oas merge' instead)\",\n command: \"import-openapi\",\n deprecated: \"Use 'zuplo oas merge' instead\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\n \"$0 source import-openapi --source <file> --destination <file> [options]\"\n )\n .option(\"source\", {\n type: \"string\",\n describe: \"The OpenAPI file to import\",\n conflicts: [\"source-url\"],\n })\n .option(\"destination\", {\n type: \"string\",\n describe:\n \"The destination file name. Defaults to the inferred path from the source name\",\n })\n .demandOption([\"source\", \"destination\"])\n .option(\"merge-mode\", {\n type: \"string\",\n describe: \"The merge mode to use when importing the OpenAPI file\",\n choices: [\"path-method\", \"operation-id\"],\n default: \"path-method\",\n });\n },\n handler: async (argv: unknown) => {\n printDiagnosticsToConsole(\n \"WARNING: 'zuplo source import-openapi' is deprecated. Please use 'zuplo oas merge' instead.\"\n );\n printDiagnosticsToConsole(\"\");\n await captureEvent({ argv, event: \"zuplo source import-openapi\" });\n await importOpenApi(argv as Arguments);\n },\n};\n"]}
1
+ {"version":3,"file":"import-openapi.js","sourceRoot":"","sources":["../../../src/cmds/source/import-openapi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EACL,KAAK,EACL,kBAAkB,GACnB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAa,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAE3E,eAAe;IACb,IAAI,EAAE,0EAA0E;IAChF,OAAO,EAAE,gBAAgB;IACzB,UAAU,EAAE,+BAA+B;IAC3C,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CACJ,yEAAyE,CAC1E;aACA,MAAM,CAAC,QAAQ,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,4BAA4B;YACtC,SAAS,EAAE,CAAC,YAAY,CAAC;SAC1B,CAAC;aACD,MAAM,CAAC,aAAa,EAAE;YACrB,IAAI,EAAE,QAAQ;YACd,QAAQ,EACN,+EAA+E;SAClF,CAAC;aACD,YAAY,CAAC,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;aACvC,MAAM,CAAC,YAAY,EAAE;YACpB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,uDAAuD;YACjE,OAAO,EAAE,CAAC,aAAa,EAAE,cAAc,CAAC;YACxC,OAAO,EAAE,aAAa;SACvB,CAAC;aACD,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;YAEd,MAAM,MAAM,GAAG,IAAI,CAAC,MAAgB,CAAC;YACrC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnB,kBAAkB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACzC,CAAC;YAGD,MAAM,WAAW,GAAG,IAAI,CAAC,WAAqB,CAAC;YAC/C,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACvC,MAAM,IAAI,KAAK,CACb,uDAAuD,CACxD,CAAC;YACJ,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,yBAAyB,CACvB,6FAA6F,CAC9F,CAAC;QACF,yBAAyB,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,6BAA6B,EAAE,CAAC,CAAC;QACnE,MAAM,aAAa,CAAC,IAAiB,CAAC,CAAC;IACzC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../common/analytics/lib.js\";\nimport { printDiagnosticsToConsole } from \"../../common/output.js\";\nimport {\n isUrl,\n validateFileExists,\n} from \"../../common/validators/argument-validators.js\";\nimport { Arguments, importOpenApi } from \"../../open-api/merge/handler.js\";\n\nexport default {\n desc: \"Import an OpenAPI file into your Zuplo project (use 'oas merge' instead)\",\n command: \"import-openapi\",\n deprecated: \"Use 'zuplo oas merge' instead\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\n \"$0 source import-openapi --source <file> --destination <file> [options]\"\n )\n .option(\"source\", {\n type: \"string\",\n describe: \"The OpenAPI file to import\",\n conflicts: [\"source-url\"],\n })\n .option(\"destination\", {\n type: \"string\",\n describe:\n \"The destination file name. Defaults to the inferred path from the source name\",\n })\n .demandOption([\"source\", \"destination\"])\n .option(\"merge-mode\", {\n type: \"string\",\n describe: \"The merge mode to use when importing the OpenAPI file\",\n choices: [\"path-method\", \"operation-id\"],\n default: \"path-method\",\n })\n .check((argv) => {\n // Validate source is a URL or an existing file\n const source = argv.source as string;\n if (!isUrl(source)) {\n validateFileExists(source, \"--source\");\n }\n\n // Validate destination ends with .oas.json\n const destination = argv.destination as string;\n if (!destination.endsWith(\".oas.json\")) {\n throw new Error(\n \"--destination: File must end with .oas.json extension\"\n );\n }\n\n return true;\n });\n },\n handler: async (argv: unknown) => {\n printDiagnosticsToConsole(\n \"WARNING: 'zuplo source import-openapi' is deprecated. Please use 'zuplo oas merge' instead.\"\n );\n printDiagnosticsToConsole(\"\");\n await captureEvent({ argv, event: \"zuplo source import-openapi\" });\n await importOpenApi(argv as Arguments);\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/cmds/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAWV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBA4Cf,OAAO;;AA/C/B,wBAmDE"}
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/cmds/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAYV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBAgDf,OAAO;;AAnD/B,wBAuDE"}
package/dist/cmds/test.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { captureEvent } from "../common/analytics/lib.js";
2
2
  import { identify } from "../common/middleware/user-identification.js";
3
3
  import setBlocking from "../common/output.js";
4
+ import { validateUrl } from "../common/validators/argument-validators.js";
4
5
  import { validTestDirectoryValidator } from "../common/validators/file-system-validator.js";
5
6
  import { YargsChecker } from "../common/validators/lib.js";
6
7
  import { test } from "../test/handler.js";
@@ -13,6 +14,7 @@ export default {
13
14
  .option("endpoint", {
14
15
  type: "string",
15
16
  describe: "The URL of the Zuplo API to test against",
17
+ demandOption: true,
16
18
  })
17
19
  .option("filter", {
18
20
  type: "string",
@@ -44,6 +46,7 @@ export default {
44
46
  ],
45
47
  ])
46
48
  .check(async (argv) => {
49
+ validateUrl(argv.endpoint, "--endpoint");
47
50
  return await new YargsChecker(validTestDirectoryValidator).check(argv);
48
51
  })
49
52
  .middleware([setBlocking, identify]);
@@ -1 +1 @@
1
- {"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/cmds/test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AACvE,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAa,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAErD,eAAe;IACb,IAAI,EAAE,iDAAiD;IACvD,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CAAC,oCAAoC,CAAC;aAC3C,MAAM,CAAC,UAAU,EAAE;YAClB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,0CAA0C;SACrD,CAAC;aACD,MAAM,CAAC,QAAQ,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EACN,gGAAgG;SACnG,CAAC;aACD,MAAM,CAAC,KAAK,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,yCAAyC;YACnD,OAAO,EAAE,GAAG;YACZ,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,IAAI;SACb,CAAC;aACD,OAAO,CAAC;YACP;gBACE,sDAAsD;gBACtD,yCAAyC;aAC1C;YACD;gBACE,sEAAsE;gBACtE,8CAA8C;aAC/C;YACD;gBACE,4EAA4E;gBAC5E,oCAAoC;aACrC;YACD;gBACE,qEAAqE;gBACrE,sCAAsC;aACvC;SACF,CAAC;aACD,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACpB,OAAO,MAAM,IAAI,YAAY,CAC3B,2BAA2B,CAC5B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;aACD,UAAU,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;QAClD,MAAM,IAAI,CAAC,IAAiB,CAAC,CAAC;IAChC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../common/analytics/lib.js\";\nimport { identify } from \"../common/middleware/user-identification.js\";\nimport setBlocking from \"../common/output.js\";\nimport { validTestDirectoryValidator } from \"../common/validators/file-system-validator.js\";\nimport { YargsChecker } from \"../common/validators/lib.js\";\nimport { Arguments, test } from \"../test/handler.js\";\n\nexport default {\n desc: \"Runs the tests under /tests against an endpoint\",\n command: \"test\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\"$0 test --endpoint <url> [options]\")\n .option(\"endpoint\", {\n type: \"string\",\n describe: \"The URL of the Zuplo API to test against\",\n })\n .option(\"filter\", {\n type: \"string\",\n describe:\n \"A filter to run a subset of tests (e.g., --filter 'test name' or --filter '/test-name-regex/')\",\n })\n .option(\"dir\", {\n type: \"string\",\n describe: \"The directory containing your Zuplo API\",\n default: \".\",\n normalize: true,\n hidden: true,\n })\n .example([\n [\n \"$0 test --endpoint https://your-api-123abc.zuplo.app\",\n \"Run all tests against your deployed API\",\n ],\n [\n \"$0 test --endpoint https://your-api-123abc.zuplo.app --filter 'auth'\",\n \"Run only tests matching 'auth' in their name\",\n ],\n [\n \"$0 test --endpoint https://your-api-123abc.zuplo.app --filter '/api\\\\/v1/'\",\n \"Run tests matching a regex pattern\",\n ],\n [\n \"MY_VAR=example $0 test --endpoint https://your-api-123abc.zuplo.app\",\n \"Run tests with environment variables\",\n ],\n ])\n .check(async (argv) => {\n return await new YargsChecker<typeof argv>(\n validTestDirectoryValidator\n ).check(argv);\n })\n .middleware([setBlocking, identify]);\n },\n handler: async (argv: unknown) => {\n await captureEvent({ argv, event: \"zuplo test\" });\n await test(argv as Arguments);\n },\n};\n"]}
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/cmds/test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AACvE,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+CAA+C,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAa,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAErD,eAAe;IACb,IAAI,EAAE,iDAAiD;IACvD,OAAO,EAAE,MAAM;IACf,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CAAC,oCAAoC,CAAC;aAC3C,MAAM,CAAC,UAAU,EAAE;YAClB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,0CAA0C;YACpD,YAAY,EAAE,IAAI;SACnB,CAAC;aACD,MAAM,CAAC,QAAQ,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EACN,gGAAgG;SACnG,CAAC;aACD,MAAM,CAAC,KAAK,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,yCAAyC;YACnD,OAAO,EAAE,GAAG;YACZ,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,IAAI;SACb,CAAC;aACD,OAAO,CAAC;YACP;gBACE,sDAAsD;gBACtD,yCAAyC;aAC1C;YACD;gBACE,sEAAsE;gBACtE,8CAA8C;aAC/C;YACD;gBACE,4EAA4E;gBAC5E,oCAAoC;aACrC;YACD;gBACE,qEAAqE;gBACrE,sCAAsC;aACvC;SACF,CAAC;aACD,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YAEpB,WAAW,CAAC,IAAI,CAAC,QAAkB,EAAE,YAAY,CAAC,CAAC;YAEnD,OAAO,MAAM,IAAI,YAAY,CAC3B,2BAA2B,CAC5B,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,CAAC;aACD,UAAU,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;QAClD,MAAM,IAAI,CAAC,IAAiB,CAAC,CAAC;IAChC,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../common/analytics/lib.js\";\nimport { identify } from \"../common/middleware/user-identification.js\";\nimport setBlocking from \"../common/output.js\";\nimport { validateUrl } from \"../common/validators/argument-validators.js\";\nimport { validTestDirectoryValidator } from \"../common/validators/file-system-validator.js\";\nimport { YargsChecker } from \"../common/validators/lib.js\";\nimport { Arguments, test } from \"../test/handler.js\";\n\nexport default {\n desc: \"Runs the tests under /tests against an endpoint\",\n command: \"test\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\"$0 test --endpoint <url> [options]\")\n .option(\"endpoint\", {\n type: \"string\",\n describe: \"The URL of the Zuplo API to test against\",\n demandOption: true,\n })\n .option(\"filter\", {\n type: \"string\",\n describe:\n \"A filter to run a subset of tests (e.g., --filter 'test name' or --filter '/test-name-regex/')\",\n })\n .option(\"dir\", {\n type: \"string\",\n describe: \"The directory containing your Zuplo API\",\n default: \".\",\n normalize: true,\n hidden: true,\n })\n .example([\n [\n \"$0 test --endpoint https://your-api-123abc.zuplo.app\",\n \"Run all tests against your deployed API\",\n ],\n [\n \"$0 test --endpoint https://your-api-123abc.zuplo.app --filter 'auth'\",\n \"Run only tests matching 'auth' in their name\",\n ],\n [\n \"$0 test --endpoint https://your-api-123abc.zuplo.app --filter '/api\\\\/v1/'\",\n \"Run tests matching a regex pattern\",\n ],\n [\n \"MY_VAR=example $0 test --endpoint https://your-api-123abc.zuplo.app\",\n \"Run tests with environment variables\",\n ],\n ])\n .check(async (argv) => {\n // Validate endpoint is a valid URL\n validateUrl(argv.endpoint as string, \"--endpoint\");\n\n return await new YargsChecker<typeof argv>(\n validTestDirectoryValidator\n ).check(argv);\n })\n .middleware([setBlocking, identify]);\n },\n handler: async (argv: unknown) => {\n await captureEvent({ argv, event: \"zuplo test\" });\n await test(argv as Arguments);\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/cmds/tunnel/services/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAeV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBAuCf,OAAO;;AA1C/B,wBA8CE"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/cmds/tunnel/services/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;;;;qBAgBV,IAAI,KAAG,IAAI,CAAC,OAAO,CAAC;oBA+Cf,OAAO;;AAlD/B,wBAsDE"}
@@ -4,6 +4,7 @@ import { fetchAccount } from "../../../common/middleware/get-account-param.js";
4
4
  import { configure } from "../../../common/middleware/user-configuration.js";
5
5
  import { identify } from "../../../common/middleware/user-identification.js";
6
6
  import setBlocking from "../../../common/output.js";
7
+ import { validateFileExists } from "../../../common/validators/argument-validators.js";
7
8
  import { updateServices, } from "../../../tunnel/services/update/handler.js";
8
9
  export default {
9
10
  desc: "Updates the services for this tunnel",
@@ -14,6 +15,7 @@ export default {
14
15
  .option("configuration-file", {
15
16
  type: "string",
16
17
  describe: "The path to the configuration file",
18
+ normalize: true,
17
19
  })
18
20
  .option("tunnel-id", {
19
21
  type: "string",
@@ -27,6 +29,10 @@ export default {
27
29
  })
28
30
  .demandOption(["configuration-file", "tunnel-id"])
29
31
  .demandOption("api-key", "You must provide an API key with --api-key")
32
+ .check((argv) => {
33
+ validateFileExists(argv["configuration-file"], "--configuration-file");
34
+ return true;
35
+ })
30
36
  .example([
31
37
  [
32
38
  "$0 tunnel services update --tunnel-id tnl_TRMZwunq2PLNQDwhu6A04Bmx --configuration-file ./services.json",
@@ -1 +1 @@
1
- {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/cmds/tunnel/services/update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,WAAW,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAEL,cAAc,GACf,MAAM,4CAA4C,CAAC;AAEpD,eAAe;IACb,IAAI,EAAE,sCAAsC;IAC5C,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CACJ,kFAAkF,CACnF;aACA,MAAM,CAAC,oBAAoB,EAAE;YAC5B,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,oCAAoC;SAC/C,CAAC;aACD,MAAM,CAAC,WAAW,EAAE;YACnB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,8CAA8C;SACzD,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,wBAAwB;YAClC,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,QAAQ;SAChB,CAAC;aACD,YAAY,CAAC,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;aACjD,YAAY,CAAC,SAAS,EAAE,4CAA4C,CAAC;aACrE,OAAO,CAAC;YACP;gBACE,yGAAyG;gBACzG,gDAAgD;aACjD;YACD;gBACE,4IAA4I;gBAC5I,gCAAgC;aACjC;SACF,CAAC;aACD,UAAU,CAAC;YACV,WAAW;YACX,YAAY;YACZ,SAAS;YACT,YAAY;YACZ,QAAQ;SACT,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,8BAA8B,EAAE,CAAC,CAAC;QACpE,MAAM,cAAc,CAAC,IAAiB,CAAC,CAAC;IAC1C,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../../common/analytics/lib.js\";\nimport { authenticate } from \"../../../common/middleware/authentication.js\";\nimport { fetchAccount } from \"../../../common/middleware/get-account-param.js\";\nimport { configure } from \"../../../common/middleware/user-configuration.js\";\nimport { identify } from \"../../../common/middleware/user-identification.js\";\nimport setBlocking from \"../../../common/output.js\";\nimport {\n Arguments,\n updateServices,\n} from \"../../../tunnel/services/update/handler.js\";\n\nexport default {\n desc: \"Updates the services for this tunnel\",\n command: \"update\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\n \"$0 tunnel services update --tunnel-id <id> --configuration-file <file> [options]\"\n )\n .option(\"configuration-file\", {\n type: \"string\",\n describe: \"The path to the configuration file\",\n })\n .option(\"tunnel-id\", {\n type: \"string\",\n describe: \"The ID of the tunnel containing the services\",\n })\n .option(\"api-key\", {\n type: \"string\",\n describe: \"The API Key from Zuplo\",\n envVar: \"API_KEY\",\n alias: \"apikey\",\n })\n .demandOption([\"configuration-file\", \"tunnel-id\"])\n .demandOption(\"api-key\", \"You must provide an API key with --api-key\")\n .example([\n [\n \"$0 tunnel services update --tunnel-id tnl_TRMZwunq2PLNQDwhu6A04Bmx --configuration-file ./services.json\",\n \"Update the services configuration for a tunnel\",\n ],\n [\n \"$0 tunnel services update --tunnel-id tnl_TRMZwunq2PLNQDwhu6A04Bmx --configuration-file ./config/tunnel-services.json --account my-account\",\n \"Explicitly specify the account\",\n ],\n ])\n .middleware([\n setBlocking,\n authenticate,\n configure,\n fetchAccount,\n identify,\n ]);\n },\n handler: async (argv: unknown) => {\n await captureEvent({ argv, event: \"zuplo tunnel services update\" });\n await updateServices(argv as Arguments);\n },\n};\n"]}
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/cmds/tunnel/services/update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,kDAAkD,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,WAAW,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvF,OAAO,EAEL,cAAc,GACf,MAAM,4CAA4C,CAAC;AAEpD,eAAe;IACb,IAAI,EAAE,sCAAsC;IAC5C,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,CAAC,KAAW,EAAiB,EAAE;QACtC,OAAO,KAAK;aACT,KAAK,CACJ,kFAAkF,CACnF;aACA,MAAM,CAAC,oBAAoB,EAAE;YAC5B,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,oCAAoC;YAC9C,SAAS,EAAE,IAAI;SAChB,CAAC;aACD,MAAM,CAAC,WAAW,EAAE;YACnB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,8CAA8C;SACzD,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACjB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,wBAAwB;YAClC,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,QAAQ;SAChB,CAAC;aACD,YAAY,CAAC,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;aACjD,YAAY,CAAC,SAAS,EAAE,4CAA4C,CAAC;aACrE,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;YACd,kBAAkB,CAChB,IAAI,CAAC,oBAAoB,CAAW,EACpC,sBAAsB,CACvB,CAAC;YACF,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;aACD,OAAO,CAAC;YACP;gBACE,yGAAyG;gBACzG,gDAAgD;aACjD;YACD;gBACE,4IAA4I;gBAC5I,gCAAgC;aACjC;SACF,CAAC;aACD,UAAU,CAAC;YACV,WAAW;YACX,YAAY;YACZ,SAAS;YACT,YAAY;YACZ,QAAQ;SACT,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAa,EAAE,EAAE;QAC/B,MAAM,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,8BAA8B,EAAE,CAAC,CAAC;QACpE,MAAM,cAAc,CAAC,IAAiB,CAAC,CAAC;IAC1C,CAAC;CACF,CAAC","sourcesContent":["import { Argv } from \"yargs\";\nimport { captureEvent } from \"../../../common/analytics/lib.js\";\nimport { authenticate } from \"../../../common/middleware/authentication.js\";\nimport { fetchAccount } from \"../../../common/middleware/get-account-param.js\";\nimport { configure } from \"../../../common/middleware/user-configuration.js\";\nimport { identify } from \"../../../common/middleware/user-identification.js\";\nimport setBlocking from \"../../../common/output.js\";\nimport { validateFileExists } from \"../../../common/validators/argument-validators.js\";\nimport {\n Arguments,\n updateServices,\n} from \"../../../tunnel/services/update/handler.js\";\n\nexport default {\n desc: \"Updates the services for this tunnel\",\n command: \"update\",\n builder: (yargs: Argv): Argv<unknown> => {\n return yargs\n .usage(\n \"$0 tunnel services update --tunnel-id <id> --configuration-file <file> [options]\"\n )\n .option(\"configuration-file\", {\n type: \"string\",\n describe: \"The path to the configuration file\",\n normalize: true,\n })\n .option(\"tunnel-id\", {\n type: \"string\",\n describe: \"The ID of the tunnel containing the services\",\n })\n .option(\"api-key\", {\n type: \"string\",\n describe: \"The API Key from Zuplo\",\n envVar: \"API_KEY\",\n alias: \"apikey\",\n })\n .demandOption([\"configuration-file\", \"tunnel-id\"])\n .demandOption(\"api-key\", \"You must provide an API key with --api-key\")\n .check((argv) => {\n validateFileExists(\n argv[\"configuration-file\"] as string,\n \"--configuration-file\"\n );\n return true;\n })\n .example([\n [\n \"$0 tunnel services update --tunnel-id tnl_TRMZwunq2PLNQDwhu6A04Bmx --configuration-file ./services.json\",\n \"Update the services configuration for a tunnel\",\n ],\n [\n \"$0 tunnel services update --tunnel-id tnl_TRMZwunq2PLNQDwhu6A04Bmx --configuration-file ./config/tunnel-services.json --account my-account\",\n \"Explicitly specify the account\",\n ],\n ])\n .middleware([\n setBlocking,\n authenticate,\n configure,\n fetchAccount,\n identify,\n ]);\n },\n handler: async (argv: unknown) => {\n await captureEvent({ argv, event: \"zuplo tunnel services update\" });\n await updateServices(argv as Arguments);\n },\n};\n"]}
@@ -0,0 +1,30 @@
1
+ export declare function validateFileExists(
2
+ filePath: string,
3
+ optionName: string
4
+ ): string;
5
+ export declare function validateDirectoryExists(
6
+ dirPath: string,
7
+ optionName: string
8
+ ): string;
9
+ export declare function validatePort(port: number, optionName: string): number;
10
+ export declare function validateUrl(
11
+ urlString: string,
12
+ optionName: string
13
+ ): string;
14
+ export declare function validateFileExtension(
15
+ filePath: string,
16
+ validExtensions: string[],
17
+ optionName: string
18
+ ): string;
19
+ export declare function validatePattern(
20
+ value: string,
21
+ pattern: RegExp,
22
+ optionName: string,
23
+ patternDescription: string
24
+ ): string;
25
+ export declare function isUrl(value: string): boolean;
26
+ export declare function validateFileOrUrl(
27
+ source: string,
28
+ optionName: string
29
+ ): string;
30
+ //# sourceMappingURL=argument-validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argument-validators.d.ts","sourceRoot":"","sources":["../../../src/common/validators/argument-validators.ts"],"names":[],"mappings":"AASA,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,MAAM,CAmBR;AAQD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,MAAM,CAmBR;AAQD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAUrE;AAQD,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAgBzE;AASD,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,EAAE,EACzB,UAAU,EAAE,MAAM,GACjB,MAAM,CAQR;AAUD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,kBAAkB,EAAE,MAAM,GACzB,MAAM,CAKR;AAOD,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAO5C;AASD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAK5E"}
@@ -0,0 +1,89 @@
1
+ import { accessSync, constants, existsSync, statSync } from "node:fs";
2
+ import path from "node:path";
3
+ export function validateFileExists(filePath, optionName) {
4
+ const resolvedPath = path.resolve(filePath);
5
+ if (!existsSync(resolvedPath)) {
6
+ throw new Error(`${optionName}: File not found: ${filePath}`);
7
+ }
8
+ try {
9
+ accessSync(resolvedPath, constants.R_OK);
10
+ }
11
+ catch {
12
+ throw new Error(`${optionName}: File is not readable: ${filePath}`);
13
+ }
14
+ const stats = statSync(resolvedPath);
15
+ if (!stats.isFile()) {
16
+ throw new Error(`${optionName}: Path is not a file: ${filePath}`);
17
+ }
18
+ return resolvedPath;
19
+ }
20
+ export function validateDirectoryExists(dirPath, optionName) {
21
+ const resolvedPath = path.resolve(dirPath);
22
+ if (!existsSync(resolvedPath)) {
23
+ throw new Error(`${optionName}: Directory not found: ${dirPath}`);
24
+ }
25
+ try {
26
+ accessSync(resolvedPath, constants.R_OK);
27
+ }
28
+ catch {
29
+ throw new Error(`${optionName}: Directory is not readable: ${dirPath}`);
30
+ }
31
+ const stats = statSync(resolvedPath);
32
+ if (!stats.isDirectory()) {
33
+ throw new Error(`${optionName}: Path is not a directory: ${dirPath}`);
34
+ }
35
+ return resolvedPath;
36
+ }
37
+ export function validatePort(port, optionName) {
38
+ if (!Number.isInteger(port)) {
39
+ throw new Error(`${optionName}: Port must be an integer, got: ${port}`);
40
+ }
41
+ if (port < 1 || port > 65535) {
42
+ throw new Error(`${optionName}: Port must be between 1 and 65535, got: ${port}`);
43
+ }
44
+ return port;
45
+ }
46
+ export function validateUrl(urlString, optionName) {
47
+ try {
48
+ const url = new URL(urlString);
49
+ if (!["http:", "https:"].includes(url.protocol)) {
50
+ throw new Error(`${optionName}: URL must use http or https protocol, got: ${url.protocol}`);
51
+ }
52
+ return urlString;
53
+ }
54
+ catch (error) {
55
+ if (error instanceof Error && error.message.includes("protocol")) {
56
+ throw error;
57
+ }
58
+ throw new Error(`${optionName}: Invalid URL format: ${urlString}`);
59
+ }
60
+ }
61
+ export function validateFileExtension(filePath, validExtensions, optionName) {
62
+ const ext = path.extname(filePath).toLowerCase();
63
+ if (!validExtensions.includes(ext)) {
64
+ throw new Error(`${optionName}: File must have one of these extensions: ${validExtensions.join(", ")}, got: ${ext || "(none)"}`);
65
+ }
66
+ return filePath;
67
+ }
68
+ export function validatePattern(value, pattern, optionName, patternDescription) {
69
+ if (!pattern.test(value)) {
70
+ throw new Error(`${optionName}: Value must ${patternDescription}`);
71
+ }
72
+ return value;
73
+ }
74
+ export function isUrl(value) {
75
+ try {
76
+ const url = new URL(value);
77
+ return ["http:", "https:"].includes(url.protocol);
78
+ }
79
+ catch {
80
+ return false;
81
+ }
82
+ }
83
+ export function validateFileOrUrl(source, optionName) {
84
+ if (isUrl(source)) {
85
+ return validateUrl(source, optionName);
86
+ }
87
+ return validateFileExists(source, optionName);
88
+ }
89
+ //# sourceMappingURL=argument-validators.js.map