@teambit/lanes 0.0.453 → 0.0.455

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,13 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  require("core-js/modules/es.array.iterator.js");
6
-
7
5
  require("core-js/modules/es.promise.js");
8
-
9
6
  require("core-js/modules/es.regexp.exec.js");
10
-
11
7
  Object.defineProperty(exports, "__esModule", {
12
8
  value: true
13
9
  });
@@ -18,281 +14,197 @@ Object.defineProperty(exports, "Lane", {
18
14
  }
19
15
  });
20
16
  exports.default = exports.LanesMain = void 0;
21
-
22
17
  function _defineProperty2() {
23
18
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
24
-
25
19
  _defineProperty2 = function () {
26
20
  return data;
27
21
  };
28
-
29
22
  return data;
30
23
  }
31
-
32
24
  function _cli() {
33
25
  const data = require("@teambit/cli");
34
-
35
26
  _cli = function () {
36
27
  return data;
37
28
  };
38
-
39
29
  return data;
40
30
  }
41
-
42
31
  function _scope() {
43
32
  const data = require("@teambit/scope");
44
-
45
33
  _scope = function () {
46
34
  return data;
47
35
  };
48
-
49
36
  return data;
50
37
  }
51
-
52
38
  function _graphql() {
53
39
  const data = require("@teambit/graphql");
54
-
55
40
  _graphql = function () {
56
41
  return data;
57
42
  };
58
-
59
43
  return data;
60
44
  }
61
-
62
45
  function _workspace() {
63
46
  const data = require("@teambit/workspace");
64
-
65
47
  _workspace = function () {
66
48
  return data;
67
49
  };
68
-
69
50
  return data;
70
51
  }
71
-
72
52
  function _getRemoteByName() {
73
53
  const data = _interopRequireDefault(require("@teambit/legacy/dist/remotes/get-remote-by-name"));
74
-
75
54
  _getRemoteByName = function () {
76
55
  return data;
77
56
  };
78
-
79
57
  return data;
80
58
  }
81
-
82
59
  function _lanesModules() {
83
60
  const data = require("@teambit/lanes.modules.diff");
84
-
85
61
  _lanesModules = function () {
86
62
  return data;
87
63
  };
88
-
89
64
  return data;
90
65
  }
91
-
92
66
  function _laneId() {
93
67
  const data = require("@teambit/lane-id");
94
-
95
68
  _laneId = function () {
96
69
  return data;
97
70
  };
98
-
99
71
  return data;
100
72
  }
101
-
102
73
  function _bitError() {
103
74
  const data = require("@teambit/bit-error");
104
-
105
75
  _bitError = function () {
106
76
  return data;
107
77
  };
108
-
109
78
  return data;
110
79
  }
111
-
112
80
  function _logger() {
113
81
  const data = require("@teambit/logger");
114
-
115
82
  _logger = function () {
116
83
  return data;
117
84
  };
118
-
119
85
  return data;
120
86
  }
121
-
122
87
  function _mergeVersion() {
123
88
  const data = require("@teambit/legacy/dist/consumer/versions-ops/merge-version");
124
-
125
89
  _mergeVersion = function () {
126
90
  return data;
127
91
  };
128
-
129
92
  return data;
130
93
  }
131
-
132
94
  function _importer() {
133
95
  const data = require("@teambit/importer");
134
-
135
96
  _importer = function () {
136
97
  return data;
137
98
  };
138
-
139
99
  return data;
140
100
  }
141
-
142
101
  function _community() {
143
102
  const data = require("@teambit/community");
144
-
145
103
  _community = function () {
146
104
  return data;
147
105
  };
148
-
149
106
  return data;
150
107
  }
151
-
152
108
  function _component() {
153
109
  const data = _interopRequireDefault(require("@teambit/component"));
154
-
155
110
  _component = function () {
156
111
  return data;
157
112
  };
158
-
159
113
  return data;
160
114
  }
161
-
162
115
  function _removeLanes() {
163
116
  const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/lanes/remove-lanes"));
164
-
165
117
  _removeLanes = function () {
166
118
  return data;
167
119
  };
168
-
169
120
  return data;
170
121
  }
171
-
172
122
  function _models() {
173
123
  const data = require("@teambit/legacy/dist/scope/models");
174
-
175
124
  _models = function () {
176
125
  return data;
177
126
  };
178
-
179
127
  return data;
180
128
  }
