Platforms
A platform is a kind of app: a template to copy, the root scripts every app of that kind gets, and the targetsplatform init can set up in it. The built-in platforms are:
| Platform | Template | Targets | What it is |
|---|---|---|---|
web | web | A Nuxt web app: users, auth, account and admin | |
web-standalone | web-standalone | The web app with an OAuth server and API for the mobile and desktop apps (app name web) | |
mobile | mobile | ios, android, apple-watch | A Capacitor app on @frigear-nu/mobile |
desktop | desktop | tauri | A Tauri app on @frigear-nu/desktop |
A project adds its own, such as a wall display or a kiosk: see Custom platforms.
platform add
pnpx @frigear-nu/cli platform add <platform> [name] [-t <template>] [--apps-dir <dir>] [--ref <ref>] [--no-scripts] [--no-install]
| Argument | Default | Purpose |
|---|---|---|
platform | required | web, web-standalone, mobile, desktop, a platform from frigear.platforms in the root package.json, or any other name together with --template. |
name | the platform's name | Folder of the app, kebab-cased. Add the same platform again under another name for a second app. |
-t, --template | the platform's | A template name (web, web-standalone, mobile, desktop, or from frigear.templates) or a giget source such as gh:org/repo/path#ref. |
--apps-dir | auto | Where the app goes; see Where it works. |
--ref | main | Branch or tag of the Frigear repository for the built-in templates. |
--no-scripts | Do not add the platform's scripts to the root package.json. | |
--no-install | Skip the install and prepare:env. |
It works from anywhere in a workspace, the root and the apps folder included:
pnpx @frigear-nu/cli platform add mobile # apps/mobile
cd apps && pnpx @frigear-nu/cli platform add desktop # apps/desktop
pnpx @frigear-nu/cli platform add mobile tablet # a second Capacitor app in apps/tablet
pnpx @frigear-nu/cli platform add display lobby --template web
What it does:
- Copies the template into
<apps folder>/<name>. It fails when that folder already has apackage.json; in a terminal it asks for another name. - Names the package
<scope>/<name>, with the scope of the existing apps (@workspacein the starters), else of the root package, and records"frigear": { "platform": "<platform>" }in it, soplatform initknows what it is. When a workspace package or a dependency of the app already has that name (@frigear-nu/mobilein a workspace scoped@frigear-nu), the package is<scope>/<name>-appinstead, with a warning. The folder and scripts keep<name>. - Adds the platform's root scripts under the app's name. Scripts the root already has are kept as they are, and the
root
devscript is not changed. - Runs the install and the root
prepare:envscript, which writes the app's.envfrom its.env.example. - Prints the next steps.
Root scripts
With the default names these are the multi-platform starter's scripts, so a project that grows one platform at a time ends up with the same commands:
| Platform | Scripts (for an app named mobile, desktop, web) |
|---|---|
mobile | dev:mobile, mobile:native, mobile:doctor, mobile:watch, mobile:sync, mobile:ios, mobile:ios:device, mobile:android |
desktop | dev:desktop, desktop:setup, desktop:doctor, desktop:init, desktop:sync, desktop:dev, desktop:build, desktop:sidecar |
web, web-standalone | dev:web, and db:generate and db:migrate when the root has none yet |
A second app gets its own set: platform add mobile tablet adds dev:tablet, tablet:ios, tablet:android, ...
To start it with the rest, add --filter ./apps/tablet to the root dev script.
Signing in from the new app
A mobile or desktop app signs in at an OAuth server. The command does not register it for you; its next steps say what to do:
- When an app of the workspace runs
@frigear-nu/oauth-server: import the new app'sidentityin that app'snuxt.config.tsand add it tooauthServer.clients, as the multi-platform starter does. - Otherwise: set
NUXT_PUBLIC_AUTHENTICATION_CLIENT_ISSUER(and_API_BASE) in the new app's.env.
identity.ts before you register it or create its native projects.platform init
pnpx @frigear-nu/cli platform init <target> [--app <name>] [--apps-dir <dir>] [-- <flags>]
| Target | Platform | Runs in the app |
|---|---|---|
ios, android | mobile | its native script (frigear-mobile native --platform <target>) |
apple-watch (watchos, watch) | mobile | its watch script, else frigear-mobile watch: a watchOS companion app |
tauri (desktop) | desktop | its native script, else frigear-desktop init |
Which app:
--app: a folder in the apps folder, or a path;- else the app you run it from;
- else the only app whose platform has the target. With several it asks, or fails outside a terminal and lists them.
The platform is the app's frigear.platform, else worked out from its dependencies (@frigear-nu/mobile,
@frigear-nu/desktop, nuxt). It runs the target's script of the app when the app has it, else the target's binary
from the app's dependencies. Flags after -- go to the script or binary:
pnpx @frigear-nu/cli platform init ios -- --if-missing
pnpx @frigear-nu/cli platform init apple-watch --app tablet
platform list
pnpx @frigear-nu/cli platform list [--apps-dir <dir>]
Prints the platforms (built-in and the project's own) with their templates and targets, the template names, and each app of the apps folder with its platform.
app:create
pnpx @frigear-nu/cli app:create <name> [--template <template>] [--apps-dir <dir>] [--ref <ref>] [--no-install]
The older form of platform add <template> <name>, with --template defaulting to web. It adds the root scripts
too.
Next steps
- Custom platforms – declare a platform of your own.
- Mobile CLI and devices – what
frigear-mobile nativeandwatchdo. - Multi-platform starter – the project all three platforms add up to.