pmsec 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.
- package/package.json +1 -1
- package/src/cli.mjs +10 -4
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -142,18 +142,24 @@ async function runEnable(targets, json, days, env, home, platform, out, err) {
|
|
|
142
142
|
const warn = preflightWarn(t);
|
|
143
143
|
if (warn) warnings.push({ tool: t.name, warn });
|
|
144
144
|
try {
|
|
145
|
-
const
|
|
146
|
-
|
|
145
|
+
const current = await t.read(env, home, platform);
|
|
146
|
+
const currentDays = current.days ?? 0;
|
|
147
|
+
const effective = Math.max(currentDays, days);
|
|
148
|
+
const kept = currentDays >= days && currentDays > 0;
|
|
149
|
+
const r = await t.write(effective, env, home, platform);
|
|
150
|
+
results.push({ tool: t.name, path: r.path, days: effective, requested: days, kept, ok: true, warn });
|
|
147
151
|
} catch (e) {
|
|
148
152
|
failures.push({ tool: t.name, error: explainFsError(e, t.name) });
|
|
149
|
-
results.push({ tool: t.name, path: e?.path ?? null, days, ok: false, error: explainFsError(e, t.name), warn });
|
|
153
|
+
results.push({ tool: t.name, path: e?.path ?? null, days, requested: days, kept: false, ok: false, error: explainFsError(e, t.name), warn });
|
|
150
154
|
}
|
|
151
155
|
}
|
|
152
156
|
if (json) out.write(JSON.stringify({ enabled: true, bundleDays: days, results, warnings, ok: failures.length === 0 }, null, 2) + "\n");
|
|
153
157
|
else for (const r of results) {
|
|
154
158
|
if (r.ok) {
|
|
159
|
+
const action = r.kept ? "keep " : "enable ";
|
|
160
|
+
const note = r.kept ? ` (kept existing ${r.days}d ≥ ${r.requested}d)` : "";
|
|
155
161
|
const tail = r.warn ? `\n ⚠ ${r.warn}` : "";
|
|
156
|
-
out.write(
|
|
162
|
+
out.write(`${action} ${r.tool.padEnd(4)} [${r.path}]${note}${tail}\n`);
|
|
157
163
|
} else {
|
|
158
164
|
out.write(`FAIL ${r.tool.padEnd(4)} ${r.error}\n`);
|
|
159
165
|
}
|