-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: check db integrity after building it.
- Loading branch information
Showing
5 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/.env | ||
/dist | ||
elm-stuff | ||
/check-db-app.js | ||
/compute-aggregated-app.js | ||
/node_modules | ||
/public/app.js | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { Elm } = require("./check-db-app"); | ||
|
||
const elmApp = Elm.CheckDb.init({}); | ||
|
||
elmApp.ports.logAndExit.subscribe(({ message, status }) => { | ||
if (status > 0) { | ||
console.error(`🚨 ERROR: ${message}`); | ||
} else { | ||
console.info(message); | ||
} | ||
process.exit(status); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,10 @@ | |
"build": "npm run server:build && rimraf dist && npm run build:init && parcel build index.html --public-url ./", | ||
"build:init": "./bin/update-version.sh && mkdir -p dist && cp -r public/* dist/ && npm run db:build", | ||
"build:standalone-app": "npm run build && npm run server:build && cp server-app.js dist/ && cp openapi.yaml dist/", | ||
"processes:build": "elm make src/ComputeAggregated.elm --output=compute-aggregated-app.js && node compute-aggregated.js", | ||
"decrypt": "./bin/decrypt", | ||
"encrypt": "./bin/encrypt", | ||
"db:build": "./bin/build-db", | ||
"db:build": "./bin/build-db && npm run db:check", | ||
"db:check": "elm make src/CheckDb.elm --optimize --output=check-db-app.js 1> /dev/null && node check-db.js", | ||
"lint:openapi": "npx swagger-cli validate openapi.yaml", | ||
"lint:prettier": "prettier --config .prettierrc --check", | ||
"lint:prettier:all": "npm run lint:prettier -- .", | ||
|
@@ -34,6 +34,7 @@ | |
"fix:ruff:format": "pipenv run ruff format --force-exclude", | ||
"fix:all": "npm run fix:ruff:all && npm run fix:prettier:all", | ||
"format:json": "npx [email protected] --write . && pipenv run ruff check --select I --fix && pipenv run ruff format", | ||
"processes:build": "elm make src/ComputeAggregated.elm --output=compute-aggregated-app.js && node compute-aggregated.js", | ||
"server:build": "npm run db:build && elm make src/Server.elm --optimize --output=server-app.js", | ||
"server:dev": "npm run server:build && nodemon server.js --config nodemon.json", | ||
"server:debug": "elm make src/Server.elm --output=server-app.js && nodemon server.js --config nodemon.json", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
port module CheckDb exposing (main) | ||
|
||
import Static.Db as StaticDb | ||
import Static.Json as StaticJson | ||
|
||
|
||
main : Program () () () | ||
main = | ||
Platform.worker | ||
{ init = | ||
always <| | ||
( () | ||
, case StaticDb.db StaticJson.rawJsonProcesses of | ||
Err error -> | ||
logAndExit { message = "Db is dubious: " ++ error, status = 1 } | ||
|
||
Ok _ -> | ||
logAndExit { message = "Db is fine", status = 0 } | ||
) | ||
, subscriptions = always Sub.none | ||
, update = \_ _ -> ( (), Cmd.none ) | ||
} | ||
|
||
|
||
port logAndExit : { message : String, status : Int } -> Cmd msg |