@sanity/cli-core 2.1.2 → 2.2.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 (87) hide show
  1. package/README.md +224 -1
  2. package/dist/SanityCommand.d.ts +454 -0
  3. package/dist/SanityCommand.js +5 -4
  4. package/dist/SanityCommand.js.map +1 -1
  5. package/dist/_exports/browser.d.ts +21 -0
  6. package/dist/_exports/browser.js +5 -0
  7. package/dist/_exports/browser.js.map +1 -0
  8. package/dist/_exports/config.d.ts +653 -0
  9. package/dist/_exports/config.js +18 -0
  10. package/dist/_exports/config.js.map +1 -0
  11. package/dist/_exports/debug.d.ts +20 -0
  12. package/dist/_exports/debug.js.map +1 -0
  13. package/dist/_exports/errors.d.ts +67 -0
  14. package/dist/_exports/errors.js +5 -0
  15. package/dist/_exports/errors.js.map +1 -0
  16. package/dist/_exports/index.d.ts +30 -33
  17. package/dist/_exports/index.js +42 -39
  18. package/dist/_exports/index.js.map +1 -1
  19. package/dist/_exports/package-manager.d.ts +191 -0
  20. package/dist/_exports/package-manager.js +3 -0
  21. package/dist/_exports/package-manager.js.map +1 -1
  22. package/dist/_exports/schemas.d.ts +227 -0
  23. package/dist/_exports/schemas.js +4 -0
  24. package/dist/_exports/schemas.js.map +1 -0
  25. package/dist/_exports/tasks.d.ts +120 -0
  26. package/dist/_exports/tasks.js +4 -0
  27. package/dist/_exports/tasks.js.map +1 -0
  28. package/dist/_exports/telemetry.d.ts +156 -0
  29. package/dist/_exports/telemetry.js +7 -0
  30. package/dist/_exports/telemetry.js.map +1 -0
  31. package/dist/_exports/types.d.ts +444 -0
  32. package/dist/_exports/types.js +3 -0
  33. package/dist/_exports/types.js.map +1 -0
  34. package/dist/_exports/util.d.ts +132 -0
  35. package/dist/_exports/util.js +16 -0
  36. package/dist/_exports/util.js.map +1 -0
  37. package/dist/_exports/ux.d.ts +15 -0
  38. package/dist/_exports/ux.js +6 -4
  39. package/dist/_exports/ux.js.map +1 -1
  40. package/dist/apiClient.d.ts +79 -0
  41. package/dist/{services/apiClient.js → apiClient.js} +2 -2
  42. package/dist/{services/apiClient.js.map → apiClient.js.map} +1 -1
  43. package/dist/config/cli/cliTokenCache.js.map +1 -0
  44. package/dist/{services → config/cli}/cliUserConfig.js +31 -6
  45. package/dist/config/cli/cliUserConfig.js.map +1 -0
  46. package/dist/config/cli/getCliConfig.js +1 -1
  47. package/dist/config/cli/getCliConfig.js.map +1 -1
  48. package/dist/config/cli/schemas.js +1 -0
  49. package/dist/config/cli/schemas.js.map +1 -1
  50. package/dist/config/cli/types/cliConfig.js.map +1 -1
  51. package/dist/config/cli/workbenchApp.js +19 -38
  52. package/dist/config/cli/workbenchApp.js.map +1 -1
  53. package/dist/config/studio/getStudioWorkspaces.js +1 -1
  54. package/dist/config/studio/getStudioWorkspaces.js.map +1 -1
  55. package/dist/config/studio/readStudioConfig.worker.js +1 -1
  56. package/dist/config/studio/readStudioConfig.worker.js.map +1 -1
  57. package/dist/exitCodes.d.ts +23 -0
  58. package/dist/loaders/studio/studioWorkerLoader.worker.js +2 -2
  59. package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -1
  60. package/dist/telemetry/getCliTelemetry.js +3 -2
  61. package/dist/telemetry/getCliTelemetry.js.map +1 -1
  62. package/dist/telemetry/getTelemetryBaseInfo.js +1 -1
  63. package/dist/telemetry/getTelemetryBaseInfo.js.map +1 -1
  64. package/dist/util/environment/mockBrowserEnvironment.js +3 -2
  65. package/dist/util/environment/mockBrowserEnvironment.js.map +1 -1
  66. package/dist/util/environment/setupBrowserStubs.js +1 -1
  67. package/dist/util/environment/setupBrowserStubs.js.map +1 -1
  68. package/dist/util/getSanityConfigDir.js +1 -0
  69. package/dist/util/getSanityConfigDir.js.map +1 -1
  70. package/dist/util/getSanityEnvVar.js +1 -0
  71. package/dist/util/getSanityEnvVar.js.map +1 -1
  72. package/dist/util/getSanityUrl.js +1 -0
  73. package/dist/util/getSanityUrl.js.map +1 -1
  74. package/dist/util/getWorkspace.js +1 -0
  75. package/dist/util/getWorkspace.js.map +1 -1
  76. package/dist/util/importModule.js +1 -1
  77. package/dist/util/importModule.js.map +1 -1
  78. package/dist/util/promisifyWorker.js +1 -1
  79. package/dist/util/promisifyWorker.js.map +1 -1
  80. package/package.json +57 -9
  81. package/dist/debug.js.map +0 -1
  82. package/dist/services/cliTokenCache.js.map +0 -1
  83. package/dist/services/cliUserConfig.js.map +0 -1
  84. package/dist/services/getCliToken.js +0 -26
  85. package/dist/services/getCliToken.js.map +0 -1
  86. /package/dist/{debug.js → _exports/debug.js} +0 -0
  87. /package/dist/{services → config/cli}/cliTokenCache.js +0 -0
@@ -0,0 +1,79 @@
1
+ import { ClientConfig } from "@sanity/client";
2
+ import { SanityClient } from "@sanity/client";
3
+
4
+ /**
5
+ * Create a "global" (unscoped) Sanity API client.
6
+ *
7
+ * @public
8
+ *
9
+ * @param options - The options to use for the client.
10
+ * @returns Promise that resolves to a configured Sanity API client.
11
+ */
12
+ export declare function getGlobalCliClient({
13
+ requireUser,
14
+ token: providedToken,
15
+ unauthenticated,
16
+ ...config
17
+ }: GlobalCliClientOptions): Promise<SanityClient>;
18
+
19
+ /**
20
+ * Create a "project" (scoped) Sanity API client.
21
+ *
22
+ * @public
23
+ *
24
+ * @param options - The options to use for the client.
25
+ * @returns Promise that resolves to a configured Sanity API client.
26
+ */
27
+ export declare function getProjectCliClient({
28
+ requireUser,
29
+ token: providedToken,
30
+ ...config
31
+ }: ProjectCliClientOptions): Promise<SanityClient>;
32
+
33
+ /**
34
+ * @public
35
+ */
36
+ export declare interface GlobalCliClientOptions extends ClientConfig {
37
+ /**
38
+ * The API version to use for this client.
39
+ */
40
+ apiVersion: string;
41
+ /**
42
+ * Whether to require a user to be authenticated to use this client.
43
+ * Default: `false`.
44
+ * Throws an error if `true` and user is not authenticated.
45
+ */
46
+ requireUser?: boolean;
47
+ /**
48
+ * Whether to skip reading the stored CLI token. When `true`, the client will
49
+ * have no token unless one is explicitly provided.
50
+ * Default: `false`.
51
+ */
52
+ unauthenticated?: boolean;
53
+ }
54
+
55
+ /**
56
+ * @public
57
+ */
58
+ export declare interface ProjectCliClientOptions extends ClientConfig {
59
+ /**
60
+ * The API version to use for this client.
61
+ */
62
+ apiVersion: string;
63
+ /**
64
+ * The project ID to use for this client.
65
+ */
66
+ projectId: string;
67
+ /**
68
+ * The dataset to use for this client.
69
+ */
70
+ dataset?: string;
71
+ /**
72
+ * Whether to require a user to be authenticated to use this client.
73
+ * Default: `false`.
74
+ * Throws an error if `true` and user is not authenticated.
75
+ */
76
+ requireUser?: boolean;
77
+ }
78
+
79
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { styleText } from 'node:util';
2
2
  import { createClient, requester as defaultRequester, isHttpError } from '@sanity/client';
