# 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: 1. Run `./rename-template.sh` to 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. 1. Run `make` - this will trigger the initial build, download all dependencies and make other preparations as necessary. 1. Start developing! Read the rest of the readme below for more information about what you can do. ## Table of Contents - [Makefile](#makefile) - [Quick workflows](#quick-workflows) - [NPM (package.json)](#npm-packagejson) - [Common workflows](#common-workflows) - [Scaffolding](#scaffolding) - [Available generators](#available-generators) - [How migrations are numbered](#how-migrations-are-numbered) - [Examples](#examples) - [Tips & gotchas](#tips--gotchas) - [GitHub Workflows](#github-workflows) - [Project layout](#project-layout) - [Testing](#testing) - [Release Please (automated versioning & releases)](#release-please-automated-versioning--releases) - [Resources](#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/.tar.gz`. | Sharing source-only bundle. | Excludes tests, logs, node_modules, etc. | | `make appstore` | Builds an **App Store–ready** tarball at `build/artifacts/appstore/.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/.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** ```bash 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** ```bash make dist # builds both source + appstore tarballs ``` **Sign and publish to App Store** ```bash # Ensure version.txt is set, and your key exists at ~/.nextcloud/certificates/.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 local `composer.phar`. ## NPM (package.json) Run with `pnpm