@scalar/cli 2.1.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -24
- package/chunks/{action-CYP4VDK3.js → action-37EV4UHW.js} +12 -35
- package/chunks/{action-MENXFJH3.js → action-4XI7XJR4.js} +9 -9
- package/chunks/{action-H5OHT2GV.js → action-5IU77OII.js} +7 -3
- package/chunks/{action-STIEAXOE.js → action-B3KKREWQ.js} +16 -5
- package/chunks/{action-BYZUBXVB.js → action-CH24QGTE.js} +8 -4
- package/chunks/action-F3UX5E3M.js +522 -0
- package/chunks/{action-GB6DM53B.js → action-FDB7NEOK.js} +21 -10
- package/chunks/action-FIXBOJEW.js +244 -0
- package/chunks/{action-DFKHSDFV.js → action-G26LSVZ7.js} +7 -3
- package/chunks/{action-Q5UJ32D6.js → action-H3RTILLM.js} +1 -1
- package/chunks/{action-GEBRPNRT.js → action-HGBBV353.js} +15 -16
- package/chunks/{action-5R5FDF6S.js → action-IUE4IOWO.js} +67 -22
- package/chunks/{action-TPBKPHNS.js → action-JZLZ7ZAD.js} +22 -22
- package/chunks/action-LA6KVAXQ.js +374 -0
- package/chunks/{action-PVDDRIM6.js → action-M7RQKBSB.js} +65 -26
- package/chunks/{action-F4Y6Q2VB.js → action-MSLBC2SO.js} +21 -21
- package/chunks/{action-BNEGJBUH.js → action-NVSZT2ZD.js} +8 -9
- package/chunks/{action-ANU5HGC4.js → action-OGQSTRMX.js} +17 -14
- package/chunks/{action-CLSD7O2R.js → action-PAGJ5PWC.js} +10 -10
- package/chunks/action-QE2ZQQX7.js +250 -0
- package/chunks/{action-HD2T6BFJ.js → action-QPUSPD5M.js} +10 -10
- package/chunks/{action-45OGQB2M.js → action-R7IMFHQ5.js} +17 -8
- package/chunks/{action-UDZUUJSI.js → action-SH4UUXPL.js} +18 -7
- package/chunks/action-SNLCIBQC.js +84 -0
- package/chunks/{action-C5VB4ITT.js → action-SQG3JAII.js} +36 -18
- package/chunks/action-UZQJNYK4.js +18 -0
- package/chunks/{action-HNKM3Q65.js → action-VC4DCVST.js} +17 -14
- package/chunks/{action-BMFXENMX.js → action-VTVFY2MP.js} +39 -34
- package/chunks/{action-TZ5KGAQT.js → action-WFWYGY7O.js} +17 -14
- package/chunks/{action-W5BATF4Q.js → action-XMNX5ZYT.js} +24 -24
- package/chunks/{agent-XGLOHXNA.js → agent-HCQRMHQ5.js} +25 -5
- package/chunks/asyncapi-QM76O55R.js +105 -0
- package/chunks/{build.action-LKOILPA6.js → build.action-P7FCIMYU.js} +22 -22
- package/chunks/{chunk-23I5PKZZ.js → chunk-24WAOKGG.js} +32 -5
- package/chunks/chunk-3L6DLIXJ.js +25530 -0
- package/chunks/chunk-3ZJYGGAA.js +30 -0
- package/chunks/{chunk-ZTVWAKNJ.js → chunk-4NHMAG6F.js} +1 -1
- package/chunks/{chunk-IX7LJ3AD.js → chunk-4ORL4MST.js} +2 -3
- package/chunks/{chunk-OAXFCOJV.js → chunk-4ZDQXWBT.js} +2 -1
- package/chunks/{chunk-ASMHW5AY.js → chunk-6ZMT63IV.js} +1 -1
- package/chunks/{chunk-P2VH7DOC.js → chunk-7AGLC7WV.js} +6 -6
- package/chunks/{chunk-SXYALPYK.js → chunk-AO3F5XWR.js} +498 -60
- package/chunks/{chunk-B6QZJWCQ.js → chunk-B2MHTD3R.js} +4 -6
- package/chunks/{chunk-4QS7SJTG.js → chunk-CISTON3A.js} +51 -36
- package/chunks/chunk-COBPBRQF.js +25 -0
- package/chunks/{chunk-2BSG2QHO.js → chunk-F467BYYR.js} +133 -20
- package/chunks/{chunk-TLFMATXR.js → chunk-GSGZHE26.js} +33 -25
- package/chunks/{chunk-UPUTMFD4.js → chunk-HCPN3KNF.js} +185 -13
- package/chunks/{chunk-P646T2WH.js → chunk-HPL3ZZ2P.js} +131 -13
- package/chunks/{chunk-H2WRMLYY.js → chunk-IKT5F47M.js} +3571 -7
- package/chunks/{chunk-AHWWJ3MD.js → chunk-K4DTP5TV.js} +1 -1
- package/chunks/{chunk-TQ5XC2E3.js → chunk-LFU5ZUAP.js} +77 -11
- package/chunks/{chunk-5BISXQX4.js → chunk-M37TP6U2.js} +11 -13
- package/chunks/chunk-OQKDBLOZ.js +741 -0
- package/chunks/chunk-P7H7GY5A.js +14 -0
- package/chunks/{chunk-47Y4L5IT.js → chunk-PBXZN65A.js} +1031 -481
- package/chunks/{chunk-HQKBZOYU.js → chunk-PT5TI77I.js} +3 -3
- package/chunks/chunk-Q7DOQHZN.js +404 -0
- package/chunks/{chunk-X4QLDBB5.js → chunk-T5HJUAWB.js} +24 -3
- package/chunks/{chunk-NUXPNUSS.js → chunk-UGGNHILG.js} +1 -1
- package/chunks/{chunk-4DGQIAJX.js → chunk-VNYE4R7N.js} +154 -14
- package/chunks/{chunk-KWOL7A6J.js → chunk-X5T526CE.js} +2 -2
- package/chunks/chunk-XCSR4RIT.js +210 -0
- package/chunks/{chunk-SHSHFGA7.js → chunk-Z2KMGFE6.js} +4 -6
- package/chunks/{create.action-FFQLBSJH.js → create.action-HDD2WUON.js} +22 -22
- package/chunks/{delete.action-STHQHP4F.js → delete.action-7GOZY7ID.js} +22 -22
- package/chunks/{delete.action-QNN3LC2F.js → delete.action-VE66JFDS.js} +22 -22
- package/chunks/{get.action-OTKYOP3Z.js → get.action-2745EB4N.js} +15 -16
- package/chunks/{list.action-KDM5RHEH.js → list.action-3VTXQJRA.js} +19 -19
- package/chunks/{list.action-6I5EZAVB.js → list.action-4QDCZLSZ.js} +22 -22
- package/chunks/{publish.action-PODTVRXS.js → publish.action-ULQLZKWU.js} +44 -36
- package/chunks/{update.action-KMD4ZM75.js → update.action-6QEFP7NA.js} +22 -22
- package/chunks/{update.action-4F6STTEQ.js → update.action-OROQSP2S.js} +22 -22
- package/docs.html +104 -103
- package/index.js +84 -68
- package/package.json +16 -12
- package/chunks/action-CCW66QJN.js +0 -72
- package/chunks/action-CQ56FVES.js +0 -65
- package/chunks/action-JOSVV6YA.js +0 -71
- package/chunks/action-P7LN6FGY.js +0 -13
- package/chunks/action-R6ZZO26F.js +0 -299
- package/chunks/action-TWFJNQ2R.js +0 -95
- package/chunks/chunk-5BPPGTUU.js +0 -463
- package/chunks/chunk-DOVIWNKQ.js +0 -108
- package/chunks/chunk-ISGLWBXZ.js +0 -4265
- package/chunks/chunk-T7MDADON.js +0 -17
- package/chunks/chunk-VTYTPSXO.js +0 -161
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
getFileOrUrl
|
|
4
|
-
} from "./chunk-23I5PKZZ.js";
|
|
5
|
-
import "./chunk-IX7LJ3AD.js";
|
|
6
|
-
import {
|
|
7
|
-
output
|
|
8
|
-
} from "./chunk-X4QLDBB5.js";
|
|
9
|
-
import "./chunk-3MZYUBJ6.js";
|
|
10
|
-
|
|
11
|
-
// src/domains/document/lint/action.ts
|
|
12
|
-
import spectralCore from "@stoplight/spectral-core";
|
|
13
|
-
import "@stoplight/spectral-rulesets";
|
|
14
|
-
import as from "ansis";
|
|
15
|
-
|
|
16
|
-
// src/domains/document/lint/helpers.ts
|
|
17
|
-
import { bundleAndLoadRuleset } from "@stoplight/spectral-ruleset-bundler/with-loader";
|
|
18
|
-
async function loadRuleset(ruleset) {
|
|
19
|
-
return await bundleAndLoadRuleset("/.spectral.yaml", {
|
|
20
|
-
fs: {
|
|
21
|
-
promises: {
|
|
22
|
-
// @ts-expect-error No need for overloading here.
|
|
23
|
-
async readFile(_filepath) {
|
|
24
|
-
return ruleset;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
format: "esm"
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
var defaultRuleset = `extends: spectral:oas
|
|
32
|
-
rules: {}`;
|
|
33
|
-
var severityToLabel = (severity) => {
|
|
34
|
-
return {
|
|
35
|
-
0: "Error",
|
|
36
|
-
1: "Warning",
|
|
37
|
-
2: "Information",
|
|
38
|
-
3: "Hint"
|
|
39
|
-
}[severity];
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// src/domains/document/lint/action.ts
|
|
43
|
-
var { Spectral } = spectralCore;
|
|
44
|
-
async function lintAction(inputArgument, { rule: ruleArgument }) {
|
|
45
|
-
if (!inputArgument) {
|
|
46
|
-
return output.error().title("Invalid argument").message("Please provide a file path").exit("error");
|
|
47
|
-
}
|
|
48
|
-
const spectral = new Spectral();
|
|
49
|
-
const specification = await getFileOrUrl(inputArgument);
|
|
50
|
-
const ruleFileContents = ruleArgument ? await getFileOrUrl(ruleArgument) : defaultRuleset;
|
|
51
|
-
const ruleset = await loadRuleset(ruleFileContents);
|
|
52
|
-
spectral.setRuleset(ruleset);
|
|
53
|
-
const spectralDiagnostics = await spectral.run(specification);
|
|
54
|
-
const hasErrors = spectralDiagnostics.filter((d) => d.severity === 0).length !== 0;
|
|
55
|
-
if (!hasErrors) {
|
|
56
|
-
output.info().message(as.green("\u2714 No issues found!")).print();
|
|
57
|
-
} else {
|
|
58
|
-
output.warn().line(as.red("\u2716 Issues found:")).print();
|
|
59
|
-
}
|
|
60
|
-
for (const diagnostic of spectralDiagnostics) {
|
|
61
|
-
output.info().line(`${as.yellow("Rule:")} ${as.bold(diagnostic.code)}`).line(`${as.yellow("Message:")} ${diagnostic.message}`).line(`${as.yellow("Severity:")} ${severityToLabel(diagnostic.severity)}`).line(
|
|
62
|
-
`${as.yellow("Location:")} ${diagnostic.range.start.line}:${diagnostic.range.start.character} - ${diagnostic.range.end.line}:${diagnostic.range.end.character}`
|
|
63
|
-
).line(as.gray("---")).print();
|
|
64
|
-
}
|
|
65
|
-
if (hasErrors) {
|
|
66
|
-
output.error().exit("error");
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
export {
|
|
70
|
-
lintAction
|
|
71
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
downloadIsolate,
|
|
4
|
-
updateIsolate
|
|
5
|
-
} from "./chunk-TQ5XC2E3.js";
|
|
6
|
-
import "./chunk-KWOL7A6J.js";
|
|
7
|
-
import "./chunk-OAXFCOJV.js";
|
|
8
|
-
import "./chunk-X4QLDBB5.js";
|
|
9
|
-
import "./chunk-3MZYUBJ6.js";
|
|
10
|
-
export {
|
|
11
|
-
downloadIsolate,
|
|
12
|
-
updateIsolate
|
|
13
|
-
};
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
getPublishDeploymentUrl
|
|
4
|
-
} from "./chunk-ZTVWAKNJ.js";
|
|
5
|
-
import {
|
|
6
|
-
readAndParseConfig,
|
|
7
|
-
renderConfigError
|
|
8
|
-
} from "./chunk-P2VH7DOC.js";
|
|
9
|
-
import {
|
|
10
|
-
resolveProject
|
|
11
|
-
} from "./chunk-T7B6WNZC.js";
|
|
12
|
-
import "./chunk-47Y4L5IT.js";
|
|
13
|
-
import "./chunk-DOVIWNKQ.js";
|
|
14
|
-
import {
|
|
15
|
-
apiService
|
|
16
|
-
} from "./chunk-SXYALPYK.js";
|
|
17
|
-
import {
|
|
18
|
-
getDatabaseClient
|
|
19
|
-
} from "./chunk-SHSHFGA7.js";
|
|
20
|
-
import "./chunk-UPUTMFD4.js";
|
|
21
|
-
import "./chunk-B6QZJWCQ.js";
|
|
22
|
-
import "./chunk-5BPPGTUU.js";
|
|
23
|
-
import "./chunk-P646T2WH.js";
|
|
24
|
-
import "./chunk-4QS7SJTG.js";
|
|
25
|
-
import "./chunk-VTYTPSXO.js";
|
|
26
|
-
import {
|
|
27
|
-
getAuthData
|
|
28
|
-
} from "./chunk-5BISXQX4.js";
|
|
29
|
-
import "./chunk-OAXFCOJV.js";
|
|
30
|
-
import "./chunk-TLFMATXR.js";
|
|
31
|
-
import "./chunk-4DGQIAJX.js";
|
|
32
|
-
import {
|
|
33
|
-
isGithubBackedDocsProject,
|
|
34
|
-
publishRecordSchema,
|
|
35
|
-
slugSchema
|
|
36
|
-
} from "./chunk-ISGLWBXZ.js";
|
|
37
|
-
import {
|
|
38
|
-
zod_default
|
|
39
|
-
} from "./chunk-H2WRMLYY.js";
|
|
40
|
-
import "./chunk-K74E42RV.js";
|
|
41
|
-
import "./chunk-IX7LJ3AD.js";
|
|
42
|
-
import {
|
|
43
|
-
output
|
|
44
|
-
} from "./chunk-X4QLDBB5.js";
|
|
45
|
-
import "./chunk-3MZYUBJ6.js";
|
|
46
|
-
|
|
47
|
-
// src/domains/project/publish/action.ts
|
|
48
|
-
import { dirname } from "node:path";
|
|
49
|
-
|
|
50
|
-
// src/domains/project/publish/publish.ts
|
|
51
|
-
import fs from "node:fs";
|
|
52
|
-
import path from "node:path";
|
|
53
|
-
import { Readable } from "node:stream";
|
|
54
|
-
import ignore from "ignore";
|
|
55
|
-
import tar from "tar-fs";
|
|
56
|
-
var DEFAULT_IGNORED_FILES = ["node_modules", ".git"];
|
|
57
|
-
function isErrnoException(error) {
|
|
58
|
-
return error instanceof Error && "code" in error;
|
|
59
|
-
}
|
|
60
|
-
async function readGitIgnore(configDir) {
|
|
61
|
-
try {
|
|
62
|
-
const gitignore = await fs.promises.readFile(
|
|
63
|
-
path.resolve(configDir, ".gitignore"),
|
|
64
|
-
"utf8"
|
|
65
|
-
);
|
|
66
|
-
return gitignore;
|
|
67
|
-
} catch (err) {
|
|
68
|
-
if (isErrnoException(err) && err.code === "ENOENT") return null;
|
|
69
|
-
throw err;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async function createProjectTar(configDir) {
|
|
73
|
-
const ignorer = ignore({ allowRelativePaths: true });
|
|
74
|
-
const gitignore = await readGitIgnore(configDir);
|
|
75
|
-
if (gitignore) ignorer.add(gitignore);
|
|
76
|
-
ignorer.add(DEFAULT_IGNORED_FILES);
|
|
77
|
-
return Readable.from(
|
|
78
|
-
tar.pack(configDir, {
|
|
79
|
-
ignore: (name) => ignorer.ignores(name),
|
|
80
|
-
dereference: true
|
|
81
|
-
})
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
async function publishGithub({
|
|
85
|
-
slug,
|
|
86
|
-
preview,
|
|
87
|
-
apiClient
|
|
88
|
-
}) {
|
|
89
|
-
const publishGithubResult = await apiClient.publish.publishGithub({
|
|
90
|
-
slug,
|
|
91
|
-
preview
|
|
92
|
-
});
|
|
93
|
-
if (publishGithubResult.error) {
|
|
94
|
-
return {
|
|
95
|
-
success: false,
|
|
96
|
-
error: publishGithubResult.message
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
success: true,
|
|
101
|
-
publishUid: publishGithubResult.data.publishUid
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
async function publishProject({
|
|
105
|
-
configDir,
|
|
106
|
-
configPath,
|
|
107
|
-
config,
|
|
108
|
-
slug,
|
|
109
|
-
mode
|
|
110
|
-
}) {
|
|
111
|
-
try {
|
|
112
|
-
const root = path.join(configDir, config.root ?? "./");
|
|
113
|
-
const relativeConfigPath = path.relative(root, configPath);
|
|
114
|
-
const apiClient = await apiService();
|
|
115
|
-
const projectTar = await createProjectTar(root);
|
|
116
|
-
const result = await apiClient.publish.publishCli({
|
|
117
|
-
tarStream: Readable.toWeb(projectTar),
|
|
118
|
-
slug,
|
|
119
|
-
configPath: relativeConfigPath,
|
|
120
|
-
mode
|
|
121
|
-
});
|
|
122
|
-
if (result.error)
|
|
123
|
-
return {
|
|
124
|
-
success: false,
|
|
125
|
-
error: result.originalError ?? result.message
|
|
126
|
-
};
|
|
127
|
-
return { success: true, publishUid: result.data.publishUid };
|
|
128
|
-
} catch (e) {
|
|
129
|
-
return { success: false, error: e };
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
async function publishUnifiedDocsProjectFromGithub({
|
|
133
|
-
slug,
|
|
134
|
-
preview,
|
|
135
|
-
apiClient
|
|
136
|
-
}) {
|
|
137
|
-
const result = await apiClient.publish.publishDocsProject({
|
|
138
|
-
slug,
|
|
139
|
-
preview
|
|
140
|
-
});
|
|
141
|
-
if (result.error) {
|
|
142
|
-
return {
|
|
143
|
-
success: false,
|
|
144
|
-
error: result.message
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
success: true,
|
|
149
|
-
publishUid: result.data.publishUid
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// src/helpers/utils.ts
|
|
154
|
-
var sleep = (ms) => {
|
|
155
|
-
return new Promise((resolve) => {
|
|
156
|
-
setTimeout(resolve, ms);
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
// src/domains/project/publish/action.ts
|
|
161
|
-
async function publishAction(args) {
|
|
162
|
-
const argsParseResult = zod_default.object({
|
|
163
|
-
slug: slugSchema,
|
|
164
|
-
config: zod_default.string().optional(),
|
|
165
|
-
preview: zod_default.coerce.boolean().default(false),
|
|
166
|
-
github: zod_default.coerce.boolean().default(false)
|
|
167
|
-
}).safeParse(args);
|
|
168
|
-
if (argsParseResult.error)
|
|
169
|
-
return output.error().title("Invalid Arguments").message(argsParseResult.error.issues[0].message).exit("error");
|
|
170
|
-
const {
|
|
171
|
-
config: configPathOption,
|
|
172
|
-
slug,
|
|
173
|
-
preview,
|
|
174
|
-
github
|
|
175
|
-
} = argsParseResult.data;
|
|
176
|
-
const apiClient = await apiService();
|
|
177
|
-
const auth = await getAuthData();
|
|
178
|
-
auth.addEventListener((state) => Object.assign(auth, state));
|
|
179
|
-
if (!slug) {
|
|
180
|
-
return output.error().title("Invalid argument").message("Slug is required. Try passing --slug flag.").exit("error");
|
|
181
|
-
}
|
|
182
|
-
if (github) {
|
|
183
|
-
const resolved = await resolveProject(slug, apiClient);
|
|
184
|
-
if (resolved.kind === "not-found") {
|
|
185
|
-
return output.error().title("Project not found").message(`No project with slug "${slug}" was found for your team.`).exit("error");
|
|
186
|
-
}
|
|
187
|
-
if (resolved.kind === "github") {
|
|
188
|
-
if (!resolved.project.repository) {
|
|
189
|
-
return output.error().title("Your project is not linked to a GitHub repository").message(
|
|
190
|
-
"For a sync publish, please configure your GitHub connection through the dashboard."
|
|
191
|
-
).exit("error");
|
|
192
|
-
}
|
|
193
|
-
if (resolved.project.repository.expired) {
|
|
194
|
-
return output.error().title("Your GitHub repository access is expired.").message(
|
|
195
|
-
"Please reconnect your project through the Scalar Dashboard to publish via sync."
|
|
196
|
-
).exit("error");
|
|
197
|
-
}
|
|
198
|
-
const publishResult3 = await publishGithub({ apiClient, slug, preview });
|
|
199
|
-
if (!publishResult3.success) {
|
|
200
|
-
return output.error().title("Could not publish sync project.").message(publishResult3.error).exit("error");
|
|
201
|
-
}
|
|
202
|
-
return await waitForPublish({
|
|
203
|
-
teamUid: auth.teamUid,
|
|
204
|
-
publishUid: publishResult3.publishUid
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
if (!isGithubBackedDocsProject(resolved.project)) {
|
|
208
|
-
return output.error().title("Your project is not linked to a GitHub repository").message(
|
|
209
|
-
"For a sync publish, please configure your GitHub connection through the dashboard."
|
|
210
|
-
).exit("error");
|
|
211
|
-
}
|
|
212
|
-
if (resolved.project.repository.expired) {
|
|
213
|
-
return output.error().title("Your GitHub repository access is expired.").message(
|
|
214
|
-
"Please reconnect your project through the Scalar Dashboard to publish via sync."
|
|
215
|
-
).exit("error");
|
|
216
|
-
}
|
|
217
|
-
const publishResult2 = await publishUnifiedDocsProjectFromGithub({
|
|
218
|
-
apiClient,
|
|
219
|
-
slug,
|
|
220
|
-
preview
|
|
221
|
-
});
|
|
222
|
-
if (!publishResult2.success) {
|
|
223
|
-
return output.error().title("Could not publish sync project.").message(publishResult2.error).exit("error");
|
|
224
|
-
}
|
|
225
|
-
return await waitForPublish({
|
|
226
|
-
teamUid: auth.teamUid,
|
|
227
|
-
publishUid: publishResult2.publishUid
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
const configResult = readAndParseConfig(configPathOption ?? "");
|
|
231
|
-
if (!configResult.success) {
|
|
232
|
-
renderConfigError(configResult.error);
|
|
233
|
-
}
|
|
234
|
-
const { config, filePath: configPath } = configResult;
|
|
235
|
-
const publishResult = await publishProject({
|
|
236
|
-
config,
|
|
237
|
-
slug,
|
|
238
|
-
configDir: dirname(configPath),
|
|
239
|
-
configPath,
|
|
240
|
-
...preview && { mode: "preview" }
|
|
241
|
-
});
|
|
242
|
-
if (!publishResult.success) {
|
|
243
|
-
return output.error().title("Something went wrong while deploying the project").message(
|
|
244
|
-
publishResult.error instanceof Error ? publishResult.error.message : publishResult.error
|
|
245
|
-
).exit("error");
|
|
246
|
-
}
|
|
247
|
-
return await waitForPublish({
|
|
248
|
-
teamUid: auth.teamUid,
|
|
249
|
-
publishUid: publishResult.publishUid
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
async function waitForPublish({
|
|
253
|
-
teamUid,
|
|
254
|
-
publishUid
|
|
255
|
-
}) {
|
|
256
|
-
const dbClient = await getDatabaseClient();
|
|
257
|
-
const logger = output.info({ animate: true }).loader("Deployment in progress");
|
|
258
|
-
while (true) {
|
|
259
|
-
const deployStatus = await getDeployStatus({
|
|
260
|
-
client: dbClient,
|
|
261
|
-
publishUid,
|
|
262
|
-
teamUid
|
|
263
|
-
});
|
|
264
|
-
if (deployStatus.error === true) {
|
|
265
|
-
return output.error().title(
|
|
266
|
-
"Something went wrong while getting information about the deployment"
|
|
267
|
-
).exit("error");
|
|
268
|
-
}
|
|
269
|
-
logger.update("loader", 0, { content: deployStatus.data.message });
|
|
270
|
-
if (deployStatus.data.status === "deployed") {
|
|
271
|
-
const deploymentUrl = getPublishDeploymentUrl(deployStatus.data);
|
|
272
|
-
if (deploymentUrl) {
|
|
273
|
-
output.info().line(
|
|
274
|
-
`${deployStatus.data.preview ? "Preview URL" : "Deployment URL"}: ${deploymentUrl}`
|
|
275
|
-
).print();
|
|
276
|
-
}
|
|
277
|
-
logger.exit("success");
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
if (deployStatus.data.status === "error") {
|
|
281
|
-
logger.exit("error");
|
|
282
|
-
}
|
|
283
|
-
await sleep(3e3);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
async function getDeployStatus({
|
|
287
|
-
client,
|
|
288
|
-
publishUid,
|
|
289
|
-
teamUid
|
|
290
|
-
}) {
|
|
291
|
-
return client.getOne({
|
|
292
|
-
collectionPath: `team/${teamUid}/publish`,
|
|
293
|
-
schema: publishRecordSchema,
|
|
294
|
-
query: { uid: publishUid }
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
export {
|
|
298
|
-
publishAction
|
|
299
|
-
};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
measureTime
|
|
4
|
-
} from "./chunk-KHDYYVYF.js";
|
|
5
|
-
import "./chunk-23I5PKZZ.js";
|
|
6
|
-
import {
|
|
7
|
-
external_exports
|
|
8
|
-
} from "./chunk-H2WRMLYY.js";
|
|
9
|
-
import {
|
|
10
|
-
require_dist
|
|
11
|
-
} from "./chunk-K74E42RV.js";
|
|
12
|
-
import {
|
|
13
|
-
isYamlFileName
|
|
14
|
-
} from "./chunk-IX7LJ3AD.js";
|
|
15
|
-
import {
|
|
16
|
-
output
|
|
17
|
-
} from "./chunk-X4QLDBB5.js";
|
|
18
|
-
import {
|
|
19
|
-
__toESM
|
|
20
|
-
} from "./chunk-3MZYUBJ6.js";
|
|
21
|
-
|
|
22
|
-
// src/domains/document/join/action.ts
|
|
23
|
-
var import_yaml = __toESM(require_dist(), 1);
|
|
24
|
-
import fs from "node:fs/promises";
|
|
25
|
-
import as from "ansis";
|
|
26
|
-
import { join, normalize } from "@scalar/openapi-parser";
|
|
27
|
-
|
|
28
|
-
// src/domains/document/join/helpers.ts
|
|
29
|
-
var getValueByPath = (input, path) => {
|
|
30
|
-
return path.reduce((acc, segment) => {
|
|
31
|
-
if (acc && typeof acc === "object" && acc !== null && segment in acc) {
|
|
32
|
-
return acc[segment];
|
|
33
|
-
}
|
|
34
|
-
return void 0;
|
|
35
|
-
}, input);
|
|
36
|
-
};
|
|
37
|
-
var getPrefixes = (documents, path) => {
|
|
38
|
-
const segments = path.split(".");
|
|
39
|
-
return documents.map((doc) => {
|
|
40
|
-
const value = getValueByPath(doc, segments);
|
|
41
|
-
if (value === void 0) {
|
|
42
|
-
return "";
|
|
43
|
-
}
|
|
44
|
-
return String(value);
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// src/domains/document/join/action.ts
|
|
49
|
-
var formatErrorMessage = (conflicts) => {
|
|
50
|
-
return conflicts.map((conflict) => {
|
|
51
|
-
if (conflict.type === "component") {
|
|
52
|
-
return `Component '/${conflict.componentType}/${conflict.name}' has conflicts`;
|
|
53
|
-
}
|
|
54
|
-
if (conflict.type === "path") {
|
|
55
|
-
return `Path '${conflict.path} ${conflict.method}' has conflicts`;
|
|
56
|
-
}
|
|
57
|
-
return `Webhook '${conflict.path} ${conflict.method}' has conflicts`;
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
async function joinAction(rawInput, rawOpt) {
|
|
61
|
-
const { error, data: input } = external_exports.array(external_exports.string()).safeParse(rawInput);
|
|
62
|
-
if (error) {
|
|
63
|
-
return output.error().title("Invalid input").message(error.issues[0].message).exit("error");
|
|
64
|
-
}
|
|
65
|
-
const { error: optsError, data: opts } = external_exports.object({
|
|
66
|
-
output: external_exports.string(),
|
|
67
|
-
prefixComponentsWithPathValue: external_exports.string().optional()
|
|
68
|
-
}).safeParse(rawOpt);
|
|
69
|
-
if (optsError) {
|
|
70
|
-
return output.error().title("Invalid options").line("").line(
|
|
71
|
-
optsError.issues.map((e) => `${e.message} property: '${e.path}'`).join("\n")
|
|
72
|
-
).line("").exit("error");
|
|
73
|
-
}
|
|
74
|
-
const files = (await Promise.all(input.map((file) => fs.readFile(file, "utf-8")))).map((it) => normalize(it));
|
|
75
|
-
const prefixes = opts.prefixComponentsWithPathValue ? getPrefixes(files, opts.prefixComponentsWithPathValue) : [];
|
|
76
|
-
const { executionTimeMs, result } = await measureTime(
|
|
77
|
-
() => join(files, { prefixComponents: prefixes })
|
|
78
|
-
);
|
|
79
|
-
if (!result.ok) {
|
|
80
|
-
return output.error().title("Failed to join OpenAPI documents").line().line(`Conflicts:
|
|
81
|
-
${formatErrorMessage(result.conflicts).join("\n")}`).line().exit("error");
|
|
82
|
-
}
|
|
83
|
-
const isYaml = isYamlFileName(opts.output);
|
|
84
|
-
await fs.writeFile(
|
|
85
|
-
opts.output,
|
|
86
|
-
isYaml ? import_yaml.default.stringify(result.document) : JSON.stringify(result.document, null, 2),
|
|
87
|
-
"utf8"
|
|
88
|
-
);
|
|
89
|
-
output.info().message(
|
|
90
|
-
`${as.green("\u{1F91D} OpenAPI Documents joined")} in ${as.white(`${as.bold(`${Math.round(executionTimeMs)}`)} ms`)}`
|
|
91
|
-
).print();
|
|
92
|
-
}
|
|
93
|
-
export {
|
|
94
|
-
joinAction
|
|
95
|
-
};
|