@teambit/workspace 0.0.598 → 0.0.605
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/bit-map.d.ts +9 -1
- package/dist/bit-map.js +37 -2
- package/dist/bit-map.js.map +1 -1
- package/dist/component-tree.widget.d.ts +1 -0
- package/dist/eject-conf.cmd.d.ts +1 -0
- package/dist/envs-subcommands/envs-set.cmd.d.ts +11 -0
- package/dist/envs-subcommands/envs-set.cmd.js +55 -0
- package/dist/envs-subcommands/envs-set.cmd.js.map +1 -0
- package/dist/envs-subcommands/envs-unset.cmd.d.ts +11 -0
- package/dist/envs-subcommands/envs-unset.cmd.js +46 -0
- package/dist/envs-subcommands/envs-unset.cmd.js.map +1 -0
- package/dist/list.cmd.d.ts +1 -0
- package/dist/ui/workspace/workspace-overview/workspace-overview.d.ts +1 -0
- package/dist/ui/workspace/workspace.d.ts +1 -0
- package/dist/ui/workspace-components-drawer/workspace-components.drawer.d.ts +1 -0
- package/dist/workspace-component/workspace-component-loader.js +3 -2
- package/dist/workspace-component/workspace-component-loader.js.map +1 -1
- package/dist/workspace.d.ts +18 -5
- package/dist/workspace.js +99 -21
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.provider.js +29 -1
- package/dist/workspace.provider.js.map +1 -1
- package/envs-subcommands/envs-set.cmd.ts +20 -0
- package/envs-subcommands/envs-unset.cmd.ts +18 -0
- package/package-tar/teambit-workspace-0.0.605.tgz +0 -0
- package/package.json +35 -35
- package/workspace-component/workspace-component-loader.ts +4 -3
- package/package-tar/teambit-workspace-0.0.598.tgz +0 -0
package/dist/workspace.js
CHANGED
|
@@ -1017,6 +1017,14 @@ class Workspace {
|
|
|
1017
1017
|
async getIfExist(componentId) {
|
|
1018
1018
|
return this.componentLoader.getIfExist(componentId);
|
|
1019
1019
|
}
|
|
1020
|
+
/**
|
|
1021
|
+
* whether a component exists in the workspace
|
|
1022
|
+
*/
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
exists(componentId) {
|
|
1026
|
+
return Boolean(this.consumer.bitmapIdsFromCurrentLane.find(_ => _.isEqualWithoutVersion(componentId._legacy)));
|
|
1027
|
+
}
|
|
1020
1028
|
/**
|
|
1021
1029
|
* This will make sure to fetch the objects prior to load them
|
|
1022
1030
|
* do not use it if you are not sure you need it.
|
|
@@ -1218,19 +1226,15 @@ class Workspace {
|
|
|
1218
1226
|
}
|
|
1219
1227
|
/**
|
|
1220
1228
|
* Calculate the component config based on:
|
|
1229
|
+
* the config property in the .bitmap file
|
|
1221
1230
|
* the component.json file in the component folder
|
|
1222
1231
|
* matching pattern in the variants config
|
|
1223
1232
|
* defaults extensions from workspace config
|
|
1224
|
-
*
|
|
1225
|
-
* @param {ComponentID} componentId
|
|
1226
|
-
* @param {Component} [componentFromScope]
|
|
1227
|
-
* @returns {Promise<ExtensionDataList>}
|
|
1228
|
-
* @memberof Workspace
|
|
1229
1233
|
*/
|
|
1230
1234
|
|
|
1231
1235
|
|
|
1232
1236
|
async componentExtensions(componentId, componentFromScope) {
|
|
1233
|
-
var _componentFromScope$c, _componentConfigFile$, _variantConfig$propag;
|
|
1237
|
+
var _componentFromScope$c, _componentConfigFile$, _variantConfig$propag, _wsDefaultExtensions;
|
|
1234
1238
|
|
|
1235
1239
|
// TODO: consider caching this result
|
|
1236
1240
|
let configFileExtensions;
|
|
@@ -1270,54 +1274,83 @@ class Workspace {
|
|
|
1270
1274
|
|
|
1271
1275
|
|
|
1272
1276
|
const extensionsToMerge = [];
|
|
1277
|
+
let envWasFoundPreviously = false;
|
|
1278
|
+
|
|
1279
|
+
const addAndLoadExtensions = async extensions => {
|
|
1280
|
+
const extsWithoutRemoved = extensions.filterRemovedExtensions();
|
|
1281
|
+
const selfInMergedExtensions = extsWithoutRemoved.findExtension(componentId._legacy.toStringWithoutScopeAndVersion(), true, true);
|
|
1282
|
+
const extsWithoutSelf = selfInMergedExtensions !== null && selfInMergedExtensions !== void 0 && selfInMergedExtensions.extensionId ? extsWithoutRemoved.remove(selfInMergedExtensions.extensionId) : extsWithoutRemoved;
|
|
1283
|
+
await this.loadExtensions(extsWithoutSelf);
|
|
1284
|
+
const {
|
|
1285
|
+
extensionDataListFiltered,
|
|
1286
|
+
envIsCurrentlySet
|
|
1287
|
+
} = this.filterEnvsFromExtensionsIfNeeded(extsWithoutSelf, envWasFoundPreviously);
|
|
1288
|
+
if (envIsCurrentlySet) envWasFoundPreviously = true;
|
|
1289
|
+
extensionsToMerge.push(extensionDataListFiltered);
|
|
1290
|
+
};
|
|
1273
1291
|
|
|
1274
1292
|
if (bitMapExtensions) {
|
|
1275
1293
|
const extensionsDataEntries = Object.keys(bitMapExtensions).map(aspectId => new (_extensionData().ExtensionDataEntry)(aspectId, undefined, aspectId, bitMapExtensions[aspectId]));
|
|
1276
1294
|
const extensionDataList = new (_extensionData().ExtensionDataList)(...extensionsDataEntries);
|
|
1277
|
-
|
|
1295
|
+
await addAndLoadExtensions(extensionDataList);
|
|
1278
1296
|
}
|
|
1279
1297
|
|
|
1280
1298
|
if (configFileExtensions) {
|
|
1281
|
-
|
|
1299
|
+
await addAndLoadExtensions(configFileExtensions);
|
|
1282
1300
|
}
|
|
1283
1301
|
|
|
1284
1302
|
let continuePropagating = (_componentConfigFile$ = componentConfigFile === null || componentConfigFile === void 0 ? void 0 : componentConfigFile.propagate) !== null && _componentConfigFile$ !== void 0 ? _componentConfigFile$ : true;
|
|
1285
1303
|
|
|
1286
1304
|
if (variantsExtensions && continuePropagating) {
|
|
1287
1305
|
// Put it in the start to make sure the config file is stronger
|
|
1288
|
-
|
|
1306
|
+
await addAndLoadExtensions(variantsExtensions);
|
|
1289
1307
|
}
|
|
1290
1308
|
|
|
1291
1309
|
continuePropagating = continuePropagating && ((_variantConfig$propag = variantConfig === null || variantConfig === void 0 ? void 0 : variantConfig.propagate) !== null && _variantConfig$propag !== void 0 ? _variantConfig$propag : true); // Do not apply default extensions on the default extensions (it will create infinite loop when loading them)
|
|
1292
1310
|
|
|
1293
|
-
const isDefaultExtension = wsDefaultExtensions.findExtension(componentId.toString(), true, true);
|
|
1311
|
+
const isDefaultExtension = (_wsDefaultExtensions = wsDefaultExtensions) === null || _wsDefaultExtensions === void 0 ? void 0 : _wsDefaultExtensions.findExtension(componentId.toString(), true, true);
|
|
1294
1312
|
|
|
1295
1313
|
if (wsDefaultExtensions && continuePropagating && !isDefaultExtension) {
|
|
1296
1314
|
// Put it in the start to make sure the config file is stronger
|
|
1297
|
-
|
|
1315
|
+
await addAndLoadExtensions(wsDefaultExtensions);
|
|
1298
1316
|
} // It's before the scope extensions, since there is no need to resolve extensions from scope they are already resolved
|
|
1299
1317
|
// await Promise.all(extensionsToMerge.map((extensions) => this.resolveExtensionsList(extensions)));
|
|
1300
1318
|
|
|
1301
1319
|
|
|
1302
1320
|
if (mergeFromScope && continuePropagating) {
|
|
1303
|
-
|
|
1321
|
+
await addAndLoadExtensions(scopeExtensions);
|
|
1304
1322
|
} // It's important to do this resolution before the merge, otherwise we have issues with extensions
|
|
1305
1323
|
// coming from scope with local scope name, as opposed to the same extension comes from the workspace with default scope name
|
|
1306
1324
|
|
|
1307
1325
|
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
let mergedExtensions = _extensionData().ExtensionDataList.mergeConfigs(extensionsToMerge).filterRemovedExtensions(); // remove self from merged extensions
|
|
1312
|
-
|
|
1326
|
+
await Promise.all(extensionsToMerge.map(list => this.resolveExtensionListIds(list)));
|
|
1327
|
+
return _extensionData().ExtensionDataList.mergeConfigs(extensionsToMerge);
|
|
1328
|
+
}
|
|
1313
1329
|
|
|
1314
|
-
|
|
1330
|
+
filterEnvsFromExtensionsIfNeeded(extensionDataList, envWasFoundPreviously) {
|
|
1331
|
+
const envAspect = extensionDataList.findExtension(_envs().EnvsAspect.id);
|
|
1332
|
+
const envFromEnvsAspect = envAspect === null || envAspect === void 0 ? void 0 : envAspect.config.env;
|
|
1333
|
+
const [envsNotFromEnvsAspect, nonEnvs] = (0, _lodash().partition)(extensionDataList, ext => this.envs.isEnvRegistered(ext.stringId));
|
|
1334
|
+
const extensionDataListFiltered = new (_extensionData().ExtensionDataList)(...nonEnvs);
|
|
1335
|
+
const envIsCurrentlySet = envFromEnvsAspect || envsNotFromEnvsAspect.length;
|
|
1336
|
+
const shouldIgnoreCurrentEnv = envIsCurrentlySet && envWasFoundPreviously;
|
|
1315
1337
|
|
|
1316
|
-
if (
|
|
1317
|
-
|
|
1338
|
+
if (shouldIgnoreCurrentEnv) {
|
|
1339
|
+
// still, aspect env may have other data other then config.env.
|
|
1340
|
+
if (envAspect) {
|
|
1341
|
+
delete envAspect.config.env;
|
|
1342
|
+
extensionDataListFiltered.push(envAspect);
|
|
1343
|
+
}
|
|
1344
|
+
} else {
|
|
1345
|
+
// add the envs
|
|
1346
|
+
if (envAspect) extensionDataListFiltered.push(envAspect);
|
|
1347
|
+
extensionDataListFiltered.push(...envsNotFromEnvsAspect);
|
|
1318
1348
|
}
|
|
1319
1349
|
|
|
1320
|
-
return
|
|
1350
|
+
return {
|
|
1351
|
+
extensionDataListFiltered,
|
|
1352
|
+
envIsCurrentlySet
|
|
1353
|
+
};
|
|
1321
1354
|
}
|
|
1322
1355
|
|
|
1323
1356
|
async triggerOnPreWatch(componentIds, watchOpts) {
|
|
@@ -2191,6 +2224,51 @@ your workspace.jsonc has this component-id set. you might want to remove/change
|
|
|
2191
2224
|
dedupe: true
|
|
2192
2225
|
});
|
|
2193
2226
|
}
|
|
2227
|
+
/**
|
|
2228
|
+
* configure an environment to the given components in the .bitmap file, this configuration overrides other, such as
|
|
2229
|
+
* overrides in workspace.jsonc.
|
|
2230
|
+
*/
|
|
2231
|
+
|
|
2232
|
+
|
|
2233
|
+
async setEnvToComponents(envId, components) {
|
|
2234
|
+
const envIdStr = envId.toString();
|
|
2235
|
+
components.forEach(component => {
|
|
2236
|
+
this.bitMap.addComponentConfig(component.id, envIdStr);
|
|
2237
|
+
this.bitMap.addComponentConfig(component.id, _envs().EnvsAspect.id, {
|
|
2238
|
+
env: envIdStr
|
|
2239
|
+
});
|
|
2240
|
+
});
|
|
2241
|
+
await this.bitMap.write();
|
|
2242
|
+
}
|
|
2243
|
+
/**
|
|
2244
|
+
* remove env configuration from the .bitmap file, so then other configuration, such as "variants" will take place
|
|
2245
|
+
*/
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
async unsetEnvFromComponents(components) {
|
|
2249
|
+
const changed = [];
|
|
2250
|
+
const unchanged = [];
|
|
2251
|
+
components.forEach(comp => {
|
|
2252
|
+
var _bitMapEntry$config, _bitMapEntry$config$E;
|
|
2253
|
+
|
|
2254
|
+
const bitMapEntry = this.bitMap.getBitmapEntry(comp.id);
|
|
2255
|
+
const currentEnv = (_bitMapEntry$config = bitMapEntry.config) === null || _bitMapEntry$config === void 0 ? void 0 : (_bitMapEntry$config$E = _bitMapEntry$config[_envs().EnvsAspect.id]) === null || _bitMapEntry$config$E === void 0 ? void 0 : _bitMapEntry$config$E.env;
|
|
2256
|
+
|
|
2257
|
+
if (!currentEnv) {
|
|
2258
|
+
unchanged.push(comp.id);
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
this.bitMap.removeComponentConfig(comp.id, currentEnv);
|
|
2263
|
+
this.bitMap.removeComponentConfig(comp.id, _envs().EnvsAspect.id);
|
|
2264
|
+
changed.push(comp.id);
|
|
2265
|
+
});
|
|
2266
|
+
await this.bitMap.write();
|
|
2267
|
+
return {
|
|
2268
|
+
changed,
|
|
2269
|
+
unchanged
|
|
2270
|
+
};
|
|
2271
|
+
}
|
|
2194
2272
|
|
|
2195
2273
|
}
|
|
2196
2274
|
/**
|