@teambit/snapping 0.0.0-e86ed3d47b0b4ef7fa03be5d6d6e29321c502de1 → 0.0.0-e88198f456e2dd4d5b628336ee913171c9f09eba

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 CHANGED
@@ -4,5 +4,5 @@ export type { SnappingMain, TagResults, SnapResults, SnapFromScopeResults, SnapD
4
4
  export default SnappingAspect;
5
5
  export { SnappingAspect };
6
6
  export { VersionMaker, BasicTagParams, VersionMakerParams, BasicTagSnapParams } from './version-maker';
7
- export { AUTO_TAGGED_MSG, NOTHING_TO_TAG_MSG, tagCmdOptions, TagParams, validateOptions, tagResultOutput, outputIdsIfExists, } from './tag-cmd';
7
+ export { AUTO_TAGGED_MSG, NOTHING_TO_TAG_MSG, tagCmdOptions, TagParams, validateOptions, tagResultOutput, compInBold, outputIdsIfExists, } from './tag-cmd';
8
8
  export { snapResultOutput } from './snap-cmd';
package/dist/index.js CHANGED
@@ -51,6 +51,12 @@ Object.defineProperty(exports, "VersionMakerParams", {
51
51
  return _versionMaker().VersionMakerParams;
52
52
  }
53
53
  });
54
+ Object.defineProperty(exports, "compInBold", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _tagCmd().compInBold;
58
+ }
59
+ });
54
60
  exports.default = void 0;
55
61
  Object.defineProperty(exports, "outputIdsIfExists", {
56
62
  enumerable: true,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_snapping","data","require","_versionMaker","_tagCmd","_snapCmd","_default","exports","default","SnappingAspect"],"sources":["index.ts"],"sourcesContent":["import { SnappingAspect } from './snapping.aspect';\n\nexport type { BitCloudUser } from './version-maker';\nexport type {\n SnappingMain,\n TagResults,\n SnapResults,\n SnapFromScopeResults,\n SnapDataParsed,\n SnapDataPerCompRaw,\n} from './snapping.main.runtime';\nexport default SnappingAspect;\nexport { SnappingAspect };\nexport { VersionMaker, BasicTagParams, VersionMakerParams, BasicTagSnapParams } from './version-maker';\nexport {\n AUTO_TAGGED_MSG,\n NOTHING_TO_TAG_MSG,\n tagCmdOptions,\n TagParams,\n validateOptions,\n tagResultOutput,\n outputIdsIfExists,\n} from './tag-cmd';\n\nexport { snapResultOutput } from './snap-cmd';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAaA,SAAAE,cAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAUA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAb/BC,0BAAc","ignoreList":[]}
1
+ {"version":3,"names":["_snapping","data","require","_versionMaker","_tagCmd","_snapCmd","_default","exports","default","SnappingAspect"],"sources":["index.ts"],"sourcesContent":["import { SnappingAspect } from './snapping.aspect';\n\nexport type { BitCloudUser } from './version-maker';\nexport type {\n SnappingMain,\n TagResults,\n SnapResults,\n SnapFromScopeResults,\n SnapDataParsed,\n SnapDataPerCompRaw,\n} from './snapping.main.runtime';\nexport default SnappingAspect;\nexport { SnappingAspect };\nexport { VersionMaker, BasicTagParams, VersionMakerParams, BasicTagSnapParams } from './version-maker';\nexport {\n AUTO_TAGGED_MSG,\n NOTHING_TO_TAG_MSG,\n tagCmdOptions,\n TagParams,\n validateOptions,\n tagResultOutput,\n compInBold,\n outputIdsIfExists,\n} from './tag-cmd';\n\nexport { snapResultOutput } from './snap-cmd';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAaA,SAAAE,cAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAWA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAd/BC,0BAAc","ignoreList":[]}
package/dist/reset-cmd.js CHANGED
@@ -25,6 +25,13 @@ function _yesno() {
25
25
  };
26
26
  return data;
27
27
  }
28
+ function _cli() {
29
+ const data = require("@teambit/cli");
30
+ _cli = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
28
35
  function _legacy() {
29
36
  const data = require("@teambit/legacy.constants");
30
37
  _legacy = function () {
@@ -64,7 +71,8 @@ useful for undoing mistakes before exporting. exported versions cannot be reset.
64
71
  }) {
65
72
  if (neverExported) {
66
73
  const compIds = await this.snapping.resetNeverExported();
67
- return _chalk().default.green(`successfully reset the following never-exported components:\n${compIds.join('\n')}`);
74
+ const items = compIds.map(id => (0, _cli().formatItem)(id.toString()));
75
+ return (0, _cli().joinSections)([(0, _cli().formatSection)('reset never-exported components', '', items), (0, _cli().formatSuccessSummary)(`successfully reset ${compIds.length} never-exported component(s)`)]);
68
76
  }
69
77
  if (soft && head) {
70
78
  throw new (_bitError().BitError)('please specify either --soft or --head flag, not both');
@@ -77,12 +85,10 @@ useful for undoing mistakes before exporting. exported versions cannot be reset.
77
85
  results,
78
86
  isSoftUntag
79
87
  } = await this.snapping.reset(pattern, head, force, soft);
80
- const titleSuffix = isSoftUntag ? 'soft-untagged (are not candidates for tagging any more)' : 'reset';
81
- const title = _chalk().default.green(`${results.length} component(s) were ${titleSuffix}:\n`);
82
- const components = results.map(result => {
83
- return `${_chalk().default.cyan(result.id.toStringWithoutVersion())}. version(s): ${result.versions.join(', ')}`;
84
- });
85
- return title + components.join('\n');
88
+ const titleSuffix = isSoftUntag ? 'soft-untagged' : 'reset';
89
+ const description = isSoftUntag ? 'soft-untagged versions are no longer candidates for tagging' : '';
90
+ const items = results.map(result => (0, _cli().formatItem)(`${_chalk().default.cyan(result.id.toStringWithoutVersion())} - version(s): ${result.versions.join(', ')}`));
91
+ return (0, _cli().joinSections)([(0, _cli().formatSection)(`${titleSuffix} components`, description, items), (0, _cli().formatSuccessSummary)(`${results.length} component(s) ${titleSuffix} successfully`)]);
86
92
  }
87
93
  async promptForResetAll() {
88
94
  this.snapping.logger.clearStatusLine();
@@ -1 +1 @@
1
- {"version":3,"names":["_bitError","data","require","_chalk","_interopRequireDefault","_yesno","_legacy","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ResetCmd","constructor","snapping","name","description","COMPONENT_PATTERN_HELP","report","pattern","all","head","force","soft","silent","neverExported","compIds","resetNeverExported","chalk","green","join","BitError","promptForResetAll","results","isSoftUntag","reset","titleSuffix","title","length","components","map","result","cyan","id","toStringWithoutVersion","versions","logger","clearStatusLine","ok","yesno","question","bold","exports"],"sources":["reset-cmd.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport chalk from 'chalk';\nimport yesno from 'yesno';\nimport type { Command, CommandOptions } from '@teambit/cli';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';\nimport type { SnappingMain } from './snapping.main.runtime';\n\nexport default class ResetCmd implements Command {\n name = 'reset [component-pattern]';\n description = 'revert local tags and snaps to previous versions';\n arguments = [\n {\n name: 'component-pattern',\n description: COMPONENT_PATTERN_HELP,\n },\n ];\n group = 'version-control';\n extendedDescription = `removes local component versions (tags/snaps) that haven't been exported yet.\nif no component-pattern is provided, resets all components (with confirmation prompt).\nby default reverts all local versions of each component. use --head to revert only the latest version.\nuseful for undoing mistakes before exporting. exported versions cannot be reset.`;\n alias = '';\n options = [\n ['a', 'all', 'DEPRECATED. this is now the default behavior when no component-pattern is provided'],\n ['', 'head', 'revert the head tag/snap only (by default, all local tags/snaps are reverted)'],\n ['', 'soft', 'revert only soft-tags (components tagged with --soft flag)'],\n [\n 'f',\n 'force',\n \"revert the tag even if it's used as a dependency. WARNING: components that depend on this tag will be corrupted\",\n ],\n ['', 'never-exported', 'reset only components that were never exported'],\n ['s', 'silent', 'skip confirmation when resetting all components'],\n ] as CommandOptions;\n loader = true;\n\n constructor(private snapping: SnappingMain) {}\n\n async report(\n [pattern]: [string],\n {\n all = false,\n head = false,\n force = false,\n soft = false,\n silent = false,\n neverExported = false,\n }: { all?: boolean; head?: boolean; force?: boolean; soft?: boolean; silent?: boolean; neverExported?: boolean }\n ) {\n if (neverExported) {\n const compIds = await this.snapping.resetNeverExported();\n return chalk.green(`successfully reset the following never-exported components:\\n${compIds.join('\\n')}`);\n }\n if (soft && head) {\n throw new BitError('please specify either --soft or --head flag, not both');\n }\n // if no pattern provided, reset all components (with confirmation unless --silent or --all)\n if (!pattern && !silent && !all) {\n await this.promptForResetAll();\n }\n const { results, isSoftUntag } = await this.snapping.reset(pattern, head, force, soft);\n const titleSuffix = isSoftUntag ? 'soft-untagged (are not candidates for tagging any more)' : 'reset';\n const title = chalk.green(`${results.length} component(s) were ${titleSuffix}:\\n`);\n const components = results.map((result) => {\n return `${chalk.cyan(result.id.toStringWithoutVersion())}. version(s): ${result.versions.join(', ')}`;\n });\n return title + components.join('\\n');\n }\n\n private async promptForResetAll() {\n this.snapping.logger.clearStatusLine();\n const ok = await yesno({\n question: `${chalk.bold('This will reset all local tags/snaps for all components. Would you like to proceed? [yes(y)/no(n)]')}`,\n });\n if (!ok) {\n throw new BitError('the operation has been canceled');\n }\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,OAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,MAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAmE,SAAAG,uBAAAG,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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IAAI,CAAC;EACtC;EAEA,MAAcE,iBAAiBA,CAAA,EAAG;IAChC,IAAI,CAAClB,QAAQ,CAACgC,MAAM,CAACC,eAAe,CAAC,CAAC;IACtC,MAAMC,EAAE,GAAG,MAAM,IAAAC,gBAAK,EAAC;MACrBC,QAAQ,EAAE,GAAGtB,gBAAK,CAACuB,IAAI,CAAC,oGAAoG,CAAC;IAC/H,CAAC,CAAC;IACF,IAAI,CAACH,EAAE,EAAE;MACP,MAAM,KAAIjB,oBAAQ,EAAC,iCAAiC,CAAC;IACvD;EACF;AACF;AAACqB,OAAA,CAAA3D,OAAA,GAAAmB,QAAA","ignoreList":[]}
1
+ {"version":3,"names":["_bitError","data","require","_chalk","_interopRequireDefault","_yesno","_cli","_legacy","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ResetCmd","constructor","snapping","name","description","COMPONENT_PATTERN_HELP","report","pattern","all","head","force","soft","silent","neverExported","compIds","resetNeverExported","items","map","id","formatItem","toString","joinSections","formatSection","formatSuccessSummary","length","BitError","promptForResetAll","results","isSoftUntag","reset","titleSuffix","result","chalk","cyan","toStringWithoutVersion","versions","join","logger","clearStatusLine","ok","yesno","question","bold","exports"],"sources":["reset-cmd.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport chalk from 'chalk';\nimport yesno from 'yesno';\nimport type { Command, CommandOptions } from '@teambit/cli';\nimport { formatSection, formatItem, formatSuccessSummary, joinSections } from '@teambit/cli';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';\nimport type { SnappingMain } from './snapping.main.runtime';\n\nexport default class ResetCmd implements Command {\n name = 'reset [component-pattern]';\n description = 'revert local tags and snaps to previous versions';\n arguments = [\n {\n name: 'component-pattern',\n description: COMPONENT_PATTERN_HELP,\n },\n ];\n group = 'version-control';\n extendedDescription = `removes local component versions (tags/snaps) that haven't been exported yet.\nif no component-pattern is provided, resets all components (with confirmation prompt).\nby default reverts all local versions of each component. use --head to revert only the latest version.\nuseful for undoing mistakes before exporting. exported versions cannot be reset.`;\n alias = '';\n options = [\n ['a', 'all', 'DEPRECATED. this is now the default behavior when no component-pattern is provided'],\n ['', 'head', 'revert the head tag/snap only (by default, all local tags/snaps are reverted)'],\n ['', 'soft', 'revert only soft-tags (components tagged with --soft flag)'],\n [\n 'f',\n 'force',\n \"revert the tag even if it's used as a dependency. WARNING: components that depend on this tag will be corrupted\",\n ],\n ['', 'never-exported', 'reset only components that were never exported'],\n ['s', 'silent', 'skip confirmation when resetting all components'],\n ] as CommandOptions;\n loader = true;\n\n constructor(private snapping: SnappingMain) {}\n\n async report(\n [pattern]: [string],\n {\n all = false,\n head = false,\n force = false,\n soft = false,\n silent = false,\n neverExported = false,\n }: { all?: boolean; head?: boolean; force?: boolean; soft?: boolean; silent?: boolean; neverExported?: boolean }\n ) {\n if (neverExported) {\n const compIds = await this.snapping.resetNeverExported();\n const items = compIds.map((id) => formatItem(id.toString()));\n return joinSections([\n formatSection('reset never-exported components', '', items),\n formatSuccessSummary(`successfully reset ${compIds.length} never-exported component(s)`),\n ]);\n }\n if (soft && head) {\n throw new BitError('please specify either --soft or --head flag, not both');\n }\n // if no pattern provided, reset all components (with confirmation unless --silent or --all)\n if (!pattern && !silent && !all) {\n await this.promptForResetAll();\n }\n const { results, isSoftUntag } = await this.snapping.reset(pattern, head, force, soft);\n const titleSuffix = isSoftUntag ? 'soft-untagged' : 'reset';\n const description = isSoftUntag ? 'soft-untagged versions are no longer candidates for tagging' : '';\n const items = results.map((result) =>\n formatItem(`${chalk.cyan(result.id.toStringWithoutVersion())} - version(s): ${result.versions.join(', ')}`)\n );\n return joinSections([\n formatSection(`${titleSuffix} components`, description, items),\n formatSuccessSummary(`${results.length} component(s) ${titleSuffix} successfully`),\n ]);\n }\n\n private async promptForResetAll() {\n this.snapping.logger.clearStatusLine();\n const ok = await yesno({\n question: `${chalk.bold('This will reset all local tags/sna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,CAClB,IAAAC,oBAAa,EAAC,GAAGQ,WAAW,aAAa,EAAE1B,WAAW,EAAEY,KAAK,CAAC,EAC9D,IAAAO,2BAAoB,EAAC,GAAGI,OAAO,CAACH,MAAM,iBAAiBM,WAAW,eAAe,CAAC,CACnF,CAAC;EACJ;EAEA,MAAcJ,iBAAiBA,CAAA,EAAG;IAChC,IAAI,CAACxB,QAAQ,CAACmC,MAAM,CAACC,eAAe,CAAC,CAAC;IACtC,MAAMC,EAAE,GAAG,MAAM,IAAAC,gBAAK,EAAC;MACrBC,QAAQ,EAAE,GAAGT,gBAAK,CAACU,IAAI,CAAC,oGAAoG,CAAC;IAC/H,CAAC,CAAC;IACF,IAAI,CAACH,EAAE,EAAE;MACP,MAAM,KAAId,oBAAQ,EAAC,iCAAiC,CAAC;IACvD;EACF;AACF;AAACkB,OAAA,CAAA9D,OAAA,GAAAmB,QAAA","ignoreList":[]}
@@ -12,6 +12,8 @@ export type ResetResult = {
12
12
  * we want .bitmap to have the version before the detachment. not as the head.
13
13
  */
14
14
  versionToSetInBitmap?: string;
15
+ /** batchIds from the version objects being removed, used to clean up lane history entries */
16
+ batchIds?: string[];
15
17
  };
16
18
  /**
17
19
  * If head is false, remove all local versions.
@@ -7,6 +7,13 @@ exports.getComponentsWithOptionToUntag = getComponentsWithOptionToUntag;
7
7
  exports.removeLocalVersion = removeLocalVersion;
8
8
  exports.removeLocalVersionsForAllComponents = removeLocalVersionsForAllComponents;
9
9
  exports.removeLocalVersionsForMultipleComponents = removeLocalVersionsForMultipleComponents;
10
+ function _lodash() {
11
+ const data = require("lodash");
12
+ _lodash = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
10
17
  function _bitError() {
11
18
  const data = require("@teambit/bit-error");
12
19
  _bitError = function () {
@@ -42,7 +49,14 @@ async function removeLocalVersion(consumer, id, lane, head, force = false) {
42
49
  const component = await consumer.scope.getModelComponent(id);
43
50
  const idStr = id.toString();
44
51
  const fromBitmap = consumer.bitMap.getComponentIdIfExist(id);
45
- const localVersions = await component.getLocalHashes(consumer.scope.objects, fromBitmap);
52
+ // populate lane-aware heads so `getLocalHashes` diverges against the LANE remote head, not
53
+ // the empty main one — otherwise a hidden cascade entry (no bitmap row, no main-side state)
54
+ // would treat the entire local history as "local" and wipe the seeded base on reset.
55
+ if (lane) await component.populateLocalAndRemoteHeads(consumer.scope.objects, lane);
56
+ // Pass `lane` so the lean-lane filter only keeps lane-origin snaps in localVersions. Without
57
+ // it, a merged-in main tag (e.g. 0.0.2) would be wiped from the component's versions map
58
+ // even though it still lives on the component's home scope — silent data loss for the user.
59
+ const localVersions = await component.getLocalHashes(consumer.scope.objects, fromBitmap, lane);
46
60
  if (!localVersions.length) throw new (_bitError().BitError)(`unable to untag ${idStr}, the component is not staged`);
47
61
  const headRef = component.getHeadRegardlessOfLane();
48
62
  if (!headRef) {
@@ -63,6 +77,16 @@ async function removeLocalVersion(consumer, id, lane, head, force = false) {
63
77
  }
64
78
  });
65
79
  }
80
+
81
+ // Load version objects to extract batchIds before they are removed.
82
+ // These batchIds are used to clean up the corresponding lane history entries.
83
+ // Only needed on lanes — on main there's no lane history to clean up.
84
+ let batchIds;
85
+ if (lane) {
86
+ const versionObjects = await Promise.all(versionsToRemoveStr.map(ver => component.loadVersion(ver, consumer.scope.objects, false)));
87
+ const loadedVersions = (0, _lodash().compact)(versionObjects);
88
+ batchIds = [...new Set((0, _lodash().compact)(loadedVersions.map(v => v.batchId)))];
89
+ }
66
90
  const headBefore = component.getHead();
67
91
  await consumer.scope.sources.removeComponentVersions(component, versionsToRemove, versionsToRemoveStr, lane, head);
68
92
  const headAfter = component.getHead();
@@ -77,7 +101,8 @@ async function removeLocalVersion(consumer, id, lane, head, force = false) {
77
101
  id,
78
102
  versions: versionsToRemoveStr,
79
103
  component,
80
- versionToSetInBitmap
104
+ versionToSetInBitmap,
105
+ batchIds
81
106
  };
82
107
  }
83
108
  async function removeLocalVersionsForAllComponents(workspace, remove, lane, head) {
@@ -116,6 +141,9 @@ async function removeLocalVersionsForMultipleComponents(consumer, componentsToUn
116
141
  async function getComponentsWithOptionToUntag(workspace, remove) {
117
142
  const componentList = new (_legacy().ComponentsList)(workspace);
118
143
  const laneObj = await workspace.getCurrentLaneObject();
144
+ // The result includes hidden updateDependents — `bit reset` reverts cascade snaps end-to-end.
145
+ // The bitmap-update step in `snapping.reset` skips hidden entries explicitly so we don't try
146
+ // to write workspace state for components that don't live in the workspace.
119
147
  const components = await componentList.listExportPendingComponents(laneObj);
120
148
  const removedStagedIds = await remove.getRemovedStaged();
121
149
  if (!removedStagedIds.length) return components;
@@ -1 +1 @@
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","workspace","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 type { ComponentID } from '@teambit/component-id';\nimport type { Consumer } from '@teambit/legacy.consumer';\nimport { ComponentsList } from '@teambit/legacy.component-list';\nimport { logger } from '@teambit/legacy.logger';\nimport type { Lane, ModelComponent } from '@teambit/objects';\nimport type { RemoveMain } from '@teambit/remove';\nimport { DependencyGraph } from '@teambit/legacy.dependency-graph';\nimport type { Workspace } from '@teambit/workspace';\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 workspace: Workspace,\n remove: RemoveMain,\n lane?: Lane,\n head?: boolean\n): Promise<ResetResult[]> {\n const componentsToUntag = await getComponentsWithOptionToUntag(workspace, 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(workspace.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 workspace: Workspace,\n remove: RemoveMain\n): Promise<ModelComponent[]> {\n const componentList = new ComponentsList(workspace);\n const laneObj = await workspace.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) => workspace.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;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,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAcA;AACA;AACA;AACO,eAAeK,kBAAkBA,CACtCC,QAAkB,EAClBC,EAAe,EACfC,IAAW,EACXC,IAAc,EACdC,KAAK,GAAG,KAAK,EACS;EACtB,MAAMC,SAAyB,GAAG,MAAML,QAAQ,CAACM,KAAK,CAACC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,CAACM,KAAK,CAACC,iBAAiB,CAACN,EAAE,CAAC,CAAC,CAAC;EACnHwE,UAAU,CAACS,IAAI,CAAC,GAAGD,UAAU,CAAC;EAE9B,OAAOR,UAAU;AACnB","ignoreList":[]}
1
+ {"version":3,"names":["_lodash","data","require","_bitError","_legacy","_legacy2","_legacy3","removeLocalVersion","consumer","id","lane","head","force","component","scope","getModelComponent","idStr","toString","fromBitmap","bitMap","getComponentIdIfExist","populateLocalAndRemoteHeads","objects","localVersions","getLocalHashes","length","BitError","headRef","getHeadRegardlessOfLane","Error","find","v","isEqual","versionsToRemove","versionsToRemoveStr","switchHashesWithTagsIfExist","dependencyGraph","DependencyGraph","loadAllVersions","forEach","versionToRemove","idWithVersion","toComponentId","changeVersion","dependents","getImmediateDependentsPerId","join","batchIds","versionObjects","Promise","all","map","ver","loadVersion","loadedVersions","compact","Set","batchId","headBefore","getHead","sources","removeComponentVersions","headAfter","versionToSetInBitmap","divergeData","getDivergeData","snapBeforeDetached","commonSnapBeforeDiverge","getTagOfRefIfExists","versions","removeLocalVersionsForAllComponents","workspace","remove","componentsToUntag","getComponentsWithOptionToUntag","removeLocalVersionsForMultipleComponents","candidateComponentsIds","bitId","candidateComponentsIdsStr","dependentsNotCandidates","filter","dependent","includes","version","logger","debug","componentList","ComponentsList","laneObj","getCurrentLaneObject","components","listExportPendingComponents","removedStagedIds","getRemovedStaged","removedStagedBitIds","nonExistsInStaged","c","isEqualWithoutVersion","modelComps","push"],"sources":["reset-component.ts"],"sourcesContent":["import { compact } from 'lodash';\nimport { BitError } from '@teambit/bit-error';\nimport type { ComponentID } from '@teambit/component-id';\nimport type { Consumer } from '@teambit/legacy.consumer';\nimport { ComponentsList } from '@teambit/legacy.component-list';\nimport { logger } from '@teambit/legacy.logger';\nimport type { Lane, ModelComponent } from '@teambit/objects';\nimport type { RemoveMain } from '@teambit/remove';\nimport { DependencyGraph } from '@teambit/legacy.dependency-graph';\nimport type { Workspace } from '@teambit/workspace';\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 /** batchIds from the version objects being removed, used to clean up lane history entries */\n batchIds?: 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 // populate lane-aware heads so `getLocalHashes` diverges against the LANE remote head, not\n // the empty main one — otherwise a hidden cascade entry (no bitmap row, no main-side state)\n // would treat the entire local history as \"local\" and wipe the seeded base on reset.\n if (lane) await component.populateLocalAndRemoteHeads(consumer.scope.objects, lane);\n // Pass `lane` so the lean-lane filter only keeps lane-origin snaps in localVersions. Without\n // it, a merged-in main tag (e.g. 0.0.2) would be wiped from the component's versions map\n // even though it still lives on the component's home scope — silent data loss for the user.\n const localVersions = await component.getLocalHashes(consumer.scope.objects, fromBitmap, lane);\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 // Load version objects to extract batchIds before they are removed.\n // These batchIds are used to clean up the corresponding lane history entries.\n // Only needed on lanes — on main there's no lane history to clean up.\n let batchIds: string[] | undefined;\n if (lane) {\n const versionObjects = await Promise.all(\n versionsToRemoveStr.map((ver) => component.loadVersion(ver, consumer.scope.objects, false))\n );\n const loadedVersions = compact(versionObjects);\n batchIds = [...new Set(compact(loadedVersions.map((v) => v.batchId)))];\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, batchIds };\n}\n\nexport async function removeLocalVersionsForAllComponents(\n workspace: Workspace,\n remove: RemoveMain,\n lane?: Lane,\n head?: boolean\n): Promise<ResetResult[]> {\n const componentsToUntag = await getComponentsWithOptionToUntag(workspace, 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(workspace.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 workspace: Workspace,\n remove: RemoveMain\n): Promise<ModelComponent[]> {\n const componentList = new ComponentsList(workspace);\n const laneObj = await workspace.getCurrentLaneObject();\n // The result includes hidden updateDependents — `bit reset` reverts cascade snaps end-to-end.\n // The bitmap-update step in `snapping.reset` skips hidden entries explicitly so we don't try\n // to write workspace state for components that don't live in the workspace.\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) => workspace.consumer.scope.getModelComponent(id)));\n components.push(...modelComps);\n\n return components;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAA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AiB,CAACtE,MAAM,EAAE,OAAOiE,UAAU;EAChD,MAAMQ,UAAU,GAAG,MAAMjD,OAAO,CAACC,GAAG,CAAC6C,iBAAiB,CAAC5C,GAAG,CAAE1C,EAAE,IAAK8D,SAAS,CAAC/D,QAAQ,CAACM,KAAK,CAACC,iBAAiB,CAACN,EAAE,CAAC,CAAC,CAAC;EACnHiF,UAAU,CAACS,IAAI,CAAC,GAAGD,UAAU,CAAC;EAE9B,OAAOR,UAAU;AACnB","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { Command, CommandOptions } from '@teambit/cli';
1
+ import type { Command, CommandOptions, Report } from '@teambit/cli';
2
2
  import type { Logger } from '@teambit/logger';
3
3
  import type { SnappingMain, SnapResults } from './snapping.main.runtime';
4
4
  import type { BasicTagSnapParams } from './version-maker';
@@ -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, configStore: ConfigStoreMain);
23
- report([pattern]: string[], { message, unmerged, editor, ignoreIssues, build, skipTests, skipTasks, skipAutoSnap, disableSnapPipeline, ignoreBuildErrors, rebuildDepsGraph, unmodified, failFast, detachHead, loose, }: {
23
+ report([pattern]: string[], { message, unmerged, editor, ignoreIssues, build, skipTests, skipTasks, skipAutoSnap, disableSnapPipeline, ignoreBuildErrors, rebuildDepsGraph, noLockDeps, unmodified, failFast, detachHead, loose, }: {
24
24
  unmerged?: boolean;
25
25
  editor?: string;
26
26
  ignoreIssues?: string;
@@ -28,6 +28,8 @@ export declare class SnapCmd implements Command {
28
28
  disableSnapPipeline?: boolean;
29
29
  unmodified?: boolean;
30
30
  failFast?: boolean;
31
- } & BasicTagSnapParams): Promise<string>;
31
+ } & BasicTagSnapParams): Promise<string | Report>;
32
32
  }
33
+ export declare function snapResultReport(results: SnapResults): string | Report;
34
+ /** @deprecated use snapResultReport instead */
33
35
  export declare function snapResultOutput(results: SnapResults): string;
package/dist/snap-cmd.js CHANGED
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.SnapCmd = void 0;
7
7
  exports.snapResultOutput = snapResultOutput;
8
+ exports.snapResultReport = snapResultReport;
8
9
  function _chalk() {
9
10
  const data = _interopRequireDefault(require("chalk"));
10
11
  _chalk = function () {
@@ -12,6 +13,13 @@ function _chalk() {
12
13
  };
13
14
  return data;
14
15
  }
16
+ function _lodash() {
17
+ const data = require("lodash");
18
+ _lodash = function () {
19
+ return data;
20
+ };
21
+ return data;
22
+ }
15
23
  function _componentIssues() {
16
24
  const data = require("@teambit/component-issues");
17
25
  _componentIssues = function () {
@@ -19,6 +27,13 @@ function _componentIssues() {
19
27
  };
20
28
  return data;
21
29
  }
30
+ function _cli() {
31
+ const data = require("@teambit/cli");
32
+ _cli = function () {
33
+ return data;
34
+ };
35
+ return data;
36
+ }
22
37
  function _legacy() {
23
38
  const data = require("@teambit/legacy.constants");
24
39
  _legacy = function () {
@@ -55,7 +70,7 @@ snapshots maintain component history and enable collaboration without formal rel
55
70
  _defineProperty(this, "helpUrl", 'reference/components/snaps');
56
71
  _defineProperty(this, "alias", '');
57
72
  _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.
58
- 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'], ['', 'loose', 'allow snap --build to succeed even if tasks like tests or lint fail'], ['', '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:
73
+ 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'], ['', 'loose', 'allow snap --build to succeed even if tasks like tests or lint fail'], ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'], ['', 'no-lock-deps', 'do not save the dependencies graph in the snap'], ['i', 'ignore-issues <issues>', `ignore component issues (shown in "bit status" as "issues found"), issues to ignore:
59
74
  [${Object.keys(_componentIssues().IssuesClasses).join(', ')}]
60
75
  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']]);
61
76
  _defineProperty(this, "loader", true);
@@ -72,6 +87,7 @@ to ignore multiple issues, separate them by a comma and wrap with quotes. to ign
72
87
  disableSnapPipeline = false,
73
88
  ignoreBuildErrors = false,
74
89
  rebuildDepsGraph,
90
+ noLockDeps = false,
75
91
  unmodified = false,
76
92
  failFast = false,
77
93
  detachHead,
@@ -95,17 +111,18 @@ to ignore multiple issues, separate them by a comma and wrap with quotes. to ign
95
111
  disableTagAndSnapPipelines,
96
112
  ignoreBuildErrors,
97
113
  rebuildDepsGraph,
114
+ noLockDeps,
98
115
  unmodified,
99
116
  exitOnFirstFailedTask: failFast,
100
117
  detachHead,
101
118
  loose
102
119
  });
103
120
  if (!results) return _chalk().default.yellow(_legacy().NOTHING_TO_SNAP_MSG);
104
- return snapResultOutput(results);
121
+ return snapResultReport(results);
105
122
  }
106
123
  }
107
124
  exports.SnapCmd = SnapCmd;
108
- function snapResultOutput(results) {
125
+ function snapResultReport(results) {
109
126
  const {
110
127
  snappedComponents,
111
128
  autoSnappedResults,
@@ -119,33 +136,77 @@ function snapResultOutput(results) {
119
136
  return !newComponents.searchWithoutVersion(component.id) && !removedComponents?.searchWithoutVersion(component.id);
120
137
  });
121
138
  const addedComponents = snappedComponents.filter(component => newComponents.searchWithoutVersion(component.id));
122
- const autoTaggedCount = autoSnappedResults ? autoSnappedResults.length : 0;
123
- const totalCount = totalComponentsCount ?? snappedComponents.length + autoTaggedCount;
124
- const warningsOutput = warnings && warnings.length ? `${_chalk().default.yellow(warnings.join('\n'))}\n\n` : '';
125
- const snapExplanation = `\n(use "bit export" to push these components to a remote")
126
- (use "bit reset" to unstage all local versions, or "bit reset --head" to only unstage the latest local snap)`;
127
- const compInBold = id => {
128
- const version = id.hasVersion() ? `@${id.version}` : '';
129
- return `${_chalk().default.bold(id.toStringWithoutVersion())}${version}`;
139
+ const autoSnappedCount = autoSnappedResults ? autoSnappedResults.length : 0;
140
+ const totalCount = totalComponentsCount ?? snappedComponents.length + autoSnappedCount;
141
+ const formatCompMinimal = component => {
142
+ return (0, _cli().formatItem)((0, _tagCmd().compInBold)(component.id));
130
143
  };
131
- const outputComponents = comps => {
132
- return comps.map(component => {
133
- let componentOutput = ` > ${compInBold(component.id)}`;
134
- const autoTag = autoSnappedResults.filter(result => result.triggeredBy.searchWithoutVersion(component.id));
135
- if (autoTag.length) {
136
- const autoTagComp = autoTag.map(a => compInBold(a.component.id));
137
- componentOutput += `\n ${_legacy().AUTO_SNAPPED_MSG} (${autoTagComp.length} total):
138
- ${autoTagComp.join('\n ')}`;
139
- }
140
- return componentOutput;
141
- }).join('\n');
144
+ const formatCompDetailed = component => {
145
+ let output = (0, _cli().formatItem)((0, _tagCmd().compInBold)(component.id));
146
+ const autoSnap = (autoSnappedResults ?? []).filter(result => result.triggeredBy.searchWithoutVersion(component.id));
147
+ if (autoSnap.length) {
148
+ const autoSnapComp = autoSnap.map(a => a.component.id.toString());
149
+ output += `\n ${_legacy().AUTO_SNAPPED_MSG} (${autoSnapComp.length} total):\n ${autoSnapComp.join('\n ')}`;
150
+ }
151
+ return output;
142
152
  };
143
- const outputIfExists = (label, explanation, components) => {
144
- if (!components.length) return '';
145
- return `\n${_chalk().default.underline(label)}\n(${explanation})\n${outputComponents(components)}\n`;
153
+ const hasAutoSnapped = autoSnappedCount > 0;
154
+ const buildSections = formatComp => {
155
+ const newSection = (0, _cli().formatSection)('new components', 'first version for components', addedComponents.map(formatComp));
156
+ const changedSection = (0, _cli().formatSection)('changed components', 'components that got a version bump', changedComponents.map(formatComp));
157
+ return {
158
+ newSection,
159
+ changedSection
160
+ };
146
161
  };
162
+ const removedSection = (0, _tagCmd().outputIdsIfExists)('removed components', removedComponents);
163
+ const warningsSection = warnings && warnings.length ? warnings.map(w => `${_cli().warnSymbol} ${_chalk().default.yellow(w)}`).join('\n') : '';
147
164
  const laneStr = laneName ? ` on "${laneName}" lane` : '';
148
- return outputIfExists('new components', 'first version for components', addedComponents) + outputIfExists('changed components', 'components that got a version bump', changedComponents) + (0, _tagCmd().outputIdsIfExists)('removed components', removedComponents) + warningsOutput + _chalk().default.green(`\n${totalCount} component(s) snapped${laneStr}`) + snapExplanation;
165
+ const summary = (0, _cli().formatSuccessSummary)(`${totalCount} component(s) snapped${laneStr}`);
166
+ const snapExplanation = (0, _cli().formatHint)('(use "bit export" to push these components to a remote)\n(use "bit reset" to unstage all local versions, or "bit reset --head" to only unstage the latest local snap)');
167
+
168
+ // Build minimal output (no auto-snapped listing, just counts grouped by scope)
169
+ const {
170
+ newSection,
171
+ changedSection
172
+ } = buildSections(hasAutoSnapped ? formatCompMinimal : formatCompDetailed);
173
+ const autoSnapSection = (() => {
174
+ if (!hasAutoSnapped) return '';
175
+ const scopeCounts = (0, _lodash().countBy)(autoSnappedResults, r => r.component.id.scope);
176
+ const sorted = Object.entries(scopeCounts).sort(([, a], [, b]) => b - a);
177
+ const MAX_SHOWN = 4;
178
+ const shown = sorted.slice(0, MAX_SHOWN).map(([scope, n]) => `${scope} (${n})`);
179
+ const remaining = sorted.length - MAX_SHOWN;
180
+ const scopeLine = remaining > 0 ? [...shown, `+ ${remaining} more scopes`].join(' · ') : shown.join(' · ');
181
+ const title = (0, _cli().formatTitle)(`auto-snapped dependents (${autoSnappedCount})`);
182
+ const scopes = ` ${scopeLine}`;
183
+ const hint = (0, _cli().formatDetailsHint)('full list of auto-snapped dependents');
184
+ return `${title}\n${scopes}\n${hint}`;
185
+ })();
186
+ const footerParts = [summary, snapExplanation].filter(Boolean).join('\n');
187
+ const data = (0, _cli().joinSections)([newSection, changedSection, autoSnapSection, removedSection, warningsSection, footerParts]);
188
+ if (!hasAutoSnapped) {
189
+ return data;
190
+ }
191
+
192
+ // Build detailed output (with full auto-snapped listing)
193
+ const {
194
+ newSection: newDetailed,
195
+ changedSection: changedDetailed
196
+ } = buildSections(formatCompDetailed);
197
+ const detailedFooter = [summary, snapExplanation].filter(Boolean).join('\n');
198
+ const details = (0, _cli().joinSections)([newDetailed, changedDetailed, removedSection, warningsSection, detailedFooter]);
199
+ return {
200
+ data,
201
+ code: 0,
202
+ details
203
+ };
204
+ }
205
+
206
+ /** @deprecated use snapResultReport instead */
207
+ function snapResultOutput(results) {
208
+ const result = snapResultReport(results);
209
+ return typeof result === 'string' ? result : result.details || result.data;
149
210
  }
150
211
 
151
212
  //# sourceMappingURL=snap-cmd.js.map
@@ -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","configStore","name","description","COMPONENT_PATTERN_HELP","keys","IssuesClasses","join","report","pattern","message","unmerged","editor","ignoreIssues","build","skipTests","skipTasks","skipAutoSnap","disableSnapPipeline","ignoreBuildErrors","rebuildDepsGraph","unmodified","failFast","detachHead","loose","getConfigBoolean","CFG_FORCE_LOCAL_BUILD","Boolean","disableTagAndSnapPipelines","consoleWarning","results","snap","exitOnFirstFailedTask","chalk","yellow","NOTHING_TO_SNAP_MSG","snapResultOutput","exports","snappedComponents","autoSnappedResults","warnings","newComponents","laneName","removedComponents","totalComponentsCount","changedComponents","filter","component","searchWithoutVersion","id","addedComponents","autoTaggedCount","length","totalCount","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"],"sources":["snap-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { ComponentID } from '@teambit/component-id';\nimport type { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport type { 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 type { Logger } from '@teambit/logger';\nimport type { SnappingMain, SnapResults } from './snapping.main.runtime';\nimport { outputIdsIfExists } from './tag-cmd';\nimport type { BasicTagSnapParams } from './version-maker';\nimport type { ConfigStoreMain } from '@teambit/config-store';\n\nexport class SnapCmd implements Command {\n name = 'snap [component-pattern]';\n description = 'create immutable component snapshots for development versions';\n extendedDescription = `creates snapshots with hash-based versions for development and testing. snapshots are immutable and exportable.\nby default snaps only new and modified components. use for development iterations before creating semantic version tags.\nsnapshots maintain component history and enable collaboration without formal releases.`;\n group = 'version-control';\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 ['', 'loose', 'allow snap --build to succeed even if tasks like tests or lint fail'],\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 configStore: ConfigStoreMain\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 loose = 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 = this.configStore.getConfigBoolean(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 loose,\n });\n\n if (!results) return chalk.yellow(NOTHING_TO_SNAP_MSG);\n return snapResultOutput(results);\n }\n}\n\nexport function snapResultOutput(results: SnapResults): string {\n const {\n snappedComponents,\n autoSnappedResults,\n warnings,\n newComponents,\n laneName,\n removedComponents,\n totalComponentsCount,\n }: SnapResults = results;\n const changedComponents = snappedComponents.filter((component) => {\n return !newComponents.searchWithoutVersion(component.id) && !removedComponents?.searchWithoutVersion(component.id);\n });\n const addedComponents = snappedComponents.filter((component) => newComponents.searchWithoutVersion(component.id));\n const autoTaggedCount = autoSnappedResults ? autoSnappedResults.length : 0;\n const totalCount = totalComponentsCount ?? snappedComponents.length + autoTaggedCount;\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\" 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${totalCount} component(s) snapped${laneStr}`) +\n snapExplanation\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;AAEA,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,IA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KF,WAAW,CAAChB,MAAM;AAChF,YAAYgB,WAAW,CAAC7D,IAAI,CAAC,gBAAgB,CAAC,EAAE;MACxC;MACA,OAAOyD,eAAe;IACxB,CAAC,CAAC,CACDzD,IAAI,CAAC,IAAI,CAAC;EACf,CAAC;EAED,MAAMgE,cAAc,GAAGA,CAACC,KAAK,EAAEC,WAAW,EAAEC,UAAU,KAAK;IACzD,IAAI,CAACA,UAAU,CAACtB,MAAM,EAAE,OAAO,EAAE;IACjC,OAAO,KAAKnB,gBAAK,CAAC0C,SAAS,CAACH,KAAK,CAAC,MAAMC,WAAW,MAAMZ,gBAAgB,CAACa,UAAU,CAAC,IAAI;EAC3F,CAAC;EACD,MAAME,OAAO,GAAGlC,QAAQ,GAAG,QAAQA,QAAQ,QAAQ,GAAG,EAAE;EAExD,OACE6B,cAAc,CAAC,gBAAgB,EAAE,8BAA8B,EAAErB,eAAe,CAAC,GACjFqB,cAAc,CAAC,oBAAoB,EAAE,oCAAoC,EAAE1B,iBAAiB,CAAC,GAC7F,IAAAgC,2BAAiB,EAAC,oBAAoB,EAAElC,iBAAiB,CAAC,GAC1DW,cAAc,GACdrB,gBAAK,CAAC6C,KAAK,CAAC,KAAKzB,UAAU,wBAAwBuB,OAAO,EAAE,CAAC,GAC7DrB,eAAe;AAEnB","ignoreList":[]}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_lodash","_componentIssues","_cli","_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","configStore","name","description","COMPONENT_PATTERN_HELP","keys","IssuesClasses","join","report","pattern","message","unmerged","editor","ignoreIssues","build","skipTests","skipTasks","skipAutoSnap","disableSnapPipeline","ignoreBuildErrors","rebuildDepsGraph","noLockDeps","unmodified","failFast","detachHead","loose","getConfigBoolean","CFG_FORCE_LOCAL_BUILD","Boolean","disableTagAndSnapPipelines","consoleWarning","results","snap","exitOnFirstFailedTask","chalk","yellow","NOTHING_TO_SNAP_MSG","snapResultReport","exports","snappedComponents","autoSnappedResults","warnings","newComponents","laneName","removedComponents","totalComponentsCount","changedComponents","filter","component","searchWithoutVersion","id","addedComponents","autoSnappedCount","length","totalCount","formatCompMinimal","formatItem","compInBold","formatCompDetailed","output","autoSnap","result","triggeredBy","autoSnapComp","map","a","toString","AUTO_SNAPPED_MSG","hasAutoSnapped","buildSections","formatComp","newSection","formatSection","changedSection","removedSection","outputIdsIfExists","warningsSection","w","warnSymbol","laneStr","summary","formatSuccessSummary","snapExplanation","formatHint","autoSnapSection","scopeCounts","countBy","scope","sorted","entries","sort","b","MAX_SHOWN","shown","slice","n","remaining","scopeLine","title","formatTitle","scopes","hint","formatDetailsHint","footerParts","joinSections","newDetailed","changedDetailed","detailedFooter","details","code","snapResultOutput"],"sources":["snap-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { countBy } from 'lodash';\nimport type { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport type { Command, CommandOptions, Report } from '@teambit/cli';\nimport {\n formatItem,\n formatSection,\n formatTitle,\n formatHint,\n formatDetailsHint,\n formatSuccessSummary,\n warnSymbol,\n joinSections,\n} 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 type { Logger } from '@teambit/logger';\nimport type { SnappingMain, SnapResults } from './snapping.main.runtime';\nimport { outputIdsIfExists, compInBold } from './tag-cmd';\nimport type { BasicTagSnapParams } from './version-maker';\nimport type { ConfigStoreMain } from '@teambit/config-store';\n\nexport class SnapCmd implements Command {\n name = 'snap [component-pattern]';\n description = 'create immutable component snapshots for development versions';\n extendedDescription = `creates snapshots with hash-based versions for development and testing. snapshots are immutable and exportable.\nby default snaps only new and modified components. use for development iterations before creating semantic version tags.\nsnapshots maintain component history and enable collaboration without formal releases.`;\n group = 'version-control';\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 ['', 'loose', 'allow snap --build to succeed even if tasks like tests or lint fail'],\n ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'],\n ['', 'no-lock-deps', 'do not save the dependencies graph in the snap'],\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 configStore: ConfigStoreMain\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 noLockDeps = false,\n unmodified = false,\n failFast = false,\n detachHead,\n loose = 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 = this.configStore.getConfigBoolean(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 noLockDeps,\n unmodified,\n exitOnFirstFailedTask: failFast,\n detachHead,\n loose,\n });\n\n if (!results) return chalk.yellow(NOTHING_TO_SNAP_MSG);\n return snapResultReport(results);\n }\n}\n\nexport function snapResultReport(results: SnapResults): string | Report {\n const {\n snappedComponents,\n autoSnappedResults,\n warnings,\n newComponents,\n laneName,\n removedComponents,\n totalComponentsCount,\n }: SnapResults = results;\n const changedComponents = snappedComponents.filter((component) => {\n return !newComponents.searchWithoutVersion(component.id) && !removedComponents?.searchWithoutVersion(component.id);\n });\n const addedComponents = snappedComponents.filter((component) => newComponents.searchWithoutVersion(component.id));\n const autoSnappedCount = autoSnappedResults ? autoSnappedResults.length : 0;\n const totalCount = totalComponentsCount ?? snappedComponents.length + autoSnappedCount;\n\n const formatCompMinimal = (component: ConsumerComponent): string => {\n return formatItem(compInBold(component.id));\n };\n\n const formatCompDetailed = (component: ConsumerComponent): string => {\n let output = formatItem(compInBold(component.id));\n const autoSnap = (autoSnappedResults ?? []).filter((result) =>\n result.triggeredBy.searchWithoutVersion(component.id)\n );\n if (autoSnap.length) {\n const autoSnapComp = autoSnap.map((a) => a.component.id.toString());\n output += `\\n ${AUTO_SNAPPED_MSG} (${autoSnapComp.length} total):\\n ${autoSnapComp.join('\\n ')}`;\n }\n return output;\n };\n\n const hasAutoSnapped = autoSnappedCount > 0;\n\n const buildSections = (formatComp: (c: ConsumerComponent) => string) => {\n const newSection = formatSection('new components', 'first version for components', addedComponents.map(formatComp));\n const changedSection = formatSection(\n 'changed components',\n 'components that got a version bump',\n changedComponents.map(formatComp)\n );\n return { newSection, changedSection };\n };\n\n const removedSection = outputIdsIfExists('removed components', removedComponents);\n\n const warningsSection =\n warnings && warnings.length ? warnings.map((w) => `${warnSymbol} ${chalk.yellow(w)}`).join('\\n') : '';\n\n const laneStr = laneName ? ` on \"${laneName}\" lane` : '';\n const summary = formatSuccessSummary(`${totalCount} component(s) snapped${laneStr}`);\n const snapExplanation = formatHint(\n '(use \"bit export\" to push these components to a remote)\\n(use \"bit reset\" to unstage all local versions, or \"bit reset --head\" to only unstage the latest local snap)'\n );\n\n // Build minimal output (no auto-snapped listing, just counts grouped by scope)\n const { newSection, changedSection } = buildSections(hasAutoSnapped ? formatCompMinimal : formatCompDetailed);\n\n const autoSnapSection = (() => {\n if (!hasAutoSnapped) return '';\n const scopeCounts = countBy(autoSnappedResults, (r) => r.component.id.scope);\n const sorted = Object.entries(scopeCounts).sort(([, a], [, b]) => b - a);\n const MAX_SHOWN = 4;\n const shown = sorted.slice(0, MAX_SHOWN).map(([scope, n]) => `${scope} (${n})`);\n const remaining = sorted.length - MAX_SHOWN;\n const scopeLine = remaining > 0 ? [...shown, `+ ${remaining} more scopes`].join(' · ') : shown.join(' · ');\n const title = formatTitle(`auto-snapped dependents (${autoSnappedCount})`);\n const scopes = ` ${scopeLine}`;\n const hint = formatDetailsHint('full list of auto-snapped dependents');\n return `${title}\\n${scopes}\\n${hint}`;\n })();\n\n const footerParts = [summary, snapExplanation].filter(Boolean).join('\\n');\n const data = joinSections([\n newSection,\n changedSection,\n autoSnapSection,\n removedSection,\n warningsSection,\n footerParts,\n ]);\n\n if (!hasAutoSnapped) {\n return data;\n }\n\n // Build detailed output (with full auto-snapped listing)\n const { newSection: newDetailed, changedSection: changedDetailed } = buildSections(formatCompDetailed);\n const detailedFooter = [summary, snapExplanation].filter(Boolean).join('\\n');\n const details = joinSections([newDetailed, changedDetailed, removedSection, warningsSection, detailedFooter]);\n\n return { data, code: 0, details };\n}\n\n/** @deprecated use snapResultReport instead */\nexport function snapResultOutput(results: SnapResults): string {\n const result = snapResultReport(results);\n return typeof result === 'string' ? result : result.details || result.data;\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;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,iBAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,gBAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,KAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,IAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAUA,SAAAM,QAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,OAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAQA,SAAAO,QA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