@rivetjs/nx 0.1.0-alpha.1 → 0.1.0-alpha.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/README.md CHANGED
@@ -47,6 +47,8 @@ All generators write through the Nx tree: `--dry-run` shows the files without wr
47
47
  | `@rivetjs/nx:typecheck` | `rivet sync` + `tsc --noEmit`. |
48
48
  | `@rivetjs/nx:package` | Publishable library: `.js` / `.jsx` (JSX preserved) + `.d.ts`, mapped `package.json`. |
49
49
 
50
+ The `check` executor also accepts `format: "json"`, `quiet: true` and `verbose: true`. JSON mode hides successful sync output and executor headings; Nx can still add its own task summary. Use `rivet-check --json` directly for a pipe consumed by a JSON parser. Step headings, durations and failure hints use stderr.
51
+
50
52
  ## Inferred targets
51
53
 
52
54
  ```json
@@ -7,8 +7,17 @@ export function syncStep(root, bin) {
7
7
  export function checkSteps(options, root, facts, bin) {
8
8
  const routed = facts?.kind === "app";
9
9
  const steps = [];
10
- if (options.sync ?? routed)
11
- steps.push(syncStep(root, bin));
10
+ if (options.sync ?? routed) {
11
+ const step = syncStep(root, bin);
12
+ if (options.format === "json")
13
+ step.args.push("--json", "--quiet");
14
+ else if (options.quiet)
15
+ step.args.push("--quiet");
16
+ // Capture successful sync JSON so stdout contains only the check result.
17
+ if (options.format === "json")
18
+ step.quietSuccess = true;
19
+ steps.push(step);
20
+ }
12
21
  const configs = options.tsConfig === undefined ? ["tsconfig.json"] : Array.isArray(options.tsConfig) ? options.tsConfig : [options.tsConfig];
13
22
  steps.push({
14
23
  label: "rivet-check",
@@ -19,6 +28,8 @@ export function checkSteps(options, root, facts, bin) {
19
28
  ["--no-types", options.types === false],
20
29
  ["--no-manifest", !(options.manifest ?? routed)],
21
30
  ["--format", options.format],
31
+ ["--quiet", options.quiet],
32
+ ["--verbose", options.verbose],
22
33
  ]),
23
34
  ],
24
35
  cwd: root,
@@ -27,5 +38,5 @@ export function checkSteps(options, root, facts, bin) {
27
38
  }
28
39
  export default async function checkExecutor(options, context) {
29
40
  const root = projectRoot(context);
30
- return runSteps(checkSteps(options, root, projectFacts(root), resolverFrom(root)));
41
+ return runSteps(checkSteps(options, root, projectFacts(root), resolverFrom(root)), { verbose: !options.quiet && options.format !== "json" });
31
42
  }
@@ -1,12 +1,16 @@
1
1
  export interface CheckExecutorSchema {
2
2
  /** tsconfig file(s) to check, relative to the project. Default `tsconfig.json`. */
3
3
  tsConfig?: string | string[];
4
- /** Type-aware checks (RV2101 serializability, RV3101 route links). Default true. */
4
+ /** Type-aware checks (RV3101 route links). Default true. */
5
5
  types?: boolean;
6
6
  /** Check `.rivet/editor.json` (RV7101 / RV7102). Default: routed apps only. */
7
7
  manifest?: boolean;
8
8
  /** Run `rivet sync` first (regenerates `.rivet/`). Default: routed apps only. */
9
9
  sync?: boolean;
10
10
  /** Output format. */
11
+ /** Errors only. */
12
+ quiet?: boolean;
13
+ /** Include error stacks. */
14
+ verbose?: boolean;
11
15
  format?: "text" | "json";
12
16
  }
@@ -6,13 +6,45 @@
6
6
  "type": "object",
7
7
  "properties": {
8
8
  "tsConfig": {
9
- "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }],
9
+ "oneOf": [
10
+ {
11
+ "type": "string"
12
+ },
13
+ {
14
+ "type": "array",
15
+ "items": {
16
+ "type": "string"
17
+ }
18
+ }
19
+ ],
10
20
  "description": "tsconfig file(s) to check, relative to the project. Default tsconfig.json."
11
21
  },
12
- "types": { "type": "boolean", "default": true, "description": "Type-aware checks (RV2101 serializability, RV3101 route links)." },
13
- "manifest": { "type": "boolean", "description": "Check .rivet/editor.json (RV7101 / RV7102). Default: routed apps only." },
14
- "sync": { "type": "boolean", "description": "Run rivet sync first. Default: routed apps only." },
15
- "format": { "type": "string", "enum": ["text", "json"], "description": "Output format." }
22
+ "types": {
23
+ "type": "boolean",
24
+ "default": true,
25
+ "description": "Type-aware checks (RV3101 route links)."
26
+ },
27
+ "manifest": {
28
+ "type": "boolean",
29
+ "description": "Check .rivet/editor.json (RV7101 / RV7102). Default: routed apps only."
30
+ },
31
+ "sync": {
32
+ "type": "boolean",
33
+ "description": "Run rivet sync first. Default: routed apps only."
34
+ },
35
+ "format": {
36
+ "type": "string",
37
+ "enum": ["text", "json"],
38
+ "description": "Output format."
39
+ },
40
+ "quiet": {
41
+ "type": "boolean",
42
+ "description": "Errors only; suppress warnings, progress and summaries."
43
+ },
44
+ "verbose": {
45
+ "type": "boolean",
46
+ "description": "Include error stacks from rivet-check (also DEBUG=rivet)."
47
+ }
16
48
  },
17
49
  "additionalProperties": false
18
50
  }
@@ -4,6 +4,8 @@ import type { ExecutorContext } from "@nx/devkit";
4
4
  export interface Step {
5
5
  /** Shown before the step runs. */
6
6
  label: string;
7
+ /** Buffer stdout and replay it only on failure (JSON prerequisite steps). */
8
+ quietSuccess?: boolean;
7
9
  /** Arguments after the Node binary (`[bin, …args]` or `["--input-type=module", "-e", code]`). */
8
10
  args: string[];
9
11
  cwd: string;
package/executors/run.js CHANGED
@@ -62,14 +62,25 @@ function hookSignals() {
62
62
  /** Starts a step; `exit` resolves with its status (signals count as failure). */
63
63
  export function start(step) {
64
64
  hookSignals();
65
- const child = spawn(process.execPath, step.args, { cwd: step.cwd, env: { ...process.env, ...step.env }, stdio: "inherit" });
65
+ const child = spawn(process.execPath, step.args, {
66
+ cwd: step.cwd,
67
+ env: { ...process.env, ...step.env },
68
+ stdio: step.quietSuccess ? ["inherit", "pipe", "inherit"] : "inherit",
69
+ });
66
70
  children.add(child);
71
+ const output = [];
72
+ if (step.quietSuccess)
73
+ child.stdout?.on("data", (chunk) => output.push(chunk));
67
74
  const exit = new Promise((done) => {
68
75
  child.on("error", (error) => {
69
- console.error(error);
76
+ children.delete(child);
77
+ console.error(`[rivet:nx] error: ${step.label} could not start in ${step.cwd}: ${error.message}\n fix: Check the working directory and tool installation.${process.env.DEBUG === "rivet" ? "\n" + error.stack : ""}`);
70
78
  done(1);
71
79
  });
72
- child.on("exit", (code) => {
80
+ child.on("close", (code) => {
81
+ if (step.quietSuccess && code !== 0)
82
+ for (const chunk of output)
83
+ process.stdout.write(chunk);
73
84
  children.delete(child);
74
85
  done(code ?? 1);
75
86
  });
@@ -79,10 +90,17 @@ export function start(step) {
79
90
  /** Runs steps in order; stops at the first failure. */
80
91
  export async function runSteps(steps, { verbose = true } = {}) {
81
92
  for (const step of steps) {
93
+ const started = performance.now();
82
94
  if (verbose)
83
- console.log(`> ${step.label}`);
84
- if ((await start(step).exit) !== 0)
95
+ console.error(`[rivet:nx] ${step.label} (${step.cwd})`);
96
+ const status = await start(step).exit;
97
+ if (status !== 0) {
98
+ if (verbose)
99
+ console.error(`[rivet:nx] error: ${step.label} exited ${status}. Fix the diagnostic above and rerun the target.`);
85
100
  return { success: false };
101
+ }
102
+ if (verbose)
103
+ console.error(`[rivet:nx] ${step.label} finished in ${((performance.now() - started) / 1000).toFixed(1)} s`);
86
104
  }
87
105
  return { success: true };
88
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivetjs/nx",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0-alpha.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Nx plugin for Rivet: generators, executors and inferred tasks for Rivet apps and libraries.",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@nx/devkit": "23.2.1",
41
- "create-rivet": "0.1.0-alpha.1"
41
+ "create-rivet": "0.1.0-alpha.2"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "nx": ">=23 <24"