pmsec 2026.9.0 → 2026.10.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.
- package/package.json +1 -1
- package/src/tools/cargo.mjs +28 -4
- package/src/tools/npm.mjs +1 -0
package/package.json
CHANGED
package/src/tools/cargo.mjs
CHANGED
|
@@ -8,6 +8,10 @@ export const section = "install";
|
|
|
8
8
|
export const docs = "https://rust-lang.github.io/rfcs/3801-package-cooldown.html";
|
|
9
9
|
export const extras = [];
|
|
10
10
|
|
|
11
|
+
// Stabilized resolver cooldown (cargo >= 1.100). It tracks `--days` like the
|
|
12
|
+
// primary key, so it is handled here rather than as a fixed-value extra.
|
|
13
|
+
const publishAge = { key: "global-min-publish-age", section: "registry" };
|
|
14
|
+
|
|
11
15
|
export function path(ctx) { return cargoConfigPath(ctx.env, ctx.home); }
|
|
12
16
|
|
|
13
17
|
function parseDays(value) {
|
|
@@ -18,16 +22,34 @@ function parseDays(value) {
|
|
|
18
22
|
return /^(w|weeks?)$/i.test(m[2]) ? n * 7 : n;
|
|
19
23
|
}
|
|
20
24
|
|
|
25
|
+
function parsePublishAgeDays(value) {
|
|
26
|
+
if (value === null) return null;
|
|
27
|
+
const m = value.match(/^"\s*(\d+)\s*(days?|weeks?|months?)\s*"$/i);
|
|
28
|
+
if (!m) return null;
|
|
29
|
+
const n = Number(m[1]);
|
|
30
|
+
if (/^weeks?$/i.test(m[2])) return n * 7;
|
|
31
|
+
if (/^months?$/i.test(m[2])) return n * 30;
|
|
32
|
+
return n;
|
|
33
|
+
}
|
|
34
|
+
|
|
21
35
|
export async function read(ctx) {
|
|
22
36
|
const p = path(ctx);
|
|
23
37
|
const raw = await readSafe(p);
|
|
24
38
|
const value = readKey(raw, key, { section });
|
|
25
|
-
|
|
39
|
+
const days = parseDays(value);
|
|
40
|
+
const cur = readKey(raw, publishAge.key, { section: publishAge.section });
|
|
41
|
+
const want = days ?? 1;
|
|
42
|
+
const curDays = parsePublishAgeDays(cur);
|
|
43
|
+
return {
|
|
44
|
+
path: p, configured: value, days,
|
|
45
|
+
extras: [{ key: publishAge.key, configured: cur, expected: `"${want} days"`, ok: curDays !== null && curDays >= want }],
|
|
46
|
+
};
|
|
26
47
|
}
|
|
27
48
|
|
|
28
49
|
export async function write(days, ctx) {
|
|
29
50
|
const p = path(ctx);
|
|
30
|
-
|
|
51
|
+
let text = setKey(await readSafe(p), key, `${key} = "${days}d"`, { section });
|
|
52
|
+
text = setKey(text, publishAge.key, `${publishAge.key} = "${days} days"`, { section: publishAge.section });
|
|
31
53
|
await writeAtomic(p, text);
|
|
32
54
|
return { path: p };
|
|
33
55
|
}
|
|
@@ -35,7 +57,9 @@ export async function write(days, ctx) {
|
|
|
35
57
|
export async function unset(ctx) {
|
|
36
58
|
const p = path(ctx);
|
|
37
59
|
const before = await readSafe(p);
|
|
38
|
-
const
|
|
39
|
-
|
|
60
|
+
const cooldown = removeKey(before, key, { section });
|
|
61
|
+
const age = removeKey(cooldown.text, publishAge.key, { section: publishAge.section });
|
|
62
|
+
const removed = cooldown.removed || age.removed;
|
|
63
|
+
if (removed) await writeAtomic(p, age.text);
|
|
40
64
|
return { path: p, removed };
|
|
41
65
|
}
|
package/src/tools/npm.mjs
CHANGED
|
@@ -17,6 +17,7 @@ export const extras = [
|
|
|
17
17
|
{ key: "strict-allow-scripts", expected: "true", line: "strict-allow-scripts=true" },
|
|
18
18
|
{ key: "dangerously-allow-all-scripts", expected: "false", line: "dangerously-allow-all-scripts=false" },
|
|
19
19
|
{ key: "allow-scripts-pin", expected: "true", line: "allow-scripts-pin=true" },
|
|
20
|
+
{ key: "ignore-extension", expected: "true", line: "ignore-extension=true" },
|
|
20
21
|
];
|
|
21
22
|
|
|
22
23
|
export function path(ctx) { return npmrcPath(ctx.env, ctx.home); }
|