@teambit/snapping 0.0.196 → 0.0.198

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.
@@ -1,434 +1,302 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.flat.js");
6
-
7
5
  require("core-js/modules/es.array.iterator.js");
8
-
9
6
  require("core-js/modules/es.array.unscopables.flat.js");
10
-
11
7
  require("core-js/modules/es.promise.js");
12
-
13
8
  require("core-js/modules/es.regexp.exec.js");
14
-
15
9
  require("core-js/modules/es.string.trim.js");
16
-
17
10
  Object.defineProperty(exports, "__esModule", {
18
11
  value: true
19
12
  });
20
13
  exports.default = exports.SnappingMain = void 0;
21
-
22
14
  function _defineProperty2() {
23
15
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
24
-
25
16
  _defineProperty2 = function () {
26
17
  return data;
27
18
  };
28
-
29
19
  return data;
30
20
  }
31
-
32
21
  function _cli() {
33
22
  const data = require("@teambit/cli");
34
-
35
23
  _cli = function () {
36
24
  return data;
37
25
  };
38
-
39
26
  return data;
40
27
  }
41
-
42
28
  function _featureToggle() {
43
29
  const data = require("@teambit/legacy/dist/api/consumer/lib/feature-toggle");
44
-
45
30
  _featureToggle = function () {
46
31
  return data;
47
32
  };
48
-
49
33
  return data;
50
34
  }
51
-
52
35
  function _getFlattenedDependencies() {
53
36
  const data = require("@teambit/legacy/dist/scope/component-ops/get-flattened-dependencies");
54
-
55
37
  _getFlattenedDependencies = function () {
56
38
  return data;
57
39
  };
58
-
59
40
  return data;
60
41
  }
61
-
62
42
  function _community() {
63
43
  const data = _interopRequireDefault(require("@teambit/community"));
64
-
65
44
  _community = function () {
66
45
  return data;
67
46
  };
68
-
69
47
  return data;
70
48
  }
71
-
72
49
  function _workspace() {
73
50
  const data = _interopRequireDefault(require("@teambit/workspace"));
74
-
75
51
  _workspace = function () {
76
52
  return data;
77
53
  };
78
-
79
54
  return data;
80
55
  }
81
-
82
56
  function _ramda() {
83
57
  const data = _interopRequireDefault(require("ramda"));
84
-
85
58
  _ramda = function () {
86
59
  return data;
87
60
  };
88
-
89
61
  return data;
90
62
  }
91
-
92
63
  function _semver() {
93
64
  const data = _interopRequireDefault(require("semver"));
94
-
95
65
  _semver = function () {
96
66
  return data;
97
67
  };
98
-
99
68
  return data;
100
69
  }
101
-
102
70
  function _lodash() {
103
71
  const data = require("lodash");
104
-
105
72
  _lodash = function () {
106
73
  return data;
107
74
  };
108
-
109
75
  return data;
110
76
  }
111
-
112
77
  function _analytics() {
113
78
  const data = require("@teambit/legacy/dist/analytics/analytics");
114
-
115
79
  _analytics = function () {
116
80
  return data;
117
81
  };
118
-
119
82
  return data;
120
83
  }
121
-
122
84
  function _bitId() {
123
85
  const data = require("@teambit/legacy/dist/bit-id");
124
-
125
86
  _bitId = function () {
126
87
  return data;
127
88
  };
128
-
129
89
  return data;
130
90
  }
131
-
132
91
  function _constants() {
133
92
  const data = require("@teambit/legacy/dist/constants");
134
-
135
93
  _constants = function () {
136
94
  return data;
137
95
  };
138
-
139
96
  return data;
140
97
  }
141
-
142
98
  function _componentsList() {
143
99
  const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component/components-list"));
144
-
145
100
  _componentsList = function () {
146
101
  return data;
147
102
  };
148
-
149
103
  return data;
150
104
  }
151
-
152
105
  function _hooks() {
153
106
  const data = _interopRequireDefault(require("@teambit/legacy/dist/hooks"));
154
-
155
107
  _hooks = function () {
156
108
  return data;
157
109
  };
158
-
159
110
  return data;
160
111
  }
161
-
162
112
  function _pMapSeries() {
163
113
  const data = _interopRequireDefault(require("p-map-series"));
164
-
165
114
  _pMapSeries = function () {
166
115
  return data;
167
116
  };
168
-
169
117
  return data;
170
118
  }
171
-
172
119
  function _hasWildcard() {
173
120
  const data = _interopRequireDefault(require("@teambit/legacy/dist/utils/string/has-wildcard"));
174
-
175
121
  _hasWildcard = function () {
176
122
  return data;
177
123
  };
178
-
179
124
  return data;
180
125
  }
