@teambit/snapping 1.0.1234 → 1.0.1236
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/generate-comp-from-scope.d.ts +2 -1
- package/dist/generate-comp-from-scope.js +2 -2
- package/dist/generate-comp-from-scope.js.map +1 -1
- package/dist/snapping.main.runtime.d.ts +10 -0
- package/dist/snapping.main.runtime.js +97 -24
- package/dist/snapping.main.runtime.js.map +1 -1
- package/dist/version-maker.d.ts +9 -3
- package/dist/version-maker.js +34 -10
- package/dist/version-maker.js.map +1 -1
- package/package.json +37 -37
- /package/dist/{preview-1792418223123.js → preview-1792527927744.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentID } from '@teambit/component-id';
|
|
2
2
|
import type { ScopeMain } from '@teambit/scope';
|
|
3
|
+
import type { DependenciesOverridesData } from '@teambit/legacy.consumer-config';
|
|
3
4
|
import type { Component } from '@teambit/component';
|
|
4
5
|
import type { DependenciesMain } from '@teambit/dependencies';
|
|
5
6
|
import type { DependencyResolverMain, VariantPolicyConfigArr } from '@teambit/dependency-resolver';
|
|
@@ -30,4 +31,4 @@ export type CompData = {
|
|
|
30
31
|
* ConsumerComponent.
|
|
31
32
|
*/
|
|
32
33
|
export declare function generateCompFromScope(scope: ScopeMain, depsResolver: DependencyResolverMain, compData: CompData, snapping: SnappingMain): Promise<Component>;
|
|
33
|
-
export declare function addDeps(component: Component, snapData: SnapDataParsed, scope: ScopeMain, deps: DependenciesMain, depsResolver: DependencyResolverMain, snapping: SnappingMain, autoDetect?: VariantPolicyConfigArr): Promise<void>;
|
|
34
|
+
export declare function addDeps(component: Component, snapData: SnapDataParsed, scope: ScopeMain, deps: DependenciesMain, depsResolver: DependencyResolverMain, snapping: SnappingMain, autoDetect?: VariantPolicyConfigArr, autoDetectOverrides?: DependenciesOverridesData): Promise<void>;
|
|
@@ -121,7 +121,7 @@ async function getCompDeps(scope, depsResolver, newDeps) {
|
|
|
121
121
|
compPeerDeps
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
async function addDeps(component, snapData, scope, deps, depsResolver, snapping, autoDetect) {
|
|
124
|
+
async function addDeps(component, snapData, scope, deps, depsResolver, snapping, autoDetect, autoDetectOverrides) {
|
|
125
125
|
const newDeps = snapData.newDependencies || [];
|
|
126
126
|
const updateDeps = snapData.dependencies || [];
|
|
127
127
|
const packageDeps = newDeps.filter(dep => !dep.isComponent);
|
|
@@ -188,7 +188,7 @@ async function addDeps(component, snapData, scope, deps, depsResolver, snapping,
|
|
|
188
188
|
|
|
189
189
|
// add the dependencies to the legacy ConsumerComponent object
|
|
190
190
|
// it takes care of both: given dependencies (from the cli) and the overrides, which are coming from the env.
|
|
191
|
-
await deps.loadDependenciesFromScope(consumerComponent, dependenciesData);
|
|
191
|
+
await deps.loadDependenciesFromScope(consumerComponent, dependenciesData, autoDetectOverrides);
|
|
192
192
|
await snapping.UpdateDepsAspectsSaveIntoDepsResolver(component, updateDeps);
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_componentId","data","require","_legacy","_component","_legacy2","_legacy3","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","generateCompFromScope","scope","depsResolver","compData","snapping","files","Error","map","file","SourceFile","base","path","contents","Buffer","from","content","test","id","componentId","extensions","ExtensionDataList","fromConfigObject","aspects","compDeps","getCompDeps","newDependencies","consumerComponent","ConsumerComponent","mainFile","name","fullName","schema","CURRENT_SCHEMA","overrides","ComponentOverrides","loadNewFromScope","defaultScope","log","message","date","Date","now","toString","username","email","_addFlattenedDependenciesToComponents","version","filesBitObject","legacyScope","sources","consumerComponentToVersion","modelComponent","findOrAddComponent","hash","objects","writeObjectsToTheFS","f","component","getManyByLegacy","newDeps","compIdsData","dep","isComponent","compIdsDataParsed","ComponentID","fromString","compIds","changeVersion","comps","getMany","toDependency","depId","comp","find","c","isEqualWithoutVersion","pkgName","getPackageName","Dependency","type","compDevDeps","compPeerDeps","addDeps","snapData","deps","autoDetect","updateDeps","dependencies","packageDeps","toPackageObj","pkgs","reduce","acc","curr","getPkgObj","allAutoDeps","depType","manipulateCurrentPkgs","removeDependencies","pkg","found","d","startsWith","replace","manipulateCurrentDeps","currentCompDeps","afterRemoval","includes","toStringWithoutVersion","foundInAutoDeps","packageName","undefined","state","_consumer","dependenciesData","allDependencies","get","devDependencies","peerDependencies","allPackagesDependencies","packageDependencies","devPackageDependencies","peerPackageDependencies","loadDependenciesFromScope","UpdateDepsAspectsSaveIntoDepsResolver"],"sources":["generate-comp-from-scope.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport { Dependency, ConsumerComponent, CURRENT_SCHEMA } from '@teambit/legacy.consumer-component';\nimport { SourceFile } from '@teambit/component.sources';\nimport type { ScopeMain } from '@teambit/scope';\nimport { ComponentOverrides } from '@teambit/legacy.consumer-config';\nimport { ExtensionDataList } from '@teambit/legacy.extension-data';\nimport type { Component } from '@teambit/component';\nimport type { DependenciesMain } from '@teambit/dependencies';\nimport type { DependencyResolverMain, VariantPolicyConfigArr } from '@teambit/dependency-resolver';\nimport type { FileData, SnappingMain, SnapDataParsed } from './snapping.main.runtime';\n\nexport type NewDependency = {\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\nexport type NewDependencies = NewDependency[];\n\nexport type CompData = {\n componentId: ComponentID;\n dependencies: string[];\n aspects: Record<string, any> | undefined;\n message: string | undefined;\n files: FileData[] | undefined;\n mainFile?: string;\n newDependencies?: NewDependencies;\n};\n\n/**\n * normally new components are created from a workspace. the files are in the filesystem and the ConsumerComponent\n * object is created from the files.\n * here, we need to create the ConsumerComponent object \"on the fly\". we don't have workspace, only scope. the files\n * are in-memory (we got them from snap-from-scope command).\n * the way how it is done is by creating a minimal ConsumerComponent object, then convert `Version` object from it,\n * write the version and files into the scope as objects, so then it's possible to load Component object using the\n * ConsumerComponent.\n */\nexport async function generateCompFromScope(\n scope: ScopeMain,\n depsResolver: DependencyResolverMain,\n compData: CompData,\n snapping: SnappingMain\n): Promise<Component> {\n if (!compData.files) throw new Error('generateComp: files are missing');\n const files = compData.files.map((file) => {\n return new SourceFile({ base: '.', path: file.path, contents: Buffer.from(file.content), test: false });\n });\n const id = compData.componentId;\n const extensions = ExtensionDataList.fromConfigObject(compData.aspects || {});\n const { compDeps } = await getCompDeps(scope, depsResolver, compData.newDependencies || []);\n\n const consumerComponent = new ConsumerComponent({\n mainFile: compData.mainFile || 'index.ts',\n name: compData.componentId.fullName,\n scope: compData.componentId.scope,\n files,\n schema: CURRENT_SCHEMA,\n overrides: await ComponentOverrides.loadNewFromScope(id, files, extensions, compDeps),\n defaultScope: compData.componentId.scope,\n extensions,\n // the dummy data here are not important. this Version object will be discarded later.\n log: {\n message: compData.message || '',\n date: Date.now().toString(),\n username: '',\n email: '',\n },\n });\n // this is needed, otherwise in case of updating envs/aspects, the version-validator throws\n // an error saying \"the extension ${extensionId.toString()} is missing from the flattenedDependencies\"\n await snapping._addFlattenedDependenciesToComponents([consumerComponent]);\n\n const { version, files: filesBitObject } =\n await scope.legacyScope.sources.consumerComponentToVersion(consumerComponent);\n const modelComponent = await scope.legacyScope.sources.findOrAddComponent(consumerComponent);\n consumerComponent.version = version.hash().toString();\n await scope.legacyScope.objects.writeObjectsToTheFS([version, modelComponent, ...filesBitObject.map((f) => f.file)]);\n const component = await scope.getManyByLegacy([consumerComponent]);\n\n return component[0];\n}\n\nasync function getCompDeps(scope: ScopeMain, depsResolver: DependencyResolverMain, newDeps: NewDependencies) {\n const compIdsData = newDeps.filter((dep) => dep.isComponent);\n const compIdsDataParsed = compIdsData.map((data) => ({\n ...data,\n id: ComponentID.fromString(data.id),\n }));\n const compIds = compIdsDataParsed.map((dep) => (dep.version ? dep.id.changeVersion(dep.version) : dep.id));\n const comps = await scope.getMany(compIds);\n const toDependency = (depId: ComponentID) => {\n const comp = comps.find((c) => c.id.isEqualWithoutVersion(depId));\n if (!comp) throw new Error(`unable to find the specified dependency ${depId.toString()} in the scope`);\n const pkgName = depsResolver.getPackageName(comp);\n return new Dependency(comp.id, [], pkgName);\n };\n const compDeps = compIdsDataParsed.filter((c) => c.type === 'runtime').map((dep) => toDependency(dep.id));\n const compDevDeps = compIdsDataParsed.filter((c) => c.type === 'dev').map((dep) => toDependency(dep.id));\n const compPeerDeps = compIdsDataParsed.filter((c) => c.type === 'peer').map((dep) => toDependency(dep.id));\n return { compDeps, compDevDeps, compPeerDeps };\n}\n\nexport async function addDeps(\n component: Component,\n snapData: SnapDataParsed,\n scope: ScopeMain,\n deps: DependenciesMain,\n depsResolver: DependencyResolverMain,\n snapping: SnappingMain,\n autoDetect?: VariantPolicyConfigArr\n) {\n const newDeps = snapData.newDependencies || [];\n const updateDeps = snapData.dependencies || [];\n const packageDeps = newDeps.filter((dep) => !dep.isComponent);\n const { compDeps, compDevDeps, compPeerDeps } = await getCompDeps(scope, depsResolver, newDeps);\n const toPackageObj = (pkgs: Array<{ id: string; version?: string }>) => {\n return pkgs.reduce((acc, curr) => {\n if (!curr.version) throw new Error(`please specify a version for the package dependency: \"${curr.id}\"`);\n acc[curr.id] = curr.version;\n return acc;\n }, {});\n };\n const getPkgObj = (type: 'runtime' | 'dev' | 'peer') => {\n return toPackageObj(packageDeps.filter((dep) => dep.type === type));\n };\n const allAutoDeps: { [pkgName: string]: string } = {};\n ['dependencies', 'devDependencies', 'peerDependencies'].forEach((depType) => {\n autoDetect?.[depType]?.forEach((dep) => {\n allAutoDeps[dep.name] = dep.version;\n });\n });\n\n const manipulateCurrentPkgs = (pkgs: Record<string, string>) => {\n snapData.removeDependencies?.forEach((pkg) => {\n delete pkgs[pkg];\n });\n Object.keys(pkgs).forEach((pkg) => {\n const found = updateDeps.find((d) => d.startsWith(`${pkg}@`));\n if (found) {\n pkgs[pkg] = found.replace(`${pkg}@`, '');\n }\n });\n return pkgs;\n };\n const manipulateCurrentDeps = (currentCompDeps: Dependency[]) => {\n const afterRemoval = currentCompDeps.filter(\n (dep) => !snapData.removeDependencies?.includes(dep.id.toStringWithoutVersion())\n );\n afterRemoval.forEach((dep) => {\n const found = updateDeps.find((d) => d.startsWith(`${dep.id.toStringWithoutVersion()}@`));\n if (found) {\n dep.id = dep.id.changeVersion(found.replace(`${dep.id.toStringWithoutVersion()}@`, ''));\n }\n const foundInAutoDeps = dep.packageName ? allAutoDeps[dep.packageName] : undefined;\n if (foundInAutoDeps) {\n dep.id = dep.id.changeVersion(allAutoDeps[dep.packageName!]);\n }\n });\n return afterRemoval;\n };\n\n const consumerComponent = component.state._consumer as ConsumerComponent;\n\n const dependenciesData = {\n allDependencies: {\n dependencies: [...compDeps, ...manipulateCurrentDeps(consumerComponent.dependencies.get())],\n devDependencies: [...compDevDeps, ...manipulateCurrentDeps(consumerComponent.devDependencies.get())],\n peerDependencies: [...compPeerDeps, ...manipulateCurrentDeps(consumerComponent.peerDependencies.get())],\n },\n allPackagesDependencies: {\n packageDependencies: { ...manipulateCurrentPkgs(consumerComponent.packageDependencies), ...getPkgObj('runtime') },\n devPackageDependencies: {\n ...manipulateCurrentPkgs(consumerComponent.devPackageDependencies),\n ...getPkgObj('dev'),\n },\n peerPackageDependencies: {\n ...manipulateCurrentPkgs(consumerComponent.peerPackageDependencies),\n ...getPkgObj('peer'),\n },\n },\n };\n\n // add the dependencies to the legacy ConsumerComponent object\n // it takes care of both: given dependencies (from the cli) and the overrides, which are coming from the env.\n await deps.loadDependenciesFromScope(consumerComponent, dependenciesData);\n\n await snapping.UpdateDepsAspectsSaveIntoDepsResolver(component,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BAAiB,CAAC+F,sBAAsB,CAAC,GAC/D3B,SAAS,CAAC,KAAK,CAAC,CACpB;MACD4B,uBAAuB,EAAA9I,aAAA,CAAAA,aAAA,KAClBqH,qBAAqB,CAACvE,iBAAiB,CAACgG,uBAAuB,CAAC,GAChE5B,SAAS,CAAC,MAAM,CAAC;IAExB;EACF,CAAC;;EAED;EACA;EACA,MAAMV,IAAI,CAACuC,yBAAyB,CAACjG,iBAAiB,EAAEwF,gBAAgB,CAAC;EAEzE,MAAM9G,QAAQ,CAACwH,qCAAqC,CAACnE,SAAS,EAAE6B,UAAU,CAAC;AAC7E","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_componentId","data","require","_legacy","_component","_legacy2","_legacy3","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","generateCompFromScope","scope","depsResolver","compData","snapping","files","Error","map","file","SourceFile","base","path","contents","Buffer","from","content","test","id","componentId","extensions","ExtensionDataList","fromConfigObject","aspects","compDeps","getCompDeps","newDependencies","consumerComponent","ConsumerComponent","mainFile","name","fullName","schema","CURRENT_SCHEMA","overrides","ComponentOverrides","loadNewFromScope","defaultScope","log","message","date","Date","now","toString","username","email","_addFlattenedDependenciesToComponents","version","filesBitObject","legacyScope","sources","consumerComponentToVersion","modelComponent","findOrAddComponent","hash","objects","writeObjectsToTheFS","f","component","getManyByLegacy","newDeps","compIdsData","dep","isComponent","compIdsDataParsed","ComponentID","fromString","compIds","changeVersion","comps","getMany","toDependency","depId","comp","find","c","isEqualWithoutVersion","pkgName","getPackageName","Dependency","type","compDevDeps","compPeerDeps","addDeps","snapData","deps","autoDetect","autoDetectOverrides","updateDeps","dependencies","packageDeps","toPackageObj","pkgs","reduce","acc","curr","getPkgObj","allAutoDeps","depType","manipulateCurrentPkgs","removeDependencies","pkg","found","d","startsWith","replace","manipulateCurrentDeps","currentCompDeps","afterRemoval","includes","toStringWithoutVersion","foundInAutoDeps","packageName","undefined","state","_consumer","dependenciesData","allDependencies","get","devDependencies","peerDependencies","allPackagesDependencies","packageDependencies","devPackageDependencies","peerPackageDependencies","loadDependenciesFromScope","UpdateDepsAspectsSaveIntoDepsResolver"],"sources":["generate-comp-from-scope.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport { Dependency, ConsumerComponent, CURRENT_SCHEMA } from '@teambit/legacy.consumer-component';\nimport { SourceFile } from '@teambit/component.sources';\nimport type { ScopeMain } from '@teambit/scope';\nimport type { DependenciesOverridesData } from '@teambit/legacy.consumer-config';\nimport { ComponentOverrides } from '@teambit/legacy.consumer-config';\nimport { ExtensionDataList } from '@teambit/legacy.extension-data';\nimport type { Component } from '@teambit/component';\nimport type { DependenciesMain } from '@teambit/dependencies';\nimport type { DependencyResolverMain, VariantPolicyConfigArr } from '@teambit/dependency-resolver';\nimport type { FileData, SnappingMain, SnapDataParsed } from './snapping.main.runtime';\n\nexport type NewDependency = {\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\nexport type NewDependencies = NewDependency[];\n\nexport type CompData = {\n componentId: ComponentID;\n dependencies: string[];\n aspects: Record<string, any> | undefined;\n message: string | undefined;\n files: FileData[] | undefined;\n mainFile?: string;\n newDependencies?: NewDependencies;\n};\n\n/**\n * normally new components are created from a workspace. the files are in the filesystem and the ConsumerComponent\n * object is created from the files.\n * here, we need to create the ConsumerComponent object \"on the fly\". we don't have workspace, only scope. the files\n * are in-memory (we got them from snap-from-scope command).\n * the way how it is done is by creating a minimal ConsumerComponent object, then convert `Version` object from it,\n * write the version and files into the scope as objects, so then it's possible to load Component object using the\n * ConsumerComponent.\n */\nexport async function generateCompFromScope(\n scope: ScopeMain,\n depsResolver: DependencyResolverMain,\n compData: CompData,\n snapping: SnappingMain\n): Promise<Component> {\n if (!compData.files) throw new Error('generateComp: files are missing');\n const files = compData.files.map((file) => {\n return new SourceFile({ base: '.', path: file.path, contents: Buffer.from(file.content), test: false });\n });\n const id = compData.componentId;\n const extensions = ExtensionDataList.fromConfigObject(compData.aspects || {});\n const { compDeps } = await getCompDeps(scope, depsResolver, compData.newDependencies || []);\n\n const consumerComponent = new ConsumerComponent({\n mainFile: compData.mainFile || 'index.ts',\n name: compData.componentId.fullName,\n scope: compData.componentId.scope,\n files,\n schema: CURRENT_SCHEMA,\n overrides: await ComponentOverrides.loadNewFromScope(id, files, extensions, compDeps),\n defaultScope: compData.componentId.scope,\n extensions,\n // the dummy data here are not important. this Version object will be discarded later.\n log: {\n message: compData.message || '',\n date: Date.now().toString(),\n username: '',\n email: '',\n },\n });\n // this is needed, otherwise in case of updating envs/aspects, the version-validator throws\n // an error saying \"the extension ${extensionId.toString()} is missing from the flattenedDependencies\"\n await snapping._addFlattenedDependenciesToComponents([consumerComponent]);\n\n const { version, files: filesBitObject } =\n await scope.legacyScope.sources.consumerComponentToVersion(consumerComponent);\n const modelComponent = await scope.legacyScope.sources.findOrAddComponent(consumerComponent);\n consumerComponent.version = version.hash().toString();\n await scope.legacyScope.objects.writeObjectsToTheFS([version, modelComponent, ...filesBitObject.map((f) => f.file)]);\n const component = await scope.getManyByLegacy([consumerComponent]);\n\n return component[0];\n}\n\nasync function getCompDeps(scope: ScopeMain, depsResolver: DependencyResolverMain, newDeps: NewDependencies) {\n const compIdsData = newDeps.filter((dep) => dep.isComponent);\n const compIdsDataParsed = compIdsData.map((data) => ({\n ...data,\n id: ComponentID.fromString(data.id),\n }));\n const compIds = compIdsDataParsed.map((dep) => (dep.version ? dep.id.changeVersion(dep.version) : dep.id));\n const comps = await scope.getMany(compIds);\n const toDependency = (depId: ComponentID) => {\n const comp = comps.find((c) => c.id.isEqualWithoutVersion(depId));\n if (!comp) throw new Error(`unable to find the specified dependency ${depId.toString()} in the scope`);\n const pkgName = depsResolver.getPackageName(comp);\n return new Dependency(comp.id, [], pkgName);\n };\n const compDeps = compIdsDataParsed.filter((c) => c.type === 'runtime').map((dep) => toDependency(dep.id));\n const compDevDeps = compIdsDataParsed.filter((c) => c.type === 'dev').map((dep) => toDependency(dep.id));\n const compPeerDeps = compIdsDataParsed.filter((c) => c.type === 'peer').map((dep) => toDependency(dep.id));\n return { compDeps, compDevDeps, compPeerDeps };\n}\n\nexport async function addDeps(\n component: Component,\n snapData: SnapDataParsed,\n scope: ScopeMain,\n deps: DependenciesMain,\n depsResolver: DependencyResolverMain,\n snapping: SnappingMain,\n autoDetect?: VariantPolicyConfigArr,\n autoDetectOverrides?: DependenciesOverridesData\n) {\n const newDeps = snapData.newDependencies || [];\n const updateDeps = snapData.dependencies || [];\n const packageDeps = newDeps.filter((dep) => !dep.isComponent);\n const { compDeps, compDevDeps, compPeerDeps } = await getCompDeps(scope, depsResolver, newDeps);\n const toPackageObj = (pkgs: Array<{ id: string; version?: string }>) => {\n return pkgs.reduce((acc, curr) => {\n if (!curr.version) throw new Error(`please specify a version for the package dependency: \"${curr.id}\"`);\n acc[curr.id] = curr.version;\n return acc;\n }, {});\n };\n const getPkgObj = (type: 'runtime' | 'dev' | 'peer') => {\n return toPackageObj(packageDeps.filter((dep) => dep.type === type));\n };\n const allAutoDeps: { [pkgName: string]: string } = {};\n ['dependencies', 'devDependencies', 'peerDependencies'].forEach((depType) => {\n autoDetect?.[depType]?.forEach((dep) => {\n allAutoDeps[dep.name] = dep.version;\n });\n });\n\n const manipulateCurrentPkgs = (pkgs: Record<string, string>) => {\n snapData.removeDependencies?.forEach((pkg) => {\n delete pkgs[pkg];\n });\n Object.keys(pkgs).forEach((pkg) => {\n const found = updateDeps.find((d) => d.startsWith(`${pkg}@`));\n if (found) {\n pkgs[pkg] = found.replace(`${pkg}@`, '');\n }\n });\n return pkgs;\n };\n const manipulateCurrentDeps = (currentCompDeps: Dependency[]) => {\n const afterRemoval = currentCompDeps.filter(\n (dep) => !snapData.removeDependencies?.includes(dep.id.toStringWithoutVersion())\n );\n afterRemoval.forEach((dep) => {\n const found = updateDeps.find((d) => d.startsWith(`${dep.id.toStringWithoutVersion()}@`));\n if (found) {\n dep.id = dep.id.changeVersion(found.replace(`${dep.id.toStringWithoutVersion()}@`, ''));\n }\n const foundInAutoDeps = dep.packageName ? allAutoDeps[dep.packageName] : undefined;\n if (foundInAutoDeps) {\n dep.id = dep.id.changeVersion(allAutoDeps[dep.packageName!]);\n }\n });\n return afterRemoval;\n };\n\n const consumerComponent = component.state._consumer as ConsumerComponent;\n\n const dependenciesData = {\n allDependencies: {\n dependencies: [...compDeps, ...manipulateCurrentDeps(consumerComponent.dependencies.get())],\n devDependencies: [...compDevDeps, ...manipulateCurrentDeps(consumerComponent.devDependencies.get())],\n peerDependencies: [...compPeerDeps, ...manipulateCurrentDeps(consumerComponent.peerDependencies.get())],\n },\n allPackagesDependencies: {\n packageDependencies: { ...manipulateCurrentPkgs(consumerComponent.packageDependencies), ...getPkgObj('runtime') },\n devPackageDependencies: {\n ...manipulateCurrentPkgs(consumerComponent.devPackageDependencies),\n ...getPkgObj('dev'),\n },\n peerPackageDependencies: {\n ...manipulateCurrentPkgs(consumerComponent.peerPackageDependencies),\n ...getPkgObj('peer'),\n },\n },\n };\n\n // add the dependencies to the legacy ConsumerComponent object\n // it takes care of both: given dependencies (from the cli) and the overrides, which are coming from the env.\n await deps.loadDependenciesFromScope(consumerComponent, dependenciesData, autoDetectOverrides);\n\n await snapping.UpdateDepsAspectsSaveIntoDepsResolver(component, updateDeps);\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAA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AChE5B,SAAS,CAAC,MAAM,CAAC;IAExB;EACF,CAAC;;EAED;EACA;EACA,MAAMX,IAAI,CAACwC,yBAAyB,CAAClG,iBAAiB,EAAEyF,gBAAgB,EAAE7B,mBAAmB,CAAC;EAE9F,MAAMlF,QAAQ,CAACyH,qCAAqC,CAACpE,SAAS,EAAE8B,UAAU,CAAC;AAC7E","ignoreList":[]}
|
|
@@ -143,6 +143,14 @@ export declare class SnappingMain {
|
|
|
143
143
|
batchId: string;
|
|
144
144
|
}>;
|
|
145
145
|
private addAspectsFromConfigObject;
|
|
146
|
+
/**
|
|
147
|
+
* re-calculate the dependencies policy of the component and its overrides from its config and env, the same way a
|
|
148
|
+
* workspace calculates them when it loads a component, rather than keeping the ones of the version it was loaded from.
|
|
149
|
+
* returns the policy and the overrides of the auto-detected dependencies (versions only, see
|
|
150
|
+
* ApplyOverrides.autoDetectOverrides), which include the deps of the merge-config, same as
|
|
151
|
+
* workspace.getAutoDetectOverrides().
|
|
152
|
+
*/
|
|
153
|
+
private recalcDependenciesPolicy;
|
|
146
154
|
snapFromScope(snapDataPerCompRaw: SnapDataPerCompRaw[], params: {
|
|
147
155
|
push?: boolean;
|
|
148
156
|
ignoreIssues?: string;
|
|
@@ -151,6 +159,7 @@ export declare class SnappingMain {
|
|
|
151
159
|
tag?: boolean;
|
|
152
160
|
updatedLegacyComponents?: ConsumerComponent[];
|
|
153
161
|
loadAspectOnlyForIds?: ComponentIdList;
|
|
162
|
+
recalcDependencies?: boolean;
|
|
154
163
|
} & Partial<BasicTagParams>): Promise<SnapFromScopeResults>;
|
|
155
164
|
/**
|
|
156
165
|
* save the local changes of a component(s) into the scope. snap can be done on main or on a lane.
|
|
@@ -277,6 +286,7 @@ export declare class SnappingMain {
|
|
|
277
286
|
* 2. save all dependencies data from the legacy into DependencyResolver aspect.
|
|
278
287
|
*/
|
|
279
288
|
UpdateDepsAspectsSaveIntoDepsResolver(component: Component, updatedIds: string[]): Promise<void>;
|
|
289
|
+
private updateAspectsVersions;
|
|
280
290
|
/**
|
|
281
291
|
* a new or modified workspace-root component joins every tag and snap of its members. they record
|
|
282
292
|
* the root at the version that has their files (see VersionMaker.recordWorkspaceRoot), and a build
|
|
@@ -194,12 +194,19 @@ function _dependencyResolver() {
|
|
|
194
194
|
return data;
|
|
195
195
|
}
|
|
196
196
|
function _legacy6() {
|
|
197
|
-
const data = require("@teambit/legacy.
|
|
197
|
+
const data = require("@teambit/legacy.consumer-config");
|
|
198
198
|
_legacy6 = function () {
|
|
199
199
|
return data;
|
|
200
200
|
};
|
|
201
201
|
return data;
|
|
202
202
|
}
|
|
203
|
+
function _legacy7() {
|
|
204
|
+
const data = require("@teambit/legacy.extension-data");
|
|
205
|
+
_legacy7 = function () {
|
|
206
|
+
return data;
|
|
207
|
+
};
|
|
208
|
+
return data;
|
|
209
|
+
}
|
|
203
210
|
function _builder() {
|
|
204
211
|
const data = require("@teambit/builder");
|
|
205
212
|
_builder = function () {
|
|
@@ -312,9 +319,9 @@ function _application() {
|
|
|
312
319
|
};
|
|
313
320
|
return data;
|
|
314
321
|
}
|
|
315
|
-
function
|
|
322
|
+
function _legacy8() {
|
|
316
323
|
const data = require("@teambit/legacy.scope-api");
|
|
317
|
-
|
|
324
|
+
_legacy8 = function () {
|
|
318
325
|
return data;
|
|
319
326
|
};
|
|
320
327
|
return data;
|
|
@@ -501,10 +508,10 @@ class SnappingMain {
|
|
|
501
508
|
}
|
|
502
509
|
async addAspectsFromConfigObject(component, configObject) {
|
|
503
510
|
if (!configObject) return;
|
|
504
|
-
|
|
505
|
-
const extensionsFromConfigObject =
|
|
511
|
+
_legacy7().ExtensionDataList.adjustEnvsOnConfigObject(configObject);
|
|
512
|
+
const extensionsFromConfigObject = _legacy7().ExtensionDataList.fromConfigObject(configObject);
|
|
506
513
|
const consumerComponent = component.state._consumer;
|
|
507
|
-
const extensionDataList =
|
|
514
|
+
const extensionDataList = _legacy7().ExtensionDataList.mergeConfigs([extensionsFromConfigObject, consumerComponent.extensions]).filterRemovedExtensions();
|
|
508
515
|
|
|
509
516
|
// Restore data fields from the original extensions after merging configs.
|
|
510
517
|
// configObject contains only config (from the merged config result), it has no data.
|
|
@@ -525,6 +532,49 @@ class SnappingMain {
|
|
|
525
532
|
const autoDeps = extensionsFromConfigObject.extractAutoDepsFromConfig();
|
|
526
533
|
return autoDeps;
|
|
527
534
|
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* re-calculate the dependencies policy of the component and its overrides from its config and env, the same way a
|
|
538
|
+
* workspace calculates them when it loads a component, rather than keeping the ones of the version it was loaded from.
|
|
539
|
+
* returns the policy and the overrides of the auto-detected dependencies (versions only, see
|
|
540
|
+
* ApplyOverrides.autoDetectOverrides), which include the deps of the merge-config, same as
|
|
541
|
+
* workspace.getAutoDetectOverrides().
|
|
542
|
+
*/
|
|
543
|
+
async recalcDependenciesPolicy(component, componentsInSnap, mergeConfigAutoDeps) {
|
|
544
|
+
const legacyComponent = component.state._consumer;
|
|
545
|
+
const {
|
|
546
|
+
extensions
|
|
547
|
+
} = legacyComponent;
|
|
548
|
+
const depResolverExt = extensions.findCoreExtension(_dependencyResolver().DependencyResolverAspect.id);
|
|
549
|
+
// an env that defines its policy in code is loaded only when it changed: a changed env is a changed (or missing)
|
|
550
|
+
// extension, which mergeExtensionsData() reports as a data conflict (see loadAspectOnlyForIds). when it's not
|
|
551
|
+
// loaded, it didn't change, so the env part of the stored policy is still valid. (the other parts, such as the
|
|
552
|
+
// policies of aspects and the config, are calculated by mergeVariantPolicies() from the current config)
|
|
553
|
+
const storedPolicy = _dependencyResolver().VariantPolicy.parse(depResolverExt?.data.policy || []);
|
|
554
|
+
const storedEnvPolicy = storedPolicy.filter(entry => entry.source === 'env');
|
|
555
|
+
// an env.jsonc env that is snapped along (e.g. merged as well) has its policy in its new files, like a workspace
|
|
556
|
+
// that loads the env from its files. otherwise, the policy is read from the stored version of the env.
|
|
557
|
+
const envPolicy = (await this.dependencyResolver.getEnvPolicyFromComponents(extensions, componentsInSnap)) ?? (await this.dependencyResolver.getComponentEnvPolicyFromExtension(extensions, storedEnvPolicy));
|
|
558
|
+
// when the component is an env, its own policy (its own peers) is calculated from its env.jsonc or from the loaded
|
|
559
|
+
// env. same as above, an env that defines it in code and is not loaded didn't change, so the stored one is valid.
|
|
560
|
+
const envExtendsDeps = legacyComponent.dependencies.get();
|
|
561
|
+
const storedEnvOwnPolicy = storedPolicy.filter(entry => entry.source === 'env-own');
|
|
562
|
+
const isEnvOwnPolicyMissing = storedEnvOwnPolicy.length > 0 && !(await this.dependencyResolver.getPoliciesFromEnvForItself(component.id, legacyComponent.files, envExtendsDeps));
|
|
563
|
+
const policy = await this.dependencyResolver.mergeVariantPolicies(extensions, component.id, legacyComponent.files, envExtendsDeps,
|
|
564
|
+
// merged right after the env policy, same as mergeVariantPolicies() merges a calculated own policy
|
|
565
|
+
isEnvOwnPolicyMissing ? _dependencyResolver().VariantPolicy.mergePolices([envPolicy, storedEnvOwnPolicy]) : envPolicy);
|
|
566
|
+
// the "source" of each dependency in the dependency-resolver data is determined by this policy
|
|
567
|
+
if (depResolverExt) depResolverExt.data.policy = policy.serialize();
|
|
568
|
+
legacyComponent.overrides = new (_legacy6().ComponentOverrides)((0, _lodash().pickBy)(policy.toLegacyDepsOverrides(), val => !(0, _lodash().isEmpty)(val)));
|
|
569
|
+
const mergeConfigPolicy = _dependencyResolver().VariantPolicy.fromConfigObject(mergeConfigAutoDeps || {}, {
|
|
570
|
+
source: 'auto'
|
|
571
|
+
});
|
|
572
|
+
const autoDetectOverrides = _dependencyResolver().VariantPolicy.mergePolices([policy, mergeConfigPolicy]).toLegacyAutoDetectOverrides();
|
|
573
|
+
return {
|
|
574
|
+
policy,
|
|
575
|
+
autoDetectOverrides
|
|
576
|
+
};
|
|
577
|
+
}
|
|
528
578
|
async snapFromScope(snapDataPerCompRaw, params) {
|
|
529
579
|
if (this.workspace) {
|
|
530
580
|
throw new (_bitError().BitError)(`unable to run this command from a workspace, please create a new bare-scope and run it from there`);
|
|
@@ -536,7 +586,7 @@ class SnappingMain {
|
|
|
536
586
|
try {
|
|
537
587
|
lane = await this.importer.importLaneObject(laneId);
|
|
538
588
|
} catch (err) {
|
|
539
|
-
if (err.constructor.name !==
|
|
589
|
+
if (err.constructor.name !== _legacy8().LaneNotFound.name) throw err;
|
|
540
590
|
// if the lane is not found, it's probably because it's new. create a new lane.
|
|
541
591
|
lane = await (0, _lanesModules().createLaneInScope)(laneId.name, this.scope, laneId.scope);
|
|
542
592
|
// it's important to set the lane as new in scope.json. otherwise, later, when importing and the lane is loaded
|
|
@@ -628,13 +678,20 @@ class SnappingMain {
|
|
|
628
678
|
});
|
|
629
679
|
}
|
|
630
680
|
const components = [...existingComponents, ...newComponents];
|
|
631
|
-
|
|
681
|
+
const autoDepsPerComp = new Map();
|
|
682
|
+
const addDepsToComp = (component, autoDetectOverrides) => (0, _generateCompFromScope().addDeps)(component, getSnapData(component.id), this.scope, this.deps, this.dependencyResolver, this, autoDepsPerComp.get(component), autoDetectOverrides);
|
|
632
683
|
// this must be done before we load component aspects later on, because this updated deps may update aspects.
|
|
633
684
|
await (0, _pMapSeries().default)(components, async component => {
|
|
634
685
|
const snapData = getSnapData(component.id);
|
|
635
|
-
|
|
686
|
+
autoDepsPerComp.set(component, await this.addAspectsFromConfigObject(component, snapData.aspects));
|
|
687
|
+
if (params.recalcDependencies) {
|
|
688
|
+
// the dependencies are added once the aspects are loaded, see below. only update the versions of aspects that
|
|
689
|
+
// are part of the snap (e.g. an env merged into the lane), so the correct versions get loaded.
|
|
690
|
+
await this.updateAspectsVersions(component, snapData.dependencies);
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
636
693
|
// adds explicitly defined dependencies and dependencies from envs/aspects (overrides)
|
|
637
|
-
await (
|
|
694
|
+
await addDepsToComp(component);
|
|
638
695
|
});
|
|
639
696
|
|
|
640
697
|
// for new components these are not needed. coz when generating them we already add the aspects and the files.
|
|
@@ -670,9 +727,22 @@ class SnappingMain {
|
|
|
670
727
|
} = params;
|
|
671
728
|
const compsToLoadAspects = loadAspectOnlyForIds ? components.filter(c => loadAspectOnlyForIds.hasWithoutVersion(c.id)) : components;
|
|
672
729
|
await this.scope.loadManyCompsAspects(compsToLoadAspects);
|
|
730
|
+
const policyPerComp = new Map();
|
|
731
|
+
if (params.recalcDependencies) {
|
|
732
|
+
// the config (and with it, the env) may differ from the one stored in the version the components were loaded
|
|
733
|
+
// from. now that the env is loaded, the dependencies are calculated according to it.
|
|
734
|
+
await (0, _pMapSeries().default)(components, async component => {
|
|
735
|
+
const {
|
|
736
|
+
policy,
|
|
737
|
+
autoDetectOverrides
|
|
738
|
+
} = await this.recalcDependenciesPolicy(component, components, autoDepsPerComp.get(component));
|
|
739
|
+
policyPerComp.set(component, policy);
|
|
740
|
+
await addDepsToComp(component, autoDetectOverrides);
|
|
741
|
+
});
|
|
742
|
+
}
|
|
673
743
|
|
|
674
744
|
// this is similar to what happens in the workspace. the "onLoad" is running and populating the "data" of the aspects.
|
|
675
|
-
await (0, _pMapSeries().default)(compsToLoadAspects, async comp => this.scope.executeOnCompAspectReCalcSlot(comp));
|
|
745
|
+
await (0, _pMapSeries().default)(compsToLoadAspects, async comp => this.scope.executeOnCompAspectReCalcSlot(comp, policyPerComp.get(comp)));
|
|
676
746
|
const ids = _componentId().ComponentIdList.fromArray(allCompIds);
|
|
677
747
|
const shouldTag = Boolean(params.tag);
|
|
678
748
|
const makeVersionParams = _objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -1484,6 +1554,22 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1484
1554
|
* 2. save all dependencies data from the legacy into DependencyResolver aspect.
|
|
1485
1555
|
*/
|
|
1486
1556
|
async UpdateDepsAspectsSaveIntoDepsResolver(component, updatedIds) {
|
|
1557
|
+
await this.updateAspectsVersions(component, updatedIds);
|
|
1558
|
+
const dependenciesListSerialized = (await this.dependencyResolver.extractDepsFromLegacy(component)).serialize();
|
|
1559
|
+
const extId = _dependencyResolver().DependencyResolverAspect.id;
|
|
1560
|
+
const data = {
|
|
1561
|
+
dependencies: dependenciesListSerialized
|
|
1562
|
+
};
|
|
1563
|
+
const existingExtension = component.config.extensions.findExtension(extId);
|
|
1564
|
+
if (existingExtension) {
|
|
1565
|
+
// Only merge top level of extension data
|
|
1566
|
+
Object.assign(existingExtension.data, data);
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
const extension = new (_legacy7().ExtensionDataEntry)(undefined, undefined, extId, undefined, data);
|
|
1570
|
+
component.config.extensions.push(extension);
|
|
1571
|
+
}
|
|
1572
|
+
async updateAspectsVersions(component, updatedIds) {
|
|
1487
1573
|
const legacyComponent = component.state._consumer;
|
|
1488
1574
|
legacyComponent.extensions.forEach(ext => {
|
|
1489
1575
|
const extId = ext.extensionId;
|
|
@@ -1497,19 +1583,6 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1497
1583
|
}
|
|
1498
1584
|
});
|
|
1499
1585
|
component.state.aspects = await this.scope.createAspectListFromExtensionDataList(legacyComponent.extensions);
|
|
1500
|
-
const dependenciesListSerialized = (await this.dependencyResolver.extractDepsFromLegacy(component)).serialize();
|
|
1501
|
-
const extId = _dependencyResolver().DependencyResolverAspect.id;
|
|
1502
|
-
const data = {
|
|
1503
|
-
dependencies: dependenciesListSerialized
|
|
1504
|
-
};
|
|
1505
|
-
const existingExtension = component.config.extensions.findExtension(extId);
|
|
1506
|
-
if (existingExtension) {
|
|
1507
|
-
// Only merge top level of extension data
|
|
1508
|
-
Object.assign(existingExtension.data, data);
|
|
1509
|
-
return;
|
|
1510
|
-
}
|
|
1511
|
-
const extension = new (_legacy6().ExtensionDataEntry)(undefined, undefined, extId, undefined, data);
|
|
1512
|
-
component.config.extensions.push(extension);
|
|
1513
1586
|
}
|
|
1514
1587
|
|
|
1515
1588
|
/**
|