storybook-onbook-plugin 0.2.3 → 0.2.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 (2) hide show
  1. package/dist/cli/index.js +16 -10
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -260,7 +260,17 @@ function getStorybookCommand(storybookDir) {
260
260
  console.log(
261
261
  `\u{1F4E6} Detected package manager: ${pm}${repoRoot ? ` (from ${repoRoot})` : ""}`
262
262
  );
263
- return `${pm} run storybook`;
263
+ const execCommand = {
264
+ bun: "bunx",
265
+ pnpm: "pnpm exec",
266
+ yarn: "yarn",
267
+ npm: "npx"
268
+ };
269
+ const scriptParts = script.split(" ").filter(Boolean);
270
+ return {
271
+ command: execCommand[pm] ?? "npx",
272
+ args: [...scriptParts, "--no-open"]
273
+ };
264
274
  }
265
275
  async function isStorybookRunning(url) {
266
276
  try {
@@ -281,13 +291,9 @@ async function fetchStoryIndex(url) {
281
291
  const data = await response.json();
282
292
  return Object.values(data.entries);
283
293
  }
284
- async function startStorybook(cmd, storybookDir) {
285
- console.log(`\u{1F680} Starting Storybook with: ${cmd} (in ${storybookDir})`);
286
- const [command2, ...args] = cmd.split(" ");
287
- if (!command2) {
288
- throw new Error("Invalid storybook command");
289
- }
290
- const storybookProcess = spawn(command2, [...args, "--", "--no-open"], {
294
+ async function startStorybook(command2, args, storybookDir) {
295
+ console.log(`\u{1F680} Starting Storybook with: ${command2} ${args.join(" ")} (in ${storybookDir})`);
296
+ const storybookProcess = spawn(command2, args, {
291
297
  cwd: storybookDir,
292
298
  stdio: "pipe",
293
299
  shell: true
@@ -351,8 +357,8 @@ async function generateScreenshots(options = {}) {
351
357
  if (alreadyRunning) {
352
358
  console.log("\u2705 Storybook is already running");
353
359
  } else {
354
- const cmd = getStorybookCommand(storybookDir);
355
- storybookProcess = await startStorybook(cmd, storybookDir);
360
+ const { command: command2, args } = getStorybookCommand(storybookDir);
361
+ storybookProcess = await startStorybook(command2, args, storybookDir);
356
362
  weStartedStorybook = true;
357
363
  }
358
364
  const stories = await fetchStoryIndex(url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-onbook-plugin",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "storybook-onbook-plugin": "./dist/cli/index.js"