storybook-onbook-plugin 0.2.4 → 0.2.6

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 +4 -25
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -3,7 +3,7 @@ import { command, string, run } from '@drizzle-team/brocli';
3
3
  import { spawn } from 'child_process';
4
4
  import path, { resolve, join, dirname } from 'path';
5
5
  import crypto from 'crypto';
6
- import fs, { existsSync, readFileSync } from 'fs';
6
+ import fs, { existsSync } from 'fs';
7
7
  import { chromium } from 'playwright';
8
8
 
9
9
  var CACHE_DIR = path.join(process.cwd(), ".storybook-cache");
@@ -237,39 +237,18 @@ function detectPackageManager(repoRoot) {
237
237
  }
238
238
  return "npm";
239
239
  }
240
- function getStorybookScript(storybookDir) {
241
- const packageJsonPath = join(storybookDir, "package.json");
242
- if (!existsSync(packageJsonPath)) {
243
- return null;
244
- }
245
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
246
- return packageJson.scripts?.storybook ?? null;
247
- }
248
240
 
249
241
  // src/cli/generate-screenshots/generate-screenshots.ts
250
242
  function getStorybookCommand(storybookDir) {
251
- const script = getStorybookScript(storybookDir);
252
- if (script === null) {
253
- const packageJsonPath = join(storybookDir, "package.json");
254
- throw new Error(
255
- `No "storybook" script found in ${packageJsonPath}. Use --storybook-dir to specify the correct directory or add a storybook script.`
256
- );
257
- }
258
243
  const repoRoot = findRepoRoot(storybookDir);
259
244
  const pm = repoRoot ? detectPackageManager(repoRoot) : "npm";
260
245
  console.log(
261
246
  `\u{1F4E6} Detected package manager: ${pm}${repoRoot ? ` (from ${repoRoot})` : ""}`
262
247
  );
263
- const execCommand = {
264
- bun: "bunx",
265
- pnpm: "pnpm exec",
266
- yarn: "yarn",
267
- npm: "npx"
268
- };
269
- const scriptParts = script.split(" ").filter(Boolean);
248
+ const separator = pm === "npm" || pm === "pnpm" ? ["--"] : [];
270
249
  return {
271
- command: execCommand[pm] ?? "npx",
272
- args: [...scriptParts, "--no-open"]
250
+ command: pm,
251
+ args: ["run", "storybook", ...separator, "-p", "6006", "--no-open"]
273
252
  };
274
253
  }
275
254
  async function isStorybookRunning(url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-onbook-plugin",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "storybook-onbook-plugin": "./dist/cli/index.js"