storybook-addon-dependency-previews 0.1.0

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 (189) hide show
  1. package/README.md +192 -0
  2. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  3. package/dist/addon/index.cjs +12 -0
  4. package/dist/addon/index.cjs.map +1 -0
  5. package/dist/addon/index.d.cts +5 -0
  6. package/dist/addon/index.d.mts +5 -0
  7. package/dist/addon/index.mjs +11 -0
  8. package/dist/addon/index.mjs.map +1 -0
  9. package/dist/addon/preset.cjs +8 -0
  10. package/dist/addon/preset.cjs.map +1 -0
  11. package/dist/addon/preset.d.cts +5 -0
  12. package/dist/addon/preset.d.mts +5 -0
  13. package/dist/addon/preset.mjs +6 -0
  14. package/dist/addon/preset.mjs.map +1 -0
  15. package/dist/addon/vitePlugin.cjs +26 -0
  16. package/dist/addon/vitePlugin.cjs.map +1 -0
  17. package/dist/addon/vitePlugin.d.cts +9 -0
  18. package/dist/addon/vitePlugin.d.mts +9 -0
  19. package/dist/addon/vitePlugin.mjs +24 -0
  20. package/dist/addon/vitePlugin.mjs.map +1 -0
  21. package/dist/blocks/DependencyPreviews.cjs +102 -0
  22. package/dist/blocks/DependencyPreviews.cjs.map +1 -0
  23. package/dist/blocks/DependencyPreviews.d.cts +7 -0
  24. package/dist/blocks/DependencyPreviews.d.mts +7 -0
  25. package/dist/blocks/DependencyPreviews.mjs +100 -0
  26. package/dist/blocks/DependencyPreviews.mjs.map +1 -0
  27. package/dist/blocks/DependencyPreviews.module.css +14 -0
  28. package/dist/blocks/index.cjs +1 -0
  29. package/dist/blocks/index.d.cts +1 -0
  30. package/dist/blocks/index.d.mts +1 -0
  31. package/dist/blocks/index.mjs +1 -0
  32. package/dist/cli/sb-deps.cjs +321 -0
  33. package/dist/cli/sb-deps.cjs.map +1 -0
  34. package/dist/cli/sb-deps.d.cts +1 -0
  35. package/dist/cli/sb-deps.d.mts +1 -0
  36. package/dist/cli/sb-deps.mjs +319 -0
  37. package/dist/cli/sb-deps.mjs.map +1 -0
  38. package/dist/cli/scripts/depcruise.config.cjs +38 -0
  39. package/dist/cli/scripts/depcruise.config.cjs.map +1 -0
  40. package/dist/cli/scripts/depcruise.config.d.cts +6 -0
  41. package/dist/cli/scripts/depcruise.config.d.mts +7 -0
  42. package/dist/cli/scripts/depcruise.config.mjs +37 -0
  43. package/dist/cli/scripts/depcruise.config.mjs.map +1 -0
  44. package/dist/cli/scripts/postprocess.cjs +106 -0
  45. package/dist/cli/scripts/postprocess.cjs.map +1 -0
  46. package/dist/cli/scripts/postprocess.d.cts +1 -0
  47. package/dist/cli/scripts/postprocess.d.mts +1 -0
  48. package/dist/cli/scripts/postprocess.mjs +106 -0
  49. package/dist/cli/scripts/postprocess.mjs.map +1 -0
  50. package/dist/components/ComponentSourceLink.cjs +42 -0
  51. package/dist/components/ComponentSourceLink.cjs.map +1 -0
  52. package/dist/components/ComponentSourceLink.mjs +40 -0
  53. package/dist/components/ComponentSourceLink.mjs.map +1 -0
  54. package/dist/components/ComponentSourceLink.module.css +5 -0
  55. package/dist/components/CopyButton.cjs +112 -0
  56. package/dist/components/CopyButton.cjs.map +1 -0
  57. package/dist/components/CopyButton.mjs +110 -0
  58. package/dist/components/CopyButton.mjs.map +1 -0
  59. package/dist/components/CopyButton.module.css +76 -0
  60. package/dist/components/Expandable.cjs +51 -0
  61. package/dist/components/Expandable.cjs.map +1 -0
  62. package/dist/components/Expandable.mjs +49 -0
  63. package/dist/components/Expandable.mjs.map +1 -0
  64. package/dist/components/Expandable.module.css +110 -0
  65. package/dist/components/FullParityStory.cjs +47 -0
  66. package/dist/components/FullParityStory.cjs.map +1 -0
  67. package/dist/components/FullParityStory.mjs +44 -0
  68. package/dist/components/FullParityStory.mjs.map +1 -0
  69. package/dist/components/PathCopyMolecule.cjs +28 -0
  70. package/dist/components/PathCopyMolecule.cjs.map +1 -0
  71. package/dist/components/PathCopyMolecule.mjs +26 -0
  72. package/dist/components/PathCopyMolecule.mjs.map +1 -0
  73. package/dist/components/PathCopyMolecule.module.css +14 -0
  74. package/dist/components/PrimaryPreview.cjs +35 -0
  75. package/dist/components/PrimaryPreview.cjs.map +1 -0
  76. package/dist/components/PrimaryPreview.mjs +34 -0
  77. package/dist/components/PrimaryPreview.mjs.map +1 -0
  78. package/dist/components/SbHeading.cjs +18 -0
  79. package/dist/components/SbHeading.cjs.map +1 -0
  80. package/dist/components/SbHeading.mjs +16 -0
  81. package/dist/components/SbHeading.mjs.map +1 -0
  82. package/dist/components/SbHeading.module.css +23 -0
  83. package/dist/components/StoryLink.cjs +45 -0
  84. package/dist/components/StoryLink.cjs.map +1 -0
  85. package/dist/components/StoryLink.mjs +43 -0
  86. package/dist/components/StoryLink.mjs.map +1 -0
  87. package/dist/components/StoryLink.module.css +13 -0
  88. package/dist/components/TooltipTrigger.cjs +100 -0
  89. package/dist/components/TooltipTrigger.cjs.map +1 -0
  90. package/dist/components/TooltipTrigger.mjs +98 -0
  91. package/dist/components/TooltipTrigger.mjs.map +1 -0
  92. package/dist/components/TooltipTrigger.module.css +62 -0
  93. package/dist/components/icons/ArrowToRectangleIcon.cjs +19 -0
  94. package/dist/components/icons/ArrowToRectangleIcon.cjs.map +1 -0
  95. package/dist/components/icons/ArrowToRectangleIcon.mjs +18 -0
  96. package/dist/components/icons/ArrowToRectangleIcon.mjs.map +1 -0
  97. package/dist/components/icons/BuildIcon.cjs +19 -0
  98. package/dist/components/icons/BuildIcon.cjs.map +1 -0
  99. package/dist/components/icons/BuildIcon.mjs +18 -0
  100. package/dist/components/icons/BuildIcon.mjs.map +1 -0
  101. package/dist/components/icons/CopyIcon.cjs +19 -0
  102. package/dist/components/icons/CopyIcon.cjs.map +1 -0
  103. package/dist/components/icons/CopyIcon.mjs +18 -0
  104. package/dist/components/icons/CopyIcon.mjs.map +1 -0
  105. package/dist/components/icons/CubeIcon.cjs +19 -0
  106. package/dist/components/icons/CubeIcon.cjs.map +1 -0
  107. package/dist/components/icons/CubeIcon.mjs +18 -0
  108. package/dist/components/icons/CubeIcon.mjs.map +1 -0
  109. package/dist/components/icons/DoubleChevronDown.cjs +19 -0
  110. package/dist/components/icons/DoubleChevronDown.cjs.map +1 -0
  111. package/dist/components/icons/DoubleChevronDown.mjs +18 -0
  112. package/dist/components/icons/DoubleChevronDown.mjs.map +1 -0
  113. package/dist/components/icons/ExternalLinkIcon.cjs +19 -0
  114. package/dist/components/icons/ExternalLinkIcon.cjs.map +1 -0
  115. package/dist/components/icons/ExternalLinkIcon.mjs +18 -0
  116. package/dist/components/icons/ExternalLinkIcon.mjs.map +1 -0
  117. package/dist/components/icons/EyeOpen.cjs +23 -0
  118. package/dist/components/icons/EyeOpen.cjs.map +1 -0
  119. package/dist/components/icons/EyeOpen.mjs +22 -0
  120. package/dist/components/icons/EyeOpen.mjs.map +1 -0
  121. package/dist/components/icons/LoadingRipples.cjs +79 -0
  122. package/dist/components/icons/LoadingRipples.cjs.map +1 -0
  123. package/dist/components/icons/LoadingRipples.mjs +78 -0
  124. package/dist/components/icons/LoadingRipples.mjs.map +1 -0
  125. package/dist/components/icons/SquaresPlus.cjs +19 -0
  126. package/dist/components/icons/SquaresPlus.cjs.map +1 -0
  127. package/dist/components/icons/SquaresPlus.mjs +18 -0
  128. package/dist/components/icons/SquaresPlus.mjs.map +1 -0
  129. package/dist/components/icons/Svg.cjs +37 -0
  130. package/dist/components/icons/Svg.cjs.map +1 -0
  131. package/dist/components/icons/Svg.mjs +36 -0
  132. package/dist/components/icons/Svg.mjs.map +1 -0
  133. package/dist/components/icons/X.cjs +19 -0
  134. package/dist/components/icons/X.cjs.map +1 -0
  135. package/dist/components/icons/X.mjs +18 -0
  136. package/dist/components/icons/X.mjs.map +1 -0
  137. package/dist/constants.cjs +9 -0
  138. package/dist/constants.cjs.map +1 -0
  139. package/dist/constants.mjs +7 -0
  140. package/dist/constants.mjs.map +1 -0
  141. package/dist/hooks/useDependencyGraph.cjs +63 -0
  142. package/dist/hooks/useDependencyGraph.cjs.map +1 -0
  143. package/dist/hooks/useDependencyGraph.mjs +60 -0
  144. package/dist/hooks/useDependencyGraph.mjs.map +1 -0
  145. package/dist/hooks/useDynamicStory.cjs +83 -0
  146. package/dist/hooks/useDynamicStory.cjs.map +1 -0
  147. package/dist/hooks/useDynamicStory.mjs +82 -0
  148. package/dist/hooks/useDynamicStory.mjs.map +1 -0
  149. package/dist/hooks/useStoryParams.cjs +17 -0
  150. package/dist/hooks/useStoryParams.cjs.map +1 -0
  151. package/dist/hooks/useStoryParams.mjs +16 -0
  152. package/dist/hooks/useStoryParams.mjs.map +1 -0
  153. package/dist/index.cjs +15 -0
  154. package/dist/index.d.cts +6 -0
  155. package/dist/index.d.mts +6 -0
  156. package/dist/index.mjs +9 -0
  157. package/dist/manager.cjs +22 -0
  158. package/dist/manager.cjs.map +1 -0
  159. package/dist/manager.d.cts +1 -0
  160. package/dist/manager.d.mts +1 -0
  161. package/dist/manager.mjs +21 -0
  162. package/dist/manager.mjs.map +1 -0
  163. package/dist/panels/DefaultAutoDocsLayout.cjs +24 -0
  164. package/dist/panels/DefaultAutoDocsLayout.cjs.map +1 -0
  165. package/dist/panels/DefaultAutoDocsLayout.d.cts +10 -0
  166. package/dist/panels/DefaultAutoDocsLayout.d.mts +10 -0
  167. package/dist/panels/DefaultAutoDocsLayout.mjs +22 -0
  168. package/dist/panels/DefaultAutoDocsLayout.mjs.map +1 -0
  169. package/dist/panels/GraphView.cjs +78 -0
  170. package/dist/panels/GraphView.cjs.map +1 -0
  171. package/dist/panels/GraphView.d.cts +7 -0
  172. package/dist/panels/GraphView.d.mts +7 -0
  173. package/dist/panels/GraphView.mjs +77 -0
  174. package/dist/panels/GraphView.mjs.map +1 -0
  175. package/dist/panels/index.cjs +3 -0
  176. package/dist/panels/index.d.cts +3 -0
  177. package/dist/panels/index.d.mts +3 -0
  178. package/dist/panels/index.mjs +3 -0
  179. package/dist/preview.cjs +23 -0
  180. package/dist/preview.cjs.map +1 -0
  181. package/dist/preview.d.cts +9 -0
  182. package/dist/preview.d.mts +10 -0
  183. package/dist/preview.mjs +21 -0
  184. package/dist/preview.mjs.map +1 -0
  185. package/dist/types.cjs +0 -0
  186. package/dist/types.d.cts +104 -0
  187. package/dist/types.d.mts +104 -0
  188. package/dist/types.mjs +0 -0
  189. package/package.json +94 -0
