( options: ClassifyPackagesOptions )
| 160 | * at runtime vs. which must be bundled with the deployment. |
| 161 | */ |
| 162 | export function classifyPackages( |
| 163 | options: ClassifyPackagesOptions |
| 164 | ): PackageClassification { |
| 165 | const { lockFile, excludePackages = [] } = options; |
| 166 | const privatePackages: string[] = []; |
| 167 | const publicPackages: string[] = []; |
| 168 | const packageVersions: Record<string, string> = {}; |
| 169 | |
| 170 | const excludeSet = new Set(excludePackages.map(normalizePackageName)); |
| 171 | |
| 172 | for (const pkg of lockFile.packages) { |
| 173 | // Skip excluded packages (e.g., the project's own package) |
| 174 | if (excludeSet.has(normalizePackageName(pkg.name))) { |
| 175 | continue; |
| 176 | } |
| 177 | |
| 178 | packageVersions[pkg.name] = pkg.version; |
| 179 | |
| 180 | if (isPrivatePackageSource(pkg.source)) { |
| 181 | privatePackages.push(pkg.name); |
| 182 | } else { |
| 183 | publicPackages.push(pkg.name); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | return { privatePackages, publicPackages, packageVersions }; |
| 188 | } |
no test coverage detected