@scalar/cli 2.5.2 → 2.7.1
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 +113 -28
- package/chunks/{action-Y6CEKYEK.js → action-4NGK5XMD.js} +38 -21
- package/chunks/{action-DGD6Q6Y5.js → action-5SK5NE7E.js} +10 -4
- package/chunks/{action-LUVBQEIQ.js → action-7PEQXDWT.js} +4 -4
- package/chunks/action-AQRPFQKI.js +231 -0
- package/chunks/{action-TWHLZW4V.js → action-ATGZOWSH.js} +49 -26
- package/chunks/{action-ZLTUMRO2.js → action-BAQYJ6UE.js} +25 -21
- package/chunks/{action-X7TZA3RE.js → action-BOZNBCNZ.js} +89 -14
- package/chunks/{action-OK55BFGM.js → action-BRSSC2SR.js} +7 -7
- package/chunks/{action-RBVPKCRI.js → action-CA4QYPI6.js} +6 -6
- package/chunks/{action-EPNE5XCM.js → action-CPLH2CQ5.js} +17 -17
- package/chunks/{action-FF2OMGAS.js → action-E4YSRFGT.js} +34 -20
- 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-ZWQLQENM.js → action-H6OUJWWM.js} +4 -4
- package/chunks/{action-HIL5ZFNB.js → action-HJYZCPUN.js} +5 -5
- package/chunks/{action-PAA4NWUJ.js → action-JAHFRYWZ.js} +58 -9
- package/chunks/{action-42D2C47G.js → action-LPVITMWA.js} +3 -3
- package/chunks/{action-P7RFXIC7.js → action-LVDU6YOI.js} +32 -23
- package/chunks/{action-HXHBU7XC.js → action-N7BA5I3E.js} +37 -12
- package/chunks/{action-W62AIEBN.js → action-NVI5DWFP.js} +6 -6
- package/chunks/{action-PHLOE27S.js → action-OX2566BE.js} +32 -25
- package/chunks/{action-DCINFQ57.js → action-QYGOPSTY.js} +13 -13
- package/chunks/{action-6MZZHPVQ.js → action-RBOLLIGX.js} +27 -14
- package/chunks/{action-LFL3ZZKN.js → action-SCOXTCPR.js} +15 -15
- package/chunks/{action-OILGZAMK.js → action-SNPOOW6S.js} +20 -15
- package/chunks/{action-V5KYG7XD.js → action-SRBN7N3R.js} +10 -10
- package/chunks/{action-XUQ7TKKJ.js → action-T5XMJXPO.js} +11 -7
- package/chunks/{action-6FAJNP6C.js → action-VOFDW3U2.js} +4 -4
- package/chunks/{action-SJYAMXYI.js → action-YRX6SN5F.js} +10 -4
- package/chunks/{agent-JAXLLDPE.js → agent-ASPV3R5U.js} +4 -4
- package/chunks/{asyncapi-P6Y3L7RG.js → asyncapi-H4FU6GPC.js} +10 -11
- package/chunks/{build.action-AZ5ECU4B.js → build.action-6V6GXI3X.js} +35 -31
- package/chunks/{chunk-FOKFF4EP.js → chunk-2DSVF5AD.js} +3 -3
- package/chunks/{chunk-HXIDUCSZ.js → chunk-2PPRO2QB.js} +1 -1
- package/chunks/{chunk-RPVHJMQT.js → chunk-4X47MN6Q.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-RAO7VUGM.js → chunk-BDEPNGTO.js} +1 -1
- package/chunks/{chunk-FQVVKQPU.js → chunk-BIKOD3SG.js} +134 -1
- package/chunks/{chunk-M622VXRQ.js → chunk-C2KAWRIX.js} +1 -1
- package/chunks/{chunk-NIXG4KDE.js → chunk-CWCETP6H.js} +170 -5
- package/chunks/chunk-EGOXR5FB.js +15 -0
- package/chunks/{chunk-3BWGTPPT.js → chunk-FDC2IESH.js} +1776 -1113
- package/chunks/{chunk-JV7TUEXQ.js → chunk-GPNB7ISG.js} +14 -1
- package/chunks/{chunk-SWWWYWHC.js → chunk-HGOD6THU.js} +27 -18
- package/chunks/{chunk-3DJ2GKEG.js → chunk-IMG35UXX.js} +1 -1
- package/chunks/{chunk-UB3XGOUW.js → chunk-ISXH6Q7I.js} +253 -9
- package/chunks/{chunk-MNLXYOVF.js → chunk-KCCFN4F7.js} +2 -2
- package/chunks/{chunk-KEOCJ3NJ.js → chunk-LG7IFACX.js} +38 -87
- package/chunks/{chunk-B2MHTD3R.js → chunk-MLSZVVTT.js} +1 -1
- package/chunks/{chunk-LCPFHE4Z.js → chunk-OJ2EWIJH.js} +21 -2
- package/chunks/{chunk-UMPODUJO.js → chunk-QXQZVEDC.js} +105 -15
- package/chunks/{chunk-CIFOFSZ3.js → chunk-R5LK6VPY.js} +72 -7
- package/chunks/{chunk-T7B6WNZC.js → chunk-TSURUX4A.js} +12 -3
- 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/{chunk-TYLWJ2UL.js → chunk-ZJVYOZFB.js} +2 -2
- package/chunks/{create.action-34OTO2SB.js → create.action-P6DLCK4W.js} +27 -15
- package/chunks/{delete.action-6LRT4M3S.js → delete.action-HJKRRHE2.js} +24 -15
- package/chunks/{delete.action-ZYXFMIOW.js → delete.action-Z3GAA4ZN.js} +24 -15
- package/chunks/{get.action-XP36SA2J.js → get.action-IT4EHAV4.js} +10 -10
- package/chunks/{list.action-WVRVLX5E.js → list.action-2FU5UZNH.js} +15 -15
- package/chunks/{list.action-6LF6KSD5.js → list.action-WLIAO5UW.js} +13 -13
- package/chunks/{publish.action-AHFUBT5C.js → publish.action-T4J4DRXR.js} +48 -22
- package/chunks/{update.action-ZREAFJVG.js → update.action-3OVS3HWC.js} +25 -16
- package/chunks/{update.action-YQTVUDYE.js → update.action-MY7QPSSU.js} +25 -16
- package/docs.html +289 -96
- package/index.js +436 -401
- package/package.json +14 -22
- package/skills/scalar-cli/SKILL.md +71 -0
- package/template.md +81 -3
- package/chunks/action-YRWHX2AE.js +0 -64
|
@@ -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-CWCETP6H.js";
|
|
11
|
+
import "./chunk-GPNB7ISG.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-H4FU6GPC.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) {
|
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
getPublishDeploymentUrl
|
|
4
|
-
} from "./chunk-3DJ2GKEG.js";
|
|
5
2
|
import {
|
|
6
3
|
getProjectDeployments
|
|
7
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2DSVF5AD.js";
|
|
5
|
+
import {
|
|
6
|
+
getPublishDeploymentUrl
|
|
7
|
+
} from "./chunk-IMG35UXX.js";
|
|
8
8
|
import {
|
|
9
9
|
resolveProject
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TSURUX4A.js";
|
|
11
11
|
import {
|
|
12
12
|
formatAbsoluteTime
|
|
13
13
|
} from "./chunk-AEFPCC4U.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-YILQODZF.js";
|
|
15
15
|
import {
|
|
16
16
|
apiService
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-ISXH6Q7I.js";
|
|
18
|
+
import "./chunk-LG7IFACX.js";
|
|
19
|
+
import "./chunk-4X47MN6Q.js";
|
|
20
|
+
import "./chunk-BIKOD3SG.js";
|
|
21
|
+
import "./chunk-MLSZVVTT.js";
|
|
22
|
+
import "./chunk-FDC2IESH.js";
|
|
23
|
+
import "./chunk-C2KAWRIX.js";
|
|
24
|
+
import "./chunk-R5LK6VPY.js";
|
|
25
25
|
import {
|
|
26
26
|
getAuthData
|
|
27
|
-
} from "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
27
|
+
} from "./chunk-CWCETP6H.js";
|
|
28
|
+
import "./chunk-GPNB7ISG.js";
|
|
29
|
+
import "./chunk-5UHLAJQD.js";
|
|
30
|
+
import "./chunk-5JLVQVKO.js";
|
|
31
|
+
import {
|
|
32
|
+
requireInteractive
|
|
33
|
+
} from "./chunk-EGOXR5FB.js";
|
|
31
34
|
import "./chunk-K74E42RV.js";
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-KCCFN4F7.js";
|
|
36
|
+
import "./chunk-6XWCMJDB.js";
|
|
34
37
|
import "./chunk-4ORL4MST.js";
|
|
35
38
|
import {
|
|
36
39
|
output
|
|
37
40
|
} from "./chunk-T5HJUAWB.js";
|
|
38
|
-
import "./chunk-
|
|
41
|
+
import "./chunk-XEDGMZJD.js";
|
|
39
42
|
import {
|
|
40
43
|
external_exports,
|
|
41
44
|
slugSchema
|
|
@@ -140,6 +143,7 @@ async function rollbackAction(args) {
|
|
|
140
143
|
(target.deployedAt ?? target.createdAt) * 1e3
|
|
141
144
|
);
|
|
142
145
|
if (!yes) {
|
|
146
|
+
requireInteractive("Pass --yes to confirm a rollback non-interactively.");
|
|
143
147
|
const shouldContinue = await confirm({
|
|
144
148
|
message: `Roll back the live deployment of "${slug}" to build ${target.uid} (${deployedLabel})?`,
|
|
145
149
|
initialValue: false
|
|
@@ -6,20 +6,26 @@ import {
|
|
|
6
6
|
loadOpenApiDocument,
|
|
7
7
|
printSpecificationBanner,
|
|
8
8
|
safeNormalize
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HGOD6THU.js";
|
|
10
|
+
import {
|
|
11
|
+
err,
|
|
12
|
+
ok
|
|
13
|
+
} from "./chunk-C2KAWRIX.js";
|
|
10
14
|
import {
|
|
11
15
|
watchFile
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import
|
|
16
|
+
} from "./chunk-CWCETP6H.js";
|
|
17
|
+
import "./chunk-GPNB7ISG.js";
|
|
18
|
+
import "./chunk-5UHLAJQD.js";
|
|
19
|
+
import "./chunk-5JLVQVKO.js";
|
|
20
|
+
import "./chunk-KCCFN4F7.js";
|
|
21
|
+
import "./chunk-6XWCMJDB.js";
|
|
22
|
+
import {
|
|
23
|
+
isUrl
|
|
24
|
+
} from "./chunk-4ORL4MST.js";
|
|
19
25
|
import {
|
|
20
26
|
output
|
|
21
27
|
} from "./chunk-T5HJUAWB.js";
|
|
22
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-XEDGMZJD.js";
|
|
23
29
|
import "./chunk-IKT5F47M.js";
|
|
24
30
|
import "./chunk-3MZYUBJ6.js";
|
|
25
31
|
|
|
@@ -29,13 +35,72 @@ import as from "ansis";
|
|
|
29
35
|
import { Hono } from "hono";
|
|
30
36
|
import { stream } from "hono/streaming";
|
|
31
37
|
|
|
38
|
+
// src/domains/document/serve/load-config.ts
|
|
39
|
+
import { readFile } from "node:fs/promises";
|
|
40
|
+
var loadServeConfig = async (file) => {
|
|
41
|
+
if (file === void 0) {
|
|
42
|
+
return ok({});
|
|
43
|
+
}
|
|
44
|
+
const content = await readFile(file, "utf8").catch(() => void 0);
|
|
45
|
+
if (content === void 0) {
|
|
46
|
+
return err(`Could not read configuration file: ${file}`);
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const configuration = JSON.parse(content);
|
|
50
|
+
if (!configuration || typeof configuration !== "object" || Array.isArray(configuration)) {
|
|
51
|
+
return err(`Configuration file must contain a JSON object: ${file}`);
|
|
52
|
+
}
|
|
53
|
+
return ok(configuration);
|
|
54
|
+
} catch {
|
|
55
|
+
return err(`Configuration file contains invalid JSON: ${file}`);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
32
59
|
// src/domains/document/serve/load-document.ts
|
|
60
|
+
import path from "node:path";
|
|
33
61
|
import { validate } from "@scalar/asyncapi-validator";
|
|
62
|
+
import { bundle } from "@scalar/json-magic/bundle";
|
|
63
|
+
import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
|
|
34
64
|
var loadServeDocument = async (input) => {
|
|
35
65
|
const content = await getFileOrUrl(input);
|
|
36
66
|
const document = safeNormalize(content);
|
|
37
67
|
if (!isDocument(document) || !isAsyncApiDocument(document)) {
|
|
38
|
-
|
|
68
|
+
const result2 = await loadOpenApiDocument(content);
|
|
69
|
+
if (!result2.specification) {
|
|
70
|
+
return result2;
|
|
71
|
+
}
|
|
72
|
+
const errors = [];
|
|
73
|
+
const bundled = await bundle(result2.specification, {
|
|
74
|
+
plugins: [readFiles(), fetchUrls()],
|
|
75
|
+
origin: isUrl(input) ? input : path.resolve(input),
|
|
76
|
+
treeShake: false,
|
|
77
|
+
hooks: {
|
|
78
|
+
onResolveError: (node) => {
|
|
79
|
+
errors.push({ message: `Failed to resolve reference: ${node.$ref}` });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}).catch((error) => {
|
|
83
|
+
errors.push({
|
|
84
|
+
message: error instanceof Error ? error.message : String(error)
|
|
85
|
+
});
|
|
86
|
+
return result2.specification;
|
|
87
|
+
});
|
|
88
|
+
const specification = isDocument(bundled) ? bundled : result2.specification;
|
|
89
|
+
for (const error of errors) {
|
|
90
|
+
output.warn().title(error.message).print();
|
|
91
|
+
}
|
|
92
|
+
if (!result2.valid || errors.length > 0) {
|
|
93
|
+
return {
|
|
94
|
+
...result2,
|
|
95
|
+
valid: false,
|
|
96
|
+
errors: [...result2.errors ?? [], ...errors],
|
|
97
|
+
specification
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
...result2,
|
|
102
|
+
specification
|
|
103
|
+
};
|
|
39
104
|
}
|
|
40
105
|
const result = validate(document);
|
|
41
106
|
if (!result.valid) {
|
|
@@ -53,10 +118,19 @@ var loadServeDocument = async (input) => {
|
|
|
53
118
|
};
|
|
54
119
|
|
|
55
120
|
// src/domains/document/serve/action.ts
|
|
56
|
-
async function serveAction(inputArgument, {
|
|
121
|
+
async function serveAction(inputArgument, {
|
|
122
|
+
watch,
|
|
123
|
+
once,
|
|
124
|
+
port,
|
|
125
|
+
config
|
|
126
|
+
}) {
|
|
57
127
|
if (!inputArgument) {
|
|
58
128
|
return output.error().title("Invalid argument").message("Please provide a file path").exit("error");
|
|
59
129
|
}
|
|
130
|
+
const configuration = await loadServeConfig(config);
|
|
131
|
+
if (!configuration.ok) {
|
|
132
|
+
return output.error().title("Invalid configuration").message(configuration.error).exit("error");
|
|
133
|
+
}
|
|
60
134
|
const result = await loadServeDocument(inputArgument);
|
|
61
135
|
if (result.specification === void 0) {
|
|
62
136
|
return;
|
|
@@ -68,7 +142,7 @@ async function serveAction(inputArgument, { watch, once, port }) {
|
|
|
68
142
|
}
|
|
69
143
|
const app = new Hono();
|
|
70
144
|
app.get("/", (c) => {
|
|
71
|
-
return c.html(getHtmlDocument(specification, watch));
|
|
145
|
+
return c.html(getHtmlDocument(specification, watch, configuration.data));
|
|
72
146
|
});
|
|
73
147
|
app.use("/__watcher", async (c, next) => {
|
|
74
148
|
c.header("Content-Type", "text/event-stream");
|
|
@@ -120,7 +194,7 @@ async function serveAction(inputArgument, { watch, once, port }) {
|
|
|
120
194
|
}, 2e3);
|
|
121
195
|
}
|
|
122
196
|
}
|
|
123
|
-
var getHtmlDocument = (specification, watch = false) => {
|
|
197
|
+
var getHtmlDocument = (specification, watch = false, configuration = {}) => {
|
|
124
198
|
return `<!doctype html>
|
|
125
199
|
<html>
|
|
126
200
|
<head>
|
|
@@ -148,7 +222,8 @@ var getHtmlDocument = (specification, watch = false) => {
|
|
|
148
222
|
<script
|
|
149
223
|
id="api-reference"
|
|
150
224
|
type="application/json"
|
|
151
|
-
data-
|
|
225
|
+
data-configuration="${JSON.stringify(configuration).replaceAll("&", "\\u0026").replaceAll("<", "\\u003c").replaceAll(">", "\\u003e").replaceAll('"', """)}"
|
|
226
|
+
data-proxy-url="https://proxy.scalar.com">${JSON.stringify(specification).replaceAll("<", "\\u003c")}</script>
|
|
152
227
|
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
|
|
153
228
|
</body>
|
|
154
229
|
</html>`;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getUserTeams
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6YPQGVF4.js";
|
|
5
5
|
import {
|
|
6
6
|
getDatabaseClient
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-4X47MN6Q.js";
|
|
8
|
+
import "./chunk-MLSZVVTT.js";
|
|
9
9
|
import {
|
|
10
10
|
getAuthData
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-CWCETP6H.js";
|
|
12
|
+
import "./chunk-GPNB7ISG.js";
|
|
13
|
+
import "./chunk-5UHLAJQD.js";
|
|
14
|
+
import "./chunk-5JLVQVKO.js";
|
|
15
15
|
import "./chunk-4ORL4MST.js";
|
|
16
16
|
import {
|
|
17
17
|
output,
|
|
@@ -6,22 +6,22 @@ import {
|
|
|
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
13
|
legacyTo2_0_0
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-XXSQUBXS.js";
|
|
15
15
|
import {
|
|
16
16
|
ConfigVersion
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-5JLVQVKO.js";
|
|
18
18
|
import "./chunk-K74E42RV.js";
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-KCCFN4F7.js";
|
|
20
|
+
import "./chunk-6XWCMJDB.js";
|
|
21
21
|
import {
|
|
22
22
|
output
|
|
23
23
|
} from "./chunk-T5HJUAWB.js";
|
|
24
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-XEDGMZJD.js";
|
|
25
25
|
import "./chunk-IKT5F47M.js";
|
|
26
26
|
import "./chunk-3MZYUBJ6.js";
|
|
27
27
|
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getProjectDeployments
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-2DSVF5AD.js";
|
|
5
5
|
import {
|
|
6
6
|
resolveProject
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-TSURUX4A.js";
|
|
8
8
|
import {
|
|
9
9
|
formatAbsoluteTime
|
|
10
10
|
} from "./chunk-AEFPCC4U.js";
|
|
11
11
|
import {
|
|
12
12
|
apiService
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-ISXH6Q7I.js";
|
|
14
|
+
import "./chunk-LG7IFACX.js";
|
|
15
|
+
import "./chunk-4X47MN6Q.js";
|
|
16
|
+
import "./chunk-BIKOD3SG.js";
|
|
17
|
+
import "./chunk-MLSZVVTT.js";
|
|
18
|
+
import "./chunk-FDC2IESH.js";
|
|
19
|
+
import "./chunk-C2KAWRIX.js";
|
|
20
|
+
import "./chunk-R5LK6VPY.js";
|
|
21
21
|
import {
|
|
22
22
|
getAuthData
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-CWCETP6H.js";
|
|
24
|
+
import "./chunk-GPNB7ISG.js";
|
|
25
|
+
import "./chunk-5UHLAJQD.js";
|
|
26
|
+
import "./chunk-5JLVQVKO.js";
|
|
27
27
|
import "./chunk-K74E42RV.js";
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-KCCFN4F7.js";
|
|
29
|
+
import "./chunk-6XWCMJDB.js";
|
|
30
30
|
import "./chunk-4ORL4MST.js";
|
|
31
31
|
import {
|
|
32
32
|
output,
|
|
33
33
|
printTable
|
|
34
34
|
} from "./chunk-T5HJUAWB.js";
|
|
35
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-XEDGMZJD.js";
|
|
36
36
|
import {
|
|
37
37
|
external_exports,
|
|
38
38
|
slugSchema
|
|
@@ -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-QXQZVEDC.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-2PPRO2QB.js";
|
|
17
17
|
import {
|
|
18
18
|
getAuthData
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-CWCETP6H.js";
|
|
20
20
|
import {
|
|
21
21
|
config
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-GPNB7ISG.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
|
}
|
|
@@ -2,15 +2,18 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
|
|
|
2
2
|
import {
|
|
3
3
|
measureTime
|
|
4
4
|
} from "./chunk-KHDYYVYF.js";
|
|
5
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-HGOD6THU.js";
|
|
6
6
|
import {
|
|
7
7
|
DEFAULT_FETCH_CONCURRENCY
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-OJ2EWIJH.js";
|
|
9
|
+
import {
|
|
10
|
+
requireInteractive
|
|
11
|
+
} from "./chunk-EGOXR5FB.js";
|
|
9
12
|
import {
|
|
10
13
|
require_dist
|
|
11
14
|
} from "./chunk-K74E42RV.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-KCCFN4F7.js";
|
|
16
|
+
import "./chunk-6XWCMJDB.js";
|
|
14
17
|
import {
|
|
15
18
|
isUrl,
|
|
16
19
|
isYamlFileName
|
|
@@ -18,7 +21,7 @@ import {
|
|
|
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 {
|
|
24
27
|
__toESM
|
|
@@ -49,6 +52,9 @@ async function bundleAction(input, {
|
|
|
49
52
|
"Please provide an output file using the -o flag when bundling from a URL."
|
|
50
53
|
).exit("error");
|
|
51
54
|
}
|
|
55
|
+
requireInteractive(
|
|
56
|
+
"Pass --output to bundle a document in non-interactive mode."
|
|
57
|
+
);
|
|
52
58
|
const shouldContinue = await confirm({
|
|
53
59
|
message: "No output file specified - this will overwrite the input file. Continue?",
|
|
54
60
|
initialValue: false
|