@sanity/plugin-kit 10.0.2 → 10.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,19 +3,19 @@ import { n as sharedFlags_default, t as log_default } from "./log-2MbSIFbq.js";
3
3
  import meow from "meow";
4
4
  var cmds_default = {
5
5
  init: async (options) => {
6
- await (await import("./init-CxV0isMf.js")).default(options);
6
+ await (await import("./init-BFGYqxQX.js")).default(options);
7
7
  },
8
8
  inject: async (options) => {
9
- await (await import("./inject-CBH4g4tr.js")).default(options);
9
+ await (await import("./inject-7ku0wDBp.js")).default(options);
10
10
  },
11
11
  "link-watch": async (options) => {
12
- await (await import("./link-watch-yx9QxBJi.js")).default(options);
12
+ await (await import("./link-watch-B_Tw6Ed0.js")).default(options);
13
13
  },
14
14
  "verify-package": async (options) => {
15
- await (await import("./verify-package-wurW9wW2.js")).default(options);
15
+ await (await import("./verify-package-Cm62CGGp.js")).default(options);
16
16
  },
17
17
  version: async (options) => {
18
- (await import("./version-BjoOWC3p.js")).default(options);
18
+ (await import("./version-BX9-ERrR.js")).default(options);
19
19
  }
20
20
  };
