@scalar/cli 2.8.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 +84 -1076
- package/chunks/action-25QMCP5G.js +122 -0
- package/chunks/{action-354TUG4H.js → action-2VF6LODL.js} +20 -16
- package/chunks/{action-XIUO64C7.js → action-5I4XDPPG.js} +20 -14
- package/chunks/action-6M5PTDF6.js +100 -0
- package/chunks/{action-NVI5DWFP.js → action-73ELLN3T.js} +8 -11
- package/chunks/{action-Y6NXJQ4H.js → action-7H3AWCHX.js} +21 -16
- package/chunks/{action-LLH4QPXM.js → action-BRSLSOE5.js} +19 -18
- package/chunks/{action-EOAVVL52.js → action-CQQCKSNS.js} +17 -22
- package/chunks/action-D5QWDNQ2.js +65 -0
- package/chunks/{action-Y7OUGD56.js → action-DQDHBOLJ.js} +34 -31
- package/chunks/{action-5SK5NE7E.js → action-EYPYQQVM.js} +18 -23
- package/chunks/{action-YRX6SN5F.js → action-FMA5ECUA.js} +12 -10
- package/chunks/{action-7PEQXDWT.js → action-GXDJLF2G.js} +134 -25
- package/chunks/action-HUICEXJZ.js +75 -0
- 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-UIKH4SZX.js → action-J5TO3UJW.js} +32 -26
- package/chunks/{action-H6OUJWWM.js → action-KC3ZCNDR.js} +17 -22
- package/chunks/{action-6BYGBXRC.js → action-L7TMS3Q3.js} +44 -37
- package/chunks/{action-GWXLHL2Z.js → action-LAAHRDSR.js} +5 -4
- package/chunks/{action-FCAYFPVR.js → action-LR75GHBA.js} +14 -11
- package/chunks/action-MJMLQFLT.js +1552 -0
- package/chunks/action-NHU4CUKT.js +130 -0
- package/chunks/action-NKTFNFU7.js +64 -0
- package/chunks/{action-F7A2K74G.js → action-NMW5WPD2.js} +12 -16
- package/chunks/{action-VOFDW3U2.js → action-OTPXODUE.js} +8 -7
- package/chunks/{action-43YBNBDR.js → action-RPCDNGCI.js} +54 -39
- package/chunks/{action-QQZLPI42.js → action-RQCXSJPZ.js} +55 -27
- package/chunks/action-SOYSVG67.js +147 -0
- package/chunks/action-Y7EBKCUU.js +16 -0
- package/chunks/{action-WFDNRA7D.js → action-YN4TE7TG.js} +24 -23
- package/chunks/{action-AQRPFQKI.js → action-ZGNVWTHZ.js} +14 -12
- package/chunks/action-ZKKRPLDK.js +64 -0
- package/chunks/{action-HT2DJ34Z.js → action-ZUZL7R3H.js} +20 -15
- package/chunks/{actions-OGIVBQC7.js → actions-S6K76HCW.js} +46 -19
- package/chunks/{agent-ASPV3R5U.js → agent-IRNEV4K5.js} +46 -9
- package/chunks/{asyncapi-QNFKXHEI.js → asyncapi-WQPIQMEZ.js} +15 -10
- package/chunks/{build.action-NM6CAE5F.js → build.action-CLBVKFWD.js} +28 -24
- package/chunks/chunk-25XERWCE.js +1058 -0
- package/chunks/chunk-3RIUDHLG.js +467 -0
- package/chunks/{chunk-MLSZVVTT.js → chunk-3TFOA64C.js} +19 -8
- package/chunks/{chunk-HGOD6THU.js → chunk-4JKXZ5CF.js} +12 -25
- package/chunks/{chunk-C2KAWRIX.js → chunk-5ENKYZA4.js} +1 -1
- package/chunks/{chunk-W24BETFG.js → chunk-5L7V7RCH.js} +10 -10
- package/chunks/chunk-6PSYZO3U.js +24 -0
- package/chunks/{chunk-IMG35UXX.js → chunk-ALYM4ZB2.js} +1 -1
- package/chunks/chunk-AVZFSWPD.js +37 -0
- package/chunks/{chunk-5UHLAJQD.js → chunk-BQYVSPAI.js} +36 -10
- package/chunks/{chunk-XXSQUBXS.js → chunk-CSSTCHHF.js} +6212 -4642
- package/chunks/chunk-DFOZG7ZV.js +15 -0
- package/chunks/{chunk-22HYZ7LE.js → chunk-DQD2753S.js} +3 -3
- package/chunks/{action-F2ZJNURT.js → chunk-EBNFCIKS.js} +7 -10
- package/chunks/{chunk-EXY3ZTV4.js → chunk-F3OPMYME.js} +143 -301
- package/chunks/{chunk-FDC2IESH.js → chunk-FG5AOTDN.js} +8519 -14702
- package/chunks/chunk-GKCVATQJ.js +92 -0
- package/chunks/{chunk-PH3WFNXJ.js → chunk-GMHIK5K2.js} +1 -1
- package/chunks/{chunk-GTV2BVXV.js → chunk-GYR5E6RB.js} +2 -2
- package/chunks/{chunk-OJ2EWIJH.js → chunk-HZN6IIPZ.js} +11 -6
- package/chunks/{chunk-IKT5F47M.js → chunk-I57ID5K7.js} +24 -11
- package/chunks/{chunk-BPGFSSUH.js → chunk-KOD2HX5I.js} +1 -1
- package/chunks/{chunk-L3UXDCBI.js → chunk-LOLVJNI5.js} +4 -4
- package/chunks/{chunk-KCCFN4F7.js → chunk-MN2AFJXM.js} +36 -29
- package/chunks/{chunk-UXJ753NV.js → chunk-N5CJ5MTY.js} +5 -13
- package/chunks/chunk-NAC63XJF.js +10 -0
- package/chunks/{chunk-2OCWX42S.js → chunk-NWJ37GI2.js} +166 -22
- package/chunks/{chunk-3ZJYGGAA.js → chunk-ORCUZITN.js} +1 -1
- package/chunks/chunk-QMLRYD76.js +24 -0
- package/chunks/{chunk-KKRGBXCE.js → chunk-SEURG74P.js} +303 -209
- package/chunks/{chunk-R5LK6VPY.js → chunk-SOV4POMS.js} +370 -264
- package/chunks/chunk-T34TL6KL.js +222 -0
- package/chunks/{chunk-5DEU2DVL.js → chunk-U6VE6JOS.js} +3 -15
- package/chunks/{chunk-YILQODZF.js → chunk-UFSFY7Z4.js} +23 -20
- package/chunks/{chunk-6YPQGVF4.js → chunk-ULRJZXMS.js} +1 -1
- package/chunks/chunk-US54KYOJ.js +131 -0
- package/chunks/chunk-V6LUKXBV.js +37 -0
- package/chunks/{chunk-5JLVQVKO.js → chunk-VRZSDUZK.js} +190 -152
- package/chunks/chunk-VUXPDHTQ.js +22 -0
- package/chunks/chunk-XP5UM7SF.js +21 -0
- package/chunks/chunk-Y6XGC4K5.js +311 -0
- package/chunks/{create.action-FUQ2BVJA.js → create.action-ITEOQ644.js} +34 -30
- package/chunks/{delete.action-47E66R3I.js → delete.action-77MFPLUN.js} +30 -26
- package/chunks/{delete.action-BTDFH7WY.js → delete.action-C6VX4S5Q.js} +30 -26
- package/chunks/{get.action-XC7KC2JO.js → get.action-3BP4FHZC.js} +20 -14
- package/chunks/get.action-LNBOWUVE.js +95 -0
- package/chunks/list.action-6CRFQPJT.js +156 -0
- package/chunks/list.action-KR5YIDR4.js +126 -0
- package/chunks/{publish.action-OS27XOX4.js → publish.action-YBORRPBM.js} +49 -42
- package/chunks/query-WKATAJJ6.js +129 -0
- package/chunks/scripts-6CI6U32J.js +102 -0
- package/chunks/{update.action-AEIBLCWD.js → update.action-O7TSXDGV.js} +34 -27
- package/chunks/{update.action-ZMS4CQ3T.js → update.action-QZI7M2MV.js} +34 -27
- package/index.js +579 -382
- package/package.json +15 -14
- package/skills/scalar-cli/SKILL.md +52 -46
- package/template.md +71 -136
- package/chunks/action-CA4QYPI6.js +0 -125
- package/chunks/action-JAHFRYWZ.js +0 -423
- package/chunks/action-KTYOCA2V.js +0 -229
- package/chunks/action-LEUD5P2U.js +0 -92
- package/chunks/action-LXGXKXZZ.js +0 -72
- package/chunks/action-W3C53GPH.js +0 -54
- package/chunks/action-YLF2G4G5.js +0 -37
- package/chunks/chunk-6XWCMJDB.js +0 -404
- package/chunks/chunk-K74E42RV.js +0 -7311
- package/chunks/chunk-QVQ4PNVL.js +0 -610
- package/chunks/chunk-XEDGMZJD.js +0 -366
- package/chunks/list.action-LXKEUYKO.js +0 -116
- package/chunks/list.action-OFGLMRE7.js +0 -95
- package/docs.html +0 -6245
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
BaseCollections
|
|
4
|
+
} from "./chunk-NWJ37GI2.js";
|
|
5
|
+
import {
|
|
6
|
+
getDatabaseClient
|
|
7
|
+
} from "./chunk-U6VE6JOS.js";
|
|
8
|
+
import "./chunk-SEURG74P.js";
|
|
9
|
+
import "./chunk-3TFOA64C.js";
|
|
10
|
+
import "./chunk-5ENKYZA4.js";
|
|
11
|
+
import "./chunk-Y6XGC4K5.js";
|
|
12
|
+
import "./chunk-T34TL6KL.js";
|
|
13
|
+
import "./chunk-V6LUKXBV.js";
|
|
14
|
+
import "./chunk-VUXPDHTQ.js";
|
|
15
|
+
import {
|
|
16
|
+
getAuthData
|
|
17
|
+
} from "./chunk-3RIUDHLG.js";
|
|
18
|
+
import "./chunk-N5CJ5MTY.js";
|
|
19
|
+
import "./chunk-US54KYOJ.js";
|
|
20
|
+
import {
|
|
21
|
+
teamSchema
|
|
22
|
+
} from "./chunk-BQYVSPAI.js";
|
|
23
|
+
import "./chunk-VRZSDUZK.js";
|
|
24
|
+
import "./chunk-4ORL4MST.js";
|
|
25
|
+
import "./chunk-MN2AFJXM.js";
|
|
26
|
+
import {
|
|
27
|
+
output
|
|
28
|
+
} from "./chunk-T5HJUAWB.js";
|
|
29
|
+
import "./chunk-25XERWCE.js";
|
|
30
|
+
import "./chunk-AVZFSWPD.js";
|
|
31
|
+
import "./chunk-I57ID5K7.js";
|
|
32
|
+
import "./chunk-3MZYUBJ6.js";
|
|
33
|
+
|
|
34
|
+
// src/domains/team/get/action.ts
|
|
35
|
+
async function getAction(args = {}) {
|
|
36
|
+
const auth = await getAuthData();
|
|
37
|
+
auth.addEventListener((state) => Object.assign(auth, state));
|
|
38
|
+
const client = await getDatabaseClient();
|
|
39
|
+
const team = await client.getOne({
|
|
40
|
+
collectionPath: BaseCollections.Teams,
|
|
41
|
+
query: { uid: auth.teamUid },
|
|
42
|
+
schema: teamSchema
|
|
43
|
+
});
|
|
44
|
+
if (team.error) {
|
|
45
|
+
return output.error().title("Could not load the current team").message(team.message).exit("error");
|
|
46
|
+
}
|
|
47
|
+
const details = {
|
|
48
|
+
uid: team.data.uid,
|
|
49
|
+
name: team.data.name,
|
|
50
|
+
slug: team.data.slug,
|
|
51
|
+
namespaces: team.data.namespaces
|
|
52
|
+
};
|
|
53
|
+
if (args.json) {
|
|
54
|
+
process.stdout.write(`${JSON.stringify(details, null, 2)}
|
|
55
|
+
`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
output.info().title(details.name).line(`Team ID: ${details.uid}`).line(`Slug: ${details.slug}`).line(
|
|
59
|
+
`Namespaces: ${details.namespaces.length ? details.namespaces.join(", ") : "None"}`
|
|
60
|
+
).print();
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
getAction
|
|
64
|
+
};
|
|
@@ -1,28 +1,24 @@
|
|
|
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
|
|
6
|
-
require_dist
|
|
7
|
-
} from "./chunk-K74E42RV.js";
|
|
8
|
-
import "./chunk-KCCFN4F7.js";
|
|
9
|
-
import "./chunk-6XWCMJDB.js";
|
|
4
|
+
} from "./chunk-4JKXZ5CF.js";
|
|
5
|
+
import "./chunk-QMLRYD76.js";
|
|
10
6
|
import {
|
|
11
7
|
isYamlFileName
|
|
12
8
|
} from "./chunk-4ORL4MST.js";
|
|
9
|
+
import "./chunk-MN2AFJXM.js";
|
|
13
10
|
import {
|
|
14
11
|
output
|
|
15
12
|
} from "./chunk-T5HJUAWB.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
} from "./chunk-3MZYUBJ6.js";
|
|
13
|
+
import "./chunk-25XERWCE.js";
|
|
14
|
+
import "./chunk-AVZFSWPD.js";
|
|
15
|
+
import "./chunk-I57ID5K7.js";
|
|
16
|
+
import "./chunk-3MZYUBJ6.js";
|
|
21
17
|
|
|
22
18
|
// src/domains/document/postman/action.ts
|
|
23
|
-
var import_yaml = __toESM(require_dist(), 1);
|
|
24
19
|
import fs from "node:fs";
|
|
25
20
|
import as from "ansis";
|
|
21
|
+
import YAML from "yaml";
|
|
26
22
|
import { convert } from "@scalar/postman-to-openapi";
|
|
27
23
|
async function convertAction(inputArgument, {
|
|
28
24
|
output: outputPath,
|
|
@@ -30,7 +26,7 @@ async function convertAction(inputArgument, {
|
|
|
30
26
|
}) {
|
|
31
27
|
const startTime = performance.now();
|
|
32
28
|
if (!inputArgument) {
|
|
33
|
-
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");
|
|
34
30
|
}
|
|
35
31
|
const collection = await getFileOrUrl(inputArgument);
|
|
36
32
|
let specification;
|
|
@@ -41,13 +37,13 @@ async function convertAction(inputArgument, {
|
|
|
41
37
|
} catch {
|
|
42
38
|
return output.error().title("Failed to convert Postman collection").message("The provided input is not a valid Postman collection").exit("error");
|
|
43
39
|
}
|
|
44
|
-
const openApiDocument = outputPath ? isYamlFileName(outputPath) ?
|
|
40
|
+
const openApiDocument = outputPath ? isYamlFileName(outputPath) ? YAML.stringify(specification) : JSON.stringify(specification, null, 2) : JSON.stringify(specification, null, 2);
|
|
45
41
|
if (outputPath) {
|
|
46
42
|
fs.writeFileSync(outputPath, openApiDocument, "utf8");
|
|
47
43
|
const endTime = performance.now();
|
|
48
44
|
output.info().line(
|
|
49
|
-
`${as.green("OpenAPI
|
|
50
|
-
`
|
|
45
|
+
`${as.green("OpenAPI description generated")} ${as.grey(
|
|
46
|
+
`(${as.white(`${as.bold(`${Math.round(endTime - startTime)}`)} ms`)})`
|
|
51
47
|
)}`
|
|
52
48
|
).line(`Written to ${as.cyan(outputPath)}`).print();
|
|
53
49
|
return;
|
|
@@ -1,15 +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-6XWCMJDB.js";
|
|
4
|
+
} from "./chunk-4JKXZ5CF.js";
|
|
5
|
+
import "./chunk-QMLRYD76.js";
|
|
7
6
|
import "./chunk-4ORL4MST.js";
|
|
7
|
+
import "./chunk-MN2AFJXM.js";
|
|
8
8
|
import {
|
|
9
9
|
output
|
|
10
10
|
} from "./chunk-T5HJUAWB.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-25XERWCE.js";
|
|
12
|
+
import "./chunk-AVZFSWPD.js";
|
|
13
|
+
import "./chunk-I57ID5K7.js";
|
|
13
14
|
import "./chunk-3MZYUBJ6.js";
|
|
14
15
|
|
|
15
16
|
// src/domains/document/markdown/action.ts
|
|
@@ -19,7 +20,7 @@ import { createMarkdownFromOpenApi } from "@scalar/openapi-to-markdown";
|
|
|
19
20
|
async function markdownAction(inputArgument, { output: outputPath }) {
|
|
20
21
|
const startTime = performance.now();
|
|
21
22
|
if (!inputArgument) {
|
|
22
|
-
return output.error().title("Invalid argument").message("
|
|
23
|
+
return output.error().title("Invalid argument").message("Provide a file path or URL.").exit("error");
|
|
23
24
|
}
|
|
24
25
|
const specification = await getFileOrUrl(inputArgument);
|
|
25
26
|
const markdown = await createMarkdownFromOpenApi(specification);
|
|
@@ -28,7 +29,7 @@ async function markdownAction(inputArgument, { output: outputPath }) {
|
|
|
28
29
|
const endTime = performance.now();
|
|
29
30
|
output.info().line(
|
|
30
31
|
`${as.green("Markdown generated")} ${as.grey(
|
|
31
|
-
`
|
|
32
|
+
`(${as.white(`${as.bold(`${Math.round(endTime - startTime)}`)} ms`)})`
|
|
32
33
|
)}`
|
|
33
34
|
).line(`Written to ${as.cyan(outputPath)}`).print();
|
|
34
35
|
return;
|
|
@@ -1,51 +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-
|
|
5
|
-
import {
|
|
6
|
-
resolveProject
|
|
7
|
-
} from "./chunk-TSURUX4A.js";
|
|
4
|
+
} from "./chunk-ALYM4ZB2.js";
|
|
8
5
|
import {
|
|
9
6
|
readAndParseConfig,
|
|
10
7
|
renderConfigError
|
|
11
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5L7V7RCH.js";
|
|
9
|
+
import {
|
|
10
|
+
resolveProject
|
|
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-
|
|
26
|
-
import "./chunk-
|
|
21
|
+
} from "./chunk-F3OPMYME.js";
|
|
22
|
+
import "./chunk-FG5AOTDN.js";
|
|
23
|
+
import "./chunk-SEURG74P.js";
|
|
24
|
+
import "./chunk-3TFOA64C.js";
|
|
25
|
+
import "./chunk-5ENKYZA4.js";
|
|
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";
|
|
27
31
|
import {
|
|
28
32
|
getAuthData
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import "./chunk-
|
|
31
|
-
import "./chunk-
|
|
33
|
+
} from "./chunk-3RIUDHLG.js";
|
|
34
|
+
import "./chunk-N5CJ5MTY.js";
|
|
35
|
+
import "./chunk-US54KYOJ.js";
|
|
36
|
+
import "./chunk-BQYVSPAI.js";
|
|
32
37
|
import {
|
|
33
38
|
ConfigVersion,
|
|
34
39
|
isGithubBackedDocsProject,
|
|
35
40
|
publishRecordSchema
|
|
36
|
-
} from "./chunk-
|
|
37
|
-
import "./chunk-K74E42RV.js";
|
|
38
|
-
import "./chunk-KCCFN4F7.js";
|
|
39
|
-
import "./chunk-6XWCMJDB.js";
|
|
41
|
+
} from "./chunk-VRZSDUZK.js";
|
|
40
42
|
import "./chunk-4ORL4MST.js";
|
|
43
|
+
import "./chunk-MN2AFJXM.js";
|
|
41
44
|
import {
|
|
42
45
|
output
|
|
43
46
|
} from "./chunk-T5HJUAWB.js";
|
|
44
|
-
import "./chunk-
|
|
47
|
+
import "./chunk-25XERWCE.js";
|
|
48
|
+
import "./chunk-AVZFSWPD.js";
|
|
45
49
|
import {
|
|
46
50
|
slugSchema,
|
|
47
51
|
zod_default
|
|
48
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-I57ID5K7.js";
|
|
49
53
|
import "./chunk-3MZYUBJ6.js";
|
|
50
54
|
|
|
51
55
|
// src/domains/project/publish/action.ts
|
|
@@ -395,7 +399,7 @@ async function publishAction(args) {
|
|
|
395
399
|
github: zod_default.coerce.boolean().default(false)
|
|
396
400
|
}).safeParse(args);
|
|
397
401
|
if (argsParseResult.error)
|
|
398
|
-
return output.error().title("Invalid
|
|
402
|
+
return output.error().title("Invalid arguments").message(argsParseResult.error.issues[0].message).exit("error");
|
|
399
403
|
const {
|
|
400
404
|
config: configPathOption,
|
|
401
405
|
slug,
|
|
@@ -406,7 +410,9 @@ async function publishAction(args) {
|
|
|
406
410
|
const auth = await getAuthData();
|
|
407
411
|
auth.addEventListener((state) => Object.assign(auth, state));
|
|
408
412
|
if (!slug) {
|
|
409
|
-
return output.error().title("Invalid argument").message(
|
|
413
|
+
return output.error().title("Invalid argument").message(
|
|
414
|
+
"Slug is required. Run scalar project list to find your project slug, then pass --slug <slug>."
|
|
415
|
+
).exit("error");
|
|
410
416
|
}
|
|
411
417
|
if (github) {
|
|
412
418
|
const resolved = await resolveProject(slug, apiClient);
|
|
@@ -416,17 +422,17 @@ async function publishAction(args) {
|
|
|
416
422
|
if (resolved.kind === "github") {
|
|
417
423
|
if (!resolved.project.repository) {
|
|
418
424
|
return output.error().title("Your project is not linked to a GitHub repository").message(
|
|
419
|
-
"
|
|
425
|
+
"Connect the project to a GitHub repository in the Scalar Dashboard to publish from GitHub."
|
|
420
426
|
).exit("error");
|
|
421
427
|
}
|
|
422
428
|
if (resolved.project.repository.expired) {
|
|
423
|
-
return output.error().title("
|
|
424
|
-
"
|
|
429
|
+
return output.error().title("GitHub repository access has expired").message(
|
|
430
|
+
"Reconnect the GitHub repository in the Scalar Dashboard to publish from GitHub."
|
|
425
431
|
).exit("error");
|
|
426
432
|
}
|
|
427
433
|
const publishResult3 = await publishGithub({ apiClient, slug, preview });
|
|
428
434
|
if (!publishResult3.success) {
|
|
429
|
-
return output.error().title("Could not publish
|
|
435
|
+
return output.error().title("Could not publish from GitHub").message(publishResult3.error).exit("error");
|
|
430
436
|
}
|
|
431
437
|
return await waitForPublish({
|
|
432
438
|
teamUid: auth.teamUid,
|
|
@@ -435,12 +441,12 @@ async function publishAction(args) {
|
|
|
435
441
|
}
|
|
436
442
|
if (!isGithubBackedDocsProject(resolved.project)) {
|
|
437
443
|
return output.error().title("Your project is not linked to a GitHub repository").message(
|
|
438
|
-
"
|
|
444
|
+
"Connect the project to a GitHub repository in the Scalar Dashboard to publish from GitHub."
|
|
439
445
|
).exit("error");
|
|
440
446
|
}
|
|
441
447
|
if (resolved.project.repository.expired) {
|
|
442
|
-
return output.error().title("
|
|
443
|
-
"
|
|
448
|
+
return output.error().title("GitHub repository access has expired").message(
|
|
449
|
+
"Reconnect the GitHub repository in the Scalar Dashboard to publish from GitHub."
|
|
444
450
|
).exit("error");
|
|
445
451
|
}
|
|
446
452
|
const publishResult2 = await publishUnifiedDocsProjectFromGithub({
|
|
@@ -449,7 +455,7 @@ async function publishAction(args) {
|
|
|
449
455
|
preview
|
|
450
456
|
});
|
|
451
457
|
if (!publishResult2.success) {
|
|
452
|
-
return output.error().title("Could not publish
|
|
458
|
+
return output.error().title("Could not publish from GitHub").message(publishResult2.error).exit("error");
|
|
453
459
|
}
|
|
454
460
|
return await waitForPublish({
|
|
455
461
|
teamUid: auth.teamUid,
|
|
@@ -461,6 +467,7 @@ async function publishAction(args) {
|
|
|
461
467
|
renderConfigError(configResult.error);
|
|
462
468
|
}
|
|
463
469
|
const { config, filePath: configPath } = configResult;
|
|
470
|
+
warnIfLegacyConfig(config);
|
|
464
471
|
const publishResult = await publishProject({
|
|
465
472
|
config,
|
|
466
473
|
slug,
|
|
@@ -469,7 +476,7 @@ async function publishAction(args) {
|
|
|
469
476
|
...preview && { mode: "preview" }
|
|
470
477
|
});
|
|
471
478
|
if (!publishResult.success) {
|
|
472
|
-
return output.error().title("
|
|
479
|
+
return output.error().title("Could not deploy the project").message(
|
|
473
480
|
publishResult.error instanceof Error ? publishResult.error.message : publishResult.error
|
|
474
481
|
).exit("error");
|
|
475
482
|
}
|
|
@@ -478,12 +485,18 @@ async function publishAction(args) {
|
|
|
478
485
|
publishUid: publishResult.publishUid
|
|
479
486
|
});
|
|
480
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
|
+
}
|
|
481
494
|
async function waitForPublish({
|
|
482
495
|
teamUid,
|
|
483
496
|
publishUid
|
|
484
497
|
}) {
|
|
485
498
|
const dbClient = await getDatabaseClient();
|
|
486
|
-
const logger = output.info({ animate: true }).loader("
|
|
499
|
+
const logger = output.info({ animate: true }).loader("Deploying project\u2026");
|
|
487
500
|
while (true) {
|
|
488
501
|
const deployStatus = await getDeployStatus({
|
|
489
502
|
client: dbClient,
|
|
@@ -491,9 +504,7 @@ async function waitForPublish({
|
|
|
491
504
|
teamUid
|
|
492
505
|
});
|
|
493
506
|
if (deployStatus.error === true) {
|
|
494
|
-
return output.error().title(
|
|
495
|
-
"Something went wrong while getting information about the deployment"
|
|
496
|
-
).exit("error");
|
|
507
|
+
return output.error().title("Could not load deployment status").exit("error");
|
|
497
508
|
}
|
|
498
509
|
logger.update("loader", 0, { content: deployStatus.data.message });
|
|
499
510
|
if (deployStatus.data.status === "deployed") {
|
|
@@ -503,6 +514,9 @@ async function waitForPublish({
|
|
|
503
514
|
`${deployStatus.data.preview ? "Preview URL" : "Deployment URL"}: ${deploymentUrl}`
|
|
504
515
|
).print();
|
|
505
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
|
+
}
|
|
506
520
|
logger.exit("success");
|
|
507
521
|
return;
|
|
508
522
|
}
|
|
@@ -525,5 +539,6 @@ async function getDeployStatus({
|
|
|
525
539
|
}
|
|
526
540
|
export {
|
|
527
541
|
publishAction,
|
|
528
|
-
waitForPublish
|
|
542
|
+
waitForPublish,
|
|
543
|
+
warnIfLegacyConfig
|
|
529
544
|
};
|
|
@@ -1,42 +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-
|
|
20
|
-
import "./chunk-
|
|
19
|
+
} from "./chunk-F3OPMYME.js";
|
|
20
|
+
import "./chunk-FG5AOTDN.js";
|
|
21
|
+
import "./chunk-SEURG74P.js";
|
|
22
|
+
import "./chunk-3TFOA64C.js";
|
|
23
|
+
import "./chunk-5ENKYZA4.js";
|
|
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";
|
|
21
29
|
import {
|
|
22
30
|
getAuthData
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-KCCFN4F7.js";
|
|
29
|
-
import "./chunk-6XWCMJDB.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";
|
|
30
36
|
import "./chunk-4ORL4MST.js";
|
|
37
|
+
import "./chunk-MN2AFJXM.js";
|
|
31
38
|
import {
|
|
32
39
|
output,
|
|
33
40
|
printTable
|
|
34
41
|
} from "./chunk-T5HJUAWB.js";
|
|
35
|
-
import "./chunk-
|
|
42
|
+
import "./chunk-25XERWCE.js";
|
|
43
|
+
import "./chunk-AVZFSWPD.js";
|
|
36
44
|
import {
|
|
37
45
|
external_exports,
|
|
38
46
|
slugSchema
|
|
39
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-I57ID5K7.js";
|
|
40
48
|
import "./chunk-3MZYUBJ6.js";
|
|
41
49
|
|
|
42
50
|
// src/domains/project/deployments/list/action.ts
|
|
@@ -58,11 +66,13 @@ function colorStatus(status) {
|
|
|
58
66
|
async function listAction(args) {
|
|
59
67
|
const argsParseResult = external_exports.object({ slug: slugSchema.optional() }).safeParse(args);
|
|
60
68
|
if (argsParseResult.error) {
|
|
61
|
-
return output.error().title("Invalid
|
|
69
|
+
return output.error().title("Invalid arguments").message(argsParseResult.error.issues[0].message).exit("error");
|
|
62
70
|
}
|
|
63
71
|
const { slug } = argsParseResult.data;
|
|
64
72
|
if (!slug) {
|
|
65
|
-
return output.error().title("Invalid argument").message(
|
|
73
|
+
return output.error().title("Invalid argument").message(
|
|
74
|
+
"Slug is required. Run scalar project list to find your project slug, then pass --slug <slug>."
|
|
75
|
+
).exit("error");
|
|
66
76
|
}
|
|
67
77
|
const apiClient = await apiService();
|
|
68
78
|
const auth = await getAuthData();
|
|
@@ -81,26 +91,44 @@ async function listAction(args) {
|
|
|
81
91
|
return output.error().title("Could not load deployment history").message(deploymentsResult.error).exit("error");
|
|
82
92
|
}
|
|
83
93
|
if (deploymentsResult.deployments.length === 0) {
|
|
84
|
-
output.info().
|
|
94
|
+
output.info().message(`No deployments found for project "${slug}".`).print();
|
|
85
95
|
return;
|
|
86
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();
|
|
87
105
|
printTable(
|
|
88
106
|
[
|
|
89
|
-
{ name: "current", title: "
|
|
107
|
+
{ name: "current", title: "Live", alignment: "center" },
|
|
90
108
|
{ name: "id", title: "Build ID", alignment: "left" },
|
|
91
109
|
{ name: "status", title: "Status", alignment: "left" },
|
|
92
110
|
{ name: "deployed", title: "Deployed", alignment: "left" },
|
|
93
|
-
{ name: "commit", title: "Commit", alignment: "left" }
|
|
111
|
+
{ name: "commit", title: "Commit", alignment: "left" },
|
|
112
|
+
{ name: "url", title: "URL", alignment: "left" }
|
|
94
113
|
],
|
|
95
114
|
deploymentsResult.deployments.map((record) => {
|
|
96
115
|
const isLive = record.uid === activeUid;
|
|
97
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
|
+
})();
|
|
98
125
|
return {
|
|
99
126
|
current: isLive ? as.green("\u279C") : " ",
|
|
100
127
|
id: isLive ? as.green(record.uid) : record.uid,
|
|
101
128
|
status: colorStatus(record.status),
|
|
102
|
-
deployed: deployedAt ?
|
|
103
|
-
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
|
|
104
132
|
};
|
|
105
133
|
})
|
|
106
134
|
);
|