@storybook-astro/framework 0.1.0-beta.10 → 0.1.0-beta.12
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/README.md +38 -0
- package/dist/testing.js +20 -2
- package/dist/testing.js.map +1 -1
- package/package.json +4 -4
- package/src/testing.ts +32 -3
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @storybook-astro/framework
|
|
2
|
+
|
|
3
|
+
The community-supported [Storybook](https://storybook.js.org/) framework for [Astro](https://astro.build/).
|
|
4
|
+
|
|
5
|
+
> **Beta** · Astro 6 + Storybook 10
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save-dev storybook @storybook/builder-vite @storybook-astro/framework
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
// .storybook/main.js
|
|
17
|
+
export default {
|
|
18
|
+
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
19
|
+
framework: {
|
|
20
|
+
name: '@storybook-astro/framework',
|
|
21
|
+
options: {},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Requirements
|
|
27
|
+
|
|
28
|
+
Node.js 20.16+, Storybook 10, Astro 6 beta, Vite 6+
|
|
29
|
+
|
|
30
|
+
## Links
|
|
31
|
+
|
|
32
|
+
- [Getting Started](https://storybook-astro.org/getting-started)
|
|
33
|
+
- [Live Demo](https://demo.storybook-astro.org)
|
|
34
|
+
- [GitHub](https://github.com/storybook-astro/storybook-astro)
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
MIT
|
package/dist/testing.js
CHANGED
|
@@ -15458,7 +15458,7 @@ import "vite/module-runner";
|
|
|
15458
15458
|
|
|
15459
15459
|
// src/testing.ts
|
|
15460
15460
|
import { existsSync, readFileSync } from "fs";
|
|
15461
|
-
import { join as join2 } from "path";
|
|
15461
|
+
import { join as join2, dirname as dirname2 } from "path";
|
|
15462
15462
|
function testStoryRenders(storyName, story) {
|
|
15463
15463
|
test3(`${storyName} renders in Storybook`, async () => {
|
|
15464
15464
|
globalExpect(story).toBeDefined();
|
|
@@ -15505,6 +15505,21 @@ function testStoryComposition(storyName, story, expectedArgs) {
|
|
|
15505
15505
|
}
|
|
15506
15506
|
});
|
|
15507
15507
|
}
|
|
15508
|
+
function findPackageDir(pkgName) {
|
|
15509
|
+
let dir = process.cwd();
|
|
15510
|
+
while (true) {
|
|
15511
|
+
const candidate = join2(dir, "node_modules", pkgName);
|
|
15512
|
+
if (existsSync(join2(candidate, "package.json"))) {
|
|
15513
|
+
return candidate;
|
|
15514
|
+
}
|
|
15515
|
+
const parent = dirname2(dir);
|
|
15516
|
+
if (parent === dir) {
|
|
15517
|
+
break;
|
|
15518
|
+
}
|
|
15519
|
+
dir = parent;
|
|
15520
|
+
}
|
|
15521
|
+
return null;
|
|
15522
|
+
}
|
|
15508
15523
|
function cjsInteropPlugin() {
|
|
15509
15524
|
return {
|
|
15510
15525
|
name: "cjs-esm-interop",
|
|
@@ -15520,7 +15535,10 @@ function cjsInteropPlugin() {
|
|
|
15520
15535
|
return;
|
|
15521
15536
|
}
|
|
15522
15537
|
try {
|
|
15523
|
-
const nmDir =
|
|
15538
|
+
const nmDir = findPackageDir(pkgName);
|
|
15539
|
+
if (!nmDir) {
|
|
15540
|
+
return;
|
|
15541
|
+
}
|
|
15524
15542
|
const pkgJsonPath = join2(nmDir, "package.json");
|
|
15525
15543
|
if (!existsSync(pkgJsonPath)) {
|
|
15526
15544
|
return;
|