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

feat: filter prerelease versions #108

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { parse as parseArgs } from "https://deno.land/[email protected]/flags/mod.ts";
export { expandGlob } from "https://deno.land/[email protected]/fs/mod.ts";
export * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
export { satisfies as semverSatisfies, prerelease as getPrereleaseVersion } from "https://deno.land/[email protected]/semver/mod.ts";
18 changes: 12 additions & 6 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { colors } from "./deps.ts";
import { colors, getPrereleaseVersion } from "./deps.ts";
import { Progress, SilentProgress } from "./progress.ts";
import { importUrls } from "./search.ts";
import { fragment, Semver, semver } from "./semver.ts";
Expand Down Expand Up @@ -78,13 +78,10 @@ export class Udd {
url: RegistryUrl,
): Promise<UddResult> {
const initUrl: string = url.url;
const initVersion: string = url.version();
const initVersion: string = url.version();
let newFragmentToken: string | undefined = undefined;
await this.progress.log(`Looking for releases: ${url.url}`);
const versions = await url.all();

// for now, let's pick the most recent!
let newVersion = versions[0];
let versions = await url.all();

// FIXME warn that the version modifier is moved to a fragment...
// if the version includes a modifier we move it to the fragment
Expand All @@ -101,6 +98,15 @@ export class Udd {
return { initUrl, initVersion };
}

const isInitVersionPrerelease: boolean = getPrereleaseVersion(initVersion) != null
if (!isInitVersionPrerelease) {
// if the version specified in source code file is not a pre-release version, we want to assume they want to exclude pre-releases from automatic update.
// Therefore, let's filter out all pre-release versions.
versions = versions.filter(version => getPrereleaseVersion(version) == null)
}

let newVersion = versions[0];

// if we pass a fragment with semver
let filter: ((other: Semver) => boolean) | undefined = undefined;
try {
Expand Down