@teambit/snapping 0.0.1
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/index.d.ts +4 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/snap-cmd.d.ts +25 -0
- package/dist/snap-cmd.js +175 -0
- package/dist/snap-cmd.js.map +1 -0
- package/dist/snapping.aspect.d.ts +2 -0
- package/dist/snapping.aspect.js +24 -0
- package/dist/snapping.aspect.js.map +1 -0
- package/dist/snapping.main.runtime.d.ts +46 -0
- package/dist/snapping.main.runtime.js +643 -0
- package/dist/snapping.main.runtime.js.map +1 -0
- package/dist/tag-cmd.d.ts +30 -0
- package/dist/tag-cmd.js +302 -0
- package/dist/tag-cmd.js.map +1 -0
- package/package-tar/teambit-snapping-0.0.1.tgz +0 -0
- package/package.json +91 -0
- package/preview-1648092203429.js +1 -0
- package/tsconfig.json +34 -0
- package/types/asset.d.ts +29 -0
- package/types/style.d.ts +42 -0
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
require("core-js/modules/es.array.flat.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.array.iterator.js");
|
|
8
|
+
|
|
9
|
+
require("core-js/modules/es.array.sort.js");
|
|
10
|
+
|
|
11
|
+
require("core-js/modules/es.array.unscopables.flat.js");
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/es.promise.js");
|
|
14
|
+
|
|
15
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
16
|
+
|
|
17
|
+
require("core-js/modules/es.string.trim.js");
|
|
18
|
+
|
|
19
|
+
Object.defineProperty(exports, "__esModule", {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
exports.SnappingMain = void 0;
|
|
23
|
+
|
|
24
|
+
function _defineProperty2() {
|
|
25
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
26
|
+
|
|
27
|
+
_defineProperty2 = function () {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function _cli() {
|
|
35
|
+
const data = require("@teambit/cli");
|
|
36
|
+
|
|
37
|
+
_cli = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function _componentIssues() {
|
|
45
|
+
const data = require("@teambit/component-issues");
|
|
46
|
+
|
|
47
|
+
_componentIssues = function () {
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function _community() {
|
|
55
|
+
const data = _interopRequireDefault(require("@teambit/community"));
|
|
56
|
+
|
|
57
|
+
_community = function () {
|
|
58
|
+
return data;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _workspace() {
|
|
65
|
+
const data = _interopRequireDefault(require("@teambit/workspace"));
|
|
66
|
+
|
|
67
|
+
_workspace = function () {
|
|
68
|
+
return data;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return data;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function _ramda() {
|
|
75
|
+
const data = _interopRequireDefault(require("ramda"));
|
|
76
|
+
|
|
77
|
+
_ramda = function () {
|
|
78
|
+
return data;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return data;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function _semver() {
|
|
85
|
+
const data = _interopRequireDefault(require("semver"));
|
|
86
|
+
|
|
87
|
+
_semver = function () {
|
|
88
|
+
return data;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function _lodash() {
|
|
95
|
+
const data = require("lodash");
|
|
96
|
+
|
|
97
|
+
_lodash = function () {
|
|
98
|
+
return data;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return data;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _analytics() {
|
|
105
|
+
const data = require("@teambit/legacy/dist/analytics/analytics");
|
|
106
|
+
|
|
107
|
+
_analytics = function () {
|
|
108
|
+
return data;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return data;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function _bitId() {
|
|
115
|
+
const data = require("@teambit/legacy/dist/bit-id");
|
|
116
|
+
|
|
117
|
+
_bitId = function () {
|
|
118
|
+
return data;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return data;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function _constants() {
|
|
125
|
+
const data = require("@teambit/legacy/dist/constants");
|
|
126
|
+
|
|
127
|
+
_constants = function () {
|
|
128
|
+
return data;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function _componentsList() {
|
|
135
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component/components-list"));
|
|
136
|
+
|
|
137
|
+
_componentsList = function () {
|
|
138
|
+
return data;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return data;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function _hooks() {
|
|
145
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/hooks"));
|
|
146
|
+
|
|
147
|
+
_hooks = function () {
|
|
148
|
+
return data;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return data;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function _hasWildcard() {
|
|
155
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/utils/string/has-wildcard"));
|
|
156
|
+
|
|
157
|
+
_hasWildcard = function () {
|
|
158
|
+
return data;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
return data;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function _semverHelper() {
|
|
165
|
+
const data = require("@teambit/legacy/dist/utils/semver-helper");
|
|
166
|
+
|
|
167
|
+
_semverHelper = function () {
|
|
168
|
+
return data;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
return data;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function _exceptions() {
|
|
175
|
+
const data = require("@teambit/legacy/dist/consumer/exceptions");
|
|
176
|
+
|
|
177
|
+
_exceptions = function () {
|
|
178
|
+
return data;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
return data;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function _loader() {
|
|
185
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/cli/loader"));
|
|
186
|
+
|
|
187
|
+
_loader = function () {
|
|
188
|
+
return data;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
return data;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function _tagModelComponent() {
|
|
195
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/scope/component-ops/tag-model-component"));
|
|
196
|
+
|
|
197
|
+
_tagModelComponent = function () {
|
|
198
|
+
return data;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
return data;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function _lanesIsDisabled() {
|
|
205
|
+
const data = require("@teambit/legacy/dist/consumer/lanes/exceptions/lanes-is-disabled");
|
|
206
|
+
|
|
207
|
+
_lanesIsDisabled = function () {
|
|
208
|
+
return data;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
return data;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function _componentsPendingImport() {
|
|
215
|
+
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component-ops/exceptions/components-pending-import"));
|
|
216
|
+
|
|
217
|
+
_componentsPendingImport = function () {
|
|
218
|
+
return data;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
return data;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function _logger() {
|
|
225
|
+
const data = require("@teambit/logger");
|
|
226
|
+
|
|
227
|
+
_logger = function () {
|
|
228
|
+
return data;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
return data;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function _failedLoadForTag() {
|
|
235
|
+
const data = require("@teambit/legacy/dist/consumer/component/exceptions/failed-load-for-tag");
|
|
236
|
+
|
|
237
|
+
_failedLoadForTag = function () {
|
|
238
|
+
return data;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
return data;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function _snapCmd() {
|
|
245
|
+
const data = require("./snap-cmd");
|
|
246
|
+
|
|
247
|
+
_snapCmd = function () {
|
|
248
|
+
return data;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
return data;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function _snapping() {
|
|
255
|
+
const data = require("./snapping.aspect");
|
|
256
|
+
|
|
257
|
+
_snapping = function () {
|
|
258
|
+
return data;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
return data;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function _tagCmd() {
|
|
265
|
+
const data = require("./tag-cmd");
|
|
266
|
+
|
|
267
|
+
_tagCmd = function () {
|
|
268
|
+
return data;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
return data;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
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; }
|
|
275
|
+
|
|
276
|
+
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; }
|
|
277
|
+
|
|
278
|
+
const HooksManagerInstance = _hooks().default.getInstance();
|
|
279
|
+
|
|
280
|
+
class SnappingMain {
|
|
281
|
+
constructor(workspace, logger) {
|
|
282
|
+
this.workspace = workspace;
|
|
283
|
+
this.logger = logger;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* tag the given component ids or all modified/new components if "all" param is set.
|
|
287
|
+
* tag is a similar operation as a snap, which saves the changes into the local scope, but it also creates an alias
|
|
288
|
+
* with a valid semver to that version.
|
|
289
|
+
* tag can be done only on main, not on a lane.
|
|
290
|
+
*/
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
async tag(tagParams) {
|
|
294
|
+
if (!this.workspace) throw new (_exceptions().ConsumerNotFound)();
|
|
295
|
+
const {
|
|
296
|
+
ids,
|
|
297
|
+
all,
|
|
298
|
+
exactVersion,
|
|
299
|
+
force,
|
|
300
|
+
scope,
|
|
301
|
+
includeImported,
|
|
302
|
+
persist,
|
|
303
|
+
snapped,
|
|
304
|
+
soft
|
|
305
|
+
} = tagParams;
|
|
306
|
+
const idsHasWildcard = (0, _hasWildcard().default)(ids);
|
|
307
|
+
const isAll = Boolean(all || scope || idsHasWildcard);
|
|
308
|
+
const validExactVersion = (0, _semverHelper().validateVersion)(exactVersion);
|
|
309
|
+
const preHook = isAll ? _constants().PRE_TAG_ALL_HOOK : _constants().PRE_TAG_HOOK;
|
|
310
|
+
HooksManagerInstance.triggerHook(preHook, tagParams);
|
|
311
|
+
const consumer = this.workspace.consumer;
|
|
312
|
+
const componentsList = new (_componentsList().default)(consumer);
|
|
313
|
+
|
|
314
|
+
_loader().default.start('determine components to tag...');
|
|
315
|
+
|
|
316
|
+
const newComponents = await componentsList.listNewComponents();
|
|
317
|
+
const {
|
|
318
|
+
bitIds,
|
|
319
|
+
warnings
|
|
320
|
+
} = await this.getComponentsToTag(Boolean(scope), exactVersion, includeImported, persist, force, ids, snapped);
|
|
321
|
+
if (_ramda().default.isEmpty(bitIds)) return null;
|
|
322
|
+
|
|
323
|
+
const legacyBitIds = _bitId().BitIds.fromArray(bitIds);
|
|
324
|
+
|
|
325
|
+
if (this.workspace.isLegacy) {
|
|
326
|
+
tagParams.persist = true;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
this.logger.debug(`tagging the following components: ${legacyBitIds.toString()}`);
|
|
330
|
+
|
|
331
|
+
_analytics().Analytics.addBreadCrumb('tag', `tagging the following components: ${_analytics().Analytics.hashData(legacyBitIds)}`);
|
|
332
|
+
|
|
333
|
+
if (!soft) {
|
|
334
|
+
await this.workspace.consumer.componentFsCache.deleteAllDependenciesDataCache();
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const components = await this.loadComponentsForTag(legacyBitIds);
|
|
338
|
+
this.throwForComponentIssues(components, tagParams.ignoreIssues);
|
|
339
|
+
const areComponentsMissingFromScope = components.some(c => !c.componentFromModel && c.id.hasScope());
|
|
340
|
+
|
|
341
|
+
if (areComponentsMissingFromScope) {
|
|
342
|
+
throw new (_componentsPendingImport().default)();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const {
|
|
346
|
+
taggedComponents,
|
|
347
|
+
autoTaggedResults,
|
|
348
|
+
publishedPackages
|
|
349
|
+
} = await (0, _tagModelComponent().default)(_objectSpread(_objectSpread({}, tagParams), {}, {
|
|
350
|
+
exactVersion: validExactVersion,
|
|
351
|
+
ids: legacyBitIds,
|
|
352
|
+
consumerComponents: components,
|
|
353
|
+
scope: this.workspace.scope.legacyScope,
|
|
354
|
+
consumer: this.workspace.consumer
|
|
355
|
+
}));
|
|
356
|
+
const tagResults = {
|
|
357
|
+
taggedComponents,
|
|
358
|
+
autoTaggedResults,
|
|
359
|
+
isSoftTag: tagParams.soft,
|
|
360
|
+
publishedPackages
|
|
361
|
+
}; // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
362
|
+
|
|
363
|
+
tagResults.warnings = warnings; // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
364
|
+
|
|
365
|
+
tagResults.newComponents = newComponents;
|
|
366
|
+
const postHook = isAll ? _constants().POST_TAG_ALL_HOOK : _constants().POST_TAG_HOOK;
|
|
367
|
+
HooksManagerInstance.triggerHook(postHook, tagResults);
|
|
368
|
+
|
|
369
|
+
_analytics().Analytics.setExtraData('num_components', // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
370
|
+
_ramda().default.concat(tagResults.taggedComponents, tagResults.autoTaggedResults, tagResults.newComponents).length);
|
|
371
|
+
|
|
372
|
+
await consumer.onDestroy(); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
373
|
+
|
|
374
|
+
return tagResults;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* save the local changes of a component(s) into the scope. snap can be done on main or on a lane.
|
|
378
|
+
* once a component is snapped on a lane, it becomes part of it.
|
|
379
|
+
*/
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
async snap({
|
|
383
|
+
id,
|
|
384
|
+
// @todo: rename to "patterns"
|
|
385
|
+
legacyBitIds,
|
|
386
|
+
// @todo: change to ComponentID[]. pass only if have the ids already parsed.
|
|
387
|
+
resolveUnmerged = false,
|
|
388
|
+
message = '',
|
|
389
|
+
force = false,
|
|
390
|
+
verbose = false,
|
|
391
|
+
ignoreIssues,
|
|
392
|
+
skipTests = false,
|
|
393
|
+
skipAutoSnap = false,
|
|
394
|
+
build,
|
|
395
|
+
disableTagAndSnapPipelines = false,
|
|
396
|
+
forceDeploy = false
|
|
397
|
+
}) {
|
|
398
|
+
if (!this.workspace) throw new (_exceptions().ConsumerNotFound)();
|
|
399
|
+
if (id && legacyBitIds) throw new Error(`please pass either id or legacyBitIds, not both`);
|
|
400
|
+
const consumer = this.workspace.consumer;
|
|
401
|
+
if (consumer.isLegacy) throw new (_lanesIsDisabled().LanesIsDisabled)();
|
|
402
|
+
const componentsList = new (_componentsList().default)(consumer);
|
|
403
|
+
const newComponents = await componentsList.listNewComponents();
|
|
404
|
+
const ids = legacyBitIds || (await getIdsToSnap());
|
|
405
|
+
if (!ids) return null;
|
|
406
|
+
this.logger.debug(`snapping the following components: ${ids.toString()}`);
|
|
407
|
+
await this.workspace.consumer.componentFsCache.deleteAllDependenciesDataCache();
|
|
408
|
+
const components = await this.loadComponentsForTag(ids);
|
|
409
|
+
this.throwForComponentIssues(components, ignoreIssues);
|
|
410
|
+
const areComponentsMissingFromScope = components.some(c => !c.componentFromModel && c.id.hasScope());
|
|
411
|
+
|
|
412
|
+
if (areComponentsMissingFromScope) {
|
|
413
|
+
throw new (_componentsPendingImport().default)();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const {
|
|
417
|
+
taggedComponents,
|
|
418
|
+
autoTaggedResults
|
|
419
|
+
} = await (0, _tagModelComponent().default)({
|
|
420
|
+
consumerComponents: components,
|
|
421
|
+
ids,
|
|
422
|
+
ignoreNewestVersion: false,
|
|
423
|
+
scope: this.workspace.scope.legacyScope,
|
|
424
|
+
message,
|
|
425
|
+
force,
|
|
426
|
+
consumer: this.workspace.consumer,
|
|
427
|
+
skipTests,
|
|
428
|
+
verbose,
|
|
429
|
+
skipAutoTag: skipAutoSnap,
|
|
430
|
+
persist: true,
|
|
431
|
+
soft: false,
|
|
432
|
+
build,
|
|
433
|
+
resolveUnmerged,
|
|
434
|
+
isSnap: true,
|
|
435
|
+
disableTagAndSnapPipelines,
|
|
436
|
+
forceDeploy
|
|
437
|
+
}); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
438
|
+
|
|
439
|
+
const snapResults = {
|
|
440
|
+
snappedComponents: taggedComponents,
|
|
441
|
+
autoSnappedResults: autoTaggedResults
|
|
442
|
+
};
|
|
443
|
+
snapResults.newComponents = newComponents;
|
|
444
|
+
const currentLane = consumer.getCurrentLaneId();
|
|
445
|
+
snapResults.laneName = currentLane.isDefault() ? null : currentLane.name;
|
|
446
|
+
await consumer.onDestroy(); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
447
|
+
|
|
448
|
+
return snapResults;
|
|
449
|
+
|
|
450
|
+
async function getIdsToSnap() {
|
|
451
|
+
const idHasWildcard = id && (0, _hasWildcard().default)(id);
|
|
452
|
+
|
|
453
|
+
if (id && !idHasWildcard) {
|
|
454
|
+
const bitId = consumer.getParsedId(id);
|
|
455
|
+
|
|
456
|
+
if (!force) {
|
|
457
|
+
const componentStatus = await consumer.getComponentStatusById(bitId); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
458
|
+
|
|
459
|
+
if (componentStatus.modified === false) return null;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
return new (_bitId().BitIds)(bitId);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const tagPendingComponents = await componentsList.listTagPendingComponents(); // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
466
|
+
|
|
467
|
+
if (_ramda().default.isEmpty(tagPendingComponents)) return null;
|
|
468
|
+
return idHasWildcard ? _componentsList().default.filterComponentsByWildcard(tagPendingComponents, id) : tagPendingComponents;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
async loadComponentsForTag(ids) {
|
|
473
|
+
const {
|
|
474
|
+
components
|
|
475
|
+
} = await this.workspace.consumer.loadComponents(ids.toVersionLatest());
|
|
476
|
+
|
|
477
|
+
if (this.workspace.isLegacy) {
|
|
478
|
+
return components;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
let shouldReloadComponents = false;
|
|
482
|
+
const componentsWithRelativePaths = [];
|
|
483
|
+
const componentsWithFilesNotDir = [];
|
|
484
|
+
const componentsWithCustomModuleResolution = [];
|
|
485
|
+
components.forEach(component => {
|
|
486
|
+
var _component$issues, _component$issues2;
|
|
487
|
+
|
|
488
|
+
const componentMap = component.componentMap;
|
|
489
|
+
if (componentMap.rootDir) return;
|
|
490
|
+
const hasRelativePaths = (_component$issues = component.issues) === null || _component$issues === void 0 ? void 0 : _component$issues.getIssue(_componentIssues().IssuesClasses.RelativeComponentsAuthored);
|
|
491
|
+
const hasCustomModuleResolutions = (_component$issues2 = component.issues) === null || _component$issues2 === void 0 ? void 0 : _component$issues2.getIssue(_componentIssues().IssuesClasses.MissingCustomModuleResolutionLinks); // leaving this because it can be helpful for users upgrade from legacy
|
|
492
|
+
|
|
493
|
+
if (componentMap.trackDir && !hasRelativePaths) {
|
|
494
|
+
componentMap.changeRootDirAndUpdateFilesAccordingly(componentMap.trackDir);
|
|
495
|
+
shouldReloadComponents = true;
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (hasRelativePaths) {
|
|
500
|
+
componentsWithRelativePaths.push(component.id.toStringWithoutVersion());
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if (!componentMap.trackDir) {
|
|
504
|
+
componentsWithFilesNotDir.push(component.id.toStringWithoutVersion());
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (hasCustomModuleResolutions) {
|
|
508
|
+
componentsWithCustomModuleResolution.push(component.id.toStringWithoutVersion());
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
if (componentsWithRelativePaths.length || componentsWithFilesNotDir.length) {
|
|
513
|
+
throw new (_failedLoadForTag().FailedLoadForTag)(componentsWithRelativePaths.sort(), componentsWithFilesNotDir.sort(), componentsWithCustomModuleResolution.sort());
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
if (!shouldReloadComponents) return components;
|
|
517
|
+
this.workspace.clearCache();
|
|
518
|
+
const {
|
|
519
|
+
components: reloadedComponents
|
|
520
|
+
} = await this.workspace.consumer.loadComponents(ids);
|
|
521
|
+
return reloadedComponents;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
throwForComponentIssues(components, ignoreIssues) {
|
|
525
|
+
components.forEach(component => {
|
|
526
|
+
if (this.workspace.isLegacy && component.issues) {
|
|
527
|
+
component.issues.delete(_componentIssues().IssuesClasses.RelativeComponentsAuthored);
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
if (ignoreIssues === '*') {
|
|
532
|
+
// ignore all issues
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const issuesToIgnore = ignoreIssues === null || ignoreIssues === void 0 ? void 0 : ignoreIssues.split(',').map(issue => issue.trim());
|
|
537
|
+
issuesToIgnore === null || issuesToIgnore === void 0 ? void 0 : issuesToIgnore.forEach(issue => {
|
|
538
|
+
const issueClass = _componentIssues().IssuesClasses[issue];
|
|
539
|
+
|
|
540
|
+
if (!issueClass) {
|
|
541
|
+
throw new Error(`unrecognized component-issue "${issue}". please specify one of the following:\n${Object.keys(_componentIssues().IssuesClasses).join('\n')}`);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
components.forEach(component => {
|
|
545
|
+
component.issues.delete(issueClass);
|
|
546
|
+
});
|
|
547
|
+
});
|
|
548
|
+
const componentsWithBlockingIssues = components.filter(component => {
|
|
549
|
+
var _component$issues3;
|
|
550
|
+
|
|
551
|
+
return (_component$issues3 = component.issues) === null || _component$issues3 === void 0 ? void 0 : _component$issues3.shouldBlockTagging();
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
if (!_ramda().default.isEmpty(componentsWithBlockingIssues)) {
|
|
555
|
+
throw new (_exceptions().ComponentsHaveIssues)(componentsWithBlockingIssues);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
async getComponentsToTag(isAllScope, exactVersion, includeImported, persist, force, ids, snapped) {
|
|
560
|
+
const warnings = [];
|
|
561
|
+
const componentsList = new (_componentsList().default)(this.workspace.consumer);
|
|
562
|
+
|
|
563
|
+
if (persist) {
|
|
564
|
+
const softTaggedComponents = componentsList.listSoftTaggedComponents();
|
|
565
|
+
return {
|
|
566
|
+
bitIds: softTaggedComponents,
|
|
567
|
+
warnings: []
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const tagPendingComponents = isAllScope ? await componentsList.listTagPendingOfAllScope(includeImported) : await componentsList.listTagPendingComponents();
|
|
572
|
+
const snappedComponents = await componentsList.listSnappedComponentsOnMain();
|
|
573
|
+
const snappedComponentsIds = snappedComponents.map(c => c.toBitId());
|
|
574
|
+
|
|
575
|
+
if (ids.length) {
|
|
576
|
+
const bitIds = await Promise.all(ids.map(async id => {
|
|
577
|
+
const [idWithoutVer, version] = id.split('@');
|
|
578
|
+
const idHasWildcard = (0, _hasWildcard().default)(id);
|
|
579
|
+
|
|
580
|
+
if (idHasWildcard) {
|
|
581
|
+
const allIds = _componentsList().default.filterComponentsByWildcard(tagPendingComponents, idWithoutVer);
|
|
582
|
+
|
|
583
|
+
return allIds.map(bitId => bitId.changeVersion(version));
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const bitId = this.workspace.consumer.getParsedId(idWithoutVer);
|
|
587
|
+
|
|
588
|
+
if (!force) {
|
|
589
|
+
const componentStatus = await this.workspace.consumer.getComponentStatusById(bitId);
|
|
590
|
+
if (componentStatus.modified === false) return null;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return bitId.changeVersion(version);
|
|
594
|
+
}));
|
|
595
|
+
return {
|
|
596
|
+
bitIds: (0, _lodash().compact)(bitIds.flat()),
|
|
597
|
+
warnings
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (snapped) {
|
|
602
|
+
return {
|
|
603
|
+
bitIds: snappedComponentsIds,
|
|
604
|
+
warnings
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
tagPendingComponents.push(...snappedComponentsIds);
|
|
609
|
+
|
|
610
|
+
if (isAllScope && exactVersion) {
|
|
611
|
+
const tagPendingComponentsLatest = await this.workspace.scope.legacyScope.latestVersions(tagPendingComponents, false);
|
|
612
|
+
tagPendingComponentsLatest.forEach(componentId => {
|
|
613
|
+
if (componentId.version && _semver().default.valid(componentId.version) && _semver().default.gt(componentId.version, exactVersion)) {
|
|
614
|
+
warnings.push(`warning: ${componentId.toString()} has a version greater than ${exactVersion}`);
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
return {
|
|
620
|
+
bitIds: tagPendingComponents.map(id => id.changeVersion(undefined)),
|
|
621
|
+
warnings
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
static async provider([workspace, cli, community, loggerMain]) {
|
|
626
|
+
const logger = loggerMain.createLogger(_snapping().SnappingAspect.id);
|
|
627
|
+
const snapping = new SnappingMain(workspace, logger);
|
|
628
|
+
const snapCmd = new (_snapCmd().SnapCmd)(community.getBaseDomain(), snapping);
|
|
629
|
+
const tagCmd = new (_tagCmd().TagCmd)(community.getBaseDomain(), snapping);
|
|
630
|
+
cli.register(tagCmd, snapCmd);
|
|
631
|
+
return snapping;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
exports.SnappingMain = SnappingMain;
|
|
637
|
+
(0, _defineProperty2().default)(SnappingMain, "slots", []);
|
|
638
|
+
(0, _defineProperty2().default)(SnappingMain, "dependencies", [_workspace().default, _cli().CLIAspect, _community().default, _logger().LoggerAspect]);
|
|
639
|
+
(0, _defineProperty2().default)(SnappingMain, "runtime", _cli().MainRuntime);
|
|
640
|
+
|
|
641
|
+
_snapping().SnappingAspect.addRuntime(SnappingMain);
|
|
642
|
+
|
|
643
|
+
//# sourceMappingURL=snapping.main.runtime.js.map
|