@sanity/cli-core 0.0.0-20260511075627 → 0.0.0-20260522074424
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 +37 -0
- package/dist/_exports/index.js +2 -0
- package/dist/_exports/index.js.map +1 -1
- package/dist/util/getLocalPackageVersion.js +55 -0
- package/dist/util/getLocalPackageVersion.js.map +1 -0
- package/dist/util/getWorkspace.js +20 -0
- package/dist/util/getWorkspace.js.map +1 -0
- package/dist/util/importModule.js +1 -1
- package/dist/util/importModule.js.map +1 -1
- package/package.json +7 -7
package/dist/_exports/index.d.ts
CHANGED
|
@@ -481,6 +481,34 @@ export declare function getGlobalCliClient({
|
|
|
481
481
|
...config
|
|
482
482
|
}: GlobalCliClientOptions): Promise<SanityClient_2>;
|
|
483
483
|
|
|
484
|
+
/**
|
|
485
|
+
* Resolve the filesystem directory of a locally installed package using Node
|
|
486
|
+
* module resolution. Works correctly with hoisted packages in monorepos/workspaces,
|
|
487
|
+
* pnpm symlinks, and other non-standard node_modules layouts.
|
|
488
|
+
*
|
|
489
|
+
* @param moduleName - The name of the package in npm.
|
|
490
|
+
* @param workDir - The working directory to resolve the module from. (aka project root)
|
|
491
|
+
* @returns The absolute path to the package directory.
|
|
492
|
+
* @internal
|
|
493
|
+
*/
|
|
494
|
+
export declare function getLocalPackageDir(
|
|
495
|
+
moduleName: string,
|
|
496
|
+
workDir: string,
|
|
497
|
+
): string;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Get the version of a package installed locally.
|
|
501
|
+
*
|
|
502
|
+
* @param moduleName - The name of the package in npm.
|
|
503
|
+
* @param workDir - The working directory to resolve the module from. (aka project root)
|
|
504
|
+
* @returns The version of the package installed locally.
|
|
505
|
+
* @internal
|
|
506
|
+
*/
|
|
507
|
+
export declare function getLocalPackageVersion(
|
|
508
|
+
moduleName: string,
|
|
509
|
+
workDir: string,
|
|
510
|
+
): Promise<string | null>;
|
|
511
|
+
|
|
484
512
|
/**
|
|
485
513
|
* Create a "project" (scoped) Sanity API client.
|
|
486
514
|
*
|
|
@@ -620,6 +648,15 @@ export declare function getTimer(): TimeMeasurer;
|
|
|
620
648
|
*/
|
|
621
649
|
export declare function getUserConfig(): ConfigStore;
|
|
622
650
|
|
|
651
|
+
/**
|
|
652
|
+
* @internal
|
|
653
|
+
*/
|
|
654
|
+
export declare function getWorkspace<
|
|
655
|
+
T extends {
|
|
656
|
+
name: string;
|
|
657
|
+
},
|
|
658
|
+
>(workspaces: T[], workspaceName?: string): T;
|
|
659
|
+
|
|
623
660
|
/**
|
|
624
661
|
* @public
|
|
625
662
|
*/
|
package/dist/_exports/index.js
CHANGED
|
@@ -23,9 +23,11 @@ export { getTelemetryBaseInfo } from '../telemetry/getTelemetryBaseInfo.js';
|
|
|
23
23
|
export { noopLogger } from '../telemetry/noopTelemetry.js';
|
|
24
24
|
export { doImport } from '../util/doImport.js';
|
|
25
25
|
export * from '../util/environment/mockBrowserEnvironment.js';
|
|
26
|
+
export * from '../util/getLocalPackageVersion.js';
|
|
26
27
|
export * from '../util/getSanityConfigDir.js';
|
|
27
28
|
export * from '../util/getSanityEnvVar.js';
|
|
28
29
|
export * from '../util/getSanityUrl.js';
|
|
30
|
+
export * from '../util/getWorkspace.js';
|
|
29
31
|
export * from '../util/importModule.js';
|
|
30
32
|
export * from '../util/isCi.js';
|
|
31
33
|
export * from '../util/isInteractive.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/getSanityConfigDir.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","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,SACEA,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,gCAA+B;AAC7C,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"}
|
|
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,SACEA,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"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { dirname, join, normalize, resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
3
|
+
import { moduleResolve } from 'import-meta-resolve';
|
|
4
|
+
import { readPackageJson } from './readPackageJson.js';
|
|
5
|
+
/**
|
|
6
|
+
* Get the version of a package installed locally.
|
|
7
|
+
*
|
|
8
|
+
* @param moduleName - The name of the package in npm.
|
|
9
|
+
* @param workDir - The working directory to resolve the module from. (aka project root)
|
|
10
|
+
* @returns The version of the package installed locally.
|
|
11
|
+
* @internal
|
|
12
|
+
*/ export async function getLocalPackageVersion(moduleName, workDir) {
|
|
13
|
+
try {
|
|
14
|
+
const packageDir = getLocalPackageDir(moduleName, workDir);
|
|
15
|
+
return (await readPackageJson(join(packageDir, 'package.json'))).version;
|
|
16
|
+
} catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolve the filesystem directory of a locally installed package using Node
|
|
22
|
+
* module resolution. Works correctly with hoisted packages in monorepos/workspaces,
|
|
23
|
+
* pnpm symlinks, and other non-standard node_modules layouts.
|
|
24
|
+
*
|
|
25
|
+
* @param moduleName - The name of the package in npm.
|
|
26
|
+
* @param workDir - The working directory to resolve the module from. (aka project root)
|
|
27
|
+
* @returns The absolute path to the package directory.
|
|
28
|
+
* @internal
|
|
29
|
+
*/ export function getLocalPackageDir(moduleName, workDir) {
|
|
30
|
+
// Handle import.meta.url being passed instead of a directory path
|
|
31
|
+
const dir = workDir.startsWith('file://') ? dirname(fileURLToPath(workDir)) : workDir;
|
|
32
|
+
const dirUrl = pathToFileURL(resolve(dir, 'noop.js'));
|
|
33
|
+
try {
|
|
34
|
+
const packageJsonUrl = moduleResolve(`${moduleName}/package.json`, dirUrl);
|
|
35
|
+
return dirname(fileURLToPath(packageJsonUrl));
|
|
36
|
+
} catch (err) {
|
|
37
|
+
if (!isErrPackagePathNotExported(err)) {
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Fallback: resolve main entry point and derive package root
|
|
42
|
+
const mainUrl = moduleResolve(moduleName, dirUrl);
|
|
43
|
+
const mainPath = fileURLToPath(mainUrl);
|
|
44
|
+
const normalizedName = normalize(moduleName);
|
|
45
|
+
const idx = mainPath.lastIndexOf(normalizedName);
|
|
46
|
+
if (idx === -1) {
|
|
47
|
+
throw new Error(`Could not determine package directory for '${moduleName}'`);
|
|
48
|
+
}
|
|
49
|
+
return mainPath.slice(0, idx + normalizedName.length);
|
|
50
|
+
}
|
|
51
|
+
function isErrPackagePathNotExported(err) {
|
|
52
|
+
return err instanceof Error && 'code' in err && err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=getLocalPackageVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/util/getLocalPackageVersion.ts"],"sourcesContent":["import {dirname, join, normalize, resolve} from 'node:path'\nimport {fileURLToPath, pathToFileURL} from 'node:url'\n\nimport {moduleResolve} from 'import-meta-resolve'\n\nimport {readPackageJson} from './readPackageJson.js'\n\n/**\n * Get the version of a package installed locally.\n *\n * @param moduleName - The name of the package in npm.\n * @param workDir - The working directory to resolve the module from. (aka project root)\n * @returns The version of the package installed locally.\n * @internal\n */\nexport async function getLocalPackageVersion(\n moduleName: string,\n workDir: string,\n): Promise<string | null> {\n try {\n const packageDir = getLocalPackageDir(moduleName, workDir)\n return (await readPackageJson(join(packageDir, 'package.json'))).version\n } catch {\n return null\n }\n}\n\n/**\n * Resolve the filesystem directory of a locally installed package using Node\n * module resolution. Works correctly with hoisted packages in monorepos/workspaces,\n * pnpm symlinks, and other non-standard node_modules layouts.\n *\n * @param moduleName - The name of the package in npm.\n * @param workDir - The working directory to resolve the module from. (aka project root)\n * @returns The absolute path to the package directory.\n * @internal\n */\nexport function getLocalPackageDir(moduleName: string, workDir: string): string {\n // Handle import.meta.url being passed instead of a directory path\n const dir = workDir.startsWith('file://') ? dirname(fileURLToPath(workDir)) : workDir\n const dirUrl = pathToFileURL(resolve(dir, 'noop.js'))\n\n try {\n const packageJsonUrl = moduleResolve(`${moduleName}/package.json`, dirUrl)\n return dirname(fileURLToPath(packageJsonUrl))\n } catch (err: unknown) {\n if (!isErrPackagePathNotExported(err)) {\n throw err\n }\n }\n\n // Fallback: resolve main entry point and derive package root\n const mainUrl = moduleResolve(moduleName, dirUrl)\n const mainPath = fileURLToPath(mainUrl)\n const normalizedName = normalize(moduleName)\n const idx = mainPath.lastIndexOf(normalizedName)\n if (idx === -1) {\n throw new Error(`Could not determine package directory for '${moduleName}'`)\n }\n return mainPath.slice(0, idx + normalizedName.length)\n}\n\nfunction isErrPackagePathNotExported(err: unknown): boolean {\n return err instanceof Error && 'code' in err && err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED'\n}\n"],"names":["dirname","join","normalize","resolve","fileURLToPath","pathToFileURL","moduleResolve","readPackageJson","getLocalPackageVersion","moduleName","workDir","packageDir","getLocalPackageDir","version","dir","startsWith","dirUrl","packageJsonUrl","err","isErrPackagePathNotExported","mainUrl","mainPath","normalizedName","idx","lastIndexOf","Error","slice","length","code"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,IAAI,EAAEC,SAAS,EAAEC,OAAO,QAAO,YAAW;AAC3D,SAAQC,aAAa,EAAEC,aAAa,QAAO,WAAU;AAErD,SAAQC,aAAa,QAAO,sBAAqB;AAEjD,SAAQC,eAAe,QAAO,uBAAsB;AAEpD;;;;;;;CAOC,GACD,OAAO,eAAeC,uBACpBC,UAAkB,EAClBC,OAAe;IAEf,IAAI;QACF,MAAMC,aAAaC,mBAAmBH,YAAYC;QAClD,OAAO,AAAC,CAAA,MAAMH,gBAAgBN,KAAKU,YAAY,gBAAe,EAAGE,OAAO;IAC1E,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASD,mBAAmBH,UAAkB,EAAEC,OAAe;IACpE,kEAAkE;IAClE,MAAMI,MAAMJ,QAAQK,UAAU,CAAC,aAAaf,QAAQI,cAAcM,YAAYA;IAC9E,MAAMM,SAASX,cAAcF,QAAQW,KAAK;IAE1C,IAAI;QACF,MAAMG,iBAAiBX,cAAc,GAAGG,WAAW,aAAa,CAAC,EAAEO;QACnE,OAAOhB,QAAQI,cAAca;IAC/B,EAAE,OAAOC,KAAc;QACrB,IAAI,CAACC,4BAA4BD,MAAM;YACrC,MAAMA;QACR;IACF;IAEA,6DAA6D;IAC7D,MAAME,UAAUd,cAAcG,YAAYO;IAC1C,MAAMK,WAAWjB,cAAcgB;IAC/B,MAAME,iBAAiBpB,UAAUO;IACjC,MAAMc,MAAMF,SAASG,WAAW,CAACF;IACjC,IAAIC,QAAQ,CAAC,GAAG;QACd,MAAM,IAAIE,MAAM,CAAC,2CAA2C,EAAEhB,WAAW,CAAC,CAAC;IAC7E;IACA,OAAOY,SAASK,KAAK,CAAC,GAAGH,MAAMD,eAAeK,MAAM;AACtD;AAEA,SAASR,4BAA4BD,GAAY;IAC/C,OAAOA,eAAeO,SAAS,UAAUP,OAAOA,IAAIU,IAAI,KAAK;AAC/D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
*/ export function getWorkspace(workspaces, workspaceName) {
|
|
4
|
+
if (workspaces.length === 0) {
|
|
5
|
+
throw new Error('No workspaces found');
|
|
6
|
+
}
|
|
7
|
+
if (workspaces.length === 1) {
|
|
8
|
+
return workspaces[0];
|
|
9
|
+
}
|
|
10
|
+
if (!workspaceName) {
|
|
11
|
+
throw new Error(`Multiple workspaces found. Please specify which workspace to use with '--workspace' or with the schemaExtraction.workspace config prop. Available workspaces: ${workspaces.map((w)=>w.name).join(', ')}`);
|
|
12
|
+
}
|
|
13
|
+
const workspace = workspaces.find((w)=>w.name === workspaceName);
|
|
14
|
+
if (!workspace) {
|
|
15
|
+
throw new Error(`Could not find "${workspaceName}" workspace. Available workspaces: ${workspaces.map((w)=>w.name).join(', ')}`);
|
|
16
|
+
}
|
|
17
|
+
return workspace;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=getWorkspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/util/getWorkspace.ts"],"sourcesContent":["/**\n * @internal\n */\nexport function getWorkspace<T extends {name: string}>(workspaces: T[], workspaceName?: string) {\n if (workspaces.length === 0) {\n throw new Error('No workspaces found')\n }\n\n if (workspaces.length === 1) {\n return workspaces[0]\n }\n\n if (!workspaceName) {\n throw new Error(\n `Multiple workspaces found. Please specify which workspace to use with '--workspace' or with the schemaExtraction.workspace config prop. Available workspaces: ${workspaces.map((w) => w.name).join(', ')}`,\n )\n }\n\n const workspace = workspaces.find((w) => w.name === workspaceName)\n\n if (!workspace) {\n throw new Error(\n `Could not find \"${workspaceName}\" workspace. Available workspaces: ${workspaces.map((w) => w.name).join(', ')}`,\n )\n }\n\n return workspace\n}\n"],"names":["getWorkspace","workspaces","workspaceName","length","Error","map","w","name","join","workspace","find"],"mappings":"AAAA;;CAEC,GACD,OAAO,SAASA,aAAuCC,UAAe,EAAEC,aAAsB;IAC5F,IAAID,WAAWE,MAAM,KAAK,GAAG;QAC3B,MAAM,IAAIC,MAAM;IAClB;IAEA,IAAIH,WAAWE,MAAM,KAAK,GAAG;QAC3B,OAAOF,UAAU,CAAC,EAAE;IACtB;IAEA,IAAI,CAACC,eAAe;QAClB,MAAM,IAAIE,MACR,CAAC,8JAA8J,EAAEH,WAAWI,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEC,IAAI,CAAC,OAAO;IAE/M;IAEA,MAAMC,YAAYR,WAAWS,IAAI,CAAC,CAACJ,IAAMA,EAAEC,IAAI,KAAKL;IAEpD,IAAI,CAACO,WAAW;QACd,MAAM,IAAIL,MACR,CAAC,gBAAgB,EAAEF,cAAc,mCAAmC,EAAED,WAAWI,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEC,IAAI,CAAC,OAAO;IAEpH;IAEA,OAAOC;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/importModule.ts"],"sourcesContent":["import {fileURLToPath, pathToFileURL} from 'node:url'\n\nimport {createJiti, type JitiResolveOptions} from '
|
|
1
|
+
{"version":3,"sources":["../../src/util/importModule.ts"],"sourcesContent":["import {fileURLToPath, pathToFileURL} from 'node:url'\n\nimport {createJiti, type JitiResolveOptions} from 'jiti'\n\nimport {subdebug} from '../debug.js'\n\ninterface ImportModuleOptions {\n /**\n * Whether to return the default export of the module.\n * Default: true\n */\n default?: boolean\n\n /**\n * Path to the tsconfig file to use for the import. If not provided, the tsconfig\n * will be inferred from the nearest `tsconfig.json` file.\n */\n tsconfigPath?: string\n}\n\nconst debug = subdebug('importModule')\n\n/**\n * Imports a module using jiti and returns its exports.\n * This is a thin wrapper around tsx to allow swapping out the underlying implementation in the future if needed.\n *\n * @param filePath - Path to the module to import.\n * @param options - Options for the importModule function.\n * @returns The exported module.\n *\n * @internal\n */\nexport async function importModule<T = unknown>(\n filePath: string | URL,\n options: ImportModuleOptions = {},\n): Promise<T> {\n const {default: returnDefault = true, tsconfigPath} = options\n\n const jiti = createJiti(import.meta.url, {\n debug: debug.enabled,\n tsconfigPaths: typeof tsconfigPath === 'string' ? tsconfigPath : true,\n })\n\n const fileURL = typeof filePath === 'string' ? pathToFileURL(filePath) : filePath\n\n debug(`Loading module: ${fileURLToPath(fileURL)}`, {tsconfigPath})\n\n const jitiOptions: JitiResolveOptions & {default?: true} = {}\n\n // If the default option is true, add it to the jiti options\n if (returnDefault) {\n jitiOptions.default = true\n }\n\n return jiti.import<T>(fileURLToPath(fileURL), jitiOptions)\n}\n"],"names":["fileURLToPath","pathToFileURL","createJiti","subdebug","debug","importModule","filePath","options","default","returnDefault","tsconfigPath","jiti","url","enabled","tsconfigPaths","fileURL","jitiOptions","import"],"mappings":"AAAA,SAAQA,aAAa,EAAEC,aAAa,QAAO,WAAU;AAErD,SAAQC,UAAU,QAAgC,OAAM;AAExD,SAAQC,QAAQ,QAAO,cAAa;AAgBpC,MAAMC,QAAQD,SAAS;AAEvB;;;;;;;;;CASC,GACD,OAAO,eAAeE,aACpBC,QAAsB,EACtBC,UAA+B,CAAC,CAAC;IAEjC,MAAM,EAACC,SAASC,gBAAgB,IAAI,EAAEC,YAAY,EAAC,GAAGH;IAEtD,MAAMI,OAAOT,WAAW,YAAYU,GAAG,EAAE;QACvCR,OAAOA,MAAMS,OAAO;QACpBC,eAAe,OAAOJ,iBAAiB,WAAWA,eAAe;IACnE;IAEA,MAAMK,UAAU,OAAOT,aAAa,WAAWL,cAAcK,YAAYA;IAEzEF,MAAM,CAAC,gBAAgB,EAAEJ,cAAce,UAAU,EAAE;QAACL;IAAY;IAEhE,MAAMM,cAAqD,CAAC;IAE5D,4DAA4D;IAC5D,IAAIP,eAAe;QACjBO,YAAYR,OAAO,GAAG;IACxB;IAEA,OAAOG,KAAKM,MAAM,CAAIjB,cAAce,UAAUC;AAChD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli-core",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-20260522074424",
|
|
4
4
|
"description": "Sanity CLI core package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -53,15 +53,15 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@inquirer/prompts": "^8.3.0",
|
|
55
55
|
"@oclif/core": "^4.10.6",
|
|
56
|
-
"@rexxars/jiti": "^2.6.2",
|
|
57
56
|
"@sanity/client": "^7.22.0",
|
|
58
57
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
59
58
|
"boxen": "^8.0.1",
|
|
60
59
|
"debug": "^4.4.3",
|
|
61
60
|
"get-it": "^8.7.0",
|
|
62
|
-
"get-tsconfig": "^4.
|
|
61
|
+
"get-tsconfig": "^4.14.0",
|
|
63
62
|
"import-meta-resolve": "^4.2.0",
|
|
64
|
-
"
|
|
63
|
+
"jiti": "^2.7.0",
|
|
64
|
+
"jsdom": "^29.1.1",
|
|
65
65
|
"json-lexer": "^1.2.0",
|
|
66
66
|
"log-symbols": "^7.0.1",
|
|
67
67
|
"ora": "^9.0.0",
|
|
@@ -79,11 +79,11 @@
|
|
|
79
79
|
"@swc/cli": "^0.8.1",
|
|
80
80
|
"@swc/core": "^1.15.33",
|
|
81
81
|
"@types/debug": "^4.1.13",
|
|
82
|
-
"@types/jsdom": "^28.0.
|
|
83
|
-
"@types/node": "^20.19.
|
|
82
|
+
"@types/jsdom": "^28.0.3",
|
|
83
|
+
"@types/node": "^20.19.41",
|
|
84
84
|
"eslint": "^10.2.1",
|
|
85
85
|
"publint": "^0.3.18",
|
|
86
|
-
"sanity": "^5.
|
|
86
|
+
"sanity": "^5.26.0",
|
|
87
87
|
"typescript": "^5.9.3",
|
|
88
88
|
"vitest": "^4.1.5",
|
|
89
89
|
"@repo/package.config": "0.0.1",
|