@sanity/cli 4.5.0-next.9 → 4.5.0-next.90
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 +10 -52
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/_chunks-cjs/getCliConfig.js +4 -25
- package/lib/_chunks-cjs/getCliConfig.js.map +1 -1
- package/lib/cli.js +1 -3
- package/lib/cli.js.map +1 -1
- package/lib/index.d.mts +15 -38
- package/lib/index.d.ts +15 -38
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +3 -24
- package/lib/index.mjs.map +1 -1
- package/package.json +30 -30
package/lib/_chunks-cjs/cli.js
CHANGED
|
@@ -18,7 +18,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
18
18
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
19
19
|
mod
|
|
20
20
|
));
|
|
21
|
-
var
|
|
21
|
+
var os = require("node:os"), chalk = require("chalk"), loadEnv = require("./loadEnv.js"), require$$0$5 = require("path"), require$$1$2 = require("module"), require$$0$4 = require("fs"), telemetry = require("@sanity/telemetry"), childProcess = require("node:child_process"), fs$1 = require("node:fs"), path$3 = require("node:path"), fs = require("node:fs/promises"), util$4 = require("node:util"), require$$0$6 = require("os"), require$$5$1 = require("url"), require$$1$3 = require("get-it"), require$$2$1 = require("get-it/middleware"), require$$0$7 = require("constants"), require$$0$8 = require("stream"), require$$0$9 = require("util"), require$$0$a = require("assert"), require$$0$b = require("events"), require$$6$1 = require("http"), semver = require("semver"), pkgDir = require("pkg-dir"), client$1 = require("@sanity/client"), require$$3$1 = require("crypto"), require$$1$4 = require("child_process"), getCliConfig = require("./getCliConfig.js"), require$$0$c = require("fs/promises"), require$$0$d = require("buffer"), journeyConfig = require("./journeyConfig.js"), Stream = require("node:stream"), promises$1 = require("node:stream/promises"), templateValidator = require("@sanity/template-validator"), require$$2$2 = require("string_decoder"), require$$0$e = require("zlib"), require$$7$1 = require("process"), http = require("node:http"), traverse = require("@babel/traverse"), node_url = require("node:url"), node_events = require("node:events"), node_string_decoder = require("node:string_decoder"), process$2 = require("node:process"), require$$2$3 = require("readline"), require$$0$f = require("tty");
|
|
22
22
|
function _interopDefaultCompat(e) {
|
|
23
23
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
24
24
|
}
|
|
@@ -52,7 +52,7 @@ function _mergeNamespaces(n, m) {
|
|
|
52
52
|
});
|
|
53
53
|
}), Object.freeze(n);
|
|
54
54
|
}
|
|
55
|
-
var
|
|
55
|
+
var os__default = /* @__PURE__ */ _interopDefaultCompat(os), chalk__default = /* @__PURE__ */ _interopDefaultCompat(chalk), require$$0__default$1 = /* @__PURE__ */ _interopDefaultCompat(require$$0$5), require$$1__default = /* @__PURE__ */ _interopDefaultCompat(require$$1$2), require$$0__default = /* @__PURE__ */ _interopDefaultCompat(require$$0$4), childProcess__default = /* @__PURE__ */ _interopDefaultCompat(childProcess), fs__namespace = /* @__PURE__ */ _interopNamespaceCompat(fs$1), path__default = /* @__PURE__ */ _interopDefaultCompat(path$3), fs__default = /* @__PURE__ */ _interopDefaultCompat(fs), util__default = /* @__PURE__ */ _interopDefaultCompat(util$4), require$$0__default$2 = /* @__PURE__ */ _interopDefaultCompat(require$$0$6), require$$5__default = /* @__PURE__ */ _interopDefaultCompat(require$$5$1), require$$1__default$1 = /* @__PURE__ */ _interopDefaultCompat(require$$1$3), require$$2__default = /* @__PURE__ */ _interopDefaultCompat(require$$2$1), require$$0__default$3 = /* @__PURE__ */ _interopDefaultCompat(require$$0$7), require$$0__default$4 = /* @__PURE__ */ _interopDefaultCompat(require$$0$8), require$$0__default$5 = /* @__PURE__ */ _interopDefaultCompat(require$$0$9), require$$0__default$6 = /* @__PURE__ */ _interopDefaultCompat(require$$0$a), require$$0__default$7 = /* @__PURE__ */ _interopDefaultCompat(require$$0$b), require$$6__default = /* @__PURE__ */ _interopDefaultCompat(require$$6$1), semver__default = /* @__PURE__ */ _interopDefaultCompat(semver), pkgDir__default = /* @__PURE__ */ _interopDefaultCompat(pkgDir), require$$3__default = /* @__PURE__ */ _interopDefaultCompat(require$$3$1), require$$1__default$2 = /* @__PURE__ */ _interopDefaultCompat(require$$1$4), require$$0__default$8 = /* @__PURE__ */ _interopDefaultCompat(require$$0$c), require$$0__default$9 = /* @__PURE__ */ _interopDefaultCompat(require$$0$d), Stream__default = /* @__PURE__ */ _interopDefaultCompat(Stream), require$$2__default$1 = /* @__PURE__ */ _interopDefaultCompat(require$$2$2), require$$0__default$a = /* @__PURE__ */ _interopDefaultCompat(require$$0$e), require$$7__default = /* @__PURE__ */ _interopDefaultCompat(require$$7$1), http__default = /* @__PURE__ */ _interopDefaultCompat(http), traverse__default = /* @__PURE__ */ _interopDefaultCompat(traverse), process__default = /* @__PURE__ */ _interopDefaultCompat(process$2), require$$2__default$2 = /* @__PURE__ */ _interopDefaultCompat(require$$2$3), require$$0__default$b = /* @__PURE__ */ _interopDefaultCompat(require$$0$f), resolveFrom$1 = { exports: {} }, hasRequiredResolveFrom;
|
|
56
56
|
function requireResolveFrom() {
|
|
57
57
|
if (hasRequiredResolveFrom) return resolveFrom$1.exports;
|
|
58
58
|
hasRequiredResolveFrom = 1;
|
|
@@ -48249,7 +48249,6 @@ const portMap = {
|
|
|
48249
48249
|
parcel: 1234,
|
|
48250
48250
|
fasthtml: 8e3,
|
|
48251
48251
|
sanity: 3333,
|
|
48252
|
-
"sanity-v3": 3333,
|
|
48253
48252
|
storybook: 6006
|
|
48254
48253
|
};
|
|
48255
48254
|
function getDefaultPortForFramework(frameworkSlug) {
|
|
@@ -54664,10 +54663,7 @@ Examples
|
|
|
54664
54663
|
helpText: "",
|
|
54665
54664
|
description: "Installs dependencies for Sanity Studio project",
|
|
54666
54665
|
action: async (args, context) => {
|
|
54667
|
-
const { workDir, prompt: prompt2
|
|
54668
|
-
if (packages.length > 0 && sanityMajorVersion === 2)
|
|
54669
|
-
throw new Error("Re-run this command with `@sanity/core` installed");
|
|
54670
|
-
const pkgManager = await getPackageManagerChoice(workDir, { prompt: prompt2 });
|
|
54666
|
+
const { workDir, prompt: prompt2 } = context, packages = args.argsWithoutOptions, pkgManager = await getPackageManagerChoice(workDir, { prompt: prompt2 });
|
|
54671
54667
|
packages.length > 0 ? await installNewPackages(
|
|
54672
54668
|
{ packageManager: pkgManager.chosen, packages: args.argsWithoutOptions },
|
|
54673
54669
|
context
|
|
@@ -79627,7 +79623,7 @@ class CommandRunner {
|
|
|
79627
79623
|
!isCommandGroup(command2) && command2.group && command2.group !== "default" && (cmdArgs.argsWithoutOptions = args.argsWithoutOptions.slice(1));
|
|
79628
79624
|
const output = this.handlers.outputter, prompt2 = this.handlers.prompter, { cliConfig, ...commandOptions } = options2, apiClient = getClientWrapper(
|
|
79629
79625
|
cliConfig?.config?.api || null,
|
|
79630
|
-
cliConfig?.path ||
|
|
79626
|
+
cliConfig?.path || "sanity.cli.js"
|
|
79631
79627
|
), context = {
|
|
79632
79628
|
output,
|
|
79633
79629
|
prompt: prompt2,
|
|
@@ -79635,8 +79631,11 @@ class CommandRunner {
|
|
|
79635
79631
|
chalk: chalk__default.default,
|
|
79636
79632
|
cliPackageManager,
|
|
79637
79633
|
...commandOptions,
|
|
79634
|
+
// @ts-expect-error - keep for legacy purposes
|
|
79635
|
+
sanityMajorVersion: 3,
|
|
79638
79636
|
commandRunner: this,
|
|
79639
|
-
|
|
79637
|
+
cliConfig: cliConfig?.config || void 0,
|
|
79638
|
+
cliConfigPath: cliConfig?.path || void 0
|
|
79640
79639
|
};
|
|
79641
79640
|
if (isCommandGroup(command2))
|
|
79642
79641
|
return context.output.print(generateCommandsDocumentation(this.commandGroups, command2.name));
|
|
@@ -79705,17 +79704,6 @@ function getCliRunner(commands) {
|
|
|
79705
79704
|
commands
|
|
79706
79705
|
);
|
|
79707
79706
|
}
|
|
79708
|
-
function getVersionedContextParams(cliConfig) {
|
|
79709
|
-
return cliConfig?.version === 2 ? {
|
|
79710
|
-
sanityMajorVersion: 2,
|
|
79711
|
-
cliConfig: cliConfig?.config || void 0,
|
|
79712
|
-
cliConfigPath: cliConfig?.path || void 0
|
|
79713
|
-
} : {
|
|
79714
|
-
sanityMajorVersion: 3,
|
|
79715
|
-
cliConfig: cliConfig?.config || void 0,
|
|
79716
|
-
cliConfigPath: cliConfig?.path || void 0
|
|
79717
|
-
};
|
|
79718
|
-
}
|
|
79719
79707
|
function detectRuntime() {
|
|
79720
79708
|
return "Deno" in globalThis ? "deno" : "Bun" in globalThis ? "bun" : "node";
|
|
79721
79709
|
}
|
|
@@ -80360,33 +80348,10 @@ ${err.cause.stack ? neatStack(err.cause) : err.cause}`), cliCommandTrace.error(e
|
|
|
80360
80348
|
});
|
|
80361
80349
|
}
|
|
80362
80350
|
async function getCoreModulePath(workDir, cliConfig) {
|
|
80363
|
-
const
|
|
80364
|
-
if (corePath && sanityPath) {
|
|
80365
|
-
const closest = corePath.startsWith(workDir) ? corePath : sanityPath, assumedVersion = closest === corePath ? "v2" : "v3";
|
|
80366
|
-
return console.warn(
|
|
80367
|
-
chalk__default.default.yellow(
|
|
80368
|
-
`Both \`@sanity/core\` AND \`sanity\` installed - assuming Sanity ${assumedVersion} project.`
|
|
80369
|
-
)
|
|
80370
|
-
), closest;
|
|
80371
|
-
}
|
|
80351
|
+
const sanityPath = resolveFrom.silent(workDir, "sanity/_internal");
|
|
80372
80352
|
if (sanityPath)
|
|
80373
80353
|
return sanityPath;
|
|
80374
|
-
if (
|
|
80375
|
-
return corePath;
|
|
80376
|
-
const isInstallCommand = process.argv.indexOf("install") === -1;
|
|
80377
|
-
if (cliConfig && cliConfig?.version < 3 && !corePath && !isInstallCommand) {
|
|
80378
|
-
const installCmd = await getInstallCommand({ workDir });
|
|
80379
|
-
console.warn(
|
|
80380
|
-
chalk__default.default.yellow(
|
|
80381
|
-
[
|
|
80382
|
-
"The `@sanity/core` module is not installed in current project",
|
|
80383
|
-
`Project-specific commands not available until you run \`${installCmd}\``
|
|
80384
|
-
].join(`
|
|
80385
|
-
`)
|
|
80386
|
-
)
|
|
80387
|
-
);
|
|
80388
|
-
}
|
|
80389
|
-
if (cliConfig && cliConfig.version >= 3 && !sanityPath) {
|
|
80354
|
+
if (cliConfig && !sanityPath) {
|
|
80390
80355
|
const installCmd = await getInstallCommand({ workDir });
|
|
80391
80356
|
console.warn(
|
|
80392
80357
|
chalk__default.default.yellow(
|
|
@@ -80437,13 +80402,6 @@ function loadAndSetEnvFromDotEnvFiles({
|
|
|
80437
80402
|
cmd,
|
|
80438
80403
|
isApp
|
|
80439
80404
|
}) {
|
|
80440
|
-
if (fs$1.existsSync(path__default.default.join(workDir, "sanity.json"))) {
|
|
80441
|
-
getCliConfig.debug("sanity.json exists, assuming v2 project and loading .env files using old behavior");
|
|
80442
|
-
const env = process.env.SANITY_ACTIVE_ENV || process.env.NODE_ENV || "development";
|
|
80443
|
-
getCliConfig.debug("Loading environment files using %s mode", env), loadEnv.dotenv.config({ path: path__default.default.join(workDir, `.env.${env}`) });
|
|
80444
|
-
return;
|
|
80445
|
-
}
|
|
80446
|
-
getCliConfig.debug("No sanity.json exists, assuming v3 project and loading .env files using new behavior");
|
|
80447
80405
|
const isProdCmd = ["build", "deploy"].includes(cmd);
|
|
80448
80406
|
let mode2 = process.env.SANITY_ACTIVE_ENV;
|
|
80449
80407
|
!mode2 && (isProdCmd || process.env.NODE_ENV === "production") ? mode2 = "production" : mode2 || (mode2 = "development"), mode2 === "production" && !isProdCmd && console.warn(chalk__default.default.yellow(`[WARN] Running in ${sanityEnv} environment mode
|