@sanity/cli-core 0.0.2-alpha.3 → 0.1.0-alpha.11

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 (162) hide show
  1. package/dist/SanityCommand.js +34 -3
  2. package/dist/SanityCommand.js.map +1 -1
  3. package/dist/_exports/tree.d.ts +47 -0
  4. package/dist/_exports/tree.js +3 -0
  5. package/dist/_exports/tree.js.map +1 -0
  6. package/dist/_exports/ux.d.ts +44 -0
  7. package/dist/_exports/ux.js +7 -0
  8. package/dist/_exports/ux.js.map +1 -0
  9. package/dist/config/cli/getCliConfig.worker.js +2 -1
  10. package/dist/config/cli/getCliConfig.worker.js.map +1 -1
  11. package/dist/config/cli/schemas.js +5 -2
  12. package/dist/config/cli/schemas.js.map +1 -1
  13. package/dist/config/cli/types/cliConfig.js.map +1 -1
  14. package/dist/config/findProjectRoot.js +2 -2
  15. package/dist/config/findProjectRoot.js.map +1 -1
  16. package/dist/config/studio/getStudioConfig.js +0 -3
  17. package/dist/config/studio/getStudioConfig.js.map +1 -1
  18. package/dist/config/studio/getStudioWorkspaces.js +50 -0
  19. package/dist/config/studio/getStudioWorkspaces.js.map +1 -0
  20. package/dist/config/studio/isStudioConfig.js +19 -0
  21. package/dist/config/studio/isStudioConfig.js.map +1 -0
  22. package/dist/config/studio/readStudioConfig.js +13 -9
  23. package/dist/config/studio/readStudioConfig.js.map +1 -1
  24. package/dist/config/studio/readStudioConfig.worker.js +4 -30
  25. package/dist/config/studio/readStudioConfig.worker.js.map +1 -1
  26. package/dist/config/util/findStudioConfigPath.js +24 -3
  27. package/dist/config/util/findStudioConfigPath.js.map +1 -1
  28. package/dist/config/util/recursivelyResolveProjectRoot.js.map +1 -1
  29. package/dist/index.d.ts +6027 -36
  30. package/dist/index.js +14 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/loaders/studio/studioWorkerLoader.worker.js +10 -24
  33. package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -1
  34. package/dist/loaders/studio/studioWorkerTask.js +41 -11
  35. package/dist/loaders/studio/studioWorkerTask.js.map +1 -1
  36. package/dist/loaders/tsx/tsxWorkerTask.js +3 -0
  37. package/dist/loaders/tsx/tsxWorkerTask.js.map +1 -1
  38. package/dist/services/apiClient.js +18 -17
  39. package/dist/services/apiClient.js.map +1 -1
  40. package/dist/telemetry/cleanupOldTelemetryFiles.js +30 -0
  41. package/dist/telemetry/cleanupOldTelemetryFiles.js.map +1 -0
  42. package/dist/telemetry/createTelemetryStore.js +95 -0
  43. package/dist/telemetry/createTelemetryStore.js.map +1 -0
  44. package/dist/telemetry/createTraceId.js +10 -0
  45. package/dist/telemetry/createTraceId.js.map +1 -0
  46. package/dist/telemetry/findTelemetryFiles.js +36 -0
  47. package/dist/telemetry/findTelemetryFiles.js.map +1 -0
  48. package/dist/telemetry/flushTelemetryFiles.js +107 -0
  49. package/dist/telemetry/flushTelemetryFiles.js.map +1 -0
  50. package/dist/telemetry/generateTelemetryFilePath.js +30 -0
  51. package/dist/telemetry/generateTelemetryFilePath.js.map +1 -0
  52. package/dist/telemetry/getTelemetryBaseInfo.js +33 -0
  53. package/dist/telemetry/getTelemetryBaseInfo.js.map +1 -0
  54. package/dist/telemetry/logger.js +54 -0
  55. package/dist/telemetry/logger.js.map +1 -0
  56. package/dist/telemetry/telemetryStoreDebug.js +7 -0
  57. package/dist/telemetry/telemetryStoreDebug.js.map +1 -0
  58. package/dist/telemetry/trace.js +150 -0
  59. package/dist/telemetry/trace.js.map +1 -0
  60. package/dist/telemetry/types.js +5 -0
  61. package/dist/telemetry/types.js.map +1 -0
  62. package/dist/types.js +2 -0
  63. package/dist/types.js.map +1 -1
  64. package/dist/util/doImport.js +16 -0
  65. package/dist/util/doImport.js.map +1 -0
  66. package/dist/util/environment/getStudioEnvironmentVariables.js +2 -1
  67. package/dist/util/environment/getStudioEnvironmentVariables.js.map +1 -1
  68. package/dist/util/getCliTelemetry.js +36 -0
  69. package/dist/util/getCliTelemetry.js.map +1 -0
  70. package/dist/util/isStaging.js +10 -0
  71. package/dist/util/isStaging.js.map +1 -0
  72. package/dist/util/normalizePath.js +12 -0
  73. package/dist/util/normalizePath.js.map +1 -0
  74. package/dist/util/parseStringFlag.js +19 -0
  75. package/dist/util/parseStringFlag.js.map +1 -0
  76. package/dist/util/readNDJSON.js +18 -0
  77. package/dist/util/readNDJSON.js.map +1 -0
  78. package/dist/util/resolveLocalPackage.js +34 -0
  79. package/dist/util/resolveLocalPackage.js.map +1 -0
  80. package/dist/util/tree.js +108 -0
  81. package/dist/util/tree.js.map +1 -0
  82. package/dist/util/waitForAsync.js +5 -0
  83. package/dist/util/waitForAsync.js.map +1 -0
  84. package/dist/ux/boxen.js +3 -0
  85. package/dist/ux/boxen.js.map +1 -0
  86. package/dist/ux/chalk.js +4 -0
  87. package/dist/ux/chalk.js.map +1 -0
  88. package/dist/ux/colorizeJson.js +6 -6
  89. package/dist/ux/colorizeJson.js.map +1 -1
  90. package/dist/ux/prompts.js +3 -0
  91. package/dist/ux/prompts.js.map +1 -0
  92. package/dist/ux/spinner.js +1 -1
  93. package/dist/ux/spinner.js.map +1 -1
  94. package/package.json +53 -27
  95. package/dist/SanityCommand.d.ts +0 -56
  96. package/dist/config/__tests__/cliToken.test.js +0 -74
  97. package/dist/config/__tests__/cliToken.test.js.map +0 -1
  98. package/dist/config/__tests__/cliUserConfig.test.js +0 -131
  99. package/dist/config/__tests__/cliUserConfig.test.js.map +0 -1
  100. package/dist/config/__tests__/findProjectRoot.test.js +0 -159
  101. package/dist/config/__tests__/findProjectRoot.test.js.map +0 -1
  102. package/dist/config/__tests__/findProjectRootSync.test.js +0 -112
  103. package/dist/config/__tests__/findProjectRootSync.test.js.map +0 -1
  104. package/dist/config/__tests__/getCliConfigSync.test.js +0 -31
  105. package/dist/config/__tests__/getCliConfigSync.test.js.map +0 -1
  106. package/dist/config/cli/getCliConfig.d.ts +0 -16
  107. package/dist/config/cli/getCliConfig.worker.d.ts +0 -1
  108. package/dist/config/cli/getCliConfigSync.d.ts +0 -12
  109. package/dist/config/cli/schemas.d.ts +0 -255
  110. package/dist/config/cli/types/cliConfig.d.ts +0 -74
  111. package/dist/config/cli/types/userViteConfig.d.ts +0 -5
  112. package/dist/config/findProjectRoot.d.ts +0 -14
  113. package/dist/config/findProjectRootSync.d.ts +0 -27
  114. package/dist/config/studio/getStudioConfig.d.ts +0 -14
  115. package/dist/config/studio/readStudioConfig.d.ts +0 -190
  116. package/dist/config/studio/readStudioConfig.worker.d.ts +0 -1
  117. package/dist/config/util/configPathsSync.d.ts +0 -17
  118. package/dist/config/util/findAppConfigPath.d.ts +0 -8
  119. package/dist/config/util/findConfigsPaths.d.ts +0 -16
  120. package/dist/config/util/findStudioConfigPath.d.ts +0 -9
  121. package/dist/config/util/isSanityV2StudioRoot.d.ts +0 -8
  122. package/dist/config/util/recursivelyResolveProjectRoot.d.ts +0 -27
  123. package/dist/debug.d.ts +0 -15
  124. package/dist/loaders/studio/studioWorkerLoader.worker.d.ts +0 -1
  125. package/dist/loaders/studio/studioWorkerTask.d.ts +0 -40
  126. package/dist/loaders/tsx/tsxWorkerLoader.worker.d.ts +0 -1
  127. package/dist/loaders/tsx/tsxWorkerTask.d.ts +0 -28
  128. package/dist/services/apiClient.d.ts +0 -53
  129. package/dist/services/cliUserConfig.d.ts +0 -57
  130. package/dist/services/getCliToken.d.ts +0 -7
  131. package/dist/types.d.ts +0 -7
  132. package/dist/util/NotFoundError.d.ts +0 -20
  133. package/dist/util/__tests__/createExpiringConfig.test.js +0 -400
  134. package/dist/util/__tests__/createExpiringConfig.test.js.map +0 -1
  135. package/dist/util/createExpiringConfig.d.ts +0 -37
  136. package/dist/util/environment/getStudioEnvironmentVariables.d.ts +0 -12
  137. package/dist/util/environment/mockBrowserEnvironment.d.ts +0 -17
  138. package/dist/util/environment/setupBrowserStubs.d.ts +0 -10
  139. package/dist/util/environment/stubs.d.ts +0 -254
  140. package/dist/util/fileExists.d.ts +0 -9
  141. package/dist/util/generateHelpUrl.d.ts +0 -8
  142. package/dist/util/getEmptyAuth.d.ts +0 -5
  143. package/dist/util/getSanityEnvVar.d.ts +0 -19
  144. package/dist/util/getSanityUrl.d.ts +0 -5
  145. package/dist/util/getUserConfig.d.ts +0 -2
  146. package/dist/util/isCi.d.ts +0 -1
  147. package/dist/util/isHttpError.d.ts +0 -29
  148. package/dist/util/isHttpError.js +0 -18
  149. package/dist/util/isHttpError.js.map +0 -1
  150. package/dist/util/isInteractive.d.ts +0 -1
  151. package/dist/util/isRecord.d.ts +0 -8
  152. package/dist/util/isTrueish.d.ts +0 -1
  153. package/dist/util/readJsonFile.d.ts +0 -14
  154. package/dist/util/safeStructuredClone.d.ts +0 -8
  155. package/dist/util/tryGetDefaultExport.d.ts +0 -5
  156. package/dist/util/writeJsonFile.d.ts +0 -9
  157. package/dist/ux/colorizeJson.d.ts +0 -1
  158. package/dist/ux/formatObject.d.ts +0 -1
  159. package/dist/ux/logSymbols.d.ts +0 -1
  160. package/dist/ux/printKeyValue.d.ts +0 -1
  161. package/dist/ux/spinner.d.ts +0 -1
  162. package/dist/ux/timer.d.ts +0 -12
@@ -2,6 +2,8 @@ import { Command } from '@oclif/core';
2
2
  import { getCliConfig } from './config/cli/getCliConfig.js';
3
3
  import { findProjectRoot } from './config/findProjectRoot.js';
4
4
  import { getGlobalCliClient, getProjectCliClient } from './services/apiClient.js';
