@teambit/workspace 0.0.535 → 0.0.541
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/build-graph-from-fs.ts +160 -0
- package/dist/build-graph-from-fs.d.ts +26 -0
- package/dist/build-graph-from-fs.js +254 -0
- package/dist/build-graph-from-fs.js.map +1 -0
- package/dist/workspace.d.ts +6 -2
- package/dist/workspace.js +83 -25
- package/dist/workspace.js.map +1 -1
- package/package-tar/teambit-workspace-0.0.541.tgz +0 -0
- package/package.json +47 -45
- package/workspace.ts +58 -17
- package/package-tar/teambit-workspace-0.0.535.tgz +0 -0
package/dist/workspace.js
CHANGED
|
@@ -165,6 +165,16 @@ function _legacyBitId() {
|
|
|
165
165
|
return data;
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
function _laneId() {
|
|
169
|
+
const data = require("@teambit/legacy/dist/lane-id/lane-id");
|
|
170
|
+
|
|
171
|
+
_laneId = function () {
|
|
172
|
+
return data;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
return data;
|
|
176
|
+
}
|
|
177
|
+
|
|
168
178
|
function _consumer2() {
|
|
169
179
|
const data = require("@teambit/legacy/dist/consumer");
|
|
170
180
|
|
|
@@ -225,16 +235,6 @@ function _extensionData() {
|
|
|
225
235
|
return data;
|
|
226
236
|
}
|
|
227
237
|
|
|
228
|
-
function _componentsGraph() {
|
|
229
|
-
const data = require("@teambit/legacy/dist/scope/graph/components-graph");
|
|
230
|
-
|
|
231
|
-
_componentsGraph = function () {
|
|
232
|
-
return data;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
return data;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
238
|
function _utils() {
|
|
239
239
|
const data = require("@teambit/legacy/dist/utils");
|
|
240
240
|
|
|
@@ -365,6 +365,16 @@ function _incorrectEnvAspect() {
|
|
|
365
365
|
return data;
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
+
function _buildGraphFromFs() {
|
|
369
|
+
const data = require("./build-graph-from-fs");
|
|
370
|
+
|
|
371
|
+
_buildGraphFromFs = function () {
|
|
372
|
+
return data;
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
return data;
|
|
376
|
+
}
|
|
377
|
+
|
|
368
378
|
const ComponentAdded = 'componentAdded';
|
|
369
379
|
exports.ComponentAdded = ComponentAdded;
|
|
370
380
|
const ComponentChanged = 'componentChanged';
|
|
@@ -640,7 +650,7 @@ class Workspace {
|
|
|
640
650
|
async getLegacyGraph(ids) {
|
|
641
651
|
if (!ids || ids.length < 1) ids = await this.listIds();
|
|
642
652
|
const legacyIds = ids.map(id => id._legacy);
|
|
643
|
-
const legacyGraph = await
|
|
653
|
+
const legacyGraph = await this.buildOneGraphForComponents(legacyIds);
|
|
644
654
|
return legacyGraph;
|
|
645
655
|
}
|
|
646
656
|
|
|
@@ -799,6 +809,27 @@ class Workspace {
|
|
|
799
809
|
getCurrentLaneId() {
|
|
800
810
|
return this.consumer.getCurrentLaneId();
|
|
801
811
|
}
|
|
812
|
+
/**
|
|
813
|
+
* if checked out to a lane, return the remote lane id (name+scope). otherwise, return null.
|
|
814
|
+
*/
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
getCurrentRemoteLaneId() {
|
|
818
|
+
const currentLane = this.getCurrentLaneId();
|
|
819
|
+
|
|
820
|
+
if (currentLane.isDefault()) {
|
|
821
|
+
return null;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
const trackData = this.scope.legacyScope.lanes.getRemoteTrackedDataByLocalLane(currentLane.name);
|
|
825
|
+
const remoteLaneName = trackData === null || trackData === void 0 ? void 0 : trackData.remoteLane;
|
|
826
|
+
|
|
827
|
+
if (!remoteLaneName) {
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
return _laneId().RemoteLaneId.from(remoteLaneName, trackData.remoteScope);
|
|
832
|
+
}
|
|
802
833
|
|
|
803
834
|
getDefaultExtensions() {
|
|
804
835
|
if (!this.config.extensions) {
|
|
@@ -875,7 +906,9 @@ class Workspace {
|
|
|
875
906
|
|
|
876
907
|
|
|
877
908
|
async importAndGetMany(ids, forCapsule = false) {
|
|
878
|
-
await this.scope.import(ids
|
|
909
|
+
await this.scope.import(ids, {
|
|
910
|
+
reFetchUnBuiltVersion: shouldReFetchUnBuiltVersion()
|
|
911
|
+
});
|
|
879
912
|
return this.componentLoader.getMany(ids, forCapsule);
|
|
880
913
|
}
|
|
881
914
|
/**
|
|
@@ -1192,7 +1225,7 @@ class Workspace {
|
|
|
1192
1225
|
return componentConfigFile;
|
|
1193
1226
|
}
|
|
1194
1227
|
|
|
1195
|
-
async
|
|
1228
|
+
async getAspectsGraphWithoutCore(components, isAspect) {
|
|
1196
1229
|
const ids = components.map(component => component.id._legacy);
|
|
1197
1230
|
const coreAspectsStringIds = this.aspectLoader.getCoreAspectIds();
|
|
1198
1231
|
const coreAspectsComponentIds = coreAspectsStringIds.map(id => _legacyBitId().BitId.parse(id, true));
|
|
@@ -1216,7 +1249,7 @@ class Workspace {
|
|
|
1216
1249
|
|
|
1217
1250
|
|
|
1218
1251
|
const ignoredIds = coreAspectsBitIds.concat([]);
|
|
1219
|
-
return
|
|
1252
|
+
return this.buildOneGraphForComponents(ids, _bitId().BitIds.fromArray(ignoredIds), isAspect);
|
|
1220
1253
|
}
|
|
1221
1254
|
/**
|
|
1222
1255
|
* load aspects from the workspace and if not exists in the workspace, load from the scope.
|
|
@@ -1232,15 +1265,12 @@ class Workspace {
|
|
|
1232
1265
|
const idsWithoutCore = (0, _lodash().difference)(notLoadedIds, coreAspectsStringIds);
|
|
1233
1266
|
const componentIds = await this.resolveMultipleComponentIds(idsWithoutCore);
|
|
1234
1267
|
const components = await this.importAndGetAspects(componentIds);
|
|
1235
|
-
|
|
1236
|
-
const
|
|
1237
|
-
return this.resolveComponentId(id);
|
|
1238
|
-
});
|
|
1239
|
-
const allIds = await Promise.all(allIdsP);
|
|
1240
|
-
const allComponents = await this.getMany(allIds);
|
|
1241
|
-
const aspects = allComponents.filter(component => {
|
|
1268
|
+
|
|
1269
|
+
const isAspect = async bitId => {
|
|
1242
1270
|
var _component$config$ext;
|
|
1243
1271
|
|
|
1272
|
+
const id = await this.resolveComponentId(bitId);
|
|
1273
|
+
const component = await this.get(id);
|
|
1244
1274
|
let data = (_component$config$ext = component.config.extensions.findExtension(_envs().EnvsAspect.id)) === null || _component$config$ext === void 0 ? void 0 : _component$config$ext.data;
|
|
1245
1275
|
|
|
1246
1276
|
if (!data) {
|
|
@@ -1264,14 +1294,16 @@ class Workspace {
|
|
|
1264
1294
|
}
|
|
1265
1295
|
|
|
1266
1296
|
return data.type === 'aspect';
|
|
1267
|
-
}
|
|
1268
|
-
// here we are trying to load extensions from the workspace.
|
|
1297
|
+
};
|
|
1269
1298
|
|
|
1299
|
+
const graph = await this.getAspectsGraphWithoutCore(components, isAspect);
|
|
1300
|
+
const idsStr = graph.nodes();
|
|
1301
|
+
const compIds = await this.resolveMultipleComponentIds(idsStr);
|
|
1302
|
+
const aspects = await this.getMany(compIds);
|
|
1270
1303
|
const {
|
|
1271
1304
|
workspaceComps,
|
|
1272
1305
|
scopeComps
|
|
1273
|
-
} = await this.groupComponentsByWorkspaceAndScope(aspects);
|
|
1274
|
-
|
|
1306
|
+
} = await this.groupComponentsByWorkspaceAndScope(aspects);
|
|
1275
1307
|
const scopeIds = scopeComps.map(aspect => aspect.id.toString());
|
|
1276
1308
|
const workspaceAspects = await this.requireComponents(workspaceComps);
|
|
1277
1309
|
const workspaceManifests = await this.aspectLoader.getManifestsFromRequireableExtensions(workspaceAspects, throwOnError);
|
|
@@ -1280,6 +1312,17 @@ class Workspace {
|
|
|
1280
1312
|
const allManifests = [...scopeManifests, ...workspaceManifests];
|
|
1281
1313
|
await this.aspectLoader.loadExtensionsByManifests(allManifests, throwOnError);
|
|
1282
1314
|
}
|
|
1315
|
+
/**
|
|
1316
|
+
* Note - this gets called from Harmony only.
|
|
1317
|
+
* returns one graph that includes all dependencies types. each edge has a label of the dependency
|
|
1318
|
+
* type. the nodes content is the Component object.
|
|
1319
|
+
*/
|
|
1320
|
+
|
|
1321
|
+
|
|
1322
|
+
async buildOneGraphForComponents(ids, ignoreIds, shouldIgnoreFunc) {
|
|
1323
|
+
const graphFromFsBuilder = new (_buildGraphFromFs().GraphFromFsBuilder)(this, this.logger, ignoreIds, shouldIgnoreFunc);
|
|
1324
|
+
return graphFromFsBuilder.buildGraph(ids);
|
|
1325
|
+
}
|
|
1283
1326
|
|
|
1284
1327
|
async resolveAspects(runtimeName, componentIds) {
|
|
1285
1328
|
let missingPaths = false;
|
|
@@ -1803,8 +1846,23 @@ your workspace.jsonc has this component-id set. you might want to remove/change
|
|
|
1803
1846
|
}
|
|
1804
1847
|
|
|
1805
1848
|
}
|
|
1849
|
+
/**
|
|
1850
|
+
* this is a super hacky way to do it. problem is that loadAspect is running as onStart hook, where we don't
|
|
1851
|
+
* have the CLI fully loaded yet, so we can't get the command from the CLI aspect, we have to retrieve it from
|
|
1852
|
+
* process.argv.
|
|
1853
|
+
* in general, we don't want every command to try again and again fetching un-built versions. otherwise, every time
|
|
1854
|
+
* Bit loads (even bit --help), it'll fetch them and slow down everything.
|
|
1855
|
+
* instead, long-running commands and those that need the artifacts from the Version objects, should try to re-fetch.
|
|
1856
|
+
*/
|
|
1857
|
+
|
|
1806
1858
|
|
|
1807
1859
|
exports.Workspace = Workspace;
|
|
1860
|
+
|
|
1861
|
+
function shouldReFetchUnBuiltVersion() {
|
|
1862
|
+
const commandsToReFetch = ['build', 'show', 'start', 'tag', 'install', 'link', 'import'];
|
|
1863
|
+
return commandsToReFetch.includes(process.argv[2]);
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1808
1866
|
var _default = Workspace;
|
|
1809
1867
|
exports.default = _default;
|
|
1810
1868
|
|