Development
This article will walk you through the development process of OS.js modules and packages.
Introduction
Before beginning read the overview article to familiarize yourself with the architecture and involved technologies.
With a standard installation you get a fully working development environment out of the box.
[info] Note that by default package extensions (applications, themes, etc.) are built separately from your installation/distribution. Make sure to run commands inside the correct directory
If you're using Docker (docker-compose
) for your environment, you have to execute CLI commands within the Docker image context. Example:
docker-compose exec osjs npm run watch
Naming conventions
The following list contains the naming convention for modules and packages (in git
and npm
):
[warning] Names are unique
osjs-<project>-application
- Application packageosjs-<project>-provider
- Service Provider moduleosjs-<project>-auth
- Authentication adapterosjs-<project>-settings
- Settings storage adapterosjs-<project>-adapter
- VFS Adaptersosjs-<project>-theme
- Theme packageosjs-<project>-icons
- Icons packageosjs-<project>-sounds
- Sounds packageosjs-<project>-cli
- CLI Pluginosjs-<project>
- Core modules
Official projects are scoped with @osjs/<project>-<suffix>
when published onto npmjs.
If you want to publish a module or package, look at the publish guide.
Building
These are the default provided commands for performing build actions:
npm run build
Build changes oncenpm run watch
Watch and build changes automatically
To produce a production build, prefix your command with ex: NODE_ENV=production npm run <task>
.
Testing
These are the default provided commands for performing test actions:
npm run test
- Run all tests and lintersnpm run eslint
- ESLint passnpm run stylelint
- Stylelint passnpm run jest
- Jest unit tests
Developing Modules
The OS.js client and server are split up into several modules provided by npm
packages (see package.json
).
To override these modules follow the modules guide.
To make your own module(s), you can use the CLI Wizard:
npm run make:provider
- Service Provider - See Service Provider Tutorialnpm run make:auth
- Authentication Adapter - See Authentication Tutorialnpm run make:settings
- Settings Adapter - See Settings Tutorialnpm run make:vfs
- VFS Adapter - See VFS Tutorial
For custom CLI tasks see CLI Guide
Developing Packages
Packages are usually installed via npm
(within node_modules
) but can also be placed into src/packages
. To set up custom package discovery paths, see CLI Guide.
[info] Packages installed in
node_modules/
always have the lowest priority, and discovery paths are prioritized by their order (ascending). This means you can replacenpm
installed packages without removing them frompackage.json
itself.
Run npm run make:application
to create a new application package package from a wizard using the standard template. Or an Iframe application with npm run make:iframe-application
.
# Create a new application from template
npm run make:application
# Discover all packages to make it visible in the client
npm run package:discover