Releases: choonkeat/elm-webapp
npx elm-webapp crud
elm-webapp crud
has changed
- crud generates a standard "Browser.application"
- with the ability to list, create, edit, and
- destroy "Foobar" records
+ crud <TypeName> patch the <target_directory> with the ability
+ to list, create, edit, and destroy "TypeName"
+ records
Trying it with crud Article mynews
where the subdirectory mynews
does not exist yet
$ npx [email protected] crud Article mynews
npx: installed 1 in 1.98s
Writing mynews/Makefile ...
Writing mynews/index.js ...
Writing mynews/lambda.js ...
Writing mynews/node.js ...
Writing mynews/scripts/wait-for-changes.js ...
Writing mynews/src/Client.elm ...
Writing mynews/src/Protocol.elm ...
Writing mynews/src/Server.elm ...
Writing mynews/src/Extra/Codec.elm ...
Writing mynews/src/Extra/Http.elm ...
creating mynews/src/Client/ArticleUI.elm ...
patching mynews/src/Client.elm ...
patching mynews/src/Client.elm ...
patching mynews/src/Client.elm ...
patching mynews/src/Client.elm ...
patching mynews/src/Client.elm ...
patching mynews/src/Client.elm ...
patching mynews/src/Client.elm ...
patching mynews/src/Client.elm ...
patching mynews/src/Client.elm ...
patching mynews/src/Client.elm ...
creating mynews/src/Protocol/Article.elm ...
patching mynews/src/Protocol.elm ...
patching mynews/src/Protocol.elm ...
patching mynews/src/Protocol.elm ...
patching mynews/src/Protocol.elm ...
patching mynews/src/Protocol.elm ...
patching mynews/src/Protocol.elm ...
creating mynews/src/Server/ArticleAPI.elm ...
patching mynews/src/Server.elm ...
patching mynews/src/Server.elm ...
patching mynews/src/Server.elm ...
patching mynews/src/Server.elm ...
Done! Now execute:
1. cd mynews
2. make install
3. make
$ cd mynews
mynews$ make install
...
ready. type `make` to start server
mynews$ make
...
[ 'js' ] [ 'http' ] nodeHttpServer
[ 'js' ] [ 'http' ] server listening at 8000 ...
[ 'js' ] [ 'http' ] [watch] file changes in ./src
and visiting http://localhost:8000 will show
if you run another crud
, e.g. User
into the same directory mynews, you'll get
mynews$ npx [email protected] crud User .
npx: installed 1 in 0.812s
creating src/Client/UserUI.elm ...
patching src/Client.elm ...
patching src/Client.elm ...
patching src/Client.elm ...
patching src/Client.elm ...
patching src/Client.elm ...
patching src/Client.elm ...
patching src/Client.elm ...
patching src/Client.elm ...
patching src/Client.elm ...
patching src/Client.elm ...
creating src/Protocol/User.elm ...
patching src/Protocol.elm ...
patching src/Protocol.elm ...
patching src/Protocol.elm ...
patching src/Protocol.elm ...
patching src/Protocol.elm ...
patching src/Protocol.elm ...
creating src/Server/UserAPI.elm ...
patching src/Server.elm ...
patching src/Server.elm ...
patching src/Server.elm ...
patching src/Server.elm ...
you'll get another CRUD feature added to the existing app 🥳
New cli release
Added 2 new "types". We now total 5 types of apps to be generated:
USAGE:
elm-webapp <type> <target_directory>
TYPE:
While the generated "src/Server.elm" is the same, you can choose
what kind of "src/Client.elm" to generate:
application generates a standard "Browser.application"
document generates a standard "Browser.document"
element generates a standard "Browser.element"
application-element generates a standard "Browser.element" with
routing capabilities like "Browser.application"
but more compatible with browser extensions
This generates a different "src/Server.elm" that comes with "CRUD"
operations with an in-memory server state: Data is preserved on the
Server only while the Server process is running.
crud generates a standard "Browser.application"
with the ability to list, create, edit, and
destroy "Foobar" records
EXAMPLE:
elm-webapp application helloworld
-
application-element
is for generating SPA client code that is more compatible with browser extensions. see https://github.com/jinjor/elm-break-dom and choonkeat/elm-element-navigation#1 -
crud
generates a full CRUD app that persists data in memory; in theServerState
.
crud.demo.mov
The hope is that this helps speed up development; changing the required data easily. Then before releasing the feature, edit the Server.FoobarAPI#updateFromClient
code to persist those memory values in an external DB like Hasura or DynamoDB while leaving the developed src/Client.elm
code untouched
NOTE: courtesy of npm version
, looks like git tags with v
prefix will be npm/cli updates
Type signature changes for `headerDecoder` and `httpEndpoint`
Type signature changes are described respectively in
headerDecoder
97fc97b#commitcomment-57041256httpEndpoint
59068fb#commitcomment-57041258
This release also updates the generator to include a few new MsgFromClient
and MsgFromServer
out of the box
ManyMsgFromClient (List MsgFromClient)
andManyMsgFromServer (List MsgFromServer)
variants are convenient to batch several messages to a single request and/or responseClientServerVersionMismatch
is a new default message that Client can understand that its version is out of sync with Server and should reload (or ask the end user to reload)