@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.
Files changed (88) hide show
  1. package/README.md +28 -24
  2. package/chunks/{action-CYP4VDK3.js → action-37EV4UHW.js} +12 -35
  3. package/chunks/{action-MENXFJH3.js → action-4XI7XJR4.js} +9 -9
  4. package/chunks/{action-H5OHT2GV.js → action-5IU77OII.js} +7 -3
  5. package/chunks/{action-STIEAXOE.js → action-B3KKREWQ.js} +16 -5
  6. package/chunks/{action-BYZUBXVB.js → action-CH24QGTE.js} +8 -4
  7. package/chunks/action-F3UX5E3M.js +522 -0
  8. package/chunks/{action-GB6DM53B.js → action-FDB7NEOK.js} +21 -10
  9. package/chunks/action-FIXBOJEW.js +244 -0
  10. package/chunks/{action-DFKHSDFV.js → action-G26LSVZ7.js} +7 -3
  11. package/chunks/{action-Q5UJ32D6.js → action-H3RTILLM.js} +1 -1
  12. package/chunks/{action-GEBRPNRT.js → action-HGBBV353.js} +15 -16
  13. package/chunks/{action-5R5FDF6S.js → action-IUE4IOWO.js} +67 -22
  14. package/chunks/{action-TPBKPHNS.js → action-JZLZ7ZAD.js} +22 -22
  15. package/chunks/action-LA6KVAXQ.js +374 -0
  16. package/chunks/{action-PVDDRIM6.js → action-M7RQKBSB.js} +65 -26
  17. package/chunks/{action-F4Y6Q2VB.js → action-MSLBC2SO.js} +21 -21
  18. package/chunks/{action-BNEGJBUH.js → action-NVSZT2ZD.js} +8 -9
  19. package/chunks/{action-ANU5HGC4.js → action-OGQSTRMX.js} +17 -14
  20. package/chunks/{action-CLSD7O2R.js → action-PAGJ5PWC.js} +10 -10
  21. package/chunks/action-QE2ZQQX7.js +250 -0
  22. package/chunks/{action-HD2T6BFJ.js → action-QPUSPD5M.js} +10 -10
  23. package/chunks/{action-45OGQB2M.js → action-R7IMFHQ5.js} +17 -8
  24. package/chunks/{action-UDZUUJSI.js → action-SH4UUXPL.js} +18 -7
  25. package/chunks/action-SNLCIBQC.js +84 -0
  26. package/chunks/{action-C5VB4ITT.js → action-SQG3JAII.js} +36 -18
  27. package/chunks/action-UZQJNYK4.js +18 -0
  28. package/chunks/{action-HNKM3Q65.js → action-VC4DCVST.js} +17 -14
  29. package/chunks/{action-BMFXENMX.js → action-VTVFY2MP.js} +39 -34
  30. package/chunks/{action-TZ5KGAQT.js → action-WFWYGY7O.js} +17 -14
  31. package/chunks/{action-W5BATF4Q.js → action-XMNX5ZYT.js} +24 -24
  32. package/chunks/{agent-XGLOHXNA.js → agent-HCQRMHQ5.js} +25 -5
  33. package/chunks/asyncapi-QM76O55R.js +105 -0
  34. package/chunks/{build.action-LKOILPA6.js → build.action-P7FCIMYU.js} +22 -22
  35. package/chunks/{chunk-23I5PKZZ.js → chunk-24WAOKGG.js} +32 -5
  36. package/chunks/chunk-3L6DLIXJ.js +25530 -0
  37. package/chunks/chunk-3ZJYGGAA.js +30 -0
  38. package/chunks/{chunk-ZTVWAKNJ.js → chunk-4NHMAG6F.js} +1 -1
  39. package/chunks/{chunk-IX7LJ3AD.js → chunk-4ORL4MST.js} +2 -3
  40. package/chunks/{chunk-OAXFCOJV.js → chunk-4ZDQXWBT.js} +2 -1
  41. package/chunks/{chunk-ASMHW5AY.js → chunk-6ZMT63IV.js} +1 -1
  42. package/chunks/{chunk-P2VH7DOC.js → chunk-7AGLC7WV.js} +6 -6
  43. package/chunks/{chunk-SXYALPYK.js → chunk-AO3F5XWR.js} +498 -60
  44. package/chunks/{chunk-B6QZJWCQ.js → chunk-B2MHTD3R.js} +4 -6
  45. package/chunks/{chunk-4QS7SJTG.js → chunk-CISTON3A.js} +51 -36
  46. package/chunks/chunk-COBPBRQF.js +25 -0
  47. package/chunks/{chunk-2BSG2QHO.js → chunk-F467BYYR.js} +133 -20
  48. package/chunks/{chunk-TLFMATXR.js → chunk-GSGZHE26.js} +33 -25
  49. package/chunks/{chunk-UPUTMFD4.js → chunk-HCPN3KNF.js} +185 -13
  50. package/chunks/{chunk-P646T2WH.js → chunk-HPL3ZZ2P.js} +131 -13
  51. package/chunks/{chunk-H2WRMLYY.js → chunk-IKT5F47M.js} +3571 -7
  52. package/chunks/{chunk-AHWWJ3MD.js → chunk-K4DTP5TV.js} +1 -1
  53. package/chunks/{chunk-TQ5XC2E3.js → chunk-LFU5ZUAP.js} +77 -11
  54. package/chunks/{chunk-5BISXQX4.js → chunk-M37TP6U2.js} +11 -13
  55. package/chunks/chunk-OQKDBLOZ.js +741 -0
  56. package/chunks/chunk-P7H7GY5A.js +14 -0
  57. package/chunks/{chunk-47Y4L5IT.js → chunk-PBXZN65A.js} +1031 -481
  58. package/chunks/{chunk-HQKBZOYU.js → chunk-PT5TI77I.js} +3 -3
  59. package/chunks/chunk-Q7DOQHZN.js +404 -0
  60. package/chunks/{chunk-X4QLDBB5.js → chunk-T5HJUAWB.js} +24 -3
  61. package/chunks/{chunk-NUXPNUSS.js → chunk-UGGNHILG.js} +1 -1
  62. package/chunks/{chunk-4DGQIAJX.js → chunk-VNYE4R7N.js} +154 -14
  63. package/chunks/{chunk-KWOL7A6J.js → chunk-X5T526CE.js} +2 -2
  64. package/chunks/chunk-XCSR4RIT.js +210 -0
  65. package/chunks/{chunk-SHSHFGA7.js → chunk-Z2KMGFE6.js} +4 -6
  66. package/chunks/{create.action-FFQLBSJH.js → create.action-HDD2WUON.js} +22 -22
  67. package/chunks/{delete.action-STHQHP4F.js → delete.action-7GOZY7ID.js} +22 -22
  68. package/chunks/{delete.action-QNN3LC2F.js → delete.action-VE66JFDS.js} +22 -22
  69. package/chunks/{get.action-OTKYOP3Z.js → get.action-2745EB4N.js} +15 -16
  70. package/chunks/{list.action-KDM5RHEH.js → list.action-3VTXQJRA.js} +19 -19
  71. package/chunks/{list.action-6I5EZAVB.js → list.action-4QDCZLSZ.js} +22 -22
  72. package/chunks/{publish.action-PODTVRXS.js → publish.action-ULQLZKWU.js} +44 -36
  73. package/chunks/{update.action-KMD4ZM75.js → update.action-6QEFP7NA.js} +22 -22
  74. package/chunks/{update.action-4F6STTEQ.js → update.action-OROQSP2S.js} +22 -22
  75. package/docs.html +104 -103
  76. package/index.js +84 -68
  77. package/package.json +16 -12
  78. package/chunks/action-CCW66QJN.js +0 -72
  79. package/chunks/action-CQ56FVES.js +0 -65
  80. package/chunks/action-JOSVV6YA.js +0 -71
  81. package/chunks/action-P7LN6FGY.js +0 -13
  82. package/chunks/action-R6ZZO26F.js +0 -299
  83. package/chunks/action-TWFJNQ2R.js +0 -95
  84. package/chunks/chunk-5BPPGTUU.js +0 -463
  85. package/chunks/chunk-DOVIWNKQ.js +0 -108
  86. package/chunks/chunk-ISGLWBXZ.js +0 -4265
  87. package/chunks/chunk-T7MDADON.js +0 -17
  88. package/chunks/chunk-VTYTPSXO.js +0 -161
