@uxf/scripts 11.129.0 → 12.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 CHANGED
@@ -118,7 +118,13 @@ notify-push:
118
118
  All-in-one dependency health check for projects using `@uxf/*` packages. Runs two checks:
119
119
 
120
120
  1. **Version conflict detection** — reports dependencies where the project and/or `@uxf/*` packages themselves resolve to different versions. Transitive-only duplicates (a dep pulled in by unrelated third-party packages at a different version) are ignored, since they don't affect `@uxf/*` compatibility.
121
- 2. **Peer dependency check** — verifies that all `peerDependencies` of installed `@uxf/*` packages are present and version-matched.
121
+ 2. **Peer dependency check** — verifies that all `peerDependencies` of installed `@uxf/*` packages are present and version-matched. `react`, `react-dom` and `next` are skipped, since a consumer always supplies those itself.
122
+
123
+ `@uxf/*` peers are checked like any other, and walked into: `@uxf/ui` peers `@uxf/core-react`, which peers `@uxf/core`, so a project listing only `@uxf/ui` is told to add all three. Neither yarn nor npm installs a peer of a peer, so without this the missing packages only show up as a build-time `Cannot find module`. The walk stops wherever a package is absent from `node_modules`, because its own peers cannot be read yet — `--fix` therefore installs what it found and repeats the collection until a pass adds nothing new.
124
+
125
+ A version mismatch on an `@uxf/*` package is reported but never auto-installed. Resolving a mismatch means installing `name@expected`, and for UXF packages that expected value is an exact pin taken from whichever package lags behind — so `--fix` would downgrade a package you bumped on purpose (`@uxf/data-grid@11.129.0` pins `@uxf/core@11.129.0`, and a project on `@uxf/core@11.131.0` would be pulled back). UXF packages move in lockstep, so the check points at `yarn up "@uxf/*"` instead. A _missing_ `@uxf/*` package is still installed by `--fix`, since adding one cannot downgrade anything.
126
+
127
+ A dependency pinned to a source rather than a version (`file:`, `link:`, `portal:`, `patch:`, `workspace:`, an `npm:` alias, a git URL) has no version to compare, so it is listed under **Overridden, so not version-checked** and never counted as a mismatch — that is what keeps the `file:../fe-monorepo/packages/<name>` local-testing flow green. A yarn `resolutions` entry is invisible to the check either way, since only `dependencies` and `devDependencies` are read.
122
128
 
123
129
  Supports **yarn**, **npm**, **pnpm**, and **bun**. The package manager is auto-detected from the lock file.
124
130
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/scripts",
3
- "version": "11.129.0",
3
+ "version": "12.1.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -46,6 +46,6 @@
46
46
  "@types/react-dom": "18.3.7",
47
47
  "@types/semver": "^7.7.1",
48
48
  "@uxf/core": "11.129.0",
49
- "@uxf/ui": "11.129.0"
49
+ "@uxf/ui": "12.1.1"
50
50
  }
51
51
  }
@@ -18,6 +18,45 @@ function readProjectPackageJson(cwd) {
18
18
  return null;
19
19
  }
20
20
  }
