elm-pages 3.0.8 → 3.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/codegen/elm-pages-codegen.cjs +732 -350
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmo +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateDataTest.elmo +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +2 -2
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +7328 -7699
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +2 -2
- package/generator/dead-code-review/elm.json +2 -2
- package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +1 -1
- package/generator/dead-code-review/src/ReviewConfig.elm +3 -1
- package/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm +63 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +2 -2
- package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +2768 -3160
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +2 -2
- package/generator/review/elm.json +7 -8
- package/generator/src/build.js +3 -4
- package/generator/src/cli.js +1 -1
- package/generator/src/codegen.js +1 -1
- package/generator/src/compatibility-key.js +2 -2
- package/generator/src/render.js +1 -6
- package/generator/static-code/elm-pages.js +12 -9
- package/generator/template/app/ErrorPage.elm +15 -12
- package/generator/template/codegen/elm.codegen.json +2 -2
- package/generator/template/elm-tooling.json +1 -1
- package/generator/template/gitignore +2 -1
- package/generator/template/netlify.toml +1 -1
- package/generator/template/package.json +6 -5
- package/generator/template/script/elm.json +3 -3
- package/generator/template/script/src/AddStaticRoute.elm +87 -0
- package/package.json +25 -24
- package/src/ApiRoute.elm +47 -35
- package/src/BackendTask/Custom.elm +12 -15
- package/src/BackendTask/File.elm +4 -1
- package/src/BackendTask/Glob.elm +34 -31
- package/src/BackendTask.elm +57 -44
- package/src/FatalError.elm +2 -2
- package/src/Head/Seo.elm +3 -3
- package/src/List/Chunks.elm +51 -0
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/Pages/Manifest.elm +2 -2
- package/src/Scaffold/Route.elm +95 -49
- package/src/Server/Session.elm +9 -6
|
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
|
|
|
75
75
|
const { Elm } = require("./Runner.elm.js");
|
|
76
76
|
|
|
77
77
|
// Start the Elm app
|
|
78
|
-
const flags = { initialSeed:
|
|
78
|
+
const flags = { initialSeed: 4173409726, fuzzRuns: 100, filter: null };
|
|
79
79
|
const app = Elm.Runner.init({ flags: flags });
|
|
80
80
|
|
|
81
81
|
// Record the timing at which we received the last "runTest" message
|
|
@@ -75,14 +75,14 @@ let testsCount, todoTests;
|
|
|
75
75
|
let reporter;
|
|
76
76
|
let runners = [];
|
|
77
77
|
let working = false;
|
|
78
|
-
let workersCount =
|
|
78
|
+
let workersCount = 4;
|
|
79
79
|
let startWorkCallback = function(){};
|
|
80
80
|
const verbosity = 0;
|
|
81
81
|
|
|
82
82
|
// Create a long lived reporter worker
|
|
83
83
|
const { Elm } = require("./Reporter.elm.js");
|
|
84
84
|
const flags = {
|
|
85
|
-
initialSeed:
|
|
85
|
+
initialSeed: 4173409726,
|
|
86
86
|
fuzzRuns: 100,
|
|
87
87
|
mode: "consoleNoColor",
|
|
88
88
|
verbosity: verbosity,
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"elm/html": "1.0.0",
|
|
12
12
|
"elm/json": "1.1.3",
|
|
13
13
|
"elm/regex": "1.0.0",
|
|
14
|
-
"jfmengels/elm-review": "2.13.
|
|
15
|
-
"mdgriffith/elm-codegen": "
|
|
16
|
-
"stil4m/elm-syntax": "7.2
|
|
14
|
+
"jfmengels/elm-review": "2.13.1",
|
|
15
|
+
"mdgriffith/elm-codegen": "4.1.1",
|
|
16
|
+
"stil4m/elm-syntax": "7.3.2",
|
|
17
17
|
"the-sett/elm-syntax-dsl": "6.0.2"
|
|
18
18
|
},
|
|
19
19
|
"indirect": {
|
|
@@ -25,18 +25,17 @@
|
|
|
25
25
|
"elm/time": "1.0.0",
|
|
26
26
|
"elm/virtual-dom": "1.0.3",
|
|
27
27
|
"elm-community/basics-extra": "4.1.0",
|
|
28
|
-
"elm-community/list-extra": "8.7.0",
|
|
29
28
|
"elm-community/maybe-extra": "5.3.0",
|
|
30
|
-
"elm-explorations/test": "2.1.
|
|
31
|
-
"miniBill/elm-unicode": "1.0
|
|
29
|
+
"elm-explorations/test": "2.1.2",
|
|
30
|
+
"miniBill/elm-unicode": "1.1.0",
|
|
32
31
|
"rtfeldman/elm-hex": "1.0.0",
|
|
33
32
|
"stil4m/structured-writer": "1.0.3",
|
|
34
|
-
"the-sett/elm-pretty-printer": "3.
|
|
33
|
+
"the-sett/elm-pretty-printer": "3.1.0"
|
|
35
34
|
}
|
|
36
35
|
},
|
|
37
36
|
"test-dependencies": {
|
|
38
37
|
"direct": {
|
|
39
|
-
"elm-explorations/test": "2.1.
|
|
38
|
+
"elm-explorations/test": "2.1.2"
|
|
40
39
|
},
|
|
41
40
|
"indirect": {}
|
|
42
41
|
}
|
package/generator/src/build.js
CHANGED
|
@@ -100,7 +100,7 @@ export async function run(options) {
|
|
|
100
100
|
ssr: false,
|
|
101
101
|
|
|
102
102
|
build: {
|
|
103
|
-
manifest:
|
|
103
|
+
manifest: '___vite-manifest___.json',
|
|
104
104
|
outDir: "dist",
|
|
105
105
|
rollupOptions: {
|
|
106
106
|
input: "elm-stuff/elm-pages/index.html",
|
|
@@ -123,7 +123,7 @@ export async function run(options) {
|
|
|
123
123
|
fullOutputPath,
|
|
124
124
|
withoutExtension
|
|
125
125
|
);
|
|
126
|
-
const assetManifestPath = path.join(process.cwd(), "dist/
|
|
126
|
+
const assetManifestPath = path.join(process.cwd(), "dist/___vite-manifest___.json");
|
|
127
127
|
const manifest = JSON.parse(
|
|
128
128
|
await fsPromises.readFile(assetManifestPath, { encoding: "utf-8" })
|
|
129
129
|
);
|
|
@@ -155,7 +155,7 @@ export async function run(options) {
|
|
|
155
155
|
`<script defer src="/elm.${browserElmHash}.js" type="text/javascript"></script>`
|
|
156
156
|
);
|
|
157
157
|
await fsPromises.writeFile("dist/template.html", processedIndexTemplate);
|
|
158
|
-
await fsPromises.unlink(assetManifestPath);
|
|
158
|
+
// await fsPromises.unlink(assetManifestPath);
|
|
159
159
|
const portBackendTaskCompiled = esbuild
|
|
160
160
|
.build({
|
|
161
161
|
entryPoints: ["./custom-backend-task"],
|
|
@@ -221,7 +221,6 @@ export async function render(request) {
|
|
|
221
221
|
addWatcher,
|
|
222
222
|
false
|
|
223
223
|
);
|
|
224
|
-
console.dir(response);
|
|
225
224
|
if (response.kind === "bytes") {
|
|
226
225
|
return {
|
|
227
226
|
body: response.contentDatPayload.buffer,
|
package/generator/src/cli.js
CHANGED
|
@@ -346,7 +346,7 @@ async function requireElm(compiledElmPath) {
|
|
|
346
346
|
const warnOriginal = console.warn;
|
|
347
347
|
console.warn = function () {};
|
|
348
348
|
|
|
349
|
-
let Elm = (await import(path.resolve(compiledElmPath))).default;
|
|
349
|
+
let Elm = (await import(url.pathToFileURL(path.resolve(compiledElmPath)).href)).default;
|
|
350
350
|
console.warn = warnOriginal;
|
|
351
351
|
return Elm;
|
|
352
352
|
}
|
package/generator/src/codegen.js
CHANGED
|
@@ -72,7 +72,7 @@ export async function generate(basePath) {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
function writeFetcherModules(basePath, fetcherData) {
|
|
75
|
-
Promise.all(
|
|
75
|
+
return Promise.all(
|
|
76
76
|
fetcherData.map(([name, fileContent]) => {
|
|
77
77
|
let filePath = path.join(basePath, `/Fetcher/${name.join("/")}.elm`);
|
|
78
78
|
ensureDirSync(path.dirname(filePath));
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const compatibilityKey =
|
|
1
|
+
export const compatibilityKey = 21;
|
|
2
2
|
|
|
3
|
-
export const packageVersion = "3.0.
|
|
3
|
+
export const packageVersion = "3.0.10";
|
package/generator/src/render.js
CHANGED
|
@@ -512,12 +512,7 @@ async function readFileJobNew(req, patternsToWatch) {
|
|
|
512
512
|
try {
|
|
513
513
|
patternsToWatch.add(filePath);
|
|
514
514
|
|
|
515
|
-
const fileContents =
|
|
516
|
-
(
|
|
517
|
-
await fsPromises.readFile(
|
|
518
|
-
path.join(process.env.LAMBDA_TASK_ROOT || process.cwd(), filePath)
|
|
519
|
-
)
|
|
520
|
-
).toString();
|
|
515
|
+
const fileContents = (await fsPromises.readFile(filePath)).toString();
|
|
521
516
|
// TODO does this throw an error if there is invalid frontmatter?
|
|
522
517
|
const parsedFile = matter(fileContents);
|
|
523
518
|
|
|
@@ -103,14 +103,17 @@ function find_anchor(node) {
|
|
|
103
103
|
return /** @type {HTMLAnchorElement} */ (node);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
formData
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
// only run in modern browsers to prevent exception: https://github.com/dillonkearns/elm-pages/issues/427
|
|
107
|
+
if ("SubmitEvent" in window) {
|
|
108
|
+
Object.defineProperty(SubmitEvent.prototype, "fields", {
|
|
109
|
+
get: function fields() {
|
|
110
|
+
let formData = new FormData(this.currentTarget);
|
|
111
|
+
if (this.submitter && this.submitter.name) {
|
|
112
|
+
formData.append(this.submitter.name, this.submitter.value);
|
|
113
|
+
}
|
|
114
|
+
return [...formData.entries()];
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
115
118
|
|
|
116
119
|
setup();
|
|
@@ -3,7 +3,6 @@ module ErrorPage exposing (ErrorPage(..), Model, Msg, head, init, internalError,
|
|
|
3
3
|
import Effect exposing (Effect)
|
|
4
4
|
import Head
|
|
5
5
|
import Html exposing (Html)
|
|
6
|
-
import Html.Events exposing (onClick)
|
|
7
6
|
import View exposing (View)
|
|
8
7
|
|
|
9
8
|
|
|
@@ -54,20 +53,24 @@ view : ErrorPage -> Model -> View Msg
|
|
|
54
53
|
view error model =
|
|
55
54
|
{ body =
|
|
56
55
|
[ Html.div []
|
|
57
|
-
[ Html.p []
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
)
|
|
66
|
-
]
|
|
56
|
+
[ Html.p []
|
|
57
|
+
[ Html.text <|
|
|
58
|
+
case error of
|
|
59
|
+
NotFound ->
|
|
60
|
+
"Page not found. Maybe try another URL?"
|
|
61
|
+
|
|
62
|
+
InternalError string ->
|
|
63
|
+
"Something went wrong.\n" ++ string
|
|
67
64
|
]
|
|
68
65
|
]
|
|
69
66
|
]
|
|
70
|
-
, title =
|
|
67
|
+
, title =
|
|
68
|
+
case error of
|
|
69
|
+
NotFound ->
|
|
70
|
+
"Page Not Found"
|
|
71
|
+
|
|
72
|
+
InternalError string ->
|
|
73
|
+
"Unexpected Error"
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"elm-codegen-version": "0.
|
|
2
|
+
"elm-codegen-version": "0.5.1",
|
|
3
3
|
"codegen-helpers": {
|
|
4
4
|
"packages": {
|
|
5
5
|
"elm/core": "1.0.5",
|
|
6
6
|
"dillonkearns/elm-form": "3.0.0",
|
|
7
7
|
"elm/html": "1.0.0",
|
|
8
8
|
"rtfeldman/elm-css": "18.0.0",
|
|
9
|
-
"dillonkearns/elm-pages": "10.0.
|
|
9
|
+
"dillonkearns/elm-pages": "10.0.3",
|
|
10
10
|
"elm/json": "1.1.3"
|
|
11
11
|
},
|
|
12
12
|
"local": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[build]
|
|
2
2
|
functions = "functions/"
|
|
3
3
|
publish = "dist/"
|
|
4
|
-
command = "
|
|
4
|
+
command = "export ELM_HOME=\"$NETLIFY_BUILD_BASE/cache/elm\" && npm install && npm run build"
|
|
5
5
|
|
|
6
6
|
[dev]
|
|
7
7
|
command = "npm start"
|
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
"build": "elm-pages build"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"elm-codegen": "^0.
|
|
10
|
+
"elm-codegen": "^0.5.1",
|
|
11
11
|
"elm-optimize-level-2": "^0.3.5",
|
|
12
|
-
"elm-pages": "^3.0.
|
|
13
|
-
"elm-review": "^2.10.
|
|
14
|
-
"elm-tooling": "^1.
|
|
15
|
-
"
|
|
12
|
+
"elm-pages": "^3.0.10",
|
|
13
|
+
"elm-review": "^2.10.3",
|
|
14
|
+
"elm-tooling": "^1.15.0",
|
|
15
|
+
"lamdera": "^0.19.1-1.2.1-1",
|
|
16
|
+
"vite": "^5.0.11"
|
|
16
17
|
},
|
|
17
18
|
"dependencies": {
|
|
18
19
|
"@netlify/functions": "^1.4.0"
|
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"direct": {
|
|
10
10
|
"dillonkearns/elm-cli-options-parser": "3.2.0",
|
|
11
|
-
"dillonkearns/elm-pages": "10.0.
|
|
11
|
+
"dillonkearns/elm-pages": "10.0.3",
|
|
12
12
|
"elm/bytes": "1.0.8",
|
|
13
13
|
"elm/core": "1.0.5",
|
|
14
14
|
"elm/html": "1.0.0",
|
|
15
15
|
"elm/json": "1.1.3",
|
|
16
|
-
"mdgriffith/elm-codegen": "
|
|
16
|
+
"mdgriffith/elm-codegen": "4.1.1"
|
|
17
17
|
},
|
|
18
18
|
"indirect": {
|
|
19
19
|
"Chadtech/elm-bool-extra": "2.4.2",
|
|
20
20
|
"avh4/elm-color": "1.0.0",
|
|
21
21
|
"danfishgold/base64-bytes": "1.1.0",
|
|
22
22
|
"danyx23/elm-mimetype": "4.0.1",
|
|
23
|
-
"dillonkearns/elm-bcp47-language-tag": "
|
|
23
|
+
"dillonkearns/elm-bcp47-language-tag": "2.0.0",
|
|
24
24
|
"dillonkearns/elm-date-or-date-time": "2.0.0",
|
|
25
25
|
"dillonkearns/elm-form": "3.0.0",
|
|
26
26
|
"elm/browser": "1.0.2",
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module AddStaticRoute exposing (run)
|
|
2
|
+
|
|
3
|
+
import BackendTask
|
|
4
|
+
import Cli.Option as Option
|
|
5
|
+
import Cli.OptionsParser as OptionsParser
|
|
6
|
+
import Cli.Program as Program
|
|
7
|
+
import Elm
|
|
8
|
+
import Elm.Annotation as Type
|
|
9
|
+
import Elm.Case
|
|
10
|
+
import Gen.BackendTask
|
|
11
|
+
import Gen.Effect as Effect
|
|
12
|
+
import Gen.Html as Html
|
|
13
|
+
import Gen.Platform.Sub
|
|
14
|
+
import Gen.View
|
|
15
|
+
import Pages.Script as Script exposing (Script)
|
|
16
|
+
import Scaffold.Route exposing (Type(..))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
type alias CliOptions =
|
|
20
|
+
{ moduleName : List String
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
run : Script
|
|
25
|
+
run =
|
|
26
|
+
Script.withCliOptions program
|
|
27
|
+
(\cliOptions ->
|
|
28
|
+
cliOptions
|
|
29
|
+
|> createFile
|
|
30
|
+
|> Script.writeFile
|
|
31
|
+
|> BackendTask.allowFatal
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
program : Program.Config CliOptions
|
|
36
|
+
program =
|
|
37
|
+
Program.config
|
|
38
|
+
|> Program.add
|
|
39
|
+
(OptionsParser.build CliOptions
|
|
40
|
+
|> OptionsParser.with (Option.requiredPositionalArg "module" |> Scaffold.Route.moduleNameCliArg)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
createFile : CliOptions -> { path : String, body : String }
|
|
45
|
+
createFile { moduleName } =
|
|
46
|
+
Scaffold.Route.preRender
|
|
47
|
+
{ moduleName = moduleName
|
|
48
|
+
, pages =
|
|
49
|
+
Gen.BackendTask.succeed
|
|
50
|
+
(Elm.list [])
|
|
51
|
+
, data =
|
|
52
|
+
( Alias (Type.record [])
|
|
53
|
+
, \routeParams ->
|
|
54
|
+
Gen.BackendTask.succeed (Elm.record [])
|
|
55
|
+
)
|
|
56
|
+
, head = \app -> Elm.list []
|
|
57
|
+
}
|
|
58
|
+
|> Scaffold.Route.buildWithLocalState
|
|
59
|
+
{ view =
|
|
60
|
+
\{ shared, model, app } ->
|
|
61
|
+
Gen.View.make_.view
|
|
62
|
+
{ title = moduleName |> String.join "." |> Elm.string
|
|
63
|
+
, body =
|
|
64
|
+
Elm.list
|
|
65
|
+
[ Html.h2 [] [ Html.text "New Page" ]
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
, update =
|
|
69
|
+
\{ shared, app, msg, model } ->
|
|
70
|
+
Elm.Case.custom msg
|
|
71
|
+
(Type.named [] "Msg")
|
|
72
|
+
[ Elm.Case.branch0 "NoOp"
|
|
73
|
+
(Elm.tuple model
|
|
74
|
+
Effect.none
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
, init =
|
|
78
|
+
\{ shared, app } ->
|
|
79
|
+
Elm.tuple (Elm.record []) Effect.none
|
|
80
|
+
, subscriptions =
|
|
81
|
+
\{ routeParams, path, shared, model } ->
|
|
82
|
+
Gen.Platform.Sub.none
|
|
83
|
+
, model =
|
|
84
|
+
Alias (Type.record [])
|
|
85
|
+
, msg =
|
|
86
|
+
Custom [ Elm.variant "NoOp" ]
|
|
87
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elm-pages",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.10",
|
|
5
5
|
"homepage": "https://elm-pages.com",
|
|
6
6
|
"moduleResolution": "node",
|
|
7
7
|
"description": "Type-safe static sites, written in pure elm with your own custom elm-markup syntax.",
|
|
@@ -27,45 +27,46 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"busboy": "^1.6.0",
|
|
29
29
|
"chokidar": "^3.5.3",
|
|
30
|
-
"commander": "^
|
|
30
|
+
"commander": "^11.1.0",
|
|
31
31
|
"connect": "^3.7.0",
|
|
32
32
|
"cookie-signature": "^1.2.1",
|
|
33
33
|
"cross-spawn": "7.0.3",
|
|
34
34
|
"devcert": "^1.2.2",
|
|
35
35
|
"elm-doc-preview": "^5.0.5",
|
|
36
36
|
"elm-hot": "^1.1.6",
|
|
37
|
-
"esbuild": "^0.
|
|
38
|
-
"fs-extra": "^11.
|
|
39
|
-
"globby": "
|
|
37
|
+
"esbuild": "^0.19.11",
|
|
38
|
+
"fs-extra": "^11.2.0",
|
|
39
|
+
"globby": "14.0.0",
|
|
40
40
|
"gray-matter": "^4.0.3",
|
|
41
41
|
"jsesc": "^3.0.2",
|
|
42
42
|
"kleur": "^4.1.5",
|
|
43
|
-
"make-fetch-happen": "^
|
|
44
|
-
"memfs": "^
|
|
43
|
+
"make-fetch-happen": "^13.0.0",
|
|
44
|
+
"memfs": "^4.6.0",
|
|
45
45
|
"micromatch": "^4.0.5",
|
|
46
46
|
"serve-static": "^1.15.0",
|
|
47
|
-
"terser": "^5.
|
|
48
|
-
"vite": "^
|
|
49
|
-
"which": "^
|
|
47
|
+
"terser": "^5.26.0",
|
|
48
|
+
"vite": "^5.0.11",
|
|
49
|
+
"which": "^4.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/cross-spawn": "^6.0.
|
|
53
|
-
"@types/fs-extra": "^11.0.
|
|
54
|
-
"@types/make-fetch-happen": "^10.0.
|
|
55
|
-
"@types/micromatch": "^4.0.
|
|
56
|
-
"@types/node": "^20.
|
|
57
|
-
"@types/serve-static": "^1.15.
|
|
58
|
-
"cypress": "^
|
|
59
|
-
"elm-codegen": "^0.
|
|
52
|
+
"@types/cross-spawn": "^6.0.6",
|
|
53
|
+
"@types/fs-extra": "^11.0.4",
|
|
54
|
+
"@types/make-fetch-happen": "^10.0.4",
|
|
55
|
+
"@types/micromatch": "^4.0.6",
|
|
56
|
+
"@types/node": "^20.10.7",
|
|
57
|
+
"@types/serve-static": "^1.15.5",
|
|
58
|
+
"cypress": "^13.6.2",
|
|
59
|
+
"elm-codegen": "^0.5.1",
|
|
60
60
|
"elm-optimize-level-2": "^0.3.5",
|
|
61
|
-
"elm-review": "^2.10.
|
|
61
|
+
"elm-review": "^2.10.3",
|
|
62
62
|
"elm-test": "^0.19.1-revision12",
|
|
63
|
-
"elm-tooling": "^1.
|
|
64
|
-
"elm-verify-examples": "^5.
|
|
63
|
+
"elm-tooling": "^1.15.0",
|
|
64
|
+
"elm-verify-examples": "^5.3.0",
|
|
65
65
|
"elmi-to-json": "^1.4.3",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
66
|
+
"lamdera": "^0.19.1-1.2.1-1",
|
|
67
|
+
"typescript": "^5.3.3",
|
|
68
|
+
"vite": "^5.0.11",
|
|
69
|
+
"vitest": "^1.1.3"
|
|
69
70
|
},
|
|
70
71
|
"files": [
|
|
71
72
|
"adapter/",
|
package/src/ApiRoute.elm
CHANGED
|
@@ -65,10 +65,11 @@ You define your ApiRoute's in `app/Api.elm`. Here's a simple example:
|
|
|
65
65
|
|
|
66
66
|
import ApiRoute
|
|
67
67
|
import BackendTask exposing (BackendTask)
|
|
68
|
+
import FatalError exposing (FatalError)
|
|
68
69
|
import Server.Request
|
|
69
70
|
|
|
70
71
|
routes :
|
|
71
|
-
BackendTask (List Route)
|
|
72
|
+
BackendTask FatalError (List Route)
|
|
72
73
|
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
|
73
74
|
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
|
74
75
|
routes getStaticRoutes htmlToString =
|
|
@@ -119,41 +120,52 @@ You define your ApiRoute's in `app/Api.elm`. Here's a simple example:
|
|
|
119
120
|
requestPrinterExample : ApiRoute ApiRoute.Response
|
|
120
121
|
requestPrinterExample =
|
|
121
122
|
ApiRoute.succeed
|
|
122
|
-
(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
123
|
+
(\pageId revisionId request ->
|
|
124
|
+
Encode.object
|
|
125
|
+
[ ( "pageId"
|
|
126
|
+
, Encode.string pageId
|
|
127
|
+
)
|
|
128
|
+
, ( "revisionId"
|
|
129
|
+
, Encode.string revisionId
|
|
130
|
+
)
|
|
131
|
+
, ( "body"
|
|
132
|
+
, request
|
|
133
|
+
|> Server.Request.body
|
|
134
|
+
|> Maybe.map Encode.string
|
|
135
|
+
|> Maybe.withDefault Encode.null
|
|
136
|
+
)
|
|
137
|
+
, ( "method"
|
|
138
|
+
, request
|
|
139
|
+
|> Server.Request.method
|
|
140
|
+
|> Server.Request.methodToString
|
|
141
|
+
|> Encode.string
|
|
142
|
+
)
|
|
143
|
+
, ( "cookies"
|
|
144
|
+
, request
|
|
145
|
+
|> Server.Request.cookies
|
|
146
|
+
|> Encode.dict
|
|
147
|
+
identity
|
|
148
|
+
Encode.string
|
|
149
|
+
)
|
|
150
|
+
, ( "queryParams"
|
|
151
|
+
, request
|
|
152
|
+
|> Server.Request.queryParams
|
|
153
|
+
|> Encode.dict
|
|
154
|
+
identity
|
|
155
|
+
(Encode.list Encode.string)
|
|
156
|
+
)
|
|
157
|
+
]
|
|
158
|
+
|> Response.json
|
|
159
|
+
|> BackendTask.succeed
|
|
155
160
|
)
|
|
156
|
-
|
|
161
|
+
-- Path: /pages/:pageId/revisions/:revisionId/request-test
|
|
162
|
+
|> ApiRoute.literal "pages"
|
|
163
|
+
|> ApiRoute.slash
|
|
164
|
+
|> ApiRoute.capture
|
|
165
|
+
|> ApiRoute.slash
|
|
166
|
+
|> ApiRoute.literal "revisions"
|
|
167
|
+
|> ApiRoute.slash
|
|
168
|
+
|> ApiRoute.capture
|
|
157
169
|
|> ApiRoute.slash
|
|
158
170
|
|> ApiRoute.literal "request-test"
|
|
159
171
|
|> ApiRoute.serverRender
|
|
@@ -35,26 +35,23 @@ we're using `BackendTask.allowFatal` to let the framework treat that as an unexp
|
|
|
35
35
|
```javascript
|
|
36
36
|
// custom-backend-task.js
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
} else {
|
|
49
|
-
throw `No environment variable called ${name}
|
|
38
|
+
/**
|
|
39
|
+
* @param { string } fromElm
|
|
40
|
+
* @returns { Promise<string> }
|
|
41
|
+
*/
|
|
42
|
+
export async function environmentVariable(name) {
|
|
43
|
+
const result = process.env[name];
|
|
44
|
+
if (result) {
|
|
45
|
+
return result;
|
|
46
|
+
} else {
|
|
47
|
+
throw `No environment variable called ${name}
|
|
50
48
|
|
|
51
49
|
Available:
|
|
52
50
|
|
|
53
51
|
${Object.keys(process.env).join("\n")}
|
|
54
52
|
`;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
58
55
|
```
|
|
59
56
|
|
|
60
57
|
|
package/src/BackendTask/File.elm
CHANGED
|
@@ -5,7 +5,8 @@ module BackendTask.File exposing
|
|
|
5
5
|
)
|
|
6
6
|
|
|
7
7
|
{-| This module lets you read files from the local filesystem as a [`BackendTask`](BackendTask#BackendTask).
|
|
8
|
-
File paths are relative to the root of your `elm-pages` project (next to the `elm.json` file and `src/` directory)
|
|
8
|
+
File paths are relative to the root of your `elm-pages` project (next to the `elm.json` file and `src/` directory), or
|
|
9
|
+
you can pass in absolute paths beginning with a `/`.
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
## Files With Frontmatter
|
|
@@ -167,6 +168,7 @@ bodyWithFrontmatter frontmatterDecoder filePath =
|
|
|
167
168
|
{ title = "BackendTask.File Decoder Error"
|
|
168
169
|
, body =
|
|
169
170
|
"I encountered a Json Decoder error from a call to BackendTask.File.bodyWithFrontmatter.\n\n"
|
|
171
|
+
++ ("I was trying to process `" ++ filePath ++ "`.\n\n")
|
|
170
172
|
++ Decode.errorToString frontmatterDecodeError
|
|
171
173
|
}
|
|
172
174
|
|> FatalError.build
|
|
@@ -257,6 +259,7 @@ onlyFrontmatter frontmatterDecoder filePath =
|
|
|
257
259
|
{ title = "BackendTask.File Decoder Error"
|
|
258
260
|
, body =
|
|
259
261
|
"I encountered a Json Decoder error from a call to BackendTask.File.onlyFrontmatter.\n\n"
|
|
262
|
+
++ ("I was trying to process `" ++ filePath ++ "`.\n\n")
|
|
260
263
|
++ Decode.errorToString frontmatterDecodeError
|
|
261
264
|
}
|
|
262
265
|
|> FatalError.build
|