ci(release): patch semantic release npm plugin to not use npm CLI

This commit is contained in:
PalmDevs
2024-07-22 22:58:26 +07:00
parent b76e223f07
commit 565260ef90
3 changed files with 66 additions and 1 deletions

BIN
bun.lockb

Binary file not shown.

View File

@@ -52,5 +52,8 @@
"@revanced/discord-bot",
"esbuild",
"lefthook"
]
],
"patchedDependencies": {
"@semantic-release/npm@12.0.1": "patches/@semantic-release%2Fnpm@12.0.1.patch"
}
}

View File

@@ -0,0 +1,62 @@
diff --git a/node_modules/@semantic-release/npm/.bun-tag-c9c8130945517add b/.bun-tag-c9c8130945517add
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/lib/prepare.js b/lib/prepare.js
index 3e76bec44cf595a1b4141728336bed904d4d518d..c6baf4e8de9bdf7536f9ad2e9eb9c360e031c7b5 100644
--- a/lib/prepare.js
+++ b/lib/prepare.js
@@ -1,6 +1,7 @@
import path from "path";
-import { move } from "fs-extra";
+import { rename, readFile, writeFile } from "fs/promises";
import { execa } from "execa";
+import detectIndent from 'detect-indent';
export default async function (
npmrc,
@@ -11,19 +12,12 @@ export default async function (
logger.log("Write version %s to package.json in %s", version, basePath);
- const versionResult = execa(
- "npm",
- ["version", version, "--userconfig", npmrc, "--no-git-tag-version", "--allow-same-version"],
- {
- cwd: basePath,
- env,
- preferLocal: true,
- }
- );
- versionResult.stdout.pipe(stdout, { end: false });
- versionResult.stderr.pipe(stderr, { end: false });
+ const pkgJsonPath = path.join(basePath, 'package.json')
+ const pkgJsonRaw = (await readFile(pkgJsonPath)).toString()
+ const pkgJson = JSON.parse(pkgJsonRaw)
+ pkgJson.version = version
- await versionResult;
+ await writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, detectIndent(pkgJsonRaw).indent))
if (tarballDir) {
logger.log("Creating npm package version %s", version);
@@ -38,7 +32,7 @@ export default async function (
// Only move the tarball if we need to
// Fixes: https://github.com/semantic-release/npm/issues/169
if (tarballSource !== tarballDestination) {
- await move(tarballSource, tarballDestination);
+ await rename(tarballSource, tarballDestination);
}
}
}
diff --git a/package.json b/package.json
index e716bf6b35130c168ab7c4babc89a0346aacc9ad..e372de1ca5967509a6769db88ff967e1039b03ac 100644
--- a/package.json
+++ b/package.json
@@ -21,6 +21,7 @@
"dependencies": {
"@semantic-release/error": "^4.0.0",
"aggregate-error": "^5.0.0",
+ "detect-indent": "^7.0.1",
"execa": "^9.0.0",
"fs-extra": "^11.0.0",
"lodash-es": "^4.17.21",