181
-
182
126
  function _semverHelper() {
183
127
  const data = require("@teambit/legacy/dist/utils/semver-helper");
184
-
185
128
  _semverHelper = function () {
186
129
  return data;
187
130
  };
188
-
189
131
  return data;
190
132
  }
191
-
192
133
  function _exceptions() {
193
134
  const data = require("@teambit/legacy/dist/consumer/exceptions");
194
-
195
135
  _exceptions = function () {
196
136
  return data;
197
137
  };
198
-
199
138
  return data;
200
139
  }
201
-
202
140
  function _loader() {
203
141
  const data = _interopRequireDefault(require("@teambit/legacy/dist/cli/loader"));
204
-
205
142
  _loader = function () {
206
143
  return data;
207
144
  };
208
-
209
145
  return data;
210
146
  }
211
-
212
147
  function _componentsPendingImport() {
213
148
  const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component-ops/exceptions/components-pending-import"));
214
-
215
149
  _componentsPendingImport = function () {
216
150
  return data;
217
151
  };
218
-
219
152
  return data;
220
153
  }
221
-
222
154
  function _logger() {
223
155
  const data = require("@teambit/logger");
224
-
225
156
  _logger = function () {
226
157
  return data;
227
158
  };
228
-
229
159
  return data;
230
160
  }
231
-
232
161
  function _bitError() {
233
162
  const data = require("@teambit/bit-error");
234
-
235
163
  _bitError = function () {
236
164
  return data;
237
165
  };
238
-
239
166
  return data;
240
167
  }
241
-
242
168
  function _pMap() {
243
169
  const data = _interopRequireDefault(require("p-map"));
244
-
245
170
  _pMap = function () {
246
171
  return data;
247
172
  };
248
-
249
173
  return data;
250
174
  }
251
-
252
175
  function _insights() {
253
176
  const data = require("@teambit/insights");
254
-
255
177
  _insights = function () {
256
178
  return data;
257
179
  };
258
-
259
180
  return data;
260
181
  }
261
-
262
182
  function _concurrency() {
263
183
  const data = require("@teambit/legacy/dist/utils/concurrency");
264
-
265
184
  _concurrency = function () {
266
185
  return data;
267
186
  };
268
-
269
187
  return data;
270
188
  }
271
-
272
189
  function _untagComponent() {
273
190
  const data = require("@teambit/legacy/dist/scope/component-ops/untag-component");
274
-
275
191
  _untagComponent = function () {
276
192
  return data;
277
193
  };
278
-
279
194
  return data;
280
195
  }
281
-
282
196
  function _scope() {
283
197
  const data = require("@teambit/scope");
284
-
285
198
  _scope = function () {
286
199
  return data;
287
200
  };
288
-
289
201
  return data;
290
202
  }
291
-
292
203
  function _issues() {
293
204
  const data = _interopRequireDefault(require("@teambit/issues"));
294
-
295
205
  _issues = function () {
296
206
  return data;
297
207
  };
298
-
299
208
  return data;
300
209
  }
301
-
302
210
  function _dependencyResolver() {
303
211
  const data = require("@teambit/dependency-resolver");
304
-
305
212
  _dependencyResolver = function () {
306
213
  return data;
307
214
  };
308
-
309
215
  return data;
310
216
  }
311
-
312
217
  function _builder() {
313
218
  const data = require("@teambit/builder");
314
-
315
219
  _builder = function () {
316
220
  return data;
317
221
  };
318
-
319
222
  return data;
320
223
  }
321
-
322
224
  function _export() {
323
225
  const data = require("@teambit/export");
324
-
325
226
  _export = function () {
326
227
  return data;
327
228
  };
328
-
329
229
  return data;
330
230
  }
331
-
332
231
  function _unmergedComponents() {
333
232
  const data = _interopRequireDefault(require("@teambit/legacy/dist/scope/lanes/unmerged-components"));
334
-
335
233
  _unmergedComponents = function () {
336
234
  return data;
337
235
  };
338
-
339
236
  return data;
340
237
  }
341
-
342
238
  function _artifactFiles() {
343
239
  const data = require("@teambit/legacy/dist/consumer/component/sources/artifact-files");
344
-
345
240
  _artifactFiles = function () {
346
241
  return data;
347
242
  };
348
-
349
243
  return data;
350
244
  }
351
-
352
245
  function _snapCmd() {
353
246
  const data = require("./snap-cmd");
354
-
355
247
  _snapCmd = function () {
356
248
  return data;
357
249
  };
358
-
359
250
  return data;
360
251
  }
361
-
362
252
  function _snapping() {
363
253
  const data = require("./snapping.aspect");
364
-
365
254
  _snapping = function () {
366
255
  return data;
367
256
  };
368
-
369
257
  return data;
370
258
  }
