@sanity/cli-build 2.0.1 → 4.0.0

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.
Files changed (45) hide show
  1. package/dist/_exports/_internal/build.d.ts +136 -86
  2. package/dist/_exports/_internal/build.js +3 -4
  3. package/dist/_exports/_internal/build.js.map +1 -1
  4. package/dist/_exports/_internal/extract.d.ts +1 -1
  5. package/dist/actions/build/buildApp.js +190 -0
  6. package/dist/actions/build/buildApp.js.map +1 -0
  7. package/dist/actions/build/buildDebug.js +1 -1
  8. package/dist/actions/build/buildDebug.js.map +1 -1
  9. package/dist/actions/build/buildStaticFiles.js +3 -3
  10. package/dist/actions/build/buildStaticFiles.js.map +1 -1
  11. package/dist/actions/build/buildStudio.js +222 -0
  12. package/dist/actions/build/buildStudio.js.map +1 -0
  13. package/dist/actions/build/checkRequiredDependencies.js +1 -1
  14. package/dist/actions/build/checkRequiredDependencies.js.map +1 -1
  15. package/dist/actions/build/checkStudioDependencyVersions.js +1 -1
  16. package/dist/actions/build/checkStudioDependencyVersions.js.map +1 -1
  17. package/dist/actions/build/decorateIndexWithStagingScript.js +1 -1
  18. package/dist/actions/build/decorateIndexWithStagingScript.js.map +1 -1
  19. package/dist/actions/build/getViteConfig.js +7 -6
  20. package/dist/actions/build/getViteConfig.js.map +1 -1
  21. package/dist/actions/build/handlePrereleaseVersions.js +44 -0
  22. package/dist/actions/build/handlePrereleaseVersions.js.map +1 -0
  23. package/dist/actions/build/renderDocument.js +1 -1
  24. package/dist/actions/build/renderDocument.js.map +1 -1
  25. package/dist/actions/build/renderDocumentWorker/addTimestampImportMapScriptToHtml.js +62 -1
  26. package/dist/actions/build/renderDocumentWorker/addTimestampImportMapScriptToHtml.js.map +1 -1
  27. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js +1 -1
  28. package/dist/actions/build/renderDocumentWorker/tryLoadDocumentComponent.js.map +1 -1
  29. package/dist/actions/build/resolveVendorBuildConfig.js +1 -1
  30. package/dist/actions/build/resolveVendorBuildConfig.js.map +1 -1
  31. package/dist/actions/build/writeFavicons.js +3 -3
  32. package/dist/actions/build/writeFavicons.js.map +1 -1
  33. package/dist/actions/build/writeSanityRuntime.js +5 -5
  34. package/dist/actions/build/writeSanityRuntime.js.map +1 -1
  35. package/dist/actions/schema/extractSanitySchema.worker.js +1 -1
  36. package/dist/actions/schema/extractSanitySchema.worker.js.map +1 -1
  37. package/dist/actions/schema/getExtractOptions.js.map +1 -1
  38. package/dist/actions/schema/runSchemaExtraction.js +1 -1
  39. package/dist/actions/schema/runSchemaExtraction.js.map +1 -1
  40. package/dist/actions/schema/utils/extractValidationFromSchemaError.js +1 -1
  41. package/dist/actions/schema/utils/extractValidationFromSchemaError.js.map +1 -1
  42. package/dist/actions/schema/vite/plugin-schema-extraction.js.map +1 -1
  43. package/dist/util/compareDependencyVersions.js +110 -0
  44. package/dist/util/compareDependencyVersions.js.map +1 -0
  45. package/package.json +6 -8
@@ -1,21 +1,12 @@
1
- import { CliConfig } from "@sanity/cli-core";
1
+ import { CliConfig } from "@sanity/cli-core/types";
2
2
  import { ConfigEnv } from "vite";
3
- import { Debugger } from "debug";
4
- import { DefineAppInput } from "@sanity/workbench-cli";
5
- import { DefinedTelemetryTrace } from "@sanity/telemetry";
6
3
  import { FSWatcher } from "chokidar";
7
4
  import { InlineConfig } from "vite";
8
- import { Output } from "@sanity/cli-core";
9
- import { Plugin as Plugin_2 } from "vite";
5
+ import { Output } from "@sanity/cli-core/types";
6
+ import { Plugin } from "vite";
10
7
  import { PluginOptions } from "babel-plugin-react-compiler";
11
- import { UserViteConfig } from "@sanity/cli-core";
12
-
13
- export declare const AppBuildTrace: DefinedTelemetryTrace<
14
- {
15
- outputSize: number;
16
- },
17
- void
18
- >;
8
+ import { UserViteConfig } from "@sanity/cli-core/types";
9
+ import { WorkbenchExposes } from "@sanity/workbench-cli/build";
19
10
 
