dslinter 0.1.0 → 0.1.2
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/CHANGELOG.md +8 -0
- package/README.md +43 -0
- package/bin/dslinter.mjs +6 -0
- package/bin/lib/dev-banner.mjs +6 -3
- package/bin/lib/dev-banner.test.mjs +19 -3
- package/bin/modes/dev.mjs +19 -7
- package/bin/modes/init.mjs +73 -0
- package/dashboard-dist/assets/index-BN-Qjczl.js +205 -0
- package/dashboard-dist/assets/index-BhDQfrwA.css +1 -0
- package/dashboard-dist/index.html +2 -2
- package/index.cjs +52 -52
- package/package.json +7 -6
- package/src/components/ComponentInspectPane.tsx +198 -0
- package/src/components/DashboardCommandPalette.tsx +1 -15
- package/src/components/GovernancePane.tsx +3 -3
- package/src/components/Sidebar.tsx +4 -8
- package/src/dashboard/ComponentCatalog.tsx +41 -68
- package/src/dashboard/ComponentPropUsageDetail.tsx +90 -0
- package/src/dashboard/DashboardBody.tsx +3 -3
- package/src/index.ts +27 -0
- package/src/playground/buildPlaygroundEntriesFromReport.test.ts +53 -0
- package/src/playground/buildPlaygroundEntriesFromReport.ts +389 -0
- package/src/playground/createPlaygroundRegistry.ts +48 -0
- package/src/playground/playgroundJoin.test.ts +74 -0
- package/src/playground/playgroundJoin.ts +116 -0
- package/src/report/findingsForComponent.ts +24 -0
- package/src/shell/DashboardLayout.tsx +51 -37
- package/src/shell/hashRoute.test.ts +41 -0
- package/src/shell/hashRoute.ts +2 -1
- package/templates/playground/buildRegistry.ts +26 -0
- package/templates/vite.dslinter.snippet.ts +28 -0
- package/dashboard-dist/assets/index-Pc1to7nD.css +0 -1
- package/dashboard-dist/assets/index-YvDeIoPr.js +0 -205
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.1.2
|
|
4
|
+
|
|
5
|
+
[compare changes](https://github.com/jrmybtlr/DSLinter/compare/v0.1.1...v0.1.2)
|
|
6
|
+
|
|
7
|
+
## v0.1.1
|
|
8
|
+
|
|
9
|
+
[compare changes](https://github.com/jrmybtlr/DSLinter/compare/v0.1.0...v0.1.1)
|
|
10
|
+
|
|
3
11
|
## v0.1.0
|
|
4
12
|
|
|
5
13
|
[compare changes](https://github.com/jrmybtlr/DSLinter/compare/v0.0.35...v0.1.0)
|
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ The crates.io crate **`dslint`** is a **different project**. Use **`cargo instal
|
|
|
48
48
|
Typical usage:
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
|
+
npx dslinter init # scaffold src/playground/buildRegistry.ts
|
|
51
52
|
npx dslinter # dev (watch + dashboard)
|
|
52
53
|
npx dslinter --report /path/to/repo --json
|
|
53
54
|
npx dslinter --report --output public/dslint-report.json
|
|
@@ -71,11 +72,53 @@ Set `DSLINT_SERVE_PORT` to override the default scanner port (`7878`). Your Vite
|
|
|
71
72
|
@import "dslinter/theme.css";
|
|
72
73
|
```
|
|
73
74
|
|
|
75
|
+
## Live component previews (consumer Vite apps)
|
|
76
|
+
|
|
77
|
+
If the dashboard shows **“Scan snapshot — no live preview”** for a component that appears in the catalog, the scanner found the file but Vite did not load it. Wire previews in three steps:
|
|
78
|
+
|
|
79
|
+
1. **Scaffold** (optional): `npx dslinter init` → writes `src/playground/buildRegistry.ts`
|
|
80
|
+
2. **Glob** must cover nested paths, e.g. `import.meta.glob("../components/**/*.{tsx,jsx}", { eager: true })`
|
|
81
|
+
3. **App**: pass `playgroundEntries` and `playgroundJoinSkips` from the registry into `DashboardLayout`
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { useMemo } from "react";
|
|
85
|
+
import { DashboardLayout, useWorkspaceReport } from "dslinter";
|
|
86
|
+
import {
|
|
87
|
+
buildPlaygroundEntries,
|
|
88
|
+
getPlaygroundJoinSkips,
|
|
89
|
+
} from "./playground/buildRegistry";
|
|
90
|
+
|
|
91
|
+
const dslinterReport = useWorkspaceReport({
|
|
92
|
+
reportUrl: "/dslint-report.json",
|
|
93
|
+
watchUrl: "/events",
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const playgroundEntries = useMemo(
|
|
97
|
+
() => buildPlaygroundEntries(dslinterReport.report),
|
|
98
|
+
[dslinterReport.report],
|
|
99
|
+
);
|
|
100
|
+
const playgroundJoinSkips = useMemo(
|
|
101
|
+
() => getPlaygroundJoinSkips(dslinterReport.report),
|
|
102
|
+
[dslinterReport.report],
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
<DashboardLayout
|
|
106
|
+
playgroundEntries={playgroundEntries}
|
|
107
|
+
playgroundJoinSkips={playgroundJoinSkips}
|
|
108
|
+
dslinterReport={dslinterReport}
|
|
109
|
+
/>;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
In dev, skipped joins are also logged to the console. The inspect pane shows the expected Vite glob key when a preview fails.
|
|
113
|
+
|
|
114
|
+
Run the scanner from the **project root** (`npx dslinter .`) so `playgrounds[].rel_path` matches your repo layout.
|
|
115
|
+
|
|
74
116
|
## Wiring the layout
|
|
75
117
|
|
|
76
118
|
`DashboardLayout` needs:
|
|
77
119
|
|
|
78
120
|
- **`playgroundEntries`** — from the report’s `playgrounds` list joined to your React modules (see repo `demo/src/playground/buildRegistry.ts`).
|
|
121
|
+
- **`playgroundJoinSkips`** (optional) — from `buildPlaygroundEntriesFromReportWithSkips` for richer inspect-pane hints.
|
|
79
122
|
- **`tokenCatalog`** — token wall data (see `demo/src/tokenCatalog.ts`).
|
|
80
123
|
- **`dslinterReport`** — from `useWorkspaceReport({ reportUrl: "/dslint-report.json", ... })`.
|
|
81
124
|
|
package/bin/dslinter.mjs
CHANGED
|
@@ -6,10 +6,16 @@ import { parseDslinterArgs } from "./lib/parse-args.mjs";
|
|
|
6
6
|
import { runScannerInternal } from "./lib/run-scanner.mjs";
|
|
7
7
|
import { runBuildMode } from "./modes/build.mjs";
|
|
8
8
|
import { runDevMode } from "./modes/dev.mjs";
|
|
9
|
+
import { runInitMode } from "./modes/init.mjs";
|
|
9
10
|
import { runReportMode } from "./modes/report.mjs";
|
|
10
11
|
|
|
11
12
|
const rawArgs = process.argv.slice(2);
|
|
12
13
|
|
|
14
|
+
if (rawArgs[0] === "init") {
|
|
15
|
+
runInitMode({ targetDir: rawArgs[1] });
|
|
16
|
+
process.exit(0);
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
if (process.env.DSLINTER_INTERNAL === "1") {
|
|
14
20
|
runScannerInternal(rawArgs);
|
|
15
21
|
}
|
package/bin/lib/dev-banner.mjs
CHANGED
|
@@ -196,7 +196,10 @@ export function formatDevBanner(opts) {
|
|
|
196
196
|
plainWidths.push(14 + 2 + `${apiBase}/events`.length);
|
|
197
197
|
}
|
|
198
198
|
if (opts.pollMs) plainWidths.push(14 + 2 + `polling every ${opts.pollMs} ms`.length);
|
|
199
|
-
|
|
199
|
+
const footerPlain = opts.bundledUrl
|
|
200
|
+
? " Open the Bundled UI URL in your browser. Ctrl+C to stop."
|
|
201
|
+
: " Open the Dashboard URL in your browser. Ctrl+C to stop.";
|
|
202
|
+
plainWidths.push(visibleLength(footerPlain));
|
|
200
203
|
|
|
201
204
|
const contentWidth = Math.min(maxBox - 4, Math.max(...plainWidths, 40));
|
|
202
205
|
const totalWidth = contentWidth + 4;
|
|
@@ -213,7 +216,7 @@ export function formatDevBanner(opts) {
|
|
|
213
216
|
...row(color.label("Report file"), reportPlain, contentWidth, color.value),
|
|
214
217
|
);
|
|
215
218
|
styledRows.push("");
|
|
216
|
-
if (opts.dashboardUrl) {
|
|
219
|
+
if (opts.dashboardUrl && !opts.bundledUrl) {
|
|
217
220
|
styledRows.push(
|
|
218
221
|
...row(color.label("Dashboard"), opts.dashboardUrl, contentWidth, color.url),
|
|
219
222
|
);
|
|
@@ -251,7 +254,7 @@ export function formatDevBanner(opts) {
|
|
|
251
254
|
);
|
|
252
255
|
}
|
|
253
256
|
styledRows.push("");
|
|
254
|
-
styledRows.push(color.dim(
|
|
257
|
+
styledRows.push(color.dim(footerPlain));
|
|
255
258
|
|
|
256
259
|
return boxLines(styledRows, totalWidth).join("\n");
|
|
257
260
|
}
|
|
@@ -22,7 +22,7 @@ describe("shortenPath", () => {
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
describe("formatDevBanner", () => {
|
|
25
|
-
it("includes logo, scan path, report,
|
|
25
|
+
it("includes logo, scan path, report, bundled UI, and API URLs", () => {
|
|
26
26
|
const text = formatDevBanner({
|
|
27
27
|
scanPath: "/tmp/components",
|
|
28
28
|
reportPath: "/tmp/components/public/dslint-report.json",
|
|
@@ -36,11 +36,27 @@ describe("formatDevBanner", () => {
|
|
|
36
36
|
expect(text).toContain(LOGO[1]);
|
|
37
37
|
expect(text).toContain("Scan path");
|
|
38
38
|
expect(text).toContain("Report file");
|
|
39
|
-
expect(text).toContain("
|
|
40
|
-
expect(text).toContain("http://localhost:5173/");
|
|
39
|
+
expect(text).toContain("Bundled UI");
|
|
40
|
+
expect(text).not.toContain("http://localhost:5173/");
|
|
41
|
+
expect(text).not.toMatch(/\bDashboard\b/);
|
|
41
42
|
expect(text).toContain("7878");
|
|
42
43
|
expect(text).toContain("dslint-report.json");
|
|
43
44
|
expect(text).toContain("polling every 150 ms");
|
|
45
|
+
expect(text).toContain("Open the Bundled UI URL");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("shows dashboard URL when bundled UI is not served", () => {
|
|
49
|
+
const text = formatDevBanner({
|
|
50
|
+
scanPath: "/tmp/components",
|
|
51
|
+
reportPath: "/tmp/components/public/dslint-report.json",
|
|
52
|
+
apiPort: 7878,
|
|
53
|
+
apiAvailable: true,
|
|
54
|
+
dashboardUrl: "http://localhost:5173/",
|
|
55
|
+
pollMs: 150,
|
|
56
|
+
});
|
|
57
|
+
expect(text).toContain("Dashboard");
|
|
58
|
+
expect(text).toContain("http://localhost:5173/");
|
|
59
|
+
expect(text).toContain("Open the Dashboard URL");
|
|
44
60
|
});
|
|
45
61
|
|
|
46
62
|
it("marks API unavailable when port is busy", () => {
|
package/bin/modes/dev.mjs
CHANGED
|
@@ -152,11 +152,17 @@ export async function runDevMode({ scanPath, outputPath, scannerArgs, servePort
|
|
|
152
152
|
{
|
|
153
153
|
cwd: embedRoot,
|
|
154
154
|
stdio: "inherit",
|
|
155
|
-
env: {
|
|
155
|
+
env: {
|
|
156
|
+
...process.env,
|
|
157
|
+
DSLINT_SERVE_PORT: String(port),
|
|
158
|
+
DSLINT_SCAN_ROOT: scanAbs,
|
|
159
|
+
},
|
|
156
160
|
},
|
|
157
161
|
);
|
|
158
162
|
children.push(vite);
|
|
159
|
-
printDevBanner(
|
|
163
|
+
printDevBanner(
|
|
164
|
+
attachBundledStatic ? bannerBase : { ...bannerBase, dashboardUrl },
|
|
165
|
+
);
|
|
160
166
|
|
|
161
167
|
vite.on("exit", (code, signal) => {
|
|
162
168
|
cleanup("SIGTERM");
|
|
@@ -183,11 +189,17 @@ export async function runDevMode({ scanPath, outputPath, scannerArgs, servePort
|
|
|
183
189
|
{
|
|
184
190
|
cwd: consumerViteRoot,
|
|
185
191
|
stdio: "inherit",
|
|
186
|
-
env: {
|
|
192
|
+
env: {
|
|
193
|
+
...process.env,
|
|
194
|
+
DSLINT_SERVE_PORT: String(port),
|
|
195
|
+
DSLINT_SCAN_ROOT: scanAbs,
|
|
196
|
+
},
|
|
187
197
|
},
|
|
188
198
|
);
|
|
189
199
|
children.push(vite);
|
|
190
|
-
printDevBanner(
|
|
200
|
+
printDevBanner(
|
|
201
|
+
attachBundledStatic ? bannerBase : { ...bannerBase, dashboardUrl },
|
|
202
|
+
);
|
|
191
203
|
|
|
192
204
|
vite.on("exit", (code, signal) => {
|
|
193
205
|
cleanup("SIGTERM");
|
|
@@ -198,9 +210,9 @@ export async function runDevMode({ scanPath, outputPath, scannerArgs, servePort
|
|
|
198
210
|
}
|
|
199
211
|
|
|
200
212
|
if (bundledDist) {
|
|
201
|
-
const
|
|
202
|
-
printDevBanner(
|
|
203
|
-
maybeOpenBrowser(
|
|
213
|
+
const openUrl = bundledUrl ?? `http://127.0.0.1:${port}/`;
|
|
214
|
+
printDevBanner(bannerBase);
|
|
215
|
+
maybeOpenBrowser(openUrl);
|
|
204
216
|
scanner.on("exit", (code) => process.exit(code ?? 0));
|
|
205
217
|
return;
|
|
206
218
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { copyFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {{ targetDir?: string }} opts
|
|
9
|
+
*/
|
|
10
|
+
export function runInitMode(opts = {}) {
|
|
11
|
+
const targetDir = resolve(opts.targetDir ?? process.cwd());
|
|
12
|
+
const registryDir = join(targetDir, "src", "playground");
|
|
13
|
+
const registryPath = join(registryDir, "buildRegistry.ts");
|
|
14
|
+
const templatePath = join(
|
|
15
|
+
packageRoot,
|
|
16
|
+
"templates",
|
|
17
|
+
"playground",
|
|
18
|
+
"buildRegistry.ts",
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
if (existsSync(registryPath)) {
|
|
22
|
+
process.stderr.write(
|
|
23
|
+
`dslinter init: ${registryPath} already exists — remove it first to re-scaffold.\n`,
|
|
24
|
+
);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
mkdirSync(registryDir, { recursive: true });
|
|
29
|
+
copyFileSync(templatePath, registryPath);
|
|
30
|
+
|
|
31
|
+
const snippetPath = join(registryDir, "vite.dslinter.snippet.ts");
|
|
32
|
+
const snippetTemplate = join(
|
|
33
|
+
packageRoot,
|
|
34
|
+
"templates",
|
|
35
|
+
"vite.dslinter.snippet.ts",
|
|
36
|
+
);
|
|
37
|
+
if (!existsSync(snippetPath) && existsSync(snippetTemplate)) {
|
|
38
|
+
copyFileSync(snippetTemplate, snippetPath);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const appHintPath = join(registryDir, "README.txt");
|
|
42
|
+
writeFileSync(
|
|
43
|
+
appHintPath,
|
|
44
|
+
[
|
|
45
|
+
"Wire live component previews in your App:",
|
|
46
|
+
"",
|
|
47
|
+
" import { useMemo } from 'react';",
|
|
48
|
+
" import { DashboardLayout, useWorkspaceReport } from 'dslinter';",
|
|
49
|
+
" import { buildPlaygroundEntries } from './playground/buildRegistry';",
|
|
50
|
+
"",
|
|
51
|
+
" const dslinterReport = useWorkspaceReport({ reportUrl: '/dslint-report.json', watchUrl: '/events' });",
|
|
52
|
+
" const playgroundEntries = useMemo(() => buildPlaygroundEntries(dslinterReport.report), [dslinterReport.report]);",
|
|
53
|
+
"",
|
|
54
|
+
" <DashboardLayout playgroundEntries={playgroundEntries} dslinterReport={dslinterReport} ... />",
|
|
55
|
+
"",
|
|
56
|
+
"Run the scanner from the repo root: npx dslinter .",
|
|
57
|
+
"",
|
|
58
|
+
].join("\n"),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
process.stdout.write(
|
|
62
|
+
[
|
|
63
|
+
"dslinter init: wrote playground registry",
|
|
64
|
+
` ${registryPath}`,
|
|
65
|
+
"",
|
|
66
|
+
"Next:",
|
|
67
|
+
" 1. Import buildPlaygroundEntries in your App (see src/playground/README.txt)",
|
|
68
|
+
" 2. Merge vite.dslinter.snippet.ts into vite.config.ts (proxy + react dedupe)",
|
|
69
|
+
" 3. Run npx dslinter . from the project root",
|
|
70
|
+
"",
|
|
71
|
+
].join("\n"),
|
|
72
|
+
);
|
|
73
|
+
}
|