21
21
  /** @public */
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["sharedFlags","commands"],"sources":["../src/cmds/index.ts","../src/cli.ts"],"sourcesContent":["export default {\n 'init': async (options: {argv: string[]}) => {\n await (await import('./init')).default(options)\n },\n 'inject': async (options: {argv: string[]}) => {\n await (await import('./inject')).default(options)\n },\n 'link-watch': async (options: {argv: string[]}) => {\n await (await import('./link-watch')).default(options)\n },\n 'verify-package': async (options: {argv: string[]}) => {\n await (await import('./verify-package')).default(options)\n },\n 'version': async (options: {argv: string[]}) => {\n ;(await import('./version')).default(options)\n },\n}\n","import meow from 'meow'\n\nimport commands from './cmds'\nimport {cliName} from './constants'\nimport sharedFlags from './sharedFlags'\nimport log from './util/log'\n\n/** @public */\nexport async function cliEntry(argv = process.argv) {\n const cli = meow(\n `\n\tUsage\n\t $ ${cliName} [--help] [--debug] <command> [<args>]\n\n These are common commands used in various situations:\n\n init Create a new Sanity plugin\n inject Inject config into an existing Sanity plugin\n verify-package Check that a Sanity plugin package follows plugin-kit conventions\n link-watch Recompiles plugin automatically on changes and runs yalc push --publish\n version Show the version of ${cliName} currently installed\n\n Options\n --silent Do not print info and warning messages\n --verbose Log everything. This option conflicts with --silent\n --debug Print stack trace on errors\n --version Output the version number\n --help Output usage information\n\n Examples\n # Init a new plugin in current directory\n $ ${cliName} init\n\n # Init a new plugin in my-sanity-plugin directory\n $ ${cliName} init my-sanity-plugin\n\n # Check that a Sanity plugin package in current directory follows plugin-kit conventions\n $ ${cliName} verify-package\n`,\n {\n importMeta: import.meta,\n autoHelp: false,\n flags: sharedFlags,\n argv: argv.slice(2),\n },\n )\n\n const commandName = cli.input[0]\n if (!commandName) {\n cli.showHelp() // Exits\n }\n\n if (!(commandName in commands)) {\n console.error(`Unknown command \"${commandName}\"`)\n cli.showHelp() // Exits\n }\n\n if (cli.flags.silent && cli.flags.verbose) {\n log.error(`--silent and --verbose are mutually exclusive`)\n cli.showHelp() // Exits\n }\n\n // Lazy-load command\n const cmd = commands[commandName as keyof typeof commands]\n\n try {\n log.setVerbosity(cli.flags)\n await cmd({argv: argv.slice(3)})\n } catch (err: any) {\n log.error(err instanceof TypeError || cli.flags.debug ? err.stack : err.message)\n\n process.exit(1)\n }\n}\n"],"mappings":";;;AAAA,IAAA,eAAe;CACb,MAAQ,OAAO,YAA8B;EAC3C,OAAO,MAAM,OAAO,sBAAA,CAAW,QAAQ,OAAO;CAChD;CACA,QAAU,OAAO,YAA8B;EAC7C,OAAO,MAAM,OAAO,wBAAA,CAAa,QAAQ,OAAO;CAClD;CACA,cAAc,OAAO,YAA8B;EACjD,OAAO,MAAM,OAAO,4BAAA,CAAiB,QAAQ,OAAO;CACtD;CACA,kBAAkB,OAAO,YAA8B;EACrD,OAAO,MAAM,OAAO,gCAAA,CAAqB,QAAQ,OAAO;CAC1D;CACA,SAAW,OAAO,YAA8B;EAC7C,CAAC,MAAM,OAAO,yBAAA,CAAc,QAAQ,OAAO;CAC9C;AACF;;ACRA,eAAsB,SAAS,OAAO,QAAQ,MAAM;CAClD,IAAM,MAAM,KACV;;OAEG,QAAQ;;;;;;;;0CAQ2B,QAAQ;;;;;;;;;;;QAW1C,QAAQ;;;QAGR,QAAQ;;;QAGR,QAAQ;GAEZ;EACE,YAAY,OAAO;EACnB,UAAU;EACV,OAAOA;EACP,MAAM,KAAK,MAAM,CAAC;CACpB,CACF,GAEM,cAAc,IAAI,MAAM;CAU9B,AATK,eACH,IAAI,SAAS,GAGT,eAAeC,iBACnB,QAAQ,MAAM,oBAAoB,YAAY,EAAE,GAChD,IAAI,SAAS,IAGX,IAAI,MAAM,UAAU,IAAI,MAAM,YAChC,YAAI,MAAM,+CAA+C,GACzD,IAAI,SAAS;CAIf,IAAM,MAAMA,aAAS;CAErB,IAAI;EAEF,AADA,YAAI,aAAa,IAAI,KAAK,GAC1B,MAAM,IAAI,EAAC,MAAM,KAAK,MAAM,CAAC,EAAC,CAAC;CACjC,SAAS,KAAU;EAGjB,AAFA,YAAI,MAAM,eAAe,aAAa,IAAI,MAAM,QAAQ,IAAI,QAAQ,IAAI,OAAO,GAE/E,QAAQ,KAAK,CAAC;CAChB;AACF"}
1
+ {"version":3,"file":"index.js","names":["sharedFlags","commands"],"sources":["../src/cmds/index.ts","../src/cli.ts"],"sourcesContent":["export default {\n 'init': async (options: {argv: string[]}) => {\n await (await import('./init')).default(options)\n },\n 'inject': async (options: {argv: string[]}) => {\n await (await import('./inject')).default(options)\n },\n 'link-watch': async (options: {argv: string[]}) => {\n await (await import('./link-watch')).default(options)\n },\n 'verify-package': async (options: {argv: string[]}) => {\n await (await import('./verify-package')).default(options)\n },\n 'version': async (options: {argv: string[]}) => {\n ;(await import('./version')).default(options)\n },\n}\n","import meow from 'meow'\n\nimport commands from './cmds'\nimport {cliName} from './constants'\nimport sharedFlags from './sharedFlags'\nimport log from './util/log'\n\n/** @public */\nexport async function cliEntry(argv = process.argv) {\n const cli = meow(\n `\n\tUsage\n\t $ ${cliName} [--help] [--debug] <command> [<args>]\n\n These are common commands used in various situations:\n\n init Create a new Sanity plugin\n inject Inject config into an existing Sanity plugin\n verify-package Check that a Sanity plugin package follows plugin-kit conventions\n link-watch Recompiles plugin automatically on changes and runs yalc push --publish\n version Show the version of ${cliName} currently installed\n\n Options\n --silent Do not print info and warning messages\n --verbose Log everything. This option conflicts with --silent\n --debug Print stack trace on errors\n --version Output the version number\n --help Output usage information\n\n Examples\n # Init a new plugin in current directory\n $ ${cliName} init\n\n # Init a new plugin in my-sanity-plugin directory\n $ ${cliName} init my-sanity-plugin\n\n # Check that a Sanity plugin package in current directory follows plugin-kit conventions\n $ ${cliName} verify-package\n`,\n {\n importMeta: import.meta,\n autoHelp: false,\n flags: sharedFlags,\n argv: argv.slice(2),\n },\n )\n\n const commandName = cli.input[0]\n if (!commandName) {\n cli.showHelp() // Exits\n }\n\n if (!(commandName in commands)) {\n console.error(`Unknown command \"${commandName}\"`)\n cli.showHelp() // Exits\n }\n\n if (cli.flags.silent && cli.flags.verbose) {\n log.error(`--silent and --verbose are mutually exclusive`)\n cli.showHelp() // Exits\n }\n\n // Lazy-load command\n const cmd = commands[commandName as keyof typeof commands]\n\n try {\n log.setVerbosity(cli.flags)\n await cmd({argv: argv.slice(3)})\n } catch (err: any) {\n log.error(err instanceof TypeError || cli.flags.debug ? err.stack : err.message)\n\n process.exit(1)\n }\n}\n"],"mappings":";;;AAAA,IAAA,eAAe;CACb,MAAQ,OAAO,YAA8B;EAC3C,OAAO,MAAM,OAAO,sBAAA,CAAW,QAAQ,OAAO;CAChD;CACA,QAAU,OAAO,YAA8B;EAC7C,OAAO,MAAM,OAAO,wBAAA,CAAa,QAAQ,OAAO;CAClD;CACA,cAAc,OAAO,YAA8B;EACjD,OAAO,MAAM,OAAO,4BAAA,CAAiB,QAAQ,OAAO;CACtD;CACA,kBAAkB,OAAO,YAA8B;EACrD,OAAO,MAAM,OAAO,gCAAA,CAAqB,QAAQ,OAAO;CAC1D;CACA,SAAW,OAAO,YAA8B;EAC7C,CAAC,MAAM,OAAO,yBAAA,CAAc,QAAQ,OAAO;CAC9C;AACF;;ACRA,eAAsB,SAAS,OAAO,QAAQ,MAAM;CAClD,IAAM,MAAM,KACV;;OAEG,QAAQ;;;;;;;;0CAQ2B,QAAQ;;;;;;;;;;;QAW1C,QAAQ;;;QAGR,QAAQ;;;QAGR,QAAQ;GAEZ;EACE,YAAY;EACZ,UAAU;EACV,OAAOA;EACP,MAAM,KAAK,MAAM,CAAC;CACpB,CACF,GAEM,cAAc,IAAI,MAAM;CAU9B,AATK,eACH,IAAI,SAAS,GAGT,eAAeC,iBACnB,QAAQ,MAAM,oBAAoB,YAAY,EAAE,GAChD,IAAI,SAAS,IAGX,IAAI,MAAM,UAAU,IAAI,MAAM,YAChC,YAAI,MAAM,+CAA+C,GACzD,IAAI,SAAS;CAIf,IAAM,MAAMA,aAAS;CAErB,IAAI;EAEF,AADA,YAAI,aAAa,IAAI,KAAK,GAC1B,MAAM,IAAI,EAAC,MAAM,KAAK,MAAM,CAAC,EAAC,CAAC;CACjC,SAAS,KAAU;EAGjB,AAFA,YAAI,MAAM,eAAe,aAAa,IAAI,MAAM,QAAQ,IAAI,QAAQ,IAAI,OAAO,GAE/E,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { t as cliName } from "./constants-BIVJp2Jy.js";
2
2
  import { t as log_default } from "./log-2MbSIFbq.js";
3
3
  import { D as ensureDir, F as prompt, k as isEmptyish } from "./package-8cUY5BVf.js";
4
- import { a as presetHelpList, n as init, r as initFlags, t as findStudioConfig } from "./studio-detect-DXA9mBQK.js";
4
+ import { a as presetHelpList, n as init, r as initFlags, t as findStudioConfig } from "./studio-detect-B4gMDmeH.js";
5
5
  import meow from "meow";
6
6
  import path from "path";
7
7
  import { execa } from "execa";
@@ -100,4 +100,4 @@ async function run({ argv }) {
100
100
  }
101
101
  export { run as default };
102
102
 
103
- //# sourceMappingURL=init-CxV0isMf.js.map
103
+ //# sourceMappingURL=init-BFGYqxQX.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-CxV0isMf.js","names":[],"sources":["../src/npm/manager.ts","../src/cmds/init.ts"],"sourcesContent":["import {execa} from 'execa'\n\nimport {prompt} from '../util/prompt'\n\nfunction npmIsAvailable() {\n return execa('npm', ['-v'])\n .then(() => true)\n .catch(() => false)\n}\n\nfunction yarnIsAvailable() {\n return execa('yarn', ['-v'])\n .then(() => true)\n .catch(() => false)\n}\n\nfunction pnpmAvailable() {\n return execa('pnpm', ['-v'])\n .then(() => true)\n .catch(() => false)\n}\n\nexport async function promptForPackageManager() {\n const [npm, yarn, pnpm] = await Promise.all([\n npmIsAvailable(),\n yarnIsAvailable(),\n pnpmAvailable(),\n ])\n\n const choices = [npm && 'npm', yarn && 'yarn', pnpm && 'pnpm'].filter(Boolean)\n if (choices.length < 2) {\n return choices[0] || 'npm'\n }\n\n return prompt('Which package manager do you prefer?', {\n choices: choices.map((value) => ({value, name: value})),\n default: choices[0],\n })\n}\n\nexport async function installDependencies(pm: string, {cwd}: {cwd?: string}) {\n // `reject: false` covers non-zero exits; try/catch covers spawn failures (e.g. ENOENT\n // when the package manager binary is missing) so the caller can print its hint\n try {\n const {exitCode} = await execa(pm, ['install'], {cwd, stdio: 'inherit', reject: false})\n return exitCode === 0\n } catch {\n return false\n }\n}\n","import path from 'path'\n\nimport meow from 'meow'\n\nimport {init, initFlags} from '../actions/init'\nimport {cliName} from '../constants'\nimport {installDependencies, promptForPackageManager} from '../npm/manager'\nimport {presetHelpList} from '../presets/presets'\nimport {findStudioConfig} from '../sanity/studio-detect'\nimport {isEmptyish, ensureDir} from '../util/files'\nimport log from '../util/log'\nimport {prompt} from '../util/prompt'\n\nconst description = `Initialize a new Sanity plugin`\n\nconst help = `\nUsage\n $ ${cliName} init [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 --no-install Disables automatically running package manager install\n\n --name [package-name] Use the provided package-name\n --author [name] Use the provided author\n --repo [url] Use the provided repo url\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\nExamples\n # Initialize a new plugin in the current directory\n $ ${cliName} init\n\n # Initialize a plugin in the directory ~/my-plugin\n $ ${cliName} init ~/my-plugin\n\n # Don't add oxlint or oxfmt\n $ ${cliName} init --no-oxlint --no-oxfmt\n`\n\nasync function run({argv}: {argv: string[]}) {\n const cli = meow(help, {importMeta: import.meta, flags: initFlags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n\n const {configFile} = await findStudioConfig(basePath)\n if (configFile) {\n throw new Error(\n `${configFile} exists - are you trying to init into a studio instead of a plugin?`,\n )\n }\n\n log.info('Initializing new plugin in \"%s\"', basePath)\n if (\n !cli.flags.force &&\n !(await isEmptyish(basePath)) &&\n !(await prompt('Directory is not empty, proceed?', {type: 'confirm', default: false}))\n ) {\n log.error('Directory is not empty. Cancelled.')\n return\n }\n\n await ensureDir(basePath)\n await init({basePath, flags: cli.flags})\n if (cli.flags.install) {\n if (await installDependencies(await promptForPackageManager(), {cwd: basePath})) {\n log.info('Done!')\n } else {\n log.error('Failed to install dependencies, try manually running `npm install`')\n }\n } else {\n log.info('Dependency installation skipped.')\n }\n}\n\nexport default run\n"],"mappings":";;;;;;;AAIA,SAAS,iBAAiB;CACxB,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CACxB,WAAW,EAAI,CAAC,CAChB,YAAY,EAAK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,IADA,YAAI,KAAK,qCAAmC,QAAQ,GAElD,CAAC,IAAI,MAAM,SACX,CAAE,MAAM,WAAW,QAAQ,KAC3B,CAAE,MAAM,OAAO,oCAAoC;EAAC,MAAM;EAAW,SAAS;CAAK,CAAC,GACpF;EACA,YAAI,MAAM,oCAAoC;EAC9C;CACF;CAIA,AAFA,MAAM,UAAU,QAAQ,GACxB,MAAM,KAAK;EAAC;EAAU,OAAO,IAAI;CAAK,CAAC,GACnC,IAAI,MAAM,UACR,MAAM,oBAAoB,MAAM,wBAAwB,GAAG,EAAC,KAAK,SAAQ,CAAC,IAC5E,YAAI,KAAK,OAAO,IAEhB,YAAI,MAAM,oEAAoE,IAGhF,YAAI,KAAK,kCAAkC;AAE/C"}
1
+ {"version":3,"file":"init-BFGYqxQX.js","names":[],"sources":["../src/npm/manager.ts","../src/cmds/init.ts"],"sourcesContent":["import {execa} from 'execa'\n\nimport {prompt} from '../util/prompt'\n\nfunction npmIsAvailable() {\n return execa('npm', ['-v'])\n .then(() => true)\n .catch(() => false)\n}\n\nfunction yarnIsAvailable() {\n return execa('yarn', ['-v'])\n .then(() => true)\n .catch(() => false)\n}\n\nfunction pnpmAvailable() {\n return execa('pnpm', ['-v'])\n .then(() => true)\n .catch(() => false)\n}\n\nexport async function promptForPackageManager() {\n const [npm, yarn, pnpm] = await Promise.all([\n npmIsAvailable(),\n yarnIsAvailable(),\n pnpmAvailable(),\n ])\n\n const choices = [npm && 'npm', yarn && 'yarn', pnpm && 'pnpm'].filter(Boolean)\n if (choices.length < 2) {\n return choices[0] || 'npm'\n }\n\n return prompt('Which package manager do you prefer?', {\n choices: choices.map((value) => ({value, name: value})),\n default: choices[0],\n })\n}\n\nexport async function installDependencies(pm: string, {cwd}: {cwd?: string}) {\n // `reject: false` covers non-zero exits; try/catch covers spawn failures (e.g. ENOENT\n // when the package manager binary is missing) so the caller can print its hint\n try {\n const {exitCode} = await execa(pm, ['install'], {cwd, stdio: 'inherit', reject: false})\n return exitCode === 0\n } catch {\n return false\n }\n}\n","import path from 'path'\n\nimport meow from 'meow'\n\nimport {init, initFlags} from '../actions/init'\nimport {cliName} from '../constants'\nimport {installDependencies, promptForPackageManager} from '../npm/manager'\nimport {presetHelpList} from '../presets/presets'\nimport {findStudioConfig} from '../sanity/studio-detect'\nimport {isEmptyish, ensureDir} from '../util/files'\nimport log from '../util/log'\nimport {prompt} from '../util/prompt'\n\nconst description = `Initialize a new Sanity plugin`\n\nconst help = `\nUsage\n $ ${cliName} init [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 --no-install Disables automatically running package manager install\n\n --name [package-name] Use the provided package-name\n --author [name] Use the provided author\n --repo [url] Use the provided repo url\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\nExamples\n # Initialize a new plugin in the current directory\n $ ${cliName} init\n\n # Initialize a plugin in the directory ~/my-plugin\n $ ${cliName} init ~/my-plugin\n\n # Don't add oxlint or oxfmt\n $ ${cliName} init --no-oxlint --no-oxfmt\n`\n\nasync function run({argv}: {argv: string[]}) {\n const cli = meow(help, {importMeta: import.meta, flags: initFlags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n\n const {configFile} = await findStudioConfig(basePath)\n if (configFile) {\n throw new Error(\n `${configFile} exists - are you trying to init into a studio instead of a plugin?`,\n )\n }\n\n log.info('Initializing new plugin in \"%s\"', basePath)\n if (\n !cli.flags.force &&\n !(await isEmptyish(basePath)) &&\n !(await prompt('Directory is not empty, proceed?', {type: 'confirm', default: false}))\n ) {\n log.error('Directory is not empty. Cancelled.')\n return\n }\n\n await ensureDir(basePath)\n await init({basePath, flags: cli.flags})\n if (cli.flags.install) {\n if (await installDependencies(await promptForPackageManager(), {cwd: basePath})) {\n log.info('Done!')\n } else {\n log.error('Failed to install dependencies, try manually running `npm install`')\n }\n } else {\n log.info('Dependency installation skipped.')\n }\n}\n\nexport default run\n"],"mappings":";;;;;;;AAIA,SAAS,iBAAiB;CACxB,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CACxB,WAAW,EAAI,CAAC,CAChB,YAAY,EAAK;AACtB;AAEA,SAAS,kBAAkB;CACzB,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC,CACzB,WAAW,EAAI,CAAC,CAChB,YAAY,EAAK;AACtB;AAEA,SAAS,gBAAgB;CACvB,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC,CACzB,WAAW,EAAI,CAAC,CAChB,YAAY,EAAK;AACtB;AAEA,eAAsB,0BAA0B;CAC9C,IAAM,CAAC,KAAK,MAAM,QAAQ,MAAM,QAAQ,IAAI;EAC1C,eAAe;EACf,gBAAgB;EAChB,cAAc;CAChB,CAAC,GAEK,UAAU;EAAC,OAAO;EAAO,QAAQ;EAAQ,QAAQ;CAAM,CAAC,CAAC,OAAO,OAAO;CAK7E,OAJI,QAAQ,SAAS,IACZ,QAAQ,MAAM,QAGhB,OAAO,wCAAwC;EACpD,SAAS,QAAQ,KAAK,WAAW;GAAC;GAAO,MAAM;EAAK,EAAE;EACtD,SAAS,QAAQ;CACnB,CAAC;AACH;AAEA,eAAsB,oBAAoB,IAAY,EAAC,OAAsB;CAG3E,IAAI;EACF,IAAM,EAAC,aAAY,MAAM,MAAM,IAAI,CAAC,SAAS,GAAG;GAAC;GAAK,OAAO;GAAW,QAAQ;EAAK,CAAC;EACtF,OAAO,aAAa;CACtB,QAAQ;EACN,OAAO;CACT;AACF;ACpCA,MAEM,OAAO;;MAEP,QAAQ;;;;;;;;;;;;;;;;;;;;EAoBZ,eAAe,EAAE,EAAE;;;;MAIf,QAAQ;;;MAGR,QAAQ;;;MAGR,QAAQ;;AAGd,eAAe,IAAI,EAAC,QAAyB;CAC3C,IAAM,MAAM,KAAK,MAAM;EAAC,YAAY;EAAa,OAAO;EAAW;EAAM;CAAW,CAAC,GAC/E,WAAW,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CAAC,GAErD,EAAC,eAAc,MAAM,iBAAiB,QAAQ;CACpD,IAAI,YACF,MAAU,MACR,GAAG,WAAW,oEAChB;CAIF,IADA,YAAI,KAAK,qCAAmC,QAAQ,GAElD,CAAC,IAAI,MAAM,SACX,CAAE,MAAM,WAAW,QAAQ,KAC3B,CAAE,MAAM,OAAO,oCAAoC;EAAC,MAAM;EAAW,SAAS;CAAK,CAAC,GACpF;EACA,YAAI,MAAM,oCAAoC;EAC9C;CACF;CAIA,AAFA,MAAM,UAAU,QAAQ,GACxB,MAAM,KAAK;EAAC;EAAU,OAAO,IAAI;CAAK,CAAC,GACnC,IAAI,MAAM,UACR,MAAM,oBAAoB,MAAM,wBAAwB,GAAG,EAAC,KAAK,SAAQ,CAAC,IAC5E,YAAI,KAAK,OAAO,IAEhB,YAAI,MAAM,oEAAoE,IAGhF,YAAI,KAAK,kCAAkC;AAE/C"}
@@ -1,7 +1,7 @@
1
1
  import { t as cliName } from "./constants-BIVJp2Jy.js";
2
2
  import { t as log_default } from "./log-2MbSIFbq.js";
3
- import { a as presetHelpList, i as inject, r as initFlags, t as findStudioConfig } from "./studio-detect-DXA9mBQK.js";
4
- import { t as loadPackageConfig } from "./load-package-config-CHynlKXx.js";
3
+ import { a as presetHelpList, i as inject, r as initFlags, t as findStudioConfig } from "./studio-detect-B4gMDmeH.js";
4
+ import { t as loadPackageConfig } from "./load-package-config-BJhZa2CW.js";
5
5
  import meow from "meow";
6
6
  import path from "path";
7
7
  const help = `
@@ -59,4 +59,4 @@ async function run({ argv }) {
59
59
  }
60
60
  export { run as default };
61
61
 
62
- //# sourceMappingURL=inject-CBH4g4tr.js.map
62
+ //# sourceMappingURL=inject-7ku0wDBp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"inject-CBH4g4tr.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 {findStudioConfig} from '../sanity/studio-detect'\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, {importMeta: import.meta, 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 {configFile} = await findStudioConfig(basePath)\n if (configFile) {\n throw new Error(\n `${configFile} 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,YAAY,OAAO;EAAM,OAAO;EAAW;EAAM;CAAW,CAAC,GAC/E,WAAW,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CAAC,GAErD,UAAS,MADa,kBAAkB,EAAC,SAAQ,CAAC,EAAA,EAC1B,QAAA,QAExB,EAAC,eAAc,MAAM,iBAAiB,QAAQ;CACpD,IAAI,YACF,MAAU,MACR,GAAG,WAAW,sEAChB;CAKF,AAHA,YAAI,KAAK,uCAAqC,QAAQ,GAEtD,MAAM,OAAO;EAAC;EAAU;EAAQ,OAAO,IAAI;EAAO,UAAU;CAAK,CAAC,GAClE,YAAI,KAAK,OAAO;AAClB"}
1
+ {"version":3,"file":"inject-7ku0wDBp.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 {findStudioConfig} from '../sanity/studio-detect'\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, {importMeta: import.meta, 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 {configFile} = await findStudioConfig(basePath)\n if (configFile) {\n throw new Error(\n `${configFile} 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,YAAY;EAAa,OAAO;EAAW;EAAM;CAAW,CAAC,GAC/E,WAAW,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CAAC,GAErD,UAAS,MADa,kBAAkB,EAAC,SAAQ,CAAC,EAAA,EAC1B,QAAA,QAExB,EAAC,eAAc,MAAM,iBAAiB,QAAQ;CACpD,IAAI,YACF,MAAU,MACR,GAAG,WAAW,sEAChB;CAKF,AAHA,YAAI,KAAK,uCAAqC,QAAQ,GAEtD,MAAM,OAAO;EAAC;EAAU;EAAQ,OAAO,IAAI;EAAO,UAAU;CAAK,CAAC,GAClE,YAAI,KAAK,OAAO;AAClB"}
@@ -1,8 +1,8 @@
1
1
  import "./constants-BIVJp2Jy.js";
2
2
  import { n as sharedFlags_default, t as log_default } from "./log-2MbSIFbq.js";
3
3
  import { A as mkdir, O as fileExists, R as outdent, a as getPackage } from "./package-8cUY5BVf.js";
4
- import { t as binname } from "./package-CuGiTnX2.js";
5
- import { t as loadPackageConfig } from "./load-package-config-CHynlKXx.js";
4
+ import { t as binname } from "./package-BlMyFJ9n.js";
5
+ import { t as loadPackageConfig } from "./load-package-config-BJhZa2CW.js";
6
6
  import meow from "meow";
7
7
  import { styleText } from "node:util";
8
8
  import path from "path";
@@ -14,12 +14,12 @@ async function linkWatch({ basePath }) {
14
14
  command: "npm run watch",
15
15
  extensions: "ts,js,png,svg,gif,jpeg,css",
16
16
  ...packageJson.sanityPlugin?.linkWatch
17
- };
18
- nodemon({
17
+ }, nodemonSettings = {
19
18
  watch: [outDir],
20
19
  ext: watch.extensions,
21
20
  exec: "yalc push --changed"
22
- });
21
+ };
22
+ nodemon(nodemonSettings);
23
23
  let folder = path.join(basePath, outDir);
24
24
  await fileExists(folder) || await mkdir(folder);
