dslinter 0.1.2 β†’ 0.1.4

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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.1.4
4
+
5
+ [compare changes](https://github.com/jrmybtlr/DSLinter/compare/v0.1.3...v0.1.4)
6
+
7
+ ## Unreleased
8
+
9
+ ### 🩹 Fixes
10
+
11
+ - Remove `@/` path aliases from published `src/` so host apps with their own `@/*` Vite alias (Laravel/Inertia, etc.) no longer resolve dslinter UI imports to the wrong tree. Consumers need only the official vite snippet (proxy, react dedupe, `optimizeDeps.exclude`).
12
+
13
+ ## v0.1.3
14
+
15
+ [compare changes](https://github.com/jrmybtlr/DSLinter/compare/v0.1.2...v0.1.3)
16
+
3
17
  ## v0.1.2
4
18
 
5
19
  [compare changes](https://github.com/jrmybtlr/DSLinter/compare/v0.1.1...v0.1.2)
package/README.md CHANGED
@@ -55,7 +55,19 @@ npx dslinter --report --output public/dslint-report.json
55
55
  npx dslinter --watch --output public/dslint-report.json
56
56
  ```
57
57
 
58
- Set `DSLINT_SERVE_PORT` to override the default scanner port (`7878`). Your Vite config should proxy `/dslint-report.json` and `/events` to that port in `serve` mode (see repo `demo/vite.config.ts`).
58
+ Set `DSLINT_SERVE_PORT` to override the default scanner port (`7878`). Your Vite config should proxy `/dslint-report.json` and `/events` to that port in `serve` mode. Merge `templates/vite.dslinter.snippet.ts` (copied by `npx dslinter init`) or see repo `demo/vite.config.ts` for a linked-workspace example.
59
+
60
+ ### Consumer Vite (Laravel, Inertia, existing `@/*` aliases)
61
+
62
+ Published `dslinter` source uses **relative imports only** β€” no `@/components/...` paths inside `node_modules/dslinter/src`. Your app's `@/*` alias (for example Laravel `@/*` β†’ `resources/js/*`) will not hijack dslinter's internal UI imports.
63
+
64
+ After `npx dslinter init --laravel`, merge only the official snippet into `vite.config.ts`:
65
+
66
+ - `resolve.dedupe`: `["react", "react-dom"]`
67
+ - `optimizeDeps.exclude`: `["dslinter"]` (source-first package; transpile from `node_modules`)
68
+ - `server.proxy` for `/dslint-report.json` and `/events` β†’ `DSLINT_SERVE_PORT`
69
+
70
+ You do **not** need alias overrides such as `@/components` β†’ `node_modules/dslinter/src/components`.
59
71
 
60
72
  ## Styles (Tailwind v4)
61
73
 
@@ -76,7 +88,7 @@ Set `DSLINT_SERVE_PORT` to override the default scanner port (`7878`). Your Vite
76
88
 
77
89
  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
90
 
79
- 1. **Scaffold** (optional): `npx dslinter init` β†’ writes `src/playground/buildRegistry.ts`
91
+ 1. **Scaffold** (optional): `npx dslinter init` β†’ `src/playground/buildRegistry.ts`; for Inertia/Laravel (`resources/js/…`) use `npx dslinter init --laravel`
80
92
  2. **Glob** must cover nested paths, e.g. `import.meta.glob("../components/**/*.{tsx,jsx}", { eager: true })`
81
93
  3. **App**: pass `playgroundEntries` and `playgroundJoinSkips` from the registry into `DashboardLayout`
82
94
 
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'; // adjust relative path from your entry file"
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)",
68
- " 2. Merge vite.dslinter.snippet.ts into vite.config.ts (proxy + react dedupe)",
92
+ ` 1. Import buildPlaygroundEntries in your App (see ${registryDir}/README.txt)`,
93
+ " 2. Merge vite.dslinter.snippet.ts into vite.config.ts (proxy, react dedupe, optimizeDeps.exclude)",
94
+ layout === "laravel"
95
+ ? " No extra @ alias remapping is required β€” dslinter UI uses relative imports."
96
+ : " No @ alias overrides needed for dslinter internal UI.",
69
97
  " 3. Run npx dslinter . from the project root",
70
98
  "",
71
99
  ].join("\n"),