@sanity/cli 7.3.0 → 7.4.1
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/README.md +25 -1
- package/dist/actions/build/buildApp.js +19 -14
- package/dist/actions/build/buildApp.js.map +1 -1
- package/dist/actions/build/buildStaticFiles.js +1 -1
- package/dist/actions/build/buildStaticFiles.js.map +1 -1
- package/dist/actions/build/buildStudio.js +22 -18
- package/dist/actions/build/buildStudio.js.map +1 -1
- package/dist/actions/dev/devAction.js +46 -197
- package/dist/actions/dev/devAction.js.map +1 -1
- package/dist/actions/dev/servers/getDevServerConfig.js +1 -1
- package/dist/actions/dev/servers/getDevServerConfig.js.map +1 -1
- package/dist/actions/dev/servers/startAppDevServer.js +18 -9
- package/dist/actions/dev/servers/startAppDevServer.js.map +1 -1
- package/dist/actions/dev/servers/startStudioDevServer.js +2 -2
- package/dist/actions/dev/servers/startStudioDevServer.js.map +1 -1
- package/dist/actions/dev/types.js.map +1 -1
- package/dist/actions/init/scaffoldTemplate.js +3 -12
- package/dist/actions/init/scaffoldTemplate.js.map +1 -1
- package/dist/actions/init/templates/pageBuilder.js +1 -1
- package/dist/actions/init/templates/pageBuilder.js.map +1 -1
- package/dist/actions/{dev/registration/extractDevServerManifest.js → manifest/extractStudioManifest.js} +3 -3
- package/dist/actions/manifest/extractStudioManifest.js.map +1 -0
- package/dist/actions/mcp/editorConfigs.js +8 -4
- package/dist/actions/mcp/editorConfigs.js.map +1 -1
- package/dist/commands/datasets/copy.js +17 -19
- package/dist/commands/datasets/copy.js.map +1 -1
- package/dist/commands/datasets/import.js +11 -15
- package/dist/commands/datasets/import.js.map +1 -1
- package/dist/commands/doctor.js +9 -9
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/telemetry/disable.js +3 -3
- package/dist/commands/telemetry/disable.js.map +1 -1
- package/dist/commands/telemetry/enable.js +3 -3
- package/dist/commands/telemetry/enable.js.map +1 -1
- package/dist/commands/telemetry/status.js +2 -2
- package/dist/commands/telemetry/status.js.map +1 -1
- package/dist/exports/_internal.d.ts +4 -47
- package/dist/exports/_internal.js +1 -1
- package/dist/exports/_internal.js.map +1 -1
- package/dist/server/devServer.js +1 -1
- package/dist/server/devServer.js.map +1 -1
- package/dist/util/compareDependencyVersions.js.map +1 -1
- package/dist/util/resolveLatestVersions.js +20 -2
- package/dist/util/resolveLatestVersions.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +14 -16
- package/dist/actions/build/getEnvironmentVariables.js +0 -54
- package/dist/actions/build/getEnvironmentVariables.js.map +0 -1
- package/dist/actions/dev/registration/deriveInterfaces.js +0 -46
- package/dist/actions/dev/registration/deriveInterfaces.js.map +0 -1
- package/dist/actions/dev/registration/extractDevServerManifest.js.map +0 -1
- package/dist/actions/dev/registration/interfaceSetId.js +0 -41
- package/dist/actions/dev/registration/interfaceSetId.js.map +0 -1
- package/dist/actions/dev/registration/startDevManifestWatcher.js +0 -104
- package/dist/actions/dev/registration/startDevManifestWatcher.js.map +0 -1
- package/dist/actions/dev/registration/startDevServerRegistration.js +0 -121
- package/dist/actions/dev/registration/startDevServerRegistration.js.map +0 -1
- package/dist/actions/dev/workbench/startWorkbenchDevServer.js +0 -276
- package/dist/actions/dev/workbench/startWorkbenchDevServer.js.map +0 -1
- package/dist/actions/dev/workbench/writeWorkbenchRuntime.js +0 -66
- package/dist/actions/dev/workbench/writeWorkbenchRuntime.js.map +0 -1
package/README.md
CHANGED
|
@@ -103,6 +103,7 @@ Code for sanity cli
|
|
|
103
103
|
- [`sanity schemas extract`](#sanity-schemas-extract)
|
|
104
104
|
- [`sanity schemas list`](#sanity-schemas-list)
|
|
105
105
|
- [`sanity schemas validate`](#sanity-schemas-validate)
|
|
106
|
+
- [`sanity skills install`](#sanity-skills-install)
|
|
106
107
|
- [`sanity telemetry disable`](#sanity-telemetry-disable)
|
|
107
108
|
- [`sanity telemetry enable`](#sanity-telemetry-enable)
|
|
108
109
|
- [`sanity telemetry status`](#sanity-telemetry-status)
|
|
@@ -501,7 +502,7 @@ USAGE
|
|
|
501
502
|
--stack-id <value> | --stack-name <value>] [--project-id <value> | --organization-id <value>]
|
|
502
503
|
|
|
503
504
|
ARGUMENTS
|
|
504
|
-
[DIR] Directory to create the local Blueprint in
|
|
505
|
+
[DIR] Directory to create the local Blueprint in (defaults to the current directory)
|
|
505
506
|
|
|
506
507
|
FLAGS
|
|
507
508
|
--blueprint-type=<option> Blueprint manifest type to use for the local Blueprint
|
|
@@ -528,9 +529,14 @@ DESCRIPTION
|
|
|
528
529
|
|
|
529
530
|
After initialization, use 'blueprints plan' to preview changes, then 'blueprints deploy' to apply them.
|
|
530
531
|
|
|
532
|
+
Running without a directory prompts to confirm the current directory. Run 'blueprints init .' to initialize in the
|
|
533
|
+
current directory without a prompt.
|
|
534
|
+
|
|
531
535
|
EXAMPLES
|
|
532
536
|
$ sanity blueprints init
|
|
533
537
|
|
|
538
|
+
$ sanity blueprints init .
|
|
539
|
+
|
|
534
540
|
$ sanity blueprints init [directory]
|
|
535
541
|
|
|
536
542
|
$ sanity blueprints init --blueprint-type <json|js|ts>
|
|
@@ -3185,6 +3191,24 @@ EXAMPLES
|
|
|
3185
3191
|
$ sanity schemas validate --debug-metafile-path metafile.json
|
|
3186
3192
|
```
|
|
3187
3193
|
|
|
3194
|
+
## `sanity skills install`
|
|
3195
|
+
|
|
3196
|
+
Install Sanity agent skills for detected AI editors (Antigravity, Claude Code, Cline, Cline CLI, Codex CLI, Cursor, Gemini CLI, GitHub Copilot CLI, OpenCode, VS Code, VS Code Insiders)
|
|
3197
|
+
|
|
3198
|
+
```
|
|
3199
|
+
USAGE
|
|
3200
|
+
$ sanity skills install
|
|
3201
|
+
|
|
3202
|
+
DESCRIPTION
|
|
3203
|
+
Install Sanity agent skills for detected AI editors (Antigravity, Claude Code, Cline, Cline CLI, Codex CLI, Cursor,
|
|
3204
|
+
Gemini CLI, GitHub Copilot CLI, OpenCode, VS Code, VS Code Insiders)
|
|
3205
|
+
|
|
3206
|
+
EXAMPLES
|
|
3207
|
+
Install Sanity agent skills for detected AI editors
|
|
3208
|
+
|
|
3209
|
+
$ sanity skills install
|
|
3210
|
+
```
|
|
3211
|
+
|
|
3188
3212
|
## `sanity telemetry disable`
|
|
3189
3213
|
|
|
3190
3214
|
Disable telemetry for your account
|
|
@@ -2,6 +2,7 @@ import { rm } from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { styleText } from 'node:util';
|
|
4
4
|
import { AppBuildTrace, buildDebug, getAutoUpdatesCssUrls, getAutoUpdatesImportMap, resolveVendorBuildConfig } from '@sanity/cli-build/_internal/build';
|
|
5
|
+
import { getAppEnvironmentVariables } from '@sanity/cli-build/_internal/env';
|
|
5
6
|
import { getCliTelemetry, getLocalPackageVersion, getTimer, isInteractive } from '@sanity/cli-core';
|
|
6
7
|
import { confirm, logSymbols, spinner } from '@sanity/cli-core/ux';
|
|
7
8
|
import { resolveWorkbenchApp } from '@sanity/workbench-cli/build';
|
|
@@ -12,7 +13,6 @@ import { formatModuleSizes, sortModulesBySize } from '../../util/moduleFormatUti
|
|
|
12
13
|
import { warnAboutMissingAppId } from '../../util/warnAboutMissingAppId.js';
|
|
13
14
|
import { buildStaticFiles } from './buildStaticFiles.js';
|
|
14
15
|
import { determineBasePath } from './determineBasePath.js';
|
|
15
|
-
import { getAppEnvironmentVariables } from './getEnvironmentVariables.js';
|
|
16
16
|
import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
|
|
17
17
|
/**
|
|
18
18
|
* Build the Sanity app.
|
|
@@ -24,11 +24,25 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
|
|
|
24
24
|
// `views`/`services` live on the branded `unstable_defineApp` result, not the
|
|
25
25
|
// legacy `app` config object — resolve the workbench capability to read them.
|
|
26
26
|
const workbench = resolveWorkbenchApp(cliConfig);
|
|
27
|
+
const appId = getAppId(cliConfig);
|
|
27
28
|
await internalBuildApp({
|
|
28
|
-
appId
|
|
29
|
+
appId,
|
|
29
30
|
appTitle: app?.title,
|
|
30
31
|
autoUpdatesEnabled: options.autoUpdatesEnabled,
|
|
31
|
-
|
|
32
|
+
checkAppId: ()=>{
|
|
33
|
+
// Warn if auto updates enabled but no appId configured.
|
|
34
|
+
// Skip when called from deploy, since deploy handles appId itself
|
|
35
|
+
// (prompts the user and tells them to add it to config).
|
|
36
|
+
if (!appId && !options.calledFromDeploy) {
|
|
37
|
+
warnAboutMissingAppId({
|
|
38
|
+
appType: 'app',
|
|
39
|
+
output
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
compareDependencyVersions: (packages)=>compareDependencyVersions(packages, workDir, {
|
|
44
|
+
appId
|
|
45
|
+
}),
|
|
32
46
|
determineBasePath: ()=>determineBasePath(cliConfig, 'app', output),
|
|
33
47
|
entry: app?.entry,
|
|
34
48
|
isWorkbenchApp: !!workbench,
|
|
@@ -103,18 +117,9 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
|
|
|
103
117
|
});
|
|
104
118
|
output.log(`${logSymbols.info} Building with auto-updates enabled`);
|
|
105
119
|
// Warn if auto updates enabled but no appId configured.
|
|
106
|
-
|
|
107
|
-
// (prompts the user and tells them to add it to config).
|
|
108
|
-
if (!appId && !options.calledFromDeploy) {
|
|
109
|
-
warnAboutMissingAppId({
|
|
110
|
-
appType: 'app',
|
|
111
|
-
output
|
|
112
|
-
});
|
|
113
|
-
}
|
|
120
|
+
options.checkAppId();
|
|
114
121
|
// Check the versions
|
|
115
|
-
const { mismatched, unresolvedPrerelease } = await compareDependencyVersions(autoUpdatedPackages
|
|
116
|
-
appId
|
|
117
|
-
});
|
|
122
|
+
const { mismatched, unresolvedPrerelease } = await options.compareDependencyVersions(autoUpdatedPackages);
|
|
118
123
|
if (unresolvedPrerelease.length > 0) {
|
|
119
124
|
await handlePrereleaseVersions({
|
|
120
125
|
output,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/buildApp.ts"],"sourcesContent":["import {rm} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {\n AppBuildTrace,\n buildDebug,\n getAutoUpdatesCssUrls,\n getAutoUpdatesImportMap,\n resolveVendorBuildConfig,\n} from '@sanity/cli-build/_internal/build'\nimport {\n type CliConfig,\n getCliTelemetry,\n getLocalPackageVersion,\n getTimer,\n isInteractive,\n type Output,\n UserViteConfig,\n} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner, type SpinnerInstance} from '@sanity/cli-core/ux'\nimport {type DefineAppInput} from '@sanity/workbench-cli'\nimport {resolveWorkbenchApp} from '@sanity/workbench-cli/build'\nimport {parse as semverParse} from 'semver'\n\nimport {getAppId} from '../../util/appId.js'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions.js'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils.js'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId.js'\nimport {buildStaticFiles} from './buildStaticFiles.js'\nimport {determineBasePath} from './determineBasePath.js'\nimport {getAppEnvironmentVariables} from './getEnvironmentVariables.js'\nimport {handlePrereleaseVersions} from './handlePrereleaseVersions.js'\nimport {type BuildOptions} from './types.js'\n\ninterface InternalBuildOptions {\n appId: string | undefined\n appTitle: string | undefined\n autoUpdatesEnabled: boolean\n calledFromDeploy: boolean | undefined\n determineBasePath: () => string\n entry: string | undefined\n isWorkbenchApp: boolean\n minify: boolean\n outDir: string | undefined\n output: Output\n reactCompiler: CliConfig['reactCompiler']\n schemaExtraction: CliConfig['schemaExtraction']\n services: DefineAppInput['services']\n sourceMap: boolean\n stats: boolean\n unattendedMode: boolean\n views: DefineAppInput['views']\n vite: UserViteConfig | undefined\n workDir: string\n}\n\n/**\n * Build the Sanity app.\n *\n * @internal\n */\nexport async function buildApp(options: BuildOptions): Promise<void> {\n const {cliConfig, flags, outDir, output, workDir} = options\n\n const app = cliConfig && 'app' in cliConfig ? cliConfig.app : undefined\n // `views`/`services` live on the branded `unstable_defineApp` result, not the\n // legacy `app` config object — resolve the workbench capability to read them.\n const workbench = resolveWorkbenchApp(cliConfig)\n\n await internalBuildApp({\n appId: getAppId(cliConfig),\n appTitle: app?.title,\n autoUpdatesEnabled: options.autoUpdatesEnabled,\n calledFromDeploy: options.calledFromDeploy,\n determineBasePath: () => determineBasePath(cliConfig, 'app', output),\n entry: app?.entry,\n isWorkbenchApp: !!workbench,\n minify: flags.minify,\n outDir,\n output,\n reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n schemaExtraction: cliConfig?.schemaExtraction,\n services: workbench?.services,\n sourceMap: Boolean(flags['source-maps']),\n stats: flags.stats,\n unattendedMode: flags.yes,\n views: workbench?.views,\n vite: cliConfig.vite,\n workDir,\n })\n}\n\n/**\n * Internal build app that avoids depending on flags for CLI config.\n * @param options - options for the build\n */\nasync function internalBuildApp(options: InternalBuildOptions): Promise<void> {\n buildDebug(`Building app`)\n\n const {appId, determineBasePath, outDir, output, workDir} = options\n let {autoUpdatesEnabled} = options\n const unattendedMode = options.unattendedMode\n\n const timer = getTimer()\n\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(outDir || defaultOutputDir)\n\n const installedSdkVersion = await getLocalPackageVersion('@sanity/sdk-react', workDir)\n const installedSanityVersion = await getLocalPackageVersion('sanity', workDir)\n\n if (!installedSdkVersion) {\n output.error(`Failed to find installed @sanity/sdk-react version`, {exit: 1})\n return\n }\n\n let autoUpdatesImports = {}\n let autoUpdatesCssUrls: string[] = []\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSDKVersion = semverParse(installedSdkVersion)?.version\n if (!cleanSDKVersion) {\n output.error(`Failed to parse installed SDK version: ${installedSdkVersion}`, {exit: 1})\n return\n }\n\n // Sanity might not be installed, but if it is, we want to auto update it.\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n\n const autoUpdatedPackages = [\n {name: '@sanity/sdk', version: cleanSDKVersion},\n {name: '@sanity/sdk-react', version: cleanSDKVersion},\n ...(cleanSanityVersion\n ? [{cssFile: 'index.css', name: 'sanity' as const, version: cleanSanityVersion}]\n : []),\n ]\n autoUpdatesImports = getAutoUpdatesImportMap(autoUpdatedPackages, {appId})\n autoUpdatesCssUrls = getAutoUpdatesCssUrls(autoUpdatedPackages, {appId})\n\n output.log(`${logSymbols.info} Building with auto-updates enabled`)\n\n // Warn if auto updates enabled but no appId configured.\n // Skip when called from deploy, since deploy handles appId itself\n // (prompts the user and tells them to add it to config).\n if (!appId && !options.calledFromDeploy) {\n warnAboutMissingAppId({appType: 'app', output})\n }\n\n // Check the versions\n const {mismatched, unresolvedPrerelease} = await compareDependencyVersions(\n autoUpdatedPackages,\n workDir,\n {appId},\n )\n\n if (unresolvedPrerelease.length > 0) {\n await handlePrereleaseVersions({output, unattendedMode, unresolvedPrerelease})\n autoUpdatesImports = {}\n autoUpdatesCssUrls = []\n autoUpdatesEnabled = false\n }\n\n if (mismatched.length > 0 && autoUpdatesEnabled) {\n const versionMismatchWarning =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you test locally with the same versions before deploying. \\n\\n` +\n `${mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}`\n\n // If it is non-interactive or in unattended mode, we don't want to prompt\n if (isInteractive() && !unattendedMode) {\n const shouldContinue = await confirm({\n default: false,\n message: styleText('yellow', `${versionMismatchWarning} \\n\\nContinue anyway?`),\n })\n\n if (!shouldContinue) {\n output.error('Declined to continue with build', {exit: 1})\n return\n }\n } else {\n // if non-interactive or unattended, just show the warning\n output.warn(versionMismatchWarning)\n }\n }\n }\n\n const envVarKeys = Object.keys(getAppEnvironmentVariables())\n if (envVarKeys.length > 0) {\n output.log('\\nIncluding the following environment variables as part of the JavaScript bundle:')\n for (const key of envVarKeys) output.log(`- ${key}`)\n output.log('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode && isInteractive()) {\n shouldClean = await confirm({\n default: true,\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n })\n }\n\n const basePath = determineBasePath()\n\n let spin: SpinnerInstance\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = spinner('Clean output folder').start()\n await rm(outputDir, {force: true, recursive: true})\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed(0)}ms)`\n spin.succeed()\n }\n\n spin = spinner(`Building Sanity application`).start()\n\n const trace = getCliTelemetry().trace(AppBuildTrace)\n trace.start()\n\n let autoUpdates\n if (autoUpdatesEnabled && !options.isWorkbenchApp) {\n autoUpdates = {\n cssUrls: autoUpdatesCssUrls,\n imports: autoUpdatesImports,\n vendor: await resolveVendorBuildConfig({cwd: workDir, isApp: true}),\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n appTitle: options.appTitle,\n autoUpdates,\n basePath,\n cwd: workDir,\n entry: options.entry,\n isApp: true,\n isWorkbenchApp: options.isWorkbenchApp,\n minify: options.minify,\n outputDir,\n reactCompiler: options.reactCompiler,\n schemaExtraction: options.schemaExtraction,\n services: options.services,\n sourceMap: options.sourceMap,\n views: options.views,\n vite: options.vite,\n })\n\n trace.log({\n outputSize: bundle.chunks\n .flatMap((chunk) => chunk.modules.flatMap((mod) => mod.renderedLength))\n .reduce((sum, n) => sum + n, 0),\n })\n const buildDuration = timer.end('bundleStudio')\n\n spin.text = `Build Sanity application (${buildDuration.toFixed(0)}ms)`\n spin.succeed()\n\n if (options.stats) {\n output.log('\\nLargest module files:')\n output.log(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n\n trace.complete()\n } catch (error) {\n spin.fail()\n trace.error(error)\n const message = error instanceof Error ? error.message : String(error)\n buildDebug(`Failed to build Sanity application`, {error})\n output.error(`Failed to build Sanity application: ${message}`, {exit: 1})\n }\n}\n"],"names":["rm","path","styleText","AppBuildTrace","buildDebug","getAutoUpdatesCssUrls","getAutoUpdatesImportMap","resolveVendorBuildConfig","getCliTelemetry","getLocalPackageVersion","getTimer","isInteractive","confirm","logSymbols","spinner","resolveWorkbenchApp","parse","semverParse","getAppId","compareDependencyVersions","formatModuleSizes","sortModulesBySize","warnAboutMissingAppId","buildStaticFiles","determineBasePath","getAppEnvironmentVariables","handlePrereleaseVersions","buildApp","options","cliConfig","flags","outDir","output","workDir","app","undefined","workbench","internalBuildApp","appId","appTitle","title","autoUpdatesEnabled","calledFromDeploy","entry","isWorkbenchApp","minify","reactCompiler","schemaExtraction","services","sourceMap","Boolean","stats","unattendedMode","yes","views","vite","timer","defaultOutputDir","resolve","join","outputDir","installedSdkVersion","installedSanityVersion","error","exit","autoUpdatesImports","autoUpdatesCssUrls","cleanSDKVersion","version","cleanSanityVersion","autoUpdatedPackages","name","cssFile","log","info","appType","mismatched","unresolvedPrerelease","length","versionMismatchWarning","map","mod","pkg","installed","remote","shouldContinue","default","message","warn","envVarKeys","Object","keys","key","shouldClean","basePath","spin","start","force","recursive","cleanDuration","end","text","toFixed","succeed","trace","autoUpdates","cssUrls","imports","vendor","cwd","isApp","bundle","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","slice","complete","fail","Error","String"],"mappings":"AAAA,SAAQA,EAAE,QAAO,mBAAkB;AACnC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SACEC,aAAa,EACbC,UAAU,EACVC,qBAAqB,EACrBC,uBAAuB,EACvBC,wBAAwB,QACnB,oCAAmC;AAC1C,SAEEC,eAAe,EACfC,sBAAsB,EACtBC,QAAQ,EACRC,aAAa,QAGR,mBAAkB;AACzB,SAAQC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAA6B,sBAAqB;AAEtF,SAAQC,mBAAmB,QAAO,8BAA6B;AAC/D,SAAQC,SAASC,WAAW,QAAO,SAAQ;AAE3C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B,QAAQ;YAC1BC,WAAWrB,QAAQqB,SAAS;YAC5BK,OAAO1B,QAAQ0B,KAAK;YACpBC,MAAM3B,QAAQ2B,IAAI;QACpB;QAEAiD,MAAM/B,GAAG,CAAC;YACRuC,YAAYD,OAAOE,MAAM,CACtBC,OAAO,CAAC,CAACC,QAAUA,MAAMC,OAAO,CAACF,OAAO,CAAC,CAACjC,MAAQA,IAAIoC,cAAc,GACpEC,MAAM,CAAC,CAACC,KAAKC,IAAMD,MAAMC,GAAG;QACjC;QACA,MAAMC,gBAAgBjE,MAAM4C,GAAG,CAAC;QAEhCL,KAAKM,IAAI,GAAG,CAAC,0BAA0B,EAAEoB,cAAcnB,OAAO,CAAC,GAAG,GAAG,CAAC;QACtEP,KAAKQ,OAAO;QAEZ,IAAI3E,QAAQuB,KAAK,EAAE;YACjBnB,OAAOyC,GAAG,CAAC;YACXzC,OAAOyC,GAAG,CAACrD,kBAAkBC,kBAAkB0F,OAAOE,MAAM,EAAES,KAAK,CAAC,GAAG;QACzE;QAEAlB,MAAMmB,QAAQ;IAChB,EAAE,OAAO5D,OAAO;QACdgC,KAAK6B,IAAI;QACTpB,MAAMzC,KAAK,CAACA;QACZ,MAAMwB,UAAUxB,iBAAiB8D,QAAQ9D,MAAMwB,OAAO,GAAGuC,OAAO/D;QAChE3D,WAAW,CAAC,kCAAkC,CAAC,EAAE;YAAC2D;QAAK;QACvD/B,OAAO+B,KAAK,CAAC,CAAC,oCAAoC,EAAEwB,SAAS,EAAE;YAACvB,MAAM;QAAC;IACzE;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/buildApp.ts"],"sourcesContent":["import {rm} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {\n AppBuildTrace,\n buildDebug,\n getAutoUpdatesCssUrls,\n getAutoUpdatesImportMap,\n resolveVendorBuildConfig,\n} from '@sanity/cli-build/_internal/build'\nimport {getAppEnvironmentVariables} from '@sanity/cli-build/_internal/env'\nimport {\n type CliConfig,\n getCliTelemetry,\n getLocalPackageVersion,\n getTimer,\n isInteractive,\n type Output,\n UserViteConfig,\n} from '@sanity/cli-core'\nimport {confirm, logSymbols, spinner, type SpinnerInstance} from '@sanity/cli-core/ux'\nimport {type DefineAppInput} from '@sanity/workbench-cli'\nimport {resolveWorkbenchApp} from '@sanity/workbench-cli/build'\nimport {parse as semverParse} from 'semver'\n\nimport {getAppId} from '../../util/appId.js'\nimport {\n compareDependencyVersions,\n CompareDependencyVersionsResult,\n} from '../../util/compareDependencyVersions.js'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils.js'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId.js'\nimport {buildStaticFiles} from './buildStaticFiles.js'\nimport {determineBasePath} from './determineBasePath.js'\nimport {handlePrereleaseVersions} from './handlePrereleaseVersions.js'\nimport {type BuildOptions} from './types.js'\n\ninterface InternalBuildOptions {\n appId: string | undefined\n appTitle: string | undefined\n autoUpdatesEnabled: boolean\n checkAppId: () => void\n compareDependencyVersions: (\n packages: {name: string; version: string}[],\n ) => Promise<CompareDependencyVersionsResult>\n determineBasePath: () => string\n entry: string | undefined\n isWorkbenchApp: boolean\n minify: boolean\n outDir: string | undefined\n output: Output\n reactCompiler: CliConfig['reactCompiler']\n schemaExtraction: CliConfig['schemaExtraction']\n services: DefineAppInput['services']\n sourceMap: boolean\n stats: boolean\n unattendedMode: boolean\n views: DefineAppInput['views']\n vite: UserViteConfig | undefined\n workDir: string\n}\n\n/**\n * Build the Sanity app.\n *\n * @internal\n */\nexport async function buildApp(options: BuildOptions): Promise<void> {\n const {cliConfig, flags, outDir, output, workDir} = options\n\n const app = cliConfig && 'app' in cliConfig ? cliConfig.app : undefined\n // `views`/`services` live on the branded `unstable_defineApp` result, not the\n // legacy `app` config object — resolve the workbench capability to read them.\n const workbench = resolveWorkbenchApp(cliConfig)\n\n const appId = getAppId(cliConfig)\n\n await internalBuildApp({\n appId,\n appTitle: app?.title,\n autoUpdatesEnabled: options.autoUpdatesEnabled,\n checkAppId: () => {\n // Warn if auto updates enabled but no appId configured.\n // Skip when called from deploy, since deploy handles appId itself\n // (prompts the user and tells them to add it to config).\n if (!appId && !options.calledFromDeploy) {\n warnAboutMissingAppId({appType: 'app', output})\n }\n },\n compareDependencyVersions: (packages) => compareDependencyVersions(packages, workDir, {appId}),\n determineBasePath: () => determineBasePath(cliConfig, 'app', output),\n entry: app?.entry,\n isWorkbenchApp: !!workbench,\n minify: flags.minify,\n outDir,\n output,\n reactCompiler: cliConfig && 'reactCompiler' in cliConfig ? cliConfig.reactCompiler : undefined,\n schemaExtraction: cliConfig?.schemaExtraction,\n services: workbench?.services,\n sourceMap: Boolean(flags['source-maps']),\n stats: flags.stats,\n unattendedMode: flags.yes,\n views: workbench?.views,\n vite: cliConfig.vite,\n workDir,\n })\n}\n\n/**\n * Internal build app that avoids depending on flags for CLI config.\n * @param options - options for the build\n */\nasync function internalBuildApp(options: InternalBuildOptions): Promise<void> {\n buildDebug(`Building app`)\n\n const {appId, determineBasePath, outDir, output, workDir} = options\n let {autoUpdatesEnabled} = options\n const unattendedMode = options.unattendedMode\n\n const timer = getTimer()\n\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(outDir || defaultOutputDir)\n\n const installedSdkVersion = await getLocalPackageVersion('@sanity/sdk-react', workDir)\n const installedSanityVersion = await getLocalPackageVersion('sanity', workDir)\n\n if (!installedSdkVersion) {\n output.error(`Failed to find installed @sanity/sdk-react version`, {exit: 1})\n return\n }\n\n let autoUpdatesImports = {}\n let autoUpdatesCssUrls: string[] = []\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSDKVersion = semverParse(installedSdkVersion)?.version\n if (!cleanSDKVersion) {\n output.error(`Failed to parse installed SDK version: ${installedSdkVersion}`, {exit: 1})\n return\n }\n\n // Sanity might not be installed, but if it is, we want to auto update it.\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n\n const autoUpdatedPackages = [\n {name: '@sanity/sdk', version: cleanSDKVersion},\n {name: '@sanity/sdk-react', version: cleanSDKVersion},\n ...(cleanSanityVersion\n ? [{cssFile: 'index.css', name: 'sanity' as const, version: cleanSanityVersion}]\n : []),\n ]\n autoUpdatesImports = getAutoUpdatesImportMap(autoUpdatedPackages, {appId})\n autoUpdatesCssUrls = getAutoUpdatesCssUrls(autoUpdatedPackages, {appId})\n\n output.log(`${logSymbols.info} Building with auto-updates enabled`)\n\n // Warn if auto updates enabled but no appId configured.\n options.checkAppId()\n\n // Check the versions\n const {mismatched, unresolvedPrerelease} =\n await options.compareDependencyVersions(autoUpdatedPackages)\n\n if (unresolvedPrerelease.length > 0) {\n await handlePrereleaseVersions({output, unattendedMode, unresolvedPrerelease})\n autoUpdatesImports = {}\n autoUpdatesCssUrls = []\n autoUpdatesEnabled = false\n }\n\n if (mismatched.length > 0 && autoUpdatesEnabled) {\n const versionMismatchWarning =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you test locally with the same versions before deploying. \\n\\n` +\n `${mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}`\n\n // If it is non-interactive or in unattended mode, we don't want to prompt\n if (isInteractive() && !unattendedMode) {\n const shouldContinue = await confirm({\n default: false,\n message: styleText('yellow', `${versionMismatchWarning} \\n\\nContinue anyway?`),\n })\n\n if (!shouldContinue) {\n output.error('Declined to continue with build', {exit: 1})\n return\n }\n } else {\n // if non-interactive or unattended, just show the warning\n output.warn(versionMismatchWarning)\n }\n }\n }\n\n const envVarKeys = Object.keys(getAppEnvironmentVariables())\n if (envVarKeys.length > 0) {\n output.log('\\nIncluding the following environment variables as part of the JavaScript bundle:')\n for (const key of envVarKeys) output.log(`- ${key}`)\n output.log('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode && isInteractive()) {\n shouldClean = await confirm({\n default: true,\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n })\n }\n\n const basePath = determineBasePath()\n\n let spin: SpinnerInstance\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = spinner('Clean output folder').start()\n await rm(outputDir, {force: true, recursive: true})\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed(0)}ms)`\n spin.succeed()\n }\n\n spin = spinner(`Building Sanity application`).start()\n\n const trace = getCliTelemetry().trace(AppBuildTrace)\n trace.start()\n\n let autoUpdates\n if (autoUpdatesEnabled && !options.isWorkbenchApp) {\n autoUpdates = {\n cssUrls: autoUpdatesCssUrls,\n imports: autoUpdatesImports,\n vendor: await resolveVendorBuildConfig({cwd: workDir, isApp: true}),\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n appTitle: options.appTitle,\n autoUpdates,\n basePath,\n cwd: workDir,\n entry: options.entry,\n isApp: true,\n isWorkbenchApp: options.isWorkbenchApp,\n minify: options.minify,\n outputDir,\n reactCompiler: options.reactCompiler,\n schemaExtraction: options.schemaExtraction,\n services: options.services,\n sourceMap: options.sourceMap,\n views: options.views,\n vite: options.vite,\n })\n\n trace.log({\n outputSize: bundle.chunks\n .flatMap((chunk) => chunk.modules.flatMap((mod) => mod.renderedLength))\n .reduce((sum, n) => sum + n, 0),\n })\n const buildDuration = timer.end('bundleStudio')\n\n spin.text = `Build Sanity application (${buildDuration.toFixed(0)}ms)`\n spin.succeed()\n\n if (options.stats) {\n output.log('\\nLargest module files:')\n output.log(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n\n trace.complete()\n } catch (error) {\n spin.fail()\n trace.error(error)\n const message = error instanceof Error ? error.message : String(error)\n buildDebug(`Failed to build Sanity application`, {error})\n output.error(`Failed to build Sanity application: ${message}`, {exit: 1})\n }\n}\n"],"names":["rm","path","styleText","AppBuildTrace","buildDebug","getAutoUpdatesCssUrls","getAutoUpdatesImportMap","resolveVendorBuildConfig","getAppEnvironmentVariables","getCliTelemetry","getLocalPackageVersion","getTimer","isInteractive","confirm","logSymbols","spinner","resolveWorkbenchApp","parse","semverParse","getAppId","compareDependencyVersions","formatModuleSizes","sortModulesBySize","warnAboutMissingAppId","buildStaticFiles","determineBasePath","handlePrereleaseVersions","buildApp","options","cliConfig","flags","outDir","output","workDir","app","undefined","workbench","appId","internalBuildApp","appTitle","title","autoUpdatesEnabled","checkAppId","calledFromDeploy","appType","packages","entry","isWorkbenchApp","minify","reactCompiler","schemaExtraction","services","sourceMap","Boolean","stats","unattendedMode","yes","views","vite","timer","defaultOutputDir","resolve","join","outputDir","installedSdkVersion","installedSanityVersion","error","exit","autoUpdatesImports","autoUpdatesCssUrls","cleanSDKVersion","version","cleanSanityVersion","autoUpdatedPackages","name","cssFile","log","info","mismatched","unresolvedPrerelease","length","versionMismatchWarning","map","mod","pkg","installed","remote","shouldContinue","default","message","warn","envVarKeys","Object","keys","key","shouldClean","basePath","spin","start","force","recursive","cleanDuration","end","text","toFixed","succeed","trace","autoUpdates","cssUrls","imports","vendor","cwd","isApp","bundle","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","slice","complete","fail","Error","String"],"mappings":"AAAA,SAAQA,EAAE,QAAO,mBAAkB;AACnC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SACEC,aAAa,EACbC,UAAU,EACVC,qBAAqB,EACrBC,uBAAuB,EACvBC,wBAAwB,QACnB,oCAAmC;AAC1C,SAAQC,0BAA0B,QAAO,kCAAiC;AAC1E,SAEEC,eAAe,EACfC,sBAAsB,EACtBC,QAAQ,EACRC,aAAa,QAGR,mBAAkB;AACzB,SAAQC,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAA6B,sBAAqB;AAEtF,SAAQC,mBAAmB,QAAO,8BAA6B;AAC/D,SAAQC,SAASC,WAAW,QAAO,SAAQ;AAE3C,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,SACEC,yB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,UAAUvB,QAAQuB,QAAQ;YAC1BC,WAAWxB,QAAQwB,SAAS;YAC5BK,OAAO7B,QAAQ6B,KAAK;YACpBC,MAAM9B,QAAQ8B,IAAI;QACpB;QAEAgD,MAAM9B,GAAG,CAAC;YACRsC,YAAYD,OAAOE,MAAM,CACtBC,OAAO,CAAC,CAACC,QAAUA,MAAMC,OAAO,CAACF,OAAO,CAAC,CAACjC,MAAQA,IAAIoC,cAAc,GACpEC,MAAM,CAAC,CAACC,KAAKC,IAAMD,MAAMC,GAAG;QACjC;QACA,MAAMC,gBAAgBhE,MAAM2C,GAAG,CAAC;QAEhCL,KAAKM,IAAI,GAAG,CAAC,0BAA0B,EAAEoB,cAAcnB,OAAO,CAAC,GAAG,GAAG,CAAC;QACtEP,KAAKQ,OAAO;QAEZ,IAAI7E,QAAQ0B,KAAK,EAAE;YACjBtB,OAAO4C,GAAG,CAAC;YACX5C,OAAO4C,GAAG,CAACvD,kBAAkBC,kBAAkB2F,OAAOE,MAAM,EAAES,KAAK,CAAC,GAAG;QACzE;QAEAlB,MAAMmB,QAAQ;IAChB,EAAE,OAAO3D,OAAO;QACd+B,KAAK6B,IAAI;QACTpB,MAAMxC,KAAK,CAACA;QACZ,MAAMuB,UAAUvB,iBAAiB6D,QAAQ7D,MAAMuB,OAAO,GAAGuC,OAAO9D;QAChE9D,WAAW,CAAC,kCAAkC,CAAC,EAAE;YAAC8D;QAAK;QACvDlC,OAAOkC,KAAK,CAAC,CAAC,oCAAoC,EAAEuB,SAAS,EAAE;YAACtB,MAAM;QAAC;IACzE;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { buildDebug, copyDir, extendViteConfigWithUserConfig, finalizeViteConfig, getViteConfig, resolveEntries, writeFavicons, writeSanityRuntime } from '@sanity/cli-build/_internal/build';
|
|
3
|
+
import { getAppEnvironmentVariables, getStudioEnvironmentVariables } from '@sanity/cli-build/_internal/env';
|
|
3
4
|
import { build, createBuilder } from 'vite';
|
|
4
|
-
import { getAppEnvironmentVariables, getStudioEnvironmentVariables } from './getEnvironmentVariables.js';
|
|
5
5
|
/**
|
|
6
6
|
* Builds static files
|
|
7
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/buildStaticFiles.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {\n type AutoUpdatesBuildConfig,\n buildDebug,\n copyDir,\n extendViteConfigWithUserConfig,\n finalizeViteConfig,\n getViteConfig,\n resolveEntries,\n writeFavicons,\n writeSanityRuntime,\n} from '@sanity/cli-build/_internal/build'\nimport {type CliConfig, type UserViteConfig} from '@sanity/cli-core'\nimport {type DefineAppInput} from '@sanity/workbench-cli'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {build, createBuilder} from 'vite'\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/buildStaticFiles.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {\n type AutoUpdatesBuildConfig,\n buildDebug,\n copyDir,\n extendViteConfigWithUserConfig,\n finalizeViteConfig,\n getViteConfig,\n resolveEntries,\n writeFavicons,\n writeSanityRuntime,\n} from '@sanity/cli-build/_internal/build'\nimport {\n getAppEnvironmentVariables,\n getStudioEnvironmentVariables,\n} from '@sanity/cli-build/_internal/env'\nimport {type CliConfig, type UserViteConfig} from '@sanity/cli-core'\nimport {type DefineAppInput} from '@sanity/workbench-cli'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {build, createBuilder} from 'vite'\n\nexport interface ChunkModule {\n name: string\n renderedLength: number\n}\n\nexport interface ChunkStats {\n modules: ChunkModule[]\n name: string\n}\n\ninterface StaticBuildOptions {\n basePath: string\n cwd: string\n outputDir: string\n\n appTitle?: string\n autoUpdates?: AutoUpdatesBuildConfig\n entry?: string\n isApp?: boolean\n /** Workbench app (opted in via `unstable_defineApp`) — drives the federation build. */\n isWorkbenchApp?: boolean\n minify?: boolean\n profile?: boolean\n reactCompiler?: ReactCompilerConfig\n schemaExtraction?: CliConfig['schemaExtraction']\n services?: DefineAppInput['services']\n sourceMap?: boolean\n views?: DefineAppInput['views']\n vite?: UserViteConfig\n}\n\n/**\n * Builds static files\n *\n * @internal\n */\nexport async function buildStaticFiles(\n options: StaticBuildOptions,\n): Promise<{chunks: ChunkStats[]}> {\n const {\n appTitle,\n autoUpdates,\n basePath,\n cwd,\n entry,\n isApp,\n isWorkbenchApp,\n minify = true,\n outputDir,\n reactCompiler,\n schemaExtraction,\n services,\n sourceMap = false,\n views,\n vite: extendViteConfig,\n } = options\n\n const mode = 'production'\n\n /* Federation builds only produce the federation environment\n * (remote-entry, mf-manifest) — skip client-specific steps like\n * runtime generation, static file copies, and favicons.\n */\n if (isWorkbenchApp) {\n buildDebug('Resolving entries for federation build')\n const entries = await resolveEntries({cwd, entry, isApp, isWorkbenchApp})\n\n buildDebug('Resolving vite config (federation)')\n let viteConfig = await getViteConfig({\n basePath,\n cwd,\n entries,\n getEnvironmentVariables,\n isApp,\n isWorkbenchApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n // Schema extraction is a build-time artifact, not a client-specific step,\n // so a federated studio extracts its schema like the legacy studio build.\n schemaExtraction,\n services,\n sourceMap,\n views,\n })\n\n // Apply the user's Vite config so plugins like `@vanilla-extract/vite-plugin`\n // transform source files before the federation environment is bundled.\n // `finalizeViteConfig` is intentionally skipped: the federation environment\n // has its own entry and does not use `.sanity/runtime/app.js`.\n if (extendViteConfig) {\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'build', mode},\n viteConfig,\n extendViteConfig,\n )\n }\n\n buildDebug('Bundling federation environment')\n const builder = await createBuilder(viteConfig)\n await builder.buildApp()\n buildDebug('Bundling complete')\n // TODO: add stats here\n return {chunks: []}\n }\n\n buildDebug('Writing Sanity runtime files')\n const {entries} = await writeSanityRuntime({\n appTitle,\n basePath,\n cwd,\n entry,\n isApp,\n isWorkbenchApp,\n reactStrictMode: false,\n watch: false,\n })\n\n function getEnvironmentVariables() {\n return isApp\n ? getAppEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n : getStudioEnvironmentVariables({jsonEncode: true, prefix: 'process.env.'})\n }\n\n buildDebug('Resolving vite config')\n let viteConfig = await getViteConfig({\n autoUpdates,\n basePath,\n cwd,\n entries,\n getEnvironmentVariables,\n isApp,\n isWorkbenchApp,\n minify,\n mode,\n outputDir,\n reactCompiler,\n schemaExtraction,\n sourceMap,\n })\n\n if (extendViteConfig) {\n const defaultViteConfig = viteConfig\n viteConfig = await extendViteConfigWithUserConfig(\n {command: 'build', mode},\n viteConfig,\n extendViteConfig,\n )\n viteConfig = await finalizeViteConfig(viteConfig, defaultViteConfig)\n }\n\n const fromPath = path.join(cwd, 'static')\n // Copy files placed in /static to the built /static\n buildDebug(`Copying static files from ${fromPath} to output dir`)\n const staticPath = path.join(outputDir, 'static')\n await copyDir(fromPath, staticPath)\n\n // Write favicons, not overwriting ones that already exist, to static folder\n buildDebug('Writing favicons to output dir')\n const faviconBasePath = `${basePath.replace(/\\/+$/, '')}/static`\n await writeFavicons(faviconBasePath, staticPath)\n\n buildDebug('Bundling using vite')\n const bundle = await build(viteConfig)\n buildDebug('Bundling complete')\n\n // For typescript only - this shouldn't ever be the case given we're not watching\n if (Array.isArray(bundle) || !('output' in bundle)) {\n return {chunks: []}\n }\n\n const stats: ChunkStats[] = []\n for (const chunk of bundle.output) {\n if (chunk.type !== 'chunk') {\n continue\n }\n\n stats.push({\n modules: Object.entries(chunk.modules).map(([rawFilePath, chunkModule]) => {\n const filePath = rawFilePath.startsWith('\\u0000')\n ? rawFilePath.slice('\\u0000'.length)\n : rawFilePath\n\n return {\n name: path.isAbsolute(filePath) ? path.relative(cwd, filePath) : filePath,\n renderedLength: chunkModule.renderedLength,\n }\n }),\n name: chunk.name,\n })\n }\n\n return {chunks: stats}\n}\n"],"names":["path","buildDebug","copyDir","extendViteConfigWithUserConfig","finalizeViteConfig","getViteConfig","resolveEntries","writeFavicons","writeSanityRuntime","getAppEnvironmentVariables","getStudioEnvironmentVariables","build","createBuilder","buildStaticFiles","options","appTitle","autoUpdates","basePath","cwd","entry","isApp","isWorkbenchApp","minify","outputDir","reactCompiler","schemaExtraction","services","sourceMap","views","vite","extendViteConfig","mode","entries","viteConfig","getEnvironmentVariables","command","builder","buildApp","chunks","reactStrictMode","watch","jsonEncode","prefix","defaultViteConfig","fromPath","join","staticPath","faviconBasePath","replace","bundle","Array","isArray","stats","chunk","output","type","push","modules","Object","map","rawFilePath","chunkModule","filePath","startsWith","slice","length","name","isAbsolute","relative","renderedLength"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAEEC,UAAU,EACVC,OAAO,EACPC,8BAA8B,EAC9BC,kBAAkB,EAClBC,aAAa,EACbC,cAAc,EACdC,aAAa,EACbC,kBAAkB,QACb,oCAAmC;AAC1C,SACEC,0BAA0B,EAC1BC,6BAA6B,QACxB,kCAAiC;AAIxC,SAAQC,KAAK,EAAEC,aAAa,QAAO,OAAM;AAiCzC;;;;CAIC,GACD,OAAO,eAAeC,iBACpBC,OAA2B;IAE3B,MAAM,EACJC,QAAQ,EACRC,WAAW,EACXC,QAAQ,EACRC,GAAG,EACHC,KAAK,EACLC,KAAK,EACLC,cAAc,EACdC,SAAS,IAAI,EACbC,SAAS,EACTC,aAAa,EACbC,gBAAgB,EAChBC,QAAQ,EACRC,YAAY,KAAK,EACjBC,KAAK,EACLC,MAAMC,gBAAgB,EACvB,GAAGhB;IAEJ,MAAMiB,OAAO;IAEb;;;GAGC,GACD,IAAIV,gBAAgB;QAClBpB,WAAW;QACX,MAAM+B,UAAU,MAAM1B,eAAe;YAACY;YAAKC;YAAOC;YAAOC;QAAc;QAEvEpB,WAAW;QACX,IAAIgC,aAAa,MAAM5B,cAAc;YACnCY;YACAC;YACAc;YACAE;YACAd;YACAC;YACAC;YACAS;YACAR;YACAC;YACA,0EAA0E;YAC1E,0EAA0E;YAC1EC;YACAC;YACAC;YACAC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IACX,MAAMgD,SAAS,MAAMtC,MAAMsB;IAC3BhC,WAAW;IAEX,iFAAiF;IACjF,IAAIiD,MAAMC,OAAO,CAACF,WAAW,CAAE,CAAA,YAAYA,MAAK,GAAI;QAClD,OAAO;YAACX,QAAQ,EAAE;QAAA;IACpB;IAEA,MAAMc,QAAsB,EAAE;IAC9B,KAAK,MAAMC,SAASJ,OAAOK,MAAM,CAAE;QACjC,IAAID,MAAME,IAAI,KAAK,SAAS;YAC1B;QACF;QAEAH,MAAMI,IAAI,CAAC;YACTC,SAASC,OAAO1B,OAAO,CAACqB,MAAMI,OAAO,EAAEE,GAAG,CAAC,CAAC,CAACC,aAAaC,YAAY;gBACpE,MAAMC,WAAWF,YAAYG,UAAU,CAAC,YACpCH,YAAYI,KAAK,CAAC,SAASC,MAAM,IACjCL;gBAEJ,OAAO;oBACLM,MAAMlE,KAAKmE,UAAU,CAACL,YAAY9D,KAAKoE,QAAQ,CAAClD,KAAK4C,YAAYA;oBACjEO,gBAAgBR,YAAYQ,cAAc;gBAC5C;YACF;YACAH,MAAMb,MAAMa,IAAI;QAClB;IACF;IAEA,OAAO;QAAC5B,QAAQc;IAAK;AACvB"}
|
|
@@ -2,6 +2,7 @@ import { rm } from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { styleText } from 'node:util';
|
|
4
4
|
import { buildDebug, checkRequiredDependencies, checkStudioDependencyVersions, getAutoUpdatesCssUrls, getAutoUpdatesImportMap, resolveVendorBuildConfig, StudioBuildTrace } from '@sanity/cli-build/_internal/build';
|
|
5
|
+
import { getStudioEnvironmentVariables } from '@sanity/cli-build/_internal/env';
|
|
5
6
|
import { getCliTelemetry, getLocalPackageVersion, getTimer, isInteractive } from '@sanity/cli-core';
|
|
6
7
|
import { confirm, logSymbols, select, spinner } from '@sanity/cli-core/ux';
|
|
7
8
|
import { resolveWorkbenchApp } from '@sanity/workbench-cli/build';
|
|
@@ -15,7 +16,6 @@ import { upgradePackages } from '../../util/packageManager/upgradePackages.js';
|
|
|
15
16
|
import { warnAboutMissingAppId } from '../../util/warnAboutMissingAppId.js';
|
|
16
17
|
import { buildStaticFiles } from './buildStaticFiles.js';
|
|
17
18
|
import { determineBasePath } from './determineBasePath.js';
|
|
18
|
-
import { getStudioEnvironmentVariables } from './getEnvironmentVariables.js';
|
|
19
19
|
import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
|
|
20
20
|
/**
|
|
21
21
|
* Build the Sanity Studio.
|
|
@@ -26,6 +26,7 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
|
|
|
26
26
|
// `views`/`services` live on the branded `unstable_defineApp` result — resolve
|
|
27
27
|
// the workbench capability so it's gated on the brand, like the app build.
|
|
28
28
|
const workbench = resolveWorkbenchApp(cliConfig);
|
|
29
|
+
const appId = getAppId(cliConfig);
|
|
29
30
|
const upgradePkgs = async (options)=>{
|
|
30
31
|
await upgradePackages({
|
|
31
32
|
packageManager: (await getPackageManagerChoice(workDir, {
|
|
@@ -38,16 +39,29 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
|
|
|
38
39
|
});
|
|
39
40
|
};
|
|
40
41
|
await internalBuildStudio({
|
|
41
|
-
appId
|
|
42
|
+
appId,
|
|
42
43
|
autoUpdatesEnabled: options.autoUpdatesEnabled,
|
|
43
|
-
|
|
44
|
+
checkAppId: ()=>{
|
|
45
|
+
// Warn if auto updates enabled but no appId configured.
|
|
46
|
+
// Skip when called from deploy, since deploy handles appId itself
|
|
47
|
+
// (prompts the user and tells them to add it to config).
|
|
48
|
+
if (!appId && !calledFromDeploy) {
|
|
49
|
+
warnAboutMissingAppId({
|
|
50
|
+
appType: 'studio',
|
|
51
|
+
output,
|
|
52
|
+
projectId: cliConfig?.api?.projectId
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
compareDependencyVersions: (packages)=>compareDependencyVersions(packages, workDir, {
|
|
57
|
+
appId
|
|
58
|
+
}),
|
|
44
59
|
determineBasePath: ()=>determineBasePath(cliConfig, 'studio', output),
|
|
45
60
|
isApp: determineIsApp(cliConfig),
|
|
46
61
|
isWorkbenchApp: !!workbench,
|
|
47
62
|
minify: Boolean(flags.minify),
|
|
48
63
|
outDir,
|
|
49
64
|
output,
|
|
50
|
-
projectId: cliConfig?.api?.projectId,
|
|
51
65
|
reactCompiler: cliConfig.reactCompiler,
|
|
52
66
|
schemaExtraction: cliConfig.schemaExtraction,
|
|
53
67
|
services: workbench?.services,
|
|
@@ -66,7 +80,7 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
|
|
|
66
80
|
*/ async function internalBuildStudio(options) {
|
|
67
81
|
buildDebug(`Building studio`);
|
|
68
82
|
const timer = getTimer();
|
|
69
|
-
const { appId, determineBasePath, isApp, minify, outDir, output,
|
|
83
|
+
const { appId, determineBasePath, isApp, minify, outDir, output, reactCompiler, schemaExtraction, services, sourceMap, stats, unattendedMode, upgradePackages, views, vite, workDir } = options;
|
|
70
84
|
const defaultOutputDir = path.resolve(path.join(workDir, 'dist'));
|
|
71
85
|
const outputDir = path.resolve(outDir || defaultOutputDir);
|
|
72
86
|
await checkStudioDependencyVersions(workDir, output);
|
|
@@ -87,16 +101,8 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
|
|
|
87
101
|
throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`);
|
|
88
102
|
}
|
|
89
103
|
output.log(`${logSymbols.info} Building with auto-updates enabled`);
|
|
90
|
-
// Warn if auto updates enabled but no appId configured
|
|
91
|
-
|
|
92
|
-
// (prompts the user and tells them to add it to config).
|
|
93
|
-
if (!appId && !options.calledFromDeploy) {
|
|
94
|
-
warnAboutMissingAppId({
|
|
95
|
-
appType: 'studio',
|
|
96
|
-
output,
|
|
97
|
-
projectId
|
|
98
|
-
});
|
|
99
|
-
}
|
|
104
|
+
// Warn if auto updates enabled but no appId configured
|
|
105
|
+
options.checkAppId();
|
|
100
106
|
const installedVisionVersion = await getLocalPackageVersion('@sanity/vision', workDir);
|
|
101
107
|
const cleanVisionVersion = installedVisionVersion ? semverParse(installedVisionVersion)?.version : undefined;
|
|
102
108
|
const sanityDependencies = [
|
|
@@ -125,9 +131,7 @@ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
|
|
|
125
131
|
appId
|
|
126
132
|
});
|
|
127
133
|
// Check the versions
|
|
128
|
-
const { mismatched, unresolvedPrerelease } = await compareDependencyVersions(sanityDependencies
|
|
129
|
-
appId
|
|
130
|
-
});
|
|
134
|
+
const { mismatched, unresolvedPrerelease } = await options.compareDependencyVersions(sanityDependencies);
|
|
131
135
|
if (unresolvedPrerelease.length > 0) {
|
|
132
136
|
await handlePrereleaseVersions({
|
|
133
137
|
output,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/build/buildStudio.ts"],"sourcesContent":["import {rm} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {\n buildDebug,\n checkRequiredDependencies,\n checkStudioDependencyVersions,\n getAutoUpdatesCssUrls,\n getAutoUpdatesImportMap,\n resolveVendorBuildConfig,\n StudioBuildTrace,\n} from '@sanity/cli-build/_internal/build'\nimport {\n type CliConfig,\n getCliTelemetry,\n getLocalPackageVersion,\n getTimer,\n isInteractive,\n type Output,\n UserViteConfig,\n} from '@sanity/cli-core'\nimport {confirm, logSymbols, select, spinner, type SpinnerInstance} from '@sanity/cli-core/ux'\nimport {type DefineAppInput} from '@sanity/workbench-cli'\nimport {resolveWorkbenchApp} from '@sanity/workbench-cli/build'\nimport {parse as semverParse} from 'semver'\n\nimport {getAppId} from '../../util/appId.js'\nimport {compareDependencyVersions} from '../../util/compareDependencyVersions.js'\nimport {determineIsApp} from '../../util/determineIsApp.js'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils.js'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages.js'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId.js'\nimport {buildStaticFiles} from './buildStaticFiles.js'\nimport {determineBasePath} from './determineBasePath.js'\nimport {getStudioEnvironmentVariables} from './getEnvironmentVariables.js'\nimport {handlePrereleaseVersions} from './handlePrereleaseVersions.js'\nimport {type BuildOptions} from './types.js'\n\ninterface InternalBuildOptions {\n appId: string | undefined\n autoUpdatesEnabled: boolean\n calledFromDeploy: boolean | undefined\n determineBasePath: () => string\n isApp: boolean\n isWorkbenchApp: boolean\n minify: boolean\n outDir: string | undefined\n output: Output\n projectId: string | undefined\n reactCompiler: CliConfig['reactCompiler']\n schemaExtraction: CliConfig['schemaExtraction']\n services: DefineAppInput['services']\n sourceMap: boolean\n stats: boolean\n unattendedMode: boolean\n upgradePackages(options: {packages: [name: string, version: string][]}): Promise<void>\n views: DefineAppInput['views']\n vite: UserViteConfig | undefined\n workDir: string\n}\n\n/**\n * Build the Sanity Studio.\n *\n * @internal\n */\nexport async function buildStudio(options: BuildOptions): Promise<void> {\n const {calledFromDeploy, cliConfig, flags, outDir, output, workDir} = options\n\n // `views`/`services` live on the branded `unstable_defineApp` result — resolve\n // the workbench capability so it's gated on the brand, like the app build.\n const workbench = resolveWorkbenchApp(cliConfig)\n\n const upgradePkgs = async (options: {\n packages: [name: string, version: string][]\n }): Promise<void> => {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: options.packages,\n },\n {output, workDir},\n )\n }\n\n await internalBuildStudio({\n appId: getAppId(cliConfig),\n autoUpdatesEnabled: options.autoUpdatesEnabled,\n calledFromDeploy,\n determineBasePath: () => determineBasePath(cliConfig, 'studio', output),\n isApp: determineIsApp(cliConfig),\n isWorkbenchApp: !!workbench,\n minify: Boolean(flags.minify),\n outDir,\n output,\n projectId: cliConfig?.api?.projectId,\n reactCompiler: cliConfig.reactCompiler,\n schemaExtraction: cliConfig.schemaExtraction,\n services: workbench?.services,\n sourceMap: Boolean(flags['source-maps']),\n stats: flags.stats,\n unattendedMode: Boolean(flags.yes),\n upgradePackages: upgradePkgs,\n views: workbench?.views,\n vite: cliConfig.vite,\n workDir,\n })\n}\n\n/**\n * Internal build studio that avoids depending on flags for CLI config.\n * @param options - options for the build\n */\nasync function internalBuildStudio(options: InternalBuildOptions): Promise<void> {\n buildDebug(`Building studio`)\n\n const timer = getTimer()\n const {\n appId,\n determineBasePath,\n isApp,\n minify,\n outDir,\n output,\n projectId,\n reactCompiler,\n schemaExtraction,\n services,\n sourceMap,\n stats,\n unattendedMode,\n upgradePackages,\n views,\n vite,\n workDir,\n } = options\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(outDir || defaultOutputDir)\n\n await checkStudioDependencyVersions(workDir, output)\n\n // If the check resulted in a dependency install, the CLI command will be re-run,\n // thus we want to exit early\n const {installedSanityVersion} = await checkRequiredDependencies({\n isApp,\n output,\n workDir,\n })\n\n let autoUpdatesEnabled = options.autoUpdatesEnabled\n\n let autoUpdatesImports = {}\n let autoUpdatesCssUrls: string[] = []\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n output.log(`${logSymbols.info} Building with auto-updates enabled`)\n\n // Warn if auto updates enabled but no appId configured.\n // Skip when called from deploy, since deploy handles appId itself\n // (prompts the user and tells them to add it to config).\n if (!appId && !options.calledFromDeploy) {\n warnAboutMissingAppId({appType: 'studio', output, projectId})\n }\n\n const installedVisionVersion = await getLocalPackageVersion('@sanity/vision', workDir)\n const cleanVisionVersion = installedVisionVersion\n ? semverParse(installedVisionVersion)?.version\n : undefined\n\n const sanityDependencies = [\n {cssFile: 'index.css', name: 'sanity', version: cleanSanityVersion},\n ...(cleanVisionVersion\n ? [{cssFile: 'index.css', name: '@sanity/vision' as const, version: cleanVisionVersion}]\n : [{name: '@sanity/vision' as const, version: cleanSanityVersion}]),\n ]\n autoUpdatesImports = getAutoUpdatesImportMap(sanityDependencies, {appId})\n\n autoUpdatesCssUrls = getAutoUpdatesCssUrls(sanityDependencies, {appId})\n\n // Check the versions\n const {mismatched, unresolvedPrerelease} = await compareDependencyVersions(\n sanityDependencies,\n workDir,\n {appId},\n )\n\n if (unresolvedPrerelease.length > 0) {\n await handlePrereleaseVersions({output, unattendedMode, unresolvedPrerelease})\n autoUpdatesImports = {}\n autoUpdatesCssUrls = []\n autoUpdatesEnabled = false\n }\n\n if (mismatched.length > 0 && autoUpdatesEnabled) {\n const versionMismatchWarning =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you test locally with the same versions before deploying. \\n\\n` +\n `${mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}`\n\n // If it is non-interactive or in unattended mode, we don't want to prompt\n if (isInteractive() && !unattendedMode) {\n const choice = await select({\n choices: [\n {\n name: `Upgrade local versions (recommended). You will need to run the build command again`,\n value: 'upgrade',\n },\n {\n name: `Upgrade and proceed with build`,\n value: 'upgrade-and-proceed',\n },\n {\n name: `Continue anyway`,\n value: 'continue',\n },\n {name: 'Cancel', value: 'cancel'},\n ],\n default: 'upgrade',\n message: styleText(\n 'yellow',\n `${logSymbols.warning} ${versionMismatchWarning}\\n\\nDo you want to upgrade local versions before deploying?`,\n ),\n })\n\n if (choice === 'cancel') {\n output.error('Declined to continue with build', {exit: 1})\n return\n }\n\n if (choice === 'upgrade' || choice === 'upgrade-and-proceed') {\n await upgradePackages({\n packages: mismatched.map((res) => [res.pkg, res.remote]),\n })\n\n if (choice === 'upgrade') {\n return\n }\n }\n } else {\n // if non-interactive or unattended, just show the warning\n output.warn(versionMismatchWarning)\n }\n }\n }\n\n const envVarKeys = Object.keys(getStudioEnvironmentVariables())\n if (envVarKeys.length > 0) {\n output.log('\\nIncluding the following environment variables as part of the JavaScript bundle:')\n for (const key of envVarKeys) {\n output.log(`- ${key}`)\n }\n output.log('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode && isInteractive()) {\n shouldClean = await confirm({\n default: true,\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n })\n }\n\n // Determine base path for built studio\n const basePath = determineBasePath()\n\n if (schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Building with schema extraction enabled`)\n }\n\n let spin: SpinnerInstance\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = spinner('Clean output folder').start()\n await rm(outputDir, {force: true, recursive: true})\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed(0)}ms)`\n spin.succeed()\n }\n\n spin = spinner(`Build Sanity Studio`).start()\n\n const trace = getCliTelemetry().trace(StudioBuildTrace)\n trace.start()\n\n let autoUpdates\n if (autoUpdatesEnabled && !options.isWorkbenchApp) {\n autoUpdates = {\n cssUrls: autoUpdatesCssUrls,\n imports: autoUpdatesImports,\n vendor: await resolveVendorBuildConfig({cwd: workDir, isApp: false}),\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n autoUpdates,\n basePath,\n cwd: workDir,\n isWorkbenchApp: options.isWorkbenchApp,\n minify,\n outputDir,\n reactCompiler,\n schemaExtraction,\n services,\n sourceMap,\n views,\n vite,\n })\n\n trace.log({\n outputSize: bundle.chunks\n .flatMap((chunk) => chunk.modules.flatMap((mod) => mod.renderedLength))\n .reduce((sum, n) => sum + n, 0),\n })\n const buildDuration = timer.end('bundleStudio')\n\n spin.text = `Build Sanity Studio (${buildDuration.toFixed(0)}ms)`\n spin.succeed()\n\n trace.complete()\n if (stats) {\n output.log('\\nLargest module files:')\n output.log(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n } catch (error) {\n spin.fail()\n trace.error(error)\n const message = error instanceof Error ? error.message : String(error)\n buildDebug(`Failed to build Sanity Studio`, {error})\n output.error(`Failed to build Sanity Studio: ${message}`, {exit: 1})\n }\n}\n"],"names":["rm","path","styleText","buildDebug","checkRequiredDependencies","checkStudioDependencyVersions","getAutoUpdatesCssUrls","getAutoUpdatesImportMap","resolveVendorBuildConfig","StudioBuildTrace","getCliTelemetry","getLocalPackageVersion","getTimer","isInteractive","confirm","logSymbols","select","spinner","resolveWorkbenchApp","parse","semverParse","getAppId","compareDependencyVersions","determineIsApp","formatModuleSizes","sortModulesBySize","getPackageManagerChoice","upgradePackages","warnAboutMissingAppId","buildStaticFiles","determineBasePath","getStudioEnvironmentVariables","handlePrereleaseVersions","buildStudio","options","calledFromDeploy","cliConfig","flags","outDir","output","workDir","workbench","upgradePkgs","packageManager","interactive","chosen","packages","internalBuildStudio","appId","autoUpdatesEnabled","isApp","isWorkbenchApp","minify","Boolean","projectId","api","reactCompiler","schemaExtraction","services","sourceMap","stats","unattendedMode","yes","views","vite","timer","defaultOutputDir","resolve","join","outputDir","installedSanityVersion","autoUpdatesImports","autoUpdatesCssUrls","cleanSanityVersion","version","Error","log","info","appType","installedVisionVersion","cleanVisionVersion","undefined","sanityDependencies","cssFile","name","mismatched","unresolvedPrerelease","length","versionMismatchWarning","map","mod","pkg","installed","remote","choice","choices","value","default","message","warning","error","exit","res","warn","envVarKeys","Object","keys","key","shouldClean","basePath","enabled","spin","start","force","recursive","cleanDuration","end","text","toFixed","succeed","trace","autoUpdates","cssUrls","imports","vendor","cwd","bundle","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","complete","slice","fail","String"],"mappings":"AAAA,SAAQA,EAAE,QAAO,mBAAkB;AACnC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SACEC,UAAU,EACVC,yBAAyB,EACzBC,6BAA6B,EAC7BC,qBAAqB,EACrBC,uBAAuB,EACvBC,wBAAwB,EACxBC,gBAAgB,QACX,oCAAmC;AAC1C,SAEEC,eAAe,EACfC,sBAAsB,EACtBC,QAAQ,EACR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G;QACjC;QACA,MAAMC,gBAAgBvE,MAAMmD,GAAG,CAAC;QAEhCL,KAAKM,IAAI,GAAG,CAAC,qBAAqB,EAAEmB,cAAclB,OAAO,CAAC,GAAG,GAAG,CAAC;QACjEP,KAAKQ,OAAO;QAEZC,MAAMiB,QAAQ;QACd,IAAI7E,OAAO;YACTrB,OAAOqC,GAAG,CAAC;YACXrC,OAAOqC,GAAG,CAACpD,kBAAkBC,kBAAkBqG,OAAOE,MAAM,EAAEU,KAAK,CAAC,GAAG;QACzE;IACF,EAAE,OAAOtC,OAAO;QACdW,KAAK4B,IAAI;QACTnB,MAAMpB,KAAK,CAACA;QACZ,MAAMF,UAAUE,iBAAiBzB,QAAQyB,MAAMF,OAAO,GAAG0C,OAAOxC;QAChEjG,WAAW,CAAC,6BAA6B,CAAC,EAAE;YAACiG;QAAK;QAClD7D,OAAO6D,KAAK,CAAC,CAAC,+BAA+B,EAAEF,SAAS,EAAE;YAACG,MAAM;QAAC;IACpE;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/build/buildStudio.ts"],"sourcesContent":["import {rm} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {\n buildDebug,\n checkRequiredDependencies,\n checkStudioDependencyVersions,\n getAutoUpdatesCssUrls,\n getAutoUpdatesImportMap,\n resolveVendorBuildConfig,\n StudioBuildTrace,\n} from '@sanity/cli-build/_internal/build'\nimport {getStudioEnvironmentVariables} from '@sanity/cli-build/_internal/env'\nimport {\n type CliConfig,\n getCliTelemetry,\n getLocalPackageVersion,\n getTimer,\n isInteractive,\n type Output,\n UserViteConfig,\n} from '@sanity/cli-core'\nimport {confirm, logSymbols, select, spinner, type SpinnerInstance} from '@sanity/cli-core/ux'\nimport {type DefineAppInput} from '@sanity/workbench-cli'\nimport {resolveWorkbenchApp} from '@sanity/workbench-cli/build'\nimport {parse as semverParse} from 'semver'\n\nimport {getAppId} from '../../util/appId.js'\nimport {\n compareDependencyVersions,\n CompareDependencyVersionsResult,\n} from '../../util/compareDependencyVersions.js'\nimport {determineIsApp} from '../../util/determineIsApp.js'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils.js'\nimport {getPackageManagerChoice} from '../../util/packageManager/packageManagerChoice.js'\nimport {upgradePackages} from '../../util/packageManager/upgradePackages.js'\nimport {warnAboutMissingAppId} from '../../util/warnAboutMissingAppId.js'\nimport {buildStaticFiles} from './buildStaticFiles.js'\nimport {determineBasePath} from './determineBasePath.js'\nimport {handlePrereleaseVersions} from './handlePrereleaseVersions.js'\nimport {type BuildOptions} from './types.js'\n\ninterface InternalBuildOptions {\n appId: string | undefined\n autoUpdatesEnabled: boolean\n checkAppId: () => void\n compareDependencyVersions: (\n packages: {name: string; version: string}[],\n ) => Promise<CompareDependencyVersionsResult>\n determineBasePath: () => string\n isApp: boolean\n isWorkbenchApp: boolean\n minify: boolean\n outDir: string | undefined\n output: Output\n reactCompiler: CliConfig['reactCompiler']\n schemaExtraction: CliConfig['schemaExtraction']\n services: DefineAppInput['services']\n sourceMap: boolean\n stats: boolean\n unattendedMode: boolean\n upgradePackages(options: {packages: [name: string, version: string][]}): Promise<void>\n views: DefineAppInput['views']\n vite: UserViteConfig | undefined\n workDir: string\n}\n\n/**\n * Build the Sanity Studio.\n *\n * @internal\n */\nexport async function buildStudio(options: BuildOptions): Promise<void> {\n const {calledFromDeploy, cliConfig, flags, outDir, output, workDir} = options\n\n // `views`/`services` live on the branded `unstable_defineApp` result — resolve\n // the workbench capability so it's gated on the brand, like the app build.\n const workbench = resolveWorkbenchApp(cliConfig)\n\n const appId = getAppId(cliConfig)\n\n const upgradePkgs = async (options: {\n packages: [name: string, version: string][]\n }): Promise<void> => {\n await upgradePackages(\n {\n packageManager: (await getPackageManagerChoice(workDir, {interactive: false})).chosen,\n packages: options.packages,\n },\n {output, workDir},\n )\n }\n\n await internalBuildStudio({\n appId,\n autoUpdatesEnabled: options.autoUpdatesEnabled,\n checkAppId: () => {\n // Warn if auto updates enabled but no appId configured.\n // Skip when called from deploy, since deploy handles appId itself\n // (prompts the user and tells them to add it to config).\n if (!appId && !calledFromDeploy) {\n warnAboutMissingAppId({appType: 'studio', output, projectId: cliConfig?.api?.projectId})\n }\n },\n compareDependencyVersions: (packages) => compareDependencyVersions(packages, workDir, {appId}),\n determineBasePath: () => determineBasePath(cliConfig, 'studio', output),\n isApp: determineIsApp(cliConfig),\n isWorkbenchApp: !!workbench,\n minify: Boolean(flags.minify),\n outDir,\n output,\n reactCompiler: cliConfig.reactCompiler,\n schemaExtraction: cliConfig.schemaExtraction,\n services: workbench?.services,\n sourceMap: Boolean(flags['source-maps']),\n stats: flags.stats,\n unattendedMode: Boolean(flags.yes),\n upgradePackages: upgradePkgs,\n views: workbench?.views,\n vite: cliConfig.vite,\n workDir,\n })\n}\n\n/**\n * Internal build studio that avoids depending on flags for CLI config.\n * @param options - options for the build\n */\nasync function internalBuildStudio(options: InternalBuildOptions): Promise<void> {\n buildDebug(`Building studio`)\n\n const timer = getTimer()\n const {\n appId,\n determineBasePath,\n isApp,\n minify,\n outDir,\n output,\n reactCompiler,\n schemaExtraction,\n services,\n sourceMap,\n stats,\n unattendedMode,\n upgradePackages,\n views,\n vite,\n workDir,\n } = options\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const outputDir = path.resolve(outDir || defaultOutputDir)\n\n await checkStudioDependencyVersions(workDir, output)\n\n // If the check resulted in a dependency install, the CLI command will be re-run,\n // thus we want to exit early\n const {installedSanityVersion} = await checkRequiredDependencies({\n isApp,\n output,\n workDir,\n })\n\n let autoUpdatesEnabled = options.autoUpdatesEnabled\n\n let autoUpdatesImports = {}\n let autoUpdatesCssUrls: string[] = []\n\n if (autoUpdatesEnabled) {\n // Get the clean version without build metadata: https://semver.org/#spec-item-10\n const cleanSanityVersion = semverParse(installedSanityVersion)?.version\n if (!cleanSanityVersion) {\n throw new Error(`Failed to parse installed Sanity version: ${installedSanityVersion}`)\n }\n\n output.log(`${logSymbols.info} Building with auto-updates enabled`)\n\n // Warn if auto updates enabled but no appId configured\n options.checkAppId()\n\n const installedVisionVersion = await getLocalPackageVersion('@sanity/vision', workDir)\n const cleanVisionVersion = installedVisionVersion\n ? semverParse(installedVisionVersion)?.version\n : undefined\n\n const sanityDependencies = [\n {cssFile: 'index.css', name: 'sanity', version: cleanSanityVersion},\n ...(cleanVisionVersion\n ? [{cssFile: 'index.css', name: '@sanity/vision' as const, version: cleanVisionVersion}]\n : [{name: '@sanity/vision' as const, version: cleanSanityVersion}]),\n ]\n autoUpdatesImports = getAutoUpdatesImportMap(sanityDependencies, {appId})\n\n autoUpdatesCssUrls = getAutoUpdatesCssUrls(sanityDependencies, {appId})\n\n // Check the versions\n const {mismatched, unresolvedPrerelease} =\n await options.compareDependencyVersions(sanityDependencies)\n\n if (unresolvedPrerelease.length > 0) {\n await handlePrereleaseVersions({output, unattendedMode, unresolvedPrerelease})\n autoUpdatesImports = {}\n autoUpdatesCssUrls = []\n autoUpdatesEnabled = false\n }\n\n if (mismatched.length > 0 && autoUpdatesEnabled) {\n const versionMismatchWarning =\n `The following local package versions are different from the versions currently served at runtime.\\n` +\n `When using auto updates, we recommend that you test locally with the same versions before deploying. \\n\\n` +\n `${mismatched.map((mod) => ` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\\n')}`\n\n // If it is non-interactive or in unattended mode, we don't want to prompt\n if (isInteractive() && !unattendedMode) {\n const choice = await select({\n choices: [\n {\n name: `Upgrade local versions (recommended). You will need to run the build command again`,\n value: 'upgrade',\n },\n {\n name: `Upgrade and proceed with build`,\n value: 'upgrade-and-proceed',\n },\n {\n name: `Continue anyway`,\n value: 'continue',\n },\n {name: 'Cancel', value: 'cancel'},\n ],\n default: 'upgrade',\n message: styleText(\n 'yellow',\n `${logSymbols.warning} ${versionMismatchWarning}\\n\\nDo you want to upgrade local versions before deploying?`,\n ),\n })\n\n if (choice === 'cancel') {\n output.error('Declined to continue with build', {exit: 1})\n return\n }\n\n if (choice === 'upgrade' || choice === 'upgrade-and-proceed') {\n await upgradePackages({\n packages: mismatched.map((res) => [res.pkg, res.remote]),\n })\n\n if (choice === 'upgrade') {\n return\n }\n }\n } else {\n // if non-interactive or unattended, just show the warning\n output.warn(versionMismatchWarning)\n }\n }\n }\n\n const envVarKeys = Object.keys(getStudioEnvironmentVariables())\n if (envVarKeys.length > 0) {\n output.log('\\nIncluding the following environment variables as part of the JavaScript bundle:')\n for (const key of envVarKeys) {\n output.log(`- ${key}`)\n }\n output.log('')\n }\n\n let shouldClean = true\n if (outputDir !== defaultOutputDir && !unattendedMode && isInteractive()) {\n shouldClean = await confirm({\n default: true,\n message: `Do you want to delete the existing directory (${outputDir}) first?`,\n })\n }\n\n // Determine base path for built studio\n const basePath = determineBasePath()\n\n if (schemaExtraction?.enabled) {\n output.log(`${logSymbols.info} Building with schema extraction enabled`)\n }\n\n let spin: SpinnerInstance\n if (shouldClean) {\n timer.start('cleanOutputFolder')\n spin = spinner('Clean output folder').start()\n await rm(outputDir, {force: true, recursive: true})\n const cleanDuration = timer.end('cleanOutputFolder')\n spin.text = `Clean output folder (${cleanDuration.toFixed(0)}ms)`\n spin.succeed()\n }\n\n spin = spinner(`Build Sanity Studio`).start()\n\n const trace = getCliTelemetry().trace(StudioBuildTrace)\n trace.start()\n\n let autoUpdates\n if (autoUpdatesEnabled && !options.isWorkbenchApp) {\n autoUpdates = {\n cssUrls: autoUpdatesCssUrls,\n imports: autoUpdatesImports,\n vendor: await resolveVendorBuildConfig({cwd: workDir, isApp: false}),\n }\n }\n\n try {\n timer.start('bundleStudio')\n\n const bundle = await buildStaticFiles({\n autoUpdates,\n basePath,\n cwd: workDir,\n isWorkbenchApp: options.isWorkbenchApp,\n minify,\n outputDir,\n reactCompiler,\n schemaExtraction,\n services,\n sourceMap,\n views,\n vite,\n })\n\n trace.log({\n outputSize: bundle.chunks\n .flatMap((chunk) => chunk.modules.flatMap((mod) => mod.renderedLength))\n .reduce((sum, n) => sum + n, 0),\n })\n const buildDuration = timer.end('bundleStudio')\n\n spin.text = `Build Sanity Studio (${buildDuration.toFixed(0)}ms)`\n spin.succeed()\n\n trace.complete()\n if (stats) {\n output.log('\\nLargest module files:')\n output.log(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)))\n }\n } catch (error) {\n spin.fail()\n trace.error(error)\n const message = error instanceof Error ? error.message : String(error)\n buildDebug(`Failed to build Sanity Studio`, {error})\n output.error(`Failed to build Sanity Studio: ${message}`, {exit: 1})\n }\n}\n"],"names":["rm","path","styleText","buildDebug","checkRequiredDependencies","checkStudioDependencyVersions","getAutoUpdatesCssUrls","getAutoUpdatesImportMap","resolveVendorBuildConfig","StudioBuildTrace","getStudioEnvironmentVariables","getCliTelemetry","getLocalPackageVersion","getTimer","isInteractive","confirm","logSymbols","select","spinner","resolveWorkbenchApp","parse","semverParse","getAppId","compareDependencyVersions","determineIsApp","formatModuleSizes","sortModulesBySize","getPackageManagerChoice","upgradePackages","warnAboutMissingAppId","buildStaticFiles","determineBasePath","handlePrereleaseVersions","buildStudio","options","calledFromDeploy","cliConfig","flags","outDir","output","workDir","workbench","appId","upgradePkgs","packageManager","interactive","chosen","packages","internalBuildStudio","autoUpdatesEnabled","checkAppId","appType","projectId","api","isApp","isWorkbenchApp","minify","Boolean","reactCompiler","schemaExtraction","services","sourceMap","stats","unattendedMode","yes","views","vite","timer","defaultOutputDir","resolve","join","outputDir","installedSanityVersion","autoUpdatesImports","autoUpdatesCssUrls","cleanSanityVersion","version","Error","log","info","installedVisionVersion","cleanVisionVersion","undefined","sanityDependencies","cssFile","name","mismatched","unresolvedPrerelease","length","versionMismatchWarning","map","mod","pkg","installed","remote","choice","choices","value","default","message","warning","error","exit","res","warn","envVarKeys","Object","keys","key","shouldClean","basePath","enabled","spin","start","force","recursive","cleanDuration","end","text","toFixed","succeed","trace","autoUpdates","cssUrls","imports","vendor","cwd","bundle","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","complete","slice","fail","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