From 565260ef909b2f4ecbdb00e8375697cf68563006 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Mon, 22 Jul 2024 22:58:26 +0700 Subject: [PATCH] ci(release): patch semantic release npm plugin to not use npm CLI --- bun.lockb | Bin 285856 -> 286056 bytes package.json | 5 +- patches/@semantic-release%2Fnpm@12.0.1.patch | 62 +++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 patches/@semantic-release%2Fnpm@12.0.1.patch diff --git a/bun.lockb b/bun.lockb index 27e8610af7b2f6cc078b5cd1c4f41bd43d134fdc..afde74b2f96f60e2c3aec010c5a8b85c2bc0f186 100755 GIT binary patch delta 305 zcmZ3mQ}D$u!3lnhHyZt0{Ta9VGnIW~XN)t`Gte{Me&!ofN*m*q?S{3?<#${Q5=)XZ zQj7H+ic@nF^GY(4b&FDSQWJ|)RgK*83UVC`jr0uk4E4au7@(lszsS2dAkkSMiUllU zF#TX8i}Lgrkt_4H%#|2Z?FAxb)?OGdM}b6$XQKY(Oqrng43cynvSK$KX- zuuRXt%%nOkhDAWAz_G+R!!^aF04iA#GhHg0MNK%U85kIh+dPfGHl+NS Jeo=~P0stQMSHJ)O delta 152 zcmaE{OK`zX!3lnh0*(Hy{)}7wnaaMgGcka{_A}p@QrZ|-Y&WcBF25rQ7Gq#wDEBY& zE)Ga^ei6w67UG!xHj+h|nSp^}I)4<4B47h|9k2xKpAz}&B9iv&? dIaffrCqPQlIT>OgvI5f?V_3|mUzB2+002IWB@qAs diff --git a/package.json b/package.json index 72440fb..82e9a39 100644 --- a/package.json +++ b/package.json @@ -52,5 +52,8 @@ "@revanced/discord-bot", "esbuild", "lefthook" - ] + ], + "patchedDependencies": { + "@semantic-release/npm@12.0.1": "patches/@semantic-release%2Fnpm@12.0.1.patch" + } } diff --git a/patches/@semantic-release%2Fnpm@12.0.1.patch b/patches/@semantic-release%2Fnpm@12.0.1.patch new file mode 100644 index 0000000..5344d0a --- /dev/null +++ b/patches/@semantic-release%2Fnpm@12.0.1.patch @@ -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",