@teambit/snapping 1.0.516 → 1.0.518
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 +2 -2
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/snap-cmd.d.ts +1 -1
- package/dist/snap-cmd.js.map +1 -1
- package/dist/snap-from-scope.cmd.d.ts +1 -1
- package/dist/snap-from-scope.cmd.js.map +1 -1
- package/dist/snapping.main.runtime.d.ts +1 -1
- package/dist/snapping.main.runtime.js +29 -40
- package/dist/snapping.main.runtime.js.map +1 -1
- package/dist/tag-cmd.d.ts +1 -1
- package/dist/tag-cmd.js.map +1 -1
- package/dist/tag-model-component.d.ts +6 -35
- package/dist/tag-model-component.js +17 -625
- package/dist/tag-model-component.js.map +1 -1
- package/dist/version-maker.d.ts +96 -0
- package/dist/version-maker.js +685 -0
- package/dist/version-maker.js.map +1 -0
- package/package.json +21 -21
- package/artifacts/__bit_junit.xml +0 -20
- package/artifacts/preview/teambit_component_snapping-preview.js +0 -1
- package/artifacts/schema.json +0 -17716
- /package/dist/{preview-1736997622391.js → preview-1737170420676.js} +0 -0
|
@@ -4,637 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.tagModelComponent = tagModelComponent;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
_pMapSeries = function () {
|
|
7
|
+
function _versionMaker() {
|
|
8
|
+
const data = require("./version-maker");
|
|
9
|
+
_versionMaker = function () {
|
|
11
10
|
return data;
|
|
12
11
|
};
|
|
13
12
|
return data;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return data;
|
|
19
|
-
};
|
|
20
|
-
return data;
|
|
21
|
-
}
|
|
22
|
-
function _uuid() {
|
|
23
|
-
const data = require("uuid");
|
|
24
|
-
_uuid = function () {
|
|
25
|
-
return data;
|
|
26
|
-
};
|
|
27
|
-
return data;
|
|
28
|
-
}
|
|
29
|
-
function _bitError() {
|
|
30
|
-
const data = require("@teambit/bit-error");
|
|
31
|
-
_bitError = function () {
|
|
32
|
-
return data;
|
|
33
|
-
};
|
|
34
|
-
return data;
|
|
35
|
-
}
|
|
36
|
-
function _componentId() {
|
|
37
|
-
const data = require("@teambit/component-id");
|
|
38
|
-
_componentId = function () {
|
|
39
|
-
return data;
|
|
40
|
-
};
|
|
41
|
-
return data;
|
|
42
|
-
}
|
|
43
|
-
function _legacy() {
|
|
44
|
-
const data = require("@teambit/legacy.constants");
|
|
45
|
-
_legacy = function () {
|
|
46
|
-
return data;
|
|
47
|
-
};
|
|
48
|
-
return data;
|
|
49
|
-
}
|
|
50
|
-
function _legacy2() {
|
|
51
|
-
const data = require("@teambit/legacy.consumer-component");
|
|
52
|
-
_legacy2 = function () {
|
|
53
|
-
return data;
|
|
54
|
-
};
|
|
55
|
-
return data;
|
|
56
|
-
}
|
|
57
|
-
function _workspaceModules() {
|
|
58
|
-
const data = require("@teambit/workspace.modules.node-modules-linker");
|
|
59
|
-
_workspaceModules = function () {
|
|
60
|
-
return data;
|
|
61
|
-
};
|
|
62
|
-
return data;
|
|
63
|
-
}
|
|
64
|
-
function _legacy3() {
|
|
65
|
-
const data = require("@teambit/legacy.consumer");
|
|
66
|
-
_legacy3 = function () {
|
|
67
|
-
return data;
|
|
68
|
-
};
|
|
69
|
-
return data;
|
|
70
|
-
}
|
|
71
|
-
function _remove() {
|
|
72
|
-
const data = require("@teambit/remove");
|
|
73
|
-
_remove = function () {
|
|
74
|
-
return data;
|
|
75
|
-
};
|
|
76
|
-
return data;
|
|
77
|
-
}
|
|
78
|
-
function _legacy4() {
|
|
79
|
-
const data = require("@teambit/legacy.logger");
|
|
80
|
-
_legacy4 = function () {
|
|
81
|
-
return data;
|
|
82
|
-
};
|
|
83
|
-
return data;
|
|
84
|
-
}
|
|
85
|
-
function _pkgModules() {
|
|
86
|
-
const data = require("@teambit/pkg.modules.semver-helper");
|
|
87
|
-
_pkgModules = function () {
|
|
88
|
-
return data;
|
|
89
|
-
};
|
|
90
|
-
return data;
|
|
91
|
-
}
|
|
92
|
-
function _harmonyModules() {
|
|
93
|
-
const data = require("@teambit/harmony.modules.get-basic-log");
|
|
94
|
-
_harmonyModules = function () {
|
|
95
|
-
return data;
|
|
96
|
-
};
|
|
97
|
-
return data;
|
|
98
|
-
}
|
|
99
|
-
function _toolboxCrypto() {
|
|
100
|
-
const data = require("@teambit/toolbox.crypto.sha1");
|
|
101
|
-
_toolboxCrypto = function () {
|
|
102
|
-
return data;
|
|
103
|
-
};
|
|
104
|
-
return data;
|
|
105
|
-
}
|
|
106
|
-
function _objects() {
|
|
107
|
-
const data = require("@teambit/objects");
|
|
108
|
-
_objects = function () {
|
|
109
|
-
return data;
|
|
110
|
-
};
|
|
111
|
-
return data;
|
|
112
|
-
}
|
|
113
|
-
function _messagePerComponent() {
|
|
114
|
-
const data = require("./message-per-component");
|
|
115
|
-
_messagePerComponent = function () {
|
|
116
|
-
return data;
|
|
117
|
-
};
|
|
118
|
-
return data;
|
|
119
|
-
}
|
|
120
|
-
function _toolboxPromise() {
|
|
121
|
-
const data = require("@teambit/toolbox.promise.map-pool");
|
|
122
|
-
_toolboxPromise = function () {
|
|
123
|
-
return data;
|
|
124
|
-
};
|
|
125
|
-
return data;
|
|
126
|
-
}
|
|
127
|
-
function _harmonyModules2() {
|
|
128
|
-
const data = require("@teambit/harmony.modules.feature-toggle");
|
|
129
|
-
_harmonyModules2 = function () {
|
|
130
|
-
return data;
|
|
131
|
-
};
|
|
132
|
-
return data;
|
|
133
|
-
}
|
|
134
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
135
|
-
function updateDependenciesVersions(allComponentsToTag, dependencyResolver) {
|
|
136
|
-
// filter out removed components.
|
|
137
|
-
// if a component has a deleted-component as a dependency, it was probably running "bit install <dep>" with a version
|
|
138
|
-
// from main. we want to keep it as the user requested. Otherwise, this changes the dependency version to the newly
|
|
139
|
-
// snapped one unintentionally.
|
|
140
|
-
const componentsToTag = allComponentsToTag.filter(c => !c.isRemoved());
|
|
141
|
-
const getNewDependencyVersion = id => {
|
|
142
|
-
const foundDependency = componentsToTag.find(component => component.id.isEqualWithoutVersion(id));
|
|
143
|
-
return foundDependency ? id.changeVersion(foundDependency.version) : null;
|
|
144
|
-
};
|
|
145
|
-
const changeExtensionsVersion = component => {
|
|
146
|
-
component.extensions.forEach(ext => {
|
|
147
|
-
if (ext.extensionId) {
|
|
148
|
-
const newDepId = getNewDependencyVersion(ext.extensionId);
|
|
149
|
-
if (newDepId) ext.extensionId = newDepId;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
componentsToTag.forEach(oneComponentToTag => {
|
|
154
|
-
oneComponentToTag.getAllDependencies().forEach(dependency => {
|
|
155
|
-
const newDepId = getNewDependencyVersion(dependency.id);
|
|
156
|
-
if (newDepId) dependency.id = newDepId;
|
|
157
|
-
});
|
|
158
|
-
changeExtensionsVersion(oneComponentToTag);
|
|
159
|
-
// @ts-ignore
|
|
160
|
-
oneComponentToTag = dependencyResolver.updateDepsOnLegacyTag(oneComponentToTag, getNewDependencyVersion.bind(this));
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
function setHashes(componentsToTag) {
|
|
164
|
-
componentsToTag.forEach(componentToTag => {
|
|
165
|
-
componentToTag.setNewVersion((0, _toolboxCrypto().sha1)((0, _uuid().v4)()));
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
async function setFutureVersions(componentsToTag, scope, releaseType, exactVersion, persist, autoTagIds, ids, incrementBy, preReleaseId, soft, tagDataPerComp) {
|
|
169
|
-
const isPreReleaseLike = releaseType ? ['prerelease', 'premajor', 'preminor', 'prepatch'].includes(releaseType) : false;
|
|
170
|
-
await Promise.all(componentsToTag.map(async componentToTag => {
|
|
171
|
-
const isAutoTag = autoTagIds.hasWithoutVersion(componentToTag.id);
|
|
172
|
-
const modelComponent = await scope.sources.findOrAddComponent(componentToTag);
|
|
173
|
-
const nextVersion = componentToTag.componentMap?.nextVersion?.version;
|
|
174
|
-
const getNewVersion = () => {
|
|
175
|
-
if (tagDataPerComp) {
|
|
176
|
-
const tagData = tagDataPerComp.find(t => t.componentId.isEqualWithoutVersion(componentToTag.id));
|
|
177
|
-
if (!tagData) throw new Error(`tag-data is missing for ${componentToTag.id.toStringWithoutVersion()}`);
|
|
178
|
-
if (!tagData.versionToTag) throw new Error(`tag-data.TagResults is missing for ${componentToTag.id.toStringWithoutVersion()}`);
|
|
179
|
-
const exactVersionOrReleaseType = (0, _pkgModules().getValidVersionOrReleaseType)(tagData.versionToTag);
|
|
180
|
-
return modelComponent.getVersionToAdd(exactVersionOrReleaseType.releaseType, exactVersionOrReleaseType.exactVersion, incrementBy, tagData.prereleaseId);
|
|
181
|
-
}
|
|
182
|
-
if (nextVersion && persist) {
|
|
183
|
-
const exactVersionOrReleaseType = (0, _pkgModules().getValidVersionOrReleaseType)(nextVersion);
|
|
184
|
-
return modelComponent.getVersionToAdd(exactVersionOrReleaseType.releaseType, exactVersionOrReleaseType.exactVersion, undefined, componentToTag.componentMap?.nextVersion?.preRelease);
|
|
185
|
-
}
|
|
186
|
-
if (isAutoTag) {
|
|
187
|
-
// auto-tag always bumped as patch unless it's pre-release
|
|
188
|
-
if (isPreReleaseLike) {
|
|
189
|
-
return soft ? releaseType : modelComponent.getVersionToAdd(releaseType, exactVersion, incrementBy, preReleaseId);
|
|
190
|
-
}
|
|
191
|
-
return soft ? 'patch' : modelComponent.getVersionToAdd('patch', undefined, incrementBy, preReleaseId);
|
|
192
|
-
}
|
|
193
|
-
const versionByEnteredId = getVersionByEnteredId(ids, componentToTag, modelComponent);
|
|
194
|
-
return soft ? versionByEnteredId || exactVersion || releaseType : versionByEnteredId || modelComponent.getVersionToAdd(releaseType, exactVersion, incrementBy, preReleaseId);
|
|
195
|
-
};
|
|
196
|
-
const newVersion = getNewVersion();
|
|
197
|
-
componentToTag.setNewVersion(newVersion);
|
|
198
|
-
}));
|
|
199
|
-
}
|
|
200
|
-
function getVersionByEnteredId(enteredIds, component, modelComponent) {
|
|
201
|
-
const enteredId = enteredIds.searchWithoutVersion(component.id);
|
|
202
|
-
if (enteredId && enteredId.hasVersion()) {
|
|
203
|
-
const exactVersionOrReleaseType = (0, _pkgModules().getValidVersionOrReleaseType)(enteredId.version);
|
|
204
|
-
return modelComponent.getVersionToAdd(exactVersionOrReleaseType.releaseType, exactVersionOrReleaseType.exactVersion);
|
|
205
|
-
}
|
|
206
|
-
return undefined;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// eslint-disable-next-line complexity
|
|
210
|
-
async function tagModelComponent({
|
|
211
|
-
snapping,
|
|
212
|
-
consumerComponents,
|
|
213
|
-
components,
|
|
214
|
-
ids,
|
|
215
|
-
tagDataPerComp,
|
|
216
|
-
populateArtifactsFrom,
|
|
217
|
-
populateArtifactsIgnorePkgJson,
|
|
218
|
-
message,
|
|
219
|
-
editor,
|
|
220
|
-
exactVersion,
|
|
221
|
-
releaseType,
|
|
222
|
-
preReleaseId,
|
|
223
|
-
ignoreNewestVersion = false,
|
|
224
|
-
skipTests = false,
|
|
225
|
-
skipTasks,
|
|
226
|
-
skipAutoTag,
|
|
227
|
-
soft,
|
|
228
|
-
build,
|
|
229
|
-
persist,
|
|
230
|
-
isSnap = false,
|
|
231
|
-
disableTagAndSnapPipelines,
|
|
232
|
-
ignoreBuildErrors,
|
|
233
|
-
rebuildDepsGraph,
|
|
234
|
-
incrementBy,
|
|
235
|
-
packageManagerConfigRootDir,
|
|
236
|
-
copyLogFromPreviousSnap = false,
|
|
237
|
-
exitOnFirstFailedTask = false,
|
|
238
|
-
updateDependentsOnLane = false,
|
|
239
|
-
// on lane, adds it into updateDependents prop
|
|
240
|
-
setHeadAsParent,
|
|
241
|
-
// kind of rebase. in case component is checked out to older version, ignore that version, use head
|
|
242
|
-
detachHead,
|
|
243
|
-
overrideHead
|
|
244
|
-
}) {
|
|
245
|
-
const workspace = snapping.workspace;
|
|
246
|
-
const scope = snapping.scope;
|
|
247
|
-
const builder = snapping.builder;
|
|
248
|
-
const dependencyResolver = snapping.dependencyResolver;
|
|
249
|
-
const consumer = workspace?.consumer;
|
|
250
|
-
const legacyScope = scope.legacyScope;
|
|
251
|
-
const consumerComponentsIdsMap = {};
|
|
252
|
-
// Concat and unique all the dependencies from all the components so we will not import
|
|
253
|
-
// the same dependency more then once, it's mainly for performance purpose
|
|
254
|
-
consumerComponents.forEach(consumerComponent => {
|
|
255
|
-
const componentIdString = consumerComponent.id.toString();
|
|
256
|
-
// Store it in a map so we can take it easily from the sorted array which contain only the id
|
|
257
|
-
consumerComponentsIdsMap[componentIdString] = consumerComponent;
|
|
258
|
-
});
|
|
259
|
-
const componentsToTag = Object.values(consumerComponentsIdsMap); // consumerComponents unique
|
|
260
|
-
const idsToTag = _componentId().ComponentIdList.fromArray(componentsToTag.map(c => c.id));
|
|
261
|
-
// ids without versions are new. it's impossible that tagged (and not-modified) components has
|
|
262
|
-
// them as dependencies.
|
|
263
|
-
const idsToTriggerAutoTag = idsToTag.filter(id => id.hasVersion());
|
|
264
|
-
const autoTagDataWithLocalOnly = skipAutoTag || !consumer ? [] : await workspace.getAutoTagInfo(_componentId().ComponentIdList.fromArray(idsToTriggerAutoTag));
|
|
265
|
-
const localOnly = workspace?.listLocalOnly();
|
|
266
|
-
const autoTagData = localOnly ? autoTagDataWithLocalOnly.filter(autoTagItem => !localOnly.hasWithoutVersion(autoTagItem.component.id)) : autoTagDataWithLocalOnly;
|
|
267
|
-
const autoTagComponents = autoTagData.map(autoTagItem => autoTagItem.component);
|
|
268
|
-
const autoTagComponentsFiltered = autoTagComponents.filter(c => !idsToTag.has(c.id));
|
|
269
|
-
const autoTagIds = _componentId().ComponentIdList.fromArray(autoTagComponentsFiltered.map(autoTag => autoTag.id));
|
|
270
|
-
const allComponentsToTag = [...componentsToTag, ...autoTagComponentsFiltered];
|
|
271
|
-
const messagesFromEditorFetcher = new (_messagePerComponent().MessagePerComponentFetcher)(idsToTag, autoTagIds);
|
|
272
|
-
const getMessagePerId = async () => {
|
|
273
|
-
if (editor) return messagesFromEditorFetcher.getMessagesFromEditor(legacyScope.tmp, editor);
|
|
274
|
-
if (tagDataPerComp) return tagDataPerComp.map(t => ({
|
|
275
|
-
id: t.componentId,
|
|
276
|
-
msg: t.message || message
|
|
277
|
-
}));
|
|
278
|
-
return [];
|
|
279
|
-
};
|
|
280
|
-
const messagePerId = await getMessagePerId();
|
|
281
|
-
|
|
282
|
-
// check for each one of the components whether it is using an old version
|
|
283
|
-
// TODO: once --detach-head is supported by the remote, deprecate --ignore-newest-version. and change this
|
|
284
|
-
// throwForNewestVersion to suggest using --detach-head instead. also, it the error should not be limited
|
|
285
|
-
// to tags and can be thrown for snaps as well.
|
|
286
|
-
// once --ignore-newest-version is removed, no need for this condition. it's ok to not provide the override-head option.
|
|
287
|
-
if (detachHead && !(0, _harmonyModules2().isFeatureEnabled)(_harmonyModules2().DETACH_HEAD)) {
|
|
288
|
-
throw new Error('unable to detach head, the feature is not enabled');
|
|
289
|
-
}
|
|
290
|
-
if (ignoreNewestVersion && !detachHead) overrideHead = true;
|
|
291
|
-
if (!ignoreNewestVersion && !isSnap) {
|
|
292
|
-
await throwForNewestVersion(allComponentsToTag, legacyScope);
|
|
293
|
-
}
|
|
294
|
-
_legacy4().logger.debugAndAddBreadCrumb('tag-model-components', 'sequentially persist all components');
|
|
295
|
-
setCurrentSchema(allComponentsToTag);
|
|
296
|
-
|
|
297
|
-
// go through all components and find the future versions for them
|
|
298
|
-
isSnap ? setHashes(allComponentsToTag) : await setFutureVersions(allComponentsToTag, legacyScope, releaseType, exactVersion, persist, autoTagIds, ids, incrementBy, preReleaseId, soft, tagDataPerComp);
|
|
299
|
-
// go through all dependencies and update their versions
|
|
300
|
-
updateDependenciesVersions(allComponentsToTag, dependencyResolver);
|
|
301
|
-
await addLogToComponents(componentsToTag, autoTagComponents, persist, message, messagePerId, copyLogFromPreviousSnap);
|
|
302
|
-
// don't move it down. otherwise, it'll be empty and we don't know which components were during merge.
|
|
303
|
-
// (it's being deleted in snapping.main.runtime - `_addCompToObjects` method)
|
|
304
|
-
const unmergedComps = workspace ? await workspace.listComponentsDuringMerge() : [];
|
|
305
|
-
const lane = await legacyScope.getCurrentLaneObject();
|
|
306
|
-
const stagedConfig = workspace ? await workspace.scope.getStagedConfig() : undefined;
|
|
307
|
-
if (soft) {
|
|
308
|
-
if (!consumer) throw new Error(`unable to soft-tag without consumer`);
|
|
309
|
-
consumer.updateNextVersionOnBitmap(allComponentsToTag, preReleaseId);
|
|
310
|
-
} else {
|
|
311
|
-
await snapping._addFlattenedDependenciesToComponents(allComponentsToTag, rebuildDepsGraph);
|
|
312
|
-
await snapping._addDependenciesGraphToComponents(components);
|
|
313
|
-
await snapping.throwForDepsFromAnotherLane(allComponentsToTag);
|
|
314
|
-
if (!build) emptyBuilderData(allComponentsToTag);
|
|
315
|
-
addBuildStatus(allComponentsToTag, _legacy().BuildStatus.Pending);
|
|
316
|
-
const currentLane = consumer ? consumer.getCurrentLaneId() : undefined;
|
|
317
|
-
await (0, _pMapSeries().default)(allComponentsToTag, async component => {
|
|
318
|
-
const results = await snapping._addCompToObjects({
|
|
319
|
-
source: component,
|
|
320
|
-
lane,
|
|
321
|
-
shouldValidateVersion: Boolean(build),
|
|
322
|
-
addVersionOpts: {
|
|
323
|
-
addToUpdateDependentsInLane: updateDependentsOnLane,
|
|
324
|
-
setHeadAsParent,
|
|
325
|
-
detachHead,
|
|
326
|
-
overrideHead: overrideHead
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
if (workspace) {
|
|
330
|
-
const modelComponent = component.modelComponent || (await legacyScope.getModelComponent(component.id));
|
|
331
|
-
await updateVersions(workspace, stagedConfig, currentLane, modelComponent, results.addedVersionStr, true);
|
|
332
|
-
} else {
|
|
333
|
-
const tagData = tagDataPerComp?.find(t => t.componentId.isEqualWithoutVersion(component.id));
|
|
334
|
-
if (tagData?.isNew) results.version.removeAllParents();
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
if (workspace) {
|
|
338
|
-
await workspace.scope.legacyScope.stagedSnaps.write();
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
const publishedPackages = [];
|
|
342
|
-
let harmonyComps = [];
|
|
343
|
-
if (build) {
|
|
344
|
-
const onTagOpts = {
|
|
345
|
-
disableTagAndSnapPipelines,
|
|
346
|
-
throwOnError: true,
|
|
347
|
-
forceDeploy: ignoreBuildErrors,
|
|
348
|
-
isSnap,
|
|
349
|
-
populateArtifactsFrom
|
|
350
|
-
};
|
|
351
|
-
const skipTasksParsed = skipTasks ? skipTasks.split(',').map(t => t.trim()) : undefined;
|
|
352
|
-
const seedersOnly = !workspace; // if tag from scope, build only the given components
|
|
353
|
-
const isolateOptions = {
|
|
354
|
-
packageManagerConfigRootDir,
|
|
355
|
-
seedersOnly,
|
|
356
|
-
populateArtifactsIgnorePkgJson
|
|
357
|
-
};
|
|
358
|
-
const builderOptions = {
|
|
359
|
-
exitOnFirstFailedTask,
|
|
360
|
-
skipTests,
|
|
361
|
-
skipTasks: skipTasksParsed
|
|
362
|
-
};
|
|
363
|
-
const componentsToBuild = allComponentsToTag.filter(c => !c.isRemoved());
|
|
364
|
-
if (componentsToBuild.length) {
|
|
365
|
-
await scope.reloadAspectsWithNewVersion(componentsToBuild);
|
|
366
|
-
harmonyComps = await (workspace || scope).getManyByLegacy(componentsToBuild);
|
|
367
|
-
const {
|
|
368
|
-
builderDataMap
|
|
369
|
-
} = await builder.tagListener(harmonyComps, onTagOpts, isolateOptions, builderOptions);
|
|
370
|
-
const buildResult = scope.builderDataMapToLegacyOnTagResults(builderDataMap);
|
|
371
|
-
snapping._updateComponentsByTagResult(componentsToBuild, buildResult);
|
|
372
|
-
const packageIntegritiesByPublishedPackages = snapping._getPublishedPackages(componentsToBuild);
|
|
373
|
-
publishedPackages.push(...Array.from(packageIntegritiesByPublishedPackages.keys()));
|
|
374
|
-
addIntegritiesToConsumerComponentsGraphs(packageIntegritiesByPublishedPackages, allComponentsToTag);
|
|
375
|
-
addBuildStatus(componentsToBuild, _legacy().BuildStatus.Succeed);
|
|
376
|
-
await (0, _pMapSeries().default)(harmonyComps, comp => snapping.enrichComp(comp));
|
|
377
|
-
if (populateArtifactsFrom) await updateHiddenProp(scope, populateArtifactsFrom);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
let removedComponents;
|
|
381
|
-
if (!soft) {
|
|
382
|
-
removedComponents = await removeDeletedComponentsFromBitmap(allComponentsToTag, workspace);
|
|
383
|
-
if (lane) {
|
|
384
|
-
const msgStr = message ? ` (${message})` : '';
|
|
385
|
-
const laneHistory = await legacyScope.lanes.updateLaneHistory(lane, `snap${msgStr}`);
|
|
386
|
-
legacyScope.objects.add(laneHistory);
|
|
387
|
-
}
|
|
388
|
-
await legacyScope.objects.persist();
|
|
389
|
-
await removeMergeConfigFromComponents(unmergedComps, allComponentsToTag, workspace);
|
|
390
|
-
if (workspace) {
|
|
391
|
-
await (0, _workspaceModules().linkToNodeModulesByComponents)(harmonyComps.length ? harmonyComps : await workspace.scope.getManyByLegacy(allComponentsToTag), workspace);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
// clear all objects. otherwise, ModelComponent has the wrong divergeData
|
|
396
|
-
legacyScope.objects.clearObjectsFromCache();
|
|
397
|
-
return {
|
|
398
|
-
taggedComponents: componentsToTag,
|
|
399
|
-
autoTaggedResults: autoTagData,
|
|
400
|
-
publishedPackages,
|
|
401
|
-
stagedConfig,
|
|
402
|
-
removedComponents
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
async function throwForNewestVersion(allComponentsToTag, legacyScope) {
|
|
406
|
-
const newestVersionsP = allComponentsToTag.map(async component => {
|
|
407
|
-
if (component.componentFromModel) {
|
|
408
|
-
// otherwise it's a new component, so this check is irrelevant
|
|
409
|
-
const modelComponent = await legacyScope.getModelComponentIfExist(component.id);
|
|
410
|
-
if (!modelComponent) throw new (_bitError().BitError)(`component ${component.id} was not found in the model`);
|
|
411
|
-
if (!modelComponent.listVersions().length) return null; // no versions yet, no issues.
|
|
412
|
-
const latest = modelComponent.getHeadRegardlessOfLaneAsTagOrHash();
|
|
413
|
-
if (latest !== component.version) {
|
|
414
|
-
return {
|
|
415
|
-
componentId: component.id.toStringWithoutVersion(),
|
|
416
|
-
currentVersion: component.version,
|
|
417
|
-
latestVersion: latest
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
return null;
|
|
422
|
-
});
|
|
423
|
-
const newestVersions = await Promise.all(newestVersionsP);
|
|
424
|
-
const newestVersionsWithoutEmpty = (0, _lodash().compact)(newestVersions);
|
|
425
|
-
if (newestVersionsWithoutEmpty.length) {
|
|
426
|
-
throw new (_legacy3().NewerVersionFound)(newestVersionsWithoutEmpty);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
function addIntegritiesToConsumerComponentsGraphs(packageIntegritiesByPublishedPackages, consumerComponents) {
|
|
430
|
-
const _addIntegritiesToDependenciesGraph = addIntegritiesToDependenciesGraph.bind(null, packageIntegritiesByPublishedPackages);
|
|
431
|
-
for (const consumerComponent of consumerComponents) {
|
|
432
|
-
if (consumerComponent.dependenciesGraph) {
|
|
433
|
-
consumerComponent.dependenciesGraph = _addIntegritiesToDependenciesGraph(consumerComponent.dependenciesGraph);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* Updates the dependencies graph by replacing all "pending" version numbers of component dependencies
|
|
440
|
-
* with the actual version numbers of the recently published packages. It also attaches the integrity
|
|
441
|
-
* checksums of these components to ensure data integrity for each resolved dependency.
|
|
442
|
-
*
|
|
443
|
-
* @param packageIntegritiesByPublishedPackages - A map of package names and versions to their integrity checksums.
|
|
444
|
-
* @param dependenciesGraph - The current dependencies graph, containing nodes with potentially "pending" versions.
|
|
445
|
-
* @returns A new DependenciesGraph with updated versions and integrity checksums for all previously pending dependencies.
|
|
446
|
-
*/
|
|
447
|
-
function addIntegritiesToDependenciesGraph(packageIntegritiesByPublishedPackages, dependenciesGraph) {
|
|
448
|
-
const resolvedVersions = [];
|
|
449
|
-
for (const [selector, integrity] of packageIntegritiesByPublishedPackages.entries()) {
|
|
450
|
-
if (integrity == null) continue;
|
|
451
|
-
const index = selector.indexOf('@', 1);
|
|
452
|
-
const name = selector.substring(0, index);
|
|
453
|
-
const version = selector.substring(index + 1);
|
|
454
|
-
const pendingPkg = dependenciesGraph.packages.get(`${name}@pending:`);
|
|
455
|
-
if (pendingPkg) {
|
|
456
|
-
pendingPkg.resolution = {
|
|
457
|
-
integrity
|
|
458
|
-
};
|
|
459
|
-
resolvedVersions.push({
|
|
460
|
-
name,
|
|
461
|
-
version
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
return replacePendingVersions(dependenciesGraph, resolvedVersions);
|
|
466
|
-
}
|
|
467
|
-
async function removeDeletedComponentsFromBitmap(comps, workspace) {
|
|
468
|
-
if (!workspace) {
|
|
469
|
-
return undefined;
|
|
470
|
-
}
|
|
471
|
-
const removedComps = comps.filter(comp => comp.isRemoved());
|
|
472
|
-
if (!removedComps.length) return undefined;
|
|
473
|
-
const compBitIdsToRemove = _componentId().ComponentIdList.fromArray(removedComps.map(c => c.id));
|
|
474
|
-
await (0, _remove().deleteComponentsFiles)(workspace.consumer, compBitIdsToRemove);
|
|
475
|
-
await workspace.consumer.cleanFromBitMap(compBitIdsToRemove);
|
|
476
|
-
return compBitIdsToRemove;
|
|
477
|
-
}
|
|
478
|
-
async function removeMergeConfigFromComponents(unmergedComps, components, workspace) {
|
|
479
|
-
if (!workspace || !unmergedComps.length) {
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
const configMergeFile = workspace.getConflictMergeFile();
|
|
483
|
-
unmergedComps.forEach(compId => {
|
|
484
|
-
const isNowSnapped = components.find(c => c.id.isEqualWithoutVersion(compId));
|
|
485
|
-
if (isNowSnapped) {
|
|
486
|
-
configMergeFile.removeConflict(compId.toStringWithoutVersion());
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
const currentlyUnmerged = workspace ? await workspace.listComponentsDuringMerge() : [];
|
|
490
|
-
if (configMergeFile.hasConflict() && currentlyUnmerged.length) {
|
|
491
|
-
// it's possible that "workspace" section is still there. but if all "unmerged" are now merged,
|
|
492
|
-
// then, it's safe to delete the file.
|
|
493
|
-
await configMergeFile.write();
|
|
494
|
-
} else {
|
|
495
|
-
await configMergeFile.delete();
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* otherwise, tagging without build will have the old build data of the previous snap/tag.
|
|
501
|
-
* in case we currently build, it's ok to leave the data as is, because it'll be overridden anyway.
|
|
502
|
-
*/
|
|
503
|
-
function emptyBuilderData(components) {
|
|
504
|
-
components.forEach(component => {
|
|
505
|
-
component.extensions = component.extensions.clone();
|
|
506
|
-
const existingBuilder = component.extensions.findCoreExtension(_legacy().Extensions.builder);
|
|
507
|
-
if (existingBuilder) existingBuilder.data = {};
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
async function addLogToComponents(components, autoTagComps, persist, message, messagePerComponent, copyLogFromPreviousSnap = false) {
|
|
511
|
-
// @ts-ignore this happens when running `bit tag -m ""`.
|
|
512
|
-
if (message === true) {
|
|
513
|
-
message = '';
|
|
514
|
-
}
|
|
515
|
-
const basicLog = await (0, _harmonyModules().getBasicLog)();
|
|
516
|
-
const getLog = component => {
|
|
517
|
-
const nextVersion = persist ? component.componentMap?.nextVersion : null;
|
|
518
|
-
const msgFromEditor = messagePerComponent.find(item => item.id.isEqualWithoutVersion(component.id))?.msg;
|
|
519
|
-
if (copyLogFromPreviousSnap) {
|
|
520
|
-
const currentLog = component.log;
|
|
521
|
-
if (!currentLog) {
|
|
522
|
-
throw new Error(`addLogToComponents is set copyLogFromPreviousSnap: true, but it is unable to find log in the previous snap`);
|
|
523
|
-
}
|
|
524
|
-
currentLog.message = msgFromEditor || message || currentLog.message;
|
|
525
|
-
currentLog.date = basicLog.date;
|
|
526
|
-
return currentLog;
|
|
527
|
-
}
|
|
528
|
-
return {
|
|
529
|
-
username: nextVersion?.username || basicLog.username,
|
|
530
|
-
email: nextVersion?.email || basicLog.email,
|
|
531
|
-
message: nextVersion?.message || msgFromEditor || message,
|
|
532
|
-
date: basicLog.date
|
|
533
|
-
};
|
|
534
|
-
};
|
|
535
|
-
components.forEach(component => {
|
|
536
|
-
component.log = getLog(component);
|
|
537
|
-
});
|
|
538
|
-
autoTagComps.forEach(autoTagComp => {
|
|
539
|
-
autoTagComp.log = getLog(autoTagComp);
|
|
540
|
-
const defaultMsg = 'bump dependencies versions';
|
|
541
|
-
if (message) {
|
|
542
|
-
autoTagComp.log.message += ` (${defaultMsg})`;
|
|
543
|
-
} else if (!autoTagComp.log.message) {
|
|
544
|
-
autoTagComp.log.message = defaultMsg;
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
function setCurrentSchema(components) {
|
|
549
|
-
components.forEach(component => {
|
|
550
|
-
component.schema = _legacy2().CURRENT_SCHEMA;
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
function addBuildStatus(components, buildStatus) {
|
|
554
|
-
components.forEach(component => {
|
|
555
|
-
component.buildStatus = component.isRemoved() ? _legacy().BuildStatus.Skipped : buildStatus;
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
function isAvailableOnMain(currentLane, modelComponent, id) {
|
|
559
|
-
if (currentLane.isDefault()) {
|
|
560
|
-
return true;
|
|
561
|
-
}
|
|
562
|
-
if (!id.hasVersion()) {
|
|
563
|
-
// component was unsnapped on the current lane and is back to a new component
|
|
564
|
-
return true;
|
|
565
|
-
}
|
|
566
|
-
return modelComponent.hasHead();
|
|
567
|
-
}
|
|
568
|
-
async function updateVersions(workspace, stagedConfig, currentLane, modelComponent, versionToSetInBitmap,
|
|
569
|
-
// helpful for detached head
|
|
570
|
-
isTag = true) {
|
|
571
|
-
const consumer = workspace.consumer;
|
|
572
|
-
const idLatest = modelComponent.toBitIdWithLatestVersionAllowNull();
|
|
573
|
-
const id = versionToSetInBitmap ? idLatest.changeVersion(versionToSetInBitmap) : idLatest;
|
|
574
|
-
const isOnBitmap = consumer.bitMap.getComponentIfExist(id, {
|
|
575
|
-
ignoreVersion: true
|
|
576
|
-
});
|
|
577
|
-
if (!isOnBitmap && !isTag) {
|
|
578
|
-
// handle the case when a component was deleted, snapped/tagged and is now reset.
|
|
579
|
-
const stagedData = stagedConfig.getPerId(id);
|
|
580
|
-
if (stagedData?.config && stagedData.config[_remove().RemoveAspect.id]) {
|
|
581
|
-
consumer.bitMap.addFromComponentJson(stagedData.id, stagedData.componentMapObject);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
consumer.bitMap.updateComponentId(id, undefined, undefined, true);
|
|
585
|
-
const availableOnMain = isAvailableOnMain(currentLane, modelComponent, id);
|
|
586
|
-
if (!availableOnMain) {
|
|
587
|
-
consumer.bitMap.setOnLanesOnly(id, true);
|
|
588
|
-
}
|
|
589
|
-
const componentMap = consumer.bitMap.getComponent(id);
|
|
590
|
-
const compId = await workspace.resolveComponentId(id);
|
|
591
|
-
// it can be either a tag/snap or reset.
|
|
592
|
-
if (isTag) {
|
|
593
|
-
const compMapObj = componentMap.toPlainObject();
|
|
594
|
-
const config = componentMap.config;
|
|
595
|
-
stagedConfig.addComponentConfig(compId, config, compMapObj);
|
|
596
|
-
consumer.bitMap.removeConfig(id);
|
|
597
|
-
const hash = modelComponent.getRef(id.version);
|
|
598
|
-
if (!hash) throw new Error(`updateComponentsVersions: unable to find a hash for ${id.toString()}`);
|
|
599
|
-
workspace.scope.legacyScope.stagedSnaps.addSnap(hash?.toString());
|
|
600
|
-
} else if (!componentMap.config) {
|
|
601
|
-
componentMap.config = stagedConfig.getConfigPerId(compId);
|
|
602
|
-
}
|
|
603
|
-
componentMap.clearNextVersion();
|
|
604
|
-
}
|
|
605
|
-
function replacePendingVersions(graph, resolvedVersions) {
|
|
606
|
-
let s = graph.serialize();
|
|
607
|
-
for (const {
|
|
608
|
-
name,
|
|
609
|
-
version
|
|
610
|
-
} of resolvedVersions) {
|
|
611
|
-
s = s.replaceAll(`${name}@pending:`, `${name}@${version}`);
|
|
612
|
-
}
|
|
613
|
-
const updatedDependenciesGraph = _objects().DependenciesGraph.deserialize(s);
|
|
614
|
-
// This should never happen as we know at this point that the schema version is supported
|
|
615
|
-
if (updatedDependenciesGraph == null) {
|
|
616
|
-
throw new (_bitError().BitError)('Failed to deserialize dependencies graph in replacePendingVersions()');
|
|
617
|
-
}
|
|
618
|
-
return updatedDependenciesGraph;
|
|
619
|
-
}
|
|
620
|
-
|
|
14
|
+
const _excluded = ["snapping", "consumerComponents", "components", "ids"];
|
|
15
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
621
17
|
/**
|
|
622
|
-
*
|
|
623
|
-
* the new tag uses the same files/config/build-artifacts as the previous snap.
|
|
624
|
-
* we want to mark the previous snap as hidden. so then "bit log" and "bit blame" won't show it.
|
|
18
|
+
* @deprecated use VersionMaker class instead
|
|
625
19
|
*/
|
|
626
|
-
async function
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
concurrency: 50
|
|
637
|
-
});
|
|
20
|
+
async function tagModelComponent(_ref) {
|
|
21
|
+
let {
|
|
22
|
+
snapping,
|
|
23
|
+
consumerComponents,
|
|
24
|
+
components,
|
|
25
|
+
ids
|
|
26
|
+
} = _ref,
|
|
27
|
+
params = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
const versionMaker = new (_versionMaker().VersionMaker)(snapping, components, consumerComponents, ids, params);
|
|
29
|
+
return versionMaker.makeVersion();
|
|
638
30
|
}
|
|
639
31
|
|
|
640
32
|
//# sourceMappingURL=tag-model-component.js.map
|