@teambit/yarn 0.0.882 → 0.0.884
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/dist/create-root-components-dir.js +6 -50
- package/dist/create-root-components-dir.js.map +1 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/dist/yarn.aspect.js +0 -5
- package/dist/yarn.aspect.js.map +1 -1
- package/dist/yarn.composition.js +0 -6
- package/dist/yarn.composition.js.map +1 -1
- package/dist/yarn.main.runtime.js +0 -25
- package/dist/yarn.main.runtime.js.map +1 -1
- package/dist/yarn.package-manager.js +49 -155
- package/dist/yarn.package-manager.js.map +1 -1
- package/dist/yarn.ui.runtime.js +0 -27
- package/dist/yarn.ui.runtime.js.map +1 -1
- package/package-tar/teambit-yarn-0.0.884.tgz +0 -0
- package/package.json +6 -6
- package/{preview-1666409808293.js → preview-1666582798766.js} +2 -2
- package/package-tar/teambit-yarn-0.0.882.tgz +0 -0
|
@@ -1,185 +1,131 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.promise.js");
|
|
8
|
-
|
|
9
6
|
Object.defineProperty(exports, "__esModule", {
|
|
10
7
|
value: true
|
|
11
8
|
});
|
|
12
9
|
exports.YarnPackageManager = void 0;
|
|
13
|
-
|
|
14
10
|
function _defineProperty2() {
|
|
15
11
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
|
|
17
12
|
_defineProperty2 = function () {
|
|
18
13
|
return data;
|
|
19
14
|
};
|
|
20
|
-
|
|
21
15
|
return data;
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
function _parsePackageName() {
|
|
25
18
|
const data = _interopRequireDefault(require("parse-package-name"));
|
|
26
|
-
|
|
27
19
|
_parsePackageName = function () {
|
|
28
20
|
return data;
|
|
29
21
|
};
|
|
30
|
-
|
|
31
22
|
return data;
|
|
32
23
|
}
|
|
33
|
-
|
|
34
24
|
function _dependencyResolver() {
|
|
35
25
|
const data = require("@teambit/dependency-resolver");
|
|
36
|
-
|
|
37
26
|
_dependencyResolver = function () {
|
|
38
27
|
return data;
|
|
39
28
|
};
|
|
40
|
-
|
|
41
29
|
return data;
|
|
42
30
|
}
|
|
43
|
-
|
|
44
31
|
function _fsExtra() {
|
|
45
32
|
const data = _interopRequireDefault(require("fs-extra"));
|
|
46
|
-
|
|
47
33
|
_fsExtra = function () {
|
|
48
34
|
return data;
|
|
49
35
|
};
|
|
50
|
-
|
|
51
36
|
return data;
|
|
52
37
|
}
|
|
53
|
-
|
|
54
38
|
function _path() {
|
|
55
39
|
const data = require("path");
|
|
56
|
-
|
|
57
40
|
_path = function () {
|
|
58
41
|
return data;
|
|
59
42
|
};
|
|
60
|
-
|
|
61
43
|
return data;
|
|
62
44
|
}
|
|
63
|
-
|
|
64
45
|
function _core() {
|
|
65
46
|
const data = require("@yarnpkg/core");
|
|
66
|
-
|
|
67
47
|
_core = function () {
|
|
68
48
|
return data;
|
|
69
49
|
};
|
|
70
|
-
|
|
71
50
|
return data;
|
|
72
51
|
}
|
|
73
|
-
|
|
74
52
|
function _cli() {
|
|
75
53
|
const data = require("@yarnpkg/cli");
|
|
76
|
-
|
|
77
54
|
_cli = function () {
|
|
78
55
|
return data;
|
|
79
56
|
};
|
|
80
|
-
|
|
81
57
|
return data;
|
|
82
58
|
}
|
|
83
|
-
|
|
84
59
|
function _fslib() {
|
|
85
60
|
const data = require("@yarnpkg/fslib");
|
|
86
|
-
|
|
87
61
|
_fslib = function () {
|
|
88
62
|
return data;
|
|
89
63
|
};
|
|
90
|
-
|
|
91
64
|
return data;
|
|
92
65
|
}
|
|
93
|
-
|
|
94
66
|
function _pluginNpm() {
|
|
95
67
|
const data = _interopRequireDefault(require("@yarnpkg/plugin-npm"));
|
|
96
|
-
|
|
97
68
|
_pluginNpm = function () {
|
|
98
69
|
return data;
|
|
99
70
|
};
|
|
100
|
-
|
|
101
71
|
return data;
|
|
102
72
|
}
|
|
103
|
-
|
|
104
73
|
function _parseOverrides() {
|
|
105
|
-
const data =
|
|
106
|
-
|
|
74
|
+
const data = require("@pnpm/parse-overrides");
|
|
107
75
|
_parseOverrides = function () {
|
|
108
76
|
return data;
|
|
109
77
|
};
|
|
110
|
-
|
|
111
78
|
return data;
|
|
112
79
|
}
|
|
113
|
-
|
|
114
80
|
function _lodash() {
|
|
115
81
|
const data = require("lodash");
|
|
116
|
-
|
|
117
82
|
_lodash = function () {
|
|
118
83
|
return data;
|
|
119
84
|
};
|
|
120
|
-
|
|
121
85
|
return data;
|
|
122
86
|
}
|
|
123
|
-
|
|
124
87
|
function _userHome() {
|
|
125
88
|
const data = _interopRequireDefault(require("user-home"));
|
|
126
|
-
|
|
127
89
|
_userHome = function () {
|
|
128
90
|
return data;
|
|
129
91
|
};
|
|
130
|
-
|
|
131
92
|
return data;
|
|
132
93
|
}
|
|
133
|
-
|
|
134
94
|
function _versionSelectorType2() {
|
|
135
95
|
const data = _interopRequireDefault(require("version-selector-type"));
|
|
136
|
-
|
|
137
96
|
_versionSelectorType2 = function () {
|
|
138
97
|
return data;
|
|
139
98
|
};
|
|
140
|
-
|
|
141
99
|
return data;
|
|
142
100
|
}
|
|
143
|
-
|
|
144
101
|
function _yaml() {
|
|
145
102
|
const data = _interopRequireDefault(require("yaml"));
|
|
146
|
-
|
|
147
103
|
_yaml = function () {
|
|
148
104
|
return data;
|
|
149
105
|
};
|
|
150
|
-
|
|
151
106
|
return data;
|
|
152
107
|
}
|
|
153
|
-
|
|
154
108
|
function _createRootComponentsDir() {
|
|
155
109
|
const data = require("./create-root-components-dir");
|
|
156
|
-
|
|
157
110
|
_createRootComponentsDir = function () {
|
|
158
111
|
return data;
|
|
159
112
|
};
|
|
160
|
-
|
|
161
113
|
return data;
|
|
162
114
|
}
|
|
163
|
-
|
|
164
115
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
165
|
-
|
|
166
116
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
167
|
-
|
|
168
117
|
class YarnPackageManager {
|
|
169
118
|
constructor(depResolver, logger) {
|
|
170
119
|
this.depResolver = depResolver;
|
|
171
120
|
this.logger = logger;
|
|
172
121
|
}
|
|
173
|
-
|
|
174
122
|
async install({
|
|
175
123
|
rootDir,
|
|
176
124
|
manifests,
|
|
177
125
|
componentDirectoryMap
|
|
178
126
|
}, installOptions = {}) {
|
|
179
127
|
this.logger.setStatusLine('installing dependencies');
|
|
180
|
-
|
|
181
128
|
const rootDirPath = _fslib().npath.toPortablePath(rootDir);
|
|
182
|
-
|
|
183
129
|
const cacheDir = this.getCacheFolder(installOptions.cacheRootDir);
|
|
184
130
|
const config = await this.computeConfiguration(rootDirPath, cacheDir, {
|
|
185
131
|
nodeLinker: installOptions.nodeLinker,
|
|
@@ -187,24 +133,21 @@ class YarnPackageManager {
|
|
|
187
133
|
});
|
|
188
134
|
const project = new (_core().Project)(rootDirPath, {
|
|
189
135
|
configuration: config
|
|
190
|
-
});
|
|
136
|
+
});
|
|
191
137
|
|
|
138
|
+
// @ts-ignore
|
|
192
139
|
project.setupResolutions();
|
|
193
|
-
|
|
194
140
|
if (installOptions.rootComponentsForCapsules && !installOptions.useNesting) {
|
|
195
141
|
installOptions.overrides = _objectSpread(_objectSpread({}, installOptions.overrides), this._createLocalDirectoryOverrides(rootDir, componentDirectoryMap));
|
|
196
142
|
}
|
|
197
|
-
|
|
198
143
|
const workspaceManifest = manifests[rootDir];
|
|
199
144
|
manifests = (0, _lodash().omit)(manifests, rootDir);
|
|
200
145
|
const rootWs = await this.createWorkspace(rootDir, project, workspaceManifest, installOptions.overrides);
|
|
201
|
-
|
|
202
146
|
if (installOptions.rootComponents) {
|
|
203
147
|
rootWs.manifest.installConfig = {
|
|
204
148
|
hoistingLimits: 'dependencies'
|
|
205
149
|
};
|
|
206
150
|
}
|
|
207
|
-
|
|
208
151
|
if (installOptions.rootComponents) {
|
|
209
152
|
// Manifests are extended with "wrapper components"
|
|
210
153
|
// that group all workspace components with their dependencies and peer dependencies.
|
|
@@ -212,19 +155,23 @@ class YarnPackageManager {
|
|
|
212
155
|
depResolver: this.depResolver,
|
|
213
156
|
rootDir,
|
|
214
157
|
componentDirectoryMap
|
|
215
|
-
})), manifests)
|
|
158
|
+
})), Object.entries(manifests).reduce((acc, [dir, manifest]) => {
|
|
159
|
+
acc[dir] = _objectSpread(_objectSpread({}, manifest), {}, {
|
|
160
|
+
dependencies: _objectSpread(_objectSpread(_objectSpread({}, manifest.peerDependencies), manifest['defaultPeerDependencies']), manifest.dependencies)
|
|
161
|
+
});
|
|
162
|
+
return acc;
|
|
163
|
+
}, {}));
|
|
216
164
|
} else if (installOptions.useNesting) {
|
|
217
|
-
manifests[rootDir] = workspaceManifest;
|
|
165
|
+
manifests[rootDir] = workspaceManifest;
|
|
166
|
+
// Nesting is used for scope aspect capsules.
|
|
218
167
|
// In a capsule, all peer dependencies should be installed,
|
|
219
168
|
// so we make runtime dependencies from peer dependencies.
|
|
220
|
-
|
|
221
169
|
manifests[rootDir].dependencies = _objectSpread(_objectSpread(_objectSpread({}, manifests[rootDir].peerDependencies), manifests[rootDir]['defaultPeerDependencies']), manifests[rootDir].dependencies);
|
|
222
170
|
} else if (installOptions.rootComponentsForCapsules) {
|
|
223
171
|
await updateManifestsForInstallationInWorkspaceCapsules(manifests);
|
|
224
172
|
} else {
|
|
225
173
|
manifests = await (0, _dependencyResolver().extendWithComponentsFromDir)(rootDir, manifests);
|
|
226
174
|
}
|
|
227
|
-
|
|
228
175
|
this.logger.debug(`running installation in root dir ${rootDir}`);
|
|
229
176
|
this.logger.debug('root manifest for installation', workspaceManifest);
|
|
230
177
|
this.logger.debug('components manifests for installation', manifests);
|
|
@@ -234,28 +181,23 @@ class YarnPackageManager {
|
|
|
234
181
|
return workspace;
|
|
235
182
|
});
|
|
236
183
|
const workspaces = await Promise.all(workspacesP);
|
|
237
|
-
|
|
238
184
|
if (!installOptions.rootComponents && !installOptions.rootComponentsForCapsules && !installOptions.useNesting) {
|
|
239
185
|
const workspacesIdents = {};
|
|
240
|
-
|
|
241
186
|
for (const workspace of workspaces) {
|
|
242
187
|
const workspaceIdentHash = workspace.locator.identHash;
|
|
243
|
-
|
|
244
188
|
if (workspacesIdents[workspaceIdentHash]) {
|
|
245
189
|
this.logger.debug(`overriding internal workspace fields to prevent duplications for workspace ${workspace.cwd}`);
|
|
246
190
|
this.overrideInternalWorkspaceParams(workspace);
|
|
247
191
|
}
|
|
248
|
-
|
|
249
192
|
workspacesIdents[workspace.locator.identHash] = true;
|
|
250
193
|
}
|
|
251
194
|
}
|
|
252
|
-
|
|
253
195
|
if (!manifests[rootDir]) {
|
|
254
196
|
workspaces.push(rootWs);
|
|
255
197
|
}
|
|
256
|
-
|
|
257
198
|
this.setupWorkspaces(project, workspaces);
|
|
258
|
-
const cache = await _core().Cache.find(config);
|
|
199
|
+
const cache = await _core().Cache.find(config);
|
|
200
|
+
// const existingPackageJsons = await this.backupPackageJsons(rootDir, componentDirectoryMap);
|
|
259
201
|
|
|
260
202
|
const installReport = await _core().StreamReport.start({
|
|
261
203
|
stdout: process.stdout,
|
|
@@ -267,7 +209,9 @@ class YarnPackageManager {
|
|
|
267
209
|
report
|
|
268
210
|
});
|
|
269
211
|
await project.persistLockfile();
|
|
270
|
-
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// TODO: check if package.json and link files generation can be prevented through the yarn API or
|
|
271
215
|
// mock the files by hooking to `xfs`.
|
|
272
216
|
// see the persistProject: false above
|
|
273
217
|
// await this.restorePackageJsons(existingPackageJsons);
|
|
@@ -275,12 +219,11 @@ class YarnPackageManager {
|
|
|
275
219
|
if (installReport.hasErrors()) process.exit(installReport.exitCode());
|
|
276
220
|
this.logger.consoleSuccess('installing dependencies');
|
|
277
221
|
}
|
|
222
|
+
|
|
278
223
|
/**
|
|
279
224
|
* Every component is overriden with a local directory of that component.
|
|
280
225
|
* So the component will be installed from the local directory, not from the registry.
|
|
281
226
|
*/
|
|
282
|
-
|
|
283
|
-
|
|
284
227
|
_createLocalDirectoryOverrides(rootDir, componentDirectoryMap) {
|
|
285
228
|
const overrides = {};
|
|
286
229
|
Array.from(componentDirectoryMap.hashMap.entries()).forEach(([, [component, path]]) => {
|
|
@@ -289,12 +232,10 @@ class YarnPackageManager {
|
|
|
289
232
|
});
|
|
290
233
|
return overrides;
|
|
291
234
|
}
|
|
292
|
-
|
|
293
235
|
getPackageJsonPath(dir) {
|
|
294
236
|
const packageJsonPath = (0, _path().join)(dir, 'package.json');
|
|
295
237
|
return packageJsonPath;
|
|
296
238
|
}
|
|
297
|
-
|
|
298
239
|
async backupPackageJsons(rootDir, componentDirectoryMap) {
|
|
299
240
|
const result = {};
|
|
300
241
|
const rootPackageJsonPath = this.getPackageJsonPath(rootDir);
|
|
@@ -309,35 +250,28 @@ class YarnPackageManager {
|
|
|
309
250
|
await Promise.all(componentsBackupsP);
|
|
310
251
|
return result;
|
|
311
252
|
}
|
|
312
|
-
|
|
313
253
|
async restorePackageJsons(backupJsons) {
|
|
314
254
|
const promises = Object.entries(backupJsons).map(async ([packageJsonPath, file]) => {
|
|
315
|
-
const exists = await _fsExtra().default.pathExists(packageJsonPath);
|
|
316
|
-
|
|
255
|
+
const exists = await _fsExtra().default.pathExists(packageJsonPath);
|
|
256
|
+
// if there is no backup it means it wasn't there before and should be deleted
|
|
317
257
|
if (!file) {
|
|
318
258
|
if (exists) {
|
|
319
259
|
return _fsExtra().default.remove(packageJsonPath);
|
|
320
260
|
}
|
|
321
|
-
|
|
322
261
|
return undefined;
|
|
323
262
|
}
|
|
324
|
-
|
|
325
263
|
return _fsExtra().default.writeFile(packageJsonPath, file);
|
|
326
264
|
});
|
|
327
265
|
await Promise.all(promises);
|
|
328
266
|
}
|
|
329
|
-
|
|
330
267
|
async getFileToBackup(packageJsonPath) {
|
|
331
268
|
const exists = await _fsExtra().default.pathExists(packageJsonPath);
|
|
332
|
-
|
|
333
269
|
if (!exists) {
|
|
334
270
|
return undefined;
|
|
335
271
|
}
|
|
336
|
-
|
|
337
272
|
const existingFile = await _fsExtra().default.readFile(packageJsonPath);
|
|
338
273
|
return existingFile;
|
|
339
274
|
}
|
|
340
|
-
|
|
341
275
|
async getComponentPackageJsonToBackup(component, dir) {
|
|
342
276
|
const packageJsonPath = (0, _path().resolve)((0, _path().join)(dir, 'package.json'));
|
|
343
277
|
const result = {
|
|
@@ -346,33 +280,30 @@ class YarnPackageManager {
|
|
|
346
280
|
};
|
|
347
281
|
return result;
|
|
348
282
|
}
|
|
349
|
-
|
|
350
283
|
async createWorkspace(rootDir, project, manifest, overrides) {
|
|
351
284
|
const wsPath = _fslib().npath.toPortablePath(rootDir);
|
|
352
|
-
|
|
353
285
|
const name = manifest.name || 'workspace';
|
|
354
286
|
const ws = new (_core().Workspace)(wsPath, {
|
|
355
287
|
project
|
|
356
288
|
});
|
|
357
289
|
await ws.setup();
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
290
|
+
const identity = _core().structUtils.parseIdent(name);
|
|
291
|
+
// const needOverrideInternal = !!ws.manifest.name && !!manifest.name;
|
|
362
292
|
ws.manifest.name = identity;
|
|
363
293
|
ws.manifest.version = manifest.version;
|
|
364
294
|
ws.manifest.dependencies = this.computeDeps(manifest.dependencies);
|
|
365
295
|
ws.manifest.devDependencies = this.computeDeps(manifest.devDependencies);
|
|
366
296
|
ws.manifest.peerDependencies = this.computeDeps(manifest.peerDependencies);
|
|
367
297
|
ws.manifest.installConfig = manifest.installConfig;
|
|
368
|
-
|
|
369
298
|
if (overrides) {
|
|
370
299
|
ws.manifest.resolutions = convertOverridesToResolutions(overrides);
|
|
371
|
-
}
|
|
300
|
+
}
|
|
372
301
|
|
|
302
|
+
// if (needOverrideInternal) this.overrideInternalWorkspaceParams(ws);
|
|
373
303
|
|
|
374
304
|
return ws;
|
|
375
305
|
}
|
|
306
|
+
|
|
376
307
|
/**
|
|
377
308
|
* This is used to handle cases where in the capsules dirs we have the same component with different versions
|
|
378
309
|
* The yarn ident is calculated by the manifest (package.json) name if exist
|
|
@@ -382,39 +313,34 @@ class YarnPackageManager {
|
|
|
382
313
|
* This function will make sure the ident will use the version as well
|
|
383
314
|
* @param ws
|
|
384
315
|
*/
|
|
385
|
-
|
|
386
|
-
|
|
387
316
|
overrideInternalWorkspaceParams(ws) {
|
|
388
317
|
var _ws$manifest$name, _ws$manifest$name2;
|
|
389
|
-
|
|
390
318
|
const ident = _core().structUtils.makeIdent(((_ws$manifest$name = ws.manifest.name) === null || _ws$manifest$name === void 0 ? void 0 : _ws$manifest$name.scope) || null, `${(_ws$manifest$name2 = ws.manifest.name) === null || _ws$manifest$name2 === void 0 ? void 0 : _ws$manifest$name2.name}-${ws.manifest.version}`);
|
|
319
|
+
ws.manifest.name = ident;
|
|
391
320
|
|
|
392
|
-
|
|
321
|
+
// @ts-expect-error: It's ok to initialize it now, even if it's readonly (setup is called right after construction)
|
|
322
|
+
ws.locator = _core().structUtils.makeLocator(ident, ws.reference);
|
|
393
323
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
ws.anchoredDescriptor = _core().structUtils.makeDescriptor(ws.locator, `${_core().WorkspaceResolver.protocol}${ws.relativeCwd}`); // @ts-expect-error: It's ok to initialize it now, even if it's readonly (setup is called right after construction)
|
|
324
|
+
// @ts-expect-error: It's ok to initialize it now, even if it's readonly (setup is called right after construction)
|
|
325
|
+
ws.anchoredDescriptor = _core().structUtils.makeDescriptor(ws.locator, `${_core().WorkspaceResolver.protocol}${ws.relativeCwd}`);
|
|
397
326
|
|
|
327
|
+
// @ts-expect-error: It's ok to initialize it now, even if it's readonly (setup is called right after construction)
|
|
398
328
|
ws.anchoredLocator = _core().structUtils.makeLocator(ws.locator, `${_core().WorkspaceResolver.protocol}${ws.relativeCwd}`);
|
|
399
329
|
}
|
|
400
|
-
|
|
401
330
|
setupWorkspaces(project, workspaces) {
|
|
402
331
|
project.workspaces = [];
|
|
403
332
|
project.workspacesByCwd = new Map();
|
|
404
333
|
project.workspacesByIdent = new Map();
|
|
405
334
|
workspaces.forEach(workspace => {
|
|
406
335
|
const dup = project.workspacesByIdent.get(workspace.locator.identHash);
|
|
407
|
-
|
|
408
336
|
if (typeof dup !== `undefined`) {
|
|
409
337
|
throw new Error(`Duplicate workspace name: ${workspace.cwd} conflicts with ${dup.cwd}`);
|
|
410
338
|
}
|
|
411
|
-
|
|
412
339
|
project.workspaces.push(workspace);
|
|
413
340
|
project.workspacesByCwd.set(workspace.cwd, workspace);
|
|
414
341
|
project.workspacesByIdent.set(workspace.locator.identHash, workspace);
|
|
415
342
|
});
|
|
416
343
|
}
|
|
417
|
-
|
|
418
344
|
async getScopedRegistries(registries) {
|
|
419
345
|
const scopedRegistries = Object.keys(registries.scopes).reduce((acc, scopeName) => {
|
|
420
346
|
const regDef = registries.scopes[scopeName];
|
|
@@ -423,16 +349,13 @@ class YarnPackageManager {
|
|
|
423
349
|
npmRegistryServer: regDef.uri,
|
|
424
350
|
npmAlwaysAuth: regDef.alwaysAuth
|
|
425
351
|
};
|
|
426
|
-
|
|
427
352
|
if (authProp) {
|
|
428
353
|
acc[scopeName][authProp.keyName] = authProp.value;
|
|
429
354
|
}
|
|
430
|
-
|
|
431
355
|
return acc;
|
|
432
356
|
}, {});
|
|
433
357
|
return scopedRegistries;
|
|
434
358
|
}
|
|
435
|
-
|
|
436
359
|
getAuthProp(registry) {
|
|
437
360
|
if (registry.token) {
|
|
438
361
|
return {
|
|
@@ -440,35 +363,30 @@ class YarnPackageManager {
|
|
|
440
363
|
value: registry.token
|
|
441
364
|
};
|
|
442
365
|
}
|
|
443
|
-
|
|
444
366
|
if (registry.baseToken) {
|
|
445
367
|
return {
|
|
446
368
|
keyName: 'npmAuthIdent',
|
|
447
369
|
value: registry.baseToken
|
|
448
370
|
};
|
|
449
371
|
}
|
|
450
|
-
|
|
451
372
|
return undefined;
|
|
452
373
|
}
|
|
453
|
-
|
|
454
374
|
getCacheFolder(baseDir = _userHome().default) {
|
|
455
375
|
return `${baseDir}/.yarn/cache`;
|
|
456
|
-
}
|
|
457
|
-
|
|
376
|
+
}
|
|
458
377
|
|
|
378
|
+
// TODO: implement this to automate configuration.
|
|
459
379
|
async computeConfiguration(rootDirPath, cacheFolder, options) {
|
|
460
380
|
const registries = await this.depResolver.getRegistries();
|
|
461
381
|
const proxyConfig = await this.depResolver.getProxyConfig();
|
|
462
382
|
const networkConfig = await this.depResolver.getNetworkConfig();
|
|
463
383
|
const pluginConfig = (0, _cli().getPluginConfiguration)();
|
|
464
384
|
let startingCwd;
|
|
465
|
-
|
|
466
385
|
if (options.packageManagerConfigRootDir) {
|
|
467
386
|
startingCwd = _fslib().npath.toPortablePath(options.packageManagerConfigRootDir);
|
|
468
387
|
} else {
|
|
469
388
|
startingCwd = rootDirPath;
|
|
470
389
|
}
|
|
471
|
-
|
|
472
390
|
const config = await _core().Configuration.find(startingCwd, pluginConfig);
|
|
473
391
|
const scopedRegistries = await this.getScopedRegistries(registries);
|
|
474
392
|
const defaultRegistry = registries.defaultRegistry;
|
|
@@ -488,41 +406,36 @@ class YarnPackageManager {
|
|
|
488
406
|
// enableInlineBuilds: true,
|
|
489
407
|
globalFolder: `${_userHome().default}/.yarn/global`,
|
|
490
408
|
// We need to disable self-references as say create circular symlinks.
|
|
491
|
-
nmSelfReferences: false
|
|
409
|
+
nmSelfReferences: false
|
|
410
|
+
|
|
411
|
+
// TODO: check about support for the following: (see more here - https://github.com/yarnpkg/berry/issues/1434#issuecomment-801449010)
|
|
492
412
|
// ca?: string;
|
|
493
413
|
// cert?: string;
|
|
494
414
|
// key?: string;
|
|
495
415
|
// noProxy?: boolean | string;
|
|
496
|
-
|
|
497
416
|
};
|
|
498
417
|
|
|
499
418
|
if (defaultAuthProp) {
|
|
500
419
|
data[defaultAuthProp.keyName] = defaultAuthProp.value;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
|
|
420
|
+
}
|
|
421
|
+
// TODO: node-modules is hardcoded now until adding support for pnp.
|
|
504
422
|
config.use('<bit>', data, rootDirPath, {});
|
|
505
423
|
return config;
|
|
506
424
|
}
|
|
507
|
-
|
|
508
425
|
computeDeps(rawDeps) {
|
|
509
426
|
const map = new Map();
|
|
510
427
|
if (!rawDeps) return map;
|
|
511
428
|
Object.keys(rawDeps).forEach(packageName => {
|
|
512
429
|
const ident = _core().structUtils.parseIdent(packageName);
|
|
513
|
-
|
|
514
430
|
map.set(ident.identHash, _core().structUtils.makeDescriptor(ident, rawDeps[packageName]));
|
|
515
431
|
});
|
|
516
432
|
return map;
|
|
517
433
|
}
|
|
518
|
-
|
|
519
434
|
async resolveRemoteVersion(packageName, options) {
|
|
520
435
|
var _versionSelectorType;
|
|
521
|
-
|
|
522
436
|
const parsedPackage = (0, _parsePackageName().default)(packageName);
|
|
523
437
|
const parsedVersion = parsedPackage.version;
|
|
524
438
|
const versionType = parsedVersion && ((_versionSelectorType = (0, _versionSelectorType2().default)(parsedVersion)) === null || _versionSelectorType === void 0 ? void 0 : _versionSelectorType.type);
|
|
525
|
-
|
|
526
439
|
if (versionType === 'version') {
|
|
527
440
|
return {
|
|
528
441
|
packageName: parsedPackage.name,
|
|
@@ -530,22 +443,16 @@ class YarnPackageManager {
|
|
|
530
443
|
isSemver: true
|
|
531
444
|
};
|
|
532
445
|
}
|
|
533
|
-
|
|
534
446
|
if (!_pluginNpm().default.resolvers) {
|
|
535
447
|
throw new Error('npm resolvers for yarn API not found');
|
|
536
|
-
}
|
|
537
|
-
|
|
448
|
+
}
|
|
538
449
|
|
|
450
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
539
451
|
const [_NpmRemapResolver, NpmSemverResolver, NpmTagResolver] = _pluginNpm().default.resolvers;
|
|
540
|
-
|
|
541
452
|
let resolver = new NpmSemverResolver();
|
|
542
|
-
|
|
543
453
|
const ident = _core().structUtils.parseIdent(parsedPackage.name);
|
|
544
|
-
|
|
545
454
|
let range = 'npm:*';
|
|
546
|
-
|
|
547
455
|
const rootDirPath = _fslib().npath.toPortablePath(options.rootDir);
|
|
548
|
-
|
|
549
456
|
const cacheDir = this.getCacheFolder(options.cacheRootDir);
|
|
550
457
|
const config = await this.computeConfiguration(rootDirPath, cacheDir, {
|
|
551
458
|
packageManagerConfigRootDir: options.packageManagerConfigRootDir
|
|
@@ -556,27 +463,25 @@ class YarnPackageManager {
|
|
|
556
463
|
const report = new (_core().LightReport)({
|
|
557
464
|
configuration: config,
|
|
558
465
|
stdout: process.stdout
|
|
559
|
-
});
|
|
466
|
+
});
|
|
560
467
|
|
|
468
|
+
// Handle cases when the version is a dist tag like dev / latest for example bit install lodash@latest
|
|
561
469
|
if (versionType === 'tag') {
|
|
562
470
|
resolver = new NpmTagResolver();
|
|
563
471
|
range = `npm:${parsedPackage.version}`;
|
|
564
472
|
}
|
|
473
|
+
const descriptor = _core().structUtils.makeDescriptor(ident, range);
|
|
565
474
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
475
|
+
// @ts-ignore
|
|
569
476
|
project.setupResolutions();
|
|
570
477
|
const resolveOptions = {
|
|
571
478
|
project,
|
|
572
479
|
resolver,
|
|
573
480
|
report
|
|
574
|
-
};
|
|
575
|
-
|
|
481
|
+
};
|
|
482
|
+
// const candidates = await resolver.getCandidates(descriptor, new Map(), resolveOptions);
|
|
576
483
|
const candidates = await resolver.getCandidates(descriptor, new Map(), resolveOptions);
|
|
577
|
-
|
|
578
484
|
const parsedRange = _core().structUtils.parseRange(candidates[0].reference);
|
|
579
|
-
|
|
580
485
|
const version = parsedRange.selector;
|
|
581
486
|
return {
|
|
582
487
|
packageName: parsedPackage.name,
|
|
@@ -584,22 +489,17 @@ class YarnPackageManager {
|
|
|
584
489
|
isSemver: true
|
|
585
490
|
};
|
|
586
491
|
}
|
|
587
|
-
|
|
588
492
|
async getInjectedDirs(rootDir, componentDir, packageName) {
|
|
589
493
|
const modulesDir = (0, _path().join)(rootDir, 'node_modules');
|
|
590
494
|
(0, _path().relative)(modulesDir, componentDir);
|
|
591
495
|
let yarnStateContent;
|
|
592
|
-
|
|
593
496
|
try {
|
|
594
497
|
yarnStateContent = await _fsExtra().default.readFile((0, _path().join)(modulesDir, '.yarn-state.yml'), 'utf-8');
|
|
595
498
|
} catch (err) {
|
|
596
499
|
if (err.code === 'ENOENT') return [];
|
|
597
500
|
}
|
|
598
|
-
|
|
599
501
|
const yarnState = _yaml().default.parse(yarnStateContent);
|
|
600
|
-
|
|
601
502
|
const injectedDirs = [];
|
|
602
|
-
|
|
603
503
|
for (const [key, {
|
|
604
504
|
locations
|
|
605
505
|
}] of Object.entries(yarnState)) {
|
|
@@ -609,16 +509,12 @@ class YarnPackageManager {
|
|
|
609
509
|
}
|
|
610
510
|
}
|
|
611
511
|
}
|
|
612
|
-
|
|
613
512
|
return injectedDirs;
|
|
614
513
|
}
|
|
615
|
-
|
|
616
514
|
}
|
|
617
|
-
|
|
618
515
|
exports.YarnPackageManager = YarnPackageManager;
|
|
619
|
-
|
|
620
516
|
function convertOverridesToResolutions(overrides) {
|
|
621
|
-
const parsedOverrides = (0, _parseOverrides().
|
|
517
|
+
const parsedOverrides = (0, _parseOverrides().parseOverrides)(overrides);
|
|
622
518
|
return parsedOverrides.map(override => ({
|
|
623
519
|
pattern: {
|
|
624
520
|
from: override.parentPkg ? toYarnResolutionSelector(override.parentPkg) : undefined,
|
|
@@ -627,7 +523,6 @@ function convertOverridesToResolutions(overrides) {
|
|
|
627
523
|
reference: override.newPref
|
|
628
524
|
}));
|
|
629
525
|
}
|
|
630
|
-
|
|
631
526
|
function toYarnResolutionSelector({
|
|
632
527
|
name,
|
|
633
528
|
pref
|
|
@@ -637,6 +532,7 @@ function toYarnResolutionSelector({
|
|
|
637
532
|
description: pref
|
|
638
533
|
};
|
|
639
534
|
}
|
|
535
|
+
|
|
640
536
|
/**
|
|
641
537
|
* This function prepares the component manifests for installation inside a capsule.
|
|
642
538
|
* Inside a capsule, all peer dependencies of the component should be installed.
|
|
@@ -644,15 +540,13 @@ function toYarnResolutionSelector({
|
|
|
644
540
|
* Also, the package.json files are update to contain other component dependencies
|
|
645
541
|
* in dependencies as local "file:" dependencies.
|
|
646
542
|
*/
|
|
647
|
-
|
|
648
|
-
|
|
649
543
|
async function updateManifestsForInstallationInWorkspaceCapsules(manifests) {
|
|
650
544
|
await Promise.all(Object.entries(manifests).map(async ([dir, manifest]) => {
|
|
651
545
|
const pkgJsonPath = (0, _path().join)(dir, 'package.json');
|
|
652
|
-
const pkgJson = await _fsExtra().default.readJson(pkgJsonPath);
|
|
546
|
+
const pkgJson = await _fsExtra().default.readJson(pkgJsonPath);
|
|
547
|
+
// We need to write the package.json files because they need to contain the workspace dependencies.
|
|
653
548
|
// When packages are installed via the "file:" protocol, Yarn reads their package.json files
|
|
654
549
|
// from the file system even if they are from the workspace.
|
|
655
|
-
|
|
656
550
|
await _fsExtra().default.writeJson(pkgJsonPath, _objectSpread(_objectSpread({}, pkgJson), {}, {
|
|
657
551
|
dependencies: manifest.dependencies
|
|
658
552
|
}), {
|