@teambit/snapping 1.0.244 → 1.0.246
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 +4 -4
- package/artifacts/schema.json +272 -386
- package/dist/reset-component.d.ts +3 -3
- package/dist/reset-component.js.map +1 -1
- package/dist/snapping.main.runtime.d.ts +2 -2
- package/dist/snapping.main.runtime.js +6 -6
- package/dist/snapping.main.runtime.js.map +1 -1
- package/dist/tag-model-component.js.map +1 -1
- package/package.json +16 -16
- /package/dist/{preview-1713496942811.js → preview-1713669572180.js} +0 -0
|
@@ -10,7 +10,7 @@ export type untagResult = {
|
|
|
10
10
|
/**
|
|
11
11
|
* If head is false, remove all local versions.
|
|
12
12
|
*/
|
|
13
|
-
export declare function removeLocalVersion(scope: Scope, id: ComponentID, lane
|
|
14
|
-
export declare function removeLocalVersionsForAllComponents(consumer: Consumer, lane
|
|
15
|
-
export declare function removeLocalVersionsForMultipleComponents(componentsToUntag: ModelComponent[], lane
|
|
13
|
+
export declare function removeLocalVersion(scope: Scope, id: ComponentID, lane?: Lane, head?: boolean, force?: boolean): Promise<untagResult>;
|
|
14
|
+
export declare function removeLocalVersionsForAllComponents(consumer: Consumer, lane?: Lane, head?: boolean): Promise<untagResult[]>;
|
|
15
|
+
export declare function removeLocalVersionsForMultipleComponents(componentsToUntag: ModelComponent[], lane?: Lane, head?: boolean, force: boolean, scope: Scope): Promise<untagResult[]>;
|
|
16
16
|
export declare function getComponentsWithOptionToUntag(consumer: Consumer): Promise<ModelComponent[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_bitError","data","require","_componentsList","_interopRequireDefault","_logger","obj","__esModule","default","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","getDependencyGraph","forEach","versionToRemove","idWithVersion","toComponentId","changeVersion","dependents","getImmediateDependentsPerId","join","sources","removeComponentVersions","versions","removeLocalVersionsForAllComponents","consumer","componentsToUntag","getComponentsWithOptionToUntag","removeLocalVersionsForMultipleComponents","candidateComponentsIds","map","bitId","getTagOfRefIfExists","candidateComponentsIdsStr","dependentsNotCandidates","filter","dependent","includes","version","logger","debug","Promise","all","componentList","ComponentsList","laneObj","getCurrentLaneObject","components","listExportPendingComponents"],"sources":["reset-component.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component-id';\nimport { Scope } from '@teambit/legacy/dist/scope';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { Lane, ModelComponent } from '@teambit/legacy/dist/scope/models';\n\nexport type untagResult = { 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
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","_componentsList","_interopRequireDefault","_logger","obj","__esModule","default","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","getDependencyGraph","forEach","versionToRemove","idWithVersion","toComponentId","changeVersion","dependents","getImmediateDependentsPerId","join","sources","removeComponentVersions","versions","removeLocalVersionsForAllComponents","consumer","componentsToUntag","getComponentsWithOptionToUntag","removeLocalVersionsForMultipleComponents","candidateComponentsIds","map","bitId","getTagOfRefIfExists","candidateComponentsIdsStr","dependentsNotCandidates","filter","dependent","includes","version","logger","debug","Promise","all","componentList","ComponentsList","laneObj","getCurrentLaneObject","components","listExportPendingComponents"],"sources":["reset-component.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component-id';\nimport { Scope } from '@teambit/legacy/dist/scope';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport ComponentsList from '@teambit/legacy/dist/consumer/component/components-list';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { Lane, ModelComponent } from '@teambit/legacy/dist/scope/models';\n\nexport type untagResult = { 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<untagResult> {\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 scope.getDependencyGraph();\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 lane?: Lane,\n head?: boolean\n): Promise<untagResult[]> {\n const componentsToUntag = await getComponentsWithOptionToUntag(consumer);\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, lane, head, force, consumer.scope);\n}\n\nexport async function removeLocalVersionsForMultipleComponents(\n componentsToUntag: ModelComponent[],\n lane?: Lane,\n head?: boolean,\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n force: boolean,\n scope: Scope\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 scope.getDependencyGraph();\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(consumer: Consumer): Promise<ModelComponent[]> {\n const componentList = new ComponentsList(consumer);\n const laneObj = await consumer.getCurrentLaneObject();\n const components: ModelComponent[] = await componentList.listExportPendingComponents(laneObj);\n\n return components;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAA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,CAAE,EACJ,CAAC;MACH;IACF,CAAC,CAAC;EACJ;EACAmB,iBAAM,CAACC,KAAK,CAAE,SAAQd,iBAAiB,CAAC1B,MAAO,sBAAqB,CAAC;EACrE,OAAOyC,OAAO,CAACC,GAAG,CAChBhB,iBAAiB,CAACI,GAAG,CAAErC,SAAS,IAAKN,kBAAkB,CAACC,KAAK,EAAEK,SAAS,CAACuB,aAAa,CAAC,CAAC,EAAE1B,IAAI,EAAEC,IAAI,EAAEC,KAAK,CAAC,CAC9G,CAAC;AACH;AAEO,eAAemC,8BAA8BA,CAACF,QAAkB,EAA6B;EAClG,MAAMkB,aAAa,GAAG,KAAIC,yBAAc,EAACnB,QAAQ,CAAC;EAClD,MAAMoB,OAAO,GAAG,MAAMpB,QAAQ,CAACqB,oBAAoB,CAAC,CAAC;EACrD,MAAMC,UAA4B,GAAG,MAAMJ,aAAa,CAACK,2BAA2B,CAACH,OAAO,CAAC;EAE7F,OAAOE,UAAU;AACnB","ignoreList":[]}
|
|
@@ -146,14 +146,14 @@ export declare class SnappingMain {
|
|
|
146
146
|
_getPublishedPackages(components: ConsumerComponent[]): string[];
|
|
147
147
|
_addCompToObjects({ source, lane, shouldValidateVersion, updateDependentsOnLane, }: {
|
|
148
148
|
source: ConsumerComponent;
|
|
149
|
-
lane
|
|
149
|
+
lane?: Lane;
|
|
150
150
|
shouldValidateVersion?: boolean;
|
|
151
151
|
updateDependentsOnLane?: boolean;
|
|
152
152
|
}): Promise<{
|
|
153
153
|
component: ModelComponent;
|
|
154
154
|
version: Version;
|
|
155
155
|
}>;
|
|
156
|
-
_addCompFromScopeToObjects(source: ConsumerComponent, lane
|
|
156
|
+
_addCompFromScopeToObjects(source: ConsumerComponent, lane?: Lane, updateDependentsOnLane?: boolean): Promise<{
|
|
157
157
|
component: ModelComponent;
|
|
158
158
|
version: Version;
|
|
159
159
|
}>;
|
|
@@ -685,7 +685,7 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
685
685
|
ids,
|
|
686
686
|
idsWithFutureScope: ids,
|
|
687
687
|
allVersions: false,
|
|
688
|
-
laneObject: updatedLane
|
|
688
|
+
laneObject: updatedLane,
|
|
689
689
|
// no need other snaps. only the latest one. without this option, when snapping on lane from another-scope, it
|
|
690
690
|
// may throw an error saying the previous snaps don't exist on the filesystem.
|
|
691
691
|
// (see the e2e - "snap on a lane when the component is new to the lane and the scope")
|
|
@@ -881,13 +881,13 @@ in case you're unsure about the pattern syntax, use "bit pattern [--help]"`);
|
|
|
881
881
|
};
|
|
882
882
|
const lane = await getLane();
|
|
883
883
|
if (rebuildDepsGraph) {
|
|
884
|
-
const flattenedDependenciesGetter = new (_getFlattenedDependencies().FlattenedDependenciesGetter)(this.scope.legacyScope, components, lane
|
|
884
|
+
const flattenedDependenciesGetter = new (_getFlattenedDependencies().FlattenedDependenciesGetter)(this.scope.legacyScope, components, lane);
|
|
885
885
|
await flattenedDependenciesGetter.populateFlattenedDependencies();
|
|
886
886
|
_loader().default.stop();
|
|
887
887
|
await this._addFlattenedDepsGraphToComponents(components);
|
|
888
888
|
return;
|
|
889
889
|
}
|
|
890
|
-
const flattenedEdgesGetter = new (_flattenedEdges().FlattenedEdgesGetter)(this.scope, components, this.logger, lane
|
|
890
|
+
const flattenedEdgesGetter = new (_flattenedEdges().FlattenedEdgesGetter)(this.scope, components, this.logger, lane);
|
|
891
891
|
await flattenedEdgesGetter.buildGraph();
|
|
892
892
|
components.forEach(component => {
|
|
893
893
|
flattenedEdgesGetter.populateFlattenedAndEdgesForComp(component);
|
|
@@ -898,7 +898,7 @@ in case you're unsure about the pattern syntax, use "bit pattern [--help]"`);
|
|
|
898
898
|
const lane = await this.scope.legacyScope.getCurrentLaneObject();
|
|
899
899
|
const allIds = _componentId().ComponentIdList.fromArray(components.map(c => c.id));
|
|
900
900
|
const missingDeps = await (0, _pMapSeries().default)(components, async component => {
|
|
901
|
-
return this.throwForDepsFromAnotherLaneForComp(component, allIds, lane
|
|
901
|
+
return this.throwForDepsFromAnotherLaneForComp(component, allIds, lane);
|
|
902
902
|
});
|
|
903
903
|
const flattenedMissingDeps = _componentId().ComponentIdList.uniqFromArray(missingDeps.flat().map(id => id.changeVersion(undefined)));
|
|
904
904
|
if (!flattenedMissingDeps.length) return;
|
|
@@ -908,11 +908,11 @@ in case you're unsure about the pattern syntax, use "bit pattern [--help]"`);
|
|
|
908
908
|
cache: false,
|
|
909
909
|
ignoreMissingHead: true,
|
|
910
910
|
includeVersionHistory: true,
|
|
911
|
-
lane
|
|
911
|
+
lane,
|
|
912
912
|
reason: 'of latest with version-history to make sure there are no dependencies from another lane'
|
|
913
913
|
});
|
|
914
914
|
await (0, _pMapSeries().default)(components, async component => {
|
|
915
|
-
await this.throwForDepsFromAnotherLaneForComp(component, allIds, lane
|
|
915
|
+
await this.throwForDepsFromAnotherLaneForComp(component, allIds, lane, true);
|
|
916
916
|
});
|
|
917
917
|
}
|
|
918
918
|
async throwForVariousIssues(components, ignoreIssues) {
|