@sanity/plugin-kit 8.0.1 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +8 -63
  2. package/dist/constants-BIVJp2Jy.js +7 -0
  3. package/dist/constants-BIVJp2Jy.js.map +1 -0
  4. package/dist/index.js +9 -16
  5. package/dist/index.js.map +1 -1
  6. package/dist/{init-Du_rQVkw.js → init-Bfn8LX_B.js} +6 -8
  7. package/dist/init-Bfn8LX_B.js.map +1 -0
  8. package/dist/{inject-_X7Is81B.js → inject-B5Mh7aAX.js} +5 -6
  9. package/dist/inject-B5Mh7aAX.js.map +1 -0
  10. package/dist/{link-watch-L1kA3AR0.js → link-watch-DOvzqtol.js} +4 -4
  11. package/dist/{link-watch-L1kA3AR0.js.map → link-watch-DOvzqtol.js.map} +1 -1
  12. package/dist/oxlint.js +8 -0
  13. package/dist/oxlint.js.map +1 -1
  14. package/dist/{package-B_o7MhuL.js → package-Cx3OyOx-.js} +20 -380
  15. package/dist/package-Cx3OyOx-.js.map +1 -0
  16. package/dist/package-D-XjdNv2.js +4 -0
  17. package/dist/package-D-XjdNv2.js.map +1 -0
  18. package/dist/{init-pYTOs-Fv.js → studio-detect-CnuSQGN_.js} +24 -7
  19. package/dist/studio-detect-CnuSQGN_.js.map +1 -0
  20. package/dist/{verify-package-Dala-0lE.js → verify-package-fNlJK-qr.js} +41 -14
  21. package/dist/verify-package-fNlJK-qr.js.map +1 -0
  22. package/dist/{version-COtAw8Ls.js → version-2T4tSyv6.js} +2 -2
  23. package/dist/{version-COtAw8Ls.js.map → version-2T4tSyv6.js.map} +1 -1
  24. package/package.json +6 -8
  25. package/dist/constants-BLTUL_Wd.js +0 -11
  26. package/dist/constants-BLTUL_Wd.js.map +0 -1
  27. package/dist/init-Du_rQVkw.js.map +0 -1
  28. package/dist/init-pYTOs-Fv.js.map +0 -1
  29. package/dist/inject-_X7Is81B.js.map +0 -1
  30. package/dist/package-B_o7MhuL.js.map +0 -1
  31. package/dist/package-CXmMmZoh.js +0 -4
  32. package/dist/package-CXmMmZoh.js.map +0 -1
  33. package/dist/verify-common-CzG3zw3J.js +0 -39
  34. package/dist/verify-common-CzG3zw3J.js.map +0 -1
  35. package/dist/verify-package-Dala-0lE.js.map +0 -1
  36. package/dist/verify-studio-Cg8aSAky.js +0 -61
  37. package/dist/verify-studio-Cg8aSAky.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"init-pYTOs-Fv.js","names":["applyPreset","pkg.name","pkg.version","isValidEmail","applyPreset","log","addDevDependencies","log","sharedFlags"],"sources":["../src/configs/default-source.ts","../src/configs/git.ts","../src/configs/oxfmt.ts","../src/configs/oxlint.ts","../src/configs/pkg-config.ts","../src/configs/tsconfig.ts","../src/presets/renovatebot.ts","../src/util/readme.ts","../src/util/request.ts","../src/util/user.ts","../src/presets/semver-workflow.ts","../src/presets/ui.ts","../src/presets/presets.ts","../src/actions/inject.ts","../src/actions/init.ts"],"sourcesContent":["import outdent from 'outdent'\n\nimport type {PackageJson} from '../actions/verify/types'\n\nexport function defaultSourceJs(pkg: PackageJson) {\n return (\n outdent`\n import {definePlugin} from 'sanity'\n\n /**\n * Usage in sanity.config.js (or .ts)\n *\n * \\`\\`\\`js\n * import {defineConfig} from 'sanity'\n * import {myPlugin} from '${pkg.name}'\n *\n * export default defineConfig({\n * // ...\n * plugins: [myPlugin({})],\n * })\n * \\`\\`\\`\n *\n * @public\n */\n export const myPlugin = definePlugin((_config = {}) => {\n // oxlint-disable-next-line no-console\n console.log(\\`hello from ${pkg.name}\\`)\n return {\n name: '${pkg.name}',\n }\n })\n`.trimStart() + '\\n'\n )\n}\n\nexport function defaultSourceTs(pkg: PackageJson) {\n return (\n outdent`\n import {definePlugin} from 'sanity'\n\n interface MyPluginConfig {\n /* nothing here yet */\n }\n\n /**\n * Usage in \\`sanity.config.ts\\` (or .js)\n *\n * \\`\\`\\`ts\n * import {defineConfig} from 'sanity'\n * import {myPlugin} from '${pkg.name}'\n *\n * export default defineConfig({\n * // ...\n * plugins: [myPlugin()],\n * })\n * \\`\\`\\`\n *\n * @public\n */\n export const myPlugin = definePlugin<MyPluginConfig | void>((_config = {}) => {\n // oxlint-disable-next-line no-console\n console.log('hello from ${pkg.name}')\n return {\n name: '${pkg.name}',\n }\n })\n`.trimStart() + '\\n'\n )\n}\n","import {outdent} from 'outdent'\n\nimport type {InjectTemplate} from '../actions/inject'\n\nexport function gitignoreTemplate(): InjectTemplate {\n return {\n type: 'template',\n to: '.gitignore',\n value: outdent`\n # Logs\n logs\n *.log\n npm-debug.log*\n\n # Runtime data\n pids\n *.pid\n *.seed\n\n # Directory for instrumented libs generated by jscoverage/JSCover\n lib-cov\n\n # Coverage directory used by tools like istanbul\n coverage\n\n # nyc test coverage\n .nyc_output\n\n # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)\n .grunt\n\n # node-waf configuration\n .lock-wscript\n\n # Compiled binary addons (http://nodejs.org/api/addons.html)\n build/Release\n\n # Dependency directories\n node_modules\n jspm_packages\n\n # Optional npm cache directory\n .npm\n\n # Optional REPL history\n .node_repl_history\n\n # macOS finder cache file\n .DS_Store\n\n # VS Code settings\n .vscode\n\n # IntelliJ\n .idea\n *.iml\n\n # Cache\n .cache\n\n # Yalc\n .yalc\n yalc.lock\n\n # npm package zips\n *.tgz\n `,\n }\n}\n","import type {InitFlags} from '../actions/init'\nimport type {InjectTemplate} from '../actions/inject'\n\nexport function oxfmtConfigTemplate(options: {flags: InitFlags}): InjectTemplate {\n const {flags} = options\n\n return {\n type: 'template',\n force: flags.force,\n to: 'oxfmt.config.ts',\n value: `export {default} from '@sanity/plugin-kit/oxfmt'`,\n }\n}\n","import type {InitFlags} from '../actions/init'\nimport type {InjectTemplate} from '../actions/inject'\n\nexport function oxlintConfigTemplate(options: {flags: InitFlags}): InjectTemplate {\n const {flags} = options\n\n return {\n type: 'template',\n force: flags.force,\n to: 'oxlint.config.ts',\n value: `export {default} from '@sanity/plugin-kit/oxlint'`,\n }\n}\n","import {outdent} from 'outdent'\n\nimport type {InitFlags} from '../actions/init'\nimport type {InjectTemplate} from '../actions/inject'\n\nexport function pkgConfigTemplate(options: {outDir: string; flags: InitFlags}): InjectTemplate {\n const {flags, outDir} = options\n\n return {\n type: 'template',\n force: flags.force,\n // Always a `.ts` config: plugins are ESM (`\"type\": \"module\"`), so `@sanity/pkg-utils`\n // loads it without needing a `.mts`/`.mjs` extension to force ESM interpretation.\n to: 'package.config.ts',\n value: outdent`\n import {defineConfig} from '@sanity/pkg-utils'\n\n export default defineConfig({\n dist: '${outDir}',\n tsconfig: 'tsconfig.${outDir}.json',\n\n // Remove this block to enable strict export validation\n extract: {\n rules: {\n 'ae-incompatible-release-tags': 'off',\n 'ae-internal-missing-underscore': 'off',\n 'ae-missing-release-tag': 'off',\n },\n },\n })\n `,\n }\n}\n","import {outdent} from 'outdent'\n\nimport type {InitFlags} from '../actions/init'\nimport type {InjectTemplate} from '../actions/inject'\n\nexport function tsconfigTemplate(options: {flags: InitFlags}): InjectTemplate {\n const {flags} = options\n\n return {\n type: 'template',\n force: flags.force,\n to: 'tsconfig.json',\n value: outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./src\", \"./package.config.ts\"]\n }\n `,\n }\n}\n\nexport function tsconfigTemplateDist(options: {outDir: string; flags: InitFlags}): InjectTemplate {\n const {flags, outDir} = options\n\n return {\n type: 'template',\n force: flags.force,\n to: `tsconfig.${outDir}.json`,\n value: outdent`\n {\n \"extends\": \"./tsconfig.settings\",\n \"include\": [\"./src\"],\n \"exclude\": [\n \"./src/**/__fixtures__\",\n \"./src/**/__mocks__\",\n \"./src/**/*.test.ts\",\n \"./src/**/*.test.tsx\"\n ]\n }\n `,\n }\n}\n\nexport function tsconfigTemplateSettings(options: {\n outDir: string\n flags: InitFlags\n}): InjectTemplate {\n const {flags, outDir} = options\n\n return {\n type: 'template',\n force: flags.force,\n to: `tsconfig.settings.json`,\n value: outdent`\n {\n \"compilerOptions\": {\n \"rootDir\": \".\",\n \"outDir\": \"./${outDir}\",\n\n \"target\": \"esnext\",\n \"jsx\": \"preserve\",\n \"module\": \"preserve\",\n \"moduleResolution\": \"bundler\",\n \"esModuleInterop\": true,\n \"resolveJsonModule\": true,\n \"moduleDetection\": \"force\",\n \"strict\": true,\n \"allowSyntheticDefaultImports\": true,\n \"skipLibCheck\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"isolatedModules\": true,\n\n // Don't emit by default, pkg-utils will ignore this when generating .d.ts files\n \"noEmit\": true\n }\n }\n `,\n }\n}\n","import {type InjectOptions, writeAssets} from '../actions/inject'\nimport type {Preset} from './presets'\n\nexport const renovatePreset: Preset = {\n name: 'renovatebot',\n description: 'Files to enable renovatebot.',\n apply: applyPreset,\n}\n\nasync function applyPreset(options: InjectOptions) {\n await writeAssets(\n [\n {\n type: 'copy',\n from: ['renovatebot', 'renovate.json'],\n to: 'renovate.json',\n },\n ],\n options,\n )\n}\n","import licenses from '@rexxars/choosealicense-list'\nimport outdent from 'outdent'\n\nimport type {PackageData} from '../actions/inject'\nimport type {User} from './user'\n\nexport function generateReadme(data: PackageData) {\n const {user, pluginName, license} = data\n\n return (\n outdent`\n # ${pluginName}\n\n\n ${installationSnippet(pluginName ?? 'unknown')}\n\n ## Usage\n\n Add it as a plugin in \\`sanity.config.ts\\` (or .js):\n\n \\`\\`\\`ts\n import {defineConfig} from 'sanity'\n import {myPlugin} from '${pluginName}'\n\n export default defineConfig({\n //...\n plugins: [myPlugin({})],\n })\n \\`\\`\\`\n\n ${getLicenseText(license?.id, user?.name ? (user as User) : undefined)}\n ${developTestSnippet()}\n ` + '\\n'\n )\n}\n\nexport function installationSnippet(packageName: string) {\n return outdent`\n ## Installation\n\n \\`\\`\\`sh\n npm install ${packageName}\n \\`\\`\\`\n `\n}\n\nexport function developTestSnippet() {\n return outdent`\n ## Develop & test\n\n This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)\n with default configuration for build & watch scripts.\n\n See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)\n on how to run this plugin with hotreload in the studio.\n `\n}\n\nexport function getLicenseText(licenseId?: string, user?: User) {\n if (!licenseId) {\n return ''\n }\n\n const license = licenses.find(licenseId)\n let licenseName: string | undefined = license ? license.title : undefined\n licenseName = licenseName?.replace(/\\s+license$/i, '')\n\n let licenseText = '## License\\n'\n if (licenseName && user?.name) {\n licenseText = `${licenseText}\\n[${licenseName}](LICENSE) © ${user?.name}\\n`\n } else if (licenseName) {\n licenseText = `${licenseText}\\n[${licenseName}](LICENSE)\\n`\n } else {\n licenseText = `${licenseText}\\nSee [LICENSE](LICENSE)`\n }\n\n return licenseText\n}\n\nexport function isDefaultGitHubReadme(readme: string) {\n if (!readme) {\n return false\n }\n\n const lines = readme.split('\\n', 20).filter(Boolean)\n\n // title + _optional_ description\n return lines.length <= 2 && lines[0].startsWith('#')\n}\n","import {createRequester} from 'get-it'\n\nimport pkg from '../../package.json'\n\nexport const requester = createRequester({\n headers: {'User-Agent': `${pkg.name}@${pkg.version}`},\n as: 'json',\n})\n","import {execSync} from 'child_process'\nimport path from 'path'\n\nimport {validate as isValidEmail} from 'email-validator'\nimport xdgBasedir from 'xdg-basedir'\n\nimport type {InjectOptions} from '../actions/inject'\nimport type {PackageJson} from '../actions/verify/types'\nimport {readJsonFile} from './files'\nimport {prompt} from './prompt'\nimport {requester} from './request'\n\nexport interface User {\n name: string\n email?: string\n}\n\nexport async function getUserInfo(\n {requireUserConfirmation, flags}: InjectOptions,\n pkg?: PackageJson,\n): Promise<User | undefined> {\n const userInfo =\n getPackageUserInfo({author: flags.author ?? pkg?.author}) ||\n (await getSanityUserInfo()) ||\n (await getGitUserInfo())\n if (requireUserConfirmation) {\n return promptForInfo(userInfo)\n }\n\n return userInfo\n}\n\nfunction getPackageUserInfo(pkg?: {\n author?:\n | string\n | {\n name: string\n email?: string\n }\n}): User | undefined {\n let author = pkg?.author\n if (!author) {\n return undefined\n }\n\n if (author && typeof author !== 'string') {\n return author\n } else if (!author.includes('@')) {\n return {name: author}\n }\n\n const [pre, ...post] = author.replace(/[<>[\\]]/g, '').split(/@/)\n const nameParts = pre.split(/\\s+/)\n const email = [nameParts[nameParts.length - 1], ...post].join('@')\n const name = nameParts.slice(0, -1).join(' ')\n return {name, email}\n}\n\nasync function promptForInfo(defValue?: User) {\n const name = await prompt('Author name', {\n filter: filterString,\n default: defValue && defValue.name,\n validate: requiredString,\n })\n\n const email = await prompt('Author email', {\n filter: filterString,\n default: defValue && defValue.email,\n validate: validOrEmptyEmail,\n })\n\n return {name, email}\n}\n\nasync function getSanityUserInfo(): Promise<User | undefined> {\n try {\n const data = await readJsonFile<{authToken?: string}>(\n path.join(xdgBasedir.config ?? '', 'sanity', 'config.json'),\n )\n const token = data?.authToken\n\n if (!token) {\n return undefined\n }\n\n const {body: user} = await requester<User>({\n url: 'https://api.sanity.io/v1/users/me',\n as: 'json',\n headers: {Authorization: `Bearer ${token}`},\n })\n\n if (!user) {\n return undefined\n }\n\n const {name, email} = user\n return {name, email}\n } catch {\n return undefined\n }\n}\n\nasync function getGitUserInfo(): Promise<User | undefined> {\n try {\n const name = execSync('git config user.name', {encoding: 'utf8'}).trim()\n const email = execSync('git config user.email', {encoding: 'utf8'}).trim()\n\n if (!name) {\n return undefined\n }\n\n return {name, email: email || undefined}\n } catch {\n return undefined\n }\n}\n\nfunction filterString(val: string) {\n return (val || '').trim()\n}\n\nfunction requiredString(value: string) {\n return value.length > 1 ? true : 'Required'\n}\n\nfunction validOrEmptyEmail(value: string): true | string {\n if (!value) {\n return true\n }\n\n return isValidEmail(value) ? true : 'Must either be a valid email or empty'\n}\n","import path from 'path'\n\nimport chalk from 'chalk'\nimport outdent from 'outdent'\n\nimport {type Injectable, type InjectOptions, writeAssets} from '../actions/inject'\nimport type {PackageJson} from '../actions/verify/types'\nimport {\n addPackageJsonScripts,\n addScript,\n getPackage,\n sortKeys,\n writePackageJsonDirect,\n} from '../npm/package'\nimport {resolveLatestVersions} from '../npm/resolveLatestVersions'\nimport {errorToUndefined} from '../util/errorToUndefined'\nimport {readFile, writeFile} from '../util/files'\nimport log from '../util/log'\nimport {developTestSnippet, getLicenseText, installationSnippet} from '../util/readme'\nimport {getUserInfo} from '../util/user'\nimport type {Preset} from './presets'\n\nexport const semverWorkflowPreset: Preset = {\n name: 'semver-workflow',\n description:\n 'Files and dependencies for conventional-commits, github workflow and semantic-release.',\n apply: applyPreset,\n}\n\nconst info = (write: boolean, msg: string, ...args: string[]) => write && log.info(msg, ...args)\n\nasync function applyPreset(options: InjectOptions) {\n await writeAssets(semverWorkflowFiles(), options)\n await addPrepareScript(options)\n await addDevDependencies(options)\n await updateReadme(options)\n}\n\nasync function addPrepareScript(options: InjectOptions) {\n const pkg = await getPackage(options)\n const didWrite = await addPackageJsonScripts(pkg, options, (scripts) => {\n scripts.prepare = addScript(`husky`, scripts.prepare)\n return scripts\n })\n info(didWrite, 'Added prepare script to package.json')\n}\n\nasync function addDevDependencies(options: InjectOptions) {\n const pkg = await getPackage(options)\n const devDeps = sortKeys({\n ...pkg.devDependencies,\n ...(await semverWorkflowDependencies()),\n })\n const newPkg = {...pkg}\n newPkg.devDependencies = devDeps\n await writePackageJsonDirect(newPkg, options)\n log.info('Updated devDependencies.')\n\n log.info(\n chalk.green(\n outdent`\n semantic-release preset injected.\n\n Please confer\n https://github.com/sanity-io/plugin-kit/blob/main/docs/semver-workflow.md#manual-steps-after-inject\n to finalize configuration for this preset.\n `.trim(),\n ),\n )\n}\n\nasync function updateReadme(options: InjectOptions) {\n const {basePath} = options\n\n const readmePath = path.join(basePath, 'README.md')\n const readme = (await readFile(readmePath, 'utf8').catch(errorToUndefined)) ?? ''\n\n const {install, usage, developTest, license, releaseSnippet} = await readmeSnippets(options)\n\n const prependSections = missingSections(readme, [install, usage])\n const appendSections = missingSections(readme, [license, developTest, releaseSnippet])\n\n if (prependSections.length || appendSections.length) {\n const updatedReadme = [...prependSections, readme, ...appendSections]\n .filter(Boolean)\n .join('\\n\\n')\n await writeFile(readmePath, updatedReadme, {encoding: 'utf8'})\n log.info('Updated README. Please review the changes.')\n }\n}\n\nasync function readmeSnippets(options: InjectOptions) {\n const pkg = await getPackage(options)\n const user = await getUserInfo(options, pkg)\n\n const bestEffortUrl = readmeBaseurl(pkg)\n\n const install = installationSnippet(pkg.name ?? 'unknown')\n\n const usage = outdent`\n ## Usage\n `\n\n const license = getLicenseText(typeof pkg.license === 'string' ? pkg.license : undefined, user)\n\n const releaseSnippet = outdent`\n ### Release new version\n\n Run [\"CI & Release\" workflow](${bestEffortUrl}/actions/workflows/main.yml).\n Make sure to select the main branch and check \"Release new version\".\n\n Semantic release will only release on configured branches, so it is safe to run release on any branch.\n `\n\n return {\n install,\n usage,\n license,\n developTest: developTestSnippet(),\n releaseSnippet,\n }\n}\n\n/**\n * Returns sections that do not exist \"close enough\" in readme\n */\nexport function missingSections(readme: string, sections: string[]) {\n return sections.filter((section) => !closeEnough(section, readme))\n}\n\n/**\n * a and b are considered \"close enough\" if > 50% of a lines exist in b lines\n * @param a\n * @param b\n */\nfunction closeEnough(a: string, b: string) {\n const aLines = a.split('\\n')\n const bLines = b.split('\\n')\n\n const matchingLines = aLines.filter((line) => bLines.find((bLine) => bLine === line)).length\n const isCloseEnough = matchingLines >= aLines.length * 0.5\n return isCloseEnough\n}\n\nfunction semverWorkflowFiles(): Injectable[] {\n const base: Injectable[] = [\n {\n type: 'copy',\n from: ['.github', 'workflows', 'main.yml'],\n to: ['.github', 'workflows', 'main.yml'],\n },\n {type: 'copy', from: ['.husky', 'commit-msg'], to: ['.husky', 'commit-msg']},\n {type: 'copy', from: ['.husky', 'pre-commit'], to: ['.husky', 'pre-commit']},\n {type: 'copy', from: ['.releaserc.json'], to: '.releaserc.json'},\n {type: 'copy', from: ['commitlint.template.js'], to: 'commitlint.config.js'},\n {type: 'copy', from: ['lint-staged.template.js'], to: 'lint-staged.config.js'},\n ]\n\n return base.map((fromTo) => {\n if (fromTo.type === 'copy') {\n return {\n ...fromTo,\n from: ['semver-workflow', ...fromTo.from],\n }\n }\n\n return fromTo\n })\n}\n\nasync function semverWorkflowDependencies(): Promise<Record<string, string>> {\n return resolveLatestVersions([\n '@commitlint/cli',\n '@commitlint/config-conventional',\n '@sanity/semantic-release-preset',\n 'husky',\n 'lint-staged',\n ])\n}\n\nexport function readmeBaseurl(pkg: PackageJson) {\n return ((pkg.repository?.url ?? pkg.homepage ?? 'TODO') as string)\n .replace(/.+:\\/\\//g, 'https://')\n .replace(/\\.git/g, '')\n .replace(/git@github.com\\//g, 'github.com/')\n .replace(/git@github.com:/g, 'https://github.com/')\n .replace(/#.+/g, '')\n}\n","import chalk from 'chalk'\n\nimport type {InjectOptions} from '../actions/inject'\nimport {forcedDevPackageVersions, forcedPackageVersions} from '../configs/forced-package-versions'\nimport {forceDependencyVersions, getPackage, sortKeys, writePackageJsonDirect} from '../npm/package'\nimport {resolveLatestVersions} from '../npm/resolveLatestVersions'\nimport log from '../util/log'\nimport type {Preset} from './presets'\n\nexport const ui: Preset = {\n name: 'ui',\n description: '`@sanity/ui` and dependencies',\n apply: applyPreset,\n}\n\nasync function applyPreset(options: InjectOptions) {\n await addDependencies(options)\n await addDevDependencies(options)\n\n log.info(chalk.green('ui preset injected'))\n}\n\nasync function addDependencies(options: InjectOptions) {\n const pkg = await getPackage(options)\n const newDeps = sortKeys(\n forceDependencyVersions(\n {\n ...pkg.dependencies,\n ...(await resolveDependencyList()),\n },\n forcedPackageVersions,\n ),\n )\n const newPkg = {...pkg}\n newPkg.dependencies = newDeps\n await writePackageJsonDirect(newPkg, options)\n log.info('Updated dependencies.')\n}\n\nasync function addDevDependencies(options: InjectOptions) {\n const pkg = await getPackage(options)\n const newDeps = sortKeys(\n forceDependencyVersions(\n {\n ...pkg.devDependencies,\n ...(await resolveDevDependencyList()),\n },\n forcedDevPackageVersions,\n ),\n )\n const newPkg = {...pkg}\n newPkg.devDependencies = newDeps\n await writePackageJsonDirect(newPkg, options)\n log.info('Updated devDependencies.')\n}\n\nasync function resolveDependencyList(): Promise<Record<string, string>> {\n return resolveLatestVersions(['@sanity/icons', '@sanity/ui'])\n}\n\nasync function resolveDevDependencyList(): Promise<Record<string, string>> {\n return resolveLatestVersions([\n // install the peer dependencies of `@sanity/ui` as dev dependencies\n 'react',\n 'react-dom',\n 'styled-components',\n ])\n}\n","import type {InjectOptions} from '../actions/inject'\nimport {renovatePreset} from './renovatebot'\nimport {semverWorkflowPreset} from './semver-workflow'\nimport {ui} from './ui'\n\nexport interface Preset {\n name: string\n description: string\n apply: (options: InjectOptions) => Promise<void>\n}\n\nconst presets: Preset[] = [semverWorkflowPreset, renovatePreset, ui]\nconst presetNames = presets.map((p) => p?.name)\n\nexport function presetHelpList(padStart: number) {\n return presets\n .map((p) => `${''.padStart(padStart)}${p.name.padEnd(20)}${p.description}`)\n .join('\\n')\n}\n\nexport async function injectPresets(options: InjectOptions) {\n if (options.flags.presetOnly && !options.flags.preset?.length) {\n throw new Error('--preset-only, but no --preset [preset-name] was provided.')\n }\n\n const applyPresets = presetsFromInput(options.flags.preset)\n for (const preset of applyPresets) {\n await preset.apply(options)\n }\n}\n\nfunction presetsFromInput(inputPresets: string[] | undefined): Preset[] {\n if (!inputPresets) {\n return []\n }\n const unknownPresets = inputPresets.filter((p) => !presetNames.includes(p))\n if (unknownPresets.length) {\n throw new Error(\n `Unknown --preset(s): [${unknownPresets.join(', ')}]. Must be one of: [${presetNames.join(\n ', ',\n )}]`,\n )\n }\n\n return inputPresets\n .filter(onlyUnique)\n .map((presetName) => presets.find((p) => p.name === presetName))\n .filter((p): p is Preset => !!p)\n}\n\nfunction onlyUnique(value: string, index: number, arr: string[]) {\n return arr.indexOf(value) === index\n}\n","import path from 'path'\nimport {fileURLToPath} from 'url'\n\nimport licenses from '@rexxars/choosealicense-list'\nimport gitRemoteOriginUrl from 'git-remote-origin-url'\n\nimport {gitignoreTemplate} from '../configs/git'\nimport {oxfmtConfigTemplate} from '../configs/oxfmt'\nimport {oxlintConfigTemplate} from '../configs/oxlint'\nimport {pkgConfigTemplate} from '../configs/pkg-config'\nimport {tsconfigTemplateDist, tsconfigTemplate, tsconfigTemplateSettings} from '../configs/tsconfig'\nimport {addBuildScripts, getPackage, writePackageJson} from '../npm/package'\nimport {injectPresets} from '../presets/presets'\nimport {errorToUndefined} from '../util/errorToUndefined'\nimport {\n copyFileWithOverwritePrompt,\n fileExists,\n readFile,\n writeFile,\n writeFileWithOverwritePrompt,\n} from '../util/files'\nimport log from '../util/log'\nimport {prompt, promptForPackageName, promptForRepoOrigin} from '../util/prompt'\nimport {generateReadme, isDefaultGitHubReadme} from '../util/readme'\nimport {getUserInfo} from '../util/user'\nimport type {InitFlags} from './init'\nimport type {PackageJson} from './verify/types'\n\nconst bannedFields = ['login', 'description', 'projecturl', 'email']\nconst preferredLicenses = ['MIT', 'ISC', 'BSD-3-Clause']\nconst otherLicenses = Object.keys(licenses.list).filter((id) => {\n const license = licenses.list[id]\n return (\n !preferredLicenses.includes(id) &&\n !bannedFields.some((field) => license.body.includes(`[${field}]`))\n )\n})\n\nexport interface InjectCopyFromTo {\n type: 'copy'\n from: string | string[]\n to: string | string[]\n}\n\nexport interface InjectTemplate {\n type: 'template'\n to: string | string[]\n value: string\n force?: boolean\n}\n\nexport type Injectable = InjectCopyFromTo | InjectTemplate\n\nexport interface InjectOptions {\n basePath: string\n requireUserConfirmation?: boolean\n flags: InitFlags\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n peerDependencies?: Record<string, string>\n validate?: boolean\n outDir: string\n}\n\nexport interface PackageData {\n user?: {name?: string; email?: string}\n pluginName?: string\n license?: {id: string; text: string}\n description?: string\n pkg?: PackageJson\n gitOrigin?: string\n}\n\nexport async function inject(options: InjectOptions) {\n if (options.flags.presetOnly) {\n log.info('Only apply presets, skipping default inject.')\n } else {\n await injectBase(options)\n }\n await injectPresets(options)\n}\n\nasync function injectBase(options: InjectOptions) {\n const {basePath, flags, requireUserConfirmation} = options\n const info = (write: boolean, msg: string, ...args: string[]) => write && log.info(msg, ...args)\n // Gather data\n const pkg = await getPackage(options).catch(errorToUndefined)\n log.debug('Plugin has package.json: %s', pkg ? 'yes' : 'no')\n\n const user = await getUserInfo(options, pkg)\n log.debug('User information: %o', user)\n\n const pkgName = flags.name ?? pkg?.name\n const pluginName =\n requireUserConfirmation || !pkgName ? await promptForPackageName(options, pkgName) : pkgName\n\n log.debug('Plugin name: %s', pluginName)\n\n const license = await getLicense(flags, {user, pluginName, pkg, requireUserConfirmation})\n const licenseChanged = (pkg && pkg.license) !== (license && license.id)\n log.debug('License: %s', license ? license.id : '<none>')\n\n const description = await getProjectDescription(basePath, pkg, requireUserConfirmation)\n log.debug('Description: %s', description || '<none>')\n\n const repoUrl =\n flags.repo ??\n ((await gitRemoteOriginUrl(basePath).catch(errorToUndefined)) || pkg?.repository?.url)\n\n const gitOrigin = requireUserConfirmation ? await promptForRepoOrigin(options, repoUrl) : repoUrl\n\n log.debug('Remote origin: %s', gitOrigin || '<none>')\n\n // Output\n const data: PackageData = {user, pluginName, license, description, pkg, gitOrigin}\n let didWrite\n\n // Write package.json, if returns the original (data.pkg) if it was unchanged,\n // otherwise it returns the new object\n const newPkg = await writePackageJson(data, options)\n info(newPkg !== pkg, 'Wrote package.json')\n data.pkg = newPkg\n\n didWrite = await writeLicense(data, options, licenseChanged)\n info(didWrite, 'Wrote license file (LICENSE)')\n\n didWrite = await writeReadme(data, options)\n info(didWrite, 'Wrote readme file (README.md)')\n\n didWrite = await writeStaticAssets(options)\n info(didWrite.length > 0, 'Wrote static asset files: %s', didWrite.join(', '))\n\n didWrite = await addBuildScripts(newPkg, options)\n info(didWrite, 'Added build scripts to package.json')\n\n didWrite = await addCompileDirToGitIgnore(options)\n info(didWrite, 'Added compilation output directory to .gitignore')\n}\n\nasync function writeReadme(data: PackageData, options: InjectOptions) {\n const {basePath} = options\n\n const readmePath = path.join(basePath, 'README.md')\n const readme = await readFile(readmePath, 'utf8').catch(errorToUndefined)\n\n if (readme && !isDefaultGitHubReadme(readme)) {\n return false\n }\n\n await writeFileWithOverwritePrompt(readmePath, generateReadme(data), {\n encoding: 'utf8',\n force: options.flags.force,\n })\n return true\n}\n\nasync function writeLicense(\n {license}: PackageData,\n options: InjectOptions,\n licenseChanged: boolean,\n) {\n const {basePath, flags} = options\n\n if ((flags.license as unknown as boolean) === false || !license) {\n return false\n }\n\n // Prefer whatever path the user is currently using (LICENSE.md or LICENSE)\n const hasLicenseMdFile = await fileExists(path.join(basePath, 'LICENSE.md'))\n const licensePath = path.join(basePath, hasLicenseMdFile ? 'LICENSE.md' : 'LICENSE')\n\n await writeFileWithOverwritePrompt(licensePath, license.text, {\n encoding: 'utf8',\n default: licenseChanged,\n force: flags.force,\n })\n\n return true\n}\n\nasync function getLicense(\n flags: InitFlags,\n {\n user,\n pluginName,\n pkg,\n requireUserConfirmation,\n }: PackageData & {requireUserConfirmation?: boolean},\n) {\n const license = await getLicenseIdentifier(flags, pkg, requireUserConfirmation)\n if (!license) {\n return undefined\n }\n\n const text = license.body\n .replace(/\\[fullname\\]/g, user?.name ?? '')\n .replace(/\\[project\\]/g, pluginName ?? '')\n .replace(/\\[year\\]/g, String(new Date().getFullYear()))\n\n return {id: license.id, text}\n}\n\nasync function getLicenseIdentifier(\n flags: InitFlags,\n pkg: PackageJson | undefined,\n requireUserConfirmation = false,\n) {\n // --no-license\n if ((flags.license as unknown) === false) {\n return null\n }\n\n // --license becomes \"\", --license mit becomes \"mit\"\n if (typeof flags.license === 'string') {\n const license = licenses.find(`${flags.license}`)\n if (!license) {\n throw new Error(`License \"${flags.license}\" not found`)\n }\n return license\n }\n\n // no --license flag provided, do we have one in package already?\n if (pkg && pkg.license && !requireUserConfirmation) {\n const license = licenses.find(`${pkg.license}`)\n if (license) {\n return license\n }\n\n // Warn, then prompt the user\n log.warn(`package.json contains license \"${pkg.license}\", which is not recognized`)\n }\n\n const licenseId = await prompt('Which license do you want to use?', {\n default: pkg && pkg.license && licenses.find(pkg.license) ? pkg.license : preferredLicenses[0],\n choices: [\n prompt.separator(),\n ...preferredLicenses.map((value) => ({value, name: licenses.list[value].title})),\n prompt.separator(),\n ...otherLicenses.map((value) => ({value, name: licenses.list[value].title})),\n ],\n })\n\n return licenses.find(licenseId)\n}\n\nasync function getProjectDescription(\n basePath: string,\n pkg: PackageJson | undefined,\n requireUserConfirmation = false,\n) {\n let description = await resolveProjectDescription(basePath, pkg)\n if (requireUserConfirmation) {\n description = await prompt('Plugin description', {default: description || ''})\n }\n return description ?? ''\n}\n\nasync function resolveProjectDescription(basePath: string, pkg: PackageJson | undefined) {\n // Try to grab from package.json\n if (pkg && typeof pkg.description === 'string' && pkg.description.length > 5) {\n return pkg.description\n }\n\n // Try to grab a project description from a standard GitHub-generated readme\n try {\n const readmePath = path.join(basePath, 'README.md')\n const readme = await readFile(readmePath, 'utf8')\n const [title, description] = readme.split('\\n').filter(Boolean)\n if (!title || !description || !title.match(/^#\\s+\\w+/)) {\n return null\n }\n\n // Naive, but this isn't too important\n const unlinked = description.replace(/\\[(.*?)\\]\\(.*?\\)/g, '$1')\n if (/^[^#]/.test(unlinked)) {\n return unlinked\n }\n\n return null\n } catch (err) {\n return errorToUndefined(err)\n }\n}\n\nexport async function writeAssets(injectables: Injectable[], {basePath, flags}: InjectOptions) {\n const assetsDir = await findAssetsDir()\n\n const from = (...segments: string[]) => path.join(assetsDir, 'inject', ...segments)\n const to = (...segments: string[]) => path.join(basePath, ...segments)\n\n const writes: string[] = []\n for (const injectable of injectables) {\n if (injectable.type === 'copy') {\n const fromPath = asArray(injectable.from)\n const toPath = asArray(injectable.to)\n if (await copyFileWithOverwritePrompt(from(...fromPath), to(...toPath), flags)) {\n writes.push(path.join(...toPath))\n }\n continue\n }\n\n if (injectable.type === 'template') {\n const toPath = asArray(injectable.to)\n\n await writeFileWithOverwritePrompt(to(...toPath), `${injectable.value.trim()}\\n`, {\n default: 'n',\n force: injectable.force || flags.force,\n })\n\n writes.push(path.join(...toPath))\n continue\n }\n\n throw new Error(`Unknown operation type \"${(injectable as any).type}\"`)\n }\n\n return writes\n}\n\nasync function writeStaticAssets(options: InjectOptions) {\n const {outDir, flags} = options\n\n const files: Injectable[] = [\n flags.oxlint && oxlintConfigTemplate({flags: options.flags}),\n {type: 'copy', from: 'editorconfig', to: '.editorconfig'},\n pkgConfigTemplate({outDir, flags: options.flags}),\n flags.gitignore && gitignoreTemplate(),\n flags.typescript && tsconfigTemplate({flags: options.flags}),\n flags.typescript && tsconfigTemplateDist({outDir, flags: options.flags}),\n flags.typescript && tsconfigTemplateSettings({outDir, flags: options.flags}),\n flags.oxfmt && oxfmtConfigTemplate({flags: options.flags}),\n ]\n .map((f) => (f ? (f as Injectable) : undefined))\n .filter((f): f is Injectable => !!f)\n\n const result = writeAssets(files, options)\n\n return result\n}\n\nfunction asArray(input: string | string[]): string[] {\n return typeof input === 'string' ? [input] : input\n}\n\n/**\n * assets dir might be in higher or lower in the dir hierarchy depending on\n * if we run from `dist` or `src`\n */\nasync function findAssetsDir(): Promise<string> {\n let maxBackpaddle = 3\n let currDir = path.dirname(fileURLToPath(import.meta.url))\n let assetsDir: string = ''\n while (!assetsDir && maxBackpaddle) {\n currDir = path.join(currDir, '..')\n const assets = path.join(currDir, 'assets')\n if (await fileExists(assets)) {\n assetsDir = assets\n } else {\n maxBackpaddle--\n }\n }\n\n if (!assetsDir) {\n throw new Error('Could not find assets directory!')\n }\n return assetsDir\n}\n\nasync function addCompileDirToGitIgnore(options: InjectOptions) {\n const gitIgnorePath = path.join(options.basePath, '.gitignore')\n const gitignore = await readFile(gitIgnorePath, 'utf8').catch(errorToUndefined)\n if (!gitignore) {\n return false\n }\n\n const ignore = options.outDir.replace(/^[./]+/, '').split('/')[0]\n if (!ignore) {\n return false\n }\n\n const lines = gitignore.trim().split('\\n')\n if (lines.includes(ignore)) {\n return false\n }\n\n lines.push('', '# Compiled plugin', ignore)\n\n await writeFile(gitIgnorePath, lines.join('\\n') + '\\n', {encoding: 'utf8'})\n return true\n}\n","import path from 'path'\n\nimport type {TypedFlags} from 'meow'\n\nimport {defaultSourceJs, defaultSourceTs} from '../configs/default-source'\nimport {defaultOutDir} from '../constants'\nimport {getPackage} from '../npm/package'\nimport sharedFlags from '../sharedFlags'\nimport {ensureDir, writeFile} from '../util/files'\nimport {inject} from './inject'\n\nexport const initFlags = {\n ...sharedFlags,\n scripts: {\n type: 'boolean',\n default: true,\n },\n oxlint: {\n type: 'boolean',\n default: true,\n },\n typescript: {\n type: 'boolean',\n default: true,\n },\n oxfmt: {\n type: 'boolean',\n default: true,\n },\n license: {\n type: 'string',\n },\n editorconfig: {\n type: 'boolean',\n default: true,\n },\n gitignore: {\n type: 'boolean',\n default: true,\n },\n force: {\n type: 'boolean',\n default: false,\n },\n install: {\n type: 'boolean',\n default: true,\n },\n name: {\n type: 'string',\n },\n author: {\n type: 'string',\n },\n repo: {\n type: 'string',\n },\n presetOnly: {\n type: 'boolean',\n default: false,\n },\n preset: {\n type: 'string',\n isMultiple: true,\n },\n} as const\n\nexport type InitFlags = TypedFlags<typeof initFlags>\n\nexport interface InitOptions {\n basePath: string\n flags: InitFlags\n}\n\nexport async function init(options: InitOptions) {\n let dependencies = {}\n let devDependencies = {}\n let peerDependencies = {}\n\n await inject({\n ...options,\n outDir: defaultOutDir,\n requireUserConfirmation: !options.flags.force,\n dependencies,\n devDependencies,\n peerDependencies,\n validate: false,\n })\n\n const packageJson = await getPackage({basePath: options.basePath, validate: false})\n const typescript = options.flags.typescript\n const source = typescript ? defaultSourceTs(packageJson) : defaultSourceJs(packageJson)\n const filename = typescript ? 'index.ts' : 'index.js'\n const srcDir = path.resolve(options.basePath, 'src')\n await ensureDir(srcDir)\n await writeFile(path.join(srcDir, filename), source, {encoding: 'utf8'})\n}\n"],"mappings":";;;;;;;;;;;;;;AAIA,SAAgB,gBAAgB,KAAkB;CAChD,OACE,OAAO;;;;;;;;+BAQoB,IAAI,KAAK;;;;;;;;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AAS;CACX;CACA,SAAS,EACP,MAAM,SACR;CACA,cAAc;EACZ,MAAM;EACN,SAAS;CACX;CACA,WAAW;EACT,MAAM;EACN,SAAS;CACX;CACA,OAAO;EACL,MAAM;EACN,SAAS;CACX;CACA,SAAS;EACP,MAAM;EACN,SAAS;CACX;CACA,MAAM,EACJ,MAAM,SACR;CACA,QAAQ,EACN,MAAM,SACR;CACA,MAAM,EACJ,MAAM,SACR;CACA,YAAY;EACV,MAAM;EACN,SAAS;CACX;CACA,QAAQ;EACN,MAAM;EACN,YAAY;CACd;AACF;AASA,eAAsB,KAAK,SAAsB;CAC/C,IAAI,eAAe,CAAC,GAChB,kBAAkB,CAAC,GACnB,mBAAmB,CAAC;CAExB,MAAM,OAAO;EACX,GAAG;EACH,QAAQ;EACR,yBAAyB,CAAC,QAAQ,MAAM;EACxC;EACA;EACA;EACA,UAAU;CACZ,CAAC;CAED,IAAM,cAAc,MAAM,WAAW;EAAC,UAAU,QAAQ;EAAU,UAAU;CAAK,CAAC,GAC5E,aAAa,QAAQ,MAAM,YAC3B,SAAS,aAAa,gBAAgB,WAAW,IAAI,gBAAgB,WAAW,GAChF,WAAW,aAAa,aAAa,YACrC,SAAS,KAAK,QAAQ,QAAQ,UAAU,KAAK;CAEnD,AADA,MAAM,UAAU,MAAM,GACtB,MAAM,UAAU,KAAK,KAAK,QAAQ,QAAQ,GAAG,QAAQ,EAAC,UAAU,OAAM,CAAC;AACzE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"inject-_X7Is81B.js","names":[],"sources":["../src/cmds/inject.ts"],"sourcesContent":["import path from 'path'\n\nimport meow from 'meow'\n\nimport {initFlags} from '../actions/init'\nimport {inject} from '../actions/inject'\nimport {cliName, defaultOutDir} from '../constants'\nimport {presetHelpList} from '../presets/presets'\nimport {findStudioV3Config} from '../sanity/manifest'\nimport {loadPackageConfig} from '../util/load-package-config'\nimport log from '../util/log'\n\nconst description = `Inject configuration into a Sanity plugin`\n\nconst help = `\nUsage\n $ ${cliName} inject [dir] [<args>]\n\nOptions\n --no-oxlint Disables oxlint config and dependencies from being added\n --no-oxfmt Disables oxfmt config and dependencies from being added\n --no-typescript Disables typescript config and dependencies from being added\n --no-license Disables LICENSE + package.json license field from being added\n --no-editorconfig Disables .editorconfig from being added\n --no-gitignore Disables .gitignore from being added\n --no-scripts Disables scripts from being added to package.json\n\n --license [spdx] Use the license with the given SPDX identifier\n --force No prompt when overwriting files\n\n --preset [preset-name] Adds config and files from a named preset. --preset can be supplied multiple times.\n The following presets are available:\n${presetHelpList(30)}\n --preset-only Skips the default inject steps. Use this to apply a preset to an otherwise complete plugin.\n\nExamples\n # Inject configuration into the plugin in the current directory\n $ ${cliName} inject\n\n # Inject configuration into the plugin in ~/my-plugin\n $ ${cliName} inject ~/my-plugin\n\n # Don't inject oxlint or oxfmt\n $ ${cliName} inject --no-oxlint --no-oxfmt\n\n # Inject plugin configuration and semver-workflow into the plugin in the current directory\n $ @sanity/plugin-kit inject --preset semver-workflow\n\n # Only inject semver-workflow and renovatebot config from presets\n $ ${cliName} inject --preset-only --preset semver-workflow --preset renovatebot\n\n`\n\nasync function run({argv}: {argv: string[]}) {\n const cli = meow(help, {flags: initFlags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n const packageConfig = await loadPackageConfig({basePath})\n const outDir = packageConfig?.dist ?? defaultOutDir\n\n const {v3ConfigFile} = await findStudioV3Config(basePath)\n if (v3ConfigFile) {\n throw new Error(\n `${v3ConfigFile} exists - are you trying to INJECT into a studio instead of a plugin?`,\n )\n }\n log.info('Inject config into plugin in \"%s\"', basePath)\n\n await inject({basePath, outDir, flags: cli.flags, validate: false})\n log.info('Done!')\n}\n\nexport default run\n"],"mappings":";;;;;;;AAYA,MAEM,OAAO;;MAEP,QAAQ;;;;;;;;;;;;;;;;EAgBZ,eAAe,EAAE,EAAE;;;;;MAKf,QAAQ;;;MAGR,QAAQ;;;MAGR,QAAQ;;;;;;MAMR,QAAQ;;;AAId,eAAe,IAAI,EAAC,QAAyB;CAC3C,IAAM,MAAM,KAAK,MAAM;EAAC,OAAO;EAAW;EAAM;CAAW,CAAC,GACtD,WAAW,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CAAC,GAErD,UAAS,MADa,kBAAkB,EAAC,SAAQ,CAAC,EAAA,EAC1B,QAAA,QAExB,EAAC,iBAAgB,MAAM,mBAAmB,QAAQ;CACxD,IAAI,cACF,MAAU,MACR,GAAG,aAAa,sEAClB;CAKF,AAHA,YAAI,KAAK,uCAAqC,QAAQ,GAEtD,MAAM,OAAO;EAAC;EAAU;EAAQ,OAAO,IAAI;EAAO,UAAU;CAAK,CAAC,GAClE,YAAI,KAAK,OAAO;AAClB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-B_o7MhuL.js","names":["stat","readFile","validatePackageName","validateNpmPackageName","readFile","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://git@github.com/${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, readFile, readJsonFile, 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\n/**\n * Config filenames oxfmt discovers automatically (in addition to explicit `-c` paths).\n */\nconst oxfmtConfigFiles = [\n 'oxfmt.config.ts',\n 'oxfmt.config.js',\n 'oxfmt.config.mjs',\n '.oxfmtrc.json',\n '.oxfmtrc.jsonc',\n]\n\nconst legacyPrettierConfigFiles = [\n '.prettierrc',\n '.prettierrc.json5',\n '.prettierrc.json',\n '.prettierrc.yaml',\n '.prettierrc.yml',\n '.prettierrc.js',\n '.prettierrc.cjs',\n '.prettierrc.mjs',\n '.prettierrc.toml',\n 'prettier.config.js',\n 'prettier.config.cjs',\n 'prettier.config.mjs',\n]\n\nconst oxfmtPresetSpecifier = '@sanity/plugin-kit/oxfmt'\n\nconst oxfmtSetupSnippet = outdent`\n export {default} from '${oxfmtPresetSpecifier}'\n`\n\n/**\n * Walks up from `basePath` (inclusive) looking for a workspace (monorepo) root: a directory\n * containing `pnpm-workspace.yaml`, or a `package.json` with a `workspaces` field.\n */\nasync function findWorkspaceRoot(basePath: string): Promise<string | undefined> {\n let dir = path.resolve(basePath)\n let prev: string | undefined\n while (dir !== prev) {\n if (await isWorkspaceRoot(dir)) {\n return dir\n }\n prev = dir\n dir = path.dirname(dir)\n }\n return undefined\n}\n\nasync function isWorkspaceRoot(dir: string): Promise<boolean> {\n if (await fileExists(path.join(dir, 'pnpm-workspace.yaml'))) {\n return true\n }\n const pkgPath = path.join(dir, 'package.json')\n if (await fileExists(pkgPath)) {\n try {\n const pkg = await readJsonFile<PackageJson>(pkgPath)\n return Boolean(pkg && typeof pkg === 'object' && pkg.workspaces)\n } catch {\n // an unparseable package.json is not a workspace root marker\n }\n }\n return false\n}\n\n/**\n * Finds leftover config files from a replaced tool, both next to the plugin's package.json and\n * (in a monorepo) at the workspace root, where the replacement config is expected to live.\n */\nasync function findLegacyConfigFiles(\n basePath: string,\n workspaceRoot: string | undefined,\n files: string[],\n): Promise<string[]> {\n const found: string[] = []\n for (const file of files) {\n if (await fileExists(path.join(basePath, file))) {\n found.push(file)\n }\n }\n if (workspaceRoot && workspaceRoot !== path.resolve(basePath)) {\n for (const file of files) {\n if (await fileExists(path.join(workspaceRoot, file))) {\n found.push(`${file} (in the workspace root)`)\n }\n }\n }\n return found\n}\n\n/**\n * Finds a leftover config key from a replaced tool in the plugin's package.json and (in a\n * monorepo) the workspace root package.json, where such keys used to configure the whole\n * workspace.\n */\nasync function findLegacyPackageJsonKey(\n pkgJson: PackageJson,\n basePath: string,\n workspaceRoot: string | undefined,\n key: string,\n): Promise<string[]> {\n const found: string[] = []\n if (pkgJson[key]) {\n found.push(`package.json (\"${key}\" key)`)\n }\n if (workspaceRoot && workspaceRoot !== path.resolve(basePath)) {\n const rootPkgPath = path.join(workspaceRoot, 'package.json')\n if (await fileExists(rootPkgPath)) {\n try {\n const rootPkg = await readJsonFile<PackageJson>(rootPkgPath)\n if (rootPkg && typeof rootPkg === 'object' && rootPkg[key]) {\n found.push(`package.json (\"${key}\" key, in the workspace root)`)\n }\n } catch {\n // an unparseable root package.json is not this check's concern\n }\n }\n }\n return found\n}\n\ntype ConfigDirResult = {ok: true} | {ok: false; found: boolean; error: string}\n\nasync function checkOxfmtConfigDir(dir: string, describeDir: string): Promise<ConfigDirResult> {\n const found: string[] = []\n for (const file of oxfmtConfigFiles) {\n if (await fileExists(path.join(dir, file))) {\n found.push(file)\n }\n }\n\n if (found.length === 0) {\n return {\n ok: false,\n found: false,\n error: outdent`\n Could not find an oxfmt config file ${describeDir}.\n\n plugin-kit ships a shared oxfmt preset. Create an oxfmt.config.ts there containing:\n\n ${oxfmtSetupSnippet}\n `,\n }\n }\n\n if (found.length > 1) {\n return {\n ok: false,\n found: true,\n error: outdent`\n Found multiple oxfmt config files ${describeDir}: [${found.join(', ')}].\n\n There should be at most one of these files. Delete the rest.\n `,\n }\n }\n\n const file = found[0]\n if (file.startsWith('.oxfmtrc')) {\n return {\n ok: false,\n found: true,\n error: outdent`\n Found ${file} ${describeDir}, but JSON configs cannot reuse the shared plugin-kit preset.\n\n Replace it with an oxfmt.config.ts containing:\n\n ${oxfmtSetupSnippet}\n `,\n }\n }\n\n const content = await readFile(path.join(dir, file), 'utf8')\n if (!content.includes(oxfmtPresetSpecifier)) {\n return {\n ok: false,\n found: true,\n error: outdent`\n Found ${file} ${describeDir}, but it does not use the shared plugin-kit preset (${oxfmtPresetSpecifier}).\n\n Re-export the preset:\n\n ${oxfmtSetupSnippet}\n\n or spread it into your own config to customize options.\n `,\n }\n }\n\n return {ok: true}\n}\n\n/**\n * Verifies the plugin is formatted with oxfmt using the shared plugin-kit preset, and that no\n * legacy prettier configuration remains.\n *\n * In a monorepo (a workspace root is found above the plugin), the oxfmt config is expected at the\n * workspace root; otherwise it should sit next to the package.json that installs and runs\n * plugin-kit. Since oxfmt discovers nested configs, a config next to package.json overrides the\n * workspace root config for this package — so in a monorepo the local config is validated when it\n * exists, and the workspace root config otherwise.\n */\nexport async function validateOxfmtConfig(\n basePath: string,\n pkgJson: PackageJson,\n): Promise<string[]> {\n const errors: string[] = []\n const workspaceRoot = await findWorkspaceRoot(basePath)\n\n const legacyFound = await findLegacyConfigFiles(\n basePath,\n workspaceRoot,\n legacyPrettierConfigFiles,\n )\n legacyFound.push(\n ...(await findLegacyPackageJsonKey(pkgJson, basePath, workspaceRoot, 'prettier')),\n )\n if (legacyFound.length) {\n errors.push(\n outdent`\n Found legacy prettier configuration: [${legacyFound.join(', ')}].\n\n plugin-kit has replaced prettier with oxfmt. Remove the prettier config (custom options can\n be migrated with \\`npx oxfmt --migrate=prettier\\`), drop the prettier, prettier-plugin-packagejson\n and eslint-plugin-prettier devDependencies, and format with oxfmt instead:\n\n ${oxfmtSetupSnippet}\n `,\n )\n }\n const primaryDir = workspaceRoot ?? basePath\n const primaryResult = await checkOxfmtConfigDir(\n primaryDir,\n workspaceRoot ? `in the workspace root (${workspaceRoot})` : 'next to package.json',\n )\n\n // In a monorepo, oxfmt discovers nested configs: a config next to the plugin's package.json\n // overrides the workspace root config for this package's files, so when one exists it is the\n // config that must use the shared preset.\n if (workspaceRoot && workspaceRoot !== path.resolve(basePath)) {\n const localResult = await checkOxfmtConfigDir(basePath, 'next to package.json')\n if (localResult.ok) {\n return errors\n }\n if (localResult.found) {\n errors.push(\n primaryResult.ok\n ? outdent`\n ${localResult.error}\n\n Note: this config overrides the workspace root config (${primaryDir}) for this\n package's files, since oxfmt discovers nested configs. Either make it use the shared\n preset, or delete it to fall back to the workspace root config.\n `\n : localResult.error,\n )\n return errors\n }\n }\n\n if (primaryResult.ok) {\n return errors\n }\n\n errors.push(primaryResult.error)\n return errors\n}\n\n/**\n * Config filenames oxlint discovers automatically (in addition to explicit `-c` paths).\n */\nconst oxlintConfigFiles = ['oxlint.config.ts', '.oxlintrc.json', '.oxlintrc.jsonc']\n\nconst legacyEslintConfigFiles = [\n '.eslintrc',\n '.eslintrc.js',\n '.eslintrc.cjs',\n '.eslintrc.yaml',\n '.eslintrc.yml',\n '.eslintrc.json',\n '.eslintignore',\n 'eslint.config.js',\n 'eslint.config.mjs',\n 'eslint.config.cjs',\n 'eslint.config.ts',\n 'eslint.config.mts',\n 'eslint.config.cts',\n]\n\nconst oxlintSharedConfig = '@sanity/plugin-kit/oxlint'\n\nconst oxlintSetupSnippet = outdent`\n export {default} from '${oxlintSharedConfig}'\n`\n\nasync function checkOxlintConfigDir(dir: string, describeDir: string): Promise<ConfigDirResult> {\n const found: string[] = []\n for (const file of oxlintConfigFiles) {\n if (await fileExists(path.join(dir, file))) {\n found.push(file)\n }\n }\n\n if (found.length === 0) {\n return {\n ok: false,\n found: false,\n error: outdent`\n Could not find an oxlint config file ${describeDir}.\n\n plugin-kit ships a shared oxlint config (type-aware rules, type checking and no warnings).\n Create an oxlint.config.ts there containing:\n\n ${oxlintSetupSnippet}\n `,\n }\n }\n\n if (found.length > 1) {\n return {\n ok: false,\n found: true,\n error: outdent`\n Found multiple oxlint config files ${describeDir}: [${found.join(', ')}].\n\n There should be at most one of these files. Delete the rest.\n `,\n }\n }\n\n const file = found[0]\n if (file.startsWith('.oxlintrc')) {\n return {\n ok: false,\n found: true,\n error: outdent`\n Found ${file} ${describeDir}, but JSON configs cannot reuse the shared plugin-kit config\n (package imports are only supported in oxlint.config.ts).\n\n Replace it with an oxlint.config.ts containing:\n\n ${oxlintSetupSnippet}\n `,\n }\n }\n\n const content = await readFile(path.join(dir, file), 'utf8')\n if (!content.includes(oxlintSharedConfig)) {\n return {\n ok: false,\n found: true,\n error: outdent`\n Found ${file} ${describeDir}, but it does not use the shared plugin-kit config (${oxlintSharedConfig}).\n\n Re-export the shared config:\n\n ${oxlintSetupSnippet}\n\n or extend it with your own options:\n\n import sanityPluginKitOxlint from '${oxlintSharedConfig}'\n import {defineConfig} from 'oxlint'\n\n export default defineConfig({\n extends: [sanityPluginKitOxlint],\n })\n `,\n }\n }\n\n return {ok: true}\n}\n\n/**\n * Verifies the plugin lints with oxlint using the shared plugin-kit config, and that no legacy\n * eslint configuration remains.\n *\n * In a monorepo (a workspace root is found above the plugin), the oxlint config is expected at the\n * workspace root; otherwise it should sit next to the package.json that installs and runs\n * plugin-kit. Since oxlint discovers nested configs, a config next to package.json overrides the\n * workspace root config for this package — so in a monorepo the local config is validated when it\n * exists, and the workspace root config otherwise.\n */\nexport async function validateOxlintConfig(\n basePath: string,\n pkgJson: PackageJson,\n): Promise<string[]> {\n const errors: string[] = []\n const workspaceRoot = await findWorkspaceRoot(basePath)\n\n const legacyFound = await findLegacyConfigFiles(basePath, workspaceRoot, legacyEslintConfigFiles)\n legacyFound.push(\n ...(await findLegacyPackageJsonKey(pkgJson, basePath, workspaceRoot, 'eslintConfig')),\n )\n if (legacyFound.length) {\n errors.push(\n outdent`\n Found legacy eslint configuration: [${legacyFound.join(', ')}].\n\n plugin-kit has replaced eslint with oxlint. Remove the eslint config files and the eslint\n devDependencies (eslint, eslint-config-*, eslint-plugin-*, @typescript-eslint/*), and lint\n with oxlint instead, via an oxlint.config.ts containing:\n\n ${oxlintSetupSnippet}\n `,\n )\n }\n const primaryDir = workspaceRoot ?? basePath\n const primaryResult = await checkOxlintConfigDir(\n primaryDir,\n workspaceRoot ? `in the workspace root (${workspaceRoot})` : 'next to package.json',\n )\n\n // In a monorepo, oxlint discovers nested configs: a config next to the plugin's package.json\n // overrides the workspace root config for this package's files, so when one exists it is the\n // config that must use the shared config.\n if (workspaceRoot && workspaceRoot !== path.resolve(basePath)) {\n const localResult = await checkOxlintConfigDir(basePath, 'next to package.json')\n if (localResult.ok) {\n return errors\n }\n if (localResult.found) {\n errors.push(\n primaryResult.ok\n ? outdent`\n ${localResult.error}\n\n Note: this config overrides the workspace root config (${primaryDir}) for this\n package's files, since oxlint discovers nested configs. Either make it use the shared\n config, or delete it to fall back to the workspace root config.\n `\n : localResult.error,\n )\n return errors\n }\n }\n\n if (primaryResult.ok) {\n return errors\n }\n\n errors.push(primaryResult.error)\n return errors\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, SanityPlugin} 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 useOxfmt = flags.oxfmt !== false\n const useOxlint = flags.oxlint !== false\n const useTypescript = flags.typescript !== 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 (useOxfmt) {\n log.debug('Using oxfmt. Adding to dev dependencies.')\n newDevDependencies.push('oxfmt')\n }\n\n if (useOxlint) {\n log.debug('Using oxlint. Adding to dev dependencies.')\n // oxlint-tsgolint powers the type-aware rules and type checking enabled in the shared config\n newDevDependencies.push('oxlint', 'oxlint-tsgolint')\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 // Opting out of oxfmt/oxlint must also disable the corresponding verify-package checks,\n // otherwise the scaffolded `build` script (which runs verify-package) fails out of the box\n const verifyPackageOptOuts = {\n ...(useOxfmt ? {} : {oxfmt: false}),\n ...(useOxlint ? {} : {oxlint: false}),\n }\n const prevSanityPlugin: SanityPlugin = prev.sanityPlugin ?? {}\n const sanityPlugin: SanityPlugin | undefined = Object.keys(verifyPackageOptOuts).length\n ? {\n ...prevSanityPlugin,\n verifyPackage: {...prevSanityPlugin.verifyPackage, ...verifyPackageOptOuts},\n }\n : prev.sanityPlugin\n\n // order should be compatible with oxfmt's sortPackageJson\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 ...(sanityPlugin ? {sanityPlugin} : {}),\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 if (options.flags.oxfmt !== false) {\n scripts.format = addScript(`oxfmt`, scripts.format)\n }\n scripts['link-watch'] = addScript(expectedScripts['link-watch'], scripts['link-watch'])\n if (options.flags.oxlint !== false) {\n scripts.lint = addScript(`oxlint`, scripts.lint)\n }\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;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,GAEM,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;AACF,GC1Ba,kBAAkB;CAAC;CAAO;CAAQ;CAAQ;CAAO;CAAQ;CAAO;AAAM;ACSnF,eAAsB,OACpB,SACA,SAOA;CACA,IAAM,OAAO,QAAQ,UAAU,SAAS,QAAQ,MAC1C,SAAS,MAAM,SAAS,OAAO,CAAC;EAAC,GAAG;EAAS;EAAM;EAAS,MAAM;CAAQ,CAAC,CAAC;CAClF,OAAO,UAAU,OAAO;AAC1B;AAEA,OAAO,kBAAkB,IAAI,SAAS,UAAU;AAEhD,SAAgB,qBAAqB,EAAC,YAA0B,YAAqB;CACnF,OAAO,OAAO,mCAAmC;EAC/C,SAAS,cAAc,KAAK,SAAS,QAAQ;EAC7C,SAAS,SAAS;GAChB,IAAM,aAAa,KAAK,KAAK,CAAC,CAAC,QAAQ,mBAAmB,EAAE;GAC5D,OAAO,KAAK,OAAO,MAAM,OAAO,iBAAiB;EACnD;EACA,WAAW,SAAS;GAClB,IAAM,QAA6B,aAAa,IAAI;GASpD,OARI,MAAM,SACD,MAAM,OAAO,KAGlB,KAAK,OAAO,OAAO,KAAK,SAAS,QAAQ,IACpC,mDAAmD,KAAK,KAG1D;EACT;CACF,CAAC;AACH;AAEA,SAAgB,oBAAoB,UAAyB,YAAqB;CAChF,OAAO,OAAO,sBAAsB;EAClC,SAAS;EACT,SAAS,QAAQ;GACf,IAAM,OAAO,OAAO,GAAA,CAAI,KAAK,GACvB,KAAK,kBAAkB,GAAG;GAChC,OAAO,KAAK,4BAA4B,GAAG,KAAK,GAAG,GAAG,KAAK,QAAQ;EACrE;EACA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AAgB,wBACd,MACA,WAAW,uBACa;CACxB,IAAM,UAAU,OAAO,QAAQ,IAAI,CAAC,CAAC,KAAK,UAAU;EAClD,IAAM,CAAC,OAAO,OACR,eAAe,SAAS;EAI9B,OAHI,eACK,CAAC,KAAK,YAAY,IAEpB;CACT,CAAC;CACD,OAAO,OAAO,YAAY,OAAO;AACnC"}
@@ -1,4 +0,0 @@
1
- var name = "@sanity/plugin-kit", version = "8.0.1", binname = "plugin-kit";
2
- export { name as n, version as r, binname as t };
3
-
4
- //# sourceMappingURL=package-CXmMmZoh.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-CXmMmZoh.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,39 +0,0 @@
1
- import { n as sharedFlags_default, t as log_default } from "./log-DgQL-Rv9.js";
2
- import chalk from "chalk";
3
- import outdent from "outdent";
4
- const verifyFlags = {
5
- ...sharedFlags_default,
6
- single: {
7
- default: !1,
8
- type: "boolean"
9
- }
10
- };
11
- function disableCheckText(checkKey) {
12
- return chalk.grey(outdent`
13
- To skip this validation add the following to your package.json:
14
- "sanityPlugin": {
15
- "verifyPackage": {
16
- "${checkKey}": false
17
- }
18
- }
19
- `.trimStart());
20
- }
21
- function createValidator(verifyConfig, flags, errors) {
22
- return async function(checkKey, task) {
23
- if (verifyConfig[checkKey] !== !1) {
24
- let result = await task();
25
- if (result?.length) {
26
- result.push(disableCheckText(checkKey));
27
- let errorMessage = result.join("\n\n");
28
- errors.push(errorMessage), log_default.error("\n" + errorMessage + "\n----------------------------------------------------------");
29
- }
30
- }
31
- if (flags.single && errors.length) throw Error(outdent`Detected outstanding upgrade issues.
32
-
33
- Fail-fast (--single) mode enabled, stopping validation here.
34
- `);
35
- };
36
- }
37
- export { verifyFlags as n, createValidator as t };
38
-
39
- //# sourceMappingURL=verify-common-CzG3zw3J.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-common-CzG3zw3J.js","names":["sharedFlags"],"sources":["../src/actions/verify/verify-common.ts"],"sourcesContent":["import chalk from 'chalk'\nimport type {TypedFlags} from 'meow'\nimport outdent from 'outdent'\n\nimport sharedFlags from '../../sharedFlags'\nimport log from '../../util/log'\n\nconst splitLine = `\\n----------------------------------------------------------`\n\nexport const verifyPackageConfigDefaults = {\n 'packageName': true,\n 'esmOnly': true,\n 'tsconfig': true,\n 'dependencies': true,\n 'deprecatedDependencies': true,\n 'babelConfig': true,\n 'incompatiblePlugin': true,\n 'scripts': true,\n 'pkg-utils': true,\n 'nodeEngine': true,\n 'studioConfig': true,\n 'srcIndex': true,\n 'bannedFiles': true,\n 'oxfmt': true,\n 'oxlint': true,\n} as const\n\nexport type VerifyPackageConfig = Partial<Record<keyof typeof verifyPackageConfigDefaults, boolean>>\n\nexport const verifyFlags = {\n ...sharedFlags,\n single: {\n default: false,\n type: 'boolean',\n },\n} as const\n\nexport type VerifyFlags = TypedFlags<typeof verifyFlags>\n\nfunction disableCheckText(checkKey: string) {\n return chalk.grey(\n outdent`\n To skip this validation add the following to your package.json:\n \"sanityPlugin\": {\n \"verifyPackage\": {\n \"${checkKey}\": false\n }\n }\n `.trimStart(),\n )\n}\n\nexport function createValidator(\n verifyConfig: VerifyPackageConfig,\n flags: VerifyFlags,\n errors: string[],\n) {\n return async function validation(\n checkKey: keyof VerifyPackageConfig,\n task: () => Promise<string[] | undefined>,\n ) {\n if (verifyConfig[checkKey] !== false) {\n const result = await task()\n if (result?.length) {\n result.push(disableCheckText(checkKey))\n const errorMessage = result.join('\\n\\n')\n errors.push(errorMessage)\n log.error(`\\n` + errorMessage + splitLine)\n }\n }\n\n if (flags.single && errors.length) {\n throw new Error(\n outdent`Detected outstanding upgrade issues.\n\n Fail-fast (--single) mode enabled, stopping validation here.\n `,\n )\n }\n }\n}\n"],"mappings":";;;AAOA,MAsBa,cAAc;CACzB,GAAGA;CACH,QAAQ;EACN,SAAS;EACT,MAAM;CACR;AACF;AAIA,SAAS,iBAAiB,UAAkB;CAC1C,OAAO,MAAM,KACX,OAAO;;;;uBAIY,SAAS;;;YAGpB,UAAU,CACpB;AACF;AAEA,SAAgB,gBACd,cACA,OACA,QACA;CACA,OAAO,eACL,UACA,MACA;EACA,IAAI,aAAa,cAAc,IAAO;GACpC,IAAM,SAAS,MAAM,KAAK;GAC1B,IAAI,QAAQ,QAAQ;IAClB,OAAO,KAAK,iBAAiB,QAAQ,CAAC;IACtC,IAAM,eAAe,OAAO,KAAK,MAAM;IAEvC,AADA,OAAO,KAAK,YAAY,GACxB,YAAI,MAAM,OAAO,eAAe,8DAAS;GAC3C;EACF;EAEA,IAAI,MAAM,UAAU,OAAO,QACzB,MAAU,MACR,OAAO;;;SAIT;CAEJ;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-package-Dala-0lE.js","names":[],"sources":["../src/util/ts.ts","../src/actions/verify-package.ts","../src/cmds/verify-package.ts"],"sourcesContent":["import path from 'path'\n\n// The JS compiler API is loaded from the official `@typescript/typescript6` compat package\n// instead of the `typescript` peer dependency, as TypeScript 7 (the Go-native compiler) no longer\n// ships it\nimport * as ts from '@typescript/typescript6'\n\nimport {fileExists} from './files'\n\nexport async function readTSConfig(options: {basePath: string; filename: string}) {\n const {basePath, filename} = options\n const filePath = path.resolve(basePath, filename)\n const exists = await fileExists(filePath)\n\n if (!exists) return undefined\n\n const {config} = ts.readConfigFile(filePath, ts.sys.readFile)\n\n if (!config) return undefined\n\n return ts.parseJsonConfigFileContent(config, ts.sys, basePath)\n}\n","import chalk from 'chalk'\nimport outdent from 'outdent'\n\nimport {cliName, defaultOutDir, urls} from '../constants'\nimport {getPackage} from '../npm/package'\nimport {loadPackageConfig} from '../util/load-package-config'\nimport log from '../util/log'\nimport {readTSConfig} from '../util/ts'\nimport type {PackageJson} from './verify/types'\nimport {\n validateBabelConfig,\n validateEsmOnly,\n validateNodeEngine,\n validatePackageName,\n validatePackageType,\n validatePkgUtilsDependency,\n validatePkgUtilsVersion,\n validateIncompatiblePlugin,\n validateDeprecatedDependencies,\n validateScripts,\n validateTsConfig,\n validateSanityDependencies,\n validateSrcIndexFile,\n validateBannedFiles,\n validateOxfmtConfig,\n validateOxlintConfig,\n} from './verify/validations'\nimport {createValidator, type VerifyFlags, type VerifyPackageConfig} from './verify/verify-common'\n\nexport async function verifyPackage({basePath, flags}: {basePath: string; flags: VerifyFlags}) {\n let errors: string[] = []\n\n const packageJson: PackageJson = await getPackage({basePath, validate: false})\n const verifyConfig: VerifyPackageConfig = packageJson.sanityPlugin?.verifyPackage || {}\n\n // Hard requirements (not configurable via sanityPlugin.verifyPackage): plugins must be ESM and\n // ship a compatible @sanity/pkg-utils, since plugin-kit loads package.config.ts through it.\n for (const hardError of [\n ...validatePackageType(packageJson),\n ...validatePkgUtilsVersion({basePath}),\n ]) {\n errors.push(hardError)\n log.error(`\\n${hardError}`)\n }\n\n // Load defensively: if the config can't be loaded (e.g. incompatible/missing pkg-utils), fall\n // back to defaults so the remaining checks still surface actionable issues.\n let packageConfig\n try {\n packageConfig = await loadPackageConfig({basePath})\n } catch (err) {\n log.debug('Failed to load package.config: %s', err)\n }\n const outDir = packageConfig?.dist ?? defaultOutDir\n const tsconfig = packageConfig?.tsconfig ?? 'tsconfig.json'\n\n const validation = createValidator(verifyConfig, flags, errors)\n\n const ts = await readTSConfig({basePath, filename: tsconfig})\n\n await validation('packageName', async () => validatePackageName(packageJson))\n await validation('esmOnly', async () => validateEsmOnly(packageJson))\n await validation('pkg-utils', async () => validatePkgUtilsDependency(packageJson))\n await validation('srcIndex', async () => validateSrcIndexFile(basePath))\n await validation('bannedFiles', async () => validateBannedFiles(packageJson))\n await validation('scripts', async () => validateScripts(packageJson))\n await validation('nodeEngine', async () => validateNodeEngine(packageJson))\n await validation('oxfmt', async () => validateOxfmtConfig(basePath, packageJson))\n await validation('oxlint', async () => validateOxlintConfig(basePath, packageJson))\n\n if (ts) {\n await validation('tsconfig', async () => validateTsConfig(ts, {basePath, outDir, tsconfig}))\n }\n\n await validation('incompatiblePlugin', async () =>\n validateIncompatiblePlugin({basePath, packageJson}),\n )\n\n await validation('babelConfig', async () => validateBabelConfig({basePath}))\n\n await validation('dependencies', async () => validateSanityDependencies(packageJson))\n await validation('deprecatedDependencies', async () =>\n validateDeprecatedDependencies(packageJson),\n )\n\n if (errors.length) {\n throw new Error(\n outdent`\n Detected validation issues!\n To make this package Sanity v3 compatible, fix the issues starting from the top, or disable any checks you deem unnecessary.\n\n These issues assume the package uses @sanity/plugin-kit defaults for development and building.\n Refer to ${urls.pluginReadme} for configuration options.\n\n More information is available here:\n - Studio migration guide: ${urls.migrationGuideStudio}\n - Plugin migration guide: ${urls.migrationGuidePlugin}\n - Reference documentation: ${urls.refDocs}\n\n ${chalk.grey(\n `To fail-fast on first detected issue run:\\nnpx ${cliName} verify-package --single`,\n )}\n `.trimStart(),\n )\n }\n\n log.success(\n outdent`\n No outstanding upgrade issues detected.\n\n Suggested next steps:\n - Use plugin-kit to build and develop the plugin according to ${urls.pluginReadme}.\n - Build the plugin and fix any compilation errors\n - Test the plugin using the link-watch command\n `.trim(),\n )\n}\n","import path from 'path'\n\nimport meow from 'meow'\n\nimport {verifyPackage} from '../actions/verify-package'\nimport {verifyFlags} from '../actions/verify/verify-common'\nimport {cliName} from '../constants'\n\nconst description = `Verify that a Sanity plugin package is v3 compatible, and print upgrade steps if not.`\n\nconst help = `\nUsage\n $ ${cliName} verify-package [dir] [<args>]\n\nOptions\n --single Enables fail-fast mode: Will only output the first validation that fails.\n --silent Do not print info and warning messages\n --verbose Log everything. This option conflicts with --silent\n --version Output the version number\n --help Output usage information\n\nEach check will describe how they can be individually disabled.\n\nExamples\n # Verify Sanity plugin package in current directory\n $ ${cliName} verify-package\n\n # Verify Sanity plugin package in my-plugin directory in silent mode\n $ ${cliName} verify-package my-plugin-directory --silent\n`\n\nfunction run({argv}: {argv: string[]}) {\n const cli = meow(help, {flags: verifyFlags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n return verifyPackage({basePath, flags: cli.flags})\n}\n\n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AAY,mBAAmB,WAAW,CAAC,GAC1E,MAAM,WAAW,SAAS,YAAY,oBAAoB,UAAU,WAAW,CAAC,GAChF,MAAM,WAAW,UAAU,YAAY,qBAAqB,UAAU,WAAW,CAAC,GAE9E,MACF,MAAM,WAAW,YAAY,YAAY,iBAAiB,IAAI;EAAC;EAAU;EAAQ;CAAQ,CAAC,CAAC,GAG7F,MAAM,WAAW,sBAAsB,YACrC,2BAA2B;EAAC;EAAU;CAAW,CAAC,CACpD,GAEA,MAAM,WAAW,eAAe,YAAY,oBAAoB,EAAC,SAAQ,CAAC,CAAC,GAE3E,MAAM,WAAW,gBAAgB,YAAY,2BAA2B,WAAW,CAAC,GACpF,MAAM,WAAW,0BAA0B,YACzC,+BAA+B,WAAW,CAC5C,GAEI,OAAO,QACT,MAAU,MACR,OAAO;;;;;mBAKM,KAAK,aAAa;;;oCAGD,KAAK,qBAAqB;oCAC1B,KAAK,qBAAqB;qCACzB,KAAK,QAAQ;;UAExC,MAAM,KACN,kDAAkD,QAAQ,yBAC5D,EAAE;QACF,UAAU,CACd;CAGF,YAAI,QACF,OAAO;;;;sEAI2D,KAAK,aAAa;;;IAGpF,KAAK,CACP;AACF;AC5GA,MAEM,OAAO;;MAEP,QAAQ;;;;;;;;;;;;;MAaR,QAAQ;;;MAGR,QAAQ;;AAGd,SAAS,IAAI,EAAC,QAAyB;CACrC,IAAM,MAAM,KAAK,MAAM;EAAC,OAAO;EAAa;EAAM;CAAW,CAAC;CAE9D,OAAO,cAAc;EAAC,UADL,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CAC7B;EAAG,OAAO,IAAI;CAAK,CAAC;AACnD"}
@@ -1,61 +0,0 @@
1
- import { a as urls, t as cliName } from "./constants-BLTUL_Wd.js";
2
- import { t as log_default } from "./log-DgQL-Rv9.js";
3
- import { A as validateStudioConfig, D as validateSanityDependencies, a as getPackage } from "./package-B_o7MhuL.js";
4
- import { n as verifyFlags, t as createValidator } from "./verify-common-CzG3zw3J.js";
5
- import meow from "meow";
6
- import chalk from "chalk";
7
- import path from "path";
8
- import outdent from "outdent";
9
- async function verifyStudio({ basePath, flags }) {
10
- let errors = [], packageJson = await getPackage({
11
- basePath,
12
- validate: !1
13
- }), validation = createValidator(packageJson.sanityPlugin?.verifyPackage || {}, flags, errors);
14
- if (await validation("studioConfig", async () => validateStudioConfig({ basePath })), await validation("dependencies", async () => validateSanityDependencies(packageJson)), errors.length) throw Error(outdent`
15
- Detected validation issues!
16
- This Sanity Studio is not completely V3 ready. Fix the issues starting from the top, or disable any checks you deem unnecessary.
17
-
18
- More information is available here:
19
- - Migration guide: ${urls.migrationGuideStudio}
20
- - Reference documentation: ${urls.refDocs}
21
-
22
- ${chalk.grey(`To fail-fast on first detected issue run:\nnpx ${cliName} verify-studio --single`)}
23
- `.trimStart());
24
- log_default.success(outdent`
25
- No outstanding upgrade issues detected. Studio is V3 ready!
26
- `.trim());
27
- }
28
- const help = `
29
- Usage
30
- $ ${cliName} verify-studio [dir] [<args>]
31
-
32
- Options
33
- --single Enables fail-fast mode: Will only output the first validation that fails.
34
- --silent Do not print info and warning messages
35
- --verbose Log everything. This option conflicts with --silent
36
- --version Output the version number
37
- --help Output usage information
38
-
39
- Each check will describe how they can be individually disabled.
40
-
41
- Examples
42
- # Verify Sanity Studio in current directory
43
- $ ${cliName} verify-studio
44
-
45
- # Verify Sanity Studio in my-sanity-studio directory in silent mode
46
- $ ${cliName} verify-studio my-sanity-studio --silent
47
- `;
48
- function run({ argv }) {
49
- let cli = meow(help, {
50
- flags: verifyFlags,
51
- argv,
52
- description: "Verify that a Sanity Studio is configured correctly for v3, and print upgrade steps if not."
53
- });
54
- return verifyStudio({
55
- basePath: path.resolve(cli.input[0] || process.cwd()),
56
- flags: cli.flags
57
- });
58
- }
59
- export { run as default };
60
-
61
- //# sourceMappingURL=verify-studio-Cg8aSAky.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-studio-Cg8aSAky.js","names":[],"sources":["../src/actions/verify-studio.ts","../src/cmds/verify-studio.ts"],"sourcesContent":["import chalk from 'chalk'\nimport outdent from 'outdent'\n\nimport {cliName, urls} from '../constants'\nimport {getPackage} from '../npm/package'\nimport log from '../util/log'\nimport type {PackageJson} from './verify/types'\nimport {validateSanityDependencies, validateStudioConfig} from './verify/validations'\nimport {createValidator, type VerifyFlags, type VerifyPackageConfig} from './verify/verify-common'\n\nexport async function verifyStudio({basePath, flags}: {basePath: string; flags: VerifyFlags}) {\n let errors: string[] = []\n\n const packageJson: PackageJson = await getPackage({basePath, validate: false})\n const verifyConfig: VerifyPackageConfig = packageJson.sanityPlugin?.verifyPackage || {}\n\n const validation = createValidator(verifyConfig, flags, errors)\n\n await validation('studioConfig', async () => validateStudioConfig({basePath}))\n await validation('dependencies', async () => validateSanityDependencies(packageJson))\n\n if (errors.length) {\n throw new Error(\n outdent`\n Detected validation issues!\n This Sanity Studio is not completely V3 ready. Fix the issues starting from the top, or disable any checks you deem unnecessary.\n\n More information is available here:\n - Migration guide: ${urls.migrationGuideStudio}\n - Reference documentation: ${urls.refDocs}\n\n ${chalk.grey(\n `To fail-fast on first detected issue run:\\nnpx ${cliName} verify-studio --single`,\n )}\n `.trimStart(),\n )\n }\n\n log.success(\n outdent`\n No outstanding upgrade issues detected. Studio is V3 ready!\n `.trim(),\n )\n}\n","import path from 'path'\n\nimport meow from 'meow'\n\nimport {verifyStudio} from '../actions/verify-studio'\nimport {verifyFlags} from '../actions/verify/verify-common'\nimport {cliName} from '../constants'\n\nconst description = `Verify that a Sanity Studio is configured correctly for v3, and print upgrade steps if not.`\n\nconst help = `\nUsage\n $ ${cliName} verify-studio [dir] [<args>]\n\nOptions\n --single Enables fail-fast mode: Will only output the first validation that fails.\n --silent Do not print info and warning messages\n --verbose Log everything. This option conflicts with --silent\n --version Output the version number\n --help Output usage information\n\nEach check will describe how they can be individually disabled.\n\nExamples\n # Verify Sanity Studio in current directory\n $ ${cliName} verify-studio\n\n # Verify Sanity Studio in my-sanity-studio directory in silent mode\n $ ${cliName} verify-studio my-sanity-studio --silent\n`\n\nfunction run({argv}: {argv: string[]}) {\n const cli = meow(help, {flags: verifyFlags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n return verifyStudio({basePath, flags: cli.flags})\n}\n\nexport default run\n"],"mappings":";;;;;;;;AAUA,eAAsB,aAAa,EAAC,UAAU,SAAgD;CAC5F,IAAI,SAAmB,CAAC,GAElB,cAA2B,MAAM,WAAW;EAAC;EAAU,UAAU;CAAK,CAAC,GAGvE,aAAa,gBAFuB,YAAY,cAAc,iBAAiB,CAAC,GAErC,OAAO,MAAM;CAK9D,IAHA,MAAM,WAAW,gBAAgB,YAAY,qBAAqB,EAAC,SAAQ,CAAC,CAAC,GAC7E,MAAM,WAAW,gBAAgB,YAAY,2BAA2B,WAAW,CAAC,GAEhF,OAAO,QACT,MAAU,MACR,OAAO;;;;;6BAKgB,KAAK,qBAAqB;qCAClB,KAAK,QAAQ;;UAExC,MAAM,KACN,kDAAkD,QAAQ,wBAC5D,EAAE;QACF,UAAU,CACd;CAGF,YAAI,QACF,OAAO;;IAEP,KAAK,CACP;AACF;ACnCA,MAEM,OAAO;;MAEP,QAAQ;;;;;;;;;;;;;MAaR,QAAQ;;;MAGR,QAAQ;;AAGd,SAAS,IAAI,EAAC,QAAyB;CACrC,IAAM,MAAM,KAAK,MAAM;EAAC,OAAO;EAAa;EAAM;CAAW,CAAC;CAE9D,OAAO,aAAa;EAAC,UADJ,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CAC9B;EAAG,OAAO,IAAI;CAAK,CAAC;AAClD"}