@teambit/snapping 1.0.447 → 1.0.448

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.
@@ -23,6 +23,7 @@ export type SnapDataPerCompRaw = {
23
23
  }>;
24
24
  removeDependencies?: string[];
25
25
  forkFrom?: string;
26
+ version?: string;
26
27
  };
27
28
  type SnapFromScopeOptions = {
28
29
  push?: boolean;
@@ -30,6 +31,7 @@ type SnapFromScopeOptions = {
30
31
  ignoreIssues?: string;
31
32
  disableSnapPipeline?: boolean;
32
33
  updateDependents?: boolean;
34
+ tag?: boolean;
33
35
  } & BasicTagSnapParams;
34
36
  export declare class SnapFromScopeCmd implements Command {
35
37
  private snapping;
@@ -43,7 +45,7 @@ export declare class SnapFromScopeCmd implements Command {
43
45
  private: boolean;
44
46
  constructor(snapping: SnappingMain, logger: Logger);
45
47
  report([data]: [string], options: SnapFromScopeOptions): Promise<string>;
46
- json([data]: [string], { push, message, lane, ignoreIssues, build, skipTests, disableSnapPipeline, ignoreBuildErrors, rebuildDepsGraph, updateDependents, }: SnapFromScopeOptions): Promise<{
48
+ json([data]: [string], { push, message, lane, ignoreIssues, build, skipTests, disableSnapPipeline, ignoreBuildErrors, rebuildDepsGraph, updateDependents, tag, }: SnapFromScopeOptions): Promise<{
47
49
  exportedIds: string[] | undefined;
48
50
  snappedIds: string[];
49
51
  }>;
@@ -53,13 +53,14 @@ the input data is a stringified JSON of an array of the following object.
53
53
  }>;
54
54
  removeDependencies?: string[]; // component-id (for components) or package-name (for packages) to remove from the dependencies.
55
55
  forkFrom?: string; // origin id to fork from. the componentId is the new id. (no need to populate isNew prop).
56
+ version?: string; // relevant when passing "--tag". optionally, specify the semver to tag. default to "patch".
56
57
  }
57
58
  an example of the final data: '[{"componentId":"ci.remote2/comp-b","message": "first snap"}]'
58
59
  `);
59
60
  _defineProperty(this, "alias", '');
60
61
  _defineProperty(this, "options", [['', 'push', 'export the updated objects to the original scopes once done'], ['m', 'message <message>', 'log message describing the latest changes'], ['', 'lane <lane-id>', 'fetch the components from the given lane'], ['', 'build', 'run the build pipeline'], ['', 'skip-tests', 'skip running component tests during snap process'], ['', 'disable-snap-pipeline', 'skip the snap pipeline'], ['', 'ignore-build-errors', 'run the snap pipeline although the build pipeline failed'], ['', '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:
61
62
  [${Object.keys(_componentIssues().IssuesClasses).join(', ')}]
62
- to ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify "*".`], ['', 'update-dependents', 'when snapped on a lane, mark it as update-dependents so it will be skipped from the workspace'], ['j', 'json', 'output as json format']]);
63
+ to ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify "*".`], ['', 'update-dependents', 'when snapped on a lane, mark it as update-dependents so it will be skipped from the workspace'], ['', 'tag', 'make a tag instead of a snap'], ['', 'stream', 'relevant for --json only. stream loader as json strings'], ['j', 'json', 'output as json format']]);
63
64
  _defineProperty(this, "loader", true);
64
65
  _defineProperty(this, "private", true);
65
66
  }
@@ -83,7 +84,8 @@ to ignore multiple issues, separate them by a comma and wrap with quotes. to ign
83
84
  disableSnapPipeline = false,
84
85
  ignoreBuildErrors = false,
85
86
  rebuildDepsGraph,
86
- updateDependents
87
+ updateDependents,
88
+ tag
87
89
  }) {
88
90
  const disableTagAndSnapPipelines = disableSnapPipeline;
89
91
  if (disableTagAndSnapPipelines && ignoreBuildErrors) {
@@ -103,7 +105,8 @@ to ignore multiple issues, separate them by a comma and wrap with quotes. to ign
103
105
  disableTagAndSnapPipelines,
104
106
  ignoreBuildErrors,
105
107
  rebuildDepsGraph,
106
- updateDependents
108
+ updateDependents,
109
+ tag
107
110
  });
108
111
  return {
109
112
  exportedIds: results.exportedIds?.map(id => id.toString()),
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_componentIssues","_bitError","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SnapFromScopeCmd","constructor","snapping","logger","keys","IssuesClasses","join","report","options","results","json","snappedIds","exportedIds","snappedOutput","chalk","bold","exportedOutput","length","push","message","lane","ignoreIssues","build","skipTests","disableSnapPipeline","ignoreBuildErrors","rebuildDepsGraph","updateDependents","disableTagAndSnapPipelines","BitError","snapDataPerCompRaw","parseData","snapFromScope","map","id","toString","dataParsed","JSON","parse","err","Error","Array","isArray","forEach","dataItem","componentId","files","file","path","content","Buffer","from","exports"],"sources":["snap-from-scope.cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { BitError } from '@teambit/bit-error';\nimport { Logger } from '@teambit/logger';\nimport { SnappingMain } from './snapping.main.runtime';\nimport { BasicTagSnapParams } from './tag-model-component';\n\nexport type FileData = { path: string; content: string; delete?: boolean };\n\nexport type SnapDataPerCompRaw = {\n componentId: string;\n dependencies?: string[];\n aspects?: Record<string, any>;\n message?: string;\n files?: FileData[];\n isNew?: boolean;\n mainFile?: string; // relevant when isNew is true. default to \"index.ts\".\n newDependencies?: Array<{\n id: string; // component-id or package-name. e.g. \"teambit.react/react\" or \"lodash\".\n version?: string; // version of the package. e.g. \"2.0.3\". for packages, it is mandatory.\n isComponent?: boolean; // default true. if false, it's a package dependency\n type?: 'runtime' | 'dev' | 'peer'; // default \"runtime\".\n }>;\n removeDependencies?: string[];\n forkFrom?: string; // origin id to fork from. the componentId is the new id. (no need to populate isNew prop).\n};\n\ntype SnapFromScopeOptions = {\n push?: boolean;\n lane?: string;\n ignoreIssues?: string;\n disableSnapPipeline?: boolean;\n updateDependents?: boolean;\n} & BasicTagSnapParams;\n\nexport class SnapFromScopeCmd implements Command {\n name = '_snap <data>';\n description = 'snap components from a bare-scope';\n extendedDescription = `this command should be running from a new bare scope, it first imports the components it needs and then processes the snap.\nthe input data is a stringified JSON of an array of the following object.\n{\n componentId: string; // ids always have scope, so it's safe to parse them from string\n dependencies?: string[]; // dependencies include versions. for components use component-id. e.g. [teambit.compilation/compiler@1.0.0, lodash@4.17.21]\n aspects?: Record<string,any> // e.g. { \"teambit.react/react\": {}, \"teambit.envs/envs\": { \"env\": \"teambit.react/react\" } }\n message?: string; // tag-message.\n files?: Array<{path: string, content: string}>; // replace content of specified source-files. the content is base64 encoded.\n isNew?: boolean; // if it's new, it'll be generated from the given files. otherwise, it'll be fetched from the scope and updated.\n mainFile?: string; // relevant when isNew is true. default to \"index.ts\".\n newDependencies?: Array<{ // new dependencies (components and packages) to add.\n id: string; // component-id or package-name. e.g. \"teambit.react/react\" or \"lodash\".\n version?: string; // version of the package. e.g. \"2.0.3\". for packages, it is mandatory.\n isComponent?: boolean; // default true. if false, it's a package dependency\n type?: 'runtime' | 'dev' | 'peer'; // default \"runtime\".\n }>;\n removeDependencies?: string[]; // component-id (for components) or package-name (for packages) to remove from the dependencies.\n forkFrom?: string; // origin id to fork from. the componentId is the new id. (no need to populate isNew prop).\n}\nan example of the final data: '[{\"componentId\":\"ci.remote2/comp-b\",\"message\": \"first snap\"}]'\n`;\n alias = '';\n options = [\n ['', 'push', 'export the updated objects to the original scopes once done'],\n ['m', 'message <message>', 'log message describing the latest changes'],\n ['', 'lane <lane-id>', 'fetch the components from the given lane'],\n ['', 'build', 'run the build pipeline'],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n ['', 'disable-snap-pipeline', 'skip the snap pipeline'],\n ['', 'ignore-build-errors', 'run the snap pipeline although the build pipeline failed'],\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 'update-dependents',\n 'when snapped on a lane, mark it as update-dependents so it will be skipped from the workspace',\n ],\n ['j', 'json', 'output as json format'],\n ] as CommandOptions;\n loader = true;\n private = true;\n\n constructor(\n private snapping: SnappingMain,\n private logger: Logger\n ) {}\n\n async report([data]: [string], options: SnapFromScopeOptions) {\n const results = await this.json([data], options);\n\n const { snappedIds, exportedIds } = results;\n\n const snappedOutput = `${chalk.bold('snapped components')}\\n${snappedIds.join('\\n')}`;\n const exportedOutput =\n exportedIds && exportedIds.length ? `\\n\\n${chalk.bold('exported components')}\\n${exportedIds.join('\\n')}` : '';\n\n return `${snappedOutput}${exportedOutput}`;\n }\n async json(\n [data]: [string],\n {\n push = false,\n message = '',\n lane,\n ignoreIssues,\n build = false,\n skipTests = false,\n disableSnapPipeline = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n updateDependents,\n }: SnapFromScopeOptions\n ) {\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (disableTagAndSnapPipelines && ignoreBuildErrors) {\n throw new BitError('you can use either ignore-build-errors or disable-snap-pipeline, but not both');\n }\n if (updateDependents && !lane) {\n throw new BitError('update-dependents flag is only available when snapping from a lane');\n }\n\n const snapDataPerCompRaw = this.parseData(data);\n\n const results = await this.snapping.snapFromScope(snapDataPerCompRaw, {\n push,\n message,\n lane,\n ignoreIssues,\n build,\n skipTests,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n updateDependents,\n });\n\n return {\n exportedIds: results.exportedIds?.map((id) => id.toString()),\n snappedIds: results.snappedIds.map((id) => id.toString()),\n };\n }\n private parseData(data: string): SnapDataPerCompRaw[] {\n let dataParsed: unknown;\n try {\n dataParsed = JSON.parse(data);\n } catch (err: any) {\n throw new Error(`failed parsing the data entered as JSON. err ${err.message}`);\n }\n if (!Array.isArray(dataParsed)) {\n throw new Error('expect data to be an array');\n }\n dataParsed.forEach((dataItem) => {\n if (!dataItem.componentId) throw new Error('expect data item to have \"componentId\" prop');\n dataItem.files?.forEach((file) => {\n if (!file.path) throw new Error('expect file to have \"path\" prop');\n if (file.content) {\n file.content = Buffer.from(file.content, 'base64').toString();\n }\n });\n });\n\n return dataParsed;\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;AACA,SAAAG,iBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,gBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,SAAAC,uBAAAI,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,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAL,CAAA,GAAAK,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAhB,CAAA,QAAAa,CAAA,GAAAb,CAAA,CAAAi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F;AAACgB,OAAA,CAAApD,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_componentIssues","_bitError","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SnapFromScopeCmd","constructor","snapping","logger","keys","IssuesClasses","join","report","options","results","json","snappedIds","exportedIds","snappedOutput","chalk","bold","exportedOutput","length","push","message","lane","ignoreIssues","build","skipTests","disableSnapPipeline","ignoreBuildErrors","rebuildDepsGraph","updateDependents","tag","disableTagAndSnapPipelines","BitError","snapDataPerCompRaw","parseData","snapFromScope","map","id","toString","dataParsed","JSON","parse","err","Error","Array","isArray","forEach","dataItem","componentId","files","file","path","content","Buffer","from","exports"],"sources":["snap-from-scope.cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { BitError } from '@teambit/bit-error';\nimport { Logger } from '@teambit/logger';\nimport { SnappingMain } from './snapping.main.runtime';\nimport { BasicTagSnapParams } from './tag-model-component';\n\nexport type FileData = { path: string; content: string; delete?: boolean };\n\nexport type SnapDataPerCompRaw = {\n componentId: string;\n dependencies?: string[];\n aspects?: Record<string, any>;\n message?: string;\n files?: FileData[];\n isNew?: boolean;\n mainFile?: string; // relevant when isNew is true. default to \"index.ts\".\n newDependencies?: Array<{\n id: string; // component-id or package-name. e.g. \"teambit.react/react\" or \"lodash\".\n version?: string; // version of the package. e.g. \"2.0.3\". for packages, it is mandatory.\n isComponent?: boolean; // default true. if false, it's a package dependency\n type?: 'runtime' | 'dev' | 'peer'; // default \"runtime\".\n }>;\n removeDependencies?: string[];\n forkFrom?: string; // origin id to fork from. the componentId is the new id. (no need to populate isNew prop).\n version?: string; // relevant when passing \"--tag\". optionally, specify the semver to tag. default to \"patch\".\n};\n\ntype SnapFromScopeOptions = {\n push?: boolean;\n lane?: string;\n ignoreIssues?: string;\n disableSnapPipeline?: boolean;\n updateDependents?: boolean;\n tag?: boolean;\n} & BasicTagSnapParams;\n\nexport class SnapFromScopeCmd implements Command {\n name = '_snap <data>';\n description = 'snap components from a bare-scope';\n extendedDescription = `this command should be running from a new bare scope, it first imports the components it needs and then processes the snap.\nthe input data is a stringified JSON of an array of the following object.\n{\n componentId: string; // ids always have scope, so it's safe to parse them from string\n dependencies?: string[]; // dependencies include versions. for components use component-id. e.g. [teambit.compilation/compiler@1.0.0, lodash@4.17.21]\n aspects?: Record<string,any> // e.g. { \"teambit.react/react\": {}, \"teambit.envs/envs\": { \"env\": \"teambit.react/react\" } }\n message?: string; // tag-message.\n files?: Array<{path: string, content: string}>; // replace content of specified source-files. the content is base64 encoded.\n isNew?: boolean; // if it's new, it'll be generated from the given files. otherwise, it'll be fetched from the scope and updated.\n mainFile?: string; // relevant when isNew is true. default to \"index.ts\".\n newDependencies?: Array<{ // new dependencies (components and packages) to add.\n id: string; // component-id or package-name. e.g. \"teambit.react/react\" or \"lodash\".\n version?: string; // version of the package. e.g. \"2.0.3\". for packages, it is mandatory.\n isComponent?: boolean; // default true. if false, it's a package dependency\n type?: 'runtime' | 'dev' | 'peer'; // default \"runtime\".\n }>;\n removeDependencies?: string[]; // component-id (for components) or package-name (for packages) to remove from the dependencies.\n forkFrom?: string; // origin id to fork from. the componentId is the new id. (no need to populate isNew prop).\n version?: string; // relevant when passing \"--tag\". optionally, specify the semver to tag. default to \"patch\".\n}\nan example of the final data: '[{\"componentId\":\"ci.remote2/comp-b\",\"message\": \"first snap\"}]'\n`;\n alias = '';\n options = [\n ['', 'push', 'export the updated objects to the original scopes once done'],\n ['m', 'message <message>', 'log message describing the latest changes'],\n ['', 'lane <lane-id>', 'fetch the components from the given lane'],\n ['', 'build', 'run the build pipeline'],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n ['', 'disable-snap-pipeline', 'skip the snap pipeline'],\n ['', 'ignore-build-errors', 'run the snap pipeline although the build pipeline failed'],\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 'update-dependents',\n 'when snapped on a lane, mark it as update-dependents so it will be skipped from the workspace',\n ],\n ['', 'tag', 'make a tag instead of a snap'],\n ['', 'stream', 'relevant for --json only. stream loader as json strings'],\n ['j', 'json', 'output as json format'],\n ] as CommandOptions;\n loader = true;\n private = true;\n\n constructor(\n private snapping: SnappingMain,\n private logger: Logger\n ) {}\n\n async report([data]: [string], options: SnapFromScopeOptions) {\n const results = await this.json([data], options);\n\n const { snappedIds, exportedIds } = results;\n\n const snappedOutput = `${chalk.bold('snapped components')}\\n${snappedIds.join('\\n')}`;\n const exportedOutput =\n exportedIds && exportedIds.length ? `\\n\\n${chalk.bold('exported components')}\\n${exportedIds.join('\\n')}` : '';\n\n return `${snappedOutput}${exportedOutput}`;\n }\n async json(\n [data]: [string],\n {\n push = false,\n message = '',\n lane,\n ignoreIssues,\n build = false,\n skipTests = false,\n disableSnapPipeline = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n updateDependents,\n tag,\n }: SnapFromScopeOptions\n ) {\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (disableTagAndSnapPipelines && ignoreBuildErrors) {\n throw new BitError('you can use either ignore-build-errors or disable-snap-pipeline, but not both');\n }\n if (updateDependents && !lane) {\n throw new BitError('update-dependents flag is only available when snapping from a lane');\n }\n\n const snapDataPerCompRaw = this.parseData(data);\n\n const results = await this.snapping.snapFromScope(snapDataPerCompRaw, {\n push,\n message,\n lane,\n ignoreIssues,\n build,\n skipTests,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n updateDependents,\n tag,\n });\n\n return {\n exportedIds: results.exportedIds?.map((id) => id.toString()),\n snappedIds: results.snappedIds.map((id) => id.toString()),\n };\n }\n private parseData(data: string): SnapDataPerCompRaw[] {\n let dataParsed: unknown;\n try {\n dataParsed = JSON.parse(data);\n } catch (err: any) {\n throw new Error(`failed parsing the data entered as JSON. err ${err.message}`);\n }\n if (!Array.isArray(dataParsed)) {\n throw new Error('expect data to be an array');\n }\n dataParsed.forEach((dataItem) => {\n if (!dataItem.componentId) throw new Error('expect data item to have \"componentId\" prop');\n dataItem.files?.forEach((file) => {\n if (!file.path) throw new Error('expect file to have \"path\" prop');\n if (file.content) {\n file.content = Buffer.from(file.content, 'base64').toString();\n }\n });\n });\n\n return dataParsed;\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;AACA,SAAAG,iBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,gBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,SAAAC,uBAAAI,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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IAAK;MAC/B,IAAI,CAACA,QAAQ,CAACC,WAAW,EAAE,MAAM,IAAIL,KAAK,CAAC,6CAA6C,CAAC;MACzFI,QAAQ,CAACE,KAAK,EAAEH,OAAO,CAAEI,IAAI,IAAK;QAChC,IAAI,CAACA,IAAI,CAACC,IAAI,EAAE,MAAM,IAAIR,KAAK,CAAC,iCAAiC,CAAC;QAClE,IAAIO,IAAI,CAACE,OAAO,EAAE;UAChBF,IAAI,CAACE,OAAO,GAAGC,MAAM,CAACC,IAAI,CAACJ,IAAI,CAACE,OAAO,EAAE,QAAQ,CAAC,CAACd,QAAQ,CAAC,CAAC;QAC/D;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAOC,UAAU;EACnB;AACF;AAACgB,OAAA,CAAArD,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -120,12 +120,14 @@ export declare class SnappingMain {
120
120
  ignoreIssues?: string;
121
121
  lane?: string;
122
122
  updateDependents?: boolean;
123
+ tag?: boolean;
123
124
  } & Partial<BasicTagParams>): Promise<SnapFromScopeResults>;
