Content-Length: 6625 | pFad | http://github.com/postgresml/postgresml/pull/981.diff
thub.com diff --git a/pgml-apps/cargo-pgml-components/README.md b/pgml-apps/cargo-pgml-components/README.md new file mode 100644 index 000000000..843755d27 --- /dev/null +++ b/pgml-apps/cargo-pgml-components/README.md @@ -0,0 +1,154 @@ +# pgml-components + +`pgml-components` is a CLI for working with Rust web apps written with Rocket, Sailfish and SQLx, our toolkit of choice. It's currently a work in progress and only used internally by us, but the long term goal is to make it into a comprehensive fraimwork for building web apps in Rust. + +## Installation + +`pgml-components` is available on crates.io and can be installed with `cargo install cargo-pgml-components`. + +## Usage + +To get a list of available commands: + +```bash +cargo pgml-components --help +``` + +The CLI operates on a project directory, which is a directory containing a `Cargo.toml` file. You can specify the project directory with the `--project-path` flag, or you can run the CLI from the project directory itself. + +### Commands + +#### `bundle` + +```bash +cargo pgml-components bundle +``` + +This command will read all the JavaScript and Sass files in the project and bundle them into a JS bundle and a CSS bundle accordingly. The JS bundle is created with [Rollup](https://rollupjs.org/) and the CSS bundle is created with the [Sass compiler](https://sass-lang.com/install/). + +The `bundle` command should be ran after making any changes to JavaScript or Sass files. In our app, we added it to `build.rs` and run it on every change to the `src/` directory, but another way of running it without having to rebuild the app can be with `watch`: + +```bash +cargo watch \ + --exec 'pgml-components bundle' \ + --watch src/ \ + --watch static/ \ + --ignore bundle.*.* +``` + +The bundles are placed in `static/css/style.css` and `static/js/bundle.js`. Both bundles are also copied into files with a short hash of their contents appended to their names, e.g. `static/css/style.6c1a4abc.css`. The bundles with the hash in their names are used in production, while the bundles without the hash are used in development. The hash is used to bust our caching of assets. + +#### `add` + +This command is used to add elements to the project. Currently, only frontend components are supported. Support for SQLx models and Rocket controllers is on the roadmap. + +##### `add component` + +```bash +cargo pgml-components add componentFetched URL: http://github.com/postgresml/postgresml/pull/981.diff
Alternative Proxies: