@teambit/export 0.0.880 → 0.0.882
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/dist/export-cmd.js +0 -32
- package/dist/export-cmd.js.map +1 -1
- package/dist/export.aspect.js +0 -5
- package/dist/export.aspect.js.map +1 -1
- package/dist/export.composition.js +0 -6
- package/dist/export.composition.js.map +1 -1
- package/dist/export.main.runtime.js +45 -294
- package/dist/export.main.runtime.js.map +1 -1
- package/dist/index.js +0 -15
- package/dist/index.js.map +1 -1
- package/dist/resume-export-cmd.js +0 -13
- package/dist/resume-export-cmd.js.map +1 -1
- package/package-tar/teambit-export-0.0.882.tgz +0 -0
- package/package.json +9 -9
- package/{preview-1666312873430.js → preview-1666496165706.js} +2 -2
- package/package-tar/teambit-export-0.0.880.tgz +0 -0
|
@@ -1,394 +1,276 @@
|
|
|
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
|
Object.defineProperty(exports, "__esModule", {
|
|
14
9
|
value: true
|
|
15
10
|
});
|
|
16
11
|
exports.ExportMain = void 0;
|
|
17
12
|
exports.isUserTryingToExportLanes = isUserTryingToExportLanes;
|
|
18
|
-
|
|
19
13
|
function _objectWithoutProperties2() {
|
|
20
14
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
21
|
-
|
|
22
15
|
_objectWithoutProperties2 = function () {
|
|
23
16
|
return data;
|
|
24
17
|
};
|
|
25
|
-
|
|
26
18
|
return data;
|
|
27
19
|
}
|
|
28
|
-
|
|
29
20
|
function _defineProperty2() {
|
|
30
21
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
31
|
-
|
|
32
22
|
_defineProperty2 = function () {
|
|
33
23
|
return data;
|
|
34
24
|
};
|
|
35
|
-
|
|
36
25
|
return data;
|
|
37
26
|
}
|
|
38
|
-
|
|
39
27
|
function _cli() {
|
|
40
28
|
const data = require("@teambit/cli");
|
|
41
|
-
|
|
42
29
|
_cli = function () {
|
|
43
30
|
return data;
|
|
44
31
|
};
|
|
45
|
-
|
|
46
32
|
return data;
|
|
47
33
|
}
|
|
48
|
-
|
|
49
34
|
function _scope() {
|
|
50
35
|
const data = _interopRequireDefault(require("@teambit/scope"));
|
|
51
|
-
|
|
52
36
|
_scope = function () {
|
|
53
37
|
return data;
|
|
54
38
|
};
|
|
55
|
-
|
|
56
39
|
return data;
|
|
57
40
|
}
|
|
58
|
-
|
|
59
41
|
function _ramda() {
|
|
60
42
|
const data = _interopRequireDefault(require("ramda"));
|
|
61
|
-
|
|
62
43
|
_ramda = function () {
|
|
63
44
|
return data;
|
|
64
45
|
};
|
|
65
|
-
|
|
66
46
|
return data;
|
|
67
47
|
}
|
|
68
|
-
|
|
69
48
|
function _bitError() {
|
|
70
49
|
const data = require("@teambit/bit-error");
|
|
71
|
-
|
|
72
50
|
_bitError = function () {
|
|
73
51
|
return data;
|
|
74
52
|
};
|
|
75
|
-
|
|
76
53
|
return data;
|
|
77
54
|
}
|
|
78
|
-
|
|
79
55
|
function _analytics() {
|
|
80
56
|
const data = require("@teambit/legacy/dist/analytics/analytics");
|
|
81
|
-
|
|
82
57
|
_analytics = function () {
|
|
83
58
|
return data;
|
|
84
59
|
};
|
|
85
|
-
|
|
86
60
|
return data;
|
|
87
61
|
}
|
|
88
|
-
|
|
89
62
|
function _bitId() {
|
|
90
63
|
const data = require("@teambit/legacy/dist/bit-id");
|
|
91
|
-
|
|
92
64
|
_bitId = function () {
|
|
93
65
|
return data;
|
|
94
66
|
};
|
|
95
|
-
|
|
96
67
|
return data;
|
|
97
68
|
}
|
|
98
|
-
|
|
99
69
|
function _loader() {
|
|
100
70
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/cli/loader"));
|
|
101
|
-
|
|
102
71
|
_loader = function () {
|
|
103
72
|
return data;
|
|
104
73
|
};
|
|
105
|
-
|
|
106
74
|
return data;
|
|
107
75
|
}
|
|
108
|
-
|
|
109
76
|
function _loaderMessages() {
|
|
110
77
|
const data = require("@teambit/legacy/dist/cli/loader/loader-messages");
|
|
111
|
-
|
|
112
78
|
_loaderMessages = function () {
|
|
113
79
|
return data;
|
|
114
80
|
};
|
|
115
|
-
|
|
116
81
|
return data;
|
|
117
82
|
}
|
|
118
|
-
|
|
119
83
|
function _constants() {
|
|
120
84
|
const data = require("@teambit/legacy/dist/constants");
|
|
121
|
-
|
|
122
85
|
_constants = function () {
|
|
123
86
|
return data;
|
|
124
87
|
};
|
|
125
|
-
|
|
126
88
|
return data;
|
|
127
89
|
}
|
|
128
|
-
|
|
129
90
|
function _consumer() {
|
|
130
91
|
const data = require("@teambit/legacy/dist/consumer");
|
|
131
|
-
|
|
132
92
|
_consumer = function () {
|
|
133
93
|
return data;
|
|
134
94
|
};
|
|
135
|
-
|
|
136
95
|
return data;
|
|
137
96
|
}
|
|
138
|
-
|
|
139
97
|
function _ejectComponents() {
|
|
140
98
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component-ops/eject-components"));
|
|
141
|
-
|
|
142
99
|
_ejectComponents = function () {
|
|
143
100
|
return data;
|
|
144
101
|
};
|
|
145
|
-
|
|
146
102
|
return data;
|
|
147
103
|
}
|
|
148
|
-
|
|
149
104
|
function _componentsList() {
|
|
150
105
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component/components-list"));
|
|
151
|
-
|
|
152
106
|
_componentsList = function () {
|
|
153
107
|
return data;
|
|
154
108
|
};
|
|
155
|
-
|
|
156
109
|
return data;
|
|
157
110
|
}
|
|
158
|
-
|
|
159
111
|
function _generalError() {
|
|
160
112
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/error/general-error"));
|
|
161
|
-
|
|
162
113
|
_generalError = function () {
|
|
163
114
|
return data;
|
|
164
115
|
};
|
|
165
|
-
|
|
166
116
|
return data;
|
|
167
117
|
}
|
|
168
|
-
|
|
169
118
|
function _hooks() {
|
|
170
119
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/hooks"));
|
|
171
|
-
|
|
172
120
|
_hooks = function () {
|
|
173
121
|
return data;
|
|
174
122
|
};
|
|
175
|
-
|
|
176
123
|
return data;
|
|
177
124
|
}
|
|
178
|
-
|
|
179
125
|
function _remove() {
|
|
180
126
|
const data = require("@teambit/remove");
|
|
181
|
-
|
|
182
127
|
_remove = function () {
|
|
183
128
|
return data;
|
|
184
129
|
};
|
|
185
|
-
|
|
186
130
|
return data;
|
|
187
131
|
}
|
|
188
|
-
|
|
189
132
|
function _links() {
|
|
190
133
|
const data = require("@teambit/legacy/dist/links");
|
|
191
|
-
|
|
192
134
|
_links = function () {
|
|
193
135
|
return data;
|
|
194
136
|
};
|
|
195
|
-
|
|
196
137
|
return data;
|
|
197
138
|
}
|
|
198
|
-
|
|
199
139
|
function _logger() {
|
|
200
140
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/logger/logger"));
|
|
201
|
-
|
|
202
141
|
_logger = function () {
|
|
203
142
|
return data;
|
|
204
143
|
};
|
|
205
|
-
|
|
206
144
|
return data;
|
|
207
145
|
}
|
|
208
|
-
|
|
209
146
|
function _models() {
|
|
210
147
|
const data = require("@teambit/legacy/dist/scope/models");
|
|
211
|
-
|
|
212
148
|
_models = function () {
|
|
213
149
|
return data;
|
|
214
150
|
};
|
|
215
|
-
|
|
216
151
|
return data;
|
|
217
152
|
}
|
|
218
|
-
|
|
219
153
|
function _hasWildcard() {
|
|
220
154
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/utils/string/has-wildcard"));
|
|
221
|
-
|
|
222
155
|
_hasWildcard = function () {
|
|
223
156
|
return data;
|
|
224
157
|
};
|
|
225
|
-
|
|
226
158
|
return data;
|
|
227
159
|
}
|
|
228
|
-
|
|
229
160
|
function _scope2() {
|
|
230
161
|
const data = require("@teambit/legacy/dist/scope");
|
|
231
|
-
|
|
232
162
|
_scope2 = function () {
|
|
233
163
|
return data;
|
|
234
164
|
};
|
|
235
|
-
|
|
236
165
|
return data;
|
|
237
166
|
}
|
|
238
|
-
|
|
239
167
|
function _workspace() {
|
|
240
168
|
const data = _interopRequireDefault(require("@teambit/workspace"));
|
|
241
|
-
|
|
242
169
|
_workspace = function () {
|
|
243
170
|
return data;
|
|
244
171
|
};
|
|
245
|
-
|
|
246
172
|
return data;
|
|
247
173
|
}
|
|
248
|
-
|
|
249
174
|
function _exceptions() {
|
|
250
175
|
const data = require("@teambit/legacy/dist/consumer/exceptions");
|
|
251
|
-
|
|
252
176
|
_exceptions = function () {
|
|
253
177
|
return data;
|
|
254
178
|
};
|
|
255
|
-
|
|
256
179
|
return data;
|
|
257
180
|
}
|
|
258
|
-
|
|
259
181
|
function _http() {
|
|
260
182
|
const data = require("@teambit/legacy/dist/scope/network/http");
|
|
261
|
-
|
|
262
183
|
_http = function () {
|
|
263
184
|
return data;
|
|
264
185
|
};
|
|
265
|
-
|
|
266
186
|
return data;
|
|
267
187
|
}
|
|
268
|
-
|
|
269
188
|
function _objectList() {
|
|
270
189
|
const data = require("@teambit/legacy/dist/scope/objects/object-list");
|
|
271
|
-
|
|
272
190
|
_objectList = function () {
|
|
273
191
|
return data;
|
|
274
192
|
};
|
|
275
|
-
|
|
276
193
|
return data;
|
|
277
194
|
}
|
|
278
|
-
|
|
279
195
|
function _pMapSeries() {
|
|
280
196
|
const data = _interopRequireDefault(require("p-map-series"));
|
|
281
|
-
|
|
282
197
|
_pMapSeries = function () {
|
|
283
198
|
return data;
|
|
284
199
|
};
|
|
285
|
-
|
|
286
200
|
return data;
|
|
287
201
|
}
|
|
288
|
-
|
|
289
202
|
function _laneId() {
|
|
290
203
|
const data = require("@teambit/lane-id");
|
|
291
|
-
|
|
292
204
|
_laneId = function () {
|
|
293
205
|
return data;
|
|
294
206
|
};
|
|
295
|
-
|
|
296
207
|
return data;
|
|
297
208
|
}
|
|
298
|
-
|
|
299
209
|
function _scopeRemotes() {
|
|
300
210
|
const data = require("@teambit/legacy/dist/scope/scope-remotes");
|
|
301
|
-
|
|
302
211
|
_scopeRemotes = function () {
|
|
303
212
|
return data;
|
|
304
213
|
};
|
|
305
|
-
|
|
306
214
|
return data;
|
|
307
215
|
}
|
|
308
|
-
|
|
309
216
|
function _dependencyResolver() {
|
|
310
217
|
const data = require("@teambit/dependency-resolver");
|
|
311
|
-
|
|
312
218
|
_dependencyResolver = function () {
|
|
313
219
|
return data;
|
|
314
220
|
};
|
|
315
|
-
|
|
316
221
|
return data;
|
|
317
222
|
}
|
|
318
|
-
|
|
319
223
|
function _exportScopeComponents() {
|
|
320
224
|
const data = require("@teambit/legacy/dist/scope/component-ops/export-scope-components");
|
|
321
|
-
|
|
322
225
|
_exportScopeComponents = function () {
|
|
323
226
|
return data;
|
|
324
227
|
};
|
|
325
|
-
|
|
326
228
|
return data;
|
|
327
229
|
}
|
|
328
|
-
|
|
329
230
|
function _persistFailed() {
|
|
330
231
|
const data = require("@teambit/legacy/dist/scope/exceptions/persist-failed");
|
|
331
|
-
|
|
332
232
|
_persistFailed = function () {
|
|
333
233
|
return data;
|
|
334
234
|
};
|
|
335
|
-
|
|
336
235
|
return data;
|
|
337
236
|
}
|
|
338
|
-
|
|
339
237
|
function _traverseVersions() {
|
|
340
238
|
const data = require("@teambit/legacy/dist/scope/component-ops/traverse-versions");
|
|
341
|
-
|
|
342
239
|
_traverseVersions = function () {
|
|
343
240
|
return data;
|
|
344
241
|
};
|
|
345
|
-
|
|
346
242
|
return data;
|
|
347
243
|
}
|
|
348
|
-
|
|
349
244
|
function _export() {
|
|
350
245
|
const data = require("./export.aspect");
|
|
351
|
-
|
|
352
246
|
_export = function () {
|
|
353
247
|
return data;
|
|
354
248
|
};
|
|
355
|
-
|
|
356
249
|
return data;
|
|
357
250
|
}
|
|
358
|
-
|
|
359
251
|
function _exportCmd() {
|
|
360
252
|
const data = require("./export-cmd");
|
|
361
|
-
|
|
362
253
|
_exportCmd = function () {
|
|
363
254
|
return data;
|
|
364
255
|
};
|
|
365
|
-
|
|
366
256
|
return data;
|
|
367
257
|
}
|
|
368
|
-
|
|
369
258
|
function _resumeExportCmd() {
|
|
370
259
|
const data = require("./resume-export-cmd");
|
|
371
|
-
|
|
372
260
|
_resumeExportCmd = function () {
|
|
373
261
|
return data;
|
|
374
262
|
};
|
|
375
|
-
|
|
376
263
|
return data;
|
|
377
264
|
}
|
|
378
|
-
|
|
379
265
|
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; }
|
|
380
|
-
|
|
381
266
|
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; }
|
|
382
|
-
|
|
383
267
|
const HooksManagerInstance = _hooks().default.getInstance();
|
|
384
|
-
|
|
385
268
|
class ExportMain {
|
|
386
269
|
constructor(workspace, remove, depResolver) {
|
|
387
270
|
this.workspace = workspace;
|
|
388
271
|
this.remove = remove;
|
|
389
272
|
this.depResolver = depResolver;
|
|
390
273
|
}
|
|
391
|
-
|
|
392
274
|
async export(params) {
|
|
393
275
|
HooksManagerInstance.triggerHook(_constants().PRE_EXPORT_HOOK, params);
|
|
394
276
|
const {
|
|
@@ -410,19 +292,15 @@ class ExportMain {
|
|
|
410
292
|
exportedLanes
|
|
411
293
|
};
|
|
412
294
|
HooksManagerInstance.triggerHook(_constants().POST_EXPORT_HOOK, exportResults);
|
|
413
|
-
|
|
414
295
|
if (_scope2().Scope.onPostExport) {
|
|
415
296
|
await _scope2().Scope.onPostExport(exported, exportedLanes).catch(err => {
|
|
416
297
|
_logger().default.error('fatal: onPostExport encountered an error (this error does not stop the process)', err);
|
|
417
298
|
});
|
|
418
299
|
}
|
|
419
|
-
|
|
420
300
|
return exportResults;
|
|
421
301
|
}
|
|
422
|
-
|
|
423
302
|
async exportObjectList(manyObjectsPerRemote, scopeRemotes, centralHubOptions) {
|
|
424
303
|
const http = await _http().Http.connect(_constants().CENTRAL_BIT_HUB_URL, _constants().CENTRAL_BIT_HUB_NAME);
|
|
425
|
-
|
|
426
304
|
if (this.shouldPushToCentralHub(manyObjectsPerRemote, scopeRemotes)) {
|
|
427
305
|
const objectList = this.transformToOneObjectListWithScopeData(manyObjectsPerRemote);
|
|
428
306
|
await http.pushToCentralHub(objectList, centralHubOptions);
|
|
@@ -430,14 +308,13 @@ class ExportMain {
|
|
|
430
308
|
await this.pushToRemotesCarefully(manyObjectsPerRemote);
|
|
431
309
|
}
|
|
432
310
|
}
|
|
433
|
-
|
|
434
311
|
async exportComponents(_ref) {
|
|
435
312
|
let {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
313
|
+
ids,
|
|
314
|
+
includeNonStaged,
|
|
315
|
+
originDirectly
|
|
316
|
+
} = _ref,
|
|
317
|
+
params = (0, _objectWithoutProperties2().default)(_ref, ["ids", "includeNonStaged", "originDirectly"]);
|
|
441
318
|
if (!this.workspace) throw new (_exceptions().ConsumerNotFound)();
|
|
442
319
|
const consumer = this.workspace.consumer;
|
|
443
320
|
const {
|
|
@@ -446,7 +323,6 @@ class ExportMain {
|
|
|
446
323
|
idsWithFutureScope,
|
|
447
324
|
laneObject
|
|
448
325
|
} = await this.getComponentsToExport(ids, includeNonStaged);
|
|
449
|
-
|
|
450
326
|
if (_ramda().default.isEmpty(idsToExport)) {
|
|
451
327
|
return {
|
|
452
328
|
updatedIds: [],
|
|
@@ -457,13 +333,12 @@ class ExportMain {
|
|
|
457
333
|
newIdsOnRemote: [],
|
|
458
334
|
exportedLanes: []
|
|
459
335
|
};
|
|
460
|
-
}
|
|
461
|
-
|
|
336
|
+
}
|
|
462
337
|
|
|
338
|
+
// validate lane readme component and ensure it has been snapped
|
|
463
339
|
if (laneObject !== null && laneObject !== void 0 && laneObject.readmeComponent) {
|
|
464
340
|
_throwForUnsnappedLaneReadme(laneObject);
|
|
465
341
|
}
|
|
466
|
-
|
|
467
342
|
const isOnMain = consumer.isOnMain();
|
|
468
343
|
const {
|
|
469
344
|
exported,
|
|
@@ -479,20 +354,16 @@ class ExportMain {
|
|
|
479
354
|
}));
|
|
480
355
|
if (laneObject) await updateLanesAfterExport(consumer, laneObject);
|
|
481
356
|
const removedIds = await this.getRemovedStagedBitIds();
|
|
482
|
-
|
|
483
357
|
const {
|
|
484
358
|
updatedIds,
|
|
485
359
|
nonExistOnBitMap
|
|
486
360
|
} = _updateIdsOnBitMap(consumer.bitMap, updatedLocally);
|
|
487
|
-
|
|
488
361
|
await this.removeFromStagedConfig([...updatedIds, ...nonExistOnBitMap]);
|
|
489
362
|
await linkComponents(updatedIds, consumer);
|
|
490
|
-
|
|
491
|
-
|
|
363
|
+
_analytics().Analytics.setExtraData('num_components', exported.length);
|
|
364
|
+
// it is important to have consumer.onDestroy() before running the eject operation, we want the
|
|
492
365
|
// export and eject operations to function independently. we don't want to lose the changes to
|
|
493
366
|
// .bitmap file done by the export action in case the eject action has failed.
|
|
494
|
-
|
|
495
|
-
|
|
496
367
|
await consumer.onDestroy();
|
|
497
368
|
return {
|
|
498
369
|
updatedIds,
|
|
@@ -504,11 +375,10 @@ class ExportMain {
|
|
|
504
375
|
exportedLanes: laneObject ? [laneObject] : []
|
|
505
376
|
};
|
|
506
377
|
}
|
|
378
|
+
|
|
507
379
|
/**
|
|
508
380
|
* the export process uses four steps. read more about it here: https://github.com/teambit/bit/pull/3371
|
|
509
381
|
*/
|
|
510
|
-
|
|
511
|
-
|
|
512
382
|
async exportMany({
|
|
513
383
|
scope,
|
|
514
384
|
ids,
|
|
@@ -524,35 +394,29 @@ class ExportMain {
|
|
|
524
394
|
_logger().default.debugAndAddBreadCrumb('scope.exportMany', 'ids: {ids}', {
|
|
525
395
|
ids: ids.toString()
|
|
526
396
|
});
|
|
527
|
-
|
|
528
397
|
const scopeRemotes = await (0, _scopeRemotes().getScopeRemotes)(scope);
|
|
529
398
|
const idsGroupedByScope = ids.toGroupByScopeName(idsWithFutureScope);
|
|
399
|
+
|
|
530
400
|
/**
|
|
531
401
|
* when a component is exported for the first time, and the lane-scope is not the same as the component-scope, it's
|
|
532
402
|
* important to validate that there is no such component in the original scope. otherwise, later, it'll be impossible
|
|
533
403
|
* to merge the lane because these two components don't have any snap in common.
|
|
534
404
|
*/
|
|
535
|
-
|
|
536
405
|
const validateTargetScopeForLanes = async () => {
|
|
537
406
|
if (!laneObject) {
|
|
538
407
|
return;
|
|
539
408
|
}
|
|
540
|
-
|
|
541
409
|
const newIds = _bitId().BitIds.fromArray(ids.filter(id => !id.hasScope()));
|
|
542
|
-
|
|
543
410
|
const newIdsGrouped = newIds.toGroupByScopeName(idsWithFutureScope);
|
|
544
411
|
await (0, _pMapSeries().default)(Object.keys(newIdsGrouped), async scopeName => {
|
|
545
412
|
if (scopeName === laneObject.scope) {
|
|
546
413
|
// this validation is redundant if the lane-component is in the same scope as the lane-object
|
|
547
414
|
return;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
|
|
415
|
+
}
|
|
416
|
+
// by getting the remote we also validate that this scope actually exists.
|
|
551
417
|
const remote = await scopeRemotes.resolve(scopeName, scope);
|
|
552
418
|
const list = await remote.list();
|
|
553
|
-
|
|
554
419
|
const listIds = _bitId().BitIds.fromArray(list.map(listItem => listItem.id));
|
|
555
|
-
|
|
556
420
|
newIdsGrouped[scopeName].forEach(id => {
|
|
557
421
|
if (listIds.hasWithoutScopeAndVersion(id)) {
|
|
558
422
|
throw new Error(`unable to export a lane with a new component "${id.toString()}", which has the default-scope "${scopeName}".
|
|
@@ -561,31 +425,24 @@ class ExportMain {
|
|
|
561
425
|
});
|
|
562
426
|
});
|
|
563
427
|
};
|
|
428
|
+
|
|
564
429
|
/**
|
|
565
430
|
* by default, when exporting a lane, it traverse from the Lane's head and therefore it may skip the main head.
|
|
566
431
|
* later, if for some reason the original component was deleted in its scope, the head object will be missing.
|
|
567
432
|
*/
|
|
568
|
-
|
|
569
|
-
|
|
570
433
|
const addMainHeadIfPossible = async (allHashes, modelComponent) => {
|
|
571
434
|
const head = modelComponent.head;
|
|
572
435
|
if (!head) return;
|
|
573
436
|
if (allHashes.find(h => h.hash === head.hash)) return; // head is already in the list
|
|
574
|
-
|
|
575
437
|
if (!(await scope.objects.has(head))) return; // it should not happen. but if it does, we don't want to block the export
|
|
576
|
-
|
|
577
438
|
allHashes.push(head);
|
|
578
439
|
};
|
|
579
|
-
|
|
580
440
|
const getVersionsToExport = async (modelComponent, lane) => {
|
|
581
441
|
const localTagsOrHashes = await modelComponent.getLocalTagsOrHashes(scope.objects);
|
|
582
|
-
|
|
583
442
|
if (!allVersions && !lane) {
|
|
584
443
|
return localTagsOrHashes;
|
|
585
444
|
}
|
|
586
|
-
|
|
587
445
|
let stopAt;
|
|
588
|
-
|
|
589
446
|
if (lane && !allVersions) {
|
|
590
447
|
// if lane is exported, components from other remotes may be part of this lane. we need their history.
|
|
591
448
|
// because their history could already exist on the remote from previous exports, we search this id in all
|
|
@@ -593,7 +450,6 @@ class ExportMain {
|
|
|
593
450
|
stopAt = await scope.objects.remoteLanes.getRefsFromAllLanesOnScope(lane.scope, modelComponent.toBitId());
|
|
594
451
|
if (modelComponent.laneHeadRemote) stopAt.push(modelComponent.laneHeadRemote);
|
|
595
452
|
}
|
|
596
|
-
|
|
597
453
|
const allHashes = await (0, _traverseVersions().getAllVersionHashes)({
|
|
598
454
|
modelComponent,
|
|
599
455
|
repo: scope.objects,
|
|
@@ -602,39 +458,29 @@ class ExportMain {
|
|
|
602
458
|
await addMainHeadIfPossible(allHashes, modelComponent);
|
|
603
459
|
return modelComponent.switchHashesWithTagsIfExist(allHashes);
|
|
604
460
|
};
|
|
605
|
-
|
|
606
461
|
await validateTargetScopeForLanes();
|
|
607
462
|
const groupedByScopeString = Object.keys(idsGroupedByScope).map(scopeName => `scope "${scopeName}": ${idsGroupedByScope[scopeName].toString()}`).join(', ');
|
|
608
|
-
|
|
609
463
|
_logger().default.debug(`export-scope-components, export to the following scopes ${groupedByScopeString}`);
|
|
610
|
-
|
|
611
464
|
const exportVersions = [];
|
|
612
|
-
|
|
613
465
|
const populateExportMetadata = async modelComponent => {
|
|
614
466
|
const localTagsOrHashes = await modelComponent.getLocalTagsOrHashes(scope.objects);
|
|
615
467
|
const head = modelComponent.getHeadRegardlessOfLane();
|
|
616
|
-
|
|
617
468
|
if (!head) {
|
|
618
469
|
throw new Error(`unable to export ${modelComponent.id()}, head is missing`);
|
|
619
470
|
}
|
|
620
|
-
|
|
621
471
|
exportVersions.push({
|
|
622
472
|
id: modelComponent.toBitId(),
|
|
623
473
|
versions: localTagsOrHashes,
|
|
624
474
|
head
|
|
625
475
|
});
|
|
626
476
|
};
|
|
627
|
-
|
|
628
477
|
const getUpdatedObjectsToExport = async (remoteNameStr, bitIds, lane) => {
|
|
629
478
|
bitIds.throwForDuplicationIgnoreVersion();
|
|
630
479
|
const remote = await scopeRemotes.resolve(remoteNameStr, scope);
|
|
631
|
-
|
|
632
480
|
const idsToChangeLocally = _bitId().BitIds.fromArray(bitIds.filter(id => !id.scope || id.scope === remoteNameStr));
|
|
633
|
-
|
|
634
481
|
const componentsAndObjects = [];
|
|
635
482
|
const objectList = new (_objectList().ObjectList)();
|
|
636
483
|
const objectListPerName = {};
|
|
637
|
-
|
|
638
484
|
const processModelComponent = async modelComponent => {
|
|
639
485
|
const versionToExport = await getVersionsToExport(modelComponent, lane);
|
|
640
486
|
modelComponent.clearStateData();
|
|
@@ -668,30 +514,25 @@ class ExportMain {
|
|
|
668
514
|
objectListPerName[modelComponent.name] = new (_objectList().ObjectList)(allObjectsData);
|
|
669
515
|
objectList.addIfNotExist(allObjectsData);
|
|
670
516
|
};
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
517
|
+
const modelComponents = await (0, _pMapSeries().default)(bitIds, id => scope.getModelComponent(id));
|
|
518
|
+
// super important! otherwise, the processModelComponent() changes objects in memory, while the key remains the same
|
|
519
|
+
scope.objects.clearCache();
|
|
520
|
+
// don't use Promise.all, otherwise, it'll throw "JavaScript heap out of memory" on a large set of data
|
|
676
521
|
await (0, _pMapSeries().default)(modelComponents, processModelComponent);
|
|
677
|
-
|
|
678
522
|
if (lane) {
|
|
679
523
|
lane.components.forEach(c => {
|
|
680
524
|
const idWithFutureScope = idsWithFutureScope.searchWithoutScopeAndVersion(c.id);
|
|
681
525
|
c.id = c.id.hasScope() ? c.id : c.id.changeScope((idWithFutureScope === null || idWithFutureScope === void 0 ? void 0 : idWithFutureScope.scope) || lane.scope);
|
|
682
526
|
});
|
|
683
|
-
|
|
684
527
|
if (lane.readmeComponent) {
|
|
685
528
|
lane.readmeComponent.id = lane.readmeComponent.id.hasScope() ? lane.readmeComponent.id : lane.readmeComponent.id.changeScope(lane.scope);
|
|
686
529
|
}
|
|
687
|
-
|
|
688
530
|
const laneData = {
|
|
689
531
|
ref: lane.hash(),
|
|
690
532
|
buffer: await lane.compress()
|
|
691
533
|
};
|
|
692
534
|
objectList.addIfNotExist([laneData]);
|
|
693
535
|
}
|
|
694
|
-
|
|
695
536
|
return {
|
|
696
537
|
remote,
|
|
697
538
|
objectList,
|
|
@@ -700,9 +541,7 @@ class ExportMain {
|
|
|
700
541
|
componentsAndObjects
|
|
701
542
|
};
|
|
702
543
|
};
|
|
703
|
-
|
|
704
544
|
const manyObjectsPerRemote = laneObject ? [await getUpdatedObjectsToExport(laneObject.scope, ids, laneObject)] : await (0, _pMapSeries().default)(Object.keys(idsGroupedByScope), scopeName => getUpdatedObjectsToExport(scopeName, idsGroupedByScope[scopeName], laneObject));
|
|
705
|
-
|
|
706
545
|
const getExportMetadata = async () => {
|
|
707
546
|
const exportMetadata = new (_models().ExportMetadata)({
|
|
708
547
|
exportVersions
|
|
@@ -715,7 +554,6 @@ class ExportMain {
|
|
|
715
554
|
};
|
|
716
555
|
return exportMetadataItem;
|
|
717
556
|
};
|
|
718
|
-
|
|
719
557
|
const pushAllToCentralHub = async () => {
|
|
720
558
|
const objectList = this.transformToOneObjectListWithScopeData(manyObjectsPerRemote);
|
|
721
559
|
objectList.addIfNotExist([await getExportMetadata()]);
|
|
@@ -726,26 +564,22 @@ class ExportMain {
|
|
|
726
564
|
successIds,
|
|
727
565
|
errors
|
|
728
566
|
} = pushResults;
|
|
729
|
-
|
|
730
567
|
if (failedScopes.length) {
|
|
731
568
|
throw new (_persistFailed().PersistFailed)(failedScopes, errors);
|
|
732
569
|
}
|
|
733
|
-
|
|
734
570
|
const exportedBitIds = successIds.map(id => _bitId().BitId.parse(id, true));
|
|
735
|
-
|
|
736
571
|
if (manyObjectsPerRemote.length === 1) {
|
|
737
572
|
// when on a lane, it's always exported to the lane. and the ids can be from different scopes, so having the
|
|
738
573
|
// filter below, will remove these components from the output of bit-export at the end.
|
|
739
574
|
manyObjectsPerRemote[0].exportedIds = exportedBitIds.map(id => id.toString());
|
|
740
575
|
} else {
|
|
741
576
|
manyObjectsPerRemote.forEach(objectPerRemote => {
|
|
742
|
-
const idsPerScope = exportedBitIds.filter(id => id.scope === objectPerRemote.remote.name);
|
|
743
|
-
|
|
577
|
+
const idsPerScope = exportedBitIds.filter(id => id.scope === objectPerRemote.remote.name);
|
|
578
|
+
// it's possible that idsPerScope is an empty array, in case the objects were exported already before
|
|
744
579
|
objectPerRemote.exportedIds = idsPerScope.map(id => id.toString());
|
|
745
580
|
});
|
|
746
581
|
}
|
|
747
582
|
};
|
|
748
|
-
|
|
749
583
|
const updateLocalObjects = async lane => {
|
|
750
584
|
return (0, _pMapSeries().default)(manyObjectsPerRemote, async objectsPerRemote => {
|
|
751
585
|
const {
|
|
@@ -754,34 +588,31 @@ class ExportMain {
|
|
|
754
588
|
componentsAndObjects,
|
|
755
589
|
exportedIds
|
|
756
590
|
} = objectsPerRemote;
|
|
757
|
-
const remoteNameStr = remote.name;
|
|
591
|
+
const remoteNameStr = remote.name;
|
|
592
|
+
// on Harmony, version hashes don't change, the new versions will replace the old ones.
|
|
758
593
|
// on the legacy, even when the hash changed, it's fine to have the old objects laying around.
|
|
759
594
|
// (could be removed in the future by some garbage collection).
|
|
760
|
-
|
|
761
595
|
const removeComponentVersions = false;
|
|
762
596
|
const refsToRemove = await Promise.all(idsToChangeLocally.map(id => scope.sources.getRefsForComponentRemoval(id, removeComponentVersions)));
|
|
763
|
-
scope.objects.removeManyObjects(refsToRemove.flat());
|
|
764
|
-
|
|
597
|
+
scope.objects.removeManyObjects(refsToRemove.flat());
|
|
598
|
+
// @ts-ignore
|
|
765
599
|
idsToChangeLocally.forEach(id => {
|
|
766
600
|
var _idsWithFutureScope$s;
|
|
767
|
-
|
|
768
601
|
scope.createSymlink(id, ((_idsWithFutureScope$s = idsWithFutureScope.searchWithoutScopeAndVersion(id)) === null || _idsWithFutureScope$s === void 0 ? void 0 : _idsWithFutureScope$s.scope) || remoteNameStr);
|
|
769
602
|
});
|
|
770
|
-
componentsAndObjects.forEach(componentObject => scope.sources.put(componentObject));
|
|
603
|
+
componentsAndObjects.forEach(componentObject => scope.sources.put(componentObject));
|
|
771
604
|
|
|
605
|
+
// update lanes
|
|
772
606
|
if (lane) {
|
|
773
607
|
if (idsToChangeLocally.length) {
|
|
774
608
|
// otherwise, we don't want to update scope-name of components in the lane object
|
|
775
609
|
scope.objects.add(lane);
|
|
776
610
|
}
|
|
777
|
-
|
|
778
611
|
await scope.objects.remoteLanes.syncWithLaneObject(remoteNameStr, lane);
|
|
779
612
|
}
|
|
780
|
-
|
|
781
613
|
if (isOnMain && !lane) {
|
|
782
614
|
// all exported from main
|
|
783
615
|
const remoteLaneId = _laneId().LaneId.from(_laneId().DEFAULT_LANE, remoteNameStr);
|
|
784
|
-
|
|
785
616
|
await scope.objects.remoteLanes.loadRemoteLane(remoteLaneId);
|
|
786
617
|
await Promise.all(componentsAndObjects.map(async ({
|
|
787
618
|
component
|
|
@@ -789,15 +620,12 @@ class ExportMain {
|
|
|
789
620
|
await scope.objects.remoteLanes.addEntry(remoteLaneId, component.toBitId(), component.getHead());
|
|
790
621
|
}));
|
|
791
622
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
623
|
+
await scope.objects.persist();
|
|
624
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
625
|
+
const newIdsOnRemote = exportedIds.map(id => _bitId().BitId.parse(id, true));
|
|
626
|
+
// remove version. exported component might have multiple versions exported
|
|
797
627
|
const idsWithRemoteScope = newIdsOnRemote.map(id => id.changeVersion(undefined));
|
|
798
|
-
|
|
799
628
|
const idsWithRemoteScopeUniq = _bitId().BitIds.uniqFromArray(idsWithRemoteScope);
|
|
800
|
-
|
|
801
629
|
return {
|
|
802
630
|
newIdsOnRemote,
|
|
803
631
|
exported: idsWithRemoteScopeUniq,
|
|
@@ -805,7 +633,6 @@ class ExportMain {
|
|
|
805
633
|
};
|
|
806
634
|
});
|
|
807
635
|
};
|
|
808
|
-
|
|
809
636
|
if (resumeExportId) {
|
|
810
637
|
const remotes = manyObjectsPerRemote.map(o => o.remote);
|
|
811
638
|
await (0, _exportScopeComponents().validateRemotes)(remotes, resumeExportId);
|
|
@@ -816,9 +643,7 @@ class ExportMain {
|
|
|
816
643
|
// await pushToRemotes();
|
|
817
644
|
await this.pushToRemotesCarefully(manyObjectsPerRemote, resumeExportId);
|
|
818
645
|
}
|
|
819
|
-
|
|
820
646
|
_loader().default.start('updating data locally...');
|
|
821
|
-
|
|
822
647
|
const results = await updateLocalObjects(laneObject);
|
|
823
648
|
return {
|
|
824
649
|
newIdsOnRemote: _ramda().default.flatten(results.map(r => r.newIdsOnRemote)),
|
|
@@ -826,7 +651,6 @@ class ExportMain {
|
|
|
826
651
|
updatedLocally: _bitId().BitIds.uniqFromArray(_ramda().default.flatten(results.map(r => r.updatedLocally)))
|
|
827
652
|
};
|
|
828
653
|
}
|
|
829
|
-
|
|
830
654
|
transformToOneObjectListWithScopeData(objectsPerRemote) {
|
|
831
655
|
const objectList = new (_objectList().ObjectList)();
|
|
832
656
|
objectsPerRemote.forEach(objPerRemote => {
|
|
@@ -835,7 +659,6 @@ class ExportMain {
|
|
|
835
659
|
});
|
|
836
660
|
return objectList;
|
|
837
661
|
}
|
|
838
|
-
|
|
839
662
|
async pushToRemotesCarefully(manyObjectsPerRemote, resumeExportId) {
|
|
840
663
|
const remotes = manyObjectsPerRemote.map(o => o.remote);
|
|
841
664
|
const clientId = resumeExportId || Date.now().toString();
|
|
@@ -843,16 +666,13 @@ class ExportMain {
|
|
|
843
666
|
await (0, _exportScopeComponents().validateRemotes)(remotes, clientId, Boolean(resumeExportId));
|
|
844
667
|
await (0, _exportScopeComponents().persistRemotes)(manyObjectsPerRemote, clientId);
|
|
845
668
|
}
|
|
846
|
-
|
|
847
669
|
async pushRemotesPendingDir(clientId, manyObjectsPerRemote, resumeExportId) {
|
|
848
670
|
if (resumeExportId) {
|
|
849
|
-
_logger().default.debug('pushRemotesPendingDir - skip as the resumeExportId was passed');
|
|
671
|
+
_logger().default.debug('pushRemotesPendingDir - skip as the resumeExportId was passed');
|
|
672
|
+
// no need to transfer the objects, they're already on the server. also, since this clientId
|
|
850
673
|
// exists already on the remote pending-dir, it'll cause a collision.
|
|
851
|
-
|
|
852
|
-
|
|
853
674
|
return;
|
|
854
675
|
}
|
|
855
|
-
|
|
856
676
|
const pushOptions = {
|
|
857
677
|
clientId
|
|
858
678
|
};
|
|
@@ -862,33 +682,27 @@ class ExportMain {
|
|
|
862
682
|
remote,
|
|
863
683
|
objectList
|
|
864
684
|
} = objectsPerRemote;
|
|
865
|
-
|
|
866
685
|
_loader().default.start(`transferring ${objectList.count()} objects to the remote "${remote.name}"...`);
|
|
867
|
-
|
|
868
686
|
try {
|
|
869
687
|
await remote.pushMany(objectList, pushOptions, {});
|
|
870
|
-
|
|
871
688
|
_logger().default.debugAndAddBreadCrumb('export-scope-components.pushRemotesPendingDir', 'successfully pushed all objects to the pending-dir directory on the remote');
|
|
872
|
-
|
|
873
689
|
pushedRemotes.push(remote);
|
|
874
690
|
} catch (err) {
|
|
875
691
|
_logger().default.warnAndAddBreadCrumb('exportMany', 'failed pushing objects to the remote');
|
|
876
|
-
|
|
877
692
|
await (0, _exportScopeComponents().removePendingDirs)(pushedRemotes, clientId);
|
|
878
693
|
throw err;
|
|
879
694
|
}
|
|
880
695
|
});
|
|
881
696
|
}
|
|
882
|
-
|
|
883
697
|
shouldPushToCentralHub(manyObjectsPerRemote, scopeRemotes, originDirectly = false) {
|
|
884
698
|
if (originDirectly) return false;
|
|
885
699
|
const hubRemotes = manyObjectsPerRemote.filter(m => scopeRemotes.isHub(m.remote.name));
|
|
886
700
|
if (!hubRemotes.length) return false;
|
|
887
701
|
if (hubRemotes.length === manyObjectsPerRemote.length) return true; // all are hub
|
|
888
702
|
// @todo: maybe create a flag "no-central" to support this workflow
|
|
889
|
-
|
|
890
703
|
throw new (_bitError().BitError)(`some of your components are configured to be exported to a local scope and some to the bit.cloud hub. this is not supported`);
|
|
891
704
|
}
|
|
705
|
+
|
|
892
706
|
/**
|
|
893
707
|
* Component and dependencies id changes:
|
|
894
708
|
* When exporting components with dependencies to a bare-scope, some of the dependencies may be created locally and as
|
|
@@ -897,8 +711,6 @@ class ExportMain {
|
|
|
897
711
|
*
|
|
898
712
|
* This is the Harmony version of "convertToCorrectScope". No more codemod and no more hash changes.
|
|
899
713
|
*/
|
|
900
|
-
|
|
901
|
-
|
|
902
714
|
async convertToCorrectScopeHarmony(scope, componentsObjects, remoteScope, exportingIds, idsWithFutureScope, shouldFork = false // not in used currently, but might be needed soon
|
|
903
715
|
) {
|
|
904
716
|
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
@@ -911,20 +723,17 @@ class ExportMain {
|
|
|
911
723
|
}));
|
|
912
724
|
const shouldChangeScope = shouldFork ? remoteScope !== componentsObjects.component.scope : !componentsObjects.component.scope;
|
|
913
725
|
const hasComponentChanged = shouldChangeScope;
|
|
914
|
-
|
|
915
726
|
if (shouldChangeScope) {
|
|
916
727
|
const idWithFutureScope = idsWithFutureScope.searchWithoutScopeAndVersion(componentsObjects.component.toBitId());
|
|
917
728
|
componentsObjects.component.scope = (idWithFutureScope === null || idWithFutureScope === void 0 ? void 0 : idWithFutureScope.scope) || remoteScope;
|
|
918
|
-
}
|
|
919
|
-
|
|
729
|
+
}
|
|
920
730
|
|
|
731
|
+
// return true if one of the versions has changed or the component itself
|
|
921
732
|
return haveVersionsChanged.some(x => x) || hasComponentChanged;
|
|
922
|
-
|
|
923
733
|
function changeDependencyScope(version) {
|
|
924
734
|
let hasChanged = false;
|
|
925
735
|
version.getAllDependencies().forEach(dependency => {
|
|
926
736
|
const updatedScope = getIdWithUpdatedScope(dependency.id);
|
|
927
|
-
|
|
928
737
|
if (!updatedScope.isEqual(dependency.id)) {
|
|
929
738
|
hasChanged = true;
|
|
930
739
|
dependency.id = updatedScope;
|
|
@@ -932,21 +741,17 @@ class ExportMain {
|
|
|
932
741
|
});
|
|
933
742
|
const ids = version.flattenedDependencies;
|
|
934
743
|
const needsChange = ids.some(id => id.scope !== remoteScope);
|
|
935
|
-
|
|
936
744
|
if (needsChange) {
|
|
937
745
|
version.flattenedDependencies = getBitIdsWithUpdatedScope(ids);
|
|
938
746
|
hasChanged = true;
|
|
939
747
|
}
|
|
940
|
-
|
|
941
748
|
return hasChanged;
|
|
942
749
|
}
|
|
943
|
-
|
|
944
750
|
function changeExtensionsScope(version) {
|
|
945
751
|
let hasChanged = false;
|
|
946
752
|
version.extensions.forEach(ext => {
|
|
947
753
|
if (ext.extensionId) {
|
|
948
754
|
const updatedScope = getIdWithUpdatedScope(ext.extensionId);
|
|
949
|
-
|
|
950
755
|
if (!updatedScope.isEqual(ext.extensionId)) {
|
|
951
756
|
hasChanged = true;
|
|
952
757
|
ext.extensionId = updatedScope;
|
|
@@ -955,104 +760,79 @@ class ExportMain {
|
|
|
955
760
|
});
|
|
956
761
|
return hasChanged;
|
|
957
762
|
}
|
|
958
|
-
|
|
959
763
|
function getIdWithUpdatedScope(dependencyId) {
|
|
960
764
|
if (dependencyId.scope === remoteScope) {
|
|
961
765
|
return dependencyId; // nothing has changed
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
|
|
766
|
+
}
|
|
767
|
+
// either, dependencyId is new, or this dependency is among the components to export (in case of fork)
|
|
965
768
|
if (!dependencyId.scope || exportingIds.hasWithoutVersion(dependencyId)) {
|
|
966
|
-
const depId = _models().ModelComponent.fromBitId(dependencyId);
|
|
967
|
-
|
|
968
|
-
|
|
769
|
+
const depId = _models().ModelComponent.fromBitId(dependencyId);
|
|
770
|
+
// todo: use 'load' for async and switch the foreach with map.
|
|
969
771
|
const dependencyObject = scope.objects.loadSync(depId.hash());
|
|
970
|
-
|
|
971
772
|
if (dependencyObject instanceof _models().Symlink) {
|
|
972
773
|
return dependencyId.changeScope(dependencyObject.realScope);
|
|
973
774
|
}
|
|
974
|
-
|
|
975
775
|
const currentlyExportedDep = idsWithFutureScope.searchWithoutScopeAndVersion(dependencyId);
|
|
976
|
-
|
|
977
776
|
if (currentlyExportedDep && currentlyExportedDep.scope) {
|
|
978
777
|
// it's possible that a dependency has a different defaultScope settings.
|
|
979
778
|
return dependencyId.changeScope(currentlyExportedDep.scope);
|
|
980
779
|
}
|
|
981
|
-
|
|
982
780
|
return dependencyId.changeScope(remoteScope);
|
|
983
781
|
}
|
|
984
|
-
|
|
985
782
|
return dependencyId;
|
|
986
783
|
}
|
|
987
|
-
|
|
988
784
|
function getBitIdsWithUpdatedScope(bitIds) {
|
|
989
785
|
const updatedIds = bitIds.map(id => getIdWithUpdatedScope(id));
|
|
990
786
|
return _bitId().BitIds.fromArray(updatedIds);
|
|
991
787
|
}
|
|
992
788
|
}
|
|
993
|
-
|
|
994
789
|
async removeFromStagedConfig(ids) {
|
|
995
790
|
const componentIds = await this.workspace.resolveMultipleComponentIds(ids);
|
|
996
791
|
const stagedConfig = await this.workspace.scope.getStagedConfig();
|
|
997
792
|
componentIds.map(compId => stagedConfig.removeComponentConfig(compId));
|
|
998
793
|
await stagedConfig.write();
|
|
999
794
|
}
|
|
1000
|
-
|
|
1001
795
|
async getComponentsToExport(ids, includeNonStaged) {
|
|
1002
796
|
const consumer = this.workspace.consumer;
|
|
1003
797
|
const componentsList = new (_componentsList().default)(consumer);
|
|
1004
798
|
const idsHaveWildcard = (0, _hasWildcard().default)(ids);
|
|
1005
|
-
|
|
1006
799
|
const filterNonScopeIfNeeded = async bitIds => {
|
|
1007
800
|
const idsWithFutureScope = await this.getIdsWithFutureScope(bitIds);
|
|
1008
|
-
|
|
1009
801
|
const [idsToExport, missingScope] = _ramda().default.partition(id => {
|
|
1010
802
|
const idWithFutureScope = idsWithFutureScope.searchWithoutScopeAndVersion(id);
|
|
1011
803
|
if (!idWithFutureScope) throw new Error(`idsWithFutureScope is missing ${id.toString()}`);
|
|
1012
804
|
return idWithFutureScope.hasScope();
|
|
1013
805
|
}, bitIds);
|
|
1014
|
-
|
|
1015
806
|
return {
|
|
1016
807
|
idsToExport: _bitId().BitIds.fromArray(idsToExport),
|
|
1017
808
|
missingScope,
|
|
1018
809
|
idsWithFutureScope
|
|
1019
810
|
};
|
|
1020
811
|
};
|
|
1021
|
-
|
|
1022
812
|
if (isUserTryingToExportLanes(consumer)) {
|
|
1023
813
|
if (ids.length) {
|
|
1024
814
|
throw new (_generalError().default)(`when checked out to a lane, all its components are exported. please omit the ids`);
|
|
1025
815
|
}
|
|
1026
|
-
|
|
1027
816
|
const {
|
|
1028
817
|
componentsToExport,
|
|
1029
818
|
laneObject
|
|
1030
819
|
} = await this.getLaneCompIdsToExport(consumer, includeNonStaged);
|
|
1031
820
|
const loaderMsg = componentsToExport.length > 1 ? _loaderMessages().BEFORE_EXPORTS : _loaderMessages().BEFORE_EXPORT;
|
|
1032
|
-
|
|
1033
821
|
_loader().default.start(loaderMsg);
|
|
1034
|
-
|
|
1035
822
|
const filtered = await filterNonScopeIfNeeded(componentsToExport);
|
|
1036
823
|
return _objectSpread(_objectSpread({}, filtered), {}, {
|
|
1037
824
|
laneObject
|
|
1038
825
|
});
|
|
1039
826
|
}
|
|
1040
|
-
|
|
1041
827
|
if (!ids.length || idsHaveWildcard) {
|
|
1042
828
|
_loader().default.start(_loaderMessages().BEFORE_LOADING_COMPONENTS);
|
|
1043
|
-
|
|
1044
829
|
const exportPendingComponents = includeNonStaged ? await componentsList.listNonNewComponentsIds() : await componentsList.listExportPendingComponentsIds();
|
|
1045
830
|
const componentsToExport = idsHaveWildcard ? _componentsList().default.filterComponentsByWildcard(exportPendingComponents, ids) : exportPendingComponents;
|
|
1046
831
|
const loaderMsg = componentsToExport.length > 1 ? _loaderMessages().BEFORE_EXPORTS : _loaderMessages().BEFORE_EXPORT;
|
|
1047
|
-
|
|
1048
832
|
_loader().default.start(loaderMsg);
|
|
1049
|
-
|
|
1050
833
|
return filterNonScopeIfNeeded(componentsToExport);
|
|
1051
834
|
}
|
|
1052
|
-
|
|
1053
835
|
_loader().default.start(_loaderMessages().BEFORE_EXPORT); // show single export
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
836
|
const parsedIds = await Promise.all(ids.map(id => getParsedId(consumer, id)));
|
|
1057
837
|
const statuses = await consumer.getManyComponentsStatuses(parsedIds);
|
|
1058
838
|
statuses.forEach(({
|
|
@@ -1065,70 +845,55 @@ class ExportMain {
|
|
|
1065
845
|
});
|
|
1066
846
|
return filterNonScopeIfNeeded(_bitId().BitIds.fromArray(parsedIds));
|
|
1067
847
|
}
|
|
1068
|
-
|
|
1069
848
|
async getIdsWithFutureScope(ids) {
|
|
1070
849
|
const idsArrayP = ids.map(async id => {
|
|
1071
850
|
if (id.hasScope()) return id;
|
|
1072
851
|
const componentId = await this.workspace.resolveComponentId(id);
|
|
1073
852
|
const finalScope = await this.workspace.componentDefaultScope(componentId);
|
|
1074
|
-
|
|
1075
853
|
if (finalScope) {
|
|
1076
854
|
return id.changeScope(finalScope);
|
|
1077
855
|
}
|
|
1078
|
-
|
|
1079
856
|
return id;
|
|
1080
857
|
});
|
|
1081
858
|
const idsArray = await Promise.all(idsArrayP);
|
|
1082
859
|
return _bitId().BitIds.fromArray(idsArray);
|
|
1083
860
|
}
|
|
1084
|
-
|
|
1085
861
|
async getLaneCompIdsToExport(consumer, includeNonStaged) {
|
|
1086
862
|
const currentLaneId = consumer.getCurrentLaneId();
|
|
1087
863
|
const laneObject = await consumer.scope.loadLane(currentLaneId);
|
|
1088
|
-
|
|
1089
864
|
if (!laneObject) {
|
|
1090
865
|
throw new Error(`fatal: unable to load the current lane object (${currentLaneId.toString()})`);
|
|
1091
866
|
}
|
|
1092
|
-
|
|
1093
867
|
_loader().default.start(_loaderMessages().BEFORE_LOADING_COMPONENTS);
|
|
1094
|
-
|
|
1095
868
|
const componentsList = new (_componentsList().default)(consumer);
|
|
1096
869
|
const componentsToExportWithoutRemoved = includeNonStaged ? await componentsList.listNonNewComponentsIds() : await componentsList.listExportPendingComponentsIds(laneObject);
|
|
1097
870
|
const removedStagedBitIds = await this.getRemovedStagedBitIds();
|
|
1098
|
-
|
|
1099
871
|
const componentsToExport = _bitId().BitIds.uniqFromArray([...componentsToExportWithoutRemoved, ...removedStagedBitIds]);
|
|
1100
|
-
|
|
1101
872
|
return {
|
|
1102
873
|
componentsToExport,
|
|
1103
874
|
laneObject
|
|
1104
875
|
};
|
|
1105
876
|
}
|
|
1106
|
-
|
|
1107
877
|
async getRemovedStagedBitIds() {
|
|
1108
878
|
const removedStaged = await this.remove.getRemovedStaged();
|
|
1109
879
|
return _bitId().BitIds.fromArray(removedStaged.map(r => r._legacy).map(id => id.changeVersion(undefined)));
|
|
1110
880
|
}
|
|
1111
|
-
|
|
1112
881
|
static async provider([cli, scope, workspace, remove, depResolver]) {
|
|
1113
882
|
const exportMain = new ExportMain(workspace, remove, depResolver);
|
|
1114
883
|
cli.register(new (_resumeExportCmd().ResumeExportCmd)(scope), new (_exportCmd().ExportCmd)(exportMain));
|
|
1115
884
|
return exportMain;
|
|
1116
885
|
}
|
|
1117
|
-
|
|
1118
886
|
}
|
|
1119
|
-
|
|
1120
887
|
exports.ExportMain = ExportMain;
|
|
1121
888
|
(0, _defineProperty2().default)(ExportMain, "runtime", _cli().MainRuntime);
|
|
1122
889
|
(0, _defineProperty2().default)(ExportMain, "dependencies", [_cli().CLIAspect, _scope().default, _workspace().default, _remove().RemoveAspect, _dependencyResolver().DependencyResolverAspect]);
|
|
1123
|
-
|
|
1124
890
|
_export().ExportAspect.addRuntime(ExportMain);
|
|
1125
|
-
|
|
1126
891
|
function _updateIdsOnBitMap(bitMap, componentsIds) {
|
|
1127
892
|
const updatedIds = [];
|
|
1128
893
|
const nonExistOnBitMap = new (_bitId().BitIds)();
|
|
1129
894
|
componentsIds.forEach(componentsId => {
|
|
1130
|
-
const resultId = bitMap.updateComponentId(componentsId, true);
|
|
1131
|
-
|
|
895
|
+
const resultId = bitMap.updateComponentId(componentsId, true);
|
|
896
|
+
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
1132
897
|
if (resultId.hasVersion()) updatedIds.push(resultId);else nonExistOnBitMap.push(resultId);
|
|
1133
898
|
});
|
|
1134
899
|
return {
|
|
@@ -1136,14 +901,13 @@ function _updateIdsOnBitMap(bitMap, componentsIds) {
|
|
|
1136
901
|
nonExistOnBitMap
|
|
1137
902
|
};
|
|
1138
903
|
}
|
|
1139
|
-
|
|
1140
904
|
async function getParsedId(consumer, id) {
|
|
1141
905
|
// reason why not calling `consumer.getParsedId()` first is because a component might not be on
|
|
1142
906
|
// .bitmap and only in the scope. we support this case and enable to export
|
|
1143
907
|
const parsedId = await consumer.scope.getParsedId(id);
|
|
1144
|
-
if (parsedId.hasScope()) return parsedId;
|
|
908
|
+
if (parsedId.hasScope()) return parsedId;
|
|
909
|
+
// parsing id from the scope, doesn't provide the scope-name in case it's missing, in this case
|
|
1145
910
|
// get the id including the scope from the consumer.
|
|
1146
|
-
|
|
1147
911
|
try {
|
|
1148
912
|
return consumer.getParsedId(id);
|
|
1149
913
|
} catch (err) {
|
|
@@ -1151,7 +915,6 @@ async function getParsedId(consumer, id) {
|
|
|
1151
915
|
return parsedId;
|
|
1152
916
|
}
|
|
1153
917
|
}
|
|
1154
|
-
|
|
1155
918
|
async function linkComponents(ids, consumer) {
|
|
1156
919
|
// we don't have much of a choice here, we have to load all the exported components in order to link them
|
|
1157
920
|
// some of the components might be authored, some might be imported.
|
|
@@ -1160,53 +923,41 @@ async function linkComponents(ids, consumer) {
|
|
|
1160
923
|
const nodeModuleLinker = new (_links().NodeModuleLinker)(components, consumer, consumer.bitMap);
|
|
1161
924
|
await nodeModuleLinker.link();
|
|
1162
925
|
}
|
|
1163
|
-
|
|
1164
926
|
async function ejectExportedComponents(componentsIds) {
|
|
1165
927
|
const consumer = await (0, _consumer().loadConsumer)(undefined, true);
|
|
1166
928
|
let ejectResults;
|
|
1167
|
-
|
|
1168
929
|
try {
|
|
1169
930
|
const ejectComponents = new (_ejectComponents().default)(consumer, componentsIds);
|
|
1170
931
|
ejectResults = await ejectComponents.eject();
|
|
1171
932
|
} catch (err) {
|
|
1172
933
|
const ejectErr = `The components ${componentsIds.map(c => c.toString()).join(', ')} were exported successfully.
|
|
1173
934
|
However, the eject operation has failed due to an error: ${err.msg || err}`;
|
|
1174
|
-
|
|
1175
935
|
_logger().default.error(ejectErr, err);
|
|
1176
|
-
|
|
1177
936
|
throw new Error(ejectErr);
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
|
|
937
|
+
}
|
|
938
|
+
// run the consumer.onDestroy() again, to write the changes done by the eject action to .bitmap
|
|
1181
939
|
await consumer.onDestroy();
|
|
1182
940
|
return ejectResults;
|
|
1183
941
|
}
|
|
1184
|
-
|
|
1185
942
|
function _throwForUnsnappedLaneReadme(lane) {
|
|
1186
943
|
var _lane$getComponentHea;
|
|
1187
|
-
|
|
1188
944
|
const readmeComponent = lane.readmeComponent;
|
|
1189
945
|
const isValid = (readmeComponent === null || readmeComponent === void 0 ? void 0 : readmeComponent.head) && lane.getComponent(readmeComponent.id) && ((_lane$getComponentHea = lane.getComponentHead(readmeComponent.id)) === null || _lane$getComponentHea === void 0 ? void 0 : _lane$getComponentHea.isEqual(readmeComponent === null || readmeComponent === void 0 ? void 0 : readmeComponent.head));
|
|
1190
|
-
|
|
1191
946
|
if (!isValid) {
|
|
1192
947
|
throw new (_bitError().BitError)(`${lane === null || lane === void 0 ? void 0 : lane.name} has a readme component ${readmeComponent.id} that hasn't been snapped on the lane.
|
|
1193
948
|
Please run either snap -a or snap ${readmeComponent.id} to snap the component on the lane before exporting it.`);
|
|
1194
949
|
}
|
|
1195
950
|
}
|
|
1196
|
-
|
|
1197
951
|
async function updateLanesAfterExport(consumer, lane) {
|
|
1198
952
|
const currentLane = consumer.getCurrentLaneId();
|
|
1199
953
|
const isCurrentLane = lane.name === currentLane.name;
|
|
1200
|
-
|
|
1201
954
|
if (!isCurrentLane) {
|
|
1202
955
|
throw new Error(`updateLanesAfterExport should get called only with current lane, got ${lane.name}, current ${currentLane.name}`);
|
|
1203
956
|
}
|
|
1204
|
-
|
|
1205
957
|
consumer.setCurrentLane(lane.toLaneId(), true);
|
|
1206
958
|
consumer.scope.scopeJson.removeLaneFromNew(lane.name);
|
|
1207
959
|
lane.isNew = false;
|
|
1208
960
|
}
|
|
1209
|
-
|
|
1210
961
|
function isUserTryingToExportLanes(consumer) {
|
|
1211
962
|
return consumer.isOnLane();
|
|
1212
963
|
}
|