Class CompatibilityDate

java.lang.Object
dev.gmitch215.bytebox.gradle.CompatibilityDate

public final class CompatibilityDate extends Object
Checks a compatibility date before Wrangler has to.

Three checks, in increasing authority. Format and calendar are decided here, because they are decidable here. Redundant flags are a warning, matching Cloudflare's own position that a flag already default-on is ignored. Whether the installed runtime knows a date is not decidable here at all — the set of valid dates is a property of the installed Wrangler and moves — so that one is left to wrangler deploy --dry-run.

Since:
1.0.0
  • Method Details

    • parse

      public static LocalDate parse(String text)
      Reads a date, refusing anything Wrangler would refuse for a reason decidable here.
      Parameters:
      text - the date, as yyyy-mm-dd
      Returns:
      the parsed date
    • redundant

      public static Map<String,LocalDate> redundant(LocalDate date, List<String> flags)
      Flags that are already the default for a date, and so do nothing.

      Reported rather than refused, because Cloudflare ignores a redundant flag and refusing one would break a configuration that works.

      Parameters:
      date - the compatibility date
      flags - the declared flags
      Returns:
      the redundant ones, with the date each became the default
    • nodeCompatByDefault

      public static boolean nodeCompatByDefault(LocalDate date)
      Whether a date has Node compatibility on by default.

      Which decides whether the generated configuration has to turn it off. Java needs no Node polyfills, the v2 flag is documented as increasing bundle size, and the compiler's runtime treats a process global as proof it is running under Node.

      Parameters:
      date - the compatibility date
      Returns:
      whether the flags have to be disabled explicitly