nx-lifecycle 1.0.0 → 1.1.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.
Files changed (60) hide show
  1. package/README.md +42 -4
  2. package/WHY-NX-LIFECYCLE.md +1 -1
  3. package/dist/bin.d.ts +0 -603
  4. package/dist/bin.js +3 -13
  5. package/dist/cli.d.ts +8 -6
  6. package/dist/cli.js +17 -20
  7. package/dist/commands/explain-command.d.ts +13 -0
  8. package/dist/commands/explain-command.js +60 -0
  9. package/dist/commands/lib/types.d.ts +14 -4
  10. package/dist/commands/lib/types.js +2 -1
  11. package/dist/commands/lifecycle-command.d.ts +2 -11
  12. package/dist/commands/lifecycle-command.js +16 -22
  13. package/dist/container.d.ts +3 -0
  14. package/dist/container.js +8 -0
  15. package/dist/executors/lifecycle/index.d.ts +1 -4
  16. package/dist/executors/lifecycle/index.js +1 -4
  17. package/dist/executors/lifecycle/lifecycle.d.ts +8 -9
  18. package/dist/executors/lifecycle/lifecycle.js +13 -20
  19. package/dist/lifecycle/explain.d.ts +68 -0
  20. package/dist/lifecycle/explain.js +157 -0
  21. package/dist/lifecycle/lifecycle-internal.d.ts +4 -12
  22. package/dist/lifecycle/lifecycle-internal.js +92 -109
  23. package/dist/lifecycle/normalizer.d.ts +13 -7
  24. package/dist/lifecycle/normalizer.js +29 -36
  25. package/dist/lifecycle/processor.d.ts +1 -3
  26. package/dist/lifecycle/processor.js +22 -14
  27. package/dist/lifecycle/schema.d.ts +244 -714
  28. package/dist/lifecycle/schema.js +3 -2
  29. package/dist/plugin/index.d.ts +1 -277
  30. package/dist/plugin/index.js +1 -3
  31. package/dist/plugin/lifecycle-plugin.d.ts +18 -15
  32. package/dist/plugin/lifecycle-plugin.js +90 -106
  33. package/dist/plugin/schema.d.ts +33 -343
  34. package/dist/plugin/schema.js +0 -2
  35. package/dist/schemas/configurations.d.ts +5 -6
  36. package/dist/schemas/depend-on.d.ts +38 -74
  37. package/dist/schemas/depend-on.js +5 -4
  38. package/dist/schemas/nx-json.d.ts +38 -223
  39. package/dist/schemas/nx-json.js +0 -2
  40. package/dist/schemas/project-json.d.ts +38 -223
  41. package/dist/schemas/project-json.js +0 -2
  42. package/dist/schemas/target.d.ts +72 -140
  43. package/out/nx-executor/schema.json +2 -2
  44. package/out/schema.json +1 -1
  45. package/package.json +29 -14
  46. package/.npmignore +0 -20
  47. package/dist/commands/index.d.ts +0 -755
  48. package/dist/commands/index.js +0 -14
  49. package/dist/commands/lib/dependencies.d.ts +0 -10
  50. package/dist/commands/lib/dependencies.js +0 -12
  51. package/dist/executors/lifecycle/container.d.ts +0 -603
  52. package/dist/executors/lifecycle/container.js +0 -8
  53. package/dist/lifecycle/dependencies.d.ts +0 -16
  54. package/dist/lifecycle/dependencies.js +0 -14
  55. package/dist/lifecycle/index.d.ts +0 -756
  56. package/dist/lifecycle/index.js +0 -25
  57. package/dist/plugin/container.d.ts +0 -855
  58. package/dist/plugin/container.js +0 -13
  59. package/dist/plugin/dependencies.d.ts +0 -860
  60. package/dist/plugin/dependencies.js +0 -9
package/README.md CHANGED
@@ -1,13 +1,23 @@
1
1
  <div style="text-align:center">
2
2
 
3
3
  # nx-lifecycle