21
+ /** Upper bound on the install/re-collect cycle in `--fix`; the @uxf peer graph is far shallower. */
22
+ const MAX_FIX_PASSES = 5;
23
+ /**
24
+ * Installs, re-collects, and repeats.
25
+ *
26
+ * Installing an `@uxf/*` peer puts a package into node_modules whose own peers could not be read
27
+ * before, so one pass is not enough. The @uxf graph is a DAG, so this terminates on its own;
28
+ * MAX_FIX_PASSES only guards against an install that never satisfies the requirement it was meant to
29
+ * satisfy. Every install is verified, the last one included.
30
+ */
31
+ function runFixPasses(initial, ctx) {
32
+ let pending = initial;
33
+ for (let pass = 0; pass < MAX_FIX_PASSES; pass++) {
34
+ const didInstall = (0, peer_deps_1.installDeps)(pending.missing, pending.mismatched, ctx.pm);
35
+ const projectPkg = readProjectPackageJson(ctx.cwd);
36
+ if (!projectPkg) {
37
+ console.error("\nCould not re-read package.json after installing."); // eslint-disable-line no-console
38
+ return 1;
39
+ }
40
+ const required = (0, peer_deps_1.collectRequiredPeerDeps)((0, peer_deps_1.findInstalledUxfPackages)(projectPkg), ctx.nodeModulesPath, projectPkg);
41
+ pending = (0, peer_deps_1.findMissingOrMismatchedDeps)(required, projectPkg);
42
+ if (pending.missing.size === 0 && pending.mismatched.size === 0) {
43
+ console.log("\nAll peer dependencies are now installed."); // eslint-disable-line no-console
44
+ return 0;
45
+ }
46
+ // Nothing was installed and something is still outstanding, so another pass would repeat this
47
+ // one. That is the @uxf/* mismatch case, which --fix deliberately leaves alone.
48
+ if (!didInstall) {
49
+ break;
50
+ }
51
+ }
52
+ console.log("\nStill outstanding:"); // eslint-disable-line no-console
53
+ (0, peer_deps_1.printPeerDepsReport)(pending.missing, pending.mismatched, pending.overridden);
54
+ (0, peer_deps_1.printUxfMismatchGuidance)(pending.mismatched, ctx.pm);
55
+ if (pending.missing.size > 0 || (0, peer_deps_1.splitFixableMismatches)(pending.mismatched).fixable.size > 0) {
56
+ console.error(`\nStill unresolved after ${MAX_FIX_PASSES} passes — resolve the rest by hand.`); // eslint-disable-line no-console
57
+ }
58
+ return 1;
59
+ }
21
60
  async function checkUxfDependencies(options) {
22
61
  const cwd = process.cwd();
23
62
  const pm = (0, detect_package_manager_1.detectPackageManager)(cwd);
@@ -74,18 +113,18 @@ async function checkUxfDependencies(options) {
74
113
  }
75
114
  // --- Peer dependency check ---
76
115
  const requiredPeerDeps = (0, peer_deps_1.collectRequiredPeerDeps)(uxfPackages, nodeModulesPath, projectPkg);
77
- const { missing, mismatched } = (0, peer_deps_1.findMissingOrMismatchedDeps)(requiredPeerDeps, projectPkg);
116
+ const { missing, mismatched, overridden } = (0, peer_deps_1.findMissingOrMismatchedDeps)(requiredPeerDeps, projectPkg);
78
117
  if (missing.size === 0 && mismatched.size === 0) {
118
+ (0, peer_deps_1.printPeerDepsReport)(missing, mismatched, overridden);
79
119
  console.log("All peer dependencies are correctly installed."); // eslint-disable-line no-console
80
120
  return hasIssues ? 1 : 0;
81
121
  }
82
- (0, peer_deps_1.printPeerDepsReport)(missing, mismatched);
122
+ (0, peer_deps_1.printPeerDepsReport)(missing, mismatched, overridden);
83
123
  hasIssues = true;
84
124
  if (options.isDryRun || !options.isFix) {
85
125
  (0, peer_deps_1.printSuggestedCommands)(missing, mismatched, pm);
126
+ (0, peer_deps_1.printUxfMismatchGuidance)(mismatched, pm);
86
127
  return 1;
87
128
  }
88
- (0, peer_deps_1.installDeps)(missing, mismatched, pm);
89
- console.log("\nAll peer dependencies are now installed."); // eslint-disable-line no-console
90
- return 0;
129
+ return runFixPasses({ missing, mismatched, overridden }, { cwd, nodeModulesPath, pm });
91
130
  }
@@ -1,10 +1,33 @@
1
1
  import type { DepInfo, MismatchInfo, PackageJson, PackageManager } from "./types";
