@sanity/cli-core 0.1.0-alpha.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SanityCommand.js +81 -5
- package/dist/SanityCommand.js.map +1 -1
- package/dist/_exports/request.d.ts +77 -0
- package/dist/_exports/request.js +7 -0
- package/dist/_exports/request.js.map +1 -0
- package/dist/_exports/ux.d.ts +37 -2
- package/dist/_exports/ux.js +1 -0
- package/dist/_exports/ux.js.map +1 -1
- package/dist/config/cli/getCliConfig.js +33 -33
- package/dist/config/cli/getCliConfig.js.map +1 -1
- package/dist/config/cli/getCliConfigSync.js +1 -1
- package/dist/config/cli/getCliConfigSync.js.map +1 -1
- package/dist/config/cli/schemas.js +7 -0
- package/dist/config/cli/schemas.js.map +1 -1
- package/dist/config/cli/types/cliConfig.js.map +1 -1
- package/dist/config/findProjectRoot.js +6 -2
- package/dist/config/findProjectRoot.js.map +1 -1
- package/dist/config/findProjectRootSync.js +7 -3
- package/dist/config/findProjectRootSync.js.map +1 -1
- package/dist/config/studio/getStudioWorkspaces.js +14 -1
- package/dist/config/studio/getStudioWorkspaces.js.map +1 -1
- package/dist/config/studio/readStudioConfig.worker.js +6 -5
- package/dist/config/studio/readStudioConfig.worker.js.map +1 -1
- package/dist/errors/NonInteractiveError.js +18 -0
- package/dist/errors/NonInteractiveError.js.map +1 -0
- package/dist/{util → errors}/NotFoundError.js +1 -1
- 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/index.d.ts +869 -5649
- package/dist/index.js +8 -14
- package/dist/index.js.map +1 -1
- package/dist/loaders/studio/studioWorkerLoader.worker.js +102 -23
- package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -1
- package/dist/loaders/studio/studioWorkerTask.js +18 -27
- package/dist/loaders/studio/studioWorkerTask.js.map +1 -1
- package/dist/loaders/tsx/tsxWorkerLoader.worker.js +3 -4
- package/dist/loaders/tsx/tsxWorkerLoader.worker.js.map +1 -1
- package/dist/loaders/tsx/tsxWorkerTask.js +4 -34
- package/dist/loaders/tsx/tsxWorkerTask.js.map +1 -1
- package/dist/request/createRequester.js +83 -0
- package/dist/request/createRequester.js.map +1 -0
- package/dist/services/apiClient.js +3 -3
- package/dist/services/apiClient.js.map +1 -1
- package/dist/services/cliUserConfig.js +5 -5
- package/dist/services/cliUserConfig.js.map +1 -1
- package/dist/services/getCliToken.js +2 -2
- package/dist/services/getCliToken.js.map +1 -1
- package/dist/util/doImport.js +2 -1
- package/dist/util/doImport.js.map +1 -1
- package/dist/util/environment/mockBrowserEnvironment.js +1 -0
- package/dist/util/environment/mockBrowserEnvironment.js.map +1 -1
- package/dist/util/getCliTelemetry.js +6 -8
- package/dist/util/getCliTelemetry.js.map +1 -1
- package/dist/util/getSanityUrl.js +4 -3
- package/dist/util/getSanityUrl.js.map +1 -1
- package/dist/util/importModule.js +32 -0
- package/dist/util/importModule.js.map +1 -0
- package/dist/util/isInteractive.js +1 -1
- package/dist/util/isInteractive.js.map +1 -1
- package/dist/util/promisifyWorker.js +72 -0
- package/dist/util/promisifyWorker.js.map +1 -0
- package/dist/util/readPackageJson.js +74 -0
- package/dist/util/readPackageJson.js.map +1 -0
- package/dist/ux/prompts.js +49 -1
- package/dist/ux/prompts.js.map +1 -1
- package/package.json +27 -26
- package/dist/_exports/tree.d.ts +0 -47
- package/dist/_exports/tree.js +0 -3
- package/dist/_exports/tree.js.map +0 -1
- package/dist/config/cli/getCliConfig.worker.js +0 -15
- package/dist/config/cli/getCliConfig.worker.js.map +0 -1
- package/dist/telemetry/cleanupOldTelemetryFiles.js +0 -30
- package/dist/telemetry/cleanupOldTelemetryFiles.js.map +0 -1
- package/dist/telemetry/createTelemetryStore.js +0 -95
- package/dist/telemetry/createTelemetryStore.js.map +0 -1
- package/dist/telemetry/createTraceId.js +0 -10
- package/dist/telemetry/createTraceId.js.map +0 -1
- package/dist/telemetry/findTelemetryFiles.js +0 -36
- package/dist/telemetry/findTelemetryFiles.js.map +0 -1
- package/dist/telemetry/flushTelemetryFiles.js +0 -107
- package/dist/telemetry/flushTelemetryFiles.js.map +0 -1
- package/dist/telemetry/generateTelemetryFilePath.js +0 -30
- package/dist/telemetry/generateTelemetryFilePath.js.map +0 -1
- package/dist/telemetry/logger.js +0 -54
- package/dist/telemetry/logger.js.map +0 -1
- package/dist/telemetry/telemetryStoreDebug.js +0 -7
- package/dist/telemetry/telemetryStoreDebug.js.map +0 -1
- package/dist/telemetry/trace.js +0 -150
- package/dist/telemetry/trace.js.map +0 -1
- package/dist/util/NotFoundError.js.map +0 -1
- package/dist/util/createExpiringConfig.js +0 -60
- package/dist/util/createExpiringConfig.js.map +0 -1
- package/dist/util/parseStringFlag.js +0 -19
- package/dist/util/parseStringFlag.js.map +0 -1
- package/dist/util/tree.js +0 -108
- package/dist/util/tree.js.map +0 -1
- package/dist/util/waitForAsync.js +0 -5
- package/dist/util/waitForAsync.js.map +0 -1
- package/dist/ux/formatObject.js +0 -9
- package/dist/ux/formatObject.js.map +0 -1
- package/dist/ux/printKeyValue.js +0 -16
- package/dist/ux/printKeyValue.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { dirname, resolve } from 'node:path';
|
|
2
|
+
import { ProjectRootNotFoundError } from '../errors/ProjectRootNotFoundError.js';
|
|
2
3
|
import { findAppConfigPathSync, findStudioConfigPathSync } from './util/configPathsSync.js';
|
|
3
4
|
/**
|
|
4
5
|
* Generic recursive search function for project configuration files (synchronous version).
|
|
@@ -9,7 +10,7 @@ import { findAppConfigPathSync, findStudioConfigPathSync } from './util/configPa
|
|
|
9
10
|
* @param iterations - Current iteration count, passed internally to prevent infinite recursion
|
|
10
11
|
* @returns An object if config is found, false otherwise
|
|
11
12
|
* @internal
|
|
12
|
-
*/
|
|
13
|
+
*/ function recursivelyResolveProjectRootSync(basePath, findConfigFn, projectType, iterations = 0) {
|
|
13
14
|
const configPath = findConfigFn(basePath);
|
|
14
15
|
if (configPath) {
|
|
15
16
|
return {
|
|
@@ -50,9 +51,12 @@ import { findAppConfigPathSync, findStudioConfigPathSync } from './util/configPa
|
|
|
50
51
|
if (appProjectRoot) {
|
|
51
52
|
return appProjectRoot;
|
|
52
53
|
}
|
|
53
|
-
// If nothing is found throw
|
|
54
|
-
throw new
|
|
54
|
+
// If nothing is found throw a specific error
|
|
55
|
+
throw new ProjectRootNotFoundError(`No project root found in ${cwd}`);
|
|
55
56
|
} catch (err) {
|
|
57
|
+
if (err instanceof ProjectRootNotFoundError) {
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
56
60
|
const message = err instanceof Error ? err.message : `${err}`;
|
|
57
61
|
throw new Error(`Error occurred trying to resolve project root:\n${message}`);
|
|
58
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/findProjectRootSync.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path'\n\nimport {findAppConfigPathSync, findStudioConfigPathSync} from './util/configPathsSync.js'\nimport {ProjectRootResult} from './util/recursivelyResolveProjectRoot.js'\n\n/**\n * Generic recursive search function for project configuration files (synchronous version).\n *\n * @param basePath - The base path to start searching from\n * @param findConfigFn - Function that looks for config files in a given directory\n * @param projectType - The type of project ('app' | 'studio')\n * @param iterations - Current iteration count, passed internally to prevent infinite recursion\n * @returns An object if config is found, false otherwise\n * @internal\n */\
|
|
1
|
+
{"version":3,"sources":["../../src/config/findProjectRootSync.ts"],"sourcesContent":["import {dirname, resolve} from 'node:path'\n\nimport {ProjectRootNotFoundError} from '../errors/ProjectRootNotFoundError.js'\nimport {findAppConfigPathSync, findStudioConfigPathSync} from './util/configPathsSync.js'\nimport {ProjectRootResult} from './util/recursivelyResolveProjectRoot.js'\n\n/**\n * Generic recursive search function for project configuration files (synchronous version).\n *\n * @param basePath - The base path to start searching from\n * @param findConfigFn - Function that looks for config files in a given directory\n * @param projectType - The type of project ('app' | 'studio')\n * @param iterations - Current iteration count, passed internally to prevent infinite recursion\n * @returns An object if config is found, false otherwise\n * @internal\n */\nfunction recursivelyResolveProjectRootSync(\n basePath: string,\n findConfigFn: (path: string) => string | undefined,\n projectType: 'app' | 'studio',\n iterations = 0,\n): false | ProjectRootResult {\n const configPath = findConfigFn(basePath)\n\n if (configPath) {\n return {\n directory: dirname(configPath),\n path: configPath,\n type: projectType,\n }\n }\n\n const parentDir = resolve(basePath, '..')\n if (parentDir === basePath || iterations > 50) {\n // Reached root (or max depth), give up\n return false\n }\n\n return recursivelyResolveProjectRootSync(parentDir, findConfigFn, projectType, iterations + 1)\n}\n\n/**\n * Resolve project root directory and type synchronously.\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 * @param cwd - Current working directory to start searching from\n * @returns Project root result\n * @internal\n */\nexport function findProjectRootSync(cwd: string): ProjectRootResult {\n try {\n // First try to find a studio project root, looks for `sanity.config.(ts|js)`\n const studioProjectRoot = resolveProjectRootForStudioSync(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 = resolveProjectRootForAppSync(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 in ${cwd}`)\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}`)\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 An object if config is found, false otherwise\n * @internal\n */\nfunction resolveProjectRootForStudioSync(\n basePath: string,\n iterations = 0,\n): false | ProjectRootResult {\n return recursivelyResolveProjectRootSync(basePath, findStudioConfigPathSync, '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 An object if config is found, false otherwise\n * @internal\n */\nfunction resolveProjectRootForAppSync(basePath: string, iterations = 0): false | ProjectRootResult {\n return recursivelyResolveProjectRootSync(basePath, findAppConfigPathSync, 'app', iterations)\n}\n"],"names":["dirname","resolve","ProjectRootNotFoundError","findAppConfigPathSync","findStudioConfigPathSync","recursivelyResolveProjectRootSync","basePath","findConfigFn","projectType","iterations","configPath","directory","path","type","parentDir","findProjectRootSync","cwd","studioProjectRoot","resolveProjectRootForStudioSync","appProjectRoot","resolveProjectRootForAppSync","err","message","Error"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,OAAO,QAAO,YAAW;AAE1C,SAAQC,wBAAwB,QAAO,wCAAuC;AAC9E,SAAQC,qBAAqB,EAAEC,wBAAwB,QAAO,4BAA2B;AAGzF;;;;;;;;;CASC,GACD,SAASC,kCACPC,QAAgB,EAChBC,YAAkD,EAClDC,WAA6B,EAC7BC,aAAa,CAAC;IAEd,MAAMC,aAAaH,aAAaD;IAEhC,IAAII,YAAY;QACd,OAAO;YACLC,WAAWX,QAAQU;YACnBE,MAAMF;YACNG,MAAML;QACR;IACF;IAEA,MAAMM,YAAYb,QAAQK,UAAU;IACpC,IAAIQ,cAAcR,YAAYG,aAAa,IAAI;QAC7C,uCAAuC;QACvC,OAAO;IACT;IAEA,OAAOJ,kCAAkCS,WAAWP,cAAcC,aAAaC,aAAa;AAC9F;AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASM,oBAAoBC,GAAW;IAC7C,IAAI;QACF,6EAA6E;QAC7E,MAAMC,oBAAoBC,gCAAgCF;QAC1D,IAAIC,mBAAmB;YACrB,OAAOA;QACT;QAEA,wEAAwE;QACxE,MAAME,iBAAiBC,6BAA6BJ;QACpD,IAAIG,gBAAgB;YAClB,OAAOA;QACT;QAEA,6CAA6C;QAC7C,MAAM,IAAIjB,yBAAyB,CAAC,yBAAyB,EAAEc,KAAK;IACtE,EAAE,OAAOK,KAAc;QACrB,IAAIA,eAAenB,0BAA0B;YAC3C,MAAMmB;QACR;QACA,MAAMC,UAAUD,eAAeE,QAAQF,IAAIC,OAAO,GAAG,GAAGD,KAAK;QAC7D,MAAM,IAAIE,MAAM,CAAC,gDAAgD,EAAED,SAAS;IAC9E;AACF;AAEA;;;;;;;;CAQC,GACD,SAASJ,gCACPZ,QAAgB,EAChBG,aAAa,CAAC;IAEd,OAAOJ,kCAAkCC,UAAUF,0BAA0B,UAAUK;AACzF;AAEA;;;;;;;CAOC,GACD,SAASW,6BAA6Bd,QAAgB,EAAEG,aAAa,CAAC;IACpE,OAAOJ,kCAAkCC,UAAUH,uBAAuB,OAAOM;AACnF"}
|
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
import { stat } from 'node:fs/promises';
|
|
2
2
|
import { dirname } from 'node:path';
|
|
3
|
+
import { isMainThread } from 'node:worker_threads';
|
|
3
4
|
import { firstValueFrom, of } from 'rxjs';
|
|
5
|
+
import { subdebug } from '../../debug.js';
|
|
4
6
|
import { doImport } from '../../util/doImport.js';
|
|
5
7
|
import { getEmptyAuth } from '../../util/getEmptyAuth.js';
|
|
6
8
|
import { resolveLocalPackage } from '../../util/resolveLocalPackage.js';
|
|
7
9
|
import { findStudioConfigPath } from '../util/findStudioConfigPath.js';
|
|
8
10
|
import { isStudioConfig } from './isStudioConfig.js';
|
|
11
|
+
const debug = subdebug('worker:getStudioWorkspaces');
|
|
9
12
|
/**
|
|
10
13
|
* Resolves the workspaces from the studio config.
|
|
11
14
|
*
|
|
12
|
-
*
|
|
15
|
+
* NOTE: This function should only be called from a worker thread.
|
|
16
|
+
*
|
|
17
|
+
* @param configPath - The path to the studio config
|
|
13
18
|
* @returns The workspaces
|
|
14
19
|
* @internal
|
|
15
20
|
*/ export async function getStudioWorkspaces(configPath) {
|
|
21
|
+
if (isMainThread) {
|
|
22
|
+
throw new Error('getStudioWorkspaces should only be called from a worker thread');
|
|
23
|
+
}
|
|
16
24
|
const isDirectory = (await stat(configPath)).isDirectory();
|
|
17
25
|
if (isDirectory) {
|
|
18
26
|
configPath = await findStudioConfigPath(configPath);
|
|
19
27
|
}
|
|
28
|
+
debug('Finding studio config path %s', configPath);
|
|
20
29
|
let config = await doImport(configPath);
|
|
30
|
+
debug('Imported config %o', config);
|
|
21
31
|
if (!isStudioConfig(config)) {
|
|
22
32
|
if (!('default' in config) || !isStudioConfig(config.default)) {
|
|
33
|
+
debug('Invalid studio config format in "%s"', configPath);
|
|
23
34
|
throw new TypeError(`Invalid studio config format in "${configPath}"`);
|
|
24
35
|
}
|
|
25
36
|
config = config.default;
|
|
26
37
|
}
|
|
27
38
|
const workDir = dirname(configPath);
|
|
39
|
+
debug('Work dir %s', workDir);
|
|
28
40
|
const { resolveConfig } = await resolveLocalPackage('sanity', workDir);
|
|
29
41
|
if (typeof resolveConfig !== 'function') {
|
|
30
42
|
throw new TypeError('Expected `resolveConfig` from `sanity` to be a function');
|
|
@@ -44,6 +56,7 @@ import { isStudioConfig } from './isStudioConfig.js';
|
|
|
44
56
|
state: of(getEmptyAuth())
|
|
45
57
|
}
|
|
46
58
|
}));
|
|
59
|
+
debug('Unauthed workspaces %o', unauthedWorkspaces);
|
|
47
60
|
return firstValueFrom(resolveConfig(unauthedWorkspaces));
|
|
48
61
|
}
|
|
49
62
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/config/studio/getStudioWorkspaces.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {dirname} from 'node:path'\n\nimport {firstValueFrom, of} from 'rxjs'\nimport {type Workspace} from 'sanity'\n\nimport {doImport} from '../../util/doImport.js'\nimport {getEmptyAuth} from '../../util/getEmptyAuth.js'\nimport {resolveLocalPackage} from '../../util/resolveLocalPackage.js'\nimport {findStudioConfigPath} from '../util/findStudioConfigPath.js'\nimport {isStudioConfig} from './isStudioConfig.js'\n\n/**\n * Resolves the workspaces from the studio config.\n *\n * @param
|
|
1
|
+
{"version":3,"sources":["../../../src/config/studio/getStudioWorkspaces.ts"],"sourcesContent":["import {stat} from 'node:fs/promises'\nimport {dirname} from 'node:path'\nimport {isMainThread} from 'node:worker_threads'\n\nimport {firstValueFrom, of} from 'rxjs'\nimport {type Workspace} from 'sanity'\n\nimport {subdebug} from '../../debug.js'\nimport {doImport} from '../../util/doImport.js'\nimport {getEmptyAuth} from '../../util/getEmptyAuth.js'\nimport {resolveLocalPackage} from '../../util/resolveLocalPackage.js'\nimport {findStudioConfigPath} from '../util/findStudioConfigPath.js'\nimport {isStudioConfig} from './isStudioConfig.js'\n\nconst debug = subdebug('worker:getStudioWorkspaces')\n\n/**\n * Resolves the workspaces from the studio config.\n *\n * NOTE: This function should only be called from a worker thread.\n *\n * @param configPath - The path to the studio config\n * @returns The workspaces\n * @internal\n */\nexport async function getStudioWorkspaces(configPath: string): Promise<Workspace[]> {\n if (isMainThread) {\n throw new Error('getStudioWorkspaces should only be called from a worker thread')\n }\n const isDirectory = (await stat(configPath)).isDirectory()\n if (isDirectory) {\n configPath = await findStudioConfigPath(configPath)\n }\n debug('Finding studio config path %s', configPath)\n let config = await doImport(configPath)\n\n debug('Imported config %o', config)\n if (!isStudioConfig(config)) {\n if (!('default' in config) || !isStudioConfig(config.default)) {\n debug('Invalid studio config format in \"%s\"', configPath)\n throw new TypeError(`Invalid studio config format in \"${configPath}\"`)\n }\n\n config = config.default\n }\n\n const workDir = dirname(configPath)\n debug('Work dir %s', workDir)\n const {resolveConfig} = await resolveLocalPackage<typeof import('sanity')>('sanity', workDir)\n if (typeof resolveConfig !== 'function') {\n throw new TypeError('Expected `resolveConfig` from `sanity` to be a function')\n }\n\n // We will also want to stub out some configuration - we don't need to resolve the\n // users' logged in state, for instance - so let's disable the auth implementation.\n const rawWorkspaces = Array.isArray(config)\n ? config\n : [{...config, basePath: config.basePath || '/', name: config.name || 'default'}]\n\n const unauthedWorkspaces = rawWorkspaces.map((workspace) => ({\n ...workspace,\n auth: {state: of(getEmptyAuth())},\n }))\n\n debug('Unauthed workspaces %o', unauthedWorkspaces)\n\n return firstValueFrom(resolveConfig(unauthedWorkspaces))\n}\n"],"names":["stat","dirname","isMainThread","firstValueFrom","of","subdebug","doImport","getEmptyAuth","resolveLocalPackage","findStudioConfigPath","isStudioConfig","debug","getStudioWorkspaces","configPath","Error","isDirectory","config","default","TypeError","workDir","resolveConfig","rawWorkspaces","Array","isArray","basePath","name","unauthedWorkspaces","map","workspace","auth","state"],"mappings":"AAAA,SAAQA,IAAI,QAAO,mBAAkB;AACrC,SAAQC,OAAO,QAAO,YAAW;AACjC,SAAQC,YAAY,QAAO,sBAAqB;AAEhD,SAAQC,cAAc,EAAEC,EAAE,QAAO,OAAM;AAGvC,SAAQC,QAAQ,QAAO,iBAAgB;AACvC,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,YAAY,QAAO,6BAA4B;AACvD,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,oBAAoB,QAAO,kCAAiC;AACpE,SAAQC,cAAc,QAAO,sBAAqB;AAElD,MAAMC,QAAQN,SAAS;AAEvB;;;;;;;;CAQC,GACD,OAAO,eAAeO,oBAAoBC,UAAkB;IAC1D,IAAIX,cAAc;QAChB,MAAM,IAAIY,MAAM;IAClB;IACA,MAAMC,cAAc,AAAC,CAAA,MAAMf,KAAKa,WAAU,EAAGE,WAAW;IACxD,IAAIA,aAAa;QACfF,aAAa,MAAMJ,qBAAqBI;IAC1C;IACAF,MAAM,iCAAiCE;IACvC,IAAIG,SAAS,MAAMV,SAASO;IAE5BF,MAAM,sBAAsBK;IAC5B,IAAI,CAACN,eAAeM,SAAS;QAC3B,IAAI,CAAE,CAAA,aAAaA,MAAK,KAAM,CAACN,eAAeM,OAAOC,OAAO,GAAG;YAC7DN,MAAM,wCAAwCE;YAC9C,MAAM,IAAIK,UAAU,CAAC,iCAAiC,EAAEL,WAAW,CAAC,CAAC;QACvE;QAEAG,SAASA,OAAOC,OAAO;IACzB;IAEA,MAAME,UAAUlB,QAAQY;IACxBF,MAAM,eAAeQ;IACrB,MAAM,EAACC,aAAa,EAAC,GAAG,MAAMZ,oBAA6C,UAAUW;IACrF,IAAI,OAAOC,kBAAkB,YAAY;QACvC,MAAM,IAAIF,UAAU;IACtB;IAEA,kFAAkF;IAClF,mFAAmF;IACnF,MAAMG,gBAAgBC,MAAMC,OAAO,CAACP,UAChCA,SACA;QAAC;YAAC,GAAGA,MAAM;YAAEQ,UAAUR,OAAOQ,QAAQ,IAAI;YAAKC,MAAMT,OAAOS,IAAI,IAAI;QAAS;KAAE;IAEnF,MAAMC,qBAAqBL,cAAcM,GAAG,CAAC,CAACC,YAAe,CAAA;YAC3D,GAAGA,SAAS;YACZC,MAAM;gBAACC,OAAO1B,GAAGG;YAAe;QAClC,CAAA;IAEAI,MAAM,0BAA0Be;IAEhC,OAAOvB,eAAeiB,cAAcM;AACtC"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { isMainThread, parentPort, workerData } from 'node:worker_threads';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { subdebug } from '../../debug.js';
|
|
3
4
|
import { doImport } from '../../util/doImport.js';
|
|
4
5
|
import { safeStructuredClone } from '../../util/safeStructuredClone.js';
|
|
5
6
|
import { getStudioWorkspaces } from './getStudioWorkspaces.js';
|
|
6
7
|
if (isMainThread || !parentPort) {
|
|
7
8
|
throw new Error('Should only be run in a worker!');
|
|
8
9
|
}
|
|
10
|
+
const debug = subdebug('readStudioConfig.worker');
|
|
9
11
|
const { configPath, resolvePlugins } = z.object({
|
|
10
12
|
configPath: z.string(),
|
|
11
13
|
resolvePlugins: z.boolean()
|
|
12
14
|
}).parse(workerData);
|
|
15
|
+
debug('Parsing config path %s', configPath);
|
|
13
16
|
let { default: config } = await doImport(configPath);
|
|
17
|
+
debug('Imported config %o', config);
|
|
14
18
|
if (resolvePlugins) {
|
|
19
|
+
debug('Resolving workspaces');
|
|
15
20
|
config = await getStudioWorkspaces(configPath);
|
|
21
|
+
debug('Resolved workspaces %o', config);
|
|
16
22
|
}
|
|
17
23
|
parentPort.postMessage(safeStructuredClone(config));
|
|
18
|
-
// Explicitly exit the process to avoid any dangling references from keeping
|
|
19
|
-
// the process alive after resolving it's main task
|
|
20
|
-
setImmediate(()=>{
|
|
21
|
-
process.exit(1);
|
|
22
|
-
});
|
|
23
24
|
|
|
24
25
|
//# sourceMappingURL=readStudioConfig.worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/config/studio/readStudioConfig.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {z} from 'zod'\n\nimport {doImport} from '../../util/doImport.js'\nimport {safeStructuredClone} from '../../util/safeStructuredClone.js'\nimport {getStudioWorkspaces} from './getStudioWorkspaces.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst {configPath, resolvePlugins} = z\n .object({configPath: z.string(), resolvePlugins: z.boolean()})\n .parse(workerData)\n\nlet {default: config} = await doImport(configPath)\n\nif (resolvePlugins) {\n config = await getStudioWorkspaces(configPath)\n}\n\nparentPort.postMessage(safeStructuredClone(config))\n
|
|
1
|
+
{"version":3,"sources":["../../../src/config/studio/readStudioConfig.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {z} from 'zod'\n\nimport {subdebug} from '../../debug.js'\nimport {doImport} from '../../util/doImport.js'\nimport {safeStructuredClone} from '../../util/safeStructuredClone.js'\nimport {getStudioWorkspaces} from './getStudioWorkspaces.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst debug = subdebug('readStudioConfig.worker')\n\nconst {configPath, resolvePlugins} = z\n .object({configPath: z.string(), resolvePlugins: z.boolean()})\n .parse(workerData)\n\ndebug('Parsing config path %s', configPath)\n\nlet {default: config} = await doImport(configPath)\n\ndebug('Imported config %o', config)\n\nif (resolvePlugins) {\n debug('Resolving workspaces')\n config = await getStudioWorkspaces(configPath)\n debug('Resolved workspaces %o', config)\n}\n\nparentPort.postMessage(safeStructuredClone(config))\n"],"names":["isMainThread","parentPort","workerData","z","subdebug","doImport","safeStructuredClone","getStudioWorkspaces","Error","debug","configPath","resolvePlugins","object","string","boolean","parse","default","config","postMessage"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,CAAC,QAAO,MAAK;AAErB,SAAQC,QAAQ,QAAO,iBAAgB;AACvC,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,mBAAmB,QAAO,2BAA0B;AAE5D,IAAIP,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIO,MAAM;AAClB;AAEA,MAAMC,QAAQL,SAAS;AAEvB,MAAM,EAACM,UAAU,EAAEC,cAAc,EAAC,GAAGR,EAClCS,MAAM,CAAC;IAACF,YAAYP,EAAEU,MAAM;IAAIF,gBAAgBR,EAAEW,OAAO;AAAE,GAC3DC,KAAK,CAACb;AAETO,MAAM,0BAA0BC;AAEhC,IAAI,EAACM,SAASC,MAAM,EAAC,GAAG,MAAMZ,SAASK;AAEvCD,MAAM,sBAAsBQ;AAE5B,IAAIN,gBAAgB;IAClBF,MAAM;IACNQ,SAAS,MAAMV,oBAAoBG;IACnCD,MAAM,0BAA0BQ;AAClC;AAEAhB,WAAWiB,WAAW,CAACZ,oBAAoBW"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CLIError } from '@oclif/core/errors';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when a prompt is attempted in a non-interactive environment
|
|
4
|
+
* (e.g., CI, non-TTY, piped stdin). Callers can catch this specific error
|
|
5
|
+
* to provide appropriate fallback behavior.
|
|
6
|
+
*
|
|
7
|
+
* Extends `CLIError` to suppress stack traces in user-facing output.
|
|
8
|
+
*/ export class NonInteractiveError extends CLIError {
|
|
9
|
+
constructor(promptName){
|
|
10
|
+
super(`Cannot run "${promptName}" prompt in a non-interactive environment. ` + 'Provide the required value via flags or environment variables, or run in an interactive terminal.', {
|
|
11
|
+
code: 'NON_INTERACTIVE',
|
|
12
|
+
exit: 1
|
|
13
|
+
});
|
|
14
|
+
this.name = 'NonInteractiveError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=NonInteractiveError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/errors/NonInteractiveError.ts"],"sourcesContent":["import {CLIError} from '@oclif/core/errors'\n\n/**\n * Error thrown when a prompt is attempted in a non-interactive environment\n * (e.g., CI, non-TTY, piped stdin). Callers can catch this specific error\n * to provide appropriate fallback behavior.\n *\n * Extends `CLIError` to suppress stack traces in user-facing output.\n */\nexport class NonInteractiveError extends CLIError {\n constructor(promptName: string) {\n super(\n `Cannot run \"${promptName}\" prompt in a non-interactive environment. ` +\n 'Provide the required value via flags or environment variables, or run in an interactive terminal.',\n {code: 'NON_INTERACTIVE', exit: 1},\n )\n this.name = 'NonInteractiveError'\n }\n}\n"],"names":["CLIError","NonInteractiveError","promptName","code","exit","name"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,qBAAoB;AAE3C;;;;;;CAMC,GACD,OAAO,MAAMC,4BAA4BD;IACvC,YAAYE,UAAkB,CAAE;QAC9B,KAAK,CACH,CAAC,YAAY,EAAEA,WAAW,2CAA2C,CAAC,GACpE,qGACF;YAACC,MAAM;YAAmBC,MAAM;QAAC;QAEnC,IAAI,CAACC,IAAI,GAAG;IACd;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/errors/NotFoundError.ts"],"sourcesContent":["import {isRecord} from '../util/isRecord.js'\n\n/**\n * Error thrown when a file or directory is not found\n *\n * `code` is always `ENOENT` to mirror Node.js behavior when a file is not found\n *\n * @internal\n */\nexport class NotFoundError extends Error {\n code = 'ENOENT'\n path?: string\n\n constructor(message: string, path?: string) {\n super(message)\n this.path = path\n this.name = 'NotFoundError'\n }\n}\n\n/**\n * Returns whether or not the given error is a `NotFoundError`\n *\n * @param err - The error to check\n * @returns `true` if the error is a `NotFoundError`, `false` otherwise\n * @internal\n */\nexport function isNotFoundError(err: unknown): err is NotFoundError {\n return (\n isRecord(err) &&\n 'name' in err &&\n err.name === 'NotFoundError' &&\n 'code' in err &&\n err.code === 'ENOENT' &&\n 'message' in err &&\n typeof err.message === 'string'\n )\n}\n"],"names":["isRecord","NotFoundError","Error","code","path","message","name","isNotFoundError","err"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,sBAAqB;AAE5C;;;;;;CAMC,GACD,OAAO,MAAMC,sBAAsBC;IACjCC,OAAO,SAAQ;IACfC,KAAa;IAEb,YAAYC,OAAe,EAAED,IAAa,CAAE;QAC1C,KAAK,CAACC;QACN,IAAI,CAACD,IAAI,GAAGA;QACZ,IAAI,CAACE,IAAI,GAAG;IACd;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,gBAAgBC,GAAY;IAC1C,OACER,SAASQ,QACT,UAAUA,OACVA,IAAIF,IAAI,KAAK,mBACb,UAAUE,OACVA,IAAIL,IAAI,KAAK,YACb,aAAaK,OACb,OAAOA,IAAIH,OAAO,KAAK;AAE3B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CLIError } from '@oclif/core/errors';
|
|
2
|
+
import { isRecord } from '../util/isRecord.js';
|
|
3
|
+
/**
|
|
4
|
+
* Error thrown when a project root directory cannot be found.
|
|
5
|
+
*
|
|
6
|
+
* This occurs when the CLI is run outside a Sanity project directory
|
|
7
|
+
* (one containing `sanity.config.(ts|js)` or `sanity.cli.(ts|js)`).
|
|
8
|
+
*
|
|
9
|
+
* Extends `CLIError` to suppress stack traces in user-facing output.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/ export class ProjectRootNotFoundError extends CLIError {
|
|
13
|
+
constructor(message, options){
|
|
14
|
+
super(message, {
|
|
15
|
+
code: 'PROJECT_ROOT_NOT_FOUND',
|
|
16
|
+
exit: 1,
|
|
17
|
+
suggestions: options?.suggestions
|
|
18
|
+
});
|
|
19
|
+
this.name = 'ProjectRootNotFoundError';
|
|
20
|
+
if (options?.cause) {
|
|
21
|
+
this.cause = options.cause;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns whether or not the given error is a `ProjectRootNotFoundError`
|
|
27
|
+
*
|
|
28
|
+
* @param err - The error to check
|
|
29
|
+
* @returns `true` if the error is a `ProjectRootNotFoundError`, `false` otherwise
|
|
30
|
+
* @internal
|
|
31
|
+
*/ export function isProjectRootNotFoundError(err) {
|
|
32
|
+
return isRecord(err) && 'name' in err && err.name === 'ProjectRootNotFoundError' && 'code' in err && err.code === 'PROJECT_ROOT_NOT_FOUND' && 'message' in err && typeof err.message === 'string';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=ProjectRootNotFoundError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/errors/ProjectRootNotFoundError.ts"],"sourcesContent":["import {CLIError} from '@oclif/core/errors'\n\nimport {isRecord} from '../util/isRecord.js'\n\n/**\n * Error thrown when a project root directory cannot be found.\n *\n * This occurs when the CLI is run outside a Sanity project directory\n * (one containing `sanity.config.(ts|js)` or `sanity.cli.(ts|js)`).\n *\n * Extends `CLIError` to suppress stack traces in user-facing output.\n *\n * @internal\n */\nexport class ProjectRootNotFoundError extends CLIError {\n constructor(message: string, options?: {cause?: Error; suggestions?: string[]}) {\n super(message, {code: 'PROJECT_ROOT_NOT_FOUND', exit: 1, suggestions: options?.suggestions})\n this.name = 'ProjectRootNotFoundError'\n if (options?.cause) {\n this.cause = options.cause\n }\n }\n}\n\n/**\n * Returns whether or not the given error is a `ProjectRootNotFoundError`\n *\n * @param err - The error to check\n * @returns `true` if the error is a `ProjectRootNotFoundError`, `false` otherwise\n * @internal\n */\nexport function isProjectRootNotFoundError(err: unknown): err is ProjectRootNotFoundError {\n return (\n isRecord(err) &&\n 'name' in err &&\n err.name === 'ProjectRootNotFoundError' &&\n 'code' in err &&\n err.code === 'PROJECT_ROOT_NOT_FOUND' &&\n 'message' in err &&\n typeof err.message === 'string'\n )\n}\n"],"names":["CLIError","isRecord","ProjectRootNotFoundError","message","options","code","exit","suggestions","name","cause","isProjectRootNotFoundError","err"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,qBAAoB;AAE3C,SAAQC,QAAQ,QAAO,sBAAqB;AAE5C;;;;;;;;;CASC,GACD,OAAO,MAAMC,iCAAiCF;IAC5C,YAAYG,OAAe,EAAEC,OAAiD,CAAE;QAC9E,KAAK,CAACD,SAAS;YAACE,MAAM;YAA0BC,MAAM;YAAGC,aAAaH,SAASG;QAAW;QAC1F,IAAI,CAACC,IAAI,GAAG;QACZ,IAAIJ,SAASK,OAAO;YAClB,IAAI,CAACA,KAAK,GAAGL,QAAQK,KAAK;QAC5B;IACF;AACF;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,2BAA2BC,GAAY;IACrD,OACEV,SAASU,QACT,UAAUA,OACVA,IAAIH,IAAI,KAAK,8BACb,UAAUG,OACVA,IAAIN,IAAI,KAAK,4BACb,aAAaM,OACb,OAAOA,IAAIR,OAAO,KAAK;AAE3B"}
|