20
11
  /**
21
12
  * Everything the production build needs to produce an auto-updating studio/app.
@@ -37,7 +28,71 @@ declare interface AutoUpdatesBuildConfig {
37
28
  cssUrls?: string[];
38
29
  }
39
30
 
40
- export declare const buildDebug: Debugger;
31
+ /**
32
+ * Internal build app that avoids depending on flags for CLI config.
33
+ * @param options - options for the build
34
+ */
35
+ export declare function buildApp(options: BuildOptions): Promise<void>;
36
+
37
+ declare interface BuildOptions {
38
+ appId: string | undefined;
39
+ appTitle: string | undefined;
40
+ autoUpdatesEnabled: boolean;
41
+ checkAppId: () => void;
42
+ compareDependencyVersions: (
43
+ packages: {
44
+ name: string;
45
+ version: string;
46
+ }[],
47
+ ) => Promise<CompareDependencyVersionsResult>;
48
+ determineBasePath: () => string;
49
+ entry: string | undefined;
50
+ isWorkbenchApp: boolean;
51
+ minify: boolean;
52
+ outDir: string | undefined;
53
+ output: Output;
54
+ reactCompiler: CliConfig["reactCompiler"];
55
+ schemaExtraction: CliConfig["schemaExtraction"];
56
+ sourceMap: boolean;
57
+ stats: boolean;
58
+ unattendedMode: boolean;
59
+ vite: UserViteConfig | undefined;
60
+ workDir: string;
61
+ exposes?: WorkbenchExposes;
62
+ /** The workbench app's bus identity (`__SANITY_APP_ID__`). */
63
+ workbenchAppId?: string;
64
+ }
65
+
66
+ declare interface BuildOptions_2 {
67
+ appId: string | undefined;
68
+ autoUpdatesEnabled: boolean;
69
+ checkAppId: () => void;
70
+ compareDependencyVersions: (
71
+ packages: {
72
+ name: string;
73
+ version: string;
74
+ }[],
75
+ ) => Promise<CompareDependencyVersionsResult>;
76
+ determineBasePath: () => string;
77
+ isApp: boolean;
78
+ isWorkbenchApp: boolean;
79
+ minify: boolean;
80
+ outDir: string | undefined;
81
+ output: Output;
82
+ reactCompiler: CliConfig["reactCompiler"];
83
+ schemaExtraction: CliConfig["schemaExtraction"];
84
+ sourceMap: boolean;
85
+ stats: boolean;
86
+ unattendedMode: boolean;
87
+ upgradePackages(options: {
88
+ packages: [name: string, version: string][];
89
+ }): Promise<void>;
90
+ vite: UserViteConfig | undefined;
91
+ workDir: string;
92
+ exposes?: WorkbenchExposes;
93
+ /** The workbench app's bus identity (`__SANITY_APP_ID__`). */
94
+ workbenchAppId?: string;
95
+ }
41
96
 
