@teambit/snapping 1.0.495 → 1.0.497
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/artifacts/__bit_junit.xml +8 -8
- package/artifacts/schema.json +1895 -2587
- package/dist/esm.mjs +3 -0
- package/dist/reset-component.d.ts +7 -3
- package/dist/reset-component.js +21 -10
- package/dist/reset-component.js.map +1 -1
- package/dist/snap-cmd.d.ts +1 -1
- package/dist/snap-cmd.js +5 -3
- package/dist/snap-cmd.js.map +1 -1
- package/dist/snap-distance-cmd.d.ts +3 -1
- package/dist/snap-distance-cmd.js +6 -2
- package/dist/snap-distance-cmd.js.map +1 -1
- package/dist/snapping.main.runtime.d.ts +4 -2
- package/dist/snapping.main.runtime.js +30 -11
- package/dist/snapping.main.runtime.js.map +1 -1
- package/dist/tag-cmd.js +5 -3
- package/dist/tag-cmd.js.map +1 -1
- package/dist/tag-from-scope.cmd.js +7 -3
- package/dist/tag-from-scope.cmd.js.map +1 -1
- package/dist/tag-model-component.d.ts +7 -2
- package/dist/tag-model-component.js +113 -100
- package/dist/tag-model-component.js.map +1 -1
- package/esm.mjs +3 -0
- package/package.json +37 -36
- /package/dist/{preview-1734279612846.js → preview-1734491866611.js} +0 -0
package/dist/esm.mjs
CHANGED
|
@@ -2,5 +2,8 @@
|
|
|
2
2
|
import cjsModule from './index.js';
|
|
3
3
|
|
|
4
4
|
export const SnappingAspect = cjsModule.SnappingAspect;
|
|
5
|
+
export const inputDataDescription = cjsModule.inputDataDescription;
|
|
6
|
+
export const snapFromScopeOptions = cjsModule.snapFromScopeOptions;
|
|
7
|
+
export const tagModelComponent = cjsModule.tagModelComponent;
|
|
5
8
|
|
|
6
9
|
export default cjsModule;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ComponentID } from '@teambit/component-id';
|
|
2
|
-
import { Scope } from '@teambit/legacy.scope';
|
|
3
2
|
import { Consumer } from '@teambit/legacy.consumer';
|
|
4
3
|
import { Lane, ModelComponent } from '@teambit/scope.objects';
|
|
5
4
|
import { RemoveMain } from '@teambit/remove';
|
|
@@ -7,11 +6,16 @@ export type ResetResult = {
|
|
|
7
6
|
id: ComponentID;
|
|
8
7
|
versions: string[];
|
|
9
8
|
component?: ModelComponent;
|
|
9
|
+
/**
|
|
10
|
+
* relevant when the component was detached head so the head didn't change.
|
|
11
|
+
* we want .bitmap to have the version before the detachment. not as the head.
|
|
12
|
+
*/
|
|
13
|
+
versionToSetInBitmap?: string;
|
|
10
14
|
};
|
|
11
15
|
/**
|
|
12
16
|
* If head is false, remove all local versions.
|
|
13
17
|
*/
|
|
14
|
-
export declare function removeLocalVersion(
|
|
18
|
+
export declare function removeLocalVersion(consumer: Consumer, id: ComponentID, lane?: Lane, head?: boolean, force?: boolean): Promise<ResetResult>;
|
|
15
19
|
export declare function removeLocalVersionsForAllComponents(consumer: Consumer, remove: RemoveMain, lane?: Lane, head?: boolean): Promise<ResetResult[]>;
|
|
16
|
-
export declare function removeLocalVersionsForMultipleComponents(componentsToUntag: ModelComponent[],
|
|
20
|
+
export declare function removeLocalVersionsForMultipleComponents(consumer: Consumer, componentsToUntag: ModelComponent[], lane?: Lane, head?: boolean, force?: boolean): Promise<ResetResult[]>;
|
|
17
21
|
export declare function getComponentsWithOptionToUntag(consumer: Consumer, remove: RemoveMain): Promise<ModelComponent[]>;
|
package/dist/reset-component.js
CHANGED
|
@@ -38,10 +38,11 @@ function _legacy3() {
|
|
|
38
38
|
/**
|
|
39
39
|
* If head is false, remove all local versions.
|
|
40
40
|
*/
|
|
41
|
-
async function removeLocalVersion(
|
|
42
|
-
const component = await scope.getModelComponent(id);
|
|
41
|
+
async function removeLocalVersion(consumer, id, lane, head, force = false) {
|
|
42
|
+
const component = await consumer.scope.getModelComponent(id);
|
|
43
43
|
const idStr = id.toString();
|
|
44
|
-
const
|
|
44
|
+
const fromBitmap = consumer.bitMap.getComponentIdIfExist(id);
|
|
45
|
+
const localVersions = await component.getLocalHashes(consumer.scope.objects, fromBitmap);
|
|
45
46
|
if (!localVersions.length) throw new (_bitError().BitError)(`unable to untag ${idStr}, the component is not staged`);
|
|
46
47
|
const headRef = component.getHeadRegardlessOfLane();
|
|
47
48
|
if (!headRef) {
|
|
@@ -53,7 +54,7 @@ async function removeLocalVersion(scope, id, lane, head, force = false) {
|
|
|
53
54
|
const versionsToRemove = head ? [headRef] : localVersions;
|
|
54
55
|
const versionsToRemoveStr = component.switchHashesWithTagsIfExist(versionsToRemove);
|
|
55
56
|
if (!force) {
|
|
56
|
-
const dependencyGraph = await _legacy3().DependencyGraph.loadAllVersions(scope);
|
|
57
|
+
const dependencyGraph = await _legacy3().DependencyGraph.loadAllVersions(consumer.scope);
|
|
57
58
|
versionsToRemoveStr.forEach(versionToRemove => {
|
|
58
59
|
const idWithVersion = component.toComponentId().changeVersion(versionToRemove);
|
|
59
60
|
const dependents = dependencyGraph.getImmediateDependentsPerId(idWithVersion);
|
|
@@ -62,25 +63,35 @@ async function removeLocalVersion(scope, id, lane, head, force = false) {
|
|
|
62
63
|
}
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
+
const headBefore = component.getHead();
|
|
67
|
+
await consumer.scope.sources.removeComponentVersions(component, versionsToRemove, versionsToRemoveStr, lane, head);
|
|
68
|
+
const headAfter = component.getHead();
|
|
69
|
+
let versionToSetInBitmap;
|
|
70
|
+
if (headBefore && headAfter && headBefore.isEqual(headAfter) && !lane) {
|
|
71
|
+
// if it's on main and the head didn't change, it means that it was in a detached-head state.
|
|
72
|
+
const divergeData = component.getDivergeData();
|
|
73
|
+
const snapBeforeDetached = divergeData.commonSnapBeforeDiverge;
|
|
74
|
+
if (snapBeforeDetached) versionToSetInBitmap = component.getTagOfRefIfExists(snapBeforeDetached);
|
|
75
|
+
}
|
|
66
76
|
return {
|
|
67
77
|
id,
|
|
68
78
|
versions: versionsToRemoveStr,
|
|
69
|
-
component
|
|
79
|
+
component,
|
|
80
|
+
versionToSetInBitmap
|
|
70
81
|
};
|
|
71
82
|
}
|
|
72
83
|
async function removeLocalVersionsForAllComponents(consumer, remove, lane, head) {
|
|
73
84
|
const componentsToUntag = await getComponentsWithOptionToUntag(consumer, remove);
|
|
74
85
|
const force = true; // when removing local versions from all components, no need to check if the component is used as a dependency
|
|
75
|
-
return removeLocalVersionsForMultipleComponents(
|
|
86
|
+
return removeLocalVersionsForMultipleComponents(consumer, componentsToUntag, lane, head, force);
|
|
76
87
|
}
|
|
77
|
-
async function removeLocalVersionsForMultipleComponents(
|
|
88
|
+
async function removeLocalVersionsForMultipleComponents(consumer, componentsToUntag, lane, head, force) {
|
|
78
89
|
if (!componentsToUntag.length) {
|
|
79
90
|
throw new (_bitError().BitError)(`no components found to reset on your workspace`);
|
|
80
91
|
}
|
|
81
92
|
// if only head is removed, there is risk of deleting dependencies version without their dependents.
|
|
82
93
|
if (!force && head) {
|
|
83
|
-
const dependencyGraph = await _legacy3().DependencyGraph.loadAllVersions(scope);
|
|
94
|
+
const dependencyGraph = await _legacy3().DependencyGraph.loadAllVersions(consumer.scope);
|
|
84
95
|
const candidateComponentsIds = componentsToUntag.map(component => {
|
|
85
96
|
const bitId = component.toComponentId();
|
|
86
97
|
const headRef = component.getHeadRegardlessOfLane();
|
|
@@ -100,7 +111,7 @@ async function removeLocalVersionsForMultipleComponents(componentsToUntag, scope
|
|
|
100
111
|
});
|
|
101
112
|
}
|
|
102
113
|
_legacy2().logger.debug(`found ${componentsToUntag.length} components to untag`);
|
|
103
|
-
return Promise.all(componentsToUntag.map(component => removeLocalVersion(
|
|
114
|
+
return Promise.all(componentsToUntag.map(component => removeLocalVersion(consumer, component.toComponentId(), lane, head, force)));
|
|
104
115
|
}
|
|
105
116
|
async function getComponentsWithOptionToUntag(consumer, remove) {
|
|
106
117
|
const componentList = new (_legacy().ComponentsList)(consumer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_bitError","data","require","_legacy","_legacy2","_legacy3","removeLocalVersion","scope","id","lane","head","force","component","getModelComponent","idStr","toString","localVersions","getLocalHashes","objects","length","BitError","headRef","getHeadRegardlessOfLane","Error","find","v","isEqual","versionsToRemove","versionsToRemoveStr","switchHashesWithTagsIfExist","dependencyGraph","DependencyGraph","loadAllVersions","forEach","versionToRemove","idWithVersion","toComponentId","changeVersion","dependents","getImmediateDependentsPerId","join","sources","removeComponentVersions","versions","removeLocalVersionsForAllComponents","consumer","remove","componentsToUntag","getComponentsWithOptionToUntag","removeLocalVersionsForMultipleComponents","candidateComponentsIds","map","bitId","getTagOfRefIfExists","candidateComponentsIdsStr","dependentsNotCandidates","filter","dependent","includes","version","logger","debug","Promise","all","componentList","ComponentsList","laneObj","getCurrentLaneObject","components","listExportPendingComponents","removedStagedIds","getRemovedStaged","removedStagedBitIds","nonExistsInStaged","c","isEqualWithoutVersion","modelComps","push"],"sources":["reset-component.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component-id';\nimport { Scope } from '@teambit/legacy.scope';\nimport { Consumer } from '@teambit/legacy.consumer';\nimport { ComponentsList } from '@teambit/legacy.component-list';\nimport { logger } from '@teambit/legacy.logger';\nimport { Lane, ModelComponent } from '@teambit/scope.objects';\nimport { RemoveMain } from '@teambit/remove';\nimport { DependencyGraph } from '@teambit/legacy.dependency-graph';\n\nexport type ResetResult = { id: ComponentID; versions: string[]; component?: ModelComponent };\n\n/**\n * If head is false, remove all local versions.\n */\nexport async function removeLocalVersion(\n scope: Scope,\n id: ComponentID,\n lane?: Lane,\n head?: boolean,\n force = false\n): Promise<ResetResult> {\n const component: ModelComponent = await scope.getModelComponent(id);\n const idStr = id.toString();\n const localVersions = await component.getLocalHashes(scope.objects);\n if (!localVersions.length) throw new BitError(`unable to untag ${idStr}, the component is not staged`);\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef) {\n throw new Error(`unable to reset ${idStr}, it has not head`);\n }\n if (head && !localVersions.find((v) => v.isEqual(headRef))) {\n throw new Error(`unable to reset ${idStr}, the head ${headRef.toString()} is exported`);\n }\n const versionsToRemove = head ? [headRef] : localVersions;\n const versionsToRemoveStr = component.switchHashesWithTagsIfExist(versionsToRemove);\n\n if (!force) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(scope);\n\n versionsToRemoveStr.forEach((versionToRemove) => {\n const idWithVersion = component.toComponentId().changeVersion(versionToRemove);\n const dependents = dependencyGraph.getImmediateDependentsPerId(idWithVersion);\n if (dependents.length) {\n throw new BitError(\n `unable to reset ${idStr}, the version ${versionToRemove} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n\n await scope.sources.removeComponentVersions(component, versionsToRemove, versionsToRemoveStr, lane, head);\n\n return { id, versions: versionsToRemoveStr, component };\n}\n\nexport async function removeLocalVersionsForAllComponents(\n consumer: Consumer,\n remove: RemoveMain,\n lane?: Lane,\n head?: boolean\n): Promise<ResetResult[]> {\n const componentsToUntag = await getComponentsWithOptionToUntag(consumer, remove);\n const force = true; // when removing local versions from all components, no need to check if the component is used as a dependency\n return removeLocalVersionsForMultipleComponents(componentsToUntag, consumer.scope, lane, head, force);\n}\n\nexport async function removeLocalVersionsForMultipleComponents(\n componentsToUntag: ModelComponent[],\n scope: Scope,\n lane?: Lane,\n head?: boolean,\n force?: boolean\n) {\n if (!componentsToUntag.length) {\n throw new BitError(`no components found to reset on your workspace`);\n }\n // if only head is removed, there is risk of deleting dependencies version without their dependents.\n if (!force && head) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(scope);\n const candidateComponentsIds = componentsToUntag.map((component) => {\n const bitId = component.toComponentId();\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef)\n throw new Error(`component ${bitId.toString()} does not have head. it should not be a candidate for reset`);\n\n return bitId.changeVersion(component.getTagOfRefIfExists(headRef) || headRef.toString());\n });\n const candidateComponentsIdsStr = candidateComponentsIds.map((id) => id.toString());\n candidateComponentsIds.forEach((bitId: ComponentID) => {\n const dependents = dependencyGraph.getImmediateDependentsPerId(bitId);\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const dependentsNotCandidates = dependents.filter((dependent) => !candidateComponentsIdsStr.includes(dependent));\n if (dependentsNotCandidates.length) {\n throw new BitError( // $FlowFixMe\n `unable to untag ${bitId}, the version ${bitId.version} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n logger.debug(`found ${componentsToUntag.length} components to untag`);\n return Promise.all(\n componentsToUntag.map((component) => removeLocalVersion(scope, component.toComponentId(), lane, head, force))\n );\n}\n\nexport async function getComponentsWithOptionToUntag(\n consumer: Consumer,\n remove: RemoveMain\n): Promise<ModelComponent[]> {\n const componentList = new ComponentsList(consumer);\n const laneObj = await consumer.getCurrentLaneObject();\n const components: ModelComponent[] = await componentList.listExportPendingComponents(laneObj);\n const removedStagedIds = await remove.getRemovedStaged();\n if (!removedStagedIds.length) return components;\n const removedStagedBitIds = removedStagedIds.map((id) => id);\n const nonExistsInStaged = removedStagedBitIds.filter(\n (id) => !components.find((c) => c.toComponentId().isEqualWithoutVersion(id))\n );\n if (!nonExistsInStaged.length) return components;\n const modelComps = await Promise.all(nonExistsInStaged.map((id) => consumer.scope.getModelComponent(id)));\n components.push(...modelComps);\n\n return components;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,YAA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MAAkB,EACS;EAC3B,MAAMkB,aAAa,GAAG,KAAIC,wBAAc,EAACpB,QAAQ,CAAC;EAClD,MAAMqB,OAAO,GAAG,MAAMrB,QAAQ,CAACsB,oBAAoB,CAAC,CAAC;EACrD,MAAMC,UAA4B,GAAG,MAAMJ,aAAa,CAACK,2BAA2B,CAACH,OAAO,CAAC;EAC7F,MAAMI,gBAAgB,GAAG,MAAMxB,MAAM,CAACyB,gBAAgB,CAAC,CAAC;EACxD,IAAI,CAACD,gBAAgB,CAACnD,MAAM,EAAE,OAAOiD,UAAU;EAC/C,MAAMI,mBAAmB,GAAGF,gBAAgB,CAACnB,GAAG,CAAE3C,EAAE,IAAKA,EAAE,CAAC;EAC5D,MAAMiE,iBAAiB,GAAGD,mBAAmB,CAAChB,MAAM,CACjDhD,EAAE,IAAK,CAAC4D,UAAU,CAAC5C,IAAI,CAAEkD,CAAC,IAAKA,CAAC,CAACtC,aAAa,CAAC,CAAC,CAACuC,qBAAqB,CAACnE,EAAE,CAAC,CAC7E,CAAC;EACD,IAAI,CAACiE,iBAAiB,CAACtD,MAAM,EAAE,OAAOiD,UAAU;EAChD,MAAMQ,UAAU,GAAG,MAAMd,OAAO,CAACC,GAAG,CAACU,iBAAiB,CAACtB,GAAG,CAAE3C,EAAE,IAAKqC,QAAQ,CAACtC,KAAK,CAACM,iBAAiB,CAACL,EAAE,CAAC,CAAC,CAAC;EACzG4D,UAAU,CAACS,IAAI,CAAC,GAAGD,UAAU,CAAC;EAE9B,OAAOR,UAAU;AACnB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","_legacy","_legacy2","_legacy3","removeLocalVersion","consumer","id","lane","head","force","component","scope","getModelComponent","idStr","toString","fromBitmap","bitMap","getComponentIdIfExist","localVersions","getLocalHashes","objects","length","BitError","headRef","getHeadRegardlessOfLane","Error","find","v","isEqual","versionsToRemove","versionsToRemoveStr","switchHashesWithTagsIfExist","dependencyGraph","DependencyGraph","loadAllVersions","forEach","versionToRemove","idWithVersion","toComponentId","changeVersion","dependents","getImmediateDependentsPerId","join","headBefore","getHead","sources","removeComponentVersions","headAfter","versionToSetInBitmap","divergeData","getDivergeData","snapBeforeDetached","commonSnapBeforeDiverge","getTagOfRefIfExists","versions","removeLocalVersionsForAllComponents","remove","componentsToUntag","getComponentsWithOptionToUntag","removeLocalVersionsForMultipleComponents","candidateComponentsIds","map","bitId","candidateComponentsIdsStr","dependentsNotCandidates","filter","dependent","includes","version","logger","debug","Promise","all","componentList","ComponentsList","laneObj","getCurrentLaneObject","components","listExportPendingComponents","removedStagedIds","getRemovedStaged","removedStagedBitIds","nonExistsInStaged","c","isEqualWithoutVersion","modelComps","push"],"sources":["reset-component.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component-id';\nimport { Consumer } from '@teambit/legacy.consumer';\nimport { ComponentsList } from '@teambit/legacy.component-list';\nimport { logger } from '@teambit/legacy.logger';\nimport { Lane, ModelComponent } from '@teambit/scope.objects';\nimport { RemoveMain } from '@teambit/remove';\nimport { DependencyGraph } from '@teambit/legacy.dependency-graph';\n\nexport type ResetResult = {\n id: ComponentID;\n versions: string[];\n component?: ModelComponent;\n /**\n * relevant when the component was detached head so the head didn't change.\n * we want .bitmap to have the version before the detachment. not as the head.\n */\n versionToSetInBitmap?: string;\n};\n\n/**\n * If head is false, remove all local versions.\n */\nexport async function removeLocalVersion(\n consumer: Consumer,\n id: ComponentID,\n lane?: Lane,\n head?: boolean,\n force = false\n): Promise<ResetResult> {\n const component: ModelComponent = await consumer.scope.getModelComponent(id);\n const idStr = id.toString();\n const fromBitmap = consumer.bitMap.getComponentIdIfExist(id);\n const localVersions = await component.getLocalHashes(consumer.scope.objects, fromBitmap);\n if (!localVersions.length) throw new BitError(`unable to untag ${idStr}, the component is not staged`);\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef) {\n throw new Error(`unable to reset ${idStr}, it has not head`);\n }\n if (head && !localVersions.find((v) => v.isEqual(headRef))) {\n throw new Error(`unable to reset ${idStr}, the head ${headRef.toString()} is exported`);\n }\n const versionsToRemove = head ? [headRef] : localVersions;\n const versionsToRemoveStr = component.switchHashesWithTagsIfExist(versionsToRemove);\n\n if (!force) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(consumer.scope);\n\n versionsToRemoveStr.forEach((versionToRemove) => {\n const idWithVersion = component.toComponentId().changeVersion(versionToRemove);\n const dependents = dependencyGraph.getImmediateDependentsPerId(idWithVersion);\n if (dependents.length) {\n throw new BitError(\n `unable to reset ${idStr}, the version ${versionToRemove} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n\n const headBefore = component.getHead();\n await consumer.scope.sources.removeComponentVersions(component, versionsToRemove, versionsToRemoveStr, lane, head);\n const headAfter = component.getHead();\n let versionToSetInBitmap;\n if (headBefore && headAfter && headBefore.isEqual(headAfter) && !lane) {\n // if it's on main and the head didn't change, it means that it was in a detached-head state.\n const divergeData = component.getDivergeData();\n const snapBeforeDetached = divergeData.commonSnapBeforeDiverge;\n if (snapBeforeDetached) versionToSetInBitmap = component.getTagOfRefIfExists(snapBeforeDetached);\n }\n\n return { id, versions: versionsToRemoveStr, component, versionToSetInBitmap };\n}\n\nexport async function removeLocalVersionsForAllComponents(\n consumer: Consumer,\n remove: RemoveMain,\n lane?: Lane,\n head?: boolean\n): Promise<ResetResult[]> {\n const componentsToUntag = await getComponentsWithOptionToUntag(consumer, remove);\n const force = true; // when removing local versions from all components, no need to check if the component is used as a dependency\n return removeLocalVersionsForMultipleComponents(consumer, componentsToUntag, lane, head, force);\n}\n\nexport async function removeLocalVersionsForMultipleComponents(\n consumer: Consumer,\n componentsToUntag: ModelComponent[],\n lane?: Lane,\n head?: boolean,\n force?: boolean\n) {\n if (!componentsToUntag.length) {\n throw new BitError(`no components found to reset on your workspace`);\n }\n // if only head is removed, there is risk of deleting dependencies version without their dependents.\n if (!force && head) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(consumer.scope);\n const candidateComponentsIds = componentsToUntag.map((component) => {\n const bitId = component.toComponentId();\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef)\n throw new Error(`component ${bitId.toString()} does not have head. it should not be a candidate for reset`);\n\n return bitId.changeVersion(component.getTagOfRefIfExists(headRef) || headRef.toString());\n });\n const candidateComponentsIdsStr = candidateComponentsIds.map((id) => id.toString());\n candidateComponentsIds.forEach((bitId: ComponentID) => {\n const dependents = dependencyGraph.getImmediateDependentsPerId(bitId);\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const dependentsNotCandidates = dependents.filter((dependent) => !candidateComponentsIdsStr.includes(dependent));\n if (dependentsNotCandidates.length) {\n throw new BitError( // $FlowFixMe\n `unable to untag ${bitId}, the version ${bitId.version} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n logger.debug(`found ${componentsToUntag.length} components to untag`);\n return Promise.all(\n componentsToUntag.map((component) => removeLocalVersion(consumer, component.toComponentId(), lane, head, force))\n );\n}\n\nexport async function getComponentsWithOptionToUntag(\n consumer: Consumer,\n remove: RemoveMain\n): Promise<ModelComponent[]> {\n const componentList = new ComponentsList(consumer);\n const laneObj = await consumer.getCurrentLaneObject();\n const components: ModelComponent[] = await componentList.listExportPendingComponents(laneObj);\n const removedStagedIds = await remove.getRemovedStaged();\n if (!removedStagedIds.length) return components;\n const removedStagedBitIds = removedStagedIds.map((id) => id);\n const nonExistsInStaged = removedStagedBitIds.filter(\n (id) => !components.find((c) => c.toComponentId().isEqualWithoutVersion(id))\n );\n if (!nonExistsInStaged.length) return components;\n const modelComps = await Promise.all(nonExistsInStaged.map((id) => consumer.scope.getModelComponent(id)));\n components.push(...modelComps);\n\n return components;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,QAAA;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,CAAC;EACxD,IAAI,CAACD,gBAAgB,CAAC1D,MAAM,EAAE,OAAOwD,UAAU;EAC/C,MAAMI,mBAAmB,GAAGF,gBAAgB,CAAClB,GAAG,CAAEvD,EAAE,IAAKA,EAAE,CAAC;EAC5D,MAAM4E,iBAAiB,GAAGD,mBAAmB,CAAChB,MAAM,CACjD3D,EAAE,IAAK,CAACuE,UAAU,CAACnD,IAAI,CAAEyD,CAAC,IAAKA,CAAC,CAAC7C,aAAa,CAAC,CAAC,CAAC8C,qBAAqB,CAAC9E,EAAE,CAAC,CAC7E,CAAC;EACD,IAAI,CAAC4E,iBAAiB,CAAC7D,MAAM,EAAE,OAAOwD,UAAU;EAChD,MAAMQ,UAAU,GAAG,MAAMd,OAAO,CAACC,GAAG,CAACU,iBAAiB,CAACrB,GAAG,CAAEvD,EAAE,IAAKD,QAAQ,CAACM,KAAK,CAACC,iBAAiB,CAACN,EAAE,CAAC,CAAC,CAAC;EACzGuE,UAAU,CAACS,IAAI,CAAC,GAAGD,UAAU,CAAC;EAE9B,OAAOR,UAAU;AACnB","ignoreList":[]}
|
package/dist/snap-cmd.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare class SnapCmd implements Command {
|
|
|
20
20
|
options: CommandOptions;
|
|
21
21
|
loader: boolean;
|
|
22
22
|
constructor(snapping: SnappingMain, logger: Logger, globalConfig: GlobalConfigMain);
|
|
23
|
-
report([pattern]: string[], { message, unmerged, editor, ignoreIssues, build, skipTests, skipTasks, skipAutoSnap, disableSnapPipeline, ignoreBuildErrors, rebuildDepsGraph, unmodified, failFast, }: {
|
|
23
|
+
report([pattern]: string[], { message, unmerged, editor, ignoreIssues, build, skipTests, skipTasks, skipAutoSnap, disableSnapPipeline, ignoreBuildErrors, rebuildDepsGraph, unmodified, failFast, detachHead, }: {
|
|
24
24
|
unmerged?: boolean;
|
|
25
25
|
editor?: string;
|
|
26
26
|
ignoreIssues?: string;
|
package/dist/snap-cmd.js
CHANGED
|
@@ -54,7 +54,7 @@ class SnapCmd {
|
|
|
54
54
|
_defineProperty(this, "options", [['m', 'message <message>', 'snap message describing the latest changes - will appear in component history log'], ['u', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'], ['', 'unmerged', 'complete a merge process by snapping the unmerged components'], ['b', 'build', 'locally run the build pipeline (i.e. not via rippleCI) and complete the snap'], ['', 'editor [editor]', 'open an editor to write a snap message per component. optionally specify the editor-name (defaults to vim).'], ['', 'skip-tests', 'skip running component tests during snap process'], ['', 'skip-tasks <string>', `skip the given tasks. for multiple tasks, separate by a comma and wrap with quotes.
|
|
55
55
|
specify the task-name (e.g. "TypescriptCompiler") or the task-aspect-id (e.g. teambit.compilation/compiler)`], ['', 'skip-auto-snap', 'skip auto snapping dependents'], ['', 'disable-snap-pipeline', 'skip the snap pipeline. this will for instance skip packing and publishing component version for install, and app deployment'], ['', 'ignore-build-errors', 'proceed to snap pipeline even when build pipeline fails'], ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'], ['i', 'ignore-issues <issues>', `ignore component issues (shown in "bit status" as "issues found"), issues to ignore:
|
|
56
56
|
[${Object.keys(_componentIssues().IssuesClasses).join(', ')}]
|
|
57
|
-
to ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify "*".`], ['', 'fail-fast', 'stop pipeline execution on the first failed task (by default a task is skipped only when its dependency failed)']]);
|
|
57
|
+
to ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify "*".`], ['', 'fail-fast', 'stop pipeline execution on the first failed task (by default a task is skipped only when its dependency failed)'], ['', 'detach-head', 'UNSUPPORTED YET. in case a component is checked out to an older version, snap it without changing the head']]);
|
|
58
58
|
_defineProperty(this, "loader", true);
|
|
59
59
|
}
|
|
60
60
|
async report([pattern], {
|
|
@@ -70,7 +70,8 @@ to ignore multiple issues, separate them by a comma and wrap with quotes. to ign
|
|
|
70
70
|
ignoreBuildErrors = false,
|
|
71
71
|
rebuildDepsGraph,
|
|
72
72
|
unmodified = false,
|
|
73
|
-
failFast = false
|
|
73
|
+
failFast = false,
|
|
74
|
+
detachHead
|
|
74
75
|
}) {
|
|
75
76
|
build = (await this.globalConfig.getBool(_legacy().CFG_FORCE_LOCAL_BUILD)) || Boolean(build);
|
|
76
77
|
const disableTagAndSnapPipelines = disableSnapPipeline;
|
|
@@ -91,7 +92,8 @@ to ignore multiple issues, separate them by a comma and wrap with quotes. to ign
|
|
|
91
92
|
ignoreBuildErrors,
|
|
92
93
|
rebuildDepsGraph,
|
|
93
94
|
unmodified,
|
|
94
|
-
exitOnFirstFailedTask: failFast
|
|
95
|
+
exitOnFirstFailedTask: failFast,
|
|
96
|
+
detachHead
|
|
95
97
|
});
|
|
96
98
|
if (!results) return _chalk().default.yellow(_legacy().NOTHING_TO_SNAP_MSG);
|
|
97
99
|
const {
|
package/dist/snap-cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_componentIssues","_legacy","_tagCmd","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SnapCmd","constructor","snapping","logger","globalConfig","name","description","COMPONENT_PATTERN_HELP","keys","IssuesClasses","join","report","pattern","message","unmerged","editor","ignoreIssues","build","skipTests","skipTasks","skipAutoSnap","disableSnapPipeline","ignoreBuildErrors","rebuildDepsGraph","unmodified","failFast","getBool","CFG_FORCE_LOCAL_BUILD","Boolean","disableTagAndSnapPipelines","consoleWarning","results","snap","exitOnFirstFailedTask","chalk","yellow","NOTHING_TO_SNAP_MSG","snappedComponents","autoSnappedResults","warnings","newComponents","laneName","removedComponents","changedComponents","filter","component","searchWithoutVersion","id","addedComponents","autoTaggedCount","length","warningsOutput","snapExplanation","compInBold","version","hasVersion","bold","toStringWithoutVersion","outputComponents","comps","map","componentOutput","autoTag","result","triggeredBy","autoTagComp","a","AUTO_SNAPPED_MSG","outputIfExists","label","explanation","components","underline","laneStr","outputIdsIfExists","green","exports"],"sources":["snap-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { ComponentID } from '@teambit/component-id';\nimport { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { GlobalConfigMain } from '@teambit/global-config';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport {\n NOTHING_TO_SNAP_MSG,\n AUTO_SNAPPED_MSG,\n COMPONENT_PATTERN_HELP,\n CFG_FORCE_LOCAL_BUILD,\n} from '@teambit/legacy.constants';\nimport { Logger } from '@teambit/logger';\nimport { SnappingMain, SnapResults } from './snapping.main.runtime';\nimport { outputIdsIfExists } from './tag-cmd';\nimport { BasicTagSnapParams } from './tag-model-component';\n\nexport class SnapCmd implements Command {\n name = 'snap [component-pattern]';\n description = 'create an immutable and exportable component snapshot (non-release version)';\n extendedDescription: string;\n group = 'development';\n arguments = [\n {\n name: 'component-pattern',\n description: `${COMPONENT_PATTERN_HELP}. By default, only new and modified components are snapped (add --unmodified to snap all components in the workspace).`,\n },\n ];\n helpUrl = 'reference/components/snaps';\n alias = '';\n options = [\n ['m', 'message <message>', 'snap message describing the latest changes - will appear in component history log'],\n ['u', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'],\n ['', 'unmerged', 'complete a merge process by snapping the unmerged components'],\n ['b', 'build', 'locally run the build pipeline (i.e. not via rippleCI) and complete the snap'],\n [\n '',\n 'editor [editor]',\n 'open an editor to write a snap message per component. optionally specify the editor-name (defaults to vim).',\n ],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n [\n '',\n 'skip-tasks <string>',\n `skip the given tasks. for multiple tasks, separate by a comma and wrap with quotes.\nspecify the task-name (e.g. \"TypescriptCompiler\") or the task-aspect-id (e.g. teambit.compilation/compiler)`,\n ],\n ['', 'skip-auto-snap', 'skip auto snapping dependents'],\n [\n '',\n 'disable-snap-pipeline',\n 'skip the snap pipeline. this will for instance skip packing and publishing component version for install, and app deployment',\n ],\n ['', 'ignore-build-errors', 'proceed to snap pipeline even when build pipeline fails'],\n ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'],\n [\n 'i',\n 'ignore-issues <issues>',\n `ignore component issues (shown in \"bit status\" as \"issues found\"), issues to ignore:\n[${Object.keys(IssuesClasses).join(', ')}]\nto ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify \"*\".`,\n ],\n [\n '',\n 'fail-fast',\n 'stop pipeline execution on the first failed task (by default a task is skipped only when its dependency failed)',\n ],\n ] as CommandOptions;\n loader = true;\n\n constructor(\n private snapping: SnappingMain,\n private logger: Logger,\n private globalConfig: GlobalConfigMain\n ) {}\n\n async report(\n [pattern]: string[],\n {\n message = '',\n unmerged = false,\n editor = '',\n ignoreIssues,\n build,\n skipTests = false,\n skipTasks,\n skipAutoSnap = false,\n disableSnapPipeline = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n unmodified = false,\n failFast = false,\n }: {\n unmerged?: boolean;\n editor?: string;\n ignoreIssues?: string;\n skipAutoSnap?: boolean;\n disableSnapPipeline?: boolean;\n unmodified?: boolean;\n failFast?: boolean;\n } & BasicTagSnapParams\n ) {\n build = (await this.globalConfig.getBool(CFG_FORCE_LOCAL_BUILD)) || Boolean(build);\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (!message && !editor) {\n this.logger.consoleWarning(\n `--message will be mandatory in the next few releases. make sure to add a message with your snap, will be displayed in the version history`\n );\n }\n\n const results = await this.snapping.snap({\n pattern,\n message,\n unmerged,\n editor,\n ignoreIssues,\n build,\n skipTests,\n skipTasks,\n skipAutoSnap,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n unmodified,\n exitOnFirstFailedTask: failFast,\n });\n\n if (!results) return chalk.yellow(NOTHING_TO_SNAP_MSG);\n const { snappedComponents, autoSnappedResults, warnings, newComponents, laneName, removedComponents }: SnapResults =\n results;\n const changedComponents = snappedComponents.filter((component) => {\n return (\n !newComponents.searchWithoutVersion(component.id) && !removedComponents?.searchWithoutVersion(component.id)\n );\n });\n const addedComponents = snappedComponents.filter((component) => newComponents.searchWithoutVersion(component.id));\n const autoTaggedCount = autoSnappedResults ? autoSnappedResults.length : 0;\n\n const warningsOutput = warnings && warnings.length ? `${chalk.yellow(warnings.join('\\n'))}\\n\\n` : '';\n const snapExplanation = `\\n(use \"bit export\" to push these components to a remote\")\n(use \"bit reset --all\" to unstage all local versions, or \"bit reset --head\" to only unstage the latest local snap)`;\n\n const compInBold = (id: ComponentID) => {\n const version = id.hasVersion() ? `@${id.version}` : '';\n return `${chalk.bold(id.toStringWithoutVersion())}${version}`;\n };\n\n const outputComponents = (comps: ConsumerComponent[]) => {\n return comps\n .map((component) => {\n let componentOutput = ` > ${compInBold(component.id)}`;\n const autoTag = autoSnappedResults.filter((result) => result.triggeredBy.searchWithoutVersion(component.id));\n if (autoTag.length) {\n const autoTagComp = autoTag.map((a) => compInBold(a.component.id));\n componentOutput += `\\n ${AUTO_SNAPPED_MSG} (${autoTagComp.length} total):\n ${autoTagComp.join('\\n ')}`;\n }\n return componentOutput;\n })\n .join('\\n');\n };\n\n const outputIfExists = (label, explanation, components) => {\n if (!components.length) return '';\n return `\\n${chalk.underline(label)}\\n(${explanation})\\n${outputComponents(components)}\\n`;\n };\n const laneStr = laneName ? ` on \"${laneName}\" lane` : '';\n\n return (\n outputIfExists('new components', 'first version for components', addedComponents) +\n outputIfExists('changed components', 'components that got a version bump', changedComponents) +\n outputIdsIfExists('removed components', removedComponents) +\n warningsOutput +\n chalk.green(`\\n${snappedComponents.length + autoTaggedCount} component(s) snapped${laneStr}`) +\n snapExplanation\n );\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,iBAAA;EAAA,MAA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,WAAW,CAACf,MAAM;AAClF,cAAce,WAAW,CAACvD,IAAI,CAAC,gBAAgB,CAAC,EAAE;QACxC;QACA,OAAOmD,eAAe;MACxB,CAAC,CAAC,CACDnD,IAAI,CAAC,IAAI,CAAC;IACf,CAAC;IAED,MAAM0D,cAAc,GAAGA,CAACC,KAAK,EAAEC,WAAW,EAAEC,UAAU,KAAK;MACzD,IAAI,CAACA,UAAU,CAACrB,MAAM,EAAE,OAAO,EAAE;MACjC,OAAO,KAAKhB,gBAAK,CAACsC,SAAS,CAACH,KAAK,CAAC,MAAMC,WAAW,MAAMZ,gBAAgB,CAACa,UAAU,CAAC,IAAI;IAC3F,CAAC;IACD,MAAME,OAAO,GAAGhC,QAAQ,GAAG,QAAQA,QAAQ,QAAQ,GAAG,EAAE;IAExD,OACE2B,cAAc,CAAC,gBAAgB,EAAE,8BAA8B,EAAEpB,eAAe,CAAC,GACjFoB,cAAc,CAAC,oBAAoB,EAAE,oCAAoC,EAAEzB,iBAAiB,CAAC,GAC7F,IAAA+B,2BAAiB,EAAC,oBAAoB,EAAEhC,iBAAiB,CAAC,GAC1DS,cAAc,GACdjB,gBAAK,CAACyC,KAAK,CAAC,KAAKtC,iBAAiB,CAACa,MAAM,GAAGD,eAAe,wBAAwBwB,OAAO,EAAE,CAAC,GAC7FrB,eAAe;EAEnB;AACF;AAACwB,OAAA,CAAA5E,OAAA,GAAAA,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_componentIssues","_legacy","_tagCmd","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SnapCmd","constructor","snapping","logger","globalConfig","name","description","COMPONENT_PATTERN_HELP","keys","IssuesClasses","join","report","pattern","message","unmerged","editor","ignoreIssues","build","skipTests","skipTasks","skipAutoSnap","disableSnapPipeline","ignoreBuildErrors","rebuildDepsGraph","unmodified","failFast","detachHead","getBool","CFG_FORCE_LOCAL_BUILD","Boolean","disableTagAndSnapPipelines","consoleWarning","results","snap","exitOnFirstFailedTask","chalk","yellow","NOTHING_TO_SNAP_MSG","snappedComponents","autoSnappedResults","warnings","newComponents","laneName","removedComponents","changedComponents","filter","component","searchWithoutVersion","id","addedComponents","autoTaggedCount","length","warningsOutput","snapExplanation","compInBold","version","hasVersion","bold","toStringWithoutVersion","outputComponents","comps","map","componentOutput","autoTag","result","triggeredBy","autoTagComp","a","AUTO_SNAPPED_MSG","outputIfExists","label","explanation","components","underline","laneStr","outputIdsIfExists","green","exports"],"sources":["snap-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { ComponentID } from '@teambit/component-id';\nimport { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { GlobalConfigMain } from '@teambit/global-config';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport {\n NOTHING_TO_SNAP_MSG,\n AUTO_SNAPPED_MSG,\n COMPONENT_PATTERN_HELP,\n CFG_FORCE_LOCAL_BUILD,\n} from '@teambit/legacy.constants';\nimport { Logger } from '@teambit/logger';\nimport { SnappingMain, SnapResults } from './snapping.main.runtime';\nimport { outputIdsIfExists } from './tag-cmd';\nimport { BasicTagSnapParams } from './tag-model-component';\n\nexport class SnapCmd implements Command {\n name = 'snap [component-pattern]';\n description = 'create an immutable and exportable component snapshot (non-release version)';\n extendedDescription: string;\n group = 'development';\n arguments = [\n {\n name: 'component-pattern',\n description: `${COMPONENT_PATTERN_HELP}. By default, only new and modified components are snapped (add --unmodified to snap all components in the workspace).`,\n },\n ];\n helpUrl = 'reference/components/snaps';\n alias = '';\n options = [\n ['m', 'message <message>', 'snap message describing the latest changes - will appear in component history log'],\n ['u', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'],\n ['', 'unmerged', 'complete a merge process by snapping the unmerged components'],\n ['b', 'build', 'locally run the build pipeline (i.e. not via rippleCI) and complete the snap'],\n [\n '',\n 'editor [editor]',\n 'open an editor to write a snap message per component. optionally specify the editor-name (defaults to vim).',\n ],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n [\n '',\n 'skip-tasks <string>',\n `skip the given tasks. for multiple tasks, separate by a comma and wrap with quotes.\nspecify the task-name (e.g. \"TypescriptCompiler\") or the task-aspect-id (e.g. teambit.compilation/compiler)`,\n ],\n ['', 'skip-auto-snap', 'skip auto snapping dependents'],\n [\n '',\n 'disable-snap-pipeline',\n 'skip the snap pipeline. this will for instance skip packing and publishing component version for install, and app deployment',\n ],\n ['', 'ignore-build-errors', 'proceed to snap pipeline even when build pipeline fails'],\n ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'],\n [\n 'i',\n 'ignore-issues <issues>',\n `ignore component issues (shown in \"bit status\" as \"issues found\"), issues to ignore:\n[${Object.keys(IssuesClasses).join(', ')}]\nto ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify \"*\".`,\n ],\n [\n '',\n 'fail-fast',\n 'stop pipeline execution on the first failed task (by default a task is skipped only when its dependency failed)',\n ],\n [\n '',\n 'detach-head',\n 'UNSUPPORTED YET. in case a component is checked out to an older version, snap it without changing the head',\n ],\n ] as CommandOptions;\n loader = true;\n\n constructor(\n private snapping: SnappingMain,\n private logger: Logger,\n private globalConfig: GlobalConfigMain\n ) {}\n\n async report(\n [pattern]: string[],\n {\n message = '',\n unmerged = false,\n editor = '',\n ignoreIssues,\n build,\n skipTests = false,\n skipTasks,\n skipAutoSnap = false,\n disableSnapPipeline = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n unmodified = false,\n failFast = false,\n detachHead,\n }: {\n unmerged?: boolean;\n editor?: string;\n ignoreIssues?: string;\n skipAutoSnap?: boolean;\n disableSnapPipeline?: boolean;\n unmodified?: boolean;\n failFast?: boolean;\n } & BasicTagSnapParams\n ) {\n build = (await this.globalConfig.getBool(CFG_FORCE_LOCAL_BUILD)) || Boolean(build);\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (!message && !editor) {\n this.logger.consoleWarning(\n `--message will be mandatory in the next few releases. make sure to add a message with your snap, will be displayed in the version history`\n );\n }\n\n const results = await this.snapping.snap({\n pattern,\n message,\n unmerged,\n editor,\n ignoreIssues,\n build,\n skipTests,\n skipTasks,\n skipAutoSnap,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n unmodified,\n exitOnFirstFailedTask: failFast,\n detachHead,\n });\n\n if (!results) return chalk.yellow(NOTHING_TO_SNAP_MSG);\n const { snappedComponents, autoSnappedResults, warnings, newComponents, laneName, removedComponents }: SnapResults =\n results;\n const changedComponents = snappedComponents.filter((component) => {\n return (\n !newComponents.searchWithoutVersion(component.id) && !removedComponents?.searchWithoutVersion(component.id)\n );\n });\n const addedComponents = snappedComponents.filter((component) => newComponents.searchWithoutVersion(component.id));\n const autoTaggedCount = autoSnappedResults ? autoSnappedResults.length : 0;\n\n const warningsOutput = warnings && warnings.length ? `${chalk.yellow(warnings.join('\\n'))}\\n\\n` : '';\n const snapExplanation = `\\n(use \"bit export\" to push these components to a remote\")\n(use \"bit reset --all\" to unstage all local versions, or \"bit reset --head\" to only unstage the latest local snap)`;\n\n const compInBold = (id: ComponentID) => {\n const version = id.hasVersion() ? `@${id.version}` : '';\n return `${chalk.bold(id.toStringWithoutVersion())}${version}`;\n };\n\n const outputComponents = (comps: ConsumerComponent[]) => {\n return comps\n .map((component) => {\n let componentOutput = ` > ${compInBold(component.id)}`;\n const autoTag = autoSnappedResults.filter((result) => result.triggeredBy.searchWithoutVersion(component.id));\n if (autoTag.length) {\n const autoTagComp = autoTag.map((a) => compInBold(a.component.id));\n componentOutput += `\\n ${AUTO_SNAPPED_MSG} (${autoTagComp.length} total):\n ${autoTagComp.join('\\n ')}`;\n }\n return componentOutput;\n })\n .join('\\n');\n };\n\n const outputIfExists = (label, explanation, components) => {\n if (!components.length) return '';\n return `\\n${chalk.underline(label)}\\n(${explanation})\\n${outputComponents(components)}\\n`;\n };\n const laneStr = laneName ? ` on \"${laneName}\" lane` : '';\n\n return (\n outputIfExists('new components', 'first version for components', addedComponents) +\n outputIfExists('changed components', 'components that got a version bump', changedComponents) +\n outputIdsIfExists('removed components', removedComponents) +\n warningsOutput +\n chalk.green(`\\n${snappedComponents.length + autoTaggedCount} component(s) snapped${laneStr}`) +\n snapExplanation\n );\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,iBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,gBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,SAAAC,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,C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KAAKtC,iBAAiB,CAACa,MAAM,GAAGD,eAAe,wBAAwBwB,OAAO,EAAE,CAAC,GAC7FrB,eAAe;EAEnB;AACF;AAACwB,OAAA,CAAA7E,OAAA,GAAAA,OAAA","ignoreList":[]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ScopeMain } from '@teambit/scope';
|
|
2
2
|
import { Command, CommandOptions } from '@teambit/cli';
|
|
3
|
+
import { Workspace } from '@teambit/workspace';
|
|
3
4
|
export declare class SnapDistanceCmd implements Command {
|
|
4
5
|
private scope;
|
|
6
|
+
private workspace?;
|
|
5
7
|
name: string;
|
|
6
8
|
description: string;
|
|
7
9
|
extendedDescription: string;
|
|
@@ -9,6 +11,6 @@ export declare class SnapDistanceCmd implements Command {
|
|
|
9
11
|
options: CommandOptions;
|
|
10
12
|
loader: boolean;
|
|
11
13
|
private: boolean;
|
|
12
|
-
constructor(scope: ScopeMain);
|
|
14
|
+
constructor(scope: ScopeMain, workspace?: Workspace | undefined);
|
|
13
15
|
report([id, sourceSnap, targetSnap]: [string, string, string]): Promise<string>;
|
|
14
16
|
}
|
|
@@ -15,8 +15,9 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
15
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
16
16
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
17
|
class SnapDistanceCmd {
|
|
18
|
-
constructor(scope) {
|
|
18
|
+
constructor(scope, workspace) {
|
|
19
19
|
this.scope = scope;
|
|
20
|
+
this.workspace = workspace;
|
|
20
21
|
_defineProperty(this, "name", 'snap-distance <component-id> [source-snap] [target-snap]');
|
|
21
22
|
_defineProperty(this, "description", 'show common-snap and distance between two given snaps or between local and remote snaps');
|
|
22
23
|
_defineProperty(this, "extendedDescription", `in case source and target snaps are not provided, the command will use the local and remote heads.
|
|
@@ -30,7 +31,10 @@ if source and target snaps are provided, the command will use them to calculate
|
|
|
30
31
|
async report([id, sourceSnap, targetSnap]) {
|
|
31
32
|
const compId = await this.scope.resolveComponentId(id);
|
|
32
33
|
const getSnapDistance = async () => {
|
|
33
|
-
if (!sourceSnap)
|
|
34
|
+
if (!sourceSnap) {
|
|
35
|
+
const fromWorkspace = this.workspace?.getIdIfExist(compId);
|
|
36
|
+
return this.scope.getSnapDistance(compId, false, fromWorkspace);
|
|
37
|
+
}
|
|
34
38
|
if (!targetSnap) throw new (_bitError().BitError)('either provide both source and target snaps or none');
|
|
35
39
|
return this.scope.getSnapsDistanceBetweenTwoSnaps(compId, sourceSnap, targetSnap, false);
|
|
36
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_bitError","data","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SnapDistanceCmd","constructor","scope","report","id","sourceSnap","targetSnap","compId","resolveComponentId","getSnapDistance","BitError","getSnapsDistanceBetweenTwoSnaps","snapDistance","JSON","stringify","exports"],"sources":["snap-distance-cmd.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ScopeMain } from '@teambit/scope';\nimport { Command, CommandOptions } from '@teambit/cli';\n\nexport class SnapDistanceCmd implements Command {\n name = 'snap-distance <component-id> [source-snap] [target-snap]';\n description = 'show common-snap and distance between two given snaps or between local and remote snaps';\n extendedDescription = `in case source and target snaps are not provided, the command will use the local and remote heads.\nby \"head\" we mean component-head if on main, or lane-head if on lane.\nif source and target snaps are provided, the command will use them to calculate the distance.`;\n alias = '';\n options = [] as CommandOptions;\n loader = true;\n private = true;\n\n constructor(private scope: ScopeMain) {}\n\n async report([id, sourceSnap, targetSnap]: [string, string, string]) {\n const compId = await this.scope.resolveComponentId(id);\n const getSnapDistance = async () => {\n if (!sourceSnap) return this.scope.getSnapDistance(compId, false);\n if (!targetSnap) throw new BitError('either provide both source and target snaps or none');\n return this.scope.getSnapsDistanceBetweenTwoSnaps(compId, sourceSnap, targetSnap, false);\n };\n const snapDistance = await getSnapDistance();\n return JSON.stringify(snapDistance, null, 2);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,SAAAE,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GAAAE,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAb,CAAA,QAAAU,CAAA,GAAAV,CAAA,CAAAc,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA;
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SnapDistanceCmd","constructor","scope","workspace","report","id","sourceSnap","targetSnap","compId","resolveComponentId","getSnapDistance","fromWorkspace","getIdIfExist","BitError","getSnapsDistanceBetweenTwoSnaps","snapDistance","JSON","stringify","exports"],"sources":["snap-distance-cmd.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ScopeMain } from '@teambit/scope';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { Workspace } from '@teambit/workspace';\n\nexport class SnapDistanceCmd implements Command {\n name = 'snap-distance <component-id> [source-snap] [target-snap]';\n description = 'show common-snap and distance between two given snaps or between local and remote snaps';\n extendedDescription = `in case source and target snaps are not provided, the command will use the local and remote heads.\nby \"head\" we mean component-head if on main, or lane-head if on lane.\nif source and target snaps are provided, the command will use them to calculate the distance.`;\n alias = '';\n options = [] as CommandOptions;\n loader = true;\n private = true;\n\n constructor(\n private scope: ScopeMain,\n private workspace?: Workspace\n ) {}\n\n async report([id, sourceSnap, targetSnap]: [string, string, string]) {\n const compId = await this.scope.resolveComponentId(id);\n const getSnapDistance = async () => {\n if (!sourceSnap) {\n const fromWorkspace = this.workspace?.getIdIfExist(compId);\n return this.scope.getSnapDistance(compId, false, fromWorkspace);\n }\n if (!targetSnap) throw new BitError('either provide both source and target snaps or none');\n return this.scope.getSnapsDistanceBetweenTwoSnaps(compId, sourceSnap, targetSnap, false);\n };\n const snapDistance = await getSnapDistance();\n return JSON.stringify(snapDistance, null, 2);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,SAAAE,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA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aAAa,CAAC;MACjE;MACA,IAAI,CAACJ,UAAU,EAAE,MAAM,KAAIM,oBAAQ,EAAC,qDAAqD,CAAC;MAC1F,OAAO,IAAI,CAACX,KAAK,CAACY,+BAA+B,CAACN,MAAM,EAAEF,UAAU,EAAEC,UAAU,EAAE,KAAK,CAAC;IAC1F,CAAC;IACD,MAAMQ,YAAY,GAAG,MAAML,eAAe,CAAC,CAAC;IAC5C,OAAOM,IAAI,CAACC,SAAS,CAACF,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;EAC9C;AACF;AAACG,OAAA,CAAAlB,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -90,7 +90,7 @@ export declare class SnappingMain {
|
|
|
90
90
|
* with a valid semver to that version.
|
|
91
91
|
* tag can be done only on main, not on a lane.
|
|
92
92
|
*/
|
|
93
|
-
tag({ ids, message, version, editor, snapped, unmerged, releaseType, preReleaseId, ignoreIssues, ignoreNewestVersion, skipTests, skipTasks, skipAutoTag, build, unmodified, soft, persist, ignoreBuildErrors, rebuildDepsGraph, incrementBy, disableTagAndSnapPipelines, failFast, }: {
|
|
93
|
+
tag({ ids, message, version, editor, snapped, unmerged, releaseType, preReleaseId, ignoreIssues, ignoreNewestVersion, skipTests, skipTasks, skipAutoTag, build, unmodified, soft, persist, ignoreBuildErrors, rebuildDepsGraph, incrementBy, disableTagAndSnapPipelines, failFast, detachHead, overrideHead, }: {
|
|
94
94
|
ids?: string[];
|
|
95
95
|
all?: boolean | string;
|
|
96
96
|
snapped?: boolean;
|
|
@@ -123,7 +123,7 @@ export declare class SnappingMain {
|
|
|
123
123
|
* once a component is snapped on a lane, it becomes part of it.
|
|
124
124
|
*/
|
|
125
125
|
snap({ pattern, legacyBitIds, // @todo: change to ComponentID[]. pass only if have the ids already parsed.
|
|
126
|
-
unmerged, editor, message, ignoreIssues, skipTests, skipTasks, skipAutoSnap, build, disableTagAndSnapPipelines, ignoreBuildErrors, rebuildDepsGraph, unmodified, exitOnFirstFailedTask, }: Partial<BasicTagSnapParams> & {
|
|
126
|
+
unmerged, editor, message, ignoreIssues, skipTests, skipTasks, skipAutoSnap, build, disableTagAndSnapPipelines, ignoreBuildErrors, rebuildDepsGraph, unmodified, exitOnFirstFailedTask, detachHead, }: Partial<BasicTagSnapParams> & {
|
|
127
127
|
pattern?: string;
|
|
128
128
|
legacyBitIds?: ComponentIdList;
|
|
129
129
|
unmerged?: boolean;
|
|
@@ -159,10 +159,12 @@ export declare class SnappingMain {
|
|
|
159
159
|
}): Promise<{
|
|
160
160
|
component: ModelComponent;
|
|
161
161
|
version: Version;
|
|
162
|
+
addedVersionStr: string;
|
|
162
163
|
}>;
|
|
163
164
|
_addCompFromScopeToObjects(source: ConsumerComponent, lane?: Lane, addVersionOpts?: AddVersionOpts): Promise<{
|
|
164
165
|
component: ModelComponent;
|
|
165
166
|
version: Version;
|
|
167
|
+
addedVersionStr: string;
|
|
166
168
|
}>;
|
|
167
169
|
_enrichComp(consumerComponent: ConsumerComponent, modifiedLog?: Log): Promise<ConsumerComponent>;
|
|
168
170
|
_getObjectsToEnrichComp(consumerComponent: ConsumerComponent, modifiedLog?: Log): Promise<BitObject[]>;
|
|
@@ -386,7 +386,9 @@ class SnappingMain {
|
|
|
386
386
|
rebuildDepsGraph,
|
|
387
387
|
incrementBy = 1,
|
|
388
388
|
disableTagAndSnapPipelines = false,
|
|
389
|
-
failFast = false
|
|
389
|
+
failFast = false,
|
|
390
|
+
detachHead,
|
|
391
|
+
overrideHead
|
|
390
392
|
}) {
|
|
391
393
|
if (soft) build = false;
|
|
392
394
|
if (editor && persist) {
|
|
@@ -395,6 +397,7 @@ class SnappingMain {
|
|
|
395
397
|
if (editor && message) {
|
|
396
398
|
throw new (_bitError().BitError)('you can use either --editor or --message, but not both');
|
|
397
399
|
}
|
|
400
|
+
ignoreNewestVersion = Boolean(ignoreNewestVersion || detachHead || overrideHead);
|
|
398
401
|
const exactVersion = version;
|
|
399
402
|
if (!this.workspace) throw new (_workspace().OutsideWorkspaceError)();
|
|
400
403
|
const validExactVersion = (0, _pkgModules().validateVersion)(exactVersion);
|
|
@@ -440,7 +443,9 @@ class SnappingMain {
|
|
|
440
443
|
rebuildDepsGraph,
|
|
441
444
|
incrementBy,
|
|
442
445
|
packageManagerConfigRootDir: this.workspace.path,
|
|
443
|
-
exitOnFirstFailedTask: failFast
|
|
446
|
+
exitOnFirstFailedTask: failFast,
|
|
447
|
+
detachHead,
|
|
448
|
+
overrideHead
|
|
444
449
|
});
|
|
445
450
|
const tagResults = {
|
|
446
451
|
taggedComponents,
|
|
@@ -463,6 +468,7 @@ class SnappingMain {
|
|
|
463
468
|
if (!this.scope) {
|
|
464
469
|
throw new (_bitError().BitError)(`please create a new bare-scope and run it from there`);
|
|
465
470
|
}
|
|
471
|
+
params.ignoreNewestVersion = params.ignoreNewestVersion || params.detachHead || params.overrideHead;
|
|
466
472
|
const tagDataPerComp = await Promise.all(tagDataPerCompRaw.map(async tagData => {
|
|
467
473
|
return {
|
|
468
474
|
componentId: await this.scope.resolveComponentId(tagData.componentId),
|
|
@@ -530,7 +536,7 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
530
536
|
persist: true,
|
|
531
537
|
ids: componentIds,
|
|
532
538
|
message: params.message,
|
|
533
|
-
setHeadAsParent: params.
|
|
539
|
+
setHeadAsParent: params.overrideHead
|
|
534
540
|
}));
|
|
535
541
|
const {
|
|
536
542
|
taggedComponents,
|
|
@@ -734,7 +740,8 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
734
740
|
ignoreBuildErrors = false,
|
|
735
741
|
rebuildDepsGraph,
|
|
736
742
|
unmodified = false,
|
|
737
|
-
exitOnFirstFailedTask = false
|
|
743
|
+
exitOnFirstFailedTask = false,
|
|
744
|
+
detachHead
|
|
738
745
|
}) {
|
|
739
746
|
if (!this.workspace) throw new (_workspace().OutsideWorkspaceError)();
|
|
740
747
|
if (pattern && legacyBitIds) throw new Error(`please pass either pattern or legacyBitIds, not both`);
|
|
@@ -773,7 +780,8 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
773
780
|
ignoreBuildErrors,
|
|
774
781
|
rebuildDepsGraph,
|
|
775
782
|
packageManagerConfigRootDir: this.workspace.path,
|
|
776
|
-
exitOnFirstFailedTask
|
|
783
|
+
exitOnFirstFailedTask,
|
|
784
|
+
detachHead
|
|
777
785
|
});
|
|
778
786
|
const snapResults = {
|
|
779
787
|
snappedComponents: taggedComponents,
|
|
@@ -838,7 +846,7 @@ in case you're unsure about the pattern syntax, use "bit pattern [--help]"`);
|
|
|
838
846
|
});
|
|
839
847
|
const idsMatchingPatternBitIds = _componentId().ComponentIdList.fromArray(idsMatchingPattern);
|
|
840
848
|
const componentsToUntag = candidateComponents.filter(modelComponent => idsMatchingPatternBitIds.hasWithoutVersion(modelComponent.toComponentId()));
|
|
841
|
-
return (0, _resetComponent().removeLocalVersionsForMultipleComponents)(
|
|
849
|
+
return (0, _resetComponent().removeLocalVersionsForMultipleComponents)(consumer, componentsToUntag, currentLane, head, force);
|
|
842
850
|
};
|
|
843
851
|
const softUntag = async () => {
|
|
844
852
|
const softTaggedComponentsIds = this.workspace.filter.bySoftTagged();
|
|
@@ -861,8 +869,16 @@ in case you're unsure about the pattern syntax, use "bit pattern [--help]"`);
|
|
|
861
869
|
if (isRealUntag) {
|
|
862
870
|
results = await untag();
|
|
863
871
|
await consumer.scope.objects.persist();
|
|
864
|
-
const
|
|
865
|
-
await
|
|
872
|
+
const currentLaneId = consumer.getCurrentLaneId();
|
|
873
|
+
const stagedConfig = await this.workspace.scope.getStagedConfig();
|
|
874
|
+
await (0, _pMapSeries().default)(results, async ({
|
|
875
|
+
component,
|
|
876
|
+
versionToSetInBitmap
|
|
877
|
+
}) => {
|
|
878
|
+
if (!component) return;
|
|
879
|
+
await (0, _tagModelComponent().updateVersions)(this.workspace, stagedConfig, currentLaneId, component, versionToSetInBitmap, false);
|
|
880
|
+
});
|
|
881
|
+
await this.workspace.scope.legacyScope.stagedSnaps.write();
|
|
866
882
|
} else {
|
|
867
883
|
results = await softUntag();
|
|
868
884
|
consumer.bitMap.markAsChanged();
|
|
@@ -1079,6 +1095,7 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1079
1095
|
addVersionOpts
|
|
1080
1096
|
}) {
|
|
1081
1097
|
const {
|
|
1098
|
+
addedVersionStr,
|
|
1082
1099
|
component,
|
|
1083
1100
|
version
|
|
1084
1101
|
} = await this._addCompFromScopeToObjects(source, lane, addVersionOpts);
|
|
@@ -1115,6 +1132,7 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1115
1132
|
}
|
|
1116
1133
|
if (shouldValidateVersion) version.validate();
|
|
1117
1134
|
return {
|
|
1135
|
+
addedVersionStr,
|
|
1118
1136
|
component,
|
|
1119
1137
|
version
|
|
1120
1138
|
};
|
|
@@ -1147,14 +1165,15 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1147
1165
|
if (flattenedEdges) this.objectsRepo.add(flattenedEdges);
|
|
1148
1166
|
if (dependenciesGraph) this.objectsRepo.add(dependenciesGraph);
|
|
1149
1167
|
if (!source.version) throw new Error(`addSource expects source.version to be set`);
|
|
1150
|
-
component.addVersion(version, source.version, lane, source.previouslyUsedVersion, addVersionOpts);
|
|
1168
|
+
const addedVersionStr = component.addVersion(version, source.version, lane, source.previouslyUsedVersion, addVersionOpts);
|
|
1151
1169
|
objectRepo.add(component);
|
|
1152
1170
|
if (lane) objectRepo.add(lane);
|
|
1153
1171
|
files.forEach(file => objectRepo.add(file.file));
|
|
1154
1172
|
if (artifacts) artifacts.forEach(file => objectRepo.add(file.source));
|
|
1155
1173
|
return {
|
|
1156
1174
|
component,
|
|
1157
|
-
version
|
|
1175
|
+
version,
|
|
1176
|
+
addedVersionStr
|
|
1158
1177
|
};
|
|
1159
1178
|
}
|
|
1160
1179
|
async _enrichComp(consumerComponent, modifiedLog) {
|
|
@@ -1411,7 +1430,7 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1411
1430
|
const tagFromScopeCmd = new (_tagFromScope().TagFromScopeCmd)(snapping, logger);
|
|
1412
1431
|
const snapFromScopeCmd = new (_snapFromScope().SnapFromScopeCmd)(snapping, logger);
|
|
1413
1432
|
const resetCmd = new (_resetCmd().default)(snapping);
|
|
1414
|
-
const snapDistanceCmd = new (_snapDistanceCmd().SnapDistanceCmd)(scope);
|
|
1433
|
+
const snapDistanceCmd = new (_snapDistanceCmd().SnapDistanceCmd)(scope, workspace);
|
|
1415
1434
|
cli.register(tagCmd, snapCmd, resetCmd, tagFromScopeCmd, snapFromScopeCmd, snapDistanceCmd);
|
|
1416
1435
|
return snapping;
|
|
1417
1436
|
}
|