Bumps [bamarni/composer-bin-plugin](https://github.com/bamarni/composer-bin-plugin) from 1.8.3 to 1.9.1. - [Release notes](https://github.com/bamarni/composer-bin-plugin/releases) - [Commits](https://github.com/bamarni/composer-bin-plugin/compare/1.8.3...1.9.1) --- updated-dependencies: - dependency-name: bamarni/composer-bin-plugin dependency-version: 1.9.1 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
Nextcloud App Template
This is a starter template for a Nextcloud app, using Vue 3 with Vite as frontend.
It also has a convenient file generator for when you will be developing your app.
How to use this template
At the top of the GitHub page for this repository, click "Use this template" to create a copy of this repository.
Once you have it cloned on your machine:
- Run
./rename-template.shto do a mass renaming of all the relevant files to match your app name and your user/full name. They will be asked as input when you run the script. This will also move the GitHub workflow files to the right place. - Run
make- this will trigger the initial build, download all dependencies and make other preparations as necessary. - Start developing! Read the rest of the readme below for more information about what you can do.
Table of Contents
- Makefile
- NPM (package.json)
- Common workflows
- Scaffolding
- GitHub Workflows
- Project layout
- Release Please (automated versioning & releases)
- Resources
Makefile
There is a robust Makefile in the project which should give you everything you need in order to develop & release your app.
Below is a rundown of the different targets you can run:
| Command | What it does | When to use it | Notes |
|---|---|---|---|
make |
Alias for make build. |
Anytime; default target. | Same as make build. |
make build |
Installs PHP deps (if composer.json exists) and JS deps (if package.json or js/package.json exists), then runs the JS build. |
First run; after pulling changes; CI. | Skips steps that don’t apply (no composer.json / no package.json). |
make composer |
Installs Composer deps. If Composer isn’t installed, fetches a local composer.phar. |
When PHP deps changed. | Skips if vendor/ already exists. |
make pnpm |
pnpm install --frozen-lockfile then run build. Uses root package.json if present, else js/. |
When JS deps or build changed. | Requires pnpm. |
make clean |
Removes build/ artifacts. |
Before re-packaging; to start fresh. | Keeps dependencies. |
make refresh-autoload |
Regenerate Composer autoload files | After renaming the app namespace or classes | Most useful after using ./rename-template.sh but also sometimes useful after moving around a lot of PHP files. |
make distclean |
clean + removes vendor/, node_modules/, js/vendor/, js/node_modules/. |
Nuke-from-orbit cleanup. | You’ll need to re-install deps. |
make dist |
Runs make source and make appstore. |
Release prep; CI packaging. | Produces both tarballs. |
make source |
Builds a source tarball at build/artifacts/source/<app>.tar.gz. |
Sharing source-only bundle. | Excludes tests, logs, node_modules, etc. |
make appstore |
Builds an App Store–ready tarball at build/artifacts/appstore/<app>.tar.gz. |
Upload to Nextcloud App Store. | Aggressively excludes dev/test files & dotfiles. |
make test |
Runs PHP unit tests (tests/phpunit.xml and optional tests/phpunit.integration.xml). |
CI or local test run. | Ensures Composer deps first. |
make lint |
Lints JS (pnpm lint) and PHP (composer run lint via local composer.phar if needed). |
Pre-commit checks. | Requires corresponding scripts. |
make php-cs-fixer |
Fixes staged PHP files with PHP-CS-Fixer (after php -l). |
Before committing PHP changes. | Operates on files staged in Git. |
make format |
Formats JS (pnpm format) and PHP (composer run cs:fix). |
Enforce code style. | Requires those scripts in composer/package.json. |
make openapi |
Generates OpenAPI JSON via composer script openapi. |
Refresh API docs. | Output: build/openapi/openapi.json. |
make sign |
Downloads the GitHub release tarball for the version in version.txt and prints a base64 SHA-512 signature. |
Manual signing for App Store. | Needs private key at ~/.nextcloud/certificates/<app>.key. |
make release |
Uploads the signed release to the Nextcloud App Store. | Final publish step. | Needs NEXTCLOUD_API_TOKEN env var; prompts if missing. |
Quick workflows
Fresh setup / development
pnpm --version # ensure pnpm is installed
make build # install PHP+JS deps and build
make test # run PHP tests
make lint # lint JS + PHP
Package for release
make dist # builds both source + appstore tarballs
Sign and publish to App Store
# Ensure version.txt is set, and your key exists at ~/.nextcloud/certificates/<app>.key
make sign # prints signature for the GitHub tarball
export NEXTCLOUD_API_TOKEN=... # or let the target prompt you
make release
Prerequisites:
make,curl,tar,pnpm, and (optionally)composer. If Composer isn’t installed, the Makefile auto-downloads a localcomposer.phar.
NPM (package.json)
Run with pnpm <script> (or npm run <script> / yarn <script> if you prefer).
| Script | What it does | When to use it | Notes |
|---|---|---|---|
pnpm dev |
Runs vite build --watch. |
Local dev where you want incremental rebuilds written to dist/. |
This is a watching build, not a dev server. It continuously rebuilds on file changes. Pair it with Nextcloud serving the compiled assets. |
pnpm build |
Type-checks with vue-tsc -b and then does a full vite build. |
CI, release builds, or when you want a clean production bundle. | vue-tsc -b runs TypeScript project references/build mode, catching TS errors beyond ESLint. |
pnpm lint |
Lints the src/ directory using ESLint. |
Quick checks before committing or in CI. | Respects your .eslintrc* config. No auto-fix. |
pnpm format |
Auto-fixes ESLint issues in src/ and then runs Prettier on src/ and README.md. |
Enforce consistent style automatically. | Safe to run often; keeps diffs clean. |
pnpm prepare |
Runs husky installation hook. |
After pnpm install (automatically). |
Ensures Git hooks (like pre-commit linting) are installed. |
pnpm gen |
Generates scaffolding for various templates (both PHP and TS) | Anytime you want to easily create new files from templates. | See below |
Common workflows
While developing (continuous build output):
pnpm dev
# Edit files → Vite rebuilds to dist/ automatically.
Before pushing a branch (runs automatically using commit hooks):
pnpm lint
pnpm build
Fix style issues quickly:
pnpm format
Fresh clone:
pnpm install
# husky installs via "prepare"
pnpm build
Scaffolding
Generate boilerplate for common app pieces with:
pnpm gen <type> [name]
nameis required for every type exceptmigration.- Files are created from templates in
gen/<type>and written to the configured output directory. Feel free to modify/remove any of these templates or add new ones. - Generators never create subfolders (they write directly into the output path).
Available generators
| Type | Purpose | Output directory | Name required? | Template folder | Notes |
|---|---|---|---|---|---|
component |
Vue single-file component for reusable UI | src/components |
✅ | gen/component |
For user-facing building blocks. |
page |
Vue page / route view | src/pages |
✅ | gen/page |
Pair with your router. |
api |
PHP controller (API endpoint) | lib/Controller |
✅ | gen/api |
PSR-4 namespace: OCA\<App>\Controller. |
service |
PHP service class | lib/Service |
✅ | gen/service |
Business logic; DI-friendly. |
util |
PHP utility/helper | lib/Util |
✅ | gen/util |
Pure helpers / small utilities. |
model |
PHP DB model / entity | lib/Db |
✅ | gen/model |
Pair with migrations. |
command |
Nextcloud OCC console command | lib/Command |
✅ | gen/command |
Shows up in occ. |
task-queued |
Queued background job | lib/Cron |
✅ | gen/task-queued |
Extend queued job base. |
task-timed |
Timed background job (cron) | lib/Cron |
✅ | gen/task-timed |
Scheduled execution. |
migration |
Database migration | lib/Migration |
❌ | gen/migration |
Auto-numbers version; injects version and dt. |
How migrations are numbered
The scaffolder looks at lib/Migration, finds the latest VersionNNNN... file, and increments
it for you. It also injects:
version— the next numeric versiondt— a timestamp likeYYYYMMDDHHmmss(viadate-fns)
You don’t pass a name for migrations.
Examples
Create a Vue component:
pnpm gen component UserListItem
# → src/components/UserListItem.vue
Create a Vue page:
pnpm gen page Settings
# → src/pages/Settings.vue
Create an API controller:
pnpm gen api Users
# → lib/Controller/UsersController.php
Create a service:
pnpm gen service MyService
# → lib/Service/MyService.php
Create a queued job:
pnpm gen task-queued UpdateUsers
# → lib/Cron/UpdateUsers.php
Create a migration (no name):
pnpm gen migration
# → lib/Migration/Version{NEXT}.php (with injected {version} and {dt})
Tips & gotchas
- Router pages: After
pnpm gen page <Name>, add the route in your router (src/router/index.ts) and import the file. - Cron vs queued: Use
task-timedfor scheduled runs,task-queuedfor background work enqueued by events or controllers.
GitHub Workflows
Here’s a drop-in GitHub Workflows section for your README. It explains each workflow, what
triggers it, what it does, any required secrets, and how they’re enabled by your
rename-template.sh script.
GitHub Workflows
In the template, all workflows live under .github/workflows.template/ so they don’t run on the
template repo itself.
When you create a new project from this template and run ./rename-template.sh, the script moves
them to .github/workflows/ so Actions start running automatically.
| Workflow file | What it’s called in Actions | Triggers | What it does | Secrets / env | Notes |
|---|---|---|---|---|---|
.github/workflows.template/block-unconventional-commits.yml |
Block unconventional commits | On PR open/ready/reopen/sync | Blocks PRs with non-conventional commit messages (Conventional Commits). | Uses default GITHUB_TOKEN. |
Uses webiny/action-conventional-commits. Good for keeping a clean history and auto-changelogs. |
.github/workflows.template/build-npm.yml |
Build NPM | Push & PR | Installs pnpm deps and runs pnpm build to ensure the project builds. |
— | Sets CYPRESS_INSTALL_BINARY=0, PUPPETEER_SKIP_DOWNLOAD=true to speed up CI. |
.github/workflows.template/lint-appinfo-xml.yml |
Lint appinfo.xml | Push to master & PR |
Validates appinfo/info.xml against the App Store XSD schema. |
— | Downloads schema from Nextcloud App Store repo and lints with xmllint. |
.github/workflows.template/lint-eslint.yml |
Lint eslint (summary shows as eslint) |
Push & PR | ESLint on src/** and related files. Skips if no relevant changes. |
— | Uses dorny/paths-filter to skip unrelated changes and a summary job so you can mark ESLint as “required” in branch protection. |
.github/workflows.template/lint-openapi.yml |
Lint OpenAPI | Push to master & PR |
Regenerates OpenAPI via Composer and fails if openapi*.json (and optional TS types) aren’t committed. |
— | Skips if repo owner is nextcloud-gmbh. Expects composer run openapi, and will check for src/types/openapi/openapi*.ts if present. |
.github/workflows.template/lint-php-cs.yml |
Lint php-cs | Push to master & PR |
Runs PHP coding-standards check (composer run cs:check). Suggests composer run cs:fix on failure. |
— | Sets up PHP with common extensions. |
.github/workflows.template/lint-php.yml |
Lint php / php-lint-summary | Push to master & PR |
Runs composer run lint across a PHP version matrix. Summary job reports overall status. |
— | Uses Nextcloud version matrix action to decide supported PHP versions. |
.github/workflows.template/psalm-matrix.yml |
Static analysis | Manual (workflow_dispatch) |
Runs Psalm static analysis against a Nextcloud OCP version matrix. | — | You can uncomment PR/push triggers if you want it always on. Requires composer run psalm. |
.github/workflows.template/release.yml |
Release / App Store Build / Upload Release Artifacts / Release to Nextcloud Apps | Push & PR on master |
Uses Release Please to create a GitHub release; builds App Store tarball; uploads artifact to the release; optionally pushes to Nextcloud App Store. | RELEASE_PLEASE_TOKEN (GitHub token), NEXTCLOUD_API_TOKEN (App Store), NEXTCLOUD_APP_PRIVATE_KEY (PEM, base64 or raw) |
Build step runs make && make appstore. The Upload step renames the tarball with the tag. The final step signs and submits to the App Store using your secrets. |
Project layout
.
├─ appinfo/ # App metadata & registration (info.xml, routes.php, app.php)
├─ lib/ # PHP backend code (PSR-4: OCA\<App>\…)
│ ├─ Controller/ # OCS/HTTP controllers (API endpoints)
│ ├─ Service/ # Business logic & integrations
│ ├─ Db/ # Entities / mappers
│ ├─ Migration/ # Database migrations (Version*.php)
│ ├─ Cron/ # Timed/queued background jobs
│ ├─ Command/ # occ console commands
│ └─ Util/ # Small helpers
├─ src/ # Frontend (Vue 3 + Vite + TS)
│ ├─ app.ts # ⚡ Loader for the **user-facing app** (loaded via templates/app.php)
│ ├─ settings.ts # ⚙️ Loader for the **settings page** (loaded via templates/settings.php)
│ ├─ main.ts # (optional) main entry or shared bootstrap
│ ├─ components/ # Reusable UI components
│ ├─ pages/ # Route views / pages (user-facing)
│ ├─ views/ # Additional views (e.g., settings sub-pages)
│ ├─ router/ # Vue Router setup
│ ├─ styles/ # Global styles
│ └─ assets/ # Static assets used by the frontend
├─ templates/ # Server-rendered entry templates
│ ├─ app.php # Mounts the user-facing app bundle (uses dist output of src/app.ts)
│ └─ settings.php # Mounts the settings bundle (uses dist output of src/settings.ts)
├─ l10n/ # Translations (JSON/JS) for IL10N
├─ build/ # Build artifacts & tools (created by Makefile)
│ ├─ artifacts/ # Packaged tarballs (source/appstore)
│ └─ tools/ # composer.phar, etc.
├─ gen/ # Scaffolding templates (used by `pnpm gen`)
│ ├─ component/ page/ api/ … # See “Scaffolding” section
├─ dist/ # Vite build output (bundled JS/CSS)
├─ tests/ # PHPUnit configs & tests
├─ package.json # Frontend scripts (`pnpm build`, `pnpm dev`, etc.)
├─ composer.json # PSR-4 autoload for PHP (e.g., "OCA\\<App>\\" : "lib/")
├─ Makefile # Build, lint, package, release
├─ version.txt # App version (used by sign/release targets)
└─ rename-template.sh # One-time renamer script for template cloning
Release Please (automated versioning & releases)
This template includes Release Please to
automate changelogs, tags, and GitHub releases based on Conventional Commits. It also updates
your app version in appinfo/info.xml as part of the release process.
How it works
-
You merge PRs that use Conventional Commits (e.g.,
feat:,fix:,docs:). -
The “Release” workflow (
.github/workflows/release.yml) runs Release Please:- Generates or updates a release PR with a version bump and changelog.
- When that release PR is merged, it creates a Git tag and GitHub Release.
-
The workflow then:
- Builds the App Store tarball (
make && make appstore). - Uploads the artifact to the GitHub Release.
- Optionally publishes to the Nextcloud App Store (via
make release).
- Builds the App Store tarball (
-
As part of the release, the app version in
appinfo/info.xmlis updated automatically.
Conventional Commits (what to write in your commits)
-
feat: add currency search→ minor bump -
fix: handle empty payload→ patch bump -
docs: update README -
chore: bump deps -
refactor: extract service -
Breaking change: include
!or aBREAKING CHANGE:footer e.g.feat!: drop PHP 8.0, or add a footer:BREAKING CHANGE: dropped PHP 8.0 support
This template also includes a “Block unconventional commits” workflow to help you keep commit messages compliant.
Required secrets (for full release automation)
RELEASE_PLEASE_TOKEN— GitHub token for the Release Please action.NEXTCLOUD_API_TOKEN— App Store API token (for the final publish step).NEXTCLOUD_APP_PRIVATE_KEY— Private key used to sign the app (PEM text or base64).
If you’re just testing the flow, you can skip the App Store secrets; the GitHub release and artifact upload will still work.
Typical release flow
-
Merge feature/fix PRs with Conventional Commits.
-
Release Please opens/updates a “release-please” PR (you’ll see proposed version + changelog).
-
Merge the release PR. This:
- Tags the repo (e.g.,
v1.2.0) - Creates the GitHub Release
- Triggers build & artifact upload
- Calls
make releaseto publish to the Nextcloud App Store (if secrets are set)
- Tags the repo (e.g.,
Troubleshooting
- No release PR appears → Ensure the
Releaseworkflow is enabled (moved from.github/workflows.template/by./rename-template.sh) andRELEASE_PLEASE_TOKENis set. - Version not updated in
appinfo/info.xml→ Check theReleaseworkflow logs; make sure the release PR included the XML bump (action handles this). - App Store publish fails → Verify
NEXTCLOUD_API_TOKENandNEXTCLOUD_APP_PRIVATE_KEY, and thatversion.txtmatches the intended release version. - Initial version is 1.0.0 → If you want to start from a custom version, change it in
version.txtand in.release-please-manifest.json. The default is0.0.0which bumps the first release to1.0.0automatically. If you start from a version like0.1.0, the next release will not bump the major until a breaking change is introduced.
Useful docs
Resources
-
Nextcloud app development
-
Nextcloud UI & components
-
Frontend stack
-
Backend & tooling