5
+ import { getCliTelemetry } from './util/getCliTelemetry.js';
6
+ import { isInteractive } from './util/isInteractive.js';
5
7
  export class SanityCommand extends Command {
6
8
  args;
7
9
  flags;
@@ -10,12 +12,16 @@ export class SanityCommand extends Command {
10
12
  *
11
13
  * @param args - The global API client options.
12
14
  * @returns The global API client.
15
+ *
16
+ * @deprecated use `getGlobalCliClient` function directly instead.
13
17
  */ getGlobalApiClient = (args)=>getGlobalCliClient(args);
14
18
  /**
15
19
  * Get the project API client.
16
20
  *
17
21
  * @param args - The project API client options.
18
22
  * @returns The project API client.
23
+ *
24
+ * @deprecated use `getProjectCliClient` function directly instead.
19
25
  */ getProjectApiClient = (args)=>getProjectCliClient(args);
20
26
  /**
21
27
  * Helper for outputting to the console.
@@ -32,13 +38,17 @@ export class SanityCommand extends Command {
32
38
  warn: this.warn.bind(this)
33
39
  };
34
40
  /**
41
+ * The telemetry store.
42
+ *
43
+ * @returns The telemetry store.
44
+ */ telemetry;
45
+ /**
35
46
  * Get the CLI config.
36
47
  *
37
48
  * @returns The CLI config.
38
49
  */ async getCliConfig() {
39
50
  const root = await this.getProjectRoot();
40
- const config = await getCliConfig(root.directory);
41
- return config;
51
+ return getCliConfig(root.directory);
42
52
  }
43
53
  /**
44
54
  * Get the project ID from the CLI config.
@@ -51,7 +61,7 @@ export class SanityCommand extends Command {
51
61
  /**
52
62
  * Get the project's root directory by resolving the config
53
63
  *
54
- * @returns The root project root.
64
+ * @returns The project root result.
55
65
  */ getProjectRoot() {
56
66
  return findProjectRoot(process.cwd());
57
67
  }
@@ -65,8 +75,29 @@ export class SanityCommand extends Command {
65
75
  });
66
76
  this.args = args;
67
77
  this.flags = flags;
78
+ this.telemetry = getCliTelemetry();
68
79
  await super.init();
69
80
  }
81
+ /**
82
+ * Check if the command is running in unattended mode.
83
+ *
84
+ * This means the command should not ask for user input, instead using defaults where
85
+ * possible, and if that does not make sense (eg there's missing information), then we
86
+ * should error out (remember to exit with a non-zero code).
87
+ *
88
+ * Most commands should take an explicit `--yes` flag to enable unattended mode, but
89
+ * some commands may also be run in unattended mode if `process.stdin` is not a TTY
90
+ * (eg when running in a CI environment).
91
+ */ isUnattended() {
92
+ return this.flags.yes || !this.resolveIsInteractive();
93
+ }
94
+ /**
95
+ * Resolver for checking if the terminal is interactive. Override in tests to provide mock values.
96
+ *
97
+ * @returns Whether the terminal is interactive.
98
+ */ resolveIsInteractive() {
99
+ return isInteractive();
100
+ }
70
101
  }
71
102
 
72
103
  //# sourceMappingURL=SanityCommand.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/SanityCommand.ts"],"sourcesContent":["import {Command, Interfaces} from '@oclif/core'\n\nimport {getCliConfig} from './config/cli/getCliConfig.js'\nimport {type CliConfig} from './config/cli/types/cliConfig.js'\nimport {findProjectRoot} from './config/findProjectRoot.js'\nimport {type ProjectRootResult} from './config/util/recursivelyResolveProjectRoot.js'\nimport {\n getGlobalCliClient,\n getProjectCliClient,\n type GlobalCliClientOptions,\n type ProjectCliClientOptions,\n} from './services/apiClient.js'\nimport {type Output} from './types.js'\n\ntype Flags<T extends typeof Command> = Interfaces.InferredFlags<\n (typeof SanityCommand)['baseFlags'] & T['flags']\n>\n\ntype Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>\n\nexport abstract class SanityCommand<T extends typeof Command> extends Command {\n protected args!: Args<T>\n protected flags!: Flags<T>\n\n /**\n * Get the global API client.\n *\n * @param args - The global API client options.\n * @returns The global API client.\n */\n protected getGlobalApiClient = (args: GlobalCliClientOptions) => getGlobalCliClient(args)\n\n /**\n * Get the project API client.\n *\n * @param args - The project API client options.\n * @returns The project API client.\n */\n protected getProjectApiClient = (args: ProjectCliClientOptions) => getProjectCliClient(args)\n\n /**\n * Helper for outputting to the console.\n *\n * @example\n * ```ts\n * this.output.log('Hello')\n * this.output.warn('Warning')\n * this.output.error('Error')\n * ```\n */\n protected output: Output = {\n error: this.error.bind(this),\n log: this.log.bind(this),\n warn: this.warn.bind(this),\n }\n\n /**\n * Get the CLI config.\n *\n * @returns The CLI config.\n */\n protected async getCliConfig(): Promise<CliConfig> {\n const root = await this.getProjectRoot()\n const config = await getCliConfig(root.directory)\n\n return config\n }\n\n /**\n * Get the project ID from the CLI config.\n *\n * @returns The project ID or `undefined` if it's not set.\n */\n protected async getProjectId(): Promise<string | undefined> {\n const config = await this.getCliConfig()\n\n return config.api?.projectId\n }\n\n /**\n * Get the project's root directory by resolving the config\n *\n * @returns The root project root.\n */\n protected getProjectRoot(): Promise<ProjectRootResult> {\n return findProjectRoot(process.cwd())\n }\n\n public async init(): Promise<void> {\n const {args, flags} = await this.parse({\n args: this.ctor.args,\n baseFlags: (super.ctor as typeof SanityCommand).baseFlags,\n enableJsonFlag: this.ctor.enableJsonFlag,\n flags: this.ctor.flags,\n strict: this.ctor.strict,\n })\n\n this.args = args as Args<T>\n this.flags = flags as Flags<T>\n\n await super.init()\n }\n}\n"],"names":["Command","getCliConfig","findProjectRoot","getGlobalCliClient","getProjectCliClient","SanityCommand","args","flags","getGlobalApiClient","getProjectApiClient","output","error","bind","log","warn","root","getProjectRoot","config","directory","getProjectId","api","projectId","process","cwd","init","parse","ctor","baseFlags","enableJsonFlag","strict"],"mappings":"AAAA,SAAQA,OAAO,QAAmB,cAAa;AAE/C,SAAQC,YAAY,QAAO,+BAA8B;AAEzD,SAAQC,eAAe,QAAO,8BAA6B;AAE3D,SACEC,kBAAkB,EAClBC,mBAAmB,QAGd,0BAAyB;AAShC,OAAO,MAAeC,sBAAgDL;IAC1DM,KAAc;IACdC,MAAgB;IAE1B;;;;;GAKC,GACD,AAAUC,qBAAqB,CAACF,OAAiCH,mBAAmBG,MAAK;IAEzF;;;;;GAKC,GACD,AAAUG,sBAAsB,CAACH,OAAkCF,oBAAoBE,MAAK;IAE5F;;;;;;;;;GASC,GACD,AAAUI,SAAiB;QACzBC,OAAO,IAAI,CAACA,KAAK,CAACC,IAAI,CAAC,IAAI;QAC3BC,KAAK,IAAI,CAACA,GAAG,CAACD,IAAI,CAAC,IAAI;QACvBE,MAAM,IAAI,CAACA,IAAI,CAACF,IAAI,CAAC,IAAI;IAC3B,EAAC;IAED;;;;GAIC,GACD,MAAgBX,eAAmC;QACjD,MAAMc,OAAO,MAAM,IAAI,CAACC,cAAc;QACtC,MAAMC,SAAS,MAAMhB,aAAac,KAAKG,SAAS;QAEhD,OAAOD;IACT;IAEA;;;;GAIC,GACD,MAAgBE,eAA4C;QAC1D,MAAMF,SAAS,MAAM,IAAI,CAAChB,YAAY;QAEtC,OAAOgB,OAAOG,GAAG,EAAEC;IACrB;IAEA;;;;GAIC,GACD,AAAUL,iBAA6C;QACrD,OAAOd,gBAAgBoB,QAAQC,GAAG;IACpC;IAEA,MAAaC,OAAsB;QACjC,MAAM,EAAClB,IAAI,EAAEC,KAAK,EAAC,GAAG,MAAM,IAAI,CAACkB,KAAK,CAAC;YACrCnB,MAAM,IAAI,CAACoB,IAAI,CAACpB,IAAI;YACpBqB,WAAW,AAAC,KAAK,CAACD,KAA8BC,SAAS;YACzDC,gBAAgB,IAAI,CAACF,IAAI,CAACE,cAAc;YACxCrB,OAAO,IAAI,CAACmB,IAAI,CAACnB,KAAK;YACtBsB,QAAQ,IAAI,CAACH,IAAI,CAACG,MAAM;QAC1B;QAEA,IAAI,CAACvB,IAAI,GAAGA;QACZ,IAAI,CAACC,KAAK,GAAGA;QAEb,MAAM,KAAK,CAACiB;IACd;AACF"}
