@theholocron/cli 5.0.0-alpha.391 → 5.0.0-alpha.392
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 +55 -4
- package/dist/cli.mjs.map +1 -1
- package/package.json +12 -12
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 {
|