@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
|
@@ -1,62 +1,69 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
registry
|
|
4
|
+
} from "./chunk-UFSFY7Z4.js";
|
|
2
5
|
import {
|
|
3
6
|
dashboardUrl,
|
|
4
7
|
registryUrl
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
registry
|
|
8
|
-
} from "./chunk-YILQODZF.js";
|
|
8
|
+
} from "./chunk-GYR5E6RB.js";
|
|
9
9
|
import {
|
|
10
10
|
getFileOrUrl,
|
|
11
|
-
isDocument
|
|
11
|
+
isDocument
|
|
12
|
+
} from "./chunk-4JKXZ5CF.js";
|
|
13
|
+
import {
|
|
12
14
|
safeNormalize
|
|
13
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QMLRYD76.js";
|
|
14
16
|
import {
|
|
15
17
|
DEFAULT_FETCH_CONCURRENCY
|
|
16
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-HZN6IIPZ.js";
|
|
19
|
+
import "./chunk-DFOZG7ZV.js";
|
|
17
20
|
import {
|
|
18
21
|
BaseCollections
|
|
19
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-NWJ37GI2.js";
|
|
20
23
|
import {
|
|
21
24
|
getDatabaseClient
|
|
22
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-U6VE6JOS.js";
|
|
23
26
|
import {
|
|
24
27
|
apiService
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
28
|
+
} from "./chunk-F3OPMYME.js";
|
|
29
|
+
import "./chunk-FG5AOTDN.js";
|
|
30
|
+
import "./chunk-SEURG74P.js";
|
|
31
|
+
import "./chunk-3TFOA64C.js";
|
|
32
|
+
import "./chunk-5ENKYZA4.js";
|
|
33
|
+
import "./chunk-Y6XGC4K5.js";
|
|
34
|
+
import "./chunk-SOV4POMS.js";
|
|
35
|
+
import "./chunk-T34TL6KL.js";
|
|
36
|
+
import "./chunk-V6LUKXBV.js";
|
|
37
|
+
import "./chunk-VUXPDHTQ.js";
|
|
31
38
|
import {
|
|
32
39
|
getAuthData
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import "./chunk-
|
|
40
|
+
} from "./chunk-3RIUDHLG.js";
|
|
41
|
+
import "./chunk-N5CJ5MTY.js";
|
|
42
|
+
import "./chunk-US54KYOJ.js";
|
|
35
43
|
import {
|
|
36
44
|
teamSchema
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import "./chunk-
|
|
45
|
+
} from "./chunk-BQYVSPAI.js";
|
|
46
|
+
import "./chunk-VRZSDUZK.js";
|
|
39
47
|
import {
|
|
40
48
|
requireInteractive
|
|
41
49
|
} from "./chunk-EGOXR5FB.js";
|
|
42
|
-
import "./chunk-K74E42RV.js";
|
|
43
|
-
import {
|
|
44
|
-
RegistryAsset
|
|
45
|
-
} from "./chunk-KCCFN4F7.js";
|
|
46
|
-
import "./chunk-6XWCMJDB.js";
|
|
47
50
|
import {
|
|
48
51
|
isUrl
|
|
49
52
|
} from "./chunk-4ORL4MST.js";
|
|
53
|
+
import {
|
|
54
|
+
RegistryAsset
|
|
55
|
+
} from "./chunk-MN2AFJXM.js";
|
|
50
56
|
import {
|
|
51
57
|
output
|
|
52
58
|
} from "./chunk-T5HJUAWB.js";
|
|
53
|
-
import "./chunk-
|
|
59
|
+
import "./chunk-25XERWCE.js";
|
|
60
|
+
import "./chunk-AVZFSWPD.js";
|
|
54
61
|
import {
|
|
55
62
|
docVersionSchema,
|
|
56
63
|
external_exports,
|
|
57
64
|
namespaceSchema,
|
|
58
65
|
slugSchema
|
|
59
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-I57ID5K7.js";
|
|
60
67
|
import "./chunk-3MZYUBJ6.js";
|
|
61
68
|
|
|
62
69
|
// src/domains/schema/publish.action.ts
|
|
@@ -68,7 +75,7 @@ import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
|
|
|
68
75
|
async function publishAction(file, args) {
|
|
69
76
|
const { error, data } = external_exports.object({
|
|
70
77
|
slug: slugSchema.optional(),
|
|
71
|
-
file: external_exports.string().min(1, "
|
|
78
|
+
file: external_exports.string().min(1, "Provide a valid file path or URL for your document.").optional(),
|
|
72
79
|
title: external_exports.string().max(50).optional(),
|
|
73
80
|
namespace: namespaceSchema.optional(),
|
|
74
81
|
private: external_exports.boolean().optional(),
|
|
@@ -104,11 +111,11 @@ async function publishAction(file, args) {
|
|
|
104
111
|
schema: teamSchema
|
|
105
112
|
});
|
|
106
113
|
if (team.error)
|
|
107
|
-
return output.error().title("
|
|
114
|
+
return output.error().title("Could not load the current team").message(team.message).exit("error");
|
|
108
115
|
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
109
116
|
if (!namespace) {
|
|
110
117
|
return output.error().title("Missing namespace").message(
|
|
111
|
-
"
|
|
118
|
+
"No team namespace is selected. Pass --namespace <namespace> or run `scalar team get` to see available namespaces."
|
|
112
119
|
).exit("error");
|
|
113
120
|
}
|
|
114
121
|
const client = await apiService();
|
|
@@ -116,13 +123,13 @@ async function publishAction(file, args) {
|
|
|
116
123
|
if (namespaceSchemaRes.error)
|
|
117
124
|
return output.error().title(namespaceSchemaRes.message).exit("error");
|
|
118
125
|
if (!data.file) {
|
|
119
|
-
requireInteractive("
|
|
126
|
+
requireInteractive("Provide a file path or URL.");
|
|
120
127
|
}
|
|
121
128
|
const apiFile = data.file || (await text({
|
|
122
|
-
message: "
|
|
129
|
+
message: "Enter a file path or URL for your document",
|
|
123
130
|
placeholder: "./api.yaml",
|
|
124
131
|
validate(value) {
|
|
125
|
-
if (value.length === 0) return "
|
|
132
|
+
if (value.length === 0) return "A file path or URL is required.";
|
|
126
133
|
}
|
|
127
134
|
})).toString();
|
|
128
135
|
const content = await getFileOrUrl(apiFile);
|
|
@@ -133,14 +140,14 @@ async function publishAction(file, args) {
|
|
|
133
140
|
).exit("error");
|
|
134
141
|
}
|
|
135
142
|
if (!data.slug) {
|
|
136
|
-
requireInteractive("
|
|
143
|
+
requireInteractive("Provide --slug.");
|
|
137
144
|
}
|
|
138
145
|
const slug = data.slug || (await text({
|
|
139
|
-
message: "
|
|
146
|
+
message: "Enter the schema slug",
|
|
140
147
|
validate(value) {
|
|
141
148
|
if (value.length === 0) return "Slug is required.";
|
|
142
149
|
if (slugSchema.safeParse(value)?.error)
|
|
143
|
-
return "
|
|
150
|
+
return "Enter a valid slug (e.g. my-schema)";
|
|
144
151
|
}
|
|
145
152
|
})).toString();
|
|
146
153
|
const matchingSchema = namespaceSchemaRes.data.find(
|
|
@@ -149,10 +156,10 @@ async function publishAction(file, args) {
|
|
|
149
156
|
const documentTitle = result?.info?.title;
|
|
150
157
|
const providedTitle = data.title ?? documentTitle;
|
|
151
158
|
if (!matchingSchema && !providedTitle) {
|
|
152
|
-
requireInteractive("
|
|
159
|
+
requireInteractive("Provide --title for the new schema.");
|
|
153
160
|
}
|
|
154
161
|
const title = matchingSchema || providedTitle ? providedTitle : (await text({
|
|
155
|
-
message: "
|
|
162
|
+
message: "Enter the schema title",
|
|
156
163
|
validate(value) {
|
|
157
164
|
if (value.length === 0) return "Title is required.";
|
|
158
165
|
}
|
|
@@ -162,18 +169,18 @@ async function publishAction(file, args) {
|
|
|
162
169
|
);
|
|
163
170
|
if (!parsedVersion.data) {
|
|
164
171
|
requireInteractive(
|
|
165
|
-
"
|
|
172
|
+
"Provide --version or a document with a valid info.version."
|
|
166
173
|
);
|
|
167
174
|
}
|
|
168
175
|
const version = parsedVersion.data || (await text({
|
|
169
|
-
message: "
|
|
176
|
+
message: "Enter the version (for example, 0.1.0)",
|
|
170
177
|
validate(value) {
|
|
171
178
|
if (value.length === 0) return "Version is required.";
|
|
172
179
|
if (docVersionSchema.safeParse(value)?.error)
|
|
173
180
|
return "Version must be a non-empty string";
|
|
174
181
|
}
|
|
175
182
|
})).toString();
|
|
176
|
-
const logger = output.info().line().loader(`Publishing ${slug} to Scalar
|
|
183
|
+
const logger = output.info().line().loader(`Publishing ${slug} to the Scalar Registry\u2026`);
|
|
177
184
|
const bundlingPlugins = [readFiles()];
|
|
178
185
|
if (data.bundle) {
|
|
179
186
|
bundlingPlugins.push(
|
|
@@ -208,8 +215,8 @@ async function publishAction(file, args) {
|
|
|
208
215
|
matchingSchema?.uid ?? publishRes.data.uid
|
|
209
216
|
);
|
|
210
217
|
logger.update("loader", 0, {
|
|
211
|
-
content: `
|
|
212
|
-
}).line().line(`${as.green("\u279C")} ${as.white.bold("
|
|
218
|
+
content: `Published ${slug} version ${version}.`
|
|
219
|
+
}).line().line(`${as.green("\u279C")} ${as.white.bold("Scalar Dashboard:")}`).line(as.cyan(schemaUrl)).line().line(`${as.green("\u279C")} ${as.white.bold("Scalar Registry preview:")}`).line(as.cyan(registryUrl(schema.url({ version })))).line().line(`${as.green("\u279C")} ${as.white.bold("Scalar Registry YAML:")}`).line(as.cyan(registryUrl(schema.url({ version, format: "yaml" })))).line().line(`${as.green("\u279C")} ${as.white.bold("Scalar Registry JSON:")}`).line(as.cyan(registryUrl(schema.url({ version, format: "json" })))).print();
|
|
213
220
|
}
|
|
214
221
|
export {
|
|
215
222
|
publishAction
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
isFileArgument,
|
|
4
|
+
isFileOption
|
|
5
|
+
} from "./chunk-DFOZG7ZV.js";
|
|
6
|
+
import "./chunk-3MZYUBJ6.js";
|
|
7
|
+
|
|
8
|
+
// src/helpers/completion/query.ts
|
|
9
|
+
var visibleCommands = (command) => command.createHelp().visibleCommands(command);
|
|
10
|
+
var visibleOptions = (command) => command.createHelp().visibleOptions(command);
|
|
11
|
+
var findOption = (command, flag) => visibleOptions(command).find(
|
|
12
|
+
(option) => option.short === flag || option.long === flag
|
|
13
|
+
);
|
|
14
|
+
var valueCompletion = (choices, files, prefix) => ({
|
|
15
|
+
mode: choices ? "values" : files ? "files" : "none",
|
|
16
|
+
candidates: choices?.filter((choice) => choice.startsWith(prefix)) ?? []
|
|
17
|
+
});
|
|
18
|
+
var optionCompletion = ({ option, command }, prefix) => valueCompletion(
|
|
19
|
+
option.argChoices,
|
|
20
|
+
isFileOption(command, option.long ?? "") || isFileOption(command, option.short ?? ""),
|
|
21
|
+
prefix
|
|
22
|
+
);
|
|
23
|
+
var argumentCompletion = (command, argument, prefix) => valueCompletion(
|
|
24
|
+
argument?.argChoices,
|
|
25
|
+
!!argument && isFileArgument(command, argument.name()),
|
|
26
|
+
prefix
|
|
27
|
+
);
|
|
28
|
+
var withPrefix = (result, prefix) => ({
|
|
29
|
+
...result,
|
|
30
|
+
prefix,
|
|
31
|
+
candidates: result.candidates.map((candidate) => `${prefix}${candidate}`)
|
|
32
|
+
});
|
|
33
|
+
var queryCompletion = (program, words, cursor) => {
|
|
34
|
+
const state = { command: program, position: 0, terminated: false, help: false };
|
|
35
|
+
const current = words[cursor] ?? "";
|
|
36
|
+
for (const word of words.slice(1, cursor)) {
|
|
37
|
+
if (state.pending) {
|
|
38
|
+
if (state.pending.option.required && !state.pending.consumed || !word.startsWith("-")) {
|
|
39
|
+
if (state.pending.option.variadic) state.pending.consumed = true;
|
|
40
|
+
else state.pending = void 0;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
state.pending = void 0;
|
|
44
|
+
}
|
|
45
|
+
if (!state.terminated && word === "--") {
|
|
46
|
+
state.terminated = true;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (!state.terminated && word.startsWith("-")) {
|
|
50
|
+
const equals = word.indexOf("=");
|
|
51
|
+
const flag = equals < 0 ? word : word.slice(0, equals);
|
|
52
|
+
const option = findOption(state.command, flag);
|
|
53
|
+
if (option) {
|
|
54
|
+
if ((option.required || option.optional) && (equals < 0 || option.variadic))
|
|
55
|
+
state.pending = {
|
|
56
|
+
option,
|
|
57
|
+
command: state.command,
|
|
58
|
+
consumed: equals >= 0
|
|
59
|
+
};
|
|
60
|
+
} else if (!word.startsWith("--")) {
|
|
61
|
+
for (let index = 1; index < word.length; index++) {
|
|
62
|
+
const short = findOption(state.command, `-${word[index]}`);
|
|
63
|
+
if (short?.required || short?.optional) {
|
|
64
|
+
if (index === word.length - 1 || short.variadic)
|
|
65
|
+
state.pending = { option: short, command: state.command };
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (!state.terminated && state.position === 0) {
|
|
73
|
+
if (word === "help" && state.command === program) {
|
|
74
|
+
state.help = true;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const child = visibleCommands(state.command).find(
|
|
78
|
+
(candidate) => candidate.name() === word || candidate.aliases().includes(word)
|
|
79
|
+
);
|
|
80
|
+
if (child) {
|
|
81
|
+
state.command = child;
|
|
82
|
+
state.position = 0;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
state.position++;
|
|
87
|
+
}
|
|
88
|
+
if (state.pending && (state.pending.option.required && !state.pending.consumed || !current.startsWith("-")))
|
|
89
|
+
return optionCompletion(state.pending, current);
|
|
90
|
+
if (!state.terminated && current.startsWith("-")) {
|
|
91
|
+
const equals = current.indexOf("=");
|
|
92
|
+
if (equals >= 0) {
|
|
93
|
+
const option = findOption(state.command, current.slice(0, equals));
|
|
94
|
+
if (!option || !(option.required || option.optional))
|
|
95
|
+
return { mode: "none", candidates: [] };
|
|
96
|
+
const result2 = optionCompletion(
|
|
97
|
+
{ option, command: state.command },
|
|
98
|
+
current.slice(equals + 1)
|
|
99
|
+
);
|
|
100
|
+
return withPrefix(result2, current.slice(0, equals + 1));
|
|
101
|
+
}
|
|
102
|
+
if (!current.startsWith("--") && current.length > 2) {
|
|
103
|
+
for (let index = 1; index < current.length; index++) {
|
|
104
|
+
const option = findOption(state.command, `-${current[index]}`);
|
|
105
|
+
if (option?.required || option?.optional) {
|
|
106
|
+
const result2 = optionCompletion(
|
|
107
|
+
{ option, command: state.command },
|
|
108
|
+
current.slice(index + 1)
|
|
109
|
+
);
|
|
110
|
+
return withPrefix(result2, current.slice(0, index + 1));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
mode: "values",
|
|
116
|
+
candidates: visibleOptions(state.command).flatMap((option) => [option.short, option.long]).filter((flag) => !!flag && flag.startsWith(current))
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const argument = state.command.registeredArguments[state.position] ?? state.command.registeredArguments.find((argument2) => argument2.variadic);
|
|
120
|
+
const result = argumentCompletion(state.command, argument, current);
|
|
121
|
+
if (state.position === 0 && !state.terminated) {
|
|
122
|
+
const candidates = visibleCommands(state.command).flatMap((child) => [child.name(), ...child.aliases()]).filter((name) => name.startsWith(current));
|
|
123
|
+
if (candidates.length || state.help) return { mode: "values", candidates };
|
|
124
|
+
}
|
|
125
|
+
return result;
|
|
126
|
+
};
|
|
127
|
+
export {
|
|
128
|
+
queryCompletion
|
|
129
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import "./chunk-3MZYUBJ6.js";
|
|
3
|
+
|
|
4
|
+
// src/helpers/completion/scripts.ts
|
|
5
|
+
var bash = `
|
|
6
|
+
_scalar_complete() {
|
|
7
|
+
local mode prefix candidate current word index cursor=0 trim=''
|
|
8
|
+
local -a words
|
|
9
|
+
words=()
|
|
10
|
+
# Bash splits equals signs into separate completion words by default.
|
|
11
|
+
for ((index=0; index<=COMP_CWORD; index++)); do
|
|
12
|
+
word="\${COMP_WORDS[index]}"
|
|
13
|
+
if [[ "$word" == '=' && \${#words[@]} -gt 0 ]]; then
|
|
14
|
+
words[\${#words[@]}-1]="\${words[\${#words[@]}-1]}="
|
|
15
|
+
elif [[ \${#words[@]} -gt 0 && "\${words[\${#words[@]}-1]}" == *= ]]; then
|
|
16
|
+
words[\${#words[@]}-1]="\${words[\${#words[@]}-1]}$word"
|
|
17
|
+
else
|
|
18
|
+
words[\${#words[@]}]="$word"
|
|
19
|
+
fi
|
|
20
|
+
done
|
|
21
|
+
cursor=$((\${#words[@]}-1))
|
|
22
|
+
current="\${words[cursor]}"
|
|
23
|
+
if [[ "$current" == *=* && ("\${COMP_WORDS[COMP_CWORD]}" == '=' || "\${COMP_WORDS[COMP_CWORD]}" != *=*) ]]; then
|
|
24
|
+
trim="\${current%%=*}="
|
|
25
|
+
fi
|
|
26
|
+
COMPREPLY=()
|
|
27
|
+
{
|
|
28
|
+
IFS= read -r mode
|
|
29
|
+
IFS= read -r prefix
|
|
30
|
+
if [[ "$mode" == files ]]; then
|
|
31
|
+
[[ "$prefix" == '-' ]] && prefix=''
|
|
32
|
+
current="\${current#"$prefix"}"
|
|
33
|
+
while IFS= read -r candidate; do
|
|
34
|
+
COMPREPLY[\${#COMPREPLY[@]}]="\${prefix#"$trim"}$candidate"
|
|
35
|
+
done < <(compgen -f -- "$current")
|
|
36
|
+
type compopt >/dev/null 2>&1 && compopt -o filenames
|
|
37
|
+
else
|
|
38
|
+
while IFS= read -r candidate; do
|
|
39
|
+
[[ -n "$candidate" ]] && COMPREPLY[\${#COMPREPLY[@]}]="\${candidate#"$trim"}"
|
|
40
|
+
done
|
|
41
|
+
fi
|
|
42
|
+
} < <("\${words[0]}" __complete "$cursor" -- "\${words[@]}" 2>/dev/null)
|
|
43
|
+
}
|
|
44
|
+
complete -F _scalar_complete scalar scalar-cli
|
|
45
|
+
`;
|
|
46
|
+
var zsh = `
|
|
47
|
+
_scalar_complete() {
|
|
48
|
+
local -a response candidates
|
|
49
|
+
local mode prefix
|
|
50
|
+
response=("\${(@f)$("\${words[1]}" __complete "$((CURRENT-1))" -- "\${words[@]}" 2>/dev/null)}")
|
|
51
|
+
mode="\${response[1]}"
|
|
52
|
+
prefix="\${response[2]}"
|
|
53
|
+
if [[ "$mode" == files ]]; then
|
|
54
|
+
if [[ "$prefix" != '-' ]]; then
|
|
55
|
+
compset -P "$prefix"
|
|
56
|
+
fi
|
|
57
|
+
_files
|
|
58
|
+
elif [[ "$mode" == values ]]; then
|
|
59
|
+
candidates=("\${response[@]:2}")
|
|
60
|
+
compadd -- "\${candidates[@]}"
|
|
61
|
+
fi
|
|
62
|
+
}
|
|
63
|
+
_scalar_complete "$@"
|
|
64
|
+
`;
|
|
65
|
+
var fish = `
|
|
66
|
+
function __scalar_complete
|
|
67
|
+
set -l words (commandline -opc)
|
|
68
|
+
set -l current (commandline -ct)
|
|
69
|
+
set -l cursor (count $words)
|
|
70
|
+
set -l response (command $words[1] __complete $cursor -- $words "$current" 2>/dev/null)
|
|
71
|
+
if test "$response[1]" = files
|
|
72
|
+
set -l prefix $response[2]
|
|
73
|
+
if test "$prefix" = '-'
|
|
74
|
+
set prefix ''
|
|
75
|
+
end
|
|
76
|
+
set -l path (string sub -s (math (string length -- "$prefix") + 1) -- "$current")
|
|
77
|
+
for candidate in (__fish_complete_path "$path")
|
|
78
|
+
printf '%s%s\\n' "$prefix" "$candidate"
|
|
79
|
+
end
|
|
80
|
+
else if test "$response[1]" = values
|
|
81
|
+
for candidate in $response[3..-1]
|
|
82
|
+
printf '%s\\n' "$candidate"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
complete -c scalar -f -a '(__scalar_complete)'
|
|
87
|
+
complete -c scalar-cli -f -a '(__scalar_complete)'
|
|
88
|
+
`;
|
|
89
|
+
var renderCompletionScript = (shell) => {
|
|
90
|
+
const setup = {
|
|
91
|
+
bash: "# Save this script and source it from ~/.bashrc (or ~/.bash_profile on macOS).",
|
|
92
|
+
zsh: "# Save as _scalar on fpath, then run autoload -Uz compinit; compinit.",
|
|
93
|
+
fish: "# Save as ~/.config/fish/completions/scalar.fish. Copy to scalar-cli.fish for that alias."
|
|
94
|
+
};
|
|
95
|
+
return `${shell === "zsh" ? "#compdef scalar scalar-cli\n" : ""}# Scalar CLI ${shell} completion
|
|
96
|
+
${setup[shell]}
|
|
97
|
+
# Regenerate with scalar completion ${shell} after upgrades.
|
|
98
|
+
${{ bash, zsh, fish }[shell]}`;
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
renderCompletionScript
|
|
102
|
+
};
|
|
@@ -1,42 +1,49 @@
|
|
|
1
1
|
import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
PRIVACY_VALUES
|
|
4
|
+
} from "./chunk-NAC63XJF.js";
|
|
2
5
|
import {
|
|
3
6
|
BaseCollections
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NWJ37GI2.js";
|
|
5
8
|
import {
|
|
6
9
|
getDatabaseClient
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-U6VE6JOS.js";
|
|
8
11
|
import {
|
|
9
12
|
apiService
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-F3OPMYME.js";
|
|
14
|
+
import "./chunk-FG5AOTDN.js";
|
|
15
|
+
import "./chunk-SEURG74P.js";
|
|
16
|
+
import "./chunk-3TFOA64C.js";
|
|
17
|
+
import "./chunk-5ENKYZA4.js";
|
|
18
|
+
import "./chunk-Y6XGC4K5.js";
|
|
19
|
+
import "./chunk-SOV4POMS.js";
|
|
20
|
+
import "./chunk-T34TL6KL.js";
|
|
21
|
+
import "./chunk-V6LUKXBV.js";
|
|
22
|
+
import "./chunk-VUXPDHTQ.js";
|
|
16
23
|
import {
|
|
17
24
|
getAuthData
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
25
|
+
} from "./chunk-3RIUDHLG.js";
|
|
26
|
+
import "./chunk-N5CJ5MTY.js";
|
|
27
|
+
import "./chunk-US54KYOJ.js";
|
|
20
28
|
import {
|
|
21
29
|
teamSchema
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
30
|
+
} from "./chunk-BQYVSPAI.js";
|
|
31
|
+
import "./chunk-VRZSDUZK.js";
|
|
24
32
|
import {
|
|
25
33
|
requireInteractive
|
|
26
34
|
} from "./chunk-EGOXR5FB.js";
|
|
27
|
-
import "./chunk-K74E42RV.js";
|
|
28
|
-
import "./chunk-KCCFN4F7.js";
|
|
29
|
-
import "./chunk-6XWCMJDB.js";
|
|
30
35
|
import "./chunk-4ORL4MST.js";
|
|
36
|
+
import "./chunk-MN2AFJXM.js";
|
|
31
37
|
import {
|
|
32
38
|
output
|
|
33
39
|
} from "./chunk-T5HJUAWB.js";
|
|
34
|
-
import "./chunk-
|
|
40
|
+
import "./chunk-25XERWCE.js";
|
|
41
|
+
import "./chunk-AVZFSWPD.js";
|
|
35
42
|
import {
|
|
36
43
|
external_exports,
|
|
37
44
|
namespaceSchema,
|
|
38
45
|
slugSchema
|
|
39
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-I57ID5K7.js";
|
|
40
47
|
import "./chunk-3MZYUBJ6.js";
|
|
41
48
|
|
|
42
49
|
// src/domains/schema/update.action.ts
|
|
@@ -47,7 +54,7 @@ async function updateAction(opts) {
|
|
|
47
54
|
namespace: namespaceSchema.optional(),
|
|
48
55
|
title: external_exports.string().max(50).optional(),
|
|
49
56
|
description: external_exports.string().optional(),
|
|
50
|
-
isPrivate: external_exports.enum(
|
|
57
|
+
isPrivate: external_exports.enum(PRIVACY_VALUES).transform((value) => value === "true" || value === "private").optional()
|
|
51
58
|
}).safeParse(opts);
|
|
52
59
|
if (error)
|
|
53
60
|
return output.error().title("Invalid input").message(error.issues[0].message).exit("error");
|
|
@@ -63,41 +70,41 @@ async function updateAction(opts) {
|
|
|
63
70
|
schema: teamSchema
|
|
64
71
|
});
|
|
65
72
|
if (team.error)
|
|
66
|
-
return output.error().title("
|
|
73
|
+
return output.error().title("Could not load the current team").message(team.message).exit("error");
|
|
67
74
|
const namespace = data.namespace || team.data.namespaces.at(0);
|
|
68
75
|
if (!namespace) {
|
|
69
76
|
return output.error().title("Missing namespace").message(
|
|
70
|
-
"
|
|
77
|
+
"No team namespace is selected. Pass --namespace <namespace> or run `scalar team get` to see available namespaces."
|
|
71
78
|
).exit("error");
|
|
72
79
|
}
|
|
73
80
|
const schemas = await client.managedSchemas.getSchemas(namespace);
|
|
74
81
|
if (schemas.error) return output.error().title(schemas.message).exit("error");
|
|
75
82
|
if (data.slug && !schemas.data.some((schema) => schema.slug === data.slug)) {
|
|
76
|
-
return output.error().title("
|
|
83
|
+
return output.error().title("Schema not found").message("Provide a valid schema slug.").exit("error");
|
|
77
84
|
}
|
|
78
85
|
if (!data.slug) {
|
|
79
|
-
requireInteractive("
|
|
86
|
+
requireInteractive("Provide --slug.");
|
|
80
87
|
}
|
|
81
88
|
const schemaSlug = schemas.data.find((schema) => schema.slug === data.slug)?.slug || await select({
|
|
82
|
-
message: "
|
|
89
|
+
message: "Select a schema to update",
|
|
83
90
|
options: schemas.data.map((schema) => ({
|
|
84
91
|
value: schema.slug,
|
|
85
92
|
label: schema.slug
|
|
86
93
|
}))
|
|
87
94
|
});
|
|
88
95
|
if (!schemaSlug) {
|
|
89
|
-
return output.error().title("
|
|
96
|
+
return output.error().title("Schema not found").message("Provide a valid schema slug.").exit("error");
|
|
90
97
|
}
|
|
91
|
-
const logger = output.info().loader("Updating
|
|
98
|
+
const logger = output.info().loader("Updating schema\u2026");
|
|
92
99
|
const response = await client.managedSchemas.update(namespace, schemaSlug, {
|
|
93
100
|
title: data.title,
|
|
94
101
|
description: data.description,
|
|
95
102
|
isPrivate: data.isPrivate
|
|
96
103
|
});
|
|
97
104
|
if (response.error) {
|
|
98
|
-
return output.error().title("
|
|
105
|
+
return output.error().title("Could not update the schema").message(response.message).exit("error");
|
|
99
106
|
}
|
|
100
|
-
logger.update("loader", 0, { content: "Schema updated
|
|
107
|
+
logger.update("loader", 0, { content: "Schema updated." }).exit("success");
|
|
101
108
|
}
|
|
102
109
|
export {
|
|
103
110
|
updateAction
|