@theholocron/cli 5.0.0-alpha.391 → 5.0.0-alpha.393
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/dist/cli.mjs +64 -6
- package/dist/cli.mjs.map +1 -1
- package/package.json +9 -9
package/dist/cli.mjs
CHANGED
|
@@ -3622,6 +3622,45 @@ const deployStageArgs = (y) => y.option("package-dir", {
|
|
|
3622
3622
|
type: "string",
|
|
3623
3623
|
describe: "Where to write the payload. Default: `.vercel-deploy` inside the package."
|
|
3624
3624
|
});
|
|
3625
|
+
// src/commands/deploy-stage/installed-peers.ts
|
|
3626
|
+
/**
|
|
3627
|
+
* The `package.json` of `peer` as the package at `manifestPath` would resolve it: the closest `node_modules`
|
|
3628
|
+
* above its real path, which in a pnpm install is the sibling link next to the dependency.
|
|
3629
|
+
*/
|
|
3630
|
+
function peerManifestPath(manifestPath, peer) {
|
|
3631
|
+
for (let dir = dirname(manifestPath); dirname(dir) !== dir; dir = dirname(dir)) {
|
|
3632
|
+
const candidates = [join(dir, "node_modules", peer, "package.json")];
|
|
3633
|
+
if (basename(dir) === "node_modules") candidates.push(join(dir, peer, "package.json"));
|
|
3634
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
3635
|
+
if (found) return realpathSync(found);
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
/** Adds the required peers of the package at `manifestPath` to `peers`, then theirs, each once. */
|
|
3639
|
+
function collectPeers(manifestPath, peers) {
|
|
3640
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
3641
|
+
for (const peer of Object.keys(manifest.peerDependencies ?? {})) {
|
|
3642
|
+
if (manifest.peerDependenciesMeta?.[peer]?.optional || peer in peers) continue;
|
|
3643
|
+
const peerPath = peerManifestPath(manifestPath, peer);
|
|
3644
|
+
if (!peerPath) continue;
|
|
3645
|
+
const peerManifest = JSON.parse(readFileSync(peerPath, "utf8"));
|
|
3646
|
+
if (!peerManifest.version) continue;
|
|
3647
|
+
peers[peer] = peerManifest.version;
|
|
3648
|
+
collectPeers(peerPath, peers);
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
/**
|
|
3652
|
+
* The required peer dependencies of the installed `dependency` and, in turn, of those peers, each with the
|
|
3653
|
+
* version installed beside the package that needs it. A peer that is optional, or that is not installed, is
|
|
3654
|
+
* left out. The staged payload installs with `legacy-peer-deps`, which turns off npm's own peer installation,
|
|
3655
|
+
* so these have to be listed.
|
|
3656
|
+
*/
|
|
3657
|
+
function installedPeers(packageDir, dependency) {
|
|
3658
|
+
const manifestPath = join(packageDir, "node_modules", dependency, "package.json");
|
|
3659
|
+
if (!existsSync(manifestPath)) return {};
|
|
3660
|
+
const peers = {};
|
|
3661
|
+
collectPeers(realpathSync(manifestPath), peers);
|
|
3662
|
+
return peers;
|
|
3663
|
+
}
|
|
3625
3664
|
// src/commands/deploy-stage/undeclared-externals.ts
|
|
3626
3665
|
/** `"@scope/pkg/sub"` → `"@scope/pkg"`, `"pkg/sub"` → `"pkg"`. */
|
|
3627
3666
|
function packageName(specifier) {
|
|
@@ -3695,9 +3734,14 @@ function vercelEngines(engines) {
|
|
|
3695
3734
|
* function's node_modules is already fully controlled by the
|
|
3696
3735
|
* trimmed `package.json` below (nothing extra to prune), so
|
|
3697
3736
|
* there is no upside to nft's pruning here, only risk.
|
|
3698
|
-
*
|
|
3699
|
-
*
|
|
3700
|
-
*
|
|
3737
|
+
* .npmrc — `legacy-peer-deps=true`: the plugins peer on one exact CLI version
|
|
3738
|
+
* and on `^` ranges that a prerelease never satisfies, so a strict
|
|
3739
|
+
* install fails ERESOLVE. That setting also stops npm installing peers,
|
|
3740
|
+
* so `package.json` lists the required peers of each dependency too, at
|
|
3741
|
+
* the version installed beside it. An `installCommand` in vercel.json or in the
|
|
3742
|
+
* request did not reach the install Vercel runs for the function (the
|
|
3743
|
+
* deployment still ran a plain `npm install`); an `.npmrc` in the
|
|
3744
|
+
* payload applies to whichever `npm install` runs there.
|
|
3701
3745
|
* package.json — trimmed: name/version/type/engines + dependencies only,
|
|
3702
3746
|
* each pinned to the exact version actually resolved in
|
|
3703
3747
|
* node_modules right now (not the "workspace:" / "catalog:"
|
|
@@ -3731,6 +3775,7 @@ function stageDeploy(input) {
|
|
|
3731
3775
|
const outDir = input.outDir ?? join(packageDir, ".vercel-deploy");
|
|
3732
3776
|
const print = input.print ?? (() => {});
|
|
3733
3777
|
const resolveVersion = input.resolveVersion ?? installedVersion;
|
|
3778
|
+
const resolvePeers = input.resolvePeers ?? installedPeers;
|
|
3734
3779
|
try {
|
|
3735
3780
|
const distIndex = join(packageDir, "dist", "index.mjs");
|
|
3736
3781
|
if (!existsSync(distIndex)) throw new Error(`${distIndex} not found — run \`pnpm run delivery.build\` first`);
|
|
@@ -3742,7 +3787,12 @@ function stageDeploy(input) {
|
|
|
3742
3787
|
...missing.map((name) => ` - ${name}`),
|
|
3743
3788
|
"Add each to the package's package.json (usually a new dependency of an inlined workspace package)."
|
|
3744
3789
|
].join("\n"));
|
|
3745
|
-
const
|
|
3790
|
+
const direct = Object.fromEntries(Object.keys(pkg.dependencies ?? {}).map((name) => [name, resolveVersion(packageDir, name)]));
|
|
3791
|
+
const peers = Object.fromEntries(Object.keys(direct).flatMap((name) => Object.entries(resolvePeers(packageDir, name))).filter(([name]) => !(name in direct)));
|
|
3792
|
+
const dependencies = Object.fromEntries(Object.entries({
|
|
3793
|
+
...direct,
|
|
3794
|
+
...peers
|
|
3795
|
+
}).sort(([a], [b]) => a.localeCompare(b)));
|
|
3746
3796
|
rmSync(outDir, {
|
|
3747
3797
|
recursive: true,
|
|
3748
3798
|
force: true
|
|
@@ -3760,6 +3810,7 @@ function stageDeploy(input) {
|
|
|
3760
3810
|
dependencies
|
|
3761
3811
|
};
|
|
3762
3812
|
writeFileSync(join(outDir, "package.json"), stringifyJson(deployPkg));
|
|
3813
|
+
writeFileSync(join(outDir, ".npmrc"), "legacy-peer-deps=true\n");
|
|
3763
3814
|
print(`Staged deploy payload at ${outDir}`);
|
|
3764
3815
|
print(` dependencies: ${Object.entries(dependencies).map(([n, v]) => `${n}@${v}`).join(", ")}`);
|
|
3765
3816
|
return {
|
|
@@ -15380,7 +15431,8 @@ function parseJson(raw) {
|
|
|
15380
15431
|
*
|
|
15381
15432
|
* A package is skipped only when BOTH its bound file and its bound repository (compared
|
|
15382
15433
|
* case-insensitively) already match: a package folded in from another repo keeps its
|
|
15383
|
-
* filename but is still bound to the old repo (#1221). `--
|
|
15434
|
+
* filename but is still bound to the old repo (#1221). `--force` replaces a matching entry too, because npm
|
|
15435
|
+
* expires an entry that is not used for a publish soon after it is made and still lists it as matching. `--dry-run` does the same read-only
|
|
15384
15436
|
* `trust list` per package and reports what the real run would do, without revoking or creating.
|
|
15385
15437
|
*/
|
|
15386
15438
|
async function runSyncTrust(input) {
|
|
@@ -15389,6 +15441,7 @@ async function runSyncTrust(input) {
|
|
|
15389
15441
|
const cwd = input.cwd ?? process.cwd();
|
|
15390
15442
|
const repo = input.repo ?? HOLOCRON_REPO;
|
|
15391
15443
|
const dryRun = input.dryRun ?? false;
|
|
15444
|
+
const force = input.force ?? false;
|
|
15392
15445
|
const exec = input.exec ?? defaultExec$1;
|
|
15393
15446
|
const packageNames = input.packages ?? discoverPublicPackages(cwd, scopeOf(input));
|
|
15394
15447
|
const npm = "npx";
|
|
@@ -15454,7 +15507,7 @@ async function runSyncTrust(input) {
|
|
|
15454
15507
|
const entry = parsed ?? {};
|
|
15455
15508
|
const sameFile = entry.file === input.newFile;
|
|
15456
15509
|
const sameRepo = entry.repository?.toLowerCase() === repo.toLowerCase();
|
|
15457
|
-
if (sameFile && sameRepo) {
|
|
15510
|
+
if (sameFile && sameRepo && !force) {
|
|
15458
15511
|
print(` already on ${repo} / ${input.newFile}, skipping`);
|
|
15459
15512
|
results.push({
|
|
15460
15513
|
name,
|
|
@@ -15541,6 +15594,10 @@ const publishArgs = (y) => y.option("initial", {
|
|
|
15541
15594
|
}).option("sync-trust", {
|
|
15542
15595
|
type: "array",
|
|
15543
15596
|
describe: "Migrate npm Trusted Publisher config to a new workflow filename across every public package: --sync-trust <old-file> <new-file>. See issue #689 — npm requires fresh interactive 2FA per package; re-run after approving the printed authUrl if it stops early."
|
|
15597
|
+
}).option("force", {
|
|
15598
|
+
type: "boolean",
|
|
15599
|
+
default: false,
|
|
15600
|
+
describe: "--sync-trust only: revoke and recreate every package's Trusted Publisher entry even when its file and repository already match. npm expires an entry that is not used for a publish soon after it is made but still lists it as matching, so a plain run skips it."
|
|
15544
15601
|
}).option("repo", {
|
|
15545
15602
|
type: "string",
|
|
15546
15603
|
describe: `owner/repo for Trusted Publisher config (--sync-trust). Defaults to ${HOLOCRON_REPO}.`
|
|
@@ -15580,6 +15637,7 @@ const publishCommand = {
|
|
|
15580
15637
|
oldFile,
|
|
15581
15638
|
newFile,
|
|
15582
15639
|
dryRun: argv.dryRun,
|
|
15640
|
+
force: argv.force,
|
|
15583
15641
|
...argv.group ? { group: argv.group } : {},
|
|
15584
15642
|
...argv.excludeGroup?.length ? { excludeGroups: argv.excludeGroup } : {},
|
|
15585
15643
|
...argv.repo ? { repo: argv.repo } : {}
|