@teambit/scope 1.0.106 → 1.0.108
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/clear-cache-action.ts +11 -0
- package/dist/get-scope-options.d.ts +1 -1
- package/dist/{preview-1703505948637.js → preview-1703647408454.js} +2 -2
- package/dist/scope-aspects-loader.d.ts +4 -4
- package/dist/scope-aspects-loader.js +8 -9
- package/dist/scope-aspects-loader.js.map +1 -1
- package/dist/scope-cmd.d.ts +1 -1
- package/dist/scope-component-loader.js +2 -2
- package/dist/scope-component-loader.js.map +1 -1
- package/dist/scope.composition.d.ts +2 -2
- package/dist/scope.graphql.d.ts +4 -4
- package/dist/scope.main.runtime.d.ts +30 -22
- package/dist/scope.main.runtime.js +37 -15
- package/dist/scope.main.runtime.js.map +1 -1
- package/dist/scope.ui-root.d.ts +2 -2
- package/dist/scope.ui.drawer.d.ts +1 -1
- package/dist/scope.ui.drawer.js +6 -8
- package/dist/scope.ui.drawer.js.map +1 -1
- package/dist/scope.ui.runtime.d.ts +14 -14
- package/dist/scope.ui.runtime.js +8 -11
- package/dist/scope.ui.runtime.js.map +1 -1
- package/dist/staged-config.d.ts +3 -3
- package/dist/staged-config.js +2 -3
- package/dist/staged-config.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/ui/menu/menu.d.ts +4 -4
- package/dist/ui/scope-overview/scope-overview.d.ts +5 -5
- package/dist/ui/scope-overview/scope-overview.js +2 -4
- package/dist/ui/scope-overview/scope-overview.js.map +1 -1
- package/dist/ui/scope.d.ts +3 -3
- package/dist/ui/scope.js +1 -1
- package/dist/ui/scope.js.map +1 -1
- package/get-scope-options.ts +16 -0
- package/index.ts +11 -0
- package/package.json +33 -40
- package/scope-aspects-loader.ts +493 -0
- package/scope-cmd.ts +17 -0
- package/scope-component-loader.ts +208 -0
- package/scope.aspect.ts +7 -0
- package/scope.graphql.ts +115 -0
- package/scope.main.runtime.ts +1263 -0
- package/scope.ui-root.ts +43 -0
- package/scope.ui.runtime.tsx +1 -0
- package/staged-config.ts +79 -0
- package/tsconfig.json +16 -21
- package/types/asset.d.ts +15 -3
- package/types.ts +12 -0
|
@@ -144,6 +144,13 @@ function _scopeLoader() {
|
|
|
144
144
|
};
|
|
145
145
|
return data;
|
|
146
146
|
}
|
|
147
|
+
function _getDivergeData() {
|
|
148
|
+
const data = require("@teambit/legacy/dist/scope/component-ops/get-diverge-data");
|
|
149
|
+
_getDivergeData = function () {
|
|
150
|
+
return data;
|
|
151
|
+
};
|
|
152
|
+
return data;
|
|
153
|
+
}
|
|
147
154
|
function _actions() {
|
|
148
155
|
const data = require("@teambit/legacy/dist/scope/actions");
|
|
149
156
|
_actions = function () {
|
|
@@ -526,8 +533,7 @@ class ScopeMain {
|
|
|
526
533
|
}
|
|
527
534
|
builderDataMapToLegacyOnTagResults(builderDataComponentMap) {
|
|
528
535
|
const builderDataToLegacyExtension = (component, builderData) => {
|
|
529
|
-
|
|
530
|
-
const existingBuilder = (_component$state$aspe = component.state.aspects.get(_builder().BuilderAspect.id)) === null || _component$state$aspe === void 0 ? void 0 : _component$state$aspe.legacy;
|
|
536
|
+
const existingBuilder = component.state.aspects.get(_builder().BuilderAspect.id)?.legacy;
|
|
531
537
|
const builderExtension = existingBuilder || new (_config().ExtensionDataEntry)(undefined, undefined, _builder().BuilderAspect.id);
|
|
532
538
|
builderExtension.data = builderData;
|
|
533
539
|
return builderExtension;
|
|
@@ -592,7 +598,7 @@ class ScopeMain {
|
|
|
592
598
|
force,
|
|
593
599
|
lanes
|
|
594
600
|
}, headers) {
|
|
595
|
-
const authData = (0, _http().getAuthDataFromHeader)(headers
|
|
601
|
+
const authData = (0, _http().getAuthDataFromHeader)(headers?.authorization);
|
|
596
602
|
const result = await (0, _scope2().remove)({
|
|
597
603
|
path: this.path,
|
|
598
604
|
ids,
|
|
@@ -801,7 +807,7 @@ class ScopeMain {
|
|
|
801
807
|
* list all components in the scope.
|
|
802
808
|
*/
|
|
803
809
|
async list(filter, includeCache = false, includeFromLanes = false, includeDeleted = false) {
|
|
804
|
-
const patternsWithScope =
|
|
810
|
+
const patternsWithScope = filter?.namespaces && filter?.namespaces.map(pattern => `**/${pattern || '**'}`) || undefined;
|
|
805
811
|
const componentsIds = await this.listIds(includeCache, includeFromLanes, patternsWithScope);
|
|
806
812
|
const comps = await this.getMany(filter && filter.limit ? (0, _lodash().slice)(componentsIds, filter.offset, filter.offset + filter.limit) : componentsIds);
|
|
807
813
|
return includeDeleted ? comps : comps.filter(comp => !comp.isDeleted());
|
|
@@ -830,7 +836,7 @@ class ScopeMain {
|
|
|
830
836
|
const modelComponentsToList = allModelComponents.filter(filterByCacheAndLanes);
|
|
831
837
|
let ids = modelComponentsToList.map(component => _componentId().ComponentID.fromLegacy(component.toBitIdWithLatestVersion(), component.scope || this.name));
|
|
832
838
|
if (patterns && patterns.length > 0) {
|
|
833
|
-
ids = ids.filter(id => patterns
|
|
839
|
+
ids = ids.filter(id => patterns?.some(pattern => (0, _workspaceModules().isMatchNamespacePatternItem)(id.toStringWithoutVersion(), pattern).match));
|
|
834
840
|
}
|
|
835
841
|
this.logger.debug(`scope listIds: total ${ids.length} components after filter scope`);
|
|
836
842
|
return ids;
|
|
@@ -1027,13 +1033,32 @@ class ScopeMain {
|
|
|
1027
1033
|
await modelComp.setDivergeData(this.legacyScope.objects, throws);
|
|
1028
1034
|
return modelComp.getDivergeData();
|
|
1029
1035
|
}
|
|
1036
|
+
/**
|
|
1037
|
+
* get the distance for a component between two lanes. for example, lane-b forked from lane-a and lane-b added some new snaps
|
|
1038
|
+
* @param componentId
|
|
1039
|
+
* @param sourceHead head on the source lane. leave empty if the source is main
|
|
1040
|
+
* @param targetHead head on the target lane. leave empty if the target is main
|
|
1041
|
+
* @returns
|
|
1042
|
+
*/
|
|
1043
|
+
async getSnapsDistanceBetweenTwoSnaps(componentId, sourceHead, targetHead, throws) {
|
|
1044
|
+
if (!sourceHead && !targetHead) {
|
|
1045
|
+
throw new Error(`getDivergeData got sourceHead and targetHead empty. at least one of them should be populated`);
|
|
1046
|
+
}
|
|
1047
|
+
const modelComponent = await this.legacyScope.getModelComponent(componentId);
|
|
1048
|
+
return (0, _getDivergeData().getDivergeData)({
|
|
1049
|
+
modelComponent,
|
|
1050
|
+
repo: this.legacyScope.objects,
|
|
1051
|
+
sourceHead: sourceHead ? _objects().Ref.from(sourceHead) : modelComponent.head || null,
|
|
1052
|
+
targetHead: targetHead ? _objects().Ref.from(targetHead) : modelComponent.head || null,
|
|
1053
|
+
throws
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1030
1056
|
async getExactVersionBySemverRange(id, range) {
|
|
1031
|
-
var _semver$maxSatisfying;
|
|
1032
1057
|
const modelComponent = await this.legacyScope.getModelComponent(id);
|
|
1033
1058
|
const versions = modelComponent.listVersions();
|
|
1034
|
-
return
|
|
1059
|
+
return _semver().default.maxSatisfying(versions, range, {
|
|
1035
1060
|
includePrerelease: true
|
|
1036
|
-
})
|
|
1061
|
+
})?.toString();
|
|
1037
1062
|
}
|
|
1038
1063
|
async resumeExport(exportId, remotes) {
|
|
1039
1064
|
return (0, _exportScopeComponents().resumeExport)(this.legacyScope, exportId, remotes);
|
|
@@ -1066,9 +1091,8 @@ class ScopeMain {
|
|
|
1066
1091
|
try {
|
|
1067
1092
|
return await this.legacyScope.getConsumerComponent(id);
|
|
1068
1093
|
} catch (err) {
|
|
1069
|
-
var _await$this$get;
|
|
1070
1094
|
// in case the component is missing locally, this.get imports it.
|
|
1071
|
-
return (
|
|
1095
|
+
return (await this.get(id))?.state._consumer;
|
|
1072
1096
|
}
|
|
1073
1097
|
}
|
|
1074
1098
|
|
|
@@ -1107,16 +1131,14 @@ class ScopeMain {
|
|
|
1107
1131
|
// important! previously, this was running for any aspect, not only apps. (the if statement was `this.aspectLoader.isAspectComponent(component)`)
|
|
1108
1132
|
// Ran suggests changing it and if it breaks something, we'll document is and fix it.
|
|
1109
1133
|
if (opts.loadApps) {
|
|
1110
|
-
var _appData$data;
|
|
1111
1134
|
const appData = component.state.aspects.get('teambit.harmony/application');
|
|
1112
|
-
if (appData
|
|
1135
|
+
if (appData?.data?.appName) {
|
|
1113
1136
|
aspectIds.push(component.id.toString());
|
|
1114
1137
|
}
|
|
1115
1138
|
}
|
|
1116
1139
|
if (opts.loadEnvs) {
|
|
1117
|
-
var _envsData$data, _envsData$data2, _envsData$data3;
|
|
1118
1140
|
const envsData = component.state.aspects.get(_envs().default.id);
|
|
1119
|
-
if (envsData
|
|
1141
|
+
if (envsData?.data?.services || envsData?.data?.self || envsData?.data?.type === 'env') {
|
|
1120
1142
|
aspectIds.push(component.id.toString());
|
|
1121
1143
|
}
|
|
1122
1144
|
}
|
|
@@ -1157,7 +1179,7 @@ class ScopeMain {
|
|
|
1157
1179
|
|
|
1158
1180
|
static async provider([componentExt, ui, graphql, cli, isolator, aspectLoader, express, loggerMain, envs, depsResolver, globalConfig], config, [postPutSlot, postDeleteSlot, postExportSlot, postObjectsPersistSlot, preFetchObjectsSlot, OnCompAspectReCalcSlot], harmony) {
|
|
1159
1181
|
const bitConfig = harmony.config.get('teambit.harmony/bit');
|
|
1160
|
-
const legacyScope = await (0, _scopeLoader().loadScopeIfExist)(bitConfig
|
|
1182
|
+
const legacyScope = await (0, _scopeLoader().loadScopeIfExist)(bitConfig?.cwd);
|
|
1161
1183
|
if (!legacyScope) {
|
|
1162
1184
|
return undefined;
|
|
1163
1185
|
}
|