@sanity/cli-core 0.1.0-alpha.8 → 0.1.0-alpha.9

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 (126) hide show
  1. package/dist/SanityCommand.js +7 -0
  2. package/dist/SanityCommand.js.map +1 -1
  3. package/dist/_exports/tree.d.ts +47 -1
  4. package/dist/_exports/ux.d.ts +40 -4
  5. package/dist/_exports/ux.js +1 -1
  6. package/dist/_exports/ux.js.map +1 -1
  7. package/dist/config/findProjectRoot.js +2 -2
  8. package/dist/config/findProjectRoot.js.map +1 -1
  9. package/dist/config/studio/getStudioConfig.js +0 -3
  10. package/dist/config/studio/getStudioConfig.js.map +1 -1
  11. package/dist/config/studio/getStudioWorkspaces.js +50 -0
  12. package/dist/config/studio/getStudioWorkspaces.js.map +1 -0
  13. package/dist/config/studio/isStudioConfig.js +19 -0
  14. package/dist/config/studio/isStudioConfig.js.map +1 -0
  15. package/dist/config/studio/readStudioConfig.worker.js +2 -29
  16. package/dist/config/studio/readStudioConfig.worker.js.map +1 -1
  17. package/dist/config/util/findStudioConfigPath.js +24 -3
  18. package/dist/config/util/findStudioConfigPath.js.map +1 -1
  19. package/dist/config/util/recursivelyResolveProjectRoot.js.map +1 -1
  20. package/dist/index.d.ts +6027 -36
  21. package/dist/index.js +11 -0
  22. package/dist/index.js.map +1 -1
  23. package/dist/loaders/studio/studioWorkerTask.js +41 -11
  24. package/dist/loaders/studio/studioWorkerTask.js.map +1 -1
  25. package/dist/loaders/tsx/tsxWorkerTask.js +3 -0
  26. package/dist/loaders/tsx/tsxWorkerTask.js.map +1 -1
  27. package/dist/services/apiClient.js +5 -1
  28. package/dist/services/apiClient.js.map +1 -1
  29. package/dist/telemetry/cleanupOldTelemetryFiles.js +30 -0
  30. package/dist/telemetry/cleanupOldTelemetryFiles.js.map +1 -0
  31. package/dist/telemetry/createTelemetryStore.js +95 -0
  32. package/dist/telemetry/createTelemetryStore.js.map +1 -0
  33. package/dist/telemetry/createTraceId.js +10 -0
  34. package/dist/telemetry/createTraceId.js.map +1 -0
  35. package/dist/telemetry/findTelemetryFiles.js +36 -0
  36. package/dist/telemetry/findTelemetryFiles.js.map +1 -0
  37. package/dist/telemetry/flushTelemetryFiles.js +107 -0
  38. package/dist/telemetry/flushTelemetryFiles.js.map +1 -0
  39. package/dist/telemetry/generateTelemetryFilePath.js +30 -0
  40. package/dist/telemetry/generateTelemetryFilePath.js.map +1 -0
  41. package/dist/telemetry/getTelemetryBaseInfo.js +33 -0
  42. package/dist/telemetry/getTelemetryBaseInfo.js.map +1 -0
  43. package/dist/telemetry/logger.js +54 -0
  44. package/dist/telemetry/logger.js.map +1 -0
  45. package/dist/telemetry/telemetryStoreDebug.js +7 -0
  46. package/dist/telemetry/telemetryStoreDebug.js.map +1 -0
  47. package/dist/telemetry/trace.js +150 -0
  48. package/dist/telemetry/trace.js.map +1 -0
  49. package/dist/telemetry/types.js +5 -0
  50. package/dist/telemetry/types.js.map +1 -0
  51. package/dist/util/getCliTelemetry.js +36 -0
  52. package/dist/util/getCliTelemetry.js.map +1 -0
  53. package/dist/util/isStaging.js +10 -0
  54. package/dist/util/isStaging.js.map +1 -0
  55. package/dist/util/normalizePath.js +12 -0
  56. package/dist/util/normalizePath.js.map +1 -0
  57. package/dist/util/readNDJSON.js +18 -0
  58. package/dist/util/readNDJSON.js.map +1 -0
  59. package/dist/util/waitForAsync.js +5 -0
  60. package/dist/util/waitForAsync.js.map +1 -0
  61. package/dist/ux/boxen.js +3 -0
  62. package/dist/ux/boxen.js.map +1 -0
  63. package/dist/ux/colorizeJson.js +6 -6
  64. package/dist/ux/colorizeJson.js.map +1 -1
  65. package/package.json +28 -21
  66. package/dist/SanityCommand.d.ts +0 -78
  67. package/dist/config/cli/getCliConfig.d.ts +0 -16
  68. package/dist/config/cli/getCliConfig.worker.d.ts +0 -1
  69. package/dist/config/cli/getCliConfigSync.d.ts +0 -12
  70. package/dist/config/cli/schemas.d.ts +0 -104
  71. package/dist/config/cli/types/cliConfig.d.ts +0 -83
  72. package/dist/config/cli/types/userViteConfig.d.ts +0 -5
  73. package/dist/config/findProjectRoot.d.ts +0 -14
  74. package/dist/config/findProjectRootSync.d.ts +0 -27
  75. package/dist/config/studio/getStudioConfig.d.ts +0 -14
  76. package/dist/config/studio/readStudioConfig.d.ts +0 -96
  77. package/dist/config/studio/readStudioConfig.worker.d.ts +0 -1
  78. package/dist/config/util/configPathsSync.d.ts +0 -17
  79. package/dist/config/util/findAppConfigPath.d.ts +0 -8
  80. package/dist/config/util/findConfigsPaths.d.ts +0 -16
  81. package/dist/config/util/findStudioConfigPath.d.ts +0 -9
  82. package/dist/config/util/isSanityV2StudioRoot.d.ts +0 -8
  83. package/dist/config/util/recursivelyResolveProjectRoot.d.ts +0 -27
  84. package/dist/debug.d.ts +0 -15
  85. package/dist/loaders/studio/studioWorkerLoader.worker.d.ts +0 -1
  86. package/dist/loaders/studio/studioWorkerTask.d.ts +0 -40
  87. package/dist/loaders/tsx/tsxWorkerLoader.worker.d.ts +0 -1
  88. package/dist/loaders/tsx/tsxWorkerTask.d.ts +0 -28
  89. package/dist/services/apiClient.d.ts +0 -53
  90. package/dist/services/cliUserConfig.d.ts +0 -40
  91. package/dist/services/getCliToken.d.ts +0 -7
  92. package/dist/types.d.ts +0 -15
  93. package/dist/util/NotFoundError.d.ts +0 -20
  94. package/dist/util/createExpiringConfig.d.ts +0 -37
  95. package/dist/util/doImport.d.ts +0 -7
  96. package/dist/util/environment/getStudioEnvironmentVariables.d.ts +0 -12
  97. package/dist/util/environment/mockBrowserEnvironment.d.ts +0 -17
  98. package/dist/util/environment/setupBrowserStubs.d.ts +0 -10
  99. package/dist/util/environment/stubs.d.ts +0 -254
  100. package/dist/util/fileExists.d.ts +0 -9
  101. package/dist/util/generateHelpUrl.d.ts +0 -8
  102. package/dist/util/getEmptyAuth.d.ts +0 -5
  103. package/dist/util/getSanityEnvVar.d.ts +0 -19
  104. package/dist/util/getSanityUrl.d.ts +0 -5
  105. package/dist/util/getUserConfig.d.ts +0 -2
  106. package/dist/util/isCi.d.ts +0 -1
  107. package/dist/util/isInteractive.d.ts +0 -1
  108. package/dist/util/isRecord.d.ts +0 -8
  109. package/dist/util/isTrueish.d.ts +0 -1
  110. package/dist/util/parseStringFlag.d.ts +0 -10
  111. package/dist/util/readJsonFile.d.ts +0 -14
  112. package/dist/util/resolveLocalPackage.d.ts +0 -18
  113. package/dist/util/safeStructuredClone.d.ts +0 -8
  114. package/dist/util/tree.d.ts +0 -31
  115. package/dist/util/tryGetDefaultExport.d.ts +0 -5
  116. package/dist/util/writeJsonFile.d.ts +0 -9
  117. package/dist/ux/chalk.d.ts +0 -2
  118. package/dist/ux/chalk.js +0 -4
  119. package/dist/ux/chalk.js.map +0 -1
  120. package/dist/ux/colorizeJson.d.ts +0 -1
  121. package/dist/ux/formatObject.d.ts +0 -1
  122. package/dist/ux/logSymbols.d.ts +0 -1
  123. package/dist/ux/printKeyValue.d.ts +0 -1
  124. package/dist/ux/prompts.d.ts +0 -1
  125. package/dist/ux/spinner.d.ts +0 -1
  126. package/dist/ux/timer.d.ts +0 -12
