nx-lifecycle 0.2.1 → 1.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.
Files changed (57) hide show
  1. package/.npmignore +20 -0
  2. package/README.md +242 -120
  3. package/WHY-NX-LIFECYCLE.md +64 -0
  4. package/dist/bin.d.ts +1 -2
  5. package/dist/bin.js +1 -14
  6. package/dist/cli.d.ts +1 -5
  7. package/dist/cli.js +9 -22
  8. package/dist/commands/explain-command.d.ts +12 -0
  9. package/dist/commands/explain-command.js +57 -0
  10. package/dist/commands/lib/types.d.ts +0 -3
  11. package/dist/commands/lifecycle-command.d.ts +2 -12
  12. package/dist/commands/lifecycle-command.js +13 -22
  13. package/dist/executors/lifecycle/index.d.ts +1 -4
  14. package/dist/executors/lifecycle/index.js +1 -8
  15. package/dist/executors/lifecycle/lifecycle.d.ts +8 -9
  16. package/dist/executors/lifecycle/lifecycle.js +13 -20
  17. package/dist/lifecycle/explain.d.ts +68 -0
  18. package/dist/lifecycle/explain.js +160 -0
  19. package/dist/lifecycle/lifecycle-internal.d.ts +4 -12
  20. package/dist/lifecycle/lifecycle-internal.js +93 -93
  21. package/dist/lifecycle/normalizer.d.ts +14 -8
  22. package/dist/lifecycle/normalizer.js +29 -36
  23. package/dist/lifecycle/processor.d.ts +41 -5
  24. package/dist/lifecycle/processor.js +36 -35
  25. package/dist/lifecycle/schema.d.ts +468 -66
  26. package/dist/lifecycle/schema.js +30 -21
  27. package/dist/plugin/index.d.ts +7 -0
  28. package/dist/plugin/index.js +4 -0
  29. package/dist/plugin/lifecycle-plugin.d.ts +24 -0
  30. package/dist/plugin/lifecycle-plugin.js +145 -0
  31. package/dist/{executors/lifecycle/index.d.cts → plugin/schema.d.ts} +32 -55
  32. package/dist/plugin/schema.js +19 -0
  33. package/dist/schemas/configurations.d.ts +5 -5
  34. package/dist/schemas/depend-on.d.ts +39 -9
  35. package/dist/schemas/depend-on.js +4 -2
  36. package/dist/schemas/empty.d.ts +2 -2
  37. package/dist/schemas/empty.js +2 -2
  38. package/dist/schemas/nx-json.d.ts +42 -20
  39. package/dist/schemas/nx-json.js +2 -4
  40. package/dist/schemas/project-json.d.ts +42 -20
  41. package/dist/schemas/project-json.js +2 -4
  42. package/dist/schemas/target.d.ts +79 -25
  43. package/executors.json +2 -2
  44. package/out/nx-executor/schema.json +148 -0
  45. package/out/schema.json +114 -0
  46. package/package.json +43 -41
  47. package/dist/commands/index.d.ts +0 -5
  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/index.cjs +0 -15
  52. package/dist/lifecycle/depedencies.d.ts +0 -15
  53. package/dist/lifecycle/depedencies.js +0 -14
  54. package/dist/lifecycle/index.d.ts +0 -5
  55. package/dist/lifecycle/index.js +0 -25
  56. package/dist/schemas/lib/ajv.d.ts +0 -3
  57. package/dist/schemas/lib/ajv.js +0 -9
@@ -1,6 +1,5 @@
1
- import { identifier } from 'haywire';
2
1
  import { objectSchema } from 'juniper';
3
- import { ajv } from './lib/ajv.js';
2
+ import { makeValidator } from 'juniper-validator';
4
3
  import { allTargetsSchema } from './target.js';
