@sanity/cli-core 0.0.2-alpha.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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/SanityCommand.d.ts +56 -0
- package/dist/SanityCommand.js +72 -0
- package/dist/SanityCommand.js.map +1 -0
- package/dist/config/__tests__/cliToken.test.js +74 -0
- package/dist/config/__tests__/cliToken.test.js.map +1 -0
- package/dist/config/__tests__/cliUserConfig.test.js +131 -0
- package/dist/config/__tests__/cliUserConfig.test.js.map +1 -0
- package/dist/config/__tests__/findProjectRoot.test.js +159 -0
- package/dist/config/__tests__/findProjectRoot.test.js.map +1 -0
- package/dist/config/cli/getCliConfig.d.ts +16 -0
- package/dist/config/cli/getCliConfig.js +67 -0
- package/dist/config/cli/getCliConfig.js.map +1 -0
- package/dist/config/cli/getCliConfig.worker.d.ts +1 -0
- package/dist/config/cli/getCliConfig.worker.js +14 -0
- package/dist/config/cli/getCliConfig.worker.js.map +1 -0
- package/dist/config/cli/schemas.d.ts +204 -0
- package/dist/config/cli/schemas.js +77 -0
- package/dist/config/cli/schemas.js.map +1 -0
- package/dist/config/cli/types.d.ts +13 -0
- package/dist/config/cli/types.js +3 -0
- package/dist/config/cli/types.js.map +1 -0
- package/dist/config/findProjectRoot.d.ts +14 -0
- package/dist/config/findProjectRoot.js +56 -0
- package/dist/config/findProjectRoot.js.map +1 -0
- package/dist/config/studio/getStudioConfig.d.ts +14 -0
- package/dist/config/studio/getStudioConfig.js +16 -0
- package/dist/config/studio/getStudioConfig.js.map +1 -0
- package/dist/config/studio/readStudioConfig.d.ts +190 -0
- package/dist/config/studio/readStudioConfig.js +45 -0
- package/dist/config/studio/readStudioConfig.js.map +1 -0
- package/dist/config/studio/readStudioConfig.worker.d.ts +1 -0
- package/dist/config/studio/readStudioConfig.worker.js +64 -0
- package/dist/config/studio/readStudioConfig.worker.js.map +1 -0
- package/dist/config/util/findAppConfigPath.d.ts +8 -0
- package/dist/config/util/findAppConfigPath.js +22 -0
- package/dist/config/util/findAppConfigPath.js.map +1 -0
- package/dist/config/util/findConfigsPaths.d.ts +16 -0
- package/dist/config/util/findConfigsPaths.js +21 -0
- package/dist/config/util/findConfigsPaths.js.map +1 -0
- package/dist/config/util/findStudioConfigPath.d.ts +9 -0
- package/dist/config/util/findStudioConfigPath.js +31 -0
- package/dist/config/util/findStudioConfigPath.js.map +1 -0
- package/dist/config/util/isSanityV2StudioRoot.d.ts +8 -0
- package/dist/config/util/isSanityV2StudioRoot.js +19 -0
- package/dist/config/util/isSanityV2StudioRoot.js.map +1 -0
- package/dist/config/util/recursivelyResolveProjectRoot.d.ts +27 -0
- package/dist/config/util/recursivelyResolveProjectRoot.js +28 -0
- package/dist/config/util/recursivelyResolveProjectRoot.js.map +1 -0
- package/dist/debug.d.ts +15 -0
- package/dist/debug.js +15 -0
- package/dist/debug.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/loaders/studio/stubs.d.ts +254 -0
- package/dist/loaders/studio/stubs.js +257 -0
- package/dist/loaders/studio/stubs.js.map +1 -0
- package/dist/loaders/studio/studioWorkerLoader.worker.d.ts +1 -0
- package/dist/loaders/studio/studioWorkerLoader.worker.js +117 -0
- package/dist/loaders/studio/studioWorkerLoader.worker.js.map +1 -0
- package/dist/loaders/studio/studioWorkerTask.d.ts +40 -0
- package/dist/loaders/studio/studioWorkerTask.js +69 -0
- package/dist/loaders/studio/studioWorkerTask.js.map +1 -0
- package/dist/loaders/tsx/tsxWorkerLoader.worker.d.ts +1 -0
- package/dist/loaders/tsx/tsxWorkerLoader.worker.js +12 -0
- package/dist/loaders/tsx/tsxWorkerLoader.worker.js.map +1 -0
- package/dist/loaders/tsx/tsxWorkerTask.d.ts +28 -0
- package/dist/loaders/tsx/tsxWorkerTask.js +61 -0
- package/dist/loaders/tsx/tsxWorkerTask.js.map +1 -0
- package/dist/services/apiClient.d.ts +39 -0
- package/dist/services/apiClient.js +88 -0
- package/dist/services/apiClient.js.map +1 -0
- package/dist/services/cliUserConfig.d.ts +57 -0
- package/dist/services/cliUserConfig.js +103 -0
- package/dist/services/cliUserConfig.js.map +1 -0
- package/dist/services/getCliToken.d.ts +7 -0
- package/dist/services/getCliToken.js +21 -0
- package/dist/services/getCliToken.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/util/NotFoundError.d.ts +20 -0
- package/dist/util/NotFoundError.js +27 -0
- package/dist/util/NotFoundError.js.map +1 -0
- package/dist/util/__tests__/createExpiringConfig.test.js +309 -0
- package/dist/util/__tests__/createExpiringConfig.test.js.map +1 -0
- package/dist/util/createExpiringConfig.d.ts +32 -0
- package/dist/util/createExpiringConfig.js +35 -0
- package/dist/util/createExpiringConfig.js.map +1 -0
- package/dist/util/fileExists.d.ts +9 -0
- package/dist/util/fileExists.js +13 -0
- package/dist/util/fileExists.js.map +1 -0
- package/dist/util/generateHelpUrl.d.ts +8 -0
- package/dist/util/generateHelpUrl.js +11 -0
- package/dist/util/generateHelpUrl.js.map +1 -0
- package/dist/util/getSanityEnvVar.d.ts +19 -0
- package/dist/util/getSanityEnvVar.js +24 -0
- package/dist/util/getSanityEnvVar.js.map +1 -0
- package/dist/util/getSanityUrl.d.ts +5 -0
- package/dist/util/getSanityUrl.js +8 -0
- package/dist/util/getSanityUrl.js.map +1 -0
- package/dist/util/getUserConfig.d.ts +2 -0
- package/dist/util/getUserConfig.js +15 -0
- package/dist/util/getUserConfig.js.map +1 -0
- package/dist/util/isCi.d.ts +1 -0
- package/dist/util/isCi.js +7 -0
- package/dist/util/isCi.js.map +1 -0
- package/dist/util/isHttpError.d.ts +29 -0
- package/dist/util/isHttpError.js +18 -0
- package/dist/util/isHttpError.js.map +1 -0
- package/dist/util/isInteractive.d.ts +1 -0
- package/dist/util/isInteractive.js +5 -0
- package/dist/util/isInteractive.js.map +1 -0
- package/dist/util/isRecord.d.ts +8 -0
- package/dist/util/isRecord.js +11 -0
- package/dist/util/isRecord.js.map +1 -0
- package/dist/util/isTrueish.d.ts +1 -0
- package/dist/util/isTrueish.js +10 -0
- package/dist/util/isTrueish.js.map +1 -0
- package/dist/util/readJsonFile.d.ts +8 -0
- package/dist/util/readJsonFile.js +26 -0
- package/dist/util/readJsonFile.js.map +1 -0
- package/dist/util/safeStructuredClone.d.ts +8 -0
- package/dist/util/safeStructuredClone.js +40 -0
- package/dist/util/safeStructuredClone.js.map +1 -0
- package/dist/util/writeJsonFile.d.ts +9 -0
- package/dist/util/writeJsonFile.js +19 -0
- package/dist/util/writeJsonFile.js.map +1 -0
- package/dist/ux/colorizeJson.d.ts +1 -0
- package/dist/ux/colorizeJson.js +32 -0
- package/dist/ux/colorizeJson.js.map +1 -0
- package/dist/ux/formatObject.d.ts +1 -0
- package/dist/ux/formatObject.js +9 -0
- package/dist/ux/formatObject.js.map +1 -0
- package/dist/ux/logSymbols.d.ts +1 -0
- package/dist/ux/logSymbols.js +3 -0
- package/dist/ux/logSymbols.js.map +1 -0
- package/dist/ux/printKeyValue.d.ts +1 -0
- package/dist/ux/printKeyValue.js +16 -0
- package/dist/ux/printKeyValue.js.map +1 -0
- package/dist/ux/spinner.d.ts +1 -0
- package/dist/ux/spinner.js +3 -0
- package/dist/ux/spinner.js.map +1 -0
- package/dist/ux/timer.d.ts +12 -0
- package/dist/ux/timer.js +29 -0
- package/dist/ux/timer.js.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { getTsconfig } from 'get-tsconfig';
|
|
2
|
+
import { register } from 'tsx/esm/api';
|
|
3
|
+
import { debug } from '../../debug.js';
|
|
4
|
+
import { tsxWorkerTask } from '../../loaders/tsx/tsxWorkerTask.js';
|
|
5
|
+
import { isRecord } from '../../util/isRecord.js';
|
|
6
|
+
import { NotFoundError } from '../../util/NotFoundError.js';
|
|
7
|
+
import { findPathForFiles } from '../util/findConfigsPaths.js';
|
|
8
|
+
import { cliConfigSchema } from './schemas.js';
|
|
9
|
+
/**
|
|
10
|
+
* Get the CLI config for a project, given the root path.
|
|
11
|
+
*
|
|
12
|
+
* We really want to avoid loading the CLI config in the main thread, as we'll need
|
|
13
|
+
* TypeScript loading logic, potentially with ts path aliases, syntax extensions and all
|
|
14
|
+
* sorts of nonsense. Thus, we _attempt_ to use a worker thread - but have to fall back
|
|
15
|
+
* to using the main thread if not possible. This can be the case if the configuration
|
|
16
|
+
* contains non-serializable properties, such as functions. This is unfortunately used
|
|
17
|
+
* by the vite config, for example.
|
|
18
|
+
*
|
|
19
|
+
* @param rootPath - Root path for the project, eg where `sanity.cli.(ts|js)` is located.
|
|
20
|
+
* @returns The CLI config
|
|
21
|
+
* @internal
|
|
22
|
+
*/ export async function getCliConfig(rootPath) {
|
|
23
|
+
const paths = await findPathForFiles(rootPath, [
|
|
24
|
+
'sanity.cli.ts',
|
|
25
|
+
'sanity.cli.js'
|
|
26
|
+
]);
|
|
27
|
+
const configPaths = paths.filter((path)=>path.exists);
|
|
28
|
+
if (configPaths.length === 0) {
|
|
29
|
+
throw new NotFoundError(`No CLI config found at ${rootPath}/sanity.cli.(ts|js)`);
|
|
30
|
+
}
|
|
31
|
+
if (configPaths.length > 1) {
|
|
32
|
+
throw new Error(`Multiple CLI config files found (${configPaths.map((path)=>path.path).join(', ')})`);
|
|
33
|
+
}
|
|
34
|
+
const configPath = configPaths[0].path;
|
|
35
|
+
let cliConfig;
|
|
36
|
+
try {
|
|
37
|
+
cliConfig = await tsxWorkerTask(new URL('getCliConfig.worker.js', import.meta.url), {
|
|
38
|
+
name: 'cliConfig',
|
|
39
|
+
rootPath,
|
|
40
|
+
workerData: {
|
|
41
|
+
configPath
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
} catch (err) {
|
|
45
|
+
debug('Failed to load CLI config in worker thread: %s', err);
|
|
46
|
+
// Assuming that didn't work because of unseriazable properties, so we'll try the
|
|
47
|
+
// main thread with tsx registered.
|
|
48
|
+
const tsconfig = getTsconfig(rootPath);
|
|
49
|
+
const tsx = register({
|
|
50
|
+
namespace: 'get-cli-config',
|
|
51
|
+
tsconfig: tsconfig?.path ?? undefined
|
|
52
|
+
});
|
|
53
|
+
// Ensure we get the default export (sometimes we get a bit of a mixed bag)
|
|
54
|
+
cliConfig = await tsx.import(configPath, import.meta.url);
|
|
55
|
+
cliConfig = isRecord(cliConfig) && 'default' in cliConfig ? cliConfig.default : cliConfig;
|
|
56
|
+
tsx.unregister();
|
|
57
|
+
}
|
|
58
|
+
const { data, error, success } = cliConfigSchema.safeParse(cliConfig);
|
|
59
|
+
if (!success) {
|
|
60
|
+
throw new Error(`Invalid CLI config: ${error.message}`);
|
|
61
|
+
}
|
|
62
|
+
// There is a minor difference here because of the `vite` property and how the types
|
|
63
|
+
// aren't as specific as our manually typed `CliConfig` type, thus the cast.
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=getCliConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/config/cli/getCliConfig.ts"],"sourcesContent":["import {getTsconfig} from 'get-tsconfig'\nimport {register} from 'tsx/esm/api'\n\nimport {debug} from '../../debug.js'\nimport {tsxWorkerTask} from '../../loaders/tsx/tsxWorkerTask.js'\nimport {isRecord} from '../../util/isRecord.js'\nimport {NotFoundError} from '../../util/NotFoundError.js'\nimport {findPathForFiles} from '../util/findConfigsPaths.js'\nimport {cliConfigSchema} from './schemas.js'\nimport {type CliConfig} from './types.js'\n\n/**\n * Get the CLI config for a project, given the root path.\n *\n * We really want to avoid loading the CLI config in the main thread, as we'll need\n * TypeScript loading logic, potentially with ts path aliases, syntax extensions and all\n * sorts of nonsense. Thus, we _attempt_ to use a worker thread - but have to fall back\n * to using the main thread if not possible. This can be the case if the configuration\n * contains non-serializable properties, such as functions. This is unfortunately used\n * by the vite config, for example.\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 async function getCliConfig(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 let cliConfig: CliConfig | undefined\n try {\n cliConfig = await tsxWorkerTask<CliConfig | undefined>(\n new URL('getCliConfig.worker.js', import.meta.url),\n {\n name: 'cliConfig',\n rootPath,\n workerData: {configPath},\n },\n )\n } catch (err) {\n debug('Failed to load CLI config in worker thread: %s', err)\n\n // Assuming that didn't work because of unseriazable properties, so we'll try the\n // main thread with tsx registered.\n const tsconfig = getTsconfig(rootPath)\n const tsx = register({\n namespace: 'get-cli-config',\n tsconfig: tsconfig?.path ?? undefined,\n })\n\n // Ensure we get the default export (sometimes we get a bit of a mixed bag)\n cliConfig = await tsx.import(configPath, import.meta.url)\n cliConfig = (isRecord(cliConfig) && 'default' in cliConfig ? cliConfig.default : cliConfig) as\n | CliConfig\n | undefined\n\n tsx.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":["getTsconfig","register","debug","tsxWorkerTask","isRecord","NotFoundError","findPathForFiles","cliConfigSchema","getCliConfig","rootPath","paths","configPaths","filter","path","exists","length","Error","map","join","configPath","cliConfig","URL","url","name","workerData","err","tsconfig","tsx","namespace","undefined","import","default","unregister","data","error","success","safeParse","message"],"mappings":"AAAA,SAAQA,WAAW,QAAO,eAAc;AACxC,SAAQC,QAAQ,QAAO,cAAa;AAEpC,SAAQC,KAAK,QAAO,iBAAgB;AACpC,SAAQC,aAAa,QAAO,qCAAoC;AAChE,SAAQC,QAAQ,QAAO,yBAAwB;AAC/C,SAAQC,aAAa,QAAO,8BAA6B;AACzD,SAAQC,gBAAgB,QAAO,8BAA6B;AAC5D,SAAQC,eAAe,QAAO,eAAc;AAG5C;;;;;;;;;;;;;CAaC,GACD,OAAO,eAAeC,aAAaC,QAAgB;IACjD,MAAMC,QAAQ,MAAMJ,iBAAiBG,UAAU;QAAC;QAAiB;KAAgB;IACjF,MAAME,cAAcD,MAAME,MAAM,CAAC,CAACC,OAASA,KAAKC,MAAM;IAEtD,IAAIH,YAAYI,MAAM,KAAK,GAAG;QAC5B,MAAM,IAAIV,cAAc,CAAC,uBAAuB,EAAEI,SAAS,mBAAmB,CAAC;IACjF;IAEA,IAAIE,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;IAEtC,IAAIO;IACJ,IAAI;QACFA,YAAY,MAAMjB,cAChB,IAAIkB,IAAI,0BAA0B,YAAYC,GAAG,GACjD;YACEC,MAAM;YACNd;YACAe,YAAY;gBAACL;YAAU;QACzB;IAEJ,EAAE,OAAOM,KAAK;QACZvB,MAAM,kDAAkDuB;QAExD,iFAAiF;QACjF,mCAAmC;QACnC,MAAMC,WAAW1B,YAAYS;QAC7B,MAAMkB,MAAM1B,SAAS;YACnB2B,WAAW;YACXF,UAAUA,UAAUb,QAAQgB;QAC9B;QAEA,2EAA2E;QAC3ET,YAAY,MAAMO,IAAIG,MAAM,CAACX,YAAY,YAAYG,GAAG;QACxDF,YAAahB,SAASgB,cAAc,aAAaA,YAAYA,UAAUW,OAAO,GAAGX;QAIjFO,IAAIK,UAAU;IAChB;IAEA,MAAM,EAACC,IAAI,EAAEC,KAAK,EAAEC,OAAO,EAAC,GAAG5B,gBAAgB6B,SAAS,CAAChB;IACzD,IAAI,CAACe,SAAS;QACZ,MAAM,IAAInB,MAAM,CAAC,oBAAoB,EAAEkB,MAAMG,OAAO,EAAE;IACxD;IAEA,oFAAoF;IACpF,4EAA4E;IAC5E,OAAOJ;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isMainThread, parentPort, workerData } from 'node:worker_threads';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
if (isMainThread || !parentPort) {
|
|
4
|
+
throw new Error('Should only be run in a worker!');
|
|
5
|
+
}
|
|
6
|
+
const { configPath } = z.object({
|
|
7
|
+
configPath: z.string()
|
|
8
|
+
}).parse(workerData);
|
|
9
|
+
const { default: loadedConfig } = await import(configPath);
|
|
10
|
+
// This might throw on unserializable properties, but that's actually wanted in this
|
|
11
|
+
// case, since we _need_ any unserializable props (such as vite config functions)
|
|
12
|
+
parentPort.postMessage(loadedConfig);
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=getCliConfig.worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/config/cli/getCliConfig.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {z} from 'zod'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst {configPath} = z.object({configPath: z.string()}).parse(workerData)\n\nconst {default: loadedConfig} = await import(configPath)\n\n// This might throw on unserializable properties, but that's actually wanted in this\n// case, since we _need_ any unserializable props (such as vite config functions)\nparentPort.postMessage(loadedConfig)\n"],"names":["isMainThread","parentPort","workerData","z","Error","configPath","object","string","parse","default","loadedConfig","postMessage"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,CAAC,QAAO,MAAK;AAErB,IAAIH,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIG,MAAM;AAClB;AAEA,MAAM,EAACC,UAAU,EAAC,GAAGF,EAAEG,MAAM,CAAC;IAACD,YAAYF,EAAEI,MAAM;AAAE,GAAGC,KAAK,CAACN;AAE9D,MAAM,EAACO,SAASC,YAAY,EAAC,GAAG,MAAM,MAAM,CAACL;AAE7C,oFAAoF;AACpF,iFAAiF;AACjFJ,WAAWU,WAAW,CAACD"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const reactCompilerSchema: z.ZodOptional<z.ZodObject<{
|
|
3
|
+
compilationMode: z.ZodOptional<z.ZodEnum<["all", "annotation", "infer", "syntax"]>>;
|
|
4
|
+
panicThreshold: z.ZodOptional<z.ZodEnum<["ALL_ERRORS", "CRITICAL_ERRORS", "NONE"]>>;
|
|
5
|
+
/**
|
|
6
|
+
* @see https://react.dev/learn/react-compiler#existing-projects
|
|
7
|
+
*/
|
|
8
|
+
sources: z.ZodOptional<z.ZodUnion<[z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodBoolean>, z.ZodArray<z.ZodString, "many">, z.ZodNull]>>;
|
|
9
|
+
/**
|
|
10
|
+
* The minimum major version of React that the compiler should emit code for. If the target is 19
|
|
11
|
+
* or higher, the compiler emits direct imports of React runtime APIs needed by the compiler. On
|
|
12
|
+
* versions prior to 19, an extra runtime package react-compiler-runtime is necessary to provide
|
|
13
|
+
* a userspace approximation of runtime APIs.
|
|
14
|
+
* @see https://react.dev/learn/react-compiler#using-react-compiler-with-react-17-or-18
|
|
15
|
+
*/
|
|
16
|
+
target: z.ZodEnum<["18", "19"]>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
target: "18" | "19";
|
|
19
|
+
compilationMode?: "all" | "annotation" | "infer" | "syntax" | undefined;
|
|
20
|
+
panicThreshold?: "ALL_ERRORS" | "CRITICAL_ERRORS" | "NONE" | undefined;
|
|
21
|
+
sources?: string[] | ((args_0: string, ...args: unknown[]) => boolean) | null | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
target: "18" | "19";
|
|
24
|
+
compilationMode?: "all" | "annotation" | "infer" | "syntax" | undefined;
|
|
25
|
+
panicThreshold?: "ALL_ERRORS" | "CRITICAL_ERRORS" | "NONE" | undefined;
|
|
26
|
+
sources?: string[] | ((args_0: string, ...args: unknown[]) => boolean) | null | undefined;
|
|
27
|
+
}>>;
|
|
28
|
+
export declare const cliConfigSchema: z.ZodObject<{
|
|
29
|
+
/**
|
|
30
|
+
* API configuration
|
|
31
|
+
*/
|
|
32
|
+
api: z.ZodOptional<z.ZodObject<{
|
|
33
|
+
dataset: z.ZodOptional<z.ZodString>;
|
|
34
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
dataset?: string | undefined;
|
|
37
|
+
projectId?: string | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
dataset?: string | undefined;
|
|
40
|
+
projectId?: string | undefined;
|
|
41
|
+
}>>;
|
|
42
|
+
app: z.ZodOptional<z.ZodObject<{
|
|
43
|
+
entry: z.ZodOptional<z.ZodString>;
|
|
44
|
+
id: z.ZodOptional<z.ZodString>;
|
|
45
|
+
organizationId: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
entry?: string | undefined;
|
|
48
|
+
id?: string | undefined;
|
|
49
|
+
organizationId?: string | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
entry?: string | undefined;
|
|
52
|
+
id?: string | undefined;
|
|
53
|
+
organizationId?: string | undefined;
|
|
54
|
+
}>>;
|
|
55
|
+
autoUpdates: z.ZodOptional<z.ZodBoolean>;
|
|
56
|
+
graphql: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
57
|
+
filterSuffix: z.ZodOptional<z.ZodString>;
|
|
58
|
+
generation: z.ZodOptional<z.ZodEnum<["gen1", "gen2", "gen3"]>>;
|
|
59
|
+
id: z.ZodOptional<z.ZodString>;
|
|
60
|
+
nonNullDocumentFields: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
+
playground: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
+
source: z.ZodOptional<z.ZodString>;
|
|
63
|
+
tag: z.ZodOptional<z.ZodString>;
|
|
64
|
+
workspace: z.ZodOptional<z.ZodString>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
id?: string | undefined;
|
|
67
|
+
filterSuffix?: string | undefined;
|
|
68
|
+
generation?: "gen1" | "gen2" | "gen3" | undefined;
|
|
69
|
+
nonNullDocumentFields?: boolean | undefined;
|
|
70
|
+
playground?: boolean | undefined;
|
|
71
|
+
source?: string | undefined;
|
|
72
|
+
tag?: string | undefined;
|
|
73
|
+
workspace?: string | undefined;
|
|
74
|
+
}, {
|
|
75
|
+
id?: string | undefined;
|
|
76
|
+
filterSuffix?: string | undefined;
|
|
77
|
+
generation?: "gen1" | "gen2" | "gen3" | undefined;
|
|
78
|
+
nonNullDocumentFields?: boolean | undefined;
|
|
79
|
+
playground?: boolean | undefined;
|
|
80
|
+
source?: string | undefined;
|
|
81
|
+
tag?: string | undefined;
|
|
82
|
+
workspace?: string | undefined;
|
|
83
|
+
}>, "many">>;
|
|
84
|
+
project: z.ZodOptional<z.ZodObject<{
|
|
85
|
+
basePath: z.ZodOptional<z.ZodString>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
basePath?: string | undefined;
|
|
88
|
+
}, {
|
|
89
|
+
basePath?: string | undefined;
|
|
90
|
+
}>>;
|
|
91
|
+
reactCompiler: z.ZodOptional<z.ZodObject<{
|
|
92
|
+
compilationMode: z.ZodOptional<z.ZodEnum<["all", "annotation", "infer", "syntax"]>>;
|
|
93
|
+
panicThreshold: z.ZodOptional<z.ZodEnum<["ALL_ERRORS", "CRITICAL_ERRORS", "NONE"]>>;
|
|
94
|
+
/**
|
|
95
|
+
* @see https://react.dev/learn/react-compiler#existing-projects
|
|
96
|
+
*/
|
|
97
|
+
sources: z.ZodOptional<z.ZodUnion<[z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodBoolean>, z.ZodArray<z.ZodString, "many">, z.ZodNull]>>;
|
|
98
|
+
/**
|
|
99
|
+
* The minimum major version of React that the compiler should emit code for. If the target is 19
|
|
100
|
+
* or higher, the compiler emits direct imports of React runtime APIs needed by the compiler. On
|
|
101
|
+
* versions prior to 19, an extra runtime package react-compiler-runtime is necessary to provide
|
|
102
|
+
* a userspace approximation of runtime APIs.
|
|
103
|
+
* @see https://react.dev/learn/react-compiler#using-react-compiler-with-react-17-or-18
|
|
104
|
+
*/
|
|
105
|
+
target: z.ZodEnum<["18", "19"]>;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
target: "18" | "19";
|
|
108
|
+
compilationMode?: "all" | "annotation" | "infer" | "syntax" | undefined;
|
|
109
|
+
panicThreshold?: "ALL_ERRORS" | "CRITICAL_ERRORS" | "NONE" | undefined;
|
|
110
|
+
sources?: string[] | ((args_0: string, ...args: unknown[]) => boolean) | null | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
target: "18" | "19";
|
|
113
|
+
compilationMode?: "all" | "annotation" | "infer" | "syntax" | undefined;
|
|
114
|
+
panicThreshold?: "ALL_ERRORS" | "CRITICAL_ERRORS" | "NONE" | undefined;
|
|
115
|
+
sources?: string[] | ((args_0: string, ...args: unknown[]) => boolean) | null | undefined;
|
|
116
|
+
}>>;
|
|
117
|
+
reactStrictMode: z.ZodOptional<z.ZodBoolean>;
|
|
118
|
+
server: z.ZodOptional<z.ZodObject<{
|
|
119
|
+
hostname: z.ZodOptional<z.ZodString>;
|
|
120
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
hostname?: string | undefined;
|
|
123
|
+
port?: number | undefined;
|
|
124
|
+
}, {
|
|
125
|
+
hostname?: string | undefined;
|
|
126
|
+
port?: number | undefined;
|
|
127
|
+
}>>;
|
|
128
|
+
studioHost: z.ZodOptional<z.ZodString>;
|
|
129
|
+
vite: z.ZodOptional<z.ZodUnion<[z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>, z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>]>>;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
api?: {
|
|
132
|
+
dataset?: string | undefined;
|
|
133
|
+
projectId?: string | undefined;
|
|
134
|
+
} | undefined;
|
|
135
|
+
app?: {
|
|
136
|
+
entry?: string | undefined;
|
|
137
|
+
id?: string | undefined;
|
|
138
|
+
organizationId?: string | undefined;
|
|
139
|
+
} | undefined;
|
|
140
|
+
autoUpdates?: boolean | undefined;
|
|
141
|
+
graphql?: {
|
|
142
|
+
id?: string | undefined;
|
|
143
|
+
filterSuffix?: string | undefined;
|
|
144
|
+
generation?: "gen1" | "gen2" | "gen3" | undefined;
|
|
145
|
+
nonNullDocumentFields?: boolean | undefined;
|
|
146
|
+
playground?: boolean | undefined;
|
|
147
|
+
source?: string | undefined;
|
|
148
|
+
tag?: string | undefined;
|
|
149
|
+
workspace?: string | undefined;
|
|
150
|
+
}[] | undefined;
|
|
151
|
+
project?: {
|
|
152
|
+
basePath?: string | undefined;
|
|
153
|
+
} | undefined;
|
|
154
|
+
reactCompiler?: {
|
|
155
|
+
target: "18" | "19";
|
|
156
|
+
compilationMode?: "all" | "annotation" | "infer" | "syntax" | undefined;
|
|
157
|
+
panicThreshold?: "ALL_ERRORS" | "CRITICAL_ERRORS" | "NONE" | undefined;
|
|
158
|
+
sources?: string[] | ((args_0: string, ...args: unknown[]) => boolean) | null | undefined;
|
|
159
|
+
} | undefined;
|
|
160
|
+
reactStrictMode?: boolean | undefined;
|
|
161
|
+
server?: {
|
|
162
|
+
hostname?: string | undefined;
|
|
163
|
+
port?: number | undefined;
|
|
164
|
+
} | undefined;
|
|
165
|
+
studioHost?: string | undefined;
|
|
166
|
+
vite?: ((...args: unknown[]) => unknown) | z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
167
|
+
}, {
|
|
168
|
+
api?: {
|
|
169
|
+
dataset?: string | undefined;
|
|
170
|
+
projectId?: string | undefined;
|
|
171
|
+
} | undefined;
|
|
172
|
+
app?: {
|
|
173
|
+
entry?: string | undefined;
|
|
174
|
+
id?: string | undefined;
|
|
175
|
+
organizationId?: string | undefined;
|
|
176
|
+
} | undefined;
|
|
177
|
+
autoUpdates?: boolean | undefined;
|
|
178
|
+
graphql?: {
|
|
179
|
+
id?: string | undefined;
|
|
180
|
+
filterSuffix?: string | undefined;
|
|
181
|
+
generation?: "gen1" | "gen2" | "gen3" | undefined;
|
|
182
|
+
nonNullDocumentFields?: boolean | undefined;
|
|
183
|
+
playground?: boolean | undefined;
|
|
184
|
+
source?: string | undefined;
|
|
185
|
+
tag?: string | undefined;
|
|
186
|
+
workspace?: string | undefined;
|
|
187
|
+
}[] | undefined;
|
|
188
|
+
project?: {
|
|
189
|
+
basePath?: string | undefined;
|
|
190
|
+
} | undefined;
|
|
191
|
+
reactCompiler?: {
|
|
192
|
+
target: "18" | "19";
|
|
193
|
+
compilationMode?: "all" | "annotation" | "infer" | "syntax" | undefined;
|
|
194
|
+
panicThreshold?: "ALL_ERRORS" | "CRITICAL_ERRORS" | "NONE" | undefined;
|
|
195
|
+
sources?: string[] | ((args_0: string, ...args: unknown[]) => boolean) | null | undefined;
|
|
196
|
+
} | undefined;
|
|
197
|
+
reactStrictMode?: boolean | undefined;
|
|
198
|
+
server?: {
|
|
199
|
+
hostname?: string | undefined;
|
|
200
|
+
port?: number | undefined;
|
|
201
|
+
} | undefined;
|
|
202
|
+
studioHost?: string | undefined;
|
|
203
|
+
vite?: ((...args: unknown[]) => unknown) | z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
204
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const reactCompilerSchema = z.object({
|
|
3
|
+
compilationMode: z.enum([
|
|
4
|
+
'all',
|
|
5
|
+
'annotation',
|
|
6
|
+
'infer',
|
|
7
|
+
'syntax'
|
|
8
|
+
]).optional(),
|
|
9
|
+
panicThreshold: z.enum([
|
|
10
|
+
'ALL_ERRORS',
|
|
11
|
+
'CRITICAL_ERRORS',
|
|
12
|
+
'NONE'
|
|
13
|
+
]).optional(),
|
|
14
|
+
/**
|
|
15
|
+
* @see https://react.dev/learn/react-compiler#existing-projects
|
|
16
|
+
*/ sources: z.union([
|
|
17
|
+
z.function().args(z.string()).returns(z.boolean()),
|
|
18
|
+
z.array(z.string()),
|
|
19
|
+
z.null()
|
|
20
|
+
]).optional(),
|
|
21
|
+
/**
|
|
22
|
+
* The minimum major version of React that the compiler should emit code for. If the target is 19
|
|
23
|
+
* or higher, the compiler emits direct imports of React runtime APIs needed by the compiler. On
|
|
24
|
+
* versions prior to 19, an extra runtime package react-compiler-runtime is necessary to provide
|
|
25
|
+
* a userspace approximation of runtime APIs.
|
|
26
|
+
* @see https://react.dev/learn/react-compiler#using-react-compiler-with-react-17-or-18
|
|
27
|
+
*/ target: z.enum([
|
|
28
|
+
'18',
|
|
29
|
+
'19'
|
|
30
|
+
])
|
|
31
|
+
}).optional();
|
|
32
|
+
export const cliConfigSchema = z.object({
|
|
33
|
+
/**
|
|
34
|
+
* API configuration
|
|
35
|
+
*/ api: z.object({
|
|
36
|
+
dataset: z.string().optional(),
|
|
37
|
+
projectId: z.string().optional()
|
|
38
|
+
}, {
|
|
39
|
+
description: 'API configuration'
|
|
40
|
+
}).optional(),
|
|
41
|
+
app: z.object({
|
|
42
|
+
entry: z.string().optional(),
|
|
43
|
+
id: z.string().optional(),
|
|
44
|
+
organizationId: z.string().optional()
|
|
45
|
+
}).optional(),
|
|
46
|
+
autoUpdates: z.boolean().optional(),
|
|
47
|
+
graphql: z.array(z.object({
|
|
48
|
+
filterSuffix: z.string().optional(),
|
|
49
|
+
generation: z.enum([
|
|
50
|
+
'gen1',
|
|
51
|
+
'gen2',
|
|
52
|
+
'gen3'
|
|
53
|
+
]).optional(),
|
|
54
|
+
id: z.string().optional(),
|
|
55
|
+
nonNullDocumentFields: z.boolean().optional(),
|
|
56
|
+
playground: z.boolean().optional(),
|
|
57
|
+
source: z.string().optional(),
|
|
58
|
+
tag: z.string().optional(),
|
|
59
|
+
workspace: z.string().optional()
|
|
60
|
+
})).optional(),
|
|
61
|
+
project: z.object({
|
|
62
|
+
basePath: z.string().optional()
|
|
63
|
+
}).optional(),
|
|
64
|
+
reactCompiler: reactCompilerSchema,
|
|
65
|
+
reactStrictMode: z.boolean().optional(),
|
|
66
|
+
server: z.object({
|
|
67
|
+
hostname: z.string().optional(),
|
|
68
|
+
port: z.number().optional()
|
|
69
|
+
}).optional(),
|
|
70
|
+
studioHost: z.string().optional(),
|
|
71
|
+
vite: z.union([
|
|
72
|
+
z.function(),
|
|
73
|
+
z.object({}).passthrough()
|
|
74
|
+
]).optional()
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/config/cli/schemas.ts"],"sourcesContent":["import {z} from 'zod'\n\nexport const reactCompilerSchema = z\n .object({\n compilationMode: z.enum(['all', 'annotation', 'infer', 'syntax']).optional(),\n panicThreshold: z.enum(['ALL_ERRORS', 'CRITICAL_ERRORS', 'NONE']).optional(),\n /**\n * @see https://react.dev/learn/react-compiler#existing-projects\n */\n sources: z\n .union([z.function().args(z.string()).returns(z.boolean()), z.array(z.string()), z.null()])\n .optional(),\n /**\n * The minimum major version of React that the compiler should emit code for. If the target is 19\n * or higher, the compiler emits direct imports of React runtime APIs needed by the compiler. On\n * versions prior to 19, an extra runtime package react-compiler-runtime is necessary to provide\n * a userspace approximation of runtime APIs.\n * @see https://react.dev/learn/react-compiler#using-react-compiler-with-react-17-or-18\n */\n target: z.enum(['18', '19']),\n })\n .optional()\n\nexport const cliConfigSchema = z.object({\n /**\n * API configuration\n */\n api: z\n .object(\n {\n dataset: z.string().optional(),\n projectId: z.string().optional(),\n },\n {description: 'API configuration'},\n )\n .optional(),\n\n app: z\n .object({\n entry: z.string().optional(),\n id: z.string().optional(),\n organizationId: z.string().optional(),\n })\n .optional(),\n\n autoUpdates: z.boolean().optional(),\n\n graphql: z\n .array(\n z.object({\n filterSuffix: z.string().optional(),\n generation: z.enum(['gen1', 'gen2', 'gen3']).optional(),\n id: z.string().optional(),\n nonNullDocumentFields: z.boolean().optional(),\n playground: z.boolean().optional(),\n source: z.string().optional(),\n tag: z.string().optional(),\n workspace: z.string().optional(),\n }),\n )\n .optional(),\n\n project: z\n .object({\n basePath: z.string().optional(),\n })\n .optional(),\n\n reactCompiler: reactCompilerSchema,\n\n reactStrictMode: z.boolean().optional(),\n\n server: z\n .object({\n hostname: z.string().optional(),\n port: z.number().optional(),\n })\n .optional(),\n\n studioHost: z.string().optional(),\n\n vite: z.union([z.function(), z.object({}).passthrough()]).optional(),\n})\n"],"names":["z","reactCompilerSchema","object","compilationMode","enum","optional","panicThreshold","sources","union","function","args","string","returns","boolean","array","null","target","cliConfigSchema","api","dataset","projectId","description","app","entry","id","organizationId","autoUpdates","graphql","filterSuffix","generation","nonNullDocumentFields","playground","source","tag","workspace","project","basePath","reactCompiler","reactStrictMode","server","hostname","port","number","studioHost","vite","passthrough"],"mappings":"AAAA,SAAQA,CAAC,QAAO,MAAK;AAErB,OAAO,MAAMC,sBAAsBD,EAChCE,MAAM,CAAC;IACNC,iBAAiBH,EAAEI,IAAI,CAAC;QAAC;QAAO;QAAc;QAAS;KAAS,EAAEC,QAAQ;IAC1EC,gBAAgBN,EAAEI,IAAI,CAAC;QAAC;QAAc;QAAmB;KAAO,EAAEC,QAAQ;IAC1E;;KAEC,GACDE,SAASP,EACNQ,KAAK,CAAC;QAACR,EAAES,QAAQ,GAAGC,IAAI,CAACV,EAAEW,MAAM,IAAIC,OAAO,CAACZ,EAAEa,OAAO;QAAKb,EAAEc,KAAK,CAACd,EAAEW,MAAM;QAAKX,EAAEe,IAAI;KAAG,EACzFV,QAAQ;IACX;;;;;;KAMC,GACDW,QAAQhB,EAAEI,IAAI,CAAC;QAAC;QAAM;KAAK;AAC7B,GACCC,QAAQ,GAAE;AAEb,OAAO,MAAMY,kBAAkBjB,EAAEE,MAAM,CAAC;IACtC;;GAEC,GACDgB,KAAKlB,EACFE,MAAM,CACL;QACEiB,SAASnB,EAAEW,MAAM,GAAGN,QAAQ;QAC5Be,WAAWpB,EAAEW,MAAM,GAAGN,QAAQ;IAChC,GACA;QAACgB,aAAa;IAAmB,GAElChB,QAAQ;IAEXiB,KAAKtB,EACFE,MAAM,CAAC;QACNqB,OAAOvB,EAAEW,MAAM,GAAGN,QAAQ;QAC1BmB,IAAIxB,EAAEW,MAAM,GAAGN,QAAQ;QACvBoB,gBAAgBzB,EAAEW,MAAM,GAAGN,QAAQ;IACrC,GACCA,QAAQ;IAEXqB,aAAa1B,EAAEa,OAAO,GAAGR,QAAQ;IAEjCsB,SAAS3B,EACNc,KAAK,CACJd,EAAEE,MAAM,CAAC;QACP0B,cAAc5B,EAAEW,MAAM,GAAGN,QAAQ;QACjCwB,YAAY7B,EAAEI,IAAI,CAAC;YAAC;YAAQ;YAAQ;SAAO,EAAEC,QAAQ;QACrDmB,IAAIxB,EAAEW,MAAM,GAAGN,QAAQ;QACvByB,uBAAuB9B,EAAEa,OAAO,GAAGR,QAAQ;QAC3C0B,YAAY/B,EAAEa,OAAO,GAAGR,QAAQ;QAChC2B,QAAQhC,EAAEW,MAAM,GAAGN,QAAQ;QAC3B4B,KAAKjC,EAAEW,MAAM,GAAGN,QAAQ;QACxB6B,WAAWlC,EAAEW,MAAM,GAAGN,QAAQ;IAChC,IAEDA,QAAQ;IAEX8B,SAASnC,EACNE,MAAM,CAAC;QACNkC,UAAUpC,EAAEW,MAAM,GAAGN,QAAQ;IAC/B,GACCA,QAAQ;IAEXgC,eAAepC;IAEfqC,iBAAiBtC,EAAEa,OAAO,GAAGR,QAAQ;IAErCkC,QAAQvC,EACLE,MAAM,CAAC;QACNsC,UAAUxC,EAAEW,MAAM,GAAGN,QAAQ;QAC7BoC,MAAMzC,EAAE0C,MAAM,GAAGrC,QAAQ;IAC3B,GACCA,QAAQ;IAEXsC,YAAY3C,EAAEW,MAAM,GAAGN,QAAQ;IAE/BuC,MAAM5C,EAAEQ,KAAK,CAAC;QAACR,EAAES,QAAQ;QAAIT,EAAEE,MAAM,CAAC,CAAC,GAAG2C,WAAW;KAAG,EAAExC,QAAQ;AACpE,GAAE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ConfigEnv, type InlineConfig } from 'vite';
|
|
2
|
+
import { type z } from 'zod';
|
|
3
|
+
import { type cliConfigSchema, type reactCompilerSchema } from './schemas.js';
|
|
4
|
+
/**
|
|
5
|
+
* Until these types are on npm: https://github.com/facebook/react/blob/0bc30748730063e561d87a24a4617526fdd38349/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts#L39-L122
|
|
6
|
+
*
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export type ReactCompilerConfig = z.infer<typeof reactCompilerSchema>;
|
|
10
|
+
export type UserViteConfig = ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>) | InlineConfig;
|
|
11
|
+
export type CliConfig = z.infer<typeof cliConfigSchema> & {
|
|
12
|
+
vite?: UserViteConfig;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/config/cli/types.ts"],"sourcesContent":["import {type ConfigEnv, type InlineConfig} from 'vite'\nimport {type z} from 'zod'\n\nimport {type cliConfigSchema, type reactCompilerSchema} from './schemas.js'\n\n/**\n * Until these types are on npm: https://github.com/facebook/react/blob/0bc30748730063e561d87a24a4617526fdd38349/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts#L39-L122\n *\n * @beta\n */\nexport type ReactCompilerConfig = z.infer<typeof reactCompilerSchema>\n\nexport type UserViteConfig =\n | ((config: InlineConfig, env: ConfigEnv) => InlineConfig | Promise<InlineConfig>)\n | InlineConfig\n\nexport type CliConfig = z.infer<typeof cliConfigSchema> & {\n vite?: UserViteConfig\n}\n"],"names":[],"mappings":"AAgBA,WAEC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ProjectRootResult } from './util/recursivelyResolveProjectRoot.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve project root directory and type.
|
|
4
|
+
*
|
|
5
|
+
* Project root is:
|
|
6
|
+
* - `studio` - A pre-blueprints Sanity studio root (containing `sanity.config.(ts|js)`)
|
|
7
|
+
* - `app` - A Sanity app root (containing `sanity.cli.(ts|js)`)
|
|
8
|
+
*
|
|
9
|
+
* If a Sanity Studio v2/v1 root is found (containing `sanity.json` with `root: true`),
|
|
10
|
+
* an error is thrown, as v2/v1 is no longer supported.
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare function findProjectRoot(cwd: string): Promise<ProjectRootResult>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { findAppConfigPath } from './util/findAppConfigPath.js';
|
|
2
|
+
import { findStudioConfigPath } from './util/findStudioConfigPath.js';
|
|
3
|
+
import { recursivelyResolveProjectRoot } from './util/recursivelyResolveProjectRoot.js';
|
|
4
|
+
/**
|
|
5
|
+
* Resolve project root directory and type.
|
|
6
|
+
*
|
|
7
|
+
* Project root is:
|
|
8
|
+
* - `studio` - A pre-blueprints Sanity studio root (containing `sanity.config.(ts|js)`)
|
|
9
|
+
* - `app` - A Sanity app root (containing `sanity.cli.(ts|js)`)
|
|
10
|
+
*
|
|
11
|
+
* If a Sanity Studio v2/v1 root is found (containing `sanity.json` with `root: true`),
|
|
12
|
+
* an error is thrown, as v2/v1 is no longer supported.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/ export async function findProjectRoot(cwd) {
|
|
16
|
+
try {
|
|
17
|
+
// First try to find a studio project root, looks for `sanity.config.(ts|js)`
|
|
18
|
+
const studioProjectRoot = await resolveProjectRootForStudio(cwd);
|
|
19
|
+
if (studioProjectRoot) {
|
|
20
|
+
return studioProjectRoot;
|
|
21
|
+
}
|
|
22
|
+
// Second try to find a app project root, looks for `sanity.cli.(ts|js)`
|
|
23
|
+
const appProjectRoot = await resolveProjectRootForApp(cwd);
|
|
24
|
+
if (appProjectRoot) {
|
|
25
|
+
return appProjectRoot;
|
|
26
|
+
}
|
|
27
|
+
// If nothing is found throw an error
|
|
28
|
+
throw new Error('No project root found');
|
|
29
|
+
} catch (err) {
|
|
30
|
+
const message = err instanceof Error ? err.message : `${err}`;
|
|
31
|
+
throw new Error(`Error occurred trying to resolve project root:\n${message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Recursively searches for a project configuration file in the given directory and its parents.
|
|
36
|
+
* Throws if Sanity v2 studio root is found.
|
|
37
|
+
*
|
|
38
|
+
* @param basePath - The base path to start searching from
|
|
39
|
+
* @param iterations - Current iteration count, passed internally to prevent infinite recursion.
|
|
40
|
+
* @returns A promise that resolves to an object if config is found, false otherwise
|
|
41
|
+
* @internal
|
|
42
|
+
*/ async function resolveProjectRootForStudio(basePath, iterations = 0) {
|
|
43
|
+
return recursivelyResolveProjectRoot(basePath, findStudioConfigPath, 'studio', iterations);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Recursively searches for a app project configuration file in the given directory and its parents.
|
|
47
|
+
*
|
|
48
|
+
* @param basePath - The base path to start searching from
|
|
49
|
+
* @param iterations - Current iteration count, passed internally to prevent infinite recursion.
|
|
50
|
+
* @returns A promise that resolves to an object if config is found, false otherwise
|
|
51
|
+
* @internal
|
|
52
|
+
*/ async function resolveProjectRootForApp(basePath, iterations = 0) {
|
|
53
|
+
return recursivelyResolveProjectRoot(basePath, findAppConfigPath, 'app', iterations);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=findProjectRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/config/findProjectRoot.ts"],"sourcesContent":["import {findAppConfigPath} from './util/findAppConfigPath.js'\nimport {findStudioConfigPath} 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 an error\n throw new Error('No project root found')\n } catch (err: unknown) {\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 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, findStudioConfigPath, '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":["findAppConfigPath","findStudioConfigPath","recursivelyResolveProjectRoot","findProjectRoot","cwd","studioProjectRoot","resolveProjectRootForStudio","appProjectRoot","resolveProjectRootForApp","Error","err","message","basePath","iterations"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,8BAA6B;AAC7D,SAAQC,oBAAoB,QAAO,iCAAgC;AACnE,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,qCAAqC;QACrC,MAAM,IAAIE,MAAM;IAClB,EAAE,OAAOC,KAAc;QACrB,MAAMC,UAAUD,eAAeD,QAAQC,IAAIC,OAAO,GAAG,GAAGD,KAAK;QAC7D,MAAM,IAAID,MAAM,CAAC,gDAAgD,EAAEE,SAAS;IAC9E;AACF;AAEA;;;;;;;;CAQC,GACD,eAAeL,4BACbM,QAAgB,EAChBC,aAAa,CAAC;IAEd,OAAOX,8BAA8BU,UAAUX,sBAAsB,UAAUY;AACjF;AAEA;;;;;;;CAOC,GACD,eAAeL,yBACbI,QAAgB,EAChBC,aAAa,CAAC;IAEd,OAAOX,8BAA8BU,UAAUZ,mBAAmB,OAAOa;AAC3E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type RawStudioConfig, type ResolvedStudioConfig } from './readStudioConfig.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the studio config for a project, given the root path.
|
|
4
|
+
*
|
|
5
|
+
* @param rootPath - The root path for the project
|
|
6
|
+
* @returns The studio config (some properties may be missing)
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function getStudioConfig(rootPath: string, options: {
|
|
10
|
+
resolvePlugins: true;
|
|
11
|
+
}): Promise<ResolvedStudioConfig>;
|
|
12
|
+
export declare function getStudioConfig(rootPath: string, options: {
|
|
13
|
+
resolvePlugins: false;
|
|
14
|
+
}): Promise<RawStudioConfig>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { findStudioConfigPath } from '../util/findStudioConfigPath.js';
|
|
2
|
+
import { readStudioConfig } from './readStudioConfig.js';
|
|
3
|
+
export async function getStudioConfig(rootPath, options) {
|
|
4
|
+
const studioConfigPath = await findStudioConfigPath(rootPath);
|
|
5
|
+
if (!studioConfigPath) {
|
|
6
|
+
throw new Error(`Unable to find studio configuration file in ${rootPath}`);
|
|
7
|
+
}
|
|
8
|
+
// TypeScript is not being very clever with our overloads :(
|
|
9
|
+
return options.resolvePlugins ? readStudioConfig(studioConfigPath, {
|
|
10
|
+
resolvePlugins: true
|
|
11
|
+
}) : readStudioConfig(studioConfigPath, {
|
|
12
|
+
resolvePlugins: false
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=getStudioConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/config/studio/getStudioConfig.ts"],"sourcesContent":["import {findStudioConfigPath} from '../util/findStudioConfigPath.js'\nimport {\n type RawStudioConfig,\n readStudioConfig,\n type ReadStudioConfigOptions,\n type ResolvedStudioConfig,\n} from './readStudioConfig.js'\n\n/**\n * Get the studio config for a project, given the root path.\n *\n * @param rootPath - The root path for the project\n * @returns The studio config (some properties may be missing)\n * @internal\n */\nexport async function getStudioConfig(\n rootPath: string,\n options: {resolvePlugins: true},\n): Promise<ResolvedStudioConfig>\n\nexport async function getStudioConfig(\n rootPath: string,\n options: {resolvePlugins: false},\n): Promise<RawStudioConfig>\n\nexport async function getStudioConfig(\n rootPath: string,\n options: ReadStudioConfigOptions,\n): Promise<RawStudioConfig | ResolvedStudioConfig> {\n const studioConfigPath = await findStudioConfigPath(rootPath)\n if (!studioConfigPath) {\n throw new Error(`Unable to find studio configuration file in ${rootPath}`)\n }\n\n // TypeScript is not being very clever with our overloads :(\n return options.resolvePlugins\n ? readStudioConfig(studioConfigPath, {resolvePlugins: true})\n : readStudioConfig(studioConfigPath, {resolvePlugins: false})\n}\n"],"names":["findStudioConfigPath","readStudioConfig","getStudioConfig","rootPath","options","studioConfigPath","Error","resolvePlugins"],"mappings":"AAAA,SAAQA,oBAAoB,QAAO,kCAAiC;AACpE,SAEEC,gBAAgB,QAGX,wBAAuB;AAmB9B,OAAO,eAAeC,gBACpBC,QAAgB,EAChBC,OAAgC;IAEhC,MAAMC,mBAAmB,MAAML,qBAAqBG;IACpD,IAAI,CAACE,kBAAkB;QACrB,MAAM,IAAIC,MAAM,CAAC,4CAA4C,EAAEH,UAAU;IAC3E;IAEA,4DAA4D;IAC5D,OAAOC,QAAQG,cAAc,GACzBN,iBAAiBI,kBAAkB;QAACE,gBAAgB;IAAI,KACxDN,iBAAiBI,kBAAkB;QAACE,gBAAgB;IAAK;AAC/D"}
|