@sanity/cli-core 0.1.0-alpha.11 â 0.1.0-alpha.13
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/ux.d.ts +0 -4
- package/dist/_exports/ux.js +0 -1
- package/dist/_exports/ux.js.map +1 -1
- package/dist/config/cli/getCliConfig.js +2 -1
- package/dist/config/cli/getCliConfig.js.map +1 -1
- package/dist/config/cli/schemas.js +6 -0
- package/dist/config/cli/schemas.js.map +1 -1
- package/dist/config/cli/types/cliConfig.js.map +1 -1
- package/dist/config/studio/getStudioWorkspaces.js +7 -1
- package/dist/config/studio/getStudioWorkspaces.js.map +1 -1
- package/dist/index.d.ts +935 -5692
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/util/createExpiringConfig.js +1 -0
- package/dist/util/createExpiringConfig.js.map +1 -1
- package/dist/util/readPackageJson.js +70 -0
- package/dist/util/readPackageJson.js.map +1 -0
- package/package.json +8 -9
- package/dist/ux/chalk.js +0 -4
- package/dist/ux/chalk.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './config/cli/getCliConfig.js';
|
|
2
2
|
export * from './config/cli/getCliConfigSync.js';
|
|
3
|
-
export { cliConfigSchema } from './config/cli/schemas.js';
|
|
4
3
|
export * from './config/findProjectRoot.js';
|
|
5
4
|
export * from './config/findProjectRootSync.js';
|
|
6
5
|
export * from './config/studio/getStudioConfig.js';
|
|
@@ -35,7 +34,9 @@ export * from './util/isTrueish.js';
|
|
|
35
34
|
export * from './util/normalizePath.js';
|
|
36
35
|
export * from './util/parseStringFlag.js';
|
|
37
36
|
export * from './util/readNDJSON.js';
|
|
37
|
+
export * from './util/readPackageJson.js';
|
|
38
38
|
export * from './util/resolveLocalPackage.js';
|
|
39
|
+
export * from './util/safeStructuredClone.js';
|
|
39
40
|
export * from './util/tryGetDefaultExport.js';
|
|
40
41
|
export * from './ux/colorizeJson.js';
|
|
41
42
|
export * from './ux/formatObject.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './config/cli/getCliConfig.js'\nexport * from './config/cli/getCliConfigSync.js'\nexport {
|
|
1
|
+
{"version":3,"sources":["../src/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/util/findConfigsPaths.js'\nexport * from './config/util/findStudioConfigPath.js'\nexport {type ProjectRootResult} from './config/util/recursivelyResolveProjectRoot.js'\nexport * from './debug.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 * from './telemetry/createTelemetryStore.js'\nexport * from './telemetry/flushTelemetryFiles.js'\nexport * from './telemetry/getTelemetryBaseInfo.js'\nexport * from './telemetry/telemetryStoreDebug.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 * from './util/createExpiringConfig.js'\nexport {doImport} from './util/doImport.js'\nexport * from './util/environment/mockBrowserEnvironment.js'\nexport * from './util/fileExists.js'\nexport {\n clearCliTelemetry,\n CLI_TELEMETRY_SYMBOL,\n getCliTelemetry,\n setCliTelemetry,\n} from './util/getCliTelemetry.js'\nexport * from './util/getEmptyAuth.js'\nexport * from './util/getSanityEnvVar.js'\nexport * from './util/getSanityUrl.js'\nexport * from './util/getUserConfig.js'\nexport * from './util/isCi.js'\nexport * from './util/isInteractive.js'\nexport * from './util/isRecord.js'\nexport * from './util/isStaging.js'\nexport * from './util/isTrueish.js'\nexport * from './util/normalizePath.js'\nexport * from './util/parseStringFlag.js'\nexport * from './util/readNDJSON.js'\nexport * from './util/readPackageJson.js'\nexport * from './util/resolveLocalPackage.js'\nexport * from './util/safeStructuredClone.js'\nexport * from './util/tryGetDefaultExport.js'\nexport * from './ux/colorizeJson.js'\nexport * from './ux/formatObject.js'\nexport * from './ux/printKeyValue.js'\nexport * from './ux/timer.js'\n"],"names":["doImport","clearCliTelemetry","CLI_TELEMETRY_SYMBOL","getCliTelemetry","setCliTelemetry"],"mappings":"AAAA,cAAc,+BAA8B;AAC5C,cAAc,mCAAkC;AAGhD,cAAc,8BAA6B;AAC3C,cAAc,kCAAiC;AAC/C,cAAc,qCAAoC;AAClD,cAAc,yCAAwC;AACtD,cAAc,oCAAmC;AACjD,cAAc,wCAAuC;AAErD,cAAc,aAAY;AAC1B,cAAc,uCAAsC;AACpD,cAAc,iCAAgC;AAC9C,cAAc,qBAAoB;AAClC,cAAc,0BAAyB;AACvC,cAAc,8BAA6B;AAC3C,cAAc,4BAA2B;AACzC,cAAc,sCAAqC;AACnD,cAAc,qCAAoC;AAClD,cAAc,sCAAqC;AACnD,cAAc,qCAAoC;AAOlD,cAAc,iCAAgC;AAC9C,SAAQA,QAAQ,QAAO,qBAAoB;AAC3C,cAAc,+CAA8C;AAC5D,cAAc,uBAAsB;AACpC,SACEC,iBAAiB,EACjBC,oBAAoB,EACpBC,eAAe,EACfC,eAAe,QACV,4BAA2B;AAClC,cAAc,yBAAwB;AACtC,cAAc,4BAA2B;AACzC,cAAc,yBAAwB;AACtC,cAAc,0BAAyB;AACvC,cAAc,iBAAgB;AAC9B,cAAc,0BAAyB;AACvC,cAAc,qBAAoB;AAClC,cAAc,sBAAqB;AACnC,cAAc,sBAAqB;AACnC,cAAc,0BAAyB;AACvC,cAAc,4BAA2B;AACzC,cAAc,uBAAsB;AACpC,cAAc,4BAA2B;AACzC,cAAc,gCAA+B;AAC7C,cAAc,gCAA+B;AAC7C,cAAc,gCAA+B;AAC7C,cAAc,uBAAsB;AACpC,cAAc,uBAAsB;AACpC,cAAc,wBAAuB;AACrC,cAAc,gBAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/createExpiringConfig.ts"],"sourcesContent":["import type ConfigStore from 'configstore'\n\ninterface ExpiringConfigValue {\n updatedAt: number\n value: unknown\n}\n\nexport interface ExpiringConfigOptions<Type> {\n /** Fetch value */\n fetchValue: () => Promise<Type> | Type\n /** Config key */\n key: string\n /** Config store */\n store: ConfigStore\n /** TTL (milliseconds) */\n ttl: number\n\n /** Subscribe to cache hit event */\n onCacheHit?: () => void\n /** Subscribe to fetch event */\n onFetch?: () => void\n /** Subscribe to revalidate event */\n onRevalidate?: () => void\n\n /**\n * Assert the fetched value is valid, or throw if invalid.\n * If none is provided, it will always accept the fetched value.\n */\n validateValue?: (value: unknown) => value is Type\n}\n\nexport interface ExpiringConfigApi<Type> {\n /**\n * Delete the cached value.\n */\n delete: () => void\n /**\n * Attempt to get the cached value. If there is no cached value, or the cached value has expired,\n * fetch, cache, and return the value.\n */\n get: () => Promise<Type>\n}\n\n/**\n * Create a config in the provided config store that expires after the provided TTL.\n */\nexport function createExpiringConfig<Type>({\n fetchValue,\n key,\n onCacheHit = () => null,\n onFetch = () => null,\n onRevalidate = () => null,\n store,\n ttl,\n validateValue = (value: unknown): value is Type => true,\n}: ExpiringConfigOptions<Type>): ExpiringConfigApi<Type> {\n let currentFetch: Promise<Type> | null = null\n return {\n delete() {\n store.delete(key)\n },\n async get(): Promise<Type> {\n const stored = store.get(key)\n\n if (isExpiringValue(stored)) {\n const {updatedAt, value} = stored\n if (!validateValue(value)) {\n throw new Error('Stored value is invalid')\n }\n\n const hasExpired = Date.now() - updatedAt > ttl\n\n if (!hasExpired) {\n onCacheHit()\n return value\n }\n\n onRevalidate()\n }\n\n if (currentFetch) {\n return currentFetch\n }\n onFetch()\n\n currentFetch = Promise.resolve(fetchValue())\n const nextValue = await currentFetch\n if (!validateValue(nextValue)) {\n throw new Error('Fetched value is invalid')\n }\n\n currentFetch = null\n\n store.set(key, {\n updatedAt: Date.now(),\n value: nextValue,\n })\n\n return nextValue\n },\n }\n}\n\n/**\n * Checks if the given stored value is valid (does not check if expired, only verified shape)\n *\n * @param stored - The stored value to check\n * @returns True if the stored value is valid\n * @internal\n */\nfunction isExpiringValue(stored: unknown): stored is ExpiringConfigValue {\n if (typeof stored !== 'object' || stored === null || Array.isArray(stored)) {\n return false\n }\n\n if (!('updatedAt' in stored) || typeof stored.updatedAt !== 'number') {\n return false\n }\n\n if (!('value' in stored)) {\n return false\n }\n\n return true\n}\n"],"names":["createExpiringConfig","fetchValue","key","onCacheHit","onFetch","onRevalidate","store","ttl","validateValue","value","currentFetch","delete","get","stored","isExpiringValue","updatedAt","Error","hasExpired","Date","now","Promise","resolve","nextValue","set","Array","isArray"],"mappings":"AA2CA;;CAEC,GACD,OAAO,SAASA,qBAA2B,EACzCC,UAAU,EACVC,GAAG,EACHC,aAAa,IAAM,IAAI,EACvBC,UAAU,IAAM,IAAI,EACpBC,eAAe,IAAM,IAAI,EACzBC,KAAK,EACLC,GAAG,EACHC,gBAAgB,CAACC,QAAkC,IAAI,EAC3B;IAC5B,IAAIC,eAAqC;IACzC,OAAO;QACLC;YACEL,MAAMK,MAAM,CAACT;QACf;QACA,MAAMU;YACJ,MAAMC,SAASP,MAAMM,GAAG,CAACV;YAEzB,IAAIY,gBAAgBD,SAAS;gBAC3B,MAAM,EAACE,SAAS,EAAEN,KAAK,EAAC,GAAGI;gBAC3B,IAAI,CAACL,cAAcC,QAAQ;oBACzB,MAAM,IAAIO,MAAM;gBAClB;gBAEA,MAAMC,aAAaC,KAAKC,GAAG,KAAKJ,YAAYR;gBAE5C,IAAI,CAACU,YAAY;oBACfd;oBACA,OAAOM;gBACT;gBAEAJ;YACF;YAEA,IAAIK,cAAc;gBAChB,OAAOA;YACT;
|
|
1
|
+
{"version":3,"sources":["../../src/util/createExpiringConfig.ts"],"sourcesContent":["import type ConfigStore from 'configstore'\n\ninterface ExpiringConfigValue {\n updatedAt: number\n value: unknown\n}\n\nexport interface ExpiringConfigOptions<Type> {\n /** Fetch value */\n fetchValue: () => Promise<Type> | Type\n /** Config key */\n key: string\n /** Config store */\n store: ConfigStore\n /** TTL (milliseconds) */\n ttl: number\n\n /** Subscribe to cache hit event */\n onCacheHit?: () => void\n /** Subscribe to fetch event */\n onFetch?: () => void\n /** Subscribe to revalidate event */\n onRevalidate?: () => void\n\n /**\n * Assert the fetched value is valid, or throw if invalid.\n * If none is provided, it will always accept the fetched value.\n */\n validateValue?: (value: unknown) => value is Type\n}\n\nexport interface ExpiringConfigApi<Type> {\n /**\n * Delete the cached value.\n */\n delete: () => void\n /**\n * Attempt to get the cached value. If there is no cached value, or the cached value has expired,\n * fetch, cache, and return the value.\n */\n get: () => Promise<Type>\n}\n\n/**\n * Create a config in the provided config store that expires after the provided TTL.\n */\nexport function createExpiringConfig<Type>({\n fetchValue,\n key,\n onCacheHit = () => null,\n onFetch = () => null,\n onRevalidate = () => null,\n store,\n ttl,\n validateValue = (value: unknown): value is Type => true,\n}: ExpiringConfigOptions<Type>): ExpiringConfigApi<Type> {\n let currentFetch: Promise<Type> | null = null\n return {\n delete() {\n store.delete(key)\n },\n async get(): Promise<Type> {\n const stored = store.get(key)\n\n if (isExpiringValue(stored)) {\n const {updatedAt, value} = stored\n if (!validateValue(value)) {\n throw new Error('Stored value is invalid')\n }\n\n const hasExpired = Date.now() - updatedAt > ttl\n\n if (!hasExpired) {\n onCacheHit()\n return value\n }\n\n onRevalidate()\n }\n\n // Return existing fetch if one is already in progress\n if (currentFetch) {\n return currentFetch\n }\n\n onFetch()\n\n currentFetch = Promise.resolve(fetchValue())\n const nextValue = await currentFetch\n if (!validateValue(nextValue)) {\n throw new Error('Fetched value is invalid')\n }\n\n currentFetch = null\n\n store.set(key, {\n updatedAt: Date.now(),\n value: nextValue,\n })\n\n return nextValue\n },\n }\n}\n\n/**\n * Checks if the given stored value is valid (does not check if expired, only verified shape)\n *\n * @param stored - The stored value to check\n * @returns True if the stored value is valid\n * @internal\n */\nfunction isExpiringValue(stored: unknown): stored is ExpiringConfigValue {\n if (typeof stored !== 'object' || stored === null || Array.isArray(stored)) {\n return false\n }\n\n if (!('updatedAt' in stored) || typeof stored.updatedAt !== 'number') {\n return false\n }\n\n if (!('value' in stored)) {\n return false\n }\n\n return true\n}\n"],"names":["createExpiringConfig","fetchValue","key","onCacheHit","onFetch","onRevalidate","store","ttl","validateValue","value","currentFetch","delete","get","stored","isExpiringValue","updatedAt","Error","hasExpired","Date","now","Promise","resolve","nextValue","set","Array","isArray"],"mappings":"AA2CA;;CAEC,GACD,OAAO,SAASA,qBAA2B,EACzCC,UAAU,EACVC,GAAG,EACHC,aAAa,IAAM,IAAI,EACvBC,UAAU,IAAM,IAAI,EACpBC,eAAe,IAAM,IAAI,EACzBC,KAAK,EACLC,GAAG,EACHC,gBAAgB,CAACC,QAAkC,IAAI,EAC3B;IAC5B,IAAIC,eAAqC;IACzC,OAAO;QACLC;YACEL,MAAMK,MAAM,CAACT;QACf;QACA,MAAMU;YACJ,MAAMC,SAASP,MAAMM,GAAG,CAACV;YAEzB,IAAIY,gBAAgBD,SAAS;gBAC3B,MAAM,EAACE,SAAS,EAAEN,KAAK,EAAC,GAAGI;gBAC3B,IAAI,CAACL,cAAcC,QAAQ;oBACzB,MAAM,IAAIO,MAAM;gBAClB;gBAEA,MAAMC,aAAaC,KAAKC,GAAG,KAAKJ,YAAYR;gBAE5C,IAAI,CAACU,YAAY;oBACfd;oBACA,OAAOM;gBACT;gBAEAJ;YACF;YAEA,sDAAsD;YACtD,IAAIK,cAAc;gBAChB,OAAOA;YACT;YAEAN;YAEAM,eAAeU,QAAQC,OAAO,CAACpB;YAC/B,MAAMqB,YAAY,MAAMZ;YACxB,IAAI,CAACF,cAAcc,YAAY;gBAC7B,MAAM,IAAIN,MAAM;YAClB;YAEAN,eAAe;YAEfJ,MAAMiB,GAAG,CAACrB,KAAK;gBACba,WAAWG,KAAKC,GAAG;gBACnBV,OAAOa;YACT;YAEA,OAAOA;QACT;IACF;AACF;AAEA;;;;;;CAMC,GACD,SAASR,gBAAgBD,MAAe;IACtC,IAAI,OAAOA,WAAW,YAAYA,WAAW,QAAQW,MAAMC,OAAO,CAACZ,SAAS;QAC1E,OAAO;IACT;IAEA,IAAI,CAAE,CAAA,eAAeA,MAAK,KAAM,OAAOA,OAAOE,SAAS,KAAK,UAAU;QACpE,OAAO;IACT;IAEA,IAAI,CAAE,CAAA,WAAWF,MAAK,GAAI;QACxB,OAAO;IACT;IAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Comprehensive package.json schema including all common properties.
|
|
5
|
+
* Feel free to add properties to this,
|
|
6
|
+
* đ âšī¸ BUT ENSURE OPTIONAL STUFF IS ACTUALLY OPTIONAL âšī¸đ
|
|
7
|
+
* đ âšī¸ SINCE THIS IS USED IN A NUMBER OF LOCATIONS WHERE âšī¸đ
|
|
8
|
+
* đ âšī¸ WE CANNOT ENFORCE/GUARANTEE ANY PARTICULAR PROPS âšī¸đ
|
|
9
|
+
*/ const packageJsonSchema = z.looseObject({
|
|
10
|
+
// Required fields
|
|
11
|
+
name: z.string(),
|
|
12
|
+
version: z.string(),
|
|
13
|
+
// Dependencies (optional)
|
|
14
|
+
dependencies: z.record(z.string(), z.string()).optional(),
|
|
15
|
+
devDependencies: z.record(z.string(), z.string()).optional(),
|
|
16
|
+
peerDependencies: z.record(z.string(), z.string()).optional(),
|
|
17
|
+
// Module structure (optional)
|
|
18
|
+
exports: z.record(z.string(), z.any()).optional(),
|
|
19
|
+
main: z.string().optional(),
|
|
20
|
+
types: z.string().optional(),
|
|
21
|
+
// Metadata (optional)
|
|
22
|
+
author: z.string().optional(),
|
|
23
|
+
description: z.string().optional(),
|
|
24
|
+
engines: z.record(z.string(), z.string()).optional(),
|
|
25
|
+
license: z.string().optional(),
|
|
26
|
+
private: z.boolean().optional(),
|
|
27
|
+
repository: z.object({
|
|
28
|
+
type: z.string(),
|
|
29
|
+
url: z.string()
|
|
30
|
+
}).optional(),
|
|
31
|
+
scripts: z.record(z.string(), z.string()).optional()
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Read the `package.json` file at the given path
|
|
35
|
+
*
|
|
36
|
+
* @param filePath - Path to package.json to read
|
|
37
|
+
* @param options - Options object for controlling read behavior
|
|
38
|
+
* @returns The parsed package.json
|
|
39
|
+
* @public
|
|
40
|
+
*/ export async function readPackageJson(filePath, options = {}) {
|
|
41
|
+
const { defaults = {}, skipSchemaValidation = false } = options;
|
|
42
|
+
// Read and parse the file
|
|
43
|
+
let pkg;
|
|
44
|
+
try {
|
|
45
|
+
pkg = JSON.parse(await readFile(filePath, 'utf8'));
|
|
46
|
+
} catch (err) {
|
|
47
|
+
throw new Error(`Failed to read "${filePath}"`, {
|
|
48
|
+
cause: err
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// Merge with defaults (parsed values take precedence)
|
|
52
|
+
const merged = {
|
|
53
|
+
...defaults,
|
|
54
|
+
...pkg
|
|
55
|
+
};
|
|
56
|
+
// Validate with schema unless skipped
|
|
57
|
+
let validated;
|
|
58
|
+
if (skipSchemaValidation) {
|
|
59
|
+
validated = merged;
|
|
60
|
+
} else {
|
|
61
|
+
const { data, error, success } = packageJsonSchema.safeParse(merged);
|
|
62
|
+
if (!success) {
|
|
63
|
+
throw new Error(`Invalid package.json at "${filePath}": ${error.issues.map((err)=>err.message).join('\n')}`);
|
|
64
|
+
}
|
|
65
|
+
validated = data;
|
|
66
|
+
}
|
|
67
|
+
return validated;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=readPackageJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/util/readPackageJson.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\n\nimport {z} from 'zod'\n\n/**\n * Comprehensive package.json schema including all common properties.\n * Feel free to add properties to this,\n * đ âšī¸ BUT ENSURE OPTIONAL STUFF IS ACTUALLY OPTIONAL âšī¸đ \n * đ âšī¸ SINCE THIS IS USED IN A NUMBER OF LOCATIONS WHERE âšī¸đ \n * đ âšī¸ WE CANNOT ENFORCE/GUARANTEE ANY PARTICULAR PROPS âšī¸đ \n */\nconst packageJsonSchema = z.looseObject({\n // Required fields\n name: z.string(),\n version: z.string(),\n\n // Dependencies (optional)\n dependencies: z.record(z.string(), z.string()).optional(),\n devDependencies: z.record(z.string(), z.string()).optional(),\n peerDependencies: z.record(z.string(), z.string()).optional(),\n\n // Module structure (optional)\n exports: z.record(z.string(), z.any()).optional(),\n main: z.string().optional(),\n types: z.string().optional(),\n\n // Metadata (optional)\n author: z.string().optional(),\n description: z.string().optional(),\n engines: z.record(z.string(), z.string()).optional(),\n license: z.string().optional(),\n private: z.boolean().optional(),\n repository: z\n .object({\n type: z.string(),\n url: z.string(),\n })\n .optional(),\n scripts: z.record(z.string(), z.string()).optional(),\n})\n\n/**\n * Comprehensive representation of a package.json file.\n * Consolidates all properties from previous type definitions.\n *\n * @public\n */\nexport type PackageJson = z.infer<typeof packageJsonSchema>\n\n/**\n * Options for reading package.json files\n *\n * @public\n */\nexport interface ReadPackageJsonOptions {\n /**\n * Default values to merge with the parsed package.json.\n * Parsed values take precedence over defaults.\n */\n defaults?: Partial<PackageJson>\n\n /**\n * Skip Zod schema validation. When true, the file is parsed but not validated.\n * Defaults to false.\n */\n skipSchemaValidation?: boolean\n}\n\n/**\n * Read the `package.json` file at the given path\n *\n * @param filePath - Path to package.json to read\n * @param options - Options object for controlling read behavior\n * @returns The parsed package.json\n * @public\n */\nexport async function readPackageJson(\n filePath: string | URL,\n options: ReadPackageJsonOptions = {},\n): Promise<PackageJson> {\n const {defaults = {}, skipSchemaValidation = false} = options\n\n // Read and parse the file\n let pkg: Record<string, unknown>\n try {\n pkg = JSON.parse(await readFile(filePath, 'utf8'))\n } catch (err: unknown) {\n throw new Error(`Failed to read \"${filePath}\"`, {cause: err})\n }\n\n // Merge with defaults (parsed values take precedence)\n const merged = {...defaults, ...pkg}\n\n // Validate with schema unless skipped\n let validated: PackageJson\n if (skipSchemaValidation) {\n validated = merged as PackageJson\n } else {\n const {data, error, success} = packageJsonSchema.safeParse(merged)\n if (!success) {\n throw new Error(\n `Invalid package.json at \"${filePath}\": ${error.issues.map((err) => err.message).join('\\n')}`,\n )\n }\n validated = data\n }\n\n return validated\n}\n"],"names":["readFile","z","packageJsonSchema","looseObject","name","string","version","dependencies","record","optional","devDependencies","peerDependencies","exports","any","main","types","author","description","engines","license","private","boolean","repository","object","type","url","scripts","readPackageJson","filePath","options","defaults","skipSchemaValidation","pkg","JSON","parse","err","Error","cause","merged","validated","data","error","success","safeParse","issues","map","message","join"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AAEzC,SAAQC,CAAC,QAAO,MAAK;AAErB;;;;;;CAMC,GACD,MAAMC,oBAAoBD,EAAEE,WAAW,CAAC;IACtC,kBAAkB;IAClBC,MAAMH,EAAEI,MAAM;IACdC,SAASL,EAAEI,MAAM;IAEjB,0BAA0B;IAC1BE,cAAcN,EAAEO,MAAM,CAACP,EAAEI,MAAM,IAAIJ,EAAEI,MAAM,IAAII,QAAQ;IACvDC,iBAAiBT,EAAEO,MAAM,CAACP,EAAEI,MAAM,IAAIJ,EAAEI,MAAM,IAAII,QAAQ;IAC1DE,kBAAkBV,EAAEO,MAAM,CAACP,EAAEI,MAAM,IAAIJ,EAAEI,MAAM,IAAII,QAAQ;IAE3D,8BAA8B;IAC9BG,SAASX,EAAEO,MAAM,CAACP,EAAEI,MAAM,IAAIJ,EAAEY,GAAG,IAAIJ,QAAQ;IAC/CK,MAAMb,EAAEI,MAAM,GAAGI,QAAQ;IACzBM,OAAOd,EAAEI,MAAM,GAAGI,QAAQ;IAE1B,sBAAsB;IACtBO,QAAQf,EAAEI,MAAM,GAAGI,QAAQ;IAC3BQ,aAAahB,EAAEI,MAAM,GAAGI,QAAQ;IAChCS,SAASjB,EAAEO,MAAM,CAACP,EAAEI,MAAM,IAAIJ,EAAEI,MAAM,IAAII,QAAQ;IAClDU,SAASlB,EAAEI,MAAM,GAAGI,QAAQ;IAC5BW,SAASnB,EAAEoB,OAAO,GAAGZ,QAAQ;IAC7Ba,YAAYrB,EACTsB,MAAM,CAAC;QACNC,MAAMvB,EAAEI,MAAM;QACdoB,KAAKxB,EAAEI,MAAM;IACf,GACCI,QAAQ;IACXiB,SAASzB,EAAEO,MAAM,CAACP,EAAEI,MAAM,IAAIJ,EAAEI,MAAM,IAAII,QAAQ;AACpD;AA6BA;;;;;;;CAOC,GACD,OAAO,eAAekB,gBACpBC,QAAsB,EACtBC,UAAkC,CAAC,CAAC;IAEpC,MAAM,EAACC,WAAW,CAAC,CAAC,EAAEC,uBAAuB,KAAK,EAAC,GAAGF;IAEtD,0BAA0B;IAC1B,IAAIG;IACJ,IAAI;QACFA,MAAMC,KAAKC,KAAK,CAAC,MAAMlC,SAAS4B,UAAU;IAC5C,EAAE,OAAOO,KAAc;QACrB,MAAM,IAAIC,MAAM,CAAC,gBAAgB,EAAER,SAAS,CAAC,CAAC,EAAE;YAACS,OAAOF;QAAG;IAC7D;IAEA,sDAAsD;IACtD,MAAMG,SAAS;QAAC,GAAGR,QAAQ;QAAE,GAAGE,GAAG;IAAA;IAEnC,sCAAsC;IACtC,IAAIO;IACJ,IAAIR,sBAAsB;QACxBQ,YAAYD;IACd,OAAO;QACL,MAAM,EAACE,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAGxC,kBAAkByC,SAAS,CAACL;QAC3D,IAAI,CAACI,SAAS;YACZ,MAAM,IAAIN,MACR,CAAC,yBAAyB,EAAER,SAAS,GAAG,EAAEa,MAAMG,MAAM,CAACC,GAAG,CAAC,CAACV,MAAQA,IAAIW,OAAO,EAAEC,IAAI,CAAC,OAAO;QAEjG;QACAR,YAAYC;IACd;IAEA,OAAOD;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli-core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.13",
|
|
4
4
|
"description": "Sanity CLI core package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -46,14 +46,13 @@
|
|
|
46
46
|
"@inquirer/prompts": "^8.2.0",
|
|
47
47
|
"@oclif/core": "^4.8.0",
|
|
48
48
|
"@sanity/client": "^7.14.1",
|
|
49
|
-
"@sanity/types": "^5.
|
|
49
|
+
"@sanity/types": "^5.9.0",
|
|
50
50
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
51
51
|
"boxen": "^8.0.1",
|
|
52
|
-
"chalk": "^5.6.2",
|
|
53
52
|
"configstore": "^7.0.0",
|
|
54
53
|
"debug": "^4.4.3",
|
|
55
|
-
"get-tsconfig": "^4.13.
|
|
56
|
-
"import-meta-resolve": "^4.
|
|
54
|
+
"get-tsconfig": "^4.13.6",
|
|
55
|
+
"import-meta-resolve": "^4.2.0",
|
|
57
56
|
"jsdom": "^27.4.0",
|
|
58
57
|
"json-lexer": "^1.2.0",
|
|
59
58
|
"log-symbols": "^7.0.1",
|
|
@@ -67,17 +66,17 @@
|
|
|
67
66
|
},
|
|
68
67
|
"devDependencies": {
|
|
69
68
|
"@eslint/compat": "^2.0.2",
|
|
70
|
-
"@sanity/codegen": "^5.9.
|
|
69
|
+
"@sanity/codegen": "^5.9.3",
|
|
71
70
|
"@sanity/pkg-utils": "^10.4.4",
|
|
72
71
|
"@sanity/telemetry": "^0.8.1",
|
|
73
|
-
"@swc/cli": "^0.
|
|
72
|
+
"@swc/cli": "^0.8.0",
|
|
74
73
|
"@swc/core": "^1.15.11",
|
|
75
74
|
"@types/debug": "^4.1.12",
|
|
76
75
|
"@types/jsdom": "^27.0.0",
|
|
77
|
-
"@types/node": "^20.19.
|
|
76
|
+
"@types/node": "^20.19.33",
|
|
78
77
|
"eslint": "^9.39.2",
|
|
79
78
|
"publint": "^0.3.17",
|
|
80
|
-
"sanity": "^5.
|
|
79
|
+
"sanity": "^5.9.0",
|
|
81
80
|
"typescript": "^5.9.3",
|
|
82
81
|
"vitest": "^4.0.18",
|
|
83
82
|
"@repo/package.config": "0.0.1",
|
package/dist/ux/chalk.js
DELETED
package/dist/ux/chalk.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ux/chalk.ts"],"sourcesContent":["/* eslint-disable no-restricted-imports */\nexport {default as chalk} from 'chalk'\nexport * from 'chalk'\n"],"names":["default","chalk"],"mappings":"AAAA,wCAAwC,GACxC,SAAQA,WAAWC,KAAK,QAAO,QAAO;AACtC,cAAc,QAAO"}
|