25
25
  let pkg = await getPackage({
@@ -90,4 +90,4 @@ function run({ argv }) {
90
90
  }
91
91
  export { run as default };
92
92
 
93
- //# sourceMappingURL=link-watch-yx9QxBJi.js.map
93
+ //# sourceMappingURL=link-watch-B_Tw6Ed0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"link-watch-yx9QxBJi.js","names":["pkg.binname","sharedFlags"],"sources":["../src/actions/link-watch.ts","../src/cmds/link-watch.ts"],"sourcesContent":["/*\nISC License (ISC)\nCopyright 2019 Johan Otterud\n\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,\nprovided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH\nTHE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\n\n/*\nThis code is a modified version of https://github.com/johot/yalc-watch,\nand the ISC License has been added for this file only, in accordance with the package.json license field in that package\n*/\n\nimport fs from 'fs'\nimport {styleText} from 'node:util'\nimport path from 'path'\n\nimport concurrently from 'concurrently'\nimport nodemon from 'nodemon'\n\nimport {defaultOutDir} from '../constants'\nimport {getPackage} from '../npm/package'\nimport {fileExists, mkdir} from '../util/files'\nimport {loadPackageConfig} from '../util/load-package-config'\nimport log from '../util/log'\nimport {outdent} from '../util/outdent'\n\ninterface YalcWatchConfig {\n command?: string\n extensions?: string\n}\n\ninterface PackageJson {\n sanityPlugin?: {linkWatch?: YalcWatchConfig}\n}\n\nexport async function linkWatch({basePath}: {basePath: string}) {\n const packageJson: PackageJson = JSON.parse(\n fs.readFileSync(path.join(basePath, 'package.json'), 'utf8'),\n )\n\n const packageConfig = await loadPackageConfig({basePath})\n const outDir = packageConfig?.dist ?? defaultOutDir\n\n const watch: Required<YalcWatchConfig> = {\n command: 'npm run watch',\n extensions: 'ts,js,png,svg,gif,jpeg,css',\n ...packageJson.sanityPlugin?.linkWatch,\n }\n\n // nodemon's bundled types require `script`, but exec-only settings are valid at runtime\n const nodemonSettings: Partial<Parameters<typeof nodemon>[0]> = {\n watch: [outDir],\n ext: watch.extensions,\n exec: 'yalc push --changed',\n //delay: 1000\n }\n nodemon(nodemonSettings as Parameters<typeof nodemon>[0])\n\n // ensure the folder exits so it can be watched\n const folder = path.join(basePath, outDir)\n if (!(await fileExists(folder))) {\n await mkdir(folder)\n }\n\n const pkg = await getPackage({basePath, validate: false})\n\n concurrently([watch.command])\n\n nodemon\n .on('start', function () {\n log.info(\n outdent`\n Watching ${outDir} for changes to files with extensions: ${watch.extensions}\n\n To test this package in Sanity Studio or another package, in a separate shell run:\n cd /path/to/sanity/studio-or-package\n\n Then, run one of the below commands, based on the package manager used in studio-or-package:\n\n ## yarn\n ${styleText('greenBright', `yalc add --link ${pkg.name} && yarn install`)}\n\n ## npm\n ${styleText('greenBright', `npx yalc add ${pkg.name} && npx yalc link ${pkg.name} && npm install`)}\n `.trimStart(),\n )\n })\n .on('quit', function () {\n process.exit()\n })\n .on('restart', function (files?: string[]) {\n log.info('Found changes in files:', styleText('magentaBright', (files ?? []).join(', ')))\n log.info('Pushing new yalc package...')\n })\n}\n","import path from 'path'\n\nimport meow from 'meow'\n\nimport pkg from '../../package.json'\nimport {linkWatch} from '../actions/link-watch'\nimport sharedFlags from '../sharedFlags'\n\nconst description = `Run the watch command and pushes any changes to yalc`\n\nconst help = `\nUsage\n $ ${pkg.binname} link-watch [<args>]\n\nOptions\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\nConfiguration\nTo override the default watch command configuration, provide an override in package.json under sanityPlugin:\n{\n \"sanityPlugin\": {\n \"watchCommand\": \"microbundle watch --format modern,esm,cjs --jsx React.createElement --jsxImportSource react --css inline\",\n \"linkWatch\": {\n \"command\": \"npm run watch\",\n \"extensions\": \"js,png,svg,gif,jpeg,css\"\n }\n }\n}\n\nExamples\n # Run the watch command and pushes any changes to yalc\n $ ${pkg.binname} link-watch\n`\n\nconst flags = {\n ...sharedFlags,\n watch: {\n type: 'boolean',\n default: false,\n },\n} as const\n\nfunction run({argv}: {argv: string[]}) {\n const cli = meow(help, {importMeta: import.meta, flags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n return linkWatch({basePath})\n}\n\nexport default run\n"],"mappings":";;;;;;;;;;;AA0CA,eAAsB,UAAU,EAAC,YAA+B;CAC9D,IAAM,cAA2B,KAAK,MACpC,GAAG,aAAa,KAAK,KAAK,UAAU,cAAc,GAAG,MAAM,CAC7D,GAGM,UAAS,MADa,kBAAkB,EAAC,SAAQ,CAAC,EAAA,EAC1B,QAAA,QAExB,QAAmC;EACvC,SAAS;EACT,YAAY;EACZ,GAAG,YAAY,cAAc;CAC/B;CASA,QAAQ;EALN,OAAO,CAAC,MAAM;EACd,KAAK,MAAM;EACX,MAAM;CAGc,CAAkC;CAGxD,IAAM,SAAS,KAAK,KAAK,UAAU,MAAM;CACzC,AAAM,MAAM,WAAW,MAAM,KAC3B,MAAM,MAAM,MAAM;CAGpB,IAAM,MAAM,MAAM,WAAW;EAAC;EAAU,UAAU;CAAK,CAAC;CAIxD,AAFA,aAAa,CAAC,MAAM,OAAO,CAAC,GAE5B,QACG,GAAG,SAAS,WAAY;EACvB,YAAI,KACF,OAAO;mBACI,OAAO,yCAAyC,MAAM,WAAW;;;;;;;;UAQ1E,UAAU,eAAe,mBAAmB,IAAI,KAAK,iBAAiB,EAAE;;;UAGxE,UAAU,eAAe,gBAAgB,IAAI,KAAK,oBAAoB,IAAI,KAAK,gBAAgB,EAAE;QACnG,UAAU,CACZ;CACF,CAAC,CAAC,CACD,GAAG,QAAQ,WAAY;EACtB,QAAQ,KAAK;CACf,CAAC,CAAC,CACD,GAAG,WAAW,SAAU,OAAkB;EAEzC,AADA,YAAI,KAAK,2BAA2B,UAAU,kBAAkB,SAAS,CAAC,EAAA,CAAG,KAAK,IAAI,CAAC,CAAC,GACxF,YAAI,KAAK,6BAA6B;CACxC,CAAC;AACL;AC7FA,MAEM,OAAO;;MAEPA,QAAY;;;;;;;;;;;;;;;;;;;;;;MAsBZA,QAAY;GAGZ,QAAQ;CACZ,GAAGC;CACH,OAAO;EACL,MAAM;EACN,SAAS;CACX;AACF;AAEA,SAAS,IAAI,EAAC,QAAyB;CACrC,IAAM,MAAM,KAAK,MAAM;EAAC,YAAY,OAAO;EAAM;EAAO;EAAM;CAAW,CAAC;CAE1E,OAAO,UAAU,EAAC,UADD,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CACjC,EAAC,CAAC;AAC7B"}
1
+ {"version":3,"file":"link-watch-B_Tw6Ed0.js","names":["pkg.binname","sharedFlags"],"sources":["../src/actions/link-watch.ts","../src/cmds/link-watch.ts"],"sourcesContent":["/*\nISC License (ISC)\nCopyright 2019 Johan Otterud\n\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,\nprovided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,\nWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH\nTHE USE OR PERFORMANCE OF THIS SOFTWARE.\n*/\n\n/*\nThis code is a modified version of https://github.com/johot/yalc-watch,\nand the ISC License has been added for this file only, in accordance with the package.json license field in that package\n*/\n\nimport fs from 'fs'\nimport {styleText} from 'node:util'\nimport path from 'path'\n\nimport concurrently from 'concurrently'\nimport nodemon from 'nodemon'\n\nimport {defaultOutDir} from '../constants'\nimport {getPackage} from '../npm/package'\nimport {fileExists, mkdir} from '../util/files'\nimport {loadPackageConfig} from '../util/load-package-config'\nimport log from '../util/log'\nimport {outdent} from '../util/outdent'\n\ninterface YalcWatchConfig {\n command?: string\n extensions?: string\n}\n\ninterface PackageJson {\n sanityPlugin?: {linkWatch?: YalcWatchConfig}\n}\n\nexport async function linkWatch({basePath}: {basePath: string}) {\n const packageJson: PackageJson = JSON.parse(\n fs.readFileSync(path.join(basePath, 'package.json'), 'utf8'),\n )\n\n const packageConfig = await loadPackageConfig({basePath})\n const outDir = packageConfig?.dist ?? defaultOutDir\n\n const watch: Required<YalcWatchConfig> = {\n command: 'npm run watch',\n extensions: 'ts,js,png,svg,gif,jpeg,css',\n ...packageJson.sanityPlugin?.linkWatch,\n }\n\n // nodemon's bundled types require `script`, but exec-only settings are valid at runtime\n const nodemonSettings: Partial<Parameters<typeof nodemon>[0]> = {\n watch: [outDir],\n ext: watch.extensions,\n exec: 'yalc push --changed',\n //delay: 1000\n }\n nodemon(nodemonSettings as Parameters<typeof nodemon>[0])\n\n // ensure the folder exits so it can be watched\n const folder = path.join(basePath, outDir)\n if (!(await fileExists(folder))) {\n await mkdir(folder)\n }\n\n const pkg = await getPackage({basePath, validate: false})\n\n concurrently([watch.command])\n\n nodemon\n .on('start', function () {\n log.info(\n outdent`\n Watching ${outDir} for changes to files with extensions: ${watch.extensions}\n\n To test this package in Sanity Studio or another package, in a separate shell run:\n cd /path/to/sanity/studio-or-package\n\n Then, run one of the below commands, based on the package manager used in studio-or-package:\n\n ## yarn\n ${styleText('greenBright', `yalc add --link ${pkg.name} && yarn install`)}\n\n ## npm\n ${styleText('greenBright', `npx yalc add ${pkg.name} && npx yalc link ${pkg.name} && npm install`)}\n `.trimStart(),\n )\n })\n .on('quit', function () {\n process.exit()\n })\n .on('restart', function (files?: string[]) {\n log.info('Found changes in files:', styleText('magentaBright', (files ?? []).join(', ')))\n log.info('Pushing new yalc package...')\n })\n}\n","import path from 'path'\n\nimport meow from 'meow'\n\nimport pkg from '../../package.json'\nimport {linkWatch} from '../actions/link-watch'\nimport sharedFlags from '../sharedFlags'\n\nconst description = `Run the watch command and pushes any changes to yalc`\n\nconst help = `\nUsage\n $ ${pkg.binname} link-watch [<args>]\n\nOptions\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\nConfiguration\nTo override the default watch command configuration, provide an override in package.json under sanityPlugin:\n{\n \"sanityPlugin\": {\n \"watchCommand\": \"microbundle watch --format modern,esm,cjs --jsx React.createElement --jsxImportSource react --css inline\",\n \"linkWatch\": {\n \"command\": \"npm run watch\",\n \"extensions\": \"js,png,svg,gif,jpeg,css\"\n }\n }\n}\n\nExamples\n # Run the watch command and pushes any changes to yalc\n $ ${pkg.binname} link-watch\n`\n\nconst flags = {\n ...sharedFlags,\n watch: {\n type: 'boolean',\n default: false,\n },\n} as const\n\nfunction run({argv}: {argv: string[]}) {\n const cli = meow(help, {importMeta: import.meta, flags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n return linkWatch({basePath})\n}\n\nexport default run\n"],"mappings":";;;;;;;;;;;AA0CA,eAAsB,UAAU,EAAC,YAA+B;CAC9D,IAAM,cAA2B,KAAK,MACpC,GAAG,aAAa,KAAK,KAAK,UAAU,cAAc,GAAG,MAAM,CAC7D,GAGM,UAAS,MADa,kBAAkB,EAAC,SAAQ,CAAC,EAAA,EAC1B,QAAA,QAExB,QAAmC;EACvC,SAAS;EACT,YAAY;EACZ,GAAG,YAAY,cAAc;CAC/B,GAGM,kBAA0D;EAC9D,OAAO,CAAC,MAAM;EACd,KAAK,MAAM;EACX,MAAM;CAER;CACA,QAAQ,eAAgD;CAGxD,IAAM,SAAS,KAAK,KAAK,UAAU,MAAM;CACzC,AAAM,MAAM,WAAW,MAAM,KAC3B,MAAM,MAAM,MAAM;CAGpB,IAAM,MAAM,MAAM,WAAW;EAAC;EAAU,UAAU;CAAK,CAAC;CAIxD,AAFA,aAAa,CAAC,MAAM,OAAO,CAAC,GAE5B,QACG,GAAG,SAAS,WAAY;EACvB,YAAI,KACF,OAAO;mBACI,OAAO,yCAAyC,MAAM,WAAW;;;;;;;;UAQ1E,UAAU,eAAe,mBAAmB,IAAI,KAAK,iBAAiB,EAAE;;;UAGxE,UAAU,eAAe,gBAAgB,IAAI,KAAK,oBAAoB,IAAI,KAAK,gBAAgB,EAAE;QACnG,UAAU,CACZ;CACF,CAAC,CAAC,CACD,GAAG,QAAQ,WAAY;EACtB,QAAQ,KAAK;CACf,CAAC,CAAC,CACD,GAAG,WAAW,SAAU,OAAkB;EAEzC,AADA,YAAI,KAAK,2BAA2B,UAAU,kBAAkB,SAAS,CAAC,EAAA,CAAG,KAAK,IAAI,CAAC,CAAC,GACxF,YAAI,KAAK,6BAA6B;CACxC,CAAC;AACL;AC7FA,MAEM,OAAO;;MAEPA,QAAY;;;;;;;;;;;;;;;;;;;;;;MAsBZA,QAAY;GAGZ,QAAQ;CACZ,GAAGC;CACH,OAAO;EACL,MAAM;EACN,SAAS;CACX;AACF;AAEA,SAAS,IAAI,EAAC,QAAyB;CACrC,IAAM,MAAM,KAAK,MAAM;EAAC,YAAY;EAAa;EAAO;EAAM;CAAW,CAAC;CAE1E,OAAO,UAAU,EAAC,UADD,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CACxC,EAAQ,CAAC;AAC7B"}
@@ -20,7 +20,7 @@ const CONFIG_FILE_NAMES = [
20
20
  async function loadPackageConfig(options) {
21
21
  let { basePath } = options;
22
22
  if (!CONFIG_FILE_NAMES.some((file) => fs.existsSync(path.join(basePath, file)))) return;
23
- let pkgPath = path.join(basePath, "package.json"), { loadConfig } = await import(pathToFileURL(createRequire(pkgPath).resolve("@sanity/pkg-utils")).href);
23
+ let pkgPath = path.join(basePath, "package.json"), pkgUtilsEntry = createRequire(pkgPath).resolve("@sanity/pkg-utils"), { loadConfig } = await import(pathToFileURL(pkgUtilsEntry).href);
24
24
  return loadConfig({
25
25
  cwd: basePath,
26
26
  pkgPath
@@ -28,4 +28,4 @@ async function loadPackageConfig(options) {
28
28
  }
29
29
  export { loadPackageConfig as t };
30
30
 
31
- //# sourceMappingURL=load-package-config-CHynlKXx.js.map
31
+ //# sourceMappingURL=load-package-config-BJhZa2CW.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-package-config-CHynlKXx.js","names":[],"sources":["../src/util/load-package-config.ts"],"sourcesContent":["import fs from 'node:fs'\nimport {createRequire} from 'node:module'\nimport path from 'node:path'\nimport {pathToFileURL} from 'node:url'\n\nimport type {loadConfig as LoadConfig, PkgConfigOptions} from '@sanity/pkg-utils'\n\n// Config file candidates supported by `@sanity/pkg-utils`.\nconst CONFIG_FILE_NAMES = [\n 'package.config.ts',\n 'package.config.js',\n 'package.config.cjs',\n 'package.config.mts',\n 'package.config.mjs',\n]\n\n/**\n * Loads the `@sanity/pkg-utils` package.config file for the plugin in `basePath`.\n *\n * `@sanity/pkg-utils` is a peer dependency, so we resolve `loadConfig` from the plugin's own\n * installation (relative to `basePath`). This guarantees the config is parsed with the exact\n * same pkg-utils version the plugin builds with, and lets plugin-kit run via `npx` without\n * bundling its own copy of pkg-utils.\n */\nexport async function loadPackageConfig(options: {\n basePath: string\n}): Promise<PkgConfigOptions | undefined> {\n const {basePath} = options\n\n // Cheap check first: avoid resolving the pkg-utils peer when there's no config to load.\n const hasConfigFile = CONFIG_FILE_NAMES.some((file) => fs.existsSync(path.join(basePath, file)))\n if (!hasConfigFile) {\n return undefined\n }\n\n const pkgPath = path.join(basePath, 'package.json')\n const require = createRequire(pkgPath)\n const pkgUtilsEntry = require.resolve('@sanity/pkg-utils')\n const {loadConfig} = (await import(pathToFileURL(pkgUtilsEntry).href)) as {\n loadConfig: typeof LoadConfig\n }\n\n return loadConfig({cwd: basePath, pkgPath})\n}\n"],"mappings":";;;;AAQA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;AACF;;;;;;;;;AAUA,eAAsB,kBAAkB,SAEE;CACxC,IAAM,EAAC,aAAY;CAInB,IAAI,CADkB,kBAAkB,MAAM,SAAS,GAAG,WAAW,KAAK,KAAK,UAAU,IAAI,CAAC,CAC7E,GACf;CAGF,IAAM,UAAU,KAAK,KAAK,UAAU,cAAc,GAG5C,EAAC,eAAe,MAAM,OAAO,cAFnB,cAAc,OACF,CAAC,CAAC,QAAQ,mBACuB,CAAC,CAAC,CAAC;CAIhE,OAAO,WAAW;EAAC,KAAK;EAAU;CAAO,CAAC;AAC5C"}
1
+ {"version":3,"file":"load-package-config-BJhZa2CW.js","names":[],"sources":["../src/util/load-package-config.ts"],"sourcesContent":["import fs from 'node:fs'\nimport {createRequire} from 'node:module'\nimport path from 'node:path'\nimport {pathToFileURL} from 'node:url'\n\nimport type {loadConfig as LoadConfig, PkgConfigOptions} from '@sanity/pkg-utils'\n\n// Config file candidates supported by `@sanity/pkg-utils`.\nconst CONFIG_FILE_NAMES = [\n 'package.config.ts',\n 'package.config.js',\n 'package.config.cjs',\n 'package.config.mts',\n 'package.config.mjs',\n]\n\n/**\n * Loads the `@sanity/pkg-utils` package.config file for the plugin in `basePath`.\n *\n * `@sanity/pkg-utils` is a peer dependency, so we resolve `loadConfig` from the plugin's own\n * installation (relative to `basePath`). This guarantees the config is parsed with the exact\n * same pkg-utils version the plugin builds with, and lets plugin-kit run via `npx` without\n * bundling its own copy of pkg-utils.\n */\nexport async function loadPackageConfig(options: {\n basePath: string\n}): Promise<PkgConfigOptions | undefined> {\n const {basePath} = options\n\n // Cheap check first: avoid resolving the pkg-utils peer when there's no config to load.\n const hasConfigFile = CONFIG_FILE_NAMES.some((file) => fs.existsSync(path.join(basePath, file)))\n if (!hasConfigFile) {\n return undefined\n }\n\n const pkgPath = path.join(basePath, 'package.json')\n const require = createRequire(pkgPath)\n const pkgUtilsEntry = require.resolve('@sanity/pkg-utils')\n const {loadConfig} = (await import(pathToFileURL(pkgUtilsEntry).href)) as {\n loadConfig: typeof LoadConfig\n }\n\n return loadConfig({cwd: basePath, pkgPath})\n}\n"],"mappings":";;;;AAQA,MAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;AACF;;;;;;;;;AAUA,eAAsB,kBAAkB,SAEE;CACxC,IAAM,EAAC,aAAY;CAInB,IAAI,CADkB,kBAAkB,MAAM,SAAS,GAAG,WAAW,KAAK,KAAK,UAAU,IAAI,CAAC,CAC7E,GACf;CAGF,IAAM,UAAU,KAAK,KAAK,UAAU,cAAc,GAE5C,gBADU,cAAc,OACF,CAAC,CAAC,QAAQ,mBAAmB,GACnD,EAAC,eAAe,MAAM,OAAO,cAAc,aAAa,CAAC,CAAC;CAIhE,OAAO,WAAW;EAAC,KAAK;EAAU;CAAO,CAAC;AAC5C"}
package/dist/oxlint.js CHANGED
@@ -78,11 +78,6 @@ const config = {
78
78
  importNames: ["createElement"],
79
79
  message: "Please use JSX instead of createElement, for example `createElement(Icon)` should be `<Icon />`"
80
80
  },
81
- {
82
- name: "react",
83
- importNames: ["Component", "PureComponent"],
84
- message: "Class components are not allowed. Use function components instead."
85
- },
86
81
  {
87
82
  name: "react",
88
83
  importNames: ["createRef"],
@@ -103,6 +98,7 @@ const config = {
103
98
  message: "Please use individual imports from 'lodash-es' instead, e.g. `import debounce from 'lodash-es/debounce.js'`."
104
99
  }]
105
100
  }],
101
+ "react/prefer-function-component": ["error", { allowErrorBoundary: !0 }],
106
102
  "react/react-compiler": "error",
107
103
  "typescript/ban-ts-comment": "error",
108
104
  "typescript/no-deprecated": "error",
@@ -1 +1 @@
1
- {"version":3,"file":"oxlint.js","names":[],"sources":["../src/oxlint.ts"],"sourcesContent":["import type {OxlintConfig} from 'oxlint'\n\n/**\n * Shared [oxlint](https://oxc.rs/docs/guide/usage/linter.html) config for Sanity plugins - the\n * same settings the [sanity-io/plugins](https://github.com/sanity-io/plugins) monorepo uses:\n * type-aware rules and TypeScript type checking enabled (via `oxlint-tsgolint`), warnings denied,\n * and the React, React Compiler, import, promise, a11y and unicorn rule sets turned on.\n *\n * Re-export it from an `oxlint.config.ts` next to the `package.json` that runs oxlint (the\n * repository root in a monorepo, otherwise the plugin directory):\n *\n * ```ts\n * export {default} from '@sanity/plugin-kit/oxlint'\n * ```\n *\n * To customize, extend it and add your own options ([`ignorePatterns` do not propagate through\n * `extends`](https://oxc.rs/docs/guide/usage/linter/config.html#extend-shared-configs), so spread\n * them explicitly when adding your own):\n *\n * ```ts\n * import sanityPluginKitOxlint from '@sanity/plugin-kit/oxlint'\n * import {defineConfig} from 'oxlint'\n *\n * export default defineConfig({\n * extends: [sanityPluginKitOxlint],\n * ignorePatterns: [...(sanityPluginKitOxlint.ignorePatterns ?? []), 'examples/**'],\n * })\n * ```\n *\n * Note: TypeScript config files require the Node-based `oxlint` package and Node `>=22.18`.\n *\n * @public\n */\nconst config: OxlintConfig = {\n plugins: ['typescript', 'unicorn', 'react', 'react-perf', 'oxc', 'import', 'jsx-a11y', 'promise'],\n ignorePatterns: ['**/.sanity/*', '**/dist/*', '**/sanity.types.ts'],\n options: {\n denyWarnings: true,\n reportUnusedDisableDirectives: 'error',\n typeAware: true,\n typeCheck: true,\n },\n categories: {\n correctness: 'error',\n suspicious: 'error',\n perf: 'error',\n },\n rules: {\n 'no-underscore-dangle': 'off',\n 'consistent-function-scoping': 'off',\n 'eslint/no-restricted-imports': [\n 'error',\n {\n paths: [\n {\n name: 'lodash-es',\n message:\n \"Import from individual modules instead, e.g. `import debounce from 'lodash-es/debounce.js'`. Barrel imports are ~55% slower.\",\n },\n {\n name: 'date-fns',\n message:\n \"Import from individual modules instead, e.g. `import {startOfDay} from 'date-fns/startOfDay'`. Barrel imports are ~50% slower.\",\n },\n {\n name: 'date-fns-tz',\n message:\n 'Use the official `@date-fns/tz` package (TZDate, tz, tzOffset) with date-fns v4 instead, matching sanity core.',\n },\n {\n name: 'react',\n importNames: ['createElement'],\n message:\n 'Please use JSX instead of createElement, for example `createElement(Icon)` should be `<Icon />`',\n },\n {\n name: 'react',\n importNames: ['Component', 'PureComponent'],\n message: 'Class components are not allowed. Use function components instead.',\n },\n {\n name: 'react',\n importNames: ['createRef'],\n message: 'createRef is only for class components. Use the useRef hook instead.',\n },\n {\n name: 'react',\n importNames: ['forwardRef'],\n message:\n 'forwardRef is unnecessary in React 19 — `ref` is a regular prop. Accept `ref` in your component props instead, e.g. `function Foo({ref, ...props}: Props & {ref?: Ref<T>}) {}`. See the sanity-plugin-best-practices skill.',\n },\n ],\n patterns: [\n {\n group: ['lodash.*', 'lodash/*', 'lodash'],\n message:\n \"Please use individual imports from 'lodash-es' instead, e.g. `import debounce from 'lodash-es/debounce.js'`.\",\n },\n ],\n },\n ],\n\n // React Compiler checks\n 'react/react-compiler': 'error',\n\n 'typescript/ban-ts-comment': 'error',\n 'typescript/no-deprecated': 'error',\n 'typescript/no-unnecessary-type-assertion': 'error',\n 'typescript/no-unnecessary-type-arguments': 'error',\n 'typescript/prefer-ts-expect-error': 'error',\n 'import/no-commonjs': 'error',\n 'import/no-unassigned-import': ['error', {allow: ['**/*.css']}],\n 'no-restricted-globals': [\n 'error',\n {name: '__dirname', message: 'Use path.dirname(fileURLToPath(import.meta.url)) instead'},\n {name: '__filename', message: 'Use fileURLToPath(import.meta.url) instead'},\n ],\n 'react/jsx-key': 'error',\n 'unicorn/no-abusive-eslint-disable': 'error',\n // Not relevant as we use the modern jsx-runtime transform\n 'react-in-jsx-scope': 'off',\n // Not relevant due to React Compiler\n 'react_perf/jsx-no-new-array-as-prop': 'off',\n 'react_perf/jsx-no-new-object-as-prop': 'off',\n 'react_perf/jsx-no-new-function-as-prop': 'off',\n 'react_perf/jsx-no-jsx-as-prop': 'off',\n // False negatives\n 'jsx_a11y/anchor-is-valid': 'off',\n 'jsx_a11y/no-autofocus': 'off',\n // Handy rules that are disabled by default\n 'react/exhaustive-deps': 'error',\n 'react/rules-of-hooks': 'error',\n 'eslint/no-console': ['error', {allow: ['warn', 'error']}],\n // Requires polyfills for older browsers\n 'no-array-reverse': 'off',\n 'no-array-sort': 'off',\n // Too noisy, common in callbacks/closures\n 'no-shadow': 'off',\n },\n}\n\nexport default config\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,SAAuB;CAC3B,SAAS;EAAC;EAAc;EAAW;EAAS;EAAc;EAAO;EAAU;EAAY;CAAS;CAChG,gBAAgB;EAAC;EAAgB;EAAa;CAAoB;CAClE,SAAS;EACP,cAAc;EACd,+BAA+B;EAC/B,WAAW;EACX,WAAW;CACb;CACA,YAAY;EACV,aAAa;EACb,YAAY;EACZ,MAAM;CACR;CACA,OAAO;EACL,wBAAwB;EACxB,+BAA+B;EAC/B,gCAAgC,CAC9B,SACA;GACE,OAAO;IACL;KACE,MAAM;KACN,SACE;IACJ;IACA;KACE,MAAM;KACN,SACE;IACJ;IACA;KACE,MAAM;KACN,SACE;IACJ;IACA;KACE,MAAM;KACN,aAAa,CAAC,eAAe;KAC7B,SACE;IACJ;IACA;KACE,MAAM;KACN,aAAa,CAAC,aAAa,eAAe;KAC1C,SAAS;IACX;IACA;KACE,MAAM;KACN,aAAa,CAAC,WAAW;KACzB,SAAS;IACX;IACA;KACE,MAAM;KACN,aAAa,CAAC,YAAY;KAC1B,SACE;IACJ;GACF;GACA,UAAU,CACR;IACE,OAAO;KAAC;KAAY;KAAY;IAAQ;IACxC,SACE;GACJ,CACF;EACF,CACF;EAGA,wBAAwB;EAExB,6BAA6B;EAC7B,4BAA4B;EAC5B,4CAA4C;EAC5C,4CAA4C;EAC5C,qCAAqC;EACrC,sBAAsB;EACtB,+BAA+B,CAAC,SAAS,EAAC,OAAO,CAAC,UAAU,EAAC,CAAC;EAC9D,yBAAyB;GACvB;GACA;IAAC,MAAM;IAAa,SAAS;GAA0D;GACvF;IAAC,MAAM;IAAc,SAAS;GAA4C;EAC5E;EACA,iBAAiB;EACjB,qCAAqC;EAErC,sBAAsB;EAEtB,uCAAuC;EACvC,wCAAwC;EACxC,0CAA0C;EAC1C,iCAAiC;EAEjC,4BAA4B;EAC5B,yBAAyB;EAEzB,yBAAyB;EACzB,wBAAwB;EACxB,qBAAqB,CAAC,SAAS,EAAC,OAAO,CAAC,QAAQ,OAAO,EAAC,CAAC;EAEzD,oBAAoB;EACpB,iBAAiB;EAEjB,aAAa;CACf;AACF"}
1
+ {"version":3,"file":"oxlint.js","names":[],"sources":["../src/oxlint.ts"],"sourcesContent":["import type {OxlintConfig} from 'oxlint'\n\n/**\n * Shared [oxlint](https://oxc.rs/docs/guide/usage/linter.html) config for Sanity plugins - the\n * same settings the [sanity-io/plugins](https://github.com/sanity-io/plugins) monorepo uses:\n * type-aware rules and TypeScript type checking enabled (via `oxlint-tsgolint`), warnings denied,\n * and the React, React Compiler, import, promise, a11y and unicorn rule sets turned on.\n *\n * Re-export it from an `oxlint.config.ts` next to the `package.json` that runs oxlint (the\n * repository root in a monorepo, otherwise the plugin directory):\n *\n * ```ts\n * export {default} from '@sanity/plugin-kit/oxlint'\n * ```\n *\n * To customize, extend it and add your own options ([`ignorePatterns` do not propagate through\n * `extends`](https://oxc.rs/docs/guide/usage/linter/config.html#extend-shared-configs), so spread\n * them explicitly when adding your own):\n *\n * ```ts\n * import sanityPluginKitOxlint from '@sanity/plugin-kit/oxlint'\n * import {defineConfig} from 'oxlint'\n *\n * export default defineConfig({\n * extends: [sanityPluginKitOxlint],\n * ignorePatterns: [...(sanityPluginKitOxlint.ignorePatterns ?? []), 'examples/**'],\n * })\n * ```\n *\n * Note: TypeScript config files require the Node-based `oxlint` package and Node `>=22.18`.\n *\n * @public\n */\nconst config: OxlintConfig = {\n plugins: ['typescript', 'unicorn', 'react', 'react-perf', 'oxc', 'import', 'jsx-a11y', 'promise'],\n ignorePatterns: ['**/.sanity/*', '**/dist/*', '**/sanity.types.ts'],\n options: {\n denyWarnings: true,\n reportUnusedDisableDirectives: 'error',\n typeAware: true,\n typeCheck: true,\n },\n categories: {\n correctness: 'error',\n suspicious: 'error',\n perf: 'error',\n },\n rules: {\n 'no-underscore-dangle': 'off',\n 'consistent-function-scoping': 'off',\n 'eslint/no-restricted-imports': [\n 'error',\n {\n paths: [\n {\n name: 'lodash-es',\n message:\n \"Import from individual modules instead, e.g. `import debounce from 'lodash-es/debounce.js'`. Barrel imports are ~55% slower.\",\n },\n {\n name: 'date-fns',\n message:\n \"Import from individual modules instead, e.g. `import {startOfDay} from 'date-fns/startOfDay'`. Barrel imports are ~50% slower.\",\n },\n {\n name: 'date-fns-tz',\n message:\n 'Use the official `@date-fns/tz` package (TZDate, tz, tzOffset) with date-fns v4 instead, matching sanity core.',\n },\n {\n name: 'react',\n importNames: ['createElement'],\n message:\n 'Please use JSX instead of createElement, for example `createElement(Icon)` should be `<Icon />`',\n },\n {\n name: 'react',\n importNames: ['createRef'],\n message: 'createRef is only for class components. Use the useRef hook instead.',\n },\n {\n name: 'react',\n importNames: ['forwardRef'],\n message:\n 'forwardRef is unnecessary in React 19 — `ref` is a regular prop. Accept `ref` in your component props instead, e.g. `function Foo({ref, ...props}: Props & {ref?: Ref<T>}) {}`. See the sanity-plugin-best-practices skill.',\n },\n ],\n patterns: [\n {\n group: ['lodash.*', 'lodash/*', 'lodash'],\n message:\n \"Please use individual imports from 'lodash-es' instead, e.g. `import debounce from 'lodash-es/debounce.js'`.\",\n },\n ],\n },\n ],\n\n // Prefer function components; allow class error boundaries (no hook equivalent yet)\n 'react/prefer-function-component': ['error', {allowErrorBoundary: true}],\n\n // React Compiler checks\n 'react/react-compiler': 'error',\n\n 'typescript/ban-ts-comment': 'error',\n 'typescript/no-deprecated': 'error',\n 'typescript/no-unnecessary-type-assertion': 'error',\n 'typescript/no-unnecessary-type-arguments': 'error',\n 'typescript/prefer-ts-expect-error': 'error',\n 'import/no-commonjs': 'error',\n 'import/no-unassigned-import': ['error', {allow: ['**/*.css']}],\n 'no-restricted-globals': [\n 'error',\n {name: '__dirname', message: 'Use path.dirname(fileURLToPath(import.meta.url)) instead'},\n {name: '__filename', message: 'Use fileURLToPath(import.meta.url) instead'},\n ],\n 'react/jsx-key': 'error',\n 'unicorn/no-abusive-eslint-disable': 'error',\n // Not relevant as we use the modern jsx-runtime transform\n 'react-in-jsx-scope': 'off',\n // Not relevant due to React Compiler\n 'react_perf/jsx-no-new-array-as-prop': 'off',\n 'react_perf/jsx-no-new-object-as-prop': 'off',\n 'react_perf/jsx-no-new-function-as-prop': 'off',\n 'react_perf/jsx-no-jsx-as-prop': 'off',\n // False negatives\n 'jsx_a11y/anchor-is-valid': 'off',\n 'jsx_a11y/no-autofocus': 'off',\n // Handy rules that are disabled by default\n 'react/exhaustive-deps': 'error',\n 'react/rules-of-hooks': 'error',\n 'eslint/no-console': ['error', {allow: ['warn', 'error']}],\n // Requires polyfills for older browsers\n 'no-array-reverse': 'off',\n 'no-array-sort': 'off',\n // Too noisy, common in callbacks/closures\n 'no-shadow': 'off',\n },\n}\n\nexport default config\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,SAAuB;CAC3B,SAAS;EAAC;EAAc;EAAW;EAAS;EAAc;EAAO;EAAU;EAAY;CAAS;CAChG,gBAAgB;EAAC;EAAgB;EAAa;CAAoB;CAClE,SAAS;EACP,cAAc;EACd,+BAA+B;EAC/B,WAAW;EACX,WAAW;CACb;CACA,YAAY;EACV,aAAa;EACb,YAAY;EACZ,MAAM;CACR;CACA,OAAO;EACL,wBAAwB;EACxB,+BAA+B;EAC/B,gCAAgC,CAC9B,SACA;GACE,OAAO;IACL;KACE,MAAM;KACN,SACE;IACJ;IACA;KACE,MAAM;KACN,SACE;IACJ;IACA;KACE,MAAM;KACN,SACE;IACJ;IACA;KACE,MAAM;KACN,aAAa,CAAC,eAAe;KAC7B,SACE;IACJ;IACA;KACE,MAAM;KACN,aAAa,CAAC,WAAW;KACzB,SAAS;IACX;IACA;KACE,MAAM;KACN,aAAa,CAAC,YAAY;KAC1B,SACE;IACJ;GACF;GACA,UAAU,CACR;IACE,OAAO;KAAC;KAAY;KAAY;IAAQ;IACxC,SACE;GACJ,CACF;EACF,CACF;EAGA,mCAAmC,CAAC,SAAS,EAAC,oBAAoB,GAAI,CAAC;EAGvE,wBAAwB;EAExB,6BAA6B;EAC7B,4BAA4B;EAC5B,4CAA4C;EAC5C,4CAA4C;EAC5C,qCAAqC;EACrC,sBAAsB;EACtB,+BAA+B,CAAC,SAAS,EAAC,OAAO,CAAC,UAAU,EAAC,CAAC;EAC9D,yBAAyB;GACvB;GACA;IAAC,MAAM;IAAa,SAAS;GAA0D;GACvF;IAAC,MAAM;IAAc,SAAS;GAA4C;EAC5E;EACA,iBAAiB;EACjB,qCAAqC;EAErC,sBAAsB;EAEtB,uCAAuC;EACvC,wCAAwC;EACxC,0CAA0C;EAC1C,iCAAiC;EAEjC,4BAA4B;EAC5B,yBAAyB;EAEzB,yBAAyB;EACzB,wBAAwB;EACxB,qBAAqB,CAAC,SAAS,EAAC,OAAO,CAAC,QAAQ,OAAO,EAAC,CAAC;EAEzD,oBAAoB;EACpB,iBAAiB;EAEjB,aAAa;CACf;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"package-8cUY5BVf.js","names":["URL","readFile","validatePackageName","validateNpmPackageName","readFile","validateNpmPackageName"],"sources":["../src/util/outdent.ts","../src/configs/banned-packages.ts","../src/util/github-url.ts","../src/util/prompt.ts","../src/util/files.ts","../src/actions/verify/validations.ts","../src/configs/forced-package-versions.ts","../src/npm/resolveLatestVersions.ts","../src/npm/package.ts"],"sourcesContent":["/**\n * Tagged-template helper that strips the common leading indentation from\n * multi-line strings (same semantics as the `outdent` package for the\n * patterns used in this package).\n */\nexport function outdent(strings: TemplateStringsArray, ...values: unknown[]): string {\n const match = strings[0].match(/(\\r\\n|\\r|\\n)([ \\t]*)(?:[^ \\t\\r\\n]|$)/)\n const indentationLevel = match ? match[2].length : 0\n // Only strip spaces/tabs — never consume non-whitespace from under-indented lines\n const reMatchIndent = new RegExp(`(\\\\r\\\\n|\\\\r|\\\\n)[ \\\\t]{0,${indentationLevel}}`, 'g')\n\n const outdented = strings.map((v, i) => {\n let s = v.replace(reMatchIndent, '$1')\n if (i === 0) {\n s = s.replace(/^[ \\t]*(?:\\r\\n|\\r|\\n)/, '')\n }\n if (i === strings.length - 1) {\n s = s.replace(/(?:\\r\\n|\\r|\\n)[ \\t]*$/, '')\n }\n return s\n })\n\n let result = ''\n for (let i = 0; i < outdented.length; i++) {\n result += outdented[i]\n if (i < values.length) {\n result += values[i]\n }\n }\n return result\n}\n","export const deprecatedDevDeps = [\n 'tsdx',\n 'sanipack',\n 'parcel',\n '@parcel/packager-ts',\n '@parcel/transformer-typescript-types',\n]\n","/**\n * Parse a GitHub remote URL (https, git+ssh, or scp-style) into user/repo.\n * Replaces the untyped `github-url-to-object` package.\n */\nexport function githubUrlToObject(url: string): {user: string; repo: string} | undefined {\n if (!url) {\n return undefined\n }\n\n const trimmed = url.trim()\n\n // git@github.com:user/repo(.git)\n const scp = trimmed.match(/^git@github\\.com:([^/]+)\\/(.+?)(?:\\.git)?$/i)\n if (scp) {\n return {user: scp[1], repo: scp[2]}\n }\n\n try {\n const normalized = trimmed\n .replace(/^git\\+/, '')\n .replace(/^ssh:\\/\\/git@github\\.com\\//i, 'https://github.com/')\n .replace(/^git:\\/\\/github\\.com\\//i, 'https://github.com/')\n const parsed = new URL(normalized)\n if (!/(^|\\.)github\\.com$/i.test(parsed.hostname)) {\n return undefined\n }\n const [, user, repoWithGit] = parsed.pathname.split('/')\n if (!user || !repoWithGit) {\n return undefined\n }\n return {user, repo: repoWithGit.replace(/\\.git$/i, '')}\n } catch {\n return undefined\n }\n}\n","import path from 'path'\nimport {URL} from 'url'\n\nimport inquirer, {type Question} from 'inquirer'\nimport validNpmName from 'validate-npm-package-name'\n\nimport type {InjectOptions} from '../actions/inject'\nimport {githubUrlToObject} from './github-url'\n\ninterface PromptOptions {\n choices?: any\n type?: string\n default?: any\n filter?: (val: any) => any\n validate?: (val: any) => boolean | string\n}\n\nexport async function prompt(message: string, options: PromptOptions) {\n const type = options.choices ? 'select' : (options.type ?? 'input')\n const question: Question & Pick<PromptOptions, 'validate'> = {\n ...options,\n type,\n message,\n name: 'single',\n }\n const {filter, validate} = options\n if (validate) {\n // Classic inquirer ran `validate` on the filtered value; the modern rewrite applies\n // `filter` only after the prompt resolves, so restore the original semantics here\n // (all filters used with `prompt` are idempotent)\n question.validate = (value: any) => validate(filter ? filter(value) : value)\n }\n const result = await inquirer.prompt([question])\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 type {InitFlags} from '../actions/init'\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 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","import {createRequire} from 'node:module'\nimport path from 'path'\n\nimport type {ParsedCommandLine} from '@typescript/typescript6'\nimport validateNpmPackageName from 'validate-npm-package-name'\n\nimport {deprecatedDevDeps} from '../../configs/banned-packages'\nimport {minPkgUtilsMajor, requiredNodeEngine} from '../../constants'\nimport {fileExists, readFile, readJsonFile} from '../../util/files'\nimport {outdent} from '../../util/outdent'\nimport type {PackageJson} 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 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 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).\n * The `src` directory should not be published: it bloats the package and can cause bundlers that\n * 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\".\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","import {getLatestVersion} from 'get-latest-version'\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 async 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 const entries = await Promise.all(\n Object.entries(versions).map(async ([pkgName, range]) => {\n const version = await getLatestVersion(pkgName, {range})\n if (!version) {\n throw new Error(`Found no version for ${pkgName}`)\n }\n return [pkgName, rangeify(version)] as const\n }),\n )\n\n return Object.fromEntries(entries)\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 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 {writeJsonFile} from '../util/files'\nimport {githubUrlToObject} from '../util/github-url'\nimport log from '../util/log'\nimport {resolveLatestVersions} from './resolveLatestVersions'\n\nexport interface GetPackageOptions {\n basePath: string\n validate?: boolean\n isPlugin?: boolean\n}\n\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\nexport async function getPackage(opts: GetPackageOptions): Promise<PackageJson> {\n validateOptions(opts)\n\n const {basePath, validate = true} = opts\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 validatePackage(parsed, opts)\n }\n\n return parsed\n}\n\nfunction validatePackage(manifest: PackageJson, opts: GetPackageOptions) {\n validateOptions(opts)\n\n const options = {isPlugin: true, ...opts}\n\n if (options.isPlugin) {\n validatePackageName(manifest)\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\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\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 = githubUrlToObject(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":";;;;;;;;;;;;;;;;AAKA,SAAgB,QAAQ,SAA+B,GAAG,QAA2B;CACnF,IAAM,QAAQ,QAAQ,EAAE,CAAC,MAAM,sCAAsC,GAC/D,mBAAmB,QAAQ,MAAM,EAAE,CAAC,SAAS,GAE7C,gBAAoB,OAAO,4BAA4B,iBAAiB,IAAI,GAAG,GAE/E,YAAY,QAAQ,KAAK,GAAG,MAAM;EACtC,IAAI,IAAI,EAAE,QAAQ,eAAe,IAAI;EAOrC,OANI,MAAM,MACR,IAAI,EAAE,QAAQ,yBAAyB,EAAE,IAEvC,MAAM,QAAQ,SAAS,MACzB,IAAI,EAAE,QAAQ,yBAAyB,EAAE,IAEpC;CACT,CAAC,GAEG,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAEpC,AADA,UAAU,UAAU,IAChB,IAAI,OAAO,WACb,UAAU,OAAO;CAGrB,OAAO;AACT;AC9BA,MAAa,oBAAoB;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M,uBAAuB;EAAC,GAAG;EAAU;CAAO,GAAG,OAAO,GAGvD;AACT;AAEA,eAAsB,uBAAuB,UAAuB,EAAC,YAA0B;CAC7F,MAAM,cAAc,KAAK,KAAK,UAAU,cAAc,GAAG,QAAQ;AACnE;AAEA,eAAsB,gBAAgB,UAAuB,SAAwB;CAInF,OAHK,QAAQ,MAAM,UAGZ,sBAAsB,UAAU,UAAU,aAC/C,QAAQ,QAAQ,UAAU,gBAAgB,OAAO,QAAQ,KAAK,GAC1D,QAAQ,MAAM,UAAU,OAC1B,QAAQ,SAAS,UAAU,SAAS,QAAQ,MAAM,IAEpD,QAAQ,gBAAgB,UAAU,gBAAgB,eAAe,QAAQ,aAAa,GAClF,QAAQ,MAAM,WAAW,OAC3B,QAAQ,OAAO,UAAU,UAAU,QAAQ,IAAI,IAEjD,QAAQ,iBAAiB,UAAU,gBAAgB,gBAAgB,QAAQ,cAAc,GACzF,QAAQ,QAAQ,UAAU,gBAAgB,OAAO,QAAQ,KAAK,GACvD,QACR,IAdQ;AAeX;AAEA,SAAgB,SAA4C,WAAiB;CAC3E,OAAO,OAAO,KAAK,SAAS,CAAC,CAC1B,KAAK,CAAC,CACN,QAAQ,KAAK,SAEZ,IAAI,OAAO,UAAU,MACd,MACN,CAAC,CAAM;AACd;;AAGA,SAAgB,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
+ {"version":3,"file":"package-8cUY5BVf.js","names":["URL","readFile","validatePackageName","validateNpmPackageName","readFile","validateNpmPackageName"],"sources":["../src/util/outdent.ts","../src/configs/banned-packages.ts","../src/util/github-url.ts","../src/util/prompt.ts","../src/util/files.ts","../src/actions/verify/validations.ts","../src/configs/forced-package-versions.ts","../src/npm/resolveLatestVersions.ts","../src/npm/package.ts"],"sourcesContent":["/**\n * Tagged-template helper that strips the common leading indentation from\n * multi-line strings (same semantics as the `outdent` package for the\n * patterns used in this package).\n */\nexport function outdent(strings: TemplateStringsArray, ...values: unknown[]): string {\n const match = strings[0].match(/(\\r\\n|\\r|\\n)([ \\t]*)(?:[^ \\t\\r\\n]|$)/)\n const indentationLevel = match ? match[2].length : 0\n // Only strip spaces/tabs — never consume non-whitespace from under-indented lines\n const reMatchIndent = new RegExp(`(\\\\r\\\\n|\\\\r|\\\\n)[ \\\\t]{0,${indentationLevel}}`, 'g')\n\n const outdented = strings.map((v, i) => {\n let s = v.replace(reMatchIndent, '$1')\n if (i === 0) {\n s = s.replace(/^[ \\t]*(?:\\r\\n|\\r|\\n)/, '')\n }\n if (i === strings.length - 1) {\n s = s.replace(/(?:\\r\\n|\\r|\\n)[ \\t]*$/, '')\n }\n return s\n })\n\n let result = ''\n for (let i = 0; i < outdented.length; i++) {\n result += outdented[i]\n if (i < values.length) {\n result += values[i]\n }\n }\n return result\n}\n","export const deprecatedDevDeps = [\n 'tsdx',\n 'sanipack',\n 'parcel',\n '@parcel/packager-ts',\n '@parcel/transformer-typescript-types',\n]\n","/**\n * Parse a GitHub remote URL (https, git+ssh, or scp-style) into user/repo.\n * Replaces the untyped `github-url-to-object` package.\n */\nexport function githubUrlToObject(url: string): {user: string; repo: string} | undefined {\n if (!url) {\n return undefined\n }\n\n const trimmed = url.trim()\n\n // git@github.com:user/repo(.git)\n const scp = trimmed.match(/^git@github\\.com:([^/]+)\\/(.+?)(?:\\.git)?$/i)\n if (scp) {\n return {user: scp[1], repo: scp[2]}\n }\n\n try {\n const normalized = trimmed\n .replace(/^git\\+/, '')\n .replace(/^ssh:\\/\\/git@github\\.com\\//i, 'https://github.com/')\n .replace(/^git:\\/\\/github\\.com\\//i, 'https://github.com/')\n const parsed = new URL(normalized)\n if (!/(^|\\.)github\\.com$/i.test(parsed.hostname)) {\n return undefined\n }\n const [, user, repoWithGit] = parsed.pathname.split('/')\n if (!user || !repoWithGit) {\n return undefined\n }\n return {user, repo: repoWithGit.replace(/\\.git$/i, '')}\n } catch {\n return undefined\n }\n}\n","import path from 'path'\nimport {URL} from 'url'\n\nimport inquirer, {type Question} from 'inquirer'\nimport validNpmName from 'validate-npm-package-name'\n\nimport type {InjectOptions} from '../actions/inject'\nimport {githubUrlToObject} from './github-url'\n\ninterface PromptOptions {\n choices?: any\n type?: string\n default?: any\n filter?: (val: any) => any\n validate?: (val: any) => boolean | string\n}\n\nexport async function prompt(message: string, options: PromptOptions) {\n const type = options.choices ? 'select' : (options.type ?? 'input')\n const question: Question & Pick<PromptOptions, 'validate'> = {\n ...options,\n type,\n message,\n name: 'single',\n }\n const {filter, validate} = options\n if (validate) {\n // Classic inquirer ran `validate` on the filtered value; the modern rewrite applies\n // `filter` only after the prompt resolves, so restore the original semantics here\n // (all filters used with `prompt` are idempotent)\n question.validate = (value: any) => validate(filter ? filter(value) : value)\n }\n const result = await inquirer.prompt([question])\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 type {InitFlags} from '../actions/init'\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 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","import {createRequire} from 'node:module'\nimport path from 'path'\n\nimport type {ParsedCommandLine} from '@typescript/typescript6'\nimport validateNpmPackageName from 'validate-npm-package-name'\n\nimport {deprecatedDevDeps} from '../../configs/banned-packages'\nimport {minPkgUtilsMajor, requiredNodeEngine} from '../../constants'\nimport {fileExists, readFile, readJsonFile} from '../../util/files'\nimport {outdent} from '../../util/outdent'\nimport type {PackageJson} 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 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 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).\n * The `src` directory should not be published: it bloats the package and can cause bundlers that\n * 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\".\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","import {getLatestVersion} from 'get-latest-version'\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 async 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 const entries = await Promise.all(\n Object.entries(versions).map(async ([pkgName, range]) => {\n const version = await getLatestVersion(pkgName, {range})\n if (!version) {\n throw new Error(`Found no version for ${pkgName}`)\n }\n return [pkgName, rangeify(version)] as const\n }),\n )\n\n return Object.fromEntries(entries)\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 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 {writeJsonFile} from '../util/files'\nimport {githubUrlToObject} from '../util/github-url'\nimport log from '../util/log'\nimport {resolveLatestVersions} from './resolveLatestVersions'\n\nexport interface GetPackageOptions {\n basePath: string\n validate?: boolean\n isPlugin?: boolean\n}\n\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\nexport async function getPackage(opts: GetPackageOptions): Promise<PackageJson> {\n validateOptions(opts)\n\n const {basePath, validate = true} = opts\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 validatePackage(parsed, opts)\n }\n\n return parsed\n}\n\nfunction validatePackage(manifest: PackageJson, opts: GetPackageOptions) {\n validateOptions(opts)\n\n const options = {isPlugin: true, ...opts}\n\n if (options.isPlugin) {\n validatePackageName(manifest)\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\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\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 = githubUrlToObject(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":";;;;;;;;;;;;;;;;AAKA,SAAgB,QAAQ,SAA+B,GAAG,QAA2B;CACnF,IAAM,QAAQ,QAAQ,EAAE,CAAC,MAAM,sCAAsC,GAC/D,mBAAmB,QAAQ,MAAM,EAAE,CAAC,SAAS,GAE7C,gBAAoB,OAAO,4BAA4B,iBAAiB,IAAI,GAAG,GAE/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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"}
@@ -0,0 +1,4 @@
1
+ var name = "@sanity/plugin-kit", version = "10.0.4", binname = "plugin-kit";
2
+ export { name as n, version as r, binname as t };
3
+
4
+ //# sourceMappingURL=package-BlMyFJ9n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-BlMyFJ9n.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,7 +1,7 @@
1
1
  import { n as defaultOutDir } from "./constants-BIVJp2Jy.js";
2
2
  import { n as sharedFlags_default, t as log_default } from "./log-2MbSIFbq.js";
3
3
  import { D as ensureDir, E as copyFileWithOverwritePrompt, F as prompt, I as promptForPackageName, L as promptForRepoOrigin, M as readJsonFile, N as writeFile, O as fileExists, P as writeFileWithOverwritePrompt, R as outdent, a as getPackage, c as writePackageJsonDirect, d as forcedPackageVersions, i as forceDependencyVersions, j as readFile, l as resolveLatestVersions, n as addPackageJsonScripts, o as sortKeys, r as addScript, s as writePackageJson, t as addBuildScripts, u as forcedDevPackageVersions } from "./package-8cUY5BVf.js";
4
- import { n as name, r as version } from "./package-CuGiTnX2.js";
4
+ import { n as name, r as version } from "./package-BlMyFJ9n.js";
5
5
  import { styleText } from "node:util";
6
6
  import path from "path";
7
7
  import { fileURLToPath } from "url";
@@ -418,7 +418,7 @@ async function applyPreset$1(options) {
418
418
  await writeAssets(semverWorkflowFiles(), options), await addPrepareScript(options), await addDevDependencies$1(options), await updateReadme(options);
419
419
  }
420
420
  async function addPrepareScript(options) {
421
- let didWrite = await addPackageJsonScripts(await getPackage(options), options, (scripts) => (scripts.prepare = addScript("husky", scripts.prepare), scripts));
421
+ let pkg = await getPackage(options), didWrite = await addPackageJsonScripts(pkg, options, (scripts) => (scripts.prepare = addScript("husky", scripts.prepare), scripts));
422
422
  info(didWrite, "Added prepare script to package.json");
423
423
  }
424
424
  async function addDevDependencies$1(options) {
@@ -440,11 +440,14 @@ async function updateReadme(options) {
440
440
  developTest,
441
441
  releaseSnippet
442
442
  ]);
443
- (prependSections.length || appendSections.length) && (await writeFile(readmePath, [
444
- ...prependSections,
445
- readme,
446
- ...appendSections
447
- ].filter(Boolean).join("\n\n"), { encoding: "utf8" }), log_default.info("Updated README. Please review the changes."));
443
+ if (prependSections.length || appendSections.length) {
444
+ let updatedReadme = [
445
+ ...prependSections,
446
+ readme,
447
+ ...appendSections
448
+ ].filter(Boolean).join("\n\n");
449
+ await writeFile(readmePath, updatedReadme, { encoding: "utf8" }), log_default.info("Updated README. Please review the changes.");
450
+ }
448
451
  }
449
452
  async function readmeSnippets(options) {
450
453
  let pkg = await getPackage(options), user = await getUserInfo(options, pkg), bestEffortUrl = readmeBaseurl(pkg), install = installationSnippet(pkg.name ?? "unknown"), usage = outdent`
@@ -652,8 +655,8 @@ async function writeReadme(data, options) {
652
655
  async function writeLicense({ license }, options, licenseChanged) {
653
656
  let { basePath, flags } = options;
654
657
  if (flags.license === !1 || !license) return !1;
655
- let hasLicenseMdFile = await fileExists(path.join(basePath, "LICENSE.md"));
656
- return await writeFileWithOverwritePrompt(path.join(basePath, hasLicenseMdFile ? "LICENSE.md" : "LICENSE"), license.text, {
658
+ let hasLicenseMdFile = await fileExists(path.join(basePath, "LICENSE.md")), licensePath = path.join(basePath, hasLicenseMdFile ? "LICENSE.md" : "LICENSE");
659
+ return await writeFileWithOverwritePrompt(licensePath, license.text, {
657
660
  encoding: "utf8",
658
661
  default: licenseChanged,
659
662
  force: flags.force
@@ -704,7 +707,7 @@ async function getProjectDescription(basePath, pkg, requireUserConfirmation = !1
704
707
  async function resolveProjectDescription(basePath, pkg) {
705
708
  if (pkg && typeof pkg.description == "string" && pkg.description.length > 5) return pkg.description;
706
709
  try {
707
- let [title, description] = (await readFile(path.join(basePath, "README.md"), "utf8")).split("\n").filter(Boolean);
710
+ let readmePath = path.join(basePath, "README.md"), [title, description] = (await readFile(readmePath, "utf8")).split("\n").filter(Boolean);
708
711
  if (!title || !description || !title.match(/^#\s+\w+/)) return null;
709
712
  let unlinked = description.replace(/\[(.*?)\]\(.*?\)/g, "$1");
710
713
  return /^[^#]/.test(unlinked) ? unlinked : null;
@@ -781,7 +784,7 @@ async function addCompileDirToGitIgnore(options) {
781
784
  let ignore = options.outDir.replace(/^[./]+/, "").split("/")[0];
782
785
  if (!ignore) return !1;
783
786
  let lines = gitignore.trim().split("\n");
784
- return lines.includes(ignore) ? !1 : (lines.push("", "# Compiled plugin", ignore), await writeFile(gitIgnorePath, lines.join("\n") + "\n", { encoding: "utf8" }), !0);
787
+ return !lines.includes(ignore) && (lines.push("", "# Compiled plugin", ignore), await writeFile(gitIgnorePath, lines.join("\n") + "\n", { encoding: "utf8" }), !0);
785
788
  }
786
789
  const initFlags = {
787
790
  ...sharedFlags_default,
@@ -863,4 +866,4 @@ async function findStudioConfig(basePath) {
863
866
  }
864
867
  export { presetHelpList as a, inject as i, init as n, initFlags as r, findStudioConfig as t };
865
868
 
866
- //# sourceMappingURL=studio-detect-DXA9mBQK.js.map
869
+ //# sourceMappingURL=studio-detect-B4gMDmeH.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"studio-detect-DXA9mBQK.js","names":["applyPreset","pkg.name","pkg.version","path","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/errorToUndefined.ts","../src/util/readme.ts","../src/util/email.ts","../src/util/request.ts","../src/util/xdg.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","../src/sanity/studio-detect.ts"],"sourcesContent":["import type {PackageJson} from '../actions/verify/types'\nimport {outdent} from '../util/outdent'\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 type {InjectTemplate} from '../actions/inject'\nimport {outdent} from '../util/outdent'\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 type {InitFlags} from '../actions/init'\nimport type {InjectTemplate} from '../actions/inject'\nimport {outdent} from '../util/outdent'\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 type {InitFlags} from '../actions/init'\nimport type {InjectTemplate} from '../actions/inject'\nimport {outdent} from '../util/outdent'\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","export function errorToUndefined(err: any) {\n if (err instanceof TypeError) {\n throw err\n }\n\n return undefined\n}\n","import licenses from '@rexxars/choosealicense-list'\n\nimport type {PackageData} from '../actions/inject'\nimport {outdent} from './outdent'\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/plugins/tree/main/packages/@sanity/plugin-kit)\n with default configuration for build & watch scripts.\n\n See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugins/tree/main/packages/@sanity/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","/**\n * Lightweight email check for interactive prompts.\n * Replaces the `email-validator` package.\n */\nexport function isValidEmail(value: string): boolean {\n // Practical check: local@domain with a dot in the domain. Prompt UX only —\n // not an RFC 5322 validator.\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value)\n}\n","import pkg from '../../package.json'\n\ninterface RequestOptions {\n url: string\n as?: 'json'\n headers?: Record<string, string>\n}\n\ninterface RequestResult<T> {\n body: T\n}\n\n/**\n * Tiny fetch wrapper matching the previous get-it requester shape used by\n * `getSanityUserInfo`.\n */\nexport async function requester<T>({url, headers = {}}: RequestOptions): Promise<RequestResult<T>> {\n const response = await fetch(url, {\n headers: {\n 'User-Agent': `${pkg.name}@${pkg.version}`,\n ...headers,\n },\n })\n\n if (!response.ok) {\n throw new Error(`Request to ${url} failed with status ${response.status}`)\n }\n\n return {body: (await response.json()) as T}\n}\n","import {homedir} from 'node:os'\nimport path from 'node:path'\n\n/**\n * XDG config home directory (`$XDG_CONFIG_HOME` or `~/.config`).\n * Replaces the `xdg-basedir` package.\n */\nexport const xdgConfig = process.env.XDG_CONFIG_HOME?.trim() || path.join(homedir(), '.config')\n","import {execSync} from 'child_process'\nimport path from 'path'\n\nimport type {InjectOptions} from '../actions/inject'\nimport type {PackageJson} from '../actions/verify/types'\nimport {isValidEmail} from './email'\nimport {readJsonFile} from './files'\nimport {prompt} from './prompt'\nimport {requester} from './request'\nimport {xdgConfig} from './xdg'\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(xdgConfig ?? '', '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 {styleText} from 'node:util'\nimport path from 'path'\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 {outdent} from '../util/outdent'\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 styleText(\n '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 {styleText} from 'node:util'\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(styleText('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 {execa} from 'execa'\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 execa('git', ['config', '--get', 'remote.origin.url'], {\n cwd: basePath,\n reject: false,\n })\n .then((result) => (result.exitCode === 0 ? result.stdout.trim() : undefined))\n // Spawn errors (e.g. git missing) fall through to package.json repository.url\n .catch(() => undefined)) ||\n 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","import path from 'path'\n\nimport {fileExists} from '../util/files'\n\nconst studioConfigFiles = ['sanity.config.js', 'sanity.config.ts', 'sanity.cli.js', 'sanity.cli.ts']\n\n/**\n * Detects a Sanity Studio config file (`sanity.config.*` or `sanity.cli.*`) in `basePath`.\n * Used by init/inject to refuse operating inside a Studio instead of a plugin package.\n */\nexport async function findStudioConfig(basePath: string) {\n for (const configFile of studioConfigFiles) {\n if (await fileExists(path.join(basePath, configFile))) {\n return {configFile}\n }\n }\n return {configFile: undefined}\n}\n"],"mappings":";;;;;;;;;;;;AAGA,SAAgB,gBAAgB,KAAkB;CAChD,OACE,OAAO;;;;;;;;+BAQoB,IAAI,KAAK;;;;;;;;;;;;+BAYT,IAAI,KAAK;;eAEzB,IAAI,KAAK;;;EAGtB,UAAU,IAAI;AAEhB;AAEA,SAAgB,gBAAgB,KAAkB;CAChD,OACE,OAAO;;;;;;;;;;;;+BAYoB,IAAI,KAAK;;;;;;;;;;;;8BAYV,IAAI,KAAK;;eAExB,IAAI,KAAK;;;EAGtB,UAAU,IAAI;AAEhB;AChEA,SAAgB,oBAAoC;CAClD,OAAO;EACL,MAAM;EACN,IAAI;EACJ,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DhB;AACF;AChEA,SAAgB,oBAAoB,SAA6C;CAC/E,IAAM,EAAC,UAAS;CAEhB,OAAO;EACL,MAAM;EACN,OAAO,MAAM;EACb,IAAI;EACJ,OAAO;CACT;AACF;ACTA,SAAgB,qBAAqB,SAA6C;CAChF,IAAM,EAAC,UAAS;CAEhB,OAAO;EACL,MAAM;EACN,OAAO,MAAM;EACb,IAAI;EACJ,OAAO;CACT;AACF;ACRA,SAAgB,kBAAkB,SAA6D;CAC7F,IAAM,EAAC,OAAO,WAAU;CAExB,OAAO;EACL,MAAM;EACN,OAAO,MAAM;EAGb,IAAI;EACJ,OAAO,OA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A,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;AC5FA,MAAM,oBAAoB;CAAC;CAAoB;CAAoB;CAAiB;AAAe;;;;;AAMnG,eAAsB,iBAAiB,UAAkB;CACvD,KAAK,IAAM,cAAc,mBACvB,IAAI,MAAM,WAAW,KAAK,KAAK,UAAU,UAAU,CAAC,GAClD,OAAO,EAAC,WAAU;CAGtB,OAAO,EAAC,YAAY,KAAA,EAAS;AAC/B"}
1
+ {"version":3,"file":"studio-detect-B4gMDmeH.js","names":["applyPreset","pkg.name","pkg.version","path","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/errorToUndefined.ts","../src/util/readme.ts","../src/util/email.ts","../src/util/request.ts","../src/util/xdg.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","../src/sanity/studio-detect.ts"],"sourcesContent":["import type {PackageJson} from '../actions/verify/types'\nimport {outdent} from '../util/outdent'\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 type {InjectTemplate} from '../actions/inject'\nimport {outdent} from '../util/outdent'\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 type {InitFlags} from '../actions/init'\nimport type {InjectTemplate} from '../actions/inject'\nimport {outdent} from '../util/outdent'\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 type {InitFlags} from '../actions/init'\nimport type {InjectTemplate} from '../actions/inject'\nimport {outdent} from '../util/outdent'\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","export function errorToUndefined(err: any) {\n if (err instanceof TypeError) {\n throw err\n }\n\n return undefined\n}\n","import licenses from '@rexxars/choosealicense-list'\n\nimport type {PackageData} from '../actions/inject'\nimport {outdent} from './outdent'\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/plugins/tree/main/packages/@sanity/plugin-kit)\n with default configuration for build & watch scripts.\n\n See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugins/tree/main/packages/@sanity/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","/**\n * Lightweight email check for interactive prompts.\n * Replaces the `email-validator` package.\n */\nexport function isValidEmail(value: string): boolean {\n // Practical check: local@domain with a dot in the domain. Prompt UX only —\n // not an RFC 5322 validator.\n return /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value)\n}\n","import pkg from '../../package.json'\n\ninterface RequestOptions {\n url: string\n as?: 'json'\n headers?: Record<string, string>\n}\n\ninterface RequestResult<T> {\n body: T\n}\n\n/**\n * Tiny fetch wrapper matching the previous get-it requester shape used by\n * `getSanityUserInfo`.\n */\nexport async function requester<T>({url, headers = {}}: RequestOptions): Promise<RequestResult<T>> {\n const response = await fetch(url, {\n headers: {\n 'User-Agent': `${pkg.name}@${pkg.version}`,\n ...headers,\n },\n })\n\n if (!response.ok) {\n throw new Error(`Request to ${url} failed with status ${response.status}`)\n }\n\n return {body: (await response.json()) as T}\n}\n","import {homedir} from 'node:os'\nimport path from 'node:path'\n\n/**\n * XDG config home directory (`$XDG_CONFIG_HOME` or `~/.config`).\n * Replaces the `xdg-basedir` package.\n */\nexport const xdgConfig = process.env.XDG_CONFIG_HOME?.trim() || path.join(homedir(), '.config')\n","import {execSync} from 'child_process'\nimport path from 'path'\n\nimport type {InjectOptions} from '../actions/inject'\nimport type {PackageJson} from '../actions/verify/types'\nimport {isValidEmail} from './email'\nimport {readJsonFile} from './files'\nimport {prompt} from './prompt'\nimport {requester} from './request'\nimport {xdgConfig} from './xdg'\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(xdgConfig ?? '', '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 {styleText} from 'node:util'\nimport path from 'path'\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 {outdent} from '../util/outdent'\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 styleText(\n '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 {styleText} from 'node:util'\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(styleText('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 {execa} from 'execa'\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 execa('git', ['config', '--get', 'remote.origin.url'], {\n cwd: basePath,\n reject: false,\n })\n .then((result) => (result.exitCode === 0 ? result.stdout.trim() : undefined))\n // Spawn errors (e.g. git missing) fall through to package.json repository.url\n .catch(() => undefined)) ||\n 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","import path from 'path'\n\nimport {fileExists} from '../util/files'\n\nconst studioConfigFiles = ['sanity.config.js', 'sanity.config.ts', 'sanity.cli.js', 'sanity.cli.ts']\n\n/**\n * Detects a Sanity Studio config file (`sanity.config.*` or `sanity.cli.*`) in `basePath`.\n * Used by init/inject to refuse operating inside a Studio instead of a plugin package.\n */\nexport async function findStudioConfig(basePath: string) {\n for (const configFile of studioConfigFiles) {\n if (await fileExists(path.join(basePath, configFile))) {\n return {configFile}\n }\n }\n return {configFile: undefined}\n}\n"],"mappings":";;;;;;;;;;;;AAGA,SAAgB,gBAAgB,KAAkB;CAChD,OACE,OAAO;;;;;;;;+BAQoB,IAAI,KAAK;;;;;;;;;;;;+BAYT,IAAI,KAAK;;eAEzB,IAAI,KAAK;;;EAGtB,UAAU,IAAI;AAEhB;AAEA,SAAgB,gBAAgB,KAAkB;CAChD,OACE,OAAO;;;;;;;;;;;;+BAYoB,IAAI,KAAK;;;;;;;;;;;;8BAYV,IAAI,KAAK;;eAExB,IAAI,KAAK;;;EAGtB,UAAU,IAAI;AAEhB;AChEA,SAAgB,oBAAoC;CAClD,OAAO;EACL,MAAM;EACN,IAAI;EACJ,OAAO,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DhB;AACF;AChEA,SAAgB,oBAAoB,SAA6C;CAC/E,IAAM,EAAC,UAAS;CAEhB,OAAO;EACL,MAAM;EACN,OAAO,MAAM;EACb,IAAI;EACJ,OAAO;CACT;AACF;ACTA,SAAgB,qBAAqB,SAA6C;CAChF,IAAM,EAAC,UAAS;CAEhB,OAAO;EACL,MAAM;EACN,OAAO,MAAM;EACb,IAAI;EACJ,OAAO;CACT;AACF;ACRA,SAAgB,k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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;AC5FA,MAAM,oBAAoB;CAAC;CAAoB;CAAoB;CAAiB;AAAe;;;;;AAMnG,eAAsB,iBAAiB,UAAkB;CACvD,KAAK,IAAM,cAAc,mBACvB,IAAI,MAAM,WAAW,KAAK,KAAK,UAAU,UAAU,CAAC,GAClD,OAAO,EAAC,WAAU;CAGtB,OAAO,EAAC,YAAY,KAAA,EAAS;AAC/B"}
@@ -1,7 +1,7 @@
1
1
  import { i as urls, t as cliName } from "./constants-BIVJp2Jy.js";
2
2
  import { n as sharedFlags_default, t as log_default } from "./log-2MbSIFbq.js";
3
3
  import { C as validateScripts, O as fileExists, R as outdent, S as validatePkgUtilsVersion, T as validateTsConfig, _ as validateOxfmtConfig, a as getPackage, b as validatePackageType, f as validateBabelConfig, g as validateNodeEngine, h as validateEsmOnly, m as validateDeprecatedDependencies, p as validateBannedFiles, v as validateOxlintConfig, w as validateSrcIndexFile, x as validatePkgUtilsDependency, y as validatePackageName } from "./package-8cUY5BVf.js";
4
- import { t as loadPackageConfig } from "./load-package-config-CHynlKXx.js";
4
+ import { t as loadPackageConfig } from "./load-package-config-BJhZa2CW.js";
5
5
  import meow from "meow";
6
6
  import { styleText } from "node:util";
7
7
  import path from "path";
@@ -120,4 +120,4 @@ function run({ argv }) {
120
120
  }
121
121
  export { run as default };
122
122
 
123
- //# sourceMappingURL=verify-package-wurW9wW2.js.map
123
+ //# sourceMappingURL=verify-package-Cm62CGGp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"verify-package-wurW9wW2.js","names":["sharedFlags"],"sources":["../src/util/ts.ts","../src/actions/verify/verify-common.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 {styleText} from 'node:util'\n\nimport type {TypedFlags} from 'meow'\n\nimport sharedFlags from '../../sharedFlags'\nimport log from '../../util/log'\nimport {outdent} from '../../util/outdent'\n\nconst splitLine = `\\n----------------------------------------------------------`\n\nexport const verifyPackageConfigDefaults = {\n 'packageName': true,\n 'esmOnly': true,\n 'tsconfig': true,\n 'deprecatedDependencies': true,\n 'babelConfig': true,\n 'scripts': true,\n 'pkg-utils': true,\n 'nodeEngine': 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 styleText(\n '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 package validation issues.\n\n Fail-fast (--single) mode enabled, stopping validation here.\n `,\n )\n }\n }\n}\n","import {styleText} from 'node:util'\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 {outdent} from '../util/outdent'\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 validateDeprecatedDependencies,\n validateScripts,\n validateTsConfig,\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('babelConfig', async () => validateBabelConfig({basePath}))\n\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 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 - Reference documentation: ${urls.refDocs}\n\n ${styleText(\n '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 package validation 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 follows plugin-kit conventions.`\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, {importMeta: import.meta, flags: verifyFlags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n return verifyPackage({basePath, flags: cli.flags})\n}\n\nexport default run\n"],"mappings":";;;;;;;;AASA,eAAsB,aAAa,SAA+C;CAChF,IAAM,EAAC,UAAU,aAAY,SACvB,WAAW,KAAK,QAAQ,UAAU,QAAQ;CAGhD,IAAI,CAAC,MAFgB,WAAW,QAAQ,GAE3B;CAEb,IAAM,EAAC,WAAU,GAAG,eAAe,UAAU,GAAG,IAAI,QAAQ;CAEvD,YAEL,OAAO,GAAG,2BAA2B,QAAQ,GAAG,KAAK,QA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-common.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 {styleText} from 'node:util'\n\nimport type {TypedFlags} from 'meow'\n\nimport sharedFlags from '../../sharedFlags'\nimport log from '../../util/log'\nimport {outdent} from '../../util/outdent'\n\nconst splitLine = `\\n----------------------------------------------------------`\n\nexport const verifyPackageConfigDefaults = {\n 'packageName': true,\n 'esmOnly': true,\n 'tsconfig': true,\n 'deprecatedDependencies': true,\n 'babelConfig': true,\n 'scripts': true,\n 'pkg-utils': true,\n 'nodeEngine': 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 styleText(\n '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 package validation issues.\n\n Fail-fast (--single) mode enabled, stopping validation here.\n `,\n )\n }\n }\n}\n","import {styleText} from 'node:util'\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 {outdent} from '../util/outdent'\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 validateDeprecatedDependencies,\n validateScripts,\n validateTsConfig,\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('babelConfig', async () => validateBabelConfig({basePath}))\n\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 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 - Reference documentation: ${urls.refDocs}\n\n ${styleText(\n '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 package validation 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 follows plugin-kit conventions.`\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, {importMeta: import.meta, flags: verifyFlags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n return verifyPackage({basePath, flags: cli.flags})\n}\n\nexport default run\n"],"mappings":";;;;;;;;AASA,eAAsB,aAAa,SAA+C;CAChF,IAAM,EAAC,UAAU,aAAY,SACvB,WAAW,KAAK,QAAQ,UAAU,QAAQ;CAGhD,IAAI,CAAC,MAFgB,WAAW,QAAQ,GAE3B;CAEb,IAAM,EAAC,WAAU,GAAG,eAAe,UAAU,GAAG,IAAI,QAAQ;CAEvD,YAEL,OAAO,GAAG,2BAA2B,QAAQ,GAAG,KAAK,QAAQ;AAC/D;ACbA,MAmBa,cAAc;CACzB,GAAGA;CACH,QAAQ;EACN,SAAS;EACT,MAAM;CACR;AACF;AAIA,SAAS,iBAAiB,UAAkB;CAC1C,OAAO,UACL,QACA,OAAO;;;;uBAIY,SAAS;;;YAGpB,UAAU,CACpB;AACF;AAEA,SAAgB,gBACd,cACA,OACA,QACA;CACA,OAAO,eAAe,WACpB,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;ACpDA,eAAsB,cAAc,EAAC,UAAU,S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A+B,WAAW,CAC5C,GAEI,OAAO,QACT,MAAU,MACR,OAAO;;;;;mBAKM,KAAK,aAAa;;;qCAGA,KAAK,QAAQ;;UAExC,UACA,QACA,kDAAkD,QAAQ,yBAC5D,EAAE;QACF,UAAU,CACd;CAGF,YAAI,QACF,OAAO;;;;sEAI2D,KAAK,aAAa;;;IAGpF,KAAK,CACP;AACF;ACpGA,MAEM,OAAO;;MAEP,QAAQ;;;;;;;;;;;;;MAaR,QAAQ;;;MAGR,QAAQ;;AAGd,SAAS,IAAI,EAAC,QAAyB;CACrC,IAAM,MAAM,KAAK,MAAM;EAAC,YAAY;EAAa,OAAO;EAAa;EAAM;CAAW,CAAC;CAEvF,OAAO,cAAc;EAAC,UADL,KAAK,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,CACpC;EAAU,OAAO,IAAI;CAAK,CAAC;AACnD"}
@@ -1,5 +1,5 @@
1
1
  import { n as sharedFlags_default, t as log_default } from "./log-2MbSIFbq.js";
2
- import { n as name, r as version, t as binname } from "./package-CuGiTnX2.js";
2
+ import { n as name, r as version, t as binname } from "./package-BlMyFJ9n.js";
3
3
  import meow from "meow";
4
4
  const description = `Show the installed version of ${name}`, help = `
5
5
  Usage
@@ -52,4 +52,4 @@ function run({ argv }) {
52
52
  }
53
53
  export { run as default };
54
54
 
55
- //# sourceMappingURL=version-BjoOWC3p.js.map
55
+ //# sourceMappingURL=version-BX9-ERrR.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version-BjoOWC3p.js","names":["pkg.name","pkg.binname","pkg.version","sharedFlags"],"sources":["../src/cmds/version.ts"],"sourcesContent":["import meow from 'meow'\n\nimport pkg from '../../package.json'\nimport sharedFlags from '../sharedFlags'\nimport log from '../util/log'\n\nconst description = `Show the installed version of ${pkg.name}`\n\nconst help = `\nUsage\n $ ${pkg.binname} version\n\nOptions\n --major Show only the major version\n --minor Show only the minor version\n --patch Show only the patch version\n\nExamples\n $ ${pkg.binname} version\n ${pkg.name} version ${pkg.version}\n\n $ ${pkg.binname} version --major\n ${pkg.version.split('.')[0]}\n`\n\nconst flags = {\n ...sharedFlags,\n\n major: {\n type: 'boolean',\n default: false,\n },\n\n minor: {\n type: 'boolean',\n default: false,\n },\n\n patch: {\n type: 'boolean',\n default: false,\n },\n} as const\n\nfunction run({argv}: {argv: string[]}) {\n const cli = meow(help, {importMeta: import.meta, flags, argv, description})\n const versionParts = pkg.version.split('.')\n const versionNames = ['major', 'minor', 'patch']\n const versionFlags = versionNames.filter((flagName) => cli.flags[flagName])\n const versionFlag = versionFlags[0]\n const numVersionFlags = versionFlags.length\n\n if (numVersionFlags === 0) {\n log.msg(`${pkg.name} version ${pkg.version}`)\n return\n }\n\n if (numVersionFlags > 1) {\n throw new Error(\n `--major, --minor and --patch are mutually exclusive - only one can be used at a time`,\n )\n }\n\n const partIndex = versionNames.indexOf(versionFlag)\n log.msg(versionParts[partIndex])\n}\n\nexport default run\n"],"mappings":";;;AAMA,MAAM,cAAc,iCAAiCA,QAE/C,OAAO;;MAEPC,QAAY;;;;;;;;MAQZA,QAAY;IACdD,KAAS,WAAWE,QAAY;;MAE9BD,QAAY;IACF,QAAA,MAAM,GAAG,CAAC,CAAC,GAAG;GAGxB,QAAQ;CACZ,GAAGE;CAEH,OAAO;EACL,MAAM;EACN,SAAS;CACX;CAEA,OAAO;EACL,MAAM;EACN,SAAS;CACX;CAEA,OAAO;EACL,MAAM;EACN,SAAS;CACX;AACF;AAEA,SAAS,IAAI,EAAC,QAAyB;CACrC,IAAM,MAAM,KAAK,MAAM;EAAC,YAAY,OAAO;EAAM;EAAO;EAAM;CAAW,CAAC,GACpE,eAAA,QAA2B,MAAM,GAAG,GACpC,eAAe;EAAC;EAAS;EAAS;CAAO,GACzC,eAAe,aAAa,QAAQ,aAAa,IAAI,MAAM,SAAS,GACpE,cAAc,aAAa,IAC3B,kBAAkB,aAAa;CAErC,IAAI,oBAAoB,GAAG;EACzB,YAAI,IAAI,GAAGH,KAAS,WAAWE,SAAa;EAC5C;CACF;CAEA,IAAI,kBAAkB,GACpB,MAAU,MACR,sFACF;CAGF,IAAM,YAAY,aAAa,QAAQ,WAAW;CAClD,YAAI,IAAI,aAAa,UAAU;AACjC"}
1
+ {"version":3,"file":"version-BX9-ERrR.js","names":["pkg.name","pkg.binname","pkg.version","sharedFlags"],"sources":["../src/cmds/version.ts"],"sourcesContent":["import meow from 'meow'\n\nimport pkg from '../../package.json'\nimport sharedFlags from '../sharedFlags'\nimport log from '../util/log'\n\nconst description = `Show the installed version of ${pkg.name}`\n\nconst help = `\nUsage\n $ ${pkg.binname} version\n\nOptions\n --major Show only the major version\n --minor Show only the minor version\n --patch Show only the patch version\n\nExamples\n $ ${pkg.binname} version\n ${pkg.name} version ${pkg.version}\n\n $ ${pkg.binname} version --major\n ${pkg.version.split('.')[0]}\n`\n\nconst flags = {\n ...sharedFlags,\n\n major: {\n type: 'boolean',\n default: false,\n },\n\n minor: {\n type: 'boolean',\n default: false,\n },\n\n patch: {\n type: 'boolean',\n default: false,\n },\n} as const\n\nfunction run({argv}: {argv: string[]}) {\n const cli = meow(help, {importMeta: import.meta, flags, argv, description})\n const versionParts = pkg.version.split('.')\n const versionNames = ['major', 'minor', 'patch']\n const versionFlags = versionNames.filter((flagName) => cli.flags[flagName])\n const versionFlag = versionFlags[0]\n const numVersionFlags = versionFlags.length\n\n if (numVersionFlags === 0) {\n log.msg(`${pkg.name} version ${pkg.version}`)\n return\n }\n\n if (numVersionFlags > 1) {\n throw new Error(\n `--major, --minor and --patch are mutually exclusive - only one can be used at a time`,\n )\n }\n\n const partIndex = versionNames.indexOf(versionFlag)\n log.msg(versionParts[partIndex])\n}\n\nexport default run\n"],"mappings":";;;AAMA,MAAM,cAAc,iCAAiCA,QAE/C,OAAO;;MAEPC,QAAY;;;;;;;;MAQZA,QAAY;IACdD,KAAS,WAAWE,QAAY;;MAE9BD,QAAY;IACF,QAAA,MAAM,GAAG,CAAC,CAAC,GAAG;GAGxB,QAAQ;CACZ,GAAGE;CAEH,OAAO;EACL,MAAM;EACN,SAAS;CACX;CAEA,OAAO;EACL,MAAM;EACN,SAAS;CACX;CAEA,OAAO;EACL,MAAM;EACN,SAAS;CACX;AACF;AAEA,SAAS,IAAI,EAAC,QAAyB;CACrC,IAAM,MAAM,KAAK,MAAM;EAAC,YAAY;EAAa;EAAO;EAAM;CAAW,CAAC,GACpE,eAAA,QAA2B,MAAM,GAAG,GACpC,eAAe;EAAC;EAAS;EAAS;CAAO,GACzC,eAAe,aAAa,QAAQ,aAAa,IAAI,MAAM,SAAS,GACpE,cAAc,aAAa,IAC3B,kBAAkB,aAAa;CAErC,IAAI,oBAAoB,GAAG;EACzB,YAAI,IAAI,GAAGH,KAAS,WAAWE,SAAa;EAC5C;CACF;CAEA,IAAI,kBAAkB,GACpB,MAAU,MACR,sFACF;CAGF,IAAM,YAAY,aAAa,QAAQ,WAAW;CAClD,YAAI,IAAI,aAAa,UAAU;AACjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/plugin-kit",
3
- "version": "10.0.2",
3
+ "version": "10.0.4",
4
4
  "description": "Enhanced Sanity.io plugin development experience",
5
5
  "keywords": [
6
6
  "bootstrap",
@@ -54,22 +54,22 @@
54
54
  "@sanity/tsconfig": "^2.2.1",
55
55
  "@sanity/tsdown-config": "^0.21.2",
56
56
  "@types/node": "^24.13.3",
57
- "@types/react": "^19.2.17",
57
+ "@types/react": "^19.2.18",
58
58
  "@types/validate-npm-package-name": "^4.0.2",
59
- "oxfmt": "^0.60.0",
60
- "oxlint": "^1.75.0",
59
+ "oxfmt": "^0.61.0",
60
+ "oxlint": "^1.77.0",
61
61
  "oxlint-tsgolint": "^7.0.2001",
62
62
  "react": "^19.2.8",
63
63
  "react-dom": "^19.2.8",
64
- "sanity": "^6.6.0",
64
+ "sanity": "^6.8.0",
65
65
  "styled-components": "^6.4.4",
66
66
  "tsdown": "^0.22.14",
67
67
  "typescript": "7.0.2"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@sanity/pkg-utils": "^11.0.17",
71
- "oxfmt": "^0.60.0",
72
- "oxlint": "^1.75.0"
71
+ "oxfmt": "^0.61.0",
72
+ "oxlint": "^1.77.0"
73
73
  },
74
74
  "peerDependenciesMeta": {
75
75
  "oxfmt": {
@@ -1,4 +0,0 @@
1
- var name = "@sanity/plugin-kit", version = "10.0.2", binname = "plugin-kit";
2
- export { name as n, version as r, binname as t };
3
-
4
- //# sourceMappingURL=package-CuGiTnX2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-CuGiTnX2.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}