@codependix/nx 0.0.51 → 0.0.53

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/dist/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g } from "../plugin-context.utilities-Bc3NR0GZ.js";
1
+ import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, u as h, v as g } from "../plugin-context.utilities-AMq4HSG6.js";
2
2
  import _ from "node:path";
3
3
  import { existsSync as v, readFileSync as y, realpathSync as b, statSync as x } from "node:fs";
4
4
  import { createRequire as S } from "node:module";
@@ -19,11 +19,11 @@ function resolveToolInputs(e) {
19
19
  try {
20
20
  let t = locatePackage({
21
21
  fromFile: e.resolveFrom ?? import.meta.url,
22
- name: n
22
+ name: c
23
23
  });
24
24
  return t === void 0 ? (warnUnresolved({
25
25
  logger: e.logger,
26
- names: [n]
26
+ names: [c]
27
27
  }), []) : isInsideWorkspace({
28
28
  directory: t,
29
29
  workspaceRoot: e.workspaceRoot
@@ -32,24 +32,24 @@ function resolveToolInputs(e) {
32
32
  cliDirectory: t
33
33
  }) : resolveExternalInputs(t);
34
34
  } catch (t) {
35
- return e.logger.warn(`🕸️ Skipped the cache inputs of ${n}, so a change to it will not invalidate a cached codependix gate: ${String(t)}`), [];
35
+ return e.logger.warn(`🕸️ Skipped the cache inputs of ${c}, so a change to it will not invalidate a cached codependix gate: ${String(t)}`), [];
36
36
  }
37
37
  }
38
- function collectWorkspacePackages(e) {
39
- let t = /* @__PURE__ */ new Set([e]), n = /* @__PURE__ */ new Set(), r = [e];
40
- for (let e = r.pop(); e !== void 0; e = r.pop()) {
41
- let i = readDependencies(e).filter(([, e]) => String(e).startsWith(a)).map(([e]) => e);
42
- for (let a of i) {
43
- let i = locatePackage({
44
- fromFile: _.join(e, "package.json"),
45
- name: a
38
+ function collectWorkspacePackages(t) {
39
+ let n = /* @__PURE__ */ new Set([t]), r = /* @__PURE__ */ new Set(), i = [t];
40
+ for (let t = i.pop(); t !== void 0; t = i.pop()) {
41
+ let a = readDependencies(t).filter(([, t]) => String(t).startsWith(e)).map(([e]) => e);
42
+ for (let e of a) {
43
+ let a = locatePackage({
44
+ fromFile: _.join(t, "package.json"),
45
+ name: e
46
46
  });
47
- i === void 0 ? n.add(a) : t.has(i) || (t.add(i), r.push(i));
47
+ a === void 0 ? r.add(e) : n.has(a) || (n.add(a), i.push(a));
48
48
  }
49
49
  }
50
50
  return {
51
- directories: t,
52
- unresolved: [...n].toSorted()
51
+ directories: n,
52
+ unresolved: [...r].toSorted()
53
53
  };
54
54
  }
55
55
  function locatePackage(e) {
@@ -75,14 +75,14 @@ function readManifest(e) {
75
75
  }
76
76
  function resolveExternalInputs(e) {
77
77
  let t = readDependencies(e).map(([e]) => e).filter((e) => e.startsWith("@codependix/"));
78
- return [{ externalDependencies: [n, ...t].toSorted() }];
78
+ return [{ externalDependencies: [c, ...t].toSorted() }];
79
79
  }
80
80
  function resolveWorkspaceInputs(e) {
81
81
  let t = b(e.workspaceRoot), { directories: n, unresolved: r } = collectWorkspacePackages(e.cliDirectory);
82
82
  return r.length > 0 && warnUnresolved({
83
83
  logger: e.logger,
84
84
  names: r
85
- }), [...n].flatMap((e) => o.map((n) => `{workspaceRoot}/${_.relative(t, e)}/${n}`)).toSorted();
85
+ }), [...n].flatMap((e) => a.map((n) => `{workspaceRoot}/${_.relative(t, e)}/${n}`)).toSorted();
86
86
  }
87
87
  function toRecord(e) {
88
88
  return typeof e == "object" && e ? { ...e } : {};
@@ -91,19 +91,19 @@ function warnUnresolved(e) {
91
91
  e.logger.warn(`🕸️ Skipped the cache inputs of ${e.names.join(", ")}, which could not be resolved, so a change to ${e.names.length === 1 ? "it" : "them"} will not invalidate a cached codependix gate.`);
92
92
  }
93
93
  // src/modules/plugin/plugin-tsconfig.utilities.ts
94
- function resolveTsconfigInputs(t) {
94
+ function resolveTsconfigInputs(e) {
95
95
  try {
96
- let e = b(t.workspaceRoot), { files: n, packages: r } = followExtendsChain({
97
- logger: t.logger,
98
- workspaceRoot: e
99
- }), i = [...n].map((t) => `{workspaceRoot}/${_.relative(e, t).split(_.sep).join("/")}`).toSorted();
96
+ let t = b(e.workspaceRoot), { files: n, packages: r } = followExtendsChain({
97
+ logger: e.logger,
98
+ workspaceRoot: t
99
+ }), i = [...n].map((e) => `{workspaceRoot}/${_.relative(t, e).split(_.sep).join("/")}`).toSorted();
100
100
  return r.size === 0 ? i : [...i, { externalDependencies: [...r].toSorted() }];
101
- } catch (n) {
102
- return t.logger.warn(`🕸️ Skipped following the bases the root tsconfig.json extends, so a change to one will not invalidate a cached codependix gate: ${String(n)}`), [e];
101
+ } catch (t) {
102
+ return e.logger.warn(`🕸️ Skipped following the bases the root tsconfig.json extends, so a change to one will not invalidate a cached codependix gate: ${String(t)}`), [g];
103
103
  }
104
104
  }
105
105
  function describeSkippedBase(e) {
106
- return e.kind === "undeclared" ? `the root package.json does not declare ${e.name} from a registry` : l[e.kind];
106
+ return e.kind === "undeclared" ? `the root package.json does not declare ${e.name} from a registry` : o[e.kind];
107
107
  }
108
108
  function followExtendsChain(e) {
109
109
  let t = _.join(e.workspaceRoot, "tsconfig.json"), n = readRegistryDependencies(e.workspaceRoot), r = /* @__PURE__ */ new Set([t]), i = /* @__PURE__ */ new Set(), a = v(t) ? [t] : [];
@@ -141,7 +141,7 @@ function readInstalledPackageName(e) {
141
141
  if (n !== 0 && r !== void 0) return t.slice(n, r.startsWith("@") ? n + 2 : n + 1).join("/");
142
142
  }
143
143
  function readRegistryDependencies(e) {
144
- return new Set(readDependencies(e).filter(([, e]) => !r.some((t) => String(e).startsWith(t))).map(([e]) => e));
144
+ return new Set(readDependencies(e).filter(([, e]) => !i.some((t) => String(e).startsWith(t))).map(([e]) => e));
145
145
  }
146
146
  function resolveExtendedBase(e) {
147
147
  let t = e.specifier.replaceAll("\\", "/"), n = _.isAbsolute(t) || t.startsWith("./") || t.startsWith("../") ? resolvePathBase({
@@ -169,7 +169,7 @@ function resolveExtendedBase(e) {
169
169
  };
170
170
  }
171
171
  function resolvePackageBase(e) {
172
- let { specifier: t } = e, n = t.split("/").length > (t.startsWith("@") ? 2 : 1) ? [t, `${t}.json`] : [`${t}/${i}`, t], r = S(e.file), [a] = n.flatMap((e) => {
172
+ let { specifier: t } = e, n = t.split("/").length > (t.startsWith("@") ? 2 : 1) ? [t, `${t}.json`] : [`${t}/${f}`, t], r = S(e.file), [i] = n.flatMap((e) => {
173
173
  try {
174
174
  let t = b(r.resolve(e));
175
175
  return t.endsWith(".json") ? [t] : [];
@@ -177,7 +177,7 @@ function resolvePackageBase(e) {
177
177
  return [];
178
178
  }
179
179
  });
180
- return a;
180
+ return i;
181
181
  }
182
182
  function resolvePathBase(e) {
183
183
  let t = _.resolve(_.dirname(e.file), e.specifier), n = x(t, { throwIfNoEntry: !1 })?.isFile() === !0 || t.endsWith(".json") ? t : `${t}.json`;
@@ -188,8 +188,8 @@ function warnSkipped(e) {
188
188
  }
189
189
  // src/index.ts
190
190
  var T = {
191
- createNodes: [f, async (e, t, n) => {
192
- let r = (await u()).inferTargets({
191
+ createNodes: [l, async (e, t, n) => {
192
+ let r = (await p()).inferTargets({
193
193
  options: t,
194
194
  projectConfigurationFiles: e,
195
195
  toolInputs: [...resolveToolInputs({
@@ -208,4 +208,4 @@ var T = {
208
208
  }],
209
209
  name: "@codependix/nx"
210
210
  };
211
- export { c as CODEPENDIX_NX_PLUGIN_NAME, g as DEFAULT_GATE_TARGET_NAME, s as GateModule, t as GateService, p as MainModule, d as PluginModule, m as PluginService, T as default, h as resolveGateService, u as resolvePluginService };
211
+ export { h as CODEPENDIX_NX_PLUGIN_NAME, r as DEFAULT_GATE_TARGET_NAME, t as GateModule, d as GateService, s as MainModule, m as PluginModule, n as PluginService, T as default, u as resolveGateService, p as resolvePluginService };
package/executors.json CHANGED
@@ -2,8 +2,10 @@
2
2
  "$schema": "../../../../node_modules/nx/schemas/executors.json",
3
3
  "executors": {
4
4
  "gate": {
5
+ "batchImplementation": "@codependix/nx/src/executors/gate/batch-executor",
5
6
  "description": "Fail a project whose dependency graphs break a codependix boundary rule charged to it, built over the project and its Nx dependencies.",
6
7
  "implementation": "@codependix/nx/src/executors/gate/executor",
8
+ "preferBatch": true,
7
9
  "schema": "./src/executors/gate/schema.json"
8
10
  }
9
11
  }
package/package.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "url": "https://github.com/organizzolini/codebase/issues"
5
5
  },
6
6
  "dependencies": {
7
- "@codependix/cli": "0.0.65",
8
- "@codependix/configuration": "0.0.64",
7
+ "@codependix/cli": "0.0.67",
8
+ "@codependix/configuration": "0.0.66",
9
9
  "@nestjs/common": "^11.1.21 || ^12.0.1",
10
10
  "@nestjs/core": "^11.1.21 || ^12.0.1",
11
11
  "@nx/devkit": "^24.0.0",
@@ -77,5 +77,5 @@
77
77
  "strict": true
78
78
  },
79
79
  "types": "./dist/src/index.d.ts",
80
- "version": "0.0.51"
80
+ "version": "0.0.53"
81
81
  }
@@ -1,218 +0,0 @@
1
- import "reflect-metadata";
2
- import { NestFactory as e } from "@nestjs/core";
3
- import { Injectable as t, Module as n } from "@nestjs/common";
4
- import { ConfigurationModule as r, ConfigurationService as i } from "@codependix/configuration";
5
- import a from "node:path";
6
- import { spawn as o } from "node:child_process";
7
- import { readFileSync as s } from "node:fs";
8
- import { createRequire as c } from "node:module";
9
- import { pathToFileURL as l } from "node:url";
10
- // \0rolldown/runtime.js
11
- var u = Object.defineProperty, __name = (e, t) => u(e, "name", {
12
- value: t,
13
- configurable: !0
14
- }), d = "**/{project.json,codependix.config.*}", f = "project.json", p = "{projectRoot}/codependix.config.*", m = "__codependixPluginContext", h = "@codependix/nx", g = "codependix-bound", _ = "`configurationPath` option on the @codependix/nx plugin's entry in nx.json", v = "@codependix/cli", y = "workspace:", b = [
15
- "file:",
16
- "link:",
17
- "portal:",
18
- y
19
- ], x = ["package.json", "src/**/!(*.test.*|*.spec.*)"], S = "{workspaceRoot}/tsconfig.json", C = "tsconfig.json", w = {
20
- outside: "it lies outside the workspace",
21
- unresolved: "it resolves to no file"
22
- };
23
- // \0@oxc-project+runtime@0.155.0/helpers/esm/decorateMetadata.js
24
- function __decorateMetadata(e, t) {
25
- if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
26
- }
27
- // \0@oxc-project+runtime@0.155.0/helpers/esm/decorate.js
28
- function __decorate(e, t, n, r) {
29
- var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
30
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
31
- else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
32
- return i > 3 && a && Object.defineProperty(t, n, a), a;
33
- }
34
- // src/modules/plugin/plugin.service.ts
35
- var T = class PluginService {
36
- configurationService;
37
- constructor(e) {
38
- this.configurationService = e;
39
- }
40
- isUnknownArray(e) {
41
- return Array.isArray(e);
42
- }
43
- readString(e) {
44
- let t = e.record[e.key];
45
- return typeof t == "string" && t !== "" ? t : void 0;
46
- }
47
- selectProjectRoots(e) {
48
- return e.filter((e) => a.basename(e) === f).map((e) => a.dirname(e)).filter((e) => e !== ".");
49
- }
50
- toRecord(e) {
51
- return typeof e == "object" && e ? { ...e } : {};
52
- }
53
- inferTargets(e) {
54
- let t = this.resolvePluginOptions({ options: e.options }), n = { [t.gateTargetName]: {
55
- cache: !0,
56
- executor: `${h}:gate`,
57
- inputs: [
58
- "default",
59
- "^default",
60
- `{workspaceRoot}/${t.configurationPath}`,
61
- p,
62
- ...e.toolInputs
63
- ],
64
- options: {}
65
- } };
66
- return new Map(this.selectProjectRoots(e.projectConfigurationFiles).map((e) => [e, n]));
67
- }
68
- readRegisteredOptions(e) {
69
- let { plugins: t } = this.toRecord(e);
70
- if (!this.isUnknownArray(t)) return;
71
- let { options: n } = t.map((e) => this.toRecord(e)).find(({ plugin: e }) => e === "@codependix/nx") ?? {};
72
- return n;
73
- }
74
- resolvePluginOptions(e) {
75
- let t = this.toRecord(e.options);
76
- return {
77
- configurationPath: this.configurationService.requireConfigurationPath(this.readString({
78
- key: "configurationPath",
79
- record: t
80
- }), _),
81
- gateTargetName: this.readString({
82
- key: "gateTargetName",
83
- record: t
84
- }) ?? "codependix-bound"
85
- };
86
- }
87
- };
88
- T = __decorate([t(), __decorateMetadata("design:paramtypes", [i === void 0 ? Object : i])], T);
89
- // src/modules/plugin/plugin.module.ts
90
- var E = class PluginModule {};
91
- E = __decorate([n({
92
- controllers: [],
93
- exports: [T],
94
- imports: [r],
95
- providers: [T]
96
- })], E);
97
- // src/modules/gate/gate.constants.ts
98
- var D = "@codependix/nx/loader", O = "@codependix/cli/main", k = "nx.json", A = "`configuration` executor option", j = class GateService {
99
- configurationService;
100
- pluginService;
101
- constructor(e, t) {
102
- this.configurationService = e, this.pluginService = t;
103
- }
104
- judgesOwnProject(e) {
105
- return e.selection.tags.length === 0 && e.selection.projects.length === 1 && e.selection.projects[0] === e.projectName;
106
- }
107
- readNameList(e) {
108
- return (e ?? []).flatMap((e) => e.split(",")).map((e) => e.trim()).filter((e) => e !== "");
109
- }
110
- readNxConfiguration(e) {
111
- try {
112
- return JSON.parse(s(a.join(e, k), "utf8"));
113
- } catch {
114
- return;
115
- }
116
- }
117
- async spawnCommandLine(e) {
118
- return await new Promise((t, n) => {
119
- let r = o(process.execPath, e.argv, {
120
- cwd: e.workspaceRoot,
121
- stdio: [
122
- "ignore",
123
- "pipe",
124
- "pipe"
125
- ]
126
- });
127
- r.stdout.on("data", (e) => process.stdout.write(e)), r.stderr.on("data", (e) => process.stderr.write(e)), r.on("error", n), r.on("close", (e) => {
128
- t(e === 0);
129
- });
130
- });
131
- }
132
- buildCommandArguments(e) {
133
- return [
134
- "--import",
135
- e.loaderUrl,
136
- e.cliEntryPath,
137
- "map",
138
- "--directory",
139
- e.workspaceRoot,
140
- "--config",
141
- e.configurationPath,
142
- "--check",
143
- "boundaries",
144
- ...e.projects.length > 0 ? ["--projects", e.projects.join(",")] : [],
145
- ...e.tags.length > 0 ? ["--tags", e.tags.join(",")] : [],
146
- ...e.dependencies ? [] : ["--no-dependencies"]
147
- ];
148
- }
149
- resolveConfigurationPath(e) {
150
- return e.configuration === void 0 ? this.pluginService.resolvePluginOptions({ options: this.pluginService.readRegisteredOptions(this.readNxConfiguration(e.workspaceRoot)) }).configurationPath : this.configurationService.requireConfigurationPath(e.configuration, A);
151
- }
152
- resolveSelection(e) {
153
- let t = this.readNameList(e.options.projects), n = this.readNameList(e.options.tags);
154
- if (t.length > 0 || n.length > 0) return {
155
- projects: t,
156
- tags: n
157
- };
158
- if (e.projectName === void 0) throw Error("The codependix gate executor must be run against a project, or given `projects` or `tags`.");
159
- return {
160
- projects: [e.projectName],
161
- tags: n
162
- };
163
- }
164
- async run(e) {
165
- let t = this.resolveSelection(e);
166
- if (e.cached && !this.judgesOwnProject({
167
- ...e,
168
- selection: t
169
- })) throw Error("The codependix gate target judges projects its cache inputs do not cover, so it must set `cache: false`.");
170
- let n = this.buildCommandArguments({
171
- ...t,
172
- cliEntryPath: c(import.meta.url).resolve(O),
173
- configurationPath: this.resolveConfigurationPath({
174
- configuration: e.options.configuration,
175
- workspaceRoot: e.workspaceRoot
176
- }),
177
- dependencies: e.options.dependencies !== !1,
178
- loaderUrl: l(c(import.meta.url).resolve(D)).href,
179
- workspaceRoot: e.workspaceRoot
180
- });
181
- return await this.spawnCommandLine({
182
- argv: n,
183
- workspaceRoot: e.workspaceRoot
184
- });
185
- }
186
- };
187
- j = __decorate([t(), __decorateMetadata("design:paramtypes", [i === void 0 ? Object : i, T === void 0 ? Object : T])], j);
188
- // src/modules/gate/gate.module.ts
189
- var M = class GateModule {};
190
- M = __decorate([n({
191
- controllers: [],
192
- exports: [j],
193
- imports: [r, E],
194
- providers: [j]
195
- })], M);
196
- // src/codependix-nx.module.ts
197
- var N = class MainModule {};
198
- N = __decorate([n({
199
- controllers: [],
200
- exports: [M, E],
201
- imports: [M, E],
202
- providers: []
203
- })], N);
204
- // src/modules/plugin/plugin-context.utilities.ts
205
- async function resolveGateService() {
206
- return (await resolvePluginContext()).get(j);
207
- }
208
- async function resolvePluginService() {
209
- return (await resolvePluginContext()).get(T);
210
- }
211
- async function resolvePluginContext() {
212
- let t = globalThis;
213
- return t[m] ??= e.createApplicationContext(N, {
214
- abortOnError: !1,
215
- logger: !1
216
- }), await t[m];
217
- }
218
- export { S as _, j as a, v as c, b as d, C as f, y as g, x as h, M as i, h as l, w as m, resolvePluginService as n, E as o, d as p, N as r, T as s, resolveGateService as t, g as u, __name as v };