Skip to content

Commit

Permalink
chore: filter out latest next tag
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbate committed Dec 11, 2024
1 parent 8cb124f commit d1d0fa0
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions scripts/release-deprecate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { join } from 'node:path';

const { log, error } = console;

const UNPUBLISH_TAGS = /next|pr|rc/;
const { version: CURRENT_VERSION } = JSON.parse(
const deprecateTags = /next|pr|rc/;
const { version: currentVersion } = JSON.parse(
readFileSync(join(process.cwd(), '/packages/fuels/package.json')).toString()
);
const deprecateVersions = process.env.DEPRECATE_VERSIONS === 'true';
Expand All @@ -27,18 +27,23 @@ const getPublicPackages = () => {
};

const getVersionsToDeprecate = async (packageName: string) => {
const { versions: packageVersions } = await fetch(
`https://registry.npmjs.org/${packageName}`
).then((resp) => resp.json());
const { versions } = await fetch(`https://registry.npmjs.org/${packageName}`).then((resp) =>
resp.json()
);

return Object.keys(packageVersions).filter(
(packageVersion) =>
packageVersion.search(UNPUBLISH_TAGS) > -1 && !compare(packageVersion, CURRENT_VERSION, '>=')
// Only deprecate certain tags
const validVersions = Object.keys(versions).filter(
(version) => version.search(deprecateTags) > -1 && !compare(version, currentVersion, '>=')
);

// Remove the latest next tag from the deprecation list
const latestNextVersion = validVersions.filter((version) => version.search('next') > -1).pop();
return validVersions.filter((version) => version !== latestNextVersion);
};

const main = async () => {
const packages = getPublicPackages();
// const packages = getPublicPackages();
const packages = ['fuels'];
await Promise.allSettled(
packages.map(async (packageName) => {
const versionsToDeprecate = await getVersionsToDeprecate(packageName);
Expand Down

0 comments on commit d1d0fa0

Please sign in to comment.