@@ -0,0 +1,244 @@
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 {
6
+ isAsyncApiDocument,
7
+ isDocument
8
+ } from "./chunk-24WAOKGG.js";
9
+ import "./chunk-CISTON3A.js";
10
+ import "./chunk-Q7DOQHZN.js";
11
+ import {
12
+ isUrl
13
+ } from "./chunk-4ORL4MST.js";
14
+ import {
15
+ output
16
+ } from "./chunk-T5HJUAWB.js";
17
+ import "./chunk-GSGZHE26.js";
18
+ import "./chunk-IKT5F47M.js";
19
+ import "./chunk-3MZYUBJ6.js";
20
+
21
+ // src/domains/document/split/action.ts
22
+ import fs2 from "node:fs/promises";
23
+ import path2 from "node:path";
24
+ import { text } from "@clack/prompts";
25
+ import as from "ansis";
26
+ import { bundle } from "@scalar/json-magic/bundle";
27
+ import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
28
+ import {
29
+ createServerWorkspaceStore,
30
+ WORKSPACE_FILE_NAME
31
+ } from "@scalar/workspace-store/server";
32
+
33
+ // src/domains/document/split/split-asyncapi.ts
34
+ import { createHash } from "node:crypto";
35
+ import fs from "node:fs/promises";
36
+ import path from "node:path";
37
+ import { extensions } from "@scalar/json-magic/bundle";
38
+ import { escapeJsonPointer } from "@scalar/json-magic/helpers/escape-json-pointer";
39
+ async function splitAsyncApi(document, outputPath) {
40
+ const chunks = /* @__PURE__ */ new Map();
41
+ const root = structuredClone(document);
42
+ const segmentNames = /* @__PURE__ */ new Map();
43
+ const usedNames = /* @__PURE__ */ new Set();
44
+ const shorten = (name) => name.length <= 240 ? name : `${name.slice(0, 170)}~5${createHash("sha256").update(name).digest("hex")}`;
45
+ const getFilePath = (segments) => {
46
+ const names = [];
47
+ for (const segment of segments) {
48
+ const directory = names.join("/");
49
+ const key = JSON.stringify([directory, segment]);
50
+ const existing = segmentNames.get(key);
51
+ if (existing !== void 0) {
52
+ names.push(existing);
53
+ continue;
54
+ }
55
+ const escaped = shorten(
56
+ encodeURIComponent(escapeJsonPointer(segment)).replaceAll("%", "~2").replaceAll(".", "~3").replaceAll("*", "~6") || "~7"
57
+ );
58
+ const name = shorten(
59
+ usedNames.has(`${directory}/${escaped}`.toLowerCase()) || /^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(escaped) ? escaped.replace(
60
+ /[a-z]/gi,
61
+ (letter) => `~4${letter.charCodeAt(0).toString(16)}`
62
+ ) : escaped
63
+ );
64
+ segmentNames.set(key, name);
65
+ usedNames.add(`${directory}/${name}`.toLowerCase());
66
+ names.push(name);
67
+ }
68
+ return `chunks/default/${names.join("/")}.json`;
69
+ };
70
+ const extract = (parent, key, segments) => {
71
+ const pointer = `#/${segments.map(escapeJsonPointer).join("/")}`;
72
+ const file = getFilePath(segments);
73
+ chunks.set(pointer, { file, value: parent[key] });
74
+ parent[key] = {
75
+ $ref: `#/${segments.map((segment) => encodeURIComponent(escapeJsonPointer(segment))).join("/")}`
76
+ };
77
+ };
78
+ const extractMap = (value, segments) => {
79
+ if (!isDocument(value)) {
80
+ return;
81
+ }
82
+ for (const key of Object.keys(value)) {
83
+ extract(value, key, [...segments, key]);
84
+ }
85
+ };
86
+ const resolveChannel = (value, seen = /* @__PURE__ */ new Set()) => {
87
+ if (!isDocument(value) || typeof value.$ref !== "string" || !value.$ref.startsWith("#/") || seen.has(value.$ref)) {
88
+ return value;
89
+ }
90
+ seen.add(value.$ref);
91
+ const segments = decodeURIComponent(value.$ref.slice(2)).split("/").map((segment) => segment.replaceAll("~1", "/").replaceAll("~0", "~"));
92
+ const target = segments.reduce(
93
+ (node, segment) => isDocument(node) && Object.hasOwn(node, segment) ? node[segment] : void 0,
94
+ root
95
+ );
96
+ const resolved = resolveChannel(target, seen);
97
+ if (!isDocument(resolved)) {
98
+ return value;
99
+ }
100
+ const { $ref: _ref, ...siblings } = value;
101
+ return { ...resolved, ...siblings };
102
+ };
103
+ if (isDocument(root.channels)) {
104
+ for (const [name, value] of Object.entries(root.channels)) {
105
+ const channel = structuredClone(resolveChannel(value));
106
+ if (!isDocument(channel)) {
107
+ continue;
108
+ }
109
+ root.channels[name] = channel;
110
+ extractMap(channel.messages, ["channels", name, "messages"]);
111
+ for (const method of ["publish", "subscribe"]) {
112
+ if (isDocument(channel[method])) {
113
+ if (isDocument(channel[method].message)) {
114
+ extract(channel[method], "message", [
115
+ "channels",
116
+ name,
117
+ method,
118
+ "message"
119
+ ]);
120
+ }
121
+ extract(channel, method, ["channels", name, method]);
122
+ }
123
+ }
124
+ }
125
+ }
126
+ extractMap(root.channels, ["channels"]);
127
+ extractMap(root.operations, ["operations"]);
128
+ if (isDocument(root.components)) {
129
+ for (const [type, entries] of Object.entries(root.components)) {
130
+ if (!type.startsWith("x-")) {
131
+ extractMap(entries, ["components", type]);
132
+ }
133
+ }
134
+ }
135
+ if (isDocument(root[extensions.externalDocuments])) {
136
+ extractMap(root[extensions.externalDocuments], [
137
+ extensions.externalDocuments
138
+ ]);
139
+ extract(root, extensions.externalDocuments, [extensions.externalDocuments]);
140
+ delete root[extensions.externalDocuments];
141
+ delete root[extensions.externalDocumentsMappings];
142
+ }
143
+ const pointers = [...chunks.keys()].sort((a, b) => b.length - a.length);
144
+ const rebase = (value, sourceFile) => {
145
+ if (Array.isArray(value)) {
146
+ return value.map((entry) => rebase(entry, sourceFile));
147
+ }
148
+ if (!isDocument(value)) {
149
+ return value;
150
+ }
151
+ return Object.fromEntries(
152
+ Object.entries(value).map(([key, entry]) => {
153
+ if (key !== "$ref" || typeof entry !== "string" || !entry.startsWith("#")) {
154
+ return [key, rebase(entry, sourceFile)];
155
+ }
156
+ const pointer = decodeURIComponent(entry);
157
+ const target = pointers.find(
158
+ (candidate) => pointer === candidate || pointer.startsWith(`${candidate}/`)
159
+ );
160
+ const targetFile = target && chunks.get(target)?.file || "out.json";
161
+ const fragment = target ? `#${pointer.slice(target.length)}` : pointer;
162
+ const relativeFile = path.posix.relative(
163
+ path.posix.dirname(sourceFile),
164
+ targetFile
165
+ );
166
+ return [
167
+ key,
168
+ `${relativeFile.split("/").map(encodeURIComponent).join("/")}#${fragment.slice(1).split("/").map(encodeURIComponent).join("/")}`
169
+ ];
170
+ })
171
+ );
172
+ };
173
+ for (const { file, value } of [
174
+ ...chunks.values(),
175
+ { file: "out.json", value: root }
176
+ ]) {
177
+ const destination = path.join(outputPath, file);
178
+ await fs.mkdir(path.dirname(destination), { recursive: true });
179
+ await fs.writeFile(destination, JSON.stringify(rebase(value, file)));
180
+ }
181
+ }
182
+
183
+ // src/domains/document/split/action.ts
184
+ async function splitAction(input, { output: __outputPath }) {
185
+ if (!input) {
186
+ return output.error().title("Missing input").message("Please provide a file path or URL to split").exit("error");
187
+ }
188
+ const getOutputPath = async () => {
189
+ if (__outputPath !== void 0 && typeof __outputPath === "string") {
190
+ return __outputPath;
191
+ }
192
+ const outputPath2 = await text({
193
+ message: "Where should the chunks be written?",
194
+ defaultValue: "./assets",
195
+ placeholder: "./assets"
196
+ });
197
+ if (typeof outputPath2 !== "string") {
198
+ return output.error().message("Operation cancelled by user").exit("error");
199
+ }
200
+ return outputPath2;
201
+ };
202
+ const outputPath = await getOutputPath();
203
+ const document = await bundle(isUrl(input) ? input : path2.resolve(input), {
204
+ plugins: [readFiles(), fetchUrls()],
205
+ treeShake: false,
206
+ hooks: {
207
+ onResolveError: ({ $ref }) => {
208
+ throw new Error(`Could not resolve reference: ${$ref}`);
209
+ }
210
+ }
211
+ }).catch(() => null);
212
+ if (!isDocument(document)) {
213
+ return output.error().title("Invalid input").message(
214
+ "Could not read an OpenAPI or AsyncAPI document from the input. Please provide a valid JSON or YAML file."
215
+ ).exit("error");
216
+ }
217
+ const { executionTimeMs } = await measureTime(async () => {
218
+ if (isAsyncApiDocument(document)) {
219
+ await splitAsyncApi(document, outputPath);
220
+ return;
221
+ }
222
+ const documentName = "default";
223
+ const store = await createServerWorkspaceStore({
224
+ mode: "static",
225
+ documents: [{ name: documentName, document }],
226
+ // The workspace writer prefixes its directory with cwd, including absolute paths.
227
+ directory: path2.relative(process.cwd(), path2.resolve(outputPath)) || "."
228
+ });
229
+ await store.generateWorkspaceChunks();
230
+ const workspaceFilePath = path2.join(outputPath, WORKSPACE_FILE_NAME);
231
+ const sparseDocument = JSON.parse(
232
+ await fs2.readFile(workspaceFilePath, { encoding: "utf-8" })
233
+ );
234
+ await fs2.writeFile(
235
+ path2.join(outputPath, "out.json"),
236
+ JSON.stringify(sparseDocument.documents[documentName])
237
+ );
238
+ await fs2.rm(workspaceFilePath);
239
+ });
240
+ output.info().line().title(as.green("Document Split Successfully! \u{1F389}")).line().message(`\u2728 Chunks have been generated at: ${as.blue(outputPath)}`).line(`\u23F1\uFE0F Split completed in ${as.yellow(executionTimeMs.toFixed(2))}ms`).line("").print();
241
+ }
242
+ export {
243
+ splitAction
244
+ };
@@ -1,11 +1,15 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  getFileOrUrl
4
- } from "./chunk-23I5PKZZ.js";
5
- import "./chunk-IX7LJ3AD.js";
4
+ } from "./chunk-24WAOKGG.js";
5
+ import "./chunk-CISTON3A.js";
6
+ import "./chunk-Q7DOQHZN.js";
7
+ import "./chunk-4ORL4MST.js";
6
8
  import {
7
9
  output
8
- } from "./chunk-X4QLDBB5.js";
10
+ } from "./chunk-T5HJUAWB.js";
11
+ import "./chunk-GSGZHE26.js";
12
+ import "./chunk-IKT5F47M.js";
9
13
  import "./chunk-3MZYUBJ6.js";
