Skip to content

Commit f14a1c2

Browse files
authored
If there's no version files at all, check for changed workspaces directly (#36)
1 parent 271017d commit f14a1c2

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

scripts/checkVersions.mts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,27 @@ async function main() {
5858

5959
const unreleasedWorkspaces: Workspace[] = [];
6060

61-
for (const versionFile of versionFiles) {
62-
for (const workspace of versionFile.changedWorkspaces) {
63-
if (!workspace.manifest.version) continue;
64-
if (versionFile?.releases.has(workspace)) continue;
65-
const diff = execSync(
66-
`git diff origin/main -- ${join(workspace.relativeCwd, "package.json")}`,
67-
{
68-
encoding: "utf-8",
69-
},
70-
);
71-
const hasBeenUpgraded = /^\+\s*"version":/gm.test(diff);
72-
if (!hasBeenUpgraded) unreleasedWorkspaces.push(workspace);
61+
if (versionFiles.length) {
62+
for (const versionFile of versionFiles) {
63+
for (const workspace of versionFile.changedWorkspaces) {
64+
if (!workspace.manifest.version) continue;
65+
if (versionFile?.releases.has(workspace)) continue;
66+
const diff = execSync(
67+
`git diff origin/main -- ${join(workspace.relativeCwd, "package.json")}`,
68+
{
69+
encoding: "utf-8",
70+
},
71+
);
72+
const hasBeenUpgraded = /^\+\s*"version":/gm.test(diff);
73+
if (!hasBeenUpgraded) unreleasedWorkspaces.push(workspace);
74+
}
7375
}
76+
} else {
77+
const changedWorkspaces = await gitUtils.fetchChangedWorkspaces({
78+
ref: "origin/main",
79+
project,
80+
});
81+
unreleasedWorkspaces.push(...Array.from(changedWorkspaces).filter((w) => w.manifest.version));
7482
}
7583

7684
if (unreleasedWorkspaces.length) {

0 commit comments

Comments
 (0)