Skip to content

Commands ​

Development ​

bash
cp .env.example .env
laravel key:generate
npm install
laravel migrate
laravel dev

laravel is the Laravel for Rust CLI. The equivalent is running the application binary directly: cargo run -- <command>.

Name clash with PHP's Laravel Installer

If the laravel on your PATH is PHP's Laravel Installer (laravel list shows only new and package), use cargo run -- <command> instead.

CommandEffect
laravel dev / npm run devRuns the server (restarted on Rust changes), a queue worker and Vite together
cargo run -- serveRuns only the server
cargo run -- migrateRuns migrations
cargo run -- migrate:freshEmpties the database and reruns them
cargo run -- make:migration create_customers_tableCreates a migration
cargo run -- route:listLists routes; cg's four are under /{prefix}/…
cargo run -- cache:clearClears the cache: this clears every in-progress Linker instance
cargo run -- key:generateGenerates APP_KEY: the endpoint prefix and every signed URL change
cargo run -- listEvery command

Tests and checks ​

bash
cargo test --workspace
bash
DB_CONNECTION=sqlite DATABASE_URL='sqlite::memory:' cargo test --workspace
bash
cargo test -p cg-component --test php_parity
bash
cargo clippy --workspace --all-targets
bash
npm run build
bash
npm run types:check

Syncing ​

bash
python3 scripts/sync-php-assets.py /path/to/CGWebFramework

See Syncing with the PHP project.

This wiki ​

bash
cd wiki && npm install && npm run dev
bash
cd wiki && npm run build

build checks for dead links; to deploy under a subpath, set WIKI_BASE=/path/.

Audits ​

PHP has php artisan linker:list (lists components, methods and actions and checks them one to one). Rust has no equivalent command, so do the same with grep:

Attack surface: registered components and exposed methods ​

bash
grep -rn "linker::register::<" src
bash
grep -rn -A1 "const ALIAS\|const METHODS" src/cg

Every METHODS line is a method the browser can call. When a PR adds a method → review its authorization and validation (checklist).

Fragment allow list ​

bash
grep -rn "render::register(" src

Actions: the Rust table vs the JS implementations ​

bash
sed -n '/^pub const BUILTIN_ACTIONS/,/^];/p' crates/cg-component/src/runtime/linker/response.rs \
  | grep -oE '"[a-z]+\.[a-zA-Z]+"' | tr -d '"' | sort -u > /tmp/rust-actions
grep -o "^register('[^']*'" resources/js/cg/linker/actions.js | sed "s/register('//;s/'//" | sort -u > /tmp/js-actions
diff /tmp/rust-actions /tmp/js-actions

Currently the only difference is < ui.test (only on the Rust side; see Action governance).

Custom actions: every name Rust uses exists in JS ​

bash
grep -rhoE 'Action::new\("[a-z0-9]+\.[a-zA-Z0-9]+"' src | sort -u
bash
grep -rhoE "registerLinkerAction\('[^']+'" resources/js --exclude-dir=cg | sort -u

HTML output as is ​

bash
grep -rnE 'Html::raw|\|safe' src resources/views

For each hit, check that the inserted value isn't user data, or has been escaped.

Debug output ​

bash
grep -rn "dbg!\|eprintln!\|println!" src