10
14
 
11
15
  // src/domains/document/markdown/action.ts
@@ -1,7 +1,7 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  output
4
- } from "./chunk-X4QLDBB5.js";
4
+ } from "./chunk-T5HJUAWB.js";
5
5
  import "./chunk-3MZYUBJ6.js";
6
6
 
7
7
  // src/domains/document/void/action.ts
@@ -1,29 +1,28 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  fetchFromRegistry
4
- } from "./chunk-NUXPNUSS.js";
5
- import "./chunk-T7MDADON.js";
4
+ } from "./chunk-UGGNHILG.js";
5
+ import "./chunk-COBPBRQF.js";
6
6
  import {
7
7
  registry
8
- } from "./chunk-DOVIWNKQ.js";
9
- import "./chunk-4QS7SJTG.js";
10
- import "./chunk-VTYTPSXO.js";
8
+ } from "./chunk-XCSR4RIT.js";
11
9
  import {
12
10
  getAuthData
13
- } from "./chunk-5BISXQX4.js";
14
- import "./chunk-OAXFCOJV.js";
15
- import "./chunk-TLFMATXR.js";
16
- import "./chunk-4DGQIAJX.js";
11
+ } from "./chunk-M37TP6U2.js";
12
+ import "./chunk-4ZDQXWBT.js";
13
+ import "./chunk-VNYE4R7N.js";
14
+ import "./chunk-OQKDBLOZ.js";
15
+ import "./chunk-CISTON3A.js";
16
+ import "./chunk-Q7DOQHZN.js";
17
+ import "./chunk-4ORL4MST.js";
17
18
  import {
18
- docVersionSchema
19
- } from "./chunk-ISGLWBXZ.js";
19
+ output
20
+ } from "./chunk-T5HJUAWB.js";
21
+ import "./chunk-GSGZHE26.js";
20
22
  import {
23
+ docVersionSchema,
21
24
  external_exports
22
- } from "./chunk-H2WRMLYY.js";
23
- import "./chunk-IX7LJ3AD.js";
24
- import {
25
- output
26
- } from "./chunk-X4QLDBB5.js";
25
+ } from "./chunk-IKT5F47M.js";
27
26
  import "./chunk-3MZYUBJ6.js";
