@sanity/cli 3.59.2-corel-fix-presentation-perspective-switching.536 → 3.59.2-corel-presentation-lcapi.562
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
CHANGED
@@ -26706,7 +26706,7 @@ async function applyEnvVariables(root2, envData, targetName = ".env") {
|
|
26706
26706
|
});
|
26707
26707
|
if (templatePath)
|
26708
26708
|
try {
|
26709
|
-
const templateContent = await fs.readFile(path$3.join(root2, templatePath), "utf8"), { projectId, dataset, readToken = "" } = envData, findAndReplaceVariable = (content, varRegex, value, useQuotes2) => {
|
26709
|
+
const templateContent = await fs.readFile(path$3.join(root2, templatePath), "utf8"), { projectId, dataset, readToken = "", writeToken = "" } = envData, findAndReplaceVariable = (content, varRegex, value, useQuotes2) => {
|
26710
26710
|
const varPattern = typeof varRegex == "string" ? varRegex : varRegex.source, pattern = new RegExp(`.*${varPattern}=.*$`, "gm"), matches = content.matchAll(pattern);
|
26711
26711
|
return Array.from(matches).reduce((updatedContent, match2) => {
|
26712
26712
|
if (!match2[0]) return updatedContent;
|
@@ -26721,7 +26721,8 @@ async function applyEnvVariables(root2, envData, targetName = ".env") {
|
|
26721
26721
|
const vars = [
|
26722
26722
|
{ pattern: ENV_VAR.PROJECT_ID, value: projectId },
|
26723
26723
|
{ pattern: ENV_VAR.DATASET, value: dataset },
|
26724
|
-
{ pattern: ENV_VAR.READ_TOKEN, value: readToken }
|
26724
|
+
{ pattern: ENV_VAR.READ_TOKEN, value: readToken },
|
26725
|
+
{ pattern: ENV_VAR.WRITE_TOKEN, value: writeToken }
|
26725
26726
|
], useQuotes = templateContent.includes('="');
|
26726
26727
|
for (const { pattern, value } of vars)
|
26727
26728
|
envContent = findAndReplaceVariable(envContent, pattern, value, useQuotes);
|
@@ -51917,7 +51918,7 @@ async function bootstrapRemoteTemplate(opts, context) {
|
|
51917
51918
|
}), port = getDefaultPortForFramework(packageFramework?.slug);
|
51918
51919
|
corsAdded.includes(port) === !1 && (loadEnv.debug("Setting CORS origin to http://localhost:%d", port), await setCorsOrigin(`http://localhost:${port}`, variables.projectId, apiClient), corsAdded.push(port)), loadEnv.debug("Applying environment variables to %s", pkg);
|
51919
51920
|
const envName = packageFramework?.slug === "nextjs" ? ".env.local" : ".env";
|
51920
|
-
await applyEnvVariables(packagePath, { ...variables, readToken }, envName);
|
51921
|
+
await applyEnvVariables(packagePath, { ...variables, readToken, writeToken }, envName);
|
51921
51922
|
}
|
51922
51923
|
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(), 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})`);
|
51923
51924
|
}
|