@@ -0,0 +1,319 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
3
+ import { basename, dirname, join, posix, resolve, sep } from "node:path";
4
+ import { execSync, spawn } from "node:child_process";
5
+ import { fileURLToPath } from "node:url";
6
+ import watcherParcel from "@parcel/watcher";
7
+ import micromatch from "micromatch";
8
+
9
+ //#region cli/sb-deps.ts
10
+ const argv = process.argv.slice(2);
11
+ const WATCH = argv.includes("--watch");
12
+ const RUN_SB = argv.includes("--run-storybook");
13
+ const PORT_ARGI = Math.max(argv.indexOf("--sb-port"), 0);
14
+ const SB_PORT = PORT_ARGI && argv[PORT_ARGI + 1] ? Number(argv[PORT_ARGI + 1]) || 6006 : 6006;
15
+ const projectRoot = process.cwd();
16
+ const outDir = resolve(projectRoot, ".storybook");
17
+ const rawPath = join(outDir, "dependency-previews.raw.json");
18
+ const cookedPath = join(outDir, "dependency-previews.json");
19
+ if (!existsSync(outDir)) mkdirSync(outDir, { recursive: true });
20
+ const __filename = fileURLToPath(import.meta.url);
21
+ const __dirname = dirname(__filename);
22
+ const pkgDefault = resolve(__dirname, "scripts", "depcruise.config.cjs");
23
+ const overrideCandidates = [
24
+ resolve(projectRoot, "depcruise.config.cjs"),
25
+ resolve(projectRoot, ".dependency-cruiser.js"),
26
+ resolve(projectRoot, ".dependency-cruiser.cjs")
27
+ ];
28
+ const configPath = overrideCandidates.find((p) => existsSync(p)) || (existsSync(pkgDefault) ? pkgDefault : null);
29
+ const post = resolve(__dirname, "scripts", "postprocess.mjs");
30
+ function runDepCruiseOnce() {
31
+ const cfgFlag = configPath ? `--config "${configPath}"` : "--no-config";
32
+ const cmd = `npx depcruise . ${cfgFlag} --output-type json`;
33
+ const start = Date.now();
34
+ const stdout = execSync(cmd, {
35
+ cwd: projectRoot,
36
+ stdio: [
37
+ "ignore",
38
+ "pipe",
39
+ "inherit"
40
+ ],
41
+ encoding: "utf8"
42
+ });
43
+ writeFileSync(rawPath, stdout, "utf8");
44
+ info(`graph ✓ (${ms(Date.now() - start)})`);
45
+ }
46
+ function postprocessOnce() {
47
+ const start = Date.now();
48
+ const postCmd = `node "${post}" "${rawPath}" "${cookedPath}"`;
49
+ execSync(postCmd, {
50
+ cwd: projectRoot,
51
+ stdio: "inherit"
52
+ });
53
+ info(`compiled ✓ → ${rel(cookedPath)} (${ms(Date.now() - start)})`);
54
+ }
55
+ function buildOnce() {
56
+ try {
57
+ runDepCruiseOnce();
58
+ postprocessOnce();
59
+ } catch (e) {
60
+ error("build failed");
61
+ if (!WATCH) throw e;
62
+ }
63
+ }
64
+ function toWords(input) {
65
+ return String(input).replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-./]+/g, " ").trim().split(/\s+/);
66
+ }
67
+ function toTitleCase(words) {
68
+ return words.map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
69
+ }
70
+ function toPascalCase(input) {
71
+ return toTitleCase(toWords(input)).replace(/\s+/g, "");
72
+ }
73
+ function isEmptyOrWhitespace(absPath) {
74
+ try {
75
+ const s = statSync(absPath);
76
+ if (s.size === 0) return true;
77
+ const txt = readFileSync(absPath, "utf8");
78
+ return !txt.trim();
79
+ } catch {
80
+ return true;
81
+ }
82
+ }
83
+ function isComponentsTsx(absPath) {
84
+ const norm = absPath.replace(/\\/g, "/");
85
+ return /\/src\/components\/.+\.tsx$/i.test(norm) && !/\.stories?\.tsx$/i.test(norm);
86
+ }
87
+ function componentBaseFromComponent(absCompPath) {
88
+ return basename(absCompPath, ".tsx");
89
+ }
90
+ function detectAtomicTag(absPath) {
91
+ const adaptedPath = absPath.toLowerCase().replace(/\\/g, "/");
92
+ const tokens = [
93
+ "atom",
94
+ "molecule",
95
+ "organism",
96
+ "template",
97
+ "page",
98
+ "icon"
99
+ ];
100
+ let best = null;
101
+ for (const t of tokens) {
102
+ const idx = adaptedPath.lastIndexOf(t);
103
+ if (idx !== -1 && (best === null || idx > best.idx)) best = {
104
+ val: t,
105
+ idx
106
+ };
107
+ }
108
+ return best ? best.val : null;
109
+ }
110
+ function storyPathForComponent(absCompPath) {
111
+ const dir = dirname(absCompPath);
112
+ const base = componentBaseFromComponent(absCompPath);
113
+ return join(dir, `${base}.stories.tsx`);
114
+ }
115
+ function makeTitleFromComponent(absCompPath) {
116
+ const srcRoot = join(projectRoot, "src") + sep;
117
+ const normAbs = absCompPath.replace(/\\/g, "/");
118
+ const relFromSrc = normAbs.startsWith(srcRoot.replace(/\\/g, "/")) ? normAbs.slice(srcRoot.length) : absCompPath.replace(projectRoot + sep, "").replace(/\\/g, "/");
119
+ const dir = posix.dirname(relFromSrc);
120
+ let segments = dir.split("/").filter(Boolean);
121
+ if (segments[0] && /^components?$/i.test(segments[0])) segments = segments.slice(1);
122
+ const titledFolders = segments.map((s) => toTitleCase(toWords(s)));
123
+ const compName = componentBaseFromComponent(absCompPath);
124
+ const compTitle = toTitleCase(toWords(compName));
125
+ const fullStoryPath = [...titledFolders, compTitle].filter(Boolean);
126
+ const dedupedStoryPath = [...new Set(fullStoryPath)];
127
+ return dedupedStoryPath.join(" / ");
128
+ }
129
+ function scaffoldComponent(absCompPath) {
130
+ const base = componentBaseFromComponent(absCompPath);
131
+ const componentName = toPascalCase(base);
132
+ const propsName = `PropsFor${componentName}`;
133
+ const tpl = `import type { ReactNode } from 'react'
134
+
135
+ export interface ${propsName} {
136
+ children?: ReactNode
137
+ }
138
+
139
+ export function ${componentName}({ children }: ${propsName}) {
140
+ return (
141
+ <div className="${componentName}">
142
+ <p>${componentName}</p>
143
+ {children}
144
+ </div>
145
+ )
146
+ }
147
+ `;
148
+ writeFileSync(absCompPath, tpl, "utf8");
149
+ info(`scaffolded component → \${rel(absCompPath)}`);
150
+ }
151
+ function scaffoldStoryForComponent(absCompPath) {
152
+ const base = componentBaseFromComponent(absCompPath);
153
+ const componentName = toPascalCase(base);
154
+ const propsName = `PropsFor${componentName}`;
155
+ const title = makeTitleFromComponent(absCompPath);
156
+ const atomic = detectAtomicTag(absCompPath);
157
+ const tags = ["autodocs"];
158
+ if (atomic) tags.push(atomic);
159
+ const storyTpl = `import type { Meta, StoryObj } from '@storybook/react-vite'
160
+ import type { StoryParameters } from 'storybook-addon-dependency-previews'
161
+ import { ${componentName}, type ${propsName} } from './${componentName}'
162
+
163
+ const meta: Meta<typeof ${componentName}> = {
164
+ title: '${title}',
165
+ component: ${componentName},
166
+ tags: ${JSON.stringify(tags)},
167
+ parameters: {
168
+ layout: 'padded',
169
+ __filePath: import.meta.url,
170
+ } satisfies StoryParameters,
171
+ }
172
+
173
+ export default meta
174
+
175
+ type Story = StoryObj<typeof meta>
176
+
177
+ export const Primary: Story = {
178
+ args: {} satisfies ${propsName},
179
+ }
180
+ `;
181
+ const storyPath = storyPathForComponent(absCompPath);
182
+ writeFileSync(storyPath, storyTpl, "utf8");
183
+ info(`scaffolded story → \${rel(storyPath)}`);
184
+ return storyPath;
185
+ }
186
+ function ensureStoryForComponent(absCompPath) {
187
+ const sPath = storyPathForComponent(absCompPath);
188
+ if (existsSync(sPath)) return null;
189
+ return scaffoldStoryForComponent(absCompPath);
190
+ }
191
+ function startWatcher() {
192
+ const root = projectRoot;
193
+ const includeGlobs = [
194
+ "**/*.stories.{ts,tsx,js,jsx,mdx,svelte}",
195
+ "**/*.story.{ts,tsx,js,jsx,mdx,svelte}",
196
+ "src/**/*.{ts,tsx,js,jsx,svelte}",
197
+ "depcruise.config.cjs",
198
+ ".dependency-cruiser.{js,cjs}"
199
+ ];
200
+ const ignoreGlobs = [
201
+ "node_modules/**",
202
+ ".git/**",
203
+ ".storybook/**",
204
+ "**/.cache/**",
205
+ "**/dist/**",
206
+ "**/build/**"
207
+ ];
208
+ let pending = false;
209
+ let timer = null;
210
+ let isDeletingFile = false;
211
+ function kick(reason, absPath) {
212
+ if (pending) return;
213
+ pending = true;
214
+ if (timer) clearTimeout(timer);
215
+ timer = setTimeout(() => {
216
+ info(`${reason}: ${rel(absPath)}`);
217
+ buildOnce();
218
+ pending = false;
219
+ }, 120);
220
+ }
221
+ return watcherParcel.subscribe(root, async (err, events) => {
222
+ if (err) {
223
+ error(`watch error ${err?.message || err}`);
224
+ return;
225
+ }
226
+ for (const ev of events) {
227
+ const abs = ev.path;
228
+ const relPath = rel(abs);
229
+ if (!micromatch.isMatch(relPath, includeGlobs)) continue;
230
+ if (ev.type === "delete") {
231
+ console.log("Deleted:", relPath);
232
+ isDeletingFile = true;
233
+ kick("unlink", abs);
234
+ continue;
235
+ }
236
+ if (isComponentsTsx(abs) && ev.type === "create") {
237
+ await handleComponentCreation(abs, relPath);
238
+ continue;
239
+ }
240
+ kick(ev.type, abs);
241
+ }
242
+ }, { ignore: ignoreGlobs }).then((result) => {
243
+ info("watching… (ready)");
244
+ return result;
245
+ }).catch((e) => error(`watch init failed ${e?.message || e}`));
246
+ async function handleComponentCreation(abs, relPath) {
247
+ if (isEmptyOrWhitespace(abs)) {
248
+ scaffoldComponent(abs);
249
+ }
250
+ console.log("Component creation detected:", relPath);
251
+ const createdStory = ensureStoryForComponent(abs);
252
+ if (createdStory) {
253
+ kick("create:story", createdStory);
254
+ }
255
+ }
256
+ }
257
+ let sbChild = null;
258
+ async function startStorybook() {
259
+ const isWin = process.platform === "win32";
260
+ const cmd = "npx";
261
+ const args = [
262
+ "-y",
263
+ "storybook",
264
+ "dev",
265
+ "-p",
266
+ String(SB_PORT)
267
+ ];
268
+ info(`[sb-deps] launching: ${cmd} ${args.join(" ")}`);
269
+ sbChild = spawn(cmd, args, {
270
+ cwd: projectRoot,
271
+ stdio: "inherit",
272
+ shell: isWin,
273
+ env: process.env
274
+ });
275
+ sbChild.on("error", (err) => {
276
+ error(`spawn failed: ${err?.message || err}`);
277
+ });
278
+ sbChild.on("exit", (code, sig) => {
279
+ info(`storybook exited (${sig || code})`);
280
+ sbChild = null;
281
+ });
282
+ info(`storybook running on http://localhost:${SB_PORT}`);
283
+ }
284
+ banner("sb-deps");
285
+ info(`outDir: ${rel(outDir)}`);
286
+ info(configPath ? `config: ${rel(configPath)}` : "config: (none)");
287
+ buildOnce();
288
+ let watcher = null;
289
+ if (WATCH) startWatcher().then((w) => watcher = w || null);
290
+ if (RUN_SB) startStorybook();
291
+ process.on("SIGINT", async () => {
292
+ info("shutting down…");
293
+ await watcher?.unsubscribe();
294
+ sbChild?.kill("SIGINT");
295
+ process.exit(0);
296
+ });
297
+ function rel(p) {
298
+ const prefix = resolve(projectRoot) + sep;
299
+ return p.replace(prefix, "");
300
+ }
301
+ function ms(n) {
302
+ return `${Math.max(1, Math.round(n))}ms`;
303
+ }
304
+ function info(msg) {
305
+ console.log("[sb-deps]", msg);
306
+ }
307
+ function error(msg) {
308
+ console.error("[sb-deps]", msg);
309
+ }
310
+ function banner(title) {
311
+ console.log(`\n${title} – dependency previews\n`);
312
+ }
313
+ function wait(time = 500) {
314
+ return new Promise((r) => setTimeout(r, time));
315
+ }
316
+
317
+ //#endregion
318
+ export { };
319
+ //# sourceMappingURL=sb-deps.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sb-deps.mjs","names":[],"sources":["../../cli/sb-deps.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/* eslint-disable no-console */\nimport { execSync, spawn, type ChildProcess } from 'node:child_process'\nimport {\n\texistsSync,\n\tmkdirSync,\n\twriteFileSync,\n\tstatSync,\n\treadFileSync,\n} from 'node:fs'\nimport { resolve, join, dirname, posix, sep, basename } from 'node:path'\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { createRequire } from 'node:module'\nimport watcherParcel from '@parcel/watcher'\nimport micromatch from 'micromatch'\n\n// ───────────────────────────────────────────────────────────────────────────────\n// Args\n// ───────────────────────────────────────────────────────────────────────────────\nconst argv = process.argv.slice(2)\nconst WATCH = argv.includes('--watch')\nconst RUN_SB = argv.includes('--run-storybook')\nconst PORT_ARGI = Math.max(argv.indexOf('--sb-port'), 0)\nconst SB_PORT =\n\tPORT_ARGI && argv[PORT_ARGI + 1]\n\t\t? Number(argv[PORT_ARGI + 1]) || 6006\n\t\t: 6006\n\n// ───────────────────────────────────────────────────────────────────────────────\n// Paths\n// ───────────────────────────────────────────────────────────────────────────────\nconst projectRoot = process.cwd()\nconst outDir = resolve(projectRoot, '.storybook')\nconst rawPath = join(outDir, 'dependency-previews.raw.json')\nconst cookedPath = join(outDir, 'dependency-previews.json')\n\nif (!existsSync(outDir)) mkdirSync(outDir, { recursive: true })\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\n\n// Resolve depcruise config: prefer project overrides, else bundled default\nconst pkgDefault = resolve(__dirname, 'scripts', 'depcruise.config.cjs')\nconst overrideCandidates = [\n\tresolve(projectRoot, 'depcruise.config.cjs'),\n\tresolve(projectRoot, '.dependency-cruiser.js'),\n\tresolve(projectRoot, '.dependency-cruiser.cjs'),\n]\nconst configPath =\n\toverrideCandidates.find((p) => existsSync(p)) ||\n\t(existsSync(pkgDefault) ? pkgDefault : null)\n\n// Path to postprocess helper (built as ESM)\nconst post = resolve(__dirname, 'scripts', 'postprocess.mjs')\n\n// ───────────────────────────────────────────────────────────────────────────────\n// Runners\n// ───────────────────────────────────────────────────────────────────────────────\nfunction runDepCruiseOnce() {\n\tconst cfgFlag = configPath ? `--config \"${configPath}\"` : '--no-config'\n\tconst cmd = `npx depcruise . ${cfgFlag} --output-type json`\n\tconst start = Date.now()\n\tconst stdout = execSync(cmd, {\n\t\tcwd: projectRoot,\n\t\tstdio: ['ignore', 'pipe', 'inherit'],\n\t\tencoding: 'utf8',\n\t})\n\twriteFileSync(rawPath, stdout, 'utf8')\n\tinfo(`graph ✓ (${ms(Date.now() - start)})`)\n}\n\nfunction postprocessOnce() {\n\tconst start = Date.now()\n\tconst postCmd = `node \"${post}\" \"${rawPath}\" \"${cookedPath}\"`\n\texecSync(postCmd, { cwd: projectRoot, stdio: 'inherit' })\n\tinfo(`compiled ✓ → ${rel(cookedPath)} (${ms(Date.now() - start)})`)\n}\n\nfunction buildOnce() {\n\ttry {\n\t\trunDepCruiseOnce()\n\t\tpostprocessOnce()\n\t} catch (e) {\n\t\terror('build failed')\n\t\tif (!WATCH) throw e\n\t}\n}\n\n// ───────────────────────────────────────────────────────────────────────────────\n// String utils\n// ───────────────────────────────────────────────────────────────────────────────\nfunction toWords(input: string) {\n\treturn String(input)\n\t\t.replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n\t\t.replace(/[_\\-./]+/g, ' ')\n\t\t.trim()\n\t\t.split(/\\s+/)\n}\nfunction toTitleCase(words: Array<string>) {\n\treturn words.map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(' ')\n}\nfunction toPascalCase(input: string) {\n\treturn toTitleCase(toWords(input)).replace(/\\s+/g, '')\n}\n\nfunction isEmptyOrWhitespace(absPath: string) {\n\ttry {\n\t\tconst s = statSync(absPath)\n\t\tif (s.size === 0) return true\n\t\tconst txt = readFileSync(absPath, 'utf8')\n\t\treturn !txt.trim()\n\t} catch {\n\t\treturn true\n\t}\n}\n\n// src/components/**/Thing.tsx ? (and not a story file)\nfunction isComponentsTsx(absPath: string) {\n\tconst norm = absPath.replace(/\\\\/g, '/')\n\treturn (\n\t\t/\\/src\\/components\\/.+\\.tsx$/i.test(norm) &&\n\t\t!/\\.stories?\\.tsx$/i.test(norm)\n\t)\n}\n\nfunction componentBaseFromComponent(absCompPath: string) {\n\treturn basename(absCompPath, '.tsx')\n}\n\nfunction detectAtomicTag(absPath: string) {\n\tconst adaptedPath = absPath.toLowerCase().replace(/\\\\/g, '/')\n\tconst tokens = ['atom', 'molecule', 'organism', 'template', 'page', 'icon']\n\tlet best: null | { val: string; idx: number } = null\n\tfor (const t of tokens) {\n\t\tconst idx = adaptedPath.lastIndexOf(t)\n\t\tif (idx !== -1 && (best === null || idx > best.idx))\n\t\t\tbest = { val: t, idx }\n\t}\n\treturn best ? best.val : null\n}\n\nfunction storyPathForComponent(absCompPath: string) {\n\tconst dir = dirname(absCompPath)\n\tconst base = componentBaseFromComponent(absCompPath)\n\treturn join(dir, `${base}.stories.tsx`)\n}\n\nfunction makeTitleFromComponent(absCompPath: string) {\n\tconst srcRoot = join(projectRoot, 'src') + sep\n\tconst normAbs = absCompPath.replace(/\\\\/g, '/')\n\tconst relFromSrc = normAbs.startsWith(srcRoot.replace(/\\\\/g, '/'))\n\t\t? normAbs.slice(srcRoot.length)\n\t\t: absCompPath.replace(projectRoot + sep, '').replace(/\\\\/g, '/')\n\n\tconst dir = posix.dirname(relFromSrc)\n\tlet segments = dir.split('/').filter(Boolean)\n\tif (segments[0] && /^components?$/i.test(segments[0]))\n\t\tsegments = segments.slice(1)\n\n\tconst titledFolders = segments.map((s) => toTitleCase(toWords(s)))\n\tconst compName = componentBaseFromComponent(absCompPath)\n\tconst compTitle = toTitleCase(toWords(compName))\n\n\tconst fullStoryPath = [...titledFolders, compTitle].filter(Boolean)\n\n\t// remove duplicates (e.g. Folder/Thing/Thing => Folder/Thing)\n\tconst dedupedStoryPath = [...new Set(fullStoryPath)]\n\n\treturn dedupedStoryPath.join(' / ')\n}\n\n// ───────────────────────────────────────────────────────────────────────────────\n// Story & component scaffolding\n// ───────────────────────────────────────────────────────────────────────────────\nfunction scaffoldComponent(absCompPath: string) {\n\tconst base = componentBaseFromComponent(absCompPath)\n\tconst componentName = toPascalCase(base)\n\tconst propsName = `PropsFor${componentName}`\n\n\tconst tpl = `import type { ReactNode } from 'react'\n\nexport interface ${propsName} {\n children?: ReactNode\n}\n\nexport function ${componentName}({ children }: ${propsName}) {\n return (\n <div className=\"${componentName}\">\n <p>${componentName}</p>\n {children}\n </div>\n )\n}\n`\n\twriteFileSync(absCompPath, tpl, 'utf8')\n\tinfo(`scaffolded component → \\${rel(absCompPath)}`)\n}\n\nfunction scaffoldStoryForComponent(absCompPath: string) {\n\tconst base = componentBaseFromComponent(absCompPath)\n\tconst componentName = toPascalCase(base)\n\tconst propsName = `PropsFor${componentName}`\n\tconst title = makeTitleFromComponent(absCompPath)\n\tconst atomic = detectAtomicTag(absCompPath)\n\tconst tags = ['autodocs']\n\tif (atomic) tags.push(atomic)\n\n\tconst storyTpl = `import type { Meta, StoryObj } from '@storybook/react-vite'\nimport type { StoryParameters } from 'storybook-addon-dependency-previews'\nimport { ${componentName}, type ${propsName} } from './${componentName}'\n\nconst meta: Meta<typeof ${componentName}> = {\n title: '${title}',\n component: ${componentName},\n tags: ${JSON.stringify(tags)},\n parameters: {\n layout: 'padded',\n __filePath: import.meta.url,\n } satisfies StoryParameters,\n}\n\nexport default meta\n\ntype Story = StoryObj<typeof meta>\n\nexport const Primary: Story = {\n args: {} satisfies ${propsName},\n}\n`\n\tconst storyPath = storyPathForComponent(absCompPath)\n\twriteFileSync(storyPath, storyTpl, 'utf8')\n\tinfo(`scaffolded story → \\${rel(storyPath)}`)\n\treturn storyPath\n}\n\nfunction ensureStoryForComponent(absCompPath: string) {\n\tconst sPath = storyPathForComponent(absCompPath)\n\tif (existsSync(sPath)) return null\n\treturn scaffoldStoryForComponent(absCompPath)\n}\n\n// ───────────────────────────────────────────────────────────────────────────────\n// Watcher\n// ───────────────────────────────────────────────────────────────────────────────\nfunction startWatcher() {\n\tconst root = projectRoot\n\tconst includeGlobs = [\n\t\t'**/*.stories.{ts,tsx,js,jsx,mdx,svelte}',\n\t\t'**/*.story.{ts,tsx,js,jsx,mdx,svelte}',\n\t\t'src/**/*.{ts,tsx,js,jsx,svelte}',\n\t\t'depcruise.config.cjs',\n\t\t'.dependency-cruiser.{js,cjs}',\n\t]\n\tconst ignoreGlobs = [\n\t\t'node_modules/**',\n\t\t'.git/**',\n\t\t'.storybook/**',\n\t\t'**/.cache/**',\n\t\t'**/dist/**',\n\t\t'**/build/**',\n\t]\n\n\tlet pending = false\n\tlet timer: NodeJS.Timeout | null = null\n\tlet isDeletingFile = false\n\n\tfunction kick(reason: string, absPath: string) {\n\t\tif (pending) return\n\t\tpending = true\n\t\tif (timer) clearTimeout(timer)\n\t\ttimer = setTimeout(() => {\n\t\t\tinfo(`${reason}: ${rel(absPath)}`)\n\t\t\tbuildOnce()\n\t\t\tpending = false\n\t\t}, 120)\n\t}\n\n\treturn watcherParcel\n\t\t.subscribe(\n\t\t\troot,\n\t\t\tasync (err, events) => {\n\t\t\t\tif (err) {\n\t\t\t\t\terror(`watch error ${err?.message || err}`)\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tfor (const ev of events) {\n\t\t\t\t\tconst abs = ev.path\n\t\t\t\t\tconst relPath = rel(abs)\n\t\t\t\t\tif (!micromatch.isMatch(relPath, includeGlobs)) continue\n\n\t\t\t\t\tif (ev.type === 'delete') {\n\t\t\t\t\t\tconsole.log('Deleted:', relPath)\n\t\t\t\t\t\tisDeletingFile = true\n\t\t\t\t\t\tkick('unlink', abs)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\t// COMPONENT CREATE — scaffold if empty and ensure story\n\t\t\t\t\tif (isComponentsTsx(abs) && ev.type === 'create') {\n\t\t\t\t\t\tawait handleComponentCreation(abs, relPath)\n\t\t\t\t\t\tcontinue\n\t\t\t\t\t}\n\n\t\t\t\t\t// normal rebuild\n\t\t\t\t\tkick(ev.type, abs)\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ ignore: ignoreGlobs },\n\t\t)\n\t\t.then((result) => {\n\t\t\tinfo('watching… (ready)')\n\t\t\treturn result\n\t\t})\n\t\t.catch((e) => error(`watch init failed ${e?.message || e}`))\n\n\tasync function handleComponentCreation(abs: string, relPath: string) {\n\t\tif (isEmptyOrWhitespace(abs)) {\n\t\t\tscaffoldComponent(abs)\n\t\t}\n\n\t\tconsole.log('Component creation detected:', relPath)\n\t\tconst createdStory = ensureStoryForComponent(abs)\n\t\tif (createdStory) {\n\t\t\tkick('create:story', createdStory)\n\t\t}\n\t}\n}\n\n// ───────────────────────────────────────────────────────────────────────────────\n// Storybook child\n// ───────────────────────────────────────────────────────────────────────────────\nlet sbChild: ChildProcess | null = null\nasync function startStorybook() {\n\tconst isWin = process.platform === 'win32'\n\tconst cmd = 'npx'\n\tconst args = ['-y', 'storybook', 'dev', '-p', String(SB_PORT)]\n\n\tinfo(`[sb-deps] launching: ${cmd} ${args.join(' ')}`)\n\n\tsbChild = spawn(cmd, args, {\n\t\tcwd: projectRoot,\n\t\tstdio: 'inherit',\n\t\tshell: isWin, // ← critical to avoid EINVAL on Win + Git Bash\n\t\tenv: process.env,\n\t})\n\n\tsbChild.on('error', (err: any) => {\n\t\terror(`spawn failed: ${err?.message || err}`)\n\t})\n\n\tsbChild.on('exit', (code, sig) => {\n\t\tinfo(`storybook exited (${sig || code})`)\n\t\tsbChild = null\n\t})\n\n\tinfo(`storybook running on http://localhost:${SB_PORT}`)\n}\n\n// ───────────────────────────────────────────────────────────────────────────────\n// Boot\n// ───────────────────────────────────────────────────────────────────────────────\nbanner('sb-deps')\ninfo(`outDir: ${rel(outDir)}`)\ninfo(configPath ? `config: ${rel(configPath)}` : 'config: (none)')\nbuildOnce()\n\nlet watcher: watcherParcel.AsyncSubscription | null = null\nif (WATCH) startWatcher().then((w) => (watcher = w || null))\nif (RUN_SB) startStorybook()\n\nprocess.on('SIGINT', async () => {\n\tinfo('shutting down…')\n\tawait watcher?.unsubscribe()\n\tsbChild?.kill('SIGINT')\n\tprocess.exit(0)\n})\n\n// ───────────────────────────────────────────────────────────────────────────────\n// Utils\n// ───────────────────────────────────────────────────────────────────────────────\nfunction rel(p: string) {\n\t// remove the projectRoot prefix and normalize slashes for logs\n\tconst prefix = resolve(projectRoot) + sep\n\treturn p.replace(prefix, '')\n}\nfunction ms(n: number) {\n\treturn `${Math.max(1, Math.round(n))}ms`\n}\nfunction info(msg: string) {\n\tconsole.log('[sb-deps]', msg)\n}\nfunction error(msg: string) {\n\tconsole.error('[sb-deps]', msg)\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AAiB,KAAK,WAAW,MAAM;GAC5C;AAEF,SAAQ,GAAG,SAAS,MAAM,QAAQ;AACjC,OAAK,qBAAqB,OAAO,KAAK,GAAG;AACzC,YAAU;GACT;AAEF,MAAK,yCAAyC,UAAU;;AAMzD,OAAO,UAAU;AACjB,KAAK,WAAW,IAAI,OAAO,GAAG;AAC9B,KAAK,aAAa,WAAW,IAAI,WAAW,KAAK,iBAAiB;AAClE,WAAW;AAEX,IAAI,UAAkD;AACtD,IAAI,MAAO,eAAc,CAAC,MAAM,MAAO,UAAU,KAAK,KAAM;AAC5D,IAAI,OAAQ,iBAAgB;AAE5B,QAAQ,GAAG,UAAU,YAAY;AAChC,MAAK,iBAAiB;AACtB,OAAM,SAAS,aAAa;AAC5B,UAAS,KAAK,SAAS;AACvB,SAAQ,KAAK,EAAE;EACd;AAKF,SAAS,IAAI,GAAW;CAEvB,MAAM,SAAS,QAAQ,YAAY,GAAG;AACtC,QAAO,EAAE,QAAQ,QAAQ,GAAG;;AAE7B,SAAS,GAAG,GAAW;AACtB,QAAO,GAAG,KAAK,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC,CAAC;;AAEtC,SAAS,KAAK,KAAa;AAC1B,SAAQ,IAAI,aAAa,IAAI;;AAE9B,SAAS,MAAM,KAAa;AAC3B,SAAQ,MAAM,aAAa,IAAI;;AAEhC,SAAS,OAAO,OAAe;AAC9B,SAAQ,IAAI,KAAK,MAAM,0BAA0B;;AAElD,SAAS,KAAK,OAAO,KAAK;AACzB,QAAO,IAAI,SAAS,MAAM,WAAW,GAAG,KAAK,CAAC"}
@@ -0,0 +1,38 @@
1
+
2
+ //#region cli/scripts/depcruise.config.ts
3
+ const config = {
4
+ forbidden: [
5
+ {
6
+ name: "no-circular",
7
+ severity: "error",
8
+ from: {},
9
+ to: { circular: true }
10
+ },
11
+ {
12
+ name: "no-node-modules-imports",
13
+ severity: "warn",
14
+ from: { path: "^src" },
15
+ to: { path: "^node_modules" }
16
+ },
17
+ {
18
+ name: "no-orphans-in-components",
19
+ severity: "warn",
20
+ from: {
21
+ orphan: true,
22
+ path: "^src/(components|ui|lib)/"
23
+ },
24
+ to: {}
25
+ }
26
+ ],
27
+ options: {
28
+ tsPreCompilationDeps: true,
29
+ combinedDependencies: true,
30
+ doNotFollow: { path: "node_modules" },
31
+ includeOnly: "^src"
32
+ }
33
+ };
34
+ var depcruise_config_default = config;
35
+
36
+ //#endregion
37
+ module.exports = depcruise_config_default;
38
+ //# sourceMappingURL=depcruise.config.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depcruise.config.cjs","names":[],"sources":["../../../cli/scripts/depcruise.config.ts"],"sourcesContent":["import type { IConfiguration } from 'dependency-cruiser'\n\nconst config: IConfiguration = {\n\tforbidden: [\n\t\t// 0) No circular dependencies anywhere\n\t\t{\n\t\t\tname: 'no-circular',\n\t\t\tseverity: 'error',\n\t\t\tfrom: {},\n\t\t\tto: { circular: true },\n\t\t},\n\n\t\t// 1) Warn when importing directly from node_modules (optional)\n\t\t{\n\t\t\tname: 'no-node-modules-imports',\n\t\t\tseverity: 'warn',\n\t\t\tfrom: { path: '^src' },\n\t\t\tto: { path: '^node_modules' },\n\t\t},\n\n\t\t// 2) Warn on orphan modules within components/ui/lib (valid `from`/`to` form)\n\t\t{\n\t\t\tname: 'no-orphans-in-components',\n\t\t\tseverity: 'warn',\n\t\t\tfrom: {\n\t\t\t\torphan: true,\n\t\t\t\tpath: '^src/(components|ui|lib)/',\n\t\t\t},\n\t\t\tto: {}, // must be present; empty matcher is fine\n\t\t},\n\t],\n\toptions: {\n\t\ttsPreCompilationDeps: true,\n\t\tcombinedDependencies: true,\n\t\tdoNotFollow: { path: 'node_modules' },\n\t\tincludeOnly: '^src',\n\t\t// IMPORTANT: keep baseDir disabled to avoid the previous src\\src issue\n\t\t// baseDir: 'src'\n\t},\n}\n\nexport default config\n"],"mappings":";;AAEA,MAAM,SAAyB;CAC9B,WAAW;EAEV;GACC,MAAM;GACN,UAAU;GACV,MAAM,EAAE;GACR,IAAI,EAAE,UAAU,MAAM;GACtB;EAGD;GACC,MAAM;GACN,UAAU;GACV,MAAM,EAAE,MAAM,QAAQ;GACtB,IAAI,EAAE,MAAM,iBAAiB;GAC7B;EAGD;GACC,MAAM;GACN,UAAU;GACV,MAAM;IACL,QAAQ;IACR,MAAM;IACN;GACD,IAAI,EAAE;GACN;EACD;CACD,SAAS;EACR,sBAAsB;EACtB,sBAAsB;EACtB,aAAa,EAAE,MAAM,gBAAgB;EACrC,aAAa;EAGb;CACD;AAED,+BAAe"}
@@ -0,0 +1,6 @@
1
+ import { IConfiguration } from "dependency-cruiser";
2
+
3
+ //#region cli/scripts/depcruise.config.d.ts
4
+ declare const config: IConfiguration;
5
+ export = config;
6
+ //# sourceMappingURL=depcruise.config.d.cts.map
@@ -0,0 +1,7 @@
1
+ import { IConfiguration } from "dependency-cruiser";
2
+
3
+ //#region cli/scripts/depcruise.config.d.ts
4
+ declare const config: IConfiguration;
5
+ //#endregion
6
+ export { config as default };
7
+ //# sourceMappingURL=depcruise.config.d.mts.map
@@ -0,0 +1,37 @@
1
+ //#region cli/scripts/depcruise.config.ts
2
+ const config = {
3
+ forbidden: [
4
+ {
5
+ name: "no-circular",
6
+ severity: "error",
7
+ from: {},
8
+ to: { circular: true }
9
+ },
10
+ {
11
+ name: "no-node-modules-imports",
12
+ severity: "warn",
13
+ from: { path: "^src" },
14
+ to: { path: "^node_modules" }
15
+ },
16
+ {
17
+ name: "no-orphans-in-components",
18
+ severity: "warn",
19
+ from: {
20
+ orphan: true,
21
+ path: "^src/(components|ui|lib)/"
22
+ },
23
+ to: {}
24
+ }
25
+ ],
26
+ options: {
27
+ tsPreCompilationDeps: true,
28
+ combinedDependencies: true,
29
+ doNotFollow: { path: "node_modules" },
30
+ includeOnly: "^src"
31
+ }
32
+ };
33
+ var depcruise_config_default = config;
34
+
35
+ //#endregion
36
+ export { depcruise_config_default as default };
37
+ //# sourceMappingURL=depcruise.config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depcruise.config.mjs","names":[],"sources":["../../../cli/scripts/depcruise.config.ts"],"sourcesContent":["import type { IConfiguration } from 'dependency-cruiser'\n\nconst config: IConfiguration = {\n\tforbidden: [\n\t\t// 0) No circular dependencies anywhere\n\t\t{\n\t\t\tname: 'no-circular',\n\t\t\tseverity: 'error',\n\t\t\tfrom: {},\n\t\t\tto: { circular: true },\n\t\t},\n\n\t\t// 1) Warn when importing directly from node_modules (optional)\n\t\t{\n\t\t\tname: 'no-node-modules-imports',\n\t\t\tseverity: 'warn',\n\t\t\tfrom: { path: '^src' },\n\t\t\tto: { path: '^node_modules' },\n\t\t},\n\n\t\t// 2) Warn on orphan modules within components/ui/lib (valid `from`/`to` form)\n\t\t{\n\t\t\tname: 'no-orphans-in-components',\n\t\t\tseverity: 'warn',\n\t\t\tfrom: {\n\t\t\t\torphan: true,\n\t\t\t\tpath: '^src/(components|ui|lib)/',\n\t\t\t},\n\t\t\tto: {}, // must be present; empty matcher is fine\n\t\t},\n\t],\n\toptions: {\n\t\ttsPreCompilationDeps: true,\n\t\tcombinedDependencies: true,\n\t\tdoNotFollow: { path: 'node_modules' },\n\t\tincludeOnly: '^src',\n\t\t// IMPORTANT: keep baseDir disabled to avoid the previous src\\src issue\n\t\t// baseDir: 'src'\n\t},\n}\n\nexport default config\n"],"mappings":";AAEA,MAAM,SAAyB;CAC9B,WAAW;EAEV;GACC,MAAM;GACN,UAAU;GACV,MAAM,EAAE;GACR,IAAI,EAAE,UAAU,MAAM;GACtB;EAGD;GACC,MAAM;GACN,UAAU;GACV,MAAM,EAAE,MAAM,QAAQ;GACtB,IAAI,EAAE,MAAM,iBAAiB;GAC7B;EAGD;GACC,MAAM;GACN,UAAU;GACV,MAAM;IACL,QAAQ;IACR,MAAM;IACN;GACD,IAAI,EAAE;GACN;EACD;CACD,SAAS;EACR,sBAAsB;EACtB,sBAAsB;EACtB,aAAa,EAAE,MAAM,gBAAgB;EACrC,aAAa;EAGb;CACD;AAED,+BAAe"}
@@ -0,0 +1,106 @@
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ let node_fs = require("node:fs");
3
+ let node_path = require("node:path");
4
+ let _storybook_csf = require("@storybook/csf");
5
+
6
+ //#region cli/scripts/postprocess.ts
7
+ const [, , inPathArg, outPathArg] = process.argv;
8
+ const inPath = (0, node_path.resolve)(inPathArg || ".storybook/dependency-previews.raw.json");
9
+ const outPath = (0, node_path.resolve)(outPathArg || ".storybook/dependency-previews.json");
10
+ if (!(0, node_fs.existsSync)((0, node_path.dirname)(outPath))) (0, node_fs.mkdirSync)((0, node_path.dirname)(outPath), { recursive: true });
11
+ const raw = JSON.parse((0, node_fs.readFileSync)(inPath, "utf8"));
12
+ const norm = (p) => node_path.posix.normalize(p.replaceAll("\\", "/"));
13
+ const isComponent = (p) => {
14
+ return /src\/(components|ui|lib)\//.test(p) && !/\.(css|scss|sass|less)$/.test(p);
15
+ };
16
+ /** Simple keyed-push to avoid duplicates */
17
+ function pushUnique(list, item) {
18
+ if (!list.some((x) => x.componentPath === item.componentPath)) {
19
+ list.push(item);
20
+ }
21
+ }
22
+ const graph = {};
23
+ for (const m of raw.modules || []) {
24
+ const from = norm(m.source);
25
+ if (!isComponent(from)) continue;
26
+ const deps = (m.dependencies || []).map((d) => d.resolved && norm(d.resolved)).filter(Boolean).filter(isComponent);
27
+ const topLevelFromStory = getStoryId(from);
28
+ if (!graph[from]) graph[from] = {
29
+ componentPath: from,
30
+ ...topLevelFromStory && {
31
+ storyId: topLevelFromStory?.id,
32
+ storyTitle: topLevelFromStory?.title,
33
+ storyTitlePath: topLevelFromStory?.titlePath,
34
+ storyFilePath: topLevelFromStory?.filePath
35
+ },
36
+ builtWith: [],
37
+ usedIn: []
38
+ };
39
+ for (const to of deps) {
40
+ if (from === to) continue;
41
+ const toStory = getStoryId(to);
42
+ const builtWithEntry = {
43
+ componentPath: to,
44
+ ...toStory && {
45
+ storyId: toStory.id,
46
+ storyTitle: toStory.title,
47
+ storyTitlePath: toStory.titlePath,
48
+ storyFilePath: toStory.filePath
49
+ }
50
+ };
51
+ if (!graph[to]) graph[to] = {
52
+ ...builtWithEntry,
53
+ builtWith: [],
54
+ usedIn: []
55
+ };
56
+ pushUnique(graph[from].builtWith, builtWithEntry);
57
+ const fromStory = getStoryId(from);
58
+ const usedInEntry = {
59
+ componentPath: from,
60
+ ...fromStory && {
61
+ storyId: fromStory.id,
62
+ storyTitle: fromStory.title,
63
+ storyTitlePath: fromStory.titlePath,
64
+ storyFilePath: fromStory.filePath
65
+ }
66
+ };
67
+ pushUnique(graph[to].usedIn, usedInEntry);
68
+ }
69
+ }
70
+ const byPath = (a, b) => (a.componentPath || "").localeCompare(b.componentPath || "");
71
+ for (const k of Object.keys(graph)) {
72
+ graph[k].builtWith.sort(byPath);
73
+ graph[k].usedIn.sort(byPath);
74
+ }
75
+ (0, node_fs.writeFileSync)(outPath, JSON.stringify(graph, null, 2));
76
+ function getStoryId(componentPath) {
77
+ const rawFileData = getRawStoryFileData(componentPath);
78
+ if (!rawFileData.storyFileData) return null;
79
+ const match = rawFileData.storyFileData.match(/title:\s*['"`]([^'"`]+)['"`]/);
80
+ if (!match) return null;
81
+ const titlePath = match[1];
82
+ const title = (0, node_path.basename)(titlePath).trim();
83
+ return {
84
+ title,
85
+ titlePath,
86
+ id: (0, _storybook_csf.toId)(titlePath, "docs"),
87
+ filePath: rawFileData.storyFilePath
88
+ };
89
+ }
90
+ function getRawStoryFileData(componentPath) {
91
+ const base = componentPath.replace(/\.\w+$/, "");
92
+ const storiesPath = `${base}.stories${(0, node_path.extname)(componentPath)}`;
93
+ const storyPath = `${base}.story${(0, node_path.extname)(componentPath)}`;
94
+ const storiesData = getRawFileData(storiesPath);
95
+ const storyData = getRawFileData(storyPath);
96
+ return {
97
+ storyFileData: storiesData || storyData || null,
98
+ storyFilePath: storiesData && storiesPath || storyData && storyPath || null
99
+ };
100
+ }
101
+ function getRawFileData(path) {
102
+ return (0, node_fs.existsSync)(path) && (0, node_fs.readFileSync)(path, "utf8");
103
+ }
104
+
105
+ //#endregion
106
+ //# sourceMappingURL=postprocess.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postprocess.cjs","names":["posix"],"sources":["../../../cli/scripts/postprocess.ts"],"sourcesContent":["import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs'\nimport { resolve, posix, dirname, extname, basename } from 'node:path'\nimport { toId } from '@storybook/csf'\nimport type { Deps, Graph, StoryInfo } from '../../src/types.js'\n\nconst [, , inPathArg, outPathArg] = process.argv\nconst inPath = resolve(inPathArg || '.storybook/dependency-previews.raw.json')\nconst outPath = resolve(outPathArg || '.storybook/dependency-previews.json')\n\nif (!existsSync(dirname(outPath)))\n\tmkdirSync(dirname(outPath), { recursive: true })\n\nconst raw = JSON.parse(readFileSync(inPath, 'utf8'))\nconst norm = (p: string) => posix.normalize(p.replaceAll('\\\\', '/'))\nconst isComponent = (p: string) => {\n\treturn (\n\t\t/src\\/(components|ui|lib)\\//.test(p) &&\n\t\t// Ignore css files\n\t\t!/\\.(css|scss|sass|less)$/.test(p)\n\t)\n}\n\n/** Simple keyed-push to avoid duplicates */\nfunction pushUnique(list: Array<StoryInfo>, item: StoryInfo) {\n\tif (!list.some((x) => x.componentPath === item.componentPath)) {\n\t\tlist.push(item)\n\t}\n}\n\nconst graph: Graph = {}\n\nfor (const m of raw.modules || []) {\n\tconst from = norm(m.source)\n\tif (!isComponent(from)) continue\n\n\tconst deps = (m.dependencies || [])\n\t\t.map((d: any) => d.resolved && norm(d.resolved))\n\t\t.filter(Boolean)\n\t\t.filter(isComponent)\n\n\tconst topLevelFromStory = getStoryId(from)\n\n\tif (!graph[from])\n\t\tgraph[from] = {\n\t\t\tcomponentPath: from,\n\t\t\t...(topLevelFromStory && {\n\t\t\t\tstoryId: topLevelFromStory?.id,\n\t\t\t\tstoryTitle: topLevelFromStory?.title,\n\t\t\t\tstoryTitlePath: topLevelFromStory?.titlePath,\n\t\t\t\tstoryFilePath: topLevelFromStory?.filePath,\n\t\t\t}),\n\t\t\tbuiltWith: [],\n\t\t\tusedIn: [],\n\t\t} satisfies Deps\n\n\tfor (const to of deps) {\n\t\tif (from === to) continue // 🔒 skip self-edges\n\n\t\t// ---- builtWith: from → to\n\t\tconst toStory = getStoryId(to)\n\t\tconst builtWithEntry: StoryInfo = {\n\t\t\tcomponentPath: to, // ✅ the dependency, not \"from\"\n\t\t\t...(toStory && {\n\t\t\t\tstoryId: toStory.id,\n\t\t\t\tstoryTitle: toStory.title,\n\t\t\t\tstoryTitlePath: toStory.titlePath,\n\t\t\t\tstoryFilePath: toStory.filePath,\n\t\t\t}),\n\t\t}\n\n\t\tif (!graph[to])\n\t\t\tgraph[to] = {\n\t\t\t\t...builtWithEntry,\n\t\t\t\tbuiltWith: [],\n\t\t\t\tusedIn: [],\n\t\t\t}\n\n\t\tpushUnique(graph[from].builtWith, builtWithEntry)\n\n\t\t// ---- usedIn: to ← from\n\t\tconst fromStory = getStoryId(from)\n\t\tconst usedInEntry: StoryInfo = {\n\t\t\tcomponentPath: from,\n\t\t\t...(fromStory && {\n\t\t\t\tstoryId: fromStory.id,\n\t\t\t\tstoryTitle: fromStory.title,\n\t\t\t\tstoryTitlePath: fromStory.titlePath,\n\t\t\t\tstoryFilePath: fromStory.filePath,\n\t\t\t}),\n\t\t}\n\t\tpushUnique(graph[to].usedIn, usedInEntry)\n\t}\n}\n\n// Stable sort by path for nicer diffs/UI\nconst byPath = (a: StoryInfo, b: StoryInfo) =>\n\t(a.componentPath || '').localeCompare(b.componentPath || '')\n\nfor (const k of Object.keys(graph)) {\n\tgraph[k].builtWith.sort(byPath)\n\tgraph[k].usedIn.sort(byPath)\n}\n\nwriteFileSync(outPath, JSON.stringify(graph, null, 2))\n\nfunction getStoryId(componentPath: string) {\n\tconst rawFileData = getRawStoryFileData(componentPath)\n\tif (!rawFileData.storyFileData) return null\n\n\tconst match = rawFileData.storyFileData.match(\n\t\t/title:\\s*['\"`]([^'\"`]+)['\"`]/,\n\t)\n\tif (!match) return null\n\n\tconst titlePath = match[1]\n\tconst title = basename(titlePath).trim()\n\treturn {\n\t\ttitle: title,\n\t\ttitlePath: titlePath,\n\t\tid: toId(titlePath, 'docs'),\n\t\tfilePath: rawFileData.storyFilePath,\n\t}\n}\n\nfunction getRawStoryFileData(componentPath: string) {\n\tconst base = componentPath.replace(/\\.\\w+$/, '')\n\tconst storiesPath = `${base}.stories${extname(componentPath)}`\n\tconst storyPath = `${base}.story${extname(componentPath)}`\n\n\tconst storiesData = getRawFileData(storiesPath)\n\tconst storyData = getRawFileData(storyPath)\n\n\treturn {\n\t\tstoryFileData: storiesData || storyData || null,\n\t\tstoryFilePath:\n\t\t\t(storiesData && storiesPath) || (storyData && storyPath) || null,\n\t}\n}\n\nfunction getRawFileData(path: string) {\n\treturn existsSync(path) && readFileSync(path, 'utf8')\n}\n"],"mappings":";;;;;;AAKA,MAAM,KAAK,WAAW,cAAc,QAAQ;AAC5C,MAAM,gCAAiB,aAAa,0CAA0C;AAC9E,MAAM,iCAAkB,cAAc,sCAAsC;AAE5E,IAAI,gDAAoB,QAAQ,CAAC,CAChC,+CAAkB,QAAQ,EAAE,EAAE,WAAW,MAAM,CAAC;AAEjD,MAAM,MAAM,KAAK,gCAAmB,QAAQ,OAAO,CAAC;AACpD,MAAM,QAAQ,MAAcA,gBAAM,UAAU,EAAE,WAAW,MAAM,IAAI,CAAC;AACpE,MAAM,eAAe,MAAc;AAClC,QACC,6BAA6B,KAAK,EAAE,IAEpC,CAAC,0BAA0B,KAAK,EAAE;;;AAKpC,SAAS,WAAW,MAAwB,MAAiB;AAC5D,KAAI,CAAC,KAAK,MAAM,MAAM,EAAE,kBAAkB,KAAK,cAAc,EAAE;AAC9D,OAAK,KAAK,KAAK;;;AAIjB,MAAM,QAAe,EAAE;AAEvB,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE,EAAE;CAClC,MAAM,OAAO,KAAK,EAAE,OAAO;AAC3B,KAAI,CAAC,YA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