@teambit/dependency-resolver 0.0.967 → 0.0.968
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/dependency-installer.d.ts +3 -1
- package/dist/dependency-installer.js +6 -3
- package/dist/dependency-installer.js.map +1 -1
- package/dist/manifest/update-dependency-version.d.ts +1 -1
- package/dist/manifest/update-dependency-version.js +2 -2
- package/dist/manifest/update-dependency-version.js.map +1 -1
- package/dist/manifest/workspace-manifest-factory.d.ts +1 -0
- package/dist/manifest/workspace-manifest-factory.js +6 -3
- package/dist/manifest/workspace-manifest-factory.js.map +1 -1
- package/dist/{preview-1674617375675.js → preview-1674703855071.js} +2 -2
- package/manifest/update-dependency-version.ts +4 -4
- package/manifest/workspace-manifest-factory.ts +11 -7
- package/package-tar/teambit-dependency-resolver-0.0.968.tgz +0 -0
- package/package.json +9 -9
- package/package-tar/teambit-dependency-resolver-0.0.967.tgz +0 -0
|
@@ -15,11 +15,13 @@ export declare type InstallArgs = {
|
|
|
15
15
|
export declare type InstallOptions = {
|
|
16
16
|
installTeambitBit: boolean;
|
|
17
17
|
packageManagerConfigRootDir?: string;
|
|
18
|
+
resolveVersionsFromDependenciesOnly?: boolean;
|
|
18
19
|
};
|
|
19
20
|
export declare type GetComponentManifestsOptions = {
|
|
20
21
|
componentDirectoryMap: ComponentMap<string>;
|
|
21
22
|
rootPolicy: WorkspacePolicy;
|
|
22
23
|
rootDir: string;
|
|
24
|
+
resolveVersionsFromDependenciesOnly?: boolean;
|
|
23
25
|
} & Pick<PackageManagerInstallOptions, 'dedupe' | 'dependencyFilterFn' | 'copyPeerToRuntimeOnComponents' | 'copyPeerToRuntimeOnRoot' | 'installPeersFromEnvs'>;
|
|
24
26
|
export declare type PreInstallSubscriber = (installer: DependencyInstaller, installArgs: InstallArgs) => Promise<void>;
|
|
25
27
|
export declare type PreInstallSubscriberList = Array<PreInstallSubscriber>;
|
|
@@ -54,7 +56,7 @@ export declare class DependencyInstaller {
|
|
|
54
56
|
* Compute all the component manifests (a.k.a. package.json files) that should be passed to the package manager
|
|
55
57
|
* in order to install the dependencies.
|
|
56
58
|
*/
|
|
57
|
-
getComponentManifests({ componentDirectoryMap, rootPolicy, rootDir, dedupe, dependencyFilterFn, copyPeerToRuntimeOnComponents, copyPeerToRuntimeOnRoot, installPeersFromEnvs, }: GetComponentManifestsOptions): Promise<Record<string, ProjectManifest>>;
|
|
59
|
+
getComponentManifests({ componentDirectoryMap, rootPolicy, rootDir, dedupe, dependencyFilterFn, copyPeerToRuntimeOnComponents, copyPeerToRuntimeOnRoot, installPeersFromEnvs, resolveVersionsFromDependenciesOnly, }: GetComponentManifestsOptions): Promise<Record<string, ProjectManifest>>;
|
|
58
60
|
private cleanCompsNodeModules;
|
|
59
61
|
private runPrePostSubscribers;
|
|
60
62
|
}
|
|
@@ -89,7 +89,8 @@ class DependencyInstaller {
|
|
|
89
89
|
const manifests = await this.getComponentManifests(_objectSpread(_objectSpread({}, packageManagerOptions), {}, {
|
|
90
90
|
componentDirectoryMap,
|
|
91
91
|
rootPolicy,
|
|
92
|
-
rootDir: finalRootDir
|
|
92
|
+
rootDir: finalRootDir,
|
|
93
|
+
resolveVersionsFromDependenciesOnly: options.resolveVersionsFromDependenciesOnly
|
|
93
94
|
}));
|
|
94
95
|
return this.installComponents(finalRootDir, manifests, rootPolicy, componentDirectoryMap, options, packageManagerOptions);
|
|
95
96
|
}
|
|
@@ -162,13 +163,15 @@ class DependencyInstaller {
|
|
|
162
163
|
dependencyFilterFn,
|
|
163
164
|
copyPeerToRuntimeOnComponents,
|
|
164
165
|
copyPeerToRuntimeOnRoot,
|
|
165
|
-
installPeersFromEnvs
|
|
166
|
+
installPeersFromEnvs,
|
|
167
|
+
resolveVersionsFromDependenciesOnly
|
|
166
168
|
}) {
|
|
167
169
|
const options = {
|
|
168
170
|
filterComponentsFromManifests: true,
|
|
169
171
|
createManifestForComponentsWithoutDependencies: true,
|
|
170
172
|
dedupe,
|
|
171
|
-
dependencyFilterFn
|
|
173
|
+
dependencyFilterFn,
|
|
174
|
+
resolveVersionsFromDependenciesOnly
|
|
172
175
|
};
|
|
173
176
|
const workspaceManifest = await this.dependencyResolver.getWorkspaceManifest(undefined, undefined, rootPolicy, rootDir, componentDirectoryMap.components, options);
|
|
174
177
|
const manifests = componentDirectoryMap.toArray().reduce((acc, [component, dir]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_PM_INSTALL_OPTIONS","dedupe","copyPeerToRuntimeOnRoot","copyPeerToRuntimeOnComponents","installPeersFromEnvs","DEFAULT_INSTALL_OPTIONS","installTeambitBit","DependencyInstaller","constructor","packageManager","aspectLoader","logger","dependencyResolver","rootDir","cacheRootDir","preInstallSubscriberList","postInstallSubscriberList","nodeLinker","packageImportMethod","sideEffectsCache","nodeVersion","engineStrict","peerDependencyRules","install","rootPolicy","componentDirectoryMap","options","packageManagerOptions","finalRootDir","RootDirNotDefined","manifests","getComponentManifests","installComponents","args","runPrePostSubscribers","mainAspect","calculatedPmOpts","packageManagerConfigRootDir","version","packageName","MainAspectNotInstallable","add","dependencyId","lifecycleType","value","rootComponents","keepExistingModulesDir","cleanCompsNodeModules","dependencyFilterFn","filterComponentsFromManifests","createManifestForComponentsWithoutDependencies","workspaceManifest","getWorkspaceManifest","undefined","components","toArray","reduce","acc","component","dir","getPackageName","manifest","componentsManifestsMap","get","toJson","copyPeerToRuntime","defaultPeerDependencies","fromPairs","envPolicy","selfPolicy","toNameVersionTuple","promises","map","nmDir","path","join","fs","remove","Promise","all","subscribers","type","message","setStatusLine","mapSeries","subscriber","consoleSuccess"],"sources":["dependency-installer.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport path from 'path';\nimport fs from 'fs-extra';\nimport { MainAspect, AspectLoaderMain } from '@teambit/aspect-loader';\nimport { ComponentMap } from '@teambit/component';\nimport { CreateFromComponentsOptions, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { PathAbsolute } from '@teambit/legacy/dist/utils/path';\nimport { PeerDependencyRules, ProjectManifest } from '@pnpm/types';\nimport { fromPairs } from 'lodash';\nimport { MainAspectNotInstallable, RootDirNotDefined } from './exceptions';\nimport { PackageManager, PackageManagerInstallOptions, PackageImportMethod } from './package-manager';\nimport { WorkspacePolicy } from './policy';\n\nconst DEFAULT_PM_INSTALL_OPTIONS: PackageManagerInstallOptions = {\n dedupe: true,\n copyPeerToRuntimeOnRoot: true,\n copyPeerToRuntimeOnComponents: false,\n installPeersFromEnvs: false,\n};\n\nconst DEFAULT_INSTALL_OPTIONS: InstallOptions = {\n installTeambitBit: false,\n};\n\nexport type InstallArgs = {\n rootDir: string | undefined;\n rootPolicy: WorkspacePolicy;\n componentDirectoryMap: ComponentMap<string>;\n options: InstallOptions;\n packageManagerOptions: PackageManagerInstallOptions;\n};\n\nexport type InstallOptions = {\n installTeambitBit: boolean;\n packageManagerConfigRootDir?: string;\n};\n\nexport type GetComponentManifestsOptions = {\n componentDirectoryMap: ComponentMap<string>;\n rootPolicy: WorkspacePolicy;\n rootDir: string;\n} & Pick<\n PackageManagerInstallOptions,\n 'dedupe' | 'dependencyFilterFn' | 'copyPeerToRuntimeOnComponents' | 'copyPeerToRuntimeOnRoot' | 'installPeersFromEnvs'\n>;\n\nexport type PreInstallSubscriber = (installer: DependencyInstaller, installArgs: InstallArgs) => Promise<void>;\nexport type PreInstallSubscriberList = Array<PreInstallSubscriber>;\n\nexport type PostInstallSubscriber = (installer: DependencyInstaller, installArgs: InstallArgs) => Promise<void>;\nexport type PostInstallSubscriberList = Array<PostInstallSubscriber>;\n\nexport class DependencyInstaller {\n constructor(\n /**\n * package manager instance.\n */\n private packageManager: PackageManager,\n\n private aspectLoader: AspectLoaderMain,\n\n private logger: Logger,\n\n private dependencyResolver: DependencyResolverMain,\n\n private rootDir?: string | PathAbsolute,\n\n private cacheRootDir?: string | PathAbsolute,\n\n private preInstallSubscriberList?: PreInstallSubscriberList,\n\n private postInstallSubscriberList?: PostInstallSubscriberList,\n\n private nodeLinker?: 'hoisted' | 'isolated',\n\n private packageImportMethod?: PackageImportMethod,\n\n private sideEffectsCache?: boolean,\n\n private nodeVersion?: string,\n\n private engineStrict?: boolean,\n\n private peerDependencyRules?: PeerDependencyRules\n ) {}\n\n async install(\n rootDir: string | undefined,\n rootPolicy: WorkspacePolicy,\n componentDirectoryMap: ComponentMap<string>,\n options: InstallOptions = DEFAULT_INSTALL_OPTIONS,\n packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS\n ) {\n const finalRootDir = rootDir ?? this.rootDir;\n if (!finalRootDir) {\n throw new RootDirNotDefined();\n }\n const manifests = await this.getComponentManifests({\n ...packageManagerOptions,\n componentDirectoryMap,\n rootPolicy,\n rootDir: finalRootDir,\n });\n return this.installComponents(\n finalRootDir,\n manifests,\n rootPolicy,\n componentDirectoryMap,\n options,\n packageManagerOptions\n );\n }\n\n async installComponents(\n rootDir: string | undefined,\n manifests: Record<string, ProjectManifest>,\n rootPolicy: WorkspacePolicy,\n componentDirectoryMap: ComponentMap<string>,\n options: InstallOptions = DEFAULT_INSTALL_OPTIONS,\n packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS\n ) {\n const args = {\n componentDirectoryMap,\n options,\n packageManagerOptions,\n rootDir,\n rootPolicy,\n };\n await this.runPrePostSubscribers(this.preInstallSubscriberList, 'pre', args);\n const mainAspect: MainAspect = this.aspectLoader.mainAspect;\n const finalRootDir = rootDir || this.rootDir;\n if (!finalRootDir) {\n throw new RootDirNotDefined();\n }\n // Make sure to take other default if passed options with only one option\n const calculatedPmOpts = {\n ...DEFAULT_PM_INSTALL_OPTIONS,\n cacheRootDir: this.cacheRootDir,\n nodeLinker: this.nodeLinker,\n packageImportMethod: this.packageImportMethod,\n sideEffectsCache: this.sideEffectsCache,\n nodeVersion: this.nodeVersion,\n engineStrict: this.engineStrict,\n packageManagerConfigRootDir: options.packageManagerConfigRootDir,\n peerDependencyRules: this.peerDependencyRules,\n ...packageManagerOptions,\n };\n if (options.installTeambitBit) {\n if (!mainAspect.version || !mainAspect.packageName) {\n throw new MainAspectNotInstallable();\n }\n const version = mainAspect.version;\n rootPolicy.add({\n dependencyId: mainAspect.packageName,\n lifecycleType: 'runtime',\n value: {\n version,\n },\n });\n }\n\n if (!packageManagerOptions.rootComponents && !packageManagerOptions.keepExistingModulesDir) {\n // Remove node modules dir for all components dirs, since it might contain left overs from previous install.\n //\n // This is not needed when \"rootComponents\" are used, as in that case the package manager handles the node_modules\n // and it never leaves node_modules in a broken state.\n // Removing node_modules in that case would delete useful state information that is used by Yarn or pnpm.\n await this.cleanCompsNodeModules(componentDirectoryMap);\n }\n\n // TODO: the cache should be probably passed to the package manager constructor not to the install function\n await this.packageManager.install(\n {\n rootDir: finalRootDir,\n manifests,\n componentDirectoryMap,\n },\n calculatedPmOpts\n );\n await this.runPrePostSubscribers(this.postInstallSubscriberList, 'post', args);\n return componentDirectoryMap;\n }\n\n /**\n * Compute all the component manifests (a.k.a. package.json files) that should be passed to the package manager\n * in order to install the dependencies.\n */\n public async getComponentManifests({\n componentDirectoryMap,\n rootPolicy,\n rootDir,\n dedupe,\n dependencyFilterFn,\n copyPeerToRuntimeOnComponents,\n copyPeerToRuntimeOnRoot,\n installPeersFromEnvs,\n }: GetComponentManifestsOptions) {\n const options: CreateFromComponentsOptions = {\n filterComponentsFromManifests: true,\n createManifestForComponentsWithoutDependencies: true,\n dedupe,\n dependencyFilterFn,\n };\n const workspaceManifest = await this.dependencyResolver.getWorkspaceManifest(\n undefined,\n undefined,\n rootPolicy,\n rootDir,\n componentDirectoryMap.components,\n options\n );\n const manifests: Record<string, ProjectManifest> = componentDirectoryMap\n .toArray()\n .reduce((acc, [component, dir]) => {\n const packageName = this.dependencyResolver.getPackageName(component);\n const manifest = workspaceManifest.componentsManifestsMap.get(packageName);\n if (manifest) {\n acc[dir] = manifest.toJson({ copyPeerToRuntime: copyPeerToRuntimeOnComponents });\n acc[dir].defaultPeerDependencies = fromPairs(\n manifest.envPolicy.selfPolicy.toNameVersionTuple()\n );\n }\n return acc;\n }, {});\n if (!manifests[rootDir]) {\n manifests[rootDir] = workspaceManifest.toJson({\n copyPeerToRuntime: copyPeerToRuntimeOnRoot,\n installPeersFromEnvs,\n });\n }\n return manifests;\n }\n\n private async cleanCompsNodeModules(componentDirectoryMap: ComponentMap<string>) {\n const promises = componentDirectoryMap.toArray().map(([, dir]) => {\n const nmDir = path.join(dir, 'node_modules');\n return fs.remove(nmDir);\n });\n return Promise.all(promises);\n }\n\n private async runPrePostSubscribers(\n subscribers: PreInstallSubscriberList | PostInstallSubscriberList = [],\n type: 'pre' | 'post',\n args: InstallArgs\n ): Promise<void> {\n let message = 'running pre install subscribers';\n if (type === 'post') {\n message = 'running post install subscribers';\n }\n this.logger.setStatusLine(message);\n await mapSeries(subscribers, async (subscriber) => {\n return subscriber(this, args);\n });\n this.logger.consoleSuccess(message);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA2E;AAAA;AAI3E,MAAMA,0BAAwD,GAAG;EAC/DC,MAAM,EAAE,IAAI;EACZC,uBAAuB,EAAE,IAAI;EAC7BC,6BAA6B,EAAE,KAAK;EACpCC,oBAAoB,EAAE;AACxB,CAAC;AAED,MAAMC,uBAAuC,GAAG;EAC9CC,iBAAiB,EAAE;AACrB,CAAC;AA8BM,MAAMC,mBAAmB,CAAC;EAC/BC,WAAW;EACT;AACJ;AACA;EACYC,cAA8B,EAE9BC,YAA8B,EAE9BC,MAAc,EAEdC,kBAA0C,EAE1CC,OAA+B,EAE/BC,YAAoC,EAEpCC,wBAA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C,CAAC;IACF,IAAI,CAACtB,MAAM,CAAC2E,cAAc,CAACJ,OAAO,CAAC;EACrC;AACF;AAAC"}
|
|
1
|
+
{"version":3,"names":["DEFAULT_PM_INSTALL_OPTIONS","dedupe","copyPeerToRuntimeOnRoot","copyPeerToRuntimeOnComponents","installPeersFromEnvs","DEFAULT_INSTALL_OPTIONS","installTeambitBit","DependencyInstaller","constructor","packageManager","aspectLoader","logger","dependencyResolver","rootDir","cacheRootDir","preInstallSubscriberList","postInstallSubscriberList","nodeLinker","packageImportMethod","sideEffectsCache","nodeVersion","engineStrict","peerDependencyRules","install","rootPolicy","componentDirectoryMap","options","packageManagerOptions","finalRootDir","RootDirNotDefined","manifests","getComponentManifests","resolveVersionsFromDependenciesOnly","installComponents","args","runPrePostSubscribers","mainAspect","calculatedPmOpts","packageManagerConfigRootDir","version","packageName","MainAspectNotInstallable","add","dependencyId","lifecycleType","value","rootComponents","keepExistingModulesDir","cleanCompsNodeModules","dependencyFilterFn","filterComponentsFromManifests","createManifestForComponentsWithoutDependencies","workspaceManifest","getWorkspaceManifest","undefined","components","toArray","reduce","acc","component","dir","getPackageName","manifest","componentsManifestsMap","get","toJson","copyPeerToRuntime","defaultPeerDependencies","fromPairs","envPolicy","selfPolicy","toNameVersionTuple","promises","map","nmDir","path","join","fs","remove","Promise","all","subscribers","type","message","setStatusLine","mapSeries","subscriber","consoleSuccess"],"sources":["dependency-installer.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport path from 'path';\nimport fs from 'fs-extra';\nimport { MainAspect, AspectLoaderMain } from '@teambit/aspect-loader';\nimport { ComponentMap } from '@teambit/component';\nimport { CreateFromComponentsOptions, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { PathAbsolute } from '@teambit/legacy/dist/utils/path';\nimport { PeerDependencyRules, ProjectManifest } from '@pnpm/types';\nimport { fromPairs } from 'lodash';\nimport { MainAspectNotInstallable, RootDirNotDefined } from './exceptions';\nimport { PackageManager, PackageManagerInstallOptions, PackageImportMethod } from './package-manager';\nimport { WorkspacePolicy } from './policy';\n\nconst DEFAULT_PM_INSTALL_OPTIONS: PackageManagerInstallOptions = {\n dedupe: true,\n copyPeerToRuntimeOnRoot: true,\n copyPeerToRuntimeOnComponents: false,\n installPeersFromEnvs: false,\n};\n\nconst DEFAULT_INSTALL_OPTIONS: InstallOptions = {\n installTeambitBit: false,\n};\n\nexport type InstallArgs = {\n rootDir: string | undefined;\n rootPolicy: WorkspacePolicy;\n componentDirectoryMap: ComponentMap<string>;\n options: InstallOptions;\n packageManagerOptions: PackageManagerInstallOptions;\n};\n\nexport type InstallOptions = {\n installTeambitBit: boolean;\n packageManagerConfigRootDir?: string;\n resolveVersionsFromDependenciesOnly?: boolean;\n};\n\nexport type GetComponentManifestsOptions = {\n componentDirectoryMap: ComponentMap<string>;\n rootPolicy: WorkspacePolicy;\n rootDir: string;\n resolveVersionsFromDependenciesOnly?: boolean;\n} & Pick<\n PackageManagerInstallOptions,\n 'dedupe' | 'dependencyFilterFn' | 'copyPeerToRuntimeOnComponents' | 'copyPeerToRuntimeOnRoot' | 'installPeersFromEnvs'\n>;\n\nexport type PreInstallSubscriber = (installer: DependencyInstaller, installArgs: InstallArgs) => Promise<void>;\nexport type PreInstallSubscriberList = Array<PreInstallSubscriber>;\n\nexport type PostInstallSubscriber = (installer: DependencyInstaller, installArgs: InstallArgs) => Promise<void>;\nexport type PostInstallSubscriberList = Array<PostInstallSubscriber>;\n\nexport class DependencyInstaller {\n constructor(\n /**\n * package manager instance.\n */\n private packageManager: PackageManager,\n\n private aspectLoader: AspectLoaderMain,\n\n private logger: Logger,\n\n private dependencyResolver: DependencyResolverMain,\n\n private rootDir?: string | PathAbsolute,\n\n private cacheRootDir?: string | PathAbsolute,\n\n private preInstallSubscriberList?: PreInstallSubscriberList,\n\n private postInstallSubscriberList?: PostInstallSubscriberList,\n\n private nodeLinker?: 'hoisted' | 'isolated',\n\n private packageImportMethod?: PackageImportMethod,\n\n private sideEffectsCache?: boolean,\n\n private nodeVersion?: string,\n\n private engineStrict?: boolean,\n\n private peerDependencyRules?: PeerDependencyRules\n ) {}\n\n async install(\n rootDir: string | undefined,\n rootPolicy: WorkspacePolicy,\n componentDirectoryMap: ComponentMap<string>,\n options: InstallOptions = DEFAULT_INSTALL_OPTIONS,\n packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS\n ) {\n const finalRootDir = rootDir ?? this.rootDir;\n if (!finalRootDir) {\n throw new RootDirNotDefined();\n }\n const manifests = await this.getComponentManifests({\n ...packageManagerOptions,\n componentDirectoryMap,\n rootPolicy,\n rootDir: finalRootDir,\n resolveVersionsFromDependenciesOnly: options.resolveVersionsFromDependenciesOnly,\n });\n return this.installComponents(\n finalRootDir,\n manifests,\n rootPolicy,\n componentDirectoryMap,\n options,\n packageManagerOptions\n );\n }\n\n async installComponents(\n rootDir: string | undefined,\n manifests: Record<string, ProjectManifest>,\n rootPolicy: WorkspacePolicy,\n componentDirectoryMap: ComponentMap<string>,\n options: InstallOptions = DEFAULT_INSTALL_OPTIONS,\n packageManagerOptions: PackageManagerInstallOptions = DEFAULT_PM_INSTALL_OPTIONS\n ) {\n const args = {\n componentDirectoryMap,\n options,\n packageManagerOptions,\n rootDir,\n rootPolicy,\n };\n await this.runPrePostSubscribers(this.preInstallSubscriberList, 'pre', args);\n const mainAspect: MainAspect = this.aspectLoader.mainAspect;\n const finalRootDir = rootDir || this.rootDir;\n if (!finalRootDir) {\n throw new RootDirNotDefined();\n }\n // Make sure to take other default if passed options with only one option\n const calculatedPmOpts = {\n ...DEFAULT_PM_INSTALL_OPTIONS,\n cacheRootDir: this.cacheRootDir,\n nodeLinker: this.nodeLinker,\n packageImportMethod: this.packageImportMethod,\n sideEffectsCache: this.sideEffectsCache,\n nodeVersion: this.nodeVersion,\n engineStrict: this.engineStrict,\n packageManagerConfigRootDir: options.packageManagerConfigRootDir,\n peerDependencyRules: this.peerDependencyRules,\n ...packageManagerOptions,\n };\n if (options.installTeambitBit) {\n if (!mainAspect.version || !mainAspect.packageName) {\n throw new MainAspectNotInstallable();\n }\n const version = mainAspect.version;\n rootPolicy.add({\n dependencyId: mainAspect.packageName,\n lifecycleType: 'runtime',\n value: {\n version,\n },\n });\n }\n\n if (!packageManagerOptions.rootComponents && !packageManagerOptions.keepExistingModulesDir) {\n // Remove node modules dir for all components dirs, since it might contain left overs from previous install.\n //\n // This is not needed when \"rootComponents\" are used, as in that case the package manager handles the node_modules\n // and it never leaves node_modules in a broken state.\n // Removing node_modules in that case would delete useful state information that is used by Yarn or pnpm.\n await this.cleanCompsNodeModules(componentDirectoryMap);\n }\n\n // TODO: the cache should be probably passed to the package manager constructor not to the install function\n await this.packageManager.install(\n {\n rootDir: finalRootDir,\n manifests,\n componentDirectoryMap,\n },\n calculatedPmOpts\n );\n await this.runPrePostSubscribers(this.postInstallSubscriberList, 'post', args);\n return componentDirectoryMap;\n }\n\n /**\n * Compute all the component manifests (a.k.a. package.json files) that should be passed to the package manager\n * in order to install the dependencies.\n */\n public async getComponentManifests({\n componentDirectoryMap,\n rootPolicy,\n rootDir,\n dedupe,\n dependencyFilterFn,\n copyPeerToRuntimeOnComponents,\n copyPeerToRuntimeOnRoot,\n installPeersFromEnvs,\n resolveVersionsFromDependenciesOnly,\n }: GetComponentManifestsOptions) {\n const options: CreateFromComponentsOptions = {\n filterComponentsFromManifests: true,\n createManifestForComponentsWithoutDependencies: true,\n dedupe,\n dependencyFilterFn,\n resolveVersionsFromDependenciesOnly,\n };\n const workspaceManifest = await this.dependencyResolver.getWorkspaceManifest(\n undefined,\n undefined,\n rootPolicy,\n rootDir,\n componentDirectoryMap.components,\n options\n );\n const manifests: Record<string, ProjectManifest> = componentDirectoryMap\n .toArray()\n .reduce((acc, [component, dir]) => {\n const packageName = this.dependencyResolver.getPackageName(component);\n const manifest = workspaceManifest.componentsManifestsMap.get(packageName);\n if (manifest) {\n acc[dir] = manifest.toJson({ copyPeerToRuntime: copyPeerToRuntimeOnComponents });\n acc[dir].defaultPeerDependencies = fromPairs(manifest.envPolicy.selfPolicy.toNameVersionTuple());\n }\n return acc;\n }, {});\n if (!manifests[rootDir]) {\n manifests[rootDir] = workspaceManifest.toJson({\n copyPeerToRuntime: copyPeerToRuntimeOnRoot,\n installPeersFromEnvs,\n });\n }\n return manifests;\n }\n\n private async cleanCompsNodeModules(componentDirectoryMap: ComponentMap<string>) {\n const promises = componentDirectoryMap.toArray().map(([, dir]) => {\n const nmDir = path.join(dir, 'node_modules');\n return fs.remove(nmDir);\n });\n return Promise.all(promises);\n }\n\n private async runPrePostSubscribers(\n subscribers: PreInstallSubscriberList | PostInstallSubscriberList = [],\n type: 'pre' | 'post',\n args: InstallArgs\n ): Promise<void> {\n let message = 'running pre install subscribers';\n if (type === 'post') {\n message = 'running post install subscribers';\n }\n this.logger.setStatusLine(message);\n await mapSeries(subscribers, async (subscriber) => {\n return subscriber(this, args);\n });\n this.logger.consoleSuccess(message);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAOA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA2E;AAAA;AAI3E,MAAMA,0BAAwD,GAAG;EAC/DC,MAAM,EAAE,IAAI;EACZC,uBAAuB,EAAE,IAAI;EAC7BC,6BAA6B,EAAE,KAAK;EACpCC,oBAAoB,EAAE;AACxB,CAAC;AAED,MAAMC,uBAAuC,GAAG;EAC9CC,iBAAiB,EAAE;AACrB,CAAC;AAgCM,MAAMC,mBAAmB,CAAC;EAC/BC,WAAW;EACT;AACJ;AACA;EACYC,cAA8B,EAE9BC,YAA8B,EAE9BC,MAAc,EAEdC,kBAA0C,EAE1CC,OAA+B,EAE/BC,YAAoC,EAEpCC,wBAAmD,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K,UAAU,IAAK;MACjD,OAAOA,UAAU,CAAC,IAAI,EAAEpD,IAAI,CAAC;IAC/B,CAAC,CAAC;IACF,IAAI,CAACvB,MAAM,CAAC4E,cAAc,CAACJ,OAAO,CAAC;EACrC;AACF;AAAC"}
|
|
@@ -22,4 +22,4 @@ import { VariantPolicy, WorkspacePolicy } from '../policy';
|
|
|
22
22
|
* @param {MergeDependenciesFunc} mergeDependenciesFunc
|
|
23
23
|
* @returns {DepVersionModifierFunc}
|
|
24
24
|
*/
|
|
25
|
-
export declare function updateDependencyVersion(dependency: Dependency, rootPolicy
|
|
25
|
+
export declare function updateDependencyVersion(dependency: Dependency, rootPolicy?: WorkspacePolicy, variantPolicy?: VariantPolicy): void;
|
|
@@ -36,9 +36,9 @@ function _componentPackageVersion() {
|
|
|
36
36
|
function updateDependencyVersion(dependency, rootPolicy, variantPolicy) {
|
|
37
37
|
if (dependency.getPackageName) {
|
|
38
38
|
const packageName = dependency.getPackageName();
|
|
39
|
-
const variantVersion = variantPolicy.getDepVersion(packageName, dependency.lifecycle);
|
|
39
|
+
const variantVersion = variantPolicy === null || variantPolicy === void 0 ? void 0 : variantPolicy.getDepVersion(packageName, dependency.lifecycle);
|
|
40
40
|
const variantVersionWithoutMinus = variantVersion && variantVersion !== '-' ? variantVersion : undefined;
|
|
41
|
-
const version = variantVersionWithoutMinus || rootPolicy.getValidSemverDepVersion(packageName, dependency.lifecycle === 'peer' ? 'peer' : 'runtime') || (0, _componentPackageVersion().snapToSemver)(dependency.version) || '0.0.1-new';
|
|
41
|
+
const version = variantVersionWithoutMinus || (rootPolicy === null || rootPolicy === void 0 ? void 0 : rootPolicy.getValidSemverDepVersion(packageName, dependency.lifecycle === 'peer' ? 'peer' : 'runtime')) || (0, _componentPackageVersion().snapToSemver)(dependency.version) || '0.0.1-new';
|
|
42
42
|
dependency.setVersion(version);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["updateDependencyVersion","dependency","rootPolicy","variantPolicy","getPackageName","packageName","variantVersion","getDepVersion","lifecycle","variantVersionWithoutMinus","undefined","version","getValidSemverDepVersion","snapToSemver","setVersion"],"sources":["update-dependency-version.ts"],"sourcesContent":["import { snapToSemver } from '@teambit/component-package-version';\nimport { Dependency } from '../dependencies';\nimport { VariantPolicy, WorkspacePolicy } from '../policy';\n\n/**\n * This will create a function that will modify the version of the component dependencies before calling the package manager install\n * It's important for this use case:\n * between 2 bit components we are not allowing a range, only a specific version as dependency\n * therefor, when resolve a component dependency we take the version from the actual installed version in the file system\n * imagine the following case\n * I have in my policy my-dep:0.0.10\n * during installation it is installed (hoisted to the root)\n * now i'm changing it to be ^0.0.11\n * On the next bit install, when I will look at the component deps I'll see it with version 0.0.10 always (that's resolved from the FS)\n * so the version ^0.0.11 will be never installed.\n * For installation purpose we want a different resolve method, we want to take the version from the policies so we will install the correct one\n * this function will get the root deps / policy, and a function to merge the component policies (by the dep resolver extension).\n * it will then search for the dep version in the component policy, than in the workspace policy and take it from there\n * now in the described case, it will be change to ^0.0.11 and will be install correctly\n * then on the next calculation for tagging it will have the installed version\n *\n * @param {Component} component\n * @param {ManifestDependenciesObject} rootDependencies\n * @param {MergeDependenciesFunc} mergeDependenciesFunc\n * @returns {DepVersionModifierFunc}\n */\nexport function updateDependencyVersion(\n dependency: Dependency,\n rootPolicy
|
|
1
|
+
{"version":3,"names":["updateDependencyVersion","dependency","rootPolicy","variantPolicy","getPackageName","packageName","variantVersion","getDepVersion","lifecycle","variantVersionWithoutMinus","undefined","version","getValidSemverDepVersion","snapToSemver","setVersion"],"sources":["update-dependency-version.ts"],"sourcesContent":["import { snapToSemver } from '@teambit/component-package-version';\nimport { Dependency } from '../dependencies';\nimport { VariantPolicy, WorkspacePolicy } from '../policy';\n\n/**\n * This will create a function that will modify the version of the component dependencies before calling the package manager install\n * It's important for this use case:\n * between 2 bit components we are not allowing a range, only a specific version as dependency\n * therefor, when resolve a component dependency we take the version from the actual installed version in the file system\n * imagine the following case\n * I have in my policy my-dep:0.0.10\n * during installation it is installed (hoisted to the root)\n * now i'm changing it to be ^0.0.11\n * On the next bit install, when I will look at the component deps I'll see it with version 0.0.10 always (that's resolved from the FS)\n * so the version ^0.0.11 will be never installed.\n * For installation purpose we want a different resolve method, we want to take the version from the policies so we will install the correct one\n * this function will get the root deps / policy, and a function to merge the component policies (by the dep resolver extension).\n * it will then search for the dep version in the component policy, than in the workspace policy and take it from there\n * now in the described case, it will be change to ^0.0.11 and will be install correctly\n * then on the next calculation for tagging it will have the installed version\n *\n * @param {Component} component\n * @param {ManifestDependenciesObject} rootDependencies\n * @param {MergeDependenciesFunc} mergeDependenciesFunc\n * @returns {DepVersionModifierFunc}\n */\nexport function updateDependencyVersion(\n dependency: Dependency,\n rootPolicy?: WorkspacePolicy,\n variantPolicy?: VariantPolicy\n): void {\n if (dependency.getPackageName) {\n const packageName = dependency.getPackageName();\n const variantVersion = variantPolicy?.getDepVersion(packageName, dependency.lifecycle);\n const variantVersionWithoutMinus = variantVersion && variantVersion !== '-' ? variantVersion : undefined;\n const version =\n variantVersionWithoutMinus ||\n rootPolicy?.getValidSemverDepVersion(packageName, dependency.lifecycle === 'peer' ? 'peer' : 'runtime') ||\n snapToSemver(dependency.version) ||\n '0.0.1-new';\n\n dependency.setVersion(version);\n }\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,uBAAuB,CACrCC,UAAsB,EACtBC,UAA4B,EAC5BC,aAA6B,EACvB;EACN,IAAIF,UAAU,CAACG,cAAc,EAAE;IAC7B,MAAMC,WAAW,GAAGJ,UAAU,CAACG,cAAc,EAAE;IAC/C,MAAME,cAAc,GAAGH,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEI,aAAa,CAACF,WAAW,EAAEJ,UAAU,CAACO,SAAS,CAAC;IACtF,MAAMC,0BAA0B,GAAGH,cAAc,IAAIA,cAAc,KAAK,GAAG,GAAGA,cAAc,GAAGI,SAAS;IACxG,MAAMC,OAAO,GACXF,0BAA0B,KAC1BP,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEU,wBAAwB,CAACP,WAAW,EAAEJ,UAAU,CAACO,SAAS,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,KACvG,IAAAK,uCAAY,EAACZ,UAAU,CAACU,OAAO,CAAC,IAChC,WAAW;IAEbV,UAAU,CAACa,UAAU,CAACH,OAAO,CAAC;EAChC;AACF"}
|
|
@@ -18,6 +18,7 @@ export declare type CreateFromComponentsOptions = {
|
|
|
18
18
|
createManifestForComponentsWithoutDependencies: boolean;
|
|
19
19
|
dedupe?: boolean;
|
|
20
20
|
dependencyFilterFn?: DepsFilterFn;
|
|
21
|
+
resolveVersionsFromDependenciesOnly?: boolean;
|
|
21
22
|
};
|
|
22
23
|
export declare class WorkspaceManifestFactory {
|
|
23
24
|
private dependencyResolver;
|
|
@@ -97,7 +97,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
97
97
|
const DEFAULT_CREATE_OPTIONS = {
|
|
98
98
|
filterComponentsFromManifests: true,
|
|
99
99
|
createManifestForComponentsWithoutDependencies: true,
|
|
100
|
-
dedupe: true
|
|
100
|
+
dedupe: true,
|
|
101
|
+
resolveVersionsFromDependenciesOnly: false
|
|
101
102
|
};
|
|
102
103
|
class WorkspaceManifestFactory {
|
|
103
104
|
constructor(dependencyResolver, aspectLoader) {
|
|
@@ -108,7 +109,7 @@ class WorkspaceManifestFactory {
|
|
|
108
109
|
// Make sure to take other default if passed options with only one option
|
|
109
110
|
const optsWithDefaults = Object.assign({}, DEFAULT_CREATE_OPTIONS, options);
|
|
110
111
|
const hasRootComponents = this.dependencyResolver.hasRootComponents();
|
|
111
|
-
const componentDependenciesMap = await this.buildComponentDependenciesMap(components, optsWithDefaults.filterComponentsFromManifests, rootPolicy, optsWithDefaults.dependencyFilterFn, hasRootComponents);
|
|
112
|
+
const componentDependenciesMap = await this.buildComponentDependenciesMap(components, optsWithDefaults.filterComponentsFromManifests, optsWithDefaults.resolveVersionsFromDependenciesOnly ? undefined : rootPolicy, optsWithDefaults.dependencyFilterFn, hasRootComponents);
|
|
112
113
|
let dedupedDependencies = (0, _deduping().getEmptyDedupedDependencies)();
|
|
113
114
|
rootPolicy = rootPolicy.filter(dep => dep.dependencyId !== '@teambit/legacy');
|
|
114
115
|
if (hasRootComponents) {
|
|
@@ -197,7 +198,9 @@ class WorkspaceManifestFactory {
|
|
|
197
198
|
return result;
|
|
198
199
|
}
|
|
199
200
|
async updateDependenciesVersions(component, rootPolicy, dependencyList) {
|
|
200
|
-
|
|
201
|
+
// If root policy is not passed, it means that installation happens in a capsule
|
|
202
|
+
// and we only resolve versions from the dependencies, not any policies.
|
|
203
|
+
const mergedPolicies = rootPolicy && (await this.dependencyResolver.getPolicy(component));
|
|
201
204
|
dependencyList.forEach(dep => {
|
|
202
205
|
(0, _updateDependencyVersion().updateDependencyVersion)(dep, rootPolicy, mergedPolicies);
|
|
203
206
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_CREATE_OPTIONS","filterComponentsFromManifests","createManifestForComponentsWithoutDependencies","dedupe","WorkspaceManifestFactory","constructor","dependencyResolver","aspectLoader","createFromComponents","name","version","rootPolicy","rootDir","components","options","optsWithDefaults","Object","assign","hasRootComponents","componentDependenciesMap","buildComponentDependenciesMap","dependencyFilterFn","dedupedDependencies","getEmptyDedupedDependencies","filter","dep","dependencyId","rootDependencies","dedupeDependencies","mapValues","deps","excludeWorkspaceDependencies","toManifest","componentsManifestsMap","getComponentsManifests","envSelfPeers","getEnvsSelfPeersPolicy","workspaceManifest","WorkspaceManifest","foundEnvs","component","values","push","envPolicy","peersPolicies","map","policy","selfPolicy","mergedPolicies","VariantPolicy","mergePolices","buildResultsP","packageName","componentIdToPackageName","state","_consumer","depList","getDependencies","includeHidden","componentPolicy","getPolicy","additionalDeps","coreAspectIds","getCoreAspectIds","comp","toTypeArray","compIdWithoutVersion","id","split","isExtension","includes","some","c","isEqual","componentId","pkgName","getPackageName","filterComponents","filterResolvedFromEnv","updateDependenciesVersions","depManifest","toDependenciesManifest","dependencies","result","Map","length","results","Promise","all","forEach","currResult","set","dependencyList","updateDependencyVersion","componentsManifests","pMapSeries","has","blankDependencies","devDependencies","peerDependencies","get","getVersion","hasVersion","snapToSemver","getComponentEnvPolicy","manifest","ComponentManifest","SemVer","componentsToFilterOut","filtered","ComponentDependency","depPkgName","existingComponent","find","toString","ignoreVersion","_legacy","isEqualWithoutVersion","fromPolicy","value","resolveFromEnv","pickBy","versionSpec","startsWith"],"sources":["workspace-manifest-factory.ts"],"sourcesContent":["import { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { Component } from '@teambit/component';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport { pickBy, mapValues } from 'lodash';\nimport { SemVer } from 'semver';\nimport pMapSeries from 'p-map-series';\nimport { snapToSemver } from '@teambit/component-package-version';\nimport { ComponentDependency, DependencyList, PackageName } from '../dependencies';\nimport { VariantPolicy, WorkspacePolicy, EnvPolicy } from '../policy';\nimport { DependencyResolverMain } from '../dependency-resolver.main.runtime';\nimport { ComponentsManifestsMap } from '../types';\nimport { ComponentManifest } from './component-manifest';\nimport { dedupeDependencies, DedupedDependencies, getEmptyDedupedDependencies } from './deduping';\nimport { ManifestToJsonOptions, ManifestDependenciesObject, DepObjectValue } from './manifest';\nimport { updateDependencyVersion } from './update-dependency-version';\nimport { WorkspaceManifest } from './workspace-manifest';\n\nexport type DepsFilterFn = (dependencies: DependencyList) => DependencyList;\n\nexport type ComponentDependenciesMap = Map<PackageName, ManifestDependenciesObject>;\nexport interface WorkspaceManifestToJsonOptions extends ManifestToJsonOptions {\n includeDir?: boolean;\n}\n\nexport type CreateFromComponentsOptions = {\n filterComponentsFromManifests: boolean;\n createManifestForComponentsWithoutDependencies: boolean;\n dedupe?: boolean;\n dependencyFilterFn?: DepsFilterFn;\n};\n\nconst DEFAULT_CREATE_OPTIONS: CreateFromComponentsOptions = {\n filterComponentsFromManifests: true,\n createManifestForComponentsWithoutDependencies: true,\n dedupe: true,\n};\nexport class WorkspaceManifestFactory {\n constructor(private dependencyResolver: DependencyResolverMain, private aspectLoader: AspectLoaderMain) {}\n\n async createFromComponents(\n name: string,\n version: SemVer,\n rootPolicy: WorkspacePolicy,\n rootDir: string,\n components: Component[],\n options: CreateFromComponentsOptions = DEFAULT_CREATE_OPTIONS\n ): Promise<WorkspaceManifest> {\n // Make sure to take other default if passed options with only one option\n const optsWithDefaults = Object.assign({}, DEFAULT_CREATE_OPTIONS, options);\n const hasRootComponents = this.dependencyResolver.hasRootComponents();\n const componentDependenciesMap: ComponentDependenciesMap = await this.buildComponentDependenciesMap(\n components,\n optsWithDefaults.filterComponentsFromManifests,\n rootPolicy,\n optsWithDefaults.dependencyFilterFn,\n hasRootComponents\n );\n let dedupedDependencies = getEmptyDedupedDependencies();\n rootPolicy = rootPolicy.filter((dep) => dep.dependencyId !== '@teambit/legacy');\n if (hasRootComponents) {\n const { rootDependencies } = dedupeDependencies(rootPolicy, componentDependenciesMap);\n // We hoist dependencies in order for the IDE to work.\n // For runtime, the peer dependencies are installed inside:\n // <ws root>/node_module/<comp name>/node_module/<comp name>/node_modules\n dedupedDependencies.rootDependencies = mapValues(\n rootDependencies,\n (deps) => deps && excludeWorkspaceDependencies(deps)\n );\n dedupedDependencies.componentDependenciesMap = componentDependenciesMap;\n } else if (options.dedupe) {\n dedupedDependencies = dedupeDependencies(rootPolicy, componentDependenciesMap);\n } else {\n dedupedDependencies.rootDependencies = rootPolicy.toManifest();\n dedupedDependencies.componentDependenciesMap = componentDependenciesMap;\n }\n const componentsManifestsMap = await this.getComponentsManifests(\n dedupedDependencies,\n components,\n optsWithDefaults.createManifestForComponentsWithoutDependencies\n );\n const envSelfPeers = this.getEnvsSelfPeersPolicy(componentsManifestsMap);\n const workspaceManifest = new WorkspaceManifest(\n name,\n version,\n dedupedDependencies.rootDependencies,\n envSelfPeers,\n rootDir,\n componentsManifestsMap\n );\n return workspaceManifest;\n }\n\n private getEnvsSelfPeersPolicy(componentsManifestsMap: ComponentsManifestsMap) {\n const foundEnvs: EnvPolicy[] = [];\n for (const component of componentsManifestsMap.values()) {\n foundEnvs.push(component.envPolicy);\n }\n const peersPolicies = foundEnvs.map((policy) => policy.selfPolicy);\n // TODO: At the moment we are just merge everything, so in case of conflicts one will be taken\n // TODO: once we have root for each env, we should know to handle it differently\n const mergedPolicies = VariantPolicy.mergePolices(peersPolicies);\n return mergedPolicies;\n }\n\n /**\n * Get the components and build a map with the package name (from the component) as key and the dependencies as values\n *\n * @param {Component[]} components\n * @param {boolean} [filterComponentsFromManifests=true] - filter existing components from the dep graphs\n * @returns\n */\n private async buildComponentDependenciesMap(\n components: Component[],\n filterComponentsFromManifests = true,\n rootPolicy: WorkspacePolicy,\n dependencyFilterFn: DepsFilterFn | undefined,\n hasRootComponents?: boolean\n ): Promise<ComponentDependenciesMap> {\n const buildResultsP = components.map(async (component) => {\n const packageName = componentIdToPackageName(component.state._consumer);\n let depList = await this.dependencyResolver.getDependencies(component, { includeHidden: true });\n const componentPolicy = await this.dependencyResolver.getPolicy(component);\n const additionalDeps = {};\n if (hasRootComponents) {\n const coreAspectIds = this.aspectLoader.getCoreAspectIds();\n for (const comp of depList.toTypeArray('component') as ComponentDependency[]) {\n const [compIdWithoutVersion] = comp.id.split('@');\n if (\n !comp.isExtension &&\n !coreAspectIds.includes(compIdWithoutVersion) &&\n components.some((c) => c.id.isEqual(comp.componentId))\n ) {\n const pkgName = comp.getPackageName();\n if (pkgName !== '@teambit/harmony') {\n additionalDeps[pkgName] = `workspace:*`;\n }\n }\n }\n }\n if (filterComponentsFromManifests) {\n depList = filterComponents(depList, components);\n }\n depList = filterResolvedFromEnv(depList, componentPolicy);\n // Remove bit bin from dep list\n depList = depList.filter((dep) => dep.id !== '@teambit/legacy');\n if (dependencyFilterFn) {\n depList = dependencyFilterFn(depList);\n }\n await this.updateDependenciesVersions(component, rootPolicy, depList);\n const depManifest = depList.toDependenciesManifest();\n depManifest.dependencies = {\n ...additionalDeps,\n ...depManifest.dependencies,\n };\n\n return { packageName, depManifest };\n });\n const result: ComponentDependenciesMap = new Map();\n\n if (buildResultsP.length) {\n const results = await Promise.all(buildResultsP);\n results.forEach((currResult) => {\n result.set(currResult.packageName, currResult.depManifest);\n });\n }\n\n return result;\n }\n\n private async updateDependenciesVersions(\n component: Component,\n rootPolicy: WorkspacePolicy,\n dependencyList: DependencyList\n ): Promise<void> {\n const mergedPolicies = await this.dependencyResolver.getPolicy(component);\n dependencyList.forEach((dep) => {\n updateDependencyVersion(dep, rootPolicy, mergedPolicies);\n });\n }\n\n /**\n * Get the components manifests based on the calculated dedupedDependencies\n *\n * @param {DedupedDependencies} dedupedDependencies\n * @param {Component[]} components\n * @returns {ComponentsManifestsMap}\n */\n async getComponentsManifests(\n dedupedDependencies: DedupedDependencies,\n components: Component[],\n createManifestForComponentsWithoutDependencies = true\n ): Promise<ComponentsManifestsMap> {\n const componentsManifests: ComponentsManifestsMap = new Map();\n // don't use Promise.all, along the road this code might import an env from a remote, which can't be done in parallel.\n // otherwise, it may import the same component multiple times, and if fails, the ref (remote-lane) files may be corrupted.\n await pMapSeries(components, async (component) => {\n const packageName = componentIdToPackageName(component.state._consumer);\n if (\n dedupedDependencies.componentDependenciesMap.has(packageName) ||\n createManifestForComponentsWithoutDependencies\n ) {\n const blankDependencies: ManifestDependenciesObject = {\n dependencies: {},\n devDependencies: {},\n peerDependencies: {},\n };\n let dependencies = blankDependencies;\n if (dedupedDependencies.componentDependenciesMap.has(packageName)) {\n dependencies = dedupedDependencies.componentDependenciesMap.get(packageName) as ManifestDependenciesObject;\n }\n\n const getVersion = (): string => {\n if (!component.id.hasVersion()) return '0.0.1-new';\n return snapToSemver(component.id.version as string);\n };\n\n const version = getVersion();\n const envPolicy = await this.dependencyResolver.getComponentEnvPolicy(component);\n const manifest = new ComponentManifest(packageName, new SemVer(version), dependencies, component, envPolicy);\n componentsManifests.set(packageName, manifest);\n }\n });\n return componentsManifests;\n }\n}\n\nfunction filterComponents(dependencyList: DependencyList, componentsToFilterOut: Component[]): DependencyList {\n const filtered = dependencyList.filter((dep) => {\n if (!(dep instanceof ComponentDependency)) {\n const depPkgName = dep.getPackageName?.();\n if (!depPkgName) return true;\n // If the package is already in the workspace as a local component,\n // then we don't want to install that package as a dependency to node_modules.\n // Otherwise, it would rewrite the local component inside the root node_modules that is created by bit link.\n return !componentsToFilterOut.some((component) =>\n depPkgName === componentIdToPackageName(component.state._consumer)\n );\n }\n // Remove dependencies which has no version (they are new in the workspace)\n if (!dep.componentId.hasVersion()) return false;\n const existingComponent = componentsToFilterOut.find((component) => {\n // For new components, the component has no version but the dependency id has version 0.0.1\n if (!component.id.hasVersion()) {\n return component.id.toString() === dep.componentId.toString({ ignoreVersion: true });\n }\n // We are checking against both component.id._legacy and component.state._consumer.id\n // Because during tag operation, the component.id._legacy has the current version (before the tag)\n // while the component.state._consumer.id has the upcoming version (the version that will be after the tag)\n // The dependency in some cases is already updated to the upcoming version\n return (\n component.id._legacy.isEqualWithoutVersion(dep.componentId._legacy) ||\n component.state._consumer.id.isEqualWithoutVersion(dep.componentId._legacy)\n );\n });\n if (existingComponent) return false;\n return true;\n });\n return filtered;\n}\n\n/**\n * Filter deps which should be resolved from the env, we don't want to install them, they will be linked manually later\n * @param dependencyList\n * @param componentPolicy\n */\nfunction filterResolvedFromEnv(dependencyList: DependencyList, componentPolicy: VariantPolicy): DependencyList {\n const filtered = dependencyList.filter((dep) => {\n const fromPolicy = componentPolicy.find(dep.id);\n if (!fromPolicy) {\n return true;\n }\n if (fromPolicy.value.resolveFromEnv) {\n return false;\n }\n return true;\n });\n return filtered;\n}\n\nfunction excludeWorkspaceDependencies(de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AE;QAAK,CAAC,CAAC;MACtF;MACA;MACA;MACA;MACA;MACA,OACE3E,SAAS,CAAC2B,EAAE,CAACiD,OAAO,CAACC,qBAAqB,CAAC5F,GAAG,CAACiD,WAAW,CAAC0C,OAAO,CAAC,IACnE5E,SAAS,CAACc,KAAK,CAACC,SAAS,CAACY,EAAE,CAACkD,qBAAqB,CAAC5F,GAAG,CAACiD,WAAW,CAAC0C,OAAO,CAAC;IAE/E,CAAC,CAAC;IACF,IAAIJ,iBAAiB,EAAE,OAAO,KAAK;IACnC,OAAO,IAAI;EACb,CAAC,CAAC;EACF,OAAOH,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS/B,qBAAqB,CAACc,cAA8B,EAAEjC,eAA8B,EAAkB;EAC7G,MAAMkD,QAAQ,GAAGjB,cAAc,CAACpE,MAAM,CAAEC,GAAG,IAAK;IAC9C,MAAM6F,UAAU,GAAG3D,eAAe,CAACsD,IAAI,CAACxF,GAAG,CAAC0C,EAAE,CAAC;IAC/C,IAAI,CAACmD,UAAU,EAAE;MACf,OAAO,IAAI;IACb;IACA,IAAIA,UAAU,CAACC,KAAK,CAACC,cAAc,EAAE;MACnC,OAAO,KAAK;IACd;IACA,OAAO,IAAI;EACb,CAAC,CAAC;EACF,OAAOX,QAAQ;AACjB;AAEA,SAAS9E,4BAA4B,CAACD,IAAoB,EAAkB;EAC1E,OAAO,IAAA2F,gBAAM,EAAC3F,IAAI,EAAG4F,WAAW,IAAK,CAACA,WAAW,CAACC,UAAU,CAAC,YAAY,CAAC,CAAC;AAC7E"}
|
|
1
|
+
{"version":3,"names":["DEFAULT_CREATE_OPTIONS","filterComponentsFromManifests","createManifestForComponentsWithoutDependencies","dedupe","resolveVersionsFromDependenciesOnly","WorkspaceManifestFactory","constructor","dependencyResolver","aspectLoader","createFromComponents","name","version","rootPolicy","rootDir","components","options","optsWithDefaults","Object","assign","hasRootComponents","componentDependenciesMap","buildComponentDependenciesMap","undefined","dependencyFilterFn","dedupedDependencies","getEmptyDedupedDependencies","filter","dep","dependencyId","rootDependencies","dedupeDependencies","mapValues","deps","excludeWorkspaceDependencies","toManifest","componentsManifestsMap","getComponentsManifests","envSelfPeers","getEnvsSelfPeersPolicy","workspaceManifest","WorkspaceManifest","foundEnvs","component","values","push","envPolicy","peersPolicies","map","policy","selfPolicy","mergedPolicies","VariantPolicy","mergePolices","buildResultsP","packageName","componentIdToPackageName","state","_consumer","depList","getDependencies","includeHidden","componentPolicy","getPolicy","additionalDeps","coreAspectIds","getCoreAspectIds","comp","toTypeArray","compIdWithoutVersion","id","split","isExtension","includes","some","c","isEqual","componentId","pkgName","getPackageName","filterComponents","filterResolvedFromEnv","updateDependenciesVersions","depManifest","toDependenciesManifest","dependencies","result","Map","length","results","Promise","all","forEach","currResult","set","dependencyList","updateDependencyVersion","componentsManifests","pMapSeries","has","blankDependencies","devDependencies","peerDependencies","get","getVersion","hasVersion","snapToSemver","getComponentEnvPolicy","manifest","ComponentManifest","SemVer","componentsToFilterOut","filtered","ComponentDependency","depPkgName","existingComponent","find","toString","ignoreVersion","_legacy","isEqualWithoutVersion","fromPolicy","value","resolveFromEnv","pickBy","versionSpec","startsWith"],"sources":["workspace-manifest-factory.ts"],"sourcesContent":["import { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { Component } from '@teambit/component';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport { pickBy, mapValues } from 'lodash';\nimport { SemVer } from 'semver';\nimport pMapSeries from 'p-map-series';\nimport { snapToSemver } from '@teambit/component-package-version';\nimport { ComponentDependency, DependencyList, PackageName } from '../dependencies';\nimport { VariantPolicy, WorkspacePolicy, EnvPolicy } from '../policy';\nimport { DependencyResolverMain } from '../dependency-resolver.main.runtime';\nimport { ComponentsManifestsMap } from '../types';\nimport { ComponentManifest } from './component-manifest';\nimport { dedupeDependencies, DedupedDependencies, getEmptyDedupedDependencies } from './deduping';\nimport { ManifestToJsonOptions, ManifestDependenciesObject, DepObjectValue } from './manifest';\nimport { updateDependencyVersion } from './update-dependency-version';\nimport { WorkspaceManifest } from './workspace-manifest';\n\nexport type DepsFilterFn = (dependencies: DependencyList) => DependencyList;\n\nexport type ComponentDependenciesMap = Map<PackageName, ManifestDependenciesObject>;\nexport interface WorkspaceManifestToJsonOptions extends ManifestToJsonOptions {\n includeDir?: boolean;\n}\n\nexport type CreateFromComponentsOptions = {\n filterComponentsFromManifests: boolean;\n createManifestForComponentsWithoutDependencies: boolean;\n dedupe?: boolean;\n dependencyFilterFn?: DepsFilterFn;\n resolveVersionsFromDependenciesOnly?: boolean;\n};\n\nconst DEFAULT_CREATE_OPTIONS: CreateFromComponentsOptions = {\n filterComponentsFromManifests: true,\n createManifestForComponentsWithoutDependencies: true,\n dedupe: true,\n resolveVersionsFromDependenciesOnly: false,\n};\nexport class WorkspaceManifestFactory {\n constructor(private dependencyResolver: DependencyResolverMain, private aspectLoader: AspectLoaderMain) {}\n\n async createFromComponents(\n name: string,\n version: SemVer,\n rootPolicy: WorkspacePolicy,\n rootDir: string,\n components: Component[],\n options: CreateFromComponentsOptions = DEFAULT_CREATE_OPTIONS\n ): Promise<WorkspaceManifest> {\n // Make sure to take other default if passed options with only one option\n const optsWithDefaults = Object.assign({}, DEFAULT_CREATE_OPTIONS, options);\n const hasRootComponents = this.dependencyResolver.hasRootComponents();\n const componentDependenciesMap: ComponentDependenciesMap = await this.buildComponentDependenciesMap(\n components,\n optsWithDefaults.filterComponentsFromManifests,\n optsWithDefaults.resolveVersionsFromDependenciesOnly ? undefined : rootPolicy,\n optsWithDefaults.dependencyFilterFn,\n hasRootComponents\n );\n let dedupedDependencies = getEmptyDedupedDependencies();\n rootPolicy = rootPolicy.filter((dep) => dep.dependencyId !== '@teambit/legacy');\n if (hasRootComponents) {\n const { rootDependencies } = dedupeDependencies(rootPolicy, componentDependenciesMap);\n // We hoist dependencies in order for the IDE to work.\n // For runtime, the peer dependencies are installed inside:\n // <ws root>/node_module/<comp name>/node_module/<comp name>/node_modules\n dedupedDependencies.rootDependencies = mapValues(\n rootDependencies,\n (deps) => deps && excludeWorkspaceDependencies(deps)\n );\n dedupedDependencies.componentDependenciesMap = componentDependenciesMap;\n } else if (options.dedupe) {\n dedupedDependencies = dedupeDependencies(rootPolicy, componentDependenciesMap);\n } else {\n dedupedDependencies.rootDependencies = rootPolicy.toManifest();\n dedupedDependencies.componentDependenciesMap = componentDependenciesMap;\n }\n const componentsManifestsMap = await this.getComponentsManifests(\n dedupedDependencies,\n components,\n optsWithDefaults.createManifestForComponentsWithoutDependencies\n );\n const envSelfPeers = this.getEnvsSelfPeersPolicy(componentsManifestsMap);\n const workspaceManifest = new WorkspaceManifest(\n name,\n version,\n dedupedDependencies.rootDependencies,\n envSelfPeers,\n rootDir,\n componentsManifestsMap\n );\n return workspaceManifest;\n }\n\n private getEnvsSelfPeersPolicy(componentsManifestsMap: ComponentsManifestsMap) {\n const foundEnvs: EnvPolicy[] = [];\n for (const component of componentsManifestsMap.values()) {\n foundEnvs.push(component.envPolicy);\n }\n const peersPolicies = foundEnvs.map((policy) => policy.selfPolicy);\n // TODO: At the moment we are just merge everything, so in case of conflicts one will be taken\n // TODO: once we have root for each env, we should know to handle it differently\n const mergedPolicies = VariantPolicy.mergePolices(peersPolicies);\n return mergedPolicies;\n }\n\n /**\n * Get the components and build a map with the package name (from the component) as key and the dependencies as values\n *\n * @param {Component[]} components\n * @param {boolean} [filterComponentsFromManifests=true] - filter existing components from the dep graphs\n * @returns\n */\n private async buildComponentDependenciesMap(\n components: Component[],\n filterComponentsFromManifests = true,\n rootPolicy?: WorkspacePolicy,\n dependencyFilterFn?: DepsFilterFn | undefined,\n hasRootComponents?: boolean\n ): Promise<ComponentDependenciesMap> {\n const buildResultsP = components.map(async (component) => {\n const packageName = componentIdToPackageName(component.state._consumer);\n let depList = await this.dependencyResolver.getDependencies(component, { includeHidden: true });\n const componentPolicy = await this.dependencyResolver.getPolicy(component);\n const additionalDeps = {};\n if (hasRootComponents) {\n const coreAspectIds = this.aspectLoader.getCoreAspectIds();\n for (const comp of depList.toTypeArray('component') as ComponentDependency[]) {\n const [compIdWithoutVersion] = comp.id.split('@');\n if (\n !comp.isExtension &&\n !coreAspectIds.includes(compIdWithoutVersion) &&\n components.some((c) => c.id.isEqual(comp.componentId))\n ) {\n const pkgName = comp.getPackageName();\n if (pkgName !== '@teambit/harmony') {\n additionalDeps[pkgName] = `workspace:*`;\n }\n }\n }\n }\n if (filterComponentsFromManifests) {\n depList = filterComponents(depList, components);\n }\n depList = filterResolvedFromEnv(depList, componentPolicy);\n // Remove bit bin from dep list\n depList = depList.filter((dep) => dep.id !== '@teambit/legacy');\n if (dependencyFilterFn) {\n depList = dependencyFilterFn(depList);\n }\n await this.updateDependenciesVersions(component, rootPolicy, depList);\n const depManifest = depList.toDependenciesManifest();\n depManifest.dependencies = {\n ...additionalDeps,\n ...depManifest.dependencies,\n };\n\n return { packageName, depManifest };\n });\n const result: ComponentDependenciesMap = new Map();\n\n if (buildResultsP.length) {\n const results = await Promise.all(buildResultsP);\n results.forEach((currResult) => {\n result.set(currResult.packageName, currResult.depManifest);\n });\n }\n\n return result;\n }\n\n private async updateDependenciesVersions(\n component: Component,\n rootPolicy: WorkspacePolicy | undefined,\n dependencyList: DependencyList\n ): Promise<void> {\n // If root policy is not passed, it means that installation happens in a capsule\n // and we only resolve versions from the dependencies, not any policies.\n const mergedPolicies = rootPolicy && (await this.dependencyResolver.getPolicy(component));\n dependencyList.forEach((dep) => {\n updateDependencyVersion(dep, rootPolicy, mergedPolicies);\n });\n }\n\n /**\n * Get the components manifests based on the calculated dedupedDependencies\n *\n * @param {DedupedDependencies} dedupedDependencies\n * @param {Component[]} components\n * @returns {ComponentsManifestsMap}\n */\n async getComponentsManifests(\n dedupedDependencies: DedupedDependencies,\n components: Component[],\n createManifestForComponentsWithoutDependencies = true\n ): Promise<ComponentsManifestsMap> {\n const componentsManifests: ComponentsManifestsMap = new Map();\n // don't use Promise.all, along the road this code might import an env from a remote, which can't be done in parallel.\n // otherwise, it may import the same component multiple times, and if fails, the ref (remote-lane) files may be corrupted.\n await pMapSeries(components, async (component) => {\n const packageName = componentIdToPackageName(component.state._consumer);\n if (\n dedupedDependencies.componentDependenciesMap.has(packageName) ||\n createManifestForComponentsWithoutDependencies\n ) {\n const blankDependencies: ManifestDependenciesObject = {\n dependencies: {},\n devDependencies: {},\n peerDependencies: {},\n };\n let dependencies = blankDependencies;\n if (dedupedDependencies.componentDependenciesMap.has(packageName)) {\n dependencies = dedupedDependencies.componentDependenciesMap.get(packageName) as ManifestDependenciesObject;\n }\n\n const getVersion = (): string => {\n if (!component.id.hasVersion()) return '0.0.1-new';\n return snapToSemver(component.id.version as string);\n };\n\n const version = getVersion();\n const envPolicy = await this.dependencyResolver.getComponentEnvPolicy(component);\n const manifest = new ComponentManifest(packageName, new SemVer(version), dependencies, component, envPolicy);\n componentsManifests.set(packageName, manifest);\n }\n });\n return componentsManifests;\n }\n}\n\nfunction filterComponents(dependencyList: DependencyList, componentsToFilterOut: Component[]): DependencyList {\n const filtered = dependencyList.filter((dep) => {\n if (!(dep instanceof ComponentDependency)) {\n const depPkgName = dep.getPackageName?.();\n if (!depPkgName) return true;\n // If the package is already in the workspace as a local component,\n // then we don't want to install that package as a dependency to node_modules.\n // Otherwise, it would rewrite the local component inside the root node_modules that is created by bit link.\n return !componentsToFilterOut.some(\n (component) => depPkgName === componentIdToPackageName(component.state._consumer)\n );\n }\n // Remove dependencies which has no version (they are new in the workspace)\n if (!dep.componentId.hasVersion()) return false;\n const existingComponent = componentsToFilterOut.find((component) => {\n // For new components, the component has no version but the dependency id has version 0.0.1\n if (!component.id.hasVersion()) {\n return component.id.toString() === dep.componentId.toString({ ignoreVersion: true });\n }\n // We are checking against both component.id._legacy and component.state._consumer.id\n // Because during tag operation, the component.id._legacy has the current version (before the tag)\n // while the component.state._consumer.id has the upcoming version (the version that will be after the tag)\n // The dependency in some cases is already updated to the upcoming version\n return (\n component.id._legacy.isEqualWithoutVersion(dep.componentId._legacy) ||\n component.state._consumer.id.isEqualWithoutVersion(dep.componentId._legacy)\n );\n });\n if (existingComponent) return false;\n return true;\n });\n return filtered;\n}\n\n/**\n * Filter deps which should be resolved from the env, we don't want to install them, they will be linked manually later\n * @param dependencyList\n * @param componentPolicy\n */\nfunction filterResolvedFromEnv(dependencyList: DependencyList, componentPolicy: VariantPolicy): DependencyList {\n const filtered = dependencyList.filter((dep) => {\n const fromPolicy = componentPolicy.find(dep.id);\n if (!fromPolicy) {\n return true;\n }\n if (fromPolicy.value.resolveFromEnv) {\n return false;\n }\n return true;\n });\n return filtered;\n}\n\nfunction excludeWorkspaceDependencies(deps: DepObjectValue): DepObjectValue {\n return pickBy(deps, (versionSpec) => !versionSpec.startsWith('workspace:'));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;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;AAAyD;AAAA;AAiBzD,MAAMA,sBAAmD,GAAG;EAC1DC,6BAA6B,EAAE,IAAI;EACnCC,8CAA8C,EAAE,IAAI;EACpDC,MAAM,EAAE,IAAI;EACZC,mCAAmC,EAAE;AACvC,CAAC;AACM,MAAMC,wBAAwB,CAAC;EACpCC,WAAW,CAASC,kBAA0C,EAAUC,YAA8B,EAAE;IAAA,KAApFD,kBAA0C,GAA1CA,kBAA0C;IAA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C,cAAc,EAAE;MACnC,OAAO,KAAK;IACd;IACA,OAAO,IAAI;EACb,CAAC,CAAC;EACF,OAAOX,QAAQ;AACjB;AAEA,SAAS9E,4BAA4B,CAACD,IAAoB,EAAkB;EAC1E,OAAO,IAAA2F,gBAAM,EAAC3F,IAAI,EAAG4F,WAAW,IAAK,CAACA,WAAW,CAACC,UAAU,CAAC,YAAY,CAAC,CAAC;AAC7E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.968/dist/dependency-resolver.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.dependencies_dependency-resolver@0.0.968/dist/dependency-resolver.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -26,16 +26,16 @@ import { VariantPolicy, WorkspacePolicy } from '../policy';
|
|
|
26
26
|
*/
|
|
27
27
|
export function updateDependencyVersion(
|
|
28
28
|
dependency: Dependency,
|
|
29
|
-
rootPolicy
|
|
30
|
-
variantPolicy
|
|
29
|
+
rootPolicy?: WorkspacePolicy,
|
|
30
|
+
variantPolicy?: VariantPolicy
|
|
31
31
|
): void {
|
|
32
32
|
if (dependency.getPackageName) {
|
|
33
33
|
const packageName = dependency.getPackageName();
|
|
34
|
-
const variantVersion = variantPolicy
|
|
34
|
+
const variantVersion = variantPolicy?.getDepVersion(packageName, dependency.lifecycle);
|
|
35
35
|
const variantVersionWithoutMinus = variantVersion && variantVersion !== '-' ? variantVersion : undefined;
|
|
36
36
|
const version =
|
|
37
37
|
variantVersionWithoutMinus ||
|
|
38
|
-
rootPolicy
|
|
38
|
+
rootPolicy?.getValidSemverDepVersion(packageName, dependency.lifecycle === 'peer' ? 'peer' : 'runtime') ||
|
|
39
39
|
snapToSemver(dependency.version) ||
|
|
40
40
|
'0.0.1-new';
|
|
41
41
|
|
|
@@ -27,12 +27,14 @@ export type CreateFromComponentsOptions = {
|
|
|
27
27
|
createManifestForComponentsWithoutDependencies: boolean;
|
|
28
28
|
dedupe?: boolean;
|
|
29
29
|
dependencyFilterFn?: DepsFilterFn;
|
|
30
|
+
resolveVersionsFromDependenciesOnly?: boolean;
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
const DEFAULT_CREATE_OPTIONS: CreateFromComponentsOptions = {
|
|
33
34
|
filterComponentsFromManifests: true,
|
|
34
35
|
createManifestForComponentsWithoutDependencies: true,
|
|
35
36
|
dedupe: true,
|
|
37
|
+
resolveVersionsFromDependenciesOnly: false,
|
|
36
38
|
};
|
|
37
39
|
export class WorkspaceManifestFactory {
|
|
38
40
|
constructor(private dependencyResolver: DependencyResolverMain, private aspectLoader: AspectLoaderMain) {}
|
|
@@ -51,7 +53,7 @@ export class WorkspaceManifestFactory {
|
|
|
51
53
|
const componentDependenciesMap: ComponentDependenciesMap = await this.buildComponentDependenciesMap(
|
|
52
54
|
components,
|
|
53
55
|
optsWithDefaults.filterComponentsFromManifests,
|
|
54
|
-
rootPolicy,
|
|
56
|
+
optsWithDefaults.resolveVersionsFromDependenciesOnly ? undefined : rootPolicy,
|
|
55
57
|
optsWithDefaults.dependencyFilterFn,
|
|
56
58
|
hasRootComponents
|
|
57
59
|
);
|
|
@@ -112,8 +114,8 @@ export class WorkspaceManifestFactory {
|
|
|
112
114
|
private async buildComponentDependenciesMap(
|
|
113
115
|
components: Component[],
|
|
114
116
|
filterComponentsFromManifests = true,
|
|
115
|
-
rootPolicy
|
|
116
|
-
dependencyFilterFn
|
|
117
|
+
rootPolicy?: WorkspacePolicy,
|
|
118
|
+
dependencyFilterFn?: DepsFilterFn | undefined,
|
|
117
119
|
hasRootComponents?: boolean
|
|
118
120
|
): Promise<ComponentDependenciesMap> {
|
|
119
121
|
const buildResultsP = components.map(async (component) => {
|
|
@@ -169,10 +171,12 @@ export class WorkspaceManifestFactory {
|
|
|
169
171
|
|
|
170
172
|
private async updateDependenciesVersions(
|
|
171
173
|
component: Component,
|
|
172
|
-
rootPolicy: WorkspacePolicy,
|
|
174
|
+
rootPolicy: WorkspacePolicy | undefined,
|
|
173
175
|
dependencyList: DependencyList
|
|
174
176
|
): Promise<void> {
|
|
175
|
-
|
|
177
|
+
// If root policy is not passed, it means that installation happens in a capsule
|
|
178
|
+
// and we only resolve versions from the dependencies, not any policies.
|
|
179
|
+
const mergedPolicies = rootPolicy && (await this.dependencyResolver.getPolicy(component));
|
|
176
180
|
dependencyList.forEach((dep) => {
|
|
177
181
|
updateDependencyVersion(dep, rootPolicy, mergedPolicies);
|
|
178
182
|
});
|
|
@@ -232,8 +236,8 @@ function filterComponents(dependencyList: DependencyList, componentsToFilterOut:
|
|
|
232
236
|
// If the package is already in the workspace as a local component,
|
|
233
237
|
// then we don't want to install that package as a dependency to node_modules.
|
|
234
238
|
// Otherwise, it would rewrite the local component inside the root node_modules that is created by bit link.
|
|
235
|
-
return !componentsToFilterOut.some(
|
|
236
|
-
depPkgName === componentIdToPackageName(component.state._consumer)
|
|
239
|
+
return !componentsToFilterOut.some(
|
|
240
|
+
(component) => depPkgName === componentIdToPackageName(component.state._consumer)
|
|
237
241
|
);
|
|
238
242
|
}
|
|
239
243
|
// Remove dependencies which has no version (they are new in the workspace)
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/dependency-resolver",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.968",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/dependencies/dependency-resolver",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.dependencies",
|
|
8
8
|
"name": "dependency-resolver",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.968"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"cli-highlight": "2.1.9",
|
|
@@ -31,20 +31,20 @@
|
|
|
31
31
|
"@teambit/harmony": "0.4.6",
|
|
32
32
|
"@pnpm/network.ca-file": "1.0.2",
|
|
33
33
|
"@teambit/component-version": "0.0.406",
|
|
34
|
-
"@teambit/envs": "0.0.
|
|
35
|
-
"@teambit/aspect-loader": "0.0.
|
|
36
|
-
"@teambit/component": "0.0.
|
|
34
|
+
"@teambit/envs": "0.0.968",
|
|
35
|
+
"@teambit/aspect-loader": "0.0.968",
|
|
36
|
+
"@teambit/component": "0.0.968",
|
|
37
37
|
"@teambit/logger": "0.0.742",
|
|
38
38
|
"@teambit/bit-error": "0.0.402",
|
|
39
|
-
"@teambit/graphql": "0.0.
|
|
40
|
-
"@teambit/bit": "0.0.
|
|
39
|
+
"@teambit/graphql": "0.0.968",
|
|
40
|
+
"@teambit/bit": "0.0.970",
|
|
41
41
|
"@teambit/cli": "0.0.649",
|
|
42
42
|
"@teambit/config": "0.0.662",
|
|
43
43
|
"@teambit/global-config": "0.0.651",
|
|
44
44
|
"@teambit/harmony.modules.requireable-component": "0.0.491",
|
|
45
45
|
"@teambit/legacy-bit-id": "0.0.421",
|
|
46
|
-
"@teambit/snapping": "0.0.
|
|
47
|
-
"@teambit/isolator": "0.0.
|
|
46
|
+
"@teambit/snapping": "0.0.283",
|
|
47
|
+
"@teambit/isolator": "0.0.968",
|
|
48
48
|
"@teambit/component-package-version": "0.0.421",
|
|
49
49
|
"@teambit/component-id": "0.0.425"
|
|
50
50
|
},
|
|
Binary file
|