nx-lifecycle 0.0.9 → 0.1.0
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 +83 -31
- package/bin.mjs +3 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.js +16 -0
- package/dist/cli.d.ts +22 -0
- package/dist/cli.js +45 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.js +14 -0
- package/dist/commands/lib/dependencies.d.ts +10 -0
- package/dist/commands/lib/dependencies.js +12 -0
- package/dist/commands/lib/types.d.ts +9 -0
- package/dist/commands/lib/types.js +3 -0
- package/dist/commands/lifecycle-command.d.ts +22 -0
- package/dist/commands/lifecycle-command.js +54 -0
- package/dist/executors/lifecycle/index.cjs +4 -2
- package/dist/executors/lifecycle/index.d.cts +54 -4
- package/dist/executors/lifecycle/index.d.ts +3 -45
- package/dist/executors/lifecycle/index.js +9 -21
- package/dist/executors/lifecycle/lifecycle.d.ts +6 -10
- package/dist/executors/lifecycle/lifecycle.js +14 -94
- package/dist/{executors/lifecycle → lifecycle}/constants.js +2 -1
- package/dist/{executors/lifecycle → lifecycle}/depedencies.d.ts +3 -1
- package/dist/{executors/lifecycle → lifecycle}/depedencies.js +5 -2
- package/dist/lifecycle/index.d.ts +5 -0
- package/dist/lifecycle/index.js +25 -0
- package/dist/lifecycle/lifecycle-internal.d.ts +22 -0
- package/dist/lifecycle/lifecycle-internal.js +102 -0
- package/dist/lifecycle/normalizer.d.ts +25 -0
- package/dist/lifecycle/normalizer.js +44 -0
- package/dist/{executors/lifecycle → lifecycle}/processor.js +2 -1
- package/dist/lifecycle/schema.d.ts +337 -0
- package/dist/lifecycle/schema.js +54 -0
- package/dist/lifecycle/types.d.ts +9 -0
- package/dist/lifecycle/types.js +3 -0
- package/dist/schemas/configurations.js +2 -1
- package/dist/schemas/depend-on.js +2 -1
- package/dist/schemas/empty.js +2 -1
- package/dist/schemas/index.js +2 -1
- package/dist/schemas/lib/ajv.js +6 -2
- package/dist/schemas/nx-json.js +2 -1
- package/dist/schemas/project-json.js +2 -1
- package/dist/schemas/target.js +2 -1
- package/executors.json +1 -1
- package/package.json +33 -25
- package/dist/executors/lifecycle/normalizer.d.ts +0 -23
- package/dist/executors/lifecycle/normalizer.js +0 -21
- package/dist/executors/lifecycle/types.d.ts +0 -3
- package/dist/executors/lifecycle/types.js +0 -2
- package/src/executors/lifecycle/schema.json +0 -98
- /package/dist/{executors/lifecycle → lifecycle}/constants.d.ts +0 -0
- /package/dist/{executors/lifecycle → lifecycle}/processor.d.ts +0 -0
package/README.md
CHANGED
|
@@ -89,6 +89,8 @@ Register it as a target in a `project.json`:
|
|
|
89
89
|
"lifecycle": {
|
|
90
90
|
"executor": "nx-lifecycle:lifecycle",
|
|
91
91
|
"options": {
|
|
92
|
+
"cwd": "{projectRoot}",
|
|
93
|
+
"configFile": "lifecycle.json"
|
|
92
94
|
"stages": {
|
|
93
95
|
"build": {
|
|
94
96
|
"hooks": ["pre", "run", "post"],
|
|
@@ -100,7 +102,7 @@ Register it as a target in a `project.json`:
|
|
|
100
102
|
}
|
|
101
103
|
},
|
|
102
104
|
"bindings": {
|
|
103
|
-
"
|
|
105
|
+
"tsc": "build:run",
|
|
104
106
|
"mocha": "test:run"
|
|
105
107
|
}
|
|
106
108
|
}
|
|
@@ -109,29 +111,79 @@ Register it as a target in a `project.json`:
|
|
|
109
111
|
}
|
|
110
112
|
```
|
|
111
113
|
|
|
112
|
-
Note that this target only needs to be run once (not once per project) so it is recommended to put this somewhere like a root `project.json` to own this.
|
|
114
|
+
Note that this target only needs to be run once (not once per project) so it is recommended to put this somewhere like a root `project.json` to own this. [Nx-lifecycle's own monorepo is managed in a non-published "main" package](https://github.com/JacobLey/leyman/blob/main/leyman/main/lifecycle.json).
|
|
113
115
|
|
|
114
116
|
## Usage
|
|
115
117
|
|
|
116
|
-
Because
|
|
118
|
+
Because `lifecycle` manages target dependencies itself, it probably should not be executed along with targets that are normally executed, like the `build` and `test` targets in the example above.
|
|
117
119
|
|
|
118
120
|
For example, this project's use of `nx-lifecycle` is part of a [local-only project](https://github.com/JacobLey/leyman/blob/main/leyman/main/project.json#L15) that is never deployed anywhere, and exists only to manage the repo itself.
|
|
119
121
|
|
|
120
|
-
`nx-lifecycle` will produce additional targets in your `nx.json` and `project.json`s. These will all be backed by the [noop](https://nx.dev/nx-api/nx/executors/noop) executor, and have no need to invoke caching. In fact, you should never directly manage these commands, their dependencies, or their configurations.
|
|
122
|
+
`nx-lifecycle` will produce additional targets in your `nx.json` and `project.json`s. These will all be backed by the [noop](https://nx.dev/nx-api/nx/executors/noop) executor, and have no need to invoke caching. In fact, you should never directly manage these commands, their dependencies, or their configurations. These changes should be included in your version control.
|
|
121
123
|
|
|
122
124
|
You may declare one-off targets that _depend_ on these targets though, that is the whole point! You should able to declare a target depends on the build step, without having to explicitly manage how the build script is implemented.
|
|
123
125
|
|
|
124
126
|
`nx-lifecycle` will use the `nx.json` to assign defaults, and will assign defaults to your targets that are assigned there. However that does not guarantee every target is actually executable by every project. You must declare the target in your `project.json` as well. Do not worry about copying `nx-lifecycle`'s targets over.
|
|
125
127
|
|
|
126
|
-
|
|
128
|
+
Instead of providing all the stages and bindings in the package.json file, it is also possible to manage that in a separate file, and point the plugin at it.
|
|
127
129
|
|
|
128
|
-
###
|
|
130
|
+
### As a plugin
|
|
131
|
+
|
|
132
|
+
Specify `nx-lifecycle:lifecycle` as the executor. You can pass the `lifecycle.json` config file there, or may provide the config JSON directly inline as the options.
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
// project.json
|
|
136
|
+
{
|
|
137
|
+
"targets": {
|
|
138
|
+
"lifecycle": {
|
|
139
|
+
"executor": "nx-lifecycle:lifecycle",
|
|
140
|
+
"options": {
|
|
141
|
+
"cwd": "{projectRoot}",
|
|
142
|
+
"configFile": "my-lifecycle-config.json" // defaults to "lifecycle.json"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Where the file is the options object
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
// lifecycle.json
|
|
153
|
+
{
|
|
154
|
+
"stages": {
|
|
155
|
+
"build": {
|
|
156
|
+
"hooks": ["pre", "run", "post"],
|
|
157
|
+
"dependsOn": ["^build"]
|
|
158
|
+
},
|
|
159
|
+
"test": {
|
|
160
|
+
"hooks": ["run", "report"],
|
|
161
|
+
"dependsOn": ["build"]
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
"bindings": {
|
|
165
|
+
"tsc": "build:run",
|
|
166
|
+
"mocha": "test:run"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### As a CLI
|
|
172
|
+
|
|
173
|
+
Alternatively, you may invoke this plugin as a CLI command. Similar to above, it is _recommended_ to include this dependency in some project that is outside the scope of your "normal" packages. Although it could conceptually be installed globally as well.
|
|
174
|
+
|
|
175
|
+
`pnpx nx-lifecycle --help`
|
|
176
|
+
`pnpx nx-lifecycle --config-file ./my-lifecycle.json --dry-run`
|
|
129
177
|
|
|
130
|
-
|
|
178
|
+
It is not possible to pass the configuration directly to the CLI, and must use a config file.
|
|
131
179
|
|
|
132
|
-
|
|
180
|
+
## Configuration
|
|
133
181
|
|
|
134
|
-
|
|
182
|
+
Both the CLI and the plugin support providing a config file to manage lifecycle options. This file (defaults to `lifecycle.json`) contains configuraiton that specifies the different stages and bindings for your projects.
|
|
183
|
+
|
|
184
|
+
The lifecycle executor can also provide all these options directly in the `project.json` if preferred.
|
|
185
|
+
|
|
186
|
+
### configuration.stages
|
|
135
187
|
|
|
136
188
|
Required. No default value.
|
|
137
189
|
|
|
@@ -144,7 +196,7 @@ It is an object, where every key is the name of a stage. The value is another ob
|
|
|
144
196
|
- `dependsOn`
|
|
145
197
|
- Accepts the same values as normal Nx [dependsOn](https://nx.dev/reference/project-configuration#dependson). Used to define relationship between stages, and their dependencies.
|
|
146
198
|
|
|
147
|
-
|
|
199
|
+
### configuration.bindings
|
|
148
200
|
|
|
149
201
|
Required. No default value.
|
|
150
202
|
|
|
@@ -154,32 +206,26 @@ The value is an object mapping, where the key is the name of your specific targe
|
|
|
154
206
|
|
|
155
207
|
__\*\*NOTE\*\*__ If the bound stage has `steps` defined, then you must bind to a specific step. If there are no steps, then you reference the stage directly.
|
|
156
208
|
|
|
157
|
-
```
|
|
209
|
+
```json
|
|
210
|
+
// lifecycle.json
|
|
158
211
|
{
|
|
159
|
-
"
|
|
160
|
-
"
|
|
161
|
-
"
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
},
|
|
167
|
-
"test": {
|
|
168
|
-
"hooks": ["run", "report"],
|
|
169
|
-
"dependsOn": ["build"]
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
"bindings": {
|
|
173
|
-
"nx-tsc": "build",
|
|
174
|
-
"mocha": "test:run"
|
|
175
|
-
}
|
|
176
|
-
}
|
|
212
|
+
"stages": {
|
|
213
|
+
"build": {
|
|
214
|
+
"dependsOn": ["^build"]
|
|
215
|
+
},
|
|
216
|
+
"test": {
|
|
217
|
+
"hooks": ["run", "report"],
|
|
218
|
+
"dependsOn": ["build"]
|
|
177
219
|
}
|
|
220
|
+
},
|
|
221
|
+
"bindings": {
|
|
222
|
+
"tsc": "build",
|
|
223
|
+
"mocha": "test:run"
|
|
178
224
|
}
|
|
179
225
|
}
|
|
180
226
|
```
|
|
181
227
|
|
|
182
|
-
|
|
228
|
+
### configuration.check
|
|
183
229
|
|
|
184
230
|
`boolean`. Default `true` in CI environments, otherwise `false`.
|
|
185
231
|
|
|
@@ -187,10 +233,16 @@ If `true`, the executor will fail if the `nx.json` or any `project.json` is out
|
|
|
187
233
|
|
|
188
234
|
Useful for ensuring that generated configs are up to date in version control before proceeding with deployments.
|
|
189
235
|
|
|
190
|
-
|
|
236
|
+
### configuration.dryRun
|
|
191
237
|
|
|
192
238
|
`boolean`. Default `false`.
|
|
193
239
|
|
|
194
240
|
If `true`, will do everything except actually write the updated config files.
|
|
195
241
|
|
|
196
242
|
Can still fail if `check` is `true`.
|
|
243
|
+
|
|
244
|
+
## Executors
|
|
245
|
+
|
|
246
|
+
### lifecycle
|
|
247
|
+
|
|
248
|
+
Will update all `project.json`s and the `nx.json` with declared stages, and wire up dependencies to your bound targets, ensuring that you can reference your abstract targets, Nx will invoke the required targets in dependency order as necessary.
|
package/bin.mjs
ADDED
package/dist/bin.d.ts
ADDED
package/dist/bin.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EntryScript } from "entry-script";
|
|
2
|
+
import { bind, singletonScope } from 'haywire';
|
|
3
|
+
import { launch } from 'haywire-launcher';
|
|
4
|
+
import { LifecycleCli } from './cli.js';
|
|
5
|
+
import { commandsId, commandsModule } from './commands/index.js';
|
|
6
|
+
import { consoleErrorId, consoleLogId, exitCodeId } from './commands/lib/dependencies.js';
|
|
7
|
+
export default launch(commandsModule.addBinding(bind(EntryScript).withDependencies([
|
|
8
|
+
LifecycleCli
|
|
9
|
+
]).withProvider((cli)=>cli).scoped(singletonScope)).addBinding(bind(LifecycleCli).withDependencies([
|
|
10
|
+
commandsId.supplier(),
|
|
11
|
+
consoleLogId,
|
|
12
|
+
consoleErrorId,
|
|
13
|
+
exitCodeId
|
|
14
|
+
]).withConstructorProvider().scoped(singletonScope)).toContainer());
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EntryScript } from 'entry-script';
|
|
2
|
+
import type { Supplier } from 'haywire';
|
|
3
|
+
import type { ConsoleLog, ExitCode } from './commands/lib/dependencies.js';
|
|
4
|
+
import type { AbstractCommand } from './commands/lib/types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Lifecycle CLI. Run `./bin.mjs --help` for options.
|
|
7
|
+
*
|
|
8
|
+
* Uses `yargs` package for command line parsing and logic flow.
|
|
9
|
+
*/
|
|
10
|
+
export declare class LifecycleCli extends EntryScript {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(getCommands: Supplier<AbstractCommand[]>, logger: ConsoleLog, errorLogger: ConsoleLog, exitCode: ExitCode);
|
|
13
|
+
/**
|
|
14
|
+
* Entry point to CLI script.
|
|
15
|
+
*
|
|
16
|
+
* Sets high level Yargs settings. Command/options logic is implemented in individual command modules.
|
|
17
|
+
*
|
|
18
|
+
* @param argv - process arguments
|
|
19
|
+
*/
|
|
20
|
+
main(argv: string[]): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import yargs from 'yargs';
|
|
2
|
+
import { EntryScript } from "entry-script";
|
|
3
|
+
export class LifecycleCli extends EntryScript {
|
|
4
|
+
#getCommands;
|
|
5
|
+
#logger;
|
|
6
|
+
#errorLogger;
|
|
7
|
+
#exitCode;
|
|
8
|
+
constructor(getCommands, logger, errorLogger, exitCode){
|
|
9
|
+
super();
|
|
10
|
+
this.#getCommands = getCommands;
|
|
11
|
+
this.#logger = logger;
|
|
12
|
+
this.#errorLogger = errorLogger;
|
|
13
|
+
this.#exitCode = exitCode;
|
|
14
|
+
}
|
|
15
|
+
async main(argv) {
|
|
16
|
+
const packageJson = await import('../package.json', {
|
|
17
|
+
with: {
|
|
18
|
+
type: 'json'
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const yarg = yargs().scriptName('lifecycle').option({
|
|
22
|
+
cwd: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
default: '.',
|
|
25
|
+
describe: 'Directory to resolve all other paths from'
|
|
26
|
+
}
|
|
27
|
+
}).strict().help().alias('help', 'info').version(packageJson.default.version);
|
|
28
|
+
for (const command of this.#getCommands()){
|
|
29
|
+
yarg.command(command);
|
|
30
|
+
}
|
|
31
|
+
await yarg.parseAsync(argv, {}, this.#yargsOutput.bind(this));
|
|
32
|
+
}
|
|
33
|
+
#yargsOutput(e, _argv, log) {
|
|
34
|
+
if (e) {
|
|
35
|
+
this.#exitCode(1);
|
|
36
|
+
if (log) {
|
|
37
|
+
this.#errorLogger(log);
|
|
38
|
+
}
|
|
39
|
+
} else if (log) {
|
|
40
|
+
this.#logger(log);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AbstractCommand } from './lib/types.js';
|
|
2
|
+
import { LifecycleCommand } from './lifecycle-command.js';
|
|
3
|
+
export declare const commandsId: import("haywire").HaywireId<AbstractCommand[], null, null, false, false, false, false>;
|
|
4
|
+
export declare const commandsModule: import("haywire").Module<[import("haywire").NonExtendable<import("./lib/dependencies.js").ConsoleLog | null | undefined, null, "log">] | [import("haywire").NonExtendable<import("./lib/dependencies.js").ConsoleLog | null, null, "log">] | [import("haywire").NonExtendable<import("./lib/dependencies.js").ConsoleLog | undefined, null, "log">] | [import("haywire").NonExtendable<import("./lib/dependencies.js").ConsoleLog, null, "log">] | [import("haywire").NonExtendable<import("./lib/dependencies.js").ConsoleLog | null | undefined, null, "error">] | [import("haywire").NonExtendable<import("./lib/dependencies.js").ConsoleLog | null, null, "error">] | [import("haywire").NonExtendable<import("./lib/dependencies.js").ConsoleLog | undefined, null, "error">] | [import("haywire").NonExtendable<import("./lib/dependencies.js").ConsoleLog, null, "error">] | [import("haywire").NonExtendable<import("./lib/dependencies.js").ExitCode | null | undefined, null, null>] | [import("haywire").NonExtendable<import("./lib/dependencies.js").ExitCode | null, null, null>] | [import("haywire").NonExtendable<import("./lib/dependencies.js").ExitCode | undefined, null, null>] | [import("haywire").NonExtendable<import("./lib/dependencies.js").ExitCode, null, null>] | [import("haywire").NonExtendable<import("@nx/devkit").ProjectGraph | null | undefined, null, null>] | [import("haywire").NonExtendable<import("@nx/devkit").ProjectGraph | null, null, null>] | [import("haywire").NonExtendable<import("@nx/devkit").ProjectGraph | undefined, null, null>] | [import("haywire").NonExtendable<import("@nx/devkit").ProjectGraph, null, null>] | [import("haywire").NonExtendable<string | null | undefined, null, "workspace-root">] | [import("haywire").NonExtendable<string | null, null, "workspace-root">] | [import("haywire").NonExtendable<string | undefined, null, "workspace-root">] | [import("haywire").NonExtendable<string, null, "workspace-root">] | [import("haywire").NonExtendable<typeof import("fs/promises").readFile | null | undefined, null, null>] | [import("haywire").NonExtendable<typeof import("fs/promises").readFile | null, null, null>] | [import("haywire").NonExtendable<typeof import("fs/promises").readFile | undefined, null, null>] | [import("haywire").NonExtendable<typeof import("fs/promises").readFile, null, null>] | [import("haywire").NonExtendable<typeof import("fs/promises").writeFile | null | undefined, null, null>] | [import("haywire").NonExtendable<typeof import("fs/promises").writeFile | null, null, null>] | [import("haywire").NonExtendable<typeof import("fs/promises").writeFile | undefined, null, null>] | [import("haywire").NonExtendable<typeof import("fs/promises").writeFile, null, null>] | [import("haywire").NonExtendable<import("format-file").FilesFormatter | null | undefined, null, null>] | [import("haywire").NonExtendable<import("format-file").FilesFormatter | null, null, null>] | [import("haywire").NonExtendable<import("format-file").FilesFormatter | undefined, null, null>] | [import("haywire").NonExtendable<import("format-file").FilesFormatter, null, null>] | [import("haywire").NonExtendable<boolean | null | undefined, null, "isCI">] | [import("haywire").NonExtendable<boolean | null, null, "isCI">] | [import("haywire").NonExtendable<boolean | undefined, null, "isCI">] | [import("haywire").NonExtendable<boolean, null, "isCI">] | [import("haywire").NonExtendable<import("../lifecycle/depedencies.js").Logger | null | undefined, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/depedencies.js").Logger | null, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/depedencies.js").Logger | undefined, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/depedencies.js").Logger, null, null>] | [import("haywire").NonExtendable<import("parse-cwd").ParseCwd | null | undefined, null, null>] | [import("haywire").NonExtendable<import("parse-cwd").ParseCwd | null, null, null>] | [import("haywire").NonExtendable<import("parse-cwd").ParseCwd | undefined, null, null>] | [import("haywire").NonExtendable<import("parse-cwd").ParseCwd, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/lifecycle-internal.js").ILifecycleInternal | null | undefined, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/lifecycle-internal.js").ILifecycleInternal | null, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/lifecycle-internal.js").ILifecycleInternal | undefined, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/lifecycle-internal.js").ILifecycleInternal, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/lifecycle-internal.js").LifecycleInternal, typeof import("../lifecycle/lifecycle-internal.js").LifecycleInternal, null>] | [import("haywire").NonExtendable<import("../lifecycle/lifecycle-internal.js").LifecycleInternal | null | undefined, typeof import("../lifecycle/lifecycle-internal.js").LifecycleInternal, null>] | [import("haywire").NonExtendable<import("../lifecycle/lifecycle-internal.js").LifecycleInternal | null, typeof import("../lifecycle/lifecycle-internal.js").LifecycleInternal, null>] | [import("haywire").NonExtendable<import("../lifecycle/lifecycle-internal.js").LifecycleInternal | undefined, typeof import("../lifecycle/lifecycle-internal.js").LifecycleInternal, null>] | [import("haywire").NonExtendable<import("../lifecycle/normalizer.js").Normalizer, typeof import("../lifecycle/normalizer.js").Normalizer, null>] | [import("haywire").NonExtendable<import("../lifecycle/processor.js").NxAndProjectJsonProcessor, null, null>] | [import("haywire").NonExtendable<import("../schemas/nx-json.js").IsNxJson, null, "nxJson">] | [import("haywire").NonExtendable<import("../schemas/project-json.js").IsProjectJson, null, "projectJson">] | [import("haywire").NonExtendable<import("../lifecycle/normalizer.js").Normalizer | null | undefined, typeof import("../lifecycle/normalizer.js").Normalizer, null>] | [import("haywire").NonExtendable<import("../lifecycle/normalizer.js").Normalizer | null, typeof import("../lifecycle/normalizer.js").Normalizer, null>] | [import("haywire").NonExtendable<import("../lifecycle/normalizer.js").Normalizer | undefined, typeof import("../lifecycle/normalizer.js").Normalizer, null>] | [import("haywire").NonExtendable<import("../lifecycle/processor.js").NxAndProjectJsonProcessor | null | undefined, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/processor.js").NxAndProjectJsonProcessor | null, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/processor.js").NxAndProjectJsonProcessor | undefined, null, null>] | [import("haywire").NonExtendable<import("../schemas/nx-json.js").IsNxJson | null | undefined, null, "nxJson">] | [import("haywire").NonExtendable<import("../schemas/nx-json.js").IsNxJson | null, null, "nxJson">] | [import("haywire").NonExtendable<import("../schemas/nx-json.js").IsNxJson | undefined, null, "nxJson">] | [import("haywire").NonExtendable<import("../schemas/project-json.js").IsProjectJson | null | undefined, null, "projectJson">] | [import("haywire").NonExtendable<import("../schemas/project-json.js").IsProjectJson | null, null, "projectJson">] | [import("haywire").NonExtendable<import("../schemas/project-json.js").IsProjectJson | undefined, null, "projectJson">] | [import("haywire").NonExtendable<AbstractCommand[] | null | undefined, null, null>] | [import("haywire").NonExtendable<AbstractCommand[] | null, null, null>] | [import("haywire").NonExtendable<AbstractCommand[] | undefined, null, null>] | [import("haywire").NonExtendable<AbstractCommand[], null, null>] | [import("haywire").NonExtendable<LifecycleCommand, typeof LifecycleCommand, null>] | [import("haywire").NonExtendable<LifecycleCommand | null | undefined, typeof LifecycleCommand, null>] | [import("haywire").NonExtendable<LifecycleCommand | null, typeof LifecycleCommand, null>] | [import("haywire").NonExtendable<LifecycleCommand | undefined, typeof LifecycleCommand, null>], [import("haywire").NonExtendable<import("@nx/devkit").ProjectGraph, null, null>] | [import("haywire").NonExtendable<string, null, "workspace-root">] | [import("haywire").NonExtendable<typeof import("fs/promises").readFile, null, null>] | [import("haywire").NonExtendable<typeof import("fs/promises").writeFile, null, null>] | [import("haywire").NonExtendable<import("format-file").FilesFormatter, null, null>] | [import("haywire").NonExtendable<boolean, null, "isCI">] | [import("haywire").NonExtendable<import("../lifecycle/depedencies.js").Logger, null, null>] | [import("haywire").NonExtendable<import("parse-cwd").ParseCwd, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/lifecycle-internal.js").ILifecycleInternal, null, null>] | [import("haywire").NonExtendable<import("../lifecycle/lifecycle-internal.js").LifecycleInternal, typeof import("../lifecycle/lifecycle-internal.js").LifecycleInternal, null>] | [import("haywire").NonExtendable<import("../lifecycle/normalizer.js").Normalizer, typeof import("../lifecycle/normalizer.js").Normalizer, null>] | [import("haywire").NonExtendable<import("../lifecycle/processor.js").NxAndProjectJsonProcessor, null, null>] | [import("haywire").NonExtendable<import("../schemas/nx-json.js").IsNxJson, null, "nxJson">] | [import("haywire").NonExtendable<import("../schemas/project-json.js").IsProjectJson, null, "projectJson">] | [import("haywire").NonExtendable<LifecycleCommand, typeof LifecycleCommand, null>], true>;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { bind, identifier } from 'haywire';
|
|
2
|
+
import { lifecycleInternalId, lifecycleInternalModule } from '../lifecycle/index.js';
|
|
3
|
+
import { dependenciesModule, projectGraphId, workspaceRootId } from './lib/dependencies.js';
|
|
4
|
+
import { LifecycleCommand } from './lifecycle-command.js';
|
|
5
|
+
export const commandsId = identifier();
|
|
6
|
+
export const commandsModule = dependenciesModule.mergeModule(lifecycleInternalModule).addBinding(bind(commandsId).withDependencies([
|
|
7
|
+
LifecycleCommand
|
|
8
|
+
]).withProvider((...commands)=>commands)).addBinding(bind(LifecycleCommand).withDependencies([
|
|
9
|
+
projectGraphId.supplier('async'),
|
|
10
|
+
workspaceRootId,
|
|
11
|
+
lifecycleInternalId
|
|
12
|
+
]).withConstructorProvider());
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ProjectGraph } from '@nx/devkit';
|
|
2
|
+
export type ConsoleLog = (log: unknown) => void;
|
|
3
|
+
export declare const consoleLogId: import("haywire").HaywireId<ConsoleLog, null, "log", false, false, false, false>;
|
|
4
|
+
export declare const consoleErrorId: import("haywire").HaywireId<ConsoleLog, null, "error", false, false, false, false>;
|
|
5
|
+
export type ExitCode = (code: number) => void;
|
|
6
|
+
export declare const exitCodeId: import("haywire").HaywireId<ExitCode, null, null, false, false, false, false>;
|
|
7
|
+
export declare const projectGraphId: import("haywire").HaywireId<ProjectGraph, null, null, false, false, false, false>;
|
|
8
|
+
export declare const workspaceRootId: import("haywire").HaywireId<string, null, "workspace-root", false, false, false, false>;
|
|
9
|
+
export declare const dependenciesModule: import("haywire").Module<[import("haywire").NonExtendable<ConsoleLog | null | undefined, null, "log">] | [import("haywire").NonExtendable<ConsoleLog | null, null, "log">] | [import("haywire").NonExtendable<ConsoleLog | undefined, null, "log">] | [import("haywire").NonExtendable<ConsoleLog, null, "log">] | [import("haywire").NonExtendable<ConsoleLog | null | undefined, null, "error">] | [import("haywire").NonExtendable<ConsoleLog | null, null, "error">] | [import("haywire").NonExtendable<ConsoleLog | undefined, null, "error">] | [import("haywire").NonExtendable<ConsoleLog, null, "error">] | [import("haywire").NonExtendable<ExitCode | null | undefined, null, null>] | [import("haywire").NonExtendable<ExitCode | null, null, null>] | [import("haywire").NonExtendable<ExitCode | undefined, null, null>] | [import("haywire").NonExtendable<ExitCode, null, null>] | [import("haywire").NonExtendable<ProjectGraph | null | undefined, null, null>] | [import("haywire").NonExtendable<ProjectGraph | null, null, null>] | [import("haywire").NonExtendable<ProjectGraph | undefined, null, null>] | [import("haywire").NonExtendable<ProjectGraph, null, null>] | [import("haywire").NonExtendable<string | null | undefined, null, "workspace-root">] | [import("haywire").NonExtendable<string | null, null, "workspace-root">] | [import("haywire").NonExtendable<string | undefined, null, "workspace-root">] | [import("haywire").NonExtendable<string, null, "workspace-root">], never, true>;
|
|
10
|
+
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createProjectGraphAsync, workspaceRoot } from '@nx/devkit';
|
|
2
|
+
import { bind, createModule, identifier, singletonScope } from 'haywire';
|
|
3
|
+
export const consoleLogId = identifier().named('log');
|
|
4
|
+
export const consoleErrorId = identifier().named('error');
|
|
5
|
+
export const exitCodeId = identifier();
|
|
6
|
+
export const projectGraphId = identifier();
|
|
7
|
+
export const workspaceRootId = identifier().named('workspace-root');
|
|
8
|
+
export const dependenciesModule = createModule(bind(consoleLogId).withInstance(console.log)).addBinding(bind(consoleErrorId).withInstance(console.error)).addBinding(bind(exitCodeId).withInstance((code)=>{
|
|
9
|
+
process.exitCode = code;
|
|
10
|
+
})).addBinding(bind(projectGraphId).withAsyncGenerator(createProjectGraphAsync).scoped(singletonScope)).addBinding(bind(workspaceRootId).withInstance(workspaceRoot));
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=dependencies.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandModule } from 'yargs';
|
|
2
|
+
export interface LifecycleCommandInput {
|
|
3
|
+
cwd: string;
|
|
4
|
+
}
|
|
5
|
+
export type Command<ExtendedInput extends LifecycleCommandInput> = Pick<CommandModule<LifecycleCommandInput, ExtendedInput>, 'builder' | 'command' | 'describe' | 'handler'>;
|
|
6
|
+
export interface AbstractCommand extends Pick<CommandModule<LifecycleCommandInput, LifecycleCommandInput>, 'builder' | 'command' | 'describe'> {
|
|
7
|
+
handler: (args: any) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ProjectGraph } from '@nx/devkit';
|
|
2
|
+
import type { Argv } from 'yargs';
|
|
3
|
+
import type { ILifecycleInternal } from '../lifecycle/lifecycle-internal.js';
|
|
4
|
+
import type { Command, LifecycleCommandInput } from './lib/types.js';
|
|
5
|
+
interface LifecycleCommandExtendedInput extends LifecycleCommandInput {
|
|
6
|
+
configFile: string;
|
|
7
|
+
ci: boolean;
|
|
8
|
+
dryRun: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Main `load-populate-files` command
|
|
12
|
+
*/
|
|
13
|
+
export declare class LifecycleCommand implements Command<LifecycleCommandExtendedInput> {
|
|
14
|
+
#private;
|
|
15
|
+
readonly command: string[];
|
|
16
|
+
readonly describe = "Inject Nx targets as high level workflows";
|
|
17
|
+
constructor(getProjectGraph: () => Promise<ProjectGraph>, workspaceRoot: string, lifecycleInternal: ILifecycleInternal);
|
|
18
|
+
builder(this: void, yargs: Argv<LifecycleCommandInput>): Argv<LifecycleCommandExtendedInput>;
|
|
19
|
+
handler(options: LifecycleCommandExtendedInput): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=lifecycle-command.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { isCI } from 'ci-info';
|
|
2
|
+
export class LifecycleCommand {
|
|
3
|
+
command = [
|
|
4
|
+
'$0',
|
|
5
|
+
'lifecycle'
|
|
6
|
+
];
|
|
7
|
+
describe = 'Inject Nx targets as high level workflows';
|
|
8
|
+
#getProjectGraph;
|
|
9
|
+
#workspaceRoot;
|
|
10
|
+
#lifecycleInternal;
|
|
11
|
+
constructor(getProjectGraph, workspaceRoot, lifecycleInternal){
|
|
12
|
+
this.#getProjectGraph = getProjectGraph;
|
|
13
|
+
this.#workspaceRoot = workspaceRoot;
|
|
14
|
+
this.#lifecycleInternal = lifecycleInternal;
|
|
15
|
+
this.handler = this.handler.bind(this);
|
|
16
|
+
}
|
|
17
|
+
builder(yargs) {
|
|
18
|
+
return yargs.options({
|
|
19
|
+
configFile: {
|
|
20
|
+
describe: 'File that exports data content to populate',
|
|
21
|
+
type: 'string',
|
|
22
|
+
default: 'lifecycle.json'
|
|
23
|
+
},
|
|
24
|
+
ci: {
|
|
25
|
+
describe: 'Fail if file is not up to date. Implies --dry-run',
|
|
26
|
+
type: 'boolean',
|
|
27
|
+
default: isCI,
|
|
28
|
+
alias: 'check'
|
|
29
|
+
},
|
|
30
|
+
dryRun: {
|
|
31
|
+
describe: 'Do not write file',
|
|
32
|
+
type: 'boolean',
|
|
33
|
+
default: false
|
|
34
|
+
}
|
|
35
|
+
}).strict();
|
|
36
|
+
}
|
|
37
|
+
async handler(options) {
|
|
38
|
+
const projectGraph = await this.#getProjectGraph();
|
|
39
|
+
await this.#lifecycleInternal({
|
|
40
|
+
configFile: options.configFile,
|
|
41
|
+
cwd: options.cwd,
|
|
42
|
+
check: options.ci,
|
|
43
|
+
dryRun: options.dryRun
|
|
44
|
+
}, {
|
|
45
|
+
root: this.#workspaceRoot,
|
|
46
|
+
projects: Object.values(projectGraph.nodes).map((node)=>({
|
|
47
|
+
name: node.name,
|
|
48
|
+
root: node.data.root
|
|
49
|
+
}))
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=lifecycle-command.js.map
|
|
@@ -9,5 +9,7 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _commonproxy = require("common-proxy");
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const _nxpluginhandler = require("nx-plugin-handler");
|
|
13
|
+
const _default = (0, _nxpluginhandler.handler)((0, _commonproxy.commonProxy)(import('./index.js')));
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
declare const _default: (
|
|
1
|
+
declare const _default: import("nx-plugin-handler").RawHandler<(Partial<{
|
|
2
|
+
$schema: string;
|
|
2
3
|
check: boolean;
|
|
3
4
|
dryRun: boolean;
|
|
4
5
|
stages: Record<string, Partial<{
|
|
@@ -42,8 +43,57 @@ declare const _default: (options: Partial<{
|
|
|
42
43
|
hooks: string[];
|
|
43
44
|
}>>;
|
|
44
45
|
bindings: Record<string, string>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
}> & Required<Pick<{
|
|
47
|
+
$schema: string;
|
|
48
|
+
check: boolean;
|
|
49
|
+
dryRun: boolean;
|
|
50
|
+
stages: Record<string, Partial<{
|
|
51
|
+
dependsOn: ((string | (Partial<{
|
|
52
|
+
projects: string | string[];
|
|
53
|
+
}> & Required<Pick<{
|
|
54
|
+
projects: string | string[];
|
|
55
|
+
}, "projects">> & Partial<{
|
|
56
|
+
target: string;
|
|
57
|
+
params: string;
|
|
58
|
+
}> & Required<Pick<{
|
|
59
|
+
target: string;
|
|
60
|
+
params: string;
|
|
61
|
+
}, "target">>) | (Partial<{
|
|
62
|
+
dependencies: boolean;
|
|
63
|
+
}> & Partial<{
|
|
64
|
+
target: string;
|
|
65
|
+
params: string;
|
|
66
|
+
}> & Required<Pick<{
|
|
67
|
+
target: string;
|
|
68
|
+
params: string;
|
|
69
|
+
}, "target">>)) & (string | (Partial<{
|
|
70
|
+
projects: string | string[];
|
|
71
|
+
}> & Required<Pick<{
|
|
72
|
+
projects: string | string[];
|
|
73
|
+
}, "projects">> & Partial<{
|
|
74
|
+
target: string;
|
|
75
|
+
params: string;
|
|
76
|
+
}> & Required<Pick<{
|
|
77
|
+
target: string;
|
|
78
|
+
params: string;
|
|
79
|
+
}, "target">>) | (Partial<{
|
|
80
|
+
dependencies: boolean;
|
|
81
|
+
}> & Partial<{
|
|
82
|
+
target: string;
|
|
83
|
+
params: string;
|
|
84
|
+
}> & Required<Pick<{
|
|
85
|
+
target: string;
|
|
86
|
+
params: string;
|
|
87
|
+
}, "target">>) | undefined))[];
|
|
88
|
+
hooks: string[];
|
|
89
|
+
}>>;
|
|
90
|
+
bindings: Record<string, string>;
|
|
91
|
+
}, "stages" | "bindings">>) | Partial<{
|
|
92
|
+
$schema: string;
|
|
93
|
+
check: boolean;
|
|
94
|
+
dryRun: boolean;
|
|
95
|
+
configFile: string;
|
|
96
|
+
cwd: string;
|
|
97
|
+
}>>;
|
|
48
98
|
export default _default;
|
|
49
99
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1,47 +1,5 @@
|
|
|
1
|
-
declare const _default: import("
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
stages: Record<string, Partial<{
|
|
5
|
-
dependsOn: ((string | (Partial<{
|
|
6
|
-
projects: string | string[];
|
|
7
|
-
}> & Required<Pick<{
|
|
8
|
-
projects: string | string[];
|
|
9
|
-
}, "projects">> & Partial<{
|
|
10
|
-
target: string;
|
|
11
|
-
params: string;
|
|
12
|
-
}> & Required<Pick<{
|
|
13
|
-
target: string;
|
|
14
|
-
params: string;
|
|
15
|
-
}, "target">>) | (Partial<{
|
|
16
|
-
dependencies: boolean;
|
|
17
|
-
}> & Partial<{
|
|
18
|
-
target: string;
|
|
19
|
-
params: string;
|
|
20
|
-
}> & Required<Pick<{
|
|
21
|
-
target: string;
|
|
22
|
-
params: string;
|
|
23
|
-
}, "target">>)) & (string | (Partial<{
|
|
24
|
-
projects: string | string[];
|
|
25
|
-
}> & Required<Pick<{
|
|
26
|
-
projects: string | string[];
|
|
27
|
-
}, "projects">> & Partial<{
|
|
28
|
-
target: string;
|
|
29
|
-
params: string;
|
|
30
|
-
}> & Required<Pick<{
|
|
31
|
-
target: string;
|
|
32
|
-
params: string;
|
|
33
|
-
}, "target">>) | (Partial<{
|
|
34
|
-
dependencies: boolean;
|
|
35
|
-
}> & Partial<{
|
|
36
|
-
target: string;
|
|
37
|
-
params: string;
|
|
38
|
-
}> & Required<Pick<{
|
|
39
|
-
target: string;
|
|
40
|
-
params: string;
|
|
41
|
-
}, "target">>) | undefined))[];
|
|
42
|
-
hooks: string[];
|
|
43
|
-
}>>;
|
|
44
|
-
bindings: Record<string, string>;
|
|
45
|
-
}>>;
|
|
1
|
+
declare const _default: (options: import("../../lifecycle/schema.js").LifecycleOptionsOrConfig, context: import("./lifecycle.js").SimpleExecutorContext) => Promise<{
|
|
2
|
+
success: boolean;
|
|
3
|
+
}>;
|
|
46
4
|
export default _default;
|
|
47
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import { bind, createContainer
|
|
2
|
-
import {
|
|
3
|
-
import { isNxJson, isNxJsonIdentifier, isProjectJson, isProjectJsonIdentifier } from '#schemas';
|
|
4
|
-
import { dependenciesModule, formatFileIdentifier, isCiIdentifier, loggerIdentifier, readFileIdentifier, writeFileIdentifier } from './depedencies.js';
|
|
1
|
+
import { bind, createContainer } from 'haywire';
|
|
2
|
+
import { lifecycleInternalId, lifecycleInternalModule } from '../../lifecycle/index.js';
|
|
5
3
|
import { Lifecycle } from './lifecycle.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
nxAndProjectJsonProcessorIdentifier,
|
|
14
|
-
isNxJsonIdentifier,
|
|
15
|
-
isProjectJsonIdentifier,
|
|
16
|
-
loggerIdentifier
|
|
17
|
-
])).addBinding(bind(Normalizer).withConstructorProvider().withDependencies([
|
|
18
|
-
isCiIdentifier
|
|
19
|
-
])).addBinding(bind(nxAndProjectJsonProcessorIdentifier).withInstance(processNxAndProjectJsons)).addBinding(bind(isNxJsonIdentifier).withInstance(isNxJson)).addBinding(bind(isProjectJsonIdentifier).withInstance(isProjectJson));
|
|
20
|
-
const lifecycle = createContainer(dependenciesModule.mergeModule(pluginModule)).get(Lifecycle);
|
|
21
|
-
export default handler(lifecycle.lifecycle.bind(lifecycle));
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
4
|
+
const lifecycleModule = lifecycleInternalModule.addBinding(bind(Lifecycle).withDependencies([
|
|
5
|
+
lifecycleInternalId
|
|
6
|
+
]).withConstructorProvider());
|
|
7
|
+
const lifecycle = createContainer(lifecycleModule).get(Lifecycle);
|
|
8
|
+
export default lifecycle.lifecycle;
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
import type { Normalizer } from './normalizer.js';
|
|
6
|
-
import type { NxAndProjectJsonProcessor } from './processor.js';
|
|
7
|
-
import type { LifecycleOptions } from './schema.js';
|
|
8
|
-
import type { SimpleExecutorContext } from './types.js';
|
|
1
|
+
import type { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import type { ILifecycleInternal } from '../../lifecycle/lifecycle-internal.js';
|
|
3
|
+
import type { LifecycleOptionsOrConfig } from '../../lifecycle/schema.js';
|
|
4
|
+
export type SimpleExecutorContext = Pick<ExecutorContext, 'projectsConfigurations' | 'root'>;
|
|
9
5
|
/**
|
|
10
6
|
* Main logic for lifecycle file management.
|
|
11
7
|
*
|
|
@@ -15,9 +11,9 @@ import type { SimpleExecutorContext } from './types.js';
|
|
|
15
11
|
*/
|
|
16
12
|
export declare class Lifecycle {
|
|
17
13
|
#private;
|
|
18
|
-
|
|
19
|
-
lifecycle(options: LifecycleOptions, context: SimpleExecutorContext): Promise<{
|
|
14
|
+
readonly lifecycle: (options: LifecycleOptionsOrConfig, context: SimpleExecutorContext) => Promise<{
|
|
20
15
|
success: boolean;
|
|
21
16
|
}>;
|
|
17
|
+
constructor(lifecycleInternal: ILifecycleInternal);
|
|
22
18
|
}
|
|
23
19
|
//# sourceMappingURL=lifecycle.d.ts.map
|