3
- import { generateHelpUrl } from '../util/generateHelpUrl.js';
4
- import { getCliToken } from './getCliToken.js';
3
+ import { getCliToken } from './config/cli/cliUserConfig.js';
4
+ import { generateHelpUrl } from './util/generateHelpUrl.js';
5
5
  const apiHosts = {
6
6
  staging: 'https://api.sanity.work'
7
7
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/apiClient.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {\n type ClientConfig,\n type ClientError,\n createClient,\n requester as defaultRequester,\n isHttpError,\n type SanityClient,\n type ServerError,\n} from '@sanity/client'\n\nimport {generateHelpUrl} from '../util/generateHelpUrl.js'\nimport {getCliToken} from './getCliToken.js'\n\nconst apiHosts: Record<string, string | undefined> = {\n staging: 'https://api.sanity.work',\n}\n\nconst CLI_REQUEST_TAG_PREFIX = 'sanity.cli'\n\n/**\n * @public\n */\nexport interface GlobalCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n\n /**\n * Whether to skip reading the stored CLI token. When `true`, the client will\n * have no token unless one is explicitly provided.\n * Default: `false`.\n */\n unauthenticated?: boolean\n}\n\n/**\n * Create a \"global\" (unscoped) Sanity API client.\n *\n * @public\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getGlobalCliClient({\n requireUser,\n token: providedToken,\n unauthenticated,\n ...config\n}: GlobalCliClientOptions): Promise<SanityClient> {\n const requester = defaultRequester.clone()\n requester.use(authErrors())\n\n const sanityEnv = process.env.SANITY_INTERNAL_ENV || 'production'\n\n const apiHost = apiHosts[sanityEnv]\n\n // Use the provided token if set, otherwise fall back to the stored CLI token (unless unauthenticated)\n const token = providedToken || (unauthenticated ? undefined : await getCliToken())\n\n // If the token is not set and requireUser is true, throw an error\n if (!token && requireUser) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n // Suppress browser token warning since we mock browser environment in workers\n ignoreBrowserTokenWarning: true,\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: false,\n ...config,\n })\n}\n\n/**\n * @public\n */\nexport interface ProjectCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * The project ID to use for this client.\n */\n projectId: string\n\n /**\n * The dataset to use for this client.\n */\n dataset?: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n}\n\n/**\n * Create a \"project\" (scoped) Sanity API client.\n *\n * @public\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getProjectCliClient({\n requireUser,\n token: providedToken,\n ...config\n}: ProjectCliClientOptions): Promise<SanityClient> {\n const requester = defaultRequester.clone()\n requester.use(authErrors())\n\n const sanityEnv = process.env.SANITY_INTERNAL_ENV || 'production'\n\n const apiHost = apiHosts[sanityEnv]\n\n // Use the provided token if it is set, otherwise get the token from the config file\n const token = providedToken || (await getCliToken())\n\n // If the token is not set and requireUser is true, throw an error\n if (!token && requireUser) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n // Suppress browser token warning since we mock browser environment in workers\n ignoreBrowserTokenWarning: true,\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: true,\n ...config,\n })\n}\n\n/**\n * `get-it` middleware that checks for 401 authentication errors and extends the error with more\n * helpful guidance on what to do next.\n *\n * @returns get-it middleware with `onError` handler\n * @internal\n */\nfunction authErrors() {\n return {\n onError: (err: Error | null) => {\n if (!err || !isReqResError(err)) {\n return err\n }\n\n const statusCode = isHttpError(err) && err.response.body.statusCode\n if (statusCode === 401) {\n err.message = `${err.message}. You may need to login again with ${styleText('cyan', 'sanity login')}.\\nFor more information, see ${generateHelpUrl('cli-errors')}.`\n }\n\n return err\n },\n }\n}\n\nfunction isReqResError(err: Error): err is ClientError | ServerError {\n return Object.prototype.hasOwnProperty.call(err, 'response')\n}\n"],"names":["styleText","createClient","requester","defaultRequester","isHttpError","generateHelpUrl","getCliToken","apiHosts","staging","CLI_REQUEST_TAG_PREFIX","getGlobalCliClient","requireUser","token","providedToken","unauthenticated","config","clone","use","authErrors","sanityEnv","process","env","SANITY_INTERNAL_ENV","apiHost","undefined","Error","ignoreBrowserTokenWarning","requestTagPrefix","useCdn","useProjectHostname","getProjectCliClient","onError","err","isReqResError","statusCode","response","body","message","Object","prototype","hasOwnProperty","call"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAGEC,YAAY,EACZC,aAAaC,gBAAgB,EAC7BC,WAAW,QAGN,iBAAgB;AAEvB,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,WAAW,QAAO,mBAAkB;AAE5C,MAAMC,WAA+C;IACnDC,SAAS;AACX;AAEA,MAAMC,yBAAyB;AA0B/B;;;;;;;CAOC,GACD,OAAO,eAAeC,mBAAmB,EACvCC,WAAW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,cAAcD,MAAM;gBAC/B,OAAOA;YACT;YAEA,MAAME,aAAa9B,YAAY4B,QAAQA,IAAIG,QAAQ,CAACC,IAAI,CAACF,UAAU;YACnE,IAAIA,eAAe,KAAK;gBACtBF,IAAIK,OAAO,GAAG,GAAGL,IAAIK,OAAO,CAAC,mCAAmC,EAAErC,UAAU,QAAQ,gBAAgB,6BAA6B,EAAEK,gBAAgB,cAAc,CAAC,CAAC;YACrK;YAEA,OAAO2B;QACT;IACF;AACF;AAEA,SAASC,cAAcD,GAAU;IAC/B,OAAOM,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACT,KAAK;AACnD"}
1
+ {"version":3,"sources":["../src/apiClient.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {\n type ClientConfig,\n type ClientError,\n createClient,\n requester as defaultRequester,\n isHttpError,\n type SanityClient,\n type ServerError,\n} from '@sanity/client'\n\nimport {getCliToken} from './config/cli/cliUserConfig.js'\nimport {generateHelpUrl} from './util/generateHelpUrl.js'\n\nconst apiHosts: Record<string, string | undefined> = {\n staging: 'https://api.sanity.work',\n}\n\nconst CLI_REQUEST_TAG_PREFIX = 'sanity.cli'\n\n/**\n * @public\n */\nexport interface GlobalCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n\n /**\n * Whether to skip reading the stored CLI token. When `true`, the client will\n * have no token unless one is explicitly provided.\n * Default: `false`.\n */\n unauthenticated?: boolean\n}\n\n/**\n * Create a \"global\" (unscoped) Sanity API client.\n *\n * @public\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getGlobalCliClient({\n requireUser,\n token: providedToken,\n unauthenticated,\n ...config\n}: GlobalCliClientOptions): Promise<SanityClient> {\n const requester = defaultRequester.clone()\n requester.use(authErrors())\n\n const sanityEnv = process.env.SANITY_INTERNAL_ENV || 'production'\n\n const apiHost = apiHosts[sanityEnv]\n\n // Use the provided token if set, otherwise fall back to the stored CLI token (unless unauthenticated)\n const token = providedToken || (unauthenticated ? undefined : await getCliToken())\n\n // If the token is not set and requireUser is true, throw an error\n if (!token && requireUser) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n // Suppress browser token warning since we mock browser environment in workers\n ignoreBrowserTokenWarning: true,\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: false,\n ...config,\n })\n}\n\n/**\n * @public\n */\nexport interface ProjectCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * The project ID to use for this client.\n */\n projectId: string\n\n /**\n * The dataset to use for this client.\n */\n dataset?: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n}\n\n/**\n * Create a \"project\" (scoped) Sanity API client.\n *\n * @public\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getProjectCliClient({\n requireUser,\n token: providedToken,\n ...config\n}: ProjectCliClientOptions): Promise<SanityClient> {\n const requester = defaultRequester.clone()\n requester.use(authErrors())\n\n const sanityEnv = process.env.SANITY_INTERNAL_ENV || 'production'\n\n const apiHost = apiHosts[sanityEnv]\n\n // Use the provided token if it is set, otherwise get the token from the config file\n const token = providedToken || (await getCliToken())\n\n // If the token is not set and requireUser is true, throw an error\n if (!token && requireUser) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n // Suppress browser token warning since we mock browser environment in workers\n ignoreBrowserTokenWarning: true,\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: true,\n ...config,\n })\n}\n\n/**\n * `get-it` middleware that checks for 401 authentication errors and extends the error with more\n * helpful guidance on what to do next.\n *\n * @returns get-it middleware with `onError` handler\n * @internal\n */\nfunction authErrors() {\n return {\n onError: (err: Error | null) => {\n if (!err || !isReqResError(err)) {\n return err\n }\n\n const statusCode = isHttpError(err) && err.response.body.statusCode\n if (statusCode === 401) {\n err.message = `${err.message}. You may need to login again with ${styleText('cyan', 'sanity login')}.\\nFor more information, see ${generateHelpUrl('cli-errors')}.`\n }\n\n return err\n },\n }\n}\n\nfunction isReqResError(err: Error): err is ClientError | ServerError {\n return Object.prototype.hasOwnProperty.call(err, 'response')\n}\n"],"names":["styleText","createClient","requester","defaultRequester","isHttpError","getCliToken","generateHelpUrl","apiHosts","staging","CLI_REQUEST_TAG_PREFIX","getGlobalCliClient","requireUser","token","providedToken","unauthenticated","config","clone","use","authErrors","sanityEnv","process","env","SANITY_INTERNAL_ENV","apiHost","undefined","Error","ignoreBrowserTokenWarning","requestTagPrefix","useCdn","useProjectHostname","getProjectCliClient","onError","err","isReqResError","statusCode","response","body","message","Object","prototype","hasOwnProperty","call"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAGEC,YAAY,EACZC,aAAaC,gBAAgB,EAC7BC,WAAW,QAGN,iBAAgB;AAEvB,SAAQC,WAAW,QAAO,gCAA+B;AACzD,SAAQC,eAAe,QAAO,4BAA2B;AAEzD,MAAMC,WAA+C;IACnDC,SAAS;AACX;AAEA,MAAMC,yBAAyB;AA0B/B;;;;;;;CAOC,GACD,OAAO,eAAeC,mBAAmB,EACvCC,WAAW,EACXC,OAAOC,aAAa,EACpBC,eAAe,EACf,GAAGC,QACoB;IACvB,MAAMb,YAAYC,iBAAiBa,KAAK;IACxCd,UAAUe,GAAG,CAACC;IAEd,MAAMC,YAAYC,QAAQC,GAAG,CAACC,mBAAmB,IAAI;IAErD,MAAMC,UAAUhB,QAAQ,CAACY,UAAU;IAEnC,sGAAsG;IACtG,MAAMP,QAAQC,iBAAkBC,CAAAA,kBAAkBU,YAAY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EA,OAAO0B;QACT;IACF;AACF;AAEA,SAASC,cAAcD,GAAU;IAC/B,OAAOM,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACT,KAAK;AACnD"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/config/cli/cliTokenCache.ts"],"sourcesContent":["/**\n * Module-level cache for the CLI auth token, shared between\n * `getCliToken` (reads/writes) and `setCliUserConfig` (invalidates).\n *\n * Extracted into its own module to avoid a circular dependency\n * between `cliUserConfig.ts` and `getCliToken.ts`.\n */\nlet cachedToken: string | undefined\n\nexport function getCachedToken(): string | undefined {\n return cachedToken\n}\n\nexport function setCachedToken(token: string | undefined): void {\n cachedToken = token\n}\n\n/**\n * Clear the in-process token cache so the next `getCliToken()` call\n * re-reads from disk or the environment.\n *\n * Called automatically by `setCliUserConfig('authToken', ...)`.\n *\n * @internal\n */\nexport function clearCliTokenCache(): void {\n cachedToken = undefined\n}\n"],"names":["cachedToken","getCachedToken","setCachedToken","token","clearCliTokenCache","undefined"],"mappings":"AAAA;;;;;;CAMC,GACD,IAAIA;AAEJ,OAAO,SAASC;IACd,OAAOD;AACT;AAEA,OAAO,SAASE,eAAeC,KAAyB;IACtDH,cAAcG;AAChB;AAEA;;;;;;;CAOC,GACD,OAAO,SAASC;IACdJ,cAAcK;AAChB"}
@@ -1,11 +1,37 @@
1
1
  import { mkdirSync } from 'node:fs';
2
2
  import { dirname, join as joinPath } from 'node:path';
3
3
  import { z } from 'zod/mini';
4
- import { debug } from '../debug.js';
5
- import { getSanityConfigDir } from '../util/getSanityConfigDir.js';
6
- import { readJsonFileSync } from '../util/readJsonFileSync.js';
7
- import { writeJsonFileSync } from '../util/writeJsonFileSync.js';
8
- import { clearCliTokenCache } from './cliTokenCache.js';
4
+ import { debug } from '../../_exports/debug.js';
5
+ import { getSanityConfigDir } from '../../util/getSanityConfigDir.js';
6
+ import { readJsonFileSync } from '../../util/readJsonFileSync.js';
7
+ import { writeJsonFileSync } from '../../util/writeJsonFileSync.js';
8
+ import { clearCliTokenCache, getCachedToken, setCachedToken } from './cliTokenCache.js';
9
+ // Re-export so existing consumers don't break
10
+ export { clearCliTokenCache } from './cliTokenCache.js';
11
+ // Only used for testing
12
+ export const _internals = {
13
+ getCliUserConfig
14
+ };
15
+ /**
16
+ * Get the CLI authentication token from the environment or the config file
17
+ *
18
+ * @returns A promise that resolves to a CLI token, or undefined if no token is found
19
+ * @internal
20
+ */ export async function getCliToken() {
21
+ const cached = getCachedToken();
22
+ if (cached !== undefined) {
23
+ return cached;
24
+ }
25
+ const token = process.env.SANITY_AUTH_TOKEN;
26
+ if (token) {
27
+ const trimmed = token.trim();
28
+ setCachedToken(trimmed);
29
+ return trimmed;
30
+ }
31
+ const configToken = _internals.getCliUserConfig('authToken');
32
+ setCachedToken(configToken);
33
+ return configToken;
34
+ }
9
35
  const cliUserConfigSchema = {
10
36
  authToken: z.optional(z.string())
11
37
  };
