dslinter 0.1.2 → 0.1.3
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 +1 -1
- package/bin/dslinter.mjs +1 -1
- package/bin/modes/init.mjs +34 -6
- package/dashboard-dist/assets/{index-BN-Qjczl.js → index-DGUG_3SK.js} +23 -23
- package/dashboard-dist/index.html +1 -1
- package/index.cjs +52 -52
- package/package.json +6 -6
- package/src/components/ComponentInspectPane.tsx +24 -8
- package/src/index.ts +1 -0
- package/src/playground/buildPlaygroundEntriesFromReport.ts +1 -0
- package/src/playground/createPlaygroundRegistry.ts +16 -3
- package/src/playground/playgroundJoin.test.ts +8 -0
- package/src/playground/playgroundJoin.ts +33 -4
- package/templates/playground/buildRegistry.laravel.ts +26 -0
- package/templates/vite.dslint-scan-alias.snippet.ts +21 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ Set `DSLINT_SERVE_PORT` to override the default scanner port (`7878`). Your Vite
|
|
|
76
76
|
|
|
77
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
78
|
|
|
79
|
-
1. **Scaffold** (optional): `npx dslinter init` →
|
|
79
|
+
1. **Scaffold** (optional): `npx dslinter init` → `src/playground/buildRegistry.ts`; for Inertia/Laravel (`resources/js/…`) use `npx dslinter init --laravel`
|
|
80
80
|
2. **Glob** must cover nested paths, e.g. `import.meta.glob("../components/**/*.{tsx,jsx}", { eager: true })`
|
|
81
81
|
3. **App**: pass `playgroundEntries` and `playgroundJoinSkips` from the registry into `DashboardLayout`
|
|
82
82
|
|
package/bin/dslinter.mjs
CHANGED
package/bin/modes/init.mjs
CHANGED
|
@@ -5,17 +5,38 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), "../..");
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {string} targetDir
|
|
9
|
+
* @returns {"laravel" | "default"}
|
|
10
|
+
*/
|
|
11
|
+
function detectInitLayout(targetDir) {
|
|
12
|
+
if (existsSync(join(targetDir, "resources", "js"))) return "laravel";
|
|
13
|
+
return "default";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {{ targetDir?: string; layout?: "laravel" | "default"; argv?: string[] }} opts
|
|
9
18
|
*/
|
|
10
19
|
export function runInitMode(opts = {}) {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
20
|
+
const argv = opts.argv ?? [];
|
|
21
|
+
const forceLaravel = argv.includes("--laravel") || argv.includes("--resources-js");
|
|
22
|
+
const targetDir = resolve(
|
|
23
|
+
opts.targetDir ?? argv.find((a) => !a.startsWith("-")) ?? process.cwd(),
|
|
24
|
+
);
|
|
25
|
+
const layout =
|
|
26
|
+
opts.layout ?? (forceLaravel ? "laravel" : detectInitLayout(targetDir));
|
|
27
|
+
|
|
28
|
+
const registryDir =
|
|
29
|
+
layout === "laravel"
|
|
30
|
+
? join(targetDir, "resources", "js", "playground")
|
|
31
|
+
: join(targetDir, "src", "playground");
|
|
13
32
|
const registryPath = join(registryDir, "buildRegistry.ts");
|
|
33
|
+
const templateName =
|
|
34
|
+
layout === "laravel" ? "buildRegistry.laravel.ts" : "buildRegistry.ts";
|
|
14
35
|
const templatePath = join(
|
|
15
36
|
packageRoot,
|
|
16
37
|
"templates",
|
|
17
38
|
"playground",
|
|
18
|
-
|
|
39
|
+
templateName,
|
|
19
40
|
);
|
|
20
41
|
|
|
21
42
|
if (existsSync(registryPath)) {
|
|
@@ -46,7 +67,9 @@ export function runInitMode(opts = {}) {
|
|
|
46
67
|
"",
|
|
47
68
|
" import { useMemo } from 'react';",
|
|
48
69
|
" import { DashboardLayout, useWorkspaceReport } from 'dslinter';",
|
|
49
|
-
|
|
70
|
+
layout === "laravel"
|
|
71
|
+
? " import { buildPlaygroundEntries } from '@/playground/buildRegistry';"
|
|
72
|
+
: " import { buildPlaygroundEntries } from './playground/buildRegistry';",
|
|
50
73
|
"",
|
|
51
74
|
" const dslinterReport = useWorkspaceReport({ reportUrl: '/dslint-report.json', watchUrl: '/events' });",
|
|
52
75
|
" const playgroundEntries = useMemo(() => buildPlaygroundEntries(dslinterReport.report), [dslinterReport.report]);",
|
|
@@ -63,9 +86,14 @@ export function runInitMode(opts = {}) {
|
|
|
63
86
|
"dslinter init: wrote playground registry",
|
|
64
87
|
` ${registryPath}`,
|
|
65
88
|
"",
|
|
89
|
+
`Layout: ${layout}`,
|
|
90
|
+
"",
|
|
66
91
|
"Next:",
|
|
67
|
-
|
|
92
|
+
` 1. Import buildPlaygroundEntries in your App (see ${registryDir}/README.txt)`,
|
|
68
93
|
" 2. Merge vite.dslinter.snippet.ts into vite.config.ts (proxy + react dedupe)",
|
|
94
|
+
layout === "laravel"
|
|
95
|
+
? " (Inertia: glob uses resources/js/** — not @dslint-scan unless you add the alias snippet)"
|
|
96
|
+
: "",
|
|
69
97
|
" 3. Run npx dslinter . from the project root",
|
|
70
98
|
"",
|
|
71
99
|
].join("\n"),
|