@zuplo/cli 1.97.0 → 1.99.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]="
|
|
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=
|
|
46
|
+
//# debugId=91ee157c-141d-5381-a1b8-ef9f2f5625d8
|
package/dist/dev/handler.js
CHANGED
|
@@ -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]="
|
|
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]="4a8615df-d2b4-5848-86ad-a1cf7f258048")}catch(e){}}();
|
|
3
3
|
import { cpSync, existsSync } from "node:fs";
|
|
4
4
|
import { join, relative, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -44,6 +44,7 @@ export async function dev(argv) {
|
|
|
44
44
|
let editor;
|
|
45
45
|
if (argv["start-editor"]) {
|
|
46
46
|
editor = new ApiServer({
|
|
47
|
+
cliArgs: argv,
|
|
47
48
|
workingDir: sourceDirectory,
|
|
48
49
|
port: argv.editorPort,
|
|
49
50
|
isStandalone: false,
|
|
@@ -77,4 +78,4 @@ export async function dev(argv) {
|
|
|
77
78
|
});
|
|
78
79
|
}
|
|
79
80
|
//# sourceMappingURL=handler.js.map
|
|
80
|
-
//# debugId=
|
|
81
|
+
//# debugId=4a8615df-d2b4-5848-86ad-a1cf7f258048
|
package/dist/editor/handler.js
CHANGED
|
@@ -1,10 +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]="
|
|
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]="9e4106dc-1dc1-522d-9fb8-0657dd99f9f9")}catch(e){}}();
|
|
3
3
|
import { logger } from "../common/logger.js";
|
|
4
4
|
import { ApiServer } from "./server/server.js";
|
|
5
5
|
export async function editor(argv) {
|
|
6
6
|
const workingDir = argv.dir || process.cwd();
|
|
7
7
|
const server = new ApiServer({
|
|
8
|
+
cliArgs: argv,
|
|
8
9
|
workingDir,
|
|
9
10
|
port: argv.port,
|
|
10
11
|
isStandalone: true,
|
|
@@ -22,4 +23,4 @@ export async function editor(argv) {
|
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
//# sourceMappingURL=handler.js.map
|
|
25
|
-
//# debugId=
|
|
26
|
+
//# debugId=9e4106dc-1dc1-522d-9fb8-0657dd99f9f9
|
|
@@ -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]="
|
|
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]="421dfa2f-b392-5e9d-9e07-f810a3e4295f")}catch(e){}}();
|
|
3
3
|
import fastifyStatic from "@fastify/static";
|
|
4
4
|
import chokidar from "chokidar";
|
|
5
5
|
import Fastify from "fastify";
|
|
@@ -7,6 +7,7 @@ import { FastifySSEPlugin } from "fastify-sse-v2";
|
|
|
7
7
|
import fs, { readFile, readdir } from "node:fs/promises";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { captureEvent, shutdownAnalytics } from "../../common/analytics/lib.js";
|
|
10
11
|
import { logger } from "../../common/logger.js";
|
|
11
12
|
import { printDiagnosticsToConsole } from "../../common/output.js";
|
|
12
13
|
import { corsPlugin } from "./cors-plugin.js";
|
|
@@ -15,17 +16,20 @@ const POLICIES_FILENAME = "policies.json";
|
|
|
15
16
|
const CONFIG_DIR = "config";
|
|
16
17
|
export class ApiServer {
|
|
17
18
|
fastify;
|
|
18
|
-
listenerPort;
|
|
19
|
-
isStandalone;
|
|
20
19
|
listenerHost;
|
|
21
|
-
workingDir;
|
|
22
20
|
watcher;
|
|
23
21
|
sseContext;
|
|
22
|
+
cliArgs;
|
|
23
|
+
workingDir;
|
|
24
|
+
listenerPort;
|
|
25
|
+
isStandalone;
|
|
24
26
|
constructor(options = {
|
|
27
|
+
cliArgs: {},
|
|
25
28
|
workingDir: ".",
|
|
26
29
|
port: 9100,
|
|
27
30
|
isStandalone: true,
|
|
28
31
|
}) {
|
|
32
|
+
this.cliArgs = options.cliArgs;
|
|
29
33
|
this.workingDir = options.workingDir;
|
|
30
34
|
this.listenerPort = options.port;
|
|
31
35
|
this.isStandalone = options.isStandalone;
|
|
@@ -38,6 +42,7 @@ export class ApiServer {
|
|
|
38
42
|
});
|
|
39
43
|
}
|
|
40
44
|
init = async () => {
|
|
45
|
+
const cliArgs = this.cliArgs;
|
|
41
46
|
this.fastify.register(corsPlugin, { origin: true });
|
|
42
47
|
this.fastify.register(FastifySSEPlugin);
|
|
43
48
|
const editorRootPath = fileURLToPath(new URL("../", import.meta.url));
|
|
@@ -47,6 +52,7 @@ export class ApiServer {
|
|
|
47
52
|
this.fastify.register((instance, _options, done) => {
|
|
48
53
|
instance.get("/", {
|
|
49
54
|
handler: async (_request, reply) => {
|
|
55
|
+
await captureEvent({ argv: cliArgs, event: "route-designer: /" });
|
|
50
56
|
let html = await readFile(path.join(editorRootPath, "index.html"), "utf-8");
|
|
51
57
|
html = html.replace("__SERVER_DATA__", JSON.stringify({
|
|
52
58
|
server_address: this.listenerHost,
|
|
@@ -57,6 +63,10 @@ export class ApiServer {
|
|
|
57
63
|
});
|
|
58
64
|
instance.get("/open-api-content", {
|
|
59
65
|
handler: async (request, reply) => {
|
|
66
|
+
await captureEvent({
|
|
67
|
+
argv: cliArgs,
|
|
68
|
+
event: "route-designer: /open-api-content",
|
|
69
|
+
});
|
|
60
70
|
const { path: filePath } = request.query;
|
|
61
71
|
if (filePath === null || filePath === undefined) {
|
|
62
72
|
return reply.code(404).send("You must select a file to work with");
|
|
@@ -90,6 +100,10 @@ export class ApiServer {
|
|
|
90
100
|
});
|
|
91
101
|
instance.get("/open-api-files", {
|
|
92
102
|
handler: async (request, reply) => {
|
|
103
|
+
await captureEvent({
|
|
104
|
+
argv: cliArgs,
|
|
105
|
+
event: "route-designer: /open-api-files",
|
|
106
|
+
});
|
|
93
107
|
const projectConfigPath = path.join(this.workingDir, CONFIG_DIR);
|
|
94
108
|
if (!(await dirExists(projectConfigPath))) {
|
|
95
109
|
request.log.warn(`Cannot find the project '${CONFIG_DIR}' folder. Make sure '${this.workingDir}' has a '${CONFIG_DIR}' folder.`);
|
|
@@ -106,6 +120,10 @@ export class ApiServer {
|
|
|
106
120
|
method: "POST",
|
|
107
121
|
url: "/save-open-api-updates",
|
|
108
122
|
handler: async (request, reply) => {
|
|
123
|
+
await captureEvent({
|
|
124
|
+
argv: cliArgs,
|
|
125
|
+
event: "route-designer: /save-open-api-updates",
|
|
126
|
+
});
|
|
109
127
|
const bodyContent = request.body;
|
|
110
128
|
bodyContent.forEach(async (fileData) => {
|
|
111
129
|
const openApiFilePath = path.join(this.workingDir, "config", fileData.filePath);
|
|
@@ -121,6 +139,10 @@ export class ApiServer {
|
|
|
121
139
|
});
|
|
122
140
|
instance.get("/updates", {
|
|
123
141
|
handler: async (request, reply) => {
|
|
142
|
+
await captureEvent({
|
|
143
|
+
argv: cliArgs,
|
|
144
|
+
event: "route-designer: /updates",
|
|
145
|
+
});
|
|
124
146
|
if (this.watcher && this.watcher.closed === true) {
|
|
125
147
|
this.watcher = chokidar.watch(path.join(this.workingDir, CONFIG_DIR));
|
|
126
148
|
}
|
|
@@ -141,6 +163,10 @@ export class ApiServer {
|
|
|
141
163
|
});
|
|
142
164
|
instance.get("/modules-data", {
|
|
143
165
|
handler: async (request, reply) => {
|
|
166
|
+
await captureEvent({
|
|
167
|
+
argv: cliArgs,
|
|
168
|
+
event: "route-designer: /modules-data",
|
|
169
|
+
});
|
|
144
170
|
const projectModulesPath = path.join(this.workingDir, "modules");
|
|
145
171
|
if (!(await dirExists(projectModulesPath))) {
|
|
146
172
|
request.log.warn(`Cannot find the project 'modules' folder. Make sure '${this.workingDir}' has a 'modules' folder.`);
|
|
@@ -211,6 +237,7 @@ export class ApiServer {
|
|
|
211
237
|
printDiagnosticsToConsole("Closing route designer");
|
|
212
238
|
}
|
|
213
239
|
try {
|
|
240
|
+
shutdownAnalytics();
|
|
214
241
|
if (this.sseContext) {
|
|
215
242
|
this.sseContext.source.end();
|
|
216
243
|
}
|
|
@@ -226,4 +253,4 @@ export class ApiServer {
|
|
|
226
253
|
};
|
|
227
254
|
}
|
|
228
255
|
//# sourceMappingURL=server.js.map
|
|
229
|
-
//# debugId=
|
|
256
|
+
//# debugId=421dfa2f-b392-5e9d-9e07-f810a3e4295f
|
|
@@ -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]="
|
|
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";
|
|
@@ -76,7 +76,19 @@ export async function importOpenApi(argv) {
|
|
|
76
76
|
const basePath = basename(normalizedFilePath, extName);
|
|
77
77
|
const fileContent = rawOpenApiSpec.toString();
|
|
78
78
|
const parsedOpenApiSpec = await parseOpenApiFile(extName, fileContent);
|
|
79
|
-
|
|
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
|
+
}
|
|
80
92
|
let originalDocument;
|
|
81
93
|
if (!existsSync(destinationFilePath)) {
|
|
82
94
|
originalDocument = (await parseOpenApiFile(".json", BASE_TEMPLATE));
|
|
@@ -130,4 +142,4 @@ export async function importOpenApi(argv) {
|
|
|
130
142
|
await printResultToConsoleAndExitGracefully(`Import successful. File written to ${destinationFilePath}`);
|
|
131
143
|
}
|
|
132
144
|
//# sourceMappingURL=handler.js.map
|
|
133
|
-
//# debugId=
|
|
145
|
+
//# debugId=084826a4-e8ee-5dc8-9b9b-486425443698
|