mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-28 20:29:53 -04:00
Compare commits
29 Commits
5be85e7b6b
...
4ffb481634
Author | SHA1 | Date | |
---|---|---|---|
4ffb481634 | |||
6bc9f2ea2e | |||
ec18d9de97 | |||
9249dca202 | |||
dac4324c8f | |||
e3c4a01648 | |||
e1735e4243 | |||
651f0cb264 | |||
3e853f51eb | |||
251cbfa5c7 | |||
1b6023a03e | |||
3e675b47f4 | |||
6f7d44ff83 | |||
b105ce3f4b | |||
0ba5f18b22 | |||
a320351041 | |||
874a5fdb57 | |||
bb092212ac | |||
9022503e76 | |||
94e1987f09 | |||
a104ef5f47 | |||
dac529e8e8 | |||
6e0e00c7f3 | |||
8942eb59a5 | |||
e80953e987 | |||
c64605f9e7 | |||
d7cea46427 | |||
45737f24e4 | |||
61634cd682 |
@ -1,5 +1,6 @@
|
||||
[workspace]
|
||||
members = [ "recipes", "kitchen", "web", "api" ]
|
||||
resolver = "2"
|
||||
|
||||
[patch.crates-io]
|
||||
# TODO(jwall): When the fix for RcSignal Binding is released we can drop this patch.
|
||||
|
16
Makefile
16
Makefile
@ -14,6 +14,11 @@
|
||||
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
mkfile_dir := $(dir $(mkfile_path))
|
||||
sqlite_url := sqlite://$(mkfile_dir)/.session_store/store.db
|
||||
out := dist
|
||||
project := kitchen
|
||||
|
||||
export out
|
||||
export kitchen
|
||||
|
||||
kitchen: wasm kitchen/src/*.rs
|
||||
cd kitchen; cargo build
|
||||
@ -27,15 +32,18 @@ static-prep: web/index.html web/favicon.ico web/static/*.css
|
||||
cp -r web/favicon.ico web/dist/
|
||||
cp -r web/static web/dist/
|
||||
|
||||
wasmrelease: wasmrelease-dist static-prep
|
||||
wasmrelease: wasm-opt static-prep
|
||||
|
||||
wasm-opt: wasmrelease-dist
|
||||
cd web; sh ../scripts/wasm-opt.sh release
|
||||
|
||||
wasmrelease-dist: web/src/*.rs web/src/components/*.rs
|
||||
cd web; wasm-pack build --mode no-install --release --target web --no-typescript --out-name kitchen_wasm --out-dir dist/
|
||||
cd web; sh ../scripts/wasm-build.sh release
|
||||
|
||||
wasm: wasm-dist static-prep
|
||||
|
||||
wasm-dist: web/src/*.rs web/src/components/*.rs
|
||||
cd web; wasm-pack build --mode no-install --target web --no-typescript --out-dir dist/ --features debug_logs
|
||||
cd web; sh ../scripts/wasm-build.sh debug
|
||||
|
||||
clean:
|
||||
rm -rf web/dist/*
|
||||
@ -50,5 +58,5 @@ sqlx-add-%:
|
||||
sqlx-revert:
|
||||
cd kitchen; cargo sqlx migrate revert --database-url $(sqlite_url)
|
||||
|
||||
sqlx-prepare:
|
||||
sqlx-prepare: kitchen
|
||||
cd kitchen; cargo sqlx prepare --database-url $(sqlite_url)
|
||||
|
33
flake.lock
generated
33
flake.lock
generated
@ -31,6 +31,24 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681202837,
|
||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
@ -124,6 +142,21 @@
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
@ -45,6 +45,14 @@
|
||||
wasm-bindgen = pkgs.callPackage wasm-bindgenGen { inherit pkgs; };
|
||||
kitchenWasm = kitchenWasmGen {
|
||||
inherit pkgs rust-wasm wasm-bindgen version;
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
# I'm maintaining some patches for these so the lockfile hashes are a little
|
||||
# incorrect. We override those here.
|
||||
"wasm-web-component-0.2.0" = "sha256-quuPgzGb2F96blHmD3BAUjsWQYbSyJGZl27PVrwL92k=";
|
||||
"sycamore-0.8.2" = "sha256-D968+8C5EelGGmot9/LkAlULZOf/Cr+1WYXRCMwb1nQ=";
|
||||
"sqlx-0.6.2" = "sha256-X/LFvtzRfiOIEZJiVzmFvvULPpjhqvI99pSwH7a//GM=";
|
||||
};
|
||||
};
|
||||
kitchen = (kitchenGen {
|
||||
inherit pkgs version naersk-lib kitchenWasm rust-wasm;
|
||||
|
@ -0,0 +1,2 @@
|
||||
-- Add down migration script here
|
||||
ALTER TABLE recipes DROP COLUMN serving_count;
|
2
kitchen/migrations/20240701002811_recipe-servings.up.sql
Normal file
2
kitchen/migrations/20240701002811_recipe-servings.up.sql
Normal file
@ -0,0 +1,2 @@
|
||||
-- Add up migration script here
|
||||
ALTER TABLE recipes ADD column serving_count number;
|
@ -3,23 +3,18 @@
|
||||
features ? "",
|
||||
rust-wasm,
|
||||
wasm-bindgen,
|
||||
lockFile,
|
||||
outputHashes,
|
||||
}:
|
||||
with pkgs;
|
||||
let
|
||||
pname = "kitchen-wasm";
|
||||
src = ./../..;
|
||||
lockFile = ./../../Cargo.lock;
|
||||
# NOTE(jwall): Because we use wasm-pack directly below we need
|
||||
# the cargo dependencies to already be installed.
|
||||
cargoDeps = (pkgs.rustPlatform.importCargoLock { inherit lockFile; outputHashes = {
|
||||
# I'm maintaining some patches for these so the lockfile hashes are a little
|
||||
# incorrect. We override those here.
|
||||
"wasm-web-component-0.2.0" = "sha256-quuPgzGb2F96blHmD3BAUjsWQYbSyJGZl27PVrwL92k=";
|
||||
"sycamore-0.8.2" = "sha256-D968+8C5EelGGmot9/LkAlULZOf/Cr+1WYXRCMwb1nQ=";
|
||||
"sqlx-0.6.2" = "sha256-X/LFvtzRfiOIEZJiVzmFvvULPpjhqvI99pSwH7a//GM=";
|
||||
};
|
||||
});
|
||||
cargoDeps = (pkgs.rustPlatform.importCargoLock { inherit lockFile outputHashes; });
|
||||
in
|
||||
# TODO(zaphar): I should actually be leveraging naersklib.buildPackage with a postInstall for the optimization and bindgen
|
||||
stdenv.mkDerivation {
|
||||
inherit src pname;
|
||||
version = version;
|
||||
@ -34,14 +29,13 @@ stdenv.mkDerivation {
|
||||
'';
|
||||
# TODO(jwall): Build this from the root rather than the src.
|
||||
buildPhase = ''
|
||||
set -x
|
||||
echo building with wasm-pack
|
||||
wasm-pack --version
|
||||
mkdir -p $out
|
||||
cd web
|
||||
cp -r static $out
|
||||
cargo build --lib --release --target wasm32-unknown-unknown --target-dir $out --offline
|
||||
wasm-bindgen $out/wasm32-unknown-unknown/release/kitchen_wasm.wasm --out-dir $out --typescript --target web
|
||||
sh ../scripts/wasm-build.sh release
|
||||
#cargo build --lib --release --target wasm32-unknown-unknown --target-dir $out ${features} --offline
|
||||
#wasm-bindgen $out/wasm32-unknown-unknown/release/kitchen_wasm.wasm --out-dir $out --typescript --target web
|
||||
#sh ../scripts/wasm-opt.sh release
|
||||
wasm-opt $out/kitchen_wasm_bg.wasm -o $out/kitchen_wasm_bg-opt.wasm -O
|
||||
rm -f $out/kitchen_wasm_bg.wasm
|
||||
mv $out/kitchen_wasm_bg-opt.wasm $out/kitchen_wasm_bg.wasm
|
||||
|
@ -8,9 +8,7 @@ in
|
||||
, nodejs
|
||||
, pkg-config
|
||||
, openssl
|
||||
, stdenv
|
||||
, curl
|
||||
, runCommand
|
||||
}:
|
||||
|
||||
# This package is special so we don't use the naersk infrastructure to build it.
|
||||
|
@ -6,10 +6,6 @@ A web assembly experiment in Meal Planning and Shopping List management.
|
||||
|
||||
Ensure you have rust installed with support for the web assembly target. You can see instructions here: [Rust wasm book](https://rustwasm.github.io/docs/book/game-of-life/setup.html).
|
||||
|
||||
You will also want to have trunk installed. You can see instructions for that here: [trunk](https://trunkrs.dev/)
|
||||
|
||||
Then obtain the source. We do not at this time publish kitchen on [crates.io](https://crates.io/).
|
||||
|
||||
```sh
|
||||
git clone https://github.com/zaphar/kitchen
|
||||
cd kitchen
|
||||
@ -23,7 +19,7 @@ make release
|
||||
|
||||
# Hacking on kitchen
|
||||
|
||||
If you want to hack on kitchen, then you may find it useful to use trunk in dev mode. The run script will run build the app and run trunk with it watching for changes and reloading on demand in your browser.
|
||||
The run script will run build the app and run it for you.
|
||||
|
||||
```sh
|
||||
./run.sh
|
||||
@ -37,4 +33,4 @@ If all of the above looks like too much work, and you already use the nix packag
|
||||
|
||||
```sh
|
||||
nix run github:zaphar/kitchen
|
||||
```
|
||||
```
|
||||
|
9
scripts/wasm-build.sh
Normal file
9
scripts/wasm-build.sh
Normal file
@ -0,0 +1,9 @@
|
||||
set -x
|
||||
buildtype=$1;
|
||||
|
||||
if [ ${buildtype} = "release" ]; then
|
||||
buildtype_flag="--release"
|
||||
fi
|
||||
|
||||
cargo build --lib ${buildtype_flag} --target wasm32-unknown-unknown --target-dir $out --features debug_logs
|
||||
wasm-bindgen $out/wasm32-unknown-unknown/${buildtype}/kitchen_wasm.wasm --out-dir $out --typescript --target web
|
6
scripts/wasm-opt.sh
Normal file
6
scripts/wasm-opt.sh
Normal file
@ -0,0 +1,6 @@
|
||||
set -x
|
||||
buildtype=$1;
|
||||
|
||||
wasm-opt $out/wasm32-unknown-unkown/${buildtype}/${project}_wasm.wasm --out-dir dist/ -O
|
||||
rm -f $out/${project}_wasm_bg.wasm
|
||||
mv $out/${project}_wasm_bg-opt.wasm dist/${project}_wasm_bg.wasm
|
Loading…
x
Reference in New Issue
Block a user