@sanity/cli-core 0.0.0-20260528100500 → 0.0.0-20260610082142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_exports/index.d.ts +26 -7
- package/dist/_exports/index.js +1 -0
- package/dist/_exports/index.js.map +1 -1
- package/dist/config/cli/getCliConfig.js +7 -0
- package/dist/config/cli/getCliConfig.js.map +1 -1
- package/dist/config/cli/getCliConfigSync.js +6 -0
- package/dist/config/cli/getCliConfigSync.js.map +1 -1
- package/dist/config/cli/schemas.js +0 -3
- package/dist/config/cli/schemas.js.map +1 -1
- package/dist/config/cli/types/cliConfig.js.map +1 -1
- package/dist/config/cli/workbenchApp.js +89 -0
- package/dist/config/cli/workbenchApp.js.map +1 -0
- package/package.json +3 -3
package/dist/_exports/index.d.ts
CHANGED
|
@@ -87,13 +87,6 @@ export declare interface CliConfig {
|
|
|
87
87
|
*/
|
|
88
88
|
autoUpdates?: boolean;
|
|
89
89
|
};
|
|
90
|
-
/**
|
|
91
|
-
* Enable federated builds & dev environments for your studio or application.
|
|
92
|
-
* @experimental
|
|
93
|
-
*/
|
|
94
|
-
federation?: {
|
|
95
|
-
enabled: boolean;
|
|
96
|
-
};
|
|
97
90
|
/** Define the GraphQL APIs that the CLI can deploy and interact with */
|
|
98
91
|
graphql?: Array<{
|
|
99
92
|
filterSuffix?: string;
|
|
@@ -748,6 +741,32 @@ export declare function isStaging(): boolean;
|
|
|
748
741
|
*/
|
|
749
742
|
export declare function isStudioConfig(value: unknown): boolean;
|
|
750
743
|
|
|
744
|
+
/**
|
|
745
|
+
* Whether `app` is a branded `unstable_defineApp(...)` result — the sole
|
|
746
|
+
* workbench opt-in. Mirrors `@sanity/federation`'s `isWorkbenchApp` without the
|
|
747
|
+
* runtime dependency, narrowing to the shared `app` config plus the
|
|
748
|
+
* workbench-only fields a branded result carries: its `name`, dock panel
|
|
749
|
+
* `views`, and background worker `services`. The shape is inlined rather than
|
|
750
|
+
* a named export since callers reach it only through this predicate; `type`
|
|
751
|
+
* uses the same literals federation does so `views`/`services` stay assignable
|
|
752
|
+
* to `DefineAppInput['views' | 'services']` downstream.
|
|
753
|
+
*/
|
|
754
|
+
export declare function isWorkbenchApp(
|
|
755
|
+
app: CliConfig["app"],
|
|
756
|
+
): app is NonNullable<CliConfig["app"]> & {
|
|
757
|
+
name: string;
|
|
758
|
+
services?: {
|
|
759
|
+
name: string;
|
|
760
|
+
src: string;
|
|
761
|
+
type: "worker";
|
|
762
|
+
}[];
|
|
763
|
+
views?: {
|
|
764
|
+
name: string;
|
|
765
|
+
src: string;
|
|
766
|
+
type: "panel";
|
|
767
|
+
}[];
|
|
768
|
+
};
|
|
769
|
+
|
|
751
770
|
/**
|
|
752
771
|
* Mocks a browser-like environment for processes in the main thread by:
|
|
753
772
|
* - Injecting browser globals (window, document, ResizeObserver, etc.)
|
package/dist/_exports/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from '../config/cli/getCliConfig.js';
|
|
2
2
|
export * from '../config/cli/getCliConfigSync.js';
|
|
3
|
+
export { isWorkbenchApp } from '../config/cli/workbenchApp.js';
|
|
3
4
|
export * from '../config/findProjectRoot.js';
|
|
4
5
|
export * from '../config/findProjectRootSync.js';
|
|
5
6
|
export * from '../config/studio/getStudioConfig.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_exports/index.ts"],"sourcesContent":["export * from '../config/cli/getCliConfig.js'\nexport * from '../config/cli/getCliConfigSync.js'\nexport {type CliConfig} from '../config/cli/types/cliConfig.js'\nexport {type UserViteConfig} from '../config/cli/types/userViteConfig.js'\nexport * from '../config/findProjectRoot.js'\nexport * from '../config/findProjectRootSync.js'\nexport * from '../config/studio/getStudioConfig.js'\nexport * from '../config/studio/getStudioWorkspaces.js'\nexport * from '../config/studio/isStudioConfig.js'\nexport * from '../config/util/findConfigsPaths.js'\nexport * from '../config/util/findStudioConfigPath.js'\nexport {type ProjectRootResult} from '../config/util/recursivelyResolveProjectRoot.js'\nexport * from '../debug.js'\nexport * from '../errors/NonInteractiveError.js'\nexport * from '../errors/NotFoundError.js'\nexport * from '../errors/ProjectRootNotFoundError.js'\nexport * from '../exitCodes.js'\nexport * from '../loaders/studio/studioWorkerTask.js'\nexport * from '../loaders/tsx/tsxWorkerTask.js'\nexport * from '../SanityCommand.js'\nexport * from '../services/apiClient.js'\nexport * from '../services/cliUserConfig.js'\nexport * from '../services/getCliToken.js'\nexport {\n clearCliTelemetry,\n CLI_TELEMETRY_SYMBOL,\n getCliTelemetry,\n setCliTelemetry,\n} from '../telemetry/getCliTelemetry.js'\nexport {getTelemetryBaseInfo} from '../telemetry/getTelemetryBaseInfo.js'\nexport {noopLogger} from '../telemetry/noopTelemetry.js'\nexport {\n type CLITelemetryStore,\n type ConsentInformation,\n type TelemetryUserProperties,\n} from '../telemetry/types.js'\nexport {type Output, type SanityOrgUser} from '../types.js'\nexport {doImport} from '../util/doImport.js'\nexport * from '../util/environment/mockBrowserEnvironment.js'\nexport * from '../util/getLocalPackageVersion.js'\nexport * from '../util/getSanityConfigDir.js'\nexport * from '../util/getSanityEnvVar.js'\nexport * from '../util/getSanityUrl.js'\nexport * from '../util/getWorkspace.js'\nexport * from '../util/importModule.js'\nexport * from '../util/isCi.js'\nexport * from '../util/isInteractive.js'\nexport * from '../util/isStaging.js'\nexport * from '../util/normalizePath.js'\nexport * from '../util/promisifyWorker.js'\nexport * from '../util/readPackageJson.js'\nexport * from '../util/resolveLocalPackage.js'\nexport * from '../util/safeStructuredClone.js'\nexport * from '../ux/colorizeJson.js'\nexport * from '../ux/timer.js'\n"],"names":["clearCliTelemetry","CLI_TELEMETRY_SYMBOL","getCliTelemetry","setCliTelemetry","getTelemetryBaseInfo","noopLogger","doImport"],"mappings":"AAAA,cAAc,gCAA+B;AAC7C,cAAc,oCAAmC;AAGjD,cAAc,+BAA8B;AAC5C,cAAc,mCAAkC;AAChD,cAAc,sCAAqC;AACnD,cAAc,0CAAyC;AACvD,cAAc,qCAAoC;AAClD,cAAc,qCAAoC;AAClD,cAAc,yCAAwC;AAEtD,cAAc,cAAa;AAC3B,cAAc,mCAAkC;AAChD,cAAc,6BAA4B;AAC1C,cAAc,wCAAuC;AACrD,cAAc,kBAAiB;AAC/B,cAAc,wCAAuC;AACrD,cAAc,kCAAiC;AAC/C,cAAc,sBAAqB;AACnC,cAAc,2BAA0B;AACxC,cAAc,+BAA8B;AAC5C,cAAc,6BAA4B;AAC1C,
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/index.ts"],"sourcesContent":["export * from '../config/cli/getCliConfig.js'\nexport * from '../config/cli/getCliConfigSync.js'\nexport {type CliConfig} from '../config/cli/types/cliConfig.js'\nexport {type UserViteConfig} from '../config/cli/types/userViteConfig.js'\nexport {isWorkbenchApp} from '../config/cli/workbenchApp.js'\nexport * from '../config/findProjectRoot.js'\nexport * from '../config/findProjectRootSync.js'\nexport * from '../config/studio/getStudioConfig.js'\nexport * from '../config/studio/getStudioWorkspaces.js'\nexport * from '../config/studio/isStudioConfig.js'\nexport * from '../config/util/findConfigsPaths.js'\nexport * from '../config/util/findStudioConfigPath.js'\nexport {type ProjectRootResult} from '../config/util/recursivelyResolveProjectRoot.js'\nexport * from '../debug.js'\nexport * from '../errors/NonInteractiveError.js'\nexport * from '../errors/NotFoundError.js'\nexport * from '../errors/ProjectRootNotFoundError.js'\nexport * from '../exitCodes.js'\nexport * from '../loaders/studio/studioWorkerTask.js'\nexport * from '../loaders/tsx/tsxWorkerTask.js'\nexport * from '../SanityCommand.js'\nexport * from '../services/apiClient.js'\nexport * from '../services/cliUserConfig.js'\nexport * from '../services/getCliToken.js'\nexport {\n clearCliTelemetry,\n CLI_TELEMETRY_SYMBOL,\n getCliTelemetry,\n setCliTelemetry,\n} from '../telemetry/getCliTelemetry.js'\nexport {getTelemetryBaseInfo} from '../telemetry/getTelemetryBaseInfo.js'\nexport {noopLogger} from '../telemetry/noopTelemetry.js'\nexport {\n type CLITelemetryStore,\n type ConsentInformation,\n type TelemetryUserProperties,\n} from '../telemetry/types.js'\nexport {type Output, type SanityOrgUser} from '../types.js'\nexport {doImport} from '../util/doImport.js'\nexport * from '../util/environment/mockBrowserEnvironment.js'\nexport * from '../util/getLocalPackageVersion.js'\nexport * from '../util/getSanityConfigDir.js'\nexport * from '../util/getSanityEnvVar.js'\nexport * from '../util/getSanityUrl.js'\nexport * from '../util/getWorkspace.js'\nexport * from '../util/importModule.js'\nexport * from '../util/isCi.js'\nexport * from '../util/isInteractive.js'\nexport * from '../util/isStaging.js'\nexport * from '../util/normalizePath.js'\nexport * from '../util/promisifyWorker.js'\nexport * from '../util/readPackageJson.js'\nexport * from '../util/resolveLocalPackage.js'\nexport * from '../util/safeStructuredClone.js'\nexport * from '../ux/colorizeJson.js'\nexport * from '../ux/timer.js'\n"],"names":["isWorkbenchApp","clearCliTelemetry","CLI_TELEMETRY_SYMBOL","getCliTelemetry","setCliTelemetry","getTelemetryBaseInfo","noopLogger","doImport"],"mappings":"AAAA,cAAc,gCAA+B;AAC7C,cAAc,oCAAmC;AAGjD,SAAQA,cAAc,QAAO,gCAA+B;AAC5D,cAAc,+BAA8B;AAC5C,cAAc,mCAAkC;AAChD,cAAc,sCAAqC;AACnD,cAAc,0CAAyC;AACvD,cAAc,qCAAoC;AAClD,cAAc,qCAAoC;AAClD,cAAc,yCAAwC;AAEtD,cAAc,cAAa;AAC3B,cAAc,mCAAkC;AAChD,cAAc,6BAA4B;AAC1C,cAAc,wCAAuC;AACrD,cAAc,kBAAiB;AAC/B,cAAc,wCAAuC;AACrD,cAAc,kCAAiC;AAC/C,cAAc,sBAAqB;AACnC,cAAc,2BAA0B;AACxC,cAAc,+BAA8B;AAC5C,cAAc,6BAA4B;AAC1C,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,eAAe,QACV,kCAAiC;AACxC,SAAQC,oBAAoB,QAAO,uCAAsC;AACzE,SAAQC,UAAU,QAAO,gCAA+B;AAOxD,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,cAAc,gDAA+C;AAC7D,cAAc,oCAAmC;AACjD,cAAc,gCAA+B;AAC7C,cAAc,6BAA4B;AAC1C,cAAc,0BAAyB;AACvC,cAAc,0BAAyB;AACvC,cAAc,0BAAyB;AACvC,cAAc,kBAAiB;AAC/B,cAAc,2BAA0B;AACxC,cAAc,uBAAsB;AACpC,cAAc,2BAA0B;AACxC,cAAc,6BAA4B;AAC1C,cAAc,6BAA4B;AAC1C,cAAc,iCAAgC;AAC9C,cAAc,iCAAgC;AAC9C,cAAc,wBAAuB;AACrC,cAAc,iBAAgB"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
2
3
|
import { debug } from '../../debug.js';
|
|
3
4
|
import { NotFoundError } from '../../errors/NotFoundError.js';
|
|
4
5
|
import { importModule } from '../../util/importModule.js';
|
|
5
6
|
import { findPathForFiles } from '../util/findConfigsPaths.js';
|
|
6
7
|
import { cliConfigSchema } from './schemas.js';
|
|
8
|
+
import { isWorkbenchApp, parseWorkbenchCliConfig } from './workbenchApp.js';
|
|
7
9
|
const cache = new Map();
|
|
8
10
|
/**
|
|
9
11
|
* Get the CLI config for a project, given the root path.
|
|
@@ -81,6 +83,11 @@ const cache = new Map();
|
|
|
81
83
|
cause: err
|
|
82
84
|
});
|
|
83
85
|
}
|
|
86
|
+
// Branch as early as possible: a branded `unstable_defineApp(...)` opts into
|
|
87
|
+
// workbench behavior, so its `app` skips the legacy `app` schema entirely.
|
|
88
|
+
if (isWorkbenchApp(cliConfig?.app)) {
|
|
89
|
+
return parseWorkbenchCliConfig(cliConfig, dirname(configPath));
|
|
90
|
+
}
|
|
84
91
|
const { data, error, success } = cliConfigSchema.safeParse(cliConfig);
|
|
85
92
|
if (!success) {
|
|
86
93
|
debug(`Invalid CLI config: ${error.message}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/config/cli/getCliConfig.ts"],"sourcesContent":["import {createRequire} from 'node:module'\n\nimport {debug} from '../../debug.js'\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {importModule} from '../../util/importModule.js'\nimport {findPathForFiles} from '../util/findConfigsPaths.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\n\nconst cache = new Map<string, Promise<CliConfig>>()\n\n/**\n * Get the CLI config for a project, given the root path.\n *\n * Results are cached in-memory keyed by rootPath for the lifetime of the\n * process. Since the CLI always runs from a single project root, the config\n * won't change during a command's execution, so caching avoids redundant\n * filesystem reads and jiti imports from the prerun hook, SanityCommand\n * helpers, and action files.\n *\n * If loading fails the cached promise is evicted so the next call retries.\n *\n * Long-lived processes that need to observe edits to `sanity.cli.(ts|js)`\n * (e.g. a dev-server watcher) should use {@link getCliConfigUncached}\n * instead — it bypasses both this in-memory cache and Node's module cache.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfig(rootPath: string): Promise<CliConfig> {\n const cached = cache.get(rootPath)\n if (cached) {\n return cached\n }\n\n const promise = getCliConfigUncached(rootPath).catch((err) => {\n cache.delete(rootPath)\n throw err\n })\n\n cache.set(rootPath, promise)\n return promise\n}\n\n/**\n * Read the CLI config for a project from disk, bypassing both the\n * `getCliConfig` in-memory cache and Node's module cache. Each call locates\n * `sanity.cli.(ts|js)`, drops any prior jiti compilation from `require.cache`,\n * re-imports, and re-validates.\n *\n * Use this when the config file is expected to change during the process's\n * lifetime — typically a dev-server watcher that needs the new values picked\n * up after each save. One-shot CLI invocations should prefer\n * {@link getCliConfig} so the prerun hook, SanityCommand helpers, and action\n * files share a single load.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The freshly loaded CLI config\n * @internal\n */\nexport async function getCliConfigUncached(rootPath: string): Promise<CliConfig> {\n const paths = await findPathForFiles(rootPath, ['sanity.cli.ts', 'sanity.cli.js'])\n const configPaths = paths.filter((path) => path.exists)\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(\n `Multiple CLI config files found (${configPaths.map((path) => path.path).join(', ')})`,\n )\n }\n\n const configPath = configPaths[0].path\n\n debug(`Loading CLI config from: ${configPath}`)\n\n // Drop any cached compilation of this file from Node's CJS module cache\n // (jiti compiles `sanity.cli.ts` to CJS and registers it via `require.cache`).\n // Without this, repeated calls would receive the previously imported module\n // even though the file on disk has changed. No-op on first load.\n const cjsRequire = createRequire(import.meta.url)\n delete cjsRequire.cache[configPath]\n\n let cliConfig: CliConfig | undefined\n try {\n const result = await importModule<CliConfig>(configPath)\n\n debug('CLI config loaded: %o', result)\n\n cliConfig = result\n } catch (err) {\n debug('Failed to load CLI config in worker thread: %s', err)\n\n throw new Error('CLI config cannot be loaded', {cause: err})\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n debug(`Invalid CLI config: ${error.message}`)\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n return data\n}\n"],"names":["createRequire","debug","NotFoundError","importModule","findPathForFiles","cliConfigSchema","cache","Map","getCliConfig","rootPath","cached","get","promise","getCliConfigUncached","catch","err","delete","set","paths","configPaths","filter","path","exists","length","Error","map","join","configPath","cjsRequire","url","cliConfig","result","cause","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,aAAa,QAAO,cAAa;
|
|
1
|
+
{"version":3,"sources":["../../../src/config/cli/getCliConfig.ts"],"sourcesContent":["import {createRequire} from 'node:module'\nimport {dirname} from 'node:path'\n\nimport {debug} from '../../debug.js'\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {importModule} from '../../util/importModule.js'\nimport {findPathForFiles} from '../util/findConfigsPaths.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, parseWorkbenchCliConfig} from './workbenchApp.js'\n\nconst cache = new Map<string, Promise<CliConfig>>()\n\n/**\n * Get the CLI config for a project, given the root path.\n *\n * Results are cached in-memory keyed by rootPath for the lifetime of the\n * process. Since the CLI always runs from a single project root, the config\n * won't change during a command's execution, so caching avoids redundant\n * filesystem reads and jiti imports from the prerun hook, SanityCommand\n * helpers, and action files.\n *\n * If loading fails the cached promise is evicted so the next call retries.\n *\n * Long-lived processes that need to observe edits to `sanity.cli.(ts|js)`\n * (e.g. a dev-server watcher) should use {@link getCliConfigUncached}\n * instead — it bypasses both this in-memory cache and Node's module cache.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfig(rootPath: string): Promise<CliConfig> {\n const cached = cache.get(rootPath)\n if (cached) {\n return cached\n }\n\n const promise = getCliConfigUncached(rootPath).catch((err) => {\n cache.delete(rootPath)\n throw err\n })\n\n cache.set(rootPath, promise)\n return promise\n}\n\n/**\n * Read the CLI config for a project from disk, bypassing both the\n * `getCliConfig` in-memory cache and Node's module cache. Each call locates\n * `sanity.cli.(ts|js)`, drops any prior jiti compilation from `require.cache`,\n * re-imports, and re-validates.\n *\n * Use this when the config file is expected to change during the process's\n * lifetime — typically a dev-server watcher that needs the new values picked\n * up after each save. One-shot CLI invocations should prefer\n * {@link getCliConfig} so the prerun hook, SanityCommand helpers, and action\n * files share a single load.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The freshly loaded CLI config\n * @internal\n */\nexport async function getCliConfigUncached(rootPath: string): Promise<CliConfig> {\n const paths = await findPathForFiles(rootPath, ['sanity.cli.ts', 'sanity.cli.js'])\n const configPaths = paths.filter((path) => path.exists)\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(\n `Multiple CLI config files found (${configPaths.map((path) => path.path).join(', ')})`,\n )\n }\n\n const configPath = configPaths[0].path\n\n debug(`Loading CLI config from: ${configPath}`)\n\n // Drop any cached compilation of this file from Node's CJS module cache\n // (jiti compiles `sanity.cli.ts` to CJS and registers it via `require.cache`).\n // Without this, repeated calls would receive the previously imported module\n // even though the file on disk has changed. No-op on first load.\n const cjsRequire = createRequire(import.meta.url)\n delete cjsRequire.cache[configPath]\n\n let cliConfig: CliConfig | undefined\n try {\n const result = await importModule<CliConfig>(configPath)\n\n debug('CLI config loaded: %o', result)\n\n cliConfig = result\n } catch (err) {\n debug('Failed to load CLI config in worker thread: %s', err)\n\n throw new Error('CLI config cannot be loaded', {cause: err})\n }\n\n // Branch as early as possible: a branded `unstable_defineApp(...)` opts into\n // workbench behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, dirname(configPath))\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n debug(`Invalid CLI config: ${error.message}`)\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n return data\n}\n"],"names":["createRequire","dirname","debug","NotFoundError","importModule","findPathForFiles","cliConfigSchema","isWorkbenchApp","parseWorkbenchCliConfig","cache","Map","getCliConfig","rootPath","cached","get","promise","getCliConfigUncached","catch","err","delete","set","paths","configPaths","filter","path","exists","length","Error","map","join","configPath","cjsRequire","url","cliConfig","result","cause","app","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,aAAa,QAAO,cAAa;AACzC,SAAQC,OAAO,QAAO,YAAW;AAEjC,SAAQC,KAAK,QAAO,iBAAgB;AACpC,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,gBAAgB,QAAO,8BAA6B;AAC5D,SAAQC,eAAe,QAAO,eAAc;AAE5C,SAAQC,cAAc,EAAEC,uBAAuB,QAAO,oBAAmB;AAEzE,MAAMC,QAAQ,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;IAC5D;IAEA,6EAA6E;IAC7E,2EAA2E;IAC3E,IAAIX,eAAe0B,WAAWG,MAAM;QAClC,OAAO5B,wBAAwByB,WAAWhC,QAAQ6B;IACpD;IAEA,MAAM,EAACO,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGjC,gBAAgBkC,SAAS,CAACP;IACzD,IAAI,CAACM,SAAS;QACZrC,MAAM,CAAC,oBAAoB,EAAEoC,MAAMG,OAAO,EAAE;QAC5C,MAAM,IAAId,MAAM,CAAC,oBAAoB,EAAEW,MAAMG,OAAO,EAAE,EAAE;YAACN,OAAOG;QAAK;IACvE;IAEA,OAAOD;AACT"}
|
|
@@ -5,6 +5,7 @@ import { register } from 'tsx/esm/api';
|
|
|
5
5
|
import { NotFoundError } from '../../errors/NotFoundError.js';
|
|
6
6
|
import { tryGetDefaultExport } from '../../util/tryGetDefaultExport.js';
|
|
7
7
|
import { cliConfigSchema } from './schemas.js';
|
|
8
|
+
import { isWorkbenchApp, parseWorkbenchCliConfig } from './workbenchApp.js';
|
|
8
9
|
/**
|
|
9
10
|
* Get the CLI config for a project synchronously, given the root path.
|
|
10
11
|
*
|
|
@@ -39,6 +40,11 @@ import { cliConfigSchema } from './schemas.js';
|
|
|
39
40
|
} finally{
|
|
40
41
|
unregister();
|
|
41
42
|
}
|
|
43
|
+
// Branch as early as possible: a branded `unstable_defineApp(...)` opts into
|
|
44
|
+
// workbench behavior, so its `app` skips the legacy `app` schema entirely.
|
|
45
|
+
if (isWorkbenchApp(cliConfig?.app)) {
|
|
46
|
+
return parseWorkbenchCliConfig(cliConfig, rootPath);
|
|
47
|
+
}
|
|
42
48
|
const { data, error, success } = cliConfigSchema.safeParse(cliConfig);
|
|
43
49
|
if (!success) {
|
|
44
50
|
throw new Error(`Invalid CLI config: ${error.message}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/config/cli/getCliConfigSync.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {createRequire} from 'node:module'\nimport {join} from 'node:path'\n\nimport {register} from 'tsx/esm/api'\n\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {tryGetDefaultExport} from '../../util/tryGetDefaultExport.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\n\n/**\n * Get the CLI config for a project synchronously, given the root path.\n *\n * This loads the CLI config in the main thread using tsx/register for TypeScript support.\n * Note: This is a synchronous operation and does not use worker threads like the async version.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfigSync(rootPath: string): CliConfig {\n const possiblePaths = ['sanity.cli.ts', 'sanity.cli.js'].map((file) => join(rootPath, file))\n const configPaths = possiblePaths.filter((path) => existsSync(path))\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(`Multiple CLI config files found (${configPaths.join(', ')})`)\n }\n\n const configPath = configPaths[0]\n\n // Register tsx for TypeScript support\n const unregister = register()\n\n let cliConfig: CliConfig | undefined\n try {\n // Use createRequire for synchronous loading in ESM contexts\n // This works when tsx loader is active\n const require = createRequire(import.meta.url)\n const loaded = require(configPath)\n cliConfig = tryGetDefaultExport(loaded) as CliConfig | undefined\n } finally {\n unregister()\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`)\n }\n\n // There is a minor difference here because of the `vite` property and how the types\n // aren't as specific as our manually typed `CliConfig` type, thus the cast.\n return data as CliConfig\n}\n"],"names":["existsSync","createRequire","join","register","NotFoundError","tryGetDefaultExport","cliConfigSchema","getCliConfigSync","rootPath","possiblePaths","map","file","configPaths","filter","path","length","Error","configPath","unregister","cliConfig","require","url","loaded","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,aAAa,QAAO,cAAa;AACzC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,QAAQ,QAAO,cAAa;AAEpC,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,eAAe,QAAO,eAAc;
|
|
1
|
+
{"version":3,"sources":["../../../src/config/cli/getCliConfigSync.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {createRequire} from 'node:module'\nimport {join} from 'node:path'\n\nimport {register} from 'tsx/esm/api'\n\nimport {NotFoundError} from '../../errors/NotFoundError.js'\nimport {tryGetDefaultExport} from '../../util/tryGetDefaultExport.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\nimport {isWorkbenchApp, parseWorkbenchCliConfig} from './workbenchApp.js'\n\n/**\n * Get the CLI config for a project synchronously, given the root path.\n *\n * This loads the CLI config in the main thread using tsx/register for TypeScript support.\n * Note: This is a synchronous operation and does not use worker threads like the async version.\n *\n * @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.\n * @returns The CLI config\n * @internal\n */\nexport function getCliConfigSync(rootPath: string): CliConfig {\n const possiblePaths = ['sanity.cli.ts', 'sanity.cli.js'].map((file) => join(rootPath, file))\n const configPaths = possiblePaths.filter((path) => existsSync(path))\n\n if (configPaths.length === 0) {\n throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`)\n }\n\n if (configPaths.length > 1) {\n throw new Error(`Multiple CLI config files found (${configPaths.join(', ')})`)\n }\n\n const configPath = configPaths[0]\n\n // Register tsx for TypeScript support\n const unregister = register()\n\n let cliConfig: CliConfig | undefined\n try {\n // Use createRequire for synchronous loading in ESM contexts\n // This works when tsx loader is active\n const require = createRequire(import.meta.url)\n const loaded = require(configPath)\n cliConfig = tryGetDefaultExport(loaded) as CliConfig | undefined\n } finally {\n unregister()\n }\n\n // Branch as early as possible: a branded `unstable_defineApp(...)` opts into\n // workbench behavior, so its `app` skips the legacy `app` schema entirely.\n if (isWorkbenchApp(cliConfig?.app)) {\n return parseWorkbenchCliConfig(cliConfig, rootPath)\n }\n\n const {data, error, success} = cliConfigSchema.safeParse(cliConfig)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`)\n }\n\n // There is a minor difference here because of the `vite` property and how the types\n // aren't as specific as our manually typed `CliConfig` type, thus the cast.\n return data as CliConfig\n}\n"],"names":["existsSync","createRequire","join","register","NotFoundError","tryGetDefaultExport","cliConfigSchema","isWorkbenchApp","parseWorkbenchCliConfig","getCliConfigSync","rootPath","possiblePaths","map","file","configPaths","filter","path","length","Error","configPath","unregister","cliConfig","require","url","loaded","app","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,aAAa,QAAO,cAAa;AACzC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,QAAQ,QAAO,cAAa;AAEpC,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,eAAe,QAAO,eAAc;AAE5C,SAAQC,cAAc,EAAEC,uBAAuB,QAAO,oBAAmB;AAEzE;;;;;;;;;CASC,GACD,OAAO,SAASC,iBAAiBC,QAAgB;IAC/C,MAAMC,gBAAgB;QAAC;QAAiB;KAAgB,CAACC,GAAG,CAAC,CAACC,OAASX,KAAKQ,UAAUG;IACtF,MAAMC,cAAcH,cAAcI,MAAM,CAAC,CAACC,OAAShB,WAAWgB;IAE9D,IAAIF,YAAYG,MAAM,KAAK,GAAG;QAC5B,MAAM,IAAIb,cAAc,CAAC,uBAAuB,EAAEM,SAAS,mBAAmB,CAAC;IACjF;IAEA,IAAII,YAAYG,MAAM,GAAG,GAAG;QAC1B,MAAM,IAAIC,MAAM,CAAC,iCAAiC,EAAEJ,YAAYZ,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/E;IAEA,MAAMiB,aAAaL,WAAW,CAAC,EAAE;IAEjC,sCAAsC;IACtC,MAAMM,aAAajB;IAEnB,IAAIkB;IACJ,IAAI;QACF,4DAA4D;QAC5D,uCAAuC;QACvC,MAAMC,UAAUrB,cAAc,YAAYsB,GAAG;QAC7C,MAAMC,SAASF,QAAQH;QACvBE,YAAYhB,oBAAoBmB;IAClC,SAAU;QACRJ;IACF;IAEA,6EAA6E;IAC7E,2EAA2E;IAC3E,IAAIb,eAAec,WAAWI,MAAM;QAClC,OAAOjB,wBAAwBa,WAAWX;IAC5C;IAEA,MAAM,EAACgB,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGtB,gBAAgBuB,SAAS,CAACR;IACzD,IAAI,CAACO,SAAS;QACZ,MAAM,IAAIV,MAAM,CAAC,oBAAoB,EAAES,MAAMG,OAAO,EAAE;IACxD;IAEA,oFAAoF;IACpF,4EAA4E;IAC5E,OAAOJ;AACT"}
|
|
@@ -18,9 +18,6 @@ import { z } from 'zod/mini';
|
|
|
18
18
|
appId: z.optional(z.string()),
|
|
19
19
|
autoUpdates: z.optional(z.boolean())
|
|
20
20
|
})),
|
|
21
|
-
federation: z.optional(z.object({
|
|
22
|
-
enabled: z.boolean()
|
|
23
|
-
})),
|
|
24
21
|
graphql: z.optional(z.array(z.object({
|
|
25
22
|
filterSuffix: z.optional(z.string()),
|
|
26
23
|
generation: z.optional(z.enum([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/config/cli/schemas.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {z} from 'zod/mini'\n\nimport {type CliConfig, type TypeGenConfig} from './types/cliConfig'\nimport {type UserViteConfig} from './types/userViteConfig'\n\n/**\n * @public\n */\nexport const cliConfigSchema = z.object({\n api: z.optional(\n z.object({\n dataset: z.optional(z.string()),\n projectId: z.optional(z.string()),\n }),\n ),\n\n app: z.optional(\n z.object({\n entry: z.optional(z.string()),\n icon: z.optional(z.string()),\n id: z.optional(z.string()),\n organizationId: z.optional(z.string()),\n title: z.optional(z.string()),\n }),\n ),\n\n autoUpdates: z.optional(z.boolean()),\n\n deployment: z.optional(\n z.object({\n appId: z.optional(z.string()),\n autoUpdates: z.optional(z.boolean()),\n }),\n ),\n\n
|
|
1
|
+
{"version":3,"sources":["../../../src/config/cli/schemas.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\nimport {z} from 'zod/mini'\n\nimport {type CliConfig, type TypeGenConfig} from './types/cliConfig'\nimport {type UserViteConfig} from './types/userViteConfig'\n\n/**\n * @public\n */\nexport const cliConfigSchema = z.object({\n api: z.optional(\n z.object({\n dataset: z.optional(z.string()),\n projectId: z.optional(z.string()),\n }),\n ),\n\n app: z.optional(\n z.object({\n entry: z.optional(z.string()),\n icon: z.optional(z.string()),\n id: z.optional(z.string()),\n organizationId: z.optional(z.string()),\n title: z.optional(z.string()),\n }),\n ),\n\n autoUpdates: z.optional(z.boolean()),\n\n deployment: z.optional(\n z.object({\n appId: z.optional(z.string()),\n autoUpdates: z.optional(z.boolean()),\n }),\n ),\n\n graphql: z.optional(\n z.array(\n z.object({\n filterSuffix: z.optional(z.string()),\n generation: z.optional(z.enum(['gen1', 'gen2', 'gen3'])),\n id: z.optional(z.string()),\n nonNullDocumentFields: z.optional(z.boolean()),\n playground: z.optional(z.boolean()),\n source: z.optional(z.string()),\n tag: z.optional(z.string()),\n workspace: z.optional(z.string()),\n }),\n ),\n ),\n\n mediaLibrary: z.optional(\n z.object({\n aspectsPath: z.optional(z.string()),\n }),\n ),\n\n project: z.optional(\n z.object({\n basePath: z.optional(z.string()),\n }),\n ),\n\n reactCompiler: z.optional(z.custom<ReactCompilerConfig>()),\n\n reactStrictMode: z.optional(z.boolean()),\n\n schemaExtraction: z.optional(\n z.object({\n enabled: z.optional(z.boolean()),\n enforceRequiredFields: z.optional(z.boolean()),\n path: z.optional(z.string()),\n watchPatterns: z.optional(z.array(z.string())),\n workspace: z.optional(z.string()),\n }),\n ),\n\n server: z.optional(\n z.object({\n hostname: z.optional(z.string()),\n port: z.optional(z.number()),\n }),\n ),\n\n studioHost: z.optional(z.string()),\n\n vite: z.optional(z.custom<UserViteConfig>()),\n\n typegen: z.optional(z.custom<Partial<TypeGenConfig> & {enabled?: boolean}>()),\n}) satisfies z.core.$ZodType<CliConfig>\n"],"names":["z","cliConfigSchema","object","api","optional","dataset","string","projectId","app","entry","icon","id","organizationId","title","autoUpdates","boolean","deployment","appId","graphql","array","filterSuffix","generation","enum","nonNullDocumentFields","playground","source","tag","workspace","mediaLibrary","aspectsPath","project","basePath","reactCompiler","custom","reactStrictMode","schemaExtraction","enabled","enforceRequiredFields","path","watchPatterns","server","hostname","port","number","studioHost","vite","typegen"],"mappings":"AACA,SAAQA,CAAC,QAAO,WAAU;AAK1B;;CAEC,GACD,OAAO,MAAMC,kBAAkBD,EAAEE,MAAM,CAAC;IACtCC,KAAKH,EAAEI,QAAQ,CACbJ,EAAEE,MAAM,CAAC;QACPG,SAASL,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QAC5BC,WAAWP,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAChC;IAGFE,KAAKR,EAAEI,QAAQ,CACbJ,EAAEE,MAAM,CAAC;QACPO,OAAOT,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QAC1BI,MAAMV,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACzBK,IAAIX,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACvBM,gBAAgBZ,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACnCO,OAAOb,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAC5B;IAGFQ,aAAad,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;IAEjCC,YAAYhB,EAAEI,QAAQ,CACpBJ,EAAEE,MAAM,CAAC;QACPe,OAAOjB,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QAC1BQ,aAAad,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;IACnC;IAGFG,SAASlB,EAAEI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BJ,EAAEE,MAAM,CAAC;QACPuC,UAAUzC,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QAC7BoC,MAAM1C,EAAEI,QAAQ,CAACJ,EAAE2C,MAAM;IAC3B;IAGFC,YAAY5C,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAE/BuC,MAAM7C,EAAEI,QAAQ,CAACJ,EAAEiC,MAAM;IAEzBa,SAAS9C,EAAEI,QAAQ,CAACJ,EAAEiC,MAAM;AAC9B,GAAuC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/config/cli/types/cliConfig.ts"],"sourcesContent":["import {type PluginOptions as ReactCompilerConfig} from 'babel-plugin-react-compiler'\n\nimport {type UserViteConfig} from './userViteConfig'\n\nexport interface TypeGenConfig {\n formatGeneratedCode: boolean\n generates: string\n overloadClientMethods: boolean\n path: string | string[]\n schema: string\n}\n\n/**\n * @public\n */\nexport interface CliConfig {\n /** The project ID and dataset the Sanity CLI should use to run its commands */\n api?: {\n dataset?: string\n projectId?: string\n }\n\n /** Configuration for custom Sanity apps built with the App SDK */\n app?: {\n /** The entrypoint for your custom app. By default, `src/App.tsx` */\n entry?: string\n /**\n * Path to an icon file relative to project root.\n * The file must be an SVG.\n */\n icon?: string\n /** @deprecated Use deployment.appId */\n id?: string\n /** The ID for the Sanity organization that manages this application */\n organizationId?: string\n /** The title of the custom app, as it is seen in Dashboard UI */\n title?: string\n }\n\n /** @deprecated Use deployment.autoUpdates */\n autoUpdates?: boolean\n\n /** Options for custom app and Studio deployments */\n deployment?: {\n /**\n * The ID for your custom app or Studio. Generated when deploying your app or Studio for the first time.\n * Get your app ID by either:\n * 1. Checking the output of `sanity deploy`, or\n * 2. Checking your project’s Studio tab at https://sanity.io/manage\n *\n * @remarks This is required for all custom app deployments, and for Studios opting in to fine grained version control.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity#k0896ed4574b7}\n */\n appId?: string\n /**\n * Enable automatic updates for your Studio or custom app’s Sanity dependencies.\n * {@link https://www.sanity.io/docs/studio/latest-version-of-sanity}\n */\n autoUpdates?: boolean\n }\n\n /** Define the GraphQL APIs that the CLI can deploy and interact with */\n graphql?: Array<{\n filterSuffix?: string\n generation?: 'gen1' | 'gen2' | 'gen3'\n id?: string\n nonNullDocumentFields?: boolean\n playground?: boolean\n source?: string\n tag?: string\n workspace?: string\n }>\n\n /** Configuration for the Media Library */\n mediaLibrary?: {\n /** The path to the Media Library aspects directory. When using the CLI to manage aspects, this is the directory they will be read from and written to. */\n aspectsPath?: string\n }\n\n /** Contains the property `basePath` which lets you change the top-level slug for the Studio. You typically need to set this if you embed the Studio in another application where it is one of many routes. Defaults to an empty string. */\n project?: {\n basePath?: string\n }\n\n /** Configuration options for React Compiler */\n reactCompiler?: ReactCompilerConfig\n\n /** Wraps the Studio in \\<React.StrictMode\\> root to aid in flagging potential problems related to concurrent features (startTransition, useTransition, useDeferredValue, Suspense). Can also be enabled by setting SANITY_STUDIO_REACT_STRICT_MODE=\"true\"|\"false\". It only applies to sanity dev in development mode and is ignored in sanity build and in production. Defaults to false. */\n reactStrictMode?: boolean\n\n /**\n * Configuration for schema extraction (`sanity schema extract`)\n */\n schemaExtraction?: {\n /**\n * Enable schema extraction as part of sanity dev and sanity build\n */\n enabled?: boolean\n\n /**\n * When true, schema fields marked as required will be non-optional in the output.\n * Defaults to `false`\n */\n enforceRequiredFields?: boolean\n\n /**\n * Output path for the extracted schema file.\n * Defaults to `schema.json` in the working directory.\n */\n path?: string\n\n /**\n * Additional glob patterns to watch for schema changes in watch mode.\n * These extend the default patterns:\n * - `sanity.config.{js,jsx,ts,tsx,mjs}`\n * - `schema*\\/**\\/*.{js,jsx,ts,tsx,mjs}`\n */\n watchPatterns?: string[]\n\n /**\n * The name of the workspace to generate a schema for. Required if your Sanity project has more than one\n * workspace.\n */\n workspace?: string\n }\n\n /** Defines the hostname and port that the development server should run on. hostname defaults to localhost, and port to 3333. */\n server?: {\n hostname?: string\n port?: number\n }\n\n /** @deprecated Use deployment.appId */\n studioHost?: string\n\n /**\n * Configuration for Sanity typegen\n */\n typegen?: Partial<TypeGenConfig> & {\n /**\n * Enable typegen as part of sanity dev and sanity build.\n * When enabled, types are generated on startup and when files change.\n * Defaults to `false`\n */\n enabled?: boolean\n }\n\n /** Exposes the default Vite configuration for custom apps and the Studio so it can be changed and extended. */\n vite?: UserViteConfig\n}\n"],"names":[],"mappings":"AAYA;;CAEC,GACD,WAsIC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { cliConfigSchema } from './schemas.js';
|
|
4
|
+
/**
|
|
5
|
+
* The brand `unstable_defineApp` stamps on its result, registered in the global
|
|
6
|
+
* symbol registry. Inlined here rather than imported from `@sanity/federation`
|
|
7
|
+
* so cli-core — the hot path for every CLI command, most of which never touch
|
|
8
|
+
* workbench — doesn't pull that package (and its transitive deps) into startup
|
|
9
|
+
* just for this identity check. `Symbol.for` keys the same global symbol that
|
|
10
|
+
* federation stamps, so the check is identical; the only shared contract is the
|
|
11
|
+
* symbol string, which cli-core already mirrors (see `APPLICATION_TYPES` below).
|
|
12
|
+
*/ const WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp');
|
|
13
|
+
/**
|
|
14
|
+
* Whether `app` is a branded `unstable_defineApp(...)` result — the sole
|
|
15
|
+
* workbench opt-in. Mirrors `@sanity/federation`'s `isWorkbenchApp` without the
|
|
16
|
+
* runtime dependency, narrowing to the shared `app` config plus the
|
|
17
|
+
* workbench-only fields a branded result carries: its `name`, dock panel
|
|
18
|
+
* `views`, and background worker `services`. The shape is inlined rather than
|
|
19
|
+
* a named export since callers reach it only through this predicate; `type`
|
|
20
|
+
* uses the same literals federation does so `views`/`services` stay assignable
|
|
21
|
+
* to `DefineAppInput['views' | 'services']` downstream.
|
|
22
|
+
*/ export function isWorkbenchApp(app) {
|
|
23
|
+
return typeof app === 'object' && app !== null && WORKBENCH_APP_BRAND in app;
|
|
24
|
+
}
|
|
25
|
+
const STUDIO_CONFIG_FILES = [
|
|
26
|
+
'sanity.config.ts',
|
|
27
|
+
'sanity.config.tsx',
|
|
28
|
+
'sanity.config.js',
|
|
29
|
+
'sanity.config.jsx',
|
|
30
|
+
'sanity.config.mjs',
|
|
31
|
+
'sanity.config.cjs'
|
|
32
|
+
];
|
|
33
|
+
// Mirrors `@sanity/federation`'s `ApplicationType` enum. `unstable_defineApp`
|
|
34
|
+
// is a pure identity wrapper that doesn't validate its input, so the loader is
|
|
35
|
+
// the first place an explicit `applicationType` can be checked.
|
|
36
|
+
const APPLICATION_TYPES = [
|
|
37
|
+
'coreApp',
|
|
38
|
+
'studio',
|
|
39
|
+
'canvas',
|
|
40
|
+
'dashboard',
|
|
41
|
+
'media-library',
|
|
42
|
+
'system'
|
|
43
|
+
];
|
|
44
|
+
function isApplicationType(value) {
|
|
45
|
+
return typeof value === 'string' && APPLICATION_TYPES.includes(value);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Infer the application type for a workbench app when `unstable_defineApp`
|
|
49
|
+
* didn't set one: a project with a `sanity.config.*` is a studio, otherwise a
|
|
50
|
+
* core (SDK) app. An explicit `applicationType` always wins.
|
|
51
|
+
*/ function detectApplicationType(projectDir) {
|
|
52
|
+
return STUDIO_CONFIG_FILES.some((file)=>existsSync(join(projectDir, file))) ? 'studio' : 'coreApp';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Parse a config whose `app` is a branded `unstable_defineApp(...)` result.
|
|
56
|
+
* The branded `app` bypasses the legacy `app` object schema (which would strip
|
|
57
|
+
* its identity fields and the brand symbol); every other field is still
|
|
58
|
+
* validated. The brand is preserved so downstream code relies on the
|
|
59
|
+
* `isWorkbenchApp` identity (from `@sanity/federation`) instead of a flag.
|
|
60
|
+
*
|
|
61
|
+
* Resolves `applicationType` here — as early as possible — so studio-vs-app
|
|
62
|
+
* classification is settled once and read off the app everywhere else. The
|
|
63
|
+
* resolved value lands on a clone, never the caller's object, so re-parsing the
|
|
64
|
+
* same `app` for a different directory can't inherit a stale inference.
|
|
65
|
+
*/ export function parseWorkbenchCliConfig(cliConfig, projectDir) {
|
|
66
|
+
const { app, ...rest } = cliConfig;
|
|
67
|
+
const { data, error, success } = cliConfigSchema.safeParse(rest);
|
|
68
|
+
if (!success) {
|
|
69
|
+
throw new Error(`Invalid CLI config: ${error.message}`, {
|
|
70
|
+
cause: error
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const explicit = app.applicationType;
|
|
74
|
+
if (explicit !== undefined && !isApplicationType(explicit)) {
|
|
75
|
+
throw new Error(`Invalid \`applicationType\` "${explicit}" in \`unstable_defineApp\` — expected one of: ${APPLICATION_TYPES.join(', ')}`);
|
|
76
|
+
}
|
|
77
|
+
const applicationType = explicit ?? detectApplicationType(projectDir);
|
|
78
|
+
// Clone the branded app rather than mutating the caller's object. Copying own
|
|
79
|
+
// property descriptors carries over the non-enumerable `unstable_defineApp`
|
|
80
|
+
// brand, which a spread would drop.
|
|
81
|
+
const resolvedApp = Object.defineProperties({}, Object.getOwnPropertyDescriptors(app));
|
|
82
|
+
resolvedApp.applicationType = applicationType;
|
|
83
|
+
return {
|
|
84
|
+
...data,
|
|
85
|
+
app: resolvedApp
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=workbenchApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/config/cli/workbenchApp.ts"],"sourcesContent":["import {existsSync} from 'node:fs'\nimport {join} from 'node:path'\n\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types/cliConfig.js'\n\n/**\n * The brand `unstable_defineApp` stamps on its result, registered in the global\n * symbol registry. Inlined here rather than imported from `@sanity/federation`\n * so cli-core — the hot path for every CLI command, most of which never touch\n * workbench — doesn't pull that package (and its transitive deps) into startup\n * just for this identity check. `Symbol.for` keys the same global symbol that\n * federation stamps, so the check is identical; the only shared contract is the\n * symbol string, which cli-core already mirrors (see `APPLICATION_TYPES` below).\n */\nconst WORKBENCH_APP_BRAND = Symbol.for('sanity.workbench.defineApp')\n\n/**\n * Whether `app` is a branded `unstable_defineApp(...)` result — the sole\n * workbench opt-in. Mirrors `@sanity/federation`'s `isWorkbenchApp` without the\n * runtime dependency, narrowing to the shared `app` config plus the\n * workbench-only fields a branded result carries: its `name`, dock panel\n * `views`, and background worker `services`. The shape is inlined rather than\n * a named export since callers reach it only through this predicate; `type`\n * uses the same literals federation does so `views`/`services` stay assignable\n * to `DefineAppInput['views' | 'services']` downstream.\n */\nexport function isWorkbenchApp(app: CliConfig['app']): app is NonNullable<CliConfig['app']> & {\n name: string\n services?: {name: string; src: string; type: 'worker'}[]\n views?: {name: string; src: string; type: 'panel'}[]\n} {\n return typeof app === 'object' && app !== null && WORKBENCH_APP_BRAND in app\n}\n\nconst STUDIO_CONFIG_FILES = [\n 'sanity.config.ts',\n 'sanity.config.tsx',\n 'sanity.config.js',\n 'sanity.config.jsx',\n 'sanity.config.mjs',\n 'sanity.config.cjs',\n]\n\n// Mirrors `@sanity/federation`'s `ApplicationType` enum. `unstable_defineApp`\n// is a pure identity wrapper that doesn't validate its input, so the loader is\n// the first place an explicit `applicationType` can be checked.\nconst APPLICATION_TYPES = [\n 'coreApp',\n 'studio',\n 'canvas',\n 'dashboard',\n 'media-library',\n 'system',\n] as const\ntype ApplicationType = (typeof APPLICATION_TYPES)[number]\n\nfunction isApplicationType(value: unknown): value is ApplicationType {\n return typeof value === 'string' && (APPLICATION_TYPES as readonly string[]).includes(value)\n}\n\n/**\n * Infer the application type for a workbench app when `unstable_defineApp`\n * didn't set one: a project with a `sanity.config.*` is a studio, otherwise a\n * core (SDK) app. An explicit `applicationType` always wins.\n */\nfunction detectApplicationType(projectDir: string): ApplicationType {\n return STUDIO_CONFIG_FILES.some((file) => existsSync(join(projectDir, file)))\n ? 'studio'\n : 'coreApp'\n}\n\n/**\n * Parse a config whose `app` is a branded `unstable_defineApp(...)` result.\n * The branded `app` bypasses the legacy `app` object schema (which would strip\n * its identity fields and the brand symbol); every other field is still\n * validated. The brand is preserved so downstream code relies on the\n * `isWorkbenchApp` identity (from `@sanity/federation`) instead of a flag.\n *\n * Resolves `applicationType` here — as early as possible — so studio-vs-app\n * classification is settled once and read off the app everywhere else. The\n * resolved value lands on a clone, never the caller's object, so re-parsing the\n * same `app` for a different directory can't inherit a stale inference.\n */\nexport function parseWorkbenchCliConfig(cliConfig: unknown, projectDir: string): CliConfig {\n const {app, ...rest} = cliConfig as Record<string, unknown> & {\n app: Record<string, unknown> & {applicationType?: string}\n }\n const {data, error, success} = cliConfigSchema.safeParse(rest)\n if (!success) {\n throw new Error(`Invalid CLI config: ${error.message}`, {cause: error})\n }\n\n const explicit = app.applicationType\n if (explicit !== undefined && !isApplicationType(explicit)) {\n throw new Error(\n `Invalid \\`applicationType\\` \"${explicit}\" in \\`unstable_defineApp\\` — expected one of: ${APPLICATION_TYPES.join(', ')}`,\n )\n }\n const applicationType = explicit ?? detectApplicationType(projectDir)\n\n // Clone the branded app rather than mutating the caller's object. Copying own\n // property descriptors carries over the non-enumerable `unstable_defineApp`\n // brand, which a spread would drop.\n const resolvedApp = Object.defineProperties({}, Object.getOwnPropertyDescriptors(app)) as Record<\n string,\n unknown\n >\n resolvedApp.applicationType = applicationType\n\n return {...data, app: resolvedApp} as CliConfig\n}\n"],"names":["existsSync","join","cliConfigSchema","WORKBENCH_APP_BRAND","Symbol","for","isWorkbenchApp","app","STUDIO_CONFIG_FILES","APPLICATION_TYPES","isApplicationType","value","includes","detectApplicationType","projectDir","some","file","parseWorkbenchCliConfig","cliConfig","rest","data","error","success","safeParse","Error","message","cause","explicit","applicationType","undefined","resolvedApp","Object","defineProperties","getOwnPropertyDescriptors"],"mappings":"AAAA,SAAQA,UAAU,QAAO,UAAS;AAClC,SAAQC,IAAI,QAAO,YAAW;AAE9B,SAAQC,eAAe,QAAO,eAAc;AAG5C;;;;;;;;CAQC,GACD,MAAMC,sBAAsBC,OAAOC,GAAG,CAAC;AAEvC;;;;;;;;;CASC,GACD,OAAO,SAASC,eAAeC,GAAqB;IAKlD,OAAO,OAAOA,QAAQ,YAAYA,QAAQ,QAAQJ,uBAAuBI;AAC3E;AAEA,MAAMC,sBAAsB;IAC1B;IACA;IACA;IACA;IACA;IACA;CACD;AAED,8EAA8E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20260610082142",
|
|
4
4
|
"description": "Sanity CLI core package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@inquirer/prompts": "^8.3.0",
|
|
55
|
-
"@oclif/core": "^4.
|
|
55
|
+
"@oclif/core": "^4.11.0",
|
|
56
56
|
"@sanity/client": "^7.22.0",
|
|
57
57
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
58
58
|
"boxen": "^8.0.1",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"read-package-up": "^12.0.0",
|
|
69
69
|
"rxjs": "^7.8.2",
|
|
70
70
|
"tsx": "^4.21.0",
|
|
71
|
-
"vite": "^7.3.
|
|
71
|
+
"vite": "^7.3.3",
|
|
72
72
|
"vite-node": "^5.3.0",
|
|
73
73
|
"zod": "^4.3.6"
|
|
74
74
|
},
|