371
-
372
259
  function _tagCmd() {
373
260
  const data = require("./tag-cmd");
374
-
375
261
  _tagCmd = function () {
376
262
  return data;
377
263
  };
378
-
379
264
  return data;
380
265
  }
381
-
382
266
  function _componentsHaveIssues() {
383
267
  const data = require("./components-have-issues");
384
-
385
268
  _componentsHaveIssues = function () {
386
269
  return data;
387
270
  };
388
-
389
271
  return data;
390
272
  }
391
-
392
273
  function _resetCmd() {
393
274
  const data = _interopRequireDefault(require("./reset-cmd"));
394
-
395
275
  _resetCmd = function () {
396
276
  return data;
397
277
  };
398
-
399
278
  return data;
400
279
  }
401
-
402
280
  function _tagModelComponent() {
403
281
  const data = require("./tag-model-component");
404
-
405
282
  _tagModelComponent = function () {
406
283
  return data;
407
284
  };
408
-
409
285
  return data;
410
286
  }
411
-
412
287
  function _tagFromScope() {
413
288
  const data = require("./tag-from-scope.cmd");
414
-
415
289
  _tagFromScope = function () {
416
290
  return data;
417
291
  };
418
-
419
292
  return data;
420
293
  }
421
-
422
294
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
423
-
424
295
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
425
-
426
296
  const HooksManagerInstance = _hooks().default.getInstance();
