depatcher 0.0.1 → 0.0.3
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/README.md +0 -1
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +15 -5
- package/package.json +12 -5
package/README.md
CHANGED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/applyPatch.d.ts
|
|
2
|
+
declare function applyPatch_(packageName: string, patchMap: Record<string, string>): Promise<void>;
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region src/createPatch.d.ts
|
|
5
|
+
declare function createPatch_(originalFilePath: string, patchedFilePath: string, outputPatchPath: string): void;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { applyPatch_ as applyPatch, createPatch_ as createPatch };
|
package/dist/index.mjs
CHANGED
|
@@ -3,17 +3,27 @@ import { readFileSync, writeFileSync } from "node:fs";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { applyPatch, createPatch } from "diff";
|
|
5
5
|
//#region src/applyPatch.ts
|
|
6
|
-
|
|
6
|
+
const PACKAGE_MANAGER_MAP = {
|
|
7
|
+
yarn: {
|
|
8
|
+
patch: "yarn patch",
|
|
9
|
+
patchCommit: "yarn patch-commit -s"
|
|
10
|
+
},
|
|
11
|
+
pnpm: {
|
|
12
|
+
patch: "pnpm patch",
|
|
13
|
+
patchCommit: "pnpm patch-commit"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function run(command) {
|
|
7
17
|
console.log(`> ${command}`);
|
|
8
18
|
return execSync(command, {
|
|
9
19
|
encoding: "utf8",
|
|
10
|
-
stdio: "pipe"
|
|
11
|
-
...options
|
|
20
|
+
stdio: "pipe"
|
|
12
21
|
});
|
|
13
22
|
}
|
|
14
23
|
async function applyPatch_(packageName, patchMap) {
|
|
24
|
+
const packageManager = process.argv.at(0);
|
|
15
25
|
console.log(`🔄 Start patching "${packageName}"`);
|
|
16
|
-
const tempDir = run(
|
|
26
|
+
const tempDir = run(`${PACKAGE_MANAGER_MAP[packageManager].patch} ${packageName}`).split("\n")[1].slice(49);
|
|
17
27
|
for (const [originalFile, patchPath] of Object.entries(patchMap)) {
|
|
18
28
|
const fileToPatch = join(tempDir, originalFile);
|
|
19
29
|
const patchedFile = applyPatch(readFileSync(fileToPatch, "utf8").toString(), readFileSync(patchPath, "utf8").toString());
|
|
@@ -21,7 +31,7 @@ async function applyPatch_(packageName, patchMap) {
|
|
|
21
31
|
writeFileSync(fileToPatch, patchedFile, "utf8");
|
|
22
32
|
console.log(`💾 Patched ${fileToPatch} with ${patchPath}`);
|
|
23
33
|
}
|
|
24
|
-
run(
|
|
34
|
+
run(`${PACKAGE_MANAGER_MAP[packageManager].patchCommit} "${tempDir}"`);
|
|
25
35
|
console.log(`📦 "${packageName}" patched`);
|
|
26
36
|
}
|
|
27
37
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "depatcher",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Dependencies patcher ~ apply patches to dependencies",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.mts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": "./dist/index.mjs",
|
|
10
|
+
"types": "./dist/index.d.mts"
|
|
11
|
+
},
|
|
6
12
|
"keywords": [
|
|
7
13
|
"dependency",
|
|
8
14
|
"dependencies",
|
|
@@ -18,6 +24,7 @@
|
|
|
18
24
|
},
|
|
19
25
|
"scripts": {
|
|
20
26
|
"build": "tsdown",
|
|
27
|
+
"test": "yarn node --test test/*.test.ts",
|
|
21
28
|
"lint": "eslint src/**/*.ts",
|
|
22
29
|
"od": "yarn outdated"
|
|
23
30
|
},
|
|
@@ -25,13 +32,13 @@
|
|
|
25
32
|
"diff": "^9.0.0"
|
|
26
33
|
},
|
|
27
34
|
"devDependencies": {
|
|
28
|
-
"@types/node": "^25.
|
|
35
|
+
"@types/node": "^25.8.0",
|
|
29
36
|
"@yarnpkg/sdks": "^3.2.3",
|
|
30
|
-
"eslint": "^10.
|
|
37
|
+
"eslint": "^10.3.0",
|
|
31
38
|
"eslint-plugin-unicorn": "^64.0.0",
|
|
32
|
-
"tsdown": "^0.
|
|
39
|
+
"tsdown": "^0.22.0",
|
|
33
40
|
"typescript": "^6.0.3",
|
|
34
|
-
"typescript-eslint": "^8.59.
|
|
41
|
+
"typescript-eslint": "^8.59.3"
|
|
35
42
|
},
|
|
36
43
|
"files": [
|
|
37
44
|
"dist"
|