@teambit/workspace 0.0.845 → 0.0.848
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/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/workspace-component/workspace-component-loader.js +6 -0
- package/dist/workspace-component/workspace-component-loader.js.map +1 -1
- package/dist/workspace.d.ts +9 -60
- package/dist/workspace.js +23 -409
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.main.runtime.js +1 -11
- package/dist/workspace.main.runtime.js.map +1 -1
- package/dist/workspace.provider.d.ts +2 -4
- package/dist/workspace.provider.js +3 -66
- package/dist/workspace.provider.js.map +1 -1
- package/package-tar/teambit-workspace-0.0.848.tgz +0 -0
- package/package.json +28 -37
- package/{preview-1662521943539.js → preview-1662780958471.js} +2 -2
- package/workspace-component/workspace-component-loader.ts +5 -0
- package/__snapshots__/pick-outdated-pkgs.spec.ts.snap +0 -171
- package/dist/__snapshots__/pick-outdated-pkgs.spec.js.snap +0 -171
- package/dist/__snapshots__/pick-outdated-pkgs.spec.ts.snap +0 -171
- package/dist/exceptions/dependency-type-not-supported-in-policy.d.ts +0 -4
- package/dist/exceptions/dependency-type-not-supported-in-policy.js +0 -27
- package/dist/exceptions/dependency-type-not-supported-in-policy.js.map +0 -1
- package/dist/exceptions/index.d.ts +0 -1
- package/dist/exceptions/index.js +0 -23
- package/dist/exceptions/index.js.map +0 -1
- package/dist/install.cmd.d.ts +0 -44
- package/dist/install.cmd.js +0 -85
- package/dist/install.cmd.js.map +0 -1
- package/dist/link/component-list-links.d.ts +0 -7
- package/dist/link/component-list-links.js +0 -98
- package/dist/link/component-list-links.js.map +0 -1
- package/dist/link/core-aspects-links.d.ts +0 -7
- package/dist/link/core-aspects-links.js +0 -95
- package/dist/link/core-aspects-links.js.map +0 -1
- package/dist/link/get-package-name-from-target.d.ts +0 -1
- package/dist/link/get-package-name-from-target.js +0 -16
- package/dist/link/get-package-name-from-target.js.map +0 -1
- package/dist/link/index.d.ts +0 -1
- package/dist/link/index.js +0 -23
- package/dist/link/index.js.map +0 -1
- package/dist/link/link-row.d.ts +0 -12
- package/dist/link/link-row.js +0 -38
- package/dist/link/link-row.js.map +0 -1
- package/dist/link/link-to-dir.d.ts +0 -2
- package/dist/link/link-to-dir.js +0 -45
- package/dist/link/link-to-dir.js.map +0 -1
- package/dist/link/link.cmd.d.ts +0 -44
- package/dist/link/link.cmd.js +0 -176
- package/dist/link/link.cmd.js.map +0 -1
- package/dist/link/nested-deps-in-nm-links.d.ts +0 -7
- package/dist/link/nested-deps-in-nm-links.js +0 -74
- package/dist/link/nested-deps-in-nm-links.js.map +0 -1
- package/dist/link/rewire-row.d.ts +0 -6
- package/dist/link/rewire-row.js +0 -31
- package/dist/link/rewire-row.js.map +0 -1
- package/dist/pick-outdated-pkgs.d.ts +0 -16
- package/dist/pick-outdated-pkgs.js +0 -308
- package/dist/pick-outdated-pkgs.js.map +0 -1
- package/dist/pick-outdated-pkgs.spec.d.ts +0 -1
- package/dist/pick-outdated-pkgs.spec.js +0 -121
- package/dist/pick-outdated-pkgs.spec.js.map +0 -1
- package/dist/uninstall.cmd.d.ts +0 -19
- package/dist/uninstall.cmd.js +0 -47
- package/dist/uninstall.cmd.js.map +0 -1
- package/dist/update.cmd.d.ts +0 -23
- package/dist/update.cmd.js +0 -47
- package/dist/update.cmd.js.map +0 -1
- package/exceptions/dependency-type-not-supported-in-policy.ts +0 -7
- package/exceptions/index.ts +0 -1
- package/install.cmd.tsx +0 -72
- package/link/component-list-links.ts +0 -50
- package/link/core-aspects-links.ts +0 -50
- package/link/get-package-name-from-target.ts +0 -5
- package/link/index.ts +0 -1
- package/link/link-row.ts +0 -20
- package/link/link-to-dir.ts +0 -13
- package/link/link.cmd.ts +0 -100
- package/link/nested-deps-in-nm-links.ts +0 -47
- package/link/rewire-row.ts +0 -17
- package/package-tar/teambit-workspace-0.0.845.tgz +0 -0
- package/uninstall.cmd.tsx +0 -23
- package/update.cmd.tsx +0 -29
package/dist/workspace.js
CHANGED
|
@@ -29,16 +29,6 @@ function _defineProperty2() {
|
|
|
29
29
|
return data;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function _chalk() {
|
|
33
|
-
const data = _interopRequireDefault(require("chalk"));
|
|
34
|
-
|
|
35
|
-
_chalk = function () {
|
|
36
|
-
return data;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return data;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
32
|
function _memoizee() {
|
|
43
33
|
const data = _interopRequireDefault(require("memoizee"));
|
|
44
34
|
|
|
@@ -99,16 +89,6 @@ function _component() {
|
|
|
99
89
|
return data;
|
|
100
90
|
}
|
|
101
91
|
|
|
102
|
-
function _importer() {
|
|
103
|
-
const data = require("@teambit/importer");
|
|
104
|
-
|
|
105
|
-
_importer = function () {
|
|
106
|
-
return data;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
return data;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
92
|
function _bitError() {
|
|
113
93
|
const data = require("@teambit/bit-error");
|
|
114
94
|
|
|
@@ -129,16 +109,6 @@ function _config() {
|
|
|
129
109
|
return data;
|
|
130
110
|
}
|
|
131
111
|
|
|
132
|
-
function _dependencyResolver() {
|
|
133
|
-
const data = require("@teambit/dependency-resolver");
|
|
134
|
-
|
|
135
|
-
_dependencyResolver = function () {
|
|
136
|
-
return data;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
return data;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
112
|
function _envs() {
|
|
143
113
|
const data = require("@teambit/envs");
|
|
144
114
|
|
|
@@ -179,16 +149,6 @@ function _consumer() {
|
|
|
179
149
|
return data;
|
|
180
150
|
}
|
|
181
151
|
|
|
182
|
-
function _exceptions() {
|
|
183
|
-
const data = require("@teambit/legacy/dist/consumer/exceptions");
|
|
184
|
-
|
|
185
|
-
_exceptions = function () {
|
|
186
|
-
return data;
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
return data;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
152
|
function _bitId() {
|
|
193
153
|
const data = require("@teambit/legacy/dist/bit-id");
|
|
194
154
|
|
|
@@ -249,10 +209,10 @@ function _cacheFactory() {
|
|
|
249
209
|
return data;
|
|
250
210
|
}
|
|
251
211
|
|
|
252
|
-
function
|
|
212
|
+
function _exceptions() {
|
|
253
213
|
const data = require("@teambit/legacy/dist/scope/exceptions");
|
|
254
214
|
|
|
255
|
-
|
|
215
|
+
_exceptions = function () {
|
|
256
216
|
return data;
|
|
257
217
|
};
|
|
258
218
|
|
|
@@ -359,10 +319,10 @@ function _scopeComponentsImporter() {
|
|
|
359
319
|
return data;
|
|
360
320
|
}
|
|
361
321
|
|
|
362
|
-
function
|
|
322
|
+
function _exceptions2() {
|
|
363
323
|
const data = require("@teambit/legacy/dist/consumer/bit-map/exceptions");
|
|
364
324
|
|
|
365
|
-
|
|
325
|
+
_exceptions2 = function () {
|
|
366
326
|
return data;
|
|
367
327
|
};
|
|
368
328
|
|
|
@@ -409,26 +369,6 @@ function _componentConfigFile() {
|
|
|
409
369
|
return data;
|
|
410
370
|
}
|
|
411
371
|
|
|
412
|
-
function _exceptions4() {
|
|
413
|
-
const data = require("./exceptions");
|
|
414
|
-
|
|
415
|
-
_exceptions4 = function () {
|
|
416
|
-
return data;
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
return data;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
function _pickOutdatedPkgs() {
|
|
423
|
-
const data = require("./pick-outdated-pkgs");
|
|
424
|
-
|
|
425
|
-
_pickOutdatedPkgs = function () {
|
|
426
|
-
return data;
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
return data;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
372
|
function _watcher() {
|
|
433
373
|
const data = require("./watch/watcher");
|
|
434
374
|
|
|
@@ -535,7 +475,7 @@ class Workspace {
|
|
|
535
475
|
/**
|
|
536
476
|
* access to the `ComponentProvider` instance
|
|
537
477
|
*/
|
|
538
|
-
componentAspect,
|
|
478
|
+
componentAspect, dependencyResolver, variants, aspectLoader, logger, componentList = new (_componentsList().default)(consumer),
|
|
539
479
|
/**
|
|
540
480
|
* private reference to the instance of Harmony.
|
|
541
481
|
*/
|
|
@@ -559,7 +499,6 @@ class Workspace {
|
|
|
559
499
|
this.consumer = consumer;
|
|
560
500
|
this.scope = scope;
|
|
561
501
|
this.componentAspect = componentAspect;
|
|
562
|
-
this.isolator = isolator;
|
|
563
502
|
this.dependencyResolver = dependencyResolver;
|
|
564
503
|
this.variants = variants;
|
|
565
504
|
this.aspectLoader = aspectLoader;
|
|
@@ -1110,7 +1049,7 @@ class Workspace {
|
|
|
1110
1049
|
// if it's not a pattern but just id, resolve it without multimatch to support specifying id without scope-name
|
|
1111
1050
|
const id = await this.resolveComponentId(pattern);
|
|
1112
1051
|
if (this.exists(id)) return [id];
|
|
1113
|
-
if (throwForNoMatch) throw new (
|
|
1052
|
+
if (throwForNoMatch) throw new (_exceptions2().MissingBitMapComponent)(pattern);
|
|
1114
1053
|
return [];
|
|
1115
1054
|
}
|
|
1116
1055
|
|
|
@@ -1842,6 +1781,22 @@ the following envs are used in this workspace: ${availableEnvs.join(', ')}`);
|
|
|
1842
1781
|
});
|
|
1843
1782
|
return this.componentConfigFileFromComponentDirAndName(relativeComponentDir, id.fullName);
|
|
1844
1783
|
}
|
|
1784
|
+
/**
|
|
1785
|
+
* @param componentPath can be relative or absolute. supports Linux and Windows
|
|
1786
|
+
*/
|
|
1787
|
+
|
|
1788
|
+
|
|
1789
|
+
async getComponentIdByPath(componentPath) {
|
|
1790
|
+
const relativePath = _path2().default.isAbsolute(componentPath) ? _path2().default.relative(this.path, componentPath) : componentPath;
|
|
1791
|
+
const linuxPath = (0, _path().pathNormalizeToLinux)(relativePath);
|
|
1792
|
+
const bitId = this.consumer.bitMap.getComponentIdByPath(linuxPath);
|
|
1793
|
+
|
|
1794
|
+
if (bitId) {
|
|
1795
|
+
return this.resolveComponentId(bitId);
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
return undefined;
|
|
1799
|
+
}
|
|
1845
1800
|
|
|
1846
1801
|
async componentConfigFileFromComponentDirAndName(relativeComponentDir, name) {
|
|
1847
1802
|
let componentConfigFile;
|
|
@@ -2182,303 +2137,6 @@ needed-for: ${neededFor || '<unknown>'}`);
|
|
|
2182
2137
|
|
|
2183
2138
|
return resolved;
|
|
2184
2139
|
}
|
|
2185
|
-
|
|
2186
|
-
async getComponentsDirectory(ids) {
|
|
2187
|
-
const components = ids.length ? await this.getMany(ids) : await this.list();
|
|
2188
|
-
return _component().ComponentMap.as(components, component => this.componentDir(component.id));
|
|
2189
|
-
}
|
|
2190
|
-
/**
|
|
2191
|
-
* Install dependencies for all components in the workspace
|
|
2192
|
-
*
|
|
2193
|
-
* @returns
|
|
2194
|
-
* @memberof Workspace
|
|
2195
|
-
*/
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
async install(packages, options) {
|
|
2199
|
-
if (packages && packages.length) {
|
|
2200
|
-
await this._addPackages(packages, options);
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
|
-
if (options !== null && options !== void 0 && options.addMissingPeers) {
|
|
2204
|
-
var _options$copyPeerToRu, _options$copyPeerToRu2;
|
|
2205
|
-
|
|
2206
|
-
const compDirMap = await this.getComponentsDirectory([]);
|
|
2207
|
-
const mergedRootPolicy = this.dependencyResolver.getWorkspacePolicy();
|
|
2208
|
-
const depsFilterFn = await this.generateFilterFnForDepsFromLocalRemote();
|
|
2209
|
-
const pmInstallOptions = {
|
|
2210
|
-
dedupe: options === null || options === void 0 ? void 0 : options.dedupe,
|
|
2211
|
-
copyPeerToRuntimeOnRoot: (_options$copyPeerToRu = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnRoot) !== null && _options$copyPeerToRu !== void 0 ? _options$copyPeerToRu : true,
|
|
2212
|
-
copyPeerToRuntimeOnComponents: (_options$copyPeerToRu2 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnComponents) !== null && _options$copyPeerToRu2 !== void 0 ? _options$copyPeerToRu2 : false,
|
|
2213
|
-
dependencyFilterFn: depsFilterFn,
|
|
2214
|
-
overrides: this.dependencyResolver.config.overrides,
|
|
2215
|
-
packageImportMethod: this.dependencyResolver.config.packageImportMethod
|
|
2216
|
-
};
|
|
2217
|
-
const missingPeers = await this.dependencyResolver.getMissingPeerDependencies(this.path, mergedRootPolicy, compDirMap, pmInstallOptions);
|
|
2218
|
-
|
|
2219
|
-
if (missingPeers) {
|
|
2220
|
-
const missingPeerPackages = Object.entries(missingPeers).map(([peerName, range]) => `${peerName}@${range}`);
|
|
2221
|
-
await this._addPackages(missingPeerPackages, options);
|
|
2222
|
-
} else {
|
|
2223
|
-
this.logger.console('No missing peer dependencies found.');
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2226
|
-
|
|
2227
|
-
if (options !== null && options !== void 0 && options.import) {
|
|
2228
|
-
this.logger.setStatusLine('importing missing objects');
|
|
2229
|
-
await this.importObjects();
|
|
2230
|
-
this.logger.consoleSuccess();
|
|
2231
|
-
}
|
|
2232
|
-
|
|
2233
|
-
return this._installModules(options);
|
|
2234
|
-
}
|
|
2235
|
-
|
|
2236
|
-
async _addPackages(packages, options) {
|
|
2237
|
-
if (!(options !== null && options !== void 0 && options.variants) && (options === null || options === void 0 ? void 0 : options.lifecycleType) === 'dev') {
|
|
2238
|
-
throw new (_exceptions4().DependencyTypeNotSupportedInPolicy)(options === null || options === void 0 ? void 0 : options.lifecycleType);
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
this.logger.debug(`installing the following packages: ${packages.join()}`);
|
|
2242
|
-
const resolver = await this.dependencyResolver.getVersionResolver();
|
|
2243
|
-
const resolvedPackagesP = packages.map(packageName => resolver.resolveRemoteVersion(packageName, {
|
|
2244
|
-
rootDir: this.path
|
|
2245
|
-
}));
|
|
2246
|
-
const resolvedPackages = await Promise.all(resolvedPackagesP);
|
|
2247
|
-
const newWorkspacePolicyEntries = [];
|
|
2248
|
-
resolvedPackages.forEach(resolvedPackage => {
|
|
2249
|
-
if (resolvedPackage.version) {
|
|
2250
|
-
const versionWithPrefix = this.dependencyResolver.getVersionWithSavePrefix(resolvedPackage.version, options === null || options === void 0 ? void 0 : options.savePrefix);
|
|
2251
|
-
newWorkspacePolicyEntries.push({
|
|
2252
|
-
dependencyId: resolvedPackage.packageName,
|
|
2253
|
-
value: {
|
|
2254
|
-
version: versionWithPrefix
|
|
2255
|
-
},
|
|
2256
|
-
lifecycleType: (options === null || options === void 0 ? void 0 : options.lifecycleType) || 'runtime'
|
|
2257
|
-
});
|
|
2258
|
-
}
|
|
2259
|
-
});
|
|
2260
|
-
|
|
2261
|
-
if (!(options !== null && options !== void 0 && options.variants)) {
|
|
2262
|
-
var _options$updateExisti;
|
|
2263
|
-
|
|
2264
|
-
this.dependencyResolver.addToRootPolicy(newWorkspacePolicyEntries, {
|
|
2265
|
-
updateExisting: (_options$updateExisti = options === null || options === void 0 ? void 0 : options.updateExisting) !== null && _options$updateExisti !== void 0 ? _options$updateExisti : false
|
|
2266
|
-
});
|
|
2267
|
-
} else {// TODO: implement
|
|
2268
|
-
}
|
|
2269
|
-
|
|
2270
|
-
await this.dependencyResolver.persistConfig(this.path);
|
|
2271
|
-
}
|
|
2272
|
-
|
|
2273
|
-
async _getComponentsWithDependencyPolicies() {
|
|
2274
|
-
const allComponentIds = await this.listIds();
|
|
2275
|
-
const componentConfigFiles = {};
|
|
2276
|
-
const componentPoliciesById = {};
|
|
2277
|
-
(await Promise.all(allComponentIds.map(componentId => this.componentConfigFile(componentId)))).forEach((componentConfigFile, index) => {
|
|
2278
|
-
if (!componentConfigFile) return;
|
|
2279
|
-
const depResolverConfig = componentConfigFile.aspects.get(_dependencyResolver().DependencyResolverAspect.id);
|
|
2280
|
-
if (!depResolverConfig) return;
|
|
2281
|
-
const componentId = allComponentIds[index].toString();
|
|
2282
|
-
componentConfigFiles[componentId] = componentConfigFile;
|
|
2283
|
-
componentPoliciesById[componentId] = depResolverConfig.config.policy;
|
|
2284
|
-
});
|
|
2285
|
-
return {
|
|
2286
|
-
componentConfigFiles,
|
|
2287
|
-
componentPoliciesById
|
|
2288
|
-
};
|
|
2289
|
-
}
|
|
2290
|
-
/**
|
|
2291
|
-
* Updates out-of-date dependencies in the workspace.
|
|
2292
|
-
*
|
|
2293
|
-
* @param options.all {Boolean} updates all outdated dependencies without showing a prompt.
|
|
2294
|
-
*/
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
async updateDependencies(options) {
|
|
2298
|
-
const {
|
|
2299
|
-
componentConfigFiles,
|
|
2300
|
-
componentPoliciesById
|
|
2301
|
-
} = await this._getComponentsWithDependencyPolicies();
|
|
2302
|
-
const variantPatterns = this.variants.raw();
|
|
2303
|
-
|
|
2304
|
-
const variantPoliciesByPatterns = this._variantPatternsToDepPolicesDict(variantPatterns);
|
|
2305
|
-
|
|
2306
|
-
const components = await this.list();
|
|
2307
|
-
const outdatedPkgs = await this.dependencyResolver.getOutdatedPkgsFromPolicies({
|
|
2308
|
-
rootDir: this.path,
|
|
2309
|
-
variantPoliciesByPatterns,
|
|
2310
|
-
componentPoliciesById,
|
|
2311
|
-
components
|
|
2312
|
-
});
|
|
2313
|
-
let outdatedPkgsToUpdate;
|
|
2314
|
-
|
|
2315
|
-
if (options.all) {
|
|
2316
|
-
outdatedPkgsToUpdate = outdatedPkgs;
|
|
2317
|
-
} else {
|
|
2318
|
-
this.logger.off();
|
|
2319
|
-
outdatedPkgsToUpdate = await (0, _pickOutdatedPkgs().pickOutdatedPkgs)(outdatedPkgs);
|
|
2320
|
-
this.logger.on();
|
|
2321
|
-
}
|
|
2322
|
-
|
|
2323
|
-
const {
|
|
2324
|
-
updatedVariants,
|
|
2325
|
-
updatedComponents
|
|
2326
|
-
} = this.dependencyResolver.applyUpdates(outdatedPkgsToUpdate, {
|
|
2327
|
-
variantPoliciesByPatterns,
|
|
2328
|
-
componentPoliciesById
|
|
2329
|
-
});
|
|
2330
|
-
await this._updateVariantsPolicies(variantPatterns, updatedVariants);
|
|
2331
|
-
const updatedComponentConfigFiles = Object.values((0, _lodash().pick)(componentConfigFiles, updatedComponents));
|
|
2332
|
-
await this._saveManyComponentConfigFiles(updatedComponentConfigFiles);
|
|
2333
|
-
await this._reloadConsumer();
|
|
2334
|
-
return this._installModules({
|
|
2335
|
-
dedupe: true
|
|
2336
|
-
});
|
|
2337
|
-
}
|
|
2338
|
-
|
|
2339
|
-
_variantPatternsToDepPolicesDict(variantPatterns) {
|
|
2340
|
-
const variantPoliciesByPatterns = {};
|
|
2341
|
-
|
|
2342
|
-
for (const [variantPattern, extensions] of Object.entries(variantPatterns)) {
|
|
2343
|
-
var _extensions$Dependenc;
|
|
2344
|
-
|
|
2345
|
-
if ((_extensions$Dependenc = extensions[_dependencyResolver().DependencyResolverAspect.id]) !== null && _extensions$Dependenc !== void 0 && _extensions$Dependenc.policy) {
|
|
2346
|
-
var _extensions$Dependenc2;
|
|
2347
|
-
|
|
2348
|
-
variantPoliciesByPatterns[variantPattern] = (_extensions$Dependenc2 = extensions[_dependencyResolver().DependencyResolverAspect.id]) === null || _extensions$Dependenc2 === void 0 ? void 0 : _extensions$Dependenc2.policy;
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
|
|
2352
|
-
return variantPoliciesByPatterns;
|
|
2353
|
-
}
|
|
2354
|
-
|
|
2355
|
-
_updateVariantsPolicies(variantPatterns, updateVariantPolicies) {
|
|
2356
|
-
for (const variantPattern of updateVariantPolicies) {
|
|
2357
|
-
this.variants.setExtension(variantPattern, _dependencyResolver().DependencyResolverAspect.id, variantPatterns[variantPattern][_dependencyResolver().DependencyResolverAspect.id], {
|
|
2358
|
-
overrideExisting: true
|
|
2359
|
-
});
|
|
2360
|
-
}
|
|
2361
|
-
|
|
2362
|
-
return this.dependencyResolver.persistConfig(this.path);
|
|
2363
|
-
}
|
|
2364
|
-
|
|
2365
|
-
async _saveManyComponentConfigFiles(componentConfigFiles) {
|
|
2366
|
-
await Promise.all(Array.from(componentConfigFiles).map(async componentConfigFile => {
|
|
2367
|
-
await componentConfigFile.write({
|
|
2368
|
-
override: true
|
|
2369
|
-
});
|
|
2370
|
-
}));
|
|
2371
|
-
}
|
|
2372
|
-
|
|
2373
|
-
async _installModules(options) {
|
|
2374
|
-
var _options$copyPeerToRu3, _options$copyPeerToRu4;
|
|
2375
|
-
|
|
2376
|
-
this.logger.console(`installing dependencies in workspace using ${_chalk().default.cyan(this.dependencyResolver.getPackageManagerName())}`);
|
|
2377
|
-
this.logger.debug(`installing dependencies in workspace with options`, options);
|
|
2378
|
-
const hasRootComponents = this.dependencyResolver.hasRootComponents(); // TODO: this make duplicate
|
|
2379
|
-
// this.logger.consoleSuccess();
|
|
2380
|
-
// TODO: add the links results to the output
|
|
2381
|
-
|
|
2382
|
-
await this.link({
|
|
2383
|
-
linkTeambitBit: true,
|
|
2384
|
-
legacyLink: true,
|
|
2385
|
-
linkCoreAspects: false,
|
|
2386
|
-
linkDepsResolvedFromEnv: !hasRootComponents,
|
|
2387
|
-
linkNestedDepsInNM: false
|
|
2388
|
-
});
|
|
2389
|
-
this.consumer.componentLoader.clearComponentsCache();
|
|
2390
|
-
this.clearCache(); // TODO: pass get install options
|
|
2391
|
-
|
|
2392
|
-
const installer = this.dependencyResolver.getInstaller({});
|
|
2393
|
-
const compDirMap = await this.getComponentsDirectory([]);
|
|
2394
|
-
const mergedRootPolicy = this.dependencyResolver.getWorkspacePolicy();
|
|
2395
|
-
const depsFilterFn = await this.generateFilterFnForDepsFromLocalRemote();
|
|
2396
|
-
const pmInstallOptions = {
|
|
2397
|
-
dedupe: !hasRootComponents && (options === null || options === void 0 ? void 0 : options.dedupe),
|
|
2398
|
-
copyPeerToRuntimeOnRoot: (_options$copyPeerToRu3 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnRoot) !== null && _options$copyPeerToRu3 !== void 0 ? _options$copyPeerToRu3 : true,
|
|
2399
|
-
copyPeerToRuntimeOnComponents: (_options$copyPeerToRu4 = options === null || options === void 0 ? void 0 : options.copyPeerToRuntimeOnComponents) !== null && _options$copyPeerToRu4 !== void 0 ? _options$copyPeerToRu4 : false,
|
|
2400
|
-
dependencyFilterFn: depsFilterFn,
|
|
2401
|
-
overrides: this.dependencyResolver.config.overrides,
|
|
2402
|
-
packageImportMethod: this.dependencyResolver.config.packageImportMethod,
|
|
2403
|
-
rootComponents: hasRootComponents
|
|
2404
|
-
};
|
|
2405
|
-
await installer.install(this.path, mergedRootPolicy, compDirMap, {
|
|
2406
|
-
installTeambitBit: false
|
|
2407
|
-
}, pmInstallOptions);
|
|
2408
|
-
await this.link({
|
|
2409
|
-
linkTeambitBit: false,
|
|
2410
|
-
legacyLink: true,
|
|
2411
|
-
linkCoreAspects: this.dependencyResolver.linkCoreAspects(),
|
|
2412
|
-
linkDepsResolvedFromEnv: !hasRootComponents,
|
|
2413
|
-
linkNestedDepsInNM: !this.isLegacy && !hasRootComponents
|
|
2414
|
-
});
|
|
2415
|
-
await this.consumer.componentFsCache.deleteAllDependenciesDataCache();
|
|
2416
|
-
return compDirMap;
|
|
2417
|
-
}
|
|
2418
|
-
|
|
2419
|
-
async link(options = {}) {
|
|
2420
|
-
if (options.fetchObject) {
|
|
2421
|
-
await this.importObjects();
|
|
2422
|
-
}
|
|
2423
|
-
|
|
2424
|
-
options.consumer = this.consumer;
|
|
2425
|
-
const compDirMap = await this.getComponentsDirectory([]);
|
|
2426
|
-
const mergedRootPolicy = this.dependencyResolver.getWorkspacePolicy();
|
|
2427
|
-
const linker = this.dependencyResolver.getLinker({
|
|
2428
|
-
rootDir: this.path,
|
|
2429
|
-
linkingOptions: options
|
|
2430
|
-
});
|
|
2431
|
-
const res = await linker.link(this.path, mergedRootPolicy, compDirMap, options);
|
|
2432
|
-
return res;
|
|
2433
|
-
}
|
|
2434
|
-
/**
|
|
2435
|
-
* @param componentPath can be relative or absolute. supports Linux and Windows
|
|
2436
|
-
*/
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
async getComponentIdByPath(componentPath) {
|
|
2440
|
-
const relativePath = _path2().default.isAbsolute(componentPath) ? _path2().default.relative(this.path, componentPath) : componentPath;
|
|
2441
|
-
const linuxPath = (0, _path().pathNormalizeToLinux)(relativePath);
|
|
2442
|
-
const bitId = this.consumer.bitMap.getComponentIdByPath(linuxPath);
|
|
2443
|
-
|
|
2444
|
-
if (bitId) {
|
|
2445
|
-
return this.resolveComponentId(bitId);
|
|
2446
|
-
}
|
|
2447
|
-
|
|
2448
|
-
return undefined;
|
|
2449
|
-
}
|
|
2450
|
-
/**
|
|
2451
|
-
* Generate a filter to pass to the installer
|
|
2452
|
-
* This will filter deps which are come from remotes which defined in scope.json
|
|
2453
|
-
* those components comes from local remotes, usually doesn't have a package in a registry
|
|
2454
|
-
* so no reason to try to install them (it will fail)
|
|
2455
|
-
*/
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
async generateFilterFnForDepsFromLocalRemote() {
|
|
2459
|
-
// TODO: once scope create a new API for this, replace it with the new one
|
|
2460
|
-
const remotes = await this.scope._legacyRemotes();
|
|
2461
|
-
const reg = await this.dependencyResolver.getRegistries();
|
|
2462
|
-
const packageScopes = Object.keys(reg.scopes);
|
|
2463
|
-
return dependencyList => {
|
|
2464
|
-
const filtered = dependencyList.filter(dep => {
|
|
2465
|
-
if (!(dep instanceof _dependencyResolver().ComponentDependency)) {
|
|
2466
|
-
return true;
|
|
2467
|
-
}
|
|
2468
|
-
|
|
2469
|
-
if (remotes.isHub(dep.componentId.scope)) {
|
|
2470
|
-
return true;
|
|
2471
|
-
}
|
|
2472
|
-
|
|
2473
|
-
if (packageScopes.some(scope => dep.packageName.startsWith(`@${scope}/`))) {
|
|
2474
|
-
return true;
|
|
2475
|
-
}
|
|
2476
|
-
|
|
2477
|
-
return false;
|
|
2478
|
-
});
|
|
2479
|
-
return filtered;
|
|
2480
|
-
};
|
|
2481
|
-
}
|
|
2482
2140
|
/**
|
|
2483
2141
|
* whether a scope is hosted by Bit cloud.
|
|
2484
2142
|
* otherwise, it is self-hosted
|
|
@@ -2499,7 +2157,7 @@ needed-for: ${neededFor || '<unknown>'}`);
|
|
|
2499
2157
|
try {
|
|
2500
2158
|
return await this.importAndGetMany(componentIds);
|
|
2501
2159
|
} catch (err) {
|
|
2502
|
-
if (err instanceof
|
|
2160
|
+
if (err instanceof _exceptions().ComponentNotFound) {
|
|
2503
2161
|
var _config$workspaceConf3;
|
|
2504
2162
|
|
|
2505
2163
|
const config = this.harmony.get('teambit.harmony/config');
|
|
@@ -2511,36 +2169,6 @@ your workspace.jsonc has this component-id set. you might want to remove/change
|
|
|
2511
2169
|
}
|
|
2512
2170
|
}
|
|
2513
2171
|
|
|
2514
|
-
throw err;
|
|
2515
|
-
}
|
|
2516
|
-
} // TODO: replace with a proper import API on the workspace
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
async importObjects() {
|
|
2520
|
-
const importOptions = {
|
|
2521
|
-
ids: [],
|
|
2522
|
-
verbose: false,
|
|
2523
|
-
merge: false,
|
|
2524
|
-
objectsOnly: true,
|
|
2525
|
-
override: false,
|
|
2526
|
-
writeDists: false,
|
|
2527
|
-
writeConfig: false,
|
|
2528
|
-
installNpmPackages: false,
|
|
2529
|
-
importDependenciesDirectly: false,
|
|
2530
|
-
importDependents: false
|
|
2531
|
-
};
|
|
2532
|
-
const importer = new (_importer().Importer)(this, this.dependencyResolver);
|
|
2533
|
-
|
|
2534
|
-
try {
|
|
2535
|
-
const res = await importer.import(importOptions, []);
|
|
2536
|
-
return res;
|
|
2537
|
-
} catch (err) {
|
|
2538
|
-
// TODO: this is a hack since the legacy throw an error, we should provide a way to not throw this error from the legacy
|
|
2539
|
-
if (err instanceof _exceptions().NothingToImport) {
|
|
2540
|
-
// Do not write nothing to import warning
|
|
2541
|
-
return undefined;
|
|
2542
|
-
}
|
|
2543
|
-
|
|
2544
2172
|
throw err;
|
|
2545
2173
|
}
|
|
2546
2174
|
}
|
|
@@ -2765,20 +2393,6 @@ your workspace.jsonc has this component-id set. you might want to remove/change
|
|
|
2765
2393
|
});
|
|
2766
2394
|
return Promise.all(resolveMergedExtensionsP);
|
|
2767
2395
|
}
|
|
2768
|
-
/**
|
|
2769
|
-
* Uninstall the specified packages from dependencies.
|
|
2770
|
-
*
|
|
2771
|
-
* @param {string[]} the list of packages that should be removed from dependencies.
|
|
2772
|
-
*/
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
async uninstallDependencies(packages) {
|
|
2776
|
-
this.dependencyResolver.removeFromRootPolicy(packages);
|
|
2777
|
-
await this.dependencyResolver.persistConfig(this.path);
|
|
2778
|
-
return this._installModules({
|
|
2779
|
-
dedupe: true
|
|
2780
|
-
});
|
|
2781
|
-
}
|
|
2782
2396
|
/**
|
|
2783
2397
|
* configure an environment to the given components in the .bitmap file, this configuration overrides other, such as
|
|
2784
2398
|
* overrides in workspace.jsonc.
|