@sanity/cli 4.3.1-next.8 → 4.4.0-next.15
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 +82 -82
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/_chunks-cjs/getCliConfig.js +17 -9
- package/lib/_chunks-cjs/getCliConfig.js.map +1 -1
- package/lib/_chunks-cjs/loadEnv.js +12 -14
- package/lib/_chunks-cjs/loadEnv.js.map +1 -1
- package/lib/index.mjs +10 -6
- package/lib/index.mjs.map +1 -1
- package/package.json +8 -8
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 fs$1 = require("node:fs"), os = require("node:os"), path$3 = require("node:path"), 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 = 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"), require$$0$c = require("fs/promises"), require$$0$d = require("buffer"),
|
|
21
|
+
var fs$1 = require("node:fs"), os = require("node:os"), path$3 = require("node:path"), 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 = 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
|
}
|
|
@@ -8419,27 +8419,27 @@ function isCommandGroup(cmdOrGroup) {
|
|
|
8419
8419
|
const showHelpAction = async (args, context) => {
|
|
8420
8420
|
const [commandName, subCommandName] = args.argsWithoutOptions, { commandGroups } = context.commandRunner;
|
|
8421
8421
|
if (!commandName) {
|
|
8422
|
-
|
|
8422
|
+
getCliConfig.debug('No command given to "help", showing generate Sanity CLI help'), context.output.print(generateCommandsDocumentation(commandGroups));
|
|
8423
8423
|
return;
|
|
8424
8424
|
}
|
|
8425
8425
|
const defaultCommand = commandGroups.default.find((cmd) => cmd.name === commandName);
|
|
8426
8426
|
if (defaultCommand && !isCommandGroup(defaultCommand)) {
|
|
8427
|
-
|
|
8427
|
+
getCliConfig.debug(`Found command in default group with name "${commandName}"`), context.output.print(generateCommandDocumentation(defaultCommand));
|
|
8428
8428
|
return;
|
|
8429
8429
|
}
|
|
8430
8430
|
const group = commandGroups[commandName];
|
|
8431
8431
|
if (!subCommandName && !group)
|
|
8432
|
-
throw
|
|
8432
|
+
throw getCliConfig.debug(`No subcommand given, and we couldn't find a group with name "${group}"`), new Error(getNoSuchCommandText(commandName, null, commandGroups));
|
|
8433
8433
|
if (!subCommandName && group) {
|
|
8434
|
-
|
|
8434
|
+
getCliConfig.debug(`No subcommand given, but found group with name "${commandName}"`), context.output.print(generateCommandsDocumentation(commandGroups, commandName));
|
|
8435
8435
|
return;
|
|
8436
8436
|
}
|
|
8437
8437
|
if (subCommandName && !group)
|
|
8438
|
-
throw
|
|
8438
|
+
throw getCliConfig.debug(`Subcommand given, but couldn't find group with name "${commandName}"`), new Error(getNoSuchCommandText(subCommandName, commandName, commandGroups));
|
|
8439
8439
|
const subCommand = context.commandRunner.resolveSubcommand(group, subCommandName, commandName);
|
|
8440
8440
|
if (!subCommand)
|
|
8441
|
-
throw
|
|
8442
|
-
|
|
8441
|
+
throw getCliConfig.debug(`Subcommand given, but not found in group "${commandName}"`), new Error(getNoSuchCommandText(subCommandName, commandName, commandGroups));
|
|
8442
|
+
getCliConfig.debug('Subcommand "%s" for group "%s" found, showing help', subCommandName, commandName), isCommandGroup(subCommand.command) || context.output.print(
|
|
8443
8443
|
generateCommandDocumentation(subCommand.command, commandName, subCommandName)
|
|
8444
8444
|
);
|
|
8445
8445
|
}, help$1 = `
|
|
@@ -23718,9 +23718,9 @@ const cliPkgName = "@sanity/cli";
|
|
|
23718
23718
|
async function getCliUpgradeCommand(options2 = {}) {
|
|
23719
23719
|
let { cwd, workDir } = options2;
|
|
23720
23720
|
if (cwd = path__default.default.resolve(cwd || process.cwd()), workDir = path__default.default.resolve(workDir || cwd), isInstalledGlobally && isInstalledUsingYarn())
|
|
23721
|
-
return
|
|
23721
|
+
return getCliConfig.debug("CLI is installed globally with yarn"), `yarn global add ${cliPkgName}`;
|
|
23722
23722
|
if (isInstalledGlobally)
|
|
23723
|
-
return
|
|
23723
|
+
return getCliConfig.debug("CLI is installed globally with npm"), `npm install -g ${cliPkgName}`;
|
|
23724
23724
|
const cmds = cwd === workDir ? [] : [`cd ${path__default.default.relative(cwd, workDir)}`], { chosen } = await getPackageManagerChoice(workDir, { interactive: !1 });
|
|
23725
23725
|
return chosen === "yarn" ? cmds.push(`yarn upgrade ${cliPkgName}`) : chosen === "pnpm" ? cmds.push(`pnpm update ${cliPkgName}`) : cmds.push(`npm update ${cliPkgName}`), cmds.join(" && ");
|
|
23726
23726
|
}
|
|
@@ -27682,7 +27682,7 @@ async function setCorsOrigin(origin, projectId, apiClient) {
|
|
|
27682
27682
|
// allowCredentials is true to allow for embedded studios if needed
|
|
27683
27683
|
});
|
|
27684
27684
|
} catch (error2) {
|
|
27685
|
-
|
|
27685
|
+
getCliConfig.debug("Failed to set CORS origin", error2);
|
|
27686
27686
|
}
|
|
27687
27687
|
}
|
|
27688
27688
|
function canLaunchBrowser() {
|
|
@@ -27729,7 +27729,7 @@ function isTrueish(value) {
|
|
|
27729
27729
|
}
|
|
27730
27730
|
const isCi = isTrueish(process.env.CI) || // Travis CI, CircleCI, Gitlab CI, Appveyor, CodeShip
|
|
27731
27731
|
isTrueish(process.env.CONTINUOUS_INTEGRATION) || // Travis CI
|
|
27732
|
-
process.env.BUILD_NUMBER, debug$1 =
|
|
27732
|
+
process.env.BUILD_NUMBER, debug$1 = getCliConfig.debug.extend("telemetry"), FIVE_MINUTES = 1e3 * 60 * 5, LOG_FILE_NAME = "telemetry-events.ndjson", TELEMETRY_CONSENT_CONFIG_KEY = "telemetryConsent", VALID_API_STATUSES = ["granted", "denied", "unset"];
|
|
27733
27733
|
function isValidApiConsentStatus(status) {
|
|
27734
27734
|
return VALID_API_STATUSES.includes(status);
|
|
27735
27735
|
}
|
|
@@ -27829,7 +27829,7 @@ const LoginTrace = telemetry.defineTrace({
|
|
|
27829
27829
|
name: "CLI Login Step Completed",
|
|
27830
27830
|
version: 1,
|
|
27831
27831
|
description: "User completed a step in the CLI login flow"
|
|
27832
|
-
}), callbackEndpoint = "/callback", debug =
|
|
27832
|
+
}), callbackEndpoint = "/callback", debug = getCliConfig.debug.extend("auth"), callbackPorts = [4321, 4e3, 3003, 1234, 8080, 13333], platformNames = {
|
|
27833
27833
|
aix: "AIX",
|
|
27834
27834
|
android: "Android",
|
|
27835
27835
|
darwin: "MacOS",
|
|
@@ -48110,20 +48110,20 @@ async function updateInitialTemplateMetadata(apiClient, projectId, templateName)
|
|
|
48110
48110
|
});
|
|
48111
48111
|
} catch (err) {
|
|
48112
48112
|
let message = typeof err == "string" ? err : "<unknown error>";
|
|
48113
|
-
err instanceof Error && (message = err.message),
|
|
48113
|
+
err instanceof Error && (message = err.message), getCliConfig.debug("Failed to update initial template metadata for project: %s", message);
|
|
48114
48114
|
}
|
|
48115
48115
|
}
|
|
48116
48116
|
async function bootstrapLocalTemplate(opts, context) {
|
|
48117
48117
|
const { apiClient, cliRoot, output } = context, templatesDir = path__default.default.join(cliRoot, "templates"), { outputPath, templateName, useTypeScript, packageName, variables } = opts, sourceDir = path__default.default.join(templatesDir, templateName), sharedDir = path__default.default.join(templatesDir, "shared"), isAppTemplate = determineAppTemplate(templateName), template = templates[templateName];
|
|
48118
48118
|
if (!template)
|
|
48119
48119
|
throw new Error(`Template "${templateName}" not defined`);
|
|
48120
|
-
|
|
48120
|
+
getCliConfig.debug('Copying files from template "%s" to "%s"', templateName, outputPath);
|
|
48121
48121
|
let spinner = output.spinner(
|
|
48122
48122
|
opts.schemaUrl ? "Extracting your Sanity configuration" : "Bootstrapping files from template"
|
|
48123
48123
|
).start();
|
|
48124
48124
|
await copy(sourceDir, outputPath, {
|
|
48125
48125
|
rename: useTypeScript ? toTypeScriptPath : void 0
|
|
48126
|
-
}), await copy(path__default.default.join(sharedDir, "gitignore.txt"), outputPath, { rename: () => ".gitignore" }), useTypeScript && await fs__default.default.copyFile(path__default.default.join(sharedDir, "tsconfig.json"), path__default.default.join(outputPath, "tsconfig.json")), opts.schemaUrl && (
|
|
48126
|
+
}), await copy(path__default.default.join(sharedDir, "gitignore.txt"), outputPath, { rename: () => ".gitignore" }), useTypeScript && await fs__default.default.copyFile(path__default.default.join(sharedDir, "tsconfig.json"), path__default.default.join(outputPath, "tsconfig.json")), opts.schemaUrl && (getCliConfig.debug('Fetching and writing remote schema "%s"', opts.schemaUrl), await journeyConfig.getAndWriteJourneySchemaWorker({
|
|
48127
48127
|
schemasPath: path__default.default.join(outputPath, "schemaTypes"),
|
|
48128
48128
|
useTypeScript,
|
|
48129
48129
|
schemaUrl: opts.schemaUrl
|
|
@@ -48180,7 +48180,7 @@ export default [...studio]
|
|
|
48180
48180
|
`
|
|
48181
48181
|
)
|
|
48182
48182
|
].filter(Boolean)
|
|
48183
|
-
),
|
|
48183
|
+
), getCliConfig.debug("Updating initial template metadata"), await updateInitialTemplateMetadata(apiClient, variables.projectId, `cli-${templateName}`), spinner.succeed(), template;
|
|
48184
48184
|
async function writeFileIfNotExists(fileName, content) {
|
|
48185
48185
|
const filePath = path__default.default.join(outputPath, fileName);
|
|
48186
48186
|
if (opts.overwriteFiles) {
|
|
@@ -53117,29 +53117,29 @@ async function bootstrapRemoteTemplate(opts, context) {
|
|
|
53117
53117
|
const { outputPath, repoInfo, bearerToken, variables, packageName } = opts, { output, apiClient } = context, name = [repoInfo.username, repoInfo.name, repoInfo.filePath].filter(Boolean).join("/"), contentsUrl = getGitHubRawContentUrl(repoInfo), headers = {};
|
|
53118
53118
|
bearerToken && (headers.Authorization = `Bearer ${bearerToken}`);
|
|
53119
53119
|
const spinner = output.spinner(`Bootstrapping files from template "${name}"`).start(), corsAdded = [SANITY_DEFAULT_PORT];
|
|
53120
|
-
|
|
53120
|
+
getCliConfig.debug("Validating remote template");
|
|
53121
53121
|
const fileReader = new templateValidator.GitHubFileReader(contentsUrl, headers), packages = await templateValidator.getMonoRepo(fileReader), validation = await templateValidator.validateTemplate(fileReader, packages);
|
|
53122
53122
|
if (!validation.isValid)
|
|
53123
53123
|
throw new Error(validation.errors.join(`
|
|
53124
53124
|
`));
|
|
53125
|
-
|
|
53125
|
+
getCliConfig.debug('Create new directory "%s"', outputPath), await fs.mkdir(outputPath, { recursive: !0 }), getCliConfig.debug("Downloading and extracting repo to %s", outputPath), await downloadAndExtractRepo(outputPath, repoInfo, bearerToken), getCliConfig.debug("Checking if template needs read token");
|
|
53126
53126
|
const needsReadToken = await Promise.all(
|
|
53127
53127
|
(packages ?? [""]).map((pkg) => checkIfNeedsApiToken(path$3.join(outputPath, pkg), "read"))
|
|
53128
53128
|
).then((results) => results.some(Boolean)), needsWriteToken = await Promise.all(
|
|
53129
53129
|
(packages ?? [""]).map((pkg) => checkIfNeedsApiToken(path$3.join(outputPath, pkg), "write"))
|
|
53130
53130
|
).then((results) => results.some(Boolean));
|
|
53131
|
-
|
|
53131
|
+
getCliConfig.debug("Applying environment variables");
|
|
53132
53132
|
const readToken = needsReadToken ? await generateSanityApiToken(READ_TOKEN_LABEL, "read", variables.projectId, apiClient) : void 0, writeToken = needsWriteToken ? await generateSanityApiToken(WRITE_TOKEN_LABEL, "write", variables.projectId, apiClient) : void 0;
|
|
53133
53133
|
for (const pkg of packages ?? [""]) {
|
|
53134
53134
|
const packagePath = path$3.join(outputPath, pkg), packageFramework = await distExports.detectFrameworkRecord({
|
|
53135
53135
|
fs: new distExports.LocalFileSystemDetector(packagePath),
|
|
53136
53136
|
frameworkList: frameworksExports.frameworks
|
|
53137
53137
|
}), port = getDefaultPortForFramework(packageFramework?.slug);
|
|
53138
|
-
corsAdded.includes(port) === !1 && (
|
|
53138
|
+
corsAdded.includes(port) === !1 && (getCliConfig.debug("Setting CORS origin to http://localhost:%d", port), await setCorsOrigin(`http://localhost:${port}`, variables.projectId, apiClient), corsAdded.push(port)), getCliConfig.debug("Applying environment variables to %s", pkg);
|
|
53139
53139
|
const envName = packageFramework?.slug === "nextjs" ? ".env.local" : ".env";
|
|
53140
53140
|
await applyEnvVariables(packagePath, { ...variables, readToken, writeToken }, envName);
|
|
53141
53141
|
}
|
|
53142
|
-
|
|
53142
|
+
getCliConfig.debug("Setting package name to %s", packageName), await tryApplyPackageName(outputPath, packageName), getCliConfig.debug("Initializing git repository"), tryGitInit(outputPath, INITIAL_COMMIT_MESSAGE), getCliConfig.debug("Updating initial template metadata"), await updateInitialTemplateMetadata(apiClient, variables.projectId, `external-${name}`), spinner.succeed(), corsAdded.length && output.success(`CORS origins added (${corsAdded.map((p) => `localhost:${p}`).join(", ")})`), readToken && output.success(`API token generated (${READ_TOKEN_LABEL})`), writeToken && output.success(`API token generated (${WRITE_TOKEN_LABEL})`);
|
|
53143
53143
|
}
|
|
53144
53144
|
function validateEmptyPath(dir) {
|
|
53145
53145
|
const checkPath = absolutify(dir);
|
|
@@ -53795,7 +53795,7 @@ ${err.message}`);
|
|
|
53795
53795
|
if (!envFilename.startsWith(".env"))
|
|
53796
53796
|
throw new Error("Env filename must start with .env");
|
|
53797
53797
|
const hasToken = getUserConfig().get("authToken");
|
|
53798
|
-
|
|
53798
|
+
getCliConfig.debug(hasToken ? "User already has a token" : "User has no token");
|
|
53799
53799
|
let user;
|
|
53800
53800
|
hasToken ? (trace.log({ step: "login", alreadyLoggedIn: !0 }), user = await getUserData(apiClient), success("You are logged in as %s using %s", user.email, getProviderName(user.provider))) : unattended || (trace.log({ step: "login" }), user = await getOrCreateUser());
|
|
53801
53801
|
const isAppTemplate = cliFlags.template ? determineAppTemplate(cliFlags.template) : !1;
|
|
@@ -53859,7 +53859,7 @@ You can find your project on Sanity Manage \u2014 https://www.sanity.io/manage/p
|
|
|
53859
53859
|
if (embeddedStudio) {
|
|
53860
53860
|
const appDir = "app";
|
|
53861
53861
|
let srcPath = path__default.default.join(workDir, appDir);
|
|
53862
|
-
fs$1.existsSync(srcPath) || (srcPath = path__default.default.join(workDir, "src", appDir), hasSrcFolder = !0, fs$1.existsSync(srcPath) || await fs__default.default.mkdir(srcPath, { recursive: !0 }).catch(() =>
|
|
53862
|
+
fs$1.existsSync(srcPath) || (srcPath = path__default.default.join(workDir, "src", appDir), hasSrcFolder = !0, fs$1.existsSync(srcPath) || await fs__default.default.mkdir(srcPath, { recursive: !0 }).catch(() => getCliConfig.debug("Error creating folder %s", srcPath)));
|
|
53863
53863
|
const studioPath = unattended ? "/studio" : await promptForStudioPath(prompt2), embeddedStudioRouteFilePath = path__default.default.join(
|
|
53864
53864
|
srcPath,
|
|
53865
53865
|
`${studioPath}/`,
|
|
@@ -53967,7 +53967,7 @@ ${chalk2.green("Success!")} Your Sanity configuration files has been added to th
|
|
|
53967
53967
|
return;
|
|
53968
53968
|
}
|
|
53969
53969
|
const folderPath = path__default.default.dirname(filePath);
|
|
53970
|
-
await fs__default.default.mkdir(folderPath, { recursive: !0 }).catch(() =>
|
|
53970
|
+
await fs__default.default.mkdir(folderPath, { recursive: !0 }).catch(() => getCliConfig.debug("Error creating folder %s", folderPath)), await fs__default.default.writeFile(filePath, content, {
|
|
53971
53971
|
encoding: "utf8"
|
|
53972
53972
|
});
|
|
53973
53973
|
}
|
|
@@ -54026,7 +54026,7 @@ Join the Sanity community: ${chalk2.cyan("https://www.sanity.io/community/join")
|
|
|
54026
54026
|
}
|
|
54027
54027
|
async function getProjectDetails() {
|
|
54028
54028
|
if (flags.quickstart) {
|
|
54029
|
-
|
|
54029
|
+
getCliConfig.debug("Fetching project details from Journey API");
|
|
54030
54030
|
const data = await journeyConfig.fetchJourneyConfig(apiClient, flags.quickstart);
|
|
54031
54031
|
return trace.log({
|
|
54032
54032
|
step: "fetchJourneyConfig",
|
|
@@ -54052,15 +54052,15 @@ Join the Sanity community: ${chalk2.cyan("https://www.sanity.io/community/join")
|
|
|
54052
54052
|
organizationId: await getOrganizationIdForAppTemplate(organizations)
|
|
54053
54053
|
};
|
|
54054
54054
|
}
|
|
54055
|
-
|
|
54055
|
+
getCliConfig.debug("Prompting user to select or create a project");
|
|
54056
54056
|
const project = await getOrCreateProject();
|
|
54057
|
-
|
|
54057
|
+
getCliConfig.debug(`Project with name ${project.displayName} selected`), getCliConfig.debug("Prompting user to select or create a dataset");
|
|
54058
54058
|
const dataset = await getOrCreateDataset({
|
|
54059
54059
|
projectId: project.projectId,
|
|
54060
54060
|
dataset: flags.dataset,
|
|
54061
54061
|
aclMode: flags.visibility
|
|
54062
54062
|
});
|
|
54063
|
-
return
|
|
54063
|
+
return getCliConfig.debug(`Dataset with name ${dataset.datasetName} selected`), trace.log({
|
|
54064
54064
|
step: "createOrSelectDataset",
|
|
54065
54065
|
selectedOption: dataset.userAction,
|
|
54066
54066
|
datasetName: dataset.datasetName,
|
|
@@ -54119,7 +54119,7 @@ ${err.message}`);
|
|
|
54119
54119
|
}
|
|
54120
54120
|
const isUsersFirstProject = projects.length === 0;
|
|
54121
54121
|
if (isUsersFirstProject || intendedCoupon) {
|
|
54122
|
-
|
|
54122
|
+
getCliConfig.debug(
|
|
54123
54123
|
isUsersFirstProject ? "No projects found for user, prompting for name" : "Using a coupon - skipping project selection"
|
|
54124
54124
|
);
|
|
54125
54125
|
const projectName = await prompt2.single({
|
|
@@ -54142,7 +54142,7 @@ ${err.message}`);
|
|
|
54142
54142
|
coupon: intendedCoupon
|
|
54143
54143
|
}));
|
|
54144
54144
|
}
|
|
54145
|
-
|
|
54145
|
+
getCliConfig.debug(`User has ${projects.length} project(s) already, showing list of choices`);
|
|
54146
54146
|
const projectChoices = projects.map((project) => ({
|
|
54147
54147
|
value: project.id,
|
|
54148
54148
|
name: `${project.displayName} (${project.id})`
|
|
@@ -54155,7 +54155,7 @@ ${err.message}`);
|
|
|
54155
54155
|
...projectChoices
|
|
54156
54156
|
]
|
|
54157
54157
|
});
|
|
54158
|
-
return selected === "new" ? (
|
|
54158
|
+
return selected === "new" ? (getCliConfig.debug("User wants to create a new project, prompting for name"), createProject(apiClient, {
|
|
54159
54159
|
displayName: await prompt2.single({
|
|
54160
54160
|
type: "input",
|
|
54161
54161
|
message: "Your project name:",
|
|
@@ -54168,7 +54168,7 @@ ${err.message}`);
|
|
|
54168
54168
|
...response,
|
|
54169
54169
|
isFirstProject: isUsersFirstProject,
|
|
54170
54170
|
userAction: "create"
|
|
54171
|
-
}))) : (
|
|
54171
|
+
}))) : (getCliConfig.debug(`Returning selected project (${selected})`), {
|
|
54172
54172
|
projectId: selected,
|
|
54173
54173
|
displayName: projects.find((proj) => proj.id === selected)?.displayName || "",
|
|
54174
54174
|
isFirstProject: isUsersFirstProject,
|
|
@@ -54186,8 +54186,8 @@ ${err.message}`);
|
|
|
54186
54186
|
throw new Error(`Visibility mode "${opts.aclMode}" not allowed`);
|
|
54187
54187
|
const getAclMode = async () => opts.aclMode ? opts.aclMode : unattended || !privateDatasetsAllowed || defaultConfig ? "public" : privateDatasetsAllowed ? await promptForAclMode(prompt2, output) : "public";
|
|
54188
54188
|
if (opts.dataset) {
|
|
54189
|
-
if (
|
|
54190
|
-
|
|
54189
|
+
if (getCliConfig.debug("User has specified dataset through a flag (%s)", opts.dataset), !datasets.find((ds) => ds.name === opts.dataset)) {
|
|
54190
|
+
getCliConfig.debug("Specified dataset not found, creating it");
|
|
54191
54191
|
const aclMode = await getAclMode(), spinner = context.output.spinner("Creating dataset").start();
|
|
54192
54192
|
await client2.datasets.create(opts.dataset, { aclMode }), spinner.succeed();
|
|
54193
54193
|
}
|
|
@@ -54197,13 +54197,13 @@ ${err.message}`);
|
|
|
54197
54197
|
whether you want to query your content with or without authentication.
|
|
54198
54198
|
The default dataset configuration has a public dataset named "production".`;
|
|
54199
54199
|
if (datasets.length === 0) {
|
|
54200
|
-
|
|
54200
|
+
getCliConfig.debug("No datasets found for project, prompting for name"), showDefaultConfigPrompt && (output.print(datasetInfo), defaultConfig = await promptForDefaultConfig(prompt2));
|
|
54201
54201
|
const name = defaultConfig ? "production" : await promptForDatasetName(prompt2, {
|
|
54202
54202
|
message: "Name of your first dataset:"
|
|
54203
54203
|
}), aclMode = await getAclMode(), spinner = context.output.spinner("Creating dataset").start();
|
|
54204
54204
|
return await client2.datasets.create(name, { aclMode }), spinner.succeed(), { datasetName: name, userAction: "create" };
|
|
54205
54205
|
}
|
|
54206
|
-
|
|
54206
|
+
getCliConfig.debug(`User has ${datasets.length} dataset(s) already, showing list of choices`);
|
|
54207
54207
|
const datasetChoices = datasets.map((dataset) => ({ value: dataset.name })), selected = await prompt2.single({
|
|
54208
54208
|
message: "Select dataset to use",
|
|
54209
54209
|
type: "list",
|
|
@@ -54215,7 +54215,7 @@ The default dataset configuration has a public dataset named "production".`;
|
|
|
54215
54215
|
});
|
|
54216
54216
|
if (selected === "new") {
|
|
54217
54217
|
const existingDatasetNames = datasets.map((ds) => ds.name);
|
|
54218
|
-
|
|
54218
|
+
getCliConfig.debug("User wants to create a new dataset, prompting for name"), showDefaultConfigPrompt && !existingDatasetNames.includes("production") && (output.print(datasetInfo), defaultConfig = await promptForDefaultConfig(prompt2));
|
|
54219
54219
|
const newDatasetName = defaultConfig ? "production" : await promptForDatasetName(
|
|
54220
54220
|
prompt2,
|
|
54221
54221
|
{
|
|
@@ -54225,7 +54225,7 @@ The default dataset configuration has a public dataset named "production".`;
|
|
|
54225
54225
|
), aclMode = await getAclMode(), spinner = context.output.spinner("Creating dataset").start();
|
|
54226
54226
|
return await client2.datasets.create(newDatasetName, { aclMode }), spinner.succeed(), { datasetName: newDatasetName, userAction: "create" };
|
|
54227
54227
|
}
|
|
54228
|
-
return
|
|
54228
|
+
return getCliConfig.debug(`Returning selected dataset (${selected})`), { datasetName: selected, userAction: "select" };
|
|
54229
54229
|
}
|
|
54230
54230
|
function promptForDatasetImport(message) {
|
|
54231
54231
|
return prompt2.single({
|
|
@@ -54267,7 +54267,7 @@ The default dataset configuration has a public dataset named "production".`;
|
|
|
54267
54267
|
body: { metadata: { cliInitializedAt: (/* @__PURE__ */ new Date()).toISOString() } }
|
|
54268
54268
|
});
|
|
54269
54269
|
} catch {
|
|
54270
|
-
|
|
54270
|
+
getCliConfig.debug("Failed to update cliInitializedAt metadata");
|
|
54271
54271
|
}
|
|
54272
54272
|
}
|
|
54273
54273
|
async function bootstrapTemplate() {
|
|
@@ -54339,7 +54339,7 @@ The default dataset configuration has a public dataset named "production".`;
|
|
|
54339
54339
|
if (typeof createProjectName == "string" && createProjectName.trim().length === 0)
|
|
54340
54340
|
throw new Error("Please specify a project name (`--create-project <name>`)");
|
|
54341
54341
|
if (unattended) {
|
|
54342
|
-
if (
|
|
54342
|
+
if (getCliConfig.debug("Unattended mode, validating required options"), !cliFlags.dataset)
|
|
54343
54343
|
throw new Error("`--dataset` must be specified in unattended mode");
|
|
54344
54344
|
if (!isNextJs && !cliFlags["output-path"])
|
|
54345
54345
|
throw new Error("`--output-path` must be specified in unattended mode");
|
|
@@ -54353,22 +54353,22 @@ The default dataset configuration has a public dataset named "production".`;
|
|
|
54353
54353
|
);
|
|
54354
54354
|
}
|
|
54355
54355
|
if (createProjectName) {
|
|
54356
|
-
|
|
54356
|
+
getCliConfig.debug("--create-project specified, creating a new project");
|
|
54357
54357
|
let orgForCreateProjectFlag = cliFlags.organization;
|
|
54358
54358
|
if (!orgForCreateProjectFlag) {
|
|
54359
|
-
|
|
54359
|
+
getCliConfig.debug("no organization specified, selecting one");
|
|
54360
54360
|
const organizations = await apiClient({ requireUser: !0, requireProject: !1 }).request({ uri: "/organizations" });
|
|
54361
54361
|
orgForCreateProjectFlag = await getOrganizationId(organizations);
|
|
54362
54362
|
}
|
|
54363
|
-
|
|
54363
|
+
getCliConfig.debug("creating a new project");
|
|
54364
54364
|
const createdProject = await createProject(apiClient, {
|
|
54365
54365
|
displayName: createProjectName.trim(),
|
|
54366
54366
|
organizationId: orgForCreateProjectFlag,
|
|
54367
54367
|
subscription: selectedPlan ? { planId: selectedPlan } : void 0,
|
|
54368
54368
|
metadata: { coupon: intendedCoupon }
|
|
54369
54369
|
});
|
|
54370
|
-
if (
|
|
54371
|
-
|
|
54370
|
+
if (getCliConfig.debug("Project with ID %s created", createdProject.projectId), cliFlags.dataset) {
|
|
54371
|
+
getCliConfig.debug("--dataset specified, creating dataset (%s)", cliFlags.dataset);
|
|
54372
54372
|
const client2 = apiClient({ api: { projectId: createdProject.projectId } }), spinner = context.output.spinner("Creating dataset").start(), createBody = cliFlags.visibility ? { aclMode: cliFlags.visibility } : {};
|
|
54373
54373
|
await client2.datasets.create(cliFlags.dataset, createBody), spinner.succeed();
|
|
54374
54374
|
}
|
|
@@ -54412,9 +54412,9 @@ The default dataset configuration has a public dataset named "production".`;
|
|
|
54412
54412
|
async function getOrganizationId(organizations) {
|
|
54413
54413
|
if (organizations.length === 0)
|
|
54414
54414
|
return createOrganization2().then((org) => org.id);
|
|
54415
|
-
|
|
54415
|
+
getCliConfig.debug(`User has ${organizations.length} organization(s), checking attach access`);
|
|
54416
54416
|
const withGrantInfo = await getOrganizationsWithAttachGrantInfo2(organizations), withAttach = withGrantInfo.filter(({ hasAttachGrant }) => hasAttachGrant);
|
|
54417
|
-
|
|
54417
|
+
getCliConfig.debug("User has attach access to %d organizations.", withAttach.length);
|
|
54418
54418
|
const organizationChoices = [
|
|
54419
54419
|
...withGrantInfo.map(({ organization, hasAttachGrant }) => ({
|
|
54420
54420
|
value: organization.id,
|
|
@@ -54439,7 +54439,7 @@ The default dataset configuration has a public dataset named "production".`;
|
|
|
54439
54439
|
(resource) => resource.grants && resource.grants.some((grant) => grant.name === requiredGrant)
|
|
54440
54440
|
);
|
|
54441
54441
|
} catch (err) {
|
|
54442
|
-
return err.statusCode === 401 ? (
|
|
54442
|
+
return err.statusCode === 401 ? (getCliConfig.debug("No access to organization %s (401)", orgId), !1) : (getCliConfig.debug("Error checking grants for organization %s: %s", orgId, err.message), !1);
|
|
54443
54443
|
}
|
|
54444
54444
|
}
|
|
54445
54445
|
function getOrganizationsWithAttachGrantInfo2(organizations) {
|
|
@@ -54474,7 +54474,7 @@ Detected framework ${chalk2.blue(framework?.name)}, using prefix '${framework.en
|
|
|
54474
54474
|
const envPrefix = options2.framework?.envPrefix || "", keyPrefix = envPrefix.includes("SANITY") ? envPrefix : `${envPrefix}SANITY_`, fileOutputPath = path__default.default.join(options2.outputPath, filename);
|
|
54475
54475
|
for (const key2 of Object.keys(envVars))
|
|
54476
54476
|
envVars[`${keyPrefix}${key2}`] = envVars[key2], delete envVars[key2];
|
|
54477
|
-
await fs__default.default.mkdir(options2.outputPath, { recursive: !0 }).catch(() =>
|
|
54477
|
+
await fs__default.default.mkdir(options2.outputPath, { recursive: !0 }).catch(() => getCliConfig.debug("Error creating folder %s", options2.outputPath));
|
|
54478
54478
|
const existingEnv = await fs__default.default.readFile(fileOutputPath, { encoding: "utf8" }).catch((err) => err.code === "ENOENT" ? "" : Promise.reject(err)), updatedEnv = parseAndUpdateEnvVars(existingEnv, envVars, {
|
|
54479
54479
|
log: options2.log
|
|
54480
54480
|
}), warningComment = [
|
|
@@ -54577,7 +54577,7 @@ function getImportCommand(outputPath, studioVersion) {
|
|
|
54577
54577
|
const pkgPath2 = resolveFrom.silent(outputPath, "sanity/_internal");
|
|
54578
54578
|
if (!pkgPath2)
|
|
54579
54579
|
throw new Error("Failed to resolve `sanity` module - problem with dependency installation?");
|
|
54580
|
-
|
|
54580
|
+
getCliConfig.debug("`sanity` module path resolved to %s (from %s)", pkgPath2, outputPath);
|
|
54581
54581
|
const cliInternals = getCliConfig.dynamicRequire(pkgPath2);
|
|
54582
54582
|
if (!("cliProjectCommands" in cliInternals))
|
|
54583
54583
|
throw new Error("Incorrect version of the `sanity` module installed");
|
|
@@ -55246,12 +55246,12 @@ function createSetTelemetryConsentAction(status) {
|
|
|
55246
55246
|
apiVersion: "2023-12-18",
|
|
55247
55247
|
useProjectHostname: !1
|
|
55248
55248
|
}), currentInformation = await resolveConsent({ env: process.env }), isChanged = currentInformation.status !== status;
|
|
55249
|
-
if (isChanged || (
|
|
55249
|
+
if (isChanged || (getCliConfig.debug('Telemetry consent is already "%s"', status), output.print(`${telemetryStatusMessage(status, context)}
|
|
55250
55250
|
`), output.print(resultMessages[status].unchanged(currentInformation))), isChanged) {
|
|
55251
|
-
|
|
55251
|
+
getCliConfig.debug('Setting telemetry consent to "%s"', status);
|
|
55252
55252
|
try {
|
|
55253
55253
|
const uri = `/users/me/consents/telemetry/status/${status}`;
|
|
55254
|
-
|
|
55254
|
+
getCliConfig.debug("Sending telemetry consent status to %s", uri), await client2.request({
|
|
55255
55255
|
method: "PUT",
|
|
55256
55256
|
uri
|
|
55257
55257
|
}), config2.delete(TELEMETRY_CONSENT_CONFIG_KEY), output.print(`${telemetryStatusMessage(status, context)}
|
|
@@ -79637,33 +79637,33 @@ class CommandRunner {
|
|
|
79637
79637
|
return context.output.print(generateCommandsDocumentation(this.commandGroups, command2.name));
|
|
79638
79638
|
if (typeof command2.action != "function") {
|
|
79639
79639
|
const cmdName = command2.name || commandOrGroup || "<unknown>";
|
|
79640
|
-
|
|
79640
|
+
getCliConfig.debug(`Command "${cmdName}" doesnt have a valid "action"-property, showing help`);
|
|
79641
79641
|
const groupName = command2.group && command2.group !== "default" ? command2.group : null;
|
|
79642
79642
|
return context.output.print(generateCommandDocumentation(command2, groupName, subCommandName));
|
|
79643
79643
|
}
|
|
79644
|
-
return
|
|
79644
|
+
return getCliConfig.debug(`Running command "${command2.name}"`), command2.action(cmdArgs, context);
|
|
79645
79645
|
}
|
|
79646
79646
|
resolveCommand(commandOrGroup, subCommandName) {
|
|
79647
79647
|
if (this.commandGroups[commandOrGroup] && subCommandName) {
|
|
79648
|
-
|
|
79648
|
+
getCliConfig.debug(`Found group for name "${commandOrGroup}", resolving subcommand`);
|
|
79649
79649
|
const subCommand = this.resolveSubcommand(
|
|
79650
79650
|
this.commandGroups[commandOrGroup],
|
|
79651
79651
|
subCommandName,
|
|
79652
79652
|
commandOrGroup
|
|
79653
79653
|
);
|
|
79654
|
-
return
|
|
79654
|
+
return getCliConfig.debug(
|
|
79655
79655
|
subCommand ? `Subcommand resolved to "${subCommand.commandName}"` : `Subcommand with name "${subCommandName}" not found`
|
|
79656
79656
|
), subCommand;
|
|
79657
79657
|
}
|
|
79658
|
-
|
|
79658
|
+
getCliConfig.debug(`No group found with name "${commandOrGroup}", looking for command`);
|
|
79659
79659
|
const command2 = this.commandGroups.default.find((cmd) => cmd.name === commandOrGroup);
|
|
79660
|
-
return command2 ? (
|
|
79660
|
+
return command2 ? (getCliConfig.debug(`Found command in default group with name "${commandOrGroup}"`), {
|
|
79661
79661
|
command: command2,
|
|
79662
79662
|
commandName: command2.name,
|
|
79663
79663
|
parentName: "default",
|
|
79664
79664
|
isGroup: !1,
|
|
79665
79665
|
isCommand: !0
|
|
79666
|
-
}) : (
|
|
79666
|
+
}) : (getCliConfig.debug(`No default command with name "${commandOrGroup}" found, giving up`), null);
|
|
79667
79667
|
}
|
|
79668
79668
|
resolveSubcommand(group, subCommandName, parentGroupName) {
|
|
79669
79669
|
if (!subCommandName)
|
|
@@ -80130,11 +80130,11 @@ const TELEMETRY_DISCLOSED_CONFIG_KEY = "telemetryDisclosed";
|
|
|
80130
80130
|
function telemetryDisclosure() {
|
|
80131
80131
|
const userConfig = getUserConfig();
|
|
80132
80132
|
if (isCi) {
|
|
80133
|
-
|
|
80133
|
+
getCliConfig.debug("CI environment detected, skipping telemetry disclosure");
|
|
80134
80134
|
return;
|
|
80135
80135
|
}
|
|
80136
80136
|
if (userConfig.get(TELEMETRY_DISCLOSED_CONFIG_KEY)) {
|
|
80137
|
-
|
|
80137
|
+
getCliConfig.debug("Telemetry disclosure has already been shown");
|
|
80138
80138
|
return;
|
|
80139
80139
|
}
|
|
80140
80140
|
console.error(
|
|
@@ -80207,7 +80207,7 @@ var pTimeoutExports = requirePTimeout(), pTimeout = /* @__PURE__ */ loadEnv.getD
|
|
|
80207
80207
|
const MAX_BLOCKING_TIME = 300, TWELVE_HOURS = 1e3 * 60 * 60 * 12, isDisabled = isCi || // Running in CI environment
|
|
80208
80208
|
process.env.NO_UPDATE_NOTIFIER;
|
|
80209
80209
|
function runUpdateCheck(options2) {
|
|
80210
|
-
|
|
80210
|
+
getCliConfig.debug("CLI installed at %s", __dirname);
|
|
80211
80211
|
const { pkg, cwd, workDir } = options2, { name, version: version2 } = pkg, userConfig = getUserConfig(), check = getLatestRemote().catch(() => !1);
|
|
80212
80212
|
let hasPrintedResult = !1;
|
|
80213
80213
|
return { notify };
|
|
@@ -80216,25 +80216,25 @@ function runUpdateCheck(options2) {
|
|
|
80216
80216
|
return;
|
|
80217
80217
|
const result = await pTimeout(check, MAX_BLOCKING_TIME, printCachedResult);
|
|
80218
80218
|
if (hasPrintedResult) {
|
|
80219
|
-
|
|
80219
|
+
getCliConfig.debug("Has already printed result through timeout check, skipping result notification");
|
|
80220
80220
|
return;
|
|
80221
80221
|
}
|
|
80222
80222
|
printResult2(result);
|
|
80223
80223
|
}
|
|
80224
80224
|
async function printCachedResult() {
|
|
80225
|
-
|
|
80225
|
+
getCliConfig.debug("Max time (%dms) reached waiting for latest version info", MAX_BLOCKING_TIME), hasPrintedResult = !0;
|
|
80226
80226
|
const cached = userConfig.get("cliHasUpdate");
|
|
80227
|
-
return cached ? semverCompare(cached, version2) <= 0 ? (
|
|
80227
|
+
return cached ? semverCompare(cached, version2) <= 0 ? (getCliConfig.debug("CLI was upgraded since last check, falling back"), userConfig.delete("cliHasUpdate"), !1) : (getCliConfig.debug("Printing cached latest version result"), await printResult2(cached), !1) : (getCliConfig.debug("No cached latest version result found"), !1);
|
|
80228
80228
|
}
|
|
80229
80229
|
async function printResult2(newVersion) {
|
|
80230
80230
|
hasPrintedResult = !0;
|
|
80231
80231
|
const lastUpdated = userConfig.get("cliLastUpdateNag") || 0;
|
|
80232
80232
|
if (Date.now() - lastUpdated < TWELVE_HOURS) {
|
|
80233
|
-
|
|
80233
|
+
getCliConfig.debug("Less than 12 hours since last nag, skipping");
|
|
80234
80234
|
return;
|
|
80235
80235
|
}
|
|
80236
80236
|
if (!newVersion || semverCompare(newVersion, version2) <= 0) {
|
|
80237
|
-
|
|
80237
|
+
getCliConfig.debug(`New version is ${newVersion || "unknown"}, current is ${version2}. Falling back.`);
|
|
80238
80238
|
return;
|
|
80239
80239
|
}
|
|
80240
80240
|
const upgradeCommand = await getCliUpgradeCommand({ cwd, workDir }), message = [
|
|
@@ -80259,22 +80259,22 @@ ${boxen(message, {
|
|
|
80259
80259
|
}
|
|
80260
80260
|
async function getLatestRemote() {
|
|
80261
80261
|
if (isDisabled)
|
|
80262
|
-
return
|
|
80262
|
+
return getCliConfig.debug("Running on CI, or explicitly disabled, skipping update check"), !1;
|
|
80263
80263
|
const lastUpdated = userConfig.get("cliLastUpdateCheck") || 0;
|
|
80264
80264
|
if (Date.now() - lastUpdated < TWELVE_HOURS)
|
|
80265
|
-
return
|
|
80265
|
+
return getCliConfig.debug("Less than 12 hours since last check, skipping update check"), userConfig.get("cliHasUpdate") || !1;
|
|
80266
80266
|
let latestRemote;
|
|
80267
80267
|
try {
|
|
80268
|
-
|
|
80268
|
+
getCliConfig.debug("Checking for latest remote version"), latestRemote = await latestVersion(name), getCliConfig.debug("Latest remote version is %s", latestRemote);
|
|
80269
80269
|
} catch (err) {
|
|
80270
|
-
return
|
|
80270
|
+
return getCliConfig.debug(`Failed to fetch latest version of ${name} from npm:
|
|
80271
80271
|
${err.stack}`), !1;
|
|
80272
80272
|
}
|
|
80273
80273
|
if (!latestRemote)
|
|
80274
|
-
return
|
|
80274
|
+
return getCliConfig.debug(`Failed to fetch latest version of ${name} from npm`), !1;
|
|
80275
80275
|
userConfig.set("cliLastUpdateCheck", Date.now());
|
|
80276
80276
|
const diff = semverCompare(latestRemote, version2);
|
|
80277
|
-
return diff <= 0 ? (
|
|
80277
|
+
return diff <= 0 ? (getCliConfig.debug(diff === 0 ? "No update found" : "Remote version older than local"), userConfig.delete("cliHasUpdate"), !1) : (userConfig.set("cliHasUpdate", latestRemote), getCliConfig.debug("Update is available (%s)", latestRemote), latestRemote);
|
|
80278
80278
|
}
|
|
80279
80279
|
}
|
|
80280
80280
|
const sanityEnv = process.env.SANITY_INTERNAL_ENV || "production", knownEnvs = ["development", "staging", "production"];
|
|
@@ -80296,9 +80296,9 @@ async function runCli(cliRoot, { cliVersion }) {
|
|
|
80296
80296
|
} catch (err) {
|
|
80297
80297
|
console.error(chalk__default.default.red(err.message)), process.exit(1);
|
|
80298
80298
|
}
|
|
80299
|
-
await runUpdateCheck({ pkg, cwd, workDir }).notify(), telemetryDisclosure(),
|
|
80299
|
+
await runUpdateCheck({ pkg, cwd, workDir }).notify(), telemetryDisclosure(), getCliConfig.debug(`Reading CLI config from "${workDir}"`);
|
|
80300
80300
|
let cliConfig = await getCliConfig.getCliConfig(workDir, { forked: !0 });
|
|
80301
|
-
cliConfig ||
|
|
80301
|
+
cliConfig || getCliConfig.debug("No CLI config found");
|
|
80302
80302
|
const isApp = !!(cliConfig && "app" in cliConfig);
|
|
80303
80303
|
loadAndSetEnvFromDotEnvFiles({ workDir, cmd: args.groupOrCommand, isApp }), maybeFixMissingWindowsEnvVar(), cliConfig = await getCliConfig.getCliConfig(workDir, { forked: !0 });
|
|
80304
80304
|
const { logger: telemetry2, flush: flushTelemetry } = createTelemetryStore({
|
|
@@ -80341,7 +80341,7 @@ async function runCli(cliRoot, { cliVersion }) {
|
|
|
80341
80341
|
...!args.groupOrCommand && { emptyCommand: !0 }
|
|
80342
80342
|
// user did not entry a command
|
|
80343
80343
|
});
|
|
80344
|
-
cliCommandTrace.start(), cliRunner.runCommand(args.groupOrCommand, args, {
|
|
80344
|
+
getCliConfig.debug("Starting cli runner with options:", JSON.stringify(options2, null, 2)), cliCommandTrace.start(), cliRunner.runCommand(args.groupOrCommand, args, {
|
|
80345
80345
|
...options2,
|
|
80346
80346
|
telemetry: cliCommandTrace.newContext(args.groupOrCommand)
|
|
80347
80347
|
}).then(() => cliCommandTrace.complete()).catch(async (err) => {
|
|
@@ -80433,16 +80433,16 @@ function loadAndSetEnvFromDotEnvFiles({
|
|
|
80433
80433
|
isApp
|
|
80434
80434
|
}) {
|
|
80435
80435
|
if (fs$1.existsSync(path__default.default.join(workDir, "sanity.json"))) {
|
|
80436
|
-
|
|
80436
|
+
getCliConfig.debug("sanity.json exists, assuming v2 project and loading .env files using old behavior");
|
|
80437
80437
|
const env = process.env.SANITY_ACTIVE_ENV || process.env.NODE_ENV || "development";
|
|
80438
|
-
|
|
80438
|
+
getCliConfig.debug("Loading environment files using %s mode", env), loadEnv.dotenv.config({ path: path__default.default.join(workDir, `.env.${env}`) });
|
|
80439
80439
|
return;
|
|
80440
80440
|
}
|
|
80441
|
-
|
|
80441
|
+
getCliConfig.debug("No sanity.json exists, assuming v3 project and loading .env files using new behavior");
|
|
80442
80442
|
const isProdCmd = ["build", "deploy"].includes(cmd);
|
|
80443
80443
|
let mode2 = process.env.SANITY_ACTIVE_ENV;
|
|
80444
80444
|
!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
|
|
80445
|
-
`)),
|
|
80445
|
+
`)), getCliConfig.debug("Loading environment files using %s mode", mode2);
|
|
80446
80446
|
const studioEnv = loadEnv.loadEnv(mode2, workDir, [isApp ? "SANITY_APP_" : "SANITY_STUDIO_"]);
|
|
80447
80447
|
process.env = { ...process.env, ...studioEnv };
|
|
80448
80448
|
}
|