28
27
 
29
28
  // src/domains/registry/get/action.ts
@@ -6,19 +6,34 @@ import {
6
6
  findConfig,
7
7
  getCurrentFolderName,
8
8
  scalarConfigSchema
9
- } from "./chunk-47Y4L5IT.js";
10
- import "./chunk-5BPPGTUU.js";
11
- import "./chunk-4QS7SJTG.js";
12
- import "./chunk-VTYTPSXO.js";
13
- import "./chunk-TLFMATXR.js";
9
+ } from "./chunk-PBXZN65A.js";
14
10
  import {
15
- slugify
16
- } from "./chunk-ISGLWBXZ.js";
17
- import "./chunk-H2WRMLYY.js";
11
+ apiService
12
+ } from "./chunk-AO3F5XWR.js";
13
+ import "./chunk-HCPN3KNF.js";
14
+ import "./chunk-B2MHTD3R.js";
15
+ import "./chunk-3L6DLIXJ.js";
16
+ import "./chunk-P7H7GY5A.js";
17
+ import "./chunk-HPL3ZZ2P.js";
18
+ import {
19
+ getMetadata
20
+ } from "./chunk-M37TP6U2.js";
21
+ import {
22
+ config
23
+ } from "./chunk-4ZDQXWBT.js";
24
+ import "./chunk-VNYE4R7N.js";
25
+ import "./chunk-OQKDBLOZ.js";
18
26
  import "./chunk-K74E42RV.js";