181
-
182
129
  function _laneNotFound() {
183
130
  const data = require("@teambit/legacy/dist/api/scope/lib/exceptions/lane-not-found");
184
-
185
131
  _laneNotFound = function () {
186
132
  return data;
187
133
  };
188
-
189
134
  return data;
190
135
  }
191
-
192
136
  function _scopeComponentsImporter() {
193
137
  const data = _interopRequireDefault(require("@teambit/legacy/dist/scope/component-ops/scope-components-importer"));
194
-
195
138
  _scopeComponentsImporter = function () {
196
139
  return data;
197
140
  };
198
-
199
141
  return data;
200
142
  }
201
-
202
143
  function _export() {
203
144
  const data = require("@teambit/export");
204
-
205
145
  _export = function () {
206
146
  return data;
207
147
  };
208
-
209
148
  return data;
210
149
  }
211
-
212
150
  function _bitId() {
213
151
  const data = require("@teambit/legacy/dist/bit-id");
214
-
215
152
  _bitId = function () {
216
153
  return data;
217
154
  };
218
-
219
155
  return data;
220
156
  }
221
-
222
157
  function _merging() {
223
158
  const data = require("@teambit/merging");
224
-
225
159
  _merging = function () {
226
160
  return data;
227
161
  };
228
-
229
162
  return data;
230
163
  }
231
-
232
164
  function _lanes() {
233
165
  const data = require("./lanes.aspect");
234
-
235
166
  _lanes = function () {
236
167
  return data;
237
168
  };
238
-
239
169
  return data;
240
170
  }
241
-
242
171
  function _lane() {
243
172
  const data = require("./lane.cmd");
244
-
245
173
  _lane = function () {
246
174
  return data;
247
175
  };
248
-
249
176
  return data;
250
177
  }
251
-
252
178
  function _lanes2() {
253
179
  const data = require("./lanes.graphql");
254
-
255
180
  _lanes2 = function () {
256
181
  return data;
257
182
  };
258
-
259
183
  return data;
260
184
  }
261
-
262
185
  function _switch() {
263
186
  const data = require("./switch.cmd");
264
-
265
187
  _switch = function () {
266
188
  return data;
267
189
  };
268
-
269
190
  return data;
270
191
  }
271
-
272
192
  function _switchLanes() {
273
193
  const data = require("./switch-lanes");
274
-
275
194
  _switchLanes = function () {
276
195
  return data;
277
196
  };
278
-
279
197
  return data;
280
198
  }
281
-
282
199
  function _createLane() {
283
200
  const data = require("./create-lane");
284
-
285
201
  _createLane = function () {
286
202
  return data;
287
203
  };
288
-
289
204
  return data;
290
205
  }
291
-
292
206
  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; }
293
-
294
207
  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; }