@@ -51,7 +77,6 @@ const cliUserConfigSchema = {
51
77
  *
52
78
  * @param prop - The property to get the value for
53
79
  * @returns The value of the given property
54
- * @internal
55
80
  */ export function getCliUserConfig(prop) {
56
81
  const config = readConfig();
57
82
  const result = cliUserConfigSchema[prop].safeParse(config[prop]);
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/config/cli/cliUserConfig.ts"],"sourcesContent":["import {mkdirSync} from 'node:fs'\nimport {dirname, join as joinPath} from 'node:path'\n\nimport {z} from 'zod/mini'\n\nimport {debug} from '../../_exports/debug.js'\nimport {getSanityConfigDir} from '../../util/getSanityConfigDir.js'\nimport {readJsonFileSync} from '../../util/readJsonFileSync.js'\nimport {writeJsonFileSync} from '../../util/writeJsonFileSync.js'\nimport {clearCliTokenCache, getCachedToken, setCachedToken} from './cliTokenCache.js'\n\n// Re-export so existing consumers don't break\nexport {clearCliTokenCache} from './cliTokenCache.js'\n\n// Only used for testing\nexport const _internals = {\n getCliUserConfig,\n}\n\n/**\n * Get the CLI authentication token from the environment or the config file\n *\n * @returns A promise that resolves to a CLI token, or undefined if no token is found\n * @internal\n */\nexport async function getCliToken(): Promise<string | undefined> {\n const cached = getCachedToken()\n if (cached !== undefined) {\n return cached\n }\n\n const token = process.env.SANITY_AUTH_TOKEN\n if (token) {\n const trimmed = token.trim()\n setCachedToken(trimmed)\n return trimmed\n }\n\n const configToken = _internals.getCliUserConfig('authToken')\n setCachedToken(configToken)\n return configToken\n}\nconst cliUserConfigSchema = {\n authToken: z.optional(z.string()),\n}\n\n/**\n * Set the config value for the given property.\n * Validates that the passed value adheres to the defined CLI config schema.\n *\n * @param prop - The property to set the value for\n * @param value - The value to set\n * @internal\n */\nexport function setCliUserConfig(prop: 'authToken', value: string | undefined): void {\n const config = readConfig()\n const result = cliUserConfigSchema[prop].safeParse(value)\n if (!result.success) {\n const message = result.error.issues\n .map(({message, path}) => `[${path.join('.')}] ${message}`)\n .join('\\n')\n\n throw new Error(`Invalid value for config property \"${prop}\": ${message}`)\n }\n\n const configPath = getCliUserConfigPath()\n mkdirSync(dirname(configPath), {recursive: true})\n\n // When value is undefined, explicitly delete the key rather than relying\n // on JSON.stringify silently dropping undefined values.\n if (value === undefined) {\n const {[prop]: _, ...rest} = config\n writeJsonFileSync(configPath, rest, {pretty: true})\n } else {\n writeJsonFileSync(configPath, {...config, [prop]: value}, {pretty: true})\n }\n\n // Invalidate the in-process token cache so subsequent getCliToken() calls\n // pick up the new value from disk.\n clearCliTokenCache()\n}\n\n/**\n * Get the config value for the given property\n *\n * @param prop - The property to get the value for\n * @returns The value of the given property\n */\nexport function getCliUserConfig(prop: 'authToken'): string | undefined {\n const config = readConfig()\n const result = cliUserConfigSchema[prop].safeParse(config[prop])\n if (!result.success) {\n debug('Ignoring invalid stored value for \"%s\", returning undefined', prop)\n return undefined\n }\n\n return result.data\n}\n\n/**\n * A raw key-value store for CLI user configuration.\n * Unlike the typed `getCliUserConfig`/`setCliUserConfig`, this operates on\n * arbitrary keys without schema validation.\n *\n * @public\n */\nexport interface ConfigStore {\n /** Remove a key from the config file. */\n delete: (key: string) => void\n /** Read a value by key. Returns `undefined` if the key does not exist. */\n get: (key: string) => unknown\n /** Write a value by key, merging it into the existing config. */\n set: (key: string, value: unknown) => void\n}\n\n/**\n * Get a key-value store backed by the CLI user configuration file\n * (`~/.config/sanity/config.json`).\n *\n * Each call to `get`, `set`, or `delete` performs a full synchronous\n * read-modify-write cycle. This is intentional: sync I/O prevents\n * intra-process race conditions that occurred with the previous async\n * (configstore-backed) implementation.\n *\n * Note: there is no file-level locking, so concurrent writes from\n * separate CLI processes could still conflict. In practice this is\n * unlikely since CLI config writes are rare and user-initiated.\n *\n * @returns A {@link ConfigStore} for the CLI config file\n * @public\n */\nexport function getUserConfig(): ConfigStore {\n return {\n get(key: string): unknown {\n const config = readConfig()\n return config[key]\n },\n\n set(key: string, value: unknown): void {\n const config = readConfig()\n const configPath = getCliUserConfigPath()\n mkdirSync(dirname(configPath), {recursive: true})\n writeJsonFileSync(configPath, {...config, [key]: value}, {pretty: true})\n if (key === 'authToken') clearCliTokenCache()\n },\n\n // No mkdirSync needed: if readConfig() succeeded the directory already exists.\n delete(key: string): void {\n const config = readConfig()\n if (!(key in config)) return\n const {[key]: _, ...rest} = config\n writeJsonFileSync(getCliUserConfigPath(), rest, {pretty: true})\n if (key === 'authToken') clearCliTokenCache()\n },\n }\n}\n\n/**\n * Read the whole configuration from file system. If the file does not exist,\n * is corrupt, or otherwise unreadable, an empty object is returned. This is\n * intentional: the config only holds recoverable data (auth tokens, telemetry\n * consent) so silently resetting is preferable to blocking the user.\n *\n * @returns The whole CLI configuration.\n * @internal\n */\nfunction readConfig(): Record<string, unknown> {\n try {\n const config = readJsonFileSync(getCliUserConfigPath())\n if (!config || typeof config !== 'object' || Array.isArray(config)) {\n throw new Error('Invalid config file - expected an object')\n }\n return config\n } catch (err: unknown) {\n debug('Failed to read CLI config file: %s', err instanceof Error ? err.message : `${err}`)\n return {}\n }\n}\n\n/**\n * Get the file system location for the CLI user configuration file.\n * Takes into account the active environment (staging vs production).\n * The file is located in the user's home directory under the `.config` directory.\n *\n * @returns The path to the CLI configuration file.\n * @internal\n */\nfunction getCliUserConfigPath() {\n return process.env.SANITY_CLI_CONFIG_PATH || joinPath(getSanityConfigDir(), 'config.json')\n}\n"],"names":["mkdirSync","dirname","join","joinPath","z","debug","getSanityConfigDir","readJsonFileSync","writeJsonFileSync","clearCliTokenCache","getCachedToken","setCachedToken","_internals","getCliUserConfig","getCliToken","cached","undefined","token","process","env","SANITY_AUTH_TOKEN","trimmed","trim","configToken","cliUserConfigSchema","authToken","optional","string","setCliUserConfig","prop","value","config","readConfig","result","safeParse","success","message","error","issues","map","path","Error","configPath","getCliUserConfigPath","recursive","_","rest","pretty","data","getUserConfig","get","key","set","delete","Array","isArray","err","SANITY_CLI_CONFIG_PATH"],"mappings":"AAAA,SAAQA,SAAS,QAAO,UAAS;AACjC,SAAQC,OAAO,EAAEC,QAAQC,QAAQ,QAAO,YAAW;AAEnD,SAAQC,CAAC,QAAO,WAAU;AAE1B,SAAQC,KAAK,QAAO,0BAAyB;AAC7C,SAAQC,kBAAkB,QAAO,mCAAkC;AACnE,SAAQC,gBAAgB,QAAO,iCAAgC;AAC/D,SAAQC,iBAAiB,QAAO,kCAAiC;AACjE,SAAQC,kBAAkB,EAAEC,cAAc,EAAEC,cAAc,QAAO,qBAAoB;AAErF,8CAA8C;AAC9C,SAAQF,kBAAkB,QAAO,qBAAoB;AAErD,wBAAwB;AACxB,OAAO,MAAMG,aAAa;IACxBC;AACF,EAAC;AAED;;;;;CAKC,GACD,OAAO,eAAeC;IACpB,MAAMC,SAASL;IACf,IAAIK,WAAWC,WAAW;QACxB,OAAOD;IACT;IAEA,MAAME,QAAQC,QAAQC,GAAG,CAACC,iBAAiB;IAC3C,IAAIH,OAAO;QACT,MAAMI,UAAUJ,MAAMK,IAAI;QAC1BX,eAAeU;QACf,OAAOA;IACT;IAEA,MAAME,cAAcX,WAAWC,gBAAgB,CAAC;IAChDF,eAAeY;IACf,OAAOA;AACT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;;CAeC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,KAAIC,GAAW;YACb,MAAMpB,SAASC;YACf,OAAOD,MAAM,CAACoB,IAAI;QACpB;QAEAC,KAAID,GAAW,EAAErB,KAAc;YAC7B,MAAMC,SAASC;YACf,MAAMU,aAAaC;YACnB3C,UAAUC,QAAQyC,aAAa;gBAACE,WAAW;YAAI;YAC/CpC,kBAAkBkC,YAAY;gBAAC,GAAGX,MAAM;gBAAE,CAACoB,IAAI,EAAErB;YAAK,GAAG;gBAACiB,QAAQ;YAAI;YACtE,IAAII,QAAQ,aAAa1C;QAC3B;QAEA,+EAA+E;QAC/E4C,QAAOF,GAAW;YAChB,MAAMpB,SAASC;YACf,IAAI,CAAEmB,CAAAA,OAAOpB,MAAK,GAAI;YACtB,MAAM,EAAC,CAACoB,IAAI,EAAEN,CAAC,EAAE,GAAGC,MAAK,GAAGf;YAC5BvB,kBAAkBmC,wBAAwBG,MAAM;gBAACC,QAAQ;YAAI;YAC7D,IAAII,QAAQ,aAAa1C;QAC3B;IACF;AACF;AAEA;;;;;;;;CAQC,GACD,SAASuB;IACP,IAAI;QACF,MAAMD,SAASxB,iBAAiBoC;QAChC,IAAI,CAACZ,UAAU,OAAOA,WAAW,YAAYuB,MAAMC,OAAO,CAACxB,SAAS;YAClE,MAAM,IAAIU,MAAM;QAClB;QACA,OAAOV;IACT,EAAE,OAAOyB,KAAc;QACrBnD,MAAM,sCAAsCmD,eAAef,QAAQe,IAAIpB,OAAO,GAAG,GAAGoB,KAAK;QACzF,OAAO,CAAC;IACV;AACF;AAEA;;;;;;;CAOC,GACD,SAASb;IACP,OAAOzB,QAAQC,GAAG,CAACsC,sBAAsB,IAAItD,SAASG,sBAAsB;AAC9E"}
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import { dirname } from 'node:path';
3
- import { debug } from '../../debug.js';
3
+ import { debug } from '../../_exports/debug.js';
4
4
  import { NotFoundError } from '../../errors/NotFoundError.js';
5
5
  import { importModule } from '../../util/importModule.js';
6
6
  import { findPathForFiles } from '../util/findConfigsPaths.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/getCliConfig.ts"],"sourcesContent":["import {createRequire} from 'node:module'\nimport {dirname} from 'node:path'\n\nimport {debug} from '../../debug.js'\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {importModule} from '../../util/importModule.js'\nimport {findPathForFiles} from '../util/findConfigsPaths.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, parseWorkbenchCliConfig} from './workbenchApp.js'\n\nconst cache = new Map<string, Promise<CliConfig>>()\n\n/**\n * Get the CLI config for a project, given the root path.\n *\n * Results are cached in-memory keyed by rootPath for the lifetime of the\n * process. Since the CLI always runs from a single project root, the config\n * won't change during a command's execution, so caching avoids redundant\n * filesystem reads and jiti imports from the prerun hook, SanityCommand\n * helpers, and action files.\n *\n * If loading fails the cached promise is evicted so the next call retries.\n *\n * Long-lived processes that need to observe edits to `sanity.cli.(ts|js)`\n * (e.g. a dev-server watcher) should use {@link getCliConfigUncached}\n * instead — it bypasses both this in-memory cache and Node's module cache.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfig(rootPath: string): Promise<CliConfig> {\n const cached = cache.get(rootPath)\n if (cached) {\n return cached\n }\n\n const promise = getCliConfigUncached(rootPath).catch((err) => {\n cache.delete(rootPath)\n throw err\n })\n\n cache.set(rootPath, promise)\n return promise\n}\n\n/**\n * Read the CLI config for a project from disk, bypassing both the\n * `getCliConfig` in-memory cache and Node's module cache. Each call locates\n * `sanity.cli.(ts|js)`, drops any prior jiti compilation from `require.cache`,\n * re-imports, and re-validates.\n *\n * Use this when the config file is expected to change during the process's\n * lifetime — typically a dev-server watcher that needs the new values picked\n * up after each save. One-shot CLI invocations should prefer\n * {@link getCliConfig} so the prerun hook, SanityCommand helpers, and action\n * files share a single load.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The freshly loaded CLI config\n * @internal\n */\nexport async function getCliConfigUncached(rootPath: string): Promise<CliConfig> {\n const paths = await findPathForFiles(rootPath, ['sanity.cli.ts', 'sanity.cli.js'])\n const configPaths = paths.filter((path) => path.exists)\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(\n `Multiple CLI config files found (${configPaths.map((path) => path.path).join(', ')})`,\n )\n }\n\n const configPath = configPaths[0].path\n\n debug(`Loading CLI config from: ${configPath}`)\n\n // Drop any cached compilation of this file from Node's CJS module cache\n // (jiti compiles `sanity.cli.ts` to CJS and registers it via `require.cache`).\n // Without this, repeated calls would receive the previously imported module\n // even though the file on disk has changed. No-op on first load.\n const cjsRequire = createRequire(import.meta.url)\n delete cjsRequire.cache[configPath]\n\n let cliConfig: CliConfig | undefined\n try {\n const result = await importModule<CliConfig>(configPath)\n\n debug('CLI config loaded: %o', result)\n\n cliConfig = result\n } catch (err) {\n debug('Failed to load CLI config in worker thread: %s', err)\n\n throw new Error('CLI config cannot be loaded', {cause: err})\n }\n\n // Branch as early as possible: a branded `unstable_defineApp(...)` opts into\n // workbench behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, dirname(configPath))\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n debug(`Invalid CLI config: ${error.message}`)\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n return data\n}\n"],"names":["createRequire","dirname","debug","NotFoundError","importModule","findPathForFiles","cliConfigSchema","isWorkbenchApp","parseWorkbenchCliConfig","cache","Map","getCliConfig","rootPath","cached","get","promise","getCliConfigUncached","catch","err","delete","set","paths","configPaths","filter","path","exists","length","Error","map","join","configPath","cjsRequire","url","cliCon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AAwE;IACxE,+EAA+E;IAC/E,4EAA4E;IAC5E,iEAAiE;IACjE,MAAMC,aAAa/B,cAAc,YAAYgC,GAAG;IAChD,OAAOD,WAAWtB,KAAK,CAACqB,WAAW;IAEnC,IAAIG;IACJ,IAAI;QACF,MAAMC,SAAS,MAAM9B,aAAwB0B;QAE7C5B,MAAM,yBAAyBgC;QAE/BD,YAAYC;IACd,EAAE,OAAOhB,KAAK;QACZhB,MAAM,kDAAkDgB;QAExD,MAAM,IAAIS,MAAM,+BAA+B;YAACQ,OAAOjB;QAAG;IAC5D;IAEA,6EAA6E;IAC7E,2EAA2E;IAC3E,IAAIX,eAAe0B,WAAWG,MAAM;QAClC,OAAO5B,wBAAwByB,WAAWhC,QAAQ6B;IACpD;IAEA,MAAM,EAACO,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGjC,gBAAgBkC,SAAS,CAACP;IACzD,IAAI,CAACM,SAAS;QACZrC,MAAM,CAAC,oBAAoB,EAAEoC,MAAMG,OAAO,EAAE;QAC5C,MAAM,IAAId,MAAM,CAAC,oBAAoB,EAAEW,MAAMG,OAAO,EAAE,EAAE;YAACN,OAAOG;QAAK;IACvE;IAEA,OAAOD;AACT"}
1
+ {"version":3,"sources":["../../../src/config/cli/getCliConfig.ts"],"sourcesContent":["import {createRequire} from 'node:module'\nimport {dirname} from 'node:path'\n\nimport {debug} from '../../_exports/debug.js'\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {importModule} from '../../util/importModule.js'\nimport {findPathForFiles} from '../util/findConfigsPaths.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, parseWorkbenchCliConfig} from './workbenchApp.js'\n\nconst cache = new Map<string, Promise<CliConfig>>()\n\n/**\n * Get the CLI config for a project, given the root path.\n *\n * Results are cached in-memory keyed by rootPath for the lifetime of the\n * process. Since the CLI always runs from a single project root, the config\n * won't change during a command's execution, so caching avoids redundant\n * filesystem reads and jiti imports from the prerun hook, SanityCommand\n * helpers, and action files.\n *\n * If loading fails the cached promise is evicted so the next call retries.\n *\n * Long-lived processes that need to observe edits to `sanity.cli.(ts|js)`\n * (e.g. a dev-server watcher) should use {@link getCliConfigUncached}\n * instead — it bypasses both this in-memory cache and Node's module cache.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfig(rootPath: string): Promise<CliConfig> {\n const cached = cache.get(rootPath)\n if (cached) {\n return cached\n }\n\n const promise = getCliConfigUncached(rootPath).catch((err) => {\n cache.delete(rootPath)\n throw err\n })\n\n cache.set(rootPath, promise)\n return promise\n}\n\n/**\n * Read the CLI config for a project from disk, bypassing both the\n * `getCliConfig` in-memory cache and Node's module cache. Each call locates\n * `sanity.cli.(ts|js)`, drops any prior jiti compilation from `require.cache`,\n * re-imports, and re-validates.\n *\n * Use this when the config file is expected to change during the process's\n * lifetime — typically a dev-server watcher that needs the new values picked\n * up after each save. One-shot CLI invocations should prefer\n * {@link getCliConfig} so the prerun hook, SanityCommand helpers, and action\n * files share a single load.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The freshly loaded CLI config\n * @internal\n */\nexport async function getCliConfigUncached(rootPath: string): Promise<CliConfig> {\n const paths = await findPathForFiles(rootPath, ['sanity.cli.ts', 'sanity.cli.js'])\n const configPaths = paths.filter((path) => path.exists)\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(\n `Multiple CLI config files found (${configPaths.map((path) => path.path).join(', ')})`,\n )\n }\n\n const configPath = configPaths[0].path\n\n debug(`Loading CLI config from: ${configPath}`)\n\n // Drop any cached compilation of this file from Node's CJS module cache\n // (jiti compiles `sanity.cli.ts` to CJS and registers it via `require.cache`).\n // Without this, repeated calls would receive the previously imported module\n // even though the file on disk has changed. No-op on first load.\n const cjsRequire = createRequire(import.meta.url)\n delete cjsRequire.cache[configPath]\n\n let cliConfig: CliConfig | undefined\n try {\n const result = await importModule<CliConfig>(configPath)\n\n debug('CLI config loaded: %o', result)\n\n cliConfig = result\n } catch (err) {\n debug('Failed to load CLI config in worker thread: %s', err)\n\n throw new Error('CLI config cannot be loaded', {cause: err})\n }\n\n // Branch as early as possible: a branded `unstable_defineApp(...)` opts into\n // workbench behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, dirname(configPath))\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n debug(`Invalid CLI config: ${error.message}`)\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n return data\n}\n"],"names":["createRequire","dirname","debug","NotFoundError","importModule","findPathForFiles","cliConfigSchema","isWorkbenchApp","parseWorkbenchCliConfig","cache","Map","getCliConfig","rootPath","cached","get","promise","getCliConfigUncached","catch","err","delete","set","paths","configPaths","filter","path","exists","length","Error","map","join","configPath","cjsRequire","url","cliConfig","result","cause","app","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,aAAa,QAAO,cAAa;AACzC,SAAQC,OAAO,QAAO,YAAW;AAEjC,SAAQC,KAAK,QAAO,0BAAyB;AAC7C,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,gBAAgB,QAAO,8BAA6B;AAC5D,SAAQC,eAAe,QAAO,eAAc;AAE5C,SAAQC,cAAc,EAAEC,uBAAuB,QAAO,oBAAmB;AAEzE,MAAMC,QAAQ,IAAIC;AAElB;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,aAAaC,QAAgB;IAC3C,MAAMC,SAASJ,MAAMK,GAAG,CAACF;IACzB,IAAIC,QAAQ;QACV,OAAOA;IACT;IAEA,MAAME,UAAUC,qBAAqBJ,UAAUK,KAAK,CAAC,CAACC;QAC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P;IACzD,IAAI,CAACM,SAAS;QACZrC,MAAM,CAAC,oBAAoB,EAAEoC,MAAMG,OAAO,EAAE;QAC5C,MAAM,IAAId,MAAM,CAAC,oBAAoB,EAAEW,MAAMG,OAAO,EAAE,EAAE;YAACN,OAAOG;QAAK;IACvE;IAEA,OAAOD;AACT"}
@@ -52,6 +52,7 @@ import { z } from 'zod/mini';
52
52
  port: z.optional(z.number())
53
53
  })),
