@sanity/plugin-kit 6.0.3 → 6.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.
Files changed (52) hide show
  1. package/dist/constants.js +12 -0
  2. package/dist/constants.js.map +1 -0
  3. package/dist/index.js +72 -4
  4. package/dist/index.js.map +1 -1
  5. package/dist/init.js +866 -0
  6. package/dist/init.js.map +1 -0
  7. package/dist/init2.js +99 -0
  8. package/dist/init2.js.map +1 -0
  9. package/dist/{_chunks-es/inject.js → inject.js} +22 -16
  10. package/dist/inject.js.map +1 -0
  11. package/dist/link-watch.js +93 -0
  12. package/dist/link-watch.js.map +1 -0
  13. package/dist/load-package-config.js +31 -0
  14. package/dist/load-package-config.js.map +1 -0
  15. package/dist/log.js +31 -0
  16. package/dist/log.js.map +1 -0
  17. package/dist/package.js +908 -0
  18. package/dist/package.js.map +1 -0
  19. package/dist/package2.js +4 -0
  20. package/dist/package2.js.map +1 -0
  21. package/dist/verify-common.js +145 -0
  22. package/dist/verify-common.js.map +1 -0
  23. package/dist/verify-package.js +89 -0
  24. package/dist/verify-package.js.map +1 -0
  25. package/dist/verify-studio.js +65 -0
  26. package/dist/verify-studio.js.map +1 -0
  27. package/dist/version.js +54 -0
  28. package/dist/version.js.map +1 -0
  29. package/package.json +8 -7
  30. package/dist/_chunks-es/index.js +0 -125
  31. package/dist/_chunks-es/index.js.map +0 -1
  32. package/dist/_chunks-es/init.js +0 -85
  33. package/dist/_chunks-es/init.js.map +0 -1
  34. package/dist/_chunks-es/init2.js +0 -839
  35. package/dist/_chunks-es/init2.js.map +0 -1
  36. package/dist/_chunks-es/inject.js.map +0 -1
  37. package/dist/_chunks-es/link-watch.js +0 -91
  38. package/dist/_chunks-es/link-watch.js.map +0 -1
  39. package/dist/_chunks-es/load-package-config.js +0 -22
  40. package/dist/_chunks-es/load-package-config.js.map +0 -1
  41. package/dist/_chunks-es/package.js +0 -1066
  42. package/dist/_chunks-es/package.js.map +0 -1
  43. package/dist/_chunks-es/package2.js +0 -9
  44. package/dist/_chunks-es/package2.js.map +0 -1
  45. package/dist/_chunks-es/verify-common.js +0 -169
  46. package/dist/_chunks-es/verify-common.js.map +0 -1
  47. package/dist/_chunks-es/verify-package.js +0 -95
  48. package/dist/_chunks-es/verify-package.js.map +0 -1
  49. package/dist/_chunks-es/verify-studio.js +0 -61
  50. package/dist/_chunks-es/verify-studio.js.map +0 -1
  51. package/dist/_chunks-es/version.js +0 -50
  52. package/dist/_chunks-es/version.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.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, {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;YACF,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;EAAO;EAAM;CAAW,CAAC,GAC3C,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": "6.0.3",
3
+ "version": "6.0.4",
4
4
  "description": "Enhanced Sanity.io plugin development experience",
5
5
  "keywords": [
6
6
  "bootstrap",
@@ -58,7 +58,9 @@
58
58
  "yalc": "1.0.0-pre.53"
59
59
  },
60
60
  "devDependencies": {
61
- "@sanity/pkg-utils": "^10.8.2",
61
+ "@sanity/pkg-utils": "^10.9.0",
62
+ "@sanity/tsconfig": "^2.2.0",
63
+ "@sanity/tsdown-config": "^0.11.0",
62
64
  "@types/eslint": "^8.56.12",
63
65
  "@types/github-url-to-object": "^4.0.4",
64
66
  "@types/inquirer": "^9.0.3",
@@ -79,12 +81,11 @@
79
81
  "react-dom": "^19.2.7",
80
82
  "sanity": "^6.3.0",
81
83
  "styled-components": "^6.4.3",
82
- "typescript": "6.0.3",
83
- "@repo/package.config": "0.0.0",
84
- "@repo/tsconfig": "0.0.0"
84
+ "tsdown": "^0.22.3",
85
+ "typescript": "6.0.3"
85
86
  },
86
87
  "peerDependencies": {
87
- "@sanity/pkg-utils": "^10.8.2",
88
+ "@sanity/pkg-utils": "^10.9.0",
88
89
  "eslint": ">=8.0.0",
89
90
  "typescript": "5.8.x || 5.9.x || 6.0.x"
90
91
  },
@@ -93,6 +94,6 @@
93
94
  },