295
-
296
208
  class LanesMain {
297
209
  constructor(workspace, scope, merging, componentAspect, logger, importer, exporter) {
298
210
  this.workspace = workspace;
@@ -303,7 +215,6 @@ class LanesMain {
303
215
  this.importer = importer;
304
216
  this.exporter = exporter;
305
217
  }
306
-
307
218
  async getLanes({
308
219
  name,
309
220
  remote,
@@ -312,59 +223,45 @@ class LanesMain {
312
223
  notMerged
313
224
  }) {
314
225
  var _this$workspace;
315
-
316
226
  const showMergeData = Boolean(merged || notMerged);
317
227
  const consumer = (_this$workspace = this.workspace) === null || _this$workspace === void 0 ? void 0 : _this$workspace.consumer;
318
-
319
228
  if (remote) {
320
229
  const remoteObj = await (0, _getRemoteByName().default)(remote, consumer);
321
230
  const lanes = await remoteObj.listLanes(name, showMergeData);
322
231
  return lanes;
323
232
  }
324
-
325
233
  if (name === _laneId().DEFAULT_LANE) {
326
234
  const defaultLane = await this.getLaneDataOfDefaultLane();
327
235
  return defaultLane ? [defaultLane] : [];
328
236
  }
329
-
330
237
  const lanes = await this.scope.legacyScope.lanes.getLanesData(this.scope.legacyScope, name, showMergeData);
331
-
332
238
  if (showDefaultLane) {
333
239
  const defaultLane = await this.getLaneDataOfDefaultLane();
334
240
  if (defaultLane) lanes.push(defaultLane);
335
241
  }
336
-
337
242
  return lanes;
338
243
  }
339
-
340
244
  getCurrentLaneName() {
341
245
  var _this$getCurrentLaneI;
342
-
343
246
  return ((_this$getCurrentLaneI = this.getCurrentLaneId()) === null || _this$getCurrentLaneI === void 0 ? void 0 : _this$getCurrentLaneI.name) || null;
344
247
  }
345
-
346
248
  getCurrentLaneNameOrAlias() {
347
249
  const currentLaneId = this.getCurrentLaneId();
348
250
  if (!currentLaneId) return null;
349
251
  const trackingData = this.scope.legacyScope.lanes.getLocalTrackedLaneByRemoteName(currentLaneId.name, currentLaneId.scope);
350
252
  return trackingData || currentLaneId.name;
351
253
  }
352
-
353
254
  getCurrentLaneId() {
354
255
  if (!this.workspace) return null;
355
256
  return this.workspace.consumer.getCurrentLaneId();
356
257
  }
357
-
358
258
  getDefaultLaneId() {
359
259
  return _laneId().LaneId.from(_laneId().DEFAULT_LANE, this.scope.name);
360
260
  }
361
-
362
261
  setCurrentLane(laneId, alias, exported) {
363
262
  var _this$workspace2;
364
-
365
263
  (_this$workspace2 = this.workspace) === null || _this$workspace2 === void 0 ? void 0 : _this$workspace2.consumer.setCurrentLane(laneId, exported);
366
264
  }
367
-
368
265
  async createLane(name, {
369
266
  remoteScope,
370
267
  alias
@@ -372,16 +269,12 @@ class LanesMain {
372
269
  if (!this.workspace) {
373
270
  throw new (_bitError().BitError)(`unable to create a lane outside of Bit workspace`);
374
271
  }
375
-
376
272
  if (alias) {
377
273
  (0, _createLane().throwForInvalidLaneName)(alias);
378
274
  }
379
-
380
275
  const scope = remoteScope || this.workspace.defaultScope;
381
276
  await (0, _createLane().createLane)(this.workspace.consumer, name, scope);
382
-
383
277
  const laneId = _laneId().LaneId.from(name, scope);
384
-
385
278
  this.setCurrentLane(laneId, alias, false);
386
279
  const trackLaneData = {
387
280
  localLane: alias || name,
@@ -393,19 +286,15 @@ class LanesMain {
393
286
  await this.workspace.consumer.onDestroy();
394
287
  return trackLaneData;
395
288
  }
396
-
397
289
  async trackLane(localName, remoteScope, remoteName) {
398
290
  if (!this.workspace) {
399
291
  throw new (_bitError().BitError)(`unable to track a lane outside of Bit workspace`);
400
292
  }
401
-
402
293
  const laneId = await this.scope.legacyScope.lanes.parseLaneIdFromString(localName);
403
294
  const lane = await this.scope.legacyScope.lanes.loadLane(laneId);
404
-
405
295
  if (!lane) {
406
296
  throw new (_bitError().BitError)(`unable to find a local lane "${localName}"`);
407
297
  }
408
-
409
298
  const beforeTrackData = this.scope.legacyScope.lanes.getRemoteTrackedDataByLocalLane(localName);
410
299
  const beforeTrackDataCloned = beforeTrackData ? _objectSpread({}, beforeTrackData) : undefined;
411
300
  const afterTrackData = {
@@ -420,27 +309,21 @@ class LanesMain {
420
309
  afterTrackData
421
310
  };
422
311
  }
423
-
424
312
  async aliasLane(laneName, alias) {
425
313
  if (!this.workspace) {
426
314
  throw new (_bitError().BitError)(`unable to alias a lane outside of Bit workspace`);
427
315
  }
428
-
429
316
  if (alias.includes(_laneId().LANE_REMOTE_DELIMITER)) {
430
317
  throw new (_bitError().BitError)(`an alias cannot include a delimiter "${_laneId().LANE_REMOTE_DELIMITER}"`);
431
318
  }
432
-
433
319
  if (alias === laneName) {
434
320
  throw new (_bitError().BitError)(`an alias cannot be the same as the lane name`);
435
321
  }
436
-
437
322
  const laneId = await this.scope.legacyScope.lanes.parseLaneIdFromString(laneName);
438
323
  const lane = await this.scope.legacyScope.lanes.loadLane(laneId);
439
-
440
324
  if (!lane) {
441
325
  throw new (_bitError().BitError)(`unable to find a local lane "${laneName}"`);
442
326
  }
443
-
444
327
  const trackData = {
445
328
  localLane: alias,
446
329
  remoteLane: laneId.name,
@@ -454,25 +337,19 @@ class LanesMain {
454
337
  laneId
455
338
  };
456
339
  }
457
-
458
340
  async changeScope(laneName, remoteScope) {
459
341
  if (!this.workspace) {
460
342
  throw new (_bitError().BitError)(`unable to change-scope of a lane outside of Bit workspace`);
461
343
  }
462
-
463
344
  const laneNameWithoutScope = laneName.includes(_laneId().LANE_REMOTE_DELIMITER) ? laneName.split(_laneId().LANE_REMOTE_DELIMITER)[1] : laneName;
464
345
  const laneId = await this.scope.legacyScope.lanes.parseLaneIdFromString(laneName);
465
346
  const lane = await this.scope.legacyScope.lanes.loadLane(laneId);
466
-
467
347
  if (!lane) {
468
348
  throw new (_bitError().BitError)(`unable to find a local lane "${laneName}"`);
469
349
  }
470
-
471
350
  const remoteScopeBefore = lane.scope;
472
351
  lane.scope = remoteScope;
473
-
474
352
  const newLaneId = _laneId().LaneId.from(laneId.name, remoteScope);
475
-
476
353
  const trackData = {
477
354
  localLane: laneNameWithoutScope,
478
355
  remoteLane: laneId.name,
@@ -486,62 +363,56 @@ class LanesMain {
486
363
  remoteScopeBefore
487
364
  };
488
365
  }
366
+
489
367
  /**
490
368
  * change a lane-name and if possible, export the lane to the remote
491
369
  */
492
-
493
-
494
370
  async rename(currentName, newName) {
495
371
  if (!this.workspace) {
496
372
  throw new (_bitError().BitError)(`unable to rename a lane outside of Bit workspace`);
497
373
  }
498
-
499
374
  (0, _createLane().throwForInvalidLaneName)(newName);
500
375
  const existingAliasWithNewName = this.scope.legacyScope.lanes.getRemoteTrackedDataByLocalLane(newName);
501
-
502
376
  if (existingAliasWithNewName) {
503
377
  const remoteIdStr = `${existingAliasWithNewName.remoteLane}/${existingAliasWithNewName.remoteScope}`;
504
378
  throw new (_bitError().BitError)(`unable to rename to ${newName}. this name is already used to track: ${remoteIdStr}`);
505
379
  }
506
-
507
380
  const laneNameWithoutScope = currentName.includes(_laneId().LANE_REMOTE_DELIMITER) ? currentName.split(_laneId().LANE_REMOTE_DELIMITER)[1] : currentName;
508
381
  const laneId = await this.scope.legacyScope.lanes.parseLaneIdFromString(currentName);
509
382
  const lane = await this.scope.legacyScope.lanes.loadLane(laneId);
510
-
511
383
  if (!lane) {
512
384
  throw new (_bitError().BitError)(`unable to find a local lane "${currentName}"`);
513
- } // rename the ref file
514
-
385
+ }
515
386
 
516
- await this.scope.legacyScope.objects.remoteLanes.renameRefByNewLaneName(laneNameWithoutScope, newName, lane.scope); // change tracking data
387
+ // rename the ref file
388
+ await this.scope.legacyScope.objects.remoteLanes.renameRefByNewLaneName(laneNameWithoutScope, newName, lane.scope);
517
389
 
390
+ // change tracking data
518
391
  const afterTrackData = {
519
392
  localLane: newName,
520
393
  remoteLane: newName,
521
394
  remoteScope: lane.scope
522
395
  };
523
396
  this.scope.legacyScope.lanes.trackLane(afterTrackData);
524
- this.scope.legacyScope.lanes.removeTrackLane(laneNameWithoutScope); // change the lane object
397
+ this.scope.legacyScope.lanes.removeTrackLane(laneNameWithoutScope);
525
398
 
399
+ // change the lane object
526
400
  lane.name = newName;
527
- await this.scope.legacyScope.lanes.saveLane(lane); // change current-lane if needed
401
+ await this.scope.legacyScope.lanes.saveLane(lane);
528
402
 
403
+ // change current-lane if needed
529
404
  const currentLaneName = this.getCurrentLaneName();
530
-
531
405
  if (currentLaneName === laneNameWithoutScope) {
532
406
  const newLaneId = _laneId().LaneId.from(newName, lane.scope);
533
-
534
407
  const isExported = this.workspace.consumer.bitMap.isLaneExported;
535
408
  this.setCurrentLane(newLaneId, undefined, isExported);
536
- } // export the lane with only the name-change
537
-
409
+ }
538
410
 
411
+ // export the lane with only the name-change
539
412
  const clonedLaneToExport = lane.clone();
540
413
  clonedLaneToExport.components = []; // otherwise, it'll export the changes done on the components.
541
-
542
414
  let exported = false;
543
415
  let exportErr;
544
-
545
416
  try {
546
417
  await this.exportLane(clonedLaneToExport);
547
418
  exported = true;
@@ -549,14 +420,12 @@ class LanesMain {
549
420
  this.logger.error(`unable to export ${lane.id.toString()}: ${err.message}`);
550
421
  exportErr = err;
551
422
  }
552
-
553
423
  await this.workspace.consumer.onDestroy();
554
424
  return {
555
425
  exported,
556
426
  exportErr
557
427
  };
558
428
  }
559
-
560
429
  async exportLane(lane) {
561
430
  await this.exporter.exportMany({
562
431
  scope: this.scope.legacyScope,
@@ -566,6 +435,7 @@ class LanesMain {
566
435
  allVersions: false
567
436
  });
568
437
  }
438
+
569
439
  /**
570
440
  * get a Lane object from the remote.
571
441
  * `persistIfNotExists` saves the object in the local scope only if the lane is not there yet.
@@ -573,41 +443,31 @@ class LanesMain {
573
443
  * see `sources.mergeLane()` for export and `import-components._saveLaneDataIfNeeded()` for import.
574
444
  * in this case, because we only bring the lane object and not the components, it's not easy to do the merge.
575
445
  */
576
-
577
-
578
446
  async importLaneObject(laneId, persistIfNotExists = true) {
579
447
  const legacyScope = this.scope.legacyScope;
580
-
581
448
  const scopeComponentImporter = _scopeComponentsImporter().default.getInstance(legacyScope);
582
-
583
449
  const results = await scopeComponentImporter.importLanes([laneId]);
584
450
  const laneObject = results[0];
585
451
  if (!laneObject) throw new (_laneNotFound().LaneNotFound)(laneId.scope, laneId.name);
586
-
587
452
  if (persistIfNotExists) {
588
453
  const exists = await legacyScope.loadLane(laneId);
589
-
590
454
  if (!exists) {
591
455
  await legacyScope.lanes.saveLane(laneObject);
592
456
  }
593
457
  }
594
-
595
458
  return laneObject;
596
459
  }
460
+
597
461
  /**
598
462
  * fetch the lane object and its components from the remote.
599
463
  * save the objects to the local scope.
600
464
  * this method doesn't change anything in the workspace.
601
465
  */
602
-
603
-
604
466
  async fetchLaneWithItsComponents(laneId) {
605
467
  this.logger.debug(`fetching lane ${laneId.toString()}`);
606
-
607
468
  if (!this.workspace) {
608
469
  throw new (_bitError().BitError)('unable to fetch lanes outside of Bit workspace');
609
470
  }
610
-
611
471
  const lane = await this.importLaneObject(laneId);
612
472
  if (!lane) throw new Error(`unable to import lane ${laneId.toString()} from the remote`);
613
473
  const importOptions = {
@@ -628,25 +488,22 @@ class LanesMain {
628
488
  this.logger.debug(`fetching lane ${laneId.toString()} done, fetched ${importedIds.length} components`);
629
489
  return lane;
630
490
  }
631
-
632
491
  async removeLanes(laneNames, {
633
492
  remote,
634
493
  force
635
494
  }) {
636
495
  var _this$workspace3;
637
-
638
496
  const results = await (0, _removeLanes().default)((_this$workspace3 = this.workspace) === null || _this$workspace3 === void 0 ? void 0 : _this$workspace3.consumer, laneNames, remote, force);
639
497
  if (this.workspace) await this.workspace.consumer.onDestroy();
640
498
  return results.laneResults;
641
499
  }
500
+
642
501
  /**
643
502
  * switch to a different local or remote lane.
644
503
  * switching to a remote lane also imports and writes the components of that remote lane.
645
504
  * by default, only the components existing on the workspace will be imported from that lane, unless the "getAll"
646
505
  * flag is true.
647
506
  */
648
-
649
-
650
507
  async switchLanes(laneName, {
651
508
  alias,
652
509
  merge,
@@ -656,23 +513,17 @@ class LanesMain {
656
513
  if (!this.workspace) {
657
514
  throw new (_bitError().BitError)(`unable to switch lanes outside of Bit workspace`);
658
515
  }
659
-
660
516
  let mergeStrategy;
661
-
662
517
  if (merge && typeof merge === 'string') {
663
518
  const mergeOptions = Object.keys(_mergeVersion().MergeOptions);
664
-
665
519
  if (!mergeOptions.includes(merge)) {
666
520
  throw new (_bitError().BitError)(`merge must be one of the following: ${mergeOptions.join(', ')}`);
667
521
  }
668
-
669
522
  mergeStrategy = merge;
670
523
  }
671
-
672
524
  if (alias) {
673
525
  (0, _createLane().throwForInvalidLaneName)(alias);
674
526
  }
675
-
676
527
  const switchProps = {
677
528
  laneName,
678
529
  existingOnWorkspaceOnly: !getAll,
@@ -695,19 +546,17 @@ class LanesMain {
695
546
  };
696
547
  return new (_switchLanes().LaneSwitcher)(this.workspace, this.logger, switchProps, checkoutProps, this).switch();
697
548
  }
549
+
698
550
  /**
699
551
  * the values array may include zero to two values and will be processed as following:
700
552
  * [] => diff between the current lane and default lane. (only inside workspace).
701
553
  * [to] => diff between the current lane (or default-lane when in scope) and "to" lane.
702
554
  * [from, to] => diff between "from" lane and "to" lane.
703
555
  */
704
-
705
-
706
556
  async getDiff(values, diffOptions = {}, pattern) {
707
557
  const laneDiffGenerator = new (_lanesModules().LaneDiffGenerator)(this.workspace, this.scope);
708
558
  return laneDiffGenerator.generate(values, diffOptions, pattern);
709
559
  }
710
-
711
560
  async getLaneComponentModels(lane) {
712
561
  if (!lane) return [];
713
562
  const laneComponents = lane.components;
@@ -719,7 +568,6 @@ class LanesMain {
719
568
  const components = await host.getMany(laneComponentIds);
720
569
  return components;
721
570
  }
722
-
723
571
  async getLaneReadmeComponent(lane) {
724
572
  if (!lane) return undefined;
725
573
  const laneReadmeComponent = lane.readmeComponent;
@@ -729,39 +577,31 @@ class LanesMain {
729
577
  const readmeComponent = await host.get(laneReadmeComponentId);
730
578
  return readmeComponent;
731
579
  }
732
-
733
580
  async removeLaneReadme(laneName) {
734
581
  if (!this.workspace) {
735
582
  throw new (_bitError().BitError)('unable to remove the lane readme component outside of Bit workspace');
736
583
  }
737
-
738
584
  const currentLaneName = this.getCurrentLaneName();
739
-
740
585
  if (!laneName && !currentLaneName) {
741
586
  return {
742
587
  result: false,
743
588
  message: 'unable to remove the lane readme component. Either pass a laneName or switch to a lane'
744
589
  };
745
590
  }
746
-
747
591
  const scope = this.workspace.scope.legacyScope;
748
592
  const laneId = laneName ? await scope.lanes.parseLaneIdFromString(laneName) : this.getCurrentLaneId();
749
593
  const lane = await scope.loadLane(laneId);
750
-
751
594
  if (!(lane !== null && lane !== void 0 && lane.readmeComponent)) {
752
595
  throw new (_bitError().BitError)(`there is no readme component added to the lane ${laneName || currentLaneName}`);
753
596
  }
754
-
755
597
  const readmeComponentId = await this.workspace.resolveComponentId(lane.readmeComponent.id);
756
598
  const existingLaneConfig = (await this.workspace.getSpecificComponentConfig(readmeComponentId, _lanes().LanesAspect.id)) || {};
757
599
  const remoteLaneIdStr = lane.toLaneId().toString();
758
-
759
600
  if (existingLaneConfig.readme) {
760
601
  delete existingLaneConfig.readme[remoteLaneIdStr];
761
602
  await this.workspace.removeSpecificComponentConfig(readmeComponentId, _lanes().LanesAspect.id, false);
762
603
  await this.workspace.addSpecificComponentConfig(readmeComponentId, _lanes().LanesAspect.id, existingLaneConfig);
763
604
  }
764
-
765
605
  lane.setReadmeComponent(undefined);
766
606
  await scope.lanes.saveLane(lane);
767
607
  await this.workspace.bitMap.write();
@@ -769,30 +609,25 @@ class LanesMain {
769
609
  result: true
770
610
  };
771
611
  }
772
-
773
612
  async addLaneReadme(readmeComponentIdStr, laneName) {
774
613
  if (!this.workspace) {
775
614
  throw new (_bitError().BitError)(`unable to track a lane readme component outside of Bit workspace`);
776
615
  }
777
-
778
616
  const readmeComponentId = await this.workspace.resolveComponentId(readmeComponentIdStr);
779
617
  const readmeComponentBitId = readmeComponentId._legacy;
780
618
  const scope = this.workspace.scope.legacyScope;
781
619
  const laneId = laneName ? await scope.lanes.parseLaneIdFromString(laneName) : this.getCurrentLaneId();
782
620
  const lane = await scope.loadLane(laneId);
783
-
784
621
  if (!lane) {
785
622
  return {
786
623
  result: false,
787
624
  message: `cannot find lane ${laneName}`
788
625
  };
789
626
  }
790
-
791
627
  lane.setReadmeComponent(readmeComponentBitId);
792
628
  await scope.lanes.saveLane(lane);
793
629
  const existingLaneConfig = (await this.workspace.getSpecificComponentConfig(readmeComponentId, _lanes().LanesAspect.id)) || {};
794
630
  const remoteLaneIdStr = lane.toLaneId().toString();
795
-
796
631
  if (existingLaneConfig.readme) {
797
632
  await this.workspace.addSpecificComponentConfig(readmeComponentId, _lanes().LanesAspect.id, _objectSpread(_objectSpread({}, existingLaneConfig), {}, {
798
633
  readme: _objectSpread(_objectSpread({}, existingLaneConfig.readme), {}, {
@@ -806,26 +641,21 @@ class LanesMain {
806
641
  }
807
642
  }));
808
643
  }
809
-
810
644
  await this.workspace.bitMap.write();
811
645
  return {
812
646
  result: true
813
647
  };
814
648
  }
815
-
816
649
  async getLaneDataOfDefaultLane() {
817
650
  var _this$workspace4;
818
-
819
651
  const consumer = (_this$workspace4 = this.workspace) === null || _this$workspace4 === void 0 ? void 0 : _this$workspace4.consumer;
820
652
  let bitIds = [];
821
-
822
653
  if (!consumer) {
823
654
  const scopeComponents = await this.scope.list();
824
655
  bitIds = scopeComponents.filter(component => component.head).map(component => component.id._legacy);
825
656
  } else {
826
657
  bitIds = await consumer.getIdsOfDefaultLane();
827
658
  }
828
-
829
659
  return {
830
660
  name: _laneId().DEFAULT_LANE,
831
661
  remote: null,
@@ -838,7 +668,6 @@ class LanesMain {
838
668
  hash: ''
839
669
  };
840
670
  }
841
-
842
671
  static async provider([cli, scope, workspace, graphql, community, merging, component, loggerMain, importer, exporter]) {
843
672
  const logger = loggerMain.createLogger(_lanes().LanesAspect.id);
844
673
  const lanesMain = new LanesMain(workspace, scope, merging, component, logger, importer, exporter);
@@ -849,16 +678,12 @@ class LanesMain {
849
678
  graphql.register((0, _lanes2().lanesSchema)(lanesMain));
850
679
  return lanesMain;
851
680
  }
852
-
853
681
  }
854
-
855
682
  exports.LanesMain = LanesMain;
856
683
  (0, _defineProperty2().default)(LanesMain, "slots", []);
857
684
  (0, _defineProperty2().default)(LanesMain, "dependencies", [_cli().CLIAspect, _scope().ScopeAspect, _workspace().WorkspaceAspect, _graphql().GraphqlAspect, _community().CommunityAspect, _merging().MergingAspect, _component().default, _logger().LoggerAspect, _importer().ImporterAspect, _export().ExportAspect]);
858
685
  (0, _defineProperty2().default)(LanesMain, "runtime", _cli().MainRuntime);
859
-
860
686
  _lanes().LanesAspect.addRuntime(LanesMain);
861
-
862
687
  var _default = LanesMain;
863
688
  exports.default = _default;
864
689