forked from changesets/changesets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getUntaggedPrivatePackages.ts
38 lines (33 loc) 路 1.03 KB
/
getUntaggedPrivatePackages.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import * as git from "@changesets/git";
import { Package, Tool } from "@manypkg/get-packages";
import { PublishedResult } from "./publishPackages";
export async function getUntaggedPrivatePackages(
privatePackages: Package[],
cwd: string,
tool: Tool
) {
const packageWithTags = await Promise.all(
privatePackages.map(async (privatePkg) => {
const tagName =
tool === "root"
? `v${privatePkg.packageJson.version}`
: `${privatePkg.packageJson.name}@${privatePkg.packageJson.version}`;
const isMissingTag = !(
(await git.tagExists(tagName, cwd)) ||
(await git.remoteTagExists(tagName))
);
return { pkg: privatePkg, isMissingTag };
})
);
const untagged: PublishedResult[] = [];
for (const packageWithTag of packageWithTags) {
if (packageWithTag.isMissingTag) {
untagged.push({
name: packageWithTag.pkg.packageJson.name,
newVersion: packageWithTag.pkg.packageJson.version,
published: false,
});
}
}
return untagged;
}