27
+ import "./chunk-CISTON3A.js";
28
+ import "./chunk-Q7DOQHZN.js";
29
+ import "./chunk-4ORL4MST.js";
19
30
  import {
20
31
  output
21
- } from "./chunk-X4QLDBB5.js";
32
+ } from "./chunk-T5HJUAWB.js";
33
+ import "./chunk-GSGZHE26.js";
34
+ import {
35
+ slugify
36
+ } from "./chunk-IKT5F47M.js";
22
37
  import "./chunk-3MZYUBJ6.js";
23
38
 
24
39
  // src/domains/project/init/action.ts
@@ -27,13 +42,13 @@ import path from "node:path";
27
42
  import { cancel, confirm, isCancel, text } from "@clack/prompts";
28
43
  import as from "ansis";
29
44
 
30
- // ../../node_modules/.pnpm/@scalar+galaxy@0.6.12/node_modules/@scalar/galaxy/dist/3.1.json
45
+ // ../../node_modules/.pnpm/@scalar+galaxy@0.7.0/node_modules/@scalar/galaxy/dist/3.1.json
31
46
  var __default = {
32
47
  openapi: "3.1.1",
33
48
  info: {
34
49
  title: "Scalar Galaxy",
35
50
  description: "The Scalar Galaxy is an example OpenAPI document to test OpenAPI tools and libraries. It's a fictional universe with fictional planets and fictional data.\n\n## Resources\n\n* https://github.com/scalar/scalar\n* https://github.com/OAI/OpenAPI-Specification\n* https://scalar.com\n\n## Markdown Support\n\nAll descriptions *can* contain ~~tons of text~~ **Markdown**. [If GitHub supports the syntax](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax), chances are we're supporting it, too.\n\n<details>\n <summary>Examples</summary>\n\n **Blockquotes**\n\n > I love OpenAPI. <3\n\n **Tables**\n\n | Feature | Availability |\n | ---------------- | ------------ |\n | Markdown Support | \u2713 |\n\n **Accordion**\n\n ```html\n <details>\n <summary>Using Details Tags</summary>\n <p>HTML Example</p>\n </details>\n ```\n\n **Images**\n\n Yes, there's support for images, too!\n\n ![Empty placeholder image showing the width/height](https://images.placeholders.dev/?width=1280&height=720)\n\n **Alerts**\n\n > [!tip]\n > You can use Markdown alerts in your descriptions.\n\n</details>\n",
36
- version: "0.6.12",
51
+ version: "0.7.0",
37
52
  contact: {
38
53
  name: "Scalar Support",
39
54
  url: "https://scalar.com",
@@ -1991,7 +2006,6 @@ async function initAction({
1991
2006
  force
1992
2007
  }) {
1993
2008
  const configFile = findConfig() || CONFIG_FILE_DEFAULT;
1994
- let validInput;
1995
2009
  const nextSteps = () => {
1996
2010
  output.info().line("What to do next:").line(
1997
2011
  ` ${as.cyan("scalar project preview")} to preview your project locally`
@@ -2053,26 +2067,57 @@ async function initAction({
2053
2067
  }
2054
2068
  }
2055
2069
  });
2056
- validInput = !!subdomain;
2070
+ const { auth } = await getMetadata();
2071
+ const apiClient = auth ? await apiService({ noExit: true }).catch(() => null) : void 0;
2072
+ if (!apiClient) {
2073
+ output.warn().message(
2074
+ "Subdomain availability was not checked. Run scalar auth login to check availability."
2075
+ ).print();
2076
+ }
2057
2077
  const folderName = getCurrentFolderName();
2058
- while (!validInput) {
2059
- const response = await text({
2078
+ const suppliedSubdomain = typeof subdomain === "string" ? subdomain.trim().toLowerCase() : void 0;
2079
+ if (subdomain !== void 0 && !suppliedSubdomain) {
2080
+ return output.error().message("Provide a name with --subdomain.").exit("error");
2081
+ }
2082
+ while (true) {
2083
+ const response = suppliedSubdomain ?? await text({
2060
2084
  message: "What is the name of your project?",
2061
2085
  defaultValue: folderName,
2062
2086
  placeholder: folderName
2063
2087
  });
2064
2088
  if (isCancel(response)) {
2065
- handleCancel();
2066
- } else {
2067
- validInput = true;
2089
+ return handleCancel();
2068
2090
  }
2069
2091
  const title = response.toString();
2070
- const slug = slugify(title);
2092
+ const slug = suppliedSubdomain ?? slugify(title);
2093
+ const validSubdomain = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(slug);
2094
+ if (!validSubdomain) {
2095
+ const message = "Use a subdomain with 1 to 63 letters, numbers, or hyphens, starting and ending with a letter or number.";
2096
+ if (suppliedSubdomain) {
2097
+ return output.error().message(message).exit("error");
2098
+ }
2099
+ output.error().message(message).print();
2100
+ continue;
2101
+ }
2102
+ if (apiClient) {
2103
+ const result = await apiClient.publish.getDomainAvailability(`${slug}.${config.publishTld}`).catch(() => null);
2104
+ if (!result || result.error) {
2105
+ return output.error().message("Could not check subdomain availability. Please try again.").exit("error");
2106
+ }
2107
+ if (!result.data.available) {
2108
+ const message = `Subdomain "${slug}" is already taken. Choose another name.`;
2109
+ if (suppliedSubdomain) {
2110
+ return output.error().message(message).exit("error");
2111
+ }
2112
+ output.error().message(message).print();
2113
+ continue;
2114
+ }
2115
+ }
2071
2116
  configuration.info = { title, description: `Documentation for ${title}` };
2072
- subdomain = slug;
2073
- output.info().line(`${as.green("\u2714")} Subdomain: ${as.green(subdomain)}`).print();
2117
+ configuration.siteConfig.subdomain = slug;
2118
+ output.info().line(`${as.green("\u2714")} Subdomain: ${as.green(slug)}`).print();
2119
+ break;
2074
2120
  }
2075
- configuration.siteConfig.subdomain = subdomain.trim();
2076
2121
  const content = JSON.stringify(configuration, null, 2);
2077
2122
  await fs.writeFile(configFile, content);
2078
2123
  await fs.writeFile(
@@ -1,7 +1,7 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  getProjectDeployments
4
- } from "./chunk-HQKBZOYU.js";
4
+ } from "./chunk-PT5TI77I.js";
5
5
  import {
6
6
  resolveProject
7
7
  } from "./chunk-T7B6WNZC.js";
@@ -10,33 +10,33 @@ import {
10
10
  } from "./chunk-AEFPCC4U.js";
11
11
  import {
12
12
  apiService
13
- } from "./chunk-SXYALPYK.js";
14
- import "./chunk-2BSG2QHO.js";
15
- import "./chunk-SHSHFGA7.js";
16
- import "./chunk-UPUTMFD4.js";
17
- import "./chunk-B6QZJWCQ.js";
18
- import "./chunk-5BPPGTUU.js";
19
- import "./chunk-P646T2WH.js";
20
- import "./chunk-4QS7SJTG.js";
21
- import "./chunk-VTYTPSXO.js";
13
+ } from "./chunk-AO3F5XWR.js";
14
+ import "./chunk-F467BYYR.js";
15
+ import "./chunk-Z2KMGFE6.js";
16
+ import "./chunk-HCPN3KNF.js";
17
+ import "./chunk-B2MHTD3R.js";
18
+ import "./chunk-3L6DLIXJ.js";
19
+ import "./chunk-P7H7GY5A.js";
20
+ import "./chunk-HPL3ZZ2P.js";
22
21
  import {
23
22
  getAuthData
24
- } from "./chunk-5BISXQX4.js";
25
- import "./chunk-OAXFCOJV.js";
26
- import "./chunk-TLFMATXR.js";
27
- import "./chunk-4DGQIAJX.js";
28
- import {
29
- slugSchema
30
- } from "./chunk-ISGLWBXZ.js";
31
- import {
32
- external_exports
33
- } from "./chunk-H2WRMLYY.js";
23
+ } from "./chunk-M37TP6U2.js";
24
+ import "./chunk-4ZDQXWBT.js";
25
+ import "./chunk-VNYE4R7N.js";
26
+ import "./chunk-OQKDBLOZ.js";
34
27
  import "./chunk-K74E42RV.js";
35
- import "./chunk-IX7LJ3AD.js";
28
+ import "./chunk-CISTON3A.js";
29
+ import "./chunk-Q7DOQHZN.js";
30
+ import "./chunk-4ORL4MST.js";
36
31
  import {
37
32
  output,
38
33
  printTable
39
- } from "./chunk-X4QLDBB5.js";
34
+ } from "./chunk-T5HJUAWB.js";
35
+ import "./chunk-GSGZHE26.js";
36
+ import {
37
+ external_exports,
38
+ slugSchema
39
+ } from "./chunk-IKT5F47M.js";
40
40
  import "./chunk-3MZYUBJ6.js";
41
41
 
42
42
  // src/domains/project/deployments/list/action.ts