1
+ {"version":3,"sources":["../src/SanityCommand.ts"],"sourcesContent":["import {Command, Interfaces} from '@oclif/core'\n\nimport {getCliConfig} from './config/cli/getCliConfig.js'\nimport {type CliConfig} from './config/cli/types/cliConfig.js'\nimport {findProjectRoot} from './config/findProjectRoot.js'\nimport {type ProjectRootResult} from './config/util/recursivelyResolveProjectRoot.js'\nimport {\n getGlobalCliClient,\n getProjectCliClient,\n type GlobalCliClientOptions,\n type ProjectCliClientOptions,\n} from './services/apiClient.js'\nimport {type CLITelemetryStore} from './telemetry/types.js'\nimport {type Output} from './types.js'\nimport {getCliTelemetry} from './util/getCliTelemetry.js'\nimport {isInteractive} from './util/isInteractive.js'\n\ntype Flags<T extends typeof Command> = Interfaces.InferredFlags<\n (typeof SanityCommand)['baseFlags'] & T['flags']\n>\n\ntype Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>\n\nexport abstract class SanityCommand<T extends typeof Command> extends Command {\n protected args!: Args<T>\n protected flags!: Flags<T>\n\n /**\n * Get the global API client.\n *\n * @param args - The global API client options.\n * @returns The global API client.\n *\n * @deprecated use `getGlobalCliClient` function directly instead.\n */\n protected getGlobalApiClient = (args: GlobalCliClientOptions) => getGlobalCliClient(args)\n\n /**\n * Get the project API client.\n *\n * @param args - The project API client options.\n * @returns The project API client.\n *\n * @deprecated use `getProjectCliClient` function directly instead.\n */\n protected getProjectApiClient = (args: ProjectCliClientOptions) => getProjectCliClient(args)\n\n /**\n * Helper for outputting to the console.\n *\n * @example\n * ```ts\n * this.output.log('Hello')\n * this.output.warn('Warning')\n * this.output.error('Error')\n * ```\n */\n protected output: Output = {\n error: this.error.bind(this),\n log: this.log.bind(this),\n warn: this.warn.bind(this),\n }\n\n /**\n * The telemetry store.\n *\n * @returns The telemetry store.\n */\n protected telemetry!: CLITelemetryStore\n\n /**\n * Get the CLI config.\n *\n * @returns The CLI config.\n */\n protected async getCliConfig(): Promise<CliConfig> {\n const root = await this.getProjectRoot()\n\n return getCliConfig(root.directory)\n }\n\n /**\n * Get the project ID from the CLI config.\n *\n * @returns The project ID or `undefined` if it's not set.\n */\n protected async getProjectId(): Promise<string | undefined> {\n const config = await this.getCliConfig()\n\n return config.api?.projectId\n }\n\n /**\n * Get the project's root directory by resolving the config\n *\n * @returns The project root result.\n */\n protected getProjectRoot(): Promise<ProjectRootResult> {\n return findProjectRoot(process.cwd())\n }\n\n public async init(): Promise<void> {\n const {args, flags} = await this.parse({\n args: this.ctor.args,\n baseFlags: (super.ctor as typeof SanityCommand).baseFlags,\n enableJsonFlag: this.ctor.enableJsonFlag,\n flags: this.ctor.flags,\n strict: this.ctor.strict,\n })\n\n this.args = args as Args<T>\n this.flags = flags as Flags<T>\n this.telemetry = getCliTelemetry()\n\n await super.init()\n }\n\n /**\n * Check if the command is running in unattended mode.\n *\n * This means the command should not ask for user input, instead using defaults where\n * possible, and if that does not make sense (eg there's missing information), then we\n * should error out (remember to exit with a non-zero code).\n *\n * Most commands should take an explicit `--yes` flag to enable unattended mode, but\n * some commands may also be run in unattended mode if `process.stdin` is not a TTY\n * (eg when running in a CI environment).\n */\n protected isUnattended(): boolean {\n return this.flags.yes || !this.resolveIsInteractive()\n }\n\n /**\n * Resolver for checking if the terminal is interactive. Override in tests to provide mock values.\n *\n * @returns Whether the terminal is interactive.\n */\n protected resolveIsInteractive(): boolean {\n return isInteractive()\n }\n}\n"],"names":["Command","getCliConfig","findProjectRoot","getGlobalCliClient","getProjectCliClient","getCliTelemetry","isInteractive","SanityCommand","args","flags","getGlobalApiClient","getProjectApiClient","output","error","bind","log","warn","telemetry","root","getProjectRoot","directory","getProjectId","config","api","projectId","process","cwd","init","parse","ctor","baseFlags","enableJsonFlag","strict","isUnattended","yes","resolveIsInteractive"],"mappings":"AAAA,SAAQA,OAAO,QAAmB,cAAa;AAE/C,SAAQC,YAAY,QAAO,+BAA8B;AAEzD,SAAQC,eAAe,QAAO,8BAA6B;AAE3D,SACEC,kBAAkB,EAClBC,mBAAmB,QAGd,0BAAyB;AAGhC,SAAQC,eAAe,QAAO,4BAA2B;AACzD,SAAQC,aAAa,QAAO,0BAAyB;AAQrD,OAAO,MAAeC,sBAAgDP;IAC1DQ,KAAc;IACdC,MAAgB;IAE1B;;;;;;;GAOC,GACD,AAAUC,qBAAqB,CAACF,OAAiCL,mBAAmBK,MAAK;IAEzF;;;;;;;GAOC,GACD,AAAUG,sBAAsB,CAACH,OAAkCJ,oBAAoBI,MAAK;IAE5F;;;;;;;;;GASC,GACD,AAAUI,SAAiB;QACzBC,OAAO,IAAI,CAACA,KAAK,CAACC,IAAI,CAAC,IAAI;QAC3BC,KAAK,IAAI,CAACA,GAAG,CAACD,IAAI,CAAC,IAAI;QACvBE,MAAM,IAAI,CAACA,IAAI,CAACF,IAAI,CAAC,IAAI;IAC3B,EAAC;IAED;;;;GAIC,GACD,AAAUG,UAA6B;IAEvC;;;;GAIC,GACD,MAAgBhB,eAAmC;QACjD,MAAMiB,OAAO,MAAM,IAAI,CAACC,cAAc;QAEtC,OAAOlB,aAAaiB,KAAKE,SAAS;IACpC;IAEA;;;;GAIC,GACD,MAAgBC,eAA4C;QAC1D,MAAMC,SAAS,MAAM,IAAI,CAACrB,YAAY;QAEtC,OAAOqB,OAAOC,GAAG,EAAEC;IACrB;IAEA;;;;GAIC,GACD,AAAUL,iBAA6C;QACrD,OAAOjB,gBAAgBuB,QAAQC,GAAG;IACpC;IAEA,MAAaC,OAAsB;QACjC,MAAM,EAACnB,IAAI,EAAEC,KAAK,EAAC,GAAG,MAAM,IAAI,CAACmB,KAAK,CAAC;YACrCpB,MAAM,IAAI,CAACqB,IAAI,CAACrB,IAAI;YACpBsB,WAAW,AAAC,KAAK,CAACD,KAA8BC,SAAS;YACzDC,gBAAgB,IAAI,CAACF,IAAI,CAACE,cAAc;YACxCtB,OAAO,IAAI,CAACoB,IAAI,CAACpB,KAAK;YACtBuB,QAAQ,IAAI,CAACH,IAAI,CAACG,MAAM;QAC1B;QAEA,IAAI,CAACxB,IAAI,GAAGA;QACZ,IAAI,CAACC,KAAK,GAAGA;QACb,IAAI,CAACQ,SAAS,GAAGZ;QAEjB,MAAM,KAAK,CAACsB;IACd;IAEA;;;;;;;;;;GAUC,GACD,AAAUM,eAAwB;QAChC,OAAO,IAAI,CAACxB,KAAK,CAACyB,GAAG,IAAI,CAAC,IAAI,CAACC,oBAAoB;IACrD;IAEA;;;;GAIC,GACD,AAAUA,uBAAgC;QACxC,OAAO7B;IACT;AACF"}
@@ -0,0 +1,47 @@
1
+ import {Path} from '@sanity/types'
2
+
3
+ declare interface BaseNode {
4
+ path: Path
5
+ }
6
+
7
+ /**
8
+ * Converts a set of markers with paths into a tree of markers where the paths
9
+ * are embedded in the tree
10
+ */
11
+ export declare function convertToTree<const Node extends BaseNode>(nodes: Node[]): Tree<Node>
12
+
13
+ /**
14
+ * Recursively formats a given tree into a printed user-friendly tree structure
15
+ */
16
+ export declare const formatTree: <Node extends BaseNode>({
17
+ getMessage,
18
+ getNodes: getLeaves,
19
+ indent,
20
+ node,
21
+ paddingLength,
22
+ }: Options<Node>) => string
23
+
24
+ /**
25
+ * Recursively calculates the max length of all the keys in the given validation
26
+ * tree respecting extra length due to indentation depth. Used to calculate the
27
+ * padding for the rest of the tree.
28
+ */
29
+ export declare const maxKeyLength: (
30
+ children?: Record<string, Tree<BaseNode>>,
31
+ depth?: number,
32
+ ) => number
33
+
34
+ declare interface Options<Node extends BaseNode> {
35
+ getMessage: (node: Node) => string
36
+ paddingLength: number
37
+ getNodes?: (node: Tree<Node>) => Node[] | undefined
38
+ indent?: string
39
+ node?: Record<string, Tree<Node>>
40
+ }
41
+
42
+ export declare interface Tree<Node extends BaseNode> {
43
+ children?: Record<string, Tree<Node>>
44
+ nodes?: Node[]
45
+ }
46
+
47
+ export {}
@@ -0,0 +1,3 @@
1
+ export * from '../util/tree.js';
2
+
3
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/_exports/tree.ts"],"sourcesContent":["export * from '../util/tree.js'\n"],"names":[],"mappings":"AAAA,cAAc,kBAAiB"}
@@ -0,0 +1,44 @@
1
+ import {default as boxen} from 'boxen'
2
+ import {Options as BoxenOptions} from 'boxen'
3
+ import {Boxes} from 'boxen'
4
+ import {default as chalk} from 'chalk'
5
+ import {CustomBorderStyle} from 'boxen'
6
+ import {default as logSymbols} from 'log-symbols'
7
+ import {Spacing} from 'boxen'
8
+ import {Spinner} from 'ora'
9
+ import {default as spinner} from 'ora'
10
+ import {Ora as SpinnerInstance} from 'ora'
11
+ import {Options as SpinnerOptions} from 'ora'
12
+ import {oraPromise as spinnerPromise} from 'ora'
13
+ import {PromiseOptions as SpinnerPromiseOptions} from 'ora'
14
+
15
+ export {boxen}
16
+
17
+ export {BoxenOptions}
18
+
19
+ export {Boxes}
20
+
21
+ export {chalk}
22
+
23
+ export {CustomBorderStyle}
24
+
25
+ export {logSymbols}
26
+
27
+ export {Spacing}
28
+
29
+ export {Spinner}
30
+
31
+ export {spinner}
32
+
33
+ export {SpinnerInstance}
34
+
35
+ export {SpinnerOptions}
36
+
37
+ export {spinnerPromise}
38
+
39
+ export {SpinnerPromiseOptions}
40
+
41
+ export * from '@inquirer/prompts'
42
+ export * from 'chalk'
43
+
44
+ export {}
@@ -0,0 +1,7 @@
1
+ export * from '../ux/boxen.js';
2
+ export * from '../ux/chalk.js';
3
+ export * from '../ux/logSymbols.js';
4
+ export * from '../ux/prompts.js';
5
+ export * from '../ux/spinner.js';
6
+
7
+ //# sourceMappingURL=ux.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/_exports/ux.ts"],"sourcesContent":["export * from '../ux/boxen.js'\nexport * from '../ux/chalk.js'\nexport * from '../ux/logSymbols.js'\nexport * from '../ux/prompts.js'\nexport * from '../ux/spinner.js'\n"],"names":[],"mappings":"AAAA,cAAc,iBAAgB;AAC9B,cAAc,iBAAgB;AAC9B,cAAc,sBAAqB;AACnC,cAAc,mBAAkB;AAChC,cAAc,mBAAkB"}
@@ -1,12 +1,13 @@
1
1
  import { isMainThread, parentPort, workerData } from 'node:worker_threads';
2
2
  import { z } from 'zod';
3
+ import { doImport } from '../../util/doImport.js';
3
4
  if (isMainThread || !parentPort) {
4
5
  throw new Error('Should only be run in a worker!');
5
6
  }
6
7
  const { configPath } = z.object({
7
8
  configPath: z.string()
8
9
  }).parse(workerData);
9
- const { default: loadedConfig } = await import(configPath);
10
+ const { default: loadedConfig } = await doImport(configPath);
10
11
  // This might throw on unserializable properties, but that's actually wanted in this
11
12
  // case, since we _need_ any unserializable props (such as vite config functions)
12
13
  parentPort.postMessage(loadedConfig);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/cli/getCliConfig.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {z} from 'zod'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst {configPath} = z.object({configPath: z.string()}).parse(workerData)\n\nconst {default: loadedConfig} = await import(configPath)\n\n// This might throw on unserializable properties, but that's actually wanted in this\n// case, since we _need_ any unserializable props (such as vite config functions)\nparentPort.postMessage(loadedConfig)\n"],"names":["isMainThread","parentPort","workerData","z","Error","configPath","object","string","parse","default","loadedConfig","postMessage"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,CAAC,QAAO,MAAK;AAErB,IAAIH,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIG,MAAM;AAClB;AAEA,MAAM,EAACC,UAAU,EAAC,GAAGF,EAAEG,MAAM,CAAC;IAACD,YAAYF,EAAEI,MAAM;AAAE,GAAGC,KAAK,CAACN;AAE9D,MAAM,EAACO,SAASC,YAAY,EAAC,GAAG,MAAM,MAAM,CAACL;AAE7C,oFAAoF;AACpF,iFAAiF;AACjFJ,WAAWU,WAAW,CAACD"}
1
+ {"version":3,"sources":["../../../src/config/cli/getCliConfig.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {z} from 'zod'\n\nimport {doImport} from '../../util/doImport.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst {configPath} = z.object({configPath: z.string()}).parse(workerData)\n\nconst {default: loadedConfig} = await doImport(configPath)\n\n// This might throw on unserializable properties, but that's actually wanted in this\n// case, since we _need_ any unserializable props (such as vite config functions)\nparentPort.postMessage(loadedConfig)\n"],"names":["isMainThread","parentPort","workerData","z","doImport","Error","configPath","object","string","parse","default","loadedConfig","postMessage"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,CAAC,QAAO,MAAK;AAErB,SAAQC,QAAQ,QAAO,yBAAwB;AAE/C,IAAIJ,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAII,MAAM;AAClB;AAEA,MAAM,EAACC,UAAU,EAAC,GAAGH,EAAEI,MAAM,CAAC;IAACD,YAAYH,EAAEK,MAAM;AAAE,GAAGC,KAAK,CAACP;AAE9D,MAAM,EAACQ,SAASC,YAAY,EAAC,GAAG,MAAMP,SAASE;AAE/C,oFAAoF;AACpF,iFAAiF;AACjFL,WAAWW,WAAW,CAACD"}
@@ -8,8 +8,10 @@ import { z } from 'zod';
8
8
  }).optional(),
