nx-lifecycle 1.1.2 → 1.1.4

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.
@@ -11,7 +11,7 @@ export const lifecycleCommand = {
11
11
  describe: 'Inject Nx targets as high level workflows',
12
12
  builder: (yargs)=>yargs.options({
13
13
  configFile: {
14
- describe: 'File that exports data content to populate',
14
+ describe: 'Config file with `stages` and `bindings`',
15
15
  type: 'string',
16
16
  default: 'lifecycle.json'
17
17
  },
@@ -1,20 +1,31 @@
1
1
  import { readFile, writeFile } from 'node:fs/promises';
2
2
  import { deepEqual } from 'fast-equals';
3
3
  import { formatFiles } from 'format-file';
4
+ import { hasCode } from 'unknown-error';
4
5
  import { assertNxJson, assertProjectJson } from '#schemas';
5
6
  import { normalizeOptions } from './normalizer.js';
6
7
  import { processNxAndProjectJsons } from './processor.js';
7
8
  const loadJsonConfigs = async ({ nxJsonPath, packageJsonPaths })=>{
8
9
  const [rawNxJson, ...rawProjectJsons] = await Promise.all([
9
10
  readFile(nxJsonPath, 'utf8'),
10
- ...packageJsonPaths.map(async ({ name, path })=>({
11
- name,
12
- path,
13
- rawData: await readFile(path, 'utf8')
14
- }))
11
+ ...packageJsonPaths.map(async ({ name, path })=>{
12
+ try {
13
+ return {
14
+ name,
15
+ path,
16
+ rawData: await readFile(path, 'utf8')
17
+ };
18
+ } catch (err) {
19
+ if (hasCode(err, 'ENOENT')) {
20
+ return null;
21
+ }
22
+ throw err;
23
+ }
24
+ })
15
25
  ]);
16
- const parsedNxJson = JSON.parse(rawNxJson);
26
+ let parsedNxJson;
17
27
  try {
28
+ parsedNxJson = JSON.parse(rawNxJson);
18
29
  assertNxJson(parsedNxJson);
19
30
  } catch (err) {
20
31
  throw new Error('Failed to parse nx.json', {
@@ -27,9 +38,10 @@ const loadJsonConfigs = async ({ nxJsonPath, packageJsonPaths })=>{
27
38
  path: nxJsonPath,
28
39
  data: parsedNxJson
29
40
  },
30
- projectJsons: rawProjectJsons.map(({ name, path, rawData })=>{
31
- const data = JSON.parse(rawData);
41
+ projectJsons: rawProjectJsons.filter((rawProjectJson)=>rawProjectJson !== null).map(({ name, path, rawData })=>{
42
+ let data;
32
43
  try {
44
+ data = JSON.parse(rawData);
33
45
  assertProjectJson(data);
34
46
  } catch (err) {
35
47
  throw new Error(`Failed to parse ${path}`, {
@@ -188,6 +188,9 @@ const processProjectJson = ({ projectJson, lifecycleTargets, registeredTargets,
188
188
  }
189
189
  for (const [targetName, target] of Object.entries(targets)){
190
190
  if (targetsToRemove.has(targetName) || lifecycleTargets.has(targetName)) {
191
+ if ('executor' in target || 'command' in target) {
192
+ throw new Error(`Overlap in lifecycle hook and project.json target: ${targetName}`);
193
+ }
191
194
  delete targets[targetName];
192
195
  } else if (target.dependsOn) {
193
196
  const processedTarget = {
@@ -30,8 +30,8 @@ export declare const stagesSchema: import("juniper").ObjectSchema<{}, never, imp
30
30
  params?: string;
31
31
  dependencies?: never;
32
32
  projects: (string | string[] | undefined) & (string | string[]);
33
- } & string), [], never, unknown, false>;
34
- hooks: import("juniper").ArraySchema<string, [], never, unknown, false>;
33
+ } & string), [], never, unknown, false, 0>;
34
+ hooks: import("juniper").ArraySchema<string, [], never, unknown, false, 0>;
35
35
  }, never, boolean, import("juniper").EmptyIndex, unknown, false>, import("juniper").EmptyIndex, unknown, false>;
36
36
  export declare const bindingsSchema: import("juniper").ObjectSchema<{}, never, import("juniper").StringSchema<string, false>, import("juniper").EmptyIndex, unknown, false>;
37
37
  declare const lifecycleOptionsSchema: import("juniper").ObjectSchema<{
@@ -70,8 +70,8 @@ declare const lifecycleOptionsSchema: import("juniper").ObjectSchema<{
70
70
  params?: string;
71
71
  dependencies?: never;
72
72
  projects: (string | string[] | undefined) & (string | string[]);
73
- } & string), [], never, unknown, false>;
74
- hooks: import("juniper").ArraySchema<string, [], never, unknown, false>;
73
+ } & string), [], never, unknown, false, 0>;
74
+ hooks: import("juniper").ArraySchema<string, [], never, unknown, false, 0>;
75
75
  }, never, boolean, import("juniper").EmptyIndex, unknown, false>, import("juniper").EmptyIndex, unknown, false>;
76
76
  bindings: import("juniper").ObjectSchema<{}, never, import("juniper").StringSchema<string, false>, import("juniper").EmptyIndex, unknown, false>;
77
77
  }, "bindings" | "stages", false, import("juniper").EmptyIndex, unknown, false>;
@@ -32,8 +32,8 @@ declare const lifecyclePluginOptionsSchema: import("juniper").ObjectSchema<{
32
32
  params?: string;
33
33
  dependencies?: never;
34
34
  projects: (string | string[] | undefined) & (string | string[]);
35
- } & string), [], never, unknown, false>;
36
- hooks: import("juniper").ArraySchema<string, [], never, unknown, false>;
35
+ } & string), [], never, unknown, false, 0>;
36
+ hooks: import("juniper").ArraySchema<string, [], never, unknown, false, 0>;
37
37
  }, never, boolean, import("juniper").EmptyIndex, unknown, false>, import("juniper").EmptyIndex, unknown, false>;
38
38
  bindings: import("juniper").ObjectSchema<{}, never, import("juniper").StringSchema<string, false>, import("juniper").EmptyIndex, unknown, false>;
39
39
  }, "bindings" | "stages", false, import("juniper").EmptyIndex, unknown, false>;
@@ -40,7 +40,7 @@ export declare const dependsOnSchema: import("juniper").ArraySchema<string | {
40
40
  params?: string;
41
41
  dependencies?: never;
42
42
  projects: (string | string[] | undefined) & (string | string[]);
43
- } & string), [], never, unknown, false>;
43
+ } & string), [], never, unknown, false, 0>;
44
44
  export type DependsOn = SchemaType<typeof dependsOnSchema>;
45
45
  export {};
46
46
  //# sourceMappingURL=depend-on.d.ts.map
@@ -1,7 +1,7 @@
1
+ export * from './configurations.js';
2
+ export * from './depend-on.js';
1
3
  export * from './empty.js';
2
4
  export * from './nx-json.js';
3
5
  export * from './project-json.js';
4
- export * from './configurations.js';
5
- export * from './depend-on.js';
6
6
  export * from './target.js';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,8 @@
1
+ export * from './configurations.js';
2
+ export * from './depend-on.js';
1
3
  export * from './empty.js';
2
4
  export * from './nx-json.js';
3
5
  export * from './project-json.js';
4
- export * from './configurations.js';
5
- export * from './depend-on.js';
6
6
  export * from './target.js';
7
7
 
8
8
  //# sourceMappingURL=index.js.map
@@ -3,6 +3,7 @@ import type { JuniperValidator } from 'juniper-validator';
3
3
  declare const nxJsonSchema: import("juniper").ObjectSchema<{
4
4
  targetDefaults: import("juniper").ObjectSchema<{}, never, import("juniper").ObjectSchema<{
5
5
  executor: import("juniper").StringSchema<string, false>;
6
+ command: import("juniper").StringSchema<string, false>;
6
7
  dependsOn: import("juniper").ArraySchema<string | {
7
8
  target: string;
8
9
  params?: string;
@@ -33,7 +34,7 @@ declare const nxJsonSchema: import("juniper").ObjectSchema<{
33
34
  params?: string;
34
35
  dependencies?: never;
35
36
  projects: (string | string[] | undefined) & (string | string[]);
36
- } & string), [], never, unknown, false>;
37
+ } & string), [], never, unknown, false, 0>;
37
38
  configurations: import("juniper").ObjectSchema<{}, never, boolean, import("juniper").EmptyIndex, {
38
39
  [x: string]: unknown;
39
40
  __lifecycle?: never;
@@ -3,6 +3,7 @@ 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
+ command: import("juniper").StringSchema<string, false>;
6
7
  dependsOn: import("juniper").ArraySchema<string | {
7
8
  target: string;
8
9
  params?: string;
@@ -33,7 +34,7 @@ declare const projectJsonSchema: import("juniper").ObjectSchema<{
33
34
  params?: string;
34
35
  dependencies?: never;
35
36
  projects: (string | string[] | undefined) & (string | string[]);
36
- } & string), [], never, unknown, false>;
37
+ } & string), [], never, unknown, false, 0>;
37
38
  configurations: import("juniper").ObjectSchema<{}, never, boolean, import("juniper").EmptyIndex, {
38
39
  [x: string]: unknown;
39
40
  __lifecycle?: never;
@@ -1,6 +1,7 @@
1
1
  import type { SchemaType } from 'juniper';
2
2
  declare const targetSchema: import("juniper").ObjectSchema<{
3
3
  executor: import("juniper").StringSchema<string, false>;
4
+ command: import("juniper").StringSchema<string, false>;
4
5
  dependsOn: import("juniper").ArraySchema<string | {
5
6
  target: string;
6
7
  params?: string;
@@ -31,7 +32,7 @@ declare const targetSchema: import("juniper").ObjectSchema<{
31
32
  params?: string;
32
33
  dependencies?: never;
33
34
  projects: (string | string[] | undefined) & (string | string[]);
34
- } & string), [], never, unknown, false>;
35
+ } & string), [], never, unknown, false, 0>;
35
36
  configurations: import("juniper").ObjectSchema<{}, never, boolean, import("juniper").EmptyIndex, {
36
37
  [x: string]: unknown;
37
38
  __lifecycle?: never;
@@ -42,6 +43,7 @@ declare const targetSchema: import("juniper").ObjectSchema<{
42
43
  export type Target = SchemaType<typeof targetSchema>;
43
44
  export declare const allTargetsSchema: import("juniper").ObjectSchema<{}, never, import("juniper").ObjectSchema<{
44
45
  executor: import("juniper").StringSchema<string, false>;
46
+ command: import("juniper").StringSchema<string, false>;
45
47
  dependsOn: import("juniper").ArraySchema<string | {
46
48
  target: string;
47
49
  params?: string;
@@ -72,7 +74,7 @@ export declare const allTargetsSchema: import("juniper").ObjectSchema<{}, never,
72
74
  params?: string;
73
75
  dependencies?: never;
74
76
  projects: (string | string[] | undefined) & (string | string[]);
75
- } & string), [], never, unknown, false>;
77
+ } & string), [], never, unknown, false, 0>;
76
78
  configurations: import("juniper").ObjectSchema<{}, never, boolean, import("juniper").EmptyIndex, {
77
79
  [x: string]: unknown;
78
80
  __lifecycle?: never;
@@ -4,6 +4,7 @@ import { dependsOnSchema } from './depend-on.js';
4
4
  const targetSchema = objectSchema({
5
5
  properties: {
6
6
  executor: stringSchema(),
7
+ command: stringSchema(),
7
8
  dependsOn: dependsOnSchema,
8
9
  configurations: configurationsSchema
9
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx-lifecycle",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Nx plugin that derives every dependsOn from declared lifecycle stages (build, test, …) and the targets bound to them.",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -45,6 +45,7 @@
45
45
  "bin.mjs",
46
46
  "executors.json",
47
47
  "out",
48
+ "!out/.generated.json",
48
49
  "WHY-NX-LIFECYCLE.md"
49
50
  ],
50
51
  "imports": {
@@ -58,16 +59,16 @@
58
59
  "lifecycle": "./bin.mjs"
59
60
  },
60
61
  "dependencies": {
61
- "@nx/devkit": "^23.2.1",
62
+ "@nx/devkit": "^23.3.0",
62
63
  "ci-info": "^4.4.0",
63
- "entry-script": "^4.1.0",
64
+ "entry-script": "^4.1.1",
64
65
  "fast-equals": "^6.0.4",
65
- "format-file": "^1.0.2",
66
- "haywire": "^2.0.0",
67
- "haywire-launcher": "^1.0.2",
68
- "juniper": "^2.2.1",
69
- "juniper-validator": "^0.3.0",
70
- "nx": "^23.2.1",
66
+ "format-file": "^1.0.3",
67
+ "haywire": "^2.0.2",
68
+ "haywire-launcher": "^1.1.0",
69
+ "juniper": "^2.4.1",
70
+ "juniper-validator": "^0.5.0",
71
+ "nx": "^23.3.0",
71
72
  "parse-cwd": "^2.0.2",
72
73
  "unknown-error": "^0.1.0",
73
74
  "yargs": "^18.2.0"
@@ -83,10 +84,11 @@
83
84
  "@types/sinon": "^22.0.0",
84
85
  "@types/yargs": "^17.0.35",
85
86
  "@typescript/native": "npm:typescript@^7.0.2",
87
+ "barrelify": "^2.2.1",
86
88
  "c8": "^12.0.0",
87
89
  "eslint": "^10.12.0",
88
90
  "expect-type": "^1.4.0",
89
- "load-populate-files": "^1.0.3",
91
+ "load-populate-files": "^1.1.2",
90
92
  "mocha": "^12.0.2",
91
93
  "mocha-chain": "^1.0.1",
92
94
  "sinon": "^22.1.0",