UNPKG

storybook

Version:

Storybook: Develop, document, and test UI components in isolation

81 lines (77 loc) 2.76 kB
#!/usr/bin/env node import CJS_COMPAT_NODE_URL_ret6ivvuly from 'node:url'; import CJS_COMPAT_NODE_PATH_ret6ivvuly from 'node:path'; import CJS_COMPAT_NODE_MODULE_ret6ivvuly from "node:module"; var __filename = CJS_COMPAT_NODE_URL_ret6ivvuly.fileURLToPath(import.meta.url); var __dirname = CJS_COMPAT_NODE_PATH_ret6ivvuly.dirname(__filename); var require = CJS_COMPAT_NODE_MODULE_ret6ivvuly.createRequire(import.meta.url); // ------------------------------------------------------------ // end of CJS compatibility banner, injected by Storybook's esbuild configuration // ------------------------------------------------------------ import { MIN_SUPPORTED_NODE_DESCRIPTION, isNodeVersionSupported, versions_default } from "../_node-chunks/chunk-BV2M6I75.js"; import { resolvePackageDir } from "../_node-chunks/chunk-UHVMRW65.js"; import { join } from "../_node-chunks/chunk-TGEJ6REI.js"; import { require_dist } from "../_node-chunks/chunk-XSYEGQMM.js"; import { __toESM } from "../_node-chunks/chunk-5IHDTMLC.js"; // src/bin/dispatcher.ts import { pathToFileURL } from "node:url"; import { executeCommand, executeNodeCommand } from "storybook/internal/common"; import { logger } from "storybook/internal/node-logger"; var import_ts_dedent = __toESM(require_dist(), 1); var [major, minor, patch] = process.versions.node.split(".").map(Number); isNodeVersionSupported(major, minor, patch) || (logger.error( import_ts_dedent.dedent`To run Storybook, you need Node.js version ${MIN_SUPPORTED_NODE_DESCRIPTION}. You are currently running Node.js ${process.version}. Please upgrade your Node.js installation.` ), process.exit(1)); async function run() { let args = process.argv.slice(2); if (["dev", "build", "index"].includes(args[0])) { await import(pathToFileURL(join(resolvePackageDir("storybook"), "dist/bin/core.js")).href); return; } let targetCli = args[0] === "init" ? { pkg: "create-storybook", args: args.slice(1) } : { pkg: "@storybook/cli", args }; try { let { default: targetCliPackageJson } = await import(`${targetCli.pkg}/package.json`, { with: { type: "json" } }); if (targetCliPackageJson.version === versions_default[targetCli.pkg]) { executeNodeCommand({ scriptPath: join(resolvePackageDir(targetCli.pkg), "dist/bin/index.js"), args: targetCli.args, options: { stdio: "inherit" } }).on("exit", (code) => { process.exit(code ?? 1); }); return; } } catch { } executeCommand({ command: "npx", args: ["--yes", `${targetCli.pkg}@${versions_default[targetCli.pkg]}`, ...targetCli.args], stdio: "inherit" }).on("exit", (code) => { process.exit(code ?? 1); }); } run();