@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/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook-astro/framework",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.12",
|
|
4
4
|
"description": "Community-supported Storybook framework for Astro 6 components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/storybook-astro/storybook-astro.git",
|
|
10
10
|
"directory": "packages/@storybook-astro/framework"
|
|
11
11
|
},
|
|
12
12
|
"homepage": "https://storybook-astro.org",
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/storybook-astro/storybook-astro/issues"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">=20.16.0 || >=22.19.0 || >=24.0.0"
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
149
|
"dependencies": {
|
|
150
|
-
"@storybook-astro/renderer": "0.1.0-beta.
|
|
150
|
+
"@storybook-astro/renderer": "0.1.0-beta.12",
|
|
151
151
|
"vite": "^6.2.5 || ^7.0.0"
|
|
152
152
|
}
|
|
153
153
|
}
|
package/src/testing.ts
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
// eslint-disable-next-line n/no-extraneous-import
|
|
33
33
|
import { test, expect } from 'vitest';
|
|
34
34
|
import { existsSync, readFileSync } from 'node:fs';
|
|
35
|
-
import { join } from 'node:path';
|
|
35
|
+
import { join, dirname } from 'node:path';
|
|
36
36
|
import type { Plugin } from 'vite';
|
|
37
37
|
|
|
38
38
|
// ---------------------------------------------------------------------------
|
|
@@ -137,6 +137,32 @@ export function testStoryComposition(storyName: string, story: any, expectedArgs
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
// ---------------------------------------------------------------------------
|
|
141
|
+
// Helpers
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Walk up from cwd to find a package in node_modules.
|
|
146
|
+
* Supports monorepos where packages are hoisted to the root.
|
|
147
|
+
*/
|
|
148
|
+
function findPackageDir(pkgName: string): string | null {
|
|
149
|
+
let dir = process.cwd();
|
|
150
|
+
|
|
151
|
+
while (true) {
|
|
152
|
+
const candidate = join(dir, 'node_modules', pkgName);
|
|
153
|
+
|
|
154
|
+
if (existsSync(join(candidate, 'package.json'))) {
|
|
155
|
+
return candidate;
|
|
156
|
+
}
|
|
157
|
+
const parent = dirname(dir);
|
|
158
|
+
|
|
159
|
+
if (parent === dir) {break;}
|
|
160
|
+
dir = parent;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
|
|
140
166
|
// ---------------------------------------------------------------------------
|
|
141
167
|
// Vite plugins for testing
|
|
142
168
|
// ---------------------------------------------------------------------------
|
|
@@ -179,8 +205,11 @@ export function cjsInteropPlugin(): Plugin {
|
|
|
179
205
|
if (subpath && !['server-renderer', 'server', 'client'].includes(subpath)) {return;}
|
|
180
206
|
|
|
181
207
|
try {
|
|
182
|
-
// Find the package.json
|
|
183
|
-
|
|
208
|
+
// Find the package.json — walk up from cwd to find node_modules
|
|
209
|
+
// (supports monorepos where packages are hoisted to root)
|
|
210
|
+
const nmDir = findPackageDir(pkgName);
|
|
211
|
+
|
|
212
|
+
if (!nmDir) {return;}
|
|
184
213
|
const pkgJsonPath = join(nmDir, 'package.json');
|
|
185
214
|
|
|
186
215
|
if (!existsSync(pkgJsonPath)) {return;}
|