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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.1.3
4
+
5
+ [compare changes](https://github.com/jrmybtlr/DSLinter/compare/v0.1.2...v0.1.3)
6
+
3
7
  ## v0.1.2
4
8
 
5
9
  [compare changes](https://github.com/jrmybtlr/DSLinter/compare/v0.1.1...v0.1.2)
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` → writes `src/playground/buildRegistry.ts`
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
@@ -12,7 +12,7 @@ import { runReportMode } from "./modes/report.mjs";
12
12
  const rawArgs = process.argv.slice(2);
13
13
 
14
14
  if (rawArgs[0] === "init") {
15
- runInitMode({ targetDir: rawArgs[1] });
15
+ runInitMode({ argv: rawArgs.slice(1) });
16
16
  process.exit(0);
17
17
  }
18
18
 
@@ -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 {{ targetDir?: string }} opts
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 targetDir = resolve(opts.targetDir ?? process.cwd());
12
- const registryDir = join(targetDir, "src", "playground");
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
- "buildRegistry.ts",
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
- " import { buildPlaygroundEntries } from './playground/buildRegistry';",
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
- " 1. Import buildPlaygroundEntries in your App (see src/playground/README.txt)",
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"),