@scalar/cli 2.10.0 → 2.11.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 +82 -1290
- package/chunks/{action-YSVTZVKV.js → action-25QMCP5G.js} +37 -26
- package/chunks/{action-X7BA7PQQ.js → action-2VF6LODL.js} +20 -18
- package/chunks/{action-5N3P43MD.js → action-5I4XDPPG.js} +16 -15
- package/chunks/action-6M5PTDF6.js +100 -0
- package/chunks/{action-PAM2EZ22.js → action-73ELLN3T.js} +8 -7
- package/chunks/{action-XOADBXSX.js → action-7H3AWCHX.js} +17 -16
- package/chunks/{action-KDUFU7TZ.js → action-BRSLSOE5.js} +19 -16
- package/chunks/{action-7XOHYWYM.js → action-CQQCKSNS.js} +13 -15
- package/chunks/action-D5QWDNQ2.js +65 -0
- package/chunks/{action-5RL4NWUZ.js → action-DQDHBOLJ.js} +33 -30
- package/chunks/{action-DKDRAIKV.js → action-EYPYQQVM.js} +13 -15
- package/chunks/{action-ZFI77WA5.js → action-FMA5ECUA.js} +10 -10
- package/chunks/{action-DTEO4YNX.js → action-GXDJLF2G.js} +13 -11
- package/chunks/{action-657A4K2D.js → action-HUICEXJZ.js} +26 -23
- package/chunks/action-IH6G77C5.js +38 -0
- package/chunks/{action-H3RTILLM.js → action-IIQMZVRJ.js} +1 -1
- package/chunks/action-IQM54ITT.js +164 -0
- package/chunks/{action-EAUTQ77U.js → action-J5TO3UJW.js} +26 -24
- package/chunks/{action-UUL6SWV4.js → action-KC3ZCNDR.js} +12 -14
- package/chunks/{action-HT42NUUX.js → action-L7TMS3Q3.js} +40 -38
- package/chunks/{action-GWYYTUTM.js → action-LAAHRDSR.js} +5 -5
- package/chunks/{action-5LF4XYHX.js → action-LR75GHBA.js} +12 -12
- package/chunks/{action-PPTFYZWD.js → action-MJMLQFLT.js} +12 -12
- package/chunks/action-NHU4CUKT.js +130 -0
- package/chunks/{action-4GZI2M5B.js → action-NKTFNFU7.js} +19 -17
- package/chunks/{action-CB55NWAU.js → action-NMW5WPD2.js} +9 -9
- package/chunks/{action-GFLRD7LO.js → action-OTPXODUE.js} +8 -8
- package/chunks/{action-R4PGILN4.js → action-RPCDNGCI.js} +47 -36
- package/chunks/{action-TOBU74JH.js → action-RQCXSJPZ.js} +51 -27
- package/chunks/{action-JEYDBB3P.js → action-SOYSVG67.js} +15 -15
- package/chunks/action-Y7EBKCUU.js +16 -0
- package/chunks/{action-XLE37MZL.js → action-YN4TE7TG.js} +23 -22
- package/chunks/{action-CABLS46Q.js → action-ZGNVWTHZ.js} +11 -11
- package/chunks/{action-4W5GUGEG.js → action-ZKKRPLDK.js} +20 -19
- package/chunks/{action-ZKA3RR3S.js → action-ZUZL7R3H.js} +18 -17
- package/chunks/{actions-3SAMH7A5.js → actions-S6K76HCW.js} +23 -20
- package/chunks/{agent-2ESZI7NO.js → agent-IRNEV4K5.js} +44 -9
- package/chunks/{asyncapi-4HGVM3PR.js → asyncapi-WQPIQMEZ.js} +13 -12
- package/chunks/{build.action-VBGFGACM.js → build.action-CLBVKFWD.js} +28 -26
- package/chunks/chunk-25XERWCE.js +1058 -0
- package/chunks/{chunk-35Z7VTJT.js → chunk-3RIUDHLG.js} +52 -38
- package/chunks/{chunk-ZYBLQ5CT.js → chunk-3TFOA64C.js} +9 -4
- package/chunks/{chunk-CWVYOXXM.js → chunk-4JKXZ5CF.js} +11 -7
- package/chunks/{chunk-XAGJJNQW.js → chunk-5L7V7RCH.js} +10 -10
- package/chunks/{chunk-KZNRQVMY.js → chunk-ALYM4ZB2.js} +1 -1
- package/chunks/chunk-AVZFSWPD.js +37 -0
- package/chunks/{chunk-GYRQPDTK.js → chunk-BQYVSPAI.js} +14 -2
- package/chunks/{chunk-UDBSV3CK.js → chunk-CSSTCHHF.js} +6083 -4167
- package/chunks/{chunk-ZGNDXPLU.js → chunk-DQD2753S.js} +3 -3
- package/chunks/{action-F2ZJNURT.js → chunk-EBNFCIKS.js} +7 -10
- package/chunks/{chunk-ATNTXKMS.js → chunk-F3OPMYME.js} +118 -38
- package/chunks/{chunk-KHF2QXBG.js → chunk-FG5AOTDN.js} +1433 -641
- package/chunks/{chunk-K2HIB5BA.js → chunk-GKCVATQJ.js} +3 -3
- package/chunks/{chunk-BIMLCGKS.js → chunk-GMHIK5K2.js} +1 -1
- package/chunks/{chunk-5SMP756H.js → chunk-GYR5E6RB.js} +2 -2
- package/chunks/{chunk-MC4EMNOR.js → chunk-HZN6IIPZ.js} +7 -6
- package/chunks/{chunk-VVRUSQCY.js → chunk-I57ID5K7.js} +13 -0
- package/chunks/{chunk-VYFGRLVQ.js → chunk-KOD2HX5I.js} +1 -1
- package/chunks/{chunk-ZKJPLWRJ.js → chunk-LOLVJNI5.js} +4 -4
- package/chunks/{chunk-GLWTVLKM.js → chunk-MN2AFJXM.js} +9 -2
- package/chunks/{chunk-WB6PWTMU.js → chunk-N5CJ5MTY.js} +1 -1
- package/chunks/{chunk-JXGF5EHC.js → chunk-NWJ37GI2.js} +23 -13
- package/chunks/{chunk-3ZJYGGAA.js → chunk-ORCUZITN.js} +1 -1
- package/chunks/{chunk-H467HDVV.js → chunk-QMLRYD76.js} +1 -1
- package/chunks/{chunk-43WALAW3.js → chunk-SEURG74P.js} +64 -115
- package/chunks/{chunk-G4HRW2FZ.js → chunk-SOV4POMS.js} +366 -253
- package/chunks/chunk-T34TL6KL.js +222 -0
- package/chunks/{chunk-WDIWLXLV.js → chunk-U6VE6JOS.js} +3 -3
- package/chunks/{chunk-MMWSCTDB.js → chunk-UFSFY7Z4.js} +19 -19
- package/chunks/{chunk-WIEXQUTD.js → chunk-ULRJZXMS.js} +1 -1
- package/chunks/{chunk-DHZW7Q7U.js → chunk-US54KYOJ.js} +2 -4
- package/chunks/{chunk-36LXIJIZ.js → chunk-V6LUKXBV.js} +1 -16
- package/chunks/{chunk-6M7TL2G2.js → chunk-VRZSDUZK.js} +45 -5
- package/chunks/chunk-VUXPDHTQ.js +22 -0
- package/chunks/chunk-XP5UM7SF.js +21 -0
- package/chunks/{chunk-IPZP3VRA.js → chunk-Y6XGC4K5.js} +5 -21
- package/chunks/{create.action-DBNIS665.js → create.action-ITEOQ644.js} +34 -32
- package/chunks/{delete.action-K7BLK7DK.js → delete.action-77MFPLUN.js} +29 -27
- package/chunks/{delete.action-GBOZC45K.js → delete.action-C6VX4S5Q.js} +30 -28
- package/chunks/{get.action-N3JOY3OU.js → get.action-3BP4FHZC.js} +16 -15
- package/chunks/{get.action-QHKMYZBK.js → get.action-LNBOWUVE.js} +24 -20
- package/chunks/{list.action-6SSO3JVN.js → list.action-6CRFQPJT.js} +39 -29
- package/chunks/{list.action-TJCS6UEY.js → list.action-KR5YIDR4.js} +37 -26
- package/chunks/{publish.action-T24VHRMR.js → publish.action-YBORRPBM.js} +45 -43
- package/chunks/{scripts-VIBLGKYG.js → scripts-6CI6U32J.js} +1 -1
- package/chunks/{update.action-VOE6PH5F.js → update.action-O7TSXDGV.js} +29 -27
- package/chunks/{update.action-OGYNBXRU.js → update.action-QZI7M2MV.js} +30 -28
- package/index.js +283 -278
- package/package.json +2 -2
- package/skills/scalar-cli/SKILL.md +49 -49
- package/template.md +66 -253
- 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
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
createError,
|
|
4
|
+
displayError
|
|
5
|
+
} from "./chunk-ORCUZITN.js";
|
|
6
|
+
import {
|
|
7
|
+
readAndParseConfig,
|
|
8
|
+
renderConfigError
|
|
9
|
+
} from "./chunk-5L7V7RCH.js";
|
|
10
|
+
import {
|
|
11
|
+
CONFIG_FILE_DEFAULT,
|
|
12
|
+
expandFolderGuides,
|
|
13
|
+
findConfig,
|
|
14
|
+
legacyTo2_0_0
|
|
15
|
+
} from "./chunk-CSSTCHHF.js";
|
|
16
|
+
import "./chunk-5ENKYZA4.js";
|
|
17
|
+
import {
|
|
18
|
+
ConfigVersion
|
|
19
|
+
} from "./chunk-VRZSDUZK.js";
|
|
20
|
+
import {
|
|
21
|
+
output
|
|
22
|
+
} from "./chunk-T5HJUAWB.js";
|
|
23
|
+
import "./chunk-I57ID5K7.js";
|
|
24
|
+
import "./chunk-3MZYUBJ6.js";
|
|
25
|
+
|
|
26
|
+
// src/domains/project/upgrade/action.ts
|
|
27
|
+
import { spawnSync } from "node:child_process";
|
|
28
|
+
import { existsSync } from "node:fs";
|
|
29
|
+
import fs from "node:fs/promises";
|
|
30
|
+
import path from "node:path";
|
|
31
|
+
import { text } from "@clack/prompts";
|
|
32
|
+
import as from "ansis";
|
|
33
|
+
import { n } from "neverpanic";
|
|
34
|
+
async function upgradeAction(__configPath) {
|
|
35
|
+
const configPath = __configPath || findConfig() || await text({
|
|
36
|
+
message: "Where is your configuration file located?",
|
|
37
|
+
defaultValue: CONFIG_FILE_DEFAULT,
|
|
38
|
+
placeholder: CONFIG_FILE_DEFAULT
|
|
39
|
+
});
|
|
40
|
+
const parseConfigResult = readAndParseConfig(configPath);
|
|
41
|
+
if (!parseConfigResult.success) {
|
|
42
|
+
renderConfigError(parseConfigResult.error);
|
|
43
|
+
}
|
|
44
|
+
if (parseConfigResult.success) {
|
|
45
|
+
output.info().line(
|
|
46
|
+
`${as.green("[SUCCESS]")} ${as.green("Configuration is valid:")} ${as.green(parseConfigResult.filePath)}`
|
|
47
|
+
).print();
|
|
48
|
+
}
|
|
49
|
+
const { config } = parseConfigResult;
|
|
50
|
+
if (config.version === ConfigVersion.V2) {
|
|
51
|
+
return output.info().title("Your Scalar configuration is already upgraded").message(
|
|
52
|
+
"You are already on the latest Scalar docs version. No further action required."
|
|
53
|
+
).exit("success");
|
|
54
|
+
}
|
|
55
|
+
const projectRootDir = path.resolve(
|
|
56
|
+
path.dirname(parseConfigResult.filePath),
|
|
57
|
+
config.root ?? "./"
|
|
58
|
+
);
|
|
59
|
+
const publishedFiles = listGitFiles(projectRootDir);
|
|
60
|
+
const expandedConfigResult = await n.fromUnsafe(
|
|
61
|
+
() => expandFolderGuides(config, async (folderPath) => {
|
|
62
|
+
const entries = await fs.readdir(
|
|
63
|
+
path.join(projectRootDir, folderPath),
|
|
64
|
+
{
|
|
65
|
+
withFileTypes: true
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
return entries.filter((entry) => entry.isFile() || entry.isDirectory()).map((entry) => ({
|
|
69
|
+
name: entry.name,
|
|
70
|
+
type: entry.isFile() ? "file" : "dir",
|
|
71
|
+
path: path.posix.join(folderPath, entry.name)
|
|
72
|
+
})).filter(
|
|
73
|
+
(entry) => entry.type === "dir" || !publishedFiles || entry.path.startsWith("..") || publishedFiles.has(entry.path)
|
|
74
|
+
);
|
|
75
|
+
}),
|
|
76
|
+
(originalError) => createError("FAILED_TO_EXPAND_FOLDER_GUIDES", originalError)
|
|
77
|
+
);
|
|
78
|
+
if (!expandedConfigResult.success) {
|
|
79
|
+
return output.error().title("Could not read the folders of your folder-based guides.").message(expandedConfigResult.error.code).message(displayError(expandedConfigResult.error.detail)).exit("error");
|
|
80
|
+
}
|
|
81
|
+
const upgradedConfigResult = n.fromUnsafe(
|
|
82
|
+
() => legacyTo2_0_0(expandedConfigResult.data, {
|
|
83
|
+
isPathTaken: (filePath) => existsSync(path.join(projectRootDir, filePath))
|
|
84
|
+
}),
|
|
85
|
+
(originalError) => createError("FAILED_TO_UPGRADE_CONFIG_V1", originalError)
|
|
86
|
+
);
|
|
87
|
+
if (!upgradedConfigResult.success) {
|
|
88
|
+
return output.error().title("Could not upgrade the configuration").message(upgradedConfigResult.error.code).message(displayError(upgradedConfigResult.error.detail)).exit("error");
|
|
89
|
+
}
|
|
90
|
+
const { upgradedConfig, sideFiles, dropped } = upgradedConfigResult.data;
|
|
91
|
+
for (const sideFile of sideFiles) {
|
|
92
|
+
const writeSideFileResult = await n.fromUnsafe(
|
|
93
|
+
() => fs.writeFile(
|
|
94
|
+
path.join(projectRootDir, sideFile.path),
|
|
95
|
+
sideFile.content,
|
|
96
|
+
{ flag: "wx" }
|
|
97
|
+
),
|
|
98
|
+
(originalError) => createError("FAILED_TO_WRITE_UPGRADED_SIDE_FILE", originalError)
|
|
99
|
+
);
|
|
100
|
+
if (!writeSideFileResult.success) {
|
|
101
|
+
return output.error().title(`Could not save ${sideFile.path}`).message(writeSideFileResult.error.code).message(displayError(writeSideFileResult.error.detail)).exit("error");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (dropped.length) {
|
|
105
|
+
output.warn().title("Some settings have no V2 equivalent and were not carried over:").message(dropped.join(", ")).print();
|
|
106
|
+
}
|
|
107
|
+
const writeUpgradedConfigResult = await n.fromUnsafe(
|
|
108
|
+
() => fs.writeFile(
|
|
109
|
+
parseConfigResult.filePath,
|
|
110
|
+
JSON.stringify(upgradedConfig, null, 2)
|
|
111
|
+
),
|
|
112
|
+
(originalError) => createError("FAILED_TO_WRITE_UPGRADED_CONFIG", originalError)
|
|
113
|
+
);
|
|
114
|
+
if (!writeUpgradedConfigResult.success) {
|
|
115
|
+
return output.error().title("Could not save the upgraded configuration").message(writeUpgradedConfigResult.error.code).message(displayError(writeUpgradedConfigResult.error.detail)).exit("error");
|
|
116
|
+
}
|
|
117
|
+
return output.info().title("Scalar Docs configuration upgraded").message("Run `scalar project preview` to preview your project.").exit("success");
|
|
118
|
+
}
|
|
119
|
+
function listGitFiles(projectRootDir) {
|
|
120
|
+
const result = spawnSync(
|
|
121
|
+
"git",
|
|
122
|
+
["ls-files", "--cached", "--others", "--exclude-standard", "-z"],
|
|
123
|
+
{ cwd: projectRootDir, encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
|
|
124
|
+
);
|
|
125
|
+
if (result.status !== 0) return null;
|
|
126
|
+
return new Set(result.stdout.split("\0").filter(Boolean));
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
upgradeAction
|
|
130
|
+
};
|
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
BaseCollections
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NWJ37GI2.js";
|
|
5
5
|
import {
|
|
6
6
|
getDatabaseClient
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-IPZP3VRA.js";
|
|
7
|
+
} from "./chunk-U6VE6JOS.js";
|
|
8
|
+
import "./chunk-SEURG74P.js";
|
|
9
|
+
import "./chunk-3TFOA64C.js";
|
|
11
10
|
import "./chunk-5ENKYZA4.js";
|
|
12
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-Y6XGC4K5.js";
|
|
12
|
+
import "./chunk-T34TL6KL.js";
|
|
13
|
+
import "./chunk-V6LUKXBV.js";
|
|
14
|
+
import "./chunk-VUXPDHTQ.js";
|
|
13
15
|
import {
|
|
14
16
|
getAuthData
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-3RIUDHLG.js";
|
|
18
|
+
import "./chunk-N5CJ5MTY.js";
|
|
19
|
+
import "./chunk-US54KYOJ.js";
|
|
18
20
|
import {
|
|
19
21
|
teamSchema
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-GLWTVLKM.js";
|
|
22
|
+
} from "./chunk-BQYVSPAI.js";
|
|
23
|
+
import "./chunk-VRZSDUZK.js";
|
|
23
24
|
import "./chunk-4ORL4MST.js";
|
|
24
|
-
import "./chunk-
|
|
25
|
+
import "./chunk-MN2AFJXM.js";
|
|
25
26
|
import {
|
|
26
27
|
output
|
|
27
28
|
} from "./chunk-T5HJUAWB.js";
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-25XERWCE.js";
|
|
30
|
+
import "./chunk-AVZFSWPD.js";
|
|
31
|
+
import "./chunk-I57ID5K7.js";
|
|
30
32
|
import "./chunk-3MZYUBJ6.js";
|
|
31
33
|
|
|
32
34
|
// src/domains/team/get/action.ts
|
|
@@ -40,7 +42,7 @@ async function getAction(args = {}) {
|
|
|
40
42
|
schema: teamSchema
|
|
41
43
|
});
|
|
42
44
|
if (team.error) {
|
|
43
|
-
return output.error().title("
|
|
45
|
+
return output.error().title("Could not load the current team").message(team.message).exit("error");
|
|
44
46
|
}
|
|
45
47
|
const details = {
|
|
46
48
|
uid: team.data.uid,
|
|
@@ -53,7 +55,7 @@ async function getAction(args = {}) {
|
|
|
53
55
|
`);
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
|
-
output.info().title(details.name).line(`Team
|
|
58
|
+
output.info().title(details.name).line(`Team ID: ${details.uid}`).line(`Slug: ${details.slug}`).line(
|
|
57
59
|
`Namespaces: ${details.namespaces.length ? details.namespaces.join(", ") : "None"}`
|
|
58
60
|
).print();
|
|
59
61
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getFileOrUrl
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-GLWTVLKM.js";
|
|
4
|
+
} from "./chunk-4JKXZ5CF.js";
|
|
5
|
+
import "./chunk-QMLRYD76.js";
|
|
7
6
|
import {
|
|
8
7
|
isYamlFileName
|
|
9
8
|
} from "./chunk-4ORL4MST.js";
|
|
10
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-MN2AFJXM.js";
|
|
11
10
|
import {
|
|
12
11
|
output
|
|
13
12
|
} from "./chunk-T5HJUAWB.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-25XERWCE.js";
|
|
14
|
+
import "./chunk-AVZFSWPD.js";
|
|
15
|
+
import "./chunk-I57ID5K7.js";
|
|
16
16
|
import "./chunk-3MZYUBJ6.js";
|
|
17
17
|
|
|
18
18
|
// src/domains/document/postman/action.ts
|
|
@@ -26,7 +26,7 @@ async function convertAction(inputArgument, {
|
|
|
26
26
|
}) {
|
|
27
27
|
const startTime = performance.now();
|
|
28
28
|
if (!inputArgument) {
|
|
29
|
-
return output.error().title("Invalid argument").message("
|
|
29
|
+
return output.error().title("Invalid argument").message("Provide a Postman collection file path or URL.").exit("error");
|
|
30
30
|
}
|
|
31
31
|
const collection = await getFileOrUrl(inputArgument);
|
|
32
32
|
let specification;
|
|
@@ -42,8 +42,8 @@ async function convertAction(inputArgument, {
|
|
|
42
42
|
fs.writeFileSync(outputPath, openApiDocument, "utf8");
|
|
43
43
|
const endTime = performance.now();
|
|
44
44
|
output.info().line(
|
|
45
|
-
`${as.green("OpenAPI
|
|
46
|
-
`
|
|
45
|
+
`${as.green("OpenAPI description generated")} ${as.grey(
|
|
46
|
+
`(${as.white(`${as.bold(`${Math.round(endTime - startTime)}`)} ms`)})`
|
|
47
47
|
)}`
|
|
48
48
|
).line(`Written to ${as.cyan(outputPath)}`).print();
|
|
49
49
|
return;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getFileOrUrl
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-GLWTVLKM.js";
|
|
4
|
+
} from "./chunk-4JKXZ5CF.js";
|
|
5
|
+
import "./chunk-QMLRYD76.js";
|
|
7
6
|
import "./chunk-4ORL4MST.js";
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-MN2AFJXM.js";
|
|
9
8
|
import {
|
|
10
9
|
output
|
|
11
10
|
} from "./chunk-T5HJUAWB.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-25XERWCE.js";
|
|
12
|
+
import "./chunk-AVZFSWPD.js";
|
|
13
|
+
import "./chunk-I57ID5K7.js";
|
|
14
14
|
import "./chunk-3MZYUBJ6.js";
|
|
15
15
|
|
|
16
16
|
// src/domains/document/markdown/action.ts
|
|
@@ -20,7 +20,7 @@ import { createMarkdownFromOpenApi } from "@scalar/openapi-to-markdown";
|
|
|
20
20
|
async function markdownAction(inputArgument, { output: outputPath }) {
|
|
21
21
|
const startTime = performance.now();
|
|
22
22
|
if (!inputArgument) {
|
|
23
|
-
return output.error().title("Invalid argument").message("
|
|
23
|
+
return output.error().title("Invalid argument").message("Provide a file path or URL.").exit("error");
|
|
24
24
|
}
|
|
25
25
|
const specification = await getFileOrUrl(inputArgument);
|
|
26
26
|
const markdown = await createMarkdownFromOpenApi(specification);
|
|
@@ -29,7 +29,7 @@ async function markdownAction(inputArgument, { output: outputPath }) {
|
|
|
29
29
|
const endTime = performance.now();
|
|
30
30
|
output.info().line(
|
|
31
31
|
`${as.green("Markdown generated")} ${as.grey(
|
|
32
|
-
`
|
|
32
|
+
`(${as.white(`${as.bold(`${Math.round(endTime - startTime)}`)} ms`)})`
|
|
33
33
|
)}`
|
|
34
34
|
).line(`Written to ${as.cyan(outputPath)}`).print();
|
|
35
35
|
return;
|
|
@@ -1,53 +1,55 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
getPublishDeploymentUrl
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ALYM4ZB2.js";
|
|
5
5
|
import {
|
|
6
6
|
readAndParseConfig,
|
|
7
7
|
renderConfigError
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5L7V7RCH.js";
|
|
9
9
|
import {
|
|
10
10
|
resolveProject
|
|
11
11
|
} from "./chunk-TSURUX4A.js";
|
|
12
12
|
import {
|
|
13
13
|
DEFAULT_ASSETS_DIR
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-CSSTCHHF.js";
|
|
15
|
+
import "./chunk-UFSFY7Z4.js";
|
|
16
16
|
import {
|
|
17
17
|
getDatabaseClient
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-U6VE6JOS.js";
|
|
19
19
|
import {
|
|
20
20
|
apiService
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-IPZP3VRA.js";
|
|
21
|
+
} from "./chunk-F3OPMYME.js";
|
|
22
|
+
import "./chunk-FG5AOTDN.js";
|
|
23
|
+
import "./chunk-SEURG74P.js";
|
|
24
|
+
import "./chunk-3TFOA64C.js";
|
|
26
25
|
import "./chunk-5ENKYZA4.js";
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-Y6XGC4K5.js";
|
|
27
|
+
import "./chunk-SOV4POMS.js";
|
|
28
|
+
import "./chunk-T34TL6KL.js";
|
|
29
|
+
import "./chunk-V6LUKXBV.js";
|
|
30
|
+
import "./chunk-VUXPDHTQ.js";
|
|
29
31
|
import {
|
|
30
32
|
getAuthData
|
|
31
|
-
} from "./chunk-
|
|
32
|
-
import "./chunk-
|
|
33
|
-
import "./chunk-
|
|
34
|
-
import "./chunk-
|
|
33
|
+
} from "./chunk-3RIUDHLG.js";
|
|
34
|
+
import "./chunk-N5CJ5MTY.js";
|
|
35
|
+
import "./chunk-US54KYOJ.js";
|
|
36
|
+
import "./chunk-BQYVSPAI.js";
|
|
35
37
|
import {
|
|
36
38
|
ConfigVersion,
|
|
37
39
|
isGithubBackedDocsProject,
|
|
38
40
|
publishRecordSchema
|
|
39
|
-
} from "./chunk-
|
|
40
|
-
import "./chunk-GLWTVLKM.js";
|
|
41
|
+
} from "./chunk-VRZSDUZK.js";
|
|
41
42
|
import "./chunk-4ORL4MST.js";
|
|
42
|
-
import "./chunk-
|
|
43
|
+
import "./chunk-MN2AFJXM.js";
|
|
43
44
|
import {
|
|
44
45
|
output
|
|
45
46
|
} from "./chunk-T5HJUAWB.js";
|
|
46
|
-
import "./chunk-
|
|
47
|
+
import "./chunk-25XERWCE.js";
|
|
48
|
+
import "./chunk-AVZFSWPD.js";
|
|
47
49
|
import {
|
|
48
50
|
slugSchema,
|
|
49
51
|
zod_default
|
|
50
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-I57ID5K7.js";
|
|
51
53
|
import "./chunk-3MZYUBJ6.js";
|
|
52
54
|
|
|
53
55
|
// src/domains/project/publish/action.ts
|
|
@@ -397,7 +399,7 @@ async function publishAction(args) {
|
|
|
397
399
|
github: zod_default.coerce.boolean().default(false)
|
|
398
400
|
}).safeParse(args);
|
|
399
401
|
if (argsParseResult.error)
|
|
400
|
-
return output.error().title("Invalid
|
|
402
|
+
return output.error().title("Invalid arguments").message(argsParseResult.error.issues[0].message).exit("error");
|
|
401
403
|
const {
|
|
402
404
|
config: configPathOption,
|
|
403
405
|
slug,
|
|
@@ -420,17 +422,17 @@ async function publishAction(args) {
|
|
|
420
422
|
if (resolved.kind === "github") {
|
|
421
423
|
if (!resolved.project.repository) {
|
|
422
424
|
return output.error().title("Your project is not linked to a GitHub repository").message(
|
|
423
|
-
"
|
|
425
|
+
"Connect the project to a GitHub repository in the Scalar Dashboard to publish from GitHub."
|
|
424
426
|
).exit("error");
|
|
425
427
|
}
|
|
426
428
|
if (resolved.project.repository.expired) {
|
|
427
|
-
return output.error().title("
|
|
428
|
-
"
|
|
429
|
+
return output.error().title("GitHub repository access has expired").message(
|
|
430
|
+
"Reconnect the GitHub repository in the Scalar Dashboard to publish from GitHub."
|
|
429
431
|
).exit("error");
|
|
430
432
|
}
|
|
431
433
|
const publishResult3 = await publishGithub({ apiClient, slug, preview });
|
|
432
434
|
if (!publishResult3.success) {
|
|
433
|
-
return output.error().title("Could not publish
|
|
435
|
+
return output.error().title("Could not publish from GitHub").message(publishResult3.error).exit("error");
|
|
434
436
|
}
|
|
435
437
|
return await waitForPublish({
|
|
436
438
|
teamUid: auth.teamUid,
|
|
@@ -439,12 +441,12 @@ async function publishAction(args) {
|
|
|
439
441
|
}
|
|
440
442
|
if (!isGithubBackedDocsProject(resolved.project)) {
|
|
441
443
|
return output.error().title("Your project is not linked to a GitHub repository").message(
|
|
442
|
-
"
|
|
444
|
+
"Connect the project to a GitHub repository in the Scalar Dashboard to publish from GitHub."
|
|
443
445
|
).exit("error");
|
|
444
446
|
}
|
|
445
447
|
if (resolved.project.repository.expired) {
|
|
446
|
-
return output.error().title("
|
|
447
|
-
"
|
|
448
|
+
return output.error().title("GitHub repository access has expired").message(
|
|
449
|
+
"Reconnect the GitHub repository in the Scalar Dashboard to publish from GitHub."
|
|
448
450
|
).exit("error");
|
|
449
451
|
}
|
|
450
452
|
const publishResult2 = await publishUnifiedDocsProjectFromGithub({
|
|
@@ -453,7 +455,7 @@ async function publishAction(args) {
|
|
|
453
455
|
preview
|
|
454
456
|
});
|
|
455
457
|
if (!publishResult2.success) {
|
|
456
|
-
return output.error().title("Could not publish
|
|
458
|
+
return output.error().title("Could not publish from GitHub").message(publishResult2.error).exit("error");
|
|
457
459
|
}
|
|
458
460
|
return await waitForPublish({
|
|
459
461
|
teamUid: auth.teamUid,
|
|
@@ -465,6 +467,7 @@ async function publishAction(args) {
|
|
|
465
467
|
renderConfigError(configResult.error);
|
|
466
468
|
}
|
|
467
469
|
const { config, filePath: configPath } = configResult;
|
|
470
|
+
warnIfLegacyConfig(config);
|
|
468
471
|
const publishResult = await publishProject({
|
|
469
472
|
config,
|
|
470
473
|
slug,
|
|
@@ -473,7 +476,7 @@ async function publishAction(args) {
|
|
|
473
476
|
...preview && { mode: "preview" }
|
|
474
477
|
});
|
|
475
478
|
if (!publishResult.success) {
|
|
476
|
-
return output.error().title("
|
|
479
|
+
return output.error().title("Could not deploy the project").message(
|
|
477
480
|
publishResult.error instanceof Error ? publishResult.error.message : publishResult.error
|
|
478
481
|
).exit("error");
|
|
479
482
|
}
|
|
@@ -482,12 +485,18 @@ async function publishAction(args) {
|
|
|
482
485
|
publishUid: publishResult.publishUid
|
|
483
486
|
});
|
|
484
487
|
}
|
|
488
|
+
function warnIfLegacyConfig(config) {
|
|
489
|
+
if (config.version !== ConfigVersion.V1) return;
|
|
490
|
+
output.warn().title("This project uses a v1 Scalar config").line(
|
|
491
|
+
"It will be upgraded to v2 for this build only. Run `scalar project upgrade` to upgrade the config file."
|
|
492
|
+
).print();
|
|
493
|
+
}
|
|
485
494
|
async function waitForPublish({
|
|
486
495
|
teamUid,
|
|
487
496
|
publishUid
|
|
488
497
|
}) {
|
|
489
498
|
const dbClient = await getDatabaseClient();
|
|
490
|
-
const logger = output.info({ animate: true }).loader("
|
|
499
|
+
const logger = output.info({ animate: true }).loader("Deploying project\u2026");
|
|
491
500
|
while (true) {
|
|
492
501
|
const deployStatus = await getDeployStatus({
|
|
493
502
|
client: dbClient,
|
|
@@ -495,9 +504,7 @@ async function waitForPublish({
|
|
|
495
504
|
teamUid
|
|
496
505
|
});
|
|
497
506
|
if (deployStatus.error === true) {
|
|
498
|
-
return output.error().title(
|
|
499
|
-
"Something went wrong while getting information about the deployment"
|
|
500
|
-
).exit("error");
|
|
507
|
+
return output.error().title("Could not load deployment status").exit("error");
|
|
501
508
|
}
|
|
502
509
|
logger.update("loader", 0, { content: deployStatus.data.message });
|
|
503
510
|
if (deployStatus.data.status === "deployed") {
|
|
@@ -507,6 +514,9 @@ async function waitForPublish({
|
|
|
507
514
|
`${deployStatus.data.preview ? "Preview URL" : "Deployment URL"}: ${deploymentUrl}`
|
|
508
515
|
).print();
|
|
509
516
|
}
|
|
517
|
+
if (deployStatus.data.hasWarnings) {
|
|
518
|
+
output.warn().title("The build finished with warnings").line("Check the build log in the Scalar Dashboard for details.").print();
|
|
519
|
+
}
|
|
510
520
|
logger.exit("success");
|
|
511
521
|
return;
|
|
512
522
|
}
|
|
@@ -529,5 +539,6 @@ async function getDeployStatus({
|
|
|
529
539
|
}
|
|
530
540
|
export {
|
|
531
541
|
publishAction,
|
|
532
|
-
waitForPublish
|
|
542
|
+
waitForPublish,
|
|
543
|
+
warnIfLegacyConfig
|
|
533
544
|
};
|
|
@@ -1,44 +1,50 @@
|
|
|
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-DQD2753S.js";
|
|
5
5
|
import {
|
|
6
6
|
resolveProject
|
|
7
7
|
} from "./chunk-TSURUX4A.js";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import
|
|
9
|
+
formatListTime
|
|
10
|
+
} from "./chunk-XP5UM7SF.js";
|
|
11
|
+
import "./chunk-AEFPCC4U.js";
|
|
12
|
+
import {
|
|
13
|
+
getPublishPreviewUrl
|
|
14
|
+
} from "./chunk-UFSFY7Z4.js";
|
|
15
|
+
import "./chunk-NWJ37GI2.js";
|
|
16
|
+
import "./chunk-U6VE6JOS.js";
|
|
13
17
|
import {
|
|
14
18
|
apiService
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-IPZP3VRA.js";
|
|
19
|
+
} from "./chunk-F3OPMYME.js";
|
|
20
|
+
import "./chunk-FG5AOTDN.js";
|
|
21
|
+
import "./chunk-SEURG74P.js";
|
|
22
|
+
import "./chunk-3TFOA64C.js";
|
|
20
23
|
import "./chunk-5ENKYZA4.js";
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-Y6XGC4K5.js";
|
|
25
|
+
import "./chunk-SOV4POMS.js";
|
|
26
|
+
import "./chunk-T34TL6KL.js";
|
|
27
|
+
import "./chunk-V6LUKXBV.js";
|
|
28
|
+
import "./chunk-VUXPDHTQ.js";
|
|
23
29
|
import {
|
|
24
30
|
getAuthData
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-GLWTVLKM.js";
|
|
31
|
+
} from "./chunk-3RIUDHLG.js";
|
|
32
|
+
import "./chunk-N5CJ5MTY.js";
|
|
33
|
+
import "./chunk-US54KYOJ.js";
|
|
34
|
+
import "./chunk-BQYVSPAI.js";
|
|
35
|
+
import "./chunk-VRZSDUZK.js";
|
|
31
36
|
import "./chunk-4ORL4MST.js";
|
|
32
|
-
import "./chunk-
|
|
37
|
+
import "./chunk-MN2AFJXM.js";
|
|
33
38
|
import {
|
|
34
39
|
output,
|
|
35
40
|
printTable
|
|
36
41
|
} from "./chunk-T5HJUAWB.js";
|
|
37
|
-
import "./chunk-
|
|
42
|
+
import "./chunk-25XERWCE.js";
|
|
43
|
+
import "./chunk-AVZFSWPD.js";
|
|
38
44
|
import {
|
|
39
45
|
external_exports,
|
|
40
46
|
slugSchema
|
|
41
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-I57ID5K7.js";
|
|
42
48
|
import "./chunk-3MZYUBJ6.js";
|
|
43
49
|
|
|
44
50
|
// src/domains/project/deployments/list/action.ts
|
|
@@ -60,7 +66,7 @@ function colorStatus(status) {
|
|
|
60
66
|
async function listAction(args) {
|
|
61
67
|
const argsParseResult = external_exports.object({ slug: slugSchema.optional() }).safeParse(args);
|
|
62
68
|
if (argsParseResult.error) {
|
|
63
|
-
return output.error().title("Invalid
|
|
69
|
+
return output.error().title("Invalid arguments").message(argsParseResult.error.issues[0].message).exit("error");
|
|
64
70
|
}
|
|
65
71
|
const { slug } = argsParseResult.data;
|
|
66
72
|
if (!slug) {
|
|
@@ -85,26 +91,44 @@ async function listAction(args) {
|
|
|
85
91
|
return output.error().title("Could not load deployment history").message(deploymentsResult.error).exit("error");
|
|
86
92
|
}
|
|
87
93
|
if (deploymentsResult.deployments.length === 0) {
|
|
88
|
-
output.info().
|
|
94
|
+
output.info().message(`No deployments found for project "${slug}".`).print();
|
|
89
95
|
return;
|
|
90
96
|
}
|
|
97
|
+
const domains = await apiClient.publish.getProjectDomains(project.uid);
|
|
98
|
+
if (domains.error) {
|
|
99
|
+
console.error(
|
|
100
|
+
"[WARN] Could not load deployment URLs. Build history is still available."
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const scalarDomain = domains.error ? null : domains.data.scalarDomain;
|
|
104
|
+
const now = Date.now();
|
|
91
105
|
printTable(
|
|
92
106
|
[
|
|
93
|
-
{ name: "current", title: "
|
|
107
|
+
{ name: "current", title: "Live", alignment: "center" },
|
|
94
108
|
{ name: "id", title: "Build ID", alignment: "left" },
|
|
95
109
|
{ name: "status", title: "Status", alignment: "left" },
|
|
96
110
|
{ name: "deployed", title: "Deployed", alignment: "left" },
|
|
97
|
-
{ name: "commit", title: "Commit", alignment: "left" }
|
|
111
|
+
{ name: "commit", title: "Commit", alignment: "left" },
|
|
112
|
+
{ name: "url", title: "URL", alignment: "left" }
|
|
98
113
|
],
|
|
99
114
|
deploymentsResult.deployments.map((record) => {
|
|
100
115
|
const isLive = record.uid === activeUid;
|
|
101
116
|
const deployedAt = record.deployedAt ?? (record.status === "deployed" ? record.createdAt : null);
|
|
117
|
+
const url = (() => {
|
|
118
|
+
if (record.status !== "deployed" || !scalarDomain) return "\u2014";
|
|
119
|
+
try {
|
|
120
|
+
return getPublishPreviewUrl(record.uid, scalarDomain, record.subpath);
|
|
121
|
+
} catch {
|
|
122
|
+
return "\u2014";
|
|
123
|
+
}
|
|
124
|
+
})();
|
|
102
125
|
return {
|
|
103
126
|
current: isLive ? as.green("\u279C") : " ",
|
|
104
127
|
id: isLive ? as.green(record.uid) : record.uid,
|
|
105
128
|
status: colorStatus(record.status),
|
|
106
|
-
deployed: deployedAt ?
|
|
107
|
-
commit: record.commitSha ? record.commitSha.slice(0, 7) : as.dim("\u2014")
|
|
129
|
+
deployed: deployedAt !== null ? formatListTime(deployedAt, now) : as.dim("\u2014"),
|
|
130
|
+
commit: record.commitSha ? record.commitSha.slice(0, 7) : as.dim("\u2014"),
|
|
131
|
+
url
|
|
108
132
|
};
|
|
109
133
|
})
|
|
110
134
|
);
|