42
97
  /**
43
98
  * Builds static files
@@ -48,6 +103,12 @@ export declare function buildStaticFiles(options: StaticBuildOptions): Promise<{
48
103
  chunks: ChunkStats[];
49
104
  }>;
50
105
 
106
+ /**
107
+ * Internal build studio that avoids depending on flags for CLI config.
108
+ * @param options - options for the build
109
+ */
110
+ export declare function buildStudio(options: BuildOptions_2): Promise<void>;
111
+
51
112
  /**
52
113
  * Checks that the studio has declared and installed the required dependencies
53
114
  * needed by the Sanity modules. While we generally use regular, explicit
@@ -93,6 +154,53 @@ declare interface ChunkStats {
93
154
  name: string;
94
155
  }
95
156
 
157
+ export declare interface CompareDependencyVersions {
158
+ installed: string;
159
+ pkg: string;
160
+ remote: string;
161
+ }
162
+
163
+ /**
164
+ * @internal
165
+ *
166
+ * Compares the versions of dependencies in the studio or app with their remote versions.
167
+ *
168
+ * This function reads the package.json file in the provided working directory, and compares the versions of the dependencies
169
+ * specified in the `autoUpdatesImports` parameter with their remote versions. If the versions do not match, the dependency is
170
+ * added to a list of failed dependencies, which is returned by the function.
171
+ *
172
+ * The failed dependencies are anything that does not strictly match the remote version.
173
+ * This means that if a version is lower or greater by even a patch it will be marked as failed.
174
+ *
175
+ * @param packages - An array of packages with their name and version to compare against remote.
176
+ * @param workDir - The path to the working directory containing the package.json file.
177
+ * @param options - Optional configuration for version comparison.
178
+ *
179
+ * @returns A promise that resolves to an object containing `mismatched` (packages whose local and remote versions differ)
180
+ * and `unresolvedPrerelease` (packages with prerelease versions that could not be resolved remotely).
181
+ *
182
+ * @throws Throws an error if the remote version of a non-prerelease package cannot be fetched, or if the local version
183
+ * of a package cannot be parsed.
184
+ */
185
+ export declare function compareDependencyVersions(
186
+ packages: {
187
+ name: string;
188
+ version: string;
189
+ }[],
190
+ workDir: string,
191
+ { appId }?: CompareDependencyVersionsOptions,
192
+ ): Promise<CompareDependencyVersionsResult>;
193
+
194
+ declare interface CompareDependencyVersionsOptions {
195
+ /** When provided, uses the app-specific module endpoint instead of the default endpoint. */
196
+ appId?: string;
197
+ }
198
+
199
+ export declare interface CompareDependencyVersionsResult {
200
+ mismatched: Array<CompareDependencyVersions>;
201
+ unresolvedPrerelease: Array<UnresolvedPrerelease>;
202
+ }
203
+
96
204
  /**
97
205
  * Merge user-provided Vite configuration object or function
98
206
  *
@@ -107,48 +215,6 @@ export declare function extendViteConfigWithUserConfig(
107
215
  userConfig: UserViteConfig,
108
216
  ): Promise<InlineConfig>;
109
217
 
110
- export declare function formatModuleSizes(modules: ChunkModule[]): string;
111
-
112
- /**
113
- * Generate CDN CSS URLs for auto-updated packages.
114
- * Uses the same URL pattern as JS module URLs so the module server
115
- * resolves CSS and JS to the same version.
116
- *
117
- * @internal
118
- */
119
- export declare function getAutoUpdatesCssUrls<const Pkg extends PackageWithCss>(
120
- packages: Pkg[],
121
- options?: {
122
- appId?: string;
123
- baseUrl?: string;
124
- timestamp?: number;
125
- },
126
- ): string[];
127
-
128
- /**
129
- * @internal
130
- */
131
- export declare function getAutoUpdatesImportMap<const Pkg extends Package>(
132
- packages: Pkg[],
133
- options?: {
134
- appId?: string;
135
- baseUrl?: string;
136
- timestamp?: number;
137
- },
138
- ): { [K in `${Pkg["name"]}/` | Pkg["name"]]: string };
139
-
140
- /**
141
- * @internal
142
- */
143
- export declare function getModuleUrl(
144
- pkg: Package,
145
- options?: {
146
- appId?: string;
147
- baseUrl?: string;
148
- timestamp?: number;
149
- },
150
- ): string;
151
-
152
218
  /**
153
219
  * Get a configuration object for Vite based on the passed options
154
220
  *
@@ -158,15 +224,6 @@ export declare function getViteConfig(
158
224
  options: ViteOptions,
159
225
  ): Promise<InlineConfig>;
160
226
 
161
- declare type Package = {
162
- name: string;
163
- version: string;
164
- };
165
-
166
- declare type PackageWithCss = Package & {
167
- cssFile?: string;
168
- };
169
-
170
227
  /**
171
228
  * Resolves vendor package entry points and metadata for a combined studio/app build.
172
229
  * Does not run a build — callers add `entries` to the main Vite/Rolldown input and
@@ -203,8 +260,6 @@ declare interface RuntimeOptions {
203
260
  */
204
261
  export declare const SANITY_CACHE_DIR = "node_modules/.sanity";
205
262
 