2
2
  export declare function findInstalledUxfPackages(projectPkg: PackageJson): string[];
3
3
  export declare function collectRequiredPeerDeps(uxfPackages: string[], nodeModulesPath: string, projectPkg: PackageJson): Map<string, DepInfo>;
4
+ /**
5
+ * A spec that names a source rather than a version range: `file:`, `link:`, `portal:`, `patch:`,
6
+ * `workspace:`, `npm:` aliases, `git+ssh:`, `github:`. There is no version to compare, and every
7
+ * one of them is a deliberate override — the `file:../fe-monorepo/packages/<name>` local-testing
8
+ * flow being the common case — so the check reports them instead of calling them a mismatch.
9
+ */
10
+ export declare function isOverrideSpec(spec: string): boolean;
4
11
  export declare function findMissingOrMismatchedDeps(requiredPeerDeps: Map<string, DepInfo>, projectPkg: PackageJson): {
5
12
  missing: Map<string, DepInfo>;
6
13
  mismatched: Map<string, MismatchInfo>;
14
+ overridden: Map<string, string>;
7
15
  };
8
- export declare function printPeerDepsReport(missing: Map<string, DepInfo>, mismatched: Map<string, MismatchInfo>): void;
16
+ export declare function printPeerDepsReport(missing: Map<string, DepInfo>, mismatched: Map<string, MismatchInfo>, overridden?: Map<string, string>): void;
17
+ /**
18
+ * Splits version mismatches into the ones `--fix` may install and the ones it must not.
19
+ *
20
+ * `installDeps` resolves a mismatch by installing `name@expected`, and `expected` is whatever the
21
+ * peer declares. For `@uxf/*` that is an exact pin, so a project deliberately ahead of one package
22
+ * would be *downgraded* to match the one that lags: `@uxf/data-grid@11.129.0` pins
23
+ * `@uxf/core@11.129.0`, and a project on `@uxf/core@11.131.0` would be pulled back. UXF packages move
24
+ * in lockstep via `yarn up "@uxf/*"`, so the drift is worth reporting but never worth auto-resolving.
25
+ */
26
+ export declare function splitFixableMismatches(mismatched: Map<string, MismatchInfo>): {
27
+ fixable: Map<string, MismatchInfo>;
28
+ uxf: Map<string, MismatchInfo>;
29
+ };
30
+ export declare function printUxfMismatchGuidance(mismatched: Map<string, MismatchInfo>, pm: PackageManager): void;
9
31
  export declare function printSuggestedCommands(missing: Map<string, DepInfo>, mismatched: Map<string, MismatchInfo>, pm: PackageManager): void;
10
- export declare function installDeps(missing: Map<string, DepInfo>, mismatched: Map<string, MismatchInfo>, pm: PackageManager): void;
32
+ /** Returns whether anything was actually installed, so a fix loop can tell progress from a stall. */
33
+ export declare function installDeps(missing: Map<string, DepInfo>, mismatched: Map<string, MismatchInfo>, pm: PackageManager): boolean;
@@ -5,8 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.findInstalledUxfPackages = findInstalledUxfPackages;
7
7
  exports.collectRequiredPeerDeps = collectRequiredPeerDeps;
8
+ exports.isOverrideSpec = isOverrideSpec;
8
9
  exports.findMissingOrMismatchedDeps = findMissingOrMismatchedDeps;
9
10
  exports.printPeerDepsReport = printPeerDepsReport;
11
+ exports.splitFixableMismatches = splitFixableMismatches;
12
+ exports.printUxfMismatchGuidance = printUxfMismatchGuidance;
10
13
  exports.printSuggestedCommands = printSuggestedCommands;
11
14
  exports.installDeps = installDeps;
12
15
  const child_process_1 = require("child_process");