9
9
  app: z.object({
10
10
  entry: z.string().optional(),
11
+ icon: z.string().optional(),
11
12
  id: z.string().optional(),
12
- organizationId: z.string().optional()
13
+ organizationId: z.string().optional(),
14
+ title: z.string().optional()
13
15
  }).optional(),
14
16
  autoUpdates: z.boolean().optional(),
15
17
  deployment: z.object({
@@ -43,7 +45,8 @@ import { z } from 'zod';
43
45
  port: z.number().optional()
44
46
  }).optional(),
45
47
  studioHost: z.string().optional(),
46
- vite: z.custom().optional()
48
+ vite: z.custom().optional(),
49
+ typegen: z.custom().optional()
47
50
  });
48
51
 
49
52
  //# sourceMappingURL=schemas.js.map
@@ -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'\n\nimport {type CliConfig} from './types/cliConfig'\nimport {type UserViteConfig} from './types/userViteConfig'\n\n/**\n * @public\n */\nexport const cliConfigSchema = z.object({\n api: z\n .object({\n dataset: z.string().optional(),\n projectId: z.string().optional(),\n })\n .optional(),\n\n app: z\n .object({\n entry: z.string().optional(),\n id: z.string().optional(),\n organizationId: z.string().optional(),\n })\n .optional(),\n\n autoUpdates: z.boolean().optional(),\n\n deployment: z\n .object({\n appId: z.string().optional(),\n autoUpdates: z.boolean().optional(),\n })\n .optional(),\n\n graphql: z\n .array(\n z.object({\n filterSuffix: z.string().optional(),\n generation: z.enum(['gen1', 'gen2', 'gen3']).optional(),\n id: z.string().optional(),\n nonNullDocumentFields: z.boolean().optional(),\n playground: z.boolean().optional(),\n source: z.string().optional(),\n tag: z.string().optional(),\n workspace: z.string().optional(),\n }),\n )\n .optional(),\n\n mediaLibrary: z\n .object({\n aspectsPath: z.string().optional(),\n })\n .optional(),\n\n project: z\n .object({\n basePath: z.string().optional(),\n })\n .optional(),\n\n reactCompiler: z.custom<ReactCompilerConfig>().optional(),\n\n reactStrictMode: z.boolean().optional(),\n\n server: z\n .object({\n hostname: z.string().optional(),\n port: z.number().optional(),\n })\n .optional(),\n\n studioHost: z.string().optional(),\n\n vite: z.custom<UserViteConfig>().optional(),\n}) satisfies z.ZodType<CliConfig>\n"],"names":["z","cliConfigSchema","object","api","dataset","string","optional","projectId","app","entry","id","organizationId","autoUpdates","boolean","deployment","appId","graphql","array","filterSuffix","generation","enum","nonNullDocumentFields","playground","source","tag","workspace","mediaLibrary","aspectsPath","project","basePath","reactCompiler","custom","reactStrictMode","server","hostname","port","number","studioHost","vite"],"mappings":"AACA,SAAQA,CAAC,QAAO,MAAK;AAKrB;;CAEC,GACD,OAAO,MAAMC,kBAAkBD,EAAEE,MAAM,CAAC;IACtCC,KAAKH,EACFE,MAAM,CAAC;QACNE,SAASJ,EAAEK,MAAM,GAAGC,QAAQ;QAC5BC,WAAWP,EAAEK,MAAM,GAAGC,QAAQ;IAChC,GACCA,QAAQ;IAEXE,KAAKR,EACFE,MAAM,CAAC;QACNO,OAAOT,EAAEK,MAAM,GAAGC,QAAQ;QAC1BI,IAAIV,EAAEK,MAAM,GAAGC,QAAQ;QACvBK,gBAAgBX,EAAEK,MAAM,GAAGC,QAAQ;IACrC,GACCA,QAAQ;IAEXM,aAAaZ,EAAEa,OAAO,GAAGP,QAAQ;IAEjCQ,YAAYd,EACTE,MAAM,CAAC;QACNa,OAAOf,EAAEK,MAAM,GAAGC,QAAQ;QAC1BM,aAAaZ,EAAEa,OAAO,GAAGP,QAAQ;IACnC,GACCA,QAAQ;IAEXU,SAAShB,EACNiB,KAAK,CACJjB,EAAEE,MAAM,CAAC;QACPgB,cAAclB,EAAEK,MAAM,GAAGC,QAAQ;QACjCa,YAAYnB,EAAEoB,IAAI,CAAC;YAAC;YAAQ;YAAQ;SAAO,EAAEd,QAAQ;QACrDI,IAAIV,EAAEK,MAAM,GAAGC,QAAQ;QACvBe,uBAAuBrB,EAAEa,OAAO,GAAGP,QAAQ;QAC3CgB,YAAYtB,EAAEa,OAAO,GAAGP,QAAQ;QAChCiB,QAAQvB,EAAEK,MAAM,GAAGC,QAAQ;QAC3BkB,KAAKxB,EAAEK,MAAM,GAAGC,QAAQ;QACxBmB,WAAWzB,EAAEK,MAAM,GAAGC,QAAQ;IAChC,IAEDA,QAAQ;IAEXoB,cAAc1B,EACXE,MAAM,CAAC;QACNyB,aAAa3B,EAAEK,MAAM,GAAGC,QAAQ;IAClC,GACCA,QAAQ;IAEXsB,SAAS5B,EACNE,MAAM,CAAC;QACN2B,UAAU7B,EAAEK,MAAM,GAAGC,QAAQ;IAC/B,GACCA,QAAQ;IAEXwB,eAAe9B,EAAE+B,MAAM,GAAwBzB,QAAQ;IAEvD0B,iBAAiBhC,EAAEa,OAAO,GAAGP,QAAQ;IAErC2B,QAAQjC,EACLE,MAAM,CAAC;QACNgC,UAAUlC,EAAEK,MAAM,GAAGC,QAAQ;QAC7B6B,MAAMnC,EAAEoC,MAAM,GAAG9B,QAAQ;IAC3B,GACCA,QAAQ;IAEX+B,YAAYrC,EAAEK,MAAM,GAAGC,QAAQ;IAE/BgC,MAAMtC,EAAE+B,MAAM,GAAmBzB,QAAQ;AAC3C,GAAiC"}
1
+ {"version":3,"sources":["../../../src/config/cli/schemas.ts"],"sourcesContent":["import {type TypeGenConfig} from '@sanity/codegen'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {z} from 'zod'\n\nimport {type CliConfig} from './types/cliConfig'\nimport {type UserViteConfig} from './types/userViteConfig'\n\n/**\n * @public\n */\nexport const cliConfigSchema = z.object({\n api: z\n .object({\n dataset: z.string().optional(),\n projectId: z.string().optional(),\n })\n .optional(),\n\n app: z\n .object({\n entry: z.string().optional(),\n icon: z.string().optional(),\n id: z.string().optional(),\n organizationId: z.string().optional(),\n title: z.string().optional(),\n })\n .optional(),\n\n autoUpdates: z.boolean().optional(),\n\n deployment: z\n .object({\n appId: z.string().optional(),\n autoUpdates: z.boolean().optional(),\n })\n .optional(),\n\n graphql: z\n .array(\n z.object({\n filterSuffix: z.string().optional(),\n generation: z.enum(['gen1', 'gen2', 'gen3']).optional(),\n id: z.string().optional(),\n nonNullDocumentFields: z.boolean().optional(),\n playground: z.boolean().optional(),\n source: z.string().optional(),\n tag: z.string().optional(),\n workspace: z.string().optional(),\n }),\n )\n .optional(),\n\n mediaLibrary: z\n .object({\n aspectsPath: z.string().optional(),\n })\n .optional(),\n\n project: z\n .object({\n basePath: z.string().optional(),\n })\n .optional(),\n\n reactCompiler: z.custom<ReactCompilerConfig>().optional(),\n\n reactStrictMode: z.boolean().optional(),\n\n server: z\n .object({\n hostname: z.string().optional(),\n port: z.number().optional(),\n })\n .optional(),\n\n studioHost: z.string().optional(),\n\n vite: z.custom<UserViteConfig>().optional(),\n\n typegen: z.custom<TypeGenConfig>().optional(),\n}) satisfies z.ZodType<CliConfig>\n"],"names":["z","cliConfigSchema","object","api","dataset","string","optional","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","server","hostname","port","number","studioHost","vite","typegen"],"mappings":"AAEA,SAAQA,CAAC,QAAO,MAAK;AAKrB;;CAEC,GACD,OAAO,MAAMC,kBAAkBD,EAAEE,MAAM,CAAC;IACtCC,KAAKH,EACFE,MAAM,CAAC;QACNE,SAASJ,EAAEK,MAAM,GAAGC,QAAQ;QAC5BC,WAAWP,EAAEK,MAAM,GAAGC,QAAQ;IAChC,GACCA,QAAQ;IAEXE,KAAKR,EACFE,MAAM,CAAC;QACNO,OAAOT,EAAEK,MAAM,GAAGC,QAAQ;QAC1BI,MAAMV,EAAEK,MAAM,GAAGC,QAAQ;QACzBK,IAAIX,EAAEK,MAAM,GAAGC,QAAQ;QACvBM,gBAAgBZ,EAAEK,MAAM,GAAGC,QAAQ;QACnCO,OAAOb,EAAEK,MAAM,GAAGC,QAAQ;IAC5B,GACCA,QAAQ;IAEXQ,aAAad,EAAEe,OAAO,GAAGT,QAAQ;IAEjCU,YAAYhB,EACTE,MAAM,CAAC;QACNe,OAAOjB,EAAEK,MAAM,GAAGC,QAAQ;QAC1BQ,aAAad,EAAEe,OAAO,GAAGT,QAAQ;IACnC,GACCA,QAAQ;IAEXY,SAASlB,EACNmB,KAAK,CACJnB,EAAEE,MAAM,CAAC;QACPkB,cAAcpB,EAAEK,MAAM,GAAGC,QAAQ;QACjCe,YAAYrB,EAAEsB,IAAI,CAAC;YAAC;YAAQ;YAAQ;SAAO,EAAEhB,QAAQ;QACrDK,IAAIX,EAAEK,MAAM,GAAGC,QAAQ;QACvBiB,uBAAuBvB,EAAEe,OAAO,GAAGT,QAAQ;QAC3CkB,YAAYxB,EAAEe,OAAO,GAAGT,QAAQ;QAChCmB,QAAQzB,EAAEK,MAAM,GAAGC,QAAQ;QAC3BoB,KAAK1B,EAAEK,MAAM,GAAGC,QAAQ;QACxBqB,WAAW3B,EAAEK,MAAM,GAAGC,QAAQ;IAChC,IAEDA,QAAQ;IAEXsB,cAAc5B,EACXE,MAAM,CAAC;QACN2B,aAAa7B,EAAEK,MAAM,GAAGC,QAAQ;IAClC,GACCA,QAAQ;IAEXwB,SAAS9B,EACNE,MAAM,CAAC;QACN6B,UAAU/B,EAAEK,MAAM,GAAGC,QAAQ;IAC/B,GACCA,QAAQ;IAEX0B,eAAehC,EAAEiC,MAAM,GAAwB3B,QAAQ;IAEvD4B,iBAAiBlC,EAAEe,OAAO,GAAGT,QAAQ;IAErC6B,QAAQnC,EACLE,MAAM,CAAC;QACNkC,UAAUpC,EAAEK,MAAM,GAAGC,QAAQ;QAC7B+B,MAAMrC,EAAEsC,MAAM,GAAGhC,QAAQ;IAC3B,GACCA,QAAQ;IAEXiC,YAAYvC,EAAEK,MAAM,GAAGC,QAAQ;IAE/BkC,MAAMxC,EAAEiC,MAAM,GAAmB3B,QAAQ;IAEzCmC,SAASzC,EAAEiC,MAAM,GAAkB3B,QAAQ;AAC7C,GAAiC"}
@@ -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\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 /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: 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 false. */\n reactStrictMode?: boolean\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 /** 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":"AAIA;;CAEC,GACD,WA+EC"}
1
+ {"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type TypeGenConfig} from '@sanity/codegen'\nimport {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\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 /** String encoding of an icon (typically an SVG) */\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 /** The title of the custom app. Used in Dashboard and in the browser tab */\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 false. */\n reactStrictMode?: boolean\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 /** 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":"AAKA;;CAEC,GACD,WAwFC"}
@@ -1,5 +1,5 @@
1
1
  import { findAppConfigPath } from './util/findAppConfigPath.js';
2
- import { findStudioConfigPath } from './util/findStudioConfigPath.js';
2
+ import { tryFindStudioConfigPath } from './util/findStudioConfigPath.js';
3
3
  import { recursivelyResolveProjectRoot } from './util/recursivelyResolveProjectRoot.js';
4
4
  /**
5
5
  * Resolve project root directory and type.
@@ -40,7 +40,7 @@ import { recursivelyResolveProjectRoot } from './util/recursivelyResolveProjectR
40
40
  * @returns A promise that resolves to an object if config is found, false otherwise
41
41
  * @internal
42
42
  */ async function resolveProjectRootForStudio(basePath, iterations = 0) {
43
- return recursivelyResolveProjectRoot(basePath, findStudioConfigPath, 'studio', iterations);
43
+ return recursivelyResolveProjectRoot(basePath, tryFindStudioConfigPath, 'studio', iterations);
44
44
  }
