@sanity/cli 3.67.1 → 3.67.2-content-os.38
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 +140 -381
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/index.d.mts +1 -0
- package/lib/index.d.ts +1 -0
- package/package.json +8 -9
- package/src/actions/init-project/bootstrapRemoteTemplate.ts +10 -2
- package/src/actions/init-project/initProject.ts +28 -51
- package/src/actions/login/login.ts +2 -3
- package/src/commands/logout/logoutCommand.ts +1 -1
- package/src/outputters/cliOutputter.ts +21 -8
- package/src/types.ts +1 -0
- package/src/util/frameworkPort.ts +63 -0
- package/src/util/generateCommandsDocumentation.ts +7 -4
- package/src/util/remoteTemplate.ts +43 -209
package/lib/_chunks-cjs/cli.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"use strict";
|
2
|
-
var fs$1 = require("node:fs"), os = require("node:os"), path$3 = require("node:path"), chalk = require("chalk"), loadEnv = require("./loadEnv.js"), require$$0$4 = require("path"), require$$1$2 = require("module"), require$$0$5 = require("fs"), telemetry = require("@sanity/telemetry"), childProcess = require("node:child_process"), fs = require("node:fs/promises"), util$4 = require("node:util"), require$$0$6 = require("os"), require$$0$c = 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$a = require("util"), require$$0$9 = 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"), require$$0$d = require("fs/promises"), require$$0$e = require("buffer"), silverFleece = require("silver-fleece"), getCliConfig = require("./getCliConfig.js"), journeyConfig = require("./journeyConfig.js"), Stream = require("node:stream"), promises$1 = require("node:stream/promises"), require$$
|
2
|
+
var fs$1 = require("node:fs"), os = require("node:os"), path$3 = require("node:path"), chalk = require("chalk"), loadEnv = require("./loadEnv.js"), require$$0$4 = require("path"), require$$1$2 = require("module"), require$$0$5 = require("fs"), telemetry = require("@sanity/telemetry"), childProcess = require("node:child_process"), fs = require("node:fs/promises"), util$4 = require("node:util"), require$$0$6 = require("os"), require$$0$c = 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$a = require("util"), require$$0$9 = 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"), require$$0$d = require("fs/promises"), require$$0$e = require("buffer"), silverFleece = require("silver-fleece"), getCliConfig = require("./getCliConfig.js"), 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$f = 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$g = require("tty");
|
3
3
|
function _interopDefaultCompat(e) {
|
4
4
|
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
5
5
|
}
|
@@ -33,7 +33,7 @@ function _mergeNamespaces(n, m) {
|
|
33
33
|
});
|
34
34
|
}), Object.freeze(n);
|
35
35
|
}
|
36
|
-
var fs__namespace = /* @__PURE__ */ _interopNamespaceCompat(fs$1), os__default = /* @__PURE__ */ _interopDefaultCompat(os), path__default = /* @__PURE__ */ _interopDefaultCompat(path$3), chalk__default = /* @__PURE__ */ _interopDefaultCompat(chalk), require$$0__default = /* @__PURE__ */ _interopDefaultCompat(require$$0$4), require$$1__default = /* @__PURE__ */ _interopDefaultCompat(require$$1$2), require$$0__default$1 = /* @__PURE__ */ _interopDefaultCompat(require$$0$5), childProcess__default = /* @__PURE__ */ _interopDefaultCompat(childProcess), fs__default = /* @__PURE__ */ _interopDefaultCompat(fs), util__default = /* @__PURE__ */ _interopDefaultCompat(util$4), require$$0__default$2 = /* @__PURE__ */ _interopDefaultCompat(require$$0$6), require$$0__default$8 = /* @__PURE__ */ _interopDefaultCompat(require$$0$c), 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$6 = /* @__PURE__ */ _interopDefaultCompat(require$$0$a), require$$0__default$5 = /* @__PURE__ */ _interopDefaultCompat(require$$0$9), 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$9 = /* @__PURE__ */ _interopDefaultCompat(require$$0$d), require$$0__default$a = /* @__PURE__ */ _interopDefaultCompat(require$$0$e), Stream__default = /* @__PURE__ */ _interopDefaultCompat(Stream), require$$0__default$b = /* @__PURE__ */ _interopDefaultCompat(require$$0$f), 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$
|
36
|
+
var fs__namespace = /* @__PURE__ */ _interopNamespaceCompat(fs$1), os__default = /* @__PURE__ */ _interopDefaultCompat(os), path__default = /* @__PURE__ */ _interopDefaultCompat(path$3), chalk__default = /* @__PURE__ */ _interopDefaultCompat(chalk), require$$0__default = /* @__PURE__ */ _interopDefaultCompat(require$$0$4), require$$1__default = /* @__PURE__ */ _interopDefaultCompat(require$$1$2), require$$0__default$1 = /* @__PURE__ */ _interopDefaultCompat(require$$0$5), childProcess__default = /* @__PURE__ */ _interopDefaultCompat(childProcess), fs__default = /* @__PURE__ */ _interopDefaultCompat(fs), util__default = /* @__PURE__ */ _interopDefaultCompat(util$4), require$$0__default$2 = /* @__PURE__ */ _interopDefaultCompat(require$$0$6), require$$0__default$8 = /* @__PURE__ */ _interopDefaultCompat(require$$0$c), 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$6 = /* @__PURE__ */ _interopDefaultCompat(require$$0$a), require$$0__default$5 = /* @__PURE__ */ _interopDefaultCompat(require$$0$9), 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$9 = /* @__PURE__ */ _interopDefaultCompat(require$$0$d), require$$0__default$a = /* @__PURE__ */ _interopDefaultCompat(require$$0$e), Stream__default = /* @__PURE__ */ _interopDefaultCompat(Stream), require$$2__default$1 = /* @__PURE__ */ _interopDefaultCompat(require$$2$2), require$$0__default$b = /* @__PURE__ */ _interopDefaultCompat(require$$0$f), 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$c = /* @__PURE__ */ _interopDefaultCompat(require$$0$g), resolveFrom$1 = { exports: {} }, hasRequiredResolveFrom;
|
37
37
|
function requireResolveFrom() {
|
38
38
|
if (hasRequiredResolveFrom) return resolveFrom$1.exports;
|
39
39
|
hasRequiredResolveFrom = 1;
|
@@ -7519,19 +7519,22 @@ function generateCommandsDocumentation(commandGroups, group = "default") {
|
|
7519
7519
|
throw new Error(getNoSuchCommandText(group));
|
7520
7520
|
const cmdLength = commands.reduce((max2, cmd) => Math.max(cmd.name.length, max2), 0), prefix = group === "default" ? "" : ` ${group}`;
|
7521
7521
|
return [
|
7522
|
-
`usage: sanity${prefix} [--default] [-v|--version] [-d|--debug] [-h|--help] <command> [<args>]`,
|
7522
|
+
`usage: npx sanity${prefix} [--default] [-v|--version] [-d|--debug] [-h|--help] <command> [<args>]`,
|
7523
7523
|
"",
|
7524
7524
|
"Commands:"
|
7525
|
-
].concat(commands.map((cmd) => ` ${lodashExports.padEnd(cmd.name, cmdLength + 1)} ${cmd.description}`)).concat([
|
7525
|
+
].concat(commands.map((cmd) => ` ${lodashExports.padEnd(cmd.name, cmdLength + 1)} ${cmd.description}`)).concat([
|
7526
|
+
"",
|
7527
|
+
`See 'npx sanity help${prefix} <command>' for specific information on a subcommand.`
|
7528
|
+
]).join(`
|
7526
7529
|
`);
|
7527
7530
|
}
|
7528
7531
|
function generateCommandDocumentation(command2, group, subCommand) {
|
7529
7532
|
if (!command2)
|
7530
7533
|
throw new Error(
|
7531
|
-
subCommand ? `"${subCommand}" is not a subcommand of "${group}". See 'sanity help ${group}'` : getNoSuchCommandText(group || command2)
|
7534
|
+
subCommand ? `"${subCommand}" is not a subcommand of "${group}". See 'npx sanity help ${group}'` : getNoSuchCommandText(group || command2)
|
7532
7535
|
);
|
7533
7536
|
return [
|
7534
|
-
`usage: sanity ${[group || command2.name, subCommand].filter(Boolean).join(" ")} ${command2.signature}`,
|
7537
|
+
`usage: npx sanity ${[group || command2.name, subCommand].filter(Boolean).join(" ")} ${command2.signature}`,
|
7535
7538
|
"",
|
7536
7539
|
` ${command2.description}`,
|
7537
7540
|
"",
|
@@ -9064,8 +9067,8 @@ var jsYaml$3, hasRequiredJsYaml$3;
|
|
9064
9067
|
function requireJsYaml$3() {
|
9065
9068
|
if (hasRequiredJsYaml$3) return jsYaml$3;
|
9066
9069
|
hasRequiredJsYaml$3 = 1;
|
9067
|
-
var
|
9068
|
-
return jsYaml$3 =
|
9070
|
+
var yaml = requireJsYaml$4();
|
9071
|
+
return jsYaml$3 = yaml, jsYaml$3;
|
9069
9072
|
}
|
9070
9073
|
var toml = {}, parse$2 = { exports: {} }, tomlParser = { exports: {} }, parser$2, hasRequiredParser$1;
|
9071
9074
|
function requireParser$1() {
|
@@ -18944,7 +18947,7 @@ function requirePFilter() {
|
|
18944
18947
|
)).filter((value) => !!value[0]).map((value) => value[1]);
|
18945
18948
|
return pFilter$1.exports = pFilter2, pFilter$1.exports.default = pFilter2, pFilter$1.exports;
|
18946
18949
|
}
|
18947
|
-
var pFilterExports = requirePFilter(), pFilter = /* @__PURE__ */ loadEnv.getDefaultExportFromCjs(pFilterExports)
|
18950
|
+
var pFilterExports = requirePFilter(), pFilter = /* @__PURE__ */ loadEnv.getDefaultExportFromCjs(pFilterExports);
|
18948
18951
|
const CLIInitStepCompleted = telemetry.defineTrace({
|
18949
18952
|
name: "CLI Init Step Completed",
|
18950
18953
|
version: 1,
|
@@ -22410,14 +22413,14 @@ var jsYaml, hasRequiredJsYaml;
|
|
22410
22413
|
function requireJsYaml() {
|
22411
22414
|
if (hasRequiredJsYaml) return jsYaml;
|
22412
22415
|
hasRequiredJsYaml = 1;
|
22413
|
-
var
|
22414
|
-
return jsYaml =
|
22416
|
+
var yaml = requireJsYaml$1();
|
22417
|
+
return jsYaml = yaml, jsYaml;
|
22415
22418
|
}
|
22416
22419
|
var hasRequiredLoadYamlFile;
|
22417
22420
|
function requireLoadYamlFile() {
|
22418
22421
|
if (hasRequiredLoadYamlFile) return loadYamlFile.exports;
|
22419
22422
|
hasRequiredLoadYamlFile = 1;
|
22420
|
-
const fs2 = requireGracefulFs(), pify2 = requirePify(), stripBom2 = requireStripBom(),
|
22423
|
+
const fs2 = requireGracefulFs(), pify2 = requirePify(), stripBom2 = requireStripBom(), yaml = requireJsYaml(), parse3 = (data) => yaml.safeLoad(stripBom2(data));
|
22421
22424
|
return loadYamlFile.exports = (fp) => pify2(fs2.readFile)(fp, "utf8").then((data) => parse3(data)), loadYamlFile.exports.sync = (fp) => parse3(fs2.readFileSync(fp, "utf8")), loadYamlFile.exports;
|
22422
22425
|
}
|
22423
22426
|
var whichPm, hasRequiredWhichPm;
|
@@ -22507,7 +22510,7 @@ function requirePreferredPm() {
|
|
22507
22510
|
return pm && { name: pm.name, version: pm.version || "*" };
|
22508
22511
|
}, preferredPm;
|
22509
22512
|
}
|
22510
|
-
var preferredPmExports = requirePreferredPm(), preferredPM = /* @__PURE__ */ loadEnv.getDefaultExportFromCjs(preferredPmExports);
|
22513
|
+
var preferredPmExports = requirePreferredPm(), preferredPM = /* @__PURE__ */ loadEnv.getDefaultExportFromCjs(preferredPmExports), whichExports = requireWhich(), which = /* @__PURE__ */ loadEnv.getDefaultExportFromCjs(whichExports);
|
22511
22514
|
const isInteractive$1 = process.stdout.isTTY && process.env.TERM !== "dumb" && !("CI" in process.env), ALLOWED_PACKAGE_MANAGERS = ["npm", "yarn", "pnpm", "bun", "manual"], allowedPackageManagersString = ALLOWED_PACKAGE_MANAGERS.map((pm) => `"${pm}"`).join(
|
22512
22515
|
" | "
|
22513
22516
|
), EXPERIMENTAL = ["bun"];
|
@@ -23198,206 +23201,14 @@ function requireHighLevelOpt() {
|
|
23198
23201
|
opt[k]
|
23199
23202
|
]).reduce((set2, kv) => (set2[kv[0]] = kv[1], set2), /* @__PURE__ */ Object.create(null)) : {}, highLevelOpt;
|
23200
23203
|
}
|
23201
|
-
var minipass$1 = {},
|
23202
|
-
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
23203
|
-
var hasRequiredSafeBuffer;
|
23204
|
-
function requireSafeBuffer() {
|
23205
|
-
return hasRequiredSafeBuffer || (hasRequiredSafeBuffer = 1, function(module2, exports2) {
|
23206
|
-
var buffer2 = require$$0__default$a.default, Buffer2 = buffer2.Buffer;
|
23207
|
-
function copyProps(src2, dst) {
|
23208
|
-
for (var key2 in src2)
|
23209
|
-
dst[key2] = src2[key2];
|
23210
|
-
}
|
23211
|
-
Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow ? module2.exports = buffer2 : (copyProps(buffer2, exports2), exports2.Buffer = SafeBuffer);
|
23212
|
-
function SafeBuffer(arg, encodingOrOffset, length) {
|
23213
|
-
return Buffer2(arg, encodingOrOffset, length);
|
23214
|
-
}
|
23215
|
-
SafeBuffer.prototype = Object.create(Buffer2.prototype), copyProps(Buffer2, SafeBuffer), SafeBuffer.from = function(arg, encodingOrOffset, length) {
|
23216
|
-
if (typeof arg == "number")
|
23217
|
-
throw new TypeError("Argument must not be a number");
|
23218
|
-
return Buffer2(arg, encodingOrOffset, length);
|
23219
|
-
}, SafeBuffer.alloc = function(size, fill, encoding) {
|
23220
|
-
if (typeof size != "number")
|
23221
|
-
throw new TypeError("Argument must be a number");
|
23222
|
-
var buf = Buffer2(size);
|
23223
|
-
return fill !== void 0 ? typeof encoding == "string" ? buf.fill(fill, encoding) : buf.fill(fill) : buf.fill(0), buf;
|
23224
|
-
}, SafeBuffer.allocUnsafe = function(size) {
|
23225
|
-
if (typeof size != "number")
|
23226
|
-
throw new TypeError("Argument must be a number");
|
23227
|
-
return Buffer2(size);
|
23228
|
-
}, SafeBuffer.allocUnsafeSlow = function(size) {
|
23229
|
-
if (typeof size != "number")
|
23230
|
-
throw new TypeError("Argument must be a number");
|
23231
|
-
return buffer2.SlowBuffer(size);
|
23232
|
-
};
|
23233
|
-
}(safeBuffer, safeBuffer.exports)), safeBuffer.exports;
|
23234
|
-
}
|
23235
|
-
var hasRequiredString_decoder;
|
23236
|
-
function requireString_decoder() {
|
23237
|
-
if (hasRequiredString_decoder) return string_decoder;
|
23238
|
-
hasRequiredString_decoder = 1;
|
23239
|
-
var Buffer2 = requireSafeBuffer().Buffer, isEncoding = Buffer2.isEncoding || function(encoding) {
|
23240
|
-
switch (encoding = "" + encoding, encoding && encoding.toLowerCase()) {
|
23241
|
-
case "hex":
|
23242
|
-
case "utf8":
|
23243
|
-
case "utf-8":
|
23244
|
-
case "ascii":
|
23245
|
-
case "binary":
|
23246
|
-
case "base64":
|
23247
|
-
case "ucs2":
|
23248
|
-
case "ucs-2":
|
23249
|
-
case "utf16le":
|
23250
|
-
case "utf-16le":
|
23251
|
-
case "raw":
|
23252
|
-
return !0;
|
23253
|
-
default:
|
23254
|
-
return !1;
|
23255
|
-
}
|
23256
|
-
};
|
23257
|
-
function _normalizeEncoding(enc) {
|
23258
|
-
if (!enc) return "utf8";
|
23259
|
-
for (var retried; ; )
|
23260
|
-
switch (enc) {
|
23261
|
-
case "utf8":
|
23262
|
-
case "utf-8":
|
23263
|
-
return "utf8";
|
23264
|
-
case "ucs2":
|
23265
|
-
case "ucs-2":
|
23266
|
-
case "utf16le":
|
23267
|
-
case "utf-16le":
|
23268
|
-
return "utf16le";
|
23269
|
-
case "latin1":
|
23270
|
-
case "binary":
|
23271
|
-
return "latin1";
|
23272
|
-
case "base64":
|
23273
|
-
case "ascii":
|
23274
|
-
case "hex":
|
23275
|
-
return enc;
|
23276
|
-
default:
|
23277
|
-
if (retried) return;
|
23278
|
-
enc = ("" + enc).toLowerCase(), retried = !0;
|
23279
|
-
}
|
23280
|
-
}
|
23281
|
-
function normalizeEncoding(enc) {
|
23282
|
-
var nenc = _normalizeEncoding(enc);
|
23283
|
-
if (typeof nenc != "string" && (Buffer2.isEncoding === isEncoding || !isEncoding(enc))) throw new Error("Unknown encoding: " + enc);
|
23284
|
-
return nenc || enc;
|
23285
|
-
}
|
23286
|
-
string_decoder.StringDecoder = StringDecoder;
|
23287
|
-
function StringDecoder(encoding) {
|
23288
|
-
this.encoding = normalizeEncoding(encoding);
|
23289
|
-
var nb;
|
23290
|
-
switch (this.encoding) {
|
23291
|
-
case "utf16le":
|
23292
|
-
this.text = utf16Text, this.end = utf16End, nb = 4;
|
23293
|
-
break;
|
23294
|
-
case "utf8":
|
23295
|
-
this.fillLast = utf8FillLast, nb = 4;
|
23296
|
-
break;
|
23297
|
-
case "base64":
|
23298
|
-
this.text = base64Text, this.end = base64End, nb = 3;
|
23299
|
-
break;
|
23300
|
-
default:
|
23301
|
-
this.write = simpleWrite, this.end = simpleEnd;
|
23302
|
-
return;
|
23303
|
-
}
|
23304
|
-
this.lastNeed = 0, this.lastTotal = 0, this.lastChar = Buffer2.allocUnsafe(nb);
|
23305
|
-
}
|
23306
|
-
StringDecoder.prototype.write = function(buf) {
|
23307
|
-
if (buf.length === 0) return "";
|
23308
|
-
var r, i;
|
23309
|
-
if (this.lastNeed) {
|
23310
|
-
if (r = this.fillLast(buf), r === void 0) return "";
|
23311
|
-
i = this.lastNeed, this.lastNeed = 0;
|
23312
|
-
} else
|
23313
|
-
i = 0;
|
23314
|
-
return i < buf.length ? r ? r + this.text(buf, i) : this.text(buf, i) : r || "";
|
23315
|
-
}, StringDecoder.prototype.end = utf8End, StringDecoder.prototype.text = utf8Text, StringDecoder.prototype.fillLast = function(buf) {
|
23316
|
-
if (this.lastNeed <= buf.length)
|
23317
|
-
return buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed), this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
23318
|
-
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length), this.lastNeed -= buf.length;
|
23319
|
-
};
|
23320
|
-
function utf8CheckByte(byte) {
|
23321
|
-
return byte <= 127 ? 0 : byte >> 5 === 6 ? 2 : byte >> 4 === 14 ? 3 : byte >> 3 === 30 ? 4 : byte >> 6 === 2 ? -1 : -2;
|
23322
|
-
}
|
23323
|
-
function utf8CheckIncomplete(self2, buf, i) {
|
23324
|
-
var j = buf.length - 1;
|
23325
|
-
if (j < i) return 0;
|
23326
|
-
var nb = utf8CheckByte(buf[j]);
|
23327
|
-
return nb >= 0 ? (nb > 0 && (self2.lastNeed = nb - 1), nb) : --j < i || nb === -2 ? 0 : (nb = utf8CheckByte(buf[j]), nb >= 0 ? (nb > 0 && (self2.lastNeed = nb - 2), nb) : --j < i || nb === -2 ? 0 : (nb = utf8CheckByte(buf[j]), nb >= 0 ? (nb > 0 && (nb === 2 ? nb = 0 : self2.lastNeed = nb - 3), nb) : 0));
|
23328
|
-
}
|
23329
|
-
function utf8CheckExtraBytes(self2, buf, p) {
|
23330
|
-
if ((buf[0] & 192) !== 128)
|
23331
|
-
return self2.lastNeed = 0, "\uFFFD";
|
23332
|
-
if (self2.lastNeed > 1 && buf.length > 1) {
|
23333
|
-
if ((buf[1] & 192) !== 128)
|
23334
|
-
return self2.lastNeed = 1, "\uFFFD";
|
23335
|
-
if (self2.lastNeed > 2 && buf.length > 2 && (buf[2] & 192) !== 128)
|
23336
|
-
return self2.lastNeed = 2, "\uFFFD";
|
23337
|
-
}
|
23338
|
-
}
|
23339
|
-
function utf8FillLast(buf) {
|
23340
|
-
var p = this.lastTotal - this.lastNeed, r = utf8CheckExtraBytes(this, buf);
|
23341
|
-
if (r !== void 0) return r;
|
23342
|
-
if (this.lastNeed <= buf.length)
|
23343
|
-
return buf.copy(this.lastChar, p, 0, this.lastNeed), this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
23344
|
-
buf.copy(this.lastChar, p, 0, buf.length), this.lastNeed -= buf.length;
|
23345
|
-
}
|
23346
|
-
function utf8Text(buf, i) {
|
23347
|
-
var total = utf8CheckIncomplete(this, buf, i);
|
23348
|
-
if (!this.lastNeed) return buf.toString("utf8", i);
|
23349
|
-
this.lastTotal = total;
|
23350
|
-
var end = buf.length - (total - this.lastNeed);
|
23351
|
-
return buf.copy(this.lastChar, 0, end), buf.toString("utf8", i, end);
|
23352
|
-
}
|
23353
|
-
function utf8End(buf) {
|
23354
|
-
var r = buf && buf.length ? this.write(buf) : "";
|
23355
|
-
return this.lastNeed ? r + "\uFFFD" : r;
|
23356
|
-
}
|
23357
|
-
function utf16Text(buf, i) {
|
23358
|
-
if ((buf.length - i) % 2 === 0) {
|
23359
|
-
var r = buf.toString("utf16le", i);
|
23360
|
-
if (r) {
|
23361
|
-
var c2 = r.charCodeAt(r.length - 1);
|
23362
|
-
if (c2 >= 55296 && c2 <= 56319)
|
23363
|
-
return this.lastNeed = 2, this.lastTotal = 4, this.lastChar[0] = buf[buf.length - 2], this.lastChar[1] = buf[buf.length - 1], r.slice(0, -1);
|
23364
|
-
}
|
23365
|
-
return r;
|
23366
|
-
}
|
23367
|
-
return this.lastNeed = 1, this.lastTotal = 2, this.lastChar[0] = buf[buf.length - 1], buf.toString("utf16le", i, buf.length - 1);
|
23368
|
-
}
|
23369
|
-
function utf16End(buf) {
|
23370
|
-
var r = buf && buf.length ? this.write(buf) : "";
|
23371
|
-
if (this.lastNeed) {
|
23372
|
-
var end = this.lastTotal - this.lastNeed;
|
23373
|
-
return r + this.lastChar.toString("utf16le", 0, end);
|
23374
|
-
}
|
23375
|
-
return r;
|
23376
|
-
}
|
23377
|
-
function base64Text(buf, i) {
|
23378
|
-
var n = (buf.length - i) % 3;
|
23379
|
-
return n === 0 ? buf.toString("base64", i) : (this.lastNeed = 3 - n, this.lastTotal = 3, n === 1 ? this.lastChar[0] = buf[buf.length - 1] : (this.lastChar[0] = buf[buf.length - 2], this.lastChar[1] = buf[buf.length - 1]), buf.toString("base64", i, buf.length - n));
|
23380
|
-
}
|
23381
|
-
function base64End(buf) {
|
23382
|
-
var r = buf && buf.length ? this.write(buf) : "";
|
23383
|
-
return this.lastNeed ? r + this.lastChar.toString("base64", 0, 3 - this.lastNeed) : r;
|
23384
|
-
}
|
23385
|
-
function simpleWrite(buf) {
|
23386
|
-
return buf.toString(this.encoding);
|
23387
|
-
}
|
23388
|
-
function simpleEnd(buf) {
|
23389
|
-
return buf && buf.length ? this.write(buf) : "";
|
23390
|
-
}
|
23391
|
-
return string_decoder;
|
23392
|
-
}
|
23393
|
-
var hasRequiredMinipass$1;
|
23204
|
+
var minipass$1 = {}, hasRequiredMinipass$1;
|
23394
23205
|
function requireMinipass$1() {
|
23395
23206
|
if (hasRequiredMinipass$1) return minipass$1;
|
23396
23207
|
hasRequiredMinipass$1 = 1;
|
23397
23208
|
const proc2 = typeof process == "object" && process ? process : {
|
23398
23209
|
stdout: null,
|
23399
23210
|
stderr: null
|
23400
|
-
}, EE = require$$0__default$7.default, Stream2 = require$$0__default$4.default, SD =
|
23211
|
+
}, EE = require$$0__default$7.default, Stream2 = require$$0__default$4.default, SD = require$$2__default$1.default.StringDecoder, EOF2 = Symbol("EOF"), MAYBE_EMIT_END2 = Symbol("maybeEmitEnd"), EMITTED_END2 = Symbol("emittedEnd"), EMITTING_END2 = Symbol("emittingEnd"), EMITTED_ERROR2 = Symbol("emittedError"), CLOSED2 = Symbol("closed"), READ2 = Symbol("read"), FLUSH2 = Symbol("flush"), FLUSHCHUNK2 = Symbol("flushChunk"), ENCODING2 = Symbol("encoding"), DECODER2 = Symbol("decoder"), FLOWING2 = Symbol("flowing"), PAUSED2 = Symbol("paused"), RESUME2 = Symbol("resume"), BUFFER2 = Symbol("buffer"), PIPES2 = Symbol("pipes"), BUFFERLENGTH2 = Symbol("bufferLength"), BUFFERPUSH2 = Symbol("bufferPush"), BUFFERSHIFT2 = Symbol("bufferShift"), OBJECTMODE2 = Symbol("objectMode"), DESTROYED2 = Symbol("destroyed"), ERROR2 = Symbol("error"), EMITDATA2 = Symbol("emitData"), EMITEND3 = Symbol("emitEnd"), EMITEND22 = Symbol("emitEnd2"), ASYNC2 = Symbol("async"), ABORT2 = Symbol("abort"), ABORTED2 = Symbol("aborted"), SIGNAL2 = Symbol("signal"), defer2 = (fn) => Promise.resolve().then(fn), doIter = loadEnv.commonjsGlobal._MP_NO_ITERATOR_SYMBOLS_ !== "1", ASYNCITERATOR = doIter && Symbol.asyncIterator || Symbol("asyncIterator not implemented"), ITERATOR = doIter && Symbol.iterator || Symbol("iterator not implemented"), isEndish2 = (ev) => ev === "end" || ev === "finish" || ev === "prefinish", isArrayBuffer = (b) => b instanceof ArrayBuffer || typeof b == "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0, isArrayBufferView2 = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b);
|
23401
23212
|
class Pipe2 {
|
23402
23213
|
constructor(src2, dest, opts) {
|
23403
23214
|
this.src = src2, this.dest = dest, this.opts = opts, this.ondrain = () => src2[RESUME2](), dest.on("drain", this.ondrain);
|
@@ -23796,7 +23607,7 @@ function requireMinipass() {
|
|
23796
23607
|
const proc2 = typeof process == "object" && process ? process : {
|
23797
23608
|
stdout: null,
|
23798
23609
|
stderr: null
|
23799
|
-
}, EE = require$$0__default$7.default, Stream2 = require$$0__default$4.default, SD =
|
23610
|
+
}, EE = require$$0__default$7.default, Stream2 = require$$0__default$4.default, SD = require$$2__default$1.default.StringDecoder, EOF2 = Symbol("EOF"), MAYBE_EMIT_END2 = Symbol("maybeEmitEnd"), EMITTED_END2 = Symbol("emittedEnd"), EMITTING_END2 = Symbol("emittingEnd"), EMITTED_ERROR2 = Symbol("emittedError"), CLOSED2 = Symbol("closed"), READ2 = Symbol("read"), FLUSH2 = Symbol("flush"), FLUSHCHUNK2 = Symbol("flushChunk"), ENCODING2 = Symbol("encoding"), DECODER2 = Symbol("decoder"), FLOWING2 = Symbol("flowing"), PAUSED2 = Symbol("paused"), RESUME2 = Symbol("resume"), BUFFERLENGTH2 = Symbol("bufferLength"), BUFFERPUSH2 = Symbol("bufferPush"), BUFFERSHIFT2 = Symbol("bufferShift"), OBJECTMODE2 = Symbol("objectMode"), DESTROYED2 = Symbol("destroyed"), EMITDATA2 = Symbol("emitData"), EMITEND3 = Symbol("emitEnd"), EMITEND22 = Symbol("emitEnd2"), ASYNC2 = Symbol("async"), defer2 = (fn) => Promise.resolve().then(fn), doIter = loadEnv.commonjsGlobal._MP_NO_ITERATOR_SYMBOLS_ !== "1", ASYNCITERATOR = doIter && Symbol.asyncIterator || Symbol("asyncIterator not implemented"), ITERATOR = doIter && Symbol.iterator || Symbol("iterator not implemented"), isEndish2 = (ev) => ev === "end" || ev === "finish" || ev === "prefinish", isArrayBuffer = (b) => b instanceof ArrayBuffer || typeof b == "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0, isArrayBufferView2 = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b);
|
23800
23611
|
class Pipe2 {
|
23801
23612
|
constructor(src2, dest, opts) {
|
23802
23613
|
this.src = src2, this.dest = dest, this.opts = opts, this.ondrain = () => src2[RESUME2](), dest.on("drain", this.ondrain);
|
@@ -26785,17 +26596,17 @@ function requireTar() {
|
|
26785
26596
|
return hasRequiredTar || (hasRequiredTar = 1, tar.c = tar.create = requireCreate(), tar.r = tar.replace = requireReplace(), tar.t = tar.list = requireList$1(), tar.u = tar.update = requireUpdate(), tar.x = tar.extract = requireExtract(), tar.Pack = requirePack(), tar.Unpack = requireUnpack(), tar.Parse = requireParse(), tar.ReadEntry = requireReadEntry(), tar.WriteEntry = requireWriteEntry(), tar.Header = requireHeader(), tar.Pax = requirePax(), tar.types = requireTypes$1()), tar;
|
26786
26597
|
}
|
26787
26598
|
var tarExports = requireTar();
|
26788
|
-
const
|
26789
|
-
|
26790
|
-
|
26791
|
-
|
26792
|
-
|
26599
|
+
const DISALLOWED_PATHS = [
|
26600
|
+
// Prevent security risks from unknown GitHub Actions
|
26601
|
+
"/.github/"
|
26602
|
+
], ENV_VAR = {
|
26603
|
+
...templateValidator.REQUIRED_ENV_VAR,
|
26793
26604
|
READ_TOKEN: "SANITY_API_READ_TOKEN"
|
26794
|
-
}
|
26795
|
-
|
26796
|
-
|
26797
|
-
|
26798
|
-
}
|
26605
|
+
};
|
26606
|
+
function getGitHubRawContentUrl(repoInfo) {
|
26607
|
+
const { username, name, branch, filePath } = repoInfo;
|
26608
|
+
return `https://raw.githubusercontent.com/${username}/${name}/${branch}/${filePath}`;
|
26609
|
+
}
|
26799
26610
|
function isGithubRepoShorthand(value) {
|
26800
26611
|
return URL.canParse(value) ? !1 : /^[\w-]+\/[\w-.]+(\/[@\w-.]+)*$/.test(value);
|
26801
26612
|
}
|
@@ -26871,134 +26682,29 @@ async function downloadAndExtractRepo(root2, { username, name, branch, filePath
|
|
26871
26682
|
const pathSegments = posixPath.split(path$3.posix.sep);
|
26872
26683
|
rootPath = pathSegments.length ? pathSegments[0] : null;
|
26873
26684
|
}
|
26685
|
+
for (const disallowedPath of DISALLOWED_PATHS)
|
26686
|
+
if (posixPath.includes(disallowedPath)) return !1;
|
26874
26687
|
return posixPath.startsWith(`${rootPath}${filePath ? `/${filePath}/` : "/"}`);
|
26875
26688
|
}
|
26876
26689
|
})
|
26877
26690
|
);
|
26878
26691
|
}
|
26879
|
-
async function
|
26880
|
-
const
|
26881
|
-
bearerToken && (headers.Authorization = `Bearer ${bearerToken}`);
|
26882
|
-
const handlers = {
|
26883
|
-
"package.json": {
|
26884
|
-
check: (content) => {
|
26885
|
-
try {
|
26886
|
-
const pkg = JSON.parse(content);
|
26887
|
-
return pkg.workspaces ? Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces.packages : void 0;
|
26888
|
-
} catch {
|
26889
|
-
return;
|
26890
|
-
}
|
26891
|
-
}
|
26892
|
-
},
|
26893
|
-
"pnpm-workspace.yaml": {
|
26894
|
-
check: (content) => {
|
26895
|
-
try {
|
26896
|
-
return yaml.parse(content).packages;
|
26897
|
-
} catch {
|
26898
|
-
return;
|
26899
|
-
}
|
26900
|
-
}
|
26901
|
-
},
|
26902
|
-
"lerna.json": {
|
26903
|
-
check: (content) => {
|
26904
|
-
try {
|
26905
|
-
return JSON.parse(content).packages;
|
26906
|
-
} catch {
|
26907
|
-
return;
|
26908
|
-
}
|
26909
|
-
}
|
26910
|
-
},
|
26911
|
-
"rush.json": {
|
26912
|
-
check: (content) => {
|
26913
|
-
try {
|
26914
|
-
return JSON.parse(content).projects?.map((p) => p.packageName);
|
26915
|
-
} catch {
|
26916
|
-
return;
|
26917
|
-
}
|
26918
|
-
}
|
26919
|
-
}
|
26920
|
-
}, fileChecks = await Promise.all(
|
26921
|
-
Object.keys(handlers).map(async (file) => {
|
26922
|
-
const response = await fetch(`${baseUrl}/${file}`, { headers });
|
26923
|
-
return { file, exists: response.status === 200, content: await response.text() };
|
26924
|
-
})
|
26925
|
-
);
|
26926
|
-
for (const check of fileChecks) {
|
26927
|
-
if (!check.exists) continue;
|
26928
|
-
const result = handlers[check.file].check(check.content);
|
26929
|
-
if (result) return result;
|
26930
|
-
}
|
26931
|
-
}
|
26932
|
-
async function validatePackage(baseUrl, packagePath, headers) {
|
26933
|
-
const packageUrl = packagePath ? `${baseUrl}/${packagePath}` : baseUrl, requiredFiles = [
|
26934
|
-
"package.json",
|
26935
|
-
"sanity.config.ts",
|
26936
|
-
"sanity.config.js",
|
26937
|
-
"sanity.cli.ts",
|
26938
|
-
"sanity.cli.js",
|
26939
|
-
...ENV_TEMPLATE_FILES
|
26940
|
-
], fileChecks = await Promise.all(
|
26941
|
-
requiredFiles.map(async (file) => {
|
26942
|
-
const response = await fetch(`${packageUrl}/${file}`, { headers });
|
26943
|
-
return { file, exists: response.status === 200, content: await response.text() };
|
26944
|
-
})
|
26945
|
-
), packageJson = fileChecks.find((f) => f.file === "package.json");
|
26946
|
-
if (!packageJson?.exists)
|
26947
|
-
throw new Error(`Package at ${packagePath || "root"} must include a package.json file`);
|
26948
|
-
let hasSanityDep = !1;
|
26949
|
-
try {
|
26950
|
-
const pkg = JSON.parse(packageJson.content);
|
26951
|
-
hasSanityDep = !!(pkg.dependencies?.sanity || pkg.devDependencies?.sanity);
|
26952
|
-
} catch {
|
26953
|
-
throw new Error(`Invalid package.json file in ${packagePath || "root"}`);
|
26954
|
-
}
|
26955
|
-
const hasSanityConfig = fileChecks.some(
|
26956
|
-
(f) => f.exists && (f.file === "sanity.config.ts" || f.file === "sanity.config.js")
|
26957
|
-
), hasSanityCli = fileChecks.some(
|
26958
|
-
(f) => f.exists && (f.file === "sanity.cli.ts" || f.file === "sanity.cli.js")
|
26959
|
-
), envFile = fileChecks.find(
|
26960
|
-
(f) => f.exists && ENV_TEMPLATE_FILES.includes(f.file)
|
26961
|
-
);
|
26962
|
-
if (envFile) {
|
26963
|
-
const envContent = envFile.content, hasProjectId = envContent.match(ENV_VAR.PROJECT_ID), hasDataset = envContent.match(ENV_VAR.DATASET);
|
26964
|
-
if (!hasProjectId || !hasDataset) {
|
26965
|
-
const missing = [];
|
26966
|
-
throw hasProjectId || missing.push("SANITY_PROJECT_ID or SANITY_STUDIO_PROJECT_ID"), hasDataset || missing.push("SANITY_DATASET or SANITY_STUDIO_DATASET"), new Error(
|
26967
|
-
`Environment template in ${packagePath || "repo"} must include the following variables: ${missing.join(", ")}`
|
26968
|
-
);
|
26969
|
-
}
|
26970
|
-
}
|
26971
|
-
return {
|
26972
|
-
hasSanityConfig,
|
26973
|
-
hasSanityCli,
|
26974
|
-
hasEnvFile: !!envFile,
|
26975
|
-
hasSanityDep
|
26976
|
-
};
|
26692
|
+
async function getPackages(repoInfo, bearerToken) {
|
26693
|
+
const headers = {};
|
26694
|
+
return bearerToken && (headers.Authorization = `Bearer ${bearerToken}`), templateValidator.getMonoRepo(getGitHubRawContentUrl(repoInfo), headers);
|
26977
26695
|
}
|
26978
26696
|
async function validateRemoteTemplate(repoInfo, packages = [""], bearerToken) {
|
26979
|
-
const
|
26697
|
+
const headers = {};
|
26980
26698
|
bearerToken && (headers.Authorization = `Bearer ${bearerToken}`);
|
26981
|
-
const
|
26982
|
-
|
26983
|
-
|
26984
|
-
|
26985
|
-
throw new Error('At least one package must include "sanity" as a dependency in package.json');
|
26986
|
-
if (!validations.some((v) => v.hasSanityConfig))
|
26987
|
-
throw new Error("At least one package must include a sanity.config.js or sanity.config.ts file");
|
26988
|
-
if (!validations.some((v) => v.hasSanityCli))
|
26989
|
-
throw new Error("At least one package must include a sanity.cli.js or sanity.cli.ts file");
|
26990
|
-
const missingEnvPackages = packages.filter((pkg, i) => !validations[i].hasEnvFile);
|
26991
|
-
if (missingEnvPackages.length > 0)
|
26992
|
-
throw new Error(
|
26993
|
-
`The following packages are missing .env.template, .env.example, or .env.local.example files: ${missingEnvPackages.join(
|
26994
|
-
", "
|
26995
|
-
)}`
|
26996
|
-
);
|
26699
|
+
const result = await templateValidator.validateSanityTemplate(getGitHubRawContentUrl(repoInfo), packages, headers);
|
26700
|
+
if (!result.isValid)
|
26701
|
+
throw new Error(result.errors.join(`
|
26702
|
+
`));
|
26997
26703
|
}
|
26998
26704
|
async function checkNeedsReadToken(root2) {
|
26999
26705
|
try {
|
27000
26706
|
const templatePath = await Promise.any(
|
27001
|
-
ENV_TEMPLATE_FILES.map(async (file) => (await fs.access(path$3.join(root2, file)), file))
|
26707
|
+
templateValidator.ENV_TEMPLATE_FILES.map(async (file) => (await fs.access(path$3.join(root2, file)), file))
|
27002
26708
|
);
|
27003
26709
|
return (await fs.readFile(path$3.join(root2, templatePath), "utf8")).includes(ENV_VAR.READ_TOKEN);
|
27004
26710
|
} catch {
|
@@ -27007,7 +26713,7 @@ async function checkNeedsReadToken(root2) {
|
|
27007
26713
|
}
|
27008
26714
|
async function applyEnvVariables(root2, envData, targetName = ".env") {
|
27009
26715
|
const templatePath = await Promise.any(
|
27010
|
-
ENV_TEMPLATE_FILES.map(async (file) => (await fs.access(path$3.join(root2, file)), file))
|
26716
|
+
templateValidator.ENV_TEMPLATE_FILES.map(async (file) => (await fs.access(path$3.join(root2, file)), file))
|
27011
26717
|
).catch(() => {
|
27012
26718
|
throw new Error("Could not find .env.template, .env.example or .env.local.example file");
|
27013
26719
|
});
|
@@ -27054,6 +26760,17 @@ async function generateSanityApiReadToken(label, projectId, apiClient) {
|
|
27054
26760
|
}
|
27055
26761
|
})).key;
|
27056
26762
|
}
|
26763
|
+
async function setCorsOrigin(origin, projectId, apiClient) {
|
26764
|
+
try {
|
26765
|
+
await apiClient({ api: { projectId } }).request({
|
26766
|
+
method: "POST",
|
26767
|
+
url: "/cors",
|
26768
|
+
body: { origin, allowCredentials: !1 }
|
26769
|
+
});
|
26770
|
+
} catch (error2) {
|
26771
|
+
loadEnv.debug("Failed to set CORS origin", error2);
|
26772
|
+
}
|
26773
|
+
}
|
27057
26774
|
function canLaunchBrowser() {
|
27058
26775
|
return ["win32", "darwin"].includes(os__default.default.platform()) ? !0 : !!(process.env.XDG_CURRENT_DESKTOP || process.env.GDMSESSION);
|
27059
26776
|
}
|
@@ -27240,7 +26957,7 @@ ${actionText} ${loginUrl.href}
|
|
27240
26957
|
authType: "normal"
|
27241
26958
|
}), getUserConfig().delete(TELEMETRY_CONSENT_CONFIG_KEY), hasExistingToken && await apiClient({ requireUser: !0, requireProject: !1 }).clone().config({ token: previousToken }).request({ uri: "/auth/logout", method: "POST" }).catch((err) => {
|
27242
26959
|
(err && err.response && err.response.statusCode) !== 401 && output.warn("[warn] Failed to log out existing session");
|
27243
|
-
}), output.
|
26960
|
+
}), output.success("Login successful"), trace.complete();
|
27244
26961
|
}
|
27245
26962
|
function startServerForTokenCallback(options2) {
|
27246
26963
|
const { apiHost, apiClient } = options2, domain = apiHost.includes(".sanity.work") ? "www.sanity.work" : "www.sanity.io", attemptPorts = callbackPorts.slice();
|
@@ -27347,7 +27064,7 @@ async function promptProviders(prompt2, providers) {
|
|
27347
27064
|
return providers[0];
|
27348
27065
|
const provider = await prompt2.single({
|
27349
27066
|
type: "list",
|
27350
|
-
message: "
|
27067
|
+
message: "Please log in or create a new account",
|
27351
27068
|
choices: providers.map((choice2) => choice2.title)
|
27352
27069
|
});
|
27353
27070
|
return providers.find((prov) => prov.title === provider) || providers[0];
|
@@ -47218,6 +46935,55 @@ ${chalk__default.default.yellow("\u26A0")} File "${filePath}" already exists, sk
|
|
47218
46935
|
function toTypeScriptPath(originalPath) {
|
47219
46936
|
return originalPath.replace(/\.js$/, ".ts");
|
47220
46937
|
}
|
46938
|
+
const portMap = {
|
46939
|
+
nextjs: 3e3,
|
46940
|
+
blitzjs: 3e3,
|
46941
|
+
gatsby: 8e3,
|
46942
|
+
remix: 3e3,
|
46943
|
+
astro: 3e3,
|
46944
|
+
hexo: 4e3,
|
46945
|
+
eleventy: 8080,
|
46946
|
+
docusaurus: 3e3,
|
46947
|
+
"docusaurus-2": 3e3,
|
46948
|
+
preact: 8080,
|
46949
|
+
solidstart: 3e3,
|
46950
|
+
"solidstart-1": 3e3,
|
46951
|
+
dojo: 3e3,
|
46952
|
+
ember: 4200,
|
46953
|
+
vue: 8080,
|
46954
|
+
scully: 1668,
|
46955
|
+
"ionic-angular": 4200,
|
46956
|
+
angular: 4200,
|
46957
|
+
polymer: 8081,
|
46958
|
+
svelte: 5e3,
|
46959
|
+
sveltekit: 5173,
|
46960
|
+
"sveltekit-1": 5173,
|
46961
|
+
"ionic-react": 3e3,
|
46962
|
+
"create-react-app": 3e3,
|
46963
|
+
gridsome: 8080,
|
46964
|
+
umijs: 8e3,
|
46965
|
+
saber: 3e3,
|
46966
|
+
stencil: 3333,
|
46967
|
+
nuxtjs: 3e3,
|
46968
|
+
redwoodjs: 8910,
|
46969
|
+
hugo: 1313,
|
46970
|
+
jekyll: 4e3,
|
46971
|
+
brunch: 3333,
|
46972
|
+
middleman: 4567,
|
46973
|
+
zola: 1111,
|
46974
|
+
hydrogen: 3e3,
|
46975
|
+
vite: 5173,
|
46976
|
+
vitepress: 5173,
|
46977
|
+
vuepress: 8080,
|
46978
|
+
parcel: 1234,
|
46979
|
+
fasthtml: 8e3,
|
46980
|
+
sanity: 3333,
|
46981
|
+
"sanity-v3": 3333,
|
46982
|
+
storybook: 6006
|
46983
|
+
};
|
46984
|
+
function getDefaultPortForFramework(frameworkSlug) {
|
46985
|
+
return portMap[frameworkSlug ?? ""] ?? 3e3;
|
46986
|
+
}
|
47221
46987
|
var braceExpansionExports = requireBraceExpansion(), expand$2 = /* @__PURE__ */ loadEnv.getDefaultExportFromCjs(braceExpansionExports);
|
47222
46988
|
const MAX_PATTERN_LENGTH = 1024 * 64, assertValidPattern = (pattern) => {
|
47223
46989
|
if (typeof pattern != "string")
|
@@ -52085,7 +51851,7 @@ const INITIAL_COMMIT_MESSAGE = "Initial commit from Sanity CLI";
|
|
52085
51851
|
async function bootstrapRemoteTemplate(opts, context) {
|
52086
51852
|
const { outputPath, repoInfo, bearerToken, variables, packageName } = opts, { output, apiClient } = context, name = [repoInfo.username, repoInfo.name, repoInfo.filePath].filter(Boolean).join("/"), spinner = output.spinner(`Bootstrapping files from template "${name}"`).start();
|
52087
51853
|
loadEnv.debug("Validating remote template");
|
52088
|
-
const packages = await
|
51854
|
+
const packages = await getPackages(repoInfo, bearerToken);
|
52089
51855
|
await validateRemoteTemplate(repoInfo, packages, bearerToken), loadEnv.debug('Create new directory "%s"', outputPath), await fs.mkdir(outputPath, { recursive: !0 }), loadEnv.debug("Downloading and extracting repo to %s", outputPath), await downloadAndExtractRepo(outputPath, repoInfo, bearerToken), loadEnv.debug("Checking if template needs read token");
|
52090
51856
|
const needsReadToken = await Promise.all(
|
52091
51857
|
(packages ?? [""]).map((pkg) => checkNeedsReadToken(path$3.join(outputPath, pkg)))
|
@@ -52093,10 +51859,12 @@ async function bootstrapRemoteTemplate(opts, context) {
|
|
52093
51859
|
loadEnv.debug("Applying environment variables");
|
52094
51860
|
const readToken = needsReadToken ? await generateSanityApiReadToken("API Read Token", variables.projectId, apiClient) : void 0;
|
52095
51861
|
for (const pkg of packages ?? [""]) {
|
52096
|
-
const packagePath = path$3.join(outputPath, pkg),
|
51862
|
+
const packagePath = path$3.join(outputPath, pkg), packageFramework = await distExports.detectFrameworkRecord({
|
52097
51863
|
fs: new distExports.LocalFileSystemDetector(packagePath),
|
52098
51864
|
frameworkList: frameworksExports.frameworks
|
52099
|
-
})
|
51865
|
+
}), port = getDefaultPortForFramework(packageFramework?.slug);
|
51866
|
+
loadEnv.debug("Setting CORS origin to http://localhost:%d", port), await setCorsOrigin(`http://localhost:${port}`, variables.projectId, apiClient), loadEnv.debug("Applying environment variables to %s", pkg);
|
51867
|
+
const envName = packageFramework?.slug === "nextjs" ? ".env.local" : ".env";
|
52100
51868
|
await applyEnvVariables(packagePath, { ...variables, readToken }, envName);
|
52101
51869
|
}
|
52102
51870
|
loadEnv.debug("Setting package name to %s", packageName), await tryApplyPackageName(outputPath, packageName), loadEnv.debug("Initializing git repository"), tryGitInit(outputPath, INITIAL_COMMIT_MESSAGE), loadEnv.debug("Updating initial template metadata"), await updateInitialTemplateMetadata(apiClient, variables.projectId, `external-${name}`), spinner.succeed();
|
@@ -52671,7 +52439,7 @@ export const urlFor = (source) => {
|
|
52671
52439
|
}, structure["structure."] = useTypeScript ? structureTS : structureJS), structure;
|
52672
52440
|
}, isCI = !!process.env.CI;
|
52673
52441
|
async function initSanity(args, context) {
|
52674
|
-
const { output, prompt: prompt2, workDir, apiClient, chalk: chalk2, telemetry: telemetry2, detectedFramework } = context, trace = telemetry2.trace(CLIInitStepCompleted), cliFlags = args.extOptions, unattended = cliFlags.y || cliFlags.yes, print = unattended ? lodashExports.noop : output.print,
|
52442
|
+
const { output, prompt: prompt2, workDir, apiClient, chalk: chalk2, telemetry: telemetry2, detectedFramework } = context, trace = telemetry2.trace(CLIInitStepCompleted), cliFlags = args.extOptions, unattended = cliFlags.y || cliFlags.yes, print = unattended ? lodashExports.noop : output.print, success = output.success, warn = output.warn, intendedPlan = cliFlags["project-plan"], intendedCoupon = cliFlags.coupon, reconfigure = cliFlags.reconfigure, commitMessage = cliFlags.git, useGit = typeof commitMessage > "u" ? !0 : !!commitMessage, bareOutput = cliFlags.bare, env = cliFlags.env, packageManager = cliFlags["package-manager"];
|
52675
52443
|
let remoteTemplateInfo;
|
52676
52444
|
cliFlags.template && checkIsRemoteTemplate(cliFlags.template) && (remoteTemplateInfo = await getGitHubRepoInfo(cliFlags.template, cliFlags["template-token"]));
|
52677
52445
|
let defaultConfig = cliFlags["dataset-default"], showDefaultConfigPrompt = !defaultConfig;
|
@@ -52758,19 +52526,13 @@ ${err.message}`);
|
|
52758
52526
|
if (loadEnv.debug(hasToken ? "User already has a token" : "User has no token"), hasToken) {
|
52759
52527
|
trace.log({ step: "login", alreadyLoggedIn: !0 });
|
52760
52528
|
const user = await getUserData(apiClient);
|
52761
|
-
|
52762
|
-
`${chalk2.gray(" \u{1F464} You're logged in as %s using %s")}`,
|
52763
|
-
user.name,
|
52764
|
-
getProviderName(user.provider)
|
52765
|
-
), print("");
|
52529
|
+
success("You are logged in as %s using %s", user.email, getProviderName(user.provider));
|
52766
52530
|
} else unattended || (trace.log({ step: "login" }), await getOrCreateUser());
|
52767
|
-
let introMessage = "
|
52768
|
-
cliFlags.quickstart
|
52531
|
+
let introMessage = "Fetching existing projects";
|
52532
|
+
cliFlags.quickstart && (introMessage = "Eject your existing project's Sanity configuration"), success(introMessage), print("");
|
52769
52533
|
const flags = await prepareFlags(), { projectId, displayName, isFirstProject, datasetName, schemaUrl } = await getProjectDetails(), sluggedName = lodashExports.deburr(displayName.toLowerCase()).replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
52770
52534
|
if (bareOutput) {
|
52771
|
-
print(`
|
52772
|
-
${chalk2.green("Success!")} Below are your project details:
|
52773
|
-
`), print(`Project ID: ${chalk2.cyan(projectId)}`), print(`Dataset: ${chalk2.cyan(datasetName)}`), print(
|
52535
|
+
success("Below are your project details"), print(""), print(`Project ID: ${chalk2.cyan(projectId)}`), print(`Dataset: ${chalk2.cyan(datasetName)}`), print(
|
52774
52536
|
`
|
52775
52537
|
You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/project/${projectId}
|
52776
52538
|
`
|
@@ -52956,8 +52718,8 @@ ${chalk2.green("Success!")} Your Sanity configuration files has been added to th
|
|
52956
52718
|
template,
|
52957
52719
|
datasetName,
|
52958
52720
|
context
|
52959
|
-
}),
|
52960
|
-
`)
|
52721
|
+
}), print(""), print("If you want to delete the imported data, use"), print(` ${chalk2.cyan(`npx sanity dataset delete ${datasetName}`)}`), print("and create a new clean dataset with"), print(` ${chalk2.cyan("npx sanity dataset create <name>")}
|
52722
|
+
`);
|
52961
52723
|
}
|
52962
52724
|
const devCommand = {
|
52963
52725
|
yarn: "yarn dev",
|
@@ -52972,7 +52734,7 @@ ${chalk2.green("Success!")} Now, use this command to continue:
|
|
52972
52734
|
`)) : (print(`
|
52973
52735
|
${chalk2.green("Success!")} Now, use these commands to continue:
|
52974
52736
|
`), print(`First: ${chalk2.cyan(`cd ${outputPath}`)} - to enter project\u2019s directory`), print(`Then: ${chalk2.cyan(devCommand)} - to run Sanity Studio
|
52975
|
-
`)),
|
52737
|
+
`)), print("Other helpful commands"), print("npx sanity docs - to open the documentation in a browser"), print("npx sanity manage - to open the project settings in a browser"), print("npx sanity help - to explore the CLI manual");
|
52976
52738
|
const sendInvite = isFirstProject && await prompt2.single({
|
52977
52739
|
type: "confirm",
|
52978
52740
|
message: "We have an excellent developer community, would you like us to send you an invitation to join?",
|
@@ -52983,10 +52745,9 @@ ${chalk2.green("Success!")} Now, use these commands to continue:
|
|
52983
52745
|
method: "POST"
|
52984
52746
|
}).catch(lodashExports.noop)), trace.complete();
|
52985
52747
|
async function getOrCreateUser() {
|
52986
|
-
|
52987
|
-
`);
|
52748
|
+
warn("No authentication credentials found in your Sanity config"), print("");
|
52988
52749
|
const { extOptions, ...otherArgs } = args, loginArgs = { ...otherArgs, extOptions: {} };
|
52989
|
-
await login(loginArgs, { ...context, telemetry: trace.newContext("login") })
|
52750
|
+
await login(loginArgs, { ...context, telemetry: trace.newContext("login") });
|
52990
52751
|
}
|
52991
52752
|
async function getProjectDetails() {
|
52992
52753
|
if (flags.quickstart) {
|
@@ -53090,7 +52851,7 @@ ${err.message}`);
|
|
53090
52851
|
value: project.id,
|
53091
52852
|
name: `${project.displayName} [${project.id}]`
|
53092
52853
|
})), selected = await prompt2.single({
|
53093
|
-
message: "
|
52854
|
+
message: "Create a new project or select an existing one",
|
53094
52855
|
type: "list",
|
53095
52856
|
choices: [
|
53096
52857
|
{ value: "new", name: "Create new project" },
|
@@ -53183,20 +52944,20 @@ The default dataset configuration has a public dataset named "production".`;
|
|
53183
52944
|
type: "list",
|
53184
52945
|
choices: [
|
53185
52946
|
{
|
53186
|
-
value: "
|
53187
|
-
name: "
|
53188
|
-
},
|
53189
|
-
{
|
53190
|
-
value: "shopify",
|
53191
|
-
name: "E-commerce (Shopify)"
|
52947
|
+
value: "clean",
|
52948
|
+
name: "Clean project with no predefined schema types"
|
53192
52949
|
},
|
53193
52950
|
{
|
53194
52951
|
value: "blog",
|
53195
52952
|
name: "Blog (schema)"
|
53196
52953
|
},
|
53197
52954
|
{
|
53198
|
-
value: "
|
53199
|
-
name: "
|
52955
|
+
value: "shopify",
|
52956
|
+
name: "E-commerce (Shopify)"
|
52957
|
+
},
|
52958
|
+
{
|
52959
|
+
value: "moviedb",
|
52960
|
+
name: "Movie project (schema + sample data)"
|
53200
52961
|
}
|
53201
52962
|
]
|
53202
52963
|
});
|
@@ -53474,13 +53235,6 @@ function getImportCommand(outputPath, studioVersion) {
|
|
53474
53235
|
);
|
53475
53236
|
}
|
53476
53237
|
}
|
53477
|
-
async function hasGlobalCli() {
|
53478
|
-
try {
|
53479
|
-
return !!await which("sanity");
|
53480
|
-
} catch {
|
53481
|
-
return !1;
|
53482
|
-
}
|
53483
|
-
}
|
53484
53238
|
const helpText$7 = `
|
53485
53239
|
Options
|
53486
53240
|
-y, --yes Use unattended mode, accepting defaults and using only flags for choices
|
@@ -53610,7 +53364,7 @@ ${err.message}`));
|
|
53610
53364
|
return;
|
53611
53365
|
}
|
53612
53366
|
}
|
53613
|
-
cfg.delete("authType"), cfg.delete("authToken"), cfg.delete(TELEMETRY_CONSENT_CONFIG_KEY), output.
|
53367
|
+
cfg.delete("authType"), cfg.delete("authToken"), cfg.delete(TELEMETRY_CONSENT_CONFIG_KEY), output.success("Logged out");
|
53614
53368
|
}
|
53615
53369
|
}, manageCommand = {
|
53616
53370
|
name: "manage",
|
@@ -56022,22 +55776,27 @@ class Ora {
|
|
56022
55776
|
function ora(options2) {
|
56023
55777
|
return new Ora(options2);
|
56024
55778
|
}
|
55779
|
+
const SYMBOL_CHECK = chalk__default.default.green("\u2713"), SYMBOL_WARN = chalk__default.default.yellow("\u26A0"), SYMBOL_FAIL = chalk__default.default.red("\u2717");
|
56025
55780
|
let isFirstClear = !0;
|
56026
55781
|
var cliOutputter = {
|
56027
55782
|
print(...args) {
|
56028
55783
|
console.log(...args);
|
56029
55784
|
},
|
56030
|
-
|
56031
|
-
console.
|
55785
|
+
success(firstPartOfMessage, ...args) {
|
55786
|
+
console.log(`${SYMBOL_CHECK} ${firstPartOfMessage}`, ...args);
|
55787
|
+
},
|
55788
|
+
warn(firstPartOfMessage, ...args) {
|
55789
|
+
console.warn(`${SYMBOL_WARN} ${firstPartOfMessage}`, ...args);
|
56032
55790
|
},
|
56033
|
-
error(...args) {
|
56034
|
-
|
55791
|
+
error(firstPartOfMessage, ...args) {
|
55792
|
+
firstPartOfMessage instanceof Error ? console.error(`${SYMBOL_FAIL} ${chalk__default.default.red(firstPartOfMessage.stack)}`) : console.error(`${SYMBOL_FAIL} ${firstPartOfMessage}`, ...args);
|
56035
55793
|
},
|
56036
55794
|
clear: () => {
|
56037
55795
|
process.stdout.write(isFirstClear ? "\x1Bc" : "\x1B[2J\x1B[0f"), isFirstClear = !1;
|
56038
55796
|
},
|
56039
55797
|
spinner(options2) {
|
56040
|
-
|
55798
|
+
const spinner = ora(options2);
|
55799
|
+
return spinner.succeed = (text) => spinner.stopAndPersist({ text, symbol: SYMBOL_CHECK }), spinner.warn = (text) => spinner.stopAndPersist({ text, symbol: SYMBOL_WARN }), spinner.fail = (text) => spinner.stopAndPersist({ text, symbol: SYMBOL_FAIL }), spinner;
|
56041
55800
|
}
|
56042
55801
|
}, inquirer$1 = { exports: {} }, escapeStringRegexp$1, hasRequiredEscapeStringRegexp$1;
|
56043
55802
|
function requireEscapeStringRegexp$1() {
|
@@ -56327,7 +56086,7 @@ var baseUI, hasRequiredBaseUI;
|
|
56327
56086
|
function requireBaseUI() {
|
56328
56087
|
if (hasRequiredBaseUI) return baseUI;
|
56329
56088
|
hasRequiredBaseUI = 1;
|
56330
|
-
var _ = requireLodash(), MuteStream = requireMute(), readline2 = require$$2__default$
|
56089
|
+
var _ = requireLodash(), MuteStream = requireMute(), readline2 = require$$2__default$2.default;
|
56331
56090
|
class UI {
|
56332
56091
|
constructor(opt) {
|
56333
56092
|
this.rl || (this.rl = readline2.createInterface(setupReadlineOptions(opt))), this.rl.resume(), this.onForceClose = this.onForceClose.bind(this), process.on("exit", this.onForceClose), this.rl.on("SIGINT", this.onForceClose);
|
@@ -67804,7 +67563,7 @@ function requireInternal() {
|
|
67804
67563
|
this.enc = codecOptions.encodingName, this.bomAware = codecOptions.bomAware, this.enc === "base64" ? this.encoder = InternalEncoderBase64 : this.enc === "cesu8" && (this.enc = "utf8", this.encoder = InternalEncoderCesu8, Buffer2.from("eda0bdedb2a9", "hex").toString() !== "\u{1F4A9}" && (this.decoder = InternalDecoderCesu8, this.defaultCharUnicode = iconv.defaultCharUnicode));
|
67805
67564
|
}
|
67806
67565
|
InternalCodec.prototype.encoder = InternalEncoder, InternalCodec.prototype.decoder = InternalDecoder;
|
67807
|
-
var StringDecoder =
|
67566
|
+
var StringDecoder = require$$2__default$1.default.StringDecoder;
|
67808
67567
|
StringDecoder.prototype.end || (StringDecoder.prototype.end = function() {
|
67809
67568
|
});
|
67810
67569
|
function InternalDecoder(options2, codec) {
|