Note: you can open this repository using Gitpod.io for a cloud development environment that is setup with everything you need.
Make sure you have all the prerequisite tools installed:
- Node.js v18.17.1 or later.
- Deno.
- Rancher Desktop
- Used to make development with extra services (MongoDB, Redis, etc.) easy.
- It works exactly like
docker
, except the command isnerdctl
.
- AWS CLI
- CockroachDB
- (Windows Only)Visual Studio with C++ tools(Windows Only)
- Select the "Desktop Development with C++" workflow.
- Clone the repository.
git clone https://github.com/casual-simulation/casualos.git
- Make sure global dependencies are installed.
npm install -g jake node-gyp prisma
- (Windows Only) Tell NPM to use the global
node-gyp
. (Older versions of node-gyp cannot detect Visual Studio 2022)- Powershell:
npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
- Powershell:
- Enable corepack
corepack enable
- Start CockroachDB
- Use a separate terminal tab
npm run cockroach
- If you want, you can choose to start CockroachDB when your system starts or use something like Docker to host your CockroachDB instance.
- (Optional) Add
casualos.localhost
to your hosts file.- You can use this domain to prevent the service worker from installing.
- Follow these steps:
- Open the hosts file as Sudo/Admin.
- On Max/Linux it's at
/etc/hosts
- On Windows it's at
C:\Windows\System32\drivers\etc\hosts
- On Max/Linux it's at
- Add entries to route
casualos.localhost
to127.0.0.1
:127.0.0.1 casualos.localhost
- Open the hosts file as Sudo/Admin.
- Start related services:
- If using
nerdctl
:npm run nerdctl:dev
- If using
docker
:npm run docker:dev
- If using
- Bootstrap the project.
npm run bootstrap
- Install commit hooks.
npx husky install
When developing there are a couple of key commands you can run. Most of them are NPM scripts, so they're easy to run.
- Install existing dependencies
npm run boostrap
- This runs
pnpm install --frozen-lockfile
which means that thepnpm-lock.yaml
file will not be updated. If there are packages that need to be added to the lockfile, you need to runpnpm install
manually.
- Start dev docker services
- If using
nerdctl
:npm run nerdctl:dev
- If using
docker
:npm run docker:dev
- If using
- Build & Run in Watch Mode
npm run watch
- This will trigger Vite to start in watch mode and run nodemon.
- When ready, the server will be available at http://localhost:3000.
- Build in Production Mode
npm run build
- This will trigger Vite in production mode.
- The output files will be in the
dist
folders of each project.
- Run tests In Watch Mode
npm run test:watch
- Run tests
npm test
- Start CockroachDB
npm run cockroach
- Reset your database
prisma migrate reset
- Update your database to match schema (creates a migration if needed)
prisma migrate dev
You can find other scripts in the package.json
file at the root of the repository.
Making new releases for CasualOS is pretty simple. All that needs to happen is for the master
branch to be updated and pushed to Github. From there a webhook is sent to the CI server which instructs it to make a new build and push it to production.
The version number shown in the app is taken from the most recent git tag. We additionally package the git commit hash just in case master
is pushed multiple times without updating the git tag.
Additionally, the CI server will publish the aux-common
NPM package whenever the version number in its package.json
is updated.
To make a new release, use this process:
- Make sure everything you want to release is ready and merged into
develop
. - Update the CHANGELOG.md file with the next version number, date, and changes that were made since the last version.
- Commit the updated CHANGELOG to the
develop
branch. - Merge the
develop
branch into themaster
branch.- Don't use fast-forward. (
--no-ff
) - Don't push yet.
- Don't use fast-forward. (
- Run
lerna version
.- This will look at the changes made and prompt you for the next version number.
- In most cases all you need to do is select patch.
- After confirmation lerna will update the
package.json
version numbers, add a git tag, and push the branch.
- You're done.
- GitHub will send a webhook to the CI server which will make a build and publish everything.
You can analyze builds to see what is making them large and which dependencies are included.
- Go to https://www.bundle-buddy.com/rollup
- Run a build with
npm run build:server
(we only need the server to be built - not all the libraries) - Upload the dependency graph from
src/aux-server/aux-web/dist/dependency-graph.json
. - Upload the sourcemaps from
src/aux-server/aux-web/dist/assets
. - Advance to the analysis page by clicking the button at the bottom of the page.
The reference documentation is generated automatically from doc comments. Here is a brief list of tags that are used to help generate the documentation:
@dochash
- This tells the documentation generator which page a type should be placed in. If a type does not have a@dochash
tag, then it will only make it into the documentation if it is a child of a type that is included via@dochash
. Each unique@dochash
ends up as its own page.@doctitle
- The title of a page. Only the first@doctitle
found for each@dochash
will be used.@docsidebar
- The title of a page in the sidebar. Only the first@docsidebar
found for each@dochash
will be used.@docdescription
- The SEO description of a page. Only the first@docdescription
found for each@dochash
will be used.@docname
- The visual name of the type/function being documented.@docid
- The ID of the type/function being documented. You can use{@link ref}
annotations to reference types/functions by their IDs. If omitted, then@docname
is used as the ID of a type.@docgroup
- An internal group ID for the type. Within a page, types are sorted first by@docgroup
, then by@docorder
, and finally by@docid
.@docorder
- An internal order for the type. Within a page, types are sorted first by@docgroup
, then by@docorder
, and finally by@docid
.@docrename
- Used to rename a type to reference another type. (e.g.@docrename MyOtherType
will cause all references to this type in the documentation to appear as if they are references toMyOtherType
)@docsource
- Tells the generator to generate an interface with the specified name from the property's type. Useful for properties that utilize type declarations.@docreferenceactions
- Tells the generator to find all other types/properties whose IDs match the given regex pattern and include them as extra references for the type.{@link [ref]}
- Renders a link to the type with@docid
matching[ref]
.{@tag [tag]}
- Renders a link to the given[tag]
. Prefix the tag with@
to link to listen tags.
A web application that serves the CasualOS experience. Built on the other projects.
A library that contains common operations needed to modify and understand AUX files.
A set of abstractions and common utilities required to run an AUX on any platform.
A web service that can facilitate WebSocket tunnels from the external web to a device in an internal network.
Here's a list of the tools and packages that we're using to build CasualOS.
- Dev tools
- TypeScript for type checking.
- Vite and esbuild for bundling assets.
- Lerna for managing multiple NPM packages.
- Jake for minor tasks that Vite doesn't handle.
- Jest for testing.
- ts-jest for using TypeScript.
- concurrently for running multiple things at a time.
- nodemon for running node in watch mode.
- Visual Studio Code for file editing and debugging.
- TypeDoc for API documentation generation.
- Husky for pre-commit hooks.
- Dependencies
- AUX Common
- acorn for parsing listener functions.
- acorn-jsx for parsing JSX code in listeners.
- astring for generating JS from acorn trees.
- estraverse for traversing the acorn trees and transforming them.
- lodash for easy array/object manipulation.
- lru-cache for caching formula transpilation results.
- rxjs for reactive programming.
- uuid for generating UUIDs.
- base64-js for base64 encoding/decoding of binary data.
- sha.js for SHA hashing.
- tweetnacl for Encryption/Decryption.
- fast-json-stable-stringify for deterministic JSON serialization. (for hashing)
- acorn for parsing listener functions.
- AUX Server
- vue for JS <--> HTML UI binding.
- vue-material for Material components.
- vue-color for color pickers.
- @chenfengyuan/vue-qrcode for rendering QR Codes.
- vue-router for SPA routing.
- vue-property-decorator for property decorators on Vue classes.
- vue-class-component for class decorators on Vue classes.
- vue-shortkey for keyboard shortcuts.
- three for 3D WebGL rendering.
- troika-three-text for 3D text rendering.
- express for the HTTP server.
- filepond for file uploads.
- vue-filepond for Vue.js integration.
- downloadjs for file downloads.
- mongodb for MongoDB connections.
- vue for JS <--> HTML UI binding.
- AUX Common
If you're using Visual Studio Code, I recommend getting the Jest extension. It makes it real easy to debug unit tests.