@scalar/cli 2.10.0 → 2.12.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 +84 -1289
- package/chunks/action-2OPUQFUY.js +164 -0
- package/chunks/{action-4GZI2M5B.js → action-36LZ6XXE.js} +19 -17
- package/chunks/{action-KDUFU7TZ.js → action-3XMTJJRT.js} +19 -16
- package/chunks/{action-R4PGILN4.js → action-6CLEENBI.js} +47 -36
- package/chunks/{action-ZFI77WA5.js → action-7HXYZPOT.js} +10 -10
- package/chunks/{action-X7BA7PQQ.js → action-AC5ENU6Z.js} +20 -18
- package/chunks/{action-PPTFYZWD.js → action-ADGLTNFC.js} +28 -22
- package/chunks/{action-7XOHYWYM.js → action-AOKHLTZ6.js} +25 -21
- package/chunks/{action-XOADBXSX.js → action-AVSJ3AJY.js} +17 -16
- package/chunks/{action-GFLRD7LO.js → action-D3IVCY24.js} +8 -8
- package/chunks/action-EBZJS367.js +130 -0
- package/chunks/{action-ZKA3RR3S.js → action-EZXHSAJ2.js} +18 -17
- package/chunks/{action-5LF4XYHX.js → action-FDTVHVHF.js} +12 -12
- package/chunks/{action-JEYDBB3P.js → action-FUO5F7NV.js} +15 -15
- package/chunks/{action-DKDRAIKV.js → action-HA3CMV3P.js} +13 -15
- package/chunks/{action-YSVTZVKV.js → action-IG3BK2LF.js} +37 -26
- package/chunks/{action-H3RTILLM.js → action-IIQMZVRJ.js} +1 -1
- package/chunks/{action-DTEO4YNX.js → action-JT6C472I.js} +13 -11
- package/chunks/{action-UUL6SWV4.js → action-KDT6H6ML.js} +12 -14
- package/chunks/{action-PAM2EZ22.js → action-KJDIJQ3A.js} +8 -7
- package/chunks/{action-HT42NUUX.js → action-NF5E7JKA.js} +40 -38
- package/chunks/{action-EAUTQ77U.js → action-NIZBME45.js} +26 -24
- package/chunks/{action-CB55NWAU.js → action-O757TFA2.js} +9 -9
- package/chunks/{action-XLE37MZL.js → action-ONR7QSN7.js} +23 -22
- package/chunks/{action-5RL4NWUZ.js → action-QM2BMMHG.js} +33 -30
- package/chunks/{action-GWYYTUTM.js → action-QVTAZCKY.js} +5 -5
- package/chunks/action-SLB52XRG.js +65 -0
- package/chunks/{action-CABLS46Q.js → action-UTFRCKGE.js} +11 -11
- package/chunks/{action-4W5GUGEG.js → action-VESBFIP3.js} +20 -19
- package/chunks/{action-657A4K2D.js → action-VGFAIFYE.js} +26 -23
- package/chunks/action-WCU5O2VT.js +100 -0
- package/chunks/{action-TOBU74JH.js → action-XS5EESHW.js} +51 -27
- package/chunks/action-XVNRZ5VX.js +38 -0
- package/chunks/action-Y7EBKCUU.js +16 -0
- package/chunks/{action-5N3P43MD.js → action-YWQ2OKS3.js} +16 -15
- package/chunks/{actions-3SAMH7A5.js → actions-6QG7LH7P.js} +23 -20
- package/chunks/{agent-2ESZI7NO.js → agent-ONXROEAE.js} +44 -9
- package/chunks/{asyncapi-4HGVM3PR.js → asyncapi-7IFXAIE3.js} +13 -12
- package/chunks/{build.action-VBGFGACM.js → build.action-FI4OWY3T.js} +28 -26
- package/chunks/{chunk-ZGNDXPLU.js → chunk-26VIHQGL.js} +3 -3
- package/chunks/{chunk-JXGF5EHC.js → chunk-3HCEUGOE.js} +42 -13
- package/chunks/{chunk-G4HRW2FZ.js → chunk-5TNKTLQP.js} +370 -254
- package/chunks/{chunk-XAGJJNQW.js → chunk-BB6WWG25.js} +10 -10
- package/chunks/{chunk-K2HIB5BA.js → chunk-BCFUMXMC.js} +3 -3
- package/chunks/{action-F2ZJNURT.js → chunk-EBNFCIKS.js} +7 -10
- package/chunks/{chunk-MC4EMNOR.js → chunk-EJSGWV2K.js} +7 -6
- package/chunks/{chunk-GYRQPDTK.js → chunk-FJCOYEKT.js} +139 -3
- package/chunks/{chunk-ZKJPLWRJ.js → chunk-HU47OMI4.js} +4 -4
- package/chunks/{chunk-VVRUSQCY.js → chunk-I57ID5K7.js} +13 -0
- package/chunks/{chunk-43WALAW3.js → chunk-JLNHOA5Z.js} +64 -115
- package/chunks/{chunk-5SMP756H.js → chunk-LCSU43NJ.js} +2 -2
- package/chunks/{chunk-KHF2QXBG.js → chunk-N645RGAB.js} +1853 -683
- package/chunks/{chunk-3ZJYGGAA.js → chunk-ORCUZITN.js} +1 -1
- package/chunks/{chunk-H467HDVV.js → chunk-PERC34BV.js} +1 -1
- package/chunks/chunk-Q26DFKTY.js +37 -0
- package/chunks/{chunk-MMWSCTDB.js → chunk-QJQTSRU4.js} +19 -19
- package/chunks/{chunk-WDIWLXLV.js → chunk-RLBS4HJT.js} +3 -3
- package/chunks/{chunk-ATNTXKMS.js → chunk-RNZVZMYC.js} +198 -42
- package/chunks/{chunk-IPZP3VRA.js → chunk-RYWXF3LO.js} +12 -21
- package/chunks/{chunk-CWVYOXXM.js → chunk-SNOAL2C5.js} +11 -7
- package/chunks/{chunk-UDBSV3CK.js → chunk-T3R66THO.js} +6085 -4167
- package/chunks/{chunk-VYFGRLVQ.js → chunk-U73OW57G.js} +1 -1
- package/chunks/chunk-U764PQUA.js +1034 -0
- package/chunks/{chunk-KZNRQVMY.js → chunk-UAFCSWQ6.js} +1 -1
- package/chunks/{chunk-WB6PWTMU.js → chunk-UBLFIMUA.js} +1 -1
- package/chunks/{chunk-WIEXQUTD.js → chunk-UODTHS76.js} +1 -1
- package/chunks/chunk-V3MYP5SQ.js +247 -0
- package/chunks/{chunk-36LXIJIZ.js → chunk-V6LUKXBV.js} +1 -16
- package/chunks/{chunk-6M7TL2G2.js → chunk-VRZSDUZK.js} +45 -5
- package/chunks/{chunk-GLWTVLKM.js → chunk-VUNOOPEG.js} +9 -2
- package/chunks/chunk-VUXPDHTQ.js +22 -0
- package/chunks/{chunk-DHZW7Q7U.js → chunk-VVQOFG76.js} +2 -4
- package/chunks/chunk-XP5UM7SF.js +21 -0
- package/chunks/{chunk-ZYBLQ5CT.js → chunk-Y6C3H27E.js} +9 -4
- package/chunks/{chunk-35Z7VTJT.js → chunk-YTFFBGNQ.js} +52 -38
- package/chunks/{chunk-BIMLCGKS.js → chunk-ZNLMQKDU.js} +1 -1
- package/chunks/{create.action-DBNIS665.js → create.action-PPMZEMZL.js} +34 -32
- package/chunks/{delete.action-GBOZC45K.js → delete.action-GDOHATRZ.js} +30 -28
- package/chunks/{delete.action-K7BLK7DK.js → delete.action-VAHKEHEU.js} +29 -27
- package/chunks/{get.action-QHKMYZBK.js → get.action-UXFTGO7W.js} +24 -20
- package/chunks/{get.action-N3JOY3OU.js → get.action-XON3EZDT.js} +16 -15
- package/chunks/{list.action-TJCS6UEY.js → list.action-24F5WDGR.js} +37 -26
- package/chunks/{list.action-6SSO3JVN.js → list.action-OQEAEJ5U.js} +39 -29
- package/chunks/{publish.action-T24VHRMR.js → publish.action-G7FPDRBZ.js} +45 -43
- package/chunks/{scripts-VIBLGKYG.js → scripts-6CI6U32J.js} +1 -1
- package/chunks/{update.action-VOE6PH5F.js → update.action-IFIFXZWA.js} +29 -27
- package/chunks/{update.action-OGYNBXRU.js → update.action-MJDHVVR3.js} +30 -28
- package/index.js +290 -284
- package/package.json +2 -2
- package/skills/scalar-cli/SKILL.md +49 -49
- package/template.md +68 -252
- package/chunks/action-FBRY5JKU.js +0 -37
- package/chunks/action-LYCNT3KA.js +0 -73
- package/chunks/action-OJ2NK25F.js +0 -121
- package/chunks/action-U2L5DCFG.js +0 -91
- package/chunks/chunk-MNNGUUKJ.js +0 -405
- package/chunks/chunk-ZGVZU6L2.js +0 -422
- package/docs.html +0 -6977
|
@@ -9,17 +9,18 @@ import {
|
|
|
9
9
|
generateAccessByPersonalToken,
|
|
10
10
|
requestTokens,
|
|
11
11
|
setAuthData
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-YTFFBGNQ.js";
|
|
13
13
|
import {
|
|
14
14
|
config
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
15
|
+
} from "./chunk-UBLFIMUA.js";
|
|
16
|
+
import "./chunk-VVQOFG76.js";
|
|
17
|
+
import "./chunk-FJCOYEKT.js";
|
|
18
|
+
import "./chunk-VRZSDUZK.js";
|
|
19
19
|
import {
|
|
20
20
|
output
|
|
21
21
|
} from "./chunk-T5HJUAWB.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-Q26DFKTY.js";
|
|
23
|
+
import "./chunk-I57ID5K7.js";
|
|
23
24
|
import "./chunk-3MZYUBJ6.js";
|
|
24
25
|
|
|
25
26
|
// src/domains/auth/login/action.ts
|
|
@@ -31,9 +32,8 @@ import getPort from "get-port";
|
|
|
31
32
|
// src/domains/auth/login/helpers/messages.ts
|
|
32
33
|
import as from "ansis";
|
|
33
34
|
function loggedInMessage(userIdentifier) {
|
|
34
|
-
if (process.env.CI || !userIdentifier)
|
|
35
|
-
|
|
36
|
-
return `Successfully authenticated to Scalar CLI as ${as.cyan(userIdentifier)}`;
|
|
35
|
+
if (process.env.CI || !userIdentifier) return "Logged in to Scalar.";
|
|
36
|
+
return `Logged in to Scalar as ${as.cyan(userIdentifier)}.`;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// src/domains/auth/login/action.ts
|
|
@@ -81,7 +81,7 @@ async function loginAction({
|
|
|
81
81
|
}) {
|
|
82
82
|
if (email || password) {
|
|
83
83
|
return output.error().title(
|
|
84
|
-
"Email and password
|
|
84
|
+
"Email and password authentication is no longer supported. Use `scalar auth login --token <token>` or `scalar auth login` to log in through your browser."
|
|
85
85
|
).exit("error");
|
|
86
86
|
}
|
|
87
87
|
const token = process.env.SCALAR_API_KEY || _token;
|
|
@@ -93,7 +93,7 @@ async function loginAction({
|
|
|
93
93
|
const { email: userEmail } = decode(accessToken, accessTokenPayloadSchema);
|
|
94
94
|
output.info().message(loggedInMessage(userEmail)).print();
|
|
95
95
|
} catch (err) {
|
|
96
|
-
return output.error().title("Invalid token").message(err.message ?? "
|
|
96
|
+
return output.error().title("Invalid token").message(err.message ?? "Provide a valid personal token.").exit("error");
|
|
97
97
|
}
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
@@ -103,7 +103,7 @@ async function loginAction({
|
|
|
103
103
|
try {
|
|
104
104
|
callback = await listenForCode(state);
|
|
105
105
|
} catch (err) {
|
|
106
|
-
return output.error().title("
|
|
106
|
+
return output.error().title("Could not start the login callback server").message(err.message).exit("error");
|
|
107
107
|
}
|
|
108
108
|
const loginUrl = new URL("/_scalar/oauth/authorize", config.auth.origin);
|
|
109
109
|
loginUrl.search = new URLSearchParams({
|
|
@@ -114,7 +114,7 @@ async function loginAction({
|
|
|
114
114
|
code_challenge_method: "S256",
|
|
115
115
|
state
|
|
116
116
|
}).toString();
|
|
117
|
-
output.info().message("
|
|
117
|
+
output.info().message("Open this URL to log in:").print();
|
|
118
118
|
process.stdout.write(`${as2.cyan(loginUrl.href)}
|
|
119
119
|
`);
|
|
120
120
|
openBrowser(loginUrl.href);
|
|
@@ -128,7 +128,7 @@ async function loginAction({
|
|
|
128
128
|
redirect_uri: callback.redirectUri
|
|
129
129
|
}).catch(() => void 0) : void 0;
|
|
130
130
|
finish(Boolean(tokens?.refresh_token));
|
|
131
|
-
if (!tokens?.refresh_token) throw new Error("Unable to
|
|
131
|
+
if (!tokens?.refresh_token) throw new Error("Unable to log in");
|
|
132
132
|
await setAuthData({
|
|
133
133
|
accessToken: tokens.access_token,
|
|
134
134
|
refreshToken: tokens.refresh_token
|
|
@@ -139,7 +139,7 @@ async function loginAction({
|
|
|
139
139
|
);
|
|
140
140
|
return output.info().message(loggedInMessage(userEmail)).exit("success");
|
|
141
141
|
} catch {
|
|
142
|
-
return output.error().title("
|
|
142
|
+
return output.error().title("Could not log in to Scalar").exit("error");
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
export {
|
|
@@ -5,25 +5,25 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
getFileOrUrl,
|
|
7
7
|
isDocument
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SNOAL2C5.js";
|
|
9
9
|
import {
|
|
10
10
|
isAsyncApiDocument,
|
|
11
11
|
safeNormalize
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-PERC34BV.js";
|
|
13
13
|
import {
|
|
14
14
|
requireInteractive
|
|
15
15
|
} from "./chunk-EGOXR5FB.js";
|
|
16
|
-
import "./chunk-GLWTVLKM.js";
|
|
17
16
|
import {
|
|
18
17
|
isUrl,
|
|
19
18
|
isYamlFileName
|
|
20
19
|
} from "./chunk-4ORL4MST.js";
|
|
21
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-VUNOOPEG.js";
|
|
22
21
|
import {
|
|
23
22
|
output
|
|
24
23
|
} from "./chunk-T5HJUAWB.js";
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-U764PQUA.js";
|
|
25
|
+
import "./chunk-Q26DFKTY.js";
|
|
26
|
+
import "./chunk-I57ID5K7.js";
|
|
27
27
|
import "./chunk-3MZYUBJ6.js";
|
|
28
28
|
|
|
29
29
|
// src/domains/document/upgrade/action.ts
|
|
@@ -35,24 +35,22 @@ import { upgrade as upgradeAsyncApi } from "@scalar/asyncapi-upgrader";
|
|
|
35
35
|
import { upgrade } from "@scalar/openapi-upgrader";
|
|
36
36
|
async function upgradeAction(input, { output: outputFilePath }) {
|
|
37
37
|
if (!input) {
|
|
38
|
-
return output.error().title("Missing input").message("
|
|
38
|
+
return output.error().title("Missing input").message("Provide a file path or URL to upgrade.").exit("error");
|
|
39
39
|
}
|
|
40
40
|
const isUrlInput = isUrl(input);
|
|
41
41
|
if (!outputFilePath) {
|
|
42
42
|
if (isUrlInput) {
|
|
43
|
-
return output.error().message(
|
|
44
|
-
"Please provide an output file using the -o flag when upgrading from a URL."
|
|
45
|
-
).exit("error");
|
|
43
|
+
return output.error().message("URL input requires an output file. Use `--output <file>`.").exit("error");
|
|
46
44
|
}
|
|
47
45
|
requireInteractive(
|
|
48
46
|
"Pass --output to upgrade a document in non-interactive mode."
|
|
49
47
|
);
|
|
50
48
|
const shouldContinue = await confirm({
|
|
51
|
-
message:
|
|
49
|
+
message: `No output file was specified. Overwrite "${input}"?`,
|
|
52
50
|
initialValue: false
|
|
53
51
|
});
|
|
54
52
|
if (shouldContinue !== true) {
|
|
55
|
-
return output.error().message("Operation cancelled
|
|
53
|
+
return output.error().message("Operation cancelled.").exit("error");
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
const outputFileName = outputFilePath ?? input;
|
|
@@ -60,7 +58,7 @@ async function upgradeAction(input, { output: outputFilePath }) {
|
|
|
60
58
|
const document = safeNormalize(content);
|
|
61
59
|
if (!isDocument(document)) {
|
|
62
60
|
return output.error().title("Invalid input").message(
|
|
63
|
-
"Could not read a document from the input.
|
|
61
|
+
"Could not read a document from the input. Provide a valid JSON or YAML file."
|
|
64
62
|
).exit("error");
|
|
65
63
|
}
|
|
66
64
|
const isAsyncApi = isAsyncApiDocument(document);
|
|
@@ -76,8 +74,8 @@ async function upgradeAction(input, { output: outputFilePath }) {
|
|
|
76
74
|
const version = upgraded[isAsyncApi ? "asyncapi" : "openapi"];
|
|
77
75
|
const versionSuffix = typeof version === "string" ? ` to version ${version}` : "";
|
|
78
76
|
output.info().message(
|
|
79
|
-
`${as.green(
|
|
80
|
-
).print();
|
|
77
|
+
`${as.green(`${specification} description upgraded${versionSuffix}`)} (${as.white(`${as.bold(`${executionTimeMs.toFixed(2)}`)} ms`)})`
|
|
78
|
+
).line(`Written to ${as.cyan(outputFileName)}`).print();
|
|
81
79
|
}
|
|
82
80
|
export {
|
|
83
81
|
upgradeAction
|
|
@@ -1,41 +1,48 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
dashboardUrl
|
|
4
|
+
} from "./chunk-LCSU43NJ.js";
|
|
2
5
|
import {
|
|
3
6
|
BaseCollections
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3HCEUGOE.js";
|
|
5
8
|
import {
|
|
6
9
|
getDatabaseClient
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RLBS4HJT.js";
|
|
8
11
|
import {
|
|
9
12
|
apiService
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-IPZP3VRA.js";
|
|
13
|
+
} from "./chunk-RNZVZMYC.js";
|
|
14
|
+
import "./chunk-N645RGAB.js";
|
|
15
|
+
import "./chunk-JLNHOA5Z.js";
|
|
16
|
+
import "./chunk-Y6C3H27E.js";
|
|
15
17
|
import "./chunk-5ENKYZA4.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-RYWXF3LO.js";
|
|
19
|
+
import "./chunk-5TNKTLQP.js";
|
|
20
|
+
import "./chunk-V3MYP5SQ.js";
|
|
21
|
+
import "./chunk-V6LUKXBV.js";
|
|
22
|
+
import "./chunk-VUXPDHTQ.js";
|
|
18
23
|
import {
|
|
19
24
|
getAuthData
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
25
|
+
} from "./chunk-YTFFBGNQ.js";
|
|
26
|
+
import "./chunk-UBLFIMUA.js";
|
|
27
|
+
import "./chunk-VVQOFG76.js";
|
|
23
28
|
import {
|
|
24
29
|
teamSchema
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-GLWTVLKM.js";
|
|
30
|
+
} from "./chunk-FJCOYEKT.js";
|
|
31
|
+
import "./chunk-VRZSDUZK.js";
|
|
28
32
|
import "./chunk-4ORL4MST.js";
|
|
29
|
-
import
|
|
33
|
+
import {
|
|
34
|
+
RegistryAsset
|
|
35
|
+
} from "./chunk-VUNOOPEG.js";
|
|
30
36
|
import {
|
|
31
37
|
output,
|
|
32
38
|
printTable
|
|
33
39
|
} from "./chunk-T5HJUAWB.js";
|
|
34
|
-
import "./chunk-
|
|
40
|
+
import "./chunk-U764PQUA.js";
|
|
41
|
+
import "./chunk-Q26DFKTY.js";
|
|
35
42
|
import {
|
|
36
43
|
external_exports,
|
|
37
44
|
namespaceSchema
|
|
38
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-I57ID5K7.js";
|
|
39
46
|
import "./chunk-3MZYUBJ6.js";
|
|
40
47
|
|
|
41
48
|
// src/domains/registry/list/action.ts
|
|
@@ -59,11 +66,11 @@ async function listAction(args) {
|
|
|
59
66
|
schema: teamSchema
|
|
60
67
|
});
|
|
61
68
|
if (team.error)
|
|
62
|
-
return output.error().title("
|
|
69
|
+
return output.error().title("Could not load the current team").message(team.message).exit("error");
|
|
63
70
|
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
64
71
|
if (!namespace) {
|
|
65
72
|
return output.error().title("Missing namespace").message(
|
|
66
|
-
"
|
|
73
|
+
"No team namespace is selected. Pass --namespace <namespace> or run `scalar team get` to see available namespaces."
|
|
67
74
|
).exit("error");
|
|
68
75
|
}
|
|
69
76
|
const apiClient = await apiService();
|
|
@@ -88,21 +95,25 @@ async function listAction(args) {
|
|
|
88
95
|
return;
|
|
89
96
|
}
|
|
90
97
|
if (listApisRes.data.length === 0) {
|
|
91
|
-
output.info().
|
|
98
|
+
output.info().message(`No Scalar Registry APIs found for namespace "${namespace}".`).print();
|
|
92
99
|
return;
|
|
93
100
|
}
|
|
94
101
|
printTable(
|
|
95
102
|
[
|
|
96
103
|
{ name: "title", title: "Title", alignment: "left", maxLen: 40 },
|
|
97
|
-
{ name: "
|
|
98
|
-
{ name: "
|
|
99
|
-
{ name: "
|
|
104
|
+
{ name: "namespace", title: "Namespace", alignment: "left" },
|
|
105
|
+
{ name: "slug", title: "Slug", alignment: "left", color: "blue" },
|
|
106
|
+
{ name: "version", title: "Current version", alignment: "left" },
|
|
107
|
+
{ name: "access", title: "Access", alignment: "left" },
|
|
108
|
+
{ name: "dashboard", title: "Dashboard", alignment: "left" }
|
|
100
109
|
],
|
|
101
110
|
listApisRes.data.map((api) => ({
|
|
102
111
|
title: api.title || as.dim("\u2014"),
|
|
103
|
-
|
|
112
|
+
namespace: api.namespace,
|
|
113
|
+
slug: api.slug,
|
|
104
114
|
version: api.version,
|
|
105
|
-
access: api.isPrivate ?
|
|
115
|
+
access: api.isPrivate ? "Private" : "Public",
|
|
116
|
+
dashboard: dashboardUrl(RegistryAsset.Apis, api.uid)
|
|
106
117
|
}))
|
|
107
118
|
);
|
|
108
119
|
}
|
|
@@ -32,7 +32,7 @@ var bootServer = async ({
|
|
|
32
32
|
},
|
|
33
33
|
(info) => {
|
|
34
34
|
output.info().line(
|
|
35
|
-
`${as.green.bold("\u279C
|
|
35
|
+
`${as.green.bold("\u279C Request-mirroring server")} ${as.white(
|
|
36
36
|
"listening on"
|
|
37
37
|
)} ${as.cyan(`http://localhost:${info.port}`)}
|
|
38
38
|
`
|
|
@@ -4,27 +4,27 @@ import {
|
|
|
4
4
|
} from "./chunk-KHDYYVYF.js";
|
|
5
5
|
import {
|
|
6
6
|
isDocument
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-SNOAL2C5.js";
|
|
8
8
|
import {
|
|
9
9
|
isAsyncApiDocument,
|
|
10
10
|
safeNormalize
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-PERC34BV.js";
|
|
12
12
|
import {
|
|
13
13
|
err,
|
|
14
14
|
ok
|
|
15
15
|
} from "./chunk-5ENKYZA4.js";
|
|
16
|
-
import "./chunk-GLWTVLKM.js";
|
|
17
16
|
import {
|
|
18
17
|
isYamlFileName
|
|
19
18
|
} from "./chunk-4ORL4MST.js";
|
|
20
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-VUNOOPEG.js";
|
|
21
20
|
import {
|
|
22
21
|
output
|
|
23
22
|
} from "./chunk-T5HJUAWB.js";
|
|
24
|
-
import "./chunk-
|
|
23
|
+
import "./chunk-U764PQUA.js";
|
|
24
|
+
import "./chunk-Q26DFKTY.js";
|
|
25
25
|
import {
|
|
26
26
|
external_exports
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-I57ID5K7.js";
|
|
28
28
|
import "./chunk-3MZYUBJ6.js";
|
|
29
29
|
|
|
30
30
|
// src/domains/document/join/action.ts
|
|
@@ -301,14 +301,16 @@ async function joinAction(rawInput, rawOpt) {
|
|
|
301
301
|
}).safeParse(rawOpt);
|
|
302
302
|
if (optsError) {
|
|
303
303
|
return output.error().title("Invalid options").line("").line(
|
|
304
|
-
optsError.issues.map(
|
|
304
|
+
optsError.issues.map(
|
|
305
|
+
(e) => e.path[0] === "output" ? "Provide an output file with --output <file>." : `${e.message} (option: ${e.path.join(".")})`
|
|
306
|
+
).join("\n")
|
|
305
307
|
).line("").exit("error");
|
|
306
308
|
}
|
|
307
309
|
const files = (await Promise.all(input.map((file) => fs.readFile(file, "utf-8")))).map((it) => {
|
|
308
310
|
const document = safeNormalize(it);
|
|
309
311
|
if (!isDocument(document)) {
|
|
310
312
|
return output.error().title("Invalid input").message(
|
|
311
|
-
"Could not read an API document from one of the input files.
|
|
313
|
+
"Could not read an API document from one of the input files. Provide valid JSON or YAML files."
|
|
312
314
|
).exit("error");
|
|
313
315
|
}
|
|
314
316
|
return document;
|
|
@@ -326,7 +328,7 @@ async function joinAction(rawInput, rawOpt) {
|
|
|
326
328
|
});
|
|
327
329
|
if (!isDocument(document)) {
|
|
328
330
|
return output.error().title("Invalid input").message(
|
|
329
|
-
"Could not read an API document from one of the input files.
|
|
331
|
+
"Could not read an API document from one of the input files. Provide valid JSON or YAML files."
|
|
330
332
|
).exit("error");
|
|
331
333
|
}
|
|
332
334
|
return document;
|
|
@@ -349,8 +351,8 @@ ${formatErrorMessage(result.error).join("\n")}`).line().exit("error");
|
|
|
349
351
|
"utf8"
|
|
350
352
|
);
|
|
351
353
|
output.info().message(
|
|
352
|
-
`${as.green(
|
|
353
|
-
).print();
|
|
354
|
+
`${as.green(`${specification} descriptions joined`)} (${as.white(`${as.bold(`${Math.round(executionTimeMs)}`)} ms`)})`
|
|
355
|
+
).line(`Written to ${as.cyan(opts.output)}`).print();
|
|
354
356
|
}
|
|
355
357
|
export {
|
|
356
358
|
joinAction
|
|
@@ -2,21 +2,21 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
|
|
|
2
2
|
import {
|
|
3
3
|
getFileOrUrl,
|
|
4
4
|
isDocument
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-SNOAL2C5.js";
|
|
6
6
|
import {
|
|
7
7
|
safeNormalize
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-GLWTVLKM.js";
|
|
8
|
+
} from "./chunk-PERC34BV.js";
|
|
10
9
|
import {
|
|
11
10
|
isUrl,
|
|
12
11
|
isYamlFileName
|
|
13
12
|
} from "./chunk-4ORL4MST.js";
|
|
14
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-VUNOOPEG.js";
|
|
15
14
|
import {
|
|
16
15
|
output
|
|
17
16
|
} from "./chunk-T5HJUAWB.js";
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-U764PQUA.js";
|
|
18
|
+
import "./chunk-Q26DFKTY.js";
|
|
19
|
+
import "./chunk-I57ID5K7.js";
|
|
20
20
|
import "./chunk-3MZYUBJ6.js";
|
|
21
21
|
|
|
22
22
|
// src/domains/document/format/action.ts
|
|
@@ -26,13 +26,13 @@ import { stringify } from "yaml";
|
|
|
26
26
|
async function formatAction(inputArgument, { output: outputPath }) {
|
|
27
27
|
const startTime = performance.now();
|
|
28
28
|
if (!inputArgument) {
|
|
29
|
-
return output.error().title("
|
|
29
|
+
return output.error().title("Missing input").message("Provide an API description file path or URL.").exit("error");
|
|
30
30
|
}
|
|
31
31
|
const content = await getFileOrUrl(inputArgument);
|
|
32
32
|
const document = safeNormalize(content);
|
|
33
33
|
if (!isDocument(document)) {
|
|
34
34
|
return output.error().title("Invalid input").message(
|
|
35
|
-
"Could not read a document from the input.
|
|
35
|
+
"Could not read a document from the input. Provide a valid JSON or YAML file."
|
|
36
36
|
).exit("error");
|
|
37
37
|
}
|
|
38
38
|
const newContent = isYamlFileName(outputPath || inputArgument) ? stringify(document) : JSON.stringify(document, null, 2);
|
|
@@ -41,16 +41,14 @@ async function formatAction(inputArgument, { output: outputPath }) {
|
|
|
41
41
|
} else if (!isUrl(inputArgument)) {
|
|
42
42
|
fs.writeFileSync(inputArgument, newContent, "utf8");
|
|
43
43
|
} else {
|
|
44
|
-
return output.error().title("
|
|
45
|
-
"Output file is required for URLs. Try passing --output file flag."
|
|
46
|
-
).exit("error");
|
|
44
|
+
return output.error().title("Missing input").message().message("URL input requires an output file. Use `--output <file>`.").exit("error");
|
|
47
45
|
}
|
|
48
46
|
const endTime = performance.now();
|
|
49
47
|
output.info().line(
|
|
50
|
-
`${as.green("
|
|
51
|
-
`
|
|
48
|
+
`${as.green("API description formatted")} ${as.grey(
|
|
49
|
+
`(${as.white(`${as.bold(`${Math.round(endTime - startTime)}`)} ms`)})`
|
|
52
50
|
)}`
|
|
53
|
-
).print();
|
|
51
|
+
).line(`Written to ${as.cyan(outputPath ?? inputArgument)}`).print();
|
|
54
52
|
}
|
|
55
53
|
export {
|
|
56
54
|
formatAction
|
|
@@ -2,13 +2,14 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
|
|
|
2
2
|
import {
|
|
3
3
|
readAndParseConfig,
|
|
4
4
|
renderConfigError
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-BB6WWG25.js";
|
|
6
|
+
import "./chunk-T3R66THO.js";
|
|
7
|
+
import "./chunk-5ENKYZA4.js";
|
|
8
|
+
import "./chunk-VRZSDUZK.js";
|
|
8
9
|
import {
|
|
9
10
|
output
|
|
10
11
|
} from "./chunk-T5HJUAWB.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-I57ID5K7.js";
|
|
12
13
|
import "./chunk-3MZYUBJ6.js";
|
|
13
14
|
|
|
14
15
|
// src/domains/project/check-config/action.ts
|
|
@@ -17,10 +18,10 @@ async function checkConfigAction(inputArgument) {
|
|
|
17
18
|
const result = readAndParseConfig(inputArgument);
|
|
18
19
|
if (result.success) {
|
|
19
20
|
output.info().line(
|
|
20
|
-
`${as.green("[SUCCESS]")} ${as.green("
|
|
21
|
+
`${as.green("[SUCCESS]")} ${as.green("Scalar configuration is valid:")} ${as.green(result.filePath)}`
|
|
21
22
|
).line(
|
|
22
|
-
`${as.green("Scalar
|
|
23
|
-
`
|
|
23
|
+
`${as.green("Scalar configuration validated")} ${as.grey(
|
|
24
|
+
`(${as.white.bold(`${result.validationTime} ms`)})`
|
|
24
25
|
)}
|
|
25
26
|
`
|
|
26
27
|
).print();
|
|
@@ -1,68 +1,70 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
registry
|
|
4
|
+
} from "./chunk-QJQTSRU4.js";
|
|
2
5
|
import {
|
|
3
6
|
dashboardUrl,
|
|
4
7
|
registryUrl
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
registry
|
|
8
|
-
} from "./chunk-MMWSCTDB.js";
|
|
8
|
+
} from "./chunk-LCSU43NJ.js";
|
|
9
9
|
import {
|
|
10
10
|
getFileOrUrl,
|
|
11
11
|
isDocument
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-SNOAL2C5.js";
|
|
13
13
|
import {
|
|
14
14
|
safeNormalize
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-PERC34BV.js";
|
|
16
16
|
import {
|
|
17
17
|
DEFAULT_FETCH_CONCURRENCY
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-EJSGWV2K.js";
|
|
19
19
|
import "./chunk-DFOZG7ZV.js";
|
|
20
20
|
import {
|
|
21
21
|
BaseCollections
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-3HCEUGOE.js";
|
|
23
23
|
import {
|
|
24
24
|
getDatabaseClient
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-RLBS4HJT.js";
|
|
26
26
|
import {
|
|
27
27
|
apiService
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-
|
|
32
|
-
import "./chunk-IPZP3VRA.js";
|
|
28
|
+
} from "./chunk-RNZVZMYC.js";
|
|
29
|
+
import "./chunk-N645RGAB.js";
|
|
30
|
+
import "./chunk-JLNHOA5Z.js";
|
|
31
|
+
import "./chunk-Y6C3H27E.js";
|
|
33
32
|
import "./chunk-5ENKYZA4.js";
|
|
34
|
-
import "./chunk-
|
|
35
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-RYWXF3LO.js";
|
|
34
|
+
import "./chunk-5TNKTLQP.js";
|
|
35
|
+
import "./chunk-V3MYP5SQ.js";
|
|
36
|
+
import "./chunk-V6LUKXBV.js";
|
|
37
|
+
import "./chunk-VUXPDHTQ.js";
|
|
36
38
|
import {
|
|
37
39
|
getAuthData
|
|
38
|
-
} from "./chunk-
|
|
39
|
-
import "./chunk-
|
|
40
|
-
import "./chunk-
|
|
40
|
+
} from "./chunk-YTFFBGNQ.js";
|
|
41
|
+
import "./chunk-UBLFIMUA.js";
|
|
42
|
+
import "./chunk-VVQOFG76.js";
|
|
41
43
|
import {
|
|
42
44
|
teamSchema
|
|
43
|
-
} from "./chunk-
|
|
44
|
-
import "./chunk-
|
|
45
|
+
} from "./chunk-FJCOYEKT.js";
|
|
46
|
+
import "./chunk-VRZSDUZK.js";
|
|
45
47
|
import {
|
|
46
48
|
requireInteractive
|
|
47
49
|
} from "./chunk-EGOXR5FB.js";
|
|
48
|
-
import {
|
|
49
|
-
RegistryAsset
|
|
50
|
-
} from "./chunk-GLWTVLKM.js";
|
|
51
50
|
import {
|
|
52
51
|
isUrl
|
|
53
52
|
} from "./chunk-4ORL4MST.js";
|
|
54
|
-
import
|
|
53
|
+
import {
|
|
54
|
+
RegistryAsset
|
|
55
|
+
} from "./chunk-VUNOOPEG.js";
|
|
55
56
|
import {
|
|
56
57
|
output
|
|
57
58
|
} from "./chunk-T5HJUAWB.js";
|
|
58
|
-
import "./chunk-
|
|
59
|
+
import "./chunk-U764PQUA.js";
|
|
60
|
+
import "./chunk-Q26DFKTY.js";
|
|
59
61
|
import {
|
|
60
62
|
docVersionSchema,
|
|
61
63
|
external_exports,
|
|
62
64
|
namespaceSchema,
|
|
63
65
|
slugSchema,
|
|
64
66
|
toAsciiSlug
|
|
65
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-I57ID5K7.js";
|
|
66
68
|
import "./chunk-3MZYUBJ6.js";
|
|
67
69
|
|
|
68
70
|
// src/domains/registry/publish/action.ts
|
|
@@ -74,7 +76,7 @@ import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
|
|
|
74
76
|
async function publishAction(file, args) {
|
|
75
77
|
const { error, data } = external_exports.object({
|
|
76
78
|
slug: slugSchema.optional(),
|
|
77
|
-
file: external_exports.string().min(1, "
|
|
79
|
+
file: external_exports.string().min(1, "Provide a valid file path or URL for your document.").optional(),
|
|
78
80
|
namespace: namespaceSchema.optional(),
|
|
79
81
|
version: docVersionSchema.optional(),
|
|
80
82
|
private: external_exports.coerce.boolean(),
|
|
@@ -110,11 +112,11 @@ async function publishAction(file, args) {
|
|
|
110
112
|
schema: teamSchema
|
|
111
113
|
});
|
|
112
114
|
if (team.error)
|
|
113
|
-
return output.error().title("
|
|
115
|
+
return output.error().title("Could not load the current team").message(team.message).exit("error");
|
|
114
116
|
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
115
117
|
if (!namespace) {
|
|
116
118
|
return output.error().title("Missing namespace").message(
|
|
117
|
-
"
|
|
119
|
+
"No team namespace is selected. Pass --namespace <namespace> or run `scalar team get` to see available namespaces."
|
|
118
120
|
).exit("error");
|
|
119
121
|
}
|
|
120
122
|
const client = await apiService();
|
|
@@ -122,13 +124,13 @@ async function publishAction(file, args) {
|
|
|
122
124
|
if (namespaceApisRes.error)
|
|
123
125
|
return output.error().title(namespaceApisRes.message).exit("error");
|
|
124
126
|
if (!data.file) {
|
|
125
|
-
requireInteractive("
|
|
127
|
+
requireInteractive("Provide a file path or URL.");
|
|
126
128
|
}
|
|
127
129
|
const apiFile = data.file || (await text({
|
|
128
|
-
message: "
|
|
130
|
+
message: "Enter a file path or URL for your document",
|
|
129
131
|
placeholder: "./api.yaml",
|
|
130
132
|
validate(value) {
|
|
131
|
-
if (value.length === 0) return "
|
|
133
|
+
if (value.length === 0) return "A file path or URL is required.";
|
|
132
134
|
}
|
|
133
135
|
})).toString();
|
|
134
136
|
const content = await getFileOrUrl(apiFile);
|
|
@@ -159,18 +161,18 @@ async function publishAction(file, args) {
|
|
|
159
161
|
);
|
|
160
162
|
if (!parsedVersion.data) {
|
|
161
163
|
requireInteractive(
|
|
162
|
-
"
|
|
164
|
+
"Provide --version or a document with a valid info.version."
|
|
163
165
|
);
|
|
164
166
|
}
|
|
165
167
|
const version = parsedVersion.data || (await text({
|
|
166
|
-
message: "
|
|
168
|
+
message: "Enter the version (for example, 0.1.0)",
|
|
167
169
|
validate(value) {
|
|
168
170
|
if (value.length === 0) return "Version is required.";
|
|
169
171
|
if (docVersionSchema.safeParse(value)?.error)
|
|
170
172
|
return "Version must be a non-empty string";
|
|
171
173
|
}
|
|
172
174
|
})).toString();
|
|
173
|
-
const logger = output.info().line().loader(`Publishing ${apiSlug} to Scalar
|
|
175
|
+
const logger = output.info().line().loader(`Publishing ${apiSlug} to the Scalar Registry\u2026`);
|
|
174
176
|
const matchingApi = namespaceApisRes.data.find((api2) => api2.slug === apiSlug);
|
|
175
177
|
const document = JSON.stringify(bundledDocument);
|
|
176
178
|
const publishRes = matchingApi ? await client.managedDocs.addVersion(namespace, apiSlug, {
|
|
@@ -189,14 +191,14 @@ async function publishAction(file, args) {
|
|
|
189
191
|
if (publishRes.error)
|
|
190
192
|
return output.error().title(publishRes.message).exit("error");
|
|
191
193
|
logger.update("loader", 0, {
|
|
192
|
-
content: `
|
|
194
|
+
content: `Published ${apiSlug} version ${version}.`
|
|
193
195
|
}).line().print();
|
|
194
196
|
const api = registry(namespace).apis(apiSlug);
|
|
195
197
|
const apiUrl = dashboardUrl(
|
|
196
198
|
RegistryAsset.Apis,
|
|
197
199
|
matchingApi?.uid ?? publishRes.data.uid
|
|
198
200
|
);
|
|
199
|
-
output.info().line(`${as.green("\u279C")} ${as.white.bold("
|
|
201
|
+
output.info().line(`${as.green("\u279C")} ${as.white.bold("Scalar Dashboard:")}`).line(as.cyan(apiUrl)).line().line(`${as.green("\u279C")} ${as.white.bold("Scalar Registry preview:")}`).line(as.cyan(registryUrl(api.url({ version })))).line().line(`${as.green("\u279C")} ${as.white.bold("Scalar Registry YAML:")}`).line(as.cyan(registryUrl(api.url({ version, format: "yaml" })))).line().line(`${as.green("\u279C")} ${as.white.bold("Scalar Registry JSON:")}`).line(as.cyan(registryUrl(api.url({ version, format: "json" })))).print();
|
|
200
202
|
}
|
|
201
203
|
export {
|
|
202
204
|
publishAction
|