@teambit/snapping 1.0.337 → 1.0.338

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.
@@ -23,6 +23,7 @@ import { BasicTagParams, BasicTagSnapParams } from './tag-model-component';
23
23
  import { TagDataPerCompRaw } from './tag-from-scope.cmd';
24
24
  import { SnapDataPerCompRaw, FileData } from './snap-from-scope.cmd';
25
25
  import { untagResult } from './reset-component';
26
+ import { ApplicationMain } from '@teambit/application';
26
27
  export type TagDataPerComp = {
27
28
  componentId: ComponentID;
28
29
  dependencies: ComponentID[];
@@ -78,8 +79,9 @@ export declare class SnappingMain {
78
79
  private builder;
79
80
  private importer;
80
81
  private deps;
82
+ private application;
81
83
  private objectsRepo;
82
- constructor(workspace: Workspace, logger: Logger, issues: IssuesMain, insights: InsightsMain, dependencyResolver: DependencyResolverMain, scope: ScopeMain, exporter: ExportMain, builder: BuilderMain, importer: ImporterMain, deps: DependenciesMain);
84
+ constructor(workspace: Workspace, logger: Logger, issues: IssuesMain, insights: InsightsMain, dependencyResolver: DependencyResolverMain, scope: ScopeMain, exporter: ExportMain, builder: BuilderMain, importer: ImporterMain, deps: DependenciesMain, application: ApplicationMain);
83
85
  /**
84
86
  * tag the given component ids or all modified/new components if "all" param is set.
85
87
  * tag is a similar operation as a snap, which saves the changes into the local scope, but it also creates an alias
@@ -182,7 +184,7 @@ export declare class SnappingMain {
182
184
  static slots: never[];
183
185
  static dependencies: import("@teambit/harmony").Aspect[];
184
186
  static runtime: import("@teambit/harmony").RuntimeDefinition;
185
- static provider([workspace, cli, loggerMain, issues, insights, dependencyResolver, scope, exporter, builder, importer, globalConfig, deps,]: [
187
+ static provider([workspace, cli, loggerMain, issues, insights, dependencyResolver, scope, exporter, builder, importer, globalConfig, deps, application,]: [
186
188
  Workspace,
187
189
  CLIMain,
188
190
  LoggerMain,
@@ -194,7 +196,8 @@ export declare class SnappingMain {
194
196
  BuilderMain,
195
197
  ImporterMain,
196
198
  GlobalConfigMain,
197
- DependenciesMain
199
+ DependenciesMain,
200
+ ApplicationMain
198
201
  ]): Promise<SnappingMain>;
199
202
  }
200
203
  export default SnappingMain;
@@ -312,6 +312,13 @@ function _resetComponent() {
312
312
  };
313
313
  return data;
314
314
  }
315
+ function _application() {
316
+ const data = require("@teambit/application");
317
+ _application = function () {
318
+ return data;
319
+ };
320
+ return data;
321
+ }
315
322
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
316
323
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
317
324
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -319,7 +326,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
319
326
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
320
327
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
321
328
  class SnappingMain {
322
- constructor(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer, deps) {
329
+ constructor(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer, deps, application) {
323
330
  this.workspace = workspace;
324
331
  this.logger = logger;
325
332
  this.issues = issues;
@@ -330,6 +337,7 @@ class SnappingMain {
330
337
  this.builder = builder;
331
338
  this.importer = importer;
332
339
  this.deps = deps;
340
+ this.application = application;
333
341
  _defineProperty(this, "objectsRepo", void 0);
334
342
  this.objectsRepo = this.scope?.legacyScope?.objects;
335
343
  }
@@ -902,15 +910,18 @@ in case you're unsure about the pattern syntax, use "bit pattern [--help]"`);
902
910
  this.throwForPendingImport(consumerComponents);
903
911
  }
904
912
  async throwForDepsFromAnotherLaneForComp(component, allIds, lane, throwForMissingObjects = false) {
913
+ const depsFromModel = component.componentFromModel?.getAllDependencies();
914
+ const depsFromModelIds = depsFromModel ? _componentId().ComponentIdList.fromArray(depsFromModel.map(d => d.id)) : new (_componentId().ComponentIdList)();
905
915
  const deps = component.getAllDependencies();
906
916
  const missingDeps = [];
907
917
  await Promise.all(deps.map(async dep => {
908
918
  if (!this.scope.isExported(dep.id) || !dep.id.hasVersion()) return;
909
919
  if ((0, _componentVersion().isTag)(dep.id.version)) return;
910
920
  if (allIds.hasWithoutVersion(dep.id)) return; // it's tagged/snapped now.
921
+ if (depsFromModelIds.has(dep.id)) return; // this dep is not new, it was already snapped/tagged with it before.
911
922
  let isPartOfHistory;
912
923
  try {
913
- isPartOfHistory = lane ? (await this.scope.legacyScope.isPartOfLaneHistory(dep.id, lane)) || (await this.scope.legacyScope.isPartOfMainHistory(dep.id)) : await this.scope.legacyScope.isPartOfMainHistory(dep.id);
924
+ isPartOfHistory = lane ? await this.scope.legacyScope.isPartOfLaneHistoryOrMain(dep.id, lane) : await this.scope.legacyScope.isPartOfMainHistory(dep.id);
914
925
  } catch (err) {
915
926
  if (throwForMissingObjects) throw err;
916
927
  if (err instanceof _exceptions().VersionNotFound || err instanceof _exceptions().ComponentNotFound || err instanceof _exceptions().HeadNotFound || err instanceof _exceptions().ParentNotFound) {
@@ -1125,12 +1136,16 @@ another option, in case this dependency is not in main yet is to remove all refe
1125
1136
  return artifacts;
1126
1137
  }
1127
1138
  async loadComponentsForTagOrSnap(ids, shouldClearCacheFirst = true) {
1139
+ const idsWithoutVersions = ids.map(id => id.changeVersion(undefined));
1140
+ const appIds = await this.application.loadAllAppsAsAspects(idsWithoutVersions);
1128
1141
  if (shouldClearCacheFirst) {
1129
1142
  await this.workspace.consumer.componentFsCache.deleteAllDependenciesDataCache();
1130
1143
  // don't clear only the cache of these ids. we need also the auto-tag. so it's safer to just clear all.
1131
1144
  this.workspace.clearAllComponentsCache();
1145
+ } else {
1146
+ appIds.forEach(id => this.workspace.clearComponentCache(id));
1132
1147
  }
1133
- return this.workspace.getMany(ids.map(id => id.changeVersion(undefined)));
1148
+ return this.workspace.getMany(idsWithoutVersions);
1134
1149
  }
1135
1150
  throwForPendingImport(components) {
1136
1151
  const componentsMissingFromScope = components.filter(c => !c.componentFromModel && this.scope.isExported(c.id)).map(c => c.id.toString());
@@ -1313,9 +1328,9 @@ another option, in case this dependency is not in main yet is to remove all refe
1313
1328
  warnings
1314
1329
  };
1315
1330
  }
1316
- static async provider([workspace, cli, loggerMain, issues, insights, dependencyResolver, scope, exporter, builder, importer, globalConfig, deps]) {
1331
+ static async provider([workspace, cli, loggerMain, issues, insights, dependencyResolver, scope, exporter, builder, importer, globalConfig, deps, application]) {
1317
1332
  const logger = loggerMain.createLogger(_snapping().SnappingAspect.id);
1318
- const snapping = new SnappingMain(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer, deps);
1333
+ const snapping = new SnappingMain(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer, deps, application);
1319
1334
  const snapCmd = new (_snapCmd().SnapCmd)(snapping, logger, globalConfig);
1320
1335
  const tagCmd = new (_tagCmd().TagCmd)(snapping, logger, globalConfig);
1321
1336
  const tagFromScopeCmd = new (_tagFromScope().TagFromScopeCmd)(snapping, logger);
@@ -1328,7 +1343,7 @@ another option, in case this dependency is not in main yet is to remove all refe
1328
1343
  }
1329
1344
  exports.SnappingMain = SnappingMain;
1330
1345
  _defineProperty(SnappingMain, "slots", []);
1331
- _defineProperty(SnappingMain, "dependencies", [_workspace().WorkspaceAspect, _cli().CLIAspect, _logger().LoggerAspect, _issues().IssuesAspect, _insights().InsightsAspect, _dependencyResolver().DependencyResolverAspect, _scope().ScopeAspect, _export().ExportAspect, _builder().BuilderAspect, _importer().ImporterAspect, _globalConfig().GlobalConfigAspect, _dependencies().DependenciesAspect]);
1346
+ _defineProperty(SnappingMain, "dependencies", [_workspace().WorkspaceAspect, _cli().CLIAspect, _logger().LoggerAspect, _issues().IssuesAspect, _insights().InsightsAspect, _dependencyResolver().DependencyResolverAspect, _scope().ScopeAspect, _export().ExportAspect, _builder().BuilderAspect, _importer().ImporterAspect, _globalConfig().GlobalConfigAspect, _dependencies().DependenciesAspect, _application().ApplicationAspect]);
1332
1347
  _defineProperty(SnappingMain, "runtime", _cli().MainRuntime);
1333
1348
  _snapping().SnappingAspect.addRuntime(SnappingMain);
1334
1349
  var _default = exports.default = SnappingMain;