5
4
  const nxJsonSchema = objectSchema({
6
5
  properties: {
@@ -8,7 +7,6 @@ const nxJsonSchema = objectSchema({
8
7
  },
9
8
  additionalProperties: true
10
9
  });
11
- export const isNxJson = ajv.compile(nxJsonSchema.toJSON());
12
- export const isNxJsonIdentifier = identifier().named('nxJson');
10
+ export const assertNxJson = makeValidator(nxJsonSchema).assert;
13
11
 
14
12
  //# sourceMappingURL=nx-json.js.map
@@ -1,13 +1,21 @@
1
- import type { ErrorObject } from 'ajv';
2
- import { type SchemaType } from 'juniper';
1
+ import type { SchemaType } from 'juniper';
2
+ import type { JuniperValidator } from 'juniper-validator';
3
3
  declare const projectJsonSchema: import("juniper").ObjectSchema<{
4
4
  targets: import("juniper").ObjectSchema<{}, never, import("juniper").ObjectSchema<{
5
5
  executor: import("juniper").StringSchema<string, false>;
6
- dependsOn: import("juniper").ArraySchema<(string | (Partial<{
7
- projects: string | string[];
6
+ dependsOn: import("juniper").ArraySchema<string | (Partial<{
7
+ dependencies: boolean;
8
+ projects: never;
9
+ }> & Partial<{
10
+ target: string;
11
+ params: string;
8
12
  }> & Required<Pick<{
9
- projects: string | string[];
10
- }, "projects">> & Partial<{
13
+ target: string;
14
+ params: string;
15
+ }, "target">>) | (string & Partial<{
16
+ dependencies: boolean;
17
+ projects: never;
18
+ }> & Partial<{
11
19
  target: string;
12
20
  params: string;
13
21
  }> & Required<Pick<{
@@ -15,15 +23,30 @@ declare const projectJsonSchema: import("juniper").ObjectSchema<{
15
23
  params: string;
16
24
  }, "target">>) | (Partial<{
17
25
  dependencies: boolean;
26
+ projects: never;
18
27
  }> & Partial<{
19
28
  target: string;
20
29
  params: string;
21
30
  }> & Required<Pick<{
22
31
  target: string;
23
32
  params: string;
24
- }, "target">>)) & (string | (Partial<{
33
+ }, "target">> & string) | (Partial<{
34
+ dependencies: never;
35
+ projects: string | string[];
36
+ }> & Required<Pick<{
37
+ dependencies: never;
38
+ projects: string | string[];
39
+ }, "projects">> & Partial<{
40
+ target: string;
41
+ params: string;
42
+ }> & Required<Pick<{
43
+ target: string;
44
+ params: string;
45
+ }, "target">>) | (string & Partial<{
46
+ dependencies: never;
25
47
  projects: string | string[];
26
48
  }> & Required<Pick<{
49
+ dependencies: never;
27
50
  projects: string | string[];
28
51
  }, "projects">> & Partial<{
29
52
  target: string;
@@ -32,29 +55,28 @@ declare const projectJsonSchema: import("juniper").ObjectSchema<{
32
55
  target: string;
33
56
  params: string;
34
57
  }, "target">>) | (Partial<{
35
- dependencies: boolean;
36
- }> & Partial<{
58
+ dependencies: never;
59
+ projects: string | string[];
60
+ }> & Required<Pick<{
61
+ dependencies: never;
62
+ projects: string | string[];
63
+ }, "projects">> & Partial<{
37
64
  target: string;
38
65
  params: string;
39
66
  }> & Required<Pick<{
40
67
  target: string;
41
68
  params: string;
42
- }, "target">>) | undefined), [], never, unknown, false>;
43
- configurations: import("juniper").ObjectSchema<{}, never, boolean, import("juniper").EmptyIndex, (Record<string, unknown> & Partial<{
44
- __lifecycle: never;
45
- }>) | (Partial<{
69
+ }, "target">> & string), [], never, unknown, false>;
70
+ configurations: import("juniper").ObjectSchema<{}, never, boolean, import("juniper").EmptyIndex, (Partial<{
46
71
  __lifecycle: import("juniper").EmptyObject;
47
72
  }> & Required<Pick<{
48
73
  __lifecycle: import("juniper").EmptyObject;
49
- }, "__lifecycle">>), boolean>;
74
+ }, "__lifecycle">>) | (Record<string, unknown> & Partial<{
75
+ __lifecycle: never;
76
+ }>), boolean>;
50
77
  }, never, boolean, import("juniper").EmptyIndex, unknown, false>, import("juniper").EmptyIndex, unknown, false>;
51
78
  }, never, true, import("juniper").EmptyIndex, unknown, false>;
52
79
  export type ProjectJson = SchemaType<typeof projectJsonSchema>;
53
- export interface IsProjectJson {
54
- (val: unknown): val is ProjectJson;
55
- errors?: ErrorObject[] | null;
56
- }
57
- export declare const isProjectJson: IsProjectJson;
58
- export declare const isProjectJsonIdentifier: import("haywire").HaywireId<IsProjectJson, null, "projectJson", false, false, false, false>;
80
+ export declare const assertProjectJson: JuniperValidator<ProjectJson>['assert'];
59
81
  export {};
60
82
  //# sourceMappingURL=project-json.d.ts.map
@@ -1,6 +1,5 @@
1
- import { identifier } from 'haywire';
2
1
  import { objectSchema } from 'juniper';
3
- import { ajv } from './lib/ajv.js';
2
+ import { makeValidator } from 'juniper-validator';
4
3
  import { allTargetsSchema } from './target.js';
5
4
  const projectJsonSchema = objectSchema({
6
5
  properties: {
@@ -8,7 +7,6 @@ const projectJsonSchema = objectSchema({
8
7
  },
9
8
  additionalProperties: true
10
9
  });
11
- export const isProjectJson = ajv.compile(projectJsonSchema.toJSON());
12
- export const isProjectJsonIdentifier = identifier().named('projectJson');
10
+ export const assertProjectJson = makeValidator(projectJsonSchema).assert;
13
11
 
14
12
  //# sourceMappingURL=project-json.js.map
@@ -1,11 +1,19 @@
1
- import { type SchemaType } from 'juniper';
1
+ import type { SchemaType } from 'juniper';
2
2
  declare const targetSchema: import("juniper").ObjectSchema<{
3
3
  executor: import("juniper").StringSchema<string, false>;
4
- dependsOn: import("juniper").ArraySchema<(string | (Partial<{
5
- projects: string | string[];
4
+ dependsOn: import("juniper").ArraySchema<string | (Partial<{
5
+ dependencies: boolean;
6
+ projects: never;
7
+ }> & Partial<{
8
+ target: string;
9
+ params: string;
6
10
  }> & Required<Pick<{
7
- projects: string | string[];
8
- }, "projects">> & Partial<{
11
+ target: string;
12
+ params: string;
13
+ }, "target">>) | (string & Partial<{
14
+ dependencies: boolean;
15
+ projects: never;
16
+ }> & Partial<{
9
17
  target: string;
10
18
  params: string;
11
19
  }> & Required<Pick<{
@@ -13,15 +21,30 @@ declare const targetSchema: import("juniper").ObjectSchema<{
13
21
  params: string;
14
22
  }, "target">>) | (Partial<{
15
23
  dependencies: boolean;
24
+ projects: never;
16
25
  }> & Partial<{
17
26
  target: string;
18
27
  params: string;
19
28
  }> & Required<Pick<{
20
29
  target: string;
21
30
  params: string;
22
- }, "target">>)) & (string | (Partial<{
31
+ }, "target">> & string) | (Partial<{
32
+ dependencies: never;
33
+ projects: string | string[];
34
+ }> & Required<Pick<{
35
+ dependencies: never;
36
+ projects: string | string[];
37
+ }, "projects">> & Partial<{
38
+ target: string;
39
+ params: string;
40
+ }> & Required<Pick<{
41
+ target: string;
42
+ params: string;
43
+ }, "target">>) | (string & Partial<{
44
+ dependencies: never;
23
45
  projects: string | string[];
24
46
  }> & Required<Pick<{
47
+ dependencies: never;
25
48
  projects: string | string[];
26
49
  }, "projects">> & Partial<{
27
50
  target: string;
@@ -30,30 +53,42 @@ declare const targetSchema: import("juniper").ObjectSchema<{
30
53
  target: string;
31
54
  params: string;
32
55
  }, "target">>) | (Partial<{
33
- dependencies: boolean;
34
- }> & Partial<{
56
+ dependencies: never;
57
+ projects: string | string[];
58
+ }> & Required<Pick<{
59
+ dependencies: never;
60
+ projects: string | string[];
61
+ }, "projects">> & Partial<{
35
62
  target: string;
36
63
  params: string;
37
64
  }> & Required<Pick<{
38
65
  target: string;
39
66
  params: string;
40
- }, "target">>) | undefined), [], never, unknown, false>;
41
- configurations: import("juniper").ObjectSchema<{}, never, boolean, import("juniper").EmptyIndex, (Record<string, unknown> & Partial<{
42
- __lifecycle: never;
43
- }>) | (Partial<{
67
+ }, "target">> & string), [], never, unknown, false>;
68
+ configurations: import("juniper").ObjectSchema<{}, never, boolean, import("juniper").EmptyIndex, (Partial<{
44
69
  __lifecycle: import("juniper").EmptyObject;
45
70
  }> & Required<Pick<{
46
71
  __lifecycle: import("juniper").EmptyObject;
47
- }, "__lifecycle">>), boolean>;
72
+ }, "__lifecycle">>) | (Record<string, unknown> & Partial<{
73
+ __lifecycle: never;
74
+ }>), boolean>;
48
75
  }, never, boolean, import("juniper").EmptyIndex, unknown, false>;
49
76
  export type Target = SchemaType<typeof targetSchema>;
50
77
  export declare const allTargetsSchema: import("juniper").ObjectSchema<{}, never, import("juniper").ObjectSchema<{
51
78
  executor: import("juniper").StringSchema<string, false>;
52
- dependsOn: import("juniper").ArraySchema<(string | (Partial<{
53
- projects: string | string[];
79
+ dependsOn: import("juniper").ArraySchema<string | (Partial<{
80
+ dependencies: boolean;
81
+ projects: never;
82
+ }> & Partial<{
83
+ target: string;
84
+ params: string;
54
85
  }> & Required<Pick<{
55
- projects: string | string[];
56
- }, "projects">> & Partial<{
86
+ target: string;
87
+ params: string;
88
+ }, "target">>) | (string & Partial<{
89
+ dependencies: boolean;
90
+ projects: never;
91
+ }> & Partial<{
57
92
  target: string;
58
93
  params: string;
59
94
  }> & Required<Pick<{
@@ -61,15 +96,30 @@ export declare const allTargetsSchema: import("juniper").ObjectSchema<{}, never,
61
96
  params: string;
62
97
  }, "target">>) | (Partial<{
63
98
  dependencies: boolean;
99
+ projects: never;
64
100
  }> & Partial<{
65
101
  target: string;
66
102
  params: string;
67
103
  }> & Required<Pick<{
68
104
  target: string;
69
105
  params: string;
70
- }, "target">>)) & (string | (Partial<{
106
+ }, "target">> & string) | (Partial<{
107
+ dependencies: never;
108
+ projects: string | string[];
109
+ }> & Required<Pick<{
110
+ dependencies: never;
111
+ projects: string | string[];
112
+ }, "projects">> & Partial<{
113
+ target: string;
114
+ params: string;
115
+ }> & Required<Pick<{
116
+ target: string;
117
+ params: string;
118
+ }, "target">>) | (string & Partial<{
119
+ dependencies: never;
71
120
  projects: string | string[];
72
121
  }> & Required<Pick<{
122
+ dependencies: never;
73
123
  projects: string | string[];
74
124
  }, "projects">> & Partial<{
75
125
  target: string;
@@ -78,21 +128,25 @@ export declare const allTargetsSchema: import("juniper").ObjectSchema<{}, never,
78
128
  target: string;
79
129
  params: string;
80
130
  }, "target">>) | (Partial<{
81
- dependencies: boolean;
82
- }> & Partial<{
131
+ dependencies: never;
132
+ projects: string | string[];
133
+ }> & Required<Pick<{
134
+ dependencies: never;
135
+ projects: string | string[];
136
+ }, "projects">> & Partial<{
83
137
  target: string;
84
138
  params: string;
85
139
  }> & Required<Pick<{
86
140
  target: string;
87
141
  params: string;
88
- }, "target">>) | undefined), [], never, unknown, false>;
89
- configurations: import("juniper").ObjectSchema<{}, never, boolean, import("juniper").EmptyIndex, (Record<string, unknown> & Partial<{
90
- __lifecycle: never;
91
- }>) | (Partial<{
142
+ }, "target">> & string), [], never, unknown, false>;
143
+ configurations: import("juniper").ObjectSchema<{}, never, boolean, import("juniper").EmptyIndex, (Partial<{
92
144
  __lifecycle: import("juniper").EmptyObject;
93
145
  }> & Required<Pick<{
94
146
  __lifecycle: import("juniper").EmptyObject;
95
- }, "__lifecycle">>), boolean>;
147
+ }, "__lifecycle">>) | (Record<string, unknown> & Partial<{
148
+ __lifecycle: never;
149
+ }>), boolean>;
96
150
  }, never, boolean, import("juniper").EmptyIndex, unknown, false>, import("juniper").EmptyIndex, unknown, false>;
97
151
  export type AllTargets = SchemaType<typeof allTargetsSchema>;
98
152
  export {};
package/executors.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "executors": {
3
3
  "lifecycle": {
4
- "implementation": "./dist/executors/lifecycle/index.cjs",
5
- "schema": "./src/lifecycle/schema.json",
4
+ "implementation": "./dist/executors/lifecycle/index.js",
5
+ "schema": "./out/nx-executor/schema.json",
6
6
  "description": "Keep nx lifecycle targets in sync."
7
7
  }
8
8
  }
@@ -0,0 +1,148 @@
1
+ {
2
+ "version": 1,
3
+ "outputCapture": "direct-nodejs",
4
+ "cli": "nx",
5
+ "oneOf": [
6
+ {
7
+ "type": "object",
8
+ "title": "lifecycle",
9
+ "description": "Inject Nx targets as high level workflows",
10
+ "additionalProperties": false,
11
+ "properties": {
12
+ "$schema": {
13
+ "type": "string",
14
+ "description": "Path or URL to the JSON schema for this file",
15
+ "examples": [
16
+ "https://raw.githubusercontent.com/JacobLey/leyman/refs/heads/main/apps/nx-lifecycle/src/lifecycle/schema.json"
17
+ ],
18
+ "format": "uri-reference"
19
+ },
20
+ "check": {
21
+ "type": "boolean",
22
+ "description": "Fails if references are not already updated, will not overwrite. Defaults to true during CI, false otherwise."
23
+ },
24
+ "dryRun": {
25
+ "type": "boolean",
26
+ "description": "Load files and content, but do not write anything."
27
+ },
28
+ "stages": {
29
+ "type": "object",
30
+ "description": "Lifecycle stages by name",
31
+ "additionalProperties": {
32
+ "type": "object",
33
+ "properties": {
34
+ "dependsOn": {
35
+ "type": "array",
36
+ "items": {
37
+ "oneOf": [
38
+ {
39
+ "type": "string"
40
+ },
41
+ {
42
+ "type": "object",
43
+ "oneOf": [
44
+ {
45
+ "properties": {
46
+ "dependencies": {
47
+ "type": "boolean"
48
+ },
49
+ "projects": {
50
+ "not": {}
51
+ }
52
+ }
53
+ },
54
+ {
55
+ "properties": {
56
+ "dependencies": {
57
+ "not": {}
58
+ },
59
+ "projects": {
60
+ "oneOf": [
61
+ {
62
+ "type": "array",
63
+ "items": {
64
+ "type": "string"
65
+ }
66
+ },
67
+ {
68
+ "type": "string"
69
+ }
70
+ ]
71
+ }
72
+ },
73
+ "required": [
74
+ "projects"
75
+ ]
76
+ }
77
+ ],
78
+ "properties": {
79
+ "target": {
80
+ "type": "string"
81
+ },
82
+ "params": {
83
+ "enum": [
84
+ "forward",
85
+ "ignore"
86
+ ]
87
+ }
88
+ },
89
+ "required": [
90
+ "target"
91
+ ]
92
+ }
93
+ ]
94
+ }
95
+ },
96
+ "hooks": {
97
+ "type": "array",
98
+ "items": {
99
+ "type": "string"
100
+ }
101
+ }
102
+ }
103
+ }
104
+ },
105
+ "bindings": {
106
+ "type": "object",
107
+ "description": "Bind targets to hooks",
108
+ "additionalProperties": {
109
+ "type": "string",
110
+ "description": "Name of hook in `stage:hook` format"
111
+ }
112
+ }
113
+ },
114
+ "required": [
115
+ "stages",
116
+ "bindings"
117
+ ]
118
+ },
119
+ {
120
+ "type": "object",
121
+ "additionalProperties": false,
122
+ "properties": {
123
+ "$schema": {
124
+ "type": "string",
125
+ "description": "Path or URL to the JSON schema for this file",
126
+ "examples": [
127
+ "https://raw.githubusercontent.com/JacobLey/leyman/refs/heads/main/apps/nx-lifecycle/src/lifecycle/schema.json"
128
+ ],
129
+ "format": "uri-reference"
130
+ },
131
+ "check": {
132
+ "type": "boolean",
133
+ "description": "Fails if references are not already updated, will not overwrite. Defaults to true during CI, false otherwise."
134
+ },
135
+ "dryRun": {
136
+ "type": "boolean",
137
+ "description": "Load files and content, but do not write anything."
138
+ },
139
+ "configFile": {
140
+ "type": "string"
141
+ },
142
+ "cwd": {
143
+ "type": "string"
144
+ }
145
+ }
146
+ }
147
+ ]
148
+ }
@@ -0,0 +1,114 @@
1
+ {
2
+ "type": "object",
3
+ "title": "lifecycle",
4
+ "description": "Inject Nx targets as high level workflows",
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "$schema": {
8
+ "type": "string",
9
+ "description": "Path or URL to the JSON schema for this file",
10
+ "examples": [
11
+ "https://raw.githubusercontent.com/JacobLey/leyman/refs/heads/main/apps/nx-lifecycle/src/lifecycle/schema.json"
12
+ ],
13
+ "format": "uri-reference"
14
+ },
15
+ "check": {
16
+ "type": "boolean",
17
+ "description": "Fails if references are not already updated, will not overwrite. Defaults to true during CI, false otherwise."
18
+ },
19
+ "dryRun": {
20
+ "type": "boolean",
21
+ "description": "Load files and content, but do not write anything."
22
+ },
23
+ "stages": {
24
+ "type": "object",
25
+ "description": "Lifecycle stages by name",
26
+ "additionalProperties": {
27
+ "type": "object",
28
+ "properties": {
29
+ "dependsOn": {
30
+ "type": "array",
31
+ "items": {
32
+ "oneOf": [
33
+ {
34
+ "type": "string"
35
+ },
36
+ {
37
+ "type": "object",
38
+ "oneOf": [
39
+ {
40
+ "properties": {
41
+ "dependencies": {
42
+ "type": "boolean"
43
+ },
44
+ "projects": {
45
+ "not": {}
46
+ }
47
+ }
48
+ },
49
+ {
50
+ "properties": {
51
+ "dependencies": {
52
+ "not": {}
53
+ },
54
+ "projects": {
55
+ "oneOf": [
56
+ {
57
+ "type": "array",
58
+ "items": {
59
+ "type": "string"
60
+ }
61
+ },
62
+ {
63
+ "type": "string"
64
+ }
65
+ ]
66
+ }
67
+ },
68
+ "required": [
69
+ "projects"
70
+ ]
71
+ }
72
+ ],
73
+ "properties": {
74
+ "target": {
75
+ "type": "string"
76
+ },
77
+ "params": {
78
+ "enum": [
79
+ "forward",
80
+ "ignore"
81
+ ]
82
+ }
83
+ },
84
+ "required": [
85
+ "target"
86
+ ]
87
+ }
88
+ ]
89
+ }
90
+ },
91
+ "hooks": {
92
+ "type": "array",
93
+ "items": {
94
+ "type": "string"
95
+ }
96
+ }
97
+ }
98
+ }
99
+ },
100
+ "bindings": {
101
+ "type": "object",
102
+ "description": "Bind targets to hooks",
103
+ "additionalProperties": {
104
+ "type": "string",
105
+ "description": "Name of hook in `stage:hook` format"
106
+ }
107
+ }
108
+ },
109
+ "required": [
110
+ "stages",
111
+ "bindings"
112
+ ],
113
+ "$schema": "https://json-schema.org/draft/2020-12/schema"
114
+ }