@pnpm/tools.plugin-commands-self-updater 1.0.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/LICENSE +22 -0
- package/README.md +15 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +29 -0
- package/lib/index.js.map +1 -0
- package/lib/selfUpdate.d.ts +8 -0
- package/lib/selfUpdate.js +91 -0
- package/lib/selfUpdate.js.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
|
|
4
|
+
Copyright (c) 2016-2024 Zoltan Kochan and other contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @pnpm/tools.plugin-commands-self-updater
|
|
2
|
+
|
|
3
|
+
> A command for updating pnpm itself
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pnpm/tools.plugin-commands-self-updater)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
pnpm add @pnpm/tools.plugin-commands-self-updater
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
MIT
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.selfUpdate = void 0;
|
|
27
|
+
const selfUpdate = __importStar(require("./selfUpdate"));
|
|
28
|
+
exports.selfUpdate = selfUpdate;
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA0C;AAEjC,gCAAU"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Config } from '@pnpm/config';
|
|
2
|
+
import { type InstallCommandOptions } from '@pnpm/plugin-commands-installation';
|
|
3
|
+
export declare function rcOptionsTypes(): Record<string, unknown>;
|
|
4
|
+
export declare function cliOptionsTypes(): Record<string, unknown>;
|
|
5
|
+
export declare const commandNames: string[];
|
|
6
|
+
export declare function help(): string;
|
|
7
|
+
export type SelfUpdateCommandOptions = InstallCommandOptions & Pick<Config, 'wantedPackageManager' | 'managePackageManagerVersions'>;
|
|
8
|
+
export declare function handler(opts: SelfUpdateCommandOptions): Promise<undefined | string>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.commandNames = void 0;
|
|
7
|
+
exports.rcOptionsTypes = rcOptionsTypes;
|
|
8
|
+
exports.cliOptionsTypes = cliOptionsTypes;
|
|
9
|
+
exports.help = help;
|
|
10
|
+
exports.handler = handler;
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const cli_utils_1 = require("@pnpm/cli-utils");
|
|
14
|
+
const cli_meta_1 = require("@pnpm/cli-meta");
|
|
15
|
+
const client_1 = require("@pnpm/client");
|
|
16
|
+
const pick_registry_for_package_1 = require("@pnpm/pick-registry-for-package");
|
|
17
|
+
const config_1 = require("@pnpm/config");
|
|
18
|
+
const error_1 = require("@pnpm/error");
|
|
19
|
+
const logger_1 = require("@pnpm/logger");
|
|
20
|
+
const plugin_commands_installation_1 = require("@pnpm/plugin-commands-installation");
|
|
21
|
+
const read_project_manifest_1 = require("@pnpm/read-project-manifest");
|
|
22
|
+
const tools_path_1 = require("@pnpm/tools.path");
|
|
23
|
+
const link_bins_1 = require("@pnpm/link-bins");
|
|
24
|
+
const pick_1 = __importDefault(require("ramda/src/pick"));
|
|
25
|
+
const render_help_1 = __importDefault(require("render-help"));
|
|
26
|
+
function rcOptionsTypes() {
|
|
27
|
+
return (0, pick_1.default)([], config_1.types);
|
|
28
|
+
}
|
|
29
|
+
function cliOptionsTypes() {
|
|
30
|
+
return {
|
|
31
|
+
...rcOptionsTypes(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.commandNames = ['self-update'];
|
|
35
|
+
function help() {
|
|
36
|
+
return (0, render_help_1.default)({
|
|
37
|
+
description: 'Updates pnpm to the latest version',
|
|
38
|
+
descriptionLists: [],
|
|
39
|
+
url: (0, cli_utils_1.docsUrl)('self-update'),
|
|
40
|
+
usages: [],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async function handler(opts) {
|
|
44
|
+
if ((0, cli_meta_1.isExecutedByCorepack)()) {
|
|
45
|
+
throw new error_1.PnpmError('CANT_SELF_UPDATE_IN_COREPACK', 'You should update pnpm with corepack');
|
|
46
|
+
}
|
|
47
|
+
const { resolve } = (0, client_1.createResolver)({ ...opts, authConfig: opts.rawConfig });
|
|
48
|
+
const pkgName = 'pnpm';
|
|
49
|
+
const resolution = await resolve({ alias: pkgName, pref: 'latest' }, {
|
|
50
|
+
lockfileDir: opts.lockfileDir ?? opts.dir,
|
|
51
|
+
preferredVersions: {},
|
|
52
|
+
projectDir: opts.dir,
|
|
53
|
+
registry: (0, pick_registry_for_package_1.pickRegistryForPackage)(opts.registries, pkgName, 'latest'),
|
|
54
|
+
});
|
|
55
|
+
if (!resolution?.manifest) {
|
|
56
|
+
throw new error_1.PnpmError('CANNOT_RESOLVE_PNPM', 'Cannot find latest version of pnpm');
|
|
57
|
+
}
|
|
58
|
+
if (resolution.manifest.version === cli_meta_1.packageManager.version) {
|
|
59
|
+
return `The currently active ${cli_meta_1.packageManager.name} v${cli_meta_1.packageManager.version} is already "latest" and doesn't need an update`;
|
|
60
|
+
}
|
|
61
|
+
if (opts.wantedPackageManager?.name === cli_meta_1.packageManager.name && opts.managePackageManagerVersions) {
|
|
62
|
+
const { manifest, writeProjectManifest } = await (0, read_project_manifest_1.readProjectManifest)(opts.rootProjectManifestDir);
|
|
63
|
+
manifest.packageManager = `pnpm@${resolution.manifest.version}`;
|
|
64
|
+
await writeProjectManifest(manifest);
|
|
65
|
+
return `The current project has been updated to use pnpm v${resolution.manifest.version}`;
|
|
66
|
+
}
|
|
67
|
+
const currentPkgName = (0, cli_meta_1.getCurrentPackageName)();
|
|
68
|
+
const dir = (0, tools_path_1.getToolDirPath)({
|
|
69
|
+
pnpmHomeDir: opts.pnpmHomeDir,
|
|
70
|
+
tool: {
|
|
71
|
+
name: currentPkgName,
|
|
72
|
+
version: resolution.manifest.version,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
if (fs_1.default.existsSync(dir)) {
|
|
76
|
+
await (0, link_bins_1.linkBins)(path_1.default.join(dir, opts.modulesDir ?? 'node_modules'), opts.pnpmHomeDir, {
|
|
77
|
+
warn: logger_1.globalWarn,
|
|
78
|
+
});
|
|
79
|
+
return `The latest version, v${resolution.manifest.version}, is already present on the system. It was activated by linking it from ${dir}.`;
|
|
80
|
+
}
|
|
81
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
82
|
+
fs_1.default.writeFileSync(path_1.default.join(dir, 'package.json'), '{}');
|
|
83
|
+
await plugin_commands_installation_1.add.handler({
|
|
84
|
+
...opts,
|
|
85
|
+
dir,
|
|
86
|
+
lockfileDir: dir,
|
|
87
|
+
bin: opts.pnpmHomeDir,
|
|
88
|
+
}, [`${currentPkgName}@${resolution.manifest.version}`]);
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=selfUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selfUpdate.js","sourceRoot":"","sources":["../src/selfUpdate.ts"],"names":[],"mappings":";;;;;;AAgBA,wCAEC;AAED,0CAIC;AAID,oBAOC;AAID,0BAwDC;AA/FD,4CAAmB;AACnB,gDAAuB;AACvB,+CAAyC;AACzC,6CAA4F;AAC5F,yCAA6C;AAC7C,+EAAwE;AACxE,yCAA6D;AAC7D,uCAAuC;AACvC,yCAAyC;AACzC,qFAAoF;AACpF,uEAAiE;AACjE,iDAAiD;AACjD,+CAA0C;AAC1C,0DAAiC;AACjC,8DAAoC;AAEpC,SAAgB,cAAc;IAC5B,OAAO,IAAA,cAAI,EAAC,EAAE,EAAE,cAAQ,CAAC,CAAA;AAC3B,CAAC;AAED,SAAgB,eAAe;IAC7B,OAAO;QACL,GAAG,cAAc,EAAE;KACpB,CAAA;AACH,CAAC;AAEY,QAAA,YAAY,GAAG,CAAC,aAAa,CAAC,CAAA;AAE3C,SAAgB,IAAI;IAClB,OAAO,IAAA,qBAAU,EAAC;QAChB,WAAW,EAAE,oCAAoC;QACjD,gBAAgB,EAAE,EAAE;QACpB,GAAG,EAAE,IAAA,mBAAO,EAAC,aAAa,CAAC;QAC3B,MAAM,EAAE,EAAE;KACX,CAAC,CAAA;AACJ,CAAC;AAIM,KAAK,UAAU,OAAO,CAC3B,IAA8B;IAE9B,IAAI,IAAA,+BAAoB,GAAE,EAAE,CAAC;QAC3B,MAAM,IAAI,iBAAS,CAAC,8BAA8B,EAAE,sCAAsC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;IAC3F,CAAC;IAED,MAAM,cAAc,GAAG,IAAA,gCAAqB,GAAE,CAAA;IAC9C,MAAM,GAAG,GAAG,IAAA,2BAAc,EAAC;QACzB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,IAAI,EAAE;YACJ,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,UAAU,CAAC,QAAQ,CAAC,OAAO;SACrC;KACF,CAAC,CAAA;IACF,IAAI,YAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAA,oBAAQ,EAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,IAAI,cAAc,CAAC,EAAE,IAAI,CAAC,WAAW,EAChF;YACE,IAAI,EAAE,mBAAU;SACjB,CACF,CAAA;QACD,OAAO,wBAAwB,UAAU,CAAC,QAAQ,CAAC,OAAO,2EAA2E,GAAG,GAAG,CAAA;IAC7I,CAAC;IACD,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACtC,YAAE,CAAC,aAAa,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,IAAI,CAAC,CAAA;IACtD,MAAM,kCAAG,CAAC,OAAO,CACf;QACE,GAAG,IAAI;QACP,GAAG;QACH,WAAW,EAAE,GAAG;QAChB,GAAG,EAAE,IAAI,CAAC,WAAW;KACtB,EACD,CAAC,GAAG,cAAc,IAAI,UAAU,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CACrD,CAAA;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pnpm/tools.plugin-commands-self-updater",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A command for updating pnpm itself",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"!*.map"
|
|
10
|
+
],
|
|
11
|
+
"repository": "https://github.com/pnpm/pnpm/blob/main/tools/plugin-commands-self-updater",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"pnpm9",
|
|
14
|
+
"pnpm"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18.12"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/pnpm/pnpm/blob/main/tools/plugin-commands-self-updater#readme",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
26
|
+
"render-help": "^1.0.3",
|
|
27
|
+
"@pnpm/cli-meta": "6.2.0",
|
|
28
|
+
"@pnpm/config": "21.8.1",
|
|
29
|
+
"@pnpm/cli-utils": "4.0.3",
|
|
30
|
+
"@pnpm/client": "11.1.7",
|
|
31
|
+
"@pnpm/error": "6.0.1",
|
|
32
|
+
"@pnpm/plugin-commands-installation": "17.1.0",
|
|
33
|
+
"@pnpm/pick-registry-for-package": "6.0.5",
|
|
34
|
+
"@pnpm/link-bins": "10.0.8",
|
|
35
|
+
"@pnpm/read-project-manifest": "6.0.6",
|
|
36
|
+
"@pnpm/tools.path": "1.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/cross-spawn": "^6.0.6",
|
|
40
|
+
"@types/ramda": "0.29.12",
|
|
41
|
+
"cross-spawn": "^7.0.3",
|
|
42
|
+
"nock": "13.3.4",
|
|
43
|
+
"@pnpm/prepare": "0.0.100",
|
|
44
|
+
"@pnpm/env.path": "1.0.0",
|
|
45
|
+
"@pnpm/tools.plugin-commands-self-updater": "1.0.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@pnpm/logger": "^5.1.0"
|
|
49
|
+
},
|
|
50
|
+
"funding": "https://opencollective.com/pnpm",
|
|
51
|
+
"exports": {
|
|
52
|
+
".": "./lib/index.js"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
56
|
+
"test": "pnpm run compile && pnpm run _test",
|
|
57
|
+
"compile": "tsc --build && pnpm run lint --fix",
|
|
58
|
+
"_test": "jest"
|
|
59
|
+
}
|
|
60
|
+
}
|