124
125
  snapFromScope(snapDataPerCompRaw: SnapDataPerCompRaw[], params: {
125
126
  push?: boolean;
126
127
  ignoreIssues?: string;
127
128
  lane?: string;
128
129
  updateDependents?: boolean;
130
+ tag?: boolean;
129
131
  } & Partial<BasicTagParams>): Promise<SnapFromScopeResults>;
130
132
  /**
131
133
  * save the local changes of a component(s) into the scope. snap can be done on main or on a lane.
@@ -611,7 +611,8 @@ if you're willing to lose the history from the head to the specified version, us
611
611
  type: dep.type ?? 'runtime'
612
612
  })),
613
613
  removeDependencies: snapData.removeDependencies,
614
- forkFrom: _componentId().ComponentID.fromString(snapData.forkFrom)
614
+ forkFrom: _componentId().ComponentID.fromString(snapData.forkFrom),
615
+ version: snapData.version
615
616
  };
616
617
  });
617
618
 
@@ -695,20 +696,23 @@ if you're willing to lose the history from the head to the specified version, us
695
696
  const components = await this.workspace.getMany(forkedFromData.map(f => f.componentId));
696
697
  const consumerComponents = components.map(c => c.state._consumer);
697
698
  const ids = _componentId().ComponentIdList.fromArray(allCompIds);
699
+ await this.throwForVariousIssues(components, params.ignoreIssues);
700
+ const shouldTag = Boolean(params.tag);
698
701
  const results = await (0, _tagModelComponent().tagModelComponent)(_objectSpread(_objectSpread({}, params), {}, {
699
702
  scope: this.scope,
700
703
  consumerComponents,
701
704
  tagDataPerComp: snapDataPerComp.map(s => ({
702
705
  componentId: s.componentId,
703
706
  message: s.message,
704
- dependencies: []
707
+ dependencies: [],
708
+ versionToTag: shouldTag ? s.version || 'patch' : undefined
705
709
  })),
706
710
  snapping: this,
707
711
  builder: this.builder,
708
712
  dependencyResolver: this.dependencyResolver,
709
713
  skipAutoTag: true,
710
714
  persist: true,
711
- isSnap: true,
715
+ isSnap: !shouldTag,
712
716
  ids,
713
717
  message: params.message,
714
718
  updateDependentsOnLane: params.updateDependents
@@ -782,7 +786,8 @@ if you're willing to lose the history from the head to the specified version, us
782
786
  isComponent: dep.isComponent ?? true,
783
787
  type: dep.type ?? 'runtime'
784
788
  })),
785
- removeDependencies: snapData.removeDependencies
789
+ removeDependencies: snapData.removeDependencies,
790
+ version: snapData.version
786
791
  };
787
792
  });
788
793
 
@@ -850,20 +855,22 @@ if you're willing to lose the history from the head to the specified version, us
850
855
  await (0, _pMapSeries().default)(components, async comp => this.scope.executeOnCompAspectReCalcSlot(comp));
851
856
  const consumerComponents = components.map(c => c.state._consumer);
852
857
  const ids = _componentId().ComponentIdList.fromArray(allCompIds);
858
+ const shouldTag = Boolean(params.tag);
853
859
  const results = await (0, _tagModelComponent().tagModelComponent)(_objectSpread(_objectSpread({}, params), {}, {
854
860
  scope: this.scope,
855
861
  consumerComponents,
856
862
  tagDataPerComp: snapDataPerComp.map(s => ({
857
863
  componentId: s.componentId,
858
864
  message: s.message,
859
- dependencies: []
865
+ dependencies: [],
866
+ versionToTag: shouldTag ? s.version || 'patch' : undefined
860
867
  })),
861
868
  snapping: this,
862
869
  builder: this.builder,
863
870
  dependencyResolver: this.dependencyResolver,
864
871
  skipAutoTag: true,
865
872
  persist: true,
866
- isSnap: true,
873
+ isSnap: !shouldTag,
867
874
  ids,
868
875
  message: params.message,
869
876
  updateDependentsOnLane: params.updateDependents