@pnpm/plugin-commands-patching 2.0.25 → 2.1.0
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/lib/patch.d.ts +3 -1
- package/lib/patch.js +30 -2
- package/lib/patch.js.map +1 -1
- package/lib/writePackage.d.ts +3 -1
- package/lib/writePackage.js +1 -0
- package/lib/writePackage.js.map +1 -1
- package/package.json +10 -9
package/lib/patch.d.ts
CHANGED
|
@@ -4,14 +4,16 @@ import { CreateStoreControllerOptions } from '@pnpm/store-connection-manager';
|
|
|
4
4
|
export declare function rcOptionsTypes(): Pick<any, never>;
|
|
5
5
|
export declare function cliOptionsTypes(): {
|
|
6
6
|
'edit-dir': StringConstructor;
|
|
7
|
+
'ignore-existing': BooleanConstructor;
|
|
7
8
|
};
|
|
8
9
|
export declare const shorthands: {
|
|
9
10
|
d: string;
|
|
10
11
|
};
|
|
11
12
|
export declare const commandNames: string[];
|
|
12
13
|
export declare function help(): string;
|
|
13
|
-
export type PatchCommandOptions = Pick<Config, 'dir' | 'registries' | 'tag' | 'storeDir'> & CreateStoreControllerOptions & {
|
|
14
|
+
export type PatchCommandOptions = Pick<Config, 'dir' | 'registries' | 'tag' | 'storeDir' | 'rootProjectManifest' | 'lockfileDir'> & CreateStoreControllerOptions & {
|
|
14
15
|
editDir?: string;
|
|
15
16
|
reporter?: (logObj: LogBase) => void;
|
|
17
|
+
ignoreExisting?: boolean;
|
|
16
18
|
};
|
|
17
19
|
export declare function handler(opts: PatchCommandOptions, params: string[]): Promise<string>;
|
package/lib/patch.js
CHANGED
|
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.handler = exports.help = exports.commandNames = exports.shorthands = exports.cliOptionsTypes = exports.rcOptionsTypes = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const patching_apply_patch_1 = require("@pnpm/patching.apply-patch");
|
|
8
10
|
const cli_utils_1 = require("@pnpm/cli-utils");
|
|
9
11
|
const config_1 = require("@pnpm/config");
|
|
10
12
|
const pick_1 = __importDefault(require("ramda/src/pick"));
|
|
@@ -17,7 +19,7 @@ function rcOptionsTypes() {
|
|
|
17
19
|
}
|
|
18
20
|
exports.rcOptionsTypes = rcOptionsTypes;
|
|
19
21
|
function cliOptionsTypes() {
|
|
20
|
-
return { ...rcOptionsTypes(), 'edit-dir': String };
|
|
22
|
+
return { ...rcOptionsTypes(), 'edit-dir': String, 'ignore-existing': Boolean };
|
|
21
23
|
}
|
|
22
24
|
exports.cliOptionsTypes = cliOptionsTypes;
|
|
23
25
|
exports.shorthands = {
|
|
@@ -34,6 +36,10 @@ function help() {
|
|
|
34
36
|
description: 'The package that needs to be modified will be extracted to this directory',
|
|
35
37
|
name: '--edit-dir',
|
|
36
38
|
},
|
|
39
|
+
{
|
|
40
|
+
description: 'Ignore existing patch files when patching',
|
|
41
|
+
name: '--ignore-existing',
|
|
42
|
+
},
|
|
37
43
|
],
|
|
38
44
|
}],
|
|
39
45
|
url: (0, cli_utils_1.docsUrl)('patch'),
|
|
@@ -46,10 +52,32 @@ async function handler(opts, params) {
|
|
|
46
52
|
throw new error_1.PnpmError('PATCH_EDIT_DIR_EXISTS', `The target directory already exists: '${opts.editDir}'`);
|
|
47
53
|
}
|
|
48
54
|
const editDir = opts.editDir ?? tempy_1.default.directory();
|
|
49
|
-
await (0, writePackage_1.writePackage)(params[0], editDir, opts);
|
|
55
|
+
const patchedDep = await (0, writePackage_1.writePackage)(params[0], editDir, opts);
|
|
56
|
+
if (!opts.ignoreExisting && opts.rootProjectManifest?.pnpm?.patchedDependencies) {
|
|
57
|
+
tryPatchWithExistingPatchFile({
|
|
58
|
+
patchedDep,
|
|
59
|
+
patchedDir: editDir,
|
|
60
|
+
patchedDependencies: opts.rootProjectManifest.pnpm.patchedDependencies,
|
|
61
|
+
lockfileDir: opts.lockfileDir ?? opts.dir ?? process.cwd(),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
50
64
|
return `You can now edit the following folder: ${editDir}
|
|
51
65
|
|
|
52
66
|
Once you're done with your changes, run "pnpm patch-commit ${editDir}"`;
|
|
53
67
|
}
|
|
54
68
|
exports.handler = handler;
|
|
69
|
+
function tryPatchWithExistingPatchFile({ patchedDep, patchedDir, patchedDependencies, lockfileDir, }) {
|
|
70
|
+
if (!patchedDep.alias || !patchedDep.pref) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const existingPatchFile = patchedDependencies[`${patchedDep.alias}@${patchedDep.pref}`];
|
|
74
|
+
if (!existingPatchFile) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const existingPatchFilePath = path_1.default.resolve(lockfileDir, existingPatchFile);
|
|
78
|
+
if (!fs_1.default.existsSync(existingPatchFilePath)) {
|
|
79
|
+
throw new error_1.PnpmError('PATCH_FILE_NOT_FOUND', `Unable to find patch file ${existingPatchFilePath}`);
|
|
80
|
+
}
|
|
81
|
+
(0, patching_apply_patch_1.applyPatchToDir)({ patchedDir, patchFilePath: existingPatchFilePath });
|
|
82
|
+
}
|
|
55
83
|
//# sourceMappingURL=patch.js.map
|
package/lib/patch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../src/patch.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,+CAAyC;AACzC,yCAAwD;AAKxD,0DAAiC;AACjC,8DAAoC;AACpC,kDAAyB;AACzB,uCAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../src/patch.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,qEAA4D;AAC5D,+CAAyC;AACzC,yCAAwD;AAKxD,0DAAiC;AACjC,8DAAoC;AACpC,kDAAyB;AACzB,uCAAuC;AACv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2
|
import { CreateStoreControllerOptions } from '@pnpm/store-connection-manager';
|
|
3
|
+
import { ParseWantedDependencyResult } from '@pnpm/parse-wanted-dependency';
|
|
4
|
+
export { ParseWantedDependencyResult };
|
|
3
5
|
export type WritePackageOptions = CreateStoreControllerOptions & Pick<Config, 'registries'>;
|
|
4
|
-
export declare function writePackage(pkg: string, dest: string, opts: WritePackageOptions): Promise<
|
|
6
|
+
export declare function writePackage(pkg: string, dest: string, opts: WritePackageOptions): Promise<ParseWantedDependencyResult>;
|
package/lib/writePackage.js
CHANGED
package/lib/writePackage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writePackage.js","sourceRoot":"","sources":["../src/writePackage.ts"],"names":[],"mappings":";;;AACA,6EAGuC;AACvC,+EAAwE;AACxE,
|
|
1
|
+
{"version":3,"file":"writePackage.js","sourceRoot":"","sources":["../src/writePackage.ts"],"names":[],"mappings":";;;AACA,6EAGuC;AACvC,+EAAwE;AACxE,2EAAkG;AAM3F,KAAK,UAAU,YAAY,CAAE,GAAW,EAAE,IAAY,EAAE,IAAyB;IACtF,MAAM,GAAG,GAAG,IAAA,+CAAqB,EAAC,GAAG,CAAC,CAAA;IACtC,MAAM,KAAK,GAAG,MAAM,IAAA,yDAA8B,EAAC;QACjD,GAAG,IAAI;QACP,mBAAmB,EAAE,eAAe;KACrC,CAAC,CAAA;IACF,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE;QACvD,gBAAgB,EAAE,CAAC;QACnB,WAAW,EAAE,IAAI,CAAC,GAAG;QACrB,iBAAiB,EAAE,EAAE;QACrB,UAAU,EAAE,IAAI,CAAC,GAAG;QACpB,QAAQ,EAAE,CAAC,GAAG,CAAC,KAAK,IAAI,IAAA,kDAAsB,EAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO;KACvG,CAAC,CAAA;IACF,MAAM,aAAa,GAAG,MAAM,WAAW,CAAC,KAAM,EAAE,CAAA;IAChD,MAAM,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE;QACnC,aAAa;QACb,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACZ,CAAC;AAnBD,oCAmBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/plugin-commands-patching",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Commands for creating patches",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"engines": {
|
|
12
12
|
"node": ">=14.6"
|
|
13
13
|
},
|
|
14
|
-
"repository": "https://github.com/pnpm/pnpm/blob/main/
|
|
14
|
+
"repository": "https://github.com/pnpm/pnpm/blob/main/patching/plugin-commands-patching",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"pnpm7",
|
|
17
17
|
"pnpm",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"bugs": {
|
|
22
22
|
"url": "https://github.com/pnpm/pnpm/issues"
|
|
23
23
|
},
|
|
24
|
-
"homepage": "https://github.com/pnpm/pnpm/blob/main/
|
|
24
|
+
"homepage": "https://github.com/pnpm/pnpm/blob/main/patching/plugin-commands-patching#readme",
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@pnpm/registry-mock": "3.2.0",
|
|
27
27
|
"@types/ramda": "0.28.20",
|
|
28
|
-
"@pnpm/plugin-commands-patching": "2.0
|
|
28
|
+
"@pnpm/plugin-commands-patching": "2.1.0",
|
|
29
29
|
"@pnpm/prepare": "0.0.61"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
@@ -34,15 +34,16 @@
|
|
|
34
34
|
"render-help": "^1.0.2",
|
|
35
35
|
"safe-execa": "^0.1.3",
|
|
36
36
|
"tempy": "^1.0.1",
|
|
37
|
-
"@pnpm/cli-utils": "1.0.
|
|
38
|
-
"@pnpm/config": "16.
|
|
37
|
+
"@pnpm/cli-utils": "1.0.26",
|
|
38
|
+
"@pnpm/config": "16.5.0",
|
|
39
39
|
"@pnpm/error": "4.0.1",
|
|
40
|
-
"@pnpm/parse-wanted-dependency": "4.0
|
|
40
|
+
"@pnpm/parse-wanted-dependency": "4.1.0",
|
|
41
|
+
"@pnpm/patching.apply-patch": "1.0.0",
|
|
41
42
|
"@pnpm/pick-registry-for-package": "4.0.3",
|
|
42
|
-
"@pnpm/plugin-commands-installation": "11.3.
|
|
43
|
+
"@pnpm/plugin-commands-installation": "11.3.4",
|
|
43
44
|
"@pnpm/read-package-json": "7.0.5",
|
|
44
45
|
"@pnpm/read-project-manifest": "4.1.3",
|
|
45
|
-
"@pnpm/store-connection-manager": "5.2.
|
|
46
|
+
"@pnpm/store-connection-manager": "5.2.4"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"@pnpm/logger": "^5.0.0"
|