206
- export declare function sortModulesBySize(chunks: ChunkStats[]): ChunkModule[];
207
-
208
263
  declare interface StaticBuildOptions {
209
264
  basePath: string;
210
265
  cwd: string;
@@ -212,6 +267,7 @@ declare interface StaticBuildOptions {
212
267
  appTitle?: string;
213
268
  autoUpdates?: AutoUpdatesBuildConfig;
214
269
  entry?: string;
270
+ exposes?: WorkbenchExposes;
215
271
  isApp?: boolean;
216
272
  /** Workbench app (opted in via `unstable_defineApp`) — drives the federation build. */
217
273
  isWorkbenchApp?: boolean;
@@ -219,25 +275,23 @@ declare interface StaticBuildOptions {
219
275
  profile?: boolean;
220
276
  reactCompiler?: PluginOptions;
221
277
  schemaExtraction?: CliConfig["schemaExtraction"];
222
- services?: DefineAppInput["services"];
223
278
  sourceMap?: boolean;
224
- views?: DefineAppInput["views"];
225
279
  vite?: UserViteConfig;
280
+ /** The workbench app's bus identity (`__SANITY_APP_ID__`). */
281
+ workbenchAppId?: string;
226
282
  }
227
283
 
228
- export declare const StudioBuildTrace: DefinedTelemetryTrace<
229
- {
230
- outputSize: number;
231
- },
232
- void
233
- >;
234
-
235
284
  declare interface TrackedPackage {
236
285
  deprecatedBelow: string | null;
237
286
  name: string;
238
287
  supported: string[];
239
288
  }
240
289
 
290
+ export declare interface UnresolvedPrerelease {
291
+ pkg: string;
292
+ version: string;
293
+ }
294
+
241
295
  declare interface VendorBuildConfig {
242
296
  /** Rolldown entry name -\> absolute path to the package entry file. */
243
297
  entries: Record<string, string>;
@@ -268,7 +322,7 @@ declare interface ViteOptions {
268
322
  /**
269
323
  * Additional plugins when configured, eg. typegen
270
324
  */
271
- additionalPlugins?: Plugin_2[];
325
+ additionalPlugins?: Plugin[];
272
326
  /**
273
327
  * Auto-updates configuration (production builds only). When set, vendor
274
328
  * packages are emitted as hashed ESM chunks by this build and the import map
@@ -280,6 +334,7 @@ declare interface ViteOptions {
280
334
  * Will be normalized to ensure it starts and ends with a `/`
281
335
  */
282
336
  basePath?: string;
337
+ exposes?: WorkbenchExposes;
283
338
  isApp?: boolean;
284
339
  /**
285
340
  * Whether this is a workbench app (opted in via `unstable_defineApp`). Drives
@@ -305,20 +360,15 @@ declare interface ViteOptions {
305
360
  host?: string;
306
361
  port?: number;
307
362
  };
308
- /**
309
- * Background services the workbench app declares. Built into self-contained
310
- * worker bundles and exposed through module federation as `./services/<name>`.
311
- */
312
- services?: DefineAppInput["services"];
313
363
  /**
314
364
  * Whether or not to enable source maps
315
365
  */
316
366
  sourceMap?: boolean;
317
367
  /**
318
- * Views the workbench app declares. Built into render-contract artifacts and
319
- * exposed through module federation as `./views/<name>`.
368
+ * The workbench app's bus identity, stamped into its modules as
369
+ * `__SANITY_APP_ID__` for `@sanity/runtime`. Only read for workbench apps.
320
370
  */
321
- views?: DefineAppInput["views"];
371
+ workbenchAppId?: string;
322
372
  }
323
373
 
324
374
  /**
@@ -1,13 +1,12 @@
1
- export { buildDebug } from '../../actions/build/buildDebug.js';
1
+ export { buildApp } from '../../actions/build/buildApp.js';
2
2
  export { buildStaticFiles } from '../../actions/build/buildStaticFiles.js';
3
+ export { buildStudio } from '../../actions/build/buildStudio.js';
3
4
  export { checkRequiredDependencies } from '../../actions/build/checkRequiredDependencies.js';
4
5
  export { checkStudioDependencyVersions } from '../../actions/build/checkStudioDependencyVersions.js';
5
- export { getAutoUpdatesCssUrls, getAutoUpdatesImportMap, getModuleUrl } from '../../actions/build/getAutoUpdatesImportMap.js';
6
6
  export { extendViteConfigWithUserConfig, getViteConfig } from '../../actions/build/getViteConfig.js';
7
7
  export { resolveVendorBuildConfig } from '../../actions/build/resolveVendorBuildConfig.js';
8
8
  export { writeSanityRuntime } from '../../actions/build/writeSanityRuntime.js';
9
9
  export { SANITY_CACHE_DIR } from '../../constants.js';
10
- export { AppBuildTrace, StudioBuildTrace } from '../../telemetry/build.telemetry.js';
11
- export { formatModuleSizes, sortModulesBySize } from '../../util/moduleFormatUtils.js';
10
+ export { compareDependencyVersions } from '../../util/compareDependencyVersions.js';
12
11
 
13
12
  //# sourceMappingURL=build.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/_exports/_internal/build.ts"],"sourcesContent":["export {buildDebug} from '../../actions/build/buildDebug.js'\nexport {buildStaticFiles} from '../../actions/build/buildStaticFiles.js'\nexport {checkRequiredDependencies} from '../../actions/build/checkRequiredDependencies.js'\nexport {checkStudioDependencyVersions} from '../../actions/build/checkStudioDependencyVersions.js'\nexport {\n getAutoUpdatesCssUrls,\n getAutoUpdatesImportMap,\n getModuleUrl,\n} from '../../actions/build/getAutoUpdatesImportMap.js'\nexport {extendViteConfigWithUserConfig, getViteConfig} from '../../actions/build/getViteConfig.js'\nexport {resolveVendorBuildConfig} from '../../actions/build/resolveVendorBuildConfig.js'\nexport {writeSanityRuntime} from '../../actions/build/writeSanityRuntime.js'\nexport {SANITY_CACHE_DIR} from '../../constants.js'\nexport {AppBuildTrace, StudioBuildTrace} from '../../telemetry/build.telemetry.js'\nexport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils.js'\n"],"names":["buildDebug","buildStaticFiles","checkRequiredDependencies","checkStudioDependencyVersions","getAutoUpdatesCssUrls","getAutoUpdatesImportMap","getModuleUrl","extendViteConfigWithUserConfig","getViteConfig","resolveVendorBuildConfig","writeSanityRuntime","SANITY_CACHE_DIR","AppBuildTrace","StudioBuildTrace","formatModuleSizes","sortModulesBySize"],"mappings":"AAAA,SAAQA,UAAU,QAAO,oCAAmC;AAC5D,SAAQC,gBAAgB,QAAO,0CAAyC;AACxE,SAAQC,yBAAyB,QAAO,mDAAkD;AAC1F,SAAQC,6BAA6B,QAAO,uDAAsD;AAClG,SACEC,qBAAqB,EACrBC,uBAAuB,EACvBC,YAAY,QACP,iDAAgD;AACvD,SAAQC,8BAA8B,EAAEC,aAAa,QAAO,uCAAsC;AAClG,SAAQC,wBAAwB,QAAO,kDAAiD;AACxF,SAAQC,kBAAkB,QAAO,4CAA2C;AAC5E,SAAQC,gBAAgB,QAAO,qBAAoB;AACnD,SAAQC,aAAa,EAAEC,gBAAgB,QAAO,qCAAoC;AAClF,SAAQC,iBAAiB,EAAEC,iBAAiB,QAAO,kCAAiC"}
1
+ {"version":3,"sources":["../../../src/_exports/_internal/build.ts"],"sourcesContent":["export {buildApp} from '../../actions/build/buildApp.js'\nexport {buildStaticFiles} from '../../actions/build/buildStaticFiles.js'\nexport {buildStudio} from '../../actions/build/buildStudio.js'\nexport {checkRequiredDependencies} from '../../actions/build/checkRequiredDependencies.js'\nexport {checkStudioDependencyVersions} from '../../actions/build/checkStudioDependencyVersions.js'\nexport {extendViteConfigWithUserConfig, getViteConfig} from '../../actions/build/getViteConfig.js'\nexport {resolveVendorBuildConfig} from '../../actions/build/resolveVendorBuildConfig.js'\nexport {writeSanityRuntime} from '../../actions/build/writeSanityRuntime.js'\nexport {SANITY_CACHE_DIR} from '../../constants.js'\nexport {\n compareDependencyVersions,\n type CompareDependencyVersions,\n type CompareDependencyVersionsResult,\n type UnresolvedPrerelease,\n} from '../../util/compareDependencyVersions.js'\n"],"names":["buildApp","buildStaticFiles","buildStudio","checkRequiredDependencies","checkStudioDependencyVersions","extendViteConfigWithUserConfig","getViteConfig","resolveVendorBuildConfig","writeSanityRuntime","SANITY_CACHE_DIR","compareDependencyVersions"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,kCAAiC;AACxD,SAAQC,gBAAgB,QAAO,0CAAyC;AACxE,SAAQC,WAAW,QAAO,qCAAoC;AAC9D,SAAQC,yBAAyB,QAAO,mDAAkD;AAC1F,SAAQC,6BAA6B,QAAO,uDAAsD;AAClG,SAAQC,8BAA8B,EAAEC,aAAa,QAAO,uCAAsC;AAClG,SAAQC,wBAAwB,QAAO,kDAAiD;AACxF,SAAQC,kBAAkB,QAAO,4CAA2C;AAC5E,SAAQC,gBAAgB,QAAO,qBAAoB;AACnD,SACEC,yBAAyB,QAIpB,0CAAyC"}
@@ -1,6 +1,6 @@
1
1
  import { DefinedTelemetryTrace } from "@sanity/telemetry";
2
2
  import { extractSchema } from "@sanity/schema/_internal";
3
- import { ProjectRootResult } from "@sanity/cli-core";
3
+ import { ProjectRootResult } from "@sanity/cli-core/types";
4
4
  import { SchemaValidationProblemGroup } from "@sanity/types";
5
5
 
6
6
  /**
@@ -0,0 +1,190 @@
1
+ import { rm } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { styleText } from 'node:util';
4
+ import { getLocalPackageVersion } from '@sanity/cli-core/package-manager';
5
+ import { getCliTelemetry } from '@sanity/cli-core/telemetry';
6
+ import { isInteractive } from '@sanity/cli-core/util';
7
+ import { confirm, getTimer, logSymbols, spinner } from '@sanity/cli-core/ux';
8
+ import { parse as semverParse } from 'semver';
9
+ import { AppBuildTrace } from '../../telemetry/build.telemetry.js';
10
+ import { formatModuleSizes, sortModulesBySize } from '../../util/moduleFormatUtils.js';
11
+ import { buildDebug } from './buildDebug.js';
12
+ import { buildStaticFiles } from './buildStaticFiles.js';
13
+ import { getAutoUpdatesCssUrls, getAutoUpdatesImportMap } from './getAutoUpdatesImportMap.js';
14
+ import { getAppEnvironmentVariables } from './getEnvironmentVariables.js';
15
+ import { handlePrereleaseVersions } from './handlePrereleaseVersions.js';
16
+ import { resolveVendorBuildConfig } from './resolveVendorBuildConfig.js';
17
+ /**
18
+ * Internal build app that avoids depending on flags for CLI config.
19
+ * @param options - options for the build
20
+ */ export async function buildApp(options) {
21
+ buildDebug(`Building app`);
22
+ const { appId, determineBasePath, outDir, output, workDir } = options;
23
+ let { autoUpdatesEnabled } = options;
24
+ const unattendedMode = options.unattendedMode;
25
+ const timer = getTimer();
26
+ const defaultOutputDir = path.resolve(path.join(workDir, 'dist'));
27
+ const outputDir = path.resolve(outDir || defaultOutputDir);
28
+ const installedSdkVersion = await getLocalPackageVersion('@sanity/sdk-react', workDir);
29
+ const installedSanityVersion = await getLocalPackageVersion('sanity', workDir);
30
+ if (!installedSdkVersion) {
31
+ output.error(`Failed to find installed @sanity/sdk-react version`, {
32
+ exit: 1
33
+ });
34
+ return;
35
+ }
36
+ let autoUpdatesImports = {};
37
+ let autoUpdatesCssUrls = [];
38
+ if (autoUpdatesEnabled) {
39
+ // Get the clean version without build metadata: https://semver.org/#spec-item-10
40
+ const cleanSDKVersion = semverParse(installedSdkVersion)?.version;
41
+ if (!cleanSDKVersion) {
42
+ output.error(`Failed to parse installed SDK version: ${installedSdkVersion}`, {
43
+ exit: 1
44
+ });
45
+ return;
46
+ }
47
+ // Sanity might not be installed, but if it is, we want to auto update it.
48
+ const cleanSanityVersion = semverParse(installedSanityVersion)?.version;
49
+ const autoUpdatedPackages = [
50
+ {
51
+ name: '@sanity/sdk',
52
+ version: cleanSDKVersion
53
+ },
54
+ {
55
+ name: '@sanity/sdk-react',
56
+ version: cleanSDKVersion
57
+ },
58
+ ...cleanSanityVersion ? [
59
+ {
60
+ cssFile: 'index.css',
61
+ name: 'sanity',
62
+ version: cleanSanityVersion
63
+ }
64
+ ] : []
65
+ ];
66
+ autoUpdatesImports = getAutoUpdatesImportMap(autoUpdatedPackages, {
67
+ appId
68
+ });
69
+ autoUpdatesCssUrls = getAutoUpdatesCssUrls(autoUpdatedPackages, {
70
+ appId
71
+ });
72
+ output.log(`${logSymbols.info} Building with auto-updates enabled`);
73
+ // Warn if auto updates enabled but no appId configured.
74
+ options.checkAppId();
75
+ // Check the versions
76
+ const { mismatched, unresolvedPrerelease } = await options.compareDependencyVersions(autoUpdatedPackages);
77
+ if (unresolvedPrerelease.length > 0) {
78
+ await handlePrereleaseVersions({
79
+ output,
80
+ unattendedMode,
81
+ unresolvedPrerelease
82
+ });
83
+ autoUpdatesImports = {};
84
+ autoUpdatesCssUrls = [];
85
+ autoUpdatesEnabled = false;
86
+ }
87
+ if (mismatched.length > 0 && autoUpdatesEnabled) {
88
+ const versionMismatchWarning = `The following local package versions are different from the versions currently served at runtime.\n` + `When using auto updates, we recommend that you test locally with the same versions before deploying. \n\n` + `${mismatched.map((mod)=>` - ${mod.pkg} (local version: ${mod.installed}, runtime version: ${mod.remote})`).join('\n')}`;
89
+ // If it is non-interactive or in unattended mode, we don't want to prompt
90
+ if (isInteractive() && !unattendedMode) {
91
+ const shouldContinue = await confirm({
92
+ default: false,
93
+ message: styleText('yellow', `${versionMismatchWarning} \n\nContinue anyway?`)
94
+ });
95
+ if (!shouldContinue) {
96
+ output.error('Declined to continue with build', {
97
+ exit: 1
98
+ });
99
+ return;
100
+ }
101
+ } else {
102
+ // if non-interactive or unattended, just show the warning
103
+ output.warn(versionMismatchWarning);
104
+ }
105
+ }
106
+ }
107
+ const envVarKeys = Object.keys(getAppEnvironmentVariables());
108
+ if (envVarKeys.length > 0) {
109
+ output.log('\nIncluding the following environment variables as part of the JavaScript bundle:');
110
+ for (const key of envVarKeys)output.log(`- ${key}`);
111
+ output.log('');
112
+ }
113
+ let shouldClean = true;
114
+ if (outputDir !== defaultOutputDir && !unattendedMode && isInteractive()) {
115
+ shouldClean = await confirm({
116
+ default: true,
117
+ message: `Do you want to delete the existing directory (${outputDir}) first?`
118
+ });
119
+ }
120
+ const basePath = determineBasePath();
121
+ let spin;
122
+ if (shouldClean) {
123
+ timer.start('cleanOutputFolder');
124
+ spin = spinner('Clean output folder').start();
125
+ await rm(outputDir, {
126
+ force: true,
127
+ recursive: true
128
+ });
129
+ const cleanDuration = timer.end('cleanOutputFolder');
130
+ spin.text = `Clean output folder (${cleanDuration.toFixed(0)}ms)`;
131
+ spin.succeed();
132
+ }
133
+ spin = spinner(`Building Sanity application`).start();
134
+ const trace = getCliTelemetry().trace(AppBuildTrace);
135
+ trace.start();
136
+ let autoUpdates;
137
+ if (autoUpdatesEnabled && !options.isWorkbenchApp) {
138
+ autoUpdates = {
139
+ cssUrls: autoUpdatesCssUrls,
140
+ imports: autoUpdatesImports,
141
+ vendor: await resolveVendorBuildConfig({
142
+ cwd: workDir,
143
+ isApp: true
144
+ })
145
+ };
146
+ }
147
+ try {
148
+ timer.start('bundleStudio');
149
+ const bundle = await buildStaticFiles({
150
+ appTitle: options.appTitle,
151
+ autoUpdates,
152
+ basePath,
153
+ cwd: workDir,
154
+ entry: options.entry,
155
+ exposes: options.exposes,
156
+ isApp: true,
157
+ isWorkbenchApp: options.isWorkbenchApp,
158
+ minify: options.minify,
159
+ outputDir,
160
+ reactCompiler: options.reactCompiler,
161
+ schemaExtraction: options.schemaExtraction,
162
+ sourceMap: options.sourceMap,
163
+ vite: options.vite,
164
+ workbenchAppId: options.workbenchAppId
165
+ });
166
+ trace.log({
167
+ outputSize: bundle.chunks.flatMap((chunk)=>chunk.modules.flatMap((mod)=>mod.renderedLength)).reduce((sum, n)=>sum + n, 0)
168
+ });
169
+ const buildDuration = timer.end('bundleStudio');
170
+ spin.text = `Build Sanity application (${buildDuration.toFixed(0)}ms)`;
171
+ spin.succeed();
172
+ if (options.stats) {
173
+ output.log('\nLargest module files:');
174
+ output.log(formatModuleSizes(sortModulesBySize(bundle.chunks).slice(0, 15)));
175
+ }
176
+ trace.complete();
177
+ } catch (error) {
178
+ spin.fail();
179
+ trace.error(error);
180
+ const message = error instanceof Error ? error.message : String(error);
181
+ buildDebug(`Failed to build Sanity application`, {
182
+ error
183
+ });
184
+ output.error(`Failed to build Sanity application: ${message}`, {
185
+ exit: 1
186
+ });
187
+ }
188
+ }
189
+
190
+ //# sourceMappingURL=buildApp.js.map
@@ -0,0 +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 {getLocalPackageVersion} from '@sanity/cli-core/package-manager'\nimport {getCliTelemetry} from '@sanity/cli-core/telemetry'\nimport {type CliConfig, type Output, type UserViteConfig} from '@sanity/cli-core/types'\nimport {isInteractive} from '@sanity/cli-core/util'\nimport {confirm, getTimer, logSymbols, spinner, type SpinnerInstance} from '@sanity/cli-core/ux'\nimport {type WorkbenchExposes} from '@sanity/workbench-cli/build'\nimport {parse as semverParse} from 'semver'\n\nimport {AppBuildTrace} from '../../telemetry/build.telemetry.js'\nimport {CompareDependencyVersionsResult} from '../../util/compareDependencyVersions.js'\nimport {formatModuleSizes, sortModulesBySize} from '../../util/moduleFormatUtils.js'\nimport {buildDebug} from './buildDebug.js'\nimport {buildStaticFiles} from './buildStaticFiles.js'\nimport {getAutoUpdatesCssUrls, getAutoUpdatesImportMap} from './getAutoUpdatesImportMap.js'\nimport {getAppEnvironmentVariables} from './getEnvironmentVariables.js'\nimport {handlePrereleaseVersions} from './handlePrereleaseVersions.js'\nimport {resolveVendorBuildConfig} from './resolveVendorBuildConfig.js'\n\nexport interface BuildOptions {\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 sourceMap: boolean\n stats: boolean\n unattendedMode: boolean\n vite: UserViteConfig | undefined\n workDir: string\n\n exposes?: WorkbenchExposes\n\n /** The workbench app's bus identity (`__SANITY_APP_ID__`). */\n workbenchAppId?: string\n}\n\n/**\n * Internal build app that avoids depending on flags for CLI config.\n * @param options - options for the build\n */\nexport async function buildApp(options: BuildOptions): 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 exposes: options.exposes,\n isApp: true,\n isWorkbenchApp: options.isWorkbenchApp,\n minify: options.minify,\n outputDir,\n reactCompiler: options.reactCompiler,\n schemaExtraction: options.schemaExtraction,\n sourceMap: options.sourceMap,\n vite: options.vite,\n workbenchAppId: options.workbenchAppId,\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","getLocalPackageVersion","getCliTelemetry","isInteractive","confirm","getTimer","logSymbols","spinner","parse","semverParse","AppBuildTrace","formatModuleSizes","sortModulesBySize","buildDebug","buildStaticFiles","getAutoUpdatesCssUrls","getAutoUpdatesImportMap","getAppEnvironmentVariables","handlePrereleaseVersions","resolveVendorBuildConfig","buildApp","options","appId","determineBasePath","outDir","output","workDir","autoUpdatesEnabled","unattendedMode","timer","defaultOutputDir","resolve","join","outputDir","installedSdkVersion","installedSanityVersion","error","exit","autoUpdatesImports","autoUpdatesCssUrls","cleanSDKVersion","version","cleanSanityVersion","autoUpdatedPackages","name","cssFile","log","info","checkAppId","mismatched","unresolvedPrerelease","compareDependencyVersions","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","isWorkbenchApp","cssUrls","imports","vendor","cwd","isApp","bundle","appTitle","entry","exposes","minify","reactCompiler","schemaExtraction","sourceMap","vite","workbenchAppId","outputSize","chunks","flatMap","chunk","modules","renderedLength","reduce","sum","n","buildDuration","stats","slice","complete","fail","Error","String"],"mappings":"AAAA,SAAQA,EAAE,QAAO,mBAAkB;AACnC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,sBAAsB,QAAO,mCAAkC;AACvE,SAAQC,eAAe,QAAO,6BAA4B;AAE1D,SAAQC,aAAa,QAAO,wBAAuB;AACnD,SAAQ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CAAkC,CAAC,EAAE;YAACuB;QAAK;QACvDX,OAAOW,KAAK,CAAC,CAAC,oCAAoC,EAAEyB,SAAS,EAAE;YAACxB,MAAM;QAAC;IACzE;AACF"}
@@ -1,4 +1,4 @@
1
- import { subdebug } from '@sanity/cli-core';
1
+ import { subdebug } from '@sanity/cli-core/debug';
2
2
  export const buildDebug = subdebug('build');
3
3
 
4
4
  //# sourceMappingURL=buildDebug.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/actions/build/buildDebug.ts"],"sourcesContent":["import {subdebug} from '@sanity/cli-core'\n\nexport const buildDebug = subdebug('build')\n"],"names":["subdebug","buildDebug"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AAEzC,OAAO,MAAMC,aAAaD,SAAS,SAAQ"}
1
+ {"version":3,"sources":["../../../src/actions/build/buildDebug.ts"],"sourcesContent":["import {subdebug} from '@sanity/cli-core/debug'\n\nexport const buildDebug = subdebug('build')\n"],"names":["subdebug","buildDebug"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,yBAAwB;AAE/C,OAAO,MAAMC,aAAaD,SAAS,SAAQ"}
@@ -11,7 +11,7 @@ import { resolveEntries, writeSanityRuntime } from './writeSanityRuntime.js';
11
11
  *
12
12
  * @internal
13
13
  */ export async function buildStaticFiles(options) {
14
- const { appTitle, autoUpdates, basePath, cwd, entry, isApp, isWorkbenchApp, minify = true, outputDir, reactCompiler, schemaExtraction, services, sourceMap = false, views, vite: extendViteConfig } = options;
14
+ const { appTitle, autoUpdates, basePath, cwd, entry, exposes, isApp, isWorkbenchApp, minify = true, outputDir, reactCompiler, schemaExtraction, sourceMap = false, vite: extendViteConfig, workbenchAppId } = options;
15
15
  const mode = 'production';
16
16
  /* Federation builds only produce the federation environment
17
17
  * (remote-entry, mf-manifest) — skip client-specific steps like
@@ -29,6 +29,7 @@ import { resolveEntries, writeSanityRuntime } from './writeSanityRuntime.js';
29
29
  basePath,
30
30
  cwd,
31
31
  entries,
32
+ exposes,
32
33
  getEnvironmentVariables,
33
34
  isApp,
34
35
  isWorkbenchApp,
@@ -39,9 +40,8 @@ import { resolveEntries, writeSanityRuntime } from './writeSanityRuntime.js';
39
40
  // Schema extraction is a build-time artifact, not a client-specific step,
40
41
  // so a federated studio extracts its schema like the legacy studio build.
41
42
  schemaExtraction,
42
- services,
43
43
  sourceMap,
44
- views
44
+ workbenchAppId
45
45
  });
46
46
  // Apply the user's Vite config so plugins like `@vanilla-extract/vite-plugin`
47
47
  // transform source files before the federation environment is bundled.