@@ -2,6 +2,7 @@ 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';
5
6
  import { isInteractive } from './util/isInteractive.js';
6
7
  export class SanityCommand extends Command {
7
8
  args;
@@ -37,6 +38,11 @@ export class SanityCommand extends Command {
37
38
  warn: this.warn.bind(this)
38
39
  };
39
40
  /**
41
+ * The telemetry store.
42
+ *
43
+ * @returns The telemetry store.
44
+ */ telemetry;
45
+ /**
40
46
  * Get the CLI config.
41
47
  *
42
48
  * @returns The CLI config.
@@ -69,6 +75,7 @@ export class SanityCommand extends Command {
69
75
  });
70
76
  this.args = args;
71
77
  this.flags = flags;
78
+ this.telemetry = getCliTelemetry();
72
79
  await super.init();
73
80
  }
74
81
  /**
@@ -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'\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 * 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\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","isInteractive","SanityCommand","args","flags","getGlobalApiClient","getProjectApiClient","output","error","bind","log","warn","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;AAEhC,SAAQC,aAAa,QAAO,0BAAyB;AAQrD,OAAO,MAAeC,sBAAgDN;IAC1DO,KAAc;IACdC,MAAgB;IAE1B;;;;;;;GAOC,GACD,AAAUC,qBAAqB,CAACF,OAAiCJ,mBAAmBI,MAAK;IAEzF;;;;;;;GAOC,GACD,AAAUG,sBAAsB,CAACH,OAAkCH,oBAAoBG,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,MAAgBZ,eAAmC;QACjD,MAAMe,OAAO,MAAM,IAAI,CAACC,cAAc;QAEtC,OAAOhB,aAAae,KAAKE,SAAS;IACpC;IAEA;;;;GAIC,GACD,MAAgBC,eAA4C;QAC1D,MAAMC,SAAS,MAAM,IAAI,CAACnB,YAAY;QAEtC,OAAOmB,OAAOC,GAAG,EAAEC;IACrB;IAEA;;;;GAIC,GACD,AAAUL,iBAA6C;QACrD,OAAOf,gBAAgBqB,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;IAEA;;;;;;;;;;GAUC,GACD,AAAUM,eAAwB;QAChC,OAAO,IAAI,CAACvB,KAAK,CAACwB,GAAG,IAAI,CAAC,IAAI,CAACC,oBAAoB;IACrD;IAEA;;;;GAIC,GACD,AAAUA,uBAAgC;QACxC,OAAO5B;IACT;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"}
@@ -1 +1,47 @@
1
- export * from '../util/tree.js';
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 {}
@@ -1,4 +1,40 @@
1
- export * from '../ux/chalk.js';
2
- export * from '../ux/logSymbols.js';
3
- export * from '../ux/prompts.js';
4
- export * from '../ux/spinner.js';
1
+ import {default as boxen} from 'boxen'
2
+ import {Options as BoxenOptions} from 'boxen'
3
+ import {Boxes} from 'boxen'
4
+ import {CustomBorderStyle} from 'boxen'
5
+ import {default as logSymbols} from 'log-symbols'
6
+ import {Spacing} from 'boxen'
7
+ import {Spinner} from 'ora'
8
+ import {default as spinner} from 'ora'
9
+ import {Ora as SpinnerInstance} from 'ora'
10
+ import {Options as SpinnerOptions} from 'ora'
11
+ import {oraPromise as spinnerPromise} from 'ora'
12
+ import {PromiseOptions as SpinnerPromiseOptions} from 'ora'
13
+
14
+ export {boxen}
15
+
16
+ export {BoxenOptions}
17
+
18
+ export {Boxes}
19
+
20
+ export {CustomBorderStyle}
21
+
22
+ export {logSymbols}
23
+
24
+ export {Spacing}
25
+
26
+ export {Spinner}
27
+
28
+ export {spinner}
29
+
30
+ export {SpinnerInstance}
31
+
32
+ export {SpinnerOptions}
33
+
34
+ export {spinnerPromise}
35
+
36
+ export {SpinnerPromiseOptions}
37
+
38
+ export * from '@inquirer/prompts'
39
+
40
+ export {}
@@ -1,4 +1,4 @@
1
- export * from '../ux/chalk.js';
1
+ export * from '../ux/boxen.js';
2
2
  export * from '../ux/logSymbols.js';
3
3
  export * from '../ux/prompts.js';
4
4
  export * from '../ux/spinner.js';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_exports/ux.ts"],"sourcesContent":["export * 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,sBAAqB;AACnC,cAAc,mBAAkB;AAChC,cAAc,mBAAkB"}
1
+ {"version":3,"sources":["../../src/_exports/ux.ts"],"sourcesContent":["export * from '../ux/boxen.js'\nexport * from '../ux/logSymbols.js'\nexport * from '../ux/prompts.js'\nexport * from '../ux/spinner.js'\n"],"names":[],"mappings":"AAAA,cAAc,iBAAgB;AAC9B,cAAc,sBAAqB;AACnC,cAAc,mBAAkB;AAChC,cAAc,mBAAkB"}
@@ -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"}
@@ -1,10 +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
3
  import { doImport } from '../../util/doImport.js';
6
- import { getEmptyAuth } from '../../util/getEmptyAuth.js';
7
4
  import { safeStructuredClone } from '../../util/safeStructuredClone.js';
5
+ import { getStudioWorkspaces } from './getStudioWorkspaces.js';
8
6
  if (isMainThread || !parentPort) {
9
7
  throw new Error('Should only be run in a worker!');
10
8
  }
@@ -14,32 +12,7 @@ const { configPath, resolvePlugins } = z.object({
14
12
  }).parse(workerData);
15
13
  let { default: config } = await doImport(configPath);
16
14
  if (resolvePlugins) {
17
- // If we need to resolve plugins, we need to import and use the `resolveConfig`
18
- // function from the `sanity` package. This package should be installed in the users'
19
- // studio project, not as part of the CLI - so we need to resolve the full path of the
20
- // Sanity package relative to the studio.
21
- const configUrl = pathToFileURL(configPath);
22
- const sanityUrl = await moduleResolve('sanity', configUrl);
23
- const { resolveConfig } = await doImport(sanityUrl.href);
24
- if (typeof resolveConfig !== 'function') {
25
- throw new TypeError('Expected `resolveConfig` from `sanity` to be a function');
26
- }
27
- // We'll want to use some observable tooling, but we'd prefer to use something
28
- // compatible with what the studio uses internally, thus try to load RxJS from the
29
- // sanity module path instead of installing it as a dependency locally.
30
- const rxjsPath = (await moduleResolve('rxjs', sanityUrl)).href;
31
- const { firstValueFrom, of } = await doImport(rxjsPath);
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 workspaces = Array.isArray(config) ? config : [
35
- config
36
- ];
37
- workspaces.map((workspace)=>{
38
- workspace.auth = {
39
- state: of(getEmptyAuth())
40
- };
41
- });
42
- config = await firstValueFrom(resolveConfig(config));
15
+ config = await getStudioWorkspaces(configPath);
43
16
  }
44
17
  parentPort.postMessage(safeStructuredClone(config));
45
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 {doImport} from '../../util/doImport.js'\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 doImport(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 doImport(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 doImport(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","doImport","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,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,mBAAmB,QAAO,oCAAmC;AAErE,IAAIP,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIO,MAAM;AAClB;AAEA,MAAM,EAACC,UAAU,EAAEC,cAAc,EAAC,GAAGN,EAClCO,MAAM,CAAC;IAACF,YAAYL,EAAEQ,MAAM;IAAIF,gBAAgBN,EAAES,OAAO;AAAE,GAC3DC,KAAK,CAACZ;AAET,IAAI,EAACa,SAASC,MAAM,EAAC,GAAG,MAAMX,SAASI;AAEvC,IAAIC,gBAAgB;IAClB,+EAA+E;IAC/E,qFAAqF;IACrF,sFAAsF;IACtF,yCAAyC;IACzC,MAAMO,YAAYlB,cAAcU;IAEhC,MAAMS,YAAY,MAAMf,cAAc,UAAUc;IAChD,MAAM,EAACE,aAAa,EAAC,GAAG,MAAMd,SAASa,UAAUE,IAAI;IACrD,IAAI,OAAOD,kBAAkB,YAAY;QACvC,MAAM,IAAIE,UAAU;IACtB;IAEA,8EAA8E;IAC9E,kFAAkF;IAClF,uEAAuE;IACvE,MAAMC,WAAW,AAAC,CAAA,MAAMnB,cAAc,QAAQe,UAAS,EAAGE,IAAI;IAC9D,MAAM,EAACG,cAAc,EAAEC,EAAE,EAAC,GAAG,MAAMnB,SAASiB;IAE5C,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;AAEAf,WAAW+B,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"}
@@ -2,11 +2,12 @@ import { basename } from 'node:path';
2
2
  import { findPathForFiles } from './findConfigsPaths.js';
3
3
  import { isSanityV2StudioRoot } from './isSanityV2StudioRoot.js';
4
4
  /**
5
- * Resolves to a string containing the found config path, or `false` if not found.
6
- * Throws if Sanity v2 studio root is found.
5
+ * Resolves to a string containing the found config path, otherwise throws an error.
6
+ * Also throws if Sanity v2 studio root is found.
7
7
  *
8
8
  * @param basePath - The base path to start searching from
9
- * @returns A promise that resolves to a string containing the found config path, or `undefined` if not found
9
+ * @returns A promise that resolves to a string containing the found config path
10
+ * @throws On multiple config files found, if v2 studio root found, or no config found
10
11
  * @internal
11
12
  */ export async function findStudioConfigPath(basePath) {
12
13
  if (await isSanityV2StudioRoot(basePath)) {
@@ -26,6 +27,26 @@ import { isSanityV2StudioRoot } from './isSanityV2StudioRoot.js';
26
27
  if (configPaths.length === 1) {
27
28
  return configPaths[0].path;
28
29
  }
30
+ throw new ConfigNotFoundError(`No studio config file found at ${basePath}`);
31
+ }
32
+ /**
33
+ * Tries to find the studio config path, returning `undefined` if not found.
34
+ *
35
+ * @param basePath - The base path to start searching from
36
+ * @returns A promise that resolves to a string containing the found config path, or `undefined` if not found
37
+ * @throws On errors other than config not found
38
+ * @internal
39
+ */ export async function tryFindStudioConfigPath(basePath) {
40
+ try {
41
+ return await findStudioConfigPath(basePath);
42
+ } catch (err) {
43
+ if (err instanceof ConfigNotFoundError) {
44
+ return undefined;
45
+ }
46
+ throw err;
47
+ }
48
+ }
49
+ class ConfigNotFoundError extends Error {
29
50
  }
30
51
 
31
52
  //# sourceMappingURL=findStudioConfigPath.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/util/findStudioConfigPath.ts"],"sourcesContent":["import {basename} from 'node:path'\n\nimport {findPathForFiles} from './findConfigsPaths.js'\nimport {isSanityV2StudioRoot} from './isSanityV2StudioRoot.js'\n\n/**\n * Resolves to a string containing the found config path, or `false` if not found.\n * Throws if Sanity v2 studio root is found.\n *\n * @param basePath - The base path to start searching from\n * @returns A promise that resolves to a string containing the found config path, or `undefined` if not found\n * @internal\n */\nexport async function findStudioConfigPath(basePath: string): Promise<string | undefined> {\n if (await isSanityV2StudioRoot(basePath)) {\n throw new Error(\n `Found 'sanity.json' at ${basePath} - Sanity Studio < v3 is no longer supported`,\n )\n }\n\n const paths = await findPathForFiles(basePath, [\n 'sanity.config.ts',\n 'sanity.config.tsx',\n 'sanity.config.js',\n 'sanity.config.jsx',\n ])\n\n const configPaths = paths.filter((path) => path.exists)\n if (configPaths.length > 1) {\n const baseNames = configPaths.map((config) => config.path).map((path) => basename(path))\n throw new Error(`Multiple studio config files found (${baseNames.join(', ')})`)\n }\n\n if (configPaths.length === 1) {\n return configPaths[0].path\n }\n}\n"],"names":["basename","findPathForFiles","isSanityV2StudioRoot","findStudioConfigPath","basePath","Error","paths","configPaths","filter","path","exists","length","baseNames","map","config","join"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,YAAW;AAElC,SAAQC,gBAAgB,QAAO,wBAAuB;AACtD,SAAQC,oBAAoB,QAAO,4BAA2B;AAE9D;;;;;;;CAOC,GACD,OAAO,eAAeC,qBAAqBC,QAAgB;IACzD,IAAI,MAAMF,qBAAqBE,WAAW;QACxC,MAAM,IAAIC,MACR,CAAC,uBAAuB,EAAED,SAAS,4CAA4C,CAAC;IAEpF;IAEA,MAAME,QAAQ,MAAML,iBAAiBG,UAAU;QAC7C;QACA;QACA;QACA;KACD;IAED,MAAMG,cAAcD,MAAME,MAAM,CAAC,CAACC,OAASA,KAAKC,MAAM;IACtD,IAAIH,YAAYI,MAAM,GAAG,GAAG;QAC1B,MAAMC,YAAYL,YAAYM,GAAG,CAAC,CAACC,SAAWA,OAAOL,IAAI,EAAEI,GAAG,CAAC,CAACJ,OAAST,SAASS;QAClF,MAAM,IAAIJ,MAAM,CAAC,oCAAoC,EAAEO,UAAUG,IAAI,CAAC,MAAM,CAAC,CAAC;IAChF;IAEA,IAAIR,YAAYI,MAAM,KAAK,GAAG;QAC5B,OAAOJ,WAAW,CAAC,EAAE,CAACE,IAAI;IAC5B;AACF"}
1
+ {"version":3,"sources":["../../../src/config/util/findStudioConfigPath.ts"],"sourcesContent":["import {basename} from 'node:path'\n\nimport {findPathForFiles} from './findConfigsPaths.js'\nimport {isSanityV2StudioRoot} from './isSanityV2StudioRoot.js'\n\n/**\n * Resolves to a string containing the found config path, otherwise throws an error.\n * Also throws if Sanity v2 studio root is found.\n *\n * @param basePath - The base path to start searching from\n * @returns A promise that resolves to a string containing the found config path\n * @throws On multiple config files found, if v2 studio root found, or no config found\n * @internal\n */\nexport async function findStudioConfigPath(basePath: string): Promise<string> {\n if (await isSanityV2StudioRoot(basePath)) {\n throw new Error(\n `Found 'sanity.json' at ${basePath} - Sanity Studio < v3 is no longer supported`,\n )\n }\n\n const paths = await findPathForFiles(basePath, [\n 'sanity.config.ts',\n 'sanity.config.tsx',\n 'sanity.config.js',\n 'sanity.config.jsx',\n ])\n\n const configPaths = paths.filter((path) => path.exists)\n if (configPaths.length > 1) {\n const baseNames = configPaths.map((config) => config.path).map((path) => basename(path))\n throw new Error(`Multiple studio config files found (${baseNames.join(', ')})`)\n }\n\n if (configPaths.length === 1) {\n return configPaths[0].path\n }\n\n throw new ConfigNotFoundError(`No studio config file found at ${basePath}`)\n}\n\n/**\n * Tries to find the studio config path, returning `undefined` if not found.\n *\n * @param basePath - The base path to start searching from\n * @returns A promise that resolves to a string containing the found config path, or `undefined` if not found\n * @throws On errors other than config not found\n * @internal\n */\nexport async function tryFindStudioConfigPath(basePath: string): Promise<string | undefined> {\n try {\n return await findStudioConfigPath(basePath)\n } catch (err) {\n if (err instanceof ConfigNotFoundError) {\n return undefined\n }\n throw err\n }\n}\n\nclass ConfigNotFoundError extends Error {}\n"],"names":["basename","findPathForFiles","isSanityV2StudioRoot","findStudioConfigPath","basePath","Error","paths","configPaths","filter","path","exists","length","baseNames","map","config","join","ConfigNotFoundError","tryFindStudioConfigPath","err","undefined"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,YAAW;AAElC,SAAQC,gBAAgB,QAAO,wBAAuB;AACtD,SAAQC,oBAAoB,QAAO,4BAA2B;AAE9D;;;;;;;;CAQC,GACD,OAAO,eAAeC,qBAAqBC,QAAgB;IACzD,IAAI,MAAMF,qBAAqBE,WAAW;QACxC,MAAM,IAAIC,MACR,CAAC,uBAAuB,EAAED,SAAS,4CAA4C,CAAC;IAEpF;IAEA,MAAME,QAAQ,MAAML,iBAAiBG,UAAU;QAC7C;QACA;QACA;QACA;KACD;IAED,MAAMG,cAAcD,MAAME,MAAM,CAAC,CAACC,OAASA,KAAKC,MAAM;IACtD,IAAIH,YAAYI,MAAM,GAAG,GAAG;QAC1B,MAAMC,YAAYL,YAAYM,GAAG,CAAC,CAACC,SAAWA,OAAOL,IAAI,EAAEI,GAAG,CAAC,CAACJ,OAAST,SAASS;QAClF,MAAM,IAAIJ,MAAM,CAAC,oCAAoC,EAAEO,UAAUG,IAAI,CAAC,MAAM,CAAC,CAAC;IAChF;IAEA,IAAIR,YAAYI,MAAM,KAAK,GAAG;QAC5B,OAAOJ,WAAW,CAAC,EAAE,CAACE,IAAI;IAC5B;IAEA,MAAM,IAAIO,oBAAoB,CAAC,+BAA+B,EAAEZ,UAAU;AAC5E;AAEA;;;;;;;CAOC,GACD,OAAO,eAAea,wBAAwBb,QAAgB;IAC5D,IAAI;QACF,OAAO,MAAMD,qBAAqBC;IACpC,EAAE,OAAOc,KAAK;QACZ,IAAIA,eAAeF,qBAAqB;YACtC,OAAOG;QACT;QACA,MAAMD;IACR;AACF;AAEA,MAAMF,4BAA4BX;AAAO"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/util/recursivelyResolveProjectRoot.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path'\n\n/**\n * Result of finding a project configuration\n *\n * @internal\n */\nexport interface ProjectRootResult {\n directory: string\n /**\n * Path to the project configuration file, if found.\n */\n path: string\n /**\n * Type of project root.\n */\n type: 'app' | 'studio'\n}\n\n/**\n * Generic recursive search function for project configuration files.\n *\n * @param basePath - The base path to start searching from\n * @param findConfigFn - Function that looks for config files in a given directory\n * @param projectType - The type of project ('app' | 'studio')\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 */\nexport async function recursivelyResolveProjectRoot(\n basePath: string,\n findConfigFn: (path: string) => Promise<string | undefined>,\n projectType: 'app' | 'studio',\n iterations = 0,\n): Promise<false | ProjectRootResult> {\n const configPath = await findConfigFn(basePath)\n\n if (configPath) {\n return {\n directory: dirname(configPath),\n path: configPath,\n type: projectType,\n }\n }\n\n const parentDir = resolve(basePath, '..')\n if (parentDir === basePath || iterations > 50) {\n // Reached root (or max depth), give up\n return false\n }\n\n return recursivelyResolveProjectRoot(parentDir, findConfigFn, projectType, iterations + 1)\n}\n"],"names":["dirname","resolve","recursivelyResolveProjectRoot","basePath","findConfigFn","projectType","iterations","configPath","directory","path","type","parentDir"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAW;AAmB1C;;;;;;;;;CASC,GACD,OAAO,eAAeC,8BACpBC,QAAgB,EAChBC,YAA2D,EAC3DC,WAA6B,EAC7BC,aAAa,CAAC;IAEd,MAAMC,aAAa,MAAMH,aAAaD;IAEtC,IAAII,YAAY;QACd,OAAO;YACLC,WAAWR,QAAQO;YACnBE,MAAMF;YACNG,MAAML;QACR;IACF;IAEA,MAAMM,YAAYV,QAAQE,UAAU;IACpC,IAAIQ,cAAcR,YAAYG,aAAa,IAAI;QAC7C,uCAAuC;QACvC,OAAO;IACT;IAEA,OAAOJ,8BAA8BS,WAAWP,cAAcC,aAAaC,aAAa;AAC1F"}
1
+ {"version":3,"sources":["../../../src/config/util/recursivelyResolveProjectRoot.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path'\n\n/**\n * Result of finding a project configuration\n *\n * @public\n */\nexport interface ProjectRootResult {\n directory: string\n /**\n * Path to the project configuration file, if found.\n */\n path: string\n /**\n * Type of project root.\n */\n type: 'app' | 'studio'\n}\n\n/**\n * Generic recursive search function for project configuration files.\n *\n * @param basePath - The base path to start searching from\n * @param findConfigFn - Function that looks for config files in a given directory\n * @param projectType - The type of project ('app' | 'studio')\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 */\nexport async function recursivelyResolveProjectRoot(\n basePath: string,\n findConfigFn: (path: string) => Promise<string | undefined>,\n projectType: 'app' | 'studio',\n iterations = 0,\n): Promise<false | ProjectRootResult> {\n const configPath = await findConfigFn(basePath)\n\n if (configPath) {\n return {\n directory: dirname(configPath),\n path: configPath,\n type: projectType,\n }\n }\n\n const parentDir = resolve(basePath, '..')\n if (parentDir === basePath || iterations > 50) {\n // Reached root (or max depth), give up\n return false\n }\n\n return recursivelyResolveProjectRoot(parentDir, findConfigFn, projectType, iterations + 1)\n}\n"],"names":["dirname","resolve","recursivelyResolveProjectRoot","basePath","findConfigFn","projectType","iterations","configPath","directory","path","type","parentDir"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAW;AAmB1C;;;;;;;;;CASC,GACD,OAAO,eAAeC,8BACpBC,QAAgB,EAChBC,YAA2D,EAC3DC,WAA6B,EAC7BC,aAAa,CAAC;IAEd,MAAMC,aAAa,MAAMH,aAAaD;IAEtC,IAAII,YAAY;QACd,OAAO;YACLC,WAAWR,QAAQO;YACnBE,MAAMF;YACNG,MAAML;QACR;IACF;IAEA,MAAMM,YAAYV,QAAQE,UAAU;IACpC,IAAIQ,cAAcR,YAAYG,aAAa,IAAI;QAC7C,uCAAuC;QACvC,OAAO;IACT;IAEA,OAAOJ,8BAA8BS,WAAWP,cAAcC,aAAaC,aAAa;AAC1F"}