rolldown-pnpm-config 0.5.0 → 0.5.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.
@@ -12,7 +12,7 @@ const root = Command.make("rolldown-pnpm-config").pipe(Command.withSubcommands([
12
12
  exportCommand,
13
13
  previewCommand
14
14
  ]));
15
- Command.run(root, { version: "0.5.0" }).pipe(Effect.provide(NodeServices.layer), NodeRuntime.runMain);
15
+ Command.run(root, { version: "0.5.1" }).pipe(Effect.provide(NodeServices.layer), NodeRuntime.runMain);
16
16
 
17
17
  //#endregion
18
18
  export { };
@@ -8,7 +8,7 @@ import { buildEdits } from "../edits.js";
8
8
  import { buildInteropEdits, interopEntryChanged, runInterop } from "../interop.js";
9
9
  import { buildGroupModel, computeGroupPeers } from "../interop-live.js";
10
10
  import { planEntry } from "../plan.js";
11
- import { combineReleaseAge, filterByReleaseAge, parsePnpmGate, readConfigReleaseAge } from "../release-age.js";
11
+ import { parsePnpmGate, readConfigReleaseAge } from "../release-age.js";
12
12
  import { RegistryResolver, RegistryResolverLive } from "../resolve.js";
13
13
  import { applyEdits } from "../rewrite.js";
14
14
  import { renderSummary } from "../summary.js";
@@ -19,6 +19,7 @@ import { Data, Effect, Option, Result } from "effect";
19
19
  import { readFileSync, writeFileSync } from "node:fs";
20
20
  import { NodeServices } from "@effect/platform-node";
21
21
  import { Argument, Command, Flag } from "effect/unstable/cli";
22
+ import { ReleaseAgeGate } from "@effected/npm";
22
23
 
23
24
  //#region src/cli/commands/upgrade.ts
24
25
  /**
@@ -33,7 +34,8 @@ function computeGate(source, file, resolver) {
33
34
  const { config } = yield* Effect.try(() => evaluatePluginConfig(source, file)).pipe(Effect.catch(() => Effect.succeed({ config: null })));
34
35
  const cfg = readConfigReleaseAge(config);
35
36
  const [age, exc] = yield* Effect.all([resolver.pnpmConfig("minimumReleaseAge").pipe(Effect.catch(() => Effect.succeed(null))), resolver.pnpmConfig("minimumReleaseAgeExclude").pipe(Effect.catch(() => Effect.succeed(null)))], { concurrency: "unbounded" });
36
- return combineReleaseAge(cfg, parsePnpmGate(age, exc));
37
+ const contributions = [cfg, parsePnpmGate(age, exc)].filter((g) => g !== null);
38
+ return ReleaseAgeGate.combine(...contributions);
37
39
  });
38
40
  }
39
41
  /** Maximum number of per-package version+times fetches to issue concurrently. @internal */
@@ -66,7 +68,7 @@ function resolveGatedVersions(entries, resolver, gate, now, onProgress) {
66
68
  onProgress?.(++resolved, total);
67
69
  return [
68
70
  pkg,
69
- filterByReleaseAge(vr.success, times, gate, pkg, now),
71
+ [...gate.filterVersions(vr.success, times, pkg, now)],
70
72
  vr.success
71
73
  ];
72
74
  }), { concurrency: 12 }).pipe(Effect.map((triples) => ({
@@ -1,38 +1,11 @@
1
1
  //#region src/cli/release-age.ts
2
- /** Combine two sources: strictest age (max), widest exempt set (union). @internal */
3
- function combineReleaseAge(a, b) {
4
- const ages = [a?.ageMinutes, b?.ageMinutes].filter((n) => typeof n === "number");
5
- return {
6
- ageMinutes: ages.length ? Math.max(0, ...ages) : 0,
7
- exclude: [.../* @__PURE__ */ new Set([...a?.exclude ?? [], ...b?.exclude ?? []])]
8
- };
9
- }
10
- /** Match a package name against exact names or `*`-globs (e.g. `@effect/*`). @internal */
11
- function matchesExclude(pkg, patterns) {
12
- for (const pat of patterns) {
13
- if (pat === pkg) return true;
14
- if (pat.includes("*")) {
15
- if (new RegExp(`^${pat.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`).test(pkg)) return true;
16
- }
17
- }
18
- return false;
19
- }
20
2
  /**
21
- * Drop versions younger than the gate's cutoff (and versions with no publish
22
- * timestamp). No-op when the age is 0 or the package is exempt.
23
- *
24
- * @internal
3
+ * Read a release-age gate from config and pnpm and combine it with
4
+ * {@link @effected/npm#ReleaseAgeGate.combine}. The gate model itself
5
+ * (`ReleaseAgeGate`, `PartialReleaseAgeGate`, the age filter, and the
6
+ * `@pnpm/matcher` exclude semantics) lives in `@effected/npm`; this module
7
+ * only turns this repo's two config sources into partial contributions.
25
8
  */
26
- function filterByReleaseAge(versions, times, gate, pkg, now) {
27
- if (gate.ageMinutes <= 0 || matchesExclude(pkg, gate.exclude)) return [...versions];
28
- const cutoff = now - gate.ageMinutes * 6e4;
29
- return versions.filter((v) => {
30
- const t = times[v];
31
- if (t === void 0) return false;
32
- const published = Date.parse(t);
33
- return Number.isFinite(published) && published <= cutoff;
34
- });
35
- }
36
9
  /** Unwrap a managed field that may be a bare value or a `{ value, enforcement }` FieldInput. */
37
10
  function fieldValue(raw) {
38
11
  if (raw && typeof raw === "object" && !Array.isArray(raw) && "value" in raw) return raw.value;
@@ -48,7 +21,7 @@ function readConfigReleaseAge(config) {
48
21
  if (Array.isArray(exc)) out.exclude = exc.filter((x) => typeof x === "string");
49
22
  return out.ageMinutes === void 0 && out.exclude === void 0 ? null : out;
50
23
  }
51
- /** Parse `pnpm config get minimumReleaseAge[Exclude]` stdout into a PartialGate. @internal */
24
+ /** Parse `pnpm config get minimumReleaseAge[Exclude]` stdout into a PartialReleaseAgeGate. @internal */
52
25
  function parsePnpmGate(age, exclude) {
53
26
  const out = {};
54
27
  const trimmedAge = age?.trim();
@@ -71,4 +44,4 @@ function parsePnpmGate(age, exclude) {
71
44
  }
72
45
 
73
46
  //#endregion
74
- export { combineReleaseAge, filterByReleaseAge, matchesExclude, parsePnpmGate, readConfigReleaseAge };
47
+ export { parsePnpmGate, readConfigReleaseAge };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown-pnpm-config",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "private": false,
5
5
  "description": "A dogfooding example of our plugin",
6
6
  "repository": {
@@ -36,12 +36,13 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@effect/platform-node": "4.0.0-beta.99",
39
+ "@effected/npm": "^0.3.0",
39
40
  "@effected/semver": "^0.2.0",
40
41
  "@effected/yaml": "^0.5.0",
41
42
  "effect": "4.0.0-beta.99",
42
43
  "ink": "^7.1.1",
43
44
  "ink-tab": "^5.2.0",
44
- "oxc-parser": "^0.140.0",
45
+ "oxc-parser": "^0.141.0",
45
46
  "react": "^19.2.7",
46
47
  "std-env": "^4.2.0",
47
48
  "std-osc8": "^0.2.0"