@@ -24,20 +27,45 @@ function collectRequiredPeerDeps(uxfPackages, nodeModulesPath, projectPkg) {
24
27
  var _a;
25
28
  const prodDeps = new Set(Object.keys((_a = projectPkg.dependencies) !== null && _a !== void 0 ? _a : {}));
26
29
  const peerDeps = new Map();
27
- for (const uxfPkg of uxfPackages) {
30
+ // @uxf/* peers are reported like any other, and walked into: @uxf/ui peers @uxf/core-react,
31
+ // which peers @uxf/core, and a project that lists only @uxf/ui needs all three. Neither yarn nor
32
+ // npm installs a peer of a peer, so without this walk the missing ones surface as a build-time
33
+ // "Cannot find module", never as a check failure.
34
+ //
35
+ // The walk stops wherever a package is absent from node_modules, since its own peers cannot be
36
+ // read. `--fix` therefore installs what it found and runs the collection again, until a pass
37
+ // adds nothing new.
38
+ const visited = new Map();
39
+ const queue = uxfPackages.map((name) => ({
40
+ isDev: !prodDeps.has(name),
41
+ name,
42
+ }));
43
+ while (queue.length > 0) {
44
+ const { isDev: isRequirerDev, name: uxfPkg } = queue.shift();
45
+ // Re-visit only to upgrade a package from dev to prod, so that a prod requirer found later
46
+ // still promotes everything below it.
47
+ const seenAsDev = visited.get(uxfPkg);
48
+ if (seenAsDev !== undefined && (seenAsDev === isRequirerDev || !seenAsDev)) {
49
+ continue;
50
+ }
51
+ visited.set(uxfPkg, isRequirerDev);
28
52
  const pkgJsonPath = path_1.default.join(nodeModulesPath, uxfPkg, "package.json");
29
53
  const pkgJson = (0, package_json_1.readPackageJson)(pkgJsonPath);
30
54
  if (!(pkgJson === null || pkgJson === void 0 ? void 0 : pkgJson.peerDependencies)) {
31
55
  continue;
32
56
  }
33
- const isRequirerDev = !prodDeps.has(uxfPkg);
34
57
  for (const [depName, depVersion] of Object.entries(pkgJson.peerDependencies)) {
35
- if (!depVersion || depName.startsWith("@uxf/") || CONSUMER_PROVIDED.has(depName)) {
58
+ if (!depVersion || CONSUMER_PROVIDED.has(depName)) {
36
59
  continue;
37
60
  }
61
+ if (depName.startsWith("@uxf/")) {
62
+ queue.push({ isDev: isRequirerDev, name: depName });
63
+ }
38
64
  const existing = peerDeps.get(depName);
39
65
  if (existing) {
40
- existing.requiredBy.push(uxfPkg);
66
+ if (!existing.requiredBy.includes(uxfPkg)) {
67
+ existing.requiredBy.push(uxfPkg);
68
+ }
41
69
  // If any requirer is a prod dependency, the peer dep should be prod too
42
70
  if (!isRequirerDev) {
43
71
  existing.isDev = false;
@@ -50,13 +78,21 @@ function collectRequiredPeerDeps(uxfPackages, nodeModulesPath, projectPkg) {
50
78
  }
51
79
  return peerDeps;
52
80
  }
81
+ /**
82
+ * A spec that names a source rather than a version range: `file:`, `link:`, `portal:`, `patch:`,
83
+ * `workspace:`, `npm:` aliases, `git+ssh:`, `github:`. There is no version to compare, and every
84
+ * one of them is a deliberate override — the `file:../fe-monorepo/packages/<name>` local-testing
85
+ * flow being the common case — so the check reports them instead of calling them a mismatch.
86
+ */
87
+ function isOverrideSpec(spec) {
88
+ return /^[a-z][a-z0-9+.-]*:/i.test(spec);
89
+ }
53
90
  /**
54
91
  * Whether `installed` is guaranteed to satisfy the peer-dep range `required`.
55
92
  *
56
- * Project specs can be exact pins (`6.0.3`), ranges (`^18.2.0`), or non-semver
57
- * (workspace:*, file:..., git+...). Peer specs can be any range expression.
58
- * Checks range subset so any version permitted by the project spec also
59
- * satisfies the peer range. Falls back to string equality for non-semver specs.
93
+ * Project specs can be exact pins (`6.0.3`) or ranges (`^18.2.0`); peer specs can be any range
94
+ * expression. Checks range subset so any version permitted by the project spec also satisfies the
95
+ * peer range. Falls back to string equality for anything semver cannot parse.
60
96
  */
61
97
  function isCompatible(installed, required) {
62
98
  try {
@@ -73,18 +109,29 @@ function findMissingOrMismatchedDeps(requiredPeerDeps, projectPkg) {
73
109
  const allProjectDeps = { ...projectPkg.dependencies, ...projectPkg.devDependencies };
74
110
  const missing = new Map();
75
111
  const mismatched = new Map();
112
+ const overridden = new Map();
76
113
  for (const [depName, { version, requiredBy, isDev }] of requiredPeerDeps) {
77
114
  const installedVersion = allProjectDeps[depName];
78
115
  if (!installedVersion) {
79
116
  missing.set(depName, { version, requiredBy, isDev });
80
117
  }
118
+ else if (isOverrideSpec(installedVersion)) {
119
+ overridden.set(depName, installedVersion);
120
+ }
81
121
  else if (!isCompatible(installedVersion, version)) {
82
122
  mismatched.set(depName, { expected: version, actual: installedVersion, requiredBy, isDev });
83
123
  }
84
124
  }
85
- return { missing, mismatched };
125
+ return { missing, mismatched, overridden };
86
126
  }
87
- function printPeerDepsReport(missing, mismatched) {
127
+ function printPeerDepsReport(missing, mismatched, overridden = new Map()) {
128
+ if (overridden.size > 0) {
129
+ console.log("Overridden, so not version-checked:"); // eslint-disable-line no-console
130
+ for (const [name, spec] of overridden) {
131
+ console.log(` ${name}: ${spec}`); // eslint-disable-line no-console
132
+ }
133
+ console.log(); // eslint-disable-line no-console
134
+ }
88
135
  if (missing.size > 0) {
89
136
  console.log("Missing peer dependencies:"); // eslint-disable-line no-console
90
137
  for (const [name, { version, requiredBy, isDev }] of missing) {
@@ -103,6 +150,37 @@ function printPeerDepsReport(missing, mismatched) {
103
150
  console.log(); // eslint-disable-line no-console
104
151
  }
105
152
  }
153
+ /**
154
+ * Splits version mismatches into the ones `--fix` may install and the ones it must not.
155
+ *
156
+ * `installDeps` resolves a mismatch by installing `name@expected`, and `expected` is whatever the
157
+ * peer declares. For `@uxf/*` that is an exact pin, so a project deliberately ahead of one package
158
+ * would be *downgraded* to match the one that lags: `@uxf/data-grid@11.129.0` pins
159
+ * `@uxf/core@11.129.0`, and a project on `@uxf/core@11.131.0` would be pulled back. UXF packages move
160
+ * in lockstep via `yarn up "@uxf/*"`, so the drift is worth reporting but never worth auto-resolving.
161
+ */
162
+ function splitFixableMismatches(mismatched) {
163
+ const fixable = new Map();
164
+ const uxf = new Map();
165
+ for (const [name, info] of mismatched) {
166
+ if (name.startsWith("@uxf/")) {
167
+ uxf.set(name, info);
168
+ }
169
+ else {
170
+ fixable.set(name, info);
171
+ }
172
+ }
173
+ return { fixable, uxf };
174
+ }
175
+ function printUxfMismatchGuidance(mismatched, pm) {
176
+ const { uxf } = splitFixableMismatches(mismatched);
177
+ if (uxf.size === 0) {
178
+ return;
179
+ }
180
+ // eslint-disable-next-line no-console
181
+ console.log(`The @uxf/* versions above are not auto-installed, because pinning them to a peer's version can\n` +
182
+ `downgrade a package you bumped on purpose. Move them together instead:\n ${pm} up "@uxf/*"\n`);
183
+ }
106
184
  function formatInstallArgs(packages) {
107
185
  return Array.from(packages.entries()).map(([name, version]) => `${name}@${version}`);
108
186
  }
@@ -145,8 +223,9 @@ function printSuggestedCommands(missing, mismatched, pm) {
145
223
  console.log(`To install missing dev dependencies, run:\n ${cmd} ${addArg} -D ${pkgs}\n`); // eslint-disable-line no-console
146
224
  }
147
225
  }
148
- if (mismatched.size > 0) {
149
- const { prod, dev } = splitMismatchesByDevFlag(mismatched);
226
+ const { fixable } = splitFixableMismatches(mismatched);
227
+ if (fixable.size > 0) {
228
+ const { prod, dev } = splitMismatchesByDevFlag(fixable);
150
229
  if (prod.size > 0) {
151
230
  const pkgs = formatInstallArgs(prod).join(" ");
152
231
  console.log(`To fix version mismatches, run:\n ${cmd} ${addArg} ${pkgs}\n`); // eslint-disable-line no-console
@@ -157,32 +236,40 @@ function printSuggestedCommands(missing, mismatched, pm) {
157
236
  }
158
237
  }
159
238
  }
239
+ /** Returns whether anything was actually installed, so a fix loop can tell progress from a stall. */
160
240
  function installDeps(missing, mismatched, pm) {
161
241
  const { cmd, addArg } = (0, detect_package_manager_1.getInstallCommand)(pm);
242
+ const { fixable } = splitFixableMismatches(mismatched);
243
+ let didInstall = false;
162
244
  if (missing.size > 0) {
163
245
  const { prod, dev } = splitDepsByDevFlag(missing);
164
246
  if (prod.size > 0) {
165
247
  const pkgs = formatInstallArgs(prod);
166
248
  console.log("Installing missing dependencies..."); // eslint-disable-line no-console
167
249
  (0, child_process_1.execFileSync)(cmd, [addArg, ...pkgs], { stdio: "inherit", cwd: process.cwd() });
250
+ didInstall = true;
168
251
  }
169
252
  if (dev.size > 0) {
170
253
  const pkgs = formatInstallArgs(dev);
171
254
  console.log("Installing missing dev dependencies..."); // eslint-disable-line no-console
172
255
  (0, child_process_1.execFileSync)(cmd, [addArg, "-D", ...pkgs], { stdio: "inherit", cwd: process.cwd() });
256
+ didInstall = true;
173
257
  }
174
258
  }
175
- if (mismatched.size > 0) {
176
- const { prod, dev } = splitMismatchesByDevFlag(mismatched);
259
+ if (fixable.size > 0) {
260
+ const { prod, dev } = splitMismatchesByDevFlag(fixable);
177
261
  if (prod.size > 0) {
178
262
  const pkgs = formatInstallArgs(prod);
179
263
  console.log("Fixing version mismatches..."); // eslint-disable-line no-console
180
264
  (0, child_process_1.execFileSync)(cmd, [addArg, ...pkgs], { stdio: "inherit", cwd: process.cwd() });
265
+ didInstall = true;
181
266
  }
182
267
  if (dev.size > 0) {
183
268
  const pkgs = formatInstallArgs(dev);
184
269
  console.log("Fixing dev version mismatches..."); // eslint-disable-line no-console
185
270
  (0, child_process_1.execFileSync)(cmd, [addArg, "-D", ...pkgs], { stdio: "inherit", cwd: process.cwd() });
271
+ didInstall = true;
186
272
  }
187
273
  }
274
+ return didInstall;
188
275
  }