@teambit/snapping 0.0.216 → 0.0.220
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 +1 -1
- package/dist/index.js.map +1 -1
- package/dist/snap-cmd.js +1 -1
- package/dist/snap-cmd.js.map +1 -1
- package/dist/snap-from-scope.cmd.d.ts +32 -0
- package/dist/snap-from-scope.cmd.js +143 -0
- package/dist/snap-from-scope.cmd.js.map +1 -0
- package/dist/snapping.main.runtime.d.ts +23 -3
- package/dist/snapping.main.runtime.js +122 -2
- package/dist/snapping.main.runtime.js.map +1 -1
- package/dist/tag-cmd.js.map +1 -1
- package/dist/tag-from-scope.cmd.js +2 -2
- package/dist/tag-from-scope.cmd.js.map +1 -1
- package/dist/tag-model-component.js +1 -0
- package/dist/tag-model-component.js.map +1 -1
- package/package-tar/teambit-snapping-0.0.220.tgz +0 -0
- package/package.json +16 -15
- /package/{preview-1668655447623.js → preview-1668828328298.js} +0 -0
- package/package-tar/teambit-snapping-0.0.216.tgz +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SnappingAspect } from './snapping.aspect';
|
|
2
|
-
export type { SnappingMain } from './snapping.main.runtime';
|
|
2
|
+
export type { SnappingMain, TagResults, SnapResults } from './snapping.main.runtime';
|
|
3
3
|
export default SnappingAspect;
|
|
4
4
|
export { SnappingAspect };
|
|
5
5
|
export type { onTagIdTransformer } from './tag-model-component';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SnappingAspect"],"sources":["index.ts"],"sourcesContent":["import { SnappingAspect } from './snapping.aspect';\n\nexport type { SnappingMain } from './snapping.main.runtime';\nexport default SnappingAspect;\nexport { SnappingAspect };\nexport type { onTagIdTransformer } from './tag-model-component';\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAmD,eAGpCA,0BAAc;AAAA"}
|
|
1
|
+
{"version":3,"names":["SnappingAspect"],"sources":["index.ts"],"sourcesContent":["import { SnappingAspect } from './snapping.aspect';\n\nexport type { SnappingMain, TagResults, SnapResults } from './snapping.main.runtime';\nexport default SnappingAspect;\nexport { SnappingAspect };\nexport type { onTagIdTransformer } from './tag-model-component';\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAmD,eAGpCA,0BAAc;AAAA"}
|
package/dist/snap-cmd.js
CHANGED
|
@@ -61,7 +61,7 @@ class SnapCmd {
|
|
|
61
61
|
description: `${_constants().COMPONENT_PATTERN_HELP}. By default, all new and modified components are snapped.`
|
|
62
62
|
}]);
|
|
63
63
|
(0, _defineProperty2().default)(this, "alias", '');
|
|
64
|
-
(0, _defineProperty2().default)(this, "options", [['m', 'message <message>', 'log message describing the latest changes'], ['', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'], ['', 'unmerged', 'EXPERIMENTAL. complete a merge process by snapping the unmerged components'], ['', 'build', '
|
|
64
|
+
(0, _defineProperty2().default)(this, "options", [['m', 'message <message>', 'log message describing the latest changes'], ['', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'], ['', 'unmerged', 'EXPERIMENTAL. complete a merge process by snapping the unmerged components'], ['b', 'build', 'EXPERIMENTAL. not needed for now. run the build pipeline in case the feature-flag build-on-ci is enabled'], ['', 'skip-tests', 'skip running component tests during snap process'], ['', 'skip-auto-snap', 'skip auto snapping dependents'], ['', 'disable-snap-pipeline', 'skip the snap pipeline'], ['', 'force-deploy', 'run the deploy pipeline although the build failed'], ['i', 'ignore-issues [issues]', `ignore component issues (shown in "bit status" as "issues found"), issues to ignore:
|
|
65
65
|
[${Object.keys(_componentIssues().IssuesClasses).join(', ')}]
|
|
66
66
|
to ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify "*".`], ['a', 'all', 'DEPRECATED (not needed anymore, it is the default now). snap all new and modified components'], ['f', 'force', 'DEPRECATED (use "--skip-tests" or "--unmodified" instead). force-snap even if tests are failing and even when component has not changed']]);
|
|
67
67
|
(0, _defineProperty2().default)(this, "loader", true);
|
package/dist/snap-cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SnapCmd","constructor","docsDomain","snapping","logger","name","description","COMPONENT_PATTERN_HELP","Object","keys","IssuesClasses","join","extendedDescription","WILDCARD_HELP","report","pattern","message","all","force","unmerged","ignoreIssues","build","skipTests","skipAutoSnap","disableSnapPipeline","forceDeploy","unmodified","isFeatureEnabled","BUILD_ON_CI","Boolean","disableTagAndSnapPipelines","BitError","consoleWarning","results","snap","chalk","yellow","NOTHING_TO_SNAP_MSG","snappedComponents","autoSnappedResults","warnings","newComponents","laneName","changedComponents","filter","component","searchWithoutVersion","id","addedComponents","autoTaggedCount","length","warningsOutput","tagExplanation","outputComponents","comps","map","componentOutput","toString","autoTag","result","triggeredBy","searchWithoutScopeAndVersion","autoTagComp","a","AUTO_SNAPPED_MSG","outputIfExists","label","explanation","components","underline","laneStr","green"],"sources":["snap-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { isFeatureEnabled, BUILD_ON_CI } from '@teambit/legacy/dist/api/consumer/lib/feature-toggle';\nimport {\n WILDCARD_HELP,\n NOTHING_TO_SNAP_MSG,\n AUTO_SNAPPED_MSG,\n COMPONENT_PATTERN_HELP,\n} from '@teambit/legacy/dist/constants';\nimport { BitError } from '@teambit/bit-error';\nimport { Logger } from '@teambit/logger';\nimport { SnapResults } from '@teambit/legacy/dist/api/consumer/lib/snap';\nimport { SnappingMain } from './snapping.main.runtime';\n\nexport class SnapCmd implements Command {\n name = 'snap [component-pattern]';\n description = 'EXPERIMENTAL. create an immutable and exportable component snapshot (no release version)';\n extendedDescription: string;\n arguments = [\n {\n name: 'component-pattern',\n description: `${COMPONENT_PATTERN_HELP}. By default, all new and modified components are snapped.`,\n },\n ];\n alias = '';\n options = [\n ['m', 'message <message>', 'log message describing the latest changes'],\n ['', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'],\n ['', 'unmerged', 'EXPERIMENTAL. complete a merge process by snapping the unmerged components'],\n ['', 'build', 'Harmony only. run the pipeline build and complete the tag'],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n ['', 'skip-auto-snap', 'skip auto snapping dependents'],\n ['', 'disable-snap-pipeline', 'skip the snap pipeline'],\n ['', 'force-deploy', 'Harmony only. run the deploy pipeline although the build failed'],\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, it is the default now). snap all new and modified components'],\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 private = true;\n migration = true;\n\n constructor(docsDomain: string, private snapping: SnappingMain, private logger: Logger) {\n this.extendedDescription = `https://${docsDomain}/components/snaps\n${WILDCARD_HELP('snap')}`;\n }\n\n async report(\n [pattern]: string[],\n {\n message = '',\n all = false,\n force = false,\n unmerged = false,\n ignoreIssues,\n build,\n skipTests = false,\n skipAutoSnap = false,\n disableSnapPipeline = false,\n forceDeploy = false,\n unmodified = false,\n }: {\n message?: string;\n all?: boolean;\n force?: boolean;\n unmerged?: boolean;\n ignoreIssues?: string;\n build?: boolean;\n skipTests?: boolean;\n skipAutoSnap?: boolean;\n disableSnapPipeline?: boolean;\n forceDeploy?: boolean;\n unmodified?: boolean;\n }\n ) {\n build = isFeatureEnabled(BUILD_ON_CI) ? Boolean(build) : true;\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (disableTagAndSnapPipelines && forceDeploy) {\n throw new BitError('you can use either force-deploy or disable-snap-pipeline, but not both');\n }\n\n if (all) {\n this.logger.consoleWarning(\n `--all is deprecated, please omit it. \"bit snap\" by default will snap all new and modified components`\n );\n }\n if (force) {\n this.logger.consoleWarning(\n `--force is deprecated, use either --skip-tests or --unmodified depending on the use case`\n );\n if (pattern) unmodified = true;\n }\n if (!message) {\n this.logger.consoleWarning(\n `--message will be mandatory in the next few releases. make sure to add a message with your snap`\n );\n }\n\n const results = await this.snapping.snap({\n pattern,\n message,\n unmerged,\n ignoreIssues,\n build,\n skipTests,\n skipAutoSnap,\n disableTagAndSnapPipelines,\n forceDeploy,\n unmodified,\n });\n\n if (!results) return chalk.yellow(NOTHING_TO_SNAP_MSG);\n const { snappedComponents, autoSnappedResults, warnings, newComponents, laneName }: SnapResults = results;\n const changedComponents = snappedComponents.filter(\n (component) => !newComponents.searchWithoutVersion(component.id)\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 tagExplanation = `\\n(use \"bit export\" to push these components to a remote\")\n(use \"bit reset\" to unstage versions)\\n`;\n\n const outputComponents = (comps) => {\n return comps\n .map((component) => {\n let componentOutput = ` > ${component.id.toString()}`;\n const autoTag = autoSnappedResults.filter((result) =>\n result.triggeredBy.searchWithoutScopeAndVersion(component.id)\n );\n if (autoTag.length) {\n const autoTagComp = autoTag.map((a) => a.component.id.toString());\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 warningsOutput +\n chalk.green(`${snappedComponents.length + autoTaggedCount} component(s) snapped${laneStr}`) +\n tagExplanation +\n outputIfExists('new components', 'first version for components', addedComponents) +\n outputIfExists('changed components', 'components that got a version bump', changedComponents)\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,OAAO,CAAoB;EAsCtCC,WAAW,CAACC,UAAkB,EAAUC,QAAsB,EAAUC,MAAc,EAAE;IAAA,KAAhDD,QAAsB,GAAtBA,QAAsB;IAAA,KAAUC,MAAc,GAAdA,MAAc;IAAA,8CArC/E,0BAA0B;IAAA,qDACnB,0FAA0F;IAAA;IAAA,mDAE5F,CACV;MACEC,IAAI,EAAE,mBAAmB;MACzBC,WAAW,EAAG,GAAEC,mCAAuB;IACzC,CAAC,CACF;IAAA,+CACO,EAAE;IAAA,iDACA,CACR,CAAC,GAAG,EAAE,mBAAmB,EAAE,2CAA2C,CAAC,EACvE,CAAC,EAAE,EAAE,YAAY,EAAE,0FAA0F,CAAC,EAC9G,CAAC,EAAE,EAAE,UAAU,EAAE,4EAA4E,CAAC,EAC9F,CAAC,EAAE,EAAE,OAAO,EAAE,2DAA2D,CAAC,EAC1E,CAAC,EAAE,EAAE,YAAY,EAAE,kDAAkD,CAAC,EACtE,CAAC,EAAE,EAAE,gBAAgB,EAAE,+BAA+B,CAAC,EACvD,CAAC,EAAE,EAAE,uBAAuB,EAAE,wBAAwB,CAAC,EACvD,CAAC,EAAE,EAAE,cAAc,EAAE,iEAAiE,CAAC,EACvF,CACE,GAAG,EACH,wBAAwB,EACvB;AACP,GAAGC,MAAM,CAACC,IAAI,CAACC,gCAAa,CAAC,CAACC,IAAI,CAAC,IAAI,CAAE;AACzC,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C,IAAKA,CAAC,CAAClB,SAAS,CAACE,EAAE,CAACU,QAAQ,EAAE,CAAC;UACjED,eAAe,IAAK,YAAWQ,6BAAiB,KAAIF,WAAW,CAACZ,MAAO;AACnF,cAAcY,WAAW,CAACnD,IAAI,CAAC,gBAAgB,CAAE,EAAC;QACxC;QACA,OAAO6C,eAAe;MACxB,CAAC,CAAC,CACD7C,IAAI,CAAC,IAAI,CAAC;IACf,CAAC;IAED,MAAMsD,cAAc,GAAG,CAACC,KAAK,EAAEC,WAAW,EAAEC,UAAU,KAAK;MACzD,IAAI,CAACA,UAAU,CAAClB,MAAM,EAAE,OAAO,EAAE;MACjC,OAAQ,KAAIf,gBAAK,CAACkC,SAAS,CAACH,KAAK,CAAE,MAAKC,WAAY,MAAKd,gBAAgB,CAACe,UAAU,CAAE,IAAG;IAC3F,CAAC;IACD,MAAME,OAAO,GAAG5B,QAAQ,GAAI,QAAOA,QAAS,QAAO,GAAG,EAAE;IAExD,OACES,cAAc,GACdhB,gBAAK,CAACoC,KAAK,CAAE,GAAEjC,iBAAiB,CAACY,MAAM,GAAGD,eAAgB,wBAAuBqB,OAAQ,EAAC,CAAC,GAC3FlB,cAAc,GACda,cAAc,CAAC,gBAAgB,EAAE,8BAA8B,EAAEjB,eAAe,CAAC,GACjFiB,cAAc,CAAC,oBAAoB,EAAE,oCAAoC,EAAEtB,iBAAiB,CAAC;EAEjG;AACF;AAAC"}
|
|
1
|
+
{"version":3,"names":["SnapCmd","constructor","docsDomain","snapping","logger","name","description","COMPONENT_PATTERN_HELP","Object","keys","IssuesClasses","join","extendedDescription","WILDCARD_HELP","report","pattern","message","all","force","unmerged","ignoreIssues","build","skipTests","skipAutoSnap","disableSnapPipeline","forceDeploy","unmodified","isFeatureEnabled","BUILD_ON_CI","Boolean","disableTagAndSnapPipelines","BitError","consoleWarning","results","snap","chalk","yellow","NOTHING_TO_SNAP_MSG","snappedComponents","autoSnappedResults","warnings","newComponents","laneName","changedComponents","filter","component","searchWithoutVersion","id","addedComponents","autoTaggedCount","length","warningsOutput","tagExplanation","outputComponents","comps","map","componentOutput","toString","autoTag","result","triggeredBy","searchWithoutScopeAndVersion","autoTagComp","a","AUTO_SNAPPED_MSG","outputIfExists","label","explanation","components","underline","laneStr","green"],"sources":["snap-cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { isFeatureEnabled, BUILD_ON_CI } from '@teambit/legacy/dist/api/consumer/lib/feature-toggle';\nimport {\n WILDCARD_HELP,\n NOTHING_TO_SNAP_MSG,\n AUTO_SNAPPED_MSG,\n COMPONENT_PATTERN_HELP,\n} from '@teambit/legacy/dist/constants';\nimport { BitError } from '@teambit/bit-error';\nimport { Logger } from '@teambit/logger';\nimport { SnappingMain, SnapResults } from './snapping.main.runtime';\n\nexport class SnapCmd implements Command {\n name = 'snap [component-pattern]';\n description = 'EXPERIMENTAL. create an immutable and exportable component snapshot (no release version)';\n extendedDescription: string;\n arguments = [\n {\n name: 'component-pattern',\n description: `${COMPONENT_PATTERN_HELP}. By default, all new and modified components are snapped.`,\n },\n ];\n alias = '';\n options = [\n ['m', 'message <message>', 'log message describing the latest changes'],\n ['', 'unmodified', 'include unmodified components (by default, only new and modified components are snapped)'],\n ['', 'unmerged', 'EXPERIMENTAL. complete a merge process by snapping the unmerged components'],\n [\n 'b',\n 'build',\n 'EXPERIMENTAL. not needed for now. run the build pipeline in case the feature-flag build-on-ci is enabled',\n ],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n ['', 'skip-auto-snap', 'skip auto snapping dependents'],\n ['', 'disable-snap-pipeline', 'skip the snap pipeline'],\n ['', 'force-deploy', 'run the deploy pipeline although the build failed'],\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, it is the default now). snap all new and modified components'],\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 private = true;\n migration = true;\n\n constructor(docsDomain: string, private snapping: SnappingMain, private logger: Logger) {\n this.extendedDescription = `https://${docsDomain}/components/snaps\n${WILDCARD_HELP('snap')}`;\n }\n\n async report(\n [pattern]: string[],\n {\n message = '',\n all = false,\n force = false,\n unmerged = false,\n ignoreIssues,\n build,\n skipTests = false,\n skipAutoSnap = false,\n disableSnapPipeline = false,\n forceDeploy = false,\n unmodified = false,\n }: {\n message?: string;\n all?: boolean;\n force?: boolean;\n unmerged?: boolean;\n ignoreIssues?: string;\n build?: boolean;\n skipTests?: boolean;\n skipAutoSnap?: boolean;\n disableSnapPipeline?: boolean;\n forceDeploy?: boolean;\n unmodified?: boolean;\n }\n ) {\n build = isFeatureEnabled(BUILD_ON_CI) ? Boolean(build) : true;\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (disableTagAndSnapPipelines && forceDeploy) {\n throw new BitError('you can use either force-deploy or disable-snap-pipeline, but not both');\n }\n\n if (all) {\n this.logger.consoleWarning(\n `--all is deprecated, please omit it. \"bit snap\" by default will snap all new and modified components`\n );\n }\n if (force) {\n this.logger.consoleWarning(\n `--force is deprecated, use either --skip-tests or --unmodified depending on the use case`\n );\n if (pattern) unmodified = true;\n }\n if (!message) {\n this.logger.consoleWarning(\n `--message will be mandatory in the next few releases. make sure to add a message with your snap`\n );\n }\n\n const results = await this.snapping.snap({\n pattern,\n message,\n unmerged,\n ignoreIssues,\n build,\n skipTests,\n skipAutoSnap,\n disableTagAndSnapPipelines,\n forceDeploy,\n unmodified,\n });\n\n if (!results) return chalk.yellow(NOTHING_TO_SNAP_MSG);\n const { snappedComponents, autoSnappedResults, warnings, newComponents, laneName }: SnapResults = results;\n const changedComponents = snappedComponents.filter(\n (component) => !newComponents.searchWithoutVersion(component.id)\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 tagExplanation = `\\n(use \"bit export\" to push these components to a remote\")\n(use \"bit reset\" to unstage versions)\\n`;\n\n const outputComponents = (comps) => {\n return comps\n .map((component) => {\n let componentOutput = ` > ${component.id.toString()}`;\n const autoTag = autoSnappedResults.filter((result) =>\n result.triggeredBy.searchWithoutScopeAndVersion(component.id)\n );\n if (autoTag.length) {\n const autoTagComp = autoTag.map((a) => a.component.id.toString());\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 warningsOutput +\n chalk.green(`${snappedComponents.length + autoTaggedCount} component(s) snapped${laneStr}`) +\n tagExplanation +\n outputIfExists('new components', 'first version for components', addedComponents) +\n outputIfExists('changed components', 'components that got a version bump', changedComponents)\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIO,MAAMA,OAAO,CAAoB;EA0CtCC,WAAW,CAACC,UAAkB,EAAUC,QAAsB,EAAUC,MAAc,EAAE;IAAA,KAAhDD,QAAsB,GAAtBA,QAAsB;IAAA,KAAUC,MA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AG;IAC3F,CAAC;IACD,MAAME,OAAO,GAAG5B,QAAQ,GAAI,QAAOA,QAAS,QAAO,GAAG,EAAE;IAExD,OACES,cAAc,GACdhB,gBAAK,CAACoC,KAAK,CAAE,GAAEjC,iBAAiB,CAACY,MAAM,GAAGD,eAAgB,wBAAuBqB,OAAQ,EAAC,CAAC,GAC3FlB,cAAc,GACda,cAAc,CAAC,gBAAgB,EAAE,8BAA8B,EAAEjB,eAAe,CAAC,GACjFiB,cAAc,CAAC,oBAAoB,EAAE,oCAAoC,EAAEtB,iBAAiB,CAAC;EAEjG;AACF;AAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import { Logger } from '@teambit/logger';
|
|
3
|
+
import { SnappingMain } from './snapping.main.runtime';
|
|
4
|
+
export declare type SnapDataPerCompRaw = {
|
|
5
|
+
componentId: string;
|
|
6
|
+
dependencies?: string[];
|
|
7
|
+
aspects?: Record<string, any>;
|
|
8
|
+
message?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare class SnapFromScopeCmd implements Command {
|
|
11
|
+
private snapping;
|
|
12
|
+
private logger;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
extendedDescription: string;
|
|
16
|
+
alias: string;
|
|
17
|
+
options: CommandOptions;
|
|
18
|
+
loader: boolean;
|
|
19
|
+
private: boolean;
|
|
20
|
+
migration: boolean;
|
|
21
|
+
constructor(snapping: SnappingMain, logger: Logger);
|
|
22
|
+
report([data]: [string], { push, message, ignoreIssues, build, skipTests, disableSnapPipeline, forceDeploy, }: {
|
|
23
|
+
push?: boolean;
|
|
24
|
+
message?: string;
|
|
25
|
+
ignoreIssues?: string;
|
|
26
|
+
build?: boolean;
|
|
27
|
+
skipTests?: boolean;
|
|
28
|
+
disableSnapPipeline?: boolean;
|
|
29
|
+
forceDeploy?: boolean;
|
|
30
|
+
}): Promise<string>;
|
|
31
|
+
private parseData;
|
|
32
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
require("core-js/modules/es.array.iterator.js");
|
|
5
|
+
require("core-js/modules/es.promise.js");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.SnapFromScopeCmd = void 0;
|
|
10
|
+
function _defineProperty2() {
|
|
11
|
+
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
+
_defineProperty2 = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
function _chalk() {
|
|
18
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
19
|
+
_chalk = function () {
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
function _componentIssues() {
|
|
25
|
+
const data = require("@teambit/component-issues");
|
|
26
|
+
_componentIssues = function () {
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
function _constants() {
|
|
32
|
+
const data = require("@teambit/legacy/dist/constants");
|
|
33
|
+
_constants = function () {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
function _bitError() {
|
|
39
|
+
const data = require("@teambit/bit-error");
|
|
40
|
+
_bitError = function () {
|
|
41
|
+
return data;
|
|
42
|
+
};
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
class SnapFromScopeCmd {
|
|
46
|
+
constructor(snapping, logger) {
|
|
47
|
+
this.snapping = snapping;
|
|
48
|
+
this.logger = logger;
|
|
49
|
+
(0, _defineProperty2().default)(this, "name", '_snap <data>');
|
|
50
|
+
(0, _defineProperty2().default)(this, "description", 'snap components from a bare-scope');
|
|
51
|
+
(0, _defineProperty2().default)(this, "extendedDescription", `this command should be running from a new bare scope, it first imports the components it needs and then processes the snap.
|
|
52
|
+
the input data is a stringified JSON of an array of the following object.
|
|
53
|
+
{
|
|
54
|
+
componentId: string; // ids always have scope, so it's safe to parse them from string
|
|
55
|
+
dependencies?: string[]; // e.g. [teambit/compiler@1.0.0, teambit/tester@1.0.0]
|
|
56
|
+
aspects?: Record<string,any> // e.g. { "teambit.react/react": {}, "teambit.envs/envs": { "env": "teambit.react/react" } }
|
|
57
|
+
message?: string; // tag-message.
|
|
58
|
+
}
|
|
59
|
+
an example of the final data: '[{"componentId":"ci.remote2/comp-b","message": "first snap"}]'
|
|
60
|
+
`);
|
|
61
|
+
(0, _defineProperty2().default)(this, "alias", '');
|
|
62
|
+
(0, _defineProperty2().default)(this, "options", [['', 'push', 'export the updated objects to the original scopes once done'], ['m', 'message <message>', 'log message describing the latest changes'], ['', 'build', 'run the build pipeline'], ['', 'skip-tests', 'skip running component tests during snap process'], ['', 'disable-snap-pipeline', 'skip the snap pipeline'], ['', 'force-deploy', 'run the deploy pipeline although the build failed'], ['i', 'ignore-issues [issues]', `ignore component issues (shown in "bit status" as "issues found"), issues to ignore:
|
|
63
|
+
[${Object.keys(_componentIssues().IssuesClasses).join(', ')}]
|
|
64
|
+
to ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify "*".`]]);
|
|
65
|
+
(0, _defineProperty2().default)(this, "loader", true);
|
|
66
|
+
(0, _defineProperty2().default)(this, "private", true);
|
|
67
|
+
(0, _defineProperty2().default)(this, "migration", true);
|
|
68
|
+
}
|
|
69
|
+
async report([data], {
|
|
70
|
+
push = false,
|
|
71
|
+
message = '',
|
|
72
|
+
ignoreIssues,
|
|
73
|
+
build = false,
|
|
74
|
+
skipTests = false,
|
|
75
|
+
disableSnapPipeline = false,
|
|
76
|
+
forceDeploy = false
|
|
77
|
+
}) {
|
|
78
|
+
const disableTagAndSnapPipelines = disableSnapPipeline;
|
|
79
|
+
if (disableTagAndSnapPipelines && forceDeploy) {
|
|
80
|
+
throw new (_bitError().BitError)('you can use either force-deploy or disable-snap-pipeline, but not both');
|
|
81
|
+
}
|
|
82
|
+
const snapDataPerCompRaw = this.parseData(data);
|
|
83
|
+
const results = await this.snapping.snapFromScope(snapDataPerCompRaw, {
|
|
84
|
+
push,
|
|
85
|
+
message,
|
|
86
|
+
ignoreIssues,
|
|
87
|
+
build,
|
|
88
|
+
skipTests,
|
|
89
|
+
disableTagAndSnapPipelines,
|
|
90
|
+
forceDeploy
|
|
91
|
+
});
|
|
92
|
+
if (!results) return _chalk().default.yellow(_constants().NOTHING_TO_SNAP_MSG);
|
|
93
|
+
const {
|
|
94
|
+
snappedComponents,
|
|
95
|
+
autoSnappedResults,
|
|
96
|
+
warnings,
|
|
97
|
+
newComponents,
|
|
98
|
+
laneName
|
|
99
|
+
} = results;
|
|
100
|
+
const changedComponents = snappedComponents.filter(component => !newComponents.searchWithoutVersion(component.id));
|
|
101
|
+
const addedComponents = snappedComponents.filter(component => newComponents.searchWithoutVersion(component.id));
|
|
102
|
+
const autoTaggedCount = autoSnappedResults ? autoSnappedResults.length : 0;
|
|
103
|
+
const warningsOutput = warnings && warnings.length ? `${_chalk().default.yellow(warnings.join('\n'))}\n\n` : '';
|
|
104
|
+
const tagExplanation = `\n(use "bit export" to push these components to a remote")
|
|
105
|
+
(use "bit reset" to unstage versions)\n`;
|
|
106
|
+
const outputComponents = comps => {
|
|
107
|
+
return comps.map(component => {
|
|
108
|
+
let componentOutput = ` > ${component.id.toString()}`;
|
|
109
|
+
const autoTag = autoSnappedResults.filter(result => result.triggeredBy.searchWithoutScopeAndVersion(component.id));
|
|
110
|
+
if (autoTag.length) {
|
|
111
|
+
const autoTagComp = autoTag.map(a => a.component.id.toString());
|
|
112
|
+
componentOutput += `\n ${_constants().AUTO_SNAPPED_MSG} (${autoTagComp.length} total):
|
|
113
|
+
${autoTagComp.join('\n ')}`;
|
|
114
|
+
}
|
|
115
|
+
return componentOutput;
|
|
116
|
+
}).join('\n');
|
|
117
|
+
};
|
|
118
|
+
const outputIfExists = (label, explanation, components) => {
|
|
119
|
+
if (!components.length) return '';
|
|
120
|
+
return `\n${_chalk().default.underline(label)}\n(${explanation})\n${outputComponents(components)}\n`;
|
|
121
|
+
};
|
|
122
|
+
const laneStr = laneName ? ` on "${laneName}" lane` : '';
|
|
123
|
+
return warningsOutput + _chalk().default.green(`${snappedComponents.length + autoTaggedCount} component(s) snapped${laneStr}`) + tagExplanation + outputIfExists('new components', 'first version for components', addedComponents) + outputIfExists('changed components', 'components that got a version bump', changedComponents);
|
|
124
|
+
}
|
|
125
|
+
parseData(data) {
|
|
126
|
+
let dataParsed;
|
|
127
|
+
try {
|
|
128
|
+
dataParsed = JSON.parse(data);
|
|
129
|
+
} catch (err) {
|
|
130
|
+
throw new Error(`failed parsing the data entered as JSON. err ${err.message}`);
|
|
131
|
+
}
|
|
132
|
+
if (!Array.isArray(dataParsed)) {
|
|
133
|
+
throw new Error('expect data to be an array');
|
|
134
|
+
}
|
|
135
|
+
dataParsed.forEach(dataItem => {
|
|
136
|
+
if (!dataItem.componentId) throw new Error('expect data item to have "componentId" prop');
|
|
137
|
+
});
|
|
138
|
+
return dataParsed;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.SnapFromScopeCmd = SnapFromScopeCmd;
|
|
142
|
+
|
|
143
|
+
//# sourceMappingURL=snap-from-scope.cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SnapFromScopeCmd","constructor","snapping","logger","Object","keys","IssuesClasses","join","report","data","push","message","ignoreIssues","build","skipTests","disableSnapPipeline","forceDeploy","disableTagAndSnapPipelines","BitError","snapDataPerCompRaw","parseData","results","snapFromScope","chalk","yellow","NOTHING_TO_SNAP_MSG","snappedComponents","autoSnappedResults","warnings","newComponents","laneName","changedComponents","filter","component","searchWithoutVersion","id","addedComponents","autoTaggedCount","length","warningsOutput","tagExplanation","outputComponents","comps","map","componentOutput","toString","autoTag","result","triggeredBy","searchWithoutScopeAndVersion","autoTagComp","a","AUTO_SNAPPED_MSG","outputIfExists","label","explanation","components","underline","laneStr","green","dataParsed","JSON","parse","err","Error","Array","isArray","forEach","dataItem","componentId"],"sources":["snap-from-scope.cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { NOTHING_TO_SNAP_MSG, AUTO_SNAPPED_MSG } from '@teambit/legacy/dist/constants';\nimport { BitError } from '@teambit/bit-error';\nimport { Logger } from '@teambit/logger';\nimport { SnappingMain, SnapResults } from './snapping.main.runtime';\n\nexport type SnapDataPerCompRaw = {\n componentId: string;\n dependencies?: string[];\n aspects?: Record<string, any>;\n message?: string;\n};\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[]; // 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}\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 ['', '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', 'run the deploy pipeline although the build failed'],\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 ] as CommandOptions;\n loader = true;\n private = true;\n migration = true;\n\n constructor(private snapping: SnappingMain, private logger: Logger) {}\n\n async report(\n [data]: [string],\n {\n push = false,\n message = '',\n ignoreIssues,\n build = false,\n skipTests = false,\n disableSnapPipeline = false,\n forceDeploy = false,\n }: {\n push?: boolean;\n message?: string;\n ignoreIssues?: string;\n build?: boolean;\n skipTests?: boolean;\n disableSnapPipeline?: boolean;\n forceDeploy?: boolean;\n }\n ) {\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (disableTagAndSnapPipelines && forceDeploy) {\n throw new BitError('you can use either force-deploy 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 ignoreIssues,\n build,\n skipTests,\n disableTagAndSnapPipelines,\n forceDeploy,\n });\n\n if (!results) return chalk.yellow(NOTHING_TO_SNAP_MSG);\n const { snappedComponents, autoSnappedResults, warnings, newComponents, laneName }: SnapResults = results;\n const changedComponents = snappedComponents.filter(\n (component) => !newComponents.searchWithoutVersion(component.id)\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 tagExplanation = `\\n(use \"bit export\" to push these components to a remote\")\n(use \"bit reset\" to unstage versions)\\n`;\n\n const outputComponents = (comps) => {\n return comps\n .map((component) => {\n let componentOutput = ` > ${component.id.toString()}`;\n const autoTag = autoSnappedResults.filter((result) =>\n result.triggeredBy.searchWithoutScopeAndVersion(component.id)\n );\n if (autoTag.length) {\n const autoTagComp = autoTag.map((a) => a.component.id.toString());\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 warningsOutput +\n chalk.green(`${snappedComponents.length + autoTaggedCount} component(s) snapped${laneStr}`) +\n tagExplanation +\n outputIfExists('new components', 'first version for components', addedComponents) +\n outputIfExists('changed components', 'components that got a version bump', changedComponents)\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 });\n return dataParsed;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAWO,MAAMA,gBAAgB,CAAoB;EAiC/CC,WAAW,CAASC,QAAsB,EAAUC,MAAc,EAAE;IAAA,KAAhDD,QAAsB,GAAtBA,QAAsB;IAAA,KAAUC,MAAc,GAAdA,MAAc;IAAA,8CAhC3D,cAAc;IAAA,qDACP,mCAAmC;IAAA,6DAC1B;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;IAAA,+CACS,EAAE;IAAA,iDACA,CACR,CAAC,EAAE,EAAE,MAAM,EAAE,6DAA6D,CAAC,EAC3E,CAAC,GAAG,EAAE,mBAAmB,EAAE,2CAA2C,CAAC,EACvE,CAAC,EAAE,EAAE,OAAO,EAAE,wBAAwB,CAAC,EACvC,CAAC,EAAE,EAAE,YAAY,EAAE,kDAAkD,CAAC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SAAS,CAACH,KAAK,CAAE,MAAKC,WAAY,MAAKd,gBAAgB,CAACe,UAAU,CAAE,IAAG;IAC3F,CAAC;IACD,MAAME,OAAO,GAAG5B,QAAQ,GAAI,QAAOA,QAAS,QAAO,GAAG,EAAE;IAExD,OACES,cAAc,GACdhB,gBAAK,CAACoC,KAAK,CAAE,GAAEjC,iBAAiB,CAACY,MAAM,GAAGD,eAAgB,wBAAuBqB,OAAQ,EAAC,CAAC,GAC3FlB,cAAc,GACda,cAAc,CAAC,gBAAgB,EAAE,8BAA8B,EAAEjB,eAAe,CAAC,GACjFiB,cAAc,CAAC,oBAAoB,EAAE,oCAAoC,EAAEtB,iBAAiB,CAAC;EAEjG;EACQX,SAAS,CAACX,IAAY,EAAwB;IACpD,IAAImD,UAAmB;IACvB,IAAI;MACFA,UAAU,GAAGC,IAAI,CAACC,KAAK,CAACrD,IAAI,CAAC;IAC/B,CAAC,CAAC,OAAOsD,GAAQ,EAAE;MACjB,MAAM,IAAIC,KAAK,CAAE,gDAA+CD,GAAG,CAACpD,OAAQ,EAAC,CAAC;IAChF;IACA,IAAI,CAACsD,KAAK,CAACC,OAAO,CAACN,UAAU,CAAC,EAAE;MAC9B,MAAM,IAAII,KAAK,CAAC,4BAA4B,CAAC;IAC/C;IACAJ,UAAU,CAACO,OAAO,CAAEC,QAAQ,IAAK;MAC/B,IAAI,CAACA,QAAQ,CAACC,WAAW,EAAE,MAAM,IAAIL,KAAK,CAAC,6CAA6C,CAAC;IAC3F,CAAC,CAAC;IACF,OAAOJ,UAAU;EACnB;AACF;AAAC"}
|
|
@@ -6,8 +6,6 @@ import { Workspace } from '@teambit/workspace';
|
|
|
6
6
|
import { ReleaseType } from 'semver';
|
|
7
7
|
import { BitId, BitIds } from '@teambit/legacy/dist/bit-id';
|
|
8
8
|
import { Consumer } from '@teambit/legacy/dist/consumer';
|
|
9
|
-
import { TagResults } from '@teambit/legacy/dist/api/consumer/lib/tag';
|
|
10
|
-
import { SnapResults } from '@teambit/legacy/dist/api/consumer/lib/snap';
|
|
11
9
|
import { Logger, LoggerMain } from '@teambit/logger';
|
|
12
10
|
import ConsumerComponent from '@teambit/legacy/dist/consumer/component/consumer-component';
|
|
13
11
|
import { InsightsMain } from '@teambit/insights';
|
|
@@ -21,15 +19,32 @@ import { BuilderMain } from '@teambit/builder';
|
|
|
21
19
|
import { ExportMain } from '@teambit/export';
|
|
22
20
|
import { ComponentID } from '@teambit/component-id';
|
|
23
21
|
import { BitObject } from '@teambit/legacy/dist/scope/objects';
|
|
22
|
+
import { AutoTagResult } from '@teambit/legacy/dist/scope/component-ops/auto-tag';
|
|
24
23
|
import { BasicTagParams } from './tag-model-component';
|
|
25
24
|
import { TagDataPerCompRaw } from './tag-from-scope.cmd';
|
|
25
|
+
import { SnapDataPerCompRaw } from './snap-from-scope.cmd';
|
|
26
26
|
export declare type TagDataPerComp = {
|
|
27
27
|
componentId: ComponentID;
|
|
28
28
|
dependencies: ComponentID[];
|
|
29
|
-
versionToTag
|
|
29
|
+
versionToTag?: string;
|
|
30
30
|
prereleaseId?: string;
|
|
31
31
|
message?: string;
|
|
32
32
|
};
|
|
33
|
+
export declare type SnapResults = {
|
|
34
|
+
snappedComponents: ConsumerComponent[];
|
|
35
|
+
autoSnappedResults: AutoTagResult[];
|
|
36
|
+
warnings: string[];
|
|
37
|
+
newComponents: BitIds;
|
|
38
|
+
laneName: string | null;
|
|
39
|
+
};
|
|
40
|
+
export declare type TagResults = {
|
|
41
|
+
taggedComponents: ConsumerComponent[];
|
|
42
|
+
autoTaggedResults: AutoTagResult[];
|
|
43
|
+
warnings: string[];
|
|
44
|
+
newComponents: BitIds;
|
|
45
|
+
isSoftTag: boolean;
|
|
46
|
+
publishedPackages: string[];
|
|
47
|
+
};
|
|
33
48
|
export declare class SnappingMain {
|
|
34
49
|
private workspace;
|
|
35
50
|
private logger;
|
|
@@ -65,6 +80,10 @@ export declare class SnappingMain {
|
|
|
65
80
|
ignoreIssues?: string;
|
|
66
81
|
incrementBy?: number;
|
|
67
82
|
} & Partial<BasicTagParams>): Promise<TagResults | null>;
|
|
83
|
+
snapFromScope(snapDataPerCompRaw: SnapDataPerCompRaw[], params: {
|
|
84
|
+
push?: boolean;
|
|
85
|
+
ignoreIssues?: string;
|
|
86
|
+
} & Partial<BasicTagParams>): Promise<SnapResults | null>;
|
|
68
87
|
/**
|
|
69
88
|
* save the local changes of a component(s) into the scope. snap can be done on main or on a lane.
|
|
70
89
|
* once a component is snapped on a lane, it becomes part of it.
|
|
@@ -92,6 +111,7 @@ export declare class SnappingMain {
|
|
|
92
111
|
isSoftUntag: boolean;
|
|
93
112
|
}>;
|
|
94
113
|
_addFlattenedDependenciesToComponents(scope: LegacyScope, components: ConsumerComponent[]): Promise<void>;
|
|
114
|
+
_addFlattenedDepsGraphToComponents(components: ConsumerComponent[]): Promise<void>;
|
|
95
115
|
_updateComponentsByTagResult(components: ConsumerComponent[], tagResult: LegacyOnTagResult[]): void;
|
|
96
116
|
_getPublishedPackages(components: ConsumerComponent[]): string[];
|
|
97
117
|
_addCompToObjects({ source, consumer, lane, shouldValidateVersion, }: {
|
|
@@ -25,6 +25,13 @@ function _cli() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
+
function _graph() {
|
|
29
|
+
const data = require("@teambit/graph.cleargraph");
|
|
30
|
+
_graph = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
28
35
|
function _getFlattenedDependencies() {
|
|
29
36
|
const data = require("@teambit/legacy/dist/scope/component-ops/get-flattened-dependencies");
|
|
30
37
|
_getFlattenedDependencies = function () {
|
|
@@ -291,6 +298,13 @@ function _tagFromScope() {
|
|
|
291
298
|
};
|
|
292
299
|
return data;
|
|
293
300
|
}
|
|
301
|
+
function _snapFromScope() {
|
|
302
|
+
const data = require("./snap-from-scope.cmd");
|
|
303
|
+
_snapFromScope = function () {
|
|
304
|
+
return data;
|
|
305
|
+
};
|
|
306
|
+
return data;
|
|
307
|
+
}
|
|
294
308
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
295
309
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
296
310
|
const HooksManagerInstance = _hooks().default.getInstance();
|
|
@@ -480,6 +494,68 @@ class SnappingMain {
|
|
|
480
494
|
newComponents: new (_bitId().BitIds)()
|
|
481
495
|
};
|
|
482
496
|
}
|
|
497
|
+
async snapFromScope(snapDataPerCompRaw, params) {
|
|
498
|
+
if (this.workspace) {
|
|
499
|
+
throw new (_bitError().BitError)(`unable to run this command from a workspace, please create a new bare-scope and run it from there`);
|
|
500
|
+
}
|
|
501
|
+
const snapDataPerComp = await Promise.all(snapDataPerCompRaw.map(async snapData => {
|
|
502
|
+
return {
|
|
503
|
+
componentId: await this.scope.resolveComponentId(snapData.componentId),
|
|
504
|
+
dependencies: snapData.dependencies ? await this.scope.resolveMultipleComponentIds(snapData.dependencies) : [],
|
|
505
|
+
aspects: snapData.aspects,
|
|
506
|
+
message: snapData.message
|
|
507
|
+
};
|
|
508
|
+
}));
|
|
509
|
+
const componentIds = snapDataPerComp.map(t => t.componentId);
|
|
510
|
+
const bitIds = componentIds.map(c => c._legacy);
|
|
511
|
+
const componentIdsLatest = componentIds.map(id => id.changeVersion(_constants().LATEST));
|
|
512
|
+
const components = await this.scope.import(componentIdsLatest);
|
|
513
|
+
await Promise.all(components.map(async comp => {
|
|
514
|
+
const snapData = snapDataPerComp.find(t => {
|
|
515
|
+
return t.componentId.isEqual(comp.id, {
|
|
516
|
+
ignoreVersion: true
|
|
517
|
+
});
|
|
518
|
+
});
|
|
519
|
+
if (!snapData) throw new Error(`unable to find ${comp.id.toString()} in snapDataPerComp`);
|
|
520
|
+
if (snapData.aspects) await this.scope.addAspectsFromConfigObject(comp, snapData.aspects);
|
|
521
|
+
if (snapData.dependencies.length) {
|
|
522
|
+
await this.updateDependenciesVersionsOfComponent(comp, snapData.dependencies, bitIds);
|
|
523
|
+
}
|
|
524
|
+
}));
|
|
525
|
+
const consumerComponents = components.map(c => c.state._consumer);
|
|
526
|
+
const legacyIds = _bitId().BitIds.fromArray(componentIds.map(id => id._legacy));
|
|
527
|
+
const results = await (0, _tagModelComponent().tagModelComponent)(_objectSpread(_objectSpread({}, params), {}, {
|
|
528
|
+
scope: this.scope,
|
|
529
|
+
consumerComponents,
|
|
530
|
+
tagDataPerComp: snapDataPerComp,
|
|
531
|
+
snapping: this,
|
|
532
|
+
builder: this.builder,
|
|
533
|
+
dependencyResolver: this.dependencyResolver,
|
|
534
|
+
skipAutoTag: true,
|
|
535
|
+
persist: true,
|
|
536
|
+
isSnap: true,
|
|
537
|
+
ids: legacyIds,
|
|
538
|
+
message: params.message
|
|
539
|
+
}));
|
|
540
|
+
const {
|
|
541
|
+
taggedComponents
|
|
542
|
+
} = results;
|
|
543
|
+
if (params.push) {
|
|
544
|
+
await this.exporter.exportMany({
|
|
545
|
+
scope: this.scope.legacyScope,
|
|
546
|
+
ids: legacyIds,
|
|
547
|
+
idsWithFutureScope: legacyIds,
|
|
548
|
+
allVersions: false
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
return {
|
|
552
|
+
snappedComponents: taggedComponents,
|
|
553
|
+
autoSnappedResults: [],
|
|
554
|
+
warnings: [],
|
|
555
|
+
newComponents: new (_bitId().BitIds)(),
|
|
556
|
+
laneName: null
|
|
557
|
+
};
|
|
558
|
+
}
|
|
483
559
|
|
|
484
560
|
/**
|
|
485
561
|
* save the local changes of a component(s) into the scope. snap can be done on main or on a lane.
|
|
@@ -535,7 +611,6 @@ class SnappingMain {
|
|
|
535
611
|
packageManagerConfigRootDir: this.workspace.path,
|
|
536
612
|
dependencyResolver: this.dependencyResolver
|
|
537
613
|
});
|
|
538
|
-
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
539
614
|
const snapResults = {
|
|
540
615
|
snappedComponents: taggedComponents,
|
|
541
616
|
autoSnappedResults: autoTaggedResults
|
|
@@ -638,6 +713,50 @@ there are matching among unmodified components thought. consider using --unmodif
|
|
|
638
713
|
const flattenedDependenciesGetter = new (_getFlattenedDependencies().FlattenedDependenciesGetter)(scope, components);
|
|
639
714
|
await flattenedDependenciesGetter.populateFlattenedDependencies();
|
|
640
715
|
_loader().default.stop();
|
|
716
|
+
await this._addFlattenedDepsGraphToComponents(components);
|
|
717
|
+
}
|
|
718
|
+
async _addFlattenedDepsGraphToComponents(components) {
|
|
719
|
+
const graph = new (_graph().Graph)();
|
|
720
|
+
const addEdges = (compId, dependencies, label) => {
|
|
721
|
+
dependencies.get().forEach(dep => {
|
|
722
|
+
graph.setNode(new (_graph().Node)(dep.id.toString(), dep.id));
|
|
723
|
+
graph.setEdge(new (_graph().Edge)(compId.toString(), dep.id.toString(), label));
|
|
724
|
+
});
|
|
725
|
+
};
|
|
726
|
+
components.forEach(comp => {
|
|
727
|
+
graph.setNode(new (_graph().Node)(comp.id.toString(), comp.id));
|
|
728
|
+
addEdges(comp.id, comp.dependencies, 'prod');
|
|
729
|
+
addEdges(comp.id, comp.devDependencies, 'dev');
|
|
730
|
+
addEdges(comp.id, comp.extensionDependencies, 'ext');
|
|
731
|
+
});
|
|
732
|
+
const allFlattened = components.map(comp => comp.flattenedDependencies);
|
|
733
|
+
const allFlattenedUniq = _bitId().BitIds.uniqFromArray(allFlattened.flat());
|
|
734
|
+
const allFlattenedWithoutCurrent = allFlattenedUniq.filter(id => !components.find(c => c.id.isEqual(id)));
|
|
735
|
+
const componentsAndVersions = await this.scope.legacyScope.getComponentsAndVersions(_bitId().BitIds.fromArray(allFlattenedWithoutCurrent));
|
|
736
|
+
componentsAndVersions.forEach(({
|
|
737
|
+
component,
|
|
738
|
+
version,
|
|
739
|
+
versionStr
|
|
740
|
+
}) => {
|
|
741
|
+
const compId = component.toBitId().changeVersion(versionStr);
|
|
742
|
+
graph.setNode(new (_graph().Node)(compId.toString(), compId));
|
|
743
|
+
addEdges(compId, version.dependencies, 'prod');
|
|
744
|
+
addEdges(compId, version.devDependencies, 'dev');
|
|
745
|
+
addEdges(compId, version.extensionDependencies, 'ext');
|
|
746
|
+
});
|
|
747
|
+
components.forEach(component => {
|
|
748
|
+
const edges = graph.outEdges(component.id.toString());
|
|
749
|
+
const flattenedEdges = component.flattenedDependencies.map(dep => graph.outEdges(dep.toString())).flat();
|
|
750
|
+
const allEdges = [...edges, ...flattenedEdges];
|
|
751
|
+
const edgesWithBitIds = allEdges.map(edge => ({
|
|
752
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
753
|
+
source: graph.node(edge.source).attr,
|
|
754
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
755
|
+
target: graph.node(edge.target).attr,
|
|
756
|
+
type: edge.attr
|
|
757
|
+
}));
|
|
758
|
+
component.flattenedEdges = edgesWithBitIds;
|
|
759
|
+
});
|
|
641
760
|
}
|
|
642
761
|
_updateComponentsByTagResult(components, tagResult) {
|
|
643
762
|
tagResult.forEach(result => {
|
|
@@ -903,8 +1022,9 @@ there are matching among unmodified components thought. consider using --unmodif
|
|
|
903
1022
|
const snapCmd = new (_snapCmd().SnapCmd)(community.getBaseDomain(), snapping, logger);
|
|
904
1023
|
const tagCmd = new (_tagCmd().TagCmd)(snapping, logger);
|
|
905
1024
|
const tagFromScopeCmd = new (_tagFromScope().TagFromScopeCmd)(snapping, logger);
|
|
1025
|
+
const snapFromScopeCmd = new (_snapFromScope().SnapFromScopeCmd)(snapping, logger);
|
|
906
1026
|
const resetCmd = new (_resetCmd().default)(snapping);
|
|
907
|
-
cli.register(tagCmd, snapCmd, resetCmd, tagFromScopeCmd);
|
|
1027
|
+
cli.register(tagCmd, snapCmd, resetCmd, tagFromScopeCmd, snapFromScopeCmd);
|
|
908
1028
|
return snapping;
|
|
909
1029
|
}
|
|
910
1030
|
}
|