@scalar/cli 2.5.2 → 2.8.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.
- package/README.md +319 -55
- package/chunks/{action-XUQ7TKKJ.js → action-354TUG4H.js} +11 -7
- package/chunks/{action-PHLOE27S.js → action-43YBNBDR.js} +33 -26
- package/chunks/{action-DGD6Q6Y5.js → action-5SK5NE7E.js} +10 -4
- package/chunks/{action-Y6CEKYEK.js → action-6BYGBXRC.js} +40 -23
- package/chunks/{action-LUVBQEIQ.js → action-7PEQXDWT.js} +4 -4
- package/chunks/action-AQRPFQKI.js +231 -0
- package/chunks/{action-RBVPKCRI.js → action-CA4QYPI6.js} +6 -6
- package/chunks/{action-7H3XARJP.js → action-EOAVVL52.js} +11 -5
- package/chunks/action-F2ZJNURT.js +72 -0
- package/chunks/{action-AMNYOA4B.js → action-F7A2K74G.js} +4 -4
- package/chunks/{action-HIL5ZFNB.js → action-FCAYFPVR.js} +5 -5
- package/chunks/{action-42D2C47G.js → action-GWXLHL2Z.js} +3 -3
- package/chunks/{action-ZWQLQENM.js → action-H6OUJWWM.js} +4 -4
- package/chunks/{action-TWHLZW4V.js → action-HT2DJ34Z.js} +49 -26
- package/chunks/{action-PAA4NWUJ.js → action-JAHFRYWZ.js} +58 -9
- package/chunks/{action-HXHBU7XC.js → action-KTYOCA2V.js} +37 -12
- package/chunks/{action-LFL3ZZKN.js → action-LEUD5P2U.js} +17 -17
- package/chunks/{action-FF2OMGAS.js → action-LLH4QPXM.js} +34 -20
- package/chunks/{action-OILGZAMK.js → action-LXGXKXZZ.js} +20 -15
- package/chunks/{action-W62AIEBN.js → action-NVI5DWFP.js} +6 -6
- package/chunks/{action-EPNE5XCM.js → action-QQZLPI42.js} +17 -17
- package/chunks/{action-ZLTUMRO2.js → action-UIKH4SZX.js} +25 -21
- package/chunks/{action-6FAJNP6C.js → action-VOFDW3U2.js} +4 -4
- package/chunks/{action-OK55BFGM.js → action-W3C53GPH.js} +7 -7
- package/chunks/{action-P7RFXIC7.js → action-WFDNRA7D.js} +32 -23
- package/chunks/{action-V5KYG7XD.js → action-XIUO64C7.js} +10 -10
- package/chunks/{action-X7TZA3RE.js → action-Y6NXJQ4H.js} +89 -14
- package/chunks/{action-6MZZHPVQ.js → action-Y7OUGD56.js} +27 -14
- package/chunks/{action-DCINFQ57.js → action-YLF2G4G5.js} +13 -13
- package/chunks/{action-SJYAMXYI.js → action-YRX6SN5F.js} +10 -4
- package/chunks/actions-OGIVBQC7.js +158 -0
- package/chunks/{agent-JAXLLDPE.js → agent-ASPV3R5U.js} +4 -4
- package/chunks/{asyncapi-P6Y3L7RG.js → asyncapi-QNFKXHEI.js} +10 -11
- package/chunks/{build.action-AZ5ECU4B.js → build.action-NM6CAE5F.js} +37 -33
- package/chunks/{chunk-FOKFF4EP.js → chunk-22HYZ7LE.js} +3 -3
- package/chunks/{chunk-KEOCJ3NJ.js → chunk-2OCWX42S.js} +38 -87
- package/chunks/{chunk-RPVHJMQT.js → chunk-5DEU2DVL.js} +2 -2
- package/chunks/{chunk-OQKDBLOZ.js → chunk-5JLVQVKO.js} +8 -0
- package/chunks/{chunk-VNYE4R7N.js → chunk-5UHLAJQD.js} +2 -1
- package/chunks/{chunk-CX7ZRMTC.js → chunk-6XWCMJDB.js} +1 -1
- package/chunks/{chunk-6ZMT63IV.js → chunk-6YPQGVF4.js} +1 -1
- package/chunks/{chunk-HXIDUCSZ.js → chunk-BPGFSSUH.js} +1 -1
- package/chunks/{chunk-M622VXRQ.js → chunk-C2KAWRIX.js} +1 -1
- package/chunks/chunk-EGOXR5FB.js +15 -0
- package/chunks/{chunk-UB3XGOUW.js → chunk-EXY3ZTV4.js} +262 -9
- package/chunks/{chunk-3BWGTPPT.js → chunk-FDC2IESH.js} +1776 -1113
- package/chunks/{chunk-TYLWJ2UL.js → chunk-GTV2BVXV.js} +2 -2
- package/chunks/{chunk-SWWWYWHC.js → chunk-HGOD6THU.js} +27 -18
- package/chunks/{chunk-3DJ2GKEG.js → chunk-IMG35UXX.js} +1 -1
- package/chunks/{chunk-MNLXYOVF.js → chunk-KCCFN4F7.js} +2 -2
- package/chunks/{chunk-FQVVKQPU.js → chunk-KKRGBXCE.js} +137 -1
- package/chunks/{chunk-UMPODUJO.js → chunk-L3UXDCBI.js} +105 -15
- package/chunks/{chunk-B2MHTD3R.js → chunk-MLSZVVTT.js} +1 -1
- package/chunks/{chunk-LCPFHE4Z.js → chunk-OJ2EWIJH.js} +21 -2
- package/chunks/{chunk-RAO7VUGM.js → chunk-PH3WFNXJ.js} +1 -1
- package/chunks/{chunk-NIXG4KDE.js → chunk-QVQ4PNVL.js} +170 -5
- package/chunks/{chunk-CIFOFSZ3.js → chunk-R5LK6VPY.js} +72 -7
- package/chunks/{chunk-T7B6WNZC.js → chunk-TSURUX4A.js} +12 -3
- package/chunks/{chunk-JV7TUEXQ.js → chunk-UXJ753NV.js} +14 -1
- package/chunks/{chunk-HUCR333E.js → chunk-W24BETFG.js} +2 -2
- package/chunks/{chunk-LQN4S62O.js → chunk-XEDGMZJD.js} +18 -4
- package/chunks/{chunk-NNMSZVAB.js → chunk-XXSQUBXS.js} +82 -6
- package/chunks/{chunk-M6Q3ARBV.js → chunk-YILQODZF.js} +2 -2
- package/chunks/{create.action-34OTO2SB.js → create.action-FUQ2BVJA.js} +29 -17
- package/chunks/{delete.action-ZYXFMIOW.js → delete.action-47E66R3I.js} +26 -17
- package/chunks/{delete.action-6LRT4M3S.js → delete.action-BTDFH7WY.js} +26 -17
- package/chunks/{get.action-XP36SA2J.js → get.action-XC7KC2JO.js} +10 -10
- package/chunks/{list.action-6LF6KSD5.js → list.action-LXKEUYKO.js} +13 -13
- package/chunks/{list.action-WVRVLX5E.js → list.action-OFGLMRE7.js} +17 -17
- package/chunks/{publish.action-AHFUBT5C.js → publish.action-OS27XOX4.js} +50 -24
- package/chunks/{update.action-YQTVUDYE.js → update.action-AEIBLCWD.js} +27 -18
- package/chunks/{update.action-ZREAFJVG.js → update.action-ZMS4CQ3T.js} +27 -18
- package/docs.html +679 -175
- package/index.js +492 -406
- package/package.json +14 -22
- package/skills/scalar-cli/SKILL.md +77 -0
- package/template.md +101 -3
- package/chunks/action-YRWHX2AE.js +0 -64
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getFileOrUrl
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HGOD6THU.js";
|
|
5
5
|
import {
|
|
6
6
|
require_dist
|
|
7
7
|
} from "./chunk-K74E42RV.js";
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-KCCFN4F7.js";
|
|
9
|
+
import "./chunk-6XWCMJDB.js";
|
|
10
10
|
import {
|
|
11
11
|
isYamlFileName
|
|
12
12
|
} from "./chunk-4ORL4MST.js";
|
|
13
13
|
import {
|
|
14
14
|
output
|
|
15
15
|
} from "./chunk-T5HJUAWB.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-XEDGMZJD.js";
|
|
17
17
|
import "./chunk-IKT5F47M.js";
|
|
18
18
|
import {
|
|
19
19
|
__toESM
|
|
@@ -2,17 +2,17 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
|
|
|
2
2
|
import {
|
|
3
3
|
getFileOrUrl,
|
|
4
4
|
isAsyncApiContent
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HGOD6THU.js";
|
|
6
6
|
import {
|
|
7
7
|
config
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-UXJ753NV.js";
|
|
9
|
+
import "./chunk-KCCFN4F7.js";
|
|
10
|
+
import "./chunk-6XWCMJDB.js";
|
|
11
11
|
import "./chunk-4ORL4MST.js";
|
|
12
12
|
import {
|
|
13
13
|
output
|
|
14
14
|
} from "./chunk-T5HJUAWB.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-XEDGMZJD.js";
|
|
16
16
|
import "./chunk-IKT5F47M.js";
|
|
17
17
|
import "./chunk-3MZYUBJ6.js";
|
|
18
18
|
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
downloadIsolate,
|
|
5
5
|
isDiskWriteError,
|
|
6
6
|
updateIsolate
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-L3UXDCBI.js";
|
|
8
8
|
import "./chunk-3ZJYGGAA.js";
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-BPGFSSUH.js";
|
|
10
|
+
import "./chunk-UXJ753NV.js";
|
|
11
11
|
import "./chunk-T5HJUAWB.js";
|
|
12
12
|
import "./chunk-3MZYUBJ6.js";
|
|
13
13
|
export {
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
getFileOrUrl,
|
|
4
4
|
isDocument,
|
|
5
5
|
safeNormalize
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HGOD6THU.js";
|
|
7
7
|
import {
|
|
8
8
|
require_dist
|
|
9
9
|
} from "./chunk-K74E42RV.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-KCCFN4F7.js";
|
|
11
|
+
import "./chunk-6XWCMJDB.js";
|
|
12
12
|
import {
|
|
13
13
|
isUrl,
|
|
14
14
|
isYamlFileName
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
output
|
|
18
18
|
} from "./chunk-T5HJUAWB.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-XEDGMZJD.js";
|
|
20
20
|
import "./chunk-IKT5F47M.js";
|
|
21
21
|
import {
|
|
22
22
|
__toESM
|
|
@@ -2,40 +2,57 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
|
|
|
2
2
|
import {
|
|
3
3
|
getFileOrUrl,
|
|
4
4
|
isAsyncApiContent,
|
|
5
|
-
|
|
5
|
+
loadOpenApiDocument,
|
|
6
6
|
printSpecificationBanner
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HGOD6THU.js";
|
|
8
8
|
import {
|
|
9
9
|
watchFile
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import
|
|
10
|
+
} from "./chunk-QVQ4PNVL.js";
|
|
11
|
+
import "./chunk-UXJ753NV.js";
|
|
12
|
+
import "./chunk-5UHLAJQD.js";
|
|
13
|
+
import "./chunk-5JLVQVKO.js";
|
|
14
|
+
import "./chunk-KCCFN4F7.js";
|
|
15
|
+
import "./chunk-6XWCMJDB.js";
|
|
16
|
+
import {
|
|
17
|
+
isUrl
|
|
18
|
+
} from "./chunk-4ORL4MST.js";
|
|
17
19
|
import {
|
|
18
20
|
output
|
|
19
21
|
} from "./chunk-T5HJUAWB.js";
|
|
20
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-XEDGMZJD.js";
|
|
21
23
|
import "./chunk-IKT5F47M.js";
|
|
22
24
|
import "./chunk-3MZYUBJ6.js";
|
|
23
25
|
|
|
24
26
|
// src/domains/document/mock/action.ts
|
|
27
|
+
import path2 from "node:path";
|
|
25
28
|
import as2 from "ansis";
|
|
26
29
|
|
|
27
30
|
// src/domains/document/mock/helpers.ts
|
|
31
|
+
import path from "node:path";
|
|
28
32
|
import { serve } from "@hono/node-server";
|
|
29
33
|
import as from "ansis";
|
|
34
|
+
import { bundle } from "@scalar/json-magic/bundle";
|
|
35
|
+
import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
|
|
30
36
|
import { createMockServer } from "@scalar/mock-server";
|
|
31
37
|
var bootServer = async ({
|
|
32
|
-
|
|
38
|
+
document,
|
|
39
|
+
origin,
|
|
33
40
|
port
|
|
34
41
|
}) => {
|
|
35
|
-
const app = await
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
const app = await bundle(document, {
|
|
43
|
+
origin,
|
|
44
|
+
plugins: [
|
|
45
|
+
readFiles({
|
|
46
|
+
basePath: isUrl(origin) ? process.cwd() : path.dirname(origin)
|
|
47
|
+
}),
|
|
48
|
+
fetchUrls({ blockPrivateNetworks: true })
|
|
49
|
+
],
|
|
50
|
+
treeShake: false
|
|
51
|
+
}).then((bundled) => createMockServer({ document: bundled, onRequest })).catch(
|
|
52
|
+
(error) => output.error().title(
|
|
53
|
+
`Could not start mock server: ${error instanceof Error ? error.message : String(error)}`
|
|
54
|
+
).exit("error")
|
|
55
|
+
);
|
|
39
56
|
return serve(
|
|
40
57
|
{
|
|
41
58
|
fetch: app.fetch,
|
|
@@ -55,16 +72,16 @@ var printAvailablePaths = (specification) => {
|
|
|
55
72
|
if (specification?.paths === void 0 || Object.keys(specification?.paths).length === 0) {
|
|
56
73
|
output.warn().title(as.grey("Could not find any paths in the OpenAPI file.")).print();
|
|
57
74
|
}
|
|
58
|
-
for (const
|
|
59
|
-
if (specification?.paths?.[
|
|
75
|
+
for (const path3 in specification?.paths ?? []) {
|
|
76
|
+
if (specification?.paths?.[path3] === void 0) {
|
|
60
77
|
continue;
|
|
61
78
|
}
|
|
62
|
-
for (const method in specification.paths[
|
|
63
|
-
if (specification.paths[
|
|
79
|
+
for (const method in specification.paths[path3]) {
|
|
80
|
+
if (specification.paths[path3][method] === void 0) {
|
|
64
81
|
continue;
|
|
65
82
|
}
|
|
66
83
|
output.info().line(
|
|
67
|
-
`${as[getMethodColor(method)].bold(method.toUpperCase().padEnd(6))} ${as.grey(`${
|
|
84
|
+
`${as[getMethodColor(method)].bold(method.toUpperCase().padEnd(6))} ${as.grey(`${path3}`)}`
|
|
68
85
|
).print();
|
|
69
86
|
}
|
|
70
87
|
}
|
|
@@ -92,12 +109,14 @@ function getMethodColor(method) {
|
|
|
92
109
|
|
|
93
110
|
// src/domains/document/mock/action.ts
|
|
94
111
|
async function mockAction(fileArgument, { watch, once, port }) {
|
|
95
|
-
|
|
96
|
-
|
|
112
|
+
const content = await getFileOrUrl(fileArgument);
|
|
113
|
+
if (isAsyncApiContent(content)) {
|
|
114
|
+
const { mockAsyncApi } = await import("./asyncapi-QNFKXHEI.js");
|
|
97
115
|
return mockAsyncApi(fileArgument, { watch, once, port });
|
|
98
116
|
}
|
|
117
|
+
const origin = isUrl(fileArgument) ? fileArgument : path2.resolve(fileArgument);
|
|
99
118
|
let server;
|
|
100
|
-
const result = await
|
|
119
|
+
const result = await loadOpenApiDocument(content);
|
|
101
120
|
if (!result.valid) {
|
|
102
121
|
return output.error().title("Invalid OpenAPI document").exit("error");
|
|
103
122
|
}
|
|
@@ -108,7 +127,9 @@ async function mockAction(fileArgument, { watch, once, port }) {
|
|
|
108
127
|
let { specification } = result;
|
|
109
128
|
if (watch) {
|
|
110
129
|
await watchFile(fileArgument, async () => {
|
|
111
|
-
const newResult = await
|
|
130
|
+
const newResult = await loadOpenApiDocument(
|
|
131
|
+
await getFileOrUrl(fileArgument)
|
|
132
|
+
);
|
|
112
133
|
const specificationHasChanged = newResult?.specification && JSON.stringify(specification) !== JSON.stringify(newResult.specification);
|
|
113
134
|
if (specificationHasChanged && newResult.valid) {
|
|
114
135
|
output.info().title(as2.grey("OpenAPI file modified")).print();
|
|
@@ -120,7 +141,8 @@ async function mockAction(fileArgument, { watch, once, port }) {
|
|
|
120
141
|
if (specification) {
|
|
121
142
|
server.close();
|
|
122
143
|
server = await bootServer({
|
|
123
|
-
specification,
|
|
144
|
+
document: specification,
|
|
145
|
+
origin,
|
|
124
146
|
port
|
|
125
147
|
});
|
|
126
148
|
}
|
|
@@ -133,7 +155,8 @@ async function mockAction(fileArgument, { watch, once, port }) {
|
|
|
133
155
|
}
|
|
134
156
|
printAvailablePaths(specification);
|
|
135
157
|
server = await bootServer({
|
|
136
|
-
specification,
|
|
158
|
+
document: specification,
|
|
159
|
+
origin,
|
|
137
160
|
port
|
|
138
161
|
});
|
|
139
162
|
if (once) {
|
|
@@ -2,21 +2,21 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
|
|
|
2
2
|
import {
|
|
3
3
|
getFileOrUrl,
|
|
4
4
|
isAsyncApiContent
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HGOD6THU.js";
|
|
6
6
|
import {
|
|
7
7
|
err,
|
|
8
8
|
ok
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-C2KAWRIX.js";
|
|
10
10
|
import {
|
|
11
11
|
require_dist
|
|
12
12
|
} from "./chunk-K74E42RV.js";
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-KCCFN4F7.js";
|
|
14
|
+
import "./chunk-6XWCMJDB.js";
|
|
15
15
|
import "./chunk-4ORL4MST.js";
|
|
16
16
|
import {
|
|
17
17
|
output
|
|
18
18
|
} from "./chunk-T5HJUAWB.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-XEDGMZJD.js";
|
|
20
20
|
import "./chunk-IKT5F47M.js";
|
|
21
21
|
import {
|
|
22
22
|
__toESM
|
|
@@ -176,6 +176,42 @@ function isFile(path) {
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
// ../../packages/api-document-lint/dist/validate-inline-document.js
|
|
180
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
181
|
+
function validateInlineDocument(document) {
|
|
182
|
+
const parsed = (() => {
|
|
183
|
+
try {
|
|
184
|
+
return ok((0, import_yaml.parse)(document));
|
|
185
|
+
} catch {
|
|
186
|
+
return err("Document must be valid YAML or JSON before linting.");
|
|
187
|
+
}
|
|
188
|
+
})();
|
|
189
|
+
if (!parsed.ok)
|
|
190
|
+
return parsed;
|
|
191
|
+
const references = /* @__PURE__ */ new Set([
|
|
192
|
+
"$ref",
|
|
193
|
+
"$dynamicRef",
|
|
194
|
+
"$recursiveRef",
|
|
195
|
+
"operationRef"
|
|
196
|
+
]);
|
|
197
|
+
const seen = /* @__PURE__ */ new Set();
|
|
198
|
+
const pending = [parsed.data];
|
|
199
|
+
while (pending.length) {
|
|
200
|
+
const value = pending.pop();
|
|
201
|
+
if (!value || typeof value !== "object" || seen.has(value))
|
|
202
|
+
continue;
|
|
203
|
+
seen.add(value);
|
|
204
|
+
for (const [key, child] of Object.entries(value)) {
|
|
205
|
+
if (references.has(key) && typeof child === "string" && child !== "" && !child.startsWith("#")) {
|
|
206
|
+
return err("External references are not supported by hosted linting. Bundle the document first.");
|
|
207
|
+
}
|
|
208
|
+
if (child && typeof child === "object")
|
|
209
|
+
pending.push(child);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return ok(void 0);
|
|
213
|
+
}
|
|
214
|
+
|
|
179
215
|
// ../../packages/api-document-lint/dist/run-vacuum.js
|
|
180
216
|
var execFileAsync = promisify(execFile);
|
|
181
217
|
var MAX_BUFFER = 64 * 1024 * 1024;
|
|
@@ -184,6 +220,11 @@ async function runVacuum(input, options = {}) {
|
|
|
184
220
|
if (input.document.trim().length === 0) {
|
|
185
221
|
return ok([]);
|
|
186
222
|
}
|
|
223
|
+
if (options.allowExternalReferences === false) {
|
|
224
|
+
const validation = validateInlineDocument(input.document);
|
|
225
|
+
if (!validation.ok)
|
|
226
|
+
return validation;
|
|
227
|
+
}
|
|
187
228
|
const binary = resolveVacuumBinary(options.binaryPath);
|
|
188
229
|
if (!binary.ok) {
|
|
189
230
|
return binary;
|
|
@@ -206,8 +247,15 @@ async function runVacuum(input, options = {}) {
|
|
|
206
247
|
"--skip-check",
|
|
207
248
|
// Match Spectral's working-directory base for document strings.
|
|
208
249
|
"--base",
|
|
209
|
-
process.cwd()
|
|
250
|
+
options.allowExternalReferences === false ? directory : process.cwd()
|
|
210
251
|
];
|
|
252
|
+
if (options.allowExternalReferences === false) {
|
|
253
|
+
const configPath = join2(directory, "vacuum.conf.yaml");
|
|
254
|
+
const configured = await writeFile(configPath, "{}").then(() => true).catch(() => false);
|
|
255
|
+
if (!configured)
|
|
256
|
+
return err("Could not create hosted lint configuration");
|
|
257
|
+
args.push("--remote=false", "--config", configPath);
|
|
258
|
+
}
|
|
211
259
|
if (input.ruleset && input.ruleset.trim().length > 0) {
|
|
212
260
|
const rulesetPath = join2(directory, "ruleset.yaml");
|
|
213
261
|
const wroteRuleset = await writeFile(rulesetPath, input.ruleset, "utf8").then(() => true).catch(() => false);
|
|
@@ -219,7 +267,8 @@ async function runVacuum(input, options = {}) {
|
|
|
219
267
|
args.push(documentPath, reportPath);
|
|
220
268
|
const failure = await execFileAsync(binary.data, args, {
|
|
221
269
|
maxBuffer: MAX_BUFFER,
|
|
222
|
-
timeout: TIMEOUT_MS
|
|
270
|
+
timeout: options.timeoutMs ?? TIMEOUT_MS,
|
|
271
|
+
...options.allowExternalReferences === false ? { cwd: directory } : {}
|
|
223
272
|
}).then(() => null).catch((error) => error);
|
|
224
273
|
const report = await readFile(reportPath, "utf8").catch(() => null);
|
|
225
274
|
if (report === null) {
|
|
@@ -262,7 +311,7 @@ function parseReport(report) {
|
|
|
262
311
|
}
|
|
263
312
|
|
|
264
313
|
// ../../packages/api-document-lint/dist/select-engine.js
|
|
265
|
-
var
|
|
314
|
+
var import_yaml2 = __toESM(require_dist(), 1);
|
|
266
315
|
function selectEngine(ruleset) {
|
|
267
316
|
if (!ruleset || ruleset.trim().length === 0) {
|
|
268
317
|
return "vacuum";
|
|
@@ -291,7 +340,7 @@ function isRecord(value) {
|
|
|
291
340
|
}
|
|
292
341
|
function parseRuleset(ruleset) {
|
|
293
342
|
try {
|
|
294
|
-
const value = (0,
|
|
343
|
+
const value = (0, import_yaml2.parse)(ruleset);
|
|
295
344
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
296
345
|
return value;
|
|
297
346
|
}
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
generateAccessByPersonalToken,
|
|
9
9
|
setAuthData,
|
|
10
10
|
tokenResponseSchema
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-QVQ4PNVL.js";
|
|
12
12
|
import {
|
|
13
13
|
config
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-UXJ753NV.js";
|
|
15
|
+
import "./chunk-5UHLAJQD.js";
|
|
16
|
+
import "./chunk-5JLVQVKO.js";
|
|
17
17
|
import "./chunk-4ORL4MST.js";
|
|
18
18
|
import {
|
|
19
19
|
output
|
|
@@ -28,7 +28,12 @@ import as2 from "ansis";
|
|
|
28
28
|
|
|
29
29
|
// ../../packages/mongobase-client/dist/auth/node/exchange-callback-server.js
|
|
30
30
|
import getPort from "get-port";
|
|
31
|
-
var generateTokenCallbackEndpoint = async (exchangeUrl) => {
|
|
31
|
+
var generateTokenCallbackEndpoint = async (exchangeUrl, allowedOrigin) => {
|
|
32
|
+
const parsedAllowedOrigin = URL.parse(allowedOrigin);
|
|
33
|
+
if (!parsedAllowedOrigin) {
|
|
34
|
+
throw new Error(`Invalid dashboard URL "${allowedOrigin}". Provide an absolute URL such as https://dashboard.scalar.com.`);
|
|
35
|
+
}
|
|
36
|
+
const allowedCorsOrigin = parsedAllowedOrigin.origin;
|
|
32
37
|
const http = await import("node:http");
|
|
33
38
|
const port = await getPort();
|
|
34
39
|
const server = http.createServer();
|
|
@@ -36,11 +41,24 @@ var generateTokenCallbackEndpoint = async (exchangeUrl) => {
|
|
|
36
41
|
const getTokens = async () => {
|
|
37
42
|
const resultPromise = new Promise((resolve) => {
|
|
38
43
|
server.on("request", async (req, res) => {
|
|
39
|
-
const
|
|
44
|
+
const corsHeaders = req.headers.origin === allowedCorsOrigin ? {
|
|
45
|
+
"Access-Control-Allow-Origin": allowedCorsOrigin,
|
|
46
|
+
Vary: "Origin"
|
|
47
|
+
} : { Vary: "Origin" };
|
|
48
|
+
if (req.method === "OPTIONS") {
|
|
49
|
+
res.writeHead(204, {
|
|
50
|
+
...corsHeaders,
|
|
51
|
+
"Access-Control-Allow-Methods": "POST",
|
|
52
|
+
"Access-Control-Allow-Headers": "*",
|
|
53
|
+
"Access-Control-Allow-Private-Network": "true"
|
|
54
|
+
});
|
|
55
|
+
res.end();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
40
58
|
const errorResponse = (message, code) => {
|
|
41
59
|
res.writeHead(code, {
|
|
42
60
|
"Content-Type": "application/json",
|
|
43
|
-
|
|
61
|
+
...corsHeaders
|
|
44
62
|
});
|
|
45
63
|
res.end(JSON.stringify({
|
|
46
64
|
success: false,
|
|
@@ -63,7 +81,7 @@ var generateTokenCallbackEndpoint = async (exchangeUrl) => {
|
|
|
63
81
|
if (tokens) {
|
|
64
82
|
res.writeHead(200, {
|
|
65
83
|
"Content-Type": "application/json",
|
|
66
|
-
|
|
84
|
+
...corsHeaders
|
|
67
85
|
});
|
|
68
86
|
res.end(JSON.stringify({
|
|
69
87
|
success: true,
|
|
@@ -176,13 +194,20 @@ async function loginAction({
|
|
|
176
194
|
await setAuthData({ accessToken, refreshToken });
|
|
177
195
|
output.info().message(loggedInMessage(email)).print();
|
|
178
196
|
} catch (err) {
|
|
179
|
-
output.error().title(err.message).
|
|
197
|
+
output.error().title(err.message).exit("error");
|
|
180
198
|
}
|
|
181
199
|
return;
|
|
182
200
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
201
|
+
let callbackEndpoint;
|
|
202
|
+
try {
|
|
203
|
+
callbackEndpoint = await generateTokenCallbackEndpoint(
|
|
204
|
+
`${config.services.api}/core/login/exchange`,
|
|
205
|
+
config.projects.dashboard
|
|
206
|
+
);
|
|
207
|
+
} catch (err) {
|
|
208
|
+
return output.error().title("Unable to start the login callback server").message(err.message).exit("error");
|
|
209
|
+
}
|
|
210
|
+
const { port, getTokens } = callbackEndpoint;
|
|
186
211
|
const loginUrl = `${config.projects.dashboard}/login?externalRedirect=local&port=${port}`;
|
|
187
212
|
output.info().message(`Please follow the link to login: ${as2.cyan(loginUrl)}`).print();
|
|
188
213
|
openBrowser(loginUrl);
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
apiService
|
|
4
|
-
} from "./chunk-UB3XGOUW.js";
|
|
5
2
|
import {
|
|
6
3
|
BaseCollections
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2OCWX42S.js";
|
|
8
5
|
import {
|
|
9
6
|
getDatabaseClient
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-5DEU2DVL.js";
|
|
8
|
+
import {
|
|
9
|
+
apiService
|
|
10
|
+
} from "./chunk-EXY3ZTV4.js";
|
|
11
|
+
import "./chunk-KKRGBXCE.js";
|
|
12
|
+
import "./chunk-MLSZVVTT.js";
|
|
13
|
+
import "./chunk-FDC2IESH.js";
|
|
14
|
+
import "./chunk-C2KAWRIX.js";
|
|
15
|
+
import "./chunk-R5LK6VPY.js";
|
|
16
16
|
import {
|
|
17
17
|
getAuthData
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-QVQ4PNVL.js";
|
|
19
|
+
import "./chunk-UXJ753NV.js";
|
|
20
20
|
import {
|
|
21
21
|
teamSchema
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-5UHLAJQD.js";
|
|
23
|
+
import "./chunk-5JLVQVKO.js";
|
|
24
24
|
import "./chunk-K74E42RV.js";
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-KCCFN4F7.js";
|
|
26
|
+
import "./chunk-6XWCMJDB.js";
|
|
27
27
|
import "./chunk-4ORL4MST.js";
|
|
28
28
|
import {
|
|
29
29
|
output,
|
|
30
30
|
printTable
|
|
31
31
|
} from "./chunk-T5HJUAWB.js";
|
|
32
|
-
import "./chunk-
|
|
32
|
+
import "./chunk-XEDGMZJD.js";
|
|
33
33
|
import {
|
|
34
34
|
external_exports,
|
|
35
35
|
namespaceSchema
|
|
@@ -1,42 +1,45 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
downloadIsolate
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-L3UXDCBI.js";
|
|
5
5
|
import "./chunk-3ZJYGGAA.js";
|
|
6
6
|
import {
|
|
7
7
|
readAndParseConfig,
|
|
8
8
|
renderConfigError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-W24BETFG.js";
|
|
10
10
|
import {
|
|
11
11
|
CONFIG_FILE_DEFAULT,
|
|
12
12
|
findConfig
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XXSQUBXS.js";
|
|
14
14
|
import {
|
|
15
15
|
ISOLATE_DIR
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-BPGFSSUH.js";
|
|
17
17
|
import {
|
|
18
18
|
getAuthData
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-QVQ4PNVL.js";
|
|
20
20
|
import {
|
|
21
21
|
config
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-UXJ753NV.js";
|
|
23
|
+
import "./chunk-5UHLAJQD.js";
|
|
24
24
|
import {
|
|
25
25
|
ConfigVersion
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-5JLVQVKO.js";
|
|
27
|
+
import {
|
|
28
|
+
requireInteractive
|
|
29
|
+
} from "./chunk-EGOXR5FB.js";
|
|
27
30
|
import "./chunk-K74E42RV.js";
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
31
|
+
import "./chunk-KCCFN4F7.js";
|
|
32
|
+
import "./chunk-6XWCMJDB.js";
|
|
30
33
|
import "./chunk-4ORL4MST.js";
|
|
31
34
|
import {
|
|
32
35
|
output
|
|
33
36
|
} from "./chunk-T5HJUAWB.js";
|
|
34
|
-
import "./chunk-
|
|
37
|
+
import "./chunk-XEDGMZJD.js";
|
|
35
38
|
import "./chunk-IKT5F47M.js";
|
|
36
39
|
import "./chunk-3MZYUBJ6.js";
|
|
37
40
|
|
|
38
41
|
// src/domains/project/preview/action.ts
|
|
39
|
-
import { text } from "@clack/prompts";
|
|
42
|
+
import { isCancel, text } from "@clack/prompts";
|
|
40
43
|
import as from "ansis";
|
|
41
44
|
|
|
42
45
|
// src/domains/project/preview/v2.ts
|
|
@@ -86,7 +89,8 @@ async function previewV2Project({
|
|
|
86
89
|
configPath,
|
|
87
90
|
port,
|
|
88
91
|
config: config2,
|
|
89
|
-
host
|
|
92
|
+
host,
|
|
93
|
+
openBrowser
|
|
90
94
|
}) {
|
|
91
95
|
const root = path.resolve(path.dirname(configPath), config2.root ?? "./");
|
|
92
96
|
const relativeConfigPath = path.relative(root, configPath);
|
|
@@ -103,7 +107,8 @@ async function previewV2Project({
|
|
|
103
107
|
registryBaseUrl: config.projects.registry,
|
|
104
108
|
baseUrl: config.services.api,
|
|
105
109
|
token: accessToken,
|
|
106
|
-
host
|
|
110
|
+
host,
|
|
111
|
+
openBrowser
|
|
107
112
|
});
|
|
108
113
|
}
|
|
109
114
|
|
|
@@ -116,11 +121,19 @@ async function previewAction(__configPath, options) {
|
|
|
116
121
|
if (_port < 0 || _port > 65535) {
|
|
117
122
|
return output.error().title("Invalid port").message("Port number must be between 0 and 65535").exit("error");
|
|
118
123
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
let configPath = __configPath || findConfig();
|
|
125
|
+
if (!configPath) {
|
|
126
|
+
requireInteractive(
|
|
127
|
+
"Pass the path to your Scalar configuration file to preview non-interactively."
|
|
128
|
+
);
|
|
129
|
+
const response = await text({
|
|
130
|
+
message: "Where is your configuration file located?",
|
|
131
|
+
defaultValue: CONFIG_FILE_DEFAULT,
|
|
132
|
+
placeholder: CONFIG_FILE_DEFAULT
|
|
133
|
+
});
|
|
134
|
+
if (isCancel(response)) return;
|
|
135
|
+
configPath = response;
|
|
136
|
+
}
|
|
124
137
|
const parseConfigResult = readAndParseConfig(configPath);
|
|
125
138
|
if (!parseConfigResult.success) {
|
|
126
139
|
renderConfigError(parseConfigResult.error);
|
|
@@ -140,7 +153,8 @@ async function previewAction(__configPath, options) {
|
|
|
140
153
|
configPath,
|
|
141
154
|
config: config2,
|
|
142
155
|
port: _port,
|
|
143
|
-
host: options.host
|
|
156
|
+
host: options.host,
|
|
157
|
+
openBrowser: (options.open ?? true) && Boolean(process.stdin.isTTY) && !process.env.CI
|
|
144
158
|
});
|
|
145
159
|
return;
|
|
146
160
|
}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
apiService
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-EXY3ZTV4.js";
|
|
5
|
+
import "./chunk-KKRGBXCE.js";
|
|
6
|
+
import "./chunk-MLSZVVTT.js";
|
|
7
|
+
import "./chunk-FDC2IESH.js";
|
|
8
|
+
import "./chunk-C2KAWRIX.js";
|
|
9
|
+
import "./chunk-R5LK6VPY.js";
|
|
10
|
+
import "./chunk-QVQ4PNVL.js";
|
|
11
|
+
import "./chunk-UXJ753NV.js";
|
|
12
|
+
import "./chunk-5UHLAJQD.js";
|
|
13
|
+
import "./chunk-5JLVQVKO.js";
|
|
14
|
+
import {
|
|
15
|
+
requireInteractive
|
|
16
|
+
} from "./chunk-EGOXR5FB.js";
|
|
14
17
|
import "./chunk-K74E42RV.js";
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-KCCFN4F7.js";
|
|
19
|
+
import "./chunk-6XWCMJDB.js";
|
|
17
20
|
import "./chunk-4ORL4MST.js";
|
|
18
21
|
import {
|
|
19
22
|
output
|
|
20
23
|
} from "./chunk-T5HJUAWB.js";
|
|
21
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-XEDGMZJD.js";
|
|
22
25
|
import "./chunk-IKT5F47M.js";
|
|
23
26
|
import "./chunk-3MZYUBJ6.js";
|
|
24
27
|
|
|
@@ -36,6 +39,9 @@ async function updateAction(namespace, slug, { title, description }) {
|
|
|
36
39
|
let titleValue = title;
|
|
37
40
|
let descriptionValue = description;
|
|
38
41
|
const shouldPrompt = ![title, description].some((it) => it !== void 0);
|
|
42
|
+
if (shouldPrompt) {
|
|
43
|
+
requireInteractive("Please provide --title or --description.");
|
|
44
|
+
}
|
|
39
45
|
if (!titleValue && shouldPrompt) {
|
|
40
46
|
titleValue = await text({
|
|
41
47
|
message: `What is the new title of your document? ${as.grey("(Optional)")}`
|
|
@@ -52,8 +58,7 @@ async function updateAction(namespace, slug, { title, description }) {
|
|
|
52
58
|
const logger = output.info().line().loader("Updating the api document");
|
|
53
59
|
const updateDocument = await client.managedDocs.update(namespace, slug, {
|
|
54
60
|
title: titleValue,
|
|
55
|
-
description: descriptionValue
|
|
56
|
-
isPrivate: false
|
|
61
|
+
description: descriptionValue
|
|
57
62
|
});
|
|
58
63
|
if (updateDocument.error) {
|
|
59
64
|
return output.error().title(updateDocument.message).exit("error");
|