Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not update {major}.json if an older version was published #483

Merged
merged 7 commits into from
Oct 3, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/utils/symlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function forceSymlink(target: string, newFile: string): void {
/**
* Create symbolic links to the new version file
*
* "latest.json" link is not updated if the new version is "older" (e.g., it's
* "latest.json" and "{major}.json" links are not updated if the new version is "older" (e.g., it's
* a patch release for an older major version).
*
* @param versionFilePath Path to the new version file
Expand All @@ -42,24 +42,30 @@ export function createSymlinks(
const baseVersionName = path.basename(versionFilePath);
const packageDir = path.dirname(versionFilePath);

// link latest, but only if the new version is "newer"
// link latest.json and {major}.json, but only if the new version is "newer"
if (
parsedOldVersion &&
!versionGreaterOrEqualThan(parsedNewVersion, parsedOldVersion)
) {
logger.warn(
`Not updating the latest version file: current version is "${oldVersion}", new version is "${newVersion}"`
);
logger.warn(
`Not updating the major version file: current version is "${oldVersion}", new version is "${newVersion}"`
);
} else {
logger.debug(
`Changing symlink for "latest.json" from version "${oldVersion}" to "${newVersion}"`
);
forceSymlink(baseVersionName, path.join(packageDir, 'latest.json'));
}

// link major
const majorVersionLink = `${parsedNewVersion.major}.json`;
forceSymlink(baseVersionName, path.join(packageDir, majorVersionLink));

logger.debug(
`Changing symlink for "{major}.json" from version "${oldVersion}" to "${newVersion}"`
);
const majorVersionLink = `${parsedNewVersion.major}.json`;
forceSymlink(baseVersionName, path.join(packageDir, majorVersionLink));
}

// link minor
const minorVersionLink = `${parsedNewVersion.major}.${parsedNewVersion.minor}.json`;
Expand Down