@sanity/plugin-kit
10.0.710.0.8
dist/init-CQLTseJC.js−
dist/init-CQLTseJC.jsDeleted−103
Index: package/dist/init-CQLTseJC.js
===================================================================
--- package/dist/init-CQLTseJC.js
+++ package/dist/init-CQLTseJC.js
@@ -1,103 +0,0 @@
-import { t as cliName } from "./constants-BIVJp2Jy.js";
-import { t as log_default } from "./log-2MbSIFbq.js";
-import { D as ensureDir, F as prompt, k as isEmptyish } from "./package-8cUY5BVf.js";
-import { a as presetHelpList, n as init, r as initFlags, t as findStudioConfig } from "./studio-detect-oLKO3_Aa.js";
-import meow from "meow";
-import path from "path";
-import { execa } from "execa";
-function npmIsAvailable() {
- return execa("npm", ["-v"]).then(() => !0).catch(() => !1);
-}
-function yarnIsAvailable() {
- return execa("yarn", ["-v"]).then(() => !0).catch(() => !1);
-}
-function pnpmAvailable() {
- return execa("pnpm", ["-v"]).then(() => !0).catch(() => !1);
-}
-async function promptForPackageManager() {
- let [npm, yarn, pnpm] = await Promise.all([
- npmIsAvailable(),
- yarnIsAvailable(),
- pnpmAvailable()
- ]), choices = [
- npm && "npm",
- yarn && "yarn",
- pnpm && "pnpm"
- ].filter(Boolean);
- return choices.length < 2 ? choices[0] || "npm" : prompt("Which package manager do you prefer?", {
- choices: choices.map((value) => ({
- value,
- name: value
- })),
- default: choices[0]
- });
-}
-async function installDependencies(pm, { cwd }) {
- try {
- let { exitCode } = await execa(pm, ["install"], {
- cwd,
- stdio: "inherit",
- reject: !1
- });
- return exitCode === 0;
- } catch {
- return !1;
- }
-}
-const help = `
-Usage
- $ ${cliName} init [dir] [<args>]
-
-Options
- --no-oxlint Disables oxlint config and dependencies from being added
- --no-oxfmt Disables oxfmt config and dependencies from being added
- --no-typescript Disables typescript config and dependencies from being added
- --no-license Disables LICENSE + package.json license field from being added
- --no-editorconfig Disables .editorconfig from being added
- --no-gitignore Disables .gitignore from being added
- --no-scripts Disables scripts from being added to package.json
- --no-install Disables automatically running package manager install
-
- --name [package-name] Use the provided package-name
- --author [name] Use the provided author
- --repo [url] Use the provided repo url
- --license [spdx] Use the license with the given SPDX identifier
- --force No prompt when overwriting files
-
- --preset [preset-name] Adds config and files from a named preset. --preset can be supplied multiple times.
- The following presets are available:
-${presetHelpList(30)}
-
-Examples
- # Initialize a new plugin in the current directory
- $ ${cliName} init
-
- # Initialize a plugin in the directory ~/my-plugin
- $ ${cliName} init ~/my-plugin
-
- # Don't add oxlint or oxfmt
- $ ${cliName} init --no-oxlint --no-oxfmt
-`;
-async function run({ argv }) {
- let cli = meow(help, {
- importMeta: import.meta,
- flags: initFlags,
- argv,
- description: "Initialize a new Sanity plugin"
- }), basePath = path.resolve(cli.input[0] || process.cwd()), { configFile } = await findStudioConfig(basePath);
- if (configFile) throw Error(`${configFile} exists - are you trying to init into a studio instead of a plugin?`);
- if (log_default.info("Initializing new plugin in \"%s\"", basePath), !cli.flags.force && !await isEmptyish(basePath) && !await prompt("Directory is not empty, proceed?", {
- type: "confirm",
- default: !1
- })) {
- log_default.error("Directory is not empty. Cancelled.");
- return;
- }
- await ensureDir(basePath), await init({
- basePath,
- flags: cli.flags
- }), cli.flags.install ? await installDependencies(await promptForPackageManager(), { cwd: basePath }) ? log_default.info("Done!") : log_default.error("Failed to install dependencies, try manually running `npm install`") : log_default.info("Dependency installation skipped.");
-}
-export { run as default };
-
-//# sourceMappingURL=init-CQLTseJC.js.map
\ No newline at end of file