Files
AFFiNE-Mirror/tools/cli
DarkSky 2b71b3f345 feat: improve test & bundler (#14434)
#### PR Dependency Tree


* **PR #14434** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Introduced rspack bundler as an alternative to webpack for optimized
builds.

* **Tests & Quality**
* Added comprehensive editor semantic tests covering markdown, hotkeys,
and slash-menu operations.
* Expanded CI cross-browser testing to Chromium, Firefox, and WebKit;
improved shape-rendering tests to account for zoom.

* **Bug Fixes**
  * Corrected CSS overlay styling for development servers.
  * Fixed TypeScript typings for build tooling.

* **Other**
  * Document duplication now produces consistent "(n)" suffixes.
  * French i18n completeness increased to 100%.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-02-14 16:09:09 +08:00
..
2026-02-14 16:09:09 +08:00
2025-01-08 04:07:56 +00:00
2024-12-24 15:29:48 +08:00

AFFiNE Monorepo Cli

Start

yarn affine -h

Run build command defined in package.json

yarn affine i18n build
# or
yarn build -p i18n

Run dev command defined in package.json

yarn affine web dev
# or
yarn dev -p i18n

Clean

yarn affine clean --dist --rust
# clean node_modules
yarn affine clean --node-modules

Init

Generate files that make the monorepo work properly, the per project codegen will not be included anymore

yarn affine init

Tricks

Define scripts to run a .ts files without --loader ts-node/esm/transpile-only

affine run will automatically inject ts-node's transpile service(swc used) for your scripts

{
  "name": "@affine/demo",
  "scripts": {
    "dev": "node ./dev.ts"
  }
}
affine @affine/demo dev

or

{
  "name": "@affine/demo",
  "scripts": {
    "dev": "r ./src/index.ts"
  },
  "devDependencies": {
    "@affine-tools/cli": "workspace:*"
  }
}

Short your key presses

# af is also available for running the scripts
yarn af web build

by custom shell script

personally, I use 'af'

create file af in the root of AFFiNE project with the following content

#!/usr/bin/env sh
./tools/scripts/bin/runner.js affine.ts $@

or on windows:

node "./tools/cli/bin/runner.js" affine.ts %*

and give it executable permission

chmod a+x ./af

# now you can run scripts with simply
./af web build

if you want to go further, but for vscode(or other forks) only, add the following to your .vscode/settings.json

{
  "terminal.integrated.env.osx": {
    "PATH": "${env:PATH}:${cwd}"
  },
  "terminal.integrated.env.linux": {
    "PATH": "${env:PATH}:${cwd}"
  },
  "terminal.integrated.env.windows": {
    "PATH": "${env:PATH};${cwd}"
  }
}

restart all the integrated terminals and now you get:

af web build