@teambit/snapping 1.0.577 → 1.0.578
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/snap-from-scope.cmd.js +4 -2
- package/dist/snap-from-scope.cmd.js.map +1 -1
- package/dist/snapping.main.runtime.d.ts +1 -0
- package/dist/snapping.main.runtime.js +1 -1
- package/dist/snapping.main.runtime.js.map +1 -1
- package/dist/version-maker.d.ts +1 -0
- package/dist/version-maker.js +28 -1
- package/dist/version-maker.js.map +1 -1
- package/package.json +19 -19
- /package/dist/{preview-1742613610556.js → preview-1742959196365.js} +0 -0
|
@@ -105,7 +105,8 @@ ${inputDataDescription}
|
|
|
105
105
|
ignoreBuildErrors,
|
|
106
106
|
rebuildDepsGraph,
|
|
107
107
|
updateDependents,
|
|
108
|
-
tag
|
|
108
|
+
tag,
|
|
109
|
+
skipAutoTag: true
|
|
109
110
|
});
|
|
110
111
|
const {
|
|
111
112
|
snappedIds,
|
|
@@ -148,7 +149,8 @@ ${inputDataDescription}
|
|
|
148
149
|
ignoreBuildErrors,
|
|
149
150
|
rebuildDepsGraph,
|
|
150
151
|
updateDependents,
|
|
151
|
-
tag
|
|
152
|
+
tag,
|
|
153
|
+
skipAutoTag: true
|
|
152
154
|
});
|
|
153
155
|
return {
|
|
154
156
|
code: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_componentIssues","_bitError","_lodash","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","inputDataDescription","exports","snapFromScopeOptions","keys","IssuesClasses","join","SnapFromScopeCmd","constructor","snapping","logger","report","push","message","lane","ignoreIssues","build","skipTests","disableSnapPipeline","ignoreBuildErrors","rebuildDepsGraph","updateDependents","tag","disableTagAndSnapPipelines","BitError","snapDataPerCompRaw","parseData","results","snapFromScope","snappedIds","exportedIds","snappedOutput","length","chalk","bold","exportedOutput","compact","json","code","map","id","toString","err","error","stack","dataParsed","JSON","parse","Error","Array","isArray","forEach","dataItem","componentId","files","file","path","content","Buffer","from"],"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 { compact } from 'lodash';\nimport { Logger } from '@teambit/logger';\nimport { SnappingMain } from './snapping.main.runtime';\nimport { BasicTagSnapParams } from './version-maker';\nimport { NewDependencies } from './generate-comp-from-scope';\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?: NewDependencies;\n removeDependencies?: string[];\n forkFrom?: string; // origin id to fork from. the componentId is the new id. (no need to populate isNew prop).\n version?: string; // relevant when passing \"--tag\". optionally, specify the semver to tag. default to \"patch\".\n};\n\nexport type SnapFromScopeOptions = {\n push?: boolean;\n lane?: string;\n ignoreIssues?: string;\n disableSnapPipeline?: boolean;\n updateDependents?: boolean;\n tag?: boolean;\n} & BasicTagSnapParams;\n\nexport const inputDataDescription = `the input data is a stringified JSON of an array of the following object.\n{\n componentId: string; // ids always have scope, so it's safe to parse them from string\n dependencies?: string[]; // dependencies include versions. for components use component-id. e.g. [teambit.compilation/compiler@1.0.0, lodash@4.17.21]\n aspects?: Record<string,any> // e.g. { \"teambit.react/react\": {}, \"teambit.envs/envs\": { \"env\": \"teambit.react/react\" } }\n message?: string; // tag-message.\n files?: Array<{path: string, content: string}>; // replace content of specified source-files. the content is base64 encoded.\n isNew?: boolean; // if it's new, it'll be generated from the given files. otherwise, it'll be fetched from the scope and updated.\n mainFile?: string; // relevant when isNew is true. default to \"index.ts\".\n newDependencies?: Array<{ // new dependencies (components and packages) to add.\n id: string; // component-id or package-name. e.g. \"teambit.react/react\" or \"lodash\".\n version?: string; // version of the package. e.g. \"2.0.3\". for packages, it is mandatory.\n isComponent?: boolean; // default true. if false, it's a package dependency\n type?: 'runtime' | 'dev' | 'peer'; // default \"runtime\".\n }>;\n removeDependencies?: string[]; // component-id (for components) or package-name (for packages) to remove from the dependencies.\n forkFrom?: string; // origin id to fork from. the componentId is the new id. (no need to populate isNew prop).\n version?: string; // relevant when passing \"--tag\". optionally, specify the semver to tag. default to \"patch\".\n}\nan example of the final data: '[{\"componentId\":\"ci.remote2/comp-b\",\"message\": \"first snap\"}]'`;\n\nexport const snapFromScopeOptions = [\n ['', 'push', 'export the updated objects to the original scopes once done'],\n ['m', 'message <message>', 'log message describing the latest changes'],\n ['', 'lane <lane-id>', 'fetch the components from the given lane'],\n ['', 'build', 'run the build pipeline'],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n ['', 'disable-snap-pipeline', 'skip the snap pipeline'],\n ['', 'ignore-build-errors', 'run the snap pipeline although the build pipeline failed'],\n ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'],\n [\n 'i',\n 'ignore-issues [issues]',\n `ignore component issues (shown in \"bit status\" as \"issues found\"), issues to ignore:\n[${Object.keys(IssuesClasses).join(', ')}]\nto ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify \"*\".`,\n ],\n ['', 'tag', 'make a tag instead of a snap'],\n ['', 'stream', 'relevant for --json only. stream loader as json strings'],\n ['j', 'json', 'output as json format'],\n];\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.\n${inputDataDescription}\n`;\n alias = '';\n options = [\n ...snapFromScopeOptions,\n [\n '',\n 'update-dependents',\n 'when snapped on a lane, mark it as update-dependents so it will be skipped from the workspace',\n ],\n ] as CommandOptions;\n loader = true;\n private = true;\n\n constructor(\n private snapping: SnappingMain,\n private logger: Logger\n ) {}\n\n async report(\n [data]: [string],\n {\n push = false,\n message = '',\n lane,\n ignoreIssues,\n build = false,\n skipTests = false,\n disableSnapPipeline = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n updateDependents,\n tag,\n }: SnapFromScopeOptions\n ) {\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (disableTagAndSnapPipelines && ignoreBuildErrors) {\n throw new BitError('you can use either ignore-build-errors or disable-snap-pipeline, but not both');\n }\n if (updateDependents && !lane) {\n throw new BitError('update-dependents flag is only available when snapping from a lane');\n }\n\n const snapDataPerCompRaw = this.parseData(data);\n const results = await this.snapping.snapFromScope(snapDataPerCompRaw, {\n push,\n message,\n lane,\n ignoreIssues,\n build,\n skipTests,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n updateDependents,\n tag,\n });\n\n const { snappedIds, exportedIds } = results;\n\n const snappedOutput = snappedIds.length ? `${chalk.bold('snapped components')}\\n${snappedIds.join('\\n')}` : '';\n const exportedOutput =\n exportedIds && exportedIds.length ? `${chalk.bold('exported components')}\\n${exportedIds.join('\\n')}` : '';\n\n return compact([snappedOutput, exportedOutput]).join('\\n\\n');\n }\n async json(\n [data]: [string],\n {\n push = false,\n message = '',\n lane,\n ignoreIssues,\n build = false,\n skipTests = false,\n disableSnapPipeline = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n updateDependents,\n tag,\n }: SnapFromScopeOptions\n ) {\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (disableTagAndSnapPipelines && ignoreBuildErrors) {\n throw new BitError('you can use either ignore-build-errors or disable-snap-pipeline, but not both');\n }\n if (updateDependents && !lane) {\n throw new BitError('update-dependents flag is only available when snapping from a lane');\n }\n\n const snapDataPerCompRaw = this.parseData(data);\n\n try {\n const results = await this.snapping.snapFromScope(snapDataPerCompRaw, {\n push,\n message,\n lane,\n ignoreIssues,\n build,\n skipTests,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n updateDependents,\n tag,\n });\n\n return {\n code: 0,\n data: {\n exportedIds: results.exportedIds?.map((id) => id.toString()),\n snappedIds: results.snappedIds.map((id) => id.toString()),\n },\n };\n } catch (err: any) {\n this.logger.error('snap-from-scope.json, error: ', err);\n return {\n code: 1,\n error: err.message,\n stack: err.stack,\n };\n }\n }\n private parseData(data: string): SnapDataPerCompRaw[] {\n let dataParsed: unknown;\n try {\n dataParsed = JSON.parse(data);\n } catch (err: any) {\n throw new Error(`failed parsing the data entered as JSON. err ${err.message}`);\n }\n if (!Array.isArray(dataParsed)) {\n throw new Error('expect data to be an array');\n }\n dataParsed.forEach((dataItem) => {\n if (!dataItem.componentId) throw new Error('expect data item to have \"componentId\" prop');\n dataItem.files?.forEach((file) => {\n if (!file.path) throw new Error('expect file to have \"path\" prop');\n if (file.content) {\n file.content = Buffer.from(file.content, 'base64').toString();\n }\n });\n });\n\n return dataParsed;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,iBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,gBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiC,SAAAC,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,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AI,CAAC;IAC/B,CAAC,CAAC,OAAOoE,GAAQ,EAAE;MACjB,MAAM,IAAIM,KAAK,CAAC,gDAAgDN,GAAG,CAAC7B,OAAO,EAAE,CAAC;IAChF;IACA,IAAI,CAACoC,KAAK,CAACC,OAAO,CAACL,UAAU,CAAC,EAAE;MAC9B,MAAM,IAAIG,KAAK,CAAC,4BAA4B,CAAC;IAC/C;IACAH,UAAU,CAACM,OAAO,CAAEC,QAAQ,IAAK;MAC/B,IAAI,CAACA,QAAQ,CAACC,WAAW,EAAE,MAAM,IAAIL,KAAK,CAAC,6CAA6C,CAAC;MACzFI,QAAQ,CAACE,KAAK,EAAEH,OAAO,CAAEI,IAAI,IAAK;QAChC,IAAI,CAACA,IAAI,CAACC,IAAI,EAAE,MAAM,IAAIR,KAAK,CAAC,iCAAiC,CAAC;QAClE,IAAIO,IAAI,CAACE,OAAO,EAAE;UAChBF,IAAI,CAACE,OAAO,GAAGC,MAAM,CAACC,IAAI,CAACJ,IAAI,CAACE,OAAO,EAAE,QAAQ,CAAC,CAAChB,QAAQ,CAAC,CAAC;QAC/D;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAOI,UAAU;EACnB;AACF;AAAC3C,OAAA,CAAAK,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_componentIssues","_bitError","_lodash","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","inputDataDescription","exports","snapFromScopeOptions","keys","IssuesClasses","join","SnapFromScopeCmd","constructor","snapping","logger","report","push","message","lane","ignoreIssues","build","skipTests","disableSnapPipeline","ignoreBuildErrors","rebuildDepsGraph","updateDependents","tag","disableTagAndSnapPipelines","BitError","snapDataPerCompRaw","parseData","results","snapFromScope","skipAutoTag","snappedIds","exportedIds","snappedOutput","length","chalk","bold","exportedOutput","compact","json","code","map","id","toString","err","error","stack","dataParsed","JSON","parse","Error","Array","isArray","forEach","dataItem","componentId","files","file","path","content","Buffer","from"],"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 { compact } from 'lodash';\nimport { Logger } from '@teambit/logger';\nimport { SnappingMain } from './snapping.main.runtime';\nimport { BasicTagSnapParams } from './version-maker';\nimport { NewDependencies } from './generate-comp-from-scope';\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?: NewDependencies;\n removeDependencies?: string[];\n forkFrom?: string; // origin id to fork from. the componentId is the new id. (no need to populate isNew prop).\n version?: string; // relevant when passing \"--tag\". optionally, specify the semver to tag. default to \"patch\".\n};\n\nexport type SnapFromScopeOptions = {\n push?: boolean;\n lane?: string;\n ignoreIssues?: string;\n disableSnapPipeline?: boolean;\n updateDependents?: boolean;\n tag?: boolean;\n} & BasicTagSnapParams;\n\nexport const inputDataDescription = `the input data is a stringified JSON of an array of the following object.\n{\n componentId: string; // ids always have scope, so it's safe to parse them from string\n dependencies?: string[]; // dependencies include versions. for components use component-id. e.g. [teambit.compilation/compiler@1.0.0, lodash@4.17.21]\n aspects?: Record<string,any> // e.g. { \"teambit.react/react\": {}, \"teambit.envs/envs\": { \"env\": \"teambit.react/react\" } }\n message?: string; // tag-message.\n files?: Array<{path: string, content: string}>; // replace content of specified source-files. the content is base64 encoded.\n isNew?: boolean; // if it's new, it'll be generated from the given files. otherwise, it'll be fetched from the scope and updated.\n mainFile?: string; // relevant when isNew is true. default to \"index.ts\".\n newDependencies?: Array<{ // new dependencies (components and packages) to add.\n id: string; // component-id or package-name. e.g. \"teambit.react/react\" or \"lodash\".\n version?: string; // version of the package. e.g. \"2.0.3\". for packages, it is mandatory.\n isComponent?: boolean; // default true. if false, it's a package dependency\n type?: 'runtime' | 'dev' | 'peer'; // default \"runtime\".\n }>;\n removeDependencies?: string[]; // component-id (for components) or package-name (for packages) to remove from the dependencies.\n forkFrom?: string; // origin id to fork from. the componentId is the new id. (no need to populate isNew prop).\n version?: string; // relevant when passing \"--tag\". optionally, specify the semver to tag. default to \"patch\".\n}\nan example of the final data: '[{\"componentId\":\"ci.remote2/comp-b\",\"message\": \"first snap\"}]'`;\n\nexport const snapFromScopeOptions = [\n ['', 'push', 'export the updated objects to the original scopes once done'],\n ['m', 'message <message>', 'log message describing the latest changes'],\n ['', 'lane <lane-id>', 'fetch the components from the given lane'],\n ['', 'build', 'run the build pipeline'],\n ['', 'skip-tests', 'skip running component tests during snap process'],\n ['', 'disable-snap-pipeline', 'skip the snap pipeline'],\n ['', 'ignore-build-errors', 'run the snap pipeline although the build pipeline failed'],\n ['', 'rebuild-deps-graph', 'do not reuse the saved dependencies graph, instead build it from scratch'],\n [\n 'i',\n 'ignore-issues [issues]',\n `ignore component issues (shown in \"bit status\" as \"issues found\"), issues to ignore:\n[${Object.keys(IssuesClasses).join(', ')}]\nto ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify \"*\".`,\n ],\n ['', 'tag', 'make a tag instead of a snap'],\n ['', 'stream', 'relevant for --json only. stream loader as json strings'],\n ['j', 'json', 'output as json format'],\n];\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.\n${inputDataDescription}\n`;\n alias = '';\n options = [\n ...snapFromScopeOptions,\n [\n '',\n 'update-dependents',\n 'when snapped on a lane, mark it as update-dependents so it will be skipped from the workspace',\n ],\n ] as CommandOptions;\n loader = true;\n private = true;\n\n constructor(\n private snapping: SnappingMain,\n private logger: Logger\n ) {}\n\n async report(\n [data]: [string],\n {\n push = false,\n message = '',\n lane,\n ignoreIssues,\n build = false,\n skipTests = false,\n disableSnapPipeline = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n updateDependents,\n tag,\n }: SnapFromScopeOptions\n ) {\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (disableTagAndSnapPipelines && ignoreBuildErrors) {\n throw new BitError('you can use either ignore-build-errors or disable-snap-pipeline, but not both');\n }\n if (updateDependents && !lane) {\n throw new BitError('update-dependents flag is only available when snapping from a lane');\n }\n\n const snapDataPerCompRaw = this.parseData(data);\n const results = await this.snapping.snapFromScope(snapDataPerCompRaw, {\n push,\n message,\n lane,\n ignoreIssues,\n build,\n skipTests,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n updateDependents,\n tag,\n skipAutoTag: true\n });\n\n const { snappedIds, exportedIds } = results;\n\n const snappedOutput = snappedIds.length ? `${chalk.bold('snapped components')}\\n${snappedIds.join('\\n')}` : '';\n const exportedOutput =\n exportedIds && exportedIds.length ? `${chalk.bold('exported components')}\\n${exportedIds.join('\\n')}` : '';\n\n return compact([snappedOutput, exportedOutput]).join('\\n\\n');\n }\n async json(\n [data]: [string],\n {\n push = false,\n message = '',\n lane,\n ignoreIssues,\n build = false,\n skipTests = false,\n disableSnapPipeline = false,\n ignoreBuildErrors = false,\n rebuildDepsGraph,\n updateDependents,\n tag,\n }: SnapFromScopeOptions\n ) {\n const disableTagAndSnapPipelines = disableSnapPipeline;\n if (disableTagAndSnapPipelines && ignoreBuildErrors) {\n throw new BitError('you can use either ignore-build-errors or disable-snap-pipeline, but not both');\n }\n if (updateDependents && !lane) {\n throw new BitError('update-dependents flag is only available when snapping from a lane');\n }\n\n const snapDataPerCompRaw = this.parseData(data);\n\n try {\n const results = await this.snapping.snapFromScope(snapDataPerCompRaw, {\n push,\n message,\n lane,\n ignoreIssues,\n build,\n skipTests,\n disableTagAndSnapPipelines,\n ignoreBuildErrors,\n rebuildDepsGraph,\n updateDependents,\n tag,\n skipAutoTag: true\n });\n\n return {\n code: 0,\n data: {\n exportedIds: results.exportedIds?.map((id) => id.toString()),\n snappedIds: results.snappedIds.map((id) => id.toString()),\n },\n };\n } catch (err: any) {\n this.logger.error('snap-from-scope.json, error: ', err);\n return {\n code: 1,\n error: err.message,\n stack: err.stack,\n };\n }\n }\n private parseData(data: string): SnapDataPerCompRaw[] {\n let dataParsed: unknown;\n try {\n dataParsed = JSON.parse(data);\n } catch (err: any) {\n throw new Error(`failed parsing the data entered as JSON. err ${err.message}`);\n }\n if (!Array.isArray(dataParsed)) {\n throw new Error('expect data to be an array');\n }\n dataParsed.forEach((dataItem) => {\n if (!dataItem.componentId) throw new Error('expect data item to have \"componentId\" prop');\n dataItem.files?.forEach((file) => {\n if (!file.path) throw new Error('expect file to have \"path\" prop');\n if (file.content) {\n file.content = Buffer.from(file.content, 'base64').toString();\n }\n });\n });\n\n return dataParsed;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,iBAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,gBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiC,SAAAC,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,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GAAGC,IAAI,CAACC,KAAK,CAAC1E,IAAI,CAAC;IAC/B,CAAC,CAAC,OAAOqE,GAAQ,EAAE;MACjB,MAAM,IAAIM,KAAK,CAAC,gDAAgDN,GAAG,CAAC9B,OAAO,EAAE,CAAC;IAChF;IACA,IAAI,CAACqC,KAAK,CAACC,OAAO,CAACL,UAAU,CAAC,EAAE;MAC9B,MAAM,IAAIG,KAAK,CAAC,4BAA4B,CAAC;IAC/C;IACAH,UAAU,CAACM,OAAO,CAAEC,QAAQ,IAAK;MAC/B,IAAI,CAACA,QAAQ,CAACC,WAAW,EAAE,MAAM,IAAIL,KAAK,CAAC,6CAA6C,CAAC;MACzFI,QAAQ,CAACE,KAAK,EAAEH,OAAO,CAAEI,IAAI,IAAK;QAChC,IAAI,CAACA,IAAI,CAACC,IAAI,EAAE,MAAM,IAAIR,KAAK,CAAC,iCAAiC,CAAC;QAClE,IAAIO,IAAI,CAACE,OAAO,EAAE;UAChBF,IAAI,CAACE,OAAO,GAAGC,MAAM,CAACC,IAAI,CAACJ,IAAI,CAACE,OAAO,EAAE,QAAQ,CAAC,CAAChB,QAAQ,CAAC,CAAC;QAC/D;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAOI,UAAU;EACnB;AACF;AAAC5C,OAAA,CAAAK,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -58,6 +58,7 @@ export type SnapResults = BasicTagResults & {
|
|
|
58
58
|
export type SnapFromScopeResults = {
|
|
59
59
|
snappedIds: ComponentID[];
|
|
60
60
|
exportedIds?: ComponentID[];
|
|
61
|
+
autoSnappedResults: AutoTagResult[];
|
|
61
62
|
snappedComponents: ConsumerComponent[];
|
|
62
63
|
};
|
|
63
64
|
export type TagResults = BasicTagResults & {
|
|
@@ -699,7 +699,6 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
699
699
|
dependencies: [],
|
|
700
700
|
versionToTag: shouldTag ? s.version || 'patch' : undefined
|
|
701
701
|
})),
|
|
702
|
-
skipAutoTag: true,
|
|
703
702
|
persist: true,
|
|
704
703
|
isSnap: !shouldTag,
|
|
705
704
|
message: params.message,
|
|
@@ -729,6 +728,7 @@ if you're willing to lose the history from the head to the specified version, us
|
|
|
729
728
|
return {
|
|
730
729
|
snappedComponents: taggedComponents,
|
|
731
730
|
snappedIds: taggedComponents.map(comp => comp.id),
|
|
731
|
+
autoSnappedResults: results.autoTaggedResults,
|
|
732
732
|
exportedIds
|
|
733
733
|
};
|
|
734
734
|
}
|