Add script to automate updating compatibility key.

This commit is contained in:
Dillon Kearns 2022-11-15 11:43:18 -08:00
parent cc7344d815
commit 91192ca39a
7 changed files with 1319 additions and 3 deletions

View File

@ -1 +0,0 @@
1

View File

@ -0,0 +1 @@
module.exports = { compatibilityKey: 1 };

View File

@ -9,6 +9,7 @@ const preRenderHtml = require("./pre-render-html.js");
const { lookupOrPerform } = require("./request-cache.js"); const { lookupOrPerform } = require("./request-cache.js");
const kleur = require("kleur"); const kleur = require("kleur");
const cookie = require("cookie-signature"); const cookie = require("cookie-signature");
const { compatibilityKey } = require("../compatibility-key.js");
kleur.enabled = true; kleur.enabled = true;
process.on("unhandledRejection", (error) => { process.on("unhandledRejection", (error) => {
@ -17,7 +18,6 @@ process.on("unhandledRejection", (error) => {
let foundErrors; let foundErrors;
let pendingDataSourceResponses; let pendingDataSourceResponses;
let pendingDataSourceCount; let pendingDataSourceCount;
const compatibilityKey = 1;
module.exports = module.exports =
/** /**

View File

@ -23,6 +23,7 @@ import PageServerResponse exposing (PageServerResponse)
import Pages.Flags import Pages.Flags
import Pages.Http import Pages.Http
import Pages.Internal.NotFoundReason as NotFoundReason exposing (NotFoundReason) import Pages.Internal.NotFoundReason as NotFoundReason exposing (NotFoundReason)
import Pages.Internal.Platform.CompatibilityKey
import Pages.Internal.Platform.Effect as Effect exposing (Effect) import Pages.Internal.Platform.Effect as Effect exposing (Effect)
import Pages.Internal.Platform.StaticResponses as StaticResponses exposing (StaticResponses) import Pages.Internal.Platform.StaticResponses as StaticResponses exposing (StaticResponses)
import Pages.Internal.Platform.ToJsPayload as ToJsPayload import Pages.Internal.Platform.ToJsPayload as ToJsPayload
@ -49,7 +50,7 @@ type alias Flags =
{-| -} {-| -}
currentCompatibilityKey : Int currentCompatibilityKey : Int
currentCompatibilityKey = currentCompatibilityKey =
1 Pages.Internal.Platform.CompatibilityKey.currentCompatibilityKey
{-| -} {-| -}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
module Pages.Internal.Platform.CompatibilityKey exposing (currentCompatibilityKey)
currentCompatibilityKey : Int
currentCompatibilityKey =
1

33
update-compatibility-keys.js Executable file
View File

@ -0,0 +1,33 @@
#!/usr/bin/node
const fs = require("fs");
const currentCompatibilityKey = 1;
fs.writeFileSync(
"src/Pages/Internal/Platform/CompatibilityKey.elm",
`module Pages.Internal.Platform.CompatibilityKey exposing (currentCompatibilityKey)
currentCompatibilityKey : Int
currentCompatibilityKey =
${currentCompatibilityKey}
`
);
fs.writeFileSync(
"generator/compatibility-key.js",
`module.exports = { compatibilityKey: ${currentCompatibilityKey} };
`
);
fs.writeFileSync(
"./README.md",
fs
.readFileSync("./README.md")
.toString()
.replace(
/Current Compatibility Key: \d+\./,
`Current Compatibility Key: ${currentCompatibilityKey}.`
)
);