omp-config-crypt 0.9.10 → 0.9.11
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/preflight.js +37 -2
package/package.json
CHANGED
package/src/preflight.js
CHANGED
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import path from "node:path";
|
|
9
|
-
import { readSyncPolicy } from "./sync-policy.js";
|
|
10
|
-
import { readSyncState, healSyncMetadata } from "./sync-plan.js";
|
|
9
|
+
import { readSyncPolicy, resolveResourceScope } from "./sync-policy.js";
|
|
10
|
+
import { readSyncState, healSyncMetadata, canonicalHash, SENTINEL_DELETED } from "./sync-plan.js";
|
|
11
|
+
import { inventoryResources, readResource, canonicalResourceValue } from "./sync-resources.js";
|
|
11
12
|
import { resolveNpmCommand } from "./rehydrator.js";
|
|
12
13
|
import { runUpgrade } from "./maintenance.js";
|
|
13
14
|
|
|
@@ -140,6 +141,40 @@ export async function runPreflight({
|
|
|
140
141
|
checks.push({ id: "metadata", status: "fail", detail: `sync metadata not repairable: ${err.message}` });
|
|
141
142
|
}
|
|
142
143
|
|
|
144
|
+
// local-drift: public resources whose local value no longer matches the baseline
|
|
145
|
+
// are the seeds of pull conflicts; surface them before a remote pull aborts.
|
|
146
|
+
try {
|
|
147
|
+
const policy = readSyncPolicy(root);
|
|
148
|
+
const state = readSyncState(root);
|
|
149
|
+
const inventory = inventoryResources(root);
|
|
150
|
+
const drifted = [];
|
|
151
|
+
for (const item of inventory) {
|
|
152
|
+
if (resolveResourceScope(item.id, policy, state, item).scope !== "public") continue;
|
|
153
|
+
const baselineHash = state.resources?.[item.id]?.hash;
|
|
154
|
+
if (!baselineHash || baselineHash === SENTINEL_DELETED) continue;
|
|
155
|
+
const readRes = readResource(root, item.id);
|
|
156
|
+
if (!readRes) {
|
|
157
|
+
drifted.push(`${item.id} (missing locally)`);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const localHash = canonicalHash(canonicalResourceValue(item.id, readRes.value, root));
|
|
161
|
+
if (localHash !== baselineHash) drifted.push(item.id);
|
|
162
|
+
}
|
|
163
|
+
const head = drifted.slice(0, 8);
|
|
164
|
+
const rest = drifted.length - head.length;
|
|
165
|
+
if (drifted.length === 0) {
|
|
166
|
+
checks.push({ id: "local-drift", status: "pass", detail: "no public resource drifted from baseline" });
|
|
167
|
+
} else {
|
|
168
|
+
checks.push({
|
|
169
|
+
id: "local-drift",
|
|
170
|
+
status: "warn",
|
|
171
|
+
detail: `${drifted.length} public resource(s) locally modified since last sync (may conflict on pull): ${head.join(", ")}${rest > 0 ? `, … +${rest} more` : ""}; run pull --dry-run or push to reconcile`,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
} catch (err) {
|
|
175
|
+
checks.push({ id: "local-drift", status: "warn", detail: `drift check failed: ${err.message}` });
|
|
176
|
+
}
|
|
177
|
+
|
|
143
178
|
// node-engine: informational gate against package.json engines (warn only).
|
|
144
179
|
const nodeMajor = Number(process.versions.node.split(".")[0]);
|
|
145
180
|
const floor = nodeEngineFloor();
|