@sanity/plugin-kit 5.0.1 → 5.0.3
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/_chunks-es/init.js +4 -4
- package/dist/_chunks-es/init.js.map +1 -1
- package/dist/_chunks-es/init2.js +779 -14
- package/dist/_chunks-es/init2.js.map +1 -1
- package/dist/_chunks-es/inject.js +3 -3
- package/dist/_chunks-es/inject.js.map +1 -1
- package/dist/_chunks-es/package.js +321 -1064
- package/dist/_chunks-es/package.js.map +1 -1
- package/dist/_chunks-es/package2.js +1 -1
- package/dist/_chunks-es/{ts.js → verify-common.js} +81 -83
- package/dist/_chunks-es/verify-common.js.map +1 -0
- package/dist/_chunks-es/verify-package.js +2 -2
- package/dist/_chunks-es/verify-package.js.map +1 -1
- package/dist/_chunks-es/verify-studio.js +1 -1
- package/dist/_chunks-es/verify-studio.js.map +1 -1
- package/package.json +4 -4
- package/dist/_chunks-es/ts.js.map +0 -1
package/dist/_chunks-es/init.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import meow from "meow";
|
|
3
|
-
import { initFlags, init } from "./init2.js";
|
|
3
|
+
import { initFlags, init, presetHelpList } from "./init2.js";
|
|
4
4
|
import { cliName, log } from "./index.js";
|
|
5
5
|
import execa from "execa";
|
|
6
|
-
import { prompt, hasSanityJson, findStudioV3Config, isEmptyish, ensureDir
|
|
6
|
+
import { prompt, hasSanityJson, findStudioV3Config, isEmptyish, ensureDir } from "./package.js";
|
|
7
7
|
function npmIsAvailable() {
|
|
8
8
|
return execa("npm", ["-v"]).then(() => !0).catch(() => !1);
|
|
9
9
|
}
|
|
@@ -46,7 +46,7 @@ Options
|
|
|
46
46
|
--author [name] Use the provided author
|
|
47
47
|
--repo [url] Use the provided repo url
|
|
48
48
|
--license [spdx] Use the license with the given SPDX identifier
|
|
49
|
-
--force No
|
|
49
|
+
--force No prompt when overwriting files
|
|
50
50
|
|
|
51
51
|
--preset [preset-name] Adds config and files from a named preset. --preset can be supplied multiple times.
|
|
52
52
|
The following presets are available:
|
|
@@ -71,7 +71,7 @@ async function run({ argv }) {
|
|
|
71
71
|
const { v3ConfigFile } = await findStudioV3Config(basePath);
|
|
72
72
|
if (v3ConfigFile)
|
|
73
73
|
throw new Error(
|
|
74
|
-
`${v3ConfigFile}
|
|
74
|
+
`${v3ConfigFile} exists - are you trying to init into a studio instead of a plugin?`
|
|
75
75
|
);
|
|
76
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
77
|
log.error("Directory is not empty. Cancelled.");
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;AACz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