@teambit/snapping 1.0.481 → 1.0.483

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.
@@ -25,6 +25,7 @@ import { SnapDataPerCompRaw, FileData } from './snap-from-scope.cmd';
25
25
  import { untagResult } from './reset-component';
26
26
  import { ApplicationMain } from '@teambit/application';
27
27
  import { RemoveMain } from '@teambit/remove';
28
+ export type PackageIntegritiesByPublishedPackages = Map<string, string | undefined>;
28
29
  export type TagDataPerComp = {
29
30
  componentId: ComponentID;
30
31
  dependencies: ComponentID[];
@@ -146,12 +147,13 @@ export declare class SnappingMain {
146
147
  }>;
147
148
  resetNeverExported(): Promise<ComponentID[]>;
148
149
  _addFlattenedDependenciesToComponents(components: ConsumerComponent[], rebuildDepsGraph?: boolean): Promise<void>;
150
+ _addDependenciesGraphToComponents(components: Component[]): Promise<void>;
149
151
  throwForDepsFromAnotherLane(components: ConsumerComponent[]): Promise<void>;
150
152
  throwForVariousIssues(components: Component[], ignoreIssues?: string): Promise<void>;
151
153
  private throwForDepsFromAnotherLaneForComp;
152
154
  _addFlattenedDepsGraphToComponents(components: ConsumerComponent[]): Promise<void>;
153
155
  _updateComponentsByTagResult(components: ConsumerComponent[], tagResult: LegacyOnTagResult[]): void;
154
- _getPublishedPackages(components: ConsumerComponent[]): string[];
156
+ _getPublishedPackages(components: ConsumerComponent[]): PackageIntegritiesByPublishedPackages;
155
157
  _addCompToObjects({ source, lane, shouldValidateVersion, updateDependentsOnLane, }: {
156
158
  source: ConsumerComponent;
157
159
  lane?: Lane;
@@ -235,6 +235,13 @@ function _dependencies() {
235
235
  };
236
236
  return data;
237
237
  }
238
+ function _version() {
239
+ const data = _interopRequireDefault(require("@teambit/legacy/dist/scope/models/version"));
240
+ _version = function () {
241
+ return data;
242
+ };
243
+ return data;
244
+ }
238
245
  function _snapCmd() {
239
246
  const data = require("./snap-cmd");
240
247
  _snapCmd = function () {
@@ -427,6 +434,7 @@ class SnappingMain {
427
434
  removedComponents
428
435
  } = await (0, _tagModelComponent().tagModelComponent)({
429
436
  snapping: this,
437
+ components,
430
438
  consumerComponents,
431
439
  ids: compIds,
432
440
  message,
@@ -525,6 +533,7 @@ if you're willing to lose the history from the head to the specified version, us
525
533
  return comp.buildStatus === _constants().BuildStatus.Succeed && !params.rebuildArtifacts;
526
534
  });
527
535
  const results = await (0, _tagModelComponent().tagModelComponent)(_objectSpread(_objectSpread({}, params), {}, {
536
+ components,
528
537
  consumerComponents,
529
538
  tagDataPerComp,
530
539
  populateArtifactsFrom: shouldUsePopulateArtifactsFrom ? components.map(c => c.id) : undefined,
@@ -675,6 +684,7 @@ if you're willing to lose the history from the head to the specified version, us
675
684
  const ids = _componentId().ComponentIdList.fromArray(allCompIds);
676
685
  const shouldTag = Boolean(params.tag);
677
686
  const results = await (0, _tagModelComponent().tagModelComponent)(_objectSpread(_objectSpread({}, params), {}, {
687
+ components,
678
688
  consumerComponents,
679
689
  tagDataPerComp: snapDataPerComp.map(s => ({
680
690
  componentId: s.componentId,
@@ -760,6 +770,7 @@ if you're willing to lose the history from the head to the specified version, us
760
770
  } = await (0, _tagModelComponent().tagModelComponent)({
761
771
  snapping: this,
762
772
  editor,
773
+ components,
763
774
  consumerComponents,
764
775
  ids,
765
776
  ignoreNewestVersion: false,
@@ -909,6 +920,24 @@ in case you're unsure about the pattern syntax, use "bit pattern [--help]"`);
909
920
  });
910
921
  this.logger.profile('snap._addFlattenedDependenciesToComponents');
911
922
  }
923
+ async _addDependenciesGraphToComponents(components) {
924
+ if (this.workspace == null) {
925
+ return;
926
+ }
927
+ this.logger.profile('snap._addDependenciesGraphToComponents');
928
+ const componentIdByPkgName = this.dependencyResolver.createComponentIdByPkgNameMap(components);
929
+ const options = {
930
+ rootDir: this.workspace.path,
931
+ rootComponentsPath: this.workspace.rootComponentsPath,
932
+ componentIdByPkgName
933
+ };
934
+ await Promise.all(components.map(async component => {
935
+ if (component.state._consumer.componentMap?.rootDir) {
936
+ await this.dependencyResolver.addDependenciesGraph(component, component.state._consumer.componentMap.rootDir, options);
937
+ }
938
+ }));
939
+ this.logger.profile('snap._addDependenciesGraphToComponents');
940
+ }
912
941
  async throwForDepsFromAnotherLane(components) {
913
942
  const lane = await this.scope.legacyScope.getCurrentLaneObject();
914
943
  const allIds = _componentId().ComponentIdList.fromArray(components.map(c => c.id));
@@ -1046,12 +1075,15 @@ another option, in case this dependency is not in main yet is to remove all refe
1046
1075
  });
1047
1076
  }
1048
1077
  _getPublishedPackages(components) {
1049
- const publishedPackages = components.map(comp => {
1078
+ const publishedPackages = new Map();
1079
+ for (const comp of components) {
1050
1080
  const builderExt = comp.extensions.findCoreExtension(_constants().Extensions.builder);
1051
1081
  const pkgData = builderExt?.data?.aspectsData?.find(a => a.aspectId === _constants().Extensions.pkg);
1052
- return pkgData?.data?.publishedPackage;
1053
- });
1054
- return (0, _lodash().compact)(publishedPackages);
1082
+ if (pkgData?.data?.publishedPackage != null) {
1083
+ publishedPackages.set(pkgData.data.publishedPackage, pkgData.data.integrity);
1084
+ }
1085
+ }
1086
+ return publishedPackages;
1055
1087
  }
1056
1088
  async _addCompToObjects({
1057
1089
  source,
@@ -1110,7 +1142,8 @@ another option, in case this dependency is not in main yet is to remove all refe
1110
1142
  const {
1111
1143
  version,
1112
1144
  files,
1113
- flattenedEdges
1145
+ flattenedEdges,
1146
+ dependenciesGraph
1114
1147
  } = await this.scope.legacyScope.sources.consumerComponentToVersion(source);
1115
1148
  version.origin = {
1116
1149
  id: {
@@ -1125,6 +1158,7 @@ another option, in case this dependency is not in main yet is to remove all refe
1125
1158
  };
1126
1159
  objectRepo.add(version);
1127
1160
  if (flattenedEdges) this.objectsRepo.add(flattenedEdges);
1161
+ if (dependenciesGraph) this.objectsRepo.add(dependenciesGraph);
1128
1162
  if (!source.version) throw new Error(`addSource expects source.version to be set`);
1129
1163
  component.addVersion(version, source.version, lane, source.previouslyUsedVersion, updateDependentsOnLane);
1130
1164
  objectRepo.add(component);
@@ -1152,7 +1186,11 @@ another option, in case this dependency is not in main yet is to remove all refe
1152
1186
  version.extensions = consumerComponent.extensions;
1153
1187
  version.buildStatus = consumerComponent.buildStatus;
1154
1188
  const artifactObjects = artifacts.map(file => file.source);
1155
- return [version, ...artifactObjects];
1189
+ const dependenciesGraph = _version().default.dependenciesGraphToSource(consumerComponent.dependenciesGraph);
1190
+ version.dependenciesGraphRef = dependenciesGraph ? dependenciesGraph.hash() : undefined;
1191
+ const result = [version, ...artifactObjects];
1192
+ if (dependenciesGraph) result.push(dependenciesGraph);
1193
+ return result;
1156
1194
  }
1157
1195
  transformArtifactsFromVinylToSource(artifactsFiles) {
1158
1196
  const artifacts = [];