@sanity/cli 4.1.1 → 4.1.2-4.2.0-rita-prerelease-tag.0.28
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/lib/_chunks-cjs/cli.js +183 -43
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/package.json +28 -26
package/lib/_chunks-cjs/cli.js
CHANGED
|
@@ -3767,7 +3767,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
3767
3767
|
}(lodash$1, lodash$1.exports)), lodash$1.exports;
|
|
3768
3768
|
}
|
|
3769
3769
|
var lodashExports = requireLodash();
|
|
3770
|
-
const helpText$
|
|
3770
|
+
const helpText$r = `
|
|
3771
3771
|
Arguments
|
|
3772
3772
|
<type> Type of Resource to add (currently only 'function' is supported)
|
|
3773
3773
|
|
|
@@ -3809,7 +3809,7 @@ Examples:
|
|
|
3809
3809
|
}, addBlueprintsCommand = {
|
|
3810
3810
|
name: "add",
|
|
3811
3811
|
group: "blueprints",
|
|
3812
|
-
helpText: helpText$
|
|
3812
|
+
helpText: helpText$r,
|
|
3813
3813
|
signature: "<type> [--name <name>] [--fn-type <document-publish>] [--fn-lang <ts|js>] [--javascript]",
|
|
3814
3814
|
description: "Add a Resource to a Blueprint",
|
|
3815
3815
|
async action(args, context) {
|
|
@@ -3870,7 +3870,7 @@ Examples:
|
|
|
3870
3870
|
signature: "[COMMAND]",
|
|
3871
3871
|
isGroupRoot: !0,
|
|
3872
3872
|
description: "Deploy and manage Sanity Blueprints and Stacks (IaC)"
|
|
3873
|
-
}, helpText$
|
|
3873
|
+
}, helpText$q = `
|
|
3874
3874
|
Options
|
|
3875
3875
|
--edit, -e Edit the configuration
|
|
3876
3876
|
--test, -t Test the configuration
|
|
@@ -3893,7 +3893,7 @@ Examples:
|
|
|
3893
3893
|
}, configBlueprintsCommand = {
|
|
3894
3894
|
name: "config",
|
|
3895
3895
|
group: "blueprints",
|
|
3896
|
-
helpText: helpText$
|
|
3896
|
+
helpText: helpText$q,
|
|
3897
3897
|
signature: "[--edit] [-e] [--test] [-t] [--project-id <id>]",
|
|
3898
3898
|
description: "View or edit local Blueprints configuration",
|
|
3899
3899
|
async action(args, context) {
|
|
@@ -3920,7 +3920,7 @@ Examples:
|
|
|
3920
3920
|
});
|
|
3921
3921
|
if (!success) throw new Error(error2);
|
|
3922
3922
|
}
|
|
3923
|
-
}, helpText$
|
|
3923
|
+
}, helpText$p = `
|
|
3924
3924
|
Options
|
|
3925
3925
|
--no-wait Do not wait for deployment to complete
|
|
3926
3926
|
|
|
@@ -3935,7 +3935,7 @@ Examples:
|
|
|
3935
3935
|
}, deployBlueprintsCommand = {
|
|
3936
3936
|
name: "deploy",
|
|
3937
3937
|
group: "blueprints",
|
|
3938
|
-
helpText: helpText$
|
|
3938
|
+
helpText: helpText$p,
|
|
3939
3939
|
signature: "[--no-wait]",
|
|
3940
3940
|
description: "Deploy a Blueprint to create or update a Stack",
|
|
3941
3941
|
async action(args, context) {
|
|
@@ -3958,7 +3958,7 @@ Examples:
|
|
|
3958
3958
|
});
|
|
3959
3959
|
if (!success) throw new Error(error2);
|
|
3960
3960
|
}
|
|
3961
|
-
}, helpText$
|
|
3961
|
+
}, helpText$o = `
|
|
3962
3962
|
Options
|
|
3963
3963
|
--force, -f Force destroy without confirmation
|
|
3964
3964
|
--no-wait Do not wait for destroy to complete
|
|
@@ -3977,7 +3977,7 @@ Examples:
|
|
|
3977
3977
|
}, destroyBlueprintsCommand = {
|
|
3978
3978
|
name: "destroy",
|
|
3979
3979
|
group: "blueprints",
|
|
3980
|
-
helpText: helpText$
|
|
3980
|
+
helpText: helpText$o,
|
|
3981
3981
|
signature: "[--force] [-f] [--no-wait]",
|
|
3982
3982
|
description: "Destroy a Blueprint deployment",
|
|
3983
3983
|
async action(args, context) {
|
|
@@ -4003,7 +4003,7 @@ Examples:
|
|
|
4003
4003
|
});
|
|
4004
4004
|
if (!success) throw new Error(error2);
|
|
4005
4005
|
}
|
|
4006
|
-
}, helpText$
|
|
4006
|
+
}, helpText$n = `
|
|
4007
4007
|
Examples:
|
|
4008
4008
|
# Retrieve information about the current Stack
|
|
4009
4009
|
sanity blueprints info
|
|
@@ -4012,7 +4012,7 @@ Examples:
|
|
|
4012
4012
|
}, infoBlueprintsCommand = {
|
|
4013
4013
|
name: "info",
|
|
4014
4014
|
group: "blueprints",
|
|
4015
|
-
helpText: helpText$
|
|
4015
|
+
helpText: helpText$n,
|
|
4016
4016
|
signature: "",
|
|
4017
4017
|
description: "Retrieve information about a Blueprint Stack",
|
|
4018
4018
|
async action(args, context) {
|
|
@@ -4033,7 +4033,7 @@ Examples:
|
|
|
4033
4033
|
});
|
|
4034
4034
|
if (!success) throw new Error(error2);
|
|
4035
4035
|
}
|
|
4036
|
-
}, helpText$
|
|
4036
|
+
}, helpText$m = `
|
|
4037
4037
|
Arguments
|
|
4038
4038
|
[dir] Path to initialize the Blueprint in
|
|
4039
4039
|
|
|
@@ -4055,7 +4055,7 @@ Examples:
|
|
|
4055
4055
|
}, initBlueprintsCommand = {
|
|
4056
4056
|
name: "init",
|
|
4057
4057
|
group: "blueprints",
|
|
4058
|
-
helpText: helpText$
|
|
4058
|
+
helpText: helpText$m,
|
|
4059
4059
|
signature: "[dir] [--blueprint-type <type>] [--project-id <id>]",
|
|
4060
4060
|
description: "Initialize a new Blueprint manifest file",
|
|
4061
4061
|
async action(args, context) {
|
|
@@ -4095,7 +4095,7 @@ Examples:
|
|
|
4095
4095
|
});
|
|
4096
4096
|
if (!success) throw new Error(error2);
|
|
4097
4097
|
}
|
|
4098
|
-
}, helpText$
|
|
4098
|
+
}, helpText$l = `
|
|
4099
4099
|
Options
|
|
4100
4100
|
--watch, -w Watch for new logs (streaming mode)
|
|
4101
4101
|
|
|
@@ -4110,7 +4110,7 @@ Examples:
|
|
|
4110
4110
|
}, logsBlueprintsCommand = {
|
|
4111
4111
|
name: "logs",
|
|
4112
4112
|
group: "blueprints",
|
|
4113
|
-
helpText: helpText$
|
|
4113
|
+
helpText: helpText$l,
|
|
4114
4114
|
signature: "[--watch] [-w]",
|
|
4115
4115
|
description: "Display logs for the current Blueprint Stack",
|
|
4116
4116
|
async action(args, context) {
|
|
@@ -4133,7 +4133,7 @@ Examples:
|
|
|
4133
4133
|
});
|
|
4134
4134
|
if (streaming && await streaming, !success) throw new Error(error2);
|
|
4135
4135
|
}
|
|
4136
|
-
}, helpText$
|
|
4136
|
+
}, helpText$k = `
|
|
4137
4137
|
Safe to run at any time. Will not modify any Resources.
|
|
4138
4138
|
|
|
4139
4139
|
Examples:
|
|
@@ -4142,7 +4142,7 @@ Examples:
|
|
|
4142
4142
|
`, planBlueprintsCommand = {
|
|
4143
4143
|
name: "plan",
|
|
4144
4144
|
group: "blueprints",
|
|
4145
|
-
helpText: helpText$
|
|
4145
|
+
helpText: helpText$k,
|
|
4146
4146
|
signature: "",
|
|
4147
4147
|
description: "Enumerate Resources to be deployed",
|
|
4148
4148
|
async action(args, context) {
|
|
@@ -4162,7 +4162,7 @@ Examples:
|
|
|
4162
4162
|
});
|
|
4163
4163
|
if (!success) throw new Error(error2);
|
|
4164
4164
|
}
|
|
4165
|
-
}, helpText$
|
|
4165
|
+
}, helpText$j = `
|
|
4166
4166
|
Options
|
|
4167
4167
|
--project-id <id> Project ID to use
|
|
4168
4168
|
|
|
@@ -4177,7 +4177,7 @@ Examples:
|
|
|
4177
4177
|
}, stacksBlueprintsCommand = {
|
|
4178
4178
|
name: "stacks",
|
|
4179
4179
|
group: "blueprints",
|
|
4180
|
-
helpText: helpText$
|
|
4180
|
+
helpText: helpText$j,
|
|
4181
4181
|
signature: "[--project-id <id>]",
|
|
4182
4182
|
description: "List all Blueprint Stacks for the current Project",
|
|
4183
4183
|
hideFromHelp: !0,
|
|
@@ -4345,7 +4345,7 @@ function ensureNpx() {
|
|
|
4345
4345
|
);
|
|
4346
4346
|
}
|
|
4347
4347
|
}
|
|
4348
|
-
const helpText$
|
|
4348
|
+
const helpText$i = `
|
|
4349
4349
|
Runs a given code modification script on the current studio folder.
|
|
4350
4350
|
Running the command without a specified codemod name will list available transformations.
|
|
4351
4351
|
|
|
@@ -4367,7 +4367,7 @@ Examples
|
|
|
4367
4367
|
name: "codemod",
|
|
4368
4368
|
signature: "[CODEMOD_NAME]",
|
|
4369
4369
|
description: "Updates Sanity Studio codebase with a code modification script",
|
|
4370
|
-
helpText: helpText$
|
|
4370
|
+
helpText: helpText$i,
|
|
4371
4371
|
action: codemodAction
|
|
4372
4372
|
};
|
|
4373
4373
|
var lodash_isplainobject, hasRequiredLodash_isplainobject;
|
|
@@ -7934,7 +7934,7 @@ function normalizePath(input2) {
|
|
|
7934
7934
|
const sanityDocsPrefix = "https://www.sanity.io";
|
|
7935
7935
|
return input2.startsWith(sanityDocsPrefix) ? input2.replace(sanityDocsPrefix, "") : input2;
|
|
7936
7936
|
}
|
|
7937
|
-
const helpText$
|
|
7937
|
+
const helpText$h = `
|
|
7938
7938
|
Arguments
|
|
7939
7939
|
<path> Path or URL to article, found in search results and docs content as links
|
|
7940
7940
|
|
|
@@ -7952,13 +7952,13 @@ Examples
|
|
|
7952
7952
|
`, readCommand = {
|
|
7953
7953
|
name: "read",
|
|
7954
7954
|
group: "docs",
|
|
7955
|
-
helpText: helpText$
|
|
7955
|
+
helpText: helpText$h,
|
|
7956
7956
|
signature: "<path|url> [-w, --web]",
|
|
7957
7957
|
description: "Read an article in terminal",
|
|
7958
7958
|
async action(args, context) {
|
|
7959
7959
|
const { output } = context, flags = args.extOptions, input2 = args.argsWithoutOptions[0];
|
|
7960
7960
|
if (!input2 || typeof input2 != "string") {
|
|
7961
|
-
output.error("Please provide an article path or URL"), output.print(""), output.print(helpText$
|
|
7961
|
+
output.error("Please provide an article path or URL"), output.print(""), output.print(helpText$h), process.exit(1);
|
|
7962
7962
|
return;
|
|
7963
7963
|
}
|
|
7964
7964
|
const path2 = normalizePath(input2);
|
|
@@ -7988,7 +7988,7 @@ async function searchDocs(options2, context) {
|
|
|
7988
7988
|
const results = await response.json();
|
|
7989
7989
|
return Array.isArray(results) ? results.slice(0, limit) : [];
|
|
7990
7990
|
}
|
|
7991
|
-
const isInteractive$1 = process.stdout.isTTY && process.env.TERM !== "dumb" && !("CI" in process.env), helpText$
|
|
7991
|
+
const isInteractive$1 = process.stdout.isTTY && process.env.TERM !== "dumb" && !("CI" in process.env), helpText$g = `
|
|
7992
7992
|
Arguments
|
|
7993
7993
|
<query> Search query for documentation
|
|
7994
7994
|
|
|
@@ -8009,7 +8009,7 @@ Examples
|
|
|
8009
8009
|
}, searchCommand = {
|
|
8010
8010
|
name: "search",
|
|
8011
8011
|
group: "docs",
|
|
8012
|
-
helpText: helpText$
|
|
8012
|
+
helpText: helpText$g,
|
|
8013
8013
|
signature: "<query> [--limit <limit>]",
|
|
8014
8014
|
description: "Search Sanity docs",
|
|
8015
8015
|
async action(args, context) {
|
|
@@ -8063,7 +8063,7 @@ Found ${results.length} result(s):
|
|
|
8063
8063
|
}
|
|
8064
8064
|
}
|
|
8065
8065
|
}
|
|
8066
|
-
}, helpText$
|
|
8066
|
+
}, helpText$f = `
|
|
8067
8067
|
Options
|
|
8068
8068
|
--port <port> Port to start emulator on
|
|
8069
8069
|
--open Open dev server in a new browser tab
|
|
@@ -8083,7 +8083,7 @@ Examples
|
|
|
8083
8083
|
}, devFunctionsCommand = {
|
|
8084
8084
|
name: "dev",
|
|
8085
8085
|
group: "functions",
|
|
8086
|
-
helpText: helpText$
|
|
8086
|
+
helpText: helpText$f,
|
|
8087
8087
|
signature: "[--port <port> --open]",
|
|
8088
8088
|
description: "Start the Sanity Function emulator",
|
|
8089
8089
|
async action(args, context) {
|
|
@@ -8104,7 +8104,7 @@ Examples
|
|
|
8104
8104
|
if (!success) throw new Error(error2);
|
|
8105
8105
|
shouldOpen && open(`http://localhost:${flags.port}`);
|
|
8106
8106
|
}
|
|
8107
|
-
}, helpText$
|
|
8107
|
+
}, helpText$e = `
|
|
8108
8108
|
Commands
|
|
8109
8109
|
add Add or update an environment variable
|
|
8110
8110
|
list List the environment variables
|
|
@@ -8127,7 +8127,7 @@ Examples
|
|
|
8127
8127
|
`, envFunctionsCommand = {
|
|
8128
8128
|
name: "env",
|
|
8129
8129
|
group: "functions",
|
|
8130
|
-
helpText: helpText$
|
|
8130
|
+
helpText: helpText$e,
|
|
8131
8131
|
signature: "<add|list|remove> <name> [key] [value]",
|
|
8132
8132
|
description: "Add or remove an environment variable or list environment variables for a Sanity function",
|
|
8133
8133
|
async action(args, context) {
|
|
@@ -8183,7 +8183,7 @@ Examples
|
|
|
8183
8183
|
signature: "[COMMAND]",
|
|
8184
8184
|
isGroupRoot: !0,
|
|
8185
8185
|
description: "Manage, test, and observe Sanity Functions"
|
|
8186
|
-
}, helpText$
|
|
8186
|
+
}, helpText$d = `
|
|
8187
8187
|
Arguments
|
|
8188
8188
|
<name> The name of the Function to retrieve logs for
|
|
8189
8189
|
|
|
@@ -8220,7 +8220,7 @@ Examples
|
|
|
8220
8220
|
}, logsFunctionsCommand = {
|
|
8221
8221
|
name: "logs",
|
|
8222
8222
|
group: "functions",
|
|
8223
|
-
helpText: helpText$
|
|
8223
|
+
helpText: helpText$d,
|
|
8224
8224
|
signature: "<name> [--limit <number>] [--json] [--utc] [--delete [--force]] [--watch]",
|
|
8225
8225
|
description: "Retrieve or delete logs for a Sanity Function",
|
|
8226
8226
|
async action(args, context) {
|
|
@@ -8245,7 +8245,7 @@ Examples
|
|
|
8245
8245
|
});
|
|
8246
8246
|
if (!success) throw new Error(error2);
|
|
8247
8247
|
}
|
|
8248
|
-
}, helpText$
|
|
8248
|
+
}, helpText$c = `
|
|
8249
8249
|
Arguments
|
|
8250
8250
|
<name> The name of the Sanity Function
|
|
8251
8251
|
|
|
@@ -8276,7 +8276,7 @@ Examples
|
|
|
8276
8276
|
}, testFunctionsCommand = {
|
|
8277
8277
|
name: "test",
|
|
8278
8278
|
group: "functions",
|
|
8279
|
-
helpText: helpText$
|
|
8279
|
+
helpText: helpText$c,
|
|
8280
8280
|
signature: "<name> [--data <json>] [--file <filename>] [--document-id <id>] [--timeout <seconds>] [--api <version>] [--dataset <name>] [--project-id] <id>] [--with-user-token]",
|
|
8281
8281
|
description: "Invoke a local Sanity Function",
|
|
8282
8282
|
async action(args, context) {
|
|
@@ -8366,11 +8366,11 @@ const commonMistakes = { get: "list" }, levenThreshold = 3, coreCommands = [
|
|
|
8366
8366
|
"undeploy",
|
|
8367
8367
|
"uninstall",
|
|
8368
8368
|
"users"
|
|
8369
|
-
], discouragedCommands = ["upgrade", "check", "configcheck", "uninstall"], helpText$
|
|
8369
|
+
], discouragedCommands = ["upgrade", "check", "configcheck", "uninstall"], helpText$b = `
|
|
8370
8370
|
Run the command again within a Sanity project directory, where "sanity"
|
|
8371
8371
|
is installed as a dependency.`;
|
|
8372
8372
|
function getNoSuchCommandText(cmdName, parentGroupName, groups) {
|
|
8373
|
-
return parentGroupName && groups && groups[parentGroupName] ? suggestCommand(cmdName, groups[parentGroupName], parentGroupName) : coreCommands.includes(cmdName) ? `Command "${cmdName}" is not available outside of a Sanity project context.${helpText$
|
|
8373
|
+
return parentGroupName && groups && groups[parentGroupName] ? suggestCommand(cmdName, groups[parentGroupName], parentGroupName) : coreCommands.includes(cmdName) ? `Command "${cmdName}" is not available outside of a Sanity project context.${helpText$b}` : suggestCommand(cmdName, groups ? groups.default : []);
|
|
8374
8374
|
}
|
|
8375
8375
|
function suggestCommand(cmdName, group, parentGroupName = null) {
|
|
8376
8376
|
const closest = group.filter((command2) => !discouragedCommands.includes(command2.name)).map((command2) => leven(command2.name, cmdName)).reduce(
|
|
@@ -53927,7 +53927,7 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
|
|
|
53927
53927
|
}
|
|
53928
53928
|
const chosen = await resolvePackageManager(workDir);
|
|
53929
53929
|
trace.log({ step: "selectPackageManager", selectedOption: chosen });
|
|
53930
|
-
const packages = ["@sanity/vision@
|
|
53930
|
+
const packages = ["@sanity/vision@4", "sanity@4", "@sanity/image-url@1", "styled-components@6"];
|
|
53931
53931
|
templateToUse === "blog" && packages.push("@sanity/icons"), await installNewPackages(
|
|
53932
53932
|
{
|
|
53933
53933
|
packageManager: chosen,
|
|
@@ -53944,7 +53944,7 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
|
|
|
53944
53944
|
cwd: workDir,
|
|
53945
53945
|
stdio: "inherit"
|
|
53946
53946
|
};
|
|
53947
|
-
chosen === "npm" ? await execa("npm", ["install", "--legacy-peer-deps", "next-sanity@
|
|
53947
|
+
chosen === "npm" ? await execa("npm", ["install", "--legacy-peer-deps", "next-sanity@10"], execOptions) : chosen === "yarn" ? await execa("npx", ["install-peerdeps", "--yarn", "next-sanity@10"], execOptions) : chosen === "pnpm" && await execa("pnpm", ["install", "next-sanity@10"], execOptions), print(
|
|
53948
53948
|
`
|
|
53949
53949
|
${chalk2.green("Success!")} Your Sanity configuration files has been added to this project`
|
|
53950
53950
|
);
|
|
@@ -54586,7 +54586,7 @@ function getImportCommand(outputPath, studioVersion) {
|
|
|
54586
54586
|
);
|
|
54587
54587
|
}
|
|
54588
54588
|
}
|
|
54589
|
-
const helpText$
|
|
54589
|
+
const helpText$a = `
|
|
54590
54590
|
Options
|
|
54591
54591
|
-y, --yes Use unattended mode, accepting defaults and using only flags for choices
|
|
54592
54592
|
--project, --project-id <projectId> Project ID to use for the studio
|
|
@@ -54639,7 +54639,7 @@ Examples
|
|
|
54639
54639
|
name: "init",
|
|
54640
54640
|
signature: "",
|
|
54641
54641
|
description: "Initializes a new Sanity Studio and/or project",
|
|
54642
|
-
helpText: helpText$
|
|
54642
|
+
helpText: helpText$a,
|
|
54643
54643
|
action: async (args, context) => {
|
|
54644
54644
|
const [type2] = args.argsWithoutOptions;
|
|
54645
54645
|
if (type2)
|
|
@@ -54677,7 +54677,7 @@ Examples
|
|
|
54677
54677
|
const { output } = context, { print } = output, url = "https://www.sanity.io/learn";
|
|
54678
54678
|
print(`Opening ${url}`), await open(url);
|
|
54679
54679
|
}
|
|
54680
|
-
}, helpText$
|
|
54680
|
+
}, helpText$9 = `
|
|
54681
54681
|
Options
|
|
54682
54682
|
--sso <slug> Log in using Single Sign On, using the given slug
|
|
54683
54683
|
--provider <providerId> Authenticate against a specific provider
|
|
@@ -54695,16 +54695,16 @@ Examples
|
|
|
54695
54695
|
`, loginCommand = {
|
|
54696
54696
|
name: "login",
|
|
54697
54697
|
signature: "[--sso <slug>] [--provider <providerId>] [--no-open]",
|
|
54698
|
-
helpText: helpText$
|
|
54698
|
+
helpText: helpText$9,
|
|
54699
54699
|
description: "Authenticates the CLI for access to Sanity projects",
|
|
54700
54700
|
action: login
|
|
54701
|
-
}, helpText$
|
|
54701
|
+
}, helpText$8 = `
|
|
54702
54702
|
Examples
|
|
54703
54703
|
# Log out of the CLI
|
|
54704
54704
|
sanity logout
|
|
54705
54705
|
`, logoutCommand = {
|
|
54706
54706
|
name: "logout",
|
|
54707
|
-
helpText: helpText$
|
|
54707
|
+
helpText: helpText$8,
|
|
54708
54708
|
signature: "logout",
|
|
54709
54709
|
description: "Logs out the CLI from the current user session",
|
|
54710
54710
|
async action(args, { output, apiClient }) {
|
|
@@ -54735,6 +54735,143 @@ ${err.message}`));
|
|
|
54735
54735
|
print(`Opening ${url}`), await open(url);
|
|
54736
54736
|
}
|
|
54737
54737
|
};
|
|
54738
|
+
async function getSpec(options2, context) {
|
|
54739
|
+
const { output } = context;
|
|
54740
|
+
if (options2.web) {
|
|
54741
|
+
const url = `https://www.sanity.io/docs/http-reference/${options2.slug}`;
|
|
54742
|
+
return output.print(`Opening ${url}`), await browse(url), null;
|
|
54743
|
+
}
|
|
54744
|
+
try {
|
|
54745
|
+
const baseUrl = `https://www.sanity.io/docs/api/openapi/${options2.slug}`, url = new URL(baseUrl), format = options2.format || "yaml";
|
|
54746
|
+
url.searchParams.set("format", format);
|
|
54747
|
+
const response = await fetch(url, {
|
|
54748
|
+
signal: AbortSignal.timeout(1e4)
|
|
54749
|
+
});
|
|
54750
|
+
return response.status === 404 ? (output.error(`OpenAPI specification not found: ${options2.slug}`), null) : (response.ok || (context.output.error("The OpenAPI service is currently unavailable. Please try again later."), process.exit(1)), await response.text());
|
|
54751
|
+
} catch {
|
|
54752
|
+
return context.output.error("The OpenAPI service is currently unavailable. Please try again later."), process.exit(1), null;
|
|
54753
|
+
}
|
|
54754
|
+
}
|
|
54755
|
+
const helpText$7 = `
|
|
54756
|
+
Arguments
|
|
54757
|
+
<slug> Slug of the OpenAPI specification to retrieve
|
|
54758
|
+
|
|
54759
|
+
Options
|
|
54760
|
+
--format <format> Output format: yaml (default), json
|
|
54761
|
+
-w, --web Open in web browser
|
|
54762
|
+
|
|
54763
|
+
Examples
|
|
54764
|
+
# Get a specification (YAML format, default)
|
|
54765
|
+
sanity openapi get query
|
|
54766
|
+
|
|
54767
|
+
# Get specification in JSON format
|
|
54768
|
+
sanity openapi get query --format=json
|
|
54769
|
+
|
|
54770
|
+
# Open specification in browser
|
|
54771
|
+
sanity openapi get query --web
|
|
54772
|
+
sanity openapi get query -w
|
|
54773
|
+
|
|
54774
|
+
# Pipe to file
|
|
54775
|
+
sanity openapi get query > query-api.yaml
|
|
54776
|
+
`, getCommand = {
|
|
54777
|
+
name: "get",
|
|
54778
|
+
group: "openapi",
|
|
54779
|
+
helpText: helpText$7,
|
|
54780
|
+
signature: "<slug> [--format <format>] [-w, --web]",
|
|
54781
|
+
description: "Get an OpenAPI specification by slug",
|
|
54782
|
+
async action(args, context) {
|
|
54783
|
+
const { output } = context, flags = args.extOptions, slug = args.argsWithoutOptions[0];
|
|
54784
|
+
if (!slug || typeof slug != "string") {
|
|
54785
|
+
output.error("Please provide a specification slug"), output.print(""), output.print(helpText$7), process.exit(1);
|
|
54786
|
+
return;
|
|
54787
|
+
}
|
|
54788
|
+
if (flags.format && !["json", "yaml"].includes(flags.format)) {
|
|
54789
|
+
output.error("Invalid format. Supported formats: json, yaml"), output.print(""), output.print(helpText$7), process.exit(1);
|
|
54790
|
+
return;
|
|
54791
|
+
}
|
|
54792
|
+
if (flags.web || flags.w) {
|
|
54793
|
+
await getSpec({ slug, web: !0 }, context);
|
|
54794
|
+
return;
|
|
54795
|
+
}
|
|
54796
|
+
isInteractive$1 && process.stderr.write(`Fetching OpenAPI specification: ${slug}
|
|
54797
|
+
`);
|
|
54798
|
+
const content = await getSpec(
|
|
54799
|
+
{
|
|
54800
|
+
slug,
|
|
54801
|
+
format: flags.format || "yaml"
|
|
54802
|
+
},
|
|
54803
|
+
context
|
|
54804
|
+
);
|
|
54805
|
+
content && output.print(content);
|
|
54806
|
+
}
|
|
54807
|
+
};
|
|
54808
|
+
async function listSpecs(options2, context) {
|
|
54809
|
+
const { output } = context;
|
|
54810
|
+
if (options2.web) {
|
|
54811
|
+
const url = "https://www.sanity.io/docs/http-reference";
|
|
54812
|
+
return output.print(`Opening ${url}`), await browse(url), [];
|
|
54813
|
+
}
|
|
54814
|
+
try {
|
|
54815
|
+
const response = await fetch("https://www.sanity.io/docs/api/openapi", {
|
|
54816
|
+
signal: AbortSignal.timeout(1e4)
|
|
54817
|
+
});
|
|
54818
|
+
response.ok || (context.output.error("The OpenAPI service is currently unavailable. Please try again later."), process.exit(1));
|
|
54819
|
+
const results = await response.json();
|
|
54820
|
+
return Array.isArray(results?.specs) ? results.specs : [];
|
|
54821
|
+
} catch {
|
|
54822
|
+
return context.output.error("The OpenAPI service is currently unavailable. Please try again later."), process.exit(1), [];
|
|
54823
|
+
}
|
|
54824
|
+
}
|
|
54825
|
+
const helpText$6 = `
|
|
54826
|
+
Options
|
|
54827
|
+
--json Output JSON
|
|
54828
|
+
-w, --web Open HTTP Reference in web browser
|
|
54829
|
+
|
|
54830
|
+
Examples
|
|
54831
|
+
# List all available OpenAPI specs
|
|
54832
|
+
sanity openapi list
|
|
54833
|
+
|
|
54834
|
+
# List with JSON output
|
|
54835
|
+
sanity openapi list --json
|
|
54836
|
+
|
|
54837
|
+
# Open HTTP Reference in browser
|
|
54838
|
+
sanity openapi list --web
|
|
54839
|
+
sanity openapi list -w
|
|
54840
|
+
`, listCommand = {
|
|
54841
|
+
name: "list",
|
|
54842
|
+
group: "openapi",
|
|
54843
|
+
helpText: helpText$6,
|
|
54844
|
+
signature: "[--json] [-w, --web]",
|
|
54845
|
+
description: "List all available OpenAPI specifications",
|
|
54846
|
+
async action(args, context) {
|
|
54847
|
+
const { output } = context, flags = args.extOptions;
|
|
54848
|
+
if (flags.web || flags.w) {
|
|
54849
|
+
await listSpecs({ web: !0 }, context);
|
|
54850
|
+
return;
|
|
54851
|
+
}
|
|
54852
|
+
isInteractive$1 && process.stderr.write(`Fetching available OpenAPI specifications...
|
|
54853
|
+
`);
|
|
54854
|
+
const specs = await listSpecs({}, context);
|
|
54855
|
+
if (specs.length === 0) {
|
|
54856
|
+
output.print("No OpenAPI specifications found.");
|
|
54857
|
+
return;
|
|
54858
|
+
}
|
|
54859
|
+
if (flags.json) {
|
|
54860
|
+
output.print(JSON.stringify(specs, null, 2));
|
|
54861
|
+
return;
|
|
54862
|
+
}
|
|
54863
|
+
output.print(`
|
|
54864
|
+
Found ${specs.length} OpenAPI specification(s):
|
|
54865
|
+
`), specs.forEach((spec) => {
|
|
54866
|
+
output.print(`Title: ${spec.title}`), output.print(`Slug: ${spec.slug}`), spec.description && output.print(`Description: ${spec.description}`), output.print("");
|
|
54867
|
+
}), output.print("Use 'sanity openapi get <slug>' to retrieve a specific specification.");
|
|
54868
|
+
}
|
|
54869
|
+
}, openapiGroup = {
|
|
54870
|
+
name: "openapi",
|
|
54871
|
+
signature: "[COMMAND]",
|
|
54872
|
+
isGroupRoot: !0,
|
|
54873
|
+
description: "List, browse, and retrieve Sanity OpenAPI specifications"
|
|
54874
|
+
};
|
|
54738
54875
|
async function hasProjectAttachGrant(orgId, context) {
|
|
54739
54876
|
const requiredGrantGroup = "sanity.organization.projects", requiredGrant = "attach", client2 = context.apiClient({ requireProject: !1, requireUser: !0 }).withConfig({ apiVersion: "v2021-06-07" });
|
|
54740
54877
|
try {
|
|
@@ -55228,6 +55365,9 @@ const baseCommands = [
|
|
|
55228
55365
|
manageCommand,
|
|
55229
55366
|
debugCommand,
|
|
55230
55367
|
command$1,
|
|
55368
|
+
openapiGroup,
|
|
55369
|
+
listCommand,
|
|
55370
|
+
getCommand,
|
|
55231
55371
|
projectGroup,
|
|
55232
55372
|
learnCommand,
|
|
55233
55373
|
listProjectsCommand,
|