storybook-onbook-plugin 0.2.4 → 0.2.5
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/cli/index.js +3 -25
- 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
|
|
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,17 @@ 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);
|
|
270
248
|
return {
|
|
271
|
-
command:
|
|
272
|
-
args: [
|
|
249
|
+
command: "storybook",
|
|
250
|
+
args: ["dev", "-p", "6006", "--no-open"]
|
|
273
251
|
};
|
|
274
252
|
}
|
|
275
253
|
async function isStorybookRunning(url) {
|