elm-ssr 0.5.0 → 0.5.1
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 +11 -5
- package/bin/elm-ssr.mjs +20 -1
- package/lib/scaffold.mjs +10 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# elm-ssr
|
|
2
2
|
|
|
3
|
-
Elm-first SSR library and framework for
|
|
3
|
+
Elm-first SSR library and framework for Fetch-compatible runtimes.
|
|
4
4
|
One package, three pieces:
|
|
5
5
|
|
|
6
6
|
- A **CLI** (`elm-ssr build|new|migrate|dev`) that scans your routes/islands,
|
|
7
7
|
generates the router + manifest, and runs `elm make`.
|
|
8
|
-
- A **
|
|
8
|
+
- A **Fetch-compatible runtime** (`createWorkerApp`, `renderApp`, effect adapters,
|
|
9
9
|
background tasks, SQL migrations, middleware) exported via subpaths.
|
|
10
10
|
- A set of **Elm authoring modules** under `elm-src/ElmSsr/` (Route, Loader,
|
|
11
11
|
Action, Html, Svg, Island, Page, Document, Runtime) which the build syncs
|
|
@@ -17,8 +17,12 @@ One package, three pieces:
|
|
|
17
17
|
bun add elm-ssr
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Then
|
|
21
|
-
|
|
20
|
+
Then import the runtime via subpaths and run the CLI with `bunx`:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
bunx elm-ssr new my-app
|
|
24
|
+
bunx elm-ssr build
|
|
25
|
+
```
|
|
22
26
|
|
|
23
27
|
## CLI commands
|
|
24
28
|
|
|
@@ -29,7 +33,9 @@ workspace) and import the runtime via subpaths.
|
|
|
29
33
|
(one combined island bundle exposing `Elm.<App>.Islands.<Name>`).
|
|
30
34
|
- **`elm-ssr new <name>`** — scaffold a new app and register it in
|
|
31
35
|
`elm-ssr.config.json`.
|
|
32
|
-
- **`elm-ssr dev`** — `build` then `wrangler dev
|
|
36
|
+
- **`elm-ssr dev`** — `build` then `wrangler dev` for Cloudflare-like local
|
|
37
|
+
development. For other hosts, build with `elm-ssr build` and adapt
|
|
38
|
+
`worker.fetch` in your own server/entrypoint.
|
|
33
39
|
- **`elm-ssr compress`** — pre-compress generated bundles with gzip.
|
|
34
40
|
- **`elm-ssr migrate <up|down|status>`** — apply / revert / inspect SQL-file
|
|
35
41
|
migrations. `--db postgres://…`, `sqlite://path`, or a plain SQLite file path;
|
package/bin/elm-ssr.mjs
CHANGED
|
@@ -56,15 +56,32 @@ const printHelp = () => {
|
|
|
56
56
|
`);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
let config = null;
|
|
60
|
+
try {
|
|
61
|
+
config = await readWorkspaceConfig(rootPath);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
if (!err || typeof err !== "object" || !("code" in err) || err.code !== "ENOENT") {
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const requireConfig = () => {
|
|
69
|
+
if (!config) {
|
|
70
|
+
console.error(`Error: elm-ssr.config.json not found at ${rootPath}`);
|
|
71
|
+
console.error("Please run 'elm-ssr new <name>' to create a new workspace and app.");
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
60
75
|
|
|
61
76
|
switch (command) {
|
|
62
77
|
case "build":
|
|
63
78
|
case "compress":
|
|
79
|
+
requireConfig();
|
|
64
80
|
await build({ rootPath, config });
|
|
65
81
|
break;
|
|
66
82
|
|
|
67
83
|
case "dev":
|
|
84
|
+
requireConfig();
|
|
68
85
|
await run("bun", ["run", "build"], rootPath);
|
|
69
86
|
await run("./node_modules/.bin/wrangler", ["dev"], rootPath);
|
|
70
87
|
break;
|
|
@@ -87,12 +104,14 @@ switch (command) {
|
|
|
87
104
|
}
|
|
88
105
|
|
|
89
106
|
case "routes":
|
|
107
|
+
requireConfig();
|
|
90
108
|
for (const app of config.apps) {
|
|
91
109
|
console.log(`${app.name}: root=${app.root} module=${app.module} routes=src/${app.module.split(".").join("/")}/Routes`);
|
|
92
110
|
}
|
|
93
111
|
break;
|
|
94
112
|
|
|
95
113
|
case "info":
|
|
114
|
+
requireConfig();
|
|
96
115
|
console.log(`workspace: ${packageJson.name}`);
|
|
97
116
|
console.log(`apps: ${config.apps.map((app) => app.name).join(", ")}`);
|
|
98
117
|
break;
|
package/lib/scaffold.mjs
CHANGED
|
@@ -475,7 +475,16 @@ const normalizeAppRoot = (rawRoot, name) => {
|
|
|
475
475
|
export const createAppScaffold = async (rootPath, name, options = {}) => {
|
|
476
476
|
ensureValidName(name);
|
|
477
477
|
|
|
478
|
-
|
|
478
|
+
let config;
|
|
479
|
+
try {
|
|
480
|
+
config = await readWorkspaceConfig(rootPath);
|
|
481
|
+
} catch (err) {
|
|
482
|
+
if (err && typeof err === "object" && "code" in err && err.code === "ENOENT") {
|
|
483
|
+
config = { apps: [] };
|
|
484
|
+
} else {
|
|
485
|
+
throw err;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
479
488
|
ensureAppMissing(config, name);
|
|
480
489
|
|
|
481
490
|
const appRoot = normalizeAppRoot(options.root, name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elm-ssr",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Elm-first SSR library and framework for Cloudflare Workers (and Bun): file-based routes/islands, backend-neutral effect adapters (KV/D1/Redis/Postgres), background tasks (waitUntil/Queues), SQL-file migrations, CLI scaffold + build.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Michał Majchrzak <michmajchrzak@gmail.com>",
|