| 2 | import { Package, Tool } from "@manypkg/get-packages"; |
| 3 | |
| 4 | export async function getUntaggedPackages( |
| 5 | packages: Package[], |
| 6 | cwd: string, |
| 7 | tool: Tool |
| 8 | ) { |
| 9 | const packageWithTags = await Promise.all( |
| 10 | packages.map(async (pkg) => { |
| 11 | const tagName = |
| 12 | tool === "root" |
| 13 | ? `v${pkg.packageJson.version}` |
| 14 | : `${pkg.packageJson.name}@${pkg.packageJson.version}`; |
| 15 | const isMissingTag = !( |
| 16 | (await git.tagExists(tagName, cwd)) || |
| 17 | (await git.remoteTagExists(tagName)) |
| 18 | ); |
| 19 | |
| 20 | return { pkg, isMissingTag }; |
| 21 | }) |
| 22 | ); |
| 23 | |
| 24 | const untagged: Array<{ name: string; newVersion: string }> = []; |
| 25 | |
| 26 | for (const packageWithTag of packageWithTags) { |
| 27 | if (packageWithTag.isMissingTag) { |
| 28 | untagged.push({ |
| 29 | name: packageWithTag.pkg.packageJson.name, |
| 30 | newVersion: packageWithTag.pkg.packageJson.version, |
| 31 | }); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | return untagged; |
| 36 | } |