@teambit/snapping 1.0.106 → 1.0.108
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/components-have-issues.ts +39 -0
- package/dist/flattened-edges.d.ts +1 -1
- package/dist/generate-comp-from-scope.d.ts +1 -1
- package/dist/snap-cmd.js +1 -1
- package/dist/snap-cmd.js.map +1 -1
- package/dist/snap-distance-cmd.d.ts +15 -0
- package/dist/snap-distance-cmd.js +44 -0
- package/dist/snap-distance-cmd.js.map +1 -0
- package/dist/snap-from-scope.cmd.d.ts +3 -3
- package/dist/snap-from-scope.cmd.js +1 -2
- package/dist/snap-from-scope.cmd.js.map +1 -1
- package/dist/snapping.main.runtime.d.ts +7 -7
- package/dist/snapping.main.runtime.js +21 -22
- package/dist/snapping.main.runtime.js.map +1 -1
- package/dist/snapping.spec.js +2 -2
- package/dist/snapping.spec.js.map +1 -1
- package/dist/tag-cmd.js +1 -1
- package/dist/tag-cmd.js.map +1 -1
- package/dist/tag-from-scope.cmd.d.ts +1 -1
- package/dist/tag-model-component.d.ts +4 -4
- package/dist/tag-model-component.js +11 -14
- package/dist/tag-model-component.js.map +1 -1
- package/flattened-edges.ts +189 -0
- package/generate-comp-from-scope.ts +124 -0
- package/index.ts +8 -0
- package/package.json +28 -37
- package/reset-cmd.ts +70 -0
- package/snap-cmd.ts +195 -0
- package/snap-distance-cmd.ts +29 -0
- package/snap-from-scope.cmd.ts +155 -0
- package/snapping.aspect.ts +5 -0
- package/snapping.main.runtime.ts +1331 -0
- package/snapping.spec.ts +52 -0
- package/tag-cmd.ts +360 -0
- package/tag-from-scope.cmd.ts +258 -0
- package/tag-model-component.ts +641 -0
- package/tsconfig.json +16 -21
- package/types/asset.d.ts +15 -3
- /package/dist/{preview-1703505948637.js → preview-1703647408454.js} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { BitError } from '@teambit/bit-error';
|
|
2
|
+
import IssuesAspect from '@teambit/issues';
|
|
3
|
+
import { formatIssues } from '@teambit/legacy/dist/cli/templates/component-issues-template';
|
|
4
|
+
import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { uniq } from 'lodash';
|
|
7
|
+
|
|
8
|
+
export class ComponentsHaveIssues extends BitError {
|
|
9
|
+
constructor(components: ConsumerComponent[]) {
|
|
10
|
+
components.forEach((component) => {
|
|
11
|
+
component.issues = component.issues.filterNonTagBlocking();
|
|
12
|
+
});
|
|
13
|
+
const allIssueNames = uniq(components.map((comp) => comp.issues.getAllIssueNames()).flat());
|
|
14
|
+
const issuesColored = componentIssuesTemplate(components);
|
|
15
|
+
super(`error: issues found with the following components
|
|
16
|
+
${issuesColored}
|
|
17
|
+
|
|
18
|
+
to get the list of component-issues names and suggestions how to resolve them, run "bit component-issues".
|
|
19
|
+
|
|
20
|
+
while highly not recommended, it's possible to ignore issues in two ways:
|
|
21
|
+
1) temporarily ignore for this tag/snap command by entering "--ignore-issues" flag, e.g. \`bit tag --ignore-issues "${allIssueNames.join(
|
|
22
|
+
', '
|
|
23
|
+
)}" \`
|
|
24
|
+
2) ignore the issue completely by configuring it in the workspace.jsonc file. e.g:
|
|
25
|
+
"${IssuesAspect.id}": {
|
|
26
|
+
"ignoreIssues": [${allIssueNames.map((issue) => `"${issue}"`).join(', ')}]
|
|
27
|
+
}
|
|
28
|
+
`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function componentIssuesTemplate(components: ConsumerComponent[]) {
|
|
33
|
+
function format(component: ConsumerComponent) {
|
|
34
|
+
return `${chalk.underline(chalk.cyan(component.id.toString()))}\n${formatIssues(component)}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const result = `\n${components.map(format).join('\n')}`;
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
@@ -52,7 +52,7 @@ export declare class FlattenedEdgesGetter {
|
|
|
52
52
|
private lane?;
|
|
53
53
|
private graph;
|
|
54
54
|
private missingFromGraph;
|
|
55
|
-
constructor(scope: ScopeMain, consumerComponents: ConsumerComponent[], logger: Logger, lane?: Lane
|
|
55
|
+
constructor(scope: ScopeMain, consumerComponents: ConsumerComponent[], logger: Logger, lane?: Lane);
|
|
56
56
|
buildGraph(): Promise<Graph<ComponentID, DepEdgeType>>;
|
|
57
57
|
private importMissingAndAddToGraph;
|
|
58
58
|
private addPreviousGraphs;
|
|
@@ -5,7 +5,7 @@ import { DependenciesMain } from '@teambit/dependencies';
|
|
|
5
5
|
import { DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
6
6
|
import { FileData } from './snap-from-scope.cmd';
|
|
7
7
|
import { SnapDataParsed } from './snapping.main.runtime';
|
|
8
|
-
export
|
|
8
|
+
export type CompData = {
|
|
9
9
|
componentId: ComponentID;
|
|
10
10
|
dependencies: ComponentID[];
|
|
11
11
|
aspects: Record<string, any> | undefined;
|
package/dist/snap-cmd.js
CHANGED
|
@@ -115,7 +115,7 @@ to ignore multiple issues, separate them by a comma and wrap with quotes. to ign
|
|
|
115
115
|
removedComponents
|
|
116
116
|
} = results;
|
|
117
117
|
const changedComponents = snappedComponents.filter(component => {
|
|
118
|
-
return !newComponents.searchWithoutVersion(component.id) && !
|
|
118
|
+
return !newComponents.searchWithoutVersion(component.id) && !removedComponents?.searchWithoutVersion(component.id);
|
|
119
119
|
});
|
|
120
120
|
const addedComponents = snappedComponents.filter(component => newComponents.searchWithoutVersion(component.id));
|
|
121
121
|
const autoTaggedCount = autoSnappedResults ? autoSnappedResults.length : 0;
|
package/dist/snap-cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_componentIssues","_constants","_tagCmd","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","SnapCmd","constructor","snapping","logger","globalConfig","name","description","COMPONENT_PATTERN_HELP","keys","IssuesClasses","join","report","pattern","message","all","force","unmerged","editor","ignoreIssues","build","skipTests","skipAutoSnap","disableSnapPipeline","forceDeploy","ignoreBuildErrors","rebuildDepsGraph","unmodified","failFast","getBool","CFG_FORCE_LOCAL_BUILD","Boolean","disableTagAndSnapPipelines","consoleWarning","results","snap","exitOnFirstFailedTask","chalk","yellow","NOTHING_TO_SNAP_MSG","snappedComponents","autoSnappedResults","warnings","newComponents","laneName","removedComponents","changedComponents","filter","component","searchWithoutVersion","id","addedComponents","autoTaggedCount","length","warningsOutput","snapExplanation","compInBold","version","hasVersion","bold","toStringWithoutVersion","outputComponents","comps","map","componentOutput","autoTag","result","triggeredBy","autoTagComp","a","AUTO_SNAPPED_MSG","outputIfExists","label","explanation","components","underline","laneStr","outputIdsIfExists","green","exports"],"sources":["snap-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { ComponentID } from '@teambit/component-id';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { GlobalConfigMain } from '@teambit/global-config';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport {\n NOTHING_TO_SNAP_MSG,\n AUTO_SNAPPED_MSG,\n COMPONENT_PATTERN_HELP,\n CFG_FORCE_LOCAL_BUILD,\n} from '@teambit/legacy/dist/constants';\nimport { Logger } from '@teambit/logger';\nimport { SnappingMain, SnapResults } from './snapping.main.runtime';\nimport { outputIdsIfExists } from './tag-cmd';\nimport { BasicTagSnapParams } from './tag-model-component';\n\nexport class SnapCmd implements Command {\n name = 'snap [component-pattern]';\n description = 'create an immutable and exportable component snapshot (non-release version)';\n extendedDescription: string;\n group = 'development';\n arguments = [\n {\n name: 'component-pattern',\n description: `${COMPONENT_PATTERN_HELP}. By default, only new and modified components are snapped (add --unmodified to snap all components in the workspace).`,\n },\n ];\n helpUrl = 'reference/components/snaps';\n alias = '';\n options = [\n ['m', 'message <message>', 'snap message describing the latest changes - will appear in component history log'],\n ['u', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'],\n ['', 'unmerged', 'complete a merge process by snapping the unmerged components'],\n ['b', 'build', 'locally run the build pipeline (i.e. not via rippleCI) and complete the snap'],\n [\n '',\n 'editor [editor]',\n 'open an editor to write a snap message per component. optionally specify the editor-name (defaults to vim).',\n ],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n ['', '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 ['', 'force-deploy', 'DEPRECATED. use --ignore-build-error instead'],\n ['', 'ignore-build-errors', 'proceed to snap pipeline even when build pipeline fails'],\n ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'],\n [\n 'i',\n 'ignore-issues [issues]',\n `ignore component issues (shown in \"bit status\" as \"issues found\"), issues to ignore:\n[${Object.keys(IssuesClasses).join(', ')}]\nto ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify \"*\".`,\n ],\n ['a', 'all', 'DEPRECATED (not needed anymore, now the default). snap all new and modified components'],\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 'f',\n 'force',\n 'DEPRECATED (use \"--skip-tests\" or \"--unmodified\" instead). force-snap even if tests are failing and even when component has not changed',\n ],\n ] as CommandOptions;\n loader = true;\n migration = true;\n\n constructor(private snapping: SnappingMain, private logger: Logger, private globalConfig: GlobalConfigMain) {}\n\n async report(\n [pattern]: string[],\n {\n message = '',\n all = false,\n force = false,\n unmerged = false,\n editor = '',\n ignoreIssues,\n build,\n skipTests = false,\n skipAutoSnap = false,\n disableSnapPipeline = false,\n forceDeploy = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n unmodified = false,\n failFast = false,\n }: {\n all?: boolean;\n force?: boolean;\n unmerged?: boolean;\n editor?: string;\n ignoreIssues?: string;\n skipAutoSnap?: boolean;\n disableSnapPipeline?: boolean;\n forceDeploy?: boolean;\n unmodified?: boolean;\n failFast?: boolean;\n } & BasicTagSnapParams\n ) {\n build = (await this.globalConfig.getBool(CFG_FORCE_LOCAL_BUILD)) || Boolean(build);\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (all) {\n this.logger.consoleWarning(\n `--all is deprecated, please omit it. By default all new and modified components are snapped, to snap all components add --unmodified`\n );\n }\n if (force) {\n this.logger.consoleWarning(\n `--force is deprecated, use either --skip-tests or --ignore-build-errors depending on the use case`\n );\n if (pattern) unmodified = true;\n }\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 if (forceDeploy) {\n this.logger.consoleWarning(`--force-deploy is deprecated, use --ignore-build-errors instead`);\n ignoreBuildErrors = true;\n }\n\n const results = await this.snapping.snap({\n pattern,\n message,\n unmerged,\n editor,\n ignoreIssues,\n build,\n skipTests,\n skipAutoSnap,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n unmodified,\n exitOnFirstFailedTask: failFast,\n });\n\n if (!results) return chalk.yellow(NOTHING_TO_SNAP_MSG);\n const { snappedComponents, autoSnappedResults, warnings, newComponents, laneName, removedComponents }: SnapResults =\n results;\n const changedComponents = snappedComponents.filter((component) => {\n return (\n !newComponents.searchWithoutVersion(component.id) && !removedComponents?.searchWithoutVersion(component.id)\n );\n });\n const addedComponents = snappedComponents.filter((component) => newComponents.searchWithoutVersion(component.id));\n const autoTaggedCount = autoSnappedResults ? autoSnappedResults.length : 0;\n\n const warningsOutput = warnings && warnings.length ? `${chalk.yellow(warnings.join('\\n'))}\\n\\n` : '';\n const snapExplanation = `\\n(use \"bit export\" to push these components to a remote\")\n(use \"bit reset\" to unstage all local versions, or \"bit reset --head\" to only unstage the latest local snap)`;\n\n const compInBold = (id: ComponentID) => {\n const version = id.hasVersion() ? `@${id.version}` : '';\n return `${chalk.bold(id.toStringWithoutVersion())}${version}`;\n };\n\n const outputComponents = (comps: ConsumerComponent[]) => {\n return comps\n .map((component) => {\n let componentOutput = ` > ${compInBold(component.id)}`;\n const autoTag = autoSnappedResults.filter((result) => result.triggeredBy.searchWithoutVersion(component.id));\n if (autoTag.length) {\n const autoTagComp = autoTag.map((a) => compInBold(a.component.id));\n componentOutput += `\\n ${AUTO_SNAPPED_MSG} (${autoTagComp.length} total):\n ${autoTagComp.join('\\n ')}`;\n }\n return componentOutput;\n })\n .join('\\n');\n };\n\n const outputIfExists = (label, explanation, components) => {\n if (!components.length) return '';\n return `\\n${chalk.underline(label)}\\n(${explanation})\\n${outputComponents(components)}\\n`;\n };\n const laneStr = laneName ? ` on \"${laneName}\" lane` : '';\n\n return (\n outputIfExists('new components', 'first version for components', addedComponents) +\n outputIfExists('changed components', 'components that got a version bump', changedComponents) +\n outputIdsIfExists('removed components', removedComponents) +\n warningsOutput +\n chalk.green(`\\n${snappedComponents.length + autoTaggedCount} component(s) snapped${laneStr}`) +\n snapExplanation\n );\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,iBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,gBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,WAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,UAAA,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,GAAA,WAAAA,GAAA,I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;UAClB,MAAMe,WAAW,GAAGH,OAAO,CAACF,GAAG,CAAEM,CAAC,IAAKb,UAAU,CAACa,CAAC,CAACrB,SAAS,CAACE,EAAE,CAAC,CAAC;UAClEc,eAAe,IAAK,YAAWM,6BAAiB,KAAIF,WAAW,CAACf,MAAO;AACnF,cAAce,WAAW,CAACzD,IAAI,CAAC,gBAAgB,CAAE,EAAC;QACxC;QACA,OAAOqD,eAAe;MACxB,CAAC,CAAC,CACDrD,IAAI,CAAC,IAAI,CAAC;IACf,CAAC;IAED,MAAM4D,cAAc,GAAGA,CAACC,KAAK,EAAEC,WAAW,EAAEC,UAAU,KAAK;MACzD,IAAI,CAACA,UAAU,CAACrB,MAAM,EAAE,OAAO,EAAE;MACjC,OAAQ,KAAIhB,gBAAK,CAACsC,SAAS,CAACH,KAAK,CAAE,MAAKC,WAAY,MAAKZ,gBAAgB,CAACa,UAAU,CAAE,IAAG;IAC3F,CAAC;IACD,MAAME,OAAO,GAAGhC,QAAQ,GAAI,QAAOA,QAAS,QAAO,GAAG,EAAE;IAExD,OACE2B,cAAc,CAAC,gBAAgB,EAAE,8BAA8B,EAAEpB,eAAe,CAAC,GACjFoB,cAAc,CAAC,oBAAoB,EAAE,oCAAoC,EAAEzB,iBAAiB,CAAC,GAC7F,IAAA+B,2BAAiB,EAAC,oBAAoB,EAAEhC,iBAAiB,CAAC,GAC1DS,cAAc,GACdjB,gBAAK,CAACyC,KAAK,CAAE,KAAItC,iBAAiB,CAACa,MAAM,GAAGD,eAAgB,wBAAuBwB,OAAQ,EAAC,CAAC,GAC7FrB,eAAe;EAEnB;AACF;AAACwB,OAAA,CAAA9E,OAAA,GAAAA,OAAA"}
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_componentIssues","_constants","_tagCmd","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","SnapCmd","constructor","snapping","logger","globalConfig","name","description","COMPONENT_PATTERN_HELP","keys","IssuesClasses","join","report","pattern","message","all","force","unmerged","editor","ignoreIssues","build","skipTests","skipAutoSnap","disableSnapPipeline","forceDeploy","ignoreBuildErrors","rebuildDepsGraph","unmodified","failFast","getBool","CFG_FORCE_LOCAL_BUILD","Boolean","disableTagAndSnapPipelines","consoleWarning","results","snap","exitOnFirstFailedTask","chalk","yellow","NOTHING_TO_SNAP_MSG","snappedComponents","autoSnappedResults","warnings","newComponents","laneName","removedComponents","changedComponents","filter","component","searchWithoutVersion","id","addedComponents","autoTaggedCount","length","warningsOutput","snapExplanation","compInBold","version","hasVersion","bold","toStringWithoutVersion","outputComponents","comps","map","componentOutput","autoTag","result","triggeredBy","autoTagComp","a","AUTO_SNAPPED_MSG","outputIfExists","label","explanation","components","underline","laneStr","outputIdsIfExists","green","exports"],"sources":["snap-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { ComponentID } from '@teambit/component-id';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { GlobalConfigMain } from '@teambit/global-config';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport {\n NOTHING_TO_SNAP_MSG,\n AUTO_SNAPPED_MSG,\n COMPONENT_PATTERN_HELP,\n CFG_FORCE_LOCAL_BUILD,\n} from '@teambit/legacy/dist/constants';\nimport { Logger } from '@teambit/logger';\nimport { SnappingMain, SnapResults } from './snapping.main.runtime';\nimport { outputIdsIfExists } from './tag-cmd';\nimport { BasicTagSnapParams } from './tag-model-component';\n\nexport class SnapCmd implements Command {\n name = 'snap [component-pattern]';\n description = 'create an immutable and exportable component snapshot (non-release version)';\n extendedDescription: string;\n group = 'development';\n arguments = [\n {\n name: 'component-pattern',\n description: `${COMPONENT_PATTERN_HELP}. By default, only new and modified components are snapped (add --unmodified to snap all components in the workspace).`,\n },\n ];\n helpUrl = 'reference/components/snaps';\n alias = '';\n options = [\n ['m', 'message <message>', 'snap message describing the latest changes - will appear in component history log'],\n ['u', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'],\n ['', 'unmerged', 'complete a merge process by snapping the unmerged components'],\n ['b', 'build', 'locally run the build pipeline (i.e. not via rippleCI) and complete the snap'],\n [\n '',\n 'editor [editor]',\n 'open an editor to write a snap message per component. optionally specify the editor-name (defaults to vim).',\n ],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n ['', '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 ['', 'force-deploy', 'DEPRECATED. use --ignore-build-error instead'],\n ['', 'ignore-build-errors', 'proceed to snap pipeline even when build pipeline fails'],\n ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'],\n [\n 'i',\n 'ignore-issues [issues]',\n `ignore component issues (shown in \"bit status\" as \"issues found\"), issues to ignore:\n[${Object.keys(IssuesClasses).join(', ')}]\nto ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify \"*\".`,\n ],\n ['a', 'all', 'DEPRECATED (not needed anymore, now the default). snap all new and modified components'],\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 'f',\n 'force',\n 'DEPRECATED (use \"--skip-tests\" or \"--unmodified\" instead). force-snap even if tests are failing and even when component has not changed',\n ],\n ] as CommandOptions;\n loader = true;\n migration = true;\n\n constructor(private snapping: SnappingMain, private logger: Logger, private globalConfig: GlobalConfigMain) {}\n\n async report(\n [pattern]: string[],\n {\n message = '',\n all = false,\n force = false,\n unmerged = false,\n editor = '',\n ignoreIssues,\n build,\n skipTests = false,\n skipAutoSnap = false,\n disableSnapPipeline = false,\n forceDeploy = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n unmodified = false,\n failFast = false,\n }: {\n all?: boolean;\n force?: boolean;\n unmerged?: boolean;\n editor?: string;\n ignoreIssues?: string;\n skipAutoSnap?: boolean;\n disableSnapPipeline?: boolean;\n forceDeploy?: boolean;\n unmodified?: boolean;\n failFast?: boolean;\n } & BasicTagSnapParams\n ) {\n build = (await this.globalConfig.getBool(CFG_FORCE_LOCAL_BUILD)) || Boolean(build);\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (all) {\n this.logger.consoleWarning(\n `--all is deprecated, please omit it. By default all new and modified components are snapped, to snap all components add --unmodified`\n );\n }\n if (force) {\n this.logger.consoleWarning(\n `--force is deprecated, use either --skip-tests or --ignore-build-errors depending on the use case`\n );\n if (pattern) unmodified = true;\n }\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 if (forceDeploy) {\n this.logger.consoleWarning(`--force-deploy is deprecated, use --ignore-build-errors instead`);\n ignoreBuildErrors = true;\n }\n\n const results = await this.snapping.snap({\n pattern,\n message,\n unmerged,\n editor,\n ignoreIssues,\n build,\n skipTests,\n skipAutoSnap,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n unmodified,\n exitOnFirstFailedTask: failFast,\n });\n\n if (!results) return chalk.yellow(NOTHING_TO_SNAP_MSG);\n const { snappedComponents, autoSnappedResults, warnings, newComponents, laneName, removedComponents }: SnapResults =\n results;\n const changedComponents = snappedComponents.filter((component) => {\n return (\n !newComponents.searchWithoutVersion(component.id) && !removedComponents?.searchWithoutVersion(component.id)\n );\n });\n const addedComponents = snappedComponents.filter((component) => newComponents.searchWithoutVersion(component.id));\n const autoTaggedCount = autoSnappedResults ? autoSnappedResults.length : 0;\n\n const warningsOutput = warnings && warnings.length ? `${chalk.yellow(warnings.join('\\n'))}\\n\\n` : '';\n const snapExplanation = `\\n(use \"bit export\" to push these components to a remote\")\n(use \"bit reset\" to unstage all local versions, or \"bit reset --head\" to only unstage the latest local snap)`;\n\n const compInBold = (id: ComponentID) => {\n const version = id.hasVersion() ? `@${id.version}` : '';\n return `${chalk.bold(id.toStringWithoutVersion())}${version}`;\n };\n\n const outputComponents = (comps: ConsumerComponent[]) => {\n return comps\n .map((component) => {\n let componentOutput = ` > ${compInBold(component.id)}`;\n const autoTag = autoSnappedResults.filter((result) => result.triggeredBy.searchWithoutVersion(component.id));\n if (autoTag.length) {\n const autoTagComp = autoTag.map((a) => compInBold(a.component.id));\n componentOutput += `\\n ${AUTO_SNAPPED_MSG} (${autoTagComp.length} total):\n ${autoTagComp.join('\\n ')}`;\n }\n return componentOutput;\n })\n .join('\\n');\n };\n\n const outputIfExists = (label, explanation, components) => {\n if (!components.length) return '';\n return `\\n${chalk.underline(label)}\\n(${explanation})\\n${outputComponents(components)}\\n`;\n };\n const laneStr = laneName ? ` on \"${laneName}\" lane` : '';\n\n return (\n outputIfExists('new components', 'first version for components', addedComponents) +\n outputIfExists('changed components', 'components that got a version bump', changedComponents) +\n outputIdsIfExists('removed components', removedComponents) +\n warningsOutput +\n chalk.green(`\\n${snappedComponents.length + autoTaggedCount} component(s) snapped${laneStr}`) +\n snapExplanation\n );\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,iBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,gBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAI,WAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,UAAA,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,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B,MAAMe,WAAW,GAAGH,OAAO,CAACF,GAAG,CAAEM,CAAC,IAAKb,UAAU,CAACa,CAAC,CAACrB,SAAS,CAACE,EAAE,CAAC,CAAC;UAClEc,eAAe,IAAK,YAAWM,6BAAiB,KAAIF,WAAW,CAACf,MAAO;AACnF,cAAce,WAAW,CAACzD,IAAI,CAAC,gBAAgB,CAAE,EAAC;QACxC;QACA,OAAOqD,eAAe;MACxB,CAAC,CAAC,CACDrD,IAAI,CAAC,IAAI,CAAC;IACf,CAAC;IAED,MAAM4D,cAAc,GAAGA,CAACC,KAAK,EAAEC,WAAW,EAAEC,UAAU,KAAK;MACzD,IAAI,CAACA,UAAU,CAACrB,MAAM,EAAE,OAAO,EAAE;MACjC,OAAQ,KAAIhB,gBAAK,CAACsC,SAAS,CAACH,KAAK,CAAE,MAAKC,WAAY,MAAKZ,gBAAgB,CAACa,UAAU,CAAE,IAAG;IAC3F,CAAC;IACD,MAAME,OAAO,GAAGhC,QAAQ,GAAI,QAAOA,QAAS,QAAO,GAAG,EAAE;IAExD,OACE2B,cAAc,CAAC,gBAAgB,EAAE,8BAA8B,EAAEpB,eAAe,CAAC,GACjFoB,cAAc,CAAC,oBAAoB,EAAE,oCAAoC,EAAEzB,iBAAiB,CAAC,GAC7F,IAAA+B,2BAAiB,EAAC,oBAAoB,EAAEhC,iBAAiB,CAAC,GAC1DS,cAAc,GACdjB,gBAAK,CAACyC,KAAK,CAAE,KAAItC,iBAAiB,CAACa,MAAM,GAAGD,eAAgB,wBAAuBwB,OAAQ,EAAC,CAAC,GAC7FrB,eAAe;EAEnB;AACF;AAACwB,OAAA,CAAA9E,OAAA,GAAAA,OAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ScopeMain } from '@teambit/scope';
|
|
2
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
3
|
+
export declare class SnapDistanceCmd implements Command {
|
|
4
|
+
private scope;
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
extendedDescription: string;
|
|
8
|
+
alias: string;
|
|
9
|
+
options: CommandOptions;
|
|
10
|
+
loader: boolean;
|
|
11
|
+
migration: boolean;
|
|
12
|
+
private: boolean;
|
|
13
|
+
constructor(scope: ScopeMain);
|
|
14
|
+
report([id, sourceSnap, targetSnap]: [string, string, string]): Promise<string>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SnapDistanceCmd = void 0;
|
|
7
|
+
function _bitError() {
|
|
8
|
+
const data = require("@teambit/bit-error");
|
|
9
|
+
_bitError = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
class SnapDistanceCmd {
|
|
18
|
+
constructor(scope) {
|
|
19
|
+
this.scope = scope;
|
|
20
|
+
_defineProperty(this, "name", 'snap-distance <component-id> [source-snap] [target-snap]');
|
|
21
|
+
_defineProperty(this, "description", 'show common-snap and distance between two given snaps or between local and remote snaps');
|
|
22
|
+
_defineProperty(this, "extendedDescription", `in case source and target snaps are not provided, the command will use the local and remote heads.
|
|
23
|
+
by "head" we mean component-head if on main, or lane-head if on lane.
|
|
24
|
+
if source and target snaps are provided, the command will use them to calculate the distance.`);
|
|
25
|
+
_defineProperty(this, "alias", '');
|
|
26
|
+
_defineProperty(this, "options", []);
|
|
27
|
+
_defineProperty(this, "loader", true);
|
|
28
|
+
_defineProperty(this, "migration", true);
|
|
29
|
+
_defineProperty(this, "private", true);
|
|
30
|
+
}
|
|
31
|
+
async report([id, sourceSnap, targetSnap]) {
|
|
32
|
+
const compId = await this.scope.resolveComponentId(id);
|
|
33
|
+
const getSnapDistance = async () => {
|
|
34
|
+
if (!sourceSnap) return this.scope.getSnapDistance(compId, false);
|
|
35
|
+
if (!targetSnap) throw new (_bitError().BitError)('either provide both source and target snaps or none');
|
|
36
|
+
return this.scope.getSnapsDistanceBetweenTwoSnaps(compId, sourceSnap, targetSnap, false);
|
|
37
|
+
};
|
|
38
|
+
const snapDistance = await getSnapDistance();
|
|
39
|
+
return JSON.stringify(snapDistance, null, 2);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.SnapDistanceCmd = SnapDistanceCmd;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=snap-distance-cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","SnapDistanceCmd","constructor","scope","report","id","sourceSnap","targetSnap","compId","resolveComponentId","getSnapDistance","BitError","getSnapsDistanceBetweenTwoSnaps","snapDistance","JSON","stringify","exports"],"sources":["snap-distance-cmd.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ScopeMain } from '@teambit/scope';\nimport { Command, CommandOptions } from '@teambit/cli';\n\nexport class SnapDistanceCmd implements Command {\n name = 'snap-distance <component-id> [source-snap] [target-snap]';\n description = 'show common-snap and distance between two given snaps or between local and remote snaps';\n extendedDescription = `in case source and target snaps are not provided, the command will use the local and remote heads.\nby \"head\" we mean component-head if on main, or lane-head if on lane.\nif source and target snaps are provided, the command will use them to calculate the distance.`;\n alias = '';\n options = [] as CommandOptions;\n loader = true;\n migration = true;\n private = true;\n\n constructor(private scope: ScopeMain) {}\n\n async report([id, sourceSnap, targetSnap]: [string, string, string]) {\n const compId = await this.scope.resolveComponentId(id);\n const getSnapDistance = async () => {\n if (!sourceSnap) return this.scope.getSnapDistance(compId, false);\n if (!targetSnap) throw new BitError('either provide both source and target snaps or none');\n return this.scope.getSnapsDistanceBetweenTwoSnaps(compId, sourceSnap, targetSnap, false);\n };\n const snapDistance = await getSnapDistance();\n return JSON.stringify(snapDistance, null, 2);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAE,MAAA,CAAAF,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAI,CAAA,2BAAAJ,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAK,CAAA,GAAAL,CAAA,CAAAM,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAJ,CAAA,GAAAI,CAAA,CAAAG,IAAA,CAAAR,CAAA,EAAAI,CAAA,uCAAAH,CAAA,SAAAA,CAAA,YAAAQ,SAAA,yEAAAL,CAAA,GAAAD,MAAA,GAAAO,MAAA,EAAAV,CAAA;AAIvC,MAAMW,eAAe,CAAoB;EAY9CC,WAAWA,CAASC,KAAgB,EAAE;IAAA,KAAlBA,KAAgB,GAAhBA,KAAgB;IAAAvB,eAAA,eAX7B,0DAA0D;IAAAA,eAAA,sBACnD,yFAAyF;IAAAA,eAAA,8BAChF;AACzB;AACA,8FAA8F;IAAAA,eAAA,gBACpF,EAAE;IAAAA,eAAA,kBACA,EAAE;IAAAA,eAAA,iBACH,IAAI;IAAAA,eAAA,oBACD,IAAI;IAAAA,eAAA,kBACN,IAAI;EAEyB;EAEvC,MAAMwB,MAAMA,CAAC,CAACC,EAAE,EAAEC,UAAU,EAAEC,UAAU,CAA2B,EAAE;IACnE,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACL,KAAK,CAACM,kBAAkB,CAACJ,EAAE,CAAC;IACtD,MAAMK,eAAe,GAAG,MAAAA,CAAA,KAAY;MAClC,IAAI,CAACJ,UAAU,EAAE,OAAO,IAAI,CAACH,KAAK,CAACO,eAAe,CAACF,MAAM,EAAE,KAAK,CAAC;MACjE,IAAI,CAACD,UAAU,EAAE,MAAM,KAAII,oBAAQ,EAAC,qDAAqD,CAAC;MAC1F,OAAO,IAAI,CAACR,KAAK,CAACS,+BAA+B,CAACJ,MAAM,EAAEF,UAAU,EAAEC,UAAU,EAAE,KAAK,CAAC;IAC1F,CAAC;IACD,MAAMM,YAAY,GAAG,MAAMH,eAAe,CAAC,CAAC;IAC5C,OAAOI,IAAI,CAACC,SAAS,CAACF,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;EAC9C;AACF;AAACG,OAAA,CAAAf,eAAA,GAAAA,eAAA"}
|
|
@@ -2,12 +2,12 @@ import { Command, CommandOptions } from '@teambit/cli';
|
|
|
2
2
|
import { Logger } from '@teambit/logger';
|
|
3
3
|
import { SnappingMain } from './snapping.main.runtime';
|
|
4
4
|
import { BasicTagSnapParams } from './tag-model-component';
|
|
5
|
-
export
|
|
5
|
+
export type FileData = {
|
|
6
6
|
path: string;
|
|
7
7
|
content: string;
|
|
8
8
|
delete?: boolean;
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type SnapDataPerCompRaw = {
|
|
11
11
|
componentId: string;
|
|
12
12
|
dependencies?: string[];
|
|
13
13
|
aspects?: Record<string, any>;
|
|
@@ -22,7 +22,7 @@ export declare type SnapDataPerCompRaw = {
|
|
|
22
22
|
type?: 'runtime' | 'dev' | 'peer';
|
|
23
23
|
}>;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
type SnapFromScopeOptions = {
|
|
26
26
|
push?: boolean;
|
|
27
27
|
lane?: string;
|
|
28
28
|
ignoreIssues?: string;
|
|
@@ -116,9 +116,8 @@ to ignore multiple issues, separate them by a comma and wrap with quotes. to ign
|
|
|
116
116
|
throw new Error('expect data to be an array');
|
|
117
117
|
}
|
|
118
118
|
dataParsed.forEach(dataItem => {
|
|
119
|
-
var _dataItem$files;
|
|
120
119
|
if (!dataItem.componentId) throw new Error('expect data item to have "componentId" prop');
|
|
121
|
-
|
|
120
|
+
dataItem.files?.forEach(file => {
|
|
122
121
|
if (!file.path) throw new Error('expect file to have "path" prop');
|
|
123
122
|
if (file.content) {
|
|
124
123
|
file.content = Buffer.from(file.content, 'base64').toString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_componentIssues","_bitError","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","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","forceDeploy","disableTagAndSnapPipelines","BitError","snapDataPerCompRaw","parseData","snapFromScope","dataParsed","JSON","parse","err","Error","Array","isArray","forEach","dataItem","_dataItem$files","componentId","files","file","path","content","Buffer","from","toString","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};\n\ntype SnapFromScopeOptions = {\n push?: boolean;\n lane?: string;\n ignoreIssues?: string;\n disableSnapPipeline?: boolean;\n forceDeploy?: 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 to update their versions, e.g. [teambit/compiler@1.0.0, teambit/tester@1.0.0]\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}\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 ['', 'force-deploy', 'DEPRECATED. use --ignore-build-error instead'],\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 ['j', 'json', 'output as json format'],\n ] as CommandOptions;\n loader = true;\n private = true;\n migration = true;\n\n constructor(private snapping: SnappingMain, private logger: Logger) {}\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 forceDeploy = false,\n }: SnapFromScopeOptions\n ) {\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (forceDeploy) {\n ignoreBuildErrors = true;\n }\n if (disableTagAndSnapPipelines && ignoreBuildErrors) {\n throw new BitError('you can use either ignore-build-errors or disable-snap-pipeline, but not both');\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 });\n\n return results;\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,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF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,6CAA6C,CAAC;MACzF,CAAAK,eAAA,GAAAD,QAAQ,CAACG,KAAK,cAAAF,eAAA,eAAdA,eAAA,CAAgBF,OAAO,CAAEK,IAAI,IAAK;QAChC,IAAI,CAACA,IAAI,CAACC,IAAI,EAAE,MAAM,IAAIT,KAAK,CAAC,iCAAiC,CAAC;QAClE,IAAIQ,IAAI,CAACE,OAAO,EAAE;UAChBF,IAAI,CAACE,OAAO,GAAGC,MAAM,CAACC,IAAI,CAACJ,IAAI,CAACE,OAAO,EAAE,QAAQ,CAAC,CAACG,QAAQ,CAAC,CAAC;QAC/D;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAOjB,UAAU;EACnB;AACF;AAACkB,OAAA,CAAAnD,gBAAA,GAAAA,gBAAA"}
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_componentIssues","_bitError","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","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","forceDeploy","disableTagAndSnapPipelines","BitError","snapDataPerCompRaw","parseData","snapFromScope","dataParsed","JSON","parse","err","Error","Array","isArray","forEach","dataItem","componentId","files","file","path","content","Buffer","from","toString","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};\n\ntype SnapFromScopeOptions = {\n push?: boolean;\n lane?: string;\n ignoreIssues?: string;\n disableSnapPipeline?: boolean;\n forceDeploy?: 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 to update their versions, e.g. [teambit/compiler@1.0.0, teambit/tester@1.0.0]\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}\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 ['', 'force-deploy', 'DEPRECATED. use --ignore-build-error instead'],\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 ['j', 'json', 'output as json format'],\n ] as CommandOptions;\n loader = true;\n private = true;\n migration = true;\n\n constructor(private snapping: SnappingMain, private logger: Logger) {}\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 forceDeploy = false,\n }: SnapFromScopeOptions\n ) {\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (forceDeploy) {\n ignoreBuildErrors = true;\n }\n if (disableTagAndSnapPipelines && ignoreBuildErrors) {\n throw new BitError('you can use either ignore-build-errors or disable-snap-pipeline, but not both');\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 });\n\n return results;\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,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAX,GAAA,CAAAI,GAAA,IAAAC,KAAA,WAAAL,GAAA;AAAA,SAAAM,e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C;IACJ,CAAC,CAAC;IAEF,OAAOhB,UAAU;EACnB;AACF;AAACiB,OAAA,CAAAlD,gBAAA,GAAAA,gBAAA"}
|
|
@@ -24,7 +24,7 @@ import Version, { Log } from '@teambit/legacy/dist/scope/models/version';
|
|
|
24
24
|
import { BasicTagParams } from './tag-model-component';
|
|
25
25
|
import { TagDataPerCompRaw } from './tag-from-scope.cmd';
|
|
26
26
|
import { SnapDataPerCompRaw, FileData } from './snap-from-scope.cmd';
|
|
27
|
-
export
|
|
27
|
+
export type TagDataPerComp = {
|
|
28
28
|
componentId: ComponentID;
|
|
29
29
|
dependencies: ComponentID[];
|
|
30
30
|
versionToTag?: string;
|
|
@@ -32,7 +32,7 @@ export declare type TagDataPerComp = {
|
|
|
32
32
|
message?: string;
|
|
33
33
|
isNew?: boolean;
|
|
34
34
|
};
|
|
35
|
-
export
|
|
35
|
+
export type SnapDataParsed = {
|
|
36
36
|
componentId: ComponentID;
|
|
37
37
|
dependencies: ComponentID[];
|
|
38
38
|
aspects?: Record<string, any>;
|
|
@@ -46,22 +46,22 @@ export declare type SnapDataParsed = {
|
|
|
46
46
|
type: 'runtime' | 'dev' | 'peer';
|
|
47
47
|
}[];
|
|
48
48
|
};
|
|
49
|
-
export
|
|
49
|
+
export type SnapResults = BasicTagResults & {
|
|
50
50
|
snappedComponents: ConsumerComponent[];
|
|
51
51
|
autoSnappedResults: AutoTagResult[];
|
|
52
52
|
laneName: string | null;
|
|
53
53
|
};
|
|
54
|
-
export
|
|
54
|
+
export type SnapFromScopeResults = {
|
|
55
55
|
snappedIds: string[];
|
|
56
56
|
exportedIds?: string[];
|
|
57
57
|
};
|
|
58
|
-
export
|
|
58
|
+
export type TagResults = BasicTagResults & {
|
|
59
59
|
taggedComponents: ConsumerComponent[];
|
|
60
60
|
autoTaggedResults: AutoTagResult[];
|
|
61
61
|
isSoftTag: boolean;
|
|
62
62
|
publishedPackages: string[];
|
|
63
63
|
};
|
|
64
|
-
export
|
|
64
|
+
export type BasicTagResults = {
|
|
65
65
|
warnings: string[];
|
|
66
66
|
newComponents: ComponentIdList;
|
|
67
67
|
removedComponents?: ComponentIdList;
|
|
@@ -173,7 +173,7 @@ export declare class SnappingMain {
|
|
|
173
173
|
private updateSourceFiles;
|
|
174
174
|
updateDependenciesVersionsOfComponent(component: Component, dependencies: ComponentID[], currentBitIds: ComponentID[]): Promise<void>;
|
|
175
175
|
private getComponentsToTag;
|
|
176
|
-
static slots:
|
|
176
|
+
static slots: any[];
|
|
177
177
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
178
178
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
179
179
|
static provider([workspace, cli, loggerMain, issues, insights, dependencyResolver, scope, exporter, builder, importer, globalConfig, deps,]: [
|
|
@@ -340,6 +340,13 @@ function _flattenedEdges() {
|
|
|
340
340
|
};
|
|
341
341
|
return data;
|
|
342
342
|
}
|
|
343
|
+
function _snapDistanceCmd() {
|
|
344
|
+
const data = require("./snap-distance-cmd");
|
|
345
|
+
_snapDistanceCmd = function () {
|
|
346
|
+
return data;
|
|
347
|
+
};
|
|
348
|
+
return data;
|
|
349
|
+
}
|
|
343
350
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
344
351
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
345
352
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -351,7 +358,6 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
351
358
|
const HooksManagerInstance = _hooks().default.getInstance();
|
|
352
359
|
class SnappingMain {
|
|
353
360
|
constructor(workspace, logger, issues, insights, dependencyResolver, scope, exporter, builder, importer, deps) {
|
|
354
|
-
var _this$scope;
|
|
355
361
|
this.workspace = workspace;
|
|
356
362
|
this.logger = logger;
|
|
357
363
|
this.issues = issues;
|
|
@@ -363,7 +369,7 @@ class SnappingMain {
|
|
|
363
369
|
this.importer = importer;
|
|
364
370
|
this.deps = deps;
|
|
365
371
|
_defineProperty(this, "objectsRepo", void 0);
|
|
366
|
-
this.objectsRepo =
|
|
372
|
+
this.objectsRepo = this.scope?.legacyScope?.objects;
|
|
367
373
|
}
|
|
368
374
|
|
|
369
375
|
/**
|
|
@@ -464,12 +470,12 @@ class SnappingMain {
|
|
|
464
470
|
removedComponents
|
|
465
471
|
};
|
|
466
472
|
const postHook = isAll ? _constants().POST_TAG_ALL_HOOK : _constants().POST_TAG_HOOK;
|
|
467
|
-
HooksManagerInstance
|
|
473
|
+
HooksManagerInstance?.triggerHook(postHook, tagResults);
|
|
468
474
|
_analytics().Analytics.setExtraData('num_components',
|
|
469
475
|
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
470
476
|
_ramda().default.concat(tagResults.taggedComponents, tagResults.autoTaggedResults, tagResults.newComponents).length);
|
|
471
477
|
await consumer.onDestroy(`tag (message: ${message || 'N/A'})`);
|
|
472
|
-
await
|
|
478
|
+
await stagedConfig?.write();
|
|
473
479
|
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
474
480
|
return tagResults;
|
|
475
481
|
}
|
|
@@ -498,12 +504,11 @@ class SnappingMain {
|
|
|
498
504
|
});
|
|
499
505
|
const deps = (0, _lodash().compact)(tagDataPerComp.map(t => t.dependencies).flat()).map(dep => dep.changeVersion(_constants().LATEST));
|
|
500
506
|
const additionalComponentIdsToFetch = await Promise.all(componentIds.map(async id => {
|
|
501
|
-
var _modelComp$getRef;
|
|
502
507
|
if (!id.hasVersion()) return null;
|
|
503
508
|
const modelComp = await this.scope.getBitObjectModelComponent(id);
|
|
504
509
|
if (!modelComp) throw new Error(`unable to find ModelComponent of ${id.toString()}`);
|
|
505
510
|
if (!modelComp.head) return null;
|
|
506
|
-
if (
|
|
511
|
+
if (modelComp.getRef(id.version)?.isEqual(modelComp.head)) return null;
|
|
507
512
|
if (!params.ignoreNewestVersion) {
|
|
508
513
|
throw new (_bitError().BitError)(`unable to tag "${id.toString()}", this version is older than the head ${modelComp.head.toString()}.
|
|
509
514
|
if you're willing to lose the history from the head to the specified version, use --ignore-newest-version flag`);
|
|
@@ -626,13 +631,12 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
626
631
|
// for new components these are not needed. coz when generating them we already add the aspects and the files.
|
|
627
632
|
// the dependencies are calculated later and they're provided by "newDependencies" prop (not "dependencies").
|
|
628
633
|
await Promise.all(existingComponents.map(async comp => {
|
|
629
|
-
var _snapData$files;
|
|
630
634
|
const snapData = getSnapData(comp.id);
|
|
631
635
|
if (snapData.aspects) await this.scope.addAspectsFromConfigObject(comp, snapData.aspects);
|
|
632
636
|
if (snapData.dependencies.length) {
|
|
633
637
|
await this.updateDependenciesVersionsOfComponent(comp, snapData.dependencies, componentIds);
|
|
634
638
|
}
|
|
635
|
-
if (
|
|
639
|
+
if (snapData.files?.length) {
|
|
636
640
|
await this.updateSourceFiles(comp, snapData.files);
|
|
637
641
|
}
|
|
638
642
|
}));
|
|
@@ -757,7 +761,7 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
757
761
|
const currentLane = consumer.getCurrentLaneId();
|
|
758
762
|
snapResults.laneName = currentLane.isDefault() ? null : currentLane.toString();
|
|
759
763
|
await consumer.onDestroy(`snap (message: ${message || 'N/A'})`);
|
|
760
|
-
await
|
|
764
|
+
await stagedConfig?.write();
|
|
761
765
|
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
762
766
|
return snapResults;
|
|
763
767
|
async function getIdsToSnap(workspace) {
|
|
@@ -816,11 +820,10 @@ there are matching among unmodified components thought. consider using --unmodif
|
|
|
816
820
|
const softTaggedComponentsIds = this.workspace.filter.bySoftTagged();
|
|
817
821
|
const idsToRemoveSoftTags = componentPattern ? await this.workspace.filterIdsFromPoolIdsByPattern(componentPattern, softTaggedComponentsIds) : softTaggedComponentsIds;
|
|
818
822
|
return (0, _lodash().compact)(idsToRemoveSoftTags.map(componentId => {
|
|
819
|
-
var _componentMap$nextVer;
|
|
820
823
|
const componentMap = consumer.bitMap.getComponent(componentId, {
|
|
821
824
|
ignoreVersion: true
|
|
822
825
|
});
|
|
823
|
-
const removedVersion =
|
|
826
|
+
const removedVersion = componentMap.nextVersion?.version;
|
|
824
827
|
if (!removedVersion) return null;
|
|
825
828
|
componentMap.clearNextVersion();
|
|
826
829
|
return {
|
|
@@ -1044,10 +1047,9 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1044
1047
|
}
|
|
1045
1048
|
_getPublishedPackages(components) {
|
|
1046
1049
|
const publishedPackages = components.map(comp => {
|
|
1047
|
-
var _builderExt$data, _pkgData$data;
|
|
1048
1050
|
const builderExt = comp.extensions.findCoreExtension(_constants().Extensions.builder);
|
|
1049
|
-
const pkgData = builderExt
|
|
1050
|
-
return pkgData
|
|
1051
|
+
const pkgData = builderExt?.data?.aspectsData?.find(a => a.aspectId === _constants().Extensions.pkg);
|
|
1052
|
+
return pkgData?.data?.publishedPackage;
|
|
1051
1053
|
});
|
|
1052
1054
|
return (0, _lodash().compact)(publishedPackages);
|
|
1053
1055
|
}
|
|
@@ -1170,16 +1172,13 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1170
1172
|
// ignore all issues
|
|
1171
1173
|
return;
|
|
1172
1174
|
}
|
|
1173
|
-
const issuesToIgnoreFromFlag =
|
|
1175
|
+
const issuesToIgnoreFromFlag = ignoreIssues?.split(',').map(issue => issue.trim()) || [];
|
|
1174
1176
|
const issuesToIgnoreFromConfig = this.issues.getIssuesToIgnoreGlobally();
|
|
1175
1177
|
const issuesToIgnore = [...issuesToIgnoreFromFlag, ...issuesToIgnoreFromConfig];
|
|
1176
1178
|
await this.issues.triggerAddComponentIssues(components, issuesToIgnore);
|
|
1177
1179
|
this.issues.removeIgnoredIssuesFromComponents(components, issuesToIgnore);
|
|
1178
1180
|
const legacyComponents = components.map(c => c.state._consumer);
|
|
1179
|
-
const componentsWithBlockingIssues = legacyComponents.filter(component =>
|
|
1180
|
-
var _component$issues;
|
|
1181
|
-
return (_component$issues = component.issues) === null || _component$issues === void 0 ? void 0 : _component$issues.shouldBlockTagging();
|
|
1182
|
-
});
|
|
1181
|
+
const componentsWithBlockingIssues = legacyComponents.filter(component => component.issues?.shouldBlockTagging());
|
|
1183
1182
|
if (!_ramda().default.isEmpty(componentsWithBlockingIssues)) {
|
|
1184
1183
|
throw new (_componentsHaveIssues().ComponentsHaveIssues)(componentsWithBlockingIssues);
|
|
1185
1184
|
}
|
|
@@ -1265,9 +1264,8 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1265
1264
|
deps.forEach(dep => {
|
|
1266
1265
|
const updatedBitId = updatedIds.searchWithoutVersion(dep.id);
|
|
1267
1266
|
if (updatedBitId) {
|
|
1268
|
-
var _dependenciesList$fin, _dependenciesList$fin2;
|
|
1269
1267
|
const depIdStr = dep.id.toString();
|
|
1270
|
-
const packageName =
|
|
1268
|
+
const packageName = dependenciesList.findDependency(depIdStr)?.getPackageName?.();
|
|
1271
1269
|
if (!packageName) {
|
|
1272
1270
|
throw new Error(`unable to find the package-name of "${depIdStr}" dependency inside the dependency-resolver data of "${componentIdStr}"`);
|
|
1273
1271
|
}
|
|
@@ -1367,7 +1365,8 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1367
1365
|
const tagFromScopeCmd = new (_tagFromScope().TagFromScopeCmd)(snapping, logger);
|
|
1368
1366
|
const snapFromScopeCmd = new (_snapFromScope().SnapFromScopeCmd)(snapping, logger);
|
|
1369
1367
|
const resetCmd = new (_resetCmd().default)(snapping);
|
|
1370
|
-
|
|
1368
|
+
const snapDistanceCmd = new (_snapDistanceCmd().SnapDistanceCmd)(scope);
|
|
1369
|
+
cli.register(tagCmd, snapCmd, resetCmd, tagFromScopeCmd, snapFromScopeCmd, snapDistanceCmd);
|
|
1371
1370
|
return snapping;
|
|
1372
1371
|
}
|
|
1373
1372
|
}
|