@sanity/cli-core 0.0.0-20260410130107
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/SanityCommand.js +196 -0
- package/dist/SanityCommand.js.map +1 -0
- package/dist/_exports/index.d.ts +1391 -0
- package/dist/_exports/index.js +39 -0
- package/dist/_exports/index.js.map +1 -0
- package/dist/_exports/package-manager.d.ts +33 -0
- package/dist/_exports/package-manager.js +3 -0
- package/dist/_exports/package-manager.js.map +1 -0
- package/dist/_exports/request.d.ts +79 -0
- package/dist/_exports/request.js +7 -0
- package/dist/_exports/request.js.map +1 -0
- package/dist/_exports/ux.d.ts +75 -0
- package/dist/_exports/ux.js +7 -0
- package/dist/_exports/ux.js.map +1 -0
- package/dist/config/cli/getCliConfig.js +68 -0
- package/dist/config/cli/getCliConfig.js.map +1 -0
- package/dist/config/cli/getCliConfigSync.js +51 -0
- package/dist/config/cli/getCliConfigSync.js.map +1 -0
- package/dist/config/cli/schemas.js +62 -0
- package/dist/config/cli/schemas.js.map +1 -0
- package/dist/config/cli/types/cliConfig.js +5 -0
- package/dist/config/cli/types/cliConfig.js.map +1 -0
- package/dist/config/cli/types/userViteConfig.js +5 -0
- package/dist/config/cli/types/userViteConfig.js.map +1 -0
- package/dist/config/findProjectRoot.js +62 -0
- package/dist/config/findProjectRoot.js.map +1 -0
- package/dist/config/findProjectRootSync.js +88 -0
- package/dist/config/findProjectRootSync.js.map +1 -0
- package/dist/config/studio/getStudioConfig.js +13 -0
- package/dist/config/studio/getStudioConfig.js.map +1 -0
- package/dist/config/studio/getStudioWorkspaces.js +63 -0
- package/dist/config/studio/getStudioWorkspaces.js.map +1 -0
- package/dist/config/studio/isStudioConfig.js +19 -0
- package/dist/config/studio/isStudioConfig.js.map +1 -0
- package/dist/config/studio/readStudioConfig.js +82 -0
- package/dist/config/studio/readStudioConfig.js.map +1 -0
- package/dist/config/studio/readStudioConfig.worker.js +25 -0
- package/dist/config/studio/readStudioConfig.worker.js.map +1 -0
- package/dist/config/util/configPathsSync.js +85 -0
- package/dist/config/util/configPathsSync.js.map +1 -0
- package/dist/config/util/findAppConfigPath.js +22 -0
- package/dist/config/util/findAppConfigPath.js.map +1 -0
- package/dist/config/util/findConfigsPaths.js +21 -0
- package/dist/config/util/findConfigsPaths.js.map +1 -0
- package/dist/config/util/findStudioConfigPath.js +52 -0
- package/dist/config/util/findStudioConfigPath.js.map +1 -0
- package/dist/config/util/isSanityV2StudioRoot.js +22 -0
- package/dist/config/util/isSanityV2StudioRoot.js.map +1 -0
- package/dist/config/util/recursivelyResolveProjectRoot.js +28 -0
- package/dist/config/util/recursivelyResolveProjectRoot.js.map +1 -0
- package/dist/debug.js +15 -0
- package/dist/debug.js.map +1 -0
- package/dist/errors/NonInteractiveError.js +18 -0
- package/dist/errors/NonInteractiveError.js.map +1 -0
- package/dist/errors/NotFoundError.js +27 -0
- package/dist/errors/NotFoundError.js.map +1 -0
- package/dist/errors/ProjectRootNotFoundError.js +35 -0
- package/dist/errors/ProjectRootNotFoundError.js.map +1 -0
- package/dist/exitCodes.js +17 -0
- package/dist/exitCodes.js.map +1 -0
- package/dist/loaders/studio/studioWorkerLoader.worker.js +205 -0
- package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -0
- package/dist/loaders/studio/studioWorkerTask.js +90 -0
- package/dist/loaders/studio/studioWorkerTask.js.map +1 -0
- package/dist/loaders/tsx/tsxWorkerLoader.worker.js +11 -0
- package/dist/loaders/tsx/tsxWorkerLoader.worker.js.map +1 -0
- package/dist/loaders/tsx/tsxWorkerTask.js +34 -0
- package/dist/loaders/tsx/tsxWorkerTask.js.map +1 -0
- package/dist/request/createRequester.js +83 -0
- package/dist/request/createRequester.js.map +1 -0
- package/dist/services/apiClient.js +97 -0
- package/dist/services/apiClient.js.map +1 -0
- package/dist/services/cliTokenCache.js +25 -0
- package/dist/services/cliTokenCache.js.map +1 -0
- package/dist/services/cliUserConfig.js +144 -0
- package/dist/services/cliUserConfig.js.map +1 -0
- package/dist/services/getCliToken.js +26 -0
- package/dist/services/getCliToken.js.map +1 -0
- package/dist/telemetry/getCliTelemetry.js +47 -0
- package/dist/telemetry/getCliTelemetry.js.map +1 -0
- package/dist/telemetry/getTelemetryBaseInfo.js +33 -0
- package/dist/telemetry/getTelemetryBaseInfo.js.map +1 -0
- package/dist/telemetry/readNDJSON.js +18 -0
- package/dist/telemetry/readNDJSON.js.map +1 -0
- package/dist/telemetry/types.js +5 -0
- package/dist/telemetry/types.js.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/util/doImport.js +17 -0
- package/dist/util/doImport.js.map +1 -0
- package/dist/util/environment/getStudioEnvironmentVariables.js +36 -0
- package/dist/util/environment/getStudioEnvironmentVariables.js.map +1 -0
- package/dist/util/environment/mockBrowserEnvironment.js +47 -0
- package/dist/util/environment/mockBrowserEnvironment.js.map +1 -0
- package/dist/util/environment/setupBrowserStubs.js +42 -0
- package/dist/util/environment/setupBrowserStubs.js.map +1 -0
- package/dist/util/environment/stubs.js +142 -0
- package/dist/util/environment/stubs.js.map +1 -0
- package/dist/util/fileExists.js +13 -0
- package/dist/util/fileExists.js.map +1 -0
- package/dist/util/generateHelpUrl.js +11 -0
- package/dist/util/generateHelpUrl.js.map +1 -0
- package/dist/util/getEmptyAuth.js +16 -0
- package/dist/util/getEmptyAuth.js.map +1 -0
- package/dist/util/getSanityEnvVar.js +24 -0
- package/dist/util/getSanityEnvVar.js.map +1 -0
- package/dist/util/getSanityUrl.js +9 -0
- package/dist/util/getSanityUrl.js.map +1 -0
- package/dist/util/importModule.js +32 -0
- package/dist/util/importModule.js.map +1 -0
- package/dist/util/isCi.js +7 -0
- package/dist/util/isCi.js.map +1 -0
- package/dist/util/isInteractive.js +5 -0
- package/dist/util/isInteractive.js.map +1 -0
- package/dist/util/isRecord.js +11 -0
- package/dist/util/isRecord.js.map +1 -0
- package/dist/util/isStaging.js +10 -0
- package/dist/util/isStaging.js.map +1 -0
- package/dist/util/isTrueish.js +10 -0
- package/dist/util/isTrueish.js.map +1 -0
- package/dist/util/normalizePath.js +12 -0
- package/dist/util/normalizePath.js.map +1 -0
- package/dist/util/packageManager.js +55 -0
- package/dist/util/packageManager.js.map +1 -0
- package/dist/util/promisifyWorker.js +72 -0
- package/dist/util/promisifyWorker.js.map +1 -0
- package/dist/util/readJsonFile.js +26 -0
- package/dist/util/readJsonFile.js.map +1 -0
- package/dist/util/readJsonFileSync.js +26 -0
- package/dist/util/readJsonFileSync.js.map +1 -0
- package/dist/util/readPackageJson.js +74 -0
- package/dist/util/readPackageJson.js.map +1 -0
- package/dist/util/resolveLocalPackage.js +82 -0
- package/dist/util/resolveLocalPackage.js.map +1 -0
- package/dist/util/safeStructuredClone.js +43 -0
- package/dist/util/safeStructuredClone.js.map +1 -0
- package/dist/util/tryGetDefaultExport.js +18 -0
- package/dist/util/tryGetDefaultExport.js.map +1 -0
- package/dist/util/writeJsonFileSync.js +19 -0
- package/dist/util/writeJsonFileSync.js.map +1 -0
- package/dist/ux/boxen.js +3 -0
- package/dist/ux/boxen.js.map +1 -0
- package/dist/ux/colorizeJson.js +32 -0
- package/dist/ux/colorizeJson.js.map +1 -0
- package/dist/ux/logSymbols.js +3 -0
- package/dist/ux/logSymbols.js.map +1 -0
- package/dist/ux/prompts.js +51 -0
- package/dist/ux/prompts.js.map +1 -0
- package/dist/ux/spinner.js +3 -0
- package/dist/ux/spinner.js.map +1 -0
- package/dist/ux/timer.js +29 -0
- package/dist/ux/timer.js.map +1 -0
- package/package.json +111 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export * from '../config/cli/getCliConfig.js';
|
|
2
|
+
export * from '../config/cli/getCliConfigSync.js';
|
|
3
|
+
export * from '../config/findProjectRoot.js';
|
|
4
|
+
export * from '../config/findProjectRootSync.js';
|
|
5
|
+
export * from '../config/studio/getStudioConfig.js';
|
|
6
|
+
export * from '../config/studio/getStudioWorkspaces.js';
|
|
7
|
+
export * from '../config/studio/isStudioConfig.js';
|
|
8
|
+
export * from '../config/util/findConfigsPaths.js';
|
|
9
|
+
export * from '../config/util/findStudioConfigPath.js';
|
|
10
|
+
export * from '../debug.js';
|
|
11
|
+
export * from '../errors/NonInteractiveError.js';
|
|
12
|
+
export * from '../errors/NotFoundError.js';
|
|
13
|
+
export * from '../errors/ProjectRootNotFoundError.js';
|
|
14
|
+
export * from '../exitCodes.js';
|
|
15
|
+
export * from '../loaders/studio/studioWorkerTask.js';
|
|
16
|
+
export * from '../loaders/tsx/tsxWorkerTask.js';
|
|
17
|
+
export * from '../SanityCommand.js';
|
|
18
|
+
export * from '../services/apiClient.js';
|
|
19
|
+
export * from '../services/cliUserConfig.js';
|
|
20
|
+
export * from '../services/getCliToken.js';
|
|
21
|
+
export { clearCliTelemetry, CLI_TELEMETRY_SYMBOL, getCliTelemetry, setCliTelemetry } from '../telemetry/getCliTelemetry.js';
|
|
22
|
+
export { getTelemetryBaseInfo } from '../telemetry/getTelemetryBaseInfo.js';
|
|
23
|
+
export { doImport } from '../util/doImport.js';
|
|
24
|
+
export * from '../util/environment/mockBrowserEnvironment.js';
|
|
25
|
+
export * from '../util/getSanityEnvVar.js';
|
|
26
|
+
export * from '../util/getSanityUrl.js';
|
|
27
|
+
export * from '../util/importModule.js';
|
|
28
|
+
export * from '../util/isCi.js';
|
|
29
|
+
export * from '../util/isInteractive.js';
|
|
30
|
+
export * from '../util/isStaging.js';
|
|
31
|
+
export * from '../util/normalizePath.js';
|
|
32
|
+
export * from '../util/promisifyWorker.js';
|
|
33
|
+
export * from '../util/readPackageJson.js';
|
|
34
|
+
export * from '../util/resolveLocalPackage.js';
|
|
35
|
+
export * from '../util/safeStructuredClone.js';
|
|
36
|
+
export * from '../ux/colorizeJson.js';
|
|
37
|
+
export * from '../ux/timer.js';
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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 {\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/getSanityEnvVar.js'\nexport * from '../util/getSanityUrl.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","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,SACEA,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,eAAe,QACV,kCAAiC;AACxC,SAAQC,oBAAoB,QAAO,uCAAsC;AAOzE,SAAQC,QAAQ,QAAO,sBAAqB;AAC5C,cAAc,gDAA+C;AAC7D,cAAc,6BAA4B;AAC1C,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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime-detectable package managers (excludes 'manual' which is a UI-only choice).
|
|
3
|
+
*/
|
|
4
|
+
export declare type DetectedPackageManager = "bun" | "npm" | "pnpm" | "yarn";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Return the CLI invocation command for the detected (or provided) package manager.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Optional `bin` (defaults to `'sanity'`) and `userAgent` override.
|
|
10
|
+
* @returns A string like `"npx sanity"`, `"pnpm exec sanity"`, etc.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getBinCommand(options?: {
|
|
13
|
+
bin?: string;
|
|
14
|
+
userAgent?: string;
|
|
15
|
+
}): string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Convenience wrapper that reads `process.env.npm_config_user_agent` and returns
|
|
19
|
+
* the detected package manager.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getRunningPackageManager():
|
|
22
|
+
| DetectedPackageManager
|
|
23
|
+
| undefined;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Extract the yarn major version from a `npm_config_user_agent` string.
|
|
27
|
+
*
|
|
28
|
+
* @param ua - User-agent string. Defaults to `process.env.npm_config_user_agent`.
|
|
29
|
+
* @returns The major version number, or `undefined` if yarn isn't detected.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getYarnMajorVersion(ua?: string): number | undefined;
|
|
32
|
+
|
|
33
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/package-manager.ts"],"sourcesContent":["export {\n type DetectedPackageManager,\n getBinCommand,\n getRunningPackageManager,\n getYarnMajorVersion,\n} from '../util/packageManager.js'\n"],"names":["getBinCommand","getRunningPackageManager","getYarnMajorVersion"],"mappings":"AAAA,SAEEA,aAAa,EACbC,wBAAwB,EACxBC,mBAAmB,QACd,4BAA2B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { agent } from "get-it/middleware";
|
|
2
|
+
import { base } from "get-it/middleware";
|
|
3
|
+
import { injectResponse } from "get-it/middleware";
|
|
4
|
+
import { jsonRequest } from "get-it/middleware";
|
|
5
|
+
import { jsonResponse } from "get-it/middleware";
|
|
6
|
+
import { keepAlive } from "get-it/middleware";
|
|
7
|
+
import { observable } from "get-it/middleware";
|
|
8
|
+
import { progress } from "get-it/middleware";
|
|
9
|
+
import { proxy } from "get-it/middleware";
|
|
10
|
+
import { Requester } from "get-it";
|
|
11
|
+
import { retry } from "get-it/middleware";
|
|
12
|
+
import { urlEncoded } from "get-it/middleware";
|
|
13
|
+
|
|
14
|
+
export { agent };
|
|
15
|
+
|
|
16
|
+
export { base };
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates a `get-it` requester with a standard set of middleware.
|
|
20
|
+
*
|
|
21
|
+
* Default middleware (in order):
|
|
22
|
+
* 1. `httpErrors()` — throw on HTTP error status codes
|
|
23
|
+
* 2. `headers({'User-Agent': '@sanity/cli-core@<version>'})` — identify CLI requests
|
|
24
|
+
* 3. `debug({verbose: true, namespace: 'sanity:cli'})` — debug logging
|
|
25
|
+
* 4. `promise({onlyBody: true})` — return body directly (must be last)
|
|
26
|
+
*
|
|
27
|
+
* @param options - Optional configuration to disable or customize middleware
|
|
28
|
+
* @returns A configured `get-it` requester
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare function createRequester(options?: {
|
|
32
|
+
middleware?: MiddlewareOptions;
|
|
33
|
+
}): Requester;
|
|
34
|
+
|
|
35
|
+
export { injectResponse };
|
|
36
|
+
|
|
37
|
+
export { jsonRequest };
|
|
38
|
+
|
|
39
|
+
export { jsonResponse };
|
|
40
|
+
|
|
41
|
+
export { keepAlive };
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Options for configuring individual middleware in {@link createRequester}.
|
|
45
|
+
*
|
|
46
|
+
* Each key corresponds to a middleware. Omitting a key uses the default,
|
|
47
|
+
* `false` disables it, and an object merges with the defaults.
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export declare type MiddlewareOptions = {
|
|
52
|
+
debug?:
|
|
53
|
+
| false
|
|
54
|
+
| {
|
|
55
|
+
namespace?: string;
|
|
56
|
+
verbose?: boolean;
|
|
57
|
+
};
|
|
58
|
+
headers?: false | Record<string, string>;
|
|
59
|
+
httpErrors?: false;
|
|
60
|
+
promise?:
|
|
61
|
+
| false
|
|
62
|
+
| {
|
|
63
|
+
onlyBody?: boolean;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { observable };
|
|
68
|
+
|
|
69
|
+
export { progress };
|
|
70
|
+
|
|
71
|
+
export { proxy };
|
|
72
|
+
|
|
73
|
+
export { Requester };
|
|
74
|
+
|
|
75
|
+
export { retry };
|
|
76
|
+
|
|
77
|
+
export { urlEncoded };
|
|
78
|
+
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createRequester } from '../request/createRequester.js';
|
|
2
|
+
// Re-export non-default middleware from get-it for use alongside createRequester.
|
|
3
|
+
// Default middleware (httpErrors, headers, debug, promise) are applied automatically
|
|
4
|
+
// by createRequester and don't need to be imported separately.
|
|
5
|
+
export { agent, base, injectResponse, jsonRequest, jsonResponse, keepAlive, observable, progress, proxy, retry, urlEncoded } from 'get-it/middleware';
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/request.ts"],"sourcesContent":["export {createRequester, type MiddlewareOptions} from '../request/createRequester.js'\n\n// Re-export get-it types used by consumers of createRequester\nexport {type Requester} from 'get-it'\n\n// Re-export non-default middleware from get-it for use alongside createRequester.\n// Default middleware (httpErrors, headers, debug, promise) are applied automatically\n// by createRequester and don't need to be imported separately.\nexport {\n agent,\n base,\n injectResponse,\n jsonRequest,\n jsonResponse,\n keepAlive,\n observable,\n progress,\n proxy,\n retry,\n urlEncoded,\n} from 'get-it/middleware'\n"],"names":["createRequester","agent","base","injectResponse","jsonRequest","jsonResponse","keepAlive","observable","progress","proxy","retry","urlEncoded"],"mappings":"AAAA,SAAQA,eAAe,QAA+B,gCAA+B;AAKrF,kFAAkF;AAClF,qFAAqF;AACrF,+DAA+D;AAC/D,SACEC,KAAK,EACLC,IAAI,EACJC,cAAc,EACdC,WAAW,EACXC,YAAY,EACZC,SAAS,EACTC,UAAU,EACVC,QAAQ,EACRC,KAAK,EACLC,KAAK,EACLC,UAAU,QACL,oBAAmB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { default as boxen } from "boxen";
|
|
2
|
+
import { Options as BoxenOptions } from "boxen";
|
|
3
|
+
import { Boxes } from "boxen";
|
|
4
|
+
import { CLIError } from "@oclif/core/errors";
|
|
5
|
+
import { CustomBorderStyle } from "boxen";
|
|
6
|
+
import * as inquirer from "@inquirer/prompts";
|
|
7
|
+
import { default as logSymbols } from "log-symbols";
|
|
8
|
+
import { Separator } from "@inquirer/prompts";
|
|
9
|
+
import { Spacing } from "boxen";
|
|
10
|
+
import { Spinner } from "ora";
|
|
11
|
+
import { default as spinner } from "ora";
|
|
12
|
+
import { Ora as SpinnerInstance } from "ora";
|
|
13
|
+
import { Options as SpinnerOptions } from "ora";
|
|
14
|
+
import { oraPromise as spinnerPromise } from "ora";
|
|
15
|
+
import { PromiseOptions as SpinnerPromiseOptions } from "ora";
|
|
16
|
+
|
|
17
|
+
export { boxen };
|
|
18
|
+
|
|
19
|
+
export { BoxenOptions };
|
|
20
|
+
|
|
21
|
+
export { Boxes };
|
|
22
|
+
|
|
23
|
+
export declare const checkbox: typeof inquirer.checkbox;
|
|
24
|
+
|
|
25
|
+
declare const confirm_2: typeof inquirer.confirm;
|
|
26
|
+
export { confirm_2 as confirm };
|
|
27
|
+
|
|
28
|
+
export { CustomBorderStyle };
|
|
29
|
+
|
|
30
|
+
export declare const editor: typeof inquirer.editor;
|
|
31
|
+
|
|
32
|
+
export declare const expand: typeof inquirer.expand;
|
|
33
|
+
|
|
34
|
+
export declare const input: typeof inquirer.input;
|
|
35
|
+
|
|
36
|
+
export { logSymbols };
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Error thrown when a prompt is attempted in a non-interactive environment
|
|
40
|
+
* (e.g., CI, non-TTY, piped stdin). Callers can catch this specific error
|
|
41
|
+
* to provide appropriate fallback behavior.
|
|
42
|
+
*
|
|
43
|
+
* Extends `CLIError` to suppress stack traces in user-facing output.
|
|
44
|
+
*/
|
|
45
|
+
export declare class NonInteractiveError extends CLIError {
|
|
46
|
+
constructor(promptName: string);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export declare const number: typeof inquirer.number;
|
|
50
|
+
|
|
51
|
+
export declare const password: typeof inquirer.password;
|
|
52
|
+
|
|
53
|
+
export declare const rawlist: typeof inquirer.rawlist;
|
|
54
|
+
|
|
55
|
+
export declare const search: typeof inquirer.search;
|
|
56
|
+
|
|
57
|
+
export declare const select: typeof inquirer.select;
|
|
58
|
+
|
|
59
|
+
export { Separator };
|
|
60
|
+
|
|
61
|
+
export { Spacing };
|
|
62
|
+
|
|
63
|
+
export { Spinner };
|
|
64
|
+
|
|
65
|
+
export { spinner };
|
|
66
|
+
|
|
67
|
+
export { SpinnerInstance };
|
|
68
|
+
|
|
69
|
+
export { SpinnerOptions };
|
|
70
|
+
|
|
71
|
+
export { spinnerPromise };
|
|
72
|
+
|
|
73
|
+
export { SpinnerPromiseOptions };
|
|
74
|
+
|
|
75
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_exports/ux.ts"],"sourcesContent":["export {NonInteractiveError} from '../errors/NonInteractiveError.js'\nexport * from '../ux/boxen.js'\nexport * from '../ux/logSymbols.js'\nexport * from '../ux/prompts.js'\nexport * from '../ux/spinner.js'\n"],"names":["NonInteractiveError"],"mappings":"AAAA,SAAQA,mBAAmB,QAAO,mCAAkC;AACpE,cAAc,iBAAgB;AAC9B,cAAc,sBAAqB;AACnC,cAAc,mBAAkB;AAChC,cAAc,mBAAkB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { debug } from '../../debug.js';
|
|
2
|
+
import { NotFoundError } from '../../errors/NotFoundError.js';
|
|
3
|
+
import { importModule } from '../../util/importModule.js';
|
|
4
|
+
import { findPathForFiles } from '../util/findConfigsPaths.js';
|
|
5
|
+
import { cliConfigSchema } from './schemas.js';
|
|
6
|
+
const cache = new Map();
|
|
7
|
+
/**
|
|
8
|
+
* Get the CLI config for a project, given the root path.
|
|
9
|
+
*
|
|
10
|
+
* Results are cached in-memory keyed by rootPath for the lifetime of the
|
|
11
|
+
* process. Since the CLI always runs from a single project root, the config
|
|
12
|
+
* won't change during a command's execution, so caching avoids redundant
|
|
13
|
+
* filesystem reads and jiti imports from the prerun hook, SanityCommand
|
|
14
|
+
* helpers, and action files.
|
|
15
|
+
*
|
|
16
|
+
* If loading fails the cached promise is evicted so the next call retries.
|
|
17
|
+
*
|
|
18
|
+
* @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.
|
|
19
|
+
* @returns The CLI config
|
|
20
|
+
* @internal
|
|
21
|
+
*/ export function getCliConfig(rootPath) {
|
|
22
|
+
const cached = cache.get(rootPath);
|
|
23
|
+
if (cached) {
|
|
24
|
+
return cached;
|
|
25
|
+
}
|
|
26
|
+
const promise = loadCliConfig(rootPath).catch((err)=>{
|
|
27
|
+
cache.delete(rootPath);
|
|
28
|
+
throw err;
|
|
29
|
+
});
|
|
30
|
+
cache.set(rootPath, promise);
|
|
31
|
+
return promise;
|
|
32
|
+
}
|
|
33
|
+
async function loadCliConfig(rootPath) {
|
|
34
|
+
const paths = await findPathForFiles(rootPath, [
|
|
35
|
+
'sanity.cli.ts',
|
|
36
|
+
'sanity.cli.js'
|
|
37
|
+
]);
|
|
38
|
+
const configPaths = paths.filter((path)=>path.exists);
|
|
39
|
+
if (configPaths.length === 0) {
|
|
40
|
+
throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`);
|
|
41
|
+
}
|
|
42
|
+
if (configPaths.length > 1) {
|
|
43
|
+
throw new Error(`Multiple CLI config files found (${configPaths.map((path)=>path.path).join(', ')})`);
|
|
44
|
+
}
|
|
45
|
+
const configPath = configPaths[0].path;
|
|
46
|
+
debug(`Loading CLI config from: ${configPath}`);
|
|
47
|
+
let cliConfig;
|
|
48
|
+
try {
|
|
49
|
+
const result = await importModule(configPath);
|
|
50
|
+
debug('CLI config loaded: %o', result);
|
|
51
|
+
cliConfig = result;
|
|
52
|
+
} catch (err) {
|
|
53
|
+
debug('Failed to load CLI config in worker thread: %s', err);
|
|
54
|
+
throw new Error('CLI config cannot be loaded', {
|
|
55
|
+
cause: err
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const { data, error, success } = cliConfigSchema.safeParse(cliConfig);
|
|
59
|
+
if (!success) {
|
|
60
|
+
debug(`Invalid CLI config: ${error.message}`);
|
|
61
|
+
throw new Error(`Invalid CLI config: ${error.message}`, {
|
|
62
|
+
cause: error
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=getCliConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/config/cli/getCliConfig.ts"],"sourcesContent":["import {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 * @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 = loadCliConfig(rootPath).catch((err) => {\n cache.delete(rootPath)\n throw err\n })\n\n cache.set(rootPath, promise)\n return promise\n}\n\nasync function loadCliConfig(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 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":["debug","NotFoundError","importModule","findPathForFiles","cliConfigSchema","cache","Map","getCliConfig","rootPath","cached","get","promise","loadCliConfig","catch","err","delete","set","paths","configPaths","filter","path","exists","length","Error","map","join","configPath","cliConfig","result","cause","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,KAAK,QAAO,iBAAgB;AACpC,SAAQC,aAAa,QAAO,gCAA+B;AAC3D,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,gBAAgB,QAAO,8BAA6B;AAC5D,SAAQC,eAAe,QAAO,eAAc;AAG5C,MAAMC,QAAQ,IAAIC;AAElB;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASC,aAAaC,QAAgB;IAC3C,MAAMC,SAASJ,MAAMK,GAAG,CAACF;IACzB,IAAIC,QAAQ;QACV,OAAOA;IACT;IAEA,MAAME,UAAUC,cAAcJ,UAAUK,KAAK,CAAC,CAACC;QAC7CT,MAAMU,MAAM,CAACP;QACb,MAAMM;IACR;IAEAT,MAAMW,GAAG,CAACR,UAAUG;IACpB,OAAOA;AACT;AAEA,eAAeC,cAAcJ,QAAgB;IAC3C,MAAMS,QAAQ,MAAMd,iBAAiBK,UAAU;QAAC;QAAiB;KAAgB;IACjF,MAAMU,cAAcD,MAAME,MAAM,CAAC,CAACC,OAASA,KAAKC,MAAM;IAEtD,IAAIH,YAAYI,MAAM,KAAK,GAAG;QAC5B,MAAM,IAAIrB,cAAc,CAAC,uBAAuB,EAAEO,SAAS,mBAAmB,CAAC;IACjF;IAEA,IAAIU,YAAYI,MAAM,GAAG,GAAG;QAC1B,MAAM,IAAIC,MACR,CAAC,iCAAiC,EAAEL,YAAYM,GAAG,CAAC,CAACJ,OAASA,KAAKA,IAAI,EAAEK,IAAI,CAAC,MAAM,CAAC,CAAC;IAE1F;IAEA,MAAMC,aAAaR,WAAW,CAAC,EAAE,CAACE,IAAI;IAEtCpB,MAAM,CAAC,yBAAyB,EAAE0B,YAAY;IAE9C,IAAIC;IACJ,IAAI;QACF,MAAMC,SAAS,MAAM1B,aAAwBwB;QAE7C1B,MAAM,yBAAyB4B;QAE/BD,YAAYC;IACd,EAAE,OAAOd,KAAK;QACZd,MAAM,kDAAkDc;QAExD,MAAM,IAAIS,MAAM,+BAA+B;YAACM,OAAOf;QAAG;IAC5D;IAEA,MAAM,EAACgB,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAG5B,gBAAgB6B,SAAS,CAACN;IACzD,IAAI,CAACK,SAAS;QACZhC,MAAM,CAAC,oBAAoB,EAAE+B,MAAMG,OAAO,EAAE;QAC5C,MAAM,IAAIX,MAAM,CAAC,oBAAoB,EAAEQ,MAAMG,OAAO,EAAE,EAAE;YAACL,OAAOE;QAAK;IACvE;IAEA,OAAOD;AACT"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { register } from 'tsx/esm/api';
|
|
5
|
+
import { NotFoundError } from '../../errors/NotFoundError.js';
|
|
6
|
+
import { tryGetDefaultExport } from '../../util/tryGetDefaultExport.js';
|
|
7
|
+
import { cliConfigSchema } from './schemas.js';
|
|
8
|
+
/**
|
|
9
|
+
* Get the CLI config for a project synchronously, given the root path.
|
|
10
|
+
*
|
|
11
|
+
* This loads the CLI config in the main thread using tsx/register for TypeScript support.
|
|
12
|
+
* Note: This is a synchronous operation and does not use worker threads like the async version.
|
|
13
|
+
*
|
|
14
|
+
* @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.
|
|
15
|
+
* @returns The CLI config
|
|
16
|
+
* @internal
|
|
17
|
+
*/ export function getCliConfigSync(rootPath) {
|
|
18
|
+
const possiblePaths = [
|
|
19
|
+
'sanity.cli.ts',
|
|
20
|
+
'sanity.cli.js'
|
|
21
|
+
].map((file)=>join(rootPath, file));
|
|
22
|
+
const configPaths = possiblePaths.filter((path)=>existsSync(path));
|
|
23
|
+
if (configPaths.length === 0) {
|
|
24
|
+
throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`);
|
|
25
|
+
}
|
|
26
|
+
if (configPaths.length > 1) {
|
|
27
|
+
throw new Error(`Multiple CLI config files found (${configPaths.join(', ')})`);
|
|
28
|
+
}
|
|
29
|
+
const configPath = configPaths[0];
|
|
30
|
+
// Register tsx for TypeScript support
|
|
31
|
+
const unregister = register();
|
|
32
|
+
let cliConfig;
|
|
33
|
+
try {
|
|
34
|
+
// Use createRequire for synchronous loading in ESM contexts
|
|
35
|
+
// This works when tsx loader is active
|
|
36
|
+
const require = createRequire(import.meta.url);
|
|
37
|
+
const loaded = require(configPath);
|
|
38
|
+
cliConfig = tryGetDefaultExport(loaded);
|
|
39
|
+
} finally{
|
|
40
|
+
unregister();
|
|
41
|
+
}
|
|
42
|
+
const { data, error, success } = cliConfigSchema.safeParse(cliConfig);
|
|
43
|
+
if (!success) {
|
|
44
|
+
throw new Error(`Invalid CLI config: ${error.message}`);
|
|
45
|
+
}
|
|
46
|
+
// There is a minor difference here because of the `vite` property and how the types
|
|
47
|
+
// aren't as specific as our manually typed `CliConfig` type, thus the cast.
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=getCliConfigSync.js.map
|
|
@@ -0,0 +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;AAG5C;;;;;;;;;CASC,GACD,OAAO,SAASC,iBAAiBC,QAAgB;IAC/C,MAAMC,gBAAgB;QAAC;QAAiB;KAAgB,CAACC,GAAG,CAAC,CAACC,OAAST,KAAKM,UAAUG;IACtF,MAAMC,cAAcH,cAAcI,MAAM,CAAC,CAACC,OAASd,WAAWc;IAE9D,IAAIF,YAAYG,MAAM,KAAK,GAAG;QAC5B,MAAM,IAAIX,cAAc,CAAC,uBAAuB,EAAEI,SAAS,mBAAmB,CAAC;IACjF;IAEA,IAAII,YAAYG,MAAM,GAAG,GAAG;QAC1B,MAAM,IAAIC,MAAM,CAAC,iCAAiC,EAAEJ,YAAYV,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/E;IAEA,MAAMe,aAAaL,WAAW,CAAC,EAAE;IAEjC,sCAAsC;IACtC,MAAMM,aAAaf;IAEnB,IAAIgB;IACJ,IAAI;QACF,4DAA4D;QAC5D,uCAAuC;QACvC,MAAMC,UAAUnB,cAAc,YAAYoB,GAAG;QAC7C,MAAMC,SAASF,QAAQH;QACvBE,YAAYd,oBAAoBiB;IAClC,SAAU;QACRJ;IACF;IAEA,MAAM,EAACK,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGnB,gBAAgBoB,SAAS,CAACP;IACzD,IAAI,CAACM,SAAS;QACZ,MAAM,IAAIT,MAAM,CAAC,oBAAoB,EAAEQ,MAAMG,OAAO,EAAE;IACxD;IAEA,oFAAoF;IACpF,4EAA4E;IAC5E,OAAOJ;AACT"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from 'zod/mini';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
*/ export const cliConfigSchema = z.object({
|
|
5
|
+
api: z.optional(z.object({
|
|
6
|
+
dataset: z.optional(z.string()),
|
|
7
|
+
projectId: z.optional(z.string())
|
|
8
|
+
})),
|
|
9
|
+
app: z.optional(z.object({
|
|
10
|
+
entry: z.optional(z.string()),
|
|
11
|
+
icon: z.optional(z.string()),
|
|
12
|
+
id: z.optional(z.string()),
|
|
13
|
+
organizationId: z.optional(z.string()),
|
|
14
|
+
title: z.optional(z.string())
|
|
15
|
+
})),
|
|
16
|
+
autoUpdates: z.optional(z.boolean()),
|
|
17
|
+
deployment: z.optional(z.object({
|
|
18
|
+
appId: z.optional(z.string()),
|
|
19
|
+
autoUpdates: z.optional(z.boolean())
|
|
20
|
+
})),
|
|
21
|
+
federation: z.optional(z.object({
|
|
22
|
+
enabled: z.boolean()
|
|
23
|
+
})),
|
|
24
|
+
graphql: z.optional(z.array(z.object({
|
|
25
|
+
filterSuffix: z.optional(z.string()),
|
|
26
|
+
generation: z.optional(z.enum([
|
|
27
|
+
'gen1',
|
|
28
|
+
'gen2',
|
|
29
|
+
'gen3'
|
|
30
|
+
])),
|
|
31
|
+
id: z.optional(z.string()),
|
|
32
|
+
nonNullDocumentFields: z.optional(z.boolean()),
|
|
33
|
+
playground: z.optional(z.boolean()),
|
|
34
|
+
source: z.optional(z.string()),
|
|
35
|
+
tag: z.optional(z.string()),
|
|
36
|
+
workspace: z.optional(z.string())
|
|
37
|
+
}))),
|
|
38
|
+
mediaLibrary: z.optional(z.object({
|
|
39
|
+
aspectsPath: z.optional(z.string())
|
|
40
|
+
})),
|
|
41
|
+
project: z.optional(z.object({
|
|
42
|
+
basePath: z.optional(z.string())
|
|
43
|
+
})),
|
|
44
|
+
reactCompiler: z.optional(z.custom()),
|
|
45
|
+
reactStrictMode: z.optional(z.boolean()),
|
|
46
|
+
schemaExtraction: z.optional(z.object({
|
|
47
|
+
enabled: z.optional(z.boolean()),
|
|
48
|
+
enforceRequiredFields: z.optional(z.boolean()),
|
|
49
|
+
path: z.optional(z.string()),
|
|
50
|
+
watchPatterns: z.optional(z.array(z.string())),
|
|
51
|
+
workspace: z.optional(z.string())
|
|
52
|
+
})),
|
|
53
|
+
server: z.optional(z.object({
|
|
54
|
+
hostname: z.optional(z.string()),
|
|
55
|
+
port: z.optional(z.number())
|
|
56
|
+
})),
|
|
57
|
+
studioHost: z.optional(z.string()),
|
|
58
|
+
vite: z.optional(z.custom()),
|
|
59
|
+
typegen: z.optional(z.custom())
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +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 federation: z.optional(\n z.object({\n enabled: 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","federation","enabled","graphql","array","filterSuffix","generation","enum","nonNullDocumentFields","playground","source","tag","workspace","mediaLibrary","aspectsPath","project","basePath","reactCompiler","custom","reactStrictMode","schemaExtraction","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,YAAYlB,EAAEI,QAAQ,CACpBJ,EAAEE,MAAM,CAAC;QACPiB,SAASnB,EAAEe,OAAO;IACpB;IAGFK,SAASpB,EAAEI,QAAQ,CACjBJ,EAAEqB,KAAK,CACLrB,EAAEE,MAAM,CAAC;QACPoB,cAActB,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACjCiB,YAAYvB,EAAEI,QAAQ,CAACJ,EAAEwB,IAAI,CAAC;YAAC;YAAQ;YAAQ;SAAO;QACtDb,IAAIX,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACvBmB,uBAAuBzB,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;QAC3CW,YAAY1B,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;QAChCY,QAAQ3B,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QAC3BsB,KAAK5B,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACxBuB,WAAW7B,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAChC;IAIJwB,cAAc9B,EAAEI,QAAQ,CACtBJ,EAAEE,MAAM,CAAC;QACP6B,aAAa/B,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAClC;IAGF0B,SAAShC,EAAEI,QAAQ,CACjBJ,EAAEE,MAAM,CAAC;QACP+B,UAAUjC,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAC/B;IAGF4B,eAAelC,EAAEI,QAAQ,CAACJ,EAAEmC,MAAM;IAElCC,iBAAiBpC,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;IAErCsB,kBAAkBrC,EAAEI,QAAQ,CAC1BJ,EAAEE,MAAM,CAAC;QACPiB,SAASnB,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;QAC7BuB,uBAAuBtC,EAAEI,QAAQ,CAACJ,EAAEe,OAAO;QAC3CwB,MAAMvC,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QACzBkC,eAAexC,EAAEI,QAAQ,CAACJ,EAAEqB,KAAK,CAACrB,EAAEM,MAAM;QAC1CuB,WAAW7B,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAChC;IAGFmC,QAAQzC,EAAEI,QAAQ,CAChBJ,EAAEE,MAAM,CAAC;QACPwC,UAAU1C,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;QAC7BqC,MAAM3C,EAAEI,QAAQ,CAACJ,EAAE4C,MAAM;IAC3B;IAGFC,YAAY7C,EAAEI,QAAQ,CAACJ,EAAEM,MAAM;IAE/BwC,MAAM9C,EAAEI,QAAQ,CAACJ,EAAEmC,MAAM;IAEzBY,SAAS/C,EAAEI,QAAQ,CAACJ,EAAEmC,MAAM;AAC9B,GAAuC"}
|
|
@@ -0,0 +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 /**\n * Enable federated builds & dev environments for your studio or application.\n * @experimental\n */\n federation?: {\n enabled: 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,WA8IC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/config/cli/types/userViteConfig.ts"],"sourcesContent":["import {type ConfigEnv, type InlineConfig} from 'vite'\n\n/**\n * @public\n */\nexport type UserViteConfig =\n | ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>)\n | InlineConfig\n"],"names":[],"mappings":"AAEA;;CAEC,GACD,WAEgB"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ProjectRootNotFoundError } from '../errors/ProjectRootNotFoundError.js';
|
|
2
|
+
import { findAppConfigPath } from './util/findAppConfigPath.js';
|
|
3
|
+
import { tryFindStudioConfigPath } from './util/findStudioConfigPath.js';
|
|
4
|
+
import { recursivelyResolveProjectRoot } from './util/recursivelyResolveProjectRoot.js';
|
|
5
|
+
/**
|
|
6
|
+
* Resolve project root directory and type.
|
|
7
|
+
*
|
|
8
|
+
* Project root is:
|
|
9
|
+
* - `studio` - A pre-blueprints Sanity studio root (containing `sanity.config.(ts|js)`)
|
|
10
|
+
* - `app` - A Sanity app root (containing `sanity.cli.(ts|js)`)
|
|
11
|
+
*
|
|
12
|
+
* If a Sanity Studio v2/v1 root is found (containing `sanity.json` with `root: true`),
|
|
13
|
+
* an error is thrown, as v2/v1 is no longer supported.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/ export async function findProjectRoot(cwd) {
|
|
17
|
+
try {
|
|
18
|
+
// First try to find a studio project root, looks for `sanity.config.(ts|js)`
|
|
19
|
+
const studioProjectRoot = await resolveProjectRootForStudio(cwd);
|
|
20
|
+
if (studioProjectRoot) {
|
|
21
|
+
return studioProjectRoot;
|
|
22
|
+
}
|
|
23
|
+
// Second try to find a app project root, looks for `sanity.cli.(ts|js)`
|
|
24
|
+
const appProjectRoot = await resolveProjectRootForApp(cwd);
|
|
25
|
+
if (appProjectRoot) {
|
|
26
|
+
return appProjectRoot;
|
|
27
|
+
}
|
|
28
|
+
// If nothing is found throw a specific error
|
|
29
|
+
throw new ProjectRootNotFoundError('No project root found');
|
|
30
|
+
} catch (err) {
|
|
31
|
+
if (err instanceof ProjectRootNotFoundError) {
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
const message = err instanceof Error ? err.message : `${err}`;
|
|
35
|
+
throw new Error(`Error occurred trying to resolve project root:\n${message}`, {
|
|
36
|
+
cause: err
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Recursively searches for a project configuration file in the given directory and its parents.
|
|
42
|
+
* Throws if Sanity v2 studio root is found.
|
|
43
|
+
*
|
|
44
|
+
* @param basePath - The base path to start searching from
|
|
45
|
+
* @param iterations - Current iteration count, passed internally to prevent infinite recursion.
|
|
46
|
+
* @returns A promise that resolves to an object if config is found, false otherwise
|
|
47
|
+
* @internal
|
|
48
|
+
*/ async function resolveProjectRootForStudio(basePath, iterations = 0) {
|
|
49
|
+
return recursivelyResolveProjectRoot(basePath, tryFindStudioConfigPath, 'studio', iterations);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Recursively searches for a app project configuration file in the given directory and its parents.
|
|
53
|
+
*
|
|
54
|
+
* @param basePath - The base path to start searching from
|
|
55
|
+
* @param iterations - Current iteration count, passed internally to prevent infinite recursion.
|
|
56
|
+
* @returns A promise that resolves to an object if config is found, false otherwise
|
|
57
|
+
* @internal
|
|
58
|
+
*/ async function resolveProjectRootForApp(basePath, iterations = 0) {
|
|
59
|
+
return recursivelyResolveProjectRoot(basePath, findAppConfigPath, 'app', iterations);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=findProjectRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/config/findProjectRoot.ts"],"sourcesContent":["import {ProjectRootNotFoundError} from '../errors/ProjectRootNotFoundError.js'\nimport {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 a specific error\n throw new ProjectRootNotFoundError('No project root found')\n } catch (err: unknown) {\n if (err instanceof ProjectRootNotFoundError) {\n throw err\n }\n const message = err instanceof Error ? err.message : `${err}`\n throw new Error(`Error occurred trying to resolve project root:\\n${message}`, {cause: err})\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":["ProjectRootNotFoundError","findAppConfigPath","tryFindStudioConfigPath","recursivelyResolveProjectRoot","findProjectRoot","cwd","studioProjectRoot","resolveProjectRootForStudio","appProjectRoot","resolveProjectRootForApp","err","message","Error","cause","basePath","iterations"],"mappings":"AAAA,SAAQA,wBAAwB,QAAO,wCAAuC;AAC9E,SAAQC,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,6CAA6C;QAC7C,MAAM,IAAIR,yBAAyB;IACrC,EAAE,OAAOU,KAAc;QACrB,IAAIA,eAAeV,0BAA0B;YAC3C,MAAMU;QACR;QACA,MAAMC,UAAUD,eAAeE,QAAQF,IAAIC,OAAO,GAAG,GAAGD,KAAK;QAC7D,MAAM,IAAIE,MAAM,CAAC,gDAAgD,EAAED,SAAS,EAAE;YAACE,OAAOH;QAAG;IAC3F;AACF;AAEA;;;;;;;;CAQC,GACD,eAAeH,4BACbO,QAAgB,EAChBC,aAAa,CAAC;IAEd,OAAOZ,8BAA8BW,UAAUZ,yBAAyB,UAAUa;AACpF;AAEA;;;;;;;CAOC,GACD,eAAeN,yBACbK,QAAgB,EAChBC,aAAa,CAAC;IAEd,OAAOZ,8BAA8BW,UAAUb,mBAAmB,OAAOc;AAC3E"}
|