@atlaspack/package-manager 2.14.18-noselfbuild-63bde801d.0 → 2.14.18-typescript-e769947a5.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/index.js +5219 -64
- package/lib/index.js.map +1 -0
- package/package.json +13 -11
- package/lib/JSONParseStream.js +0 -53
- package/lib/MockPackageInstaller.js +0 -79
- package/lib/NodePackageManager.js +0 -582
- package/lib/Npm.js +0 -105
- package/lib/Pnpm.js +0 -171
- package/lib/Yarn.js +0 -146
- package/lib/getCurrentPackageManager.js +0 -18
- package/lib/installPackage.js +0 -222
- package/lib/nodejsConditions.js +0 -35
- package/lib/promiseFromProcess.js +0 -18
- package/lib/utils.js +0 -101
- package/lib/validateModuleSpecifier.js +0 -14
package/lib/Pnpm.js
DELETED
@@ -1,171 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.Pnpm = void 0;
|
7
|
-
function _path() {
|
8
|
-
const data = _interopRequireDefault(require("path"));
|
9
|
-
_path = function () {
|
10
|
-
return data;
|
11
|
-
};
|
12
|
-
return data;
|
13
|
-
}
|
14
|
-
function _fs() {
|
15
|
-
const data = _interopRequireDefault(require("fs"));
|
16
|
-
_fs = function () {
|
17
|
-
return data;
|
18
|
-
};
|
19
|
-
return data;
|
20
|
-
}
|
21
|
-
function _commandExists() {
|
22
|
-
const data = _interopRequireDefault(require("command-exists"));
|
23
|
-
_commandExists = function () {
|
24
|
-
return data;
|
25
|
-
};
|
26
|
-
return data;
|
27
|
-
}
|
28
|
-
function _crossSpawn() {
|
29
|
-
const data = _interopRequireDefault(require("cross-spawn"));
|
30
|
-
_crossSpawn = function () {
|
31
|
-
return data;
|
32
|
-
};
|
33
|
-
return data;
|
34
|
-
}
|
35
|
-
function _buildCache() {
|
36
|
-
const data = require("@atlaspack/build-cache");
|
37
|
-
_buildCache = function () {
|
38
|
-
return data;
|
39
|
-
};
|
40
|
-
return data;
|
41
|
-
}
|
42
|
-
function _logger() {
|
43
|
-
const data = _interopRequireDefault(require("@atlaspack/logger"));
|
44
|
-
_logger = function () {
|
45
|
-
return data;
|
46
|
-
};
|
47
|
-
return data;
|
48
|
-
}
|
49
|
-
function _split() {
|
50
|
-
const data = _interopRequireDefault(require("split2"));
|
51
|
-
_split = function () {
|
52
|
-
return data;
|
53
|
-
};
|
54
|
-
return data;
|
55
|
-
}
|
56
|
-
var _JSONParseStream = _interopRequireDefault(require("./JSONParseStream"));
|
57
|
-
var _promiseFromProcess = _interopRequireDefault(require("./promiseFromProcess"));
|
58
|
-
var _utils = require("./utils");
|
59
|
-
var _package = _interopRequireDefault(require("../package.json"));
|
60
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
61
|
-
// $FlowFixMe
|
62
|
-
const PNPM_CMD = 'pnpm';
|
63
|
-
let hasPnpm;
|
64
|
-
let pnpmVersion;
|
65
|
-
class Pnpm {
|
66
|
-
static async exists() {
|
67
|
-
if (hasPnpm != null) {
|
68
|
-
return hasPnpm;
|
69
|
-
}
|
70
|
-
try {
|
71
|
-
hasPnpm = Boolean(await (0, _commandExists().default)('pnpm'));
|
72
|
-
} catch (err) {
|
73
|
-
hasPnpm = false;
|
74
|
-
}
|
75
|
-
return hasPnpm;
|
76
|
-
}
|
77
|
-
async install({
|
78
|
-
modules,
|
79
|
-
cwd,
|
80
|
-
saveDev = true
|
81
|
-
}) {
|
82
|
-
if (pnpmVersion == null) {
|
83
|
-
let version = await (0, _utils.exec)('pnpm --version');
|
84
|
-
pnpmVersion = parseInt(version.stdout, 10);
|
85
|
-
}
|
86
|
-
let args = ['add', '--reporter', 'ndjson'];
|
87
|
-
if (saveDev) {
|
88
|
-
args.push('-D');
|
89
|
-
}
|
90
|
-
if (pnpmVersion >= 7) {
|
91
|
-
if (_fs().default.existsSync(_path().default.join(cwd, 'pnpm-workspace.yaml'))) {
|
92
|
-
// installs in workspace root (regardless of cwd)
|
93
|
-
args.push('-w');
|
94
|
-
}
|
95
|
-
} else {
|
96
|
-
// ignores workspace root check
|
97
|
-
args.push('-W');
|
98
|
-
}
|
99
|
-
args = args.concat(modules.map(_utils.npmSpecifierFromModuleRequest));
|
100
|
-
let env = {};
|
101
|
-
for (let key in process.env) {
|
102
|
-
if (!key.startsWith('npm_') && key !== 'INIT_CWD' && key !== 'NODE_ENV') {
|
103
|
-
env[key] = process.env[key];
|
104
|
-
}
|
105
|
-
}
|
106
|
-
let addedCount = 0,
|
107
|
-
removedCount = 0;
|
108
|
-
let installProcess = (0, _crossSpawn().default)(PNPM_CMD, args, {
|
109
|
-
cwd,
|
110
|
-
env
|
111
|
-
});
|
112
|
-
installProcess.stdout.pipe((0, _split().default)()).pipe(new _JSONParseStream.default()).on('error', e => {
|
113
|
-
_logger().default.warn({
|
114
|
-
origin: '@atlaspack/package-manager',
|
115
|
-
message: e.chunk,
|
116
|
-
stack: e.stack
|
117
|
-
});
|
118
|
-
}).on('data', json => {
|
119
|
-
if (json.level === 'error') {
|
120
|
-
_logger().default.error({
|
121
|
-
origin: '@atlaspack/package-manager',
|
122
|
-
message: json.err.message,
|
123
|
-
stack: json.err.stack
|
124
|
-
});
|
125
|
-
} else if (json.level === 'info' && typeof json.message === 'string') {
|
126
|
-
_logger().default.info({
|
127
|
-
origin: '@atlaspack/package-manager',
|
128
|
-
message: prefix(json.message)
|
129
|
-
});
|
130
|
-
} else if (json.name === 'pnpm:stats') {
|
131
|
-
addedCount += json.added ?? 0;
|
132
|
-
removedCount += json.removed ?? 0;
|
133
|
-
}
|
134
|
-
});
|
135
|
-
let stderr = [];
|
136
|
-
installProcess.stderr.on('data', str => {
|
137
|
-
stderr.push(str.toString());
|
138
|
-
}).on('error', e => {
|
139
|
-
_logger().default.warn({
|
140
|
-
origin: '@atlaspack/package-manager',
|
141
|
-
message: e.message
|
142
|
-
});
|
143
|
-
});
|
144
|
-
try {
|
145
|
-
await (0, _promiseFromProcess.default)(installProcess);
|
146
|
-
if (addedCount > 0 || removedCount > 0) {
|
147
|
-
_logger().default.log({
|
148
|
-
origin: '@atlaspack/package-manager',
|
149
|
-
message: `Added ${addedCount} ${removedCount > 0 ? `and removed ${removedCount} ` : ''}packages via pnpm`
|
150
|
-
});
|
151
|
-
}
|
152
|
-
|
153
|
-
// Since we succeeded, stderr might have useful information not included
|
154
|
-
// in the json written to stdout. It's also not necessary to log these as
|
155
|
-
// errors as they often aren't.
|
156
|
-
for (let message of stderr) {
|
157
|
-
_logger().default.log({
|
158
|
-
origin: '@atlaspack/package-manager',
|
159
|
-
message
|
160
|
-
});
|
161
|
-
}
|
162
|
-
} catch (e) {
|
163
|
-
throw new Error('pnpm failed to install modules');
|
164
|
-
}
|
165
|
-
}
|
166
|
-
}
|
167
|
-
exports.Pnpm = Pnpm;
|
168
|
-
function prefix(message) {
|
169
|
-
return 'pnpm: ' + message;
|
170
|
-
}
|
171
|
-
(0, _buildCache().registerSerializableClass)(`${_package.default.version}:Pnpm`, Pnpm);
|
package/lib/Yarn.js
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.Yarn = void 0;
|
7
|
-
function _commandExists() {
|
8
|
-
const data = _interopRequireDefault(require("command-exists"));
|
9
|
-
_commandExists = function () {
|
10
|
-
return data;
|
11
|
-
};
|
12
|
-
return data;
|
13
|
-
}
|
14
|
-
function _crossSpawn() {
|
15
|
-
const data = _interopRequireDefault(require("cross-spawn"));
|
16
|
-
_crossSpawn = function () {
|
17
|
-
return data;
|
18
|
-
};
|
19
|
-
return data;
|
20
|
-
}
|
21
|
-
function _buildCache() {
|
22
|
-
const data = require("@atlaspack/build-cache");
|
23
|
-
_buildCache = function () {
|
24
|
-
return data;
|
25
|
-
};
|
26
|
-
return data;
|
27
|
-
}
|
28
|
-
function _logger() {
|
29
|
-
const data = _interopRequireDefault(require("@atlaspack/logger"));
|
30
|
-
_logger = function () {
|
31
|
-
return data;
|
32
|
-
};
|
33
|
-
return data;
|
34
|
-
}
|
35
|
-
function _split() {
|
36
|
-
const data = _interopRequireDefault(require("split2"));
|
37
|
-
_split = function () {
|
38
|
-
return data;
|
39
|
-
};
|
40
|
-
return data;
|
41
|
-
}
|
42
|
-
var _JSONParseStream = _interopRequireDefault(require("./JSONParseStream"));
|
43
|
-
var _promiseFromProcess = _interopRequireDefault(require("./promiseFromProcess"));
|
44
|
-
var _utils = require("./utils");
|
45
|
-
var _package = _interopRequireDefault(require("../package.json"));
|
46
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
47
|
-
// $FlowFixMe
|
48
|
-
const YARN_CMD = 'yarn';
|
49
|
-
let hasYarn;
|
50
|
-
let yarnVersion;
|
51
|
-
class Yarn {
|
52
|
-
static async exists() {
|
53
|
-
if (hasYarn != null) {
|
54
|
-
return hasYarn;
|
55
|
-
}
|
56
|
-
try {
|
57
|
-
hasYarn = Boolean(await (0, _commandExists().default)('yarn'));
|
58
|
-
} catch (err) {
|
59
|
-
hasYarn = false;
|
60
|
-
}
|
61
|
-
return hasYarn;
|
62
|
-
}
|
63
|
-
async install({
|
64
|
-
modules,
|
65
|
-
cwd,
|
66
|
-
saveDev = true
|
67
|
-
}) {
|
68
|
-
if (yarnVersion == null) {
|
69
|
-
let version = await (0, _utils.exec)('yarn --version');
|
70
|
-
yarnVersion = parseInt(version.stdout, 10);
|
71
|
-
}
|
72
|
-
let args = ['add', '--json'].concat(modules.map(_utils.npmSpecifierFromModuleRequest));
|
73
|
-
if (saveDev) {
|
74
|
-
args.push('-D');
|
75
|
-
if (yarnVersion < 2) {
|
76
|
-
args.push('-W');
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
// When Parcel is run by Yarn (e.g. via package.json scripts), several environment variables are
|
81
|
-
// added. When parcel in turn calls Yarn again, these can cause Yarn to behave stragely, so we
|
82
|
-
// filter them out when installing packages.
|
83
|
-
let env = {};
|
84
|
-
for (let key in process.env) {
|
85
|
-
if (!key.startsWith('npm_') && key !== 'YARN_WRAP_OUTPUT' && key !== 'INIT_CWD' && key !== 'NODE_ENV') {
|
86
|
-
env[key] = process.env[key];
|
87
|
-
}
|
88
|
-
}
|
89
|
-
let installProcess = (0, _crossSpawn().default)(YARN_CMD, args, {
|
90
|
-
cwd,
|
91
|
-
env
|
92
|
-
});
|
93
|
-
installProcess.stdout
|
94
|
-
// Invoking yarn with --json provides streaming, newline-delimited JSON output.
|
95
|
-
.pipe((0, _split().default)()).pipe(new _JSONParseStream.default()).on('error', e => {
|
96
|
-
_logger().default.error(e, '@atlaspack/package-manager');
|
97
|
-
}).on('data', message => {
|
98
|
-
switch (message.type) {
|
99
|
-
case 'step':
|
100
|
-
_logger().default.progress(prefix(`[${message.data.current}/${message.data.total}] ${message.data.message}`));
|
101
|
-
return;
|
102
|
-
case 'success':
|
103
|
-
case 'info':
|
104
|
-
_logger().default.info({
|
105
|
-
origin: '@atlaspack/package-manager',
|
106
|
-
message: prefix(message.data)
|
107
|
-
});
|
108
|
-
return;
|
109
|
-
default:
|
110
|
-
// ignore
|
111
|
-
}
|
112
|
-
});
|
113
|
-
|
114
|
-
installProcess.stderr.pipe((0, _split().default)()).pipe(new _JSONParseStream.default()).on('error', e => {
|
115
|
-
_logger().default.error(e, '@atlaspack/package-manager');
|
116
|
-
}).on('data', message => {
|
117
|
-
switch (message.type) {
|
118
|
-
case 'warning':
|
119
|
-
_logger().default.warn({
|
120
|
-
origin: '@atlaspack/package-manager',
|
121
|
-
message: prefix(message.data)
|
122
|
-
});
|
123
|
-
return;
|
124
|
-
case 'error':
|
125
|
-
_logger().default.error({
|
126
|
-
origin: '@atlaspack/package-manager',
|
127
|
-
message: prefix(message.data)
|
128
|
-
});
|
129
|
-
return;
|
130
|
-
default:
|
131
|
-
// ignore
|
132
|
-
}
|
133
|
-
});
|
134
|
-
|
135
|
-
try {
|
136
|
-
return await (0, _promiseFromProcess.default)(installProcess);
|
137
|
-
} catch (e) {
|
138
|
-
throw new Error('Yarn failed to install modules:' + e.message);
|
139
|
-
}
|
140
|
-
}
|
141
|
-
}
|
142
|
-
exports.Yarn = Yarn;
|
143
|
-
function prefix(message) {
|
144
|
-
return 'yarn: ' + message;
|
145
|
-
}
|
146
|
-
(0, _buildCache().registerSerializableClass)(`${_package.default.version}:Yarn`, Yarn);
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = getCurrentPackageManager;
|
7
|
-
function getCurrentPackageManager(userAgent = process.env.npm_config_user_agent) {
|
8
|
-
if (!userAgent) {
|
9
|
-
return undefined;
|
10
|
-
}
|
11
|
-
const pmSpec = userAgent.split(' ')[0];
|
12
|
-
const separatorPos = pmSpec.lastIndexOf('/');
|
13
|
-
const name = pmSpec.substring(0, separatorPos);
|
14
|
-
return {
|
15
|
-
name: name,
|
16
|
-
version: pmSpec.substring(separatorPos + 1)
|
17
|
-
};
|
18
|
-
}
|
package/lib/installPackage.js
DELETED
@@ -1,222 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports._addToInstallQueue = _addToInstallQueue;
|
7
|
-
exports.installPackage = installPackage;
|
8
|
-
function _assert() {
|
9
|
-
const data = _interopRequireDefault(require("assert"));
|
10
|
-
_assert = function () {
|
11
|
-
return data;
|
12
|
-
};
|
13
|
-
return data;
|
14
|
-
}
|
15
|
-
function _path() {
|
16
|
-
const data = _interopRequireDefault(require("path"));
|
17
|
-
_path = function () {
|
18
|
-
return data;
|
19
|
-
};
|
20
|
-
return data;
|
21
|
-
}
|
22
|
-
function _nullthrows() {
|
23
|
-
const data = _interopRequireDefault(require("nullthrows"));
|
24
|
-
_nullthrows = function () {
|
25
|
-
return data;
|
26
|
-
};
|
27
|
-
return data;
|
28
|
-
}
|
29
|
-
function _semver() {
|
30
|
-
const data = _interopRequireDefault(require("semver"));
|
31
|
-
_semver = function () {
|
32
|
-
return data;
|
33
|
-
};
|
34
|
-
return data;
|
35
|
-
}
|
36
|
-
function _diagnostic() {
|
37
|
-
const data = _interopRequireWildcard(require("@atlaspack/diagnostic"));
|
38
|
-
_diagnostic = function () {
|
39
|
-
return data;
|
40
|
-
};
|
41
|
-
return data;
|
42
|
-
}
|
43
|
-
function _logger() {
|
44
|
-
const data = _interopRequireDefault(require("@atlaspack/logger"));
|
45
|
-
_logger = function () {
|
46
|
-
return data;
|
47
|
-
};
|
48
|
-
return data;
|
49
|
-
}
|
50
|
-
function _utils() {
|
51
|
-
const data = require("@atlaspack/utils");
|
52
|
-
_utils = function () {
|
53
|
-
return data;
|
54
|
-
};
|
55
|
-
return data;
|
56
|
-
}
|
57
|
-
function _workers() {
|
58
|
-
const data = _interopRequireDefault(require("@atlaspack/workers"));
|
59
|
-
_workers = function () {
|
60
|
-
return data;
|
61
|
-
};
|
62
|
-
return data;
|
63
|
-
}
|
64
|
-
var _Npm = require("./Npm");
|
65
|
-
var _Yarn = require("./Yarn");
|
66
|
-
var _Pnpm = require("./Pnpm");
|
67
|
-
var _utils2 = require("./utils");
|
68
|
-
var _getCurrentPackageManager = _interopRequireDefault(require("./getCurrentPackageManager"));
|
69
|
-
var _validateModuleSpecifier = _interopRequireDefault(require("./validateModuleSpecifier"));
|
70
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
71
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
72
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
73
|
-
async function install(fs, packageManager, modules, from, projectRoot, options = {}) {
|
74
|
-
let {
|
75
|
-
installPeers = true,
|
76
|
-
saveDev = true,
|
77
|
-
packageInstaller
|
78
|
-
} = options;
|
79
|
-
let moduleNames = modules.map(m => m.name).join(', ');
|
80
|
-
_logger().default.progress(`Installing ${moduleNames}...`);
|
81
|
-
let fromPkgPath = await (0, _utils().resolveConfig)(fs, from, ['package.json'], projectRoot);
|
82
|
-
let cwd = fromPkgPath ? _path().default.dirname(fromPkgPath) : fs.cwd();
|
83
|
-
if (!packageInstaller) {
|
84
|
-
packageInstaller = await determinePackageInstaller(fs, from, projectRoot);
|
85
|
-
}
|
86
|
-
try {
|
87
|
-
await packageInstaller.install({
|
88
|
-
modules,
|
89
|
-
saveDev,
|
90
|
-
cwd,
|
91
|
-
packagePath: fromPkgPath,
|
92
|
-
fs
|
93
|
-
});
|
94
|
-
} catch (err) {
|
95
|
-
throw new Error(`Failed to install ${moduleNames}: ${err.message}`);
|
96
|
-
}
|
97
|
-
if (installPeers) {
|
98
|
-
await Promise.all(modules.map(m => installPeerDependencies(fs, packageManager, m, from, projectRoot, options)));
|
99
|
-
}
|
100
|
-
}
|
101
|
-
async function installPeerDependencies(fs, packageManager, module, from, projectRoot, options) {
|
102
|
-
const {
|
103
|
-
resolved
|
104
|
-
} = await packageManager.resolve(module.name, from);
|
105
|
-
const modulePkg = (0, _nullthrows().default)(await (0, _utils().loadConfig)(fs, resolved, ['package.json'], projectRoot)).config;
|
106
|
-
const peers = modulePkg.peerDependencies || {};
|
107
|
-
let modules = [];
|
108
|
-
for (let [name, range] of Object.entries(peers)) {
|
109
|
-
(0, _assert().default)(typeof range === 'string');
|
110
|
-
let conflicts = await (0, _utils2.getConflictingLocalDependencies)(fs, name, from, projectRoot);
|
111
|
-
if (conflicts) {
|
112
|
-
let {
|
113
|
-
pkg
|
114
|
-
} = await packageManager.resolve(name, from);
|
115
|
-
(0, _assert().default)(pkg);
|
116
|
-
if (!_semver().default.satisfies(pkg.version, range)) {
|
117
|
-
throw new (_diagnostic().default)({
|
118
|
-
diagnostic: {
|
119
|
-
message: (0, _diagnostic().md)`Could not install the peer dependency "${name}" for "${module.name}", installed version ${pkg.version} is incompatible with ${range}`,
|
120
|
-
origin: '@atlaspack/package-manager',
|
121
|
-
codeFrames: [{
|
122
|
-
filePath: conflicts.filePath,
|
123
|
-
language: 'json',
|
124
|
-
code: conflicts.json,
|
125
|
-
codeHighlights: (0, _diagnostic().generateJSONCodeHighlights)(conflicts.json, conflicts.fields.map(field => ({
|
126
|
-
key: `/${field}/${(0, _diagnostic().encodeJSONKeyComponent)(name)}`,
|
127
|
-
type: 'key',
|
128
|
-
message: 'Found this conflicting local requirement.'
|
129
|
-
})))
|
130
|
-
}]
|
131
|
-
}
|
132
|
-
});
|
133
|
-
}
|
134
|
-
continue;
|
135
|
-
}
|
136
|
-
modules.push({
|
137
|
-
name,
|
138
|
-
range
|
139
|
-
});
|
140
|
-
}
|
141
|
-
if (modules.length) {
|
142
|
-
await install(fs, packageManager, modules, from, projectRoot, Object.assign({}, options, {
|
143
|
-
installPeers: false
|
144
|
-
}));
|
145
|
-
}
|
146
|
-
}
|
147
|
-
async function determinePackageInstaller(fs, filepath, projectRoot) {
|
148
|
-
var _getCurrentPackageMan;
|
149
|
-
let configFile = await (0, _utils().resolveConfig)(fs, filepath, ['package-lock.json', 'pnpm-lock.yaml', 'yarn.lock'], projectRoot);
|
150
|
-
let configName = configFile && _path().default.basename(configFile);
|
151
|
-
|
152
|
-
// Always use the package manager that seems to be used in the project,
|
153
|
-
// falling back to a different one wouldn't update the existing lockfile.
|
154
|
-
if (configName === 'package-lock.json') {
|
155
|
-
return new _Npm.Npm();
|
156
|
-
} else if (configName === 'pnpm-lock.yaml') {
|
157
|
-
return new _Pnpm.Pnpm();
|
158
|
-
} else if (configName === 'yarn.lock') {
|
159
|
-
return new _Yarn.Yarn();
|
160
|
-
}
|
161
|
-
let currentPackageManager = (_getCurrentPackageMan = (0, _getCurrentPackageManager.default)()) === null || _getCurrentPackageMan === void 0 ? void 0 : _getCurrentPackageMan.name;
|
162
|
-
if (currentPackageManager === 'npm') {
|
163
|
-
return new _Npm.Npm();
|
164
|
-
} else if (currentPackageManager === 'yarn') {
|
165
|
-
return new _Yarn.Yarn();
|
166
|
-
} else if (currentPackageManager === 'pnpm') {
|
167
|
-
return new _Pnpm.Pnpm();
|
168
|
-
}
|
169
|
-
if (await _Yarn.Yarn.exists()) {
|
170
|
-
return new _Yarn.Yarn();
|
171
|
-
} else if (await _Pnpm.Pnpm.exists()) {
|
172
|
-
return new _Pnpm.Pnpm();
|
173
|
-
} else {
|
174
|
-
return new _Npm.Npm();
|
175
|
-
}
|
176
|
-
}
|
177
|
-
let queue = new (_utils().PromiseQueue)({
|
178
|
-
maxConcurrent: 1
|
179
|
-
});
|
180
|
-
let modulesInstalling = new Set();
|
181
|
-
|
182
|
-
// Exported so that it may be invoked from the worker api below.
|
183
|
-
// Do not call this directly! This can result in concurrent package installations
|
184
|
-
// across multiple instances of the package manager.
|
185
|
-
function _addToInstallQueue(fs, packageManager, modules, filePath, projectRoot, options) {
|
186
|
-
modules = modules.map(request => ({
|
187
|
-
name: (0, _validateModuleSpecifier.default)(request.name),
|
188
|
-
range: request.range
|
189
|
-
}));
|
190
|
-
|
191
|
-
// Wrap PromiseQueue and track modules that are currently installing.
|
192
|
-
// If a request comes in for a module that is currently installing, don't bother
|
193
|
-
// enqueuing it.
|
194
|
-
let modulesToInstall = modules.filter(m => !modulesInstalling.has(getModuleRequestKey(m)));
|
195
|
-
if (modulesToInstall.length) {
|
196
|
-
for (let m of modulesToInstall) {
|
197
|
-
modulesInstalling.add(getModuleRequestKey(m));
|
198
|
-
}
|
199
|
-
queue.add(() => install(fs, packageManager, modulesToInstall, filePath, projectRoot, options).then(() => {
|
200
|
-
for (let m of modulesToInstall) {
|
201
|
-
modulesInstalling.delete(getModuleRequestKey(m));
|
202
|
-
}
|
203
|
-
}));
|
204
|
-
}
|
205
|
-
return queue.run();
|
206
|
-
}
|
207
|
-
function installPackage(fs, packageManager, modules, filePath, projectRoot, options) {
|
208
|
-
if (_workers().default.isWorker()) {
|
209
|
-
let workerApi = _workers().default.getWorkerApi();
|
210
|
-
// TODO this should really be `__filename` but without the rewriting.
|
211
|
-
let bundlePath = process.env.ATLASPACK_BUILD_ENV === 'production' && !process.env.ATLASPACK_SELF_BUILD ? _path().default.join(__dirname, '..', 'lib/index.js') : __filename;
|
212
|
-
return workerApi.callMaster({
|
213
|
-
location: bundlePath,
|
214
|
-
args: [fs, packageManager, modules, filePath, projectRoot, options],
|
215
|
-
method: '_addToInstallQueue'
|
216
|
-
});
|
217
|
-
}
|
218
|
-
return _addToInstallQueue(fs, packageManager, modules, filePath, projectRoot, options);
|
219
|
-
}
|
220
|
-
function getModuleRequestKey(moduleRequest) {
|
221
|
-
return [moduleRequest.name, moduleRequest.range].join('@');
|
222
|
-
}
|
package/lib/nodejsConditions.js
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.defaultNodejsConditions = void 0;
|
7
|
-
exports.getConditionsFromEnv = getConditionsFromEnv;
|
8
|
-
function _process() {
|
9
|
-
const data = _interopRequireDefault(require("process"));
|
10
|
-
_process = function () {
|
11
|
-
return data;
|
12
|
-
};
|
13
|
-
return data;
|
14
|
-
}
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
|
-
// https://nodejs.org/api/packages.html#conditional-exports
|
17
|
-
// TODO We don't support { "type": "module" }
|
18
|
-
const defaultNodejsConditions = exports.defaultNodejsConditions = Object.freeze(['node-addons', 'node',
|
19
|
-
// 'import',
|
20
|
-
'require', 'module-sync', 'default']);
|
21
|
-
let envConditions = undefined;
|
22
|
-
|
23
|
-
/** @description Gets the export conditions from NODE_OPTIONS and node arguments */
|
24
|
-
function getConditionsFromEnv() {
|
25
|
-
if (!envConditions) {
|
26
|
-
const conditions = [];
|
27
|
-
for (const arg of [..._process().default.execArgv, ...(_process().default.env.NODE_OPTIONS || '').split(' ')]) {
|
28
|
-
if (arg.startsWith('--conditions=')) {
|
29
|
-
conditions.push(arg.substring(13));
|
30
|
-
}
|
31
|
-
}
|
32
|
-
envConditions = Object.freeze([...conditions, ...defaultNodejsConditions]);
|
33
|
-
}
|
34
|
-
return envConditions;
|
35
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.default = promiseFromProcess;
|
7
|
-
function promiseFromProcess(childProcess) {
|
8
|
-
return new Promise((resolve, reject) => {
|
9
|
-
childProcess.on('error', reject);
|
10
|
-
childProcess.on('close', code => {
|
11
|
-
if (code !== 0) {
|
12
|
-
reject(new Error('Child process failed'));
|
13
|
-
return;
|
14
|
-
}
|
15
|
-
resolve();
|
16
|
-
});
|
17
|
-
});
|
18
|
-
}
|