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.
- package/README.md +42 -4
- package/WHY-NX-LIFECYCLE.md +1 -1
- package/dist/bin.d.ts +0 -603
- package/dist/bin.js +3 -13
- package/dist/cli.d.ts +8 -6
- package/dist/cli.js +17 -20
- package/dist/commands/explain-command.d.ts +13 -0
- package/dist/commands/explain-command.js +60 -0
- package/dist/commands/lib/types.d.ts +14 -4
- package/dist/commands/lib/types.js +2 -1
- package/dist/commands/lifecycle-command.d.ts +2 -11
- package/dist/commands/lifecycle-command.js +16 -22
- package/dist/container.d.ts +3 -0
- package/dist/container.js +8 -0
- package/dist/executors/lifecycle/index.d.ts +1 -4
- package/dist/executors/lifecycle/index.js +1 -4
- package/dist/executors/lifecycle/lifecycle.d.ts +8 -9
- package/dist/executors/lifecycle/lifecycle.js +13 -20
- package/dist/lifecycle/explain.d.ts +68 -0
- package/dist/lifecycle/explain.js +157 -0
- package/dist/lifecycle/lifecycle-internal.d.ts +4 -12
- package/dist/lifecycle/lifecycle-internal.js +92 -109
- package/dist/lifecycle/normalizer.d.ts +13 -7
- package/dist/lifecycle/normalizer.js +29 -36
- package/dist/lifecycle/processor.d.ts +1 -3
- package/dist/lifecycle/processor.js +22 -14
- package/dist/lifecycle/schema.d.ts +244 -714
- package/dist/lifecycle/schema.js +3 -2
- package/dist/plugin/index.d.ts +1 -277
- package/dist/plugin/index.js +1 -3
- package/dist/plugin/lifecycle-plugin.d.ts +18 -15
- package/dist/plugin/lifecycle-plugin.js +90 -106
- package/dist/plugin/schema.d.ts +33 -343
- package/dist/plugin/schema.js +0 -2
- package/dist/schemas/configurations.d.ts +5 -6
- package/dist/schemas/depend-on.d.ts +38 -74
- package/dist/schemas/depend-on.js +5 -4
- package/dist/schemas/nx-json.d.ts +38 -223
- package/dist/schemas/nx-json.js +0 -2
- package/dist/schemas/project-json.d.ts +38 -223
- package/dist/schemas/project-json.js +0 -2
- package/dist/schemas/target.d.ts +72 -140
- package/out/nx-executor/schema.json +2 -2
- package/out/schema.json +1 -1
- package/package.json +29 -14
- package/.npmignore +0 -20
- package/dist/commands/index.d.ts +0 -755
- package/dist/commands/index.js +0 -14
- package/dist/commands/lib/dependencies.d.ts +0 -10
- package/dist/commands/lib/dependencies.js +0 -12
- package/dist/executors/lifecycle/container.d.ts +0 -603
- package/dist/executors/lifecycle/container.js +0 -8
- package/dist/lifecycle/dependencies.d.ts +0 -16
- package/dist/lifecycle/dependencies.js +0 -14
- package/dist/lifecycle/index.d.ts +0 -756
- package/dist/lifecycle/index.js +0 -25
- package/dist/plugin/container.d.ts +0 -855
- package/dist/plugin/container.js +0 -13
- package/dist/plugin/dependencies.d.ts +0 -860
- 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
|
-
|
|
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
|
[](https://www.npmjs.com/package/nx-lifecycle)
|
|
7
|
-
[](https://github.com/JacobLey/leyman/blob/main/
|
|
7
|
+
[](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`.
|
package/WHY-NX-LIFECYCLE.md
CHANGED
|
@@ -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.
|
|
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.
|