4
- An [Nx](https://nx.dev/) plugin that injects specific targets into high level workflows.
4
+ [Nx](https://nx.dev/) plugin that derives every `dependsOn` from declared lifecycle stages (build, test, …) and the targets bound to them.
5
5
 
6
6
  [![npm package](https://badge.fury.io/js/nx-lifecycle.svg)](https://www.npmjs.com/package/nx-lifecycle)
7
- [![License](https://img.shields.io/npm/l/nx-lifecycle.svg)](https://github.com/JacobLey/leyman/blob/main/tools/nx-lifecycle/LICENSE)
7
+ [![License](https://img.shields.io/npm/l/nx-lifecycle.svg)](https://github.com/JacobLey/leyman/blob/main/apps/nx-lifecycle/LICENSE)
8
8
 
9
9
  </div>
10
10
 
11
+ Declare your workflow once — `build` runs hooks `pre` → `run` → `post`, `test` runs after `build` — then bind tools to hooks (`tsc` → `build:run`, `mocha` → `test:run`). Then `nx run <project>:build` runs the right steps, in the right order, in any project.
12
+
13
+ - **Add a step in one place** — binding a new target (codegen, lint, a post-build step) rewires every dependent automatically, across every project.
14
+ - **Per-project implementations** — each project opts into the bound targets it declares, so TypeScript, Go and Java projects can all answer to the same `build` and `test`.
15
+ - **Nothing to commit** — the plugin infers targets when Nx builds the project graph, and fails with the fix if a project's `dependsOn` breaks the wiring. An executor that writes the config to files is also available.
16
+
17
+ **Compared to** hand-written `dependsOn` in `targetDefaults` and each `project.json`: there, adding a step between two existing ones means editing every target that depended on the first, in every project that has it.
18
+
19
+ For the problem this solves and design rationale, see [WHY-NX-LIFECYCLE.md](https://github.com/JacobLey/leyman/blob/main/apps/nx-lifecycle/WHY-NX-LIFECYCLE.md).
20
+
11
21
  ## Contents
12
22
 
13
23
  - [Install](#install)
@@ -22,8 +32,7 @@ An [Nx](https://nx.dev/) plugin that injects specific targets into high level wo
22
32
  - [check](#check)
23
33
  - [dryRun](#dryrun)
24
34
  - [CLI](#cli)
25
-
26
- For the problem this solves and design rationale, see [WHY-NX-LIFECYCLE.md](./WHY-NX-LIFECYCLE.md).
35
+ - [explain](#explain)
27
36
 
28
37
  ## Install
29
38
 
@@ -330,3 +339,32 @@ pnpx nx-lifecycle --config-file ./my-lifecycle.json --dry-run
330
339
  | `--config-file` | `string` | `lifecycle.json` | Path to the lifecycle config file. |
331
340
  | `--dry-run` | `boolean` | `false` | Compute changes without writing files. |
332
341
  | `--check` | `boolean` | `true` in CI | Fail if any file is out of sync. |
342
+
343
+ ### `explain`
344
+
345
+ Prints what runs, in which order, for the stages of a project: each stage after the stages it depends on, its hooks, and the bound targets the project declares. A `^` dependency lists the upstream projects it runs.
346
+
347
+ ```sh
348
+ pnpx nx-lifecycle explain my-lib # every stage
349
+ pnpx nx-lifecycle explain my-lib test # test, and the stages it runs after
350
+ ```
351
+
352
+ ```
353
+ my-lib
354
+
355
+ 1. build
356
+ after: ^build (my-utils)
357
+ build:pre (nothing bound)
358
+ build:run
359
+ tsc
360
+
361
+ 2. test
362
+ after: build
363
+ test:run
364
+ mocha
365
+ e2e-test (also after: my-server:build)
366
+ test:report
367
+ coverage-report
368
+ ```
369
+
370
+ Stages and bindings come from the [plugin](#plugin) options in `nx.json`, or else from `--config-file` (default `lifecycle.json`). Bound targets and their other dependencies come from the project as Nx resolves it, after `targetDefaults` and `project.json`.
@@ -59,6 +59,6 @@ The `dependsOn` fields become a tangled web of implementation details rather tha
59
59
 
60
60
  3. **Wiring** — `nx-lifecycle` reads the stages and bindings, then derives every `dependsOn`: its Nx plugin infers them when Nx builds the project graph, or its executor writes them into `nx.json` and `project.json`.
61
61
 
62
- The result: adding a new step means updating one binding. Every downstream `dependsOn` is recomputed. The generated configs are checked into version control, so CI can verify they're in sync before any deployment proceeds.
62
+ The result: adding a new step means updating one binding. Every downstream `dependsOn` is recomputed. With the plugin this happens every time Nx builds the project graph, so there is nothing to keep in sync. With the executor the generated configs are committed, and CI checks they are up to date.
63
63
 
64
64
  Now you can just run `nx run <project>:build` and let the projects determine what "building" means to it.