45
45
  /**
46
46
  * Recursively searches for a app project configuration file in the given directory and its parents.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/findProjectRoot.ts"],"sourcesContent":["import {findAppConfigPath} from './util/findAppConfigPath.js'\nimport {findStudioConfigPath} from './util/findStudioConfigPath.js'\nimport {\n type ProjectRootResult,\n recursivelyResolveProjectRoot,\n} from './util/recursivelyResolveProjectRoot.js'\n\n/**\n * Resolve project root directory and type.\n *\n * Project root is:\n * - `studio` - A pre-blueprints Sanity studio root (containing `sanity.config.(ts|js)`)\n * - `app` - A Sanity app root (containing `sanity.cli.(ts|js)`)\n *\n * If a Sanity Studio v2/v1 root is found (containing `sanity.json` with `root: true`),\n * an error is thrown, as v2/v1 is no longer supported.\n *\n * @internal\n */\nexport async function findProjectRoot(cwd: string): Promise<ProjectRootResult> {\n try {\n // First try to find a studio project root, looks for `sanity.config.(ts|js)`\n const studioProjectRoot = await resolveProjectRootForStudio(cwd)\n if (studioProjectRoot) {\n return studioProjectRoot\n }\n\n // Second try to find a app project root, looks for `sanity.cli.(ts|js)`\n const appProjectRoot = await resolveProjectRootForApp(cwd)\n if (appProjectRoot) {\n return appProjectRoot\n }\n\n // If nothing is found throw an error\n throw new Error('No project root found')\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : `${err}`\n throw new Error(`Error occurred trying to resolve project root:\\n${message}`)\n }\n}\n\n/**\n * Recursively searches for a project configuration file in the given directory and its parents.\n * Throws if Sanity v2 studio root is found.\n *\n * @param basePath - The base path to start searching from\n * @param iterations - Current iteration count, passed internally to prevent infinite recursion.\n * @returns A promise that resolves to an object if config is found, false otherwise\n * @internal\n */\nasync function resolveProjectRootForStudio(\n basePath: string,\n iterations = 0,\n): Promise<false | ProjectRootResult> {\n return recursivelyResolveProjectRoot(basePath, findStudioConfigPath, 'studio', iterations)\n}\n\n/**\n * Recursively searches for a app project configuration file in the given directory and its parents.\n *\n * @param basePath - The base path to start searching from\n * @param iterations - Current iteration count, passed internally to prevent infinite recursion.\n * @returns A promise that resolves to an object if config is found, false otherwise\n * @internal\n */\nasync function resolveProjectRootForApp(\n basePath: string,\n iterations = 0,\n): Promise<false | ProjectRootResult> {\n return recursivelyResolveProjectRoot(basePath, findAppConfigPath, 'app', iterations)\n}\n"],"names":["findAppConfigPath","findStudioConfigPath","recursivelyResolveProjectRoot","findProjectRoot","cwd","studioProjectRoot","resolveProjectRootForStudio","appProjectRoot","resolveProjectRootForApp","Error","err","message","basePath","iterations"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,8BAA6B;AAC7D,SAAQC,oBAAoB,QAAO,iCAAgC;AACnE,SAEEC,6BAA6B,QACxB,0CAAyC;AAEhD;;;;;;;;;;;CAWC,GACD,OAAO,eAAeC,gBAAgBC,GAAW;IAC/C,IAAI;QACF,6EAA6E;QAC7E,MAAMC,oBAAoB,MAAMC,4BAA4BF;QAC5D,IAAIC,mBAAmB;YACrB,OAAOA;QACT;QAEA,wEAAwE;QACxE,MAAME,iBAAiB,MAAMC,yBAAyBJ;QACtD,IAAIG,gBAAgB;YAClB,OAAOA;QACT;QAEA,qCAAqC;QACrC,MAAM,IAAIE,MAAM;IAClB,EAAE,OAAOC,KAAc;QACrB,MAAMC,UAAUD,eAAeD,QAAQC,IAAIC,OAAO,GAAG,GAAGD,KAAK;QAC7D,MAAM,IAAID,MAAM,CAAC,gDAAgD,EAAEE,SAAS;IAC9E;AACF;AAEA;;;;;;;;CAQC,GACD,eAAeL,4BACbM,QAAgB,EAChBC,aAAa,CAAC;IAEd,OAAOX,8BAA8BU,UAAUX,sBAAsB,UAAUY;AACjF;AAEA;;;;;;;CAOC,GACD,eAAeL,yBACbI,QAAgB,EAChBC,aAAa,CAAC;IAEd,OAAOX,8BAA8BU,UAAUZ,mBAAmB,OAAOa;AAC3E"}
1
+ {"version":3,"sources":["../../src/config/findProjectRoot.ts"],"sourcesContent":["import {findAppConfigPath} from './util/findAppConfigPath.js'\nimport {tryFindStudioConfigPath} from './util/findStudioConfigPath.js'\nimport {\n type ProjectRootResult,\n recursivelyResolveProjectRoot,\n} from './util/recursivelyResolveProjectRoot.js'\n\n/**\n * Resolve project root directory and type.\n *\n * Project root is:\n * - `studio` - A pre-blueprints Sanity studio root (containing `sanity.config.(ts|js)`)\n * - `app` - A Sanity app root (containing `sanity.cli.(ts|js)`)\n *\n * If a Sanity Studio v2/v1 root is found (containing `sanity.json` with `root: true`),\n * an error is thrown, as v2/v1 is no longer supported.\n *\n * @internal\n */\nexport async function findProjectRoot(cwd: string): Promise<ProjectRootResult> {\n try {\n // First try to find a studio project root, looks for `sanity.config.(ts|js)`\n const studioProjectRoot = await resolveProjectRootForStudio(cwd)\n if (studioProjectRoot) {\n return studioProjectRoot\n }\n\n // Second try to find a app project root, looks for `sanity.cli.(ts|js)`\n const appProjectRoot = await resolveProjectRootForApp(cwd)\n if (appProjectRoot) {\n return appProjectRoot\n }\n\n // If nothing is found throw an error\n throw new Error('No project root found')\n } catch (err: unknown) {\n const message = err instanceof Error ? err.message : `${err}`\n throw new Error(`Error occurred trying to resolve project root:\\n${message}`)\n }\n}\n\n/**\n * Recursively searches for a project configuration file in the given directory and its parents.\n * Throws if Sanity v2 studio root is found.\n *\n * @param basePath - The base path to start searching from\n * @param iterations - Current iteration count, passed internally to prevent infinite recursion.\n * @returns A promise that resolves to an object if config is found, false otherwise\n * @internal\n */\nasync function resolveProjectRootForStudio(\n basePath: string,\n iterations = 0,\n): Promise<false | ProjectRootResult> {\n return recursivelyResolveProjectRoot(basePath, tryFindStudioConfigPath, 'studio', iterations)\n}\n\n/**\n * Recursively searches for a app project configuration file in the given directory and its parents.\n *\n * @param basePath - The base path to start searching from\n * @param iterations - Current iteration count, passed internally to prevent infinite recursion.\n * @returns A promise that resolves to an object if config is found, false otherwise\n * @internal\n */\nasync function resolveProjectRootForApp(\n basePath: string,\n iterations = 0,\n): Promise<false | ProjectRootResult> {\n return recursivelyResolveProjectRoot(basePath, findAppConfigPath, 'app', iterations)\n}\n"],"names":["findAppConfigPath","tryFindStudioConfigPath","recursivelyResolveProjectRoot","findProjectRoot","cwd","studioProjectRoot","resolveProjectRootForStudio","appProjectRoot","resolveProjectRootForApp","Error","err","message","basePath","iterations"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,8BAA6B;AAC7D,SAAQC,uBAAuB,QAAO,iCAAgC;AACtE,SAEEC,6BAA6B,QACxB,0CAAyC;AAEhD;;;;;;;;;;;CAWC,GACD,OAAO,eAAeC,gBAAgBC,GAAW;IAC/C,IAAI;QACF,6EAA6E;QAC7E,MAAMC,oBAAoB,MAAMC,4BAA4BF;QAC5D,IAAIC,mBAAmB;YACrB,OAAOA;QACT;QAEA,wEAAwE;QACxE,MAAME,iBAAiB,MAAMC,yBAAyBJ;QACtD,IAAIG,gBAAgB;YAClB,OAAOA;QACT;QAEA,qCAAqC;QACrC,MAAM,IAAIE,MAAM;IAClB,EAAE,OAAOC,KAAc;QACrB,MAAMC,UAAUD,eAAeD,QAAQC,IAAIC,OAAO,GAAG,GAAGD,KAAK;QAC7D,MAAM,IAAID,MAAM,CAAC,gDAAgD,EAAEE,SAAS;IAC9E;AACF;AAEA;;;;;;;;CAQC,GACD,eAAeL,4BACbM,QAAgB,EAChBC,aAAa,CAAC;IAEd,OAAOX,8BAA8BU,UAAUX,yBAAyB,UAAUY;AACpF;AAEA;;;;;;;CAOC,GACD,eAAeL,yBACbI,QAAgB,EAChBC,aAAa,CAAC;IAEd,OAAOX,8BAA8BU,UAAUZ,mBAAmB,OAAOa;AAC3E"}
@@ -2,9 +2,6 @@ import { findStudioConfigPath } from '../util/findStudioConfigPath.js';
2
2
  import { readStudioConfig } from './readStudioConfig.js';
3
3
  export async function getStudioConfig(rootPath, options) {
4
4
  const studioConfigPath = await findStudioConfigPath(rootPath);
5
- if (!studioConfigPath) {
6
- throw new Error(`Unable to find studio configuration file in ${rootPath}`);
7
- }
8
5
  // TypeScript is not being very clever with our overloads :(
9
6
  return options.resolvePlugins ? readStudioConfig(studioConfigPath, {
10
7
  resolvePlugins: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/studio/getStudioConfig.ts"],"sourcesContent":["import {findStudioConfigPath} from '../util/findStudioConfigPath.js'\nimport {\n type RawStudioConfig,\n readStudioConfig,\n type ReadStudioConfigOptions,\n type ResolvedStudioConfig,\n} from './readStudioConfig.js'\n\n/**\n * Get the studio config for a project, given the root path.\n *\n * @param rootPath - The root path for the project\n * @returns The studio config (some properties may be missing)\n * @internal\n */\nexport async function getStudioConfig(\n rootPath: string,\n options: {resolvePlugins: true},\n): Promise<ResolvedStudioConfig>\n\nexport async function getStudioConfig(\n rootPath: string,\n options: {resolvePlugins: false},\n): Promise<RawStudioConfig>\n\nexport async function getStudioConfig(\n rootPath: string,\n options: ReadStudioConfigOptions,\n): Promise<RawStudioConfig | ResolvedStudioConfig> {\n const studioConfigPath = await findStudioConfigPath(rootPath)\n if (!studioConfigPath) {\n throw new Error(`Unable to find studio configuration file in ${rootPath}`)\n }\n\n // TypeScript is not being very clever with our overloads :(\n return options.resolvePlugins\n ? readStudioConfig(studioConfigPath, {resolvePlugins: true})\n : readStudioConfig(studioConfigPath, {resolvePlugins: false})\n}\n"],"names":["findStudioConfigPath","readStudioConfig","getStudioConfig","rootPath","options","studioConfigPath","Error","resolvePlugins"],"mappings":"AAAA,SAAQA,oBAAoB,QAAO,kCAAiC;AACpE,SAEEC,gBAAgB,QAGX,wBAAuB;AAmB9B,OAAO,eAAeC,gBACpBC,QAAgB,EAChBC,OAAgC;IAEhC,MAAMC,mBAAmB,MAAML,qBAAqBG;IACpD,IAAI,CAACE,kBAAkB;QACrB,MAAM,IAAIC,MAAM,CAAC,4CAA4C,EAAEH,UAAU;IAC3E;IAEA,4DAA4D;IAC5D,OAAOC,QAAQG,cAAc,GACzBN,iBAAiBI,kBAAkB;QAACE,gBAAgB;IAAI,KACxDN,iBAAiBI,kBAAkB;QAACE,gBAAgB;IAAK;AAC/D"}
1
+ {"version":3,"sources":["../../../src/config/studio/getStudioConfig.ts"],"sourcesContent":["import {findStudioConfigPath} from '../util/findStudioConfigPath.js'\nimport {\n type RawStudioConfig,\n readStudioConfig,\n type ReadStudioConfigOptions,\n type ResolvedStudioConfig,\n} from './readStudioConfig.js'\n\n/**\n * Get the studio config for a project, given the root path.\n *\n * @param rootPath - The root path for the project\n * @returns The studio config (some properties may be missing)\n * @public\n */\nexport async function getStudioConfig(\n rootPath: string,\n options: {resolvePlugins: true},\n): Promise<ResolvedStudioConfig>\n\nexport async function getStudioConfig(\n rootPath: string,\n options: {resolvePlugins: false},\n): Promise<RawStudioConfig>\n\nexport async function getStudioConfig(\n rootPath: string,\n options: ReadStudioConfigOptions,\n): Promise<RawStudioConfig | ResolvedStudioConfig> {\n const studioConfigPath = await findStudioConfigPath(rootPath)\n\n // TypeScript is not being very clever with our overloads :(\n return options.resolvePlugins\n ? readStudioConfig(studioConfigPath, {resolvePlugins: true})\n : readStudioConfig(studioConfigPath, {resolvePlugins: false})\n}\n"],"names":["findStudioConfigPath","readStudioConfig","getStudioConfig","rootPath","options","studioConfigPath","resolvePlugins"],"mappings":"AAAA,SAAQA,oBAAoB,QAAO,kCAAiC;AACpE,SAEEC,gBAAgB,QAGX,wBAAuB;AAmB9B,OAAO,eAAeC,gBACpBC,QAAgB,EAChBC,OAAgC;IAEhC,MAAMC,mBAAmB,MAAML,qBAAqBG;IAEpD,4DAA4D;IAC5D,OAAOC,QAAQE,cAAc,GACzBL,iBAAiBI,kBAAkB;QAACC,gBAAgB;IAAI,KACxDL,iBAAiBI,kBAAkB;QAACC,gBAAgB;IAAK;AAC/D"}
@@ -0,0 +1,50 @@
1
+ import { stat } from 'node:fs/promises';
2
+ import { dirname } from 'node:path';
3
+ import { firstValueFrom, of } from 'rxjs';
4
+ import { doImport } from '../../util/doImport.js';
5
+ import { getEmptyAuth } from '../../util/getEmptyAuth.js';
6
+ import { resolveLocalPackage } from '../../util/resolveLocalPackage.js';
7
+ import { findStudioConfigPath } from '../util/findStudioConfigPath.js';
8
+ import { isStudioConfig } from './isStudioConfig.js';
9
+ /**
10
+ * Resolves the workspaces from the studio config.
11
+ *
12
+ * @param options - The options for the function
13
+ * @returns The workspaces
14
+ * @internal
15
+ */ export async function getStudioWorkspaces(configPath) {
16
+ const isDirectory = (await stat(configPath)).isDirectory();
17
+ if (isDirectory) {
18
+ configPath = await findStudioConfigPath(configPath);
19
+ }
20
+ let config = await doImport(configPath);
21
+ if (!isStudioConfig(config)) {
22
+ if (!('default' in config) || !isStudioConfig(config.default)) {
23
+ throw new TypeError(`Invalid studio config format in "${configPath}"`);
24
+ }
25
+ config = config.default;
26
+ }
27
+ const workDir = dirname(configPath);
28
+ const { resolveConfig } = await resolveLocalPackage('sanity', workDir);
29
+ if (typeof resolveConfig !== 'function') {
30
+ throw new TypeError('Expected `resolveConfig` from `sanity` to be a function');
31
+ }
32
+ // We will also want to stub out some configuration - we don't need to resolve the
33
+ // users' logged in state, for instance - so let's disable the auth implementation.
34
+ const rawWorkspaces = Array.isArray(config) ? config : [
35
+ {
36
+ ...config,
37
+ basePath: config.basePath || '/',
38
+ name: config.name || 'default'
39
+ }
40
+ ];
41
+ const unauthedWorkspaces = rawWorkspaces.map((workspace)=>({
42
+ ...workspace,
43
+ auth: {
44
+ state: of(getEmptyAuth())
45
+ }
46
+ }));
47
+ return firstValueFrom(resolveConfig(unauthedWorkspaces));
48
+ }
49
+
50
+ //# sourceMappingURL=getStudioWorkspaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/config/studio/getStudioWorkspaces.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {dirname} from 'node:path'\n\nimport {firstValueFrom, of} from 'rxjs'\nimport {type Workspace} from 'sanity'\n\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\n/**\n * Resolves the workspaces from the studio config.\n *\n * @param options - The options for the function\n * @returns The workspaces\n * @internal\n */\nexport async function getStudioWorkspaces(configPath: string): Promise<Workspace[]> {\n const isDirectory = (await stat(configPath)).isDirectory()\n if (isDirectory) {\n configPath = await findStudioConfigPath(configPath)\n }\n let config = await doImport(configPath)\n if (!isStudioConfig(config)) {\n if (!('default' in config) || !isStudioConfig(config.default)) {\n throw new TypeError(`Invalid studio config format in \"${configPath}\"`)\n }\n\n config = config.default\n }\n\n const workDir = dirname(configPath)\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 unauthedWorkspaces = rawWorkspaces.map((workspace) => ({\n ...workspace,\n auth: {state: of(getEmptyAuth())},\n }))\n\n return firstValueFrom(resolveConfig(unauthedWorkspaces))\n}\n"],"names":["stat","dirname","firstValueFrom","of","doImport","getEmptyAuth","resolveLocalPackage","findStudioConfigPath","isStudioConfig","getStudioWorkspaces","configPath","isDirectory","config","default","TypeError","workDir","resolveConfig","rawWorkspaces","Array","isArray","basePath","name","unauthedWorkspaces","map","workspace","auth","state"],"mappings":"AAAA,SAAQA,IAAI,QAAO,mBAAkB;AACrC,SAAQC,OAAO,QAAO,YAAW;AAEjC,SAAQC,cAAc,EAAEC,EAAE,QAAO,OAAM;AAGvC,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;;;;;;CAMC,GACD,OAAO,eAAeC,oBAAoBC,UAAkB;IAC1D,MAAMC,cAAc,AAAC,CAAA,MAAMX,KAAKU,WAAU,EAAGC,WAAW;IACxD,IAAIA,aAAa;QACfD,aAAa,MAAMH,qBAAqBG;IAC1C;IACA,IAAIE,SAAS,MAAMR,SAASM;IAC5B,IAAI,CAACF,eAAeI,SAAS;QAC3B,IAAI,CAAE,CAAA,aAAaA,MAAK,KAAM,CAACJ,eAAeI,OAAOC,OAAO,GAAG;YAC7D,MAAM,IAAIC,UAAU,CAAC,iCAAiC,EAAEJ,WAAW,CAAC,CAAC;QACvE;QAEAE,SAASA,OAAOC,OAAO;IACzB;IAEA,MAAME,UAAUd,QAAQS;IACxB,MAAM,EAACM,aAAa,EAAC,GAAG,MAAMV,oBAA6C,UAAUS;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,qBAAqBL,cAAcM,GAAG,CAAC,CAACC,YAAe,CAAA;YAC3D,GAAGA,SAAS;YACZC,MAAM;gBAACC,OAAOvB,GAAGE;YAAe;QAClC,CAAA;IAEA,OAAOH,eAAec,cAAcM;AACtC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Checks if the given value conforms to a minimum studio config shape.
3
+ *
4
+ * @param value - The value to check
5
+ * @returns Whether the value is a studio config
6
+ * @internal
7
+ */ export function isStudioConfig(value) {
8
+ if (Array.isArray(value)) {
9
+ return value.every((item)=>isStudioConfig(item));
10
+ }
11
+ // Only actual properties marked as required by typescript are `projectId` and `dataset`,
12
+ // so this is a pretty weak check - but better than nothing.
13
+ if (typeof value === 'object' && value !== null) {
14
+ return 'projectId' in value && typeof value.projectId === 'string' && 'dataset' in value && typeof value.dataset === 'string';
15
+ }
16
+ return false;
17
+ }
18
+
19
+ //# sourceMappingURL=isStudioConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/config/studio/isStudioConfig.ts"],"sourcesContent":["/**\n * Checks if the given value conforms to a minimum studio config shape.\n *\n * @param value - The value to check\n * @returns Whether the value is a studio config\n * @internal\n */\nexport function isStudioConfig(value: unknown): boolean {\n if (Array.isArray(value)) {\n return value.every((item) => isStudioConfig(item))\n }\n\n // Only actual properties marked as required by typescript are `projectId` and `dataset`,\n // so this is a pretty weak check - but better than nothing.\n if (typeof value === 'object' && value !== null) {\n return (\n 'projectId' in value &&\n typeof value.projectId === 'string' &&\n 'dataset' in value &&\n typeof value.dataset === 'string'\n )\n }\n\n return false\n}\n"],"names":["isStudioConfig","value","Array","isArray","every","item","projectId","dataset"],"mappings":"AAAA;;;;;;CAMC,GACD,OAAO,SAASA,eAAeC,KAAc;IAC3C,IAAIC,MAAMC,OAAO,CAACF,QAAQ;QACxB,OAAOA,MAAMG,KAAK,CAAC,CAACC,OAASL,eAAeK;IAC9C;IAEA,yFAAyF;IACzF,4DAA4D;IAC5D,IAAI,OAAOJ,UAAU,YAAYA,UAAU,MAAM;QAC/C,OACE,eAAeA,SACf,OAAOA,MAAMK,SAAS,KAAK,YAC3B,aAAaL,SACb,OAAOA,MAAMM,OAAO,KAAK;IAE7B;IAEA,OAAO;AACT"}
@@ -5,25 +5,29 @@ const schemaSchema = z.object({
5
5
  name: z.string().optional(),
6
6
  types: z.array(z.object({}).passthrough())
7
7
  });
8
+ const sourceSchema = z.object({
9
+ dataset: z.string(),
10
+ projectId: z.string(),
11
+ schema: z.object({
12
+ _original: schemaSchema
13
+ })
14
+ });
8
15
  const singleStudioWorkspaceSchema = z.object({
16
+ ...sourceSchema.shape,
9
17
  basePath: z.string().optional(),
10
- dataset: z.string(),
11
18
  name: z.string().optional(),
12
19
  plugins: z.array(z.unknown()).optional(),
13
- projectId: z.string(),
14
20
  schema: schemaSchema.optional(),
15
- title: z.string().optional()
21
+ title: z.string().optional(),
22
+ unstable_sources: z.array(sourceSchema)
16
23
  }).passthrough();
17
24
  const studioWorkspaceSchema = z.object({
25
+ ...sourceSchema.shape,
18
26
  basePath: z.string(),
19
- dataset: z.string(),
20
27
  name: z.string(),
21
28
  plugins: z.array(z.unknown()).optional(),
22
- projectId: z.string(),
23
- schema: z.object({
24
- _original: schemaSchema
25
- }),
26
- title: z.string()
29
+ title: z.string(),
30
+ unstable_sources: z.array(sourceSchema)
27
31
  });
28
32
  const rawConfigSchema = z.union([
29
33
  z.array(studioWorkspaceSchema),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/studio/readStudioConfig.ts"],"sourcesContent":["import {dirname} from 'node:path'\n\nimport {z} from 'zod'\n\nimport {studioWorkerTask} from '../../loaders/studio/studioWorkerTask.js'\n\nconst schemaSchema = z.object({\n name: z.string().optional(),\n types: z.array(z.object({}).passthrough()),\n})\n\nconst singleStudioWorkspaceSchema = z\n .object({\n basePath: z.string().optional(),\n dataset: z.string(),\n name: z.string().optional(),\n plugins: z.array(z.unknown()).optional(),\n projectId: z.string(),\n schema: schemaSchema.optional(),\n title: z.string().optional(),\n })\n .passthrough()\n\nconst studioWorkspaceSchema = z.object({\n basePath: z.string(),\n dataset: z.string(),\n name: z.string(),\n plugins: z.array(z.unknown()).optional(),\n projectId: z.string(),\n schema: z.object({_original: schemaSchema}),\n title: z.string(),\n})\n\nconst rawConfigSchema = z.union([z.array(studioWorkspaceSchema), singleStudioWorkspaceSchema])\nconst resolvedConfigSchema = z.array(studioWorkspaceSchema)\n\nexport type RawStudioConfig = z.infer<typeof rawConfigSchema>\nexport type ResolvedStudioConfig = z.infer<typeof resolvedConfigSchema>\n\nexport interface ReadStudioConfigOptions {\n /**\n * Whether or not to resolve the plugins defined in the config.\n *\n * In some cases, you need this in order to have the full picture of what the studio\n * would \"see\". As an example, plugins can define schema types that are not explicitly\n * defined in the users' schema types. In order to get the full picture, you need to\n * resolve the plugins, which is an asyncronous operation.\n *\n * In other cases, it might be enough to only do a shallow pass. As an example, if you\n * only need to know about the defined workspace, or the user-defined schema types,\n * this can be set to `false` - which should resolve faster (and potentially \"safer\")\n * in terms of not triggering all kinds of browser behavior that may or may not be\n * loaded as the plugins are resolved.\n */\n resolvePlugins: boolean\n}\n\nexport async function readStudioConfig(\n configPath: string,\n options: {resolvePlugins: true},\n): Promise<ResolvedStudioConfig>\n\nexport async function readStudioConfig(\n configPath: string,\n options: {resolvePlugins: false},\n): Promise<RawStudioConfig>\n\nexport async function readStudioConfig(\n configPath: string,\n options: ReadStudioConfigOptions,\n): Promise<RawStudioConfig | ResolvedStudioConfig> {\n const result = await studioWorkerTask(new URL('readStudioConfig.worker.js', import.meta.url), {\n name: 'studioConfig',\n studioRootPath: dirname(configPath),\n workerData: {configPath, resolvePlugins: options.resolvePlugins},\n })\n\n return options.resolvePlugins ? resolvedConfigSchema.parse(result) : rawConfigSchema.parse(result)\n}\n"],"names":["dirname","z","studioWorkerTask","schemaSchema","object","name","string","optional","types","array","passthrough","singleStudioWorkspaceSchema","basePath","dataset","plugins","unknown","projectId","schema","title","studioWorkspaceSchema","_original","rawConfigSchema","union","resolvedConfigSchema","readStudioConfig","configPath","options","result","URL","url","studioRootPath","workerData","resolvePlugins","parse"],"mappings":"AAAA,SAAQA,OAAO,QAAO,YAAW;AAEjC,SAAQC,CAAC,QAAO,MAAK;AAErB,SAAQC,gBAAgB,QAAO,2CAA0C;AAEzE,MAAMC,eAAeF,EAAEG,MAAM,CAAC;IAC5BC,MAAMJ,EAAEK,MAAM,GAAGC,QAAQ;IACzBC,OAAOP,EAAEQ,KAAK,CAACR,EAAEG,MAAM,CAAC,CAAC,GAAGM,WAAW;AACzC;AAEA,MAAMC,8BAA8BV,EACjCG,MAAM,CAAC;IACNQ,UAAUX,EAAEK,MAAM,GAAGC,QAAQ;IAC7BM,SAASZ,EAAEK,MAAM;IACjBD,MAAMJ,EAAEK,MAAM,GAAGC,QAAQ;IACzBO,SAASb,EAAEQ,KAAK,CAACR,EAAEc,OAAO,IAAIR,QAAQ;IACtCS,WAAWf,EAAEK,MAAM;IACnBW,QAAQd,aAAaI,QAAQ;IAC7BW,OAAOjB,EAAEK,MAAM,GAAGC,QAAQ;AAC5B,GACCG,WAAW;AAEd,MAAMS,wBAAwBlB,EAAEG,MAAM,CAAC;IACrCQ,UAAUX,EAAEK,MAAM;IAClBO,SAASZ,EAAEK,MAAM;IACjBD,MAAMJ,EAAEK,MAAM;IACdQ,SAASb,EAAEQ,KAAK,CAACR,EAAEc,OAAO,IAAIR,QAAQ;IACtCS,WAAWf,EAAEK,MAAM;IACnBW,QAAQhB,EAAEG,MAAM,CAAC;QAACgB,WAAWjB;IAAY;IACzCe,OAAOjB,EAAEK,MAAM;AACjB;AAEA,MAAMe,kBAAkBpB,EAAEqB,KAAK,CAAC;IAACrB,EAAEQ,KAAK,CAACU;IAAwBR;CAA4B;AAC7F,MAAMY,uBAAuBtB,EAAEQ,KAAK,CAACU;AAiCrC,OAAO,eAAeK,iBACpBC,UAAkB,EAClBC,OAAgC;IAEhC,MAAMC,SAAS,MAAMzB,iBAAiB,IAAI0B,IAAI,8BAA8B,YAAYC,GAAG,GAAG;QAC5FxB,MAAM;QACNyB,gBAAgB9B,QAAQyB;QACxBM,YAAY;YAACN;YAAYO,gBAAgBN,QAAQM,cAAc;QAAA;IACjE;IAEA,OAAON,QAAQM,cAAc,GAAGT,qBAAqBU,KAAK,CAACN,UAAUN,gBAAgBY,KAAK,CAACN;AAC7F"}
1
+ {"version":3,"sources":["../../../src/config/studio/readStudioConfig.ts"],"sourcesContent":["import {dirname} from 'node:path'\n\nimport {z} from 'zod'\n\nimport {studioWorkerTask} from '../../loaders/studio/studioWorkerTask.js'\n\nconst schemaSchema = z.object({\n name: z.string().optional(),\n types: z.array(z.object({}).passthrough()),\n})\n\nconst sourceSchema = z.object({\n dataset: z.string(),\n projectId: z.string(),\n schema: z.object({_original: schemaSchema}),\n})\n\nconst singleStudioWorkspaceSchema = z\n .object({\n ...sourceSchema.shape,\n basePath: z.string().optional(),\n name: z.string().optional(),\n plugins: z.array(z.unknown()).optional(),\n schema: schemaSchema.optional(),\n title: z.string().optional(),\n unstable_sources: z.array(sourceSchema),\n })\n .passthrough()\n\nconst studioWorkspaceSchema = z.object({\n ...sourceSchema.shape,\n basePath: z.string(),\n name: z.string(),\n plugins: z.array(z.unknown()).optional(),\n title: z.string(),\n unstable_sources: z.array(sourceSchema),\n})\n\nconst rawConfigSchema = z.union([z.array(studioWorkspaceSchema), singleStudioWorkspaceSchema])\nconst resolvedConfigSchema = z.array(studioWorkspaceSchema)\n\nexport type RawStudioConfig = z.infer<typeof rawConfigSchema>\nexport type ResolvedStudioConfig = z.infer<typeof resolvedConfigSchema>\n\nexport interface ReadStudioConfigOptions {\n /**\n * Whether or not to resolve the plugins defined in the config.\n *\n * In some cases, you need this in order to have the full picture of what the studio\n * would \"see\". As an example, plugins can define schema types that are not explicitly\n * defined in the users' schema types. In order to get the full picture, you need to\n * resolve the plugins, which is an asyncronous operation.\n *\n * In other cases, it might be enough to only do a shallow pass. As an example, if you\n * only need to know about the defined workspace, or the user-defined schema types,\n * this can be set to `false` - which should resolve faster (and potentially \"safer\")\n * in terms of not triggering all kinds of browser behavior that may or may not be\n * loaded as the plugins are resolved.\n */\n resolvePlugins: boolean\n}\n\nexport async function readStudioConfig(\n configPath: string,\n options: {resolvePlugins: true},\n): Promise<ResolvedStudioConfig>\n\nexport async function readStudioConfig(\n configPath: string,\n options: {resolvePlugins: false},\n): Promise<RawStudioConfig>\n\nexport async function readStudioConfig(\n configPath: string,\n options: ReadStudioConfigOptions,\n): Promise<RawStudioConfig | ResolvedStudioConfig> {\n const result = await studioWorkerTask(new URL('readStudioConfig.worker.js', import.meta.url), {\n name: 'studioConfig',\n studioRootPath: dirname(configPath),\n workerData: {configPath, resolvePlugins: options.resolvePlugins},\n })\n\n return options.resolvePlugins ? resolvedConfigSchema.parse(result) : rawConfigSchema.parse(result)\n}\n"],"names":["dirname","z","studioWorkerTask","schemaSchema","object","name","string","optional","types","array","passthrough","sourceSchema","dataset","projectId","schema","_original","singleStudioWorkspaceSchema","shape","basePath","plugins","unknown","title","unstable_sources","studioWorkspaceSchema","rawConfigSchema","union","resolvedConfigSchema","readStudioConfig","configPath","options","result","URL","url","studioRootPath","workerData","resolvePlugins","parse"],"mappings":"AAAA,SAAQA,OAAO,QAAO,YAAW;AAEjC,SAAQC,CAAC,QAAO,MAAK;AAErB,SAAQC,gBAAgB,QAAO,2CAA0C;AAEzE,MAAMC,eAAeF,EAAEG,MAAM,CAAC;IAC5BC,MAAMJ,EAAEK,MAAM,GAAGC,QAAQ;IACzBC,OAAOP,EAAEQ,KAAK,CAACR,EAAEG,MAAM,CAAC,CAAC,GAAGM,WAAW;AACzC;AAEA,MAAMC,eAAeV,EAAEG,MAAM,CAAC;IAC5BQ,SAASX,EAAEK,MAAM;IACjBO,WAAWZ,EAAEK,MAAM;IACnBQ,QAAQb,EAAEG,MAAM,CAAC;QAACW,WAAWZ;IAAY;AAC3C;AAEA,MAAMa,8BAA8Bf,EACjCG,MAAM,CAAC;IACN,GAAGO,aAAaM,KAAK;IACrBC,UAAUjB,EAAEK,MAAM,GAAGC,QAAQ;IAC7BF,MAAMJ,EAAEK,MAAM,GAAGC,QAAQ;IACzBY,SAASlB,EAAEQ,KAAK,CAACR,EAAEmB,OAAO,IAAIb,QAAQ;IACtCO,QAAQX,aAAaI,QAAQ;IAC7Bc,OAAOpB,EAAEK,MAAM,GAAGC,QAAQ;IAC1Be,kBAAkBrB,EAAEQ,KAAK,CAACE;AAC5B,GACCD,WAAW;AAEd,MAAMa,wBAAwBtB,EAAEG,MAAM,CAAC;IACrC,GAAGO,aAAaM,KAAK;IACrBC,UAAUjB,EAAEK,MAAM;IAClBD,MAAMJ,EAAEK,MAAM;IACda,SAASlB,EAAEQ,KAAK,CAACR,EAAEmB,OAAO,IAAIb,QAAQ;IACtCc,OAAOpB,EAAEK,MAAM;IACfgB,kBAAkBrB,EAAEQ,KAAK,CAACE;AAC5B;AAEA,MAAMa,kBAAkBvB,EAAEwB,KAAK,CAAC;IAACxB,EAAEQ,KAAK,CAACc;IAAwBP;CAA4B;AAC7F,MAAMU,uBAAuBzB,EAAEQ,KAAK,CAACc;AAiCrC,OAAO,eAAeI,iBACpBC,UAAkB,EAClBC,OAAgC;IAEhC,MAAMC,SAAS,MAAM5B,iBAAiB,IAAI6B,IAAI,8BAA8B,YAAYC,GAAG,GAAG;QAC5F3B,MAAM;QACN4B,gBAAgBjC,QAAQ4B;QACxBM,YAAY;YAACN;YAAYO,gBAAgBN,QAAQM,cAAc;QAAA;IACjE;IAEA,OAAON,QAAQM,cAAc,GAAGT,qBAAqBU,KAAK,CAACN,UAAUN,gBAAgBY,KAAK,CAACN;AAC7F"}
@@ -1,9 +1,8 @@
1
- import { pathToFileURL } from 'node:url';
2
1
  import { isMainThread, parentPort, workerData } from 'node:worker_threads';
3
- import { moduleResolve } from 'import-meta-resolve';
4
2
  import { z } from 'zod';
5
- import { getEmptyAuth } from '../../util/getEmptyAuth.js';
3
+ import { doImport } from '../../util/doImport.js';
6
4
  import { safeStructuredClone } from '../../util/safeStructuredClone.js';
5
+ import { getStudioWorkspaces } from './getStudioWorkspaces.js';
7
6
  if (isMainThread || !parentPort) {
8
7
  throw new Error('Should only be run in a worker!');
9
8
  }
@@ -11,34 +10,9 @@ const { configPath, resolvePlugins } = z.object({
11
10
  configPath: z.string(),
12
11
  resolvePlugins: z.boolean()
13
12
  }).parse(workerData);
14
- let { default: config } = await import(configPath);
13
+ let { default: config } = await doImport(configPath);
15
14
  if (resolvePlugins) {
16
- // If we need to resolve plugins, we need to import and use the `resolveConfig`
17
- // function from the `sanity` package. This package should be installed in the users'
18
- // studio project, not as part of the CLI - so we need to resolve the full path of the
19
- // Sanity package relative to the studio.
20
- const configUrl = pathToFileURL(configPath);
21
- const sanityUrl = await moduleResolve('sanity', configUrl);
22
- const { resolveConfig } = await import(sanityUrl.href);
23
- if (typeof resolveConfig !== 'function') {
24
- throw new TypeError('Expected `resolveConfig` from `sanity` to be a function');
25
- }
26
- // We'll want to use some observable tooling, but we'd prefer to use something
27
- // compatible with what the studio uses internally, thus try to load RxJS from the
28
- // sanity module path instead of installing it as a dependency locally.
29
- const rxjsPath = (await moduleResolve('rxjs', sanityUrl)).href;
30
- const { firstValueFrom, of } = await import(rxjsPath);
31
- // We will also want to stub out some configuration - we don't need to resolve the
32
- // users' logged in state, for instance - so let's disable the auth implementation.
33
- const workspaces = Array.isArray(config) ? config : [
34
- config
35
- ];
36
- workspaces.map((workspace)=>{
37
- workspace.auth = {
38
- state: of(getEmptyAuth())
39
- };
40
- });
41
- config = await firstValueFrom(resolveConfig(config));
15
+ config = await getStudioWorkspaces(configPath);
42
16
  }
43
17
  parentPort.postMessage(safeStructuredClone(config));
44
18
  // Explicitly exit the process to avoid any dangling references from keeping
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/studio/readStudioConfig.worker.ts"],"sourcesContent":["import {pathToFileURL} from 'node:url'\nimport {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {moduleResolve} from 'import-meta-resolve'\nimport {z} from 'zod'\n\nimport {getEmptyAuth} from '../../util/getEmptyAuth.js'\nimport {safeStructuredClone} from '../../util/safeStructuredClone.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst {configPath, resolvePlugins} = z\n .object({configPath: z.string(), resolvePlugins: z.boolean()})\n .parse(workerData)\n\nlet {default: config} = await import(configPath)\n\nif (resolvePlugins) {\n // If we need to resolve plugins, we need to import and use the `resolveConfig`\n // function from the `sanity` package. This package should be installed in the users'\n // studio project, not as part of the CLI - so we need to resolve the full path of the\n // Sanity package relative to the studio.\n const configUrl = pathToFileURL(configPath)\n\n const sanityUrl = await moduleResolve('sanity', configUrl)\n const {resolveConfig} = await import(sanityUrl.href)\n if (typeof resolveConfig !== 'function') {\n throw new TypeError('Expected `resolveConfig` from `sanity` to be a function')\n }\n\n // We'll want to use some observable tooling, but we'd prefer to use something\n // compatible with what the studio uses internally, thus try to load RxJS from the\n // sanity module path instead of installing it as a dependency locally.\n const rxjsPath = (await moduleResolve('rxjs', sanityUrl)).href\n const {firstValueFrom, of} = await import(rxjsPath)\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 workspaces = Array.isArray(config) ? config : [config]\n workspaces.map((workspace) => {\n workspace.auth = {state: of(getEmptyAuth())}\n })\n\n config = await firstValueFrom(resolveConfig(config))\n}\n\nparentPort.postMessage(safeStructuredClone(config))\n\n// Explicitly exit the process to avoid any dangling references from keeping\n// the process alive after resolving it's main task\nsetImmediate(() => {\n process.exit(1)\n})\n"],"names":["pathToFileURL","isMainThread","parentPort","workerData","moduleResolve","z","getEmptyAuth","safeStructuredClone","Error","configPath","resolvePlugins","object","string","boolean","parse","default","config","configUrl","sanityUrl","resolveConfig","href","TypeError","rxjsPath","firstValueFrom","of","workspaces","Array","isArray","map","workspace","auth","state","postMessage","setImmediate","process","exit"],"mappings":"AAAA,SAAQA,aAAa,QAAO,WAAU;AACtC,SAAQC,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,aAAa,QAAO,sBAAqB;AACjD,SAAQC,CAAC,QAAO,MAAK;AAErB,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,mBAAmB,QAAO,oCAAmC;AAErE,IAAIN,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIM,MAAM;AAClB;AAEA,MAAM,EAACC,UAAU,EAAEC,cAAc,EAAC,GAAGL,EAClCM,MAAM,CAAC;IAACF,YAAYJ,EAAEO,MAAM;IAAIF,gBAAgBL,EAAEQ,OAAO;AAAE,GAC3DC,KAAK,CAACX;AAET,IAAI,EAACY,SAASC,MAAM,EAAC,GAAG,MAAM,MAAM,CAACP;AAErC,IAAIC,gBAAgB;IAClB,+EAA+E;IAC/E,qFAAqF;IACrF,sFAAsF;IACtF,yCAAyC;IACzC,MAAMO,YAAYjB,cAAcS;IAEhC,MAAMS,YAAY,MAAMd,cAAc,UAAUa;IAChD,MAAM,EAACE,aAAa,EAAC,GAAG,MAAM,MAAM,CAACD,UAAUE,IAAI;IACnD,IAAI,OAAOD,kBAAkB,YAAY;QACvC,MAAM,IAAIE,UAAU;IACtB;IAEA,8EAA8E;IAC9E,kFAAkF;IAClF,uEAAuE;IACvE,MAAMC,WAAW,AAAC,CAAA,MAAMlB,cAAc,QAAQc,UAAS,EAAGE,IAAI;IAC9D,MAAM,EAACG,cAAc,EAAEC,EAAE,EAAC,GAAG,MAAM,MAAM,CAACF;IAE1C,kFAAkF;IAClF,mFAAmF;IACnF,MAAMG,aAAaC,MAAMC,OAAO,CAACX,UAAUA,SAAS;QAACA;KAAO;IAC5DS,WAAWG,GAAG,CAAC,CAACC;QACdA,UAAUC,IAAI,GAAG;YAACC,OAAOP,GAAGlB;QAAe;IAC7C;IAEAU,SAAS,MAAMO,eAAeJ,cAAcH;AAC9C;AAEAd,WAAW8B,WAAW,CAACzB,oBAAoBS;AAE3C,4EAA4E;AAC5E,mDAAmD;AACnDiB,aAAa;IACXC,QAAQC,IAAI,CAAC;AACf"}
1
+ {"version":3,"sources":["../../../src/config/studio/readStudioConfig.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {z} from 'zod'\n\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 {configPath, resolvePlugins} = z\n .object({configPath: z.string(), resolvePlugins: z.boolean()})\n .parse(workerData)\n\nlet {default: config} = await doImport(configPath)\n\nif (resolvePlugins) {\n config = await getStudioWorkspaces(configPath)\n}\n\nparentPort.postMessage(safeStructuredClone(config))\n\n// Explicitly exit the process to avoid any dangling references from keeping\n// the process alive after resolving it's main task\nsetImmediate(() => {\n process.exit(1)\n})\n"],"names":["isMainThread","parentPort","workerData","z","doImport","safeStructuredClone","getStudioWorkspaces","Error","configPath","resolvePlugins","object","string","boolean","parse","default","config","postMessage","setImmediate","process","exit"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,CAAC,QAAO,MAAK;AAErB,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,mBAAmB,QAAO,2BAA0B;AAE5D,IAAIN,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIM,MAAM;AAClB;AAEA,MAAM,EAACC,UAAU,EAAEC,cAAc,EAAC,GAAGN,EAClCO,MAAM,CAAC;IAACF,YAAYL,EAAEQ,MAAM;IAAIF,gBAAgBN,EAAES,OAAO;AAAE,GAC3DC,KAAK,CAACX;AAET,IAAI,EAACY,SAASC,MAAM,EAAC,GAAG,MAAMX,SAASI;AAEvC,IAAIC,gBAAgB;IAClBM,SAAS,MAAMT,oBAAoBE;AACrC;AAEAP,WAAWe,WAAW,CAACX,oBAAoBU;AAE3C,4EAA4E;AAC5E,mDAAmD;AACnDE,aAAa;IACXC,QAAQC,IAAI,CAAC;AACf"}