@sanity/plugin-kit
7.0.28.0.0
dist/package-YDElb3ND.js.map−
dist/package-YDElb3ND.js.mapDeleted−1
Index: package/dist/package-YDElb3ND.js.map
===================================================================
--- package/dist/package-YDElb3ND.js.map
+++ package/dist/package-YDElb3ND.js.map
@@ -1,1 +0,0 @@
-{"version":3,"file":"package-YDElb3ND.js","names":["stat","readFile","validatePackageName","validateNpmPackageName","readFile","pkg.binname","isObject","validatePaths","validateNpmPackageName","githubUrl"],"sources":["../src/configs/banned-packages.ts","../src/configs/buildExtensions.ts","../src/util/prompt.ts","../src/util/files.ts","../src/actions/verify/validations.ts","../src/configs/forced-package-versions.ts","../src/util/errorToUndefined.ts","../src/sanity/manifest.ts","../src/npm/resolveLatestVersions.ts","../src/npm/package.ts"],"sourcesContent":["export const mergedPackages = [\n '@sanity/base',\n '@sanity/core',\n '@sanity/types',\n '@sanity/data-aspects',\n '@sanity/default-layout',\n '@sanity/default-login',\n '@sanity/desk-tool',\n '@sanity/field',\n '@sanity/form-builder',\n '@sanity/initial-value-templates',\n '@sanity/language-filter',\n '@sanity/production-preview',\n '@sanity/react-hooks',\n '@sanity/resolver',\n '@sanity/state-router',\n '@sanity/structure',\n '@sanity/studio-hints',\n].sort()\n\nexport const deprecatedDevDeps = [\n 'tsdx',\n 'sanipack',\n 'parcel',\n '@parcel/packager-ts',\n '@parcel/transformer-typescript-types',\n]\n","export const buildExtensions = ['.js', '.jsx', '.es6', '.es', '.mjs', '.ts', '.tsx']\n","import path from 'path'\nimport {URL} from 'url'\n\nimport githubUrlToObject from 'github-url-to-object'\nimport inquirer from 'inquirer'\nimport validNpmName from 'validate-npm-package-name'\n\nimport type {InjectOptions} from '../actions/inject'\n\nexport async function prompt(\n message: string,\n options: {\n choices?: any\n type?: string\n default?: any\n filter?: (val: any) => any\n validate?: (val: any) => boolean | string\n },\n) {\n const type = options.choices ? 'list' : options.type\n const result = await inquirer.prompt([{...options, type, message, name: 'single'}])\n return result && result.single\n}\n\nprompt.separator = () => new inquirer.Separator()\n\nexport function promptForPackageName({basePath}: InjectOptions, defaultVal?: string) {\n return prompt('Plugin name (sanity-plugin-...)', {\n default: defaultVal || path.basename(basePath),\n filter: (name) => {\n const prefixless = name.trim().replace(/^sanity-plugin-/, '')\n return name[0] === '@' ? name : `sanity-plugin-${prefixless}`\n },\n validate: (name) => {\n const valid: {errors?: string[]} = validNpmName(name)\n if (valid.errors) {\n return valid.errors[0]\n }\n\n if (name[0] !== '@' && name.endsWith('plugin')) {\n return `Name shouldn't include \"plugin\" multiple times (${name})`\n }\n\n return true\n },\n })\n}\n\nexport function promptForRepoOrigin(_options: InjectOptions, defaultVal?: string) {\n return prompt('Git repository URL', {\n default: defaultVal,\n filter: (raw) => {\n const url = (raw || '').trim()\n const gh = githubUrlToObject(url)\n return gh ? `git+ssh://[email protected]/${gh.user}/${gh.repo}.git` : url\n },\n validate: (url) => {\n if (!url) {\n return true\n }\n\n try {\n const parsed = new URL(url)\n return parsed ? true : 'Invalid URL'\n } catch {\n return 'Invalid URL'\n }\n },\n })\n}\n","import crypto from 'crypto'\nimport fs from 'fs'\nimport path from 'path'\nimport util from 'util'\n\nimport json5 from 'json5'\nimport pAny from 'p-any'\n\nimport type {InitFlags} from '../actions/init'\nimport {buildExtensions} from '../configs/buildExtensions'\nimport type {ManifestPaths} from '../sanity/manifest'\nimport log from './log'\nimport {prompt} from './prompt'\n\nconst stat = util.promisify(fs.stat)\nexport const mkdir = util.promisify(fs.mkdir)\nconst readdir = util.promisify(fs.readdir)\nconst copyFile = util.promisify(fs.copyFile)\nexport const readFile = util.promisify(fs.readFile)\nexport const writeFile = util.promisify(fs.writeFile)\n\nexport function hasSourceEquivalent(compiledFile: string, paths: ManifestPaths) {\n if (!paths.source) {\n return fileExists(\n path.isAbsolute(compiledFile) ? compiledFile : path.resolve(paths.basePath, compiledFile),\n )\n }\n\n // /plugin/dist/MyComponent.js => /plugin/src\n const baseDir = path.dirname(compiledFile.replace(paths.compiled as string, paths.source))\n\n // /plugin/dist/MyComponent.js => MyComponent\n const baseName = path.basename(compiledFile, path.extname(compiledFile))\n\n // MyComponent => /plugin/src/MyComponent\n const pathStub = path.join(baseDir, baseName)\n\n /*\n * /plugin/src/MyComponent => [\n * /plugin/src/MyComponent.jsx,\n * /plugin/src/MyComponent.mjs,\n * ...\n * ]\n */\n return buildCandidateExists(pathStub)\n}\n\n// Generally used for parts resolving\nexport async function hasSourceFile(filePath: string, paths?: ManifestPaths) {\n if (!paths?.source) {\n return fileExists(\n path.isAbsolute(filePath) ? filePath : path.resolve(paths?.basePath ?? '', filePath),\n )\n }\n\n // filePath: components/SomeInput\n // paths: {source: '/plugin/src'}\n // MyComponent => /plugin/src/MyComponent\n const pathStub = path.isAbsolute(filePath) ? filePath : path.resolve(paths.source, filePath)\n\n if (await fileExists(pathStub)) {\n return true\n }\n\n return buildCandidateExists(pathStub)\n}\n\n// Generally used for parts resolving\nexport function hasCompiledFile(filePath: string, paths?: ManifestPaths) {\n if (!paths?.compiled) {\n return fileExists(\n path.isAbsolute(filePath) ? filePath : path.resolve(paths?.basePath ?? '', filePath),\n )\n }\n\n // filePath: components/SomeInput\n // paths: {compiled: '/plugin/dist'}\n\n // components/SomeInput => /plugin/dist/components/SomeInput\n const absPath = path.isAbsolute(filePath) ? filePath : path.resolve(paths.compiled, filePath)\n\n // /plugin/dist/components/SomeInput => /plugin/dist/components/SomeInput.js\n // /plugin/dist/components/SomeInput.js => /plugin/dist/components/SomeInput.js\n // /plugin/dist/components/SomeInput.css => /plugin/dist/components/SomeInput.css\n const fileExt = path.extname(absPath)\n const withExt = fileExt === '' ? `${absPath}.js` : absPath\n\n return fileExists(withExt)\n}\n\nfunction buildCandidateExists(pathStub: string) {\n const candidates = buildExtensions.map((extCandidate) => `${pathStub}${extCandidate}`)\n\n return pAny(candidates.map((candidate) => stat(candidate)))\n .then(() => true)\n .catch(() => false)\n}\n\nexport function fileExists(filePath: string) {\n return stat(filePath)\n .then(() => true)\n .catch(() => false)\n}\n\nexport async function readJsonFile<T>(filePath: string) {\n const content = await readFile(filePath, 'utf8')\n return JSON.parse(content) as T\n}\n\nexport function writeJsonFile(filePath: string, content: Record<string, unknown>) {\n const data = JSON.stringify(content, null, 2) + '\\n'\n return writeFile(filePath, data, {encoding: 'utf8'})\n}\n\nexport async function writeFileWithOverwritePrompt(\n filePath: string,\n content: string,\n options: {default?: any; force?: boolean} & fs.ObjectEncodingOptions,\n) {\n const {default: defaultVal, force = false, ...writeOptions} = options\n const withinCwd = filePath.startsWith(process.cwd())\n const printablePath = withinCwd ? path.relative(process.cwd(), filePath) : filePath\n\n if (await fileEqualsData(filePath, content)) {\n return false\n }\n\n if (\n !force &&\n (await fileExists(filePath)) &&\n !(await prompt(`File \"${printablePath}\" already exists. Overwrite?`, {\n type: 'confirm',\n default: defaultVal,\n }))\n ) {\n return false\n }\n\n await writeFile(filePath, content, writeOptions)\n return true\n}\n\nexport async function copyFileWithOverwritePrompt(from: string, to: string, flags: InitFlags) {\n const withinCwd = to.startsWith(process.cwd())\n const printablePath = withinCwd ? path.relative(process.cwd(), to) : to\n\n if (await filesAreEqual(from, to)) {\n return false\n }\n\n await ensureDirectoryExists(to)\n\n if (\n !flags.force &&\n (await fileExists(to)) &&\n !(await prompt(`File \"${printablePath}\" already exists. Overwrite?`, {\n type: 'confirm',\n default: false,\n }))\n ) {\n return false\n }\n\n await copyFile(from, to)\n return true\n}\n\nasync function ensureDirectoryExists(filePath: string): Promise<void> {\n const dirname = path.dirname(filePath)\n if (await fileExists(dirname)) {\n return\n }\n await ensureDirectoryExists(dirname)\n await mkdir(dirname)\n}\n\nasync function fileEqualsData(filePath: string, content: string) {\n const contentHash = crypto.createHash('sha1').update(content).digest('hex')\n const remoteHash = await getFileHash(filePath)\n return contentHash === remoteHash\n}\n\nasync function filesAreEqual(file1: string, file2: string) {\n const [hash1, hash2] = await Promise.all([getFileHash(file1, false), getFileHash(file2)])\n return hash1 === hash2\n}\n\nfunction getFileHash(filePath: string, allowMissing = true) {\n return new Promise((resolve, reject) => {\n const hash = crypto.createHash('sha1')\n const stream = fs.createReadStream(filePath)\n stream.on('error', (err) => {\n if ((err as {code?: string}).code === 'ENOENT' && allowMissing) {\n resolve(null)\n } else {\n reject(err)\n }\n })\n\n stream.on('end', () => resolve(hash.digest('hex')))\n stream.on('data', (chunk) => hash.update(chunk))\n })\n}\n\nexport async function ensureDir(dirPath: string) {\n try {\n await mkdir(dirPath)\n } catch (err) {\n if ((err as {code?: string}).code !== 'EEXIST') {\n throw err\n }\n }\n}\n\nexport async function isEmptyish(dirPath: string) {\n const ignoredFiles = ['.git', '.gitignore', 'license', 'readme.md']\n const allFiles = await readdir(dirPath).catch(() => [])\n const files = allFiles.filter((file) => !ignoredFiles.includes(file.toLowerCase()))\n return files.length === 0\n}\n\nasync function readFileContent({\n filename,\n basePath,\n}: {\n filename: string\n basePath: string\n}): Promise<string | undefined> {\n const filepath = path.normalize(path.join(basePath, filename))\n try {\n return await readFile(filepath, 'utf8')\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n log.debug(`No ${filename} file found.`)\n return undefined\n }\n throw new Error(`Failed to read \"${filepath}\": ${err.message}`)\n }\n}\n\nexport async function readJson5File<T>({\n filename,\n basePath,\n}: {\n filename: string\n basePath: string\n}): Promise<T | undefined> {\n const content = await readFileContent({filename, basePath})\n if (!content) {\n return undefined\n }\n\n return parseJson5<T>(content, filename)\n}\n\nfunction parseJson5<T>(content: string, errorKey: string): T {\n try {\n return json5.parse<T>(content)\n } catch (err: any) {\n throw new Error(`Error parsing \"${errorKey}\": ${err.message}`)\n }\n}\n","import {createRequire} from 'node:module'\nimport path from 'path'\n\nimport type {ParsedCommandLine} from '@typescript/typescript6'\nimport chalk from 'chalk'\nimport outdent from 'outdent'\nimport validateNpmPackageName from 'validate-npm-package-name'\n\nimport {deprecatedDevDeps, mergedPackages} from '../../configs/banned-packages'\nimport {\n incompatiblePluginPackage,\n minPkgUtilsMajor,\n requiredNodeEngine,\n urls,\n} from '../../constants'\nimport {fileExists, readJson5File} from '../../util/files'\nimport type {PackageJson, SanityStudioJson, SanityV2Json} from './types'\n\nexport const expectedScripts = {\n 'build': 'plugin-kit verify-package --silent && pkg-utils build --strict --check --clean',\n 'watch': 'pkg-utils watch --strict',\n 'link-watch': 'plugin-kit link-watch',\n 'prepublishOnly': 'npm run build',\n}\n\nfunction filesWithSuffixes(fileBases: string[], suffixes: string[]): string[] {\n return fileBases.flatMap((file) => suffixes.map((suffix) => `${file}.${suffix}`))\n}\n\nexport function validateNodeEngine(packageJson: PackageJson) {\n if (packageJson.engines?.node !== requiredNodeEngine) {\n return [\n outdent`\n Expected package.json to contain engines.node: \"${requiredNodeEngine}\" to match @sanity/pkg-utils,\n but it was: ${packageJson.engines?.node}\n\n Please add the following to package.json:\n\n \"engines\": {\n \"node\": \"${requiredNodeEngine}\"\n }`.trimStart(),\n ]\n }\n return []\n}\n\nexport function validateScripts(packageJson: PackageJson): string[] {\n const errors: string[] = []\n\n const divergentScripts = Object.entries(expectedScripts).filter(([key, expectedCommand]) => {\n const command = packageJson.scripts?.[key]\n // check for includes instead of equals to give some leniency in command params and such\n return !command || !command.includes(expectedCommand)\n })\n\n if (divergentScripts.length) {\n errors.push(\n outdent`\n The following script commands did not contain expected defaults: ${divergentScripts\n .map(([key]) => key)\n .join(', ')}\n\n This checks for that the commands-strings includes these terms.\n\n Please add the following to your package.json \"scripts\":\n\n ${divergentScripts.map(([key, value]) => `\"${key}\": \"${value}\"`).join(',\\n')}\n `.trimStart(),\n )\n }\n return errors\n}\n\nexport async function validateTsConfig(\n ts: ParsedCommandLine,\n options: {basePath: string; outDir: string; tsconfig: string},\n) {\n const {basePath, outDir, tsconfig} = options\n\n const errors: string[] = []\n\n const expectedCompilerOptions = {\n target: 'esnext',\n jsx: 'preserve',\n module: 'preserve',\n rootDir: '.',\n outDir,\n noEmit: true,\n }\n\n const wrongEntries = Object.entries(expectedCompilerOptions).filter(([key, value]) => {\n let option: any = ts.options[key]\n\n if (key === 'rootDir' && typeof option === 'string') {\n option = path.relative(basePath, option) || '.'\n }\n\n if (key === 'outDir' && typeof option === 'string') {\n option = path.relative(basePath, option) || '.'\n }\n\n if (key === 'target' && option === 99) {\n option = 'esnext'\n }\n\n if (key === 'module' && option === 200) {\n option = 'preserve'\n }\n\n if (key === 'jsx' && option === 1) {\n option = 'preserve'\n }\n\n return typeof value === 'string' && typeof option === 'string'\n ? value.toLowerCase() !== option?.toLowerCase()\n : value !== option\n })\n\n if (wrongEntries.length) {\n const expectedOutput = wrongEntries\n .map(([key, value]) => `\"${key}\": ${typeof value === 'string' ? `\"${value}\"` : value},`)\n .join('\\n')\n\n errors.push(\n outdent`\n Recommended ${tsconfig} compilerOptions missing:\n\n The following fields had unexpected values: [${wrongEntries.map(([key]) => key).join(', ')}]\n Expected to find these values:\n ${expectedOutput}\n\n Please update your ${tsconfig} accordingly.\n `.trimStart(),\n )\n }\n\n return errors\n}\n\n/**\n * Hard requirement: plugins must be ESM (`\"type\": \"module\"`).\n *\n * plugin-kit loads `package.config.ts` through `@sanity/pkg-utils`, which can only load ESM\n * TypeScript configs reliably when the plugin itself is ESM. CommonJS (or an omitted `type`)\n * is not supported and cannot be opted out of.\n */\nexport function validatePackageType({type}: PackageJson): string[] {\n if (type === 'module') {\n return []\n }\n\n return [\n outdent`\n package.json must set \"type\": \"module\" — plugins built with @sanity/plugin-kit are ESM-only.\n Found: ${type ? `\"type\": \"${type}\"` : 'no \"type\" field (defaults to \"commonjs\")'}\n\n Please add the following to package.json:\n\n \"type\": \"module\"\n `.trimStart(),\n ]\n}\n\n/**\n * Recursively collects the locations of any `require` condition within a package.json `exports`\n * field. Conditions can be nested arbitrarily deep (and inside fallback arrays), so we walk the\n * whole tree rather than only inspecting the first level.\n *\n * Subpath keys always start with `.` (e.g. `\"./feature\"`), while condition keys never do, so an\n * exact `require` key is unambiguously a CommonJS export condition.\n */\nfunction findRequireConditions(node: unknown, pathSegments: string[]): string[] {\n if (Array.isArray(node)) {\n return node.flatMap((entry, index) =>\n findRequireConditions(entry, [...pathSegments, String(index)]),\n )\n }\n\n if (!node || typeof node !== 'object') {\n return []\n }\n\n const found: string[] = []\n for (const [key, value] of Object.entries(node)) {\n if (key === 'require') {\n found.push(formatExportsPath(pathSegments))\n }\n found.push(...findRequireConditions(value, [...pathSegments, key]))\n }\n return found\n}\n\nfunction formatExportsPath(segments: string[]): string {\n return `exports${segments.map((segment) => `[${JSON.stringify(segment)}]`).join('')}`\n}\n\n/**\n * Bans CommonJS interop in package.json. The plugin baseline is Sanity Studio v5 or later, which is\n * pure ESM, so there is no reason to publish a parallel CJS build anymore. This flags:\n *\n * - `require` export conditions\n * - the top-level `main` field\n * - the top-level `module` field\n */\nexport function validateEsmOnly(packageJson: PackageJson): string[] {\n const offenders: string[] = []\n\n if (typeof packageJson.main !== 'undefined') {\n offenders.push(`- the top-level \"main\" field (${JSON.stringify(packageJson.main)})`)\n }\n\n if (typeof packageJson.module !== 'undefined') {\n offenders.push(`- the top-level \"module\" field (${JSON.stringify(packageJson.module)})`)\n }\n\n const requireConditions = [...new Set(findRequireConditions(packageJson.exports, []))]\n for (const conditionPath of requireConditions) {\n offenders.push(`- a \"require\" export condition at ${conditionPath}`)\n }\n\n if (!offenders.length) {\n return []\n }\n\n return [\n outdent`\n package.json ships CommonJS (CJS) output, but Sanity plugins target Sanity Studio v5+, which is pure ESM.\n\n Remove the following so the package stays ESM-only:\n ${offenders.join('\\n')}\n\n Supporting CJS is not worth it:\n - It can have unintended side-effects.\n - The Node.js versions plugin-kit supports (${requiredNodeEngine}) fully support require(esm), so a\n consumer that still uses require() loads the ESM build directly — which is far more predictable.\n - Publishing a single format guarantees two copies of the plugin's code (ESM + CJS) can't both end up\n in the module tree, bloating bundles and slowing down builds.\n\n Rely on \"exports\" together with \"type\": \"module\", and drop \"main\", \"module\" and any \"require\" conditions.\n `.trimStart(),\n ]\n}\n\nexport function validatePkgUtilsDependency({devDependencies}: PackageJson): string[] {\n if (!devDependencies?.['@sanity/pkg-utils']) {\n return [\n outdent`\n package.json does not list @sanity/pkg-utils as a devDependency.\n @sanity/pkg-utils replaced parcel as the recommended build tool in @sanity/plugin-kit 2.0.0\n\n Please add it by running 'npm install --save-dev @sanity/pkg-utils'.\n `.trimStart(),\n ]\n }\n return []\n}\n\n/**\n * Verifies that the installed `@sanity/pkg-utils` (the peer dependency plugin-kit loads\n * `package.config.ts` with) is recent enough to expose the `loadConfig({cwd, pkgPath})` API.\n */\nexport function validatePkgUtilsVersion({basePath}: {basePath: string}): string[] {\n const require = createRequire(path.join(basePath, 'package.json'))\n\n let installedVersion: string | undefined\n try {\n const pkgUtilsManifest = require('@sanity/pkg-utils/package.json') as {version?: string}\n installedVersion = pkgUtilsManifest.version\n } catch {\n return [\n outdent`\n @sanity/pkg-utils is not installed.\n plugin-kit loads package.config.ts through @sanity/pkg-utils (a peer dependency).\n\n Please install it by running 'npm install --save-dev @sanity/pkg-utils'.\n `.trimStart(),\n ]\n }\n\n const major = Number.parseInt(installedVersion?.split('.')[0] ?? '', 10)\n if (!Number.isFinite(major) || major < minPkgUtilsMajor) {\n return [\n outdent`\n @sanity/pkg-utils ${installedVersion} is too old.\n plugin-kit requires @sanity/pkg-utils >=${minPkgUtilsMajor} to load package.config.ts.\n\n Please upgrade it by running 'npm install --save-dev @sanity/pkg-utils@latest'.\n `.trimStart(),\n ]\n }\n\n return []\n}\n\nexport function validateSanityDependencies(packageJson: PackageJson): string[] {\n const {dependencies, devDependencies, peerDependencies} = packageJson\n const allDependencies = {...dependencies, ...devDependencies, ...peerDependencies}\n\n const illegalDeps = Object.keys(allDependencies).filter((dep) => mergedPackages.includes(dep))\n const deps = new Set<string>(illegalDeps)\n const unique = [...deps.values()]\n if (unique.length) {\n return [\n outdent`\n package.json depends on \"@sanity/*\" packages that have moved into \"sanity\" package.\n\n The following dependencies should be replaced with \"sanity\":\n - ${unique.join('\\n- ')}\n\n Refer to the reference docs to find replacement imports:\n ${urls.refDocs}\n `.trimStart(),\n ]\n }\n return []\n}\n\nexport function validateDeprecatedDependencies(packageJson: PackageJson): string[] {\n const {dependencies, devDependencies, peerDependencies} = packageJson\n const allDependencies = {...dependencies, ...devDependencies, ...peerDependencies}\n\n const illegalDeps = Object.keys(allDependencies).filter((dep) => deprecatedDevDeps.includes(dep))\n const deps = new Set<string>(illegalDeps)\n const unique = [...deps.values()]\n if (unique.length) {\n return [\n outdent`\n package.json contains deprecated dependencies that should be removed:\n - ${unique.join('\\n- ')}\n `.trimStart(),\n ]\n }\n\n return []\n}\n\nexport async function validateBabelConfig({basePath}: {basePath: string}) {\n const suffixes = ['json', 'js', 'cjs', 'mjs']\n const babelFileNames = ['.babelrc', 'babel.config']\n const filenames = ['.babelrc', ...filesWithSuffixes(babelFileNames, suffixes)]\n\n const babelFiles: string[] = []\n for (const filename of filenames) {\n const filepath = path.normalize(path.join(basePath, filename))\n if (await fileExists(filepath)) {\n babelFiles.push(filename)\n }\n }\n\n if (babelFiles.length) {\n return [\n outdent`\n Found babel-config file: [${babelFiles.join(\n ', ',\n )}]. When using default @sanity/plugin-kit build command,\n this is probably not needed.\n\n Delete the file, or disable this check.\n `.trimStart(),\n ]\n }\n return []\n}\n\nexport async function validateStudioConfig({basePath}: {basePath: string}): Promise<string[]> {\n const suffixes = ['ts', 'js', 'tsx', 'jsx']\n\n const filenames = filesWithSuffixes(['sanity.config', 'sanity.cli'], suffixes)\n\n const files: Record<string, boolean | undefined> = {}\n\n for (const filename of filenames) {\n const filepath = path.normalize(path.join(basePath, filename))\n files[filename] = await fileExists(filepath)\n }\n\n const sanityJson = await readJson5File<SanityStudioJson>({basePath, filename: 'sanity.json'})\n\n const hasConfigFile = (fileBase: string) =>\n filesWithSuffixes([fileBase], suffixes).some((filename) => files[filename])\n const hasCliConfig = hasConfigFile('sanity.cli')\n const hasStudioConfig = hasConfigFile('sanity.config')\n\n const errors: string[] = []\n\n if (sanityJson) {\n const info = [\n outdent`\n Found sanity.json. This file is not used by Sanity Studio V3.\n\n Please consult the Studio V3 migration guide:\n ${urls.migrationGuideStudio}\n It will detail how to convert sanity.json to sanity.config.ts (or .js) and sanity.cli.ts (or .js) equivalents.\n `.trimStart(),\n sanityJson.plugins?.length &&\n outdent`\n For V3 versions and alternatives to V2 plugins, please refer to the Sanity Exchange:\n ${urls.sanityExchange}\n `.trimStart(),\n ].filter((s): s is string => !!s)\n\n errors.push(info.join('\\n\\n'))\n }\n\n if (!hasCliConfig) {\n errors.push(\n outdent`\n sanity.cli.(${suffixes.join(\n ' | ',\n )}) missing. Please create a file named sanity.cli.ts with the following content:\n\n ${chalk.green(\n outdent`\n import {createCliConfig} from 'sanity/cli'\n\n export default createCliConfig({\n api: {\n projectId: '${sanityJson?.api?.projectId ?? 'project-id'}',\n dataset: '${sanityJson?.api?.dataset ?? 'dataset'}',\n }\n })`,\n )}\n\n Make sure to replace the projectId and dataset fields with your own.\n\n For more, see ${urls.migrationGuideStudio}\n `.trimStart(),\n )\n }\n\n if (!hasStudioConfig) {\n errors.push(\n outdent`\n sanity.config.(${suffixes.join(\n ' | ',\n )}) missing. At a minimum sanity.config.ts should contain:\n\n ${chalk\n .green(\n outdent`\n import { defineConfig } from \"sanity\"\n import { deskTool } from \"sanity/desk\"\n\n export default defineConfig({\n name: \"default\",\n\n projectId: '${sanityJson?.api?.projectId ?? 'project-id'}',\n dataset: '${sanityJson?.api?.dataset ?? 'dataset'}',\n\n plugins: [\n deskTool(),\n ],\n\n schema: {\n types: [\n /* put your v2 schema-types here */\n ],\n },\n })`,\n )\n .trimStart()}\n\n Make sure to replace the projectId and dataset fields with your own.\n\n For more, see ${urls.migrationGuideStudio}\n `.trimStart(),\n )\n }\n\n return errors.length ? [errors.join(`\\n\\n---\\n\\n`)] : []\n}\n\n/**\n * Detects leftover usage of the legacy `@sanity/incompatible-plugin` shim and asks for its removal.\n *\n * The shim (a `sanity.json` + `v2-incompatible.js` entry point, plus the `@sanity/incompatible-plugin`\n * dependency) only rendered an error dialog in the long end-of-life Sanity Studio v2 when a v3 plugin\n * was installed there. plugin-kit no longer scaffolds it, so a plugin should not ship it anymore.\n */\nexport async function validateIncompatiblePlugin({\n basePath,\n packageJson,\n}: {\n basePath: string\n packageJson: PackageJson\n}): Promise<string[]> {\n const {dependencies, devDependencies, peerDependencies} = packageJson\n const inDependencies = !!(\n dependencies?.[incompatiblePluginPackage] ||\n devDependencies?.[incompatiblePluginPackage] ||\n peerDependencies?.[incompatiblePluginPackage]\n )\n\n const hasShimFile = await fileExists(path.normalize(path.join(basePath, 'v2-incompatible.js')))\n\n const sanityJson = await readJson5File<SanityV2Json>({basePath, filename: 'sanity.json'})\n const sanityJsonReferencesShim = !!sanityJson?.parts?.some((part) =>\n part?.path?.includes('v2-incompatible'),\n )\n\n if (!inDependencies && !hasShimFile && !sanityJsonReferencesShim) {\n return []\n }\n\n const found = [\n inDependencies ? `- \"${incompatiblePluginPackage}\" listed in package.json` : null,\n hasShimFile ? '- the v2-incompatible.js file' : null,\n sanityJsonReferencesShim ? '- a sanity.json referencing v2-incompatible.js' : null,\n ].filter((e): e is string => !!e)\n\n return [\n outdent`\n ${incompatiblePluginPackage} is no longer used and should be removed.\n\n It only rendered an error dialog in the long end-of-life Sanity Studio v2 when a v3 plugin was\n installed there. That compatibility shim is now obsolete, so plugin-kit no longer adds it.\n\n Found:\n ${found.join('\\n')}\n\n To fix this:\n - Remove \"${incompatiblePluginPackage}\" from package.json (dependencies/devDependencies/peerDependencies)\n - Delete the v2-incompatible.js file\n - Delete sanity.json (if it only contains the v2-incompatible \"part\")\n - Remove \"sanity.json\" and \"v2-incompatible.js\" from the package.json \"files\" array\n\n For more, see ${urls.incompatiblePlugin}\n `.trimStart(),\n ]\n}\n\nexport function validatePackageName(packageJson: PackageJson) {\n const valid = validateNpmPackageName(packageJson.name ?? '')\n if (!valid.validForNewPackages) {\n const messages = valid.errors ?? valid.warnings ?? []\n return [`Invalid package.json: \"name\" is invalid: ${messages.join(', ')}`]\n }\n\n const isScoped = packageJson.name?.startsWith('@')\n if (!isScoped && !packageJson.name?.startsWith('sanity-plugin-')) {\n return [\n `Invalid package.json: \"name\" should be prefixed with \"sanity-plugin-\" (or scoped - @your-company/plugin-name)`,\n ]\n }\n return []\n}\n\n/**\n * Plugins built with @sanity/plugin-kit publish the compiled output (the `dist` directory) plus any\n * v2-compatibility files. The `src` directory should not be published: it bloats the package and can\n * cause bundlers that resolve the `source` export condition to pull in raw, uncompiled TypeScript.\n */\nexport function validateBannedFiles(packageJson: PackageJson): string[] {\n const {files} = packageJson\n if (!Array.isArray(files)) {\n return []\n }\n\n const hasSrc = files.some((entry) => {\n if (typeof entry !== 'string') {\n return false\n }\n // Normalize entries like \"./src\", \"src/\", \"/src\" before comparing.\n const normalized = entry\n .trim()\n .replace(/^\\.?\\/+/, '')\n .replace(/\\/+$/, '')\n return normalized === 'src'\n })\n\n if (!hasSrc) {\n return []\n }\n\n return [\n outdent`\n package.json \"files\" must not include \"src\".\n\n Plugins built with @sanity/plugin-kit publish the compiled output in \"dist\" (and any v2-compatibility files).\n Shipping the \"src\" directory bloats the published package and can cause bundlers that resolve the\n \"source\" export condition to import raw, uncompiled TypeScript.\n\n Please remove \"src\" from the \"files\" array in package.json.\n `.trimStart(),\n ]\n}\n\nexport async function validateSrcIndexFile(basePath: string) {\n const paths = ['index.js', 'index.ts'].map((p) => path.join('src', p))\n const allowedIndexFiles = paths.map((file) => path.join(basePath, file))\n\n let hasIndex = false\n for (const indexFile of allowedIndexFiles) {\n hasIndex = hasIndex || (await fileExists(indexFile))\n }\n if (!hasIndex) {\n return [\n outdent`\n Expected one of [${paths.join(', ')}] to exist.\n\n @sanity/pkg-utils expects a non-jsx file to be the source entry-point for the plugin.\n If you currently have JSX in your index file, extract it into a separate file and import it.\n `,\n ]\n }\n\n return []\n}\n\nasync function disallowDuplicateConfig({\n basePath,\n pkgJson,\n configKey,\n files,\n}: {\n basePath: string\n pkgJson: PackageJson\n configKey: string\n files: string[]\n}) {\n const found: string[] = []\n for (const file of files) {\n const filePath = path.join(basePath, file)\n const exits = await fileExists(filePath)\n if (exits) {\n found.push(file)\n }\n }\n if (found.length > 1) {\n return [\n outdent`\n Found multiple config files that serve the same purpose: [${found.join(', ')}].\n\n There should be at most one of these files. Delete the rest.\n `,\n ]\n }\n if (found.length && pkgJson[configKey]) {\n return [\n outdent`\n package.json contains ${configKey}, but there also exists a config file that serves the same purpose.\n Config file: ${found.join('')}]\n\n Either delete the file or remove ${configKey} entry from package.json.\n `,\n ]\n }\n\n return []\n}\n\nexport async function disallowDuplicateEslintConfig(basePath: string, pkgJson: PackageJson) {\n return disallowDuplicateConfig({\n basePath,\n pkgJson,\n configKey: 'eslint',\n files: [\n '.eslintrc',\n '.eslintrc.js',\n '.eslintrc.cjs',\n '.eslintrc.yaml',\n '.eslintrc.yml',\n '.eslintrc.json',\n ],\n })\n}\n\nexport async function disallowDuplicatePrettierConfig(basePath: string, pkgJson: PackageJson) {\n return disallowDuplicateConfig({\n basePath,\n pkgJson,\n configKey: 'prettier',\n files: [\n '.prettierrc',\n '.prettierrc.json5',\n '.prettierrc.json',\n '.prettierrc.yaml',\n '.prettierrc.yml',\n '.prettierrc.js',\n '.prettierrc.cjs',\n '.prettier.config,js',\n '.prettier.config.cjs',\n '.prettierrc.toml',\n ],\n })\n}\n","export const forcedPackageVersions = {}\n\nexport const forcedDevPackageVersions = {}\n\nexport const forcedPeerPackageVersions = {\n 'react': '^18',\n 'react-dom': '^18',\n '@types/react': '^18',\n '@types/react-dom': '^18',\n 'sanity': '^5 || ^6.0.0-0',\n 'styled-components': '^5.2',\n}\n","export function errorToUndefined(err: any) {\n if (err instanceof TypeError) {\n throw err\n }\n\n return undefined\n}\n","import fs from 'fs'\nimport path from 'path'\nimport util from 'util'\n\nimport pkg from '../../package.json'\nimport {buildExtensions} from '../configs/buildExtensions'\nimport {errorToUndefined} from '../util/errorToUndefined'\nimport {hasSourceFile, hasCompiledFile, readJsonFile, fileExists} from '../util/files'\n\nconst stat = util.promisify(fs.stat)\nconst readFile = util.promisify(fs.readFile)\n\nconst allowedPartProps = ['name', 'implements', 'path', 'description']\nconst disallowedPluginProps = ['api', 'project', 'plugins', 'env']\n\nexport interface SanityV2Manifest {\n root?: boolean\n name: string\n paths: ManifestPaths\n parts?: {\n path: string\n }[]\n}\n\nexport interface ManifestPaths {\n basePath: string\n compiled?: string\n source?: string\n}\n\nexport interface ManifestOptions {\n isPlugin?: boolean\n validate?: boolean\n pluginName?: string\n basePath: string\n verifySourceParts?: boolean\n verifyCompiledParts?: boolean\n paths?: ManifestPaths\n flags?: Record<string, any>\n}\n\nexport async function getPaths(options: ManifestOptions) {\n const {basePath} = options\n const manifest = await readManifest(options)\n if (!manifest.paths) {\n return null\n }\n\n return absolutifyPaths(manifest.paths, basePath)\n}\n\nfunction absolutifyPaths(paths: ManifestPaths | undefined, basePath: string) {\n const getPath = (relative?: string) =>\n relative ? path.resolve(path.join(basePath, relative)) : undefined\n return paths\n ? {\n basePath,\n compiled: getPath(paths.compiled),\n source: getPath(paths.source),\n }\n : {basePath}\n}\n\nasync function readManifest(options: ManifestOptions) {\n const {basePath, validate = true} = options\n const manifestPath = path.normalize(path.join(basePath, 'sanity.json'))\n\n let content\n try {\n content = await readFile(manifestPath, 'utf8')\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n throw new Error(\n `No sanity.json found. sanity.json is required for plugins to function. Use \\`${pkg.binname} init\\` for a new plugin, or create an empty \\`sanity.json\\` with an empty object (\\`{}\\`) for existing ones.`,\n )\n }\n\n throw new Error(`Failed to read \"${manifestPath}\": ${err.message}`)\n }\n\n let parsed\n try {\n parsed = JSON.parse(content)\n } catch (err: any) {\n throw new Error(`Error parsing \"${manifestPath}\": ${err.message}`)\n }\n\n if (validate) {\n await validateManifest(parsed, options)\n }\n\n return parsed\n}\n\nasync function validateManifest(manifest: SanityV2Manifest, opts: ManifestOptions) {\n const options = {isPlugin: true, ...opts}\n\n if (!isObject(manifest)) {\n throw new Error(`Invalid sanity.json: Root must be an object`)\n }\n\n if (options.isPlugin) {\n await validatePluginManifest(manifest, options)\n } else {\n validateProjectManifest(manifest)\n }\n\n if ('root' in manifest && typeof manifest.root !== 'boolean') {\n throw new Error(`Invalid sanity.json: \"root\" property must be a boolean if declared`)\n }\n\n await validateParts(manifest, {\n ...options,\n paths: absolutifyPaths(manifest.paths, options.basePath),\n })\n}\n\nfunction validateProjectManifest(manifest: SanityV2Manifest) {\n if ('paths' in manifest) {\n throw new Error(`Invalid sanity.json: \"paths\" property has no meaning in a project manifest`)\n }\n}\n\nasync function validatePluginManifest(manifest: SanityV2Manifest, options: {basePath: string}) {\n const disallowed = Object.keys(manifest)\n .filter((key) => disallowedPluginProps.includes(key))\n .map((key) => `\"${key}\"`)\n\n if (disallowed.length > 0) {\n const plural = disallowed.length > 1 ? 's' : ''\n const joined = disallowed.join(', ')\n throw new Error(\n `Invalid sanity.json: Key${plural} ${joined} ${\n plural ? 'are' : 'is'\n } not allowed in a plugin manifest`,\n )\n }\n\n if (manifest.root) {\n throw new Error(`Invalid sanity.json: \"root\" cannot be truthy in a plugin manifest`)\n }\n\n await validatePaths(manifest, options)\n}\n\nasync function validatePaths(manifest: SanityV2Manifest, options: {basePath: string}) {\n if (!('paths' in manifest)) {\n return\n }\n\n if (!isObject(manifest.paths)) {\n throw new Error(`Invalid sanity.json: \"paths\" must be an object if declared`)\n }\n\n if (typeof manifest.paths.compiled !== 'string') {\n throw new Error(\n `Invalid sanity.json: \"paths\" must have a (string) \"compiled\" property if declared`,\n )\n }\n\n if (typeof manifest.paths.source !== 'string') {\n throw new Error(\n `Invalid sanity.json: \"paths\" must have a (string) \"source\" property if declared`,\n )\n }\n\n const sourcePath = path.resolve(options.basePath, manifest.paths.source)\n let srcStats\n try {\n srcStats = await stat(sourcePath)\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n throw new Error(`sanity.json references \"source\" path which does not exist: \"${sourcePath}\"`)\n }\n }\n\n if (!srcStats?.isDirectory()) {\n throw new Error(\n `sanity.json references \"source\" path which is not a directory: \"${sourcePath}\"`,\n )\n }\n}\n\nasync function validateParts(manifest: SanityV2Manifest, options: ManifestOptions) {\n if (!('parts' in manifest)) {\n return\n }\n\n if (!Array.isArray(manifest.parts)) {\n throw new Error(`Invalid sanity.json: \"parts\" must be an array if declared`)\n }\n\n let i = 0\n for (const part of manifest.parts) {\n await validatePart(part, i, options)\n i++\n }\n}\n\nasync function validatePart(part: Record<string, any>, index: number, options: ManifestOptions) {\n if (!isObject(part)) {\n throw new Error(`Invalid sanity.json: \"parts[${index}]\" must be an object`)\n }\n\n validateAllowedPartKeys(part, index)\n validatePartStringValues(part, index)\n validatePartNames(part, index, options)\n await validatePartFiles(part, index, options)\n}\n\nasync function validatePartFiles(\n part: {path?: string} | undefined,\n index: number,\n options: ManifestOptions,\n) {\n const {verifyCompiledParts, verifySourceParts, paths} = options\n if (!part?.path) {\n return\n }\n\n const ext = path.extname(part.path)\n if (paths?.source && ext && ext !== '.js' && buildExtensions.includes(ext)) {\n throw new Error(\n `Invalid sanity.json: Part path has extension which is not applicable after compiling. ${ext} becomes .js after compiling. Specify filename without extension (${path.basename(\n part.path,\n )}) (parts[${index}])`,\n )\n }\n\n if (!verifySourceParts && !verifyCompiledParts) {\n return\n }\n\n const [srcExists, outDirExists] = await Promise.all([\n hasSourceFile(part.path, paths),\n verifyCompiledParts && hasCompiledFile(part.path, paths),\n ])\n\n if (!srcExists) {\n throw new Error(\n `Invalid sanity.json: Part path references file that does not exist in source directory (${\n paths?.source || paths?.basePath\n }) (parts[${index}])`,\n )\n }\n\n if (verifyCompiledParts && !outDirExists) {\n throw new Error(\n `Invalid sanity.json: Part path references file (\"${part.path}\") that does not exist in compiled directory (${paths?.compiled}) (parts[${index}])`,\n )\n }\n}\n\nfunction validatePartNames(\n part: {name?: string; implements?: string} | undefined,\n index: number,\n options: ManifestOptions,\n) {\n const pluginName = options.pluginName ? options.pluginName.replace(/^sanity-plugin-/, '') : ''\n if (!part?.name || !part?.name?.startsWith(`part:${pluginName}/`)) {\n throw new Error(\n `Invalid sanity.json: \"name\" must be prefixed with \"part:${pluginName}/\" - got \"${part?.name}\" (parts[${index}])`,\n )\n }\n\n if (!part?.implements?.startsWith('part:')) {\n throw new Error(\n `Invalid sanity.json: \"implements\" must be prefixed with \"part:\" - got \"${part?.implements}\" (parts[${index}])`,\n )\n }\n}\n\nfunction validateAllowedPartKeys(part: Record<string, any>, index: number) {\n const disallowed = Object.keys(part)\n .filter((key) => !allowedPartProps.includes(key))\n .map((key) => `\"${key}\"`)\n\n if (disallowed.length > 0) {\n const plural = disallowed.length > 1 ? 's' : ''\n const joined = disallowed.join(', ')\n throw new Error(\n `Invalid sanity.json: Key${plural} ${joined} ${\n plural ? 'are' : 'is'\n } not allowed in a part declaration (parts[${index}])`,\n )\n }\n}\n\nfunction validatePartStringValues(part: Record<string, any>, index: number) {\n const nonStrings = Object.keys(part)\n .filter((key) => typeof part[key] !== 'string')\n .map((key) => `\"${key}\"`)\n\n if (nonStrings.length > 0) {\n const plural = nonStrings.length > 1 ? 's' : ''\n const joined = nonStrings.join(', ')\n throw new Error(\n `Invalid sanity.json: Key${plural} ${joined} should be of type string (parts[${index}])`,\n )\n }\n}\n\nfunction isObject(obj: any) {\n return !Array.isArray(obj) && obj !== null && typeof obj === 'object'\n}\n\nexport async function hasSanityJson(basePath: string) {\n const file = await readJsonFile<{root?: boolean}>(path.join(basePath, 'sanity.json')).catch(\n errorToUndefined,\n )\n return {exists: Boolean(file), isRoot: Boolean(file && file.root)}\n}\n\nexport async function findStudioV3Config(basePath: string) {\n const jsFile = 'sanity.config.js'\n const jsExists = await fileExists(path.join(basePath, jsFile))\n if (jsExists) {\n return {v3ConfigFile: jsFile}\n }\n const tsFile = 'sanity.config.ts'\n const tsExists = await fileExists(path.join(basePath, tsFile))\n return {v3ConfigFile: tsExists ? tsFile : undefined}\n}\n","import {getLatestVersion} from 'get-latest-version'\nimport pProps from 'p-props'\n\n// We may want to lock certain dependencies to specific versions\nconst lockedDependencies: Record<string, string> = {\n 'styled-components': '^6.1',\n 'eslint': '^8.57.0',\n // The scaffolded ESLint toolchain (@typescript-eslint v8) requires the classic JS compiler API,\n // which TypeScript 7 (the Go-native compiler) no longer ships. Unlock once typescript-eslint\n // supports TypeScript 7.\n 'typescript': '^6',\n}\n\nexport function resolveLatestVersions(packages: string[]) {\n const versions: Record<string, string> = {}\n for (const pkgName of packages) {\n versions[pkgName] = pkgName in lockedDependencies ? lockedDependencies[pkgName] : 'latest'\n }\n\n return pProps(\n versions,\n async (range, pkgName) => {\n const version = await getLatestVersion(pkgName, {range})\n if (!version) {\n throw new Error(`Found no version for ${pkgName}`)\n }\n return rangeify(version)\n },\n {concurrency: 8},\n )\n}\n\nfunction rangeify(version: string) {\n return `^${version}`\n}\n","import fs from 'fs'\nimport path from 'path'\nimport util from 'util'\n\nimport githubUrl from 'github-url-to-object'\nimport validateNpmPackageName from 'validate-npm-package-name'\n\nimport type {InjectOptions, PackageData} from '../actions/inject'\nimport type {PackageJson} from '../actions/verify/types'\nimport {expectedScripts} from '../actions/verify/validations'\nimport {\n forcedDevPackageVersions,\n forcedPackageVersions,\n forcedPeerPackageVersions,\n} from '../configs/forced-package-versions'\nimport {cliName, requiredNodeEngine} from '../constants'\nimport {getPaths, type ManifestOptions} from '../sanity/manifest'\nimport {hasSourceEquivalent, writeJsonFile} from '../util/files'\nimport log from '../util/log'\nimport {resolveLatestVersions} from './resolveLatestVersions'\n\n// New plugins ship no runtime dependencies by default. The legacy `@sanity/incompatible-plugin`\n// shim (for Sanity Studio v2) is intentionally no longer added.\nconst defaultDependencies: string[] = []\n\nconst defaultDevDependencies = [\n 'sanity',\n\n // peer dependencies of `sanity`\n 'react',\n 'react-dom',\n 'styled-components',\n]\n\nconst defaultPeerDependencies = ['react', 'sanity']\n\nconst readFile = util.promisify(fs.readFile)\n\nconst pathKeys: (keyof PackageJson)[] = ['main', 'module', 'browser', 'types']\n\nexport async function getPackage(opts: ManifestOptions): Promise<PackageJson> {\n const options = {flags: {}, ...opts}\n\n validateOptions(options)\n\n const {basePath, validate = true} = options\n const manifestPath = path.normalize(path.join(basePath, 'package.json'))\n\n let content\n try {\n content = await readFile(manifestPath, 'utf8')\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n throw new Error(\n `No package.json found. package.json is required to publish to npm. Use \\`${cliName} init\\` for a new plugin, or \\`npm init\\` for an existing one`,\n )\n }\n\n throw new Error(`Failed to read \"${manifestPath}\": ${err.message}`)\n }\n\n let parsed\n try {\n parsed = JSON.parse(content)\n } catch (err: any) {\n throw new Error(`Error parsing \"${manifestPath}\": ${err.message}`)\n }\n\n if (!isObject(parsed)) {\n throw new Error(`Invalid package.json: Root must be an object`)\n }\n\n if (validate) {\n await validatePackage(parsed, options)\n }\n\n return parsed\n}\n\nasync function validatePackage(manifest: PackageJson, opts: ManifestOptions) {\n validateOptions(opts)\n\n const options = {isPlugin: true, ...opts}\n\n if (options.isPlugin) {\n await validatePluginPackage(manifest, options)\n }\n\n validateLockFiles(options)\n}\n\nfunction validateOptions(opts: {basePath: string}) {\n const options = opts || {}\n if (!isObject(options)) {\n throw new Error(`Options must be an object`)\n }\n\n if (typeof options.basePath !== 'string') {\n throw new Error(`\"options.basePath\" must be a string (path to plugin base path)`)\n }\n}\n\nasync function validatePluginPackage(manifest: PackageJson, options: ManifestOptions) {\n validatePackageName(manifest)\n await validatePaths(manifest, options)\n}\n\nfunction validatePackageName(manifest: PackageJson) {\n if (typeof manifest.name !== 'string') {\n throw new Error(`Invalid package.json: \"name\" must be a string`)\n }\n\n const valid = validateNpmPackageName(manifest.name)\n if (!valid.validForNewPackages) {\n throw new Error(`Invalid package.json: \"name\" is invalid: ${(valid.errors ?? []).join(', ')}`)\n }\n\n const isScoped = manifest.name[0] === '@'\n if (!isScoped && !manifest.name.startsWith('sanity-plugin-')) {\n throw new Error(\n `Invalid package.json: \"name\" should be prefixed with \"sanity-plugin-\" (or scoped - @your-company/plugin-name)`,\n )\n }\n}\n\nasync function validatePaths(manifest: PackageJson, options: ManifestOptions) {\n const paths = await getPaths({\n ...options,\n pluginName: manifest.name ?? 'unknown',\n verifySourceParts: false,\n verifyCompiledParts: false,\n })\n\n const abs = (file: string) =>\n path.isAbsolute(file) ? file : path.resolve(path.join(options.basePath, file))\n\n const exists = (file: string) => fs.existsSync(abs(file))\n const willExist = (file: string) => paths && hasSourceEquivalent(abs(file), paths)\n const withinSourceDir = (file: string) => paths?.source && abs(file).startsWith(paths.source)\n const withinTargetDir = (file: string) => paths?.compiled && abs(file).startsWith(paths.compiled)\n\n for (const key of pathKeys) {\n if (!(key in manifest)) {\n continue\n }\n\n const manifestValue = manifest[key]\n if (typeof manifestValue !== 'string') {\n throw new Error(`Invalid package.json: \"${key}\" must be a string if defined`)\n }\n\n // We don't want to reference `./src/MyComponent.js` containing a bunch of JSX and whatnot,\n // instead we want to target `./dist/MyComponent.js` which is the location it'll be compiled to\n if (!options?.flags?.allowSourceTarget && paths && withinSourceDir(manifestValue)) {\n throw new Error(\n `Invalid package.json: \"${key}\" points to file within source (uncompiled) directory. Use --allow-source-target if you really want to do this.`,\n )\n }\n\n // Does it exist only because it was there prior to compilation?\n // We're clearing the folder on compilation, so we shouldn't allow it\n const fileExists = exists(manifestValue)\n if (\n fileExists &&\n paths &&\n withinTargetDir(manifestValue) &&\n !(await willExist(manifestValue))\n ) {\n throw new Error(\n `Invalid package.json: \"${key}\" points to file that will not exist after compiling`,\n )\n }\n\n // If it _doesn't_ exist and it _won't_ exist, then there isn't much point in continuing, is there?\n if (!exists(manifestValue) && !(await willExist(manifestValue))) {\n if (!paths) {\n throw new Error(`Invalid package.json: \"${key}\" points to file that does not exist`)\n }\n\n const inOutDir = paths.compiled && !abs(manifestValue).startsWith(paths.compiled)\n throw new Error(\n inOutDir\n ? `Invalid package.json: \"${key}\" points to file that does not exist, and \"paths\" is not configured to compile to this location`\n : `Invalid package.json: \"${key}\" points to file that does not exist, and no equivalent is found in source directory`,\n )\n }\n }\n}\n\nfunction isObject(obj: unknown): obj is Record<string, unknown> {\n return !Array.isArray(obj) && obj !== null && typeof obj === 'object'\n}\n\nfunction validateLockFiles(options: {basePath: string}) {\n const npm = fs.existsSync(path.join(options.basePath, 'package-lock.json'))\n const yarn = fs.existsSync(path.join(options.basePath, 'yarn.lock'))\n if (npm && yarn) {\n throw new Error(`Invalid plugin: contains both package-lock.json and yarn.lock`)\n }\n}\n\nexport async function writePackageJson(data: PackageData, options: InjectOptions) {\n const {user, pluginName, license, description, pkg: prevPkg, gitOrigin} = data\n const {\n outDir,\n peerDependencies: addPeers,\n dependencies: addDeps,\n devDependencies: addDevDeps,\n } = options\n const {flags} = options\n const prev = prevPkg || {}\n\n const usePrettier = flags.prettier !== false\n const useEslint = flags.eslint !== false\n const useTypescript = flags.eslint !== false\n\n const newDevDependencies = [cliName, '@sanity/pkg-utils']\n\n if (useTypescript) {\n log.debug('Using TypeScript. Adding to dev dependencies.')\n newDevDependencies.push('@types/react', 'typescript')\n }\n\n if (usePrettier) {\n log.debug('Using prettier. Adding to dev dependencies.')\n newDevDependencies.push('prettier', 'prettier-plugin-packagejson')\n }\n\n if (useEslint) {\n log.debug('Using eslint. Adding to dev dependencies.')\n\n newDevDependencies.push(\n 'eslint',\n 'eslint-config-sanity',\n 'eslint-plugin-react',\n 'eslint-plugin-react-hooks',\n )\n\n if (usePrettier) {\n newDevDependencies.push('eslint-config-prettier', 'eslint-plugin-prettier')\n }\n\n if (useTypescript) {\n newDevDependencies.push('@typescript-eslint/eslint-plugin', '@typescript-eslint/parser')\n }\n }\n\n log.debug('Resolving latest versions for %s', newDevDependencies.join(', '))\n const dependencies = forceDependencyVersions(\n {\n ...(prev.dependencies || {}),\n ...(addDeps || {}),\n ...(await resolveLatestVersions(defaultDependencies)),\n },\n forcedPackageVersions,\n )\n const devDependencies = forceDependencyVersions(\n {\n ...(addDevDeps || {}),\n ...(prev.devDependencies || {}),\n ...(await resolveLatestVersions([...newDevDependencies, ...defaultDevDependencies])),\n },\n forcedDevPackageVersions,\n )\n const peerDependencies = forceDependencyVersions(\n {\n ...(prev.peerDependencies || {}),\n ...(addPeers || {}),\n ...(await resolveLatestVersions(defaultPeerDependencies)),\n },\n forcedPeerPackageVersions,\n )\n\n const source = flags.typescript ? './src/index.ts' : './src/index.js'\n\n const files = [outDir]\n\n // sort alphabetically for scanability\n files.sort()\n\n // order should be compatible with prettier-plugin-packagejson\n const forcedOrder = {\n name: pluginName,\n version: prev.version ?? '1.0.0',\n description: description || '',\n keywords: prev.keywords ?? ['sanity', 'sanity-plugin'],\n ...urlsFromOrigin(gitOrigin),\n ...repoFromOrigin(gitOrigin),\n license: license ? license.id : 'UNLICENSED',\n author: user?.email ? `${user.name} <${user.email}>` : user?.name,\n sideEffects: false,\n type: 'module',\n exports: {\n '.': {\n source,\n default: `./${outDir}/index.js`,\n },\n './package.json': './package.json',\n },\n ...(flags.typescript ? {types: `./${outDir}/index.d.ts`} : {}),\n files,\n scripts: {...prev.scripts},\n dependencies: sortKeys(dependencies),\n devDependencies: sortKeys(devDependencies),\n peerDependencies: sortKeys(peerDependencies),\n engines: {\n node: requiredNodeEngine,\n },\n }\n\n const manifest: PackageJson = {\n ...forcedOrder,\n // Use already configured values by default (if not otherwise specified)\n ...(prev || {}),\n // We're de-declaring properties because of key order in package.json\n ...forcedOrder,\n }\n\n const differs = JSON.stringify(prev) !== JSON.stringify(manifest)\n log.debug('Does manifest differ? %s', differs ? 'yes' : 'no')\n if (differs) {\n await writePackageJsonDirect(manifest, options)\n }\n\n return differs ? manifest : prev\n}\n\nfunction urlsFromOrigin(gitOrigin?: string): {bugs?: {url: string}; homepage?: string} {\n if (!gitOrigin) {\n return {}\n }\n\n const details = githubUrl(gitOrigin)\n if (!details) {\n return {}\n }\n\n return {\n homepage: `https://github.com/${details.user}/${details.repo}#readme`,\n bugs: {\n url: `https://github.com/${details.user}/${details.repo}/issues`,\n },\n }\n}\n\nfunction repoFromOrigin(gitOrigin?: string) {\n if (!gitOrigin) {\n return {}\n }\n\n return {\n repository: {\n type: 'git',\n url: gitOrigin,\n },\n }\n}\n\nexport function addScript(cmd: string, existing: string) {\n if (existing && existing.includes(cmd)) {\n return existing\n }\n\n return cmd\n}\n\nexport async function addPackageJsonScripts(\n manifest: PackageJson,\n options: InjectOptions,\n updateScripts: (currentScripts: Record<string, string>) => Record<string, string>,\n) {\n const originalScripts = manifest.scripts || {}\n const scripts = updateScripts({...originalScripts})\n\n const differs = Object.keys(scripts).some((key) => scripts[key] !== originalScripts[key])\n\n if (differs) {\n await writePackageJsonDirect({...manifest, scripts}, options)\n }\n\n return differs\n}\n\nexport async function writePackageJsonDirect(manifest: PackageJson, {basePath}: InjectOptions) {\n await writeJsonFile(path.join(basePath, 'package.json'), manifest)\n}\n\nexport async function addBuildScripts(manifest: PackageJson, options: InjectOptions) {\n if (!options.flags.scripts) {\n return false\n }\n return addPackageJsonScripts(manifest, options, (scripts) => {\n scripts.build = addScript(expectedScripts.build, scripts.build)\n scripts.format = addScript(`prettier --write --cache --ignore-unknown .`, scripts.format)\n scripts['link-watch'] = addScript(expectedScripts['link-watch'], scripts['link-watch'])\n scripts.lint = addScript(`eslint .`, scripts.lint)\n scripts.prepublishOnly = addScript(expectedScripts.prepublishOnly, scripts.prepublishOnly)\n scripts.watch = addScript(expectedScripts.watch, scripts.watch)\n return scripts\n })\n}\n\nexport function sortKeys<T extends Record<string, unknown>>(unordered: T): T {\n return Object.keys(unordered)\n .sort()\n .reduce((obj, key) => {\n // @ts-expect-error this WILL work\n obj[key] = unordered[key]\n return obj\n }, {} as T)\n}\n\n/** @internal */\nexport function forceDependencyVersions(\n deps: Record<string, string>,\n versions = forcedPackageVersions,\n): Record<string, string> {\n const entries = Object.entries(deps).map((entry) => {\n const [pkg] = entry\n const forceVersion = versions[pkg as keyof typeof versions]\n if (forceVersion) {\n return [pkg, forceVersion]\n }\n return entry\n })\n return Object.fromEntries(entries)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAC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