@zuplo/cli 1.96.0 → 1.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="18229bd2-cc3c-521a-93e5-30a1d8f03044")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="91ee157c-141d-5381-a1b8-ef9f2f5625d8")}catch(e){}}();
3
3
  import { captureEvent } from "../../common/analytics/lib.js";
4
4
  import setBlocking from "../../common/output.js";
5
5
  import { ZuploProjectValidator } from "../../common/validators/file-system-validator.js";
@@ -26,6 +26,10 @@ export default {
26
26
  type: "string",
27
27
  describe: "The OpenAPI file to import",
28
28
  conflicts: ["source-url"],
29
+ })
30
+ .option("destination", {
31
+ type: "string",
32
+ describe: "The destination file name. Defaults to the inferred path from the source name",
29
33
  })
30
34
  .demandOption(["source"])
31
35
  .middleware([setBlocking])
@@ -39,4 +43,4 @@ export default {
39
43
  },
40
44
  };
41
45
  //# sourceMappingURL=import-openapi.js.map
42
- //# debugId=18229bd2-cc3c-521a-93e5-30a1d8f03044
46
+ //# debugId=91ee157c-141d-5381-a1b8-ef9f2f5625d8
@@ -1,11 +1,11 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f08b6c48-3b56-54ec-b0b8-3e814ec8612f")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="084826a4-e8ee-5dc8-9b9b-486425443698")}catch(e){}}();
3
3
  import { confirm } from "@inquirer/prompts";
4
4
  import jsYaml from "js-yaml";
5
5
  import { existsSync, writeFileSync } from "node:fs";
6
6
  import { mkdir, readFile, writeFile } from "node:fs/promises";
7
7
  import { tmpdir } from "node:os";
8
- import { basename, dirname, extname, join, relative } from "node:path";
8
+ import { basename, dirname, extname, join, relative, sep } from "node:path";
9
9
  import prettier from "prettier";
10
10
  import { logger } from "../../common/logger.js";
11
11
  import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, } from "../../common/output.js";
@@ -39,6 +39,9 @@ export async function importOpenApi(argv) {
39
39
  await mkdir(dirname(normalizedFilePath), { recursive: true });
40
40
  try {
41
41
  const response = await fetch(parsedUrl);
42
+ if (!response.ok) {
43
+ await printCriticalFailureToConsoleAndExit(`Failed to download the remote OpenAPI file. Server responded with ${response.status} ${response.statusText}`);
44
+ }
42
45
  const text = await response.text();
43
46
  try {
44
47
  const _json = JSON.parse(text);
@@ -73,7 +76,19 @@ export async function importOpenApi(argv) {
73
76
  const basePath = basename(normalizedFilePath, extName);
74
77
  const fileContent = rawOpenApiSpec.toString();
75
78
  const parsedOpenApiSpec = await parseOpenApiFile(extName, fileContent);
76
- const destinationFilePath = join(process.cwd(), "config", `${basePath.replace("oas", "")}.oas.json`);
79
+ let destinationFilePath = join(process.cwd(), "config", `${basePath.replace(".oas", "")}.oas.json`);
80
+ if (argv.destination) {
81
+ const destination = argv.destination;
82
+ if (destination.includes(sep)) {
83
+ await printCriticalFailureToConsoleAndExit(`File names should not be nested with file separators.`);
84
+ }
85
+ if (destination.endsWith("oas.json")) {
86
+ destinationFilePath = join(process.cwd(), "config", destination);
87
+ }
88
+ else {
89
+ destinationFilePath = join(process.cwd(), "config", `${destination.replace(".oas", "")}.oas.json`);
90
+ }
91
+ }
77
92
  let originalDocument;
78
93
  if (!existsSync(destinationFilePath)) {
79
94
  originalDocument = (await parseOpenApiFile(".json", BASE_TEMPLATE));
@@ -127,4 +142,4 @@ export async function importOpenApi(argv) {
127
142
  await printResultToConsoleAndExitGracefully(`Import successful. File written to ${destinationFilePath}`);
128
143
  }
129
144
  //# sourceMappingURL=handler.js.map
130
- //# debugId=f08b6c48-3b56-54ec-b0b8-3e814ec8612f
145
+ //# debugId=084826a4-e8ee-5dc8-9b9b-486425443698
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "1.96.0",
3
+ "version": "1.98.0",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/zuplo/cli",
6
6
  "description": "The command-line interface for Zuplo",