The 0.12.0 stack (#411–#416) added packages/cli/src/util/is-record.ts and replaced six private copies of the same three-line object guard with it. Three older copies remain under another name, isPlainObject, with the identical body:
| File |
Line |
packages/cli/src/filesystem/manifest.ts |
223 |
packages/cli/src/filesystem/migrations/0002-install.ts |
8 |
packages/cli/src/filesystem/migrations/0003-drop-installed-at.ts |
8 |
function isPlainObject(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
That's three copies, which is where we consolidate. They were left alone in the stack because they predate it and weren't in its diff.
Change
Delete the three functions and import isRecord from ../util/is-record (from ../../util/is-record in the migrations). There are 7 call sites. No other inline copy of the guard exists in packages/cli/src.
Migrations can share it
Migrations 0002 and 0003 can import the shared guard too. The migration run takes a project all the way to the latest schema before any command does its work, so sharing a helper with the rest of the CLI doesn't change what an old project sees.
Done when
- The three functions are gone and every call site imports
isRecord.
pnpm typecheck, pnpm lint, and the CLI suite pass.
The 0.12.0 stack (#411–#416) added
packages/cli/src/util/is-record.tsand replaced six private copies of the same three-line object guard with it. Three older copies remain under another name,isPlainObject, with the identical body:packages/cli/src/filesystem/manifest.tspackages/cli/src/filesystem/migrations/0002-install.tspackages/cli/src/filesystem/migrations/0003-drop-installed-at.tsThat's three copies, which is where we consolidate. They were left alone in the stack because they predate it and weren't in its diff.
Change
Delete the three functions and import
isRecordfrom../util/is-record(from../../util/is-recordin the migrations). There are 7 call sites. No other inline copy of the guard exists inpackages/cli/src.Migrations can share it
Migrations
0002and0003can import the shared guard too. The migration run takes a project all the way to the latest schema before any command does its work, so sharing a helper with the rest of the CLI doesn't change what an old project sees.Done when
isRecord.pnpm typecheck,pnpm lint, and the CLI suite pass.