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