427
-
428
297
  class SnappingMain {
429
298
  constructor(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder) {
430
299
  var _this$scope, _this$scope$legacySco;
431
-
432
300
  this.workspace = workspace;
433
301
  this.logger = logger;
434
302
  this.issues = issues;
@@ -440,6 +308,7 @@ class SnappingMain {
440
308
  (0, _defineProperty2().default)(this, "objectsRepo", void 0);
441
309
  this.objectsRepo = (_this$scope = this.scope) === null || _this$scope === void 0 ? void 0 : (_this$scope$legacySco = _this$scope.legacyScope) === null || _this$scope$legacySco === void 0 ? void 0 : _this$scope$legacySco.objects;
442
310
  }
311
+
443
312
  /**
444
313
  * tag the given component ids or all modified/new components if "all" param is set.
445
314
  * tag is a similar operation as a snap, which saves the changes into the local scope, but it also creates an alias
@@ -447,8 +316,6 @@ class SnappingMain {
447
316
  * tag can be done only on main, not on a lane.
448
317
  */
449
318
  // eslint-disable-next-line complexity
450
-
451
-
452
319
  async tag({
453
320
  ids = [],
454
321
  message = '',
@@ -472,19 +339,15 @@ class SnappingMain {
472
339
  }) {
473
340
  build = (0, _featureToggle().isFeatureEnabled)(_featureToggle().BUILD_ON_CI) ? Boolean(build) : true;
474
341
  if (soft) build = false;
475
-
476
342
  if (disableTagAndSnapPipelines && forceDeploy) {
477
343
  throw new (_bitError().BitError)('you can use either force-deploy or disable-tag-pipeline, but not both');
478
344
  }
479
-
480
345
  if (editor && persist) {
481
346
  throw new (_bitError().BitError)('you can use either --editor or --persist, but not both');
482
347
  }
483
-
484
348
  if (editor && message) {
485
349
  throw new (_bitError().BitError)('you can use either --editor or --message, but not both');
486
350
  }
487
-
488
351
  const exactVersion = version;
489
352
  if (!this.workspace) throw new (_exceptions().ConsumerNotFound)();
490
353
  const idsHasWildcard = (0, _hasWildcard().default)(ids);
@@ -492,26 +355,19 @@ class SnappingMain {
492
355
  const validExactVersion = (0, _semverHelper().validateVersion)(exactVersion);
493
356
  const consumer = this.workspace.consumer;
494
357
  const componentsList = new (_componentsList().default)(consumer);
495
-
496
358
  _loader().default.start('determine components to tag...');
497
-
498
359
  const newComponents = await componentsList.listNewComponents();
499
360
  const {
500
361
  bitIds,
501
362
  warnings
502
363
  } = await this.getComponentsToTag(unmodified, exactVersion, persist, ids, snapped, unmerged);
503
364
  if (_ramda().default.isEmpty(bitIds)) return null;
504
-
505
365
  const legacyBitIds = _bitId().BitIds.fromArray(bitIds);
506
-
507
366
  this.logger.debug(`tagging the following components: ${legacyBitIds.toString()}`);
508
-
509
367
  _analytics().Analytics.addBreadCrumb('tag', `tagging the following components: ${_analytics().Analytics.hashData(legacyBitIds)}`);
510
-
511
368
  if (!soft) {
512
369
  await this.workspace.consumer.componentFsCache.deleteAllDependenciesDataCache();
513
370
  }
514
-
515
371
  const components = await this.loadComponentsForTag(legacyBitIds);
516
372
  await this.throwForLegacyDependenciesInsideHarmony(components);
517
373
  await this.throwForComponentIssues(components, ignoreIssues);
@@ -549,34 +405,30 @@ class SnappingMain {
549
405
  autoTaggedResults,
550
406
  isSoftTag: soft,
551
407
  publishedPackages
552
- }; // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
553
-
554
- tagResults.warnings = warnings; // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
408
+ };
409
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
410
+ tagResults.warnings = warnings;
555
411
 
412
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
556
413
  tagResults.newComponents = newComponents;
557
414
  const postHook = isAll ? _constants().POST_TAG_ALL_HOOK : _constants().POST_TAG_HOOK;
558
415
  HooksManagerInstance === null || HooksManagerInstance === void 0 ? void 0 : HooksManagerInstance.triggerHook(postHook, tagResults);
559
-
560
- _analytics().Analytics.setExtraData('num_components', // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
416
+ _analytics().Analytics.setExtraData('num_components',
417
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
561
418
  _ramda().default.concat(tagResults.taggedComponents, tagResults.autoTaggedResults, tagResults.newComponents).length);
562
-
563
- await consumer.onDestroy(); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
564
-
419
+ await consumer.onDestroy();
420
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
565
421
  return tagResults;
566
422
  }
567
-
568
423
  async tagFromScope(params) {
569
424
  if (this.workspace) {
570
425
  throw new (_bitError().BitError)(`unable to run this command from a workspace, please create a new bare-scope and run it from there`);
571
426
  }
572
-
573
427
  const componentIds = await this.scope.resolveMultipleComponentIds(params.ids);
574
428
  const componentIdsLatest = componentIds.map(id => id.changeVersion(_constants().LATEST));
575
429
  const components = await this.scope.import(componentIdsLatest);
576
430
  const consumerComponents = components.map(c => c.state._consumer);
577
-
578
431
  const legacyIds = _bitId().BitIds.fromArray(componentIds.map(id => id._legacy));
579
-
580
432
  const results = await (0, _tagModelComponent().tagModelComponent)(_objectSpread(_objectSpread({}, params), {}, {
581
433
  scope: this.scope,
582
434
  consumerComponents,
@@ -593,7 +445,6 @@ class SnappingMain {
593
445
  autoTaggedResults,
594
446
  publishedPackages
595
447
  } = results;
596
-
597
448
  if (params.push) {
598
449
  await this.exporter.exportMany({
599
450
  scope: this.scope.legacyScope,
@@ -602,7 +453,6 @@ class SnappingMain {
602
453
  allVersions: false
603
454
  });
604
455
  }
605
-
606
456
  return {
607
457
  taggedComponents,
608
458
  autoTaggedResults,
@@ -612,12 +462,11 @@ class SnappingMain {
612
462
  newComponents: new (_bitId().BitIds)()
613
463
  };
614
464
  }
465
+
615
466
  /**
616
467
  * save the local changes of a component(s) into the scope. snap can be done on main or on a lane.
617
468
  * once a component is snapped on a lane, it becomes part of it.
618
469
  */
619
-
620
-
621
470
  async snap({
622
471
  pattern,
623
472
  legacyBitIds,
@@ -667,8 +516,8 @@ class SnappingMain {
667
516
  forceDeploy,
668
517
  packageManagerConfigRootDir: this.workspace.path,
669
518
  dependencyResolver: this.dependencyResolver
670
- }); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
671
-
519
+ });
520
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
672
521
  const snapResults = {
673
522
  snappedComponents: taggedComponents,
674
523
  autoSnappedResults: autoTaggedResults
@@ -676,76 +525,60 @@ class SnappingMain {
676
525
  snapResults.newComponents = newComponents;
677
526
  const currentLane = consumer.getCurrentLaneId();
678
527
  snapResults.laneName = currentLane.isDefault() ? null : currentLane.name;
679
- await consumer.onDestroy(); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
680
-
528
+ await consumer.onDestroy();
529
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
681
530
  return snapResults;
682
-
683
531
  async function getIdsToSnap(workspace) {
684
532
  if (unmerged) {
685
533
  return componentsList.listDuringMergeStateComponents();
686
534
  }
687
-
688
535
  const tagPendingComponents = unmodified ? await componentsList.listPotentialTagAllWorkspace() : await componentsList.listTagPendingComponents();
689
536
  if (_ramda().default.isEmpty(tagPendingComponents)) return null;
690
- const tagPendingComponentsIds = await workspace.resolveMultipleComponentIds(tagPendingComponents); // when unmodified, we ask for all components, throw if no matching. if not unmodified and no matching, see error
537
+ const tagPendingComponentsIds = await workspace.resolveMultipleComponentIds(tagPendingComponents);
538
+ // when unmodified, we ask for all components, throw if no matching. if not unmodified and no matching, see error
691
539
  // below, suggesting to use --unmodified flag.
692
-
693
540
  const shouldThrowForNoMatching = unmodified;
694
-
695
541
  const getCompIds = async () => {
696
542
  if (!pattern) return tagPendingComponentsIds;
697
-
698
543
  if (!pattern.includes('*') && !pattern.includes(',')) {
699
544
  const compId = await workspace.resolveComponentId(pattern);
700
545
  return [compId];
701
546
  }
702
-
703
547
  return workspace.scope.filterIdsFromPoolIdsByPattern(pattern, tagPendingComponentsIds, shouldThrowForNoMatching);
704
548
  };
705
-
706
549
  const componentIds = await getCompIds();
707
-
708
550
  if (!componentIds.length && pattern) {
709
551
  const allTagPending = await componentsList.listPotentialTagAllWorkspace();
710
-
711
552
  if (allTagPending.length) {
712
553
  throw new (_bitError().BitError)(`unable to find matching for "${pattern}" pattern among modified/new components.
713
554
  there are matching among unmodified components thought. consider using --unmodified flag if needed`);
714
555
  }
715
556
  }
716
-
717
557
  if (!componentIds.length) {
718
558
  return null;
719
559
  }
720
-
721
560
  return _bitId().BitIds.fromArray(componentIds.map(c => c._legacy));
722
561
  }
723
562
  }
563
+
724
564
  /**
725
565
  * remove tags/snaps that exist locally, which were not exported yet.
726
566
  * once a tag/snap is exported, it's impossible to delete it as other components may depend on it
727
567
  */
728
-
729
-
730
568
  async reset(componentPattern, head, force = false, soft = false) {
731
569
  if (!this.workspace) throw new (_exceptions().ConsumerNotFound)();
732
570
  const consumer = this.workspace.consumer;
733
571
  const currentLane = await consumer.getCurrentLaneObject();
734
-
735
572
  const untag = async () => {
736
573
  if (!componentPattern) {
737
574
  return (0, _untagComponent().removeLocalVersionsForAllComponents)(consumer, currentLane, head);
738
575
  }
739
-
740
576
  const candidateComponents = await (0, _untagComponent().getComponentsWithOptionToUntag)(consumer);
741
577
  const idsMatchingPattern = await this.workspace.idsByPattern(componentPattern);
742
-
743
578
  const idsMatchingPatternBitIds = _bitId().BitIds.fromArray(idsMatchingPattern.map(id => id._legacy));
744
-
745
579
  const componentsToUntag = candidateComponents.filter(modelComponent => idsMatchingPatternBitIds.hasWithoutVersion(modelComponent.toBitId()));
746
580
  return (0, _untagComponent().removeLocalVersionsForMultipleComponents)(componentsToUntag, currentLane, head, force, consumer.scope);
747
581
  };
748
-
749
582
  const softUntag = async () => {
750
583
  const componentsList = new (_componentsList().default)(consumer);
751
584
  const softTaggedComponents = componentsList.listSoftTaggedComponents();
@@ -753,7 +586,6 @@ there are matching among unmodified components thought. consider using --unmodif
753
586
  const idsToRemoveSoftTags = componentPattern ? this.workspace.scope.filterIdsFromPoolIdsByPattern(componentPattern, softTaggedComponentsIds) : softTaggedComponentsIds;
754
587
  return (0, _lodash().compact)(idsToRemoveSoftTags.map(componentId => {
755
588
  var _componentMap$nextVer;
756
-
757
589
  const componentMap = consumer.bitMap.getComponent(componentId._legacy, {
758
590
  ignoreScopeAndVersion: true
759
591
  });
@@ -766,10 +598,8 @@ there are matching among unmodified components thought. consider using --unmodif
766
598
  };
767
599
  }));
768
600
  };
769
-
770
601
  let results;
771
602
  const isRealUntag = !soft;
772
-
773
603
  if (isRealUntag) {
774
604
  results = await untag();
775
605
  await consumer.scope.objects.persist();
@@ -779,45 +609,36 @@ there are matching among unmodified components thought. consider using --unmodif
779
609
  results = await softUntag();
780
610
  consumer.bitMap.markAsChanged();
781
611
  }
782
-
783
612
  await consumer.onDestroy();
784
613
  return {
785
614
  results,
786
615
  isSoftUntag: !isRealUntag
787
616
  };
788
617
  }
789
-
790
618
  async _addFlattenedDependenciesToComponents(scope, components) {
791
619
  _loader().default.start('importing missing dependencies...');
792
-
793
620
  const flattenedDependenciesGetter = new (_getFlattenedDependencies().FlattenedDependenciesGetter)(scope, components);
794
621
  await flattenedDependenciesGetter.populateFlattenedDependencies();
795
-
796
622
  _loader().default.stop();
797
623
  }
798
-
799
624
  _updateComponentsByTagResult(components, tagResult) {
800
625
  tagResult.forEach(result => {
801
626
  const matchingComponent = components.find(c => c.id.isEqual(result.id));
802
-
803
627
  if (matchingComponent) {
804
628
  const existingBuilder = matchingComponent.extensions.findCoreExtension(_constants().Extensions.builder);
805
629
  if (existingBuilder) existingBuilder.data = result.builderData.data;else matchingComponent.extensions.push(result.builderData);
806
630
  }
807
631
  });
808
632
  }
809
-
810
633
  _getPublishedPackages(components) {
811
634
  const publishedPackages = components.map(comp => {
812
635
  var _builderExt$data, _builderExt$data$aspe, _pkgData$data;
813
-
814
636
  const builderExt = comp.extensions.findCoreExtension(_constants().Extensions.builder);
815
637
  const pkgData = builderExt === null || builderExt === void 0 ? void 0 : (_builderExt$data = builderExt.data) === null || _builderExt$data === void 0 ? void 0 : (_builderExt$data$aspe = _builderExt$data.aspectsData) === null || _builderExt$data$aspe === void 0 ? void 0 : _builderExt$data$aspe.find(a => a.aspectId === _constants().Extensions.pkg);
816
638
  return pkgData === null || pkgData === void 0 ? void 0 : (_pkgData$data = pkgData.data) === null || _pkgData$data === void 0 ? void 0 : _pkgData$data.publishedPackage;
817
639
  });
818
640
  return (0, _lodash().compact)(publishedPackages);
819
641
  }
820
-
821
642
  async _addCompToObjects({
822
643
  source,
823
644
  consumer,
@@ -837,7 +658,6 @@ there are matching among unmodified components thought. consider using --unmodif
837
658
  if (!source.version) throw new Error(`addSource expects source.version to be set`);
838
659
  component.addVersion(version, source.version, lane, this.objectsRepo);
839
660
  const unmergedComponent = consumer.scope.objects.unmergedComponents.getEntry(component.name);
840
-
841
661
  if (unmergedComponent) {
842
662
  if (unmergedComponent.unrelated) {
843
663
  this.logger.debug(`sources.addSource, unmerged component "${component.name}". adding an unrelated entry ${unmergedComponent.head.hash}`);
@@ -850,20 +670,17 @@ there are matching among unmodified components thought. consider using --unmodif
850
670
  this.logger.debug(`sources.addSource, unmerged component "${component.name}". adding a parent ${unmergedComponent.head.hash}`);
851
671
  version.log.message = version.log.message || _unmergedComponents().default.buildSnapMessage(unmergedComponent);
852
672
  }
853
-
854
673
  consumer.scope.objects.unmergedComponents.removeComponent(component.name);
855
674
  }
856
-
857
675
  this.objectsRepo.add(component);
858
676
  files.forEach(file => this.objectsRepo.add(file.file));
859
677
  if (artifacts) artifacts.forEach(file => this.objectsRepo.add(file.source));
860
678
  if (shouldValidateVersion) version.validate();
861
679
  return component;
862
680
  }
863
-
864
681
  async _addCompFromScopeToObjects(source, lane) {
865
- const objectRepo = this.objectsRepo; // if a component exists in the model, add a new version. Otherwise, create a new component on the model
866
-
682
+ const objectRepo = this.objectsRepo;
683
+ // if a component exists in the model, add a new version. Otherwise, create a new component on the model
867
684
  const component = await this.scope.legacyScope.sources.findOrAddComponent(source);
868
685
  const artifactFiles = (0, _artifactFiles().getArtifactsFiles)(source.extensions);
869
686
  const artifacts = this.transformArtifactsFromVinylToSource(artifactFiles);
@@ -879,13 +696,11 @@ there are matching among unmodified components thought. consider using --unmodif
879
696
  if (artifacts) artifacts.forEach(file => objectRepo.add(file.source));
880
697
  return component;
881
698
  }
882
-
883
699
  async _enrichComp(consumerComponent) {
884
700
  const objects = await this._getObjectsToEnrichComp(consumerComponent);
885
701
  objects.forEach(obj => this.objectsRepo.add(obj));
886
702
  return consumerComponent;
887
703
  }
888
-
889
704
  async _getObjectsToEnrichComp(consumerComponent) {
890
705
  const component = consumerComponent.modelComponent || (await this.scope.legacyScope.sources.findOrAddComponent(consumerComponent));
891
706
  const version = await component.loadVersion(consumerComponent.id.version, this.objectsRepo, true, true);
@@ -896,18 +711,15 @@ there are matching among unmodified components thought. consider using --unmodif
896
711
  const artifactObjects = artifacts.map(file => file.source);
897
712
  return [version, ...artifactObjects];
898
713
  }
899
-
900
714
  transformArtifactsFromVinylToSource(artifactsFiles) {
901
715
  const artifacts = [];
902
716
  artifactsFiles.forEach(artifactFiles => {
903
717
  const artifactsSource = _artifactFiles().ArtifactFiles.fromVinylsToSources(artifactFiles.vinyls);
904
-
905
718
  if (artifactsSource.length) artifactFiles.populateRefsFromSources(artifactsSource);
906
719
  artifacts.push(...artifactsSource);
907
720
  });
908
721
  return artifacts;
909
722
  }
910
-
911
723
  async loadComponentsForTag(ids) {
912
724
  const {
913
725
  components,
@@ -915,20 +727,17 @@ there are matching among unmodified components thought. consider using --unmodif
915
727
  } = await this.workspace.consumer.loadComponents(ids.toVersionLatest());
916
728
  components.forEach(component => {
917
729
  const componentMap = component.componentMap;
918
-
919
730
  if (!componentMap.rootDir) {
920
731
  throw new Error(`unable to tag ${component.id.toString()}, the "rootDir" is missing in the .bitmap file`);
921
732
  }
922
733
  });
923
734
  return [...components, ...removedComponents];
924
735
  }
925
-
926
736
  async throwForComponentIssues(legacyComponents, ignoreIssues) {
927
737
  if (ignoreIssues === '*') {
928
738
  // ignore all issues
929
739
  return;
930
740
  }
931
-
932
741
  const issuesToIgnoreFromFlag = (ignoreIssues === null || ignoreIssues === void 0 ? void 0 : ignoreIssues.split(',').map(issue => issue.trim())) || [];
933
742
  const issuesToIgnoreFromConfig = this.issues.getIssuesToIgnoreGlobally();
934
743
  const issuesToIgnore = [...issuesToIgnoreFromFlag, ...issuesToIgnoreFromConfig];
@@ -937,23 +746,18 @@ there are matching among unmodified components thought. consider using --unmodif
937
746
  this.issues.removeIgnoredIssuesFromComponents(components);
938
747
  const componentsWithBlockingIssues = legacyComponents.filter(component => {
939
748
  var _component$issues;
940
-
941
749
  return (_component$issues = component.issues) === null || _component$issues === void 0 ? void 0 : _component$issues.shouldBlockTagging();
942
750
  });
943
-
944
751
  if (!_ramda().default.isEmpty(componentsWithBlockingIssues)) {
945
752
  throw new (_componentsHaveIssues().ComponentsHaveIssues)(componentsWithBlockingIssues);
946
753
  }
947
754
  }
948
-
949
755
  throwForPendingImport(components) {
950
756
  const areComponentsMissingFromScope = components.filter(c => !c.removed).some(c => !c.componentFromModel && c.id.hasScope());
951
-
952
757
  if (areComponentsMissingFromScope) {
953
758
  throw new (_componentsPendingImport().default)();
954
759
  }
955
760
  }
956
-
957
761
  async throwForLegacyDependenciesInsideHarmony(components) {
958
762
  const throwForComponent = async component => {
959
763
  const dependenciesIds = component.getAllDependenciesIds();
@@ -963,22 +767,18 @@ there are matching among unmodified components thought. consider using --unmodif
963
767
  const modelComp = await legacyScope.getModelComponentIfExist(depId);
964
768
  if (!modelComp) return;
965
769
  const version = await modelComp.loadVersion(depId.version, legacyScope.objects);
966
-
967
770
  if (version.isLegacy) {
968
771
  throw new Error(`unable tagging "${component.id.toString()}", its dependency "${depId.toString()}" is legacy`);
969
772
  }
970
773
  }));
971
774
  };
972
-
973
775
  await (0, _pMap().default)(components, component => throwForComponent(component), {
974
776
  concurrency: (0, _concurrency().concurrentComponentsLimit)()
975
777
  });
976
778
  }
977
-
978
779
  async getComponentsToTag(includeUnmodified, exactVersion, persist, ids, snapped, unmerged) {
979
780
  const warnings = [];
980
781
  const componentsList = new (_componentsList().default)(this.workspace.consumer);
981
-
982
782
  if (persist) {
983
783
  const softTaggedComponents = componentsList.listSoftTaggedComponents();
984
784
  return {
@@ -986,29 +786,23 @@ there are matching among unmodified components thought. consider using --unmodif
986
786
  warnings: []
987
787
  };
988
788
  }
989
-
990
789
  const tagPendingBitIds = includeUnmodified ? await componentsList.listPotentialTagAllWorkspace() : await componentsList.listTagPendingComponents();
991
790
  const tagPendingComponentsIds = await this.workspace.resolveMultipleComponentIds(tagPendingBitIds);
992
791
  const snappedComponents = await componentsList.listSnappedComponentsOnMain();
993
792
  const snappedComponentsIds = snappedComponents.map(c => c.toBitId());
994
-
995
793
  if (ids.length) {
996
794
  const componentIds = await (0, _pMapSeries().default)(ids, async id => {
997
795
  const [idWithoutVer, version] = id.split('@');
998
796
  const idHasWildcard = (0, _hasWildcard().default)(id);
999
-
1000
797
  if (idHasWildcard) {
1001
798
  const allIds = this.workspace.scope.filterIdsFromPoolIdsByPattern(idWithoutVer, tagPendingComponentsIds);
1002
799
  return allIds.map(componentId => componentId.changeVersion(version));
1003
800
  }
1004
-
1005
801
  const componentId = await this.workspace.resolveComponentId(idWithoutVer);
1006
-
1007
802
  if (!includeUnmodified) {
1008
803
  const componentStatus = await this.workspace.consumer.getComponentStatusById(componentId._legacy);
1009
804
  if (componentStatus.modified === false) return null;
1010
805
  }
1011
-
1012
806
  return componentId.changeVersion(version);
1013
807
  });
1014
808
  return {
@@ -1016,23 +810,19 @@ there are matching among unmodified components thought. consider using --unmodif
1016
810
  warnings
1017
811
  };
1018
812
  }
1019
-
1020
813
  if (snapped) {
1021
814
  return {
1022
815
  bitIds: snappedComponentsIds,
1023
816
  warnings
1024
817
  };
1025
818
  }
1026
-
1027
819
  if (unmerged) {
1028
820
  return {
1029
821
  bitIds: componentsList.listDuringMergeStateComponents(),
1030
822
  warnings
1031
823
  };
1032
824
  }
1033
-
1034
825
  const tagPendingBitIdsIncludeSnapped = [...tagPendingBitIds, ...snappedComponentsIds];
1035
-
1036
826
  if (includeUnmodified && exactVersion) {
1037
827
  const tagPendingComponentsLatest = await this.workspace.scope.legacyScope.latestVersions(tagPendingBitIds, false);
1038
828
  tagPendingComponentsLatest.forEach(componentId => {
@@ -1041,13 +831,11 @@ there are matching among unmodified components thought. consider using --unmodif
1041
831
  }
1042
832
  });
1043
833
  }
1044
-
1045
834
  return {
1046
835
  bitIds: tagPendingBitIdsIncludeSnapped.map(id => id.changeVersion(undefined)),
1047
836
  warnings
1048
837
  };
1049
838
  }
1050
-
1051
839
  static async provider([workspace, cli, community, loggerMain, issues, insights, dependencyResolver, scope, exporter, builder]) {
1052
840
  const logger = loggerMain.createLogger(_snapping().SnappingAspect.id);
1053
841
  const snapping = new SnappingMain(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder);
@@ -1058,16 +846,12 @@ there are matching among unmodified components thought. consider using --unmodif
1058
846
  cli.register(tagCmd, snapCmd, resetCmd, tagFromScopeCmd);
1059
847
  return snapping;
1060
848
  }
1061
-
1062
849
  }
1063
-
1064
850
  exports.SnappingMain = SnappingMain;
1065
851
  (0, _defineProperty2().default)(SnappingMain, "slots", []);
1066
852
  (0, _defineProperty2().default)(SnappingMain, "dependencies", [_workspace().default, _cli().CLIAspect, _community().default, _logger().LoggerAspect, _issues().default, _insights().InsightsAspect, _dependencyResolver().DependencyResolverAspect, _scope().ScopeAspect, _export().ExportAspect, _builder().BuilderAspect]);
1067
853
  (0, _defineProperty2().default)(SnappingMain, "runtime", _cli().MainRuntime);
1068
-
1069
854
  _snapping().SnappingAspect.addRuntime(SnappingMain);
1070
-
1071
855
  var _default = SnappingMain;
1072
856
  exports.default = _default;
1073
857