54
54
  studioHost: z.optional(z.string()),
55
+ unstable_bundledDev: z.optional(z.boolean()),
55
56
  vite: z.optional(z.custom()),
56
57
  typegen: z.optional(z.custom())
57
58
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/schemas.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {z} from 'zod/mini'\n\nimport {type CliConfig, type TypeGenConfig} from './types/cliConfig'\nimport {type UserViteConfig} from './types/userViteConfig'\n\n/**\n * @public\n */\nexport const cliConfigSchema = z.object({\n api: z.optional(\n z.object({\n dataset: z.optional(z.string()),\n projectId: z.optional(z.string()),\n }),\n ),\n\n app: z.optional(\n z.object({\n entry: z.optional(z.string()),\n icon: z.optional(z.string()),\n id: z.optional(z.string()),\n organizationId: z.optional(z.string()),\n title: z.optional(z.string()),\n }),\n ),\n\n autoUpdates: z.optional(z.boolean()),\n\n deployment: z.optional(\n z.object({\n appId: z.optional(z.string()),\n autoUpdates: z.optional(z.boolean()),\n }),\n ),\n\n graphql: z.optional(\n z.array(\n z.object({\n filterSuffix: z.optional(z.string()),\n generation: z.optional(z.enum(['gen1', 'gen2', 'gen3'])),\n id: z.optional(z.string()),\n nonNullDocumentFields: z.optional(z.boolean()),\n playground: z.optional(z.boolean()),\n source: z.optional(z.string()),\n tag: z.optional(z.string()),\n workspace: z.optional(z.string()),\n }),\n ),\n ),\n\n mediaLibrary: z.optional(\n z.object({\n aspectsPath: z.optional(z.string()),\n }),\n ),\n\n project: z.optional(\n z.object({\n basePath: z.optional(z.string()),\n }),\n ),\n\n reactCompiler: z.optional(z.custom<ReactCompilerConfig>()),\n\n reactStrictMode: z.optional(z.boolean()),\n\n schemaExtraction: z.optional(\n z.object({\n enabled: z.optional(z.boolean()),\n enforceRequiredFields: z.optional(z.boolean()),\n path: z.optional(z.string()),\n watchPatterns: z.optional(z.array(z.string())),\n workspace: z.optional(z.string()),\n }),\n ),\n\n server: z.optional(\n z.object({\n hostname: z.optional(z.string()),\n port: z.optional(z.number()),\n }),\n ),\n\n studioHost: z.optional(z.string()),\n\n vite: z.optional(z.custom<UserViteConfig>()),\n\n typegen: z.optional(z.custom<Partial<TypeGenConfig> & {enabled?: boolean}>()),\n}) satisfies z.core.$ZodType<CliConfig>\n"],"names":["z","cliConfigSchema","object","api","optional","dataset","string","projectId","app","entry","icon","id","organizationId","title","autoUpdates","boolean","deployment","appId","graphql","array","filterSuffix","generation","enum","nonNullDocumentFields","playground","source","tag","workspace","mediaLibrary","aspectsPath","project","basePath","reactCompiler","custom","reactStrictMode","schemaExtraction","enabled","enforceRequiredFields","path","watchPatterns","server","hostname","port","number","studioHost","vite","typegen"],"mappings":"AACA,SAAQA,CAAC,QAAO,WAAU;AAK1B;;CAEC,GACD,OAAO,MAAMC,kBAAkBD,EAAEE,MAAM,CAAC;IACtCC,KAAKH,EAAEI,QAAQ,CACbJ,EAAEE,MAAM,CAAC;QACPG,SAASL,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QAC5BC,WAAWP,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAChC;IAGFE,KAAKR,EAAEI,QAAQ,CACbJ,EAAEE,MAAM,CAAC;QACPO,OAAOT,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QAC1BI,MAAMV,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACzBK,IAAIX,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACvBM,gBAAgBZ,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACnCO,OAAOb,EAAEI,QAAQ,C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AuBrC,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;QAC3CuB,MAAMtC,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACzBiC,eAAevC,EAAEI,QAAQ,CAACJ,EAAEmB,KAAK,CAACnB,EAAEM,MAAM;QAC1CqB,WAAW3B,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAChC;IAGFkC,QAAQxC,EAAEI,QAAQ,CAChBJ,EAAEE,MAAM,CAAC;QACPuC,UAAUzC,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QAC7BoC,MAAM1C,EAAEI,QAAQ,CAACJ,EAAE2C,MAAM;IAC3B;IAGFC,YAAY5C,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAE/BuC,MAAM7C,EAAEI,QAAQ,CAACJ,EAAEiC,MAAM;IAEzBa,SAAS9C,EAAEI,QAAQ,CAACJ,EAAEiC,MAAM;AAC9B,GAAuC"}
1
+ {"version":3,"sources":["../../../src/config/cli/schemas.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {z} from 'zod/mini'\n\nimport {type CliConfig, type TypeGenConfig} from './types/cliConfig'\nimport {type UserViteConfig} from './types/userViteConfig'\n\n/**\n * @public\n */\nexport const cliConfigSchema = z.object({\n api: z.optional(\n z.object({\n dataset: z.optional(z.string()),\n projectId: z.optional(z.string()),\n }),\n ),\n\n app: z.optional(\n z.object({\n entry: z.optional(z.string()),\n icon: z.optional(z.string()),\n id: z.optional(z.string()),\n organizationId: z.optional(z.string()),\n title: z.optional(z.string()),\n }),\n ),\n\n autoUpdates: z.optional(z.boolean()),\n\n deployment: z.optional(\n z.object({\n appId: z.optional(z.string()),\n autoUpdates: z.optional(z.boolean()),\n }),\n ),\n\n graphql: z.optional(\n z.array(\n z.object({\n filterSuffix: z.optional(z.string()),\n generation: z.optional(z.enum(['gen1', 'gen2', 'gen3'])),\n id: z.optional(z.string()),\n nonNullDocumentFields: z.optional(z.boolean()),\n playground: z.optional(z.boolean()),\n source: z.optional(z.string()),\n tag: z.optional(z.string()),\n workspace: z.optional(z.string()),\n }),\n ),\n ),\n\n mediaLibrary: z.optional(\n z.object({\n aspectsPath: z.optional(z.string()),\n }),\n ),\n\n project: z.optional(\n z.object({\n basePath: z.optional(z.string()),\n }),\n ),\n\n reactCompiler: z.optional(z.custom<ReactCompilerConfig>()),\n\n reactStrictMode: z.optional(z.boolean()),\n\n schemaExtraction: z.optional(\n z.object({\n enabled: z.optional(z.boolean()),\n enforceRequiredFields: z.optional(z.boolean()),\n path: z.optional(z.string()),\n watchPatterns: z.optional(z.array(z.string())),\n workspace: z.optional(z.string()),\n }),\n ),\n\n server: z.optional(\n z.object({\n hostname: z.optional(z.string()),\n port: z.optional(z.number()),\n }),\n ),\n\n studioHost: z.optional(z.string()),\n\n unstable_bundledDev: z.optional(z.boolean()),\n\n vite: z.optional(z.custom<UserViteConfig>()),\n\n typegen: z.optional(z.custom<Partial<TypeGenConfig> & {enabled?: boolean}>()),\n}) satisfies z.core.$ZodType<CliConfig>\n"],"names":["z","cliConfigSchema","object","api","optional","dataset","string","projectId","app","entry","icon","id","organizationId","title","autoUpdates","boolean","deployment","appId","graphql","array","filterSuffix","generation","enum","nonNullDocumentFields","playground","source","tag","workspace","mediaLibrary","aspectsPath","project","basePath","reactCompiler","custom","reactStrictMode","schemaExtraction","enabled","enforceRequiredFields","path","watchPatterns","server","hostname","port","number","studioHost","unstable_bundledDev","vite","typegen"],"mappings":"AACA,SAAQA,CAAC,QAAO,WAAU;AAK1B;;CAEC,GACD,OAAO,MAAMC,kBAAkBD,EAAEE,MAAM,CAAC;IACtCC,KAAKH,EAAEI,QAAQ,CACbJ,EAAEE,MAAM,CAAC;QACPG,SAASL,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QAC5BC,WAAWP,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAChC;IAGFE,KAAKR,EAAEI,QAAQ,CACbJ,EAAEE,MAAM,CAAC;QACPO,OAA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eAAehC,EAAEI,QAAQ,CAACJ,EAAEiC,MAAM;IAElCC,iBAAiBlC,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;IAErCoB,kBAAkBnC,EAAEI,QAAQ,CAC1BJ,EAAEE,MAAM,CAAC;QACPkC,SAASpC,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;QAC7BsB,uBAAuBrC,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;QAC3CuB,MAAMtC,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACzBiC,eAAevC,EAAEI,QAAQ,CAACJ,EAAEmB,KAAK,CAACnB,EAAEM,MAAM;QAC1CqB,WAAW3B,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAChC;IAGFkC,QAAQxC,EAAEI,QAAQ,CAChBJ,EAAEE,MAAM,CAAC;QACPuC,UAAUzC,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QAC7BoC,MAAM1C,EAAEI,QAAQ,CAACJ,EAAE2C,MAAM;IAC3B;IAGFC,YAAY5C,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAE/BuC,qBAAqB7C,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;IAEzC+B,MAAM9C,EAAEI,QAAQ,CAACJ,EAAEiC,MAAM;IAEzBc,SAAS/C,EAAEI,QAAQ,CAACJ,EAAEiC,MAAM;AAC9B,GAAuC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /** Dock group the app renders in. Defaults to `dock.applications`. */\n group?: 'dock.applications' | 'dock.system' | 'dock.user'\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** Sort position within the dock group, ascending. Defaults to `100`. */\n priority?: number\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */\n aspectsPath?: string\n }\n\n /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */\n project?: {\n basePath?: string\n }\n\n /** Configuration options for React Compiler */\n reactCompiler?: ReactCompilerConfig\n\n /** Wraps the Studio in \\<React.StrictMode\\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE=\"true\"|\"false\". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n"],"names":[],"mappings":"AAYA;;CAEC,GACD,WA0IC"}
1
+ {"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /** Dock group the app renders in. Defaults to `dock.applications`. */\n group?: 'dock.applications' | 'dock.system' | 'dock.user'\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** Sort position within the dock group, ascending. Defaults to `100`. */\n priority?: number\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */\n aspectsPath?: string\n }\n\n /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */\n project?: {\n basePath?: string\n }\n\n /** Configuration options for React Compiler */\n reactCompiler?: ReactCompilerConfig\n\n /** Wraps the Studio in \\<React.StrictMode\\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE=\"true\"|\"false\". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to true. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /**\n * Enable Vite's experimental bundled dev mode for `sanity dev`. This serves bundled\n * files during development, which can speed up startup and reloads for large projects.\n * Defaults to `false`.\n *\n * Unstable: may change or be removed without notice while the underlying Vite\n * feature (`experimental.bundledDev`) is experimental.\n * {@link https://vite.dev/guide/rolldown#full-bundle-mode}\n */\n unstable_bundledDev?: boolean\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n"],"names":[],"mappings":"AAYA;;CAEC,GACD,WAqJC"}
@@ -1,25 +1,14 @@
1
1
  import { existsSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { cliConfigSchema } from './schemas.js';
4
+ // Re-derived via `Symbol.for`, not imported from `@sanity/workbench-cli`: that
5
+ // import would cycle (it depends on cli-core) and pull workbench code into the
6
+ // hot config-load path.
7
+ const WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp');
4
8
  /**
5
- * The brand `unstable_defineApp` stamps on its result, registered in the global
6
- * symbol registry. `unstable_defineApp` lives in `@sanity/cli-build`, which
7
- * depends on cli-core — so cli-core can't import the brand without a cycle, and
8
- * wouldn't pull the build package into startup just for this identity check
9
- * anyway (cli-core is the hot path for every CLI command, most of which never
10
- * touch workbench). `Symbol.for` keys the same global symbol `unstable_defineApp`
11
- * stamps, so the check is identical; the only shared contract is the symbol
12
- * string, which cli-core mirrors (see `APPLICATION_TYPES` below).
13
- */ const WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp');
14
- /**
15
- * Whether `app` is a branded `unstable_defineApp(...)` result — the sole
16
- * workbench opt-in. Narrows to the shared `app` config plus the workbench-only
17
- * fields a branded result carries: its `name`, the resolved `applicationType`
18
- * (settled by `parseWorkbenchCliConfig` on load, so callers read it instead of
19
- * re-deriving studio-vs-app), dock panel `views`, and background worker
20
- * `services`. The `type` literals match the `DefineAppInput` schema so
21
- * `views`/`services` stay assignable to `DefineAppInput['views' | 'services']`
22
- * downstream.
9
+ * Boolean brand check — used for config-load routing, kept exported for
10
+ * backward compatibility. For the typed narrowing (the app's declared fields),
11
+ * use `isWorkbenchApp` from `@sanity/workbench-cli`, derived from the schema.
23
12
  */ export function isWorkbenchApp(app) {
24
13
  return typeof app === 'object' && app !== null && WORKBENCH_APP_BRAND in app;
25
14
  }
@@ -31,9 +20,9 @@ const STUDIO_CONFIG_FILES = [
31
20
  'sanity.config.mjs',
32
21
  'sanity.config.cjs'
33
22
  ];
34
- // Mirrors the `ApplicationType` enum in `@sanity/cli-build`'s `defineApp` schema.
35
- // `unstable_defineApp` is a pure identity wrapper that doesn't validate its
36
- // input, so the loader is the first place an explicit `applicationType` can be checked.
23
+ // Mirrors the `ApplicationType` enum in `@sanity/workbench-cli`'s `defineApp`
24
+ // schema — `unstable_defineApp` doesn't validate, so the loader is the first
25
+ // place `applicationType` can be checked. Kept in sync by a test there.
37
26
  const APPLICATION_TYPES = [
38
27
  'coreApp',
39
28
  'studio',
@@ -44,24 +33,17 @@ const APPLICATION_TYPES = [
44
33
  function isApplicationType(value) {
45
34
  return typeof value === 'string' && APPLICATION_TYPES.includes(value);
46
35
  }
47
- /**
48
- * Infer the application type for a workbench app when `unstable_defineApp`
49
- * didn't set one: a project with a `sanity.config.*` is a studio, otherwise a
50
- * core (SDK) app. An explicit `applicationType` always wins.
51
- */ function detectApplicationType(projectDir) {
36
+ /** Infer the type when unset: `sanity.config.*` present → studio, else core (SDK) app. */ function detectApplicationType(projectDir) {
52
37
  return STUDIO_CONFIG_FILES.some((file)=>existsSync(join(projectDir, file))) ? 'studio' : 'coreApp';
53
38
  }
54
39
  /**
55
- * Parse a config whose `app` is a branded `unstable_defineApp(...)` result.
56
- * The branded `app` bypasses the legacy `app` object schema (which would strip
57
- * its identity fields and the brand symbol); every other field is still
58
- * validated. The brand is preserved so downstream code relies on the
59
- * `isWorkbenchApp` identity (above) instead of a flag.
40
+ * Parse a config whose `app` is a branded `unstable_defineApp(...)` result. The
41
+ * branded `app` bypasses the legacy `app` schema (which would strip its identity
42
+ * fields and the brand); every other field is still validated.
60
43
  *
61
- * Resolves `applicationType` here — as early as possible — so studio-vs-app
62
- * classification is settled once and read off the app everywhere else. The
63
- * resolved value lands on a clone, never the caller's object, so re-parsing the
64
- * same `app` for a different directory can't inherit a stale inference.
44
+ * Resolves `applicationType` once, here, so studio-vs-app is settled everywhere
45
+ * downstream. The value lands on a clone, never the caller's object, so
46
+ * re-parsing the same `app` for another directory can't inherit a stale guess.
65
47
  */ export function parseWorkbenchCliConfig(cliConfig, projectDir) {
66
48
  const { app, ...rest } = cliConfig;
67
49
  const { data, error, success } = cliConfigSchema.safeParse(rest);
@@ -75,9 +57,8 @@ function isApplicationType(value) {
75
57
  throw new Error(`Invalid \`applicationType\` "${explicit}" in \`unstable_defineApp\` — expected one of: ${APPLICATION_TYPES.join(', ')}`);
76
58
  }
77
59
  const applicationType = explicit ?? detectApplicationType(projectDir);
78
- // Clone the branded app rather than mutating the caller's object. Copying own
79
- // property descriptors carries over the non-enumerable `unstable_defineApp`
80
- // brand, which a spread would drop.
60
+ // Clone via property descriptors, not spread — carries over the non-enumerable
61
+ // brand and avoids mutating the caller's object.
81
62
  const resolvedApp = Object.defineProperties({}, Object.getOwnPropertyDescriptors(app));
82
63
  resolvedApp.applicationType = applicationType;
83
64
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/workbenchApp.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {join} from 'node:path'\n\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\n\n/**\n * The brand `unstable_defineApp` stamps on its result, registered in the global\n * symbol registry. `unstable_defineApp` lives in `@sanity/cli-build`, which\n * depends on cli-core — so cli-core can't import the brand without a cycle, and\n * wouldn't pull the build package into startup just for this identity check\n * anyway (cli-core is the hot path for every CLI command, most of which never\n * touch workbench). `Symbol.for` keys the same global symbol `unstable_defineApp`\n * stamps, so the check is identical; the only shared contract is the symbol\n * string, which cli-core mirrors (see `APPLICATION_TYPES` below).\n */\nconst WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp')\n\n/**\n * Whether `app` is a branded `unstable_defineApp(...)` result — the sole\n * workbench opt-in. Narrows to the shared `app` config plus the workbench-only\n * fields a branded result carries: its `name`, the resolved `applicationType`\n * (settled by `parseWorkbenchCliConfig` on load, so callers read it instead of\n * re-deriving studio-vs-app), dock panel `views`, and background worker\n * `services`. The `type` literals match the `DefineAppInput` schema so\n * `views`/`services` stay assignable to `DefineAppInput['views' | 'services']`\n * downstream.\n */\nexport function isWorkbenchApp(app: CliConfig['app']): app is NonNullable<CliConfig['app']> & {\n applicationType?: ApplicationType\n name: string\n services?: {name: string; src: string; type: 'worker'}[]\n views?: {name: string; src: string; type: 'panel'}[]\n} {\n return typeof app === 'object' && app !== null && WORKBENCH_APP_BRAND in app\n}\n\nconst STUDIO_CONFIG_FILES = [\n 'sanity.config.ts',\n 'sanity.config.tsx',\n 'sanity.config.js',\n 'sanity.config.jsx',\n 'sanity.config.mjs',\n 'sanity.config.cjs',\n]\n\n// Mirrors the `ApplicationType` enum in `@sanity/cli-build`'s `defineApp` schema.\n// `unstable_defineApp` is a pure identity wrapper that doesn't validate its\n// input, so the loader is the first place an explicit `applicationType` can be checked.\nconst APPLICATION_TYPES = ['coreApp', 'studio', 'canvas', 'dashboard', 'media-library'] as const\n\n/** The resolved kind of a workbench app — `studio` or one of the SDK app types. */\nexport type ApplicationType = (typeof APPLICATION_TYPES)[number]\n\nfunction isApplicationType(value: unknown): value is ApplicationType {\n return typeof value === 'string' && (APPLICATION_TYPES as readonly string[]).includes(value)\n}\n\n/**\n * Infer the application type for a workbench app when `unstable_defineApp`\n * didn't set one: a project with a `sanity.config.*` is a studio, otherwise a\n * core (SDK) app. An explicit `applicationType` always wins.\n */\nfunction detectApplicationType(projectDir: string): ApplicationType {\n return STUDIO_CONFIG_FILES.some((file) => existsSync(join(projectDir, file)))\n ? 'studio'\n : 'coreApp'\n}\n\n/**\n * Parse a config whose `app` is a branded `unstable_defineApp(...)` result.\n * The branded `app` bypasses the legacy `app` object schema (which would strip\n * its identity fields and the brand symbol); every other field is still\n * validated. The brand is preserved so downstream code relies on the\n * `isWorkbenchApp` identity (above) instead of a flag.\n *\n * Resolves `applicationType` here — as early as possible — so studio-vs-app\n * classification is settled once and read off the app everywhere else. The\n * resolved value lands on a clone, never the caller's object, so re-parsing the\n * same `app` for a different directory can't inherit a stale inference.\n */\nexport function parseWorkbenchCliConfig(cliConfig: unknown, projectDir: string): CliConfig {\n const {app, ...rest} = cliConfig as Record<string, unknown> & {\n app: Record<string, unknown> & {applicationType?: string}\n }\n const {data, error, success} = cliConfigSchema.safeParse(rest)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n const explicit = app.applicationType\n if (explicit !== undefined && !isApplicationType(explicit)) {\n throw new Error(\n `Invalid \\`applicationType\\` \"${explicit}\" in \\`unstable_defineApp\\` — expected one of: ${APPLICATION_TYPES.join(', ')}`,\n )\n }\n const applicationType = explicit ?? detectApplicationType(projectDir)\n\n // Clone the branded app rather than mutating the caller's object. Copying own\n // property descriptors carries over the non-enumerable `unstable_defineApp`\n // brand, which a spread would drop.\n const resolvedApp = Object.defineProperties({}, Object.getOwnPropertyDescriptors(app)) as Record<\n string,\n unknown\n >\n resolvedApp.applicationType = applicationType\n\n return {...data, app: resolvedApp} as CliConfig\n}\n"],"names":["existsSync","join","cliConfigSchema","WORKBENCH_APP_BRAND","Symbol","for","isWorkbenchApp","app","STUDIO_CONFIG_FILES","APPLICATION_TYPES","isApplicationType","value","includes","detectApplicationType","projectDir","some","file","parseWorkbenchCliConfig","cliConfig","rest","data","error","success","safeParse","Error","message","cause","explicit","applicationType","undefined","resolvedApp","Object","defineProperties","getOwnPropertyDescriptors"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,eAAe,QAAO,eAAc;AAG5C;;;;;;;;;CASC,GACD,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC;AAEvC;;;;;;;;;CASC,GACD,OAAO,SAASC,eAAeC,GAAqB;IAMlD,OAAO,OAAOA,QAAQ,YAAYA,QAAQ,QAAQJ,uBAAuBI;AAC3E;AAEA,MAAMC,sBAAsB;IAC1B;IACA;IACA;IACA;IACA;IACA;CACD;AAED,kFAAkF;AAClF,4EAA4E;AAC5E,wFAAwF;AACxF,MAAMC,oBAAoB;IAAC;IAAW;IAAU;IAAU;IAAa;CAAgB;AAKvF,SAASC,kBAAkBC,KAAc;IACvC,OAAO,OAAOA,UAAU,YAAY,AAACF,kBAAwCG,QAAQ,CAACD;AACxF;AAEA;;;;CAIC,GACD,SAASE,sBAAsBC,UAAkB;IAC/C,OAAON,oBAAoBO,IAAI,CAAC,CAACC,OAAShB,WAAWC,KAAKa,YAAYE,UAClE,WACA;AACN;AAEA;;;;;;;;;;;CAWC,GACD,OAAO,SAASC,wBAAwBC,SAAkB,EAAEJ,UAAkB;IAC5E,MAAM,EAACP,GAAG,EAAE,GAAGY,MAAK,GAAGD;IAGvB,MAAM,EAACE,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGpB,gBAAgBqB,SAAS,CAACJ;IACzD,IAAI,CAACG,SAAS;QACZ,MAAM,IAAIE,MAAM,CAAC,oBAAoB,EAAEH,MAAMI,OAAO,EAAE,EAAE;YAACC,OAAOL;QAAK;IACvE;IAEA,MAAMM,WAAWpB,IAAIqB,eAAe;IACpC,IAAID,aAAaE,aAAa,CAACnB,kBAAkBiB,WAAW;QAC1D,MAAM,IAAIH,MACR,CAAC,6BAA6B,EAAEG,SAAS,+CAA+C,EAAElB,kBAAkBR,IAAI,CAAC,OAAO;IAE5H;IACA,MAAM2B,kBAAkBD,YAAYd,sBAAsBC;IAE1D,8EAA8E;IAC9E,4EAA4E;IAC5E,oCAAoC;IACpC,MAAMgB,cAAcC,OAAOC,gBAAgB,CAAC,CAAC,GAAGD,OAAOE,yBAAyB,CAAC1B;IAIjFuB,YAAYF,eAAe,GAAGA;IAE9B,OAAO;QAAC,GAAGR,IAAI;QAAEb,KAAKuB;IAAW;AACnC"}
1
+ {"version":3,"sources":["../../../src/config/cli/workbenchApp.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {join} from 'node:path'\n\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\n\n// Re-derived via `Symbol.for`, not imported from `@sanity/workbench-cli`: that\n// import would cycle (it depends on cli-core) and pull workbench code into the\n// hot config-load path.\nconst WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp')\n\n/**\n * Boolean brand check — used for config-load routing, kept exported for\n * backward compatibility. For the typed narrowing (the app's declared fields),\n * use `isWorkbenchApp` from `@sanity/workbench-cli`, derived from the schema.\n */\nexport function isWorkbenchApp(app: CliConfig['app']): boolean {\n return typeof app === 'object' && app !== null && WORKBENCH_APP_BRAND in app\n}\n\nconst STUDIO_CONFIG_FILES = [\n 'sanity.config.ts',\n 'sanity.config.tsx',\n 'sanity.config.js',\n 'sanity.config.jsx',\n 'sanity.config.mjs',\n 'sanity.config.cjs',\n]\n\n// Mirrors the `ApplicationType` enum in `@sanity/workbench-cli`'s `defineApp`\n// schema — `unstable_defineApp` doesn't validate, so the loader is the first\n// place `applicationType` can be checked. Kept in sync by a test there.\nconst APPLICATION_TYPES = ['coreApp', 'studio', 'canvas', 'dashboard', 'media-library'] as const\n\n/** The resolved kind of a workbench app — `studio` or one of the SDK app types. */\nexport type ApplicationType = (typeof APPLICATION_TYPES)[number]\n\nfunction isApplicationType(value: unknown): value is ApplicationType {\n return typeof value === 'string' && (APPLICATION_TYPES as readonly string[]).includes(value)\n}\n\n/** Infer the type when unset: `sanity.config.*` present → studio, else core (SDK) app. */\nfunction detectApplicationType(projectDir: string): ApplicationType {\n return STUDIO_CONFIG_FILES.some((file) => existsSync(join(projectDir, file)))\n ? 'studio'\n : 'coreApp'\n}\n\n/**\n * Parse a config whose `app` is a branded `unstable_defineApp(...)` result. The\n * branded `app` bypasses the legacy `app` schema (which would strip its identity\n * fields and the brand); every other field is still validated.\n *\n * Resolves `applicationType` once, here, so studio-vs-app is settled everywhere\n * downstream. The value lands on a clone, never the caller's object, so\n * re-parsing the same `app` for another directory can't inherit a stale guess.\n */\nexport function parseWorkbenchCliConfig(cliConfig: unknown, projectDir: string): CliConfig {\n const {app, ...rest} = cliConfig as Record<string, unknown> & {\n app: Record<string, unknown> & {applicationType?: string}\n }\n const {data, error, success} = cliConfigSchema.safeParse(rest)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n const explicit = app.applicationType\n if (explicit !== undefined && !isApplicationType(explicit)) {\n throw new Error(\n `Invalid \\`applicationType\\` \"${explicit}\" in \\`unstable_defineApp\\` — expected one of: ${APPLICATION_TYPES.join(', ')}`,\n )\n }\n const applicationType = explicit ?? detectApplicationType(projectDir)\n\n // Clone via property descriptors, not spread — carries over the non-enumerable\n // brand and avoids mutating the caller's object.\n const resolvedApp = Object.defineProperties({}, Object.getOwnPropertyDescriptors(app)) as Record<\n string,\n unknown\n >\n resolvedApp.applicationType = applicationType\n\n return {...data, app: resolvedApp} as CliConfig\n}\n"],"names":["existsSync","join","cliConfigSchema","WORKBENCH_APP_BRAND","Symbol","for","isWorkbenchApp","app","STUDIO_CONFIG_FILES","APPLICATION_TYPES","isApplicationType","value","includes","detectApplicationType","projectDir","some","file","parseWorkbenchCliConfig","cliConfig","rest","data","error","success","safeParse","Error","message","cause","explicit","applicationType","undefined","resolvedApp","Object","defineProperties","getOwnPropertyDescriptors"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,eAAe,QAAO,eAAc;AAG5C,+EAA+E;AAC/E,+EAA+E;AAC/E,wBAAwB;AACxB,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC;AAEvC;;;;CAIC,GACD,OAAO,SAASC,eAAeC,GAAqB;IAClD,OAAO,OAAOA,QAAQ,YAAYA,QAAQ,QAAQJ,uBAAuBI;AAC3E;AAEA,MAAMC,sBAAsB;IAC1B;IACA;IACA;IACA;IACA;IACA;CACD;AAED,8EAA8E;AAC9E,6EAA6E;AAC7E,wEAAwE;AACxE,MAAMC,oBAAoB;IAAC;IAAW;IAAU;IAAU;IAAa;CAAgB;AAKvF,SAASC,kBAAkBC,KAAc;IACvC,OAAO,OAAOA,UAAU,YAAY,AAACF,kBAAwCG,QAAQ,CAACD;AACxF;AAEA,wFAAwF,GACxF,SAASE,sBAAsBC,UAAkB;IAC/C,OAAON,oBAAoBO,IAAI,CAAC,CAACC,OAAShB,WAAWC,KAAKa,YAAYE,UAClE,WACA;AACN;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASC,wBAAwBC,SAAkB,EAAEJ,UAAkB;IAC5E,MAAM,EAACP,GAAG,EAAE,GAAGY,MAAK,GAAGD;IAGvB,MAAM,EAACE,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGpB,gBAAgBqB,SAAS,CAACJ;IACzD,IAAI,CAACG,SAAS;QACZ,MAAM,IAAIE,MAAM,CAAC,oBAAoB,EAAEH,MAAMI,OAAO,EAAE,EAAE;YAACC,OAAOL;QAAK;IACvE;IAEA,MAAMM,WAAWpB,IAAIqB,eAAe;IACpC,IAAID,aAAaE,aAAa,CAACnB,kBAAkBiB,WAAW;QAC1D,MAAM,IAAIH,MACR,CAAC,6BAA6B,EAAEG,SAAS,+CAA+C,EAAElB,kBAAkBR,IAAI,CAAC,OAAO;IAE5H;IACA,MAAM2B,kBAAkBD,YAAYd,sBAAsBC;IAE1D,+EAA+E;IAC/E,iDAAiD;IACjD,MAAMgB,cAAcC,OAAOC,gBAAgB,CAAC,CAAC,GAAGD,OAAOE,yBAAyB,CAAC1B;IAIjFuB,YAAYF,eAAe,GAAGA;IAE9B,OAAO;QAAC,GAAGR,IAAI;QAAEb,KAAKuB;IAAW;AACnC"}
@@ -2,7 +2,7 @@ import { stat } from 'node:fs/promises';
2
2
  import { dirname } from 'node:path';
3
3
  import { isMainThread } from 'node:worker_threads';
4
4
  import { firstValueFrom, of } from 'rxjs';
5
- import { subdebug } from '../../debug.js';
5
+ import { subdebug } from '../../_exports/debug.js';
6
6
  import { doImport } from '../../util/doImport.js';
7
7
  import { getEmptyAuth } from '../../util/getEmptyAuth.js';
8
8
  import { resolveLocalPackage } from '../../util/resolveLocalPackage.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/studio/getStudioWorkspaces.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {dirname} from 'node:path'\nimport {isMainThread} from 'node:worker_threads'\n\nimport {firstValueFrom, of} from 'rxjs'\nimport {type Workspace} from 'sanity'\n\nimport {subdebug} from '../../debug.js'\nimport {doImport} from '../../util/doImport.js'\nimport {getEmptyAuth} from '../../util/getEmptyAuth.js'\nimport {resolveLocalPackage} from '../../util/resolveLocalPackage.js'\nimport {findStudioConfigPath} from '../util/findStudioConfigPath.js'\nimport {isStudioConfig} from './isStudioConfig.js'\n\nconst debug = subdebug('worker:getStudioWorkspaces')\n\n/**\n * Resolves the workspaces from the studio config.\n *\n * NOTE: This function should only be called from a worker thread.\n *\n * @param configPath - The path to the studio config\n * @returns The workspaces\n * @internal\n */\nexport async function getStudioWorkspaces(configPath: string): Promise<Workspace[]> {\n if (isMainThread) {\n throw new Error('getStudioWorkspaces should only be called from a worker thread')\n }\n const isDirectory = (await stat(configPath)).isDirectory()\n if (isDirectory) {\n configPath = await findStudioConfigPath(configPath)\n }\n debug('Finding studio config path %s', configPath)\n let config = await doImport(configPath)\n\n debug('Imported config %o', config)\n if (!isStudioConfig(config)) {\n if (!('default' in config) || !isStudioConfig(config.default)) {\n debug('Invalid studio config format in \"%s\"', configPath)\n throw new TypeError(`Invalid studio config format in \"${configPath}\"`)\n }\n\n config = config.default\n }\n\n const workDir = dirname(configPath)\n debug('Work dir %s', workDir)\n const {resolveConfig} = await resolveLocalPackage<typeof import('sanity')>('sanity', workDir)\n if (typeof resolveConfig !== 'function') {\n throw new TypeError('Expected `resolveConfig` from `sanity` to be a function')\n }\n\n // We will also want to stub out some configuration - we don't need to resolve the\n // users' logged in state, for instance - so let's disable the auth implementation.\n const rawWorkspaces = Array.isArray(config)\n ? config\n : [{...config, basePath: config.basePath || '/', name: config.name || 'default'}]\n\n const emptyAuth = {state: of(getEmptyAuth())}\n\n const unauthedWorkspaces = rawWorkspaces.map((workspace) => ({\n ...workspace,\n auth: emptyAuth,\n }))\n\n debug('Unauthed workspaces %o', unauthedWorkspaces)\n\n return firstValueFrom(resolveConfig(unauthedWorkspaces))\n}\n"],"names":["stat","dirname","isMainThread","firstValueFrom","of","subdebug","doImport","getEmptyAuth","resolveLocalPackage","findStudioConfigPath","isStudioConfig","debug","getStudioWorkspaces","configPath","Error","isDirectory","config","default","TypeError","workDir","resolveConfig","rawWorkspaces","Array","isArray","basePath","name","emptyAuth","state","unauthedWorkspaces","map","workspace","auth"],"mappings":"AAAA,SAAQA,IAAI,QAAO,mBAAkB;AACrC,SAAQC,OAAO,QAAO,YAAW;AACjC,SAAQC,YAAY,QAAO,sBAAqB;AAEhD,SAAQC,cAAc,EAAEC,EAAE,QAAO,OAAM;AAGvC,SAAQC,QAAQ,QAAO,iBAAgB;AACvC,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,oBAAoB,QAAO,kCAAiC;AACpE,SAAQC,cAAc,QAAO,sBAAqB;AAElD,MAAMC,QAAQN,SAAS;AAEvB;;;;;;;;CAQC,GACD,OAAO,eAAeO,oBAAoBC,UAAkB;IAC1D,IAAIX,cAAc;QAChB,MAAM,IAAIY,MAAM;IAClB;IACA,MAAMC,cAAc,AAAC,CAAA,MAAMf,KAAKa,WAAU,EAAGE,WAAW;IACxD,IAAIA,aAAa;QACfF,aAAa,MAAMJ,qBAAqBI;IAC1C;IACAF,MAAM,iCAAiCE;IACvC,IAAIG,SAAS,MAAMV,SAASO;IAE5BF,MAAM,sBAAsBK;IAC5B,IAAI,CAACN,eAAeM,SAAS;QAC3B,IAAI,CAAE,CAAA,aAAaA,MAAK,KAAM,CAACN,eAAeM,OAAOC,OAAO,GAAG;YAC7DN,MAAM,wCAAwCE;YAC9C,MAAM,IAAIK,UAAU,CAAC,iCAAiC,EAAEL,WAAW,CAAC,CAAC;QACvE;QAEAG,SAASA,OAAOC,OAAO;IACzB;IAEA,MAAME,UAAUlB,QAAQY;IACxBF,MAAM,eAAeQ;IACrB,MAAM,EAACC,aAAa,EAAC,GAAG,MAAMZ,oBAA6C,UAAUW;IACrF,IAAI,OAAOC,kBAAkB,YAAY;QACvC,MAAM,IAAIF,UAAU;IACtB;IAEA,kFAAkF;IAClF,mFAAmF;IACnF,MAAMG,gBAAgBC,MAAMC,OAAO,CAACP,UAChCA,SACA;QAAC;YAAC,GAAGA,MAAM;YAAEQ,UAAUR,OAAOQ,QAAQ,IAAI;YAAKC,MAAMT,OAAOS,IAAI,IAAI;QAAS;KAAE;IAEnF,MAAMC,YAAY;QAACC,OAAOvB,GAAGG;IAAe;IAE5C,MAAMqB,qBAAqBP,cAAcQ,GAAG,CAAC,CAACC,YAAe,CAAA;YAC3D,GAAGA,SAAS;YACZC,MAAML;QACR,CAAA;IAEAf,MAAM,0BAA0BiB;IAEhC,OAAOzB,eAAeiB,cAAcQ;AACtC"}
1
+ {"version":3,"sources":["../../../src/config/studio/getStudioWorkspaces.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {dirname} from 'node:path'\nimport {isMainThread} from 'node:worker_threads'\n\nimport {firstValueFrom, of} from 'rxjs'\nimport {type Workspace} from 'sanity'\n\nimport {subdebug} from '../../_exports/debug.js'\nimport {doImport} from '../../util/doImport.js'\nimport {getEmptyAuth} from '../../util/getEmptyAuth.js'\nimport {resolveLocalPackage} from '../../util/resolveLocalPackage.js'\nimport {findStudioConfigPath} from '../util/findStudioConfigPath.js'\nimport {isStudioConfig} from './isStudioConfig.js'\n\nconst debug = subdebug('worker:getStudioWorkspaces')\n\n/**\n * Resolves the workspaces from the studio config.\n *\n * NOTE: This function should only be called from a worker thread.\n *\n * @param configPath - The path to the studio config\n * @returns The workspaces\n * @internal\n */\nexport async function getStudioWorkspaces(configPath: string): Promise<Workspace[]> {\n if (isMainThread) {\n throw new Error('getStudioWorkspaces should only be called from a worker thread')\n }\n const isDirectory = (await stat(configPath)).isDirectory()\n if (isDirectory) {\n configPath = await findStudioConfigPath(configPath)\n }\n debug('Finding studio config path %s', configPath)\n let config = await doImport(configPath)\n\n debug('Imported config %o', config)\n if (!isStudioConfig(config)) {\n if (!('default' in config) || !isStudioConfig(config.default)) {\n debug('Invalid studio config format in \"%s\"', configPath)\n throw new TypeError(`Invalid studio config format in \"${configPath}\"`)\n }\n\n config = config.default\n }\n\n const workDir = dirname(configPath)\n debug('Work dir %s', workDir)\n const {resolveConfig} = await resolveLocalPackage<typeof import('sanity')>('sanity', workDir)\n if (typeof resolveConfig !== 'function') {\n throw new TypeError('Expected `resolveConfig` from `sanity` to be a function')\n }\n\n // We will also want to stub out some configuration - we don't need to resolve the\n // users' logged in state, for instance - so let's disable the auth implementation.\n const rawWorkspaces = Array.isArray(config)\n ? config\n : [{...config, basePath: config.basePath || '/', name: config.name || 'default'}]\n\n const emptyAuth = {state: of(getEmptyAuth())}\n\n const unauthedWorkspaces = rawWorkspaces.map((workspace) => ({\n ...workspace,\n auth: emptyAuth,\n }))\n\n debug('Unauthed workspaces %o', unauthedWorkspaces)\n\n return firstValueFrom(resolveConfig(unauthedWorkspaces))\n}\n"],"names":["stat","dirname","isMainThread","firstValueFrom","of","subdebug","doImport","getEmptyAuth","resolveLocalPackage","findStudioConfigPath","isStudioConfig","debug","getStudioWorkspaces","configPath","Error","isDirectory","config","default","TypeError","workDir","resolveConfig","rawWorkspaces","Array","isArray","basePath","name","emptyAuth","state","unauthedWorkspaces","map","workspace","auth"],"mappings":"AAAA,SAAQA,IAAI,QAAO,mBAAkB;AACrC,SAAQC,OAAO,QAAO,YAAW;AACjC,SAAQC,YAAY,QAAO,sBAAqB;AAEhD,SAAQC,cAAc,EAAEC,EAAE,QAAO,OAAM;AAGvC,SAAQC,QAAQ,QAAO,0BAAyB;AAChD,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,oBAAoB,QAAO,kCAAiC;AACpE,SAAQC,cAAc,QAAO,sBAAqB;A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od/mini';
3
- import { subdebug } from '../../debug.js';
3
+ import { subdebug } from '../../_exports/debug.js';
4
4
  import { doImport } from '../../util/doImport.js';
5
5
  import { safeStructuredClone } from '../../util/safeStructuredClone.js';
6
6
  import { getStudioWorkspaces } from './getStudioWorkspaces.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/studio/readStudioConfig.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {z} from 'zod/mini'\n\nimport {subdebug} from '../../debug.js'\nimport {doImport} from '../../util/doImport.js'\nimport {safeStructuredClone} from '../../util/safeStructuredClone.js'\nimport {getStudioWorkspaces} from './getStudioWorkspaces.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst debug = subdebug('readStudioConfig.worker')\n\nconst {configPath, resolvePlugins} = z\n .object({configPath: z.string(), resolvePlugins: z.boolean()})\n .parse(workerData)\n\ndebug('Parsing config path %s', configPath)\n\nlet {default: config} = await doImport(configPath)\n\ndebug('Imported config %o', config)\n\nif (resolvePlugins) {\n debug('Resolving workspaces')\n config = await getStudioWorkspaces(configPath)\n debug('Resolved workspaces %o', config)\n}\n\nparentPort.postMessage(safeStructuredClone(config))\n"],"names":["isMainThread","parentPort","workerData","z","subdebug","doImport","safeStructuredClone","getStudioWorkspaces","Error","debug","configPath","resolvePlugins","object","string","boolean","parse","default","config","postMessage"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,CAAC,QAAO,WAAU;AAE1B,SAAQC,QAAQ,QAAO,iBAAgB;AACvC,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,mBAAmB,QAAO,2BAA0B;AAE5D,IAAIP,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIO,MAAM;AAClB;AAEA,MAAMC,QAAQL,SAAS;AAEvB,MAAM,EAACM,UAAU,EAAEC,cAAc,EAAC,GAAGR,EAClCS,MAAM,CAAC;IAACF,YAAYP,EAAEU,MAAM;IAAIF,gBAAgBR,EAAEW,OAAO;AAAE,GAC3DC,KAAK,CAACb;AAETO,MAAM,0BAA0BC;AAEhC,IAAI,EAACM,SAASC,MAAM,EAAC,GAAG,MAAMZ,SAASK;AAEvCD,MAAM,sBAAsBQ;AAE5B,IAAIN,gBAAgB;IAClBF,MAAM;IACNQ,SAAS,MAAMV,oBAAoBG;IACnCD,MAAM,0BAA0BQ;AAClC;AAEAhB,WAAWiB,WAAW,CAACZ,oBAAoBW"}
1
+ {"version":3,"sources":["../../../src/config/studio/readStudioConfig.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {z} from 'zod/mini'\n\nimport {subdebug} from '../../_exports/debug.js'\nimport {doImport} from '../../util/doImport.js'\nimport {safeStructuredClone} from '../../util/safeStructuredClone.js'\nimport {getStudioWorkspaces} from './getStudioWorkspaces.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst debug = subdebug('readStudioConfig.worker')\n\nconst {configPath, resolvePlugins} = z\n .object({configPath: z.string(), resolvePlugins: z.boolean()})\n .parse(workerData)\n\ndebug('Parsing config path %s', configPath)\n\nlet {default: config} = await doImport(configPath)\n\ndebug('Imported config %o', config)\n\nif (resolvePlugins) {\n debug('Resolving workspaces')\n config = await getStudioWorkspaces(configPath)\n debug('Resolved workspaces %o', config)\n}\n\nparentPort.postMessage(safeStructuredClone(config))\n"],"names":["isMainThread","parentPort","workerData","z","subdebug","doImport","safeStructuredClone","getStudioWorkspaces","Error","debug","configPath","resolvePlugins","object","string","boolean","parse","default","config","postMessage"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,CAAC,QAAO,WAAU;AAE1B,SAAQC,QAAQ,QAAO,0BAAyB;AAChD,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,mBAAmB,QAAO,2BAA0B;AAE5D,IAAIP,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIO,MAAM;AAClB;AAEA,MAAMC,QAAQL,SAAS;AAEvB,MAAM,EAACM,UAAU,EAAEC,cAAc,EAAC,GAAGR,EAClCS,MAAM,CAAC;IAACF,YAAYP,EAAEU,MAAM;IAAIF,gBAAgBR,EAAEW,OAAO;AAAE,GAC3DC,KAAK,CAACb;AAETO,MAAM,0BAA0BC;AAEhC,IAAI,EAACM,SAASC,MAAM,EAAC,GAAG,MAAMZ,SAASK;AAEvCD,MAAM,sBAAsBQ;AAE5B,IAAIN,gBAAgB;IAClBF,MAAM;IACNQ,SAAS,MAAMV,oBAAoBG;IACnCD,MAAM,0BAA0BQ;AAClC;AAEAhB,WAAWiB,WAAW,CAACZ,oBAAoBW"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Standard exit codes for CLI commands.
3
+ *
4
+ * - 0, 1, 2 align with oclif defaults and Unix convention.
5
+ * - 3 is application-defined (oclif does not use it).
6
+ * - 130 follows the Unix convention of 128 + signal number (SIGINT = 2).
7
+ *
8
+ * @see CLAUDE.md "Exit Code Convention" for usage guidance and examples.
9
+ */
10
+ export declare const exitCodes: {
11
+ /** Something went wrong that is not the user's fault (API errors, network, missing config, etc.). */
12
+ readonly RUNTIME_ERROR: 1;
13
+ /** The user interrupted via Ctrl+C (128 + SIGINT). Handled by SanityCommand.catch(). */
14
+ readonly SIGINT: 130;
15
+ /** Command completed normally. */
16
+ readonly SUCCESS: 0;
17
+ /** The user provided invalid input (bad args, unknown flags, validation failures). */
18
+ readonly USAGE_ERROR: 2;
19
+ /** The user declined a confirmation or chose not to proceed. */
20
+ readonly USER_ABORT: 3;
21
+ };
22
+
23
+ export {};
@@ -3,11 +3,11 @@ import { createServer, loadEnv, mergeConfig } from 'vite';
3
3
  import { ViteNodeRunner } from 'vite-node/client';
4
4
  import { ViteNodeServer } from 'vite-node/server';
5
5
  import { installSourcemapsSupport } from 'vite-node/source-map';
6
+ import { subdebug } from '../../_exports/debug.js';
6
7
  import { getCliConfig } from '../../config/cli/getCliConfig.js';
7
- import { subdebug } from '../../debug.js';
8
8
  import { isNotFoundError } from '../../errors/NotFoundError.js';
9
9
  import { getStudioEnvironmentVariables } from '../../util/environment/getStudioEnvironmentVariables.js';
10
- import { setupBrowserStubs } from '../../util/environment/setupBrowserStubs.js';
10
+ import { setupBrowserStubs } from '../../util/environment/setupBrowserStubs.js'; // TODO: this imports jsdom!!! Unpacked Size (module + dependencies): 26 MB
11
11
  import { isRecord } from '../../util/isRecord.js';
12
12
  if (isMainThread) {
13
13
  throw new Error('Should be child of thread, not the main thread');