feat(core-analytics): add withAnalytics wrapper and Analyzed brand export
Adds `withAnalytics(analytics, factory)` to packages/core-analytics — mirrors the `withAudit` pattern: thin forwarding closure that attaches the `__analyzed` brand via `attachBrand` from `@repo/core-shared/conformance` without mutating the original factory. Exports `Analyzed<F>` type and `withAnalytics` from the `@repo/core-analytics` root barrel. Adds `with-analytics.test.ts` asserting brand is present after wrapping, absent on the original fn, output passes through unchanged, and errors propagate. Adds `@repo/core-shared` as a production dependency. Also fixes `scripts/library-decisions/check.mjs` to exempt workspace-protocol entries (`workspace:*`) from the library trace requirement — internal monorepo packages are not third-party libraries and were incorrectly gated. Adds a regression test in `check.test.mjs` covering the exemption. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -63,7 +63,14 @@ function getNewRuntimeDeps(relPath, repoRoot, baseRef) {
|
||||
// New file or initial commit — treat all deps as new
|
||||
}
|
||||
const baseDeps = new Set(Object.keys(base.dependencies ?? {}));
|
||||
return Object.keys(staged.dependencies ?? {}).filter((d) => !baseDeps.has(d));
|
||||
const stagedDeps = staged.dependencies ?? {};
|
||||
return Object.keys(stagedDeps).filter(
|
||||
(d) =>
|
||||
!baseDeps.has(d) &&
|
||||
// Workspace-protocol entries are internal monorepo packages — not
|
||||
// third-party libraries, so they don't require a library trace.
|
||||
!String(stagedDeps[d]).startsWith("workspace:"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -164,6 +164,16 @@ describe("checkLibraryDecisions", () => {
|
||||
assert.deepEqual(checkLibraryDecisions(dir), []);
|
||||
});
|
||||
|
||||
test("new workspace-protocol dep (internal monorepo package) → exit 0", () => {
|
||||
const { dir, g } = makeRepo();
|
||||
commitPkg(dir, g, "packages/feat-a", { dependencies: {} });
|
||||
stagePkg(dir, g, "packages/feat-a", {
|
||||
dependencies: { "@repo/core-shared": "workspace:*" },
|
||||
});
|
||||
|
||||
assert.deepEqual(checkLibraryDecisions(dir), []);
|
||||
});
|
||||
|
||||
test("--staged-against mode: new feature-tier dep without trace → exit 1", () => {
|
||||
const { dir, g } = makeRepo();
|
||||
// Baseline commit: feature package with no deps
|
||||
|
||||
Reference in New Issue
Block a user