94
95
  "binname": "plugin-kit",
95
96
  "scripts": {
96
- "build": "pkg build --strict --check --clean"
97
+ "build": "tsdown"
97
98
  }
98
99
  }
@@ -1,125 +0,0 @@
1
- import meow from "meow";
2
- import chalk from "chalk";
3
- var commands = {
4
- init: async (options) => {
5
- await (await import("./init.js")).default(options);
6
- },
7
- inject: async (options) => {
8
- await (await import("./inject.js")).default(options);
9
- },
10
- "link-watch": async (options) => {
11
- await (await import("./link-watch.js")).default(options);
12
- },
13
- "verify-package": async (options) => {
14
- await (await import("./verify-package.js")).default(options);
15
- },
16
- "verify-studio": async (options) => {
17
- await (await import("./verify-studio.js")).default(options);
18
- },
19
- version: async (options) => {
20
- (await import("./version.js")).default(options);
21
- }
22
- };
23
- const cliName = "@sanity/plugin-kit", urls = {
24
- refDocs: "https://beta.sanity.io/docs/reference",
25
- migrationGuideStudio: "https://beta.sanity.io/docs/platform/v2-to-v3",
26
- migrationGuidePlugin: "https://beta.sanity.io/docs/platform/v2-to-v3/plugins",
27
- pluginReadme: "https://github.com/sanity-io/plugin-kit",
28
- incompatiblePlugin: "https://github.com/sanity-io/incompatible-plugin",
29
- sanityExchange: "https://www.sanity.io/exchange",
30
- linterPackage: "https://github.com/sanity-io/eslint-config-no-v2-imports"
31
- }, incompatiblePluginPackage = "@sanity/incompatible-plugin", defaultOutDir = "dist", minPkgUtilsMajor = 10, requiredNodeEngine = ">=20.19 <22 || >=22.12";
32
- var sharedFlags = {
33
- debug: {
34
- default: !1,
35
- type: "boolean"
36
- },
37
- silent: {
38
- type: "boolean",
39
- default: !1
40
- },
41
- verbose: {
42
- type: "boolean",
43
- default: !1
44
- }
45
- };
46
- let beQuiet = !1, beVerbose = !1;
47
- function setVerbosity({ verbose, silent }) {
48
- silent ? (beVerbose = !1, beQuiet = !0) : verbose && (beVerbose = !0, beQuiet = !1);
49
- }
50
- var log = {
51
- setVerbosity,
52
- // Bypasses any checks, prints regardless (only use for things like `cli --version`)
53
- msg: (msg, ...args) => !beQuiet && console.log(msg, ...args),
54
- // Debug only printed on --verbose
55
- debug: (msg, ...args) => !beQuiet && beVerbose && console.debug(`${chalk.bgBlack.white("[debug]")} ${msg}`, ...args),
56
- // Success messages only printed if not --silent
57
- success: (msg, ...args) => !beQuiet && console.info(`${chalk.bgBlack.greenBright("[success]")} ${msg}`, ...args),
58
- // Info only printed if not --silent ("standard" level)
59
- info: (msg, ...args) => !beQuiet && console.info(`${chalk.bgBlack.cyanBright("[info]")} ${msg}`, ...args),
60
- // Warning only printed if not --silent
61
- warn: (msg, ...args) => !beQuiet && console.warn(`${chalk.bgBlack.yellowBright("[warn]")} ${msg}`, ...args),
62
- // Errors are always printed
63
- error: (msg, ...args) => console.error(`${chalk.bgBlack.redBright("[error]")} ${msg}`, ...args)
64
- };
65
- async function cliEntry(argv = process.argv) {
66
- const cli = meow(
67
- `
68
- Usage
69
- $ ${cliName} [--help] [--debug] <command> [<args>]
70
-
71
- These are common commands used in various situations:
72
-
73
- init Create a new Sanity plugin
74
- inject Inject config into an existing Sanity v3 plugin
75
- verify-package Check that a Sanity plugin package follows V3 conventions. Prints upgrade steps.
76
- verify-studio Check that a Sanity Studio follows V3 conventions. Prints upgrade steps.
77
- link-watch Recompiles plugin automatically on changes and runs yalc push --publish
78
- version Show the version of ${cliName} currently installed
79
-
80
- Options
81
- --silent Do not print info and warning messages
82
- --verbose Log everything. This option conflicts with --silent
83
- --debug Print stack trace on errors
84
- --version Output the version number
85
- --help Output usage information
86
-
87
- Examples
88
- # Init a new plugin in current directory
89
- $ ${cliName} init
90
-
91
- # Init a new plugin in my-sanity-plugin directory
92
- $ ${cliName} init my-sanity-plugin
93
-
94
- # Check that a Sanity plugin package in current directory follows V3 conventions
95
- $ ${cliName} verify-package
96
-
97
- # Check that a Sanity Studio in current directory follows V3 conventions
98
- $ ${cliName} verify-studio
99
- `,
100
- {
101
- autoHelp: !1,
102
- flags: sharedFlags,
103
- argv: argv.slice(2)
104
- }
105
- ), commandName = cli.input[0];
106
- commandName || cli.showHelp(), commandName in commands || (console.error(`Unknown command "${commandName}"`), cli.showHelp()), cli.flags.silent && cli.flags.verbose && (log.error("--silent and --verbose are mutually exclusive"), cli.showHelp());
107
- const cmd = commands[commandName];
108
- try {
109
- log.setVerbosity(cli.flags), await cmd({ argv: argv.slice(3) });
110
- } catch (err) {
111
- log.error(err instanceof TypeError || cli.flags.debug ? err.stack : err.message), process.exit(1);
112
- }
113
- }
114
- export {
115
- cliEntry,
116
- cliName,
117
- defaultOutDir,
118
- incompatiblePluginPackage,
119
- log,
120
- minPkgUtilsMajor,
121
- requiredNodeEngine,
122
- sharedFlags,
123
- urls
124
- };
125
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../src/cmds/index.ts","../../src/constants.ts","../../src/sharedFlags.ts","../../src/util/log.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 'verify-studio': async (options: {argv: string[]}) => {\n await (await import('./verify-studio')).default(options)\n },\n 'version': async (options: {argv: string[]}) => {\n ;(await import('./version')).default(options)\n },\n}\n","export const cliName = '@sanity/plugin-kit'\n\nexport const urls = {\n refDocs: 'https://beta.sanity.io/docs/reference',\n migrationGuideStudio: 'https://beta.sanity.io/docs/platform/v2-to-v3',\n migrationGuidePlugin: 'https://beta.sanity.io/docs/platform/v2-to-v3/plugins',\n pluginReadme: 'https://github.com/sanity-io/plugin-kit',\n incompatiblePlugin: 'https://github.com/sanity-io/incompatible-plugin',\n sanityExchange: 'https://www.sanity.io/exchange',\n linterPackage: 'https://github.com/sanity-io/eslint-config-no-v2-imports',\n}\n\nexport const incompatiblePluginPackage = '@sanity/incompatible-plugin'\n\nexport const defaultOutDir = 'dist'\n\n/**\n * Minimum major version of `@sanity/pkg-utils` required in userland.\n *\n * plugin-kit loads `package.config.ts` via the plugin's own `@sanity/pkg-utils` (a peer\n * dependency) using the `loadConfig({cwd, pkgPath})` signature introduced in v10. Older majors\n * expose an incompatible `loadConfig({cwd})` and cannot reliably load ESM TypeScript configs.\n */\nexport const minPkgUtilsMajor = 10\n\n/**\n * Required `engines.node` range for plugins, matching `@sanity/pkg-utils` so plugins declare the\n * same Node.js support as the build tool they use.\n */\nexport const requiredNodeEngine = '>=20.19 <22 || >=22.12'\n","export default {\n debug: {\n default: false,\n type: 'boolean',\n },\n silent: {\n type: 'boolean',\n default: false,\n },\n verbose: {\n type: 'boolean',\n default: false,\n },\n} as const\n","// Note: This is _specifically_ meant for CLI usage,\n// I realize that \"singletons\" are bad.\n\nimport chalk from 'chalk'\n\nlet beQuiet = false\nlet beVerbose = false\n\nfunction setVerbosity({verbose, silent}: {verbose: boolean; silent: boolean}) {\n if (silent) {\n beVerbose = false\n beQuiet = true\n } else if (verbose) {\n beVerbose = true\n beQuiet = false\n }\n}\n\nexport default {\n setVerbosity: setVerbosity,\n\n // Bypasses any checks, prints regardless (only use for things like `cli --version`)\n msg: (msg: any, ...args: any[]) => !beQuiet && console.log(msg, ...args),\n\n // Debug only printed on --verbose\n debug: (msg: any, ...args: any[]) =>\n !beQuiet && beVerbose && console.debug(`${chalk.bgBlack.white('[debug]')} ${msg}`, ...args),\n\n // Success messages only printed if not --silent\n success: (msg: any, ...args: any[]) =>\n !beQuiet && console.info(`${chalk.bgBlack.greenBright('[success]')} ${msg}`, ...args),\n\n // Info only printed if not --silent (\"standard\" level)\n info: (msg: any, ...args: any[]) =>\n !beQuiet && console.info(`${chalk.bgBlack.cyanBright('[info]')} ${msg}`, ...args),\n\n // Warning only printed if not --silent\n warn: (msg: any, ...args: any[]) =>\n !beQuiet && console.warn(`${chalk.bgBlack.yellowBright('[warn]')} ${msg}`, ...args),\n\n // Errors are always printed\n error: (msg: any, ...args: any[]) =>\n console.error(`${chalk.bgBlack.redBright('[error]')} ${msg}`, ...args),\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 v3 plugin\n verify-package Check that a Sanity plugin package follows V3 conventions. Prints upgrade steps.\n verify-studio Check that a Sanity Studio follows V3 conventions. Prints upgrade steps.\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 V3 conventions\n $ ${cliName} verify-package\n\n # Check that a Sanity Studio in current directory follows V3 conventions\n $ ${cliName} verify-studio\n`,\n {\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"],"names":[],"mappings":";;AAAA,IAAA,WAAe;AAAA,EACb,MAAQ,OAAO,YAA8B;AAC3C,WAAO,MAAM,OAAO,WAAQ,GAAG,QAAQ,OAAO;AAAA,EAChD;AAAA,EACA,QAAU,OAAO,YAA8B;AAC7C,WAAO,MAAM,OAAO,aAAU,GAAG,QAAQ,OAAO;AAAA,EAClD;AAAA,EACA,cAAc,OAAO,YAA8B;AACjD,WAAO,MAAM,OAAO,iBAAc,GAAG,QAAQ,OAAO;AAAA,EACtD;AAAA,EACA,kBAAkB,OAAO,YAA8B;AACrD,WAAO,MAAM,OAAO,qBAAkB,GAAG,QAAQ,OAAO;AAAA,EAC1D;AAAA,EACA,iBAAiB,OAAO,YAA8B;AACpD,WAAO,MAAM,OAAO,oBAAiB,GAAG,QAAQ,OAAO;AAAA,EACzD;AAAA,EACA,SAAW,OAAO,YAA8B;AAC7C,KAAC,MAAM,OAAO,cAAW,GAAG,QAAQ,OAAO;AAAA,EAC9C;AACF;ACnBO,MAAM,UAAU,sBAEV,OAAO;AAAA,EAClB,SAAS;AAAA,EACT,sBAAsB;AAAA,EACtB,sBAAsB;AAAA,EACtB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,eAAe;AACjB,GAEa,4BAA4B,+BAE5B,gBAAgB,QAShB,mBAAmB,IAMnB,qBAAqB;AC7BlC,IAAA,cAAe;AAAA,EACb,OAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,EAAA;AAAA,EAER,QA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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAWzC,OAAO;AAAA;AAAA;AAAA,QAGP,OAAO;AAAA;AAAA;AAAA,QAGP,OAAO;AAAA;AAAA;AAAA,QAGP,OAAO;AAAA;AAAA,IAEX;AAAA,MACE,UAAU;AAAA,MACV,OAAO;AAAA,MACP,MAAM,KAAK,MAAM,CAAC;AAAA,IAAA;AAAA,EACpB,GAGI,cAAc,IAAI,MAAM,CAAC;AAC1B,iBACH,IAAI,YAGA,eAAe,aACnB,QAAQ,MAAM,oBAAoB,WAAW,GAAG,GAChD,IAAI,aAGF,IAAI,MAAM,UAAU,IAAI,MAAM,YAChC,IAAI,MAAM,+CAA+C,GACzD,IAAI,SAAA;AAIN,QAAM,MAAM,SAAS,WAAoC;AAEzD,MAAI;AACF,QAAI,aAAa,IAAI,KAAK,GAC1B,MAAM,IAAI,EAAC,MAAM,KAAK,MAAM,CAAC,EAAA,CAAE;AAAA,EACjC,SAAS,KAAU;AACjB,QAAI,MAAM,eAAe,aAAa,IAAI,MAAM,QAAQ,IAAI,QAAQ,IAAI,OAAO,GAE/E,QAAQ,KAAK,CAAC;AAAA,EAChB;AACF;"}
@@ -1,85 +0,0 @@
1
- import path from "path";
2
- import meow from "meow";
3
- import { initFlags, init, presetHelpList } from "./init2.js";
4
- import { cliName, log } from "./index.js";
5
- import execa from "execa";
6
- import { prompt, hasSanityJson, findStudioV3Config, isEmptyish, ensureDir } from "./package.js";
7
- function npmIsAvailable() {
8
- return execa("npm", ["-v"]).then(() => !0).catch(() => !1);
9
- }
10
- function yarnIsAvailable() {
11
- return execa("yarn", ["-v"]).then(() => !0).catch(() => !1);
12
- }
13
- function pnpmAvailable() {
14
- return execa("pnpm", ["-v"]).then(() => !0).catch(() => !1);
15
- }
16
- async function promptForPackageManager() {
17
- const [npm, yarn, pnpm] = await Promise.all([
18
- npmIsAvailable(),
19
- yarnIsAvailable(),
20
- pnpmAvailable()
21
- ]), choices = [npm && "npm", yarn && "yarn", pnpm && "pnpm"].filter(Boolean);
22
- return choices.length < 2 ? choices[0] || "npm" : prompt("Which package manager do you prefer?", {
23
- choices: choices.map((value) => ({ value, name: value })),
24
- default: choices[0]
25
- });
26
- }
27
- async function installDependencies(pm, { cwd }) {
28
- const proc = execa(pm, ["install"], { cwd, stdio: "inherit" }), { exitCode } = await proc;
29
- return exitCode <= 0;
30
- }
31
- const description = "Initialize a new Sanity plugin", help = `
32
- Usage
33
- $ ${cliName} init [dir] [<args>]
34
-
35
- Options
36
- --no-eslint Disables ESLint config and dependencies from being added
37
- --no-prettier Disables prettier config and dependencies from being added
38
- --no-typescript Disables typescript config and dependencies from being added
39
- --no-license Disables LICENSE + package.json license field from being added
40
- --no-editorconfig Disables .editorconfig from being added
41
- --no-gitignore Disables .gitignore from being added
42
- --no-scripts Disables scripts from being added to package.json
43
- --no-install Disables automatically running package manager install
44
-
45
- --name [package-name] Use the provided package-name
46
- --author [name] Use the provided author
47
- --repo [url] Use the provided repo url
48
- --license [spdx] Use the license with the given SPDX identifier
49
- --force No prompt when overwriting files
50
-
51
- --preset [preset-name] Adds config and files from a named preset. --preset can be supplied multiple times.
52
- The following presets are available:
53
- ${presetHelpList(30)}
54
-
55
- Examples
56
- # Initialize a new plugin in the current directory
57
- $ ${cliName} init
58
-
59
- # Initialize a plugin in the directory ~/my-plugin
60
- $ ${cliName} init ~/my-plugin
61
-
62
- # Don't add eslint or prettier
63
- $ ${cliName} init --no-eslint --no-prettier
64
- `;
65
- async function run({ argv }) {
66
- const cli = meow(help, { flags: initFlags, argv, description }), basePath = path.resolve(cli.input[0] || process.cwd()), { exists, isRoot } = await hasSanityJson(basePath);
67
- if (exists && isRoot)
68
- throw new Error(
69
- 'sanity.json has a "root" property set to true - are you trying to init into a studio instead of a plugin?'
70
- );
71
- const { v3ConfigFile } = await findStudioV3Config(basePath);
72
- if (v3ConfigFile)
73
- throw new Error(
74
- `${v3ConfigFile} exists - are you trying to init into a studio instead of a plugin?`
75
- );
76
- if (log.info('Initializing new plugin in "%s"', basePath), !cli.flags.force && !await isEmptyish(basePath) && !await prompt("Directory is not empty, proceed?", { type: "confirm", default: !1 })) {
77
- log.error("Directory is not empty. Cancelled.");
78
- return;
79
- }
80
- await ensureDir(basePath), await init({ basePath, flags: cli.flags }), cli.flags.install ? await installDependencies(await promptForPackageManager(), { cwd: basePath }) ? log.info("Done!") : log.error("Failed to install dependencies, try manually running `npm install`") : log.info("Dependency installation skipped.");
81
- }
82
- export {
83
- run as default
84
- };
85
- //# sourceMappingURL=init.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.js","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 const proc = execa(pm, ['install'], {cwd, stdio: 'inherit'})\n const {exitCode} = await proc\n return exitCode <= 0\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 {findStudioV3Config, hasSanityJson} from '../sanity/manifest'\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-eslint Disables ESLint config and dependencies from being added\n --no-prettier Disables prettier 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 eslint or prettier\n $ ${cliName} init --no-eslint --no-prettier\n`\n\nasync function run({argv}: {argv: string[]}) {\n const cli = meow(help, {flags: initFlags, argv, description})\n const basePath = path.resolve(cli.input[0] || process.cwd())\n\n const {exists, isRoot} = await hasSanityJson(basePath)\n if (exists && isRoot) {\n throw new Error(\n `sanity.json has a \"root\" property set to true - are you trying to init into a studio instead of a plugin?`,\n )\n }\n\n const {v3ConfigFile} = await findStudioV3Config(basePath)\n if (v3ConfigFile) {\n throw new Error(\n `${v3ConfigFile} 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"],"names":[],"mappings":";;;;;;AAIA,SAAS,iBAAiB;AACxB,SAAO,MAAM,OAAO,CAAC,IAAI,CAAC,EACvB,KAAK,MAAM,EAAI,EACf,MAAM,MAAM,EAAK;AACtB;AAEA,SAAS,kBAAkB;AACzB,SAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,EACxB,KAAK,MAAM,EAAI,EACf,MAAM,MAAM,EAAK;AACtB;AAEA,SAAS,gBAAgB;AACvB,SAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,EACxB,KAAK,MAAM,EAAI,EACf,MAAM,MAAM,EAAK;AACtB;AAEA,eAAsB,0BAA0B;AAC9C,QAAM,CAAC,KAAK,MAAM,IAAI,IAAI,MAAM,QAAQ,IAAI;AAAA,IAC1C,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,cAAA;AAAA,EAAc,CACf,GAEK,UAAU,CAAC,OAAO,OAAO,QAAQ,QAAQ,QAAQ,MAAM,EAAE,OAAO,OAAO;AAC7E,SAAI,QAAQ,SAAS,IACZ,QAAQ,CAAC,KAAK,QAGhB,OAAO,wCAAwC;AAAA,IACpD,SAAS,QAAQ,IAAI,CAAC,WAAW,EAAC,OAAO,MAAM,MAAA,EAAO;AAAA,IACtD,SAAS,QAAQ,CAAC;AAAA,EAAA,CACnB;AACH;AAEA,eAAsB,oBAAoB,IAAY,EAAC,OAAsB;AAC3E,QAAM,OAAO,MAAM,IAAI,CAAC,SAAS,GAAG,EAAC,KAAK,OAAO,WAAU,GACrD,EAAC,SAAA,IAAY,MAAM;AACzB,SAAO,YAAY;AACrB;AC/BA,MAAM,cAAc,kCAEd,OAAO;AAAA;AAAA,MAEP,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA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