@zuplo/cli 1.25.0 → 1.27.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.
|
@@ -59,7 +59,7 @@ describe("Routes.json Conversion Engine", () => {
|
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
61
|
"x-zuplo-path": {
|
|
62
|
-
pathMode: "path-to-
|
|
62
|
+
pathMode: "path-to-regexp",
|
|
63
63
|
},
|
|
64
64
|
},
|
|
65
65
|
},
|
|
@@ -125,7 +125,7 @@ describe("Routes.json Conversion Engine", () => {
|
|
|
125
125
|
},
|
|
126
126
|
},
|
|
127
127
|
"x-zuplo-path": {
|
|
128
|
-
pathMode: "path-to-
|
|
128
|
+
pathMode: "path-to-regexp",
|
|
129
129
|
},
|
|
130
130
|
},
|
|
131
131
|
},
|
|
@@ -191,7 +191,7 @@ describe("Routes.json Conversion Engine", () => {
|
|
|
191
191
|
},
|
|
192
192
|
},
|
|
193
193
|
"x-zuplo-path": {
|
|
194
|
-
pathMode: "path-to-
|
|
194
|
+
pathMode: "path-to-regexp",
|
|
195
195
|
},
|
|
196
196
|
},
|
|
197
197
|
},
|
|
@@ -291,7 +291,7 @@ describe("Routes.json Conversion Engine", () => {
|
|
|
291
291
|
},
|
|
292
292
|
},
|
|
293
293
|
"x-zuplo-path": {
|
|
294
|
-
pathMode: "path-to-
|
|
294
|
+
pathMode: "path-to-regexp",
|
|
295
295
|
},
|
|
296
296
|
},
|
|
297
297
|
},
|
package/dist/convert/engine.js
CHANGED
|
@@ -8,7 +8,7 @@ export function convertRoutes(routesConfig) {
|
|
|
8
8
|
if (!paths[pathObjectKey]) {
|
|
9
9
|
pathObject = {};
|
|
10
10
|
pathObject["x-zuplo-path"] = {
|
|
11
|
-
pathMode: "path-to-
|
|
11
|
+
pathMode: "path-to-regexp",
|
|
12
12
|
};
|
|
13
13
|
paths[pathObjectKey] = pathObject;
|
|
14
14
|
}
|
|
@@ -36,6 +36,14 @@ export function convertRoutes(routesConfig) {
|
|
|
36
36
|
});
|
|
37
37
|
return base;
|
|
38
38
|
}
|
|
39
|
+
export function convertPolicies(routes) {
|
|
40
|
+
const policies = routes.policies;
|
|
41
|
+
const corsPolicies = routes.corsPolicies;
|
|
42
|
+
return {
|
|
43
|
+
policies: policies ? [...policies] : [],
|
|
44
|
+
corsPolicies: corsPolicies ? [...corsPolicies] : [],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
39
47
|
function generateBaseOpenAPIConfig() {
|
|
40
48
|
return {
|
|
41
49
|
openapi: "3.1.0",
|
package/dist/convert/handler.js
CHANGED
|
@@ -4,7 +4,7 @@ import { join, relative } from "node:path";
|
|
|
4
4
|
import prettier from "prettier";
|
|
5
5
|
import { logger } from "../common/logger.js";
|
|
6
6
|
import { printCriticalFailureToConsoleAndExit } from "../common/output.js";
|
|
7
|
-
import { convertRoutes } from "./engine.js";
|
|
7
|
+
import { convertPolicies, convertRoutes } from "./engine.js";
|
|
8
8
|
export async function convert(argv) {
|
|
9
9
|
try {
|
|
10
10
|
const dir = argv.dir;
|
|
@@ -19,20 +19,14 @@ export async function convert(argv) {
|
|
|
19
19
|
writeFileSync(openAPIFilePath, formattedOpenAPI, {
|
|
20
20
|
flag: "w",
|
|
21
21
|
});
|
|
22
|
-
const policies = routes
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
parser: "json-stringify",
|
|
31
|
-
});
|
|
32
|
-
writeFileSync(policiesFilePath, formattedPolicies, {
|
|
33
|
-
flag: "w",
|
|
34
|
-
});
|
|
35
|
-
}
|
|
22
|
+
const policies = convertPolicies(routes);
|
|
23
|
+
const policiesFilePath = join(normalizedDir, "config", "policies.json");
|
|
24
|
+
const formattedPolicies = prettier.format(JSON.stringify(policies), {
|
|
25
|
+
parser: "json-stringify",
|
|
26
|
+
});
|
|
27
|
+
writeFileSync(policiesFilePath, formattedPolicies, {
|
|
28
|
+
flag: "w",
|
|
29
|
+
});
|
|
36
30
|
}
|
|
37
31
|
catch (err) {
|
|
38
32
|
logger.error(err);
|