toolcrib 0.8.0 → 0.9.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/commands/merge.js +45 -7
package/package.json
CHANGED
package/src/commands/merge.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as p from '@clack/prompts';
|
|
|
3
3
|
import { fetchRelease, fetchTestsRelease } from '../lib/release.js';
|
|
4
4
|
import { resolveVersion } from '../lib/github.js';
|
|
5
5
|
import { PendingChanges, normalize, joinPatchPath } from '../lib/patches.js';
|
|
6
|
-
import { mergeImportsField } from '../lib/deps.js';
|
|
6
|
+
import { resolveDependencyDecisions, buildProposedPackageJson, mergeImportsField } from '../lib/deps.js';
|
|
7
7
|
import { fileExists, readJsonIfExists, readLock, readTextIfExists, proposeLockUpdate } from '../lib/project.js';
|
|
8
8
|
import { MANAGED_DOCS, KNOWN_TARGET_FILES, listManagedBlocks, upsertManagedBlock } from '../lib/managedDocs.js';
|
|
9
9
|
|
|
@@ -86,8 +86,8 @@ function diffReleaseFiles(projectRoot, oldRelease, newRelease, changes, conflict
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// A file present in oldRelease but absent from newRelease was removed
|
|
89
|
-
// upstream — e.g. useAnimatedMount.ts when Drawer moved to
|
|
90
|
-
//
|
|
89
|
+
// upstream — e.g. useAnimatedMount.ts when Drawer moved to a Presence
|
|
90
|
+
// primitive in v0.10.0. Without this pass, a vendored copy of a file
|
|
91
91
|
// upstream no longer ships just sits there forever, unreferenced but
|
|
92
92
|
// never cleaned up, since the loop above only ever visits paths that
|
|
93
93
|
// still exist in the *new* release. classify(original, local, '')
|
|
@@ -305,13 +305,36 @@ export async function mergeCommand(options) {
|
|
|
305
305
|
|
|
306
306
|
await cleanupAll();
|
|
307
307
|
|
|
308
|
-
//
|
|
309
|
-
//
|
|
308
|
+
// package.json: the target release's peerDependencies the project doesn't
|
|
309
|
+
// have yet (a release can introduce new ones -- e.g. the Base UI switch
|
|
310
|
+
// added @base-ui/react), plus installs from before the "imports" subpath
|
|
311
|
+
// entry existed. One combined patch, same reason as init.js: two propose()
|
|
312
|
+
// calls for the same relPath would both diff against the original file.
|
|
310
313
|
const pkgPath = path.join(projectRoot, 'package.json');
|
|
311
314
|
const userPkg = readJsonIfExists(pkgPath);
|
|
315
|
+
let depConflicts = [];
|
|
316
|
+
let removedPeers = [];
|
|
312
317
|
if (userPkg) {
|
|
313
|
-
const
|
|
314
|
-
|
|
318
|
+
const depDecisions = resolveDependencyDecisions(userPkg, newRelease.config?.peerDependencies ?? {});
|
|
319
|
+
const pkgWithDeps = depDecisions.toAdd.length > 0
|
|
320
|
+
? buildProposedPackageJson(userPkg, depDecisions.toAdd)
|
|
321
|
+
: userPkg;
|
|
322
|
+
// The vendored tests' own peers are dev tooling, so devDependencies, as in init.
|
|
323
|
+
const testsDepDecisions = newTestsRelease
|
|
324
|
+
? resolveDependencyDecisions(pkgWithDeps, newTestsRelease.config?.peerDependencies ?? {})
|
|
325
|
+
: null;
|
|
326
|
+
const pkgWithAllDeps = testsDepDecisions?.toAdd.length > 0
|
|
327
|
+
? buildProposedPackageJson(pkgWithDeps, testsDepDecisions.toAdd, 'devDependencies')
|
|
328
|
+
: pkgWithDeps;
|
|
329
|
+
depConflicts = [...depDecisions.conflicts, ...(testsDepDecisions?.conflicts ?? [])];
|
|
330
|
+
// Peers the old release needed and the new one doesn't: reported, never
|
|
331
|
+
// removed -- the project may use them itself.
|
|
332
|
+
const newPeers = newRelease.config?.peerDependencies ?? {};
|
|
333
|
+
removedPeers = Object.keys(oldRelease.config?.peerDependencies ?? {}).filter(
|
|
334
|
+
(name) => !(name in newPeers) && (userPkg.dependencies?.[name] || userPkg.devDependencies?.[name])
|
|
335
|
+
);
|
|
336
|
+
const importsResult = mergeImportsField(pkgWithAllDeps, TOOLKIT_IMPORTS_ENTRY);
|
|
337
|
+
if (depDecisions.toAdd.length > 0 || testsDepDecisions?.toAdd.length > 0 || importsResult.changed) {
|
|
315
338
|
changes.propose(
|
|
316
339
|
'package.json',
|
|
317
340
|
readTextIfExists(pkgPath),
|
|
@@ -381,6 +404,21 @@ export async function mergeCommand(options) {
|
|
|
381
404
|
);
|
|
382
405
|
}
|
|
383
406
|
|
|
407
|
+
if (depConflicts.length > 0) {
|
|
408
|
+
process.exitCode = 1;
|
|
409
|
+
p.log.warn(
|
|
410
|
+
`${depConflicts.length} dependency conflict(s) — not staged, needs your decision:\n` +
|
|
411
|
+
depConflicts
|
|
412
|
+
.map((d) => ` ${d.name}: you have ${d.userRange}, toolcrib needs ${d.requiredRange} (${d.reason})`)
|
|
413
|
+
.join('\n')
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
if (removedPeers.length > 0) {
|
|
417
|
+
p.log.info(
|
|
418
|
+
`No longer required by toolcrib (left in package.json; remove them if your own code doesn't use them): ${removedPeers.join(', ')}`
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
|
|
384
422
|
p.outro(changes.isEmpty() ? 'No changes to apply.' : 'Review ./toolcrib-patches/, then run `toolcrib apply`.');
|
|
385
423
|
}
|
|
386
424
|
|