dslinter 0.1.1 → 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 +4 -0
- package/README.md +43 -0
- package/bin/dslinter.mjs +6 -0
- package/bin/modes/init.mjs +73 -0
- package/dashboard-dist/assets/index-BN-Qjczl.js +205 -0
- package/dashboard-dist/index.html +1 -1
- package/index.cjs +52 -52
- package/package.json +7 -6
- package/src/components/ComponentInspectPane.tsx +20 -0
- package/src/index.ts +21 -1
- package/src/playground/buildPlaygroundEntriesFromReport.ts +46 -6
- package/src/playground/createPlaygroundRegistry.ts +48 -0
- package/src/playground/playgroundJoin.test.ts +74 -0
- package/src/playground/playgroundJoin.ts +116 -0
- package/src/shell/DashboardLayout.tsx +11 -0
- package/templates/playground/buildRegistry.ts +26 -0
- package/templates/vite.dslinter.snippet.ts +28 -0
- package/dashboard-dist/assets/index-B6zsYv3h.js +0 -206
package/CHANGELOG.md
CHANGED
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
|
}
|
|
@@ -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
|
+
}
|