@pnpm/plugin-commands-setup 0.0.0-20230605-20230605142810
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/setup.d.ts +11 -0
- package/lib/setup.js +117 -0
- package/lib/setup.js.map +1 -0
- package/package.json +48 -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-2023 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/plugin-commands-setup
|
|
2
|
+
|
|
3
|
+
> pnpm commands for setting up pnpm
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pnpm/plugin-commands-setup)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add @pnpm/plugin-commands-setup
|
|
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.setup = void 0;
|
|
27
|
+
const setup = __importStar(require("./setup"));
|
|
28
|
+
exports.setup = setup;
|
|
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,+CAAgC;AAEvB,sBAAK"}
|
package/lib/setup.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const rcOptionsTypes: () => {};
|
|
2
|
+
export declare const cliOptionsTypes: () => {
|
|
3
|
+
force: BooleanConstructor;
|
|
4
|
+
};
|
|
5
|
+
export declare const shorthands: {};
|
|
6
|
+
export declare const commandNames: string[];
|
|
7
|
+
export declare function help(): string;
|
|
8
|
+
export declare function handler(opts: {
|
|
9
|
+
force?: boolean;
|
|
10
|
+
pnpmHomeDir: string;
|
|
11
|
+
}): Promise<string>;
|
package/lib/setup.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
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.handler = exports.help = exports.commandNames = exports.shorthands = exports.cliOptionsTypes = exports.rcOptionsTypes = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const cli_utils_1 = require("@pnpm/cli-utils");
|
|
10
|
+
const logger_1 = require("@pnpm/logger");
|
|
11
|
+
const os_env_path_extender_1 = require("@pnpm/os.env.path-extender");
|
|
12
|
+
const render_help_1 = __importDefault(require("render-help"));
|
|
13
|
+
const rcOptionsTypes = () => ({});
|
|
14
|
+
exports.rcOptionsTypes = rcOptionsTypes;
|
|
15
|
+
const cliOptionsTypes = () => ({
|
|
16
|
+
force: Boolean,
|
|
17
|
+
});
|
|
18
|
+
exports.cliOptionsTypes = cliOptionsTypes;
|
|
19
|
+
exports.shorthands = {};
|
|
20
|
+
exports.commandNames = ['setup'];
|
|
21
|
+
function help() {
|
|
22
|
+
return (0, render_help_1.default)({
|
|
23
|
+
description: 'Sets up pnpm',
|
|
24
|
+
descriptionLists: [
|
|
25
|
+
{
|
|
26
|
+
title: 'Options',
|
|
27
|
+
list: [
|
|
28
|
+
{
|
|
29
|
+
description: 'Override the PNPM_HOME env variable in case it already exists',
|
|
30
|
+
name: '--force',
|
|
31
|
+
shortAlias: '-f',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
url: (0, cli_utils_1.docsUrl)('setup'),
|
|
37
|
+
usages: ['pnpm setup'],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.help = help;
|
|
41
|
+
function getExecPath() {
|
|
42
|
+
// @ts-expect-error
|
|
43
|
+
if (process['pkg'] != null) {
|
|
44
|
+
// If the pnpm CLI was bundled by vercel/pkg then we cannot use the js path for npm_execpath
|
|
45
|
+
// because in that case the js is in a virtual filesystem inside the executor.
|
|
46
|
+
// Instead, we use the path to the exe file.
|
|
47
|
+
return process.execPath;
|
|
48
|
+
}
|
|
49
|
+
return (require.main != null) ? require.main.filename : process.cwd();
|
|
50
|
+
}
|
|
51
|
+
function copyCli(currentLocation, targetDir) {
|
|
52
|
+
const newExecPath = path_1.default.join(targetDir, path_1.default.basename(currentLocation));
|
|
53
|
+
if (path_1.default.relative(newExecPath, currentLocation) === '')
|
|
54
|
+
return;
|
|
55
|
+
logger_1.logger.info({
|
|
56
|
+
message: `Copying pnpm CLI from ${currentLocation} to ${newExecPath}`,
|
|
57
|
+
prefix: process.cwd(),
|
|
58
|
+
});
|
|
59
|
+
fs_1.default.mkdirSync(targetDir, { recursive: true });
|
|
60
|
+
fs_1.default.copyFileSync(currentLocation, newExecPath);
|
|
61
|
+
}
|
|
62
|
+
async function handler(opts) {
|
|
63
|
+
const execPath = getExecPath();
|
|
64
|
+
if (execPath.match(/\.[cm]?js$/) == null) {
|
|
65
|
+
copyCli(execPath, opts.pnpmHomeDir);
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const report = await (0, os_env_path_extender_1.addDirToEnvPath)(opts.pnpmHomeDir, {
|
|
69
|
+
configSectionName: 'pnpm',
|
|
70
|
+
proxyVarName: 'PNPM_HOME',
|
|
71
|
+
overwrite: opts.force,
|
|
72
|
+
position: 'start',
|
|
73
|
+
});
|
|
74
|
+
return renderSetupOutput(report);
|
|
75
|
+
}
|
|
76
|
+
catch (err) { // eslint-disable-line
|
|
77
|
+
switch (err.code) {
|
|
78
|
+
case 'ERR_PNPM_BAD_ENV_FOUND':
|
|
79
|
+
err.hint = 'If you want to override the existing env variable, use the --force option';
|
|
80
|
+
break;
|
|
81
|
+
case 'ERR_PNPM_BAD_SHELL_SECTION':
|
|
82
|
+
err.hint = 'If you want to override the existing configuration section, use the --force option';
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.handler = handler;
|
|
89
|
+
function renderSetupOutput(report) {
|
|
90
|
+
if (report.oldSettings === report.newSettings) {
|
|
91
|
+
return 'No changes to the environment were made. Everything is already up to date.';
|
|
92
|
+
}
|
|
93
|
+
const output = [];
|
|
94
|
+
if (report.configFile) {
|
|
95
|
+
output.push(reportConfigChange(report.configFile));
|
|
96
|
+
}
|
|
97
|
+
output.push(`Next configuration changes were made:
|
|
98
|
+
${report.newSettings}`);
|
|
99
|
+
if (report.configFile == null) {
|
|
100
|
+
output.push('Setup complete. Open a new terminal to start using pnpm.');
|
|
101
|
+
}
|
|
102
|
+
else if (report.configFile.changeType !== 'skipped') {
|
|
103
|
+
output.push(`To start using pnpm, run:
|
|
104
|
+
source ${report.configFile.path}
|
|
105
|
+
`);
|
|
106
|
+
}
|
|
107
|
+
return output.join('\n\n');
|
|
108
|
+
}
|
|
109
|
+
function reportConfigChange(configReport) {
|
|
110
|
+
switch (configReport.changeType) {
|
|
111
|
+
case 'created': return `Created ${configReport.path}`;
|
|
112
|
+
case 'appended': return `Appended new lines to ${configReport.path}`;
|
|
113
|
+
case 'modified': return `Replaced configuration in ${configReport.path}`;
|
|
114
|
+
case 'skipped': return `Configuration already up to date in ${configReport.path}`;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=setup.js.map
|
package/lib/setup.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,+CAAyC;AACzC,yCAAqC;AACrC,qEAImC;AACnC,8DAAoC;AAE7B,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;AAA3B,QAAA,cAAc,kBAAa;AAEjC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,CAAC;IACpC,KAAK,EAAE,OAAO;CACf,CAAC,CAAA;AAFW,QAAA,eAAe,mBAE1B;AAEW,QAAA,UAAU,GAAG,EAAE,CAAA;AAEf,QAAA,YAAY,GAAG,CAAC,OAAO,CAAC,CAAA;AAErC,SAAgB,IAAI;IAClB,OAAO,IAAA,qBAAU,EAAC;QAChB,WAAW,EAAE,cAAc;QAC3B,gBAAgB,EAAE;YAChB;gBACE,KAAK,EAAE,SAAS;gBAEhB,IAAI,EAAE;oBACJ;wBACE,WAAW,EAAE,+DAA+D;wBAC5E,IAAI,EAAE,SAAS;wBACf,UAAU,EAAE,IAAI;qBACjB;iBACF;aACF;SACF;QACD,GAAG,EAAE,IAAA,mBAAO,EAAC,OAAO,CAAC;QACrB,MAAM,EAA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QACjC,KAAK,SAAS,CAAC,CAAC,OAAO,WAAW,YAAY,CAAC,IAAI,EAAE,CAAA;QACrD,KAAK,UAAU,CAAC,CAAC,OAAO,yBAAyB,YAAY,CAAC,IAAI,EAAE,CAAA;QACpE,KAAK,UAAU,CAAC,CAAC,OAAO,6BAA6B,YAAY,CAAC,IAAI,EAAE,CAAA;QACxE,KAAK,SAAS,CAAC,CAAC,OAAO,uCAAuC,YAAY,CAAC,IAAI,EAAE,CAAA;KAChF;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pnpm/plugin-commands-setup",
|
|
3
|
+
"version": "0.0.0-20230605-20230605142810",
|
|
4
|
+
"description": "pnpm commands for setting up pnpm",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"!*.map"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=16.14"
|
|
13
|
+
},
|
|
14
|
+
"repository": "https://github.com/pnpm/pnpm/blob/main/packages/plugin-commands-setup",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pnpm8",
|
|
17
|
+
"pnpm",
|
|
18
|
+
"setup"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/pnpm/pnpm/blob/main/packages/plugin-commands-setup#readme",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@pnpm/os.env.path-extender": "^0.2.10",
|
|
27
|
+
"render-help": "^1.0.3",
|
|
28
|
+
"@pnpm/cli-utils": "0.0.0-20230605-20230605142810"
|
|
29
|
+
},
|
|
30
|
+
"funding": "https://opencollective.com/pnpm",
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@pnpm/logger": "^5.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@pnpm/error": "0.0.0-20230605-20230605142810",
|
|
36
|
+
"@pnpm/prepare": "0.0.0-20230605-20230605142810",
|
|
37
|
+
"@pnpm/plugin-commands-setup": "0.0.0-20230605-20230605142810"
|
|
38
|
+
},
|
|
39
|
+
"exports": {
|
|
40
|
+
".": "./lib/index.js"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
44
|
+
"_test": "jest",
|
|
45
|
+
"test": "pnpm run compile && pnpm run _test",
|
|
46
|
+
"compile": "tsc --build && pnpm run lint --fix"
|
|
47
|
+
}
|
|
48
|
+
}
|