@dbt-tools/web 0.4.0 → 0.4.1
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/README.md +36 -0
- package/dist-serve/server/cli.js +121 -27
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -114,6 +114,8 @@ For building the **nginx static image** from the monorepo, GHCR tags, and limita
|
|
|
114
114
|
| Expected “hot reload” after `dbt run` | The **npm** server re-reads files when the app fetches them; refresh the browser. **File watch + auto-reload** is a **Vite dev** feature — see the [user guide](../../../docs/user-guide-dbt-tools-web.md). |
|
|
115
115
|
| Slow UI on huge projects | Prefer the latest version; very large graphs still benefit from narrowing scope in the UI. |
|
|
116
116
|
|
|
117
|
+
If **`npx`** against a local **`.tgz`** fails with **`Permission denied`**, use `npx -y ./name.tgz -- --help` from the directory that contains the file, or `npx -y --package=/abs/path/name.tgz -- dbt-tools-web …`. See **Verify publish locally** under [Developing from source](#developing-from-source).
|
|
118
|
+
|
|
117
119
|
More rows and fixes: [user guide — Troubleshooting](../../../docs/user-guide-dbt-tools-web.md#troubleshooting).
|
|
118
120
|
|
|
119
121
|
---
|
|
@@ -152,6 +154,40 @@ DBT_TOOLS_TARGET_DIR=./target pnpm dev
|
|
|
152
154
|
# or: pnpm dev:target
|
|
153
155
|
```
|
|
154
156
|
|
|
157
|
+
### Verify publish locally (tarball + `npx`)
|
|
158
|
+
|
|
159
|
+
To smoke-test the published **`dbt-tools-web`** entrypoint and tarball layout **without publishing to the public npm registry**:
|
|
160
|
+
|
|
161
|
+
- **Recommended (matches CI):** from the **monorepo root** after `pnpm install`, run Verdaccio, publish `dbt-artifacts-parser` → `@dbt-tools/core` → `@dbt-tools/web`, pack, then `npx` with `NPM_CONFIG_REGISTRY` pointing at that registry:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
bash scripts/smoke-npx-with-verdaccio.sh
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
This avoids **`No matching version found for @dbt-tools/core@…`** when those versions are not yet on npm (packed tarballs list concrete semver peers).
|
|
168
|
+
|
|
169
|
+
- **Manual pack only** (only reliable if peer versions already exist on the registry `npx` uses, or you set `NPM_CONFIG_REGISTRY` accordingly):
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
pnpm --filter @dbt-tools/web pack
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`prepack` runs the full web build and writes **`dbt-tools-web-<version>.tgz` at the repo root** (the file is gitignored).
|
|
176
|
+
|
|
177
|
+
- **Empty directory** so `npx` does not see the monorepo’s `node_modules`:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
cd "$(mktemp -d)"
|
|
181
|
+
# After copying the .tgz into this directory (adjust version to match package.json):
|
|
182
|
+
npx -y ./dbt-tools-web-0.4.1.tgz -- --help
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
If you pass a **bare absolute path** to the tarball, some `npx` versions try to execute it as a shell script and fail (`Permission denied`). Prefer either a **relative** `./…tgz` path or an explicit package spec:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
npx -y --package=/absolute/path/to/dbt-tools-web-0.4.1.tgz -- dbt-tools-web --help
|
|
189
|
+
```
|
|
190
|
+
|
|
155
191
|
### Project layout (abridged)
|
|
156
192
|
|
|
157
193
|
```text
|
package/dist-serve/server/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import http from "node:http";
|
|
5
5
|
import path from "node:path";
|
|
@@ -478,7 +478,8 @@ function startServer(port) {
|
|
|
478
478
|
});
|
|
479
479
|
}
|
|
480
480
|
//#endregion
|
|
481
|
-
//#region src/server/cli.ts
|
|
481
|
+
//#region src/server/cli-args.ts
|
|
482
|
+
/** Pure CLI argument parsing for `dbt-tools-web` (testable without starting the server). */
|
|
482
483
|
var USAGE = `
|
|
483
484
|
Usage: dbt-tools-web [options]
|
|
484
485
|
|
|
@@ -487,42 +488,135 @@ Usage: dbt-tools-web [options]
|
|
|
487
488
|
--no-open Do not open the browser automatically
|
|
488
489
|
--help Show this help message
|
|
489
490
|
`.trimStart();
|
|
490
|
-
function
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
491
|
+
function readRequiredValue(argv, i, flagDesc) {
|
|
492
|
+
const next = argv[i + 1];
|
|
493
|
+
if (!next || next.startsWith("-")) return {
|
|
494
|
+
ok: false,
|
|
495
|
+
message: `Missing value for ${flagDesc}`
|
|
496
|
+
};
|
|
497
|
+
return {
|
|
498
|
+
ok: true,
|
|
499
|
+
value: next,
|
|
500
|
+
nextIndex: i + 1
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
function parsePortString(s) {
|
|
504
|
+
const parsed = Number.parseInt(s, 10);
|
|
505
|
+
if (Number.isNaN(parsed) || parsed < 1 || parsed > 65535) return null;
|
|
506
|
+
return parsed;
|
|
507
|
+
}
|
|
508
|
+
function consumeOne(argv, i, state) {
|
|
509
|
+
const arg = argv[i];
|
|
510
|
+
if (arg === "--help" || arg === "-h") return {
|
|
511
|
+
status: "done",
|
|
512
|
+
result: { kind: "help" }
|
|
513
|
+
};
|
|
514
|
+
if (arg === "--no-open") {
|
|
515
|
+
state.open = false;
|
|
516
|
+
return {
|
|
517
|
+
status: "advance",
|
|
518
|
+
nextIndex: i + 1
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
if (arg === "--target" || arg === "-t") {
|
|
522
|
+
const r = readRequiredValue(argv, i, "--target (or -t)");
|
|
523
|
+
if (!r.ok) return {
|
|
524
|
+
status: "done",
|
|
525
|
+
result: {
|
|
526
|
+
kind: "error",
|
|
527
|
+
message: r.message
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
state.targetDir = r.value;
|
|
531
|
+
return {
|
|
532
|
+
status: "advance",
|
|
533
|
+
nextIndex: r.nextIndex + 1
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
if (arg === "--port" || arg === "-p") {
|
|
537
|
+
const r = readRequiredValue(argv, i, "--port (or -p)");
|
|
538
|
+
if (!r.ok) return {
|
|
539
|
+
status: "done",
|
|
540
|
+
result: {
|
|
541
|
+
kind: "error",
|
|
542
|
+
message: r.message
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
const p = parsePortString(r.value);
|
|
546
|
+
if (p === null) return {
|
|
547
|
+
status: "done",
|
|
548
|
+
result: {
|
|
549
|
+
kind: "error",
|
|
550
|
+
message: `Invalid port: ${r.value}`
|
|
506
551
|
}
|
|
507
|
-
|
|
552
|
+
};
|
|
553
|
+
state.port = p;
|
|
554
|
+
return {
|
|
555
|
+
status: "advance",
|
|
556
|
+
nextIndex: r.nextIndex + 1
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
if (arg.startsWith("-")) return {
|
|
560
|
+
status: "done",
|
|
561
|
+
result: {
|
|
562
|
+
kind: "error",
|
|
563
|
+
message: `Unknown option: ${arg}`
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
return {
|
|
567
|
+
status: "done",
|
|
568
|
+
result: {
|
|
569
|
+
kind: "error",
|
|
570
|
+
message: `Unexpected argument: ${arg}`
|
|
508
571
|
}
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function parseCliArgs(argv) {
|
|
575
|
+
const state = {
|
|
576
|
+
targetDir: void 0,
|
|
577
|
+
port: 3e3,
|
|
578
|
+
open: true
|
|
579
|
+
};
|
|
580
|
+
let i = 0;
|
|
581
|
+
while (i < argv.length) {
|
|
582
|
+
const step = consumeOne(argv, i, state);
|
|
583
|
+
if (step.status === "done") return step.result;
|
|
584
|
+
i = step.nextIndex;
|
|
509
585
|
}
|
|
510
586
|
return {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
587
|
+
kind: "ok",
|
|
588
|
+
targetDir: state.targetDir,
|
|
589
|
+
port: state.port,
|
|
590
|
+
open: state.open
|
|
514
591
|
};
|
|
515
592
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
593
|
+
//#endregion
|
|
594
|
+
//#region src/server/cli.ts
|
|
595
|
+
var parsed = parseCliArgs(process.argv.slice(2));
|
|
596
|
+
if (parsed.kind === "help") {
|
|
597
|
+
process.stdout.write(USAGE);
|
|
598
|
+
process.exit(0);
|
|
520
599
|
}
|
|
521
|
-
|
|
600
|
+
if (parsed.kind === "error") {
|
|
601
|
+
process.stderr.write(`${parsed.message}\n`);
|
|
602
|
+
process.exit(1);
|
|
603
|
+
}
|
|
604
|
+
var { targetDir, port, open } = parsed;
|
|
522
605
|
if (targetDir !== void 0) process.env.DBT_TOOLS_TARGET_DIR = targetDir;
|
|
523
606
|
await startServer(port);
|
|
524
607
|
var url = `http://${LISTEN_HOST}:${port}`;
|
|
525
608
|
process.stdout.write(`dbt-tools-web ${url}\n`);
|
|
609
|
+
function openBrowser(safeUrl) {
|
|
610
|
+
const cb = () => {};
|
|
611
|
+
if (process.platform === "darwin") execFile("open", [safeUrl], cb);
|
|
612
|
+
else if (process.platform === "win32") execFile("cmd.exe", [
|
|
613
|
+
"/c",
|
|
614
|
+
"start",
|
|
615
|
+
"",
|
|
616
|
+
safeUrl
|
|
617
|
+
], { windowsHide: true }, cb);
|
|
618
|
+
else execFile("xdg-open", [safeUrl], cb);
|
|
619
|
+
}
|
|
526
620
|
if (open) openBrowser(url);
|
|
527
621
|
//#endregion
|
|
528
622
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dbt-tools/web",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Web application for visual dbt artifact analysis",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dbt",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"react-dom": "^19.2.4",
|
|
30
30
|
"react-markdown": "^10.1.0",
|
|
31
31
|
"remark-gfm": "^4.0.1",
|
|
32
|
-
"@dbt-tools/core": "0.4.
|
|
33
|
-
"dbt-artifacts-parser": "0.4.
|
|
32
|
+
"@dbt-tools/core": "0.4.1",
|
|
33
|
+
"dbt-artifacts-parser": "0.4.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@playwright/test": "^1.58.2",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"lint": "pnpm lint:eslint && pnpm lint:stylelint",
|
|
56
56
|
"lint:eslint": "eslint ../../../eslint.config.mjs",
|
|
57
57
|
"lint:stylelint": "stylelint -c ../../../stylelint.config.mjs **/*.css",
|
|
58
|
-
"format:stylelint": "stylelint -c ../../../stylelint.config.mjs **/*.css --fix"
|
|
58
|
+
"format:stylelint": "stylelint -c ../../../stylelint.config.mjs **/*.css --fix",
|
|
59
|
+
"smoke:npx-tgz": "bash scripts/smoke-npx-packed-tarball.sh"
|
|
59
60
|
}
|
|
60
61
|
}
|