mirror of
https://github.com/chenasraf/nextcloud-app-template.git
synced 2026-05-17 17:28:09 +00:00
feat: initial commit
This commit is contained in:
24
.editorconfig
Normal file
24
.editorconfig
Normal file
@@ -0,0 +1,24 @@
|
||||
[*]
|
||||
tab_width = 2
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[Makefile]
|
||||
tab_width = 4
|
||||
indent_size = 4
|
||||
indent_style = tab
|
||||
|
||||
[*.php]
|
||||
tab_width = 2
|
||||
indent_size = 2
|
||||
indent_style = tab
|
||||
|
||||
[*.xml]
|
||||
tab_width = 2
|
||||
indent_size = 2
|
||||
indent_style = tab
|
||||
50
.github/dependabot.yml
vendored
Normal file
50
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: composer
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
open-pull-requests-limit: 10
|
||||
- package-ecosystem: composer
|
||||
directory: "/vendor-bin/cs-fixer"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
open-pull-requests-limit: 10
|
||||
- package-ecosystem: composer
|
||||
directory: "/vendor-bin/openapi-extractor"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
open-pull-requests-limit: 10
|
||||
- package-ecosystem: composer
|
||||
directory: "/vendor-bin/phpunit"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
open-pull-requests-limit: 10
|
||||
- package-ecosystem: composer
|
||||
directory: "/vendor-bin/psalm"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
open-pull-requests-limit: 10
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
open-pull-requests-limit: 10
|
||||
31
.github/workflows.template/block-unconventional-commits.yml
vendored
Normal file
31
.github/workflows.template/block-unconventional-commits.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Block unconventional commits
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, ready_for_review, reopened, synchronize]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: block-unconventional-commits-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
block-unconventional-commits:
|
||||
name: Block unconventional commits
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: webiny/action-conventional-commits@v1.3.0
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
41
.github/workflows.template/build-npm.yml
vendored
Normal file
41
.github/workflows.template/build-npm.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
#
|
||||
# Use lint-eslint together with lint-eslint-when-unrelated to make eslint a required check for GitHub actions
|
||||
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
|
||||
|
||||
name: Build NPM
|
||||
|
||||
on:
|
||||
- pull_request
|
||||
- push
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: build-npm-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: PNPM Build
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
env:
|
||||
CYPRESS_INSTALL_BINARY: 0
|
||||
PUPPETEER_SKIP_DOWNLOAD: true
|
||||
run: |
|
||||
npm i -g pnpm
|
||||
pnpm i --frozen-lockfile
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
37
.github/workflows.template/lint-appinfo-xml.yml
vendored
Normal file
37
.github/workflows.template/lint-appinfo-xml.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Lint appinfo.xml
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: lint-info-xml-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
xml-linters:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: info.xml lint
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download schema
|
||||
run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd
|
||||
|
||||
- name: Lint info.xml
|
||||
uses: ChristophWurst/xmllint-action@v1
|
||||
with:
|
||||
xml-file: ./appinfo/info.xml
|
||||
xml-schema-file: ./info.xsd
|
||||
84
.github/workflows.template/lint-eslint.yml
vendored
Normal file
84
.github/workflows.template/lint-eslint.yml
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
#
|
||||
# Use lint-eslint together with lint-eslint-when-unrelated to make eslint a required check for GitHub actions
|
||||
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
|
||||
|
||||
name: Lint eslint
|
||||
|
||||
on:
|
||||
- pull_request
|
||||
- push
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: lint-eslint-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
changes:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
src: ${{ steps.changes.outputs.src}}
|
||||
|
||||
steps:
|
||||
- uses: dorny/paths-filter@v3
|
||||
id: changes
|
||||
continue-on-error: true
|
||||
with:
|
||||
filters: |
|
||||
src:
|
||||
- '.github/workflows/**'
|
||||
- 'src/**'
|
||||
- 'appinfo/info.xml'
|
||||
- 'package.json'
|
||||
- 'package-lock.json'
|
||||
- 'tsconfig.json'
|
||||
- '.eslintrc.*'
|
||||
- '.eslintignore'
|
||||
- '**.js'
|
||||
- '**.ts'
|
||||
- '**.vue'
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: changes
|
||||
if: needs.changes.outputs.src != 'false'
|
||||
|
||||
name: NPM lint
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
env:
|
||||
CYPRESS_INSTALL_BINARY: 0
|
||||
PUPPETEER_SKIP_DOWNLOAD: true
|
||||
run: |
|
||||
npm i -g pnpm
|
||||
pnpm i --frozen-lockfile
|
||||
|
||||
- name: Lint
|
||||
run: pnpm lint
|
||||
|
||||
summary:
|
||||
permissions:
|
||||
contents: none
|
||||
runs-on: ubuntu-latest
|
||||
needs: [changes, lint]
|
||||
|
||||
if: always()
|
||||
|
||||
# This is the summary, we just avoid to rename it so that branch protection rules still match
|
||||
name: eslint
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.changes.outputs.src != 'false' && needs.lint.result != 'success' }}; then exit 1; fi
|
||||
69
.github/workflows.template/lint-openapi.yml
vendored
Normal file
69
.github/workflows.template/lint-openapi.yml
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
name: Lint OpenAPI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: openapi-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
openapi:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get php version
|
||||
id: php_versions
|
||||
uses: icewind1991/nextcloud-version-matrix@v1
|
||||
|
||||
- name: Set up php
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ steps.php_versions.outputs.php-available }}
|
||||
extensions: xml
|
||||
coverage: none
|
||||
ini-file: development
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Check Typescript OpenApi types
|
||||
id: check_typescript_openapi
|
||||
uses: andstor/file-existence-action@v3
|
||||
with:
|
||||
files: 'src/types/openapi/openapi*.ts'
|
||||
|
||||
- name: Install dependencies
|
||||
env:
|
||||
CYPRESS_INSTALL_BINARY: 0
|
||||
PUPPETEER_SKIP_DOWNLOAD: true
|
||||
run: |
|
||||
npm i -g pnpm
|
||||
pnpm i --frozen-lockfile
|
||||
|
||||
- name: Set up dependencies
|
||||
run: composer i
|
||||
|
||||
- name: Regenerate OpenAPI
|
||||
run: composer run openapi
|
||||
|
||||
- name: Check openapi*.json and typescript changes
|
||||
run: |
|
||||
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please run \"composer run openapi\" and commit the openapi*.json files and (if applicable) src/types/openapi/openapi*.ts, see the section \"Show changes on failure\" for details' && exit 1)"
|
||||
|
||||
- name: Show changes on failure
|
||||
if: failure()
|
||||
run: |
|
||||
git status
|
||||
git --no-pager diff
|
||||
exit 1 # make it red to grab attention
|
||||
49
.github/workflows.template/lint-php-cs.yml
vendored
Normal file
49
.github/workflows.template/lint-php-cs.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Lint php-cs
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: lint-php-cs-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: php-cs
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get php version
|
||||
id: versions
|
||||
uses: icewind1991/nextcloud-version-matrix@v1
|
||||
|
||||
- name: Set up php${{ steps.versions.outputs.php-available }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ steps.versions.outputs.php-available }}
|
||||
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
|
||||
coverage: none
|
||||
ini-file: development
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer i
|
||||
|
||||
- name: Lint
|
||||
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
|
||||
71
.github/workflows.template/lint-php.yml
vendored
Normal file
71
.github/workflows.template/lint-php.yml
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Lint php
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: lint-php-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
php-versions: ${{ steps.versions.outputs.php-versions }}
|
||||
steps:
|
||||
- name: Checkout app
|
||||
uses: actions/checkout@v4
|
||||
- name: Get version matrix
|
||||
id: versions
|
||||
uses: icewind1991/nextcloud-version-matrix@v1
|
||||
|
||||
php-lint:
|
||||
runs-on: ubuntu-latest
|
||||
needs: matrix
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: ${{fromJson(needs.matrix.outputs.php-versions)}}
|
||||
|
||||
name: php-lint
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
|
||||
coverage: none
|
||||
ini-file: development
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Lint
|
||||
run: composer run lint
|
||||
|
||||
summary:
|
||||
permissions:
|
||||
contents: none
|
||||
runs-on: ubuntu-latest
|
||||
needs: php-lint
|
||||
|
||||
if: always()
|
||||
|
||||
name: php-lint-summary
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.php-lint.result != 'success' && needs.php-lint.result != 'skipped' }}; then exit 1; fi
|
||||
73
.github/workflows.template/psalm-matrix.yml
vendored
Normal file
73
.github/workflows.template/psalm-matrix.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Static analysis
|
||||
|
||||
on:
|
||||
# pull_request:
|
||||
workflow_dispatch:
|
||||
# push:
|
||||
# branches:
|
||||
# - master
|
||||
|
||||
concurrency:
|
||||
group: psalm-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
ocp-matrix: ${{ steps.versions.outputs.ocp-matrix }}
|
||||
steps:
|
||||
- name: Checkout app
|
||||
uses: actions/checkout@v4
|
||||
- name: Get version matrix
|
||||
id: versions
|
||||
uses: icewind1991/nextcloud-version-matrix@v1
|
||||
|
||||
static-analysis:
|
||||
runs-on: ubuntu-latest
|
||||
needs: matrix
|
||||
strategy:
|
||||
# do not stop on another job's failure
|
||||
fail-fast: false
|
||||
matrix: ${{ fromJson(needs.matrix.outputs.ocp-matrix) }}
|
||||
|
||||
name: static-psalm-analysis ${{ matrix.ocp-version }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up php${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
|
||||
coverage: none
|
||||
ini-file: development
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer i
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer require --dev nextcloud/ocp:${{ matrix.ocp-version }} --ignore-platform-reqs --with-dependencies
|
||||
|
||||
- name: Run coding standards check
|
||||
run: composer run psalm
|
||||
|
||||
summary:
|
||||
runs-on: ubuntu-latest
|
||||
needs: static-analysis
|
||||
|
||||
if: always()
|
||||
|
||||
name: static-psalm-analysis-summary
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.static-analysis.result != 'success' }}; then exit 1; fi
|
||||
125
.github/workflows.template/release.yml
vendored
Normal file
125
.github/workflows.template/release.yml
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
concurrency:
|
||||
group: release-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
release_created: ${{ steps.release.outputs.release_created }}
|
||||
tag_name: ${{ steps.release.outputs.tag_name }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download builds
|
||||
uses: actions/download-artifact@v4
|
||||
|
||||
- uses: googleapis/release-please-action@v4
|
||||
id: release
|
||||
with:
|
||||
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
|
||||
|
||||
build:
|
||||
name: App Store Build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get php version
|
||||
id: versions
|
||||
uses: icewind1991/nextcloud-version-matrix@v1
|
||||
|
||||
- name: Set up php${{ steps.versions.outputs.php-available }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ steps.versions.outputs.php-available }}
|
||||
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
|
||||
coverage: none
|
||||
ini-file: development
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build App
|
||||
run: |
|
||||
npm i -g pnpm
|
||||
make && make appstore
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: nextcloudapptemplate.tar.gz
|
||||
path: build/artifacts/appstore/nextcloudapptemplate.tar.gz
|
||||
|
||||
upload:
|
||||
runs-on: ubuntu-latest
|
||||
name: Upload Release Artifacts
|
||||
needs: [build, release]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: nextcloudapptemplate.tar.gz
|
||||
|
||||
- name: Prepare Artifact Upload
|
||||
run: test -f "$PWD/nextcloudapptemplate.tar.gz"
|
||||
|
||||
- name: Upload to Release
|
||||
if: ${{ needs.release.outputs.release_created }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
mv nextcloudapptemplate.tar.gz "nextcloudapptemplate-${{ needs.release.outputs.tag_name }}.tar.gz"
|
||||
gh release upload ${{ needs.release.outputs.tag_name }} nextcloudapptemplate-${{ needs.release.outputs.tag_name }}.tar.gz
|
||||
|
||||
release-nextcloud:
|
||||
name: Release to Nextcloud Apps
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build, release, upload]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Write Private Key to File
|
||||
run: |
|
||||
mkdir -p ~/.nextcloud/certificates
|
||||
if [ -z "${{ secrets.NEXTCLOUD_APP_PRIVATE_KEY }}" ]; then
|
||||
echo "Private key not provided"
|
||||
exit 1
|
||||
fi
|
||||
echo -n "${{ secrets.NEXTCLOUD_APP_PRIVATE_KEY }}" > ~/.nextcloud/certificates/nextcloudapptemplate.key
|
||||
|
||||
- name: Release to Nextcloud Apps
|
||||
if: ${{ needs.release.outputs.release_created }}
|
||||
env:
|
||||
NEXTCLOUD_API_TOKEN: ${{ secrets.NEXTCLOUD_API_TOKEN }}
|
||||
run: |
|
||||
make release
|
||||
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/.idea/
|
||||
/*.iml
|
||||
|
||||
/vendor/
|
||||
/vendor-bin/*/vendor/
|
||||
|
||||
/.php-cs-fixer.cache
|
||||
/tests/.phpunit.cache
|
||||
|
||||
/node_modules/
|
||||
/dist
|
||||
/js
|
||||
/css
|
||||
.DS_Store
|
||||
composer.lock
|
||||
build/
|
||||
tsconfig.app.tsbuildinfo
|
||||
.env
|
||||
.env.keys
|
||||
.envrc
|
||||
3
.husky/pre-commit
Normal file
3
.husky/pre-commit
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
export PHP_CS_FIXER_IGNORE_ENV=1
|
||||
pnpm lint-staged -- --relative
|
||||
2
.l10nignore
Normal file
2
.l10nignore
Normal file
@@ -0,0 +1,2 @@
|
||||
dist/
|
||||
vendor/
|
||||
6
.lintstagedrc.cjs
Normal file
6
.lintstagedrc.cjs
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
'*.{ts,vue}': ['eslint --fix'],
|
||||
'src/*.{scss,vue,ts,md,json}': ['prettier --write'],
|
||||
'*.php': [() => 'make php-cs-fixer'],
|
||||
'*Controller.php': [() => 'make openapi', () => 'git add openapi.json'],
|
||||
}
|
||||
20
.php-cs-fixer.dist.php
Normal file
20
.php-cs-fixer.dist.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once './vendor-bin/cs-fixer/vendor/autoload.php';
|
||||
|
||||
use Nextcloud\CodingStandard\Config;
|
||||
|
||||
$config = new Config();
|
||||
$config
|
||||
->getFinder()
|
||||
->notPath('build')
|
||||
->notPath('l10n')
|
||||
->notPath('node_modules')
|
||||
->notPath('src')
|
||||
->notPath('vendor')
|
||||
->notPath('gen')
|
||||
->in(__DIR__);
|
||||
|
||||
return $config;
|
||||
4
.phpactor.json
Normal file
4
.phpactor.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"$schema": "/phpactor.schema.json",
|
||||
"language_server_php_cs_fixer.enabled": true
|
||||
}
|
||||
2
.prettierignore
Normal file
2
.prettierignore
Normal file
@@ -0,0 +1,2 @@
|
||||
templates/
|
||||
scaffolds/
|
||||
18
.prettierrc
Normal file
18
.prettierrc
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"plugins": [
|
||||
"prettier-plugin-vue"
|
||||
],
|
||||
"printWidth": 100,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"overrides": [
|
||||
{
|
||||
"files": "*.md",
|
||||
"options": {
|
||||
"printWidth": 100,
|
||||
"proseWrap": "always"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
1
.release-please-manifest.json
Normal file
1
.release-please-manifest.json
Normal file
@@ -0,0 +1 @@
|
||||
{".":"0.0.0"}
|
||||
1
.tx/backport
Normal file
1
.tx/backport
Normal file
@@ -0,0 +1 @@
|
||||
master
|
||||
9
.tx/config
Normal file
9
.tx/config
Normal file
@@ -0,0 +1,9 @@
|
||||
[main]
|
||||
host = https://www.transifex.com
|
||||
lang_map = hu_HU: hu, nb_NO: nb, sk_SK: sk, th_TH: th, ja_JP: ja, bg_BG: bg, cs_CZ: cs, fi_FI: fi, he_IL: he, ar_AR: ar
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:nextcloudapptemplate]
|
||||
file_filter = translationfiles/<lang>/nextcloudapptemplate.po
|
||||
source_file = translationfiles/templates/nextcloudapptemplate.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
9
CODE_OF_CONDUCT.md
Normal file
9
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,9 @@
|
||||
In the Nextcloud community, participants from all over the world come together to create Free Software for a free internet. This is made possible by the support, hard work and enthusiasm of thousands of people, including those who create and use Nextcloud software.
|
||||
|
||||
Our code of conduct offers some guidance to ensure Nextcloud participants can cooperate effectively in a positive and inspiring atmosphere, and to explain how together we can strengthen and support each other.
|
||||
|
||||
The Code of Conduct is shared by all contributors and users who engage with the Nextcloud team and its community services. It presents a summary of the shared values and “common sense” thinking in our community.
|
||||
|
||||
You can find our full code of conduct on our website: https://nextcloud.com/code-of-conduct/
|
||||
|
||||
Please, keep our CoC in mind when you contribute! That way, everyone can be a part of our community in a productive, positive, creative and fun way.
|
||||
661
LICENSE
Normal file
661
LICENSE
Normal file
@@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
297
Makefile
Normal file
297
Makefile
Normal file
@@ -0,0 +1,297 @@
|
||||
# SPDX-FileCopyrightText: Bernhard Posselt <dev@bernhard-posselt.com>
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
#
|
||||
# Nextcloud App Template — Makefile
|
||||
# ---------------------------------
|
||||
# A friendly, batteries-included Makefile for building and packaging a Nextcloud app
|
||||
# that uses pnpm (JS) and Composer (PHP).
|
||||
#
|
||||
# Requirements:
|
||||
# - make, which, curl, tar
|
||||
# - pnpm (for JS build/lint/test)
|
||||
# - composer (optional; will auto-download local composer.phar if missing)
|
||||
#
|
||||
# Conventions:
|
||||
# - If no composer.json → Composer step is skipped.
|
||||
# - If no package.json (root) and js/package.json missing → pnpm step is skipped.
|
||||
# - JS build is delegated to your package.json scripts (tool-agnostic).
|
||||
#
|
||||
# Common recipes:
|
||||
# make build → install deps & build
|
||||
# make dist → build source + appstore tarballs
|
||||
# make test → run PHP unit tests
|
||||
# make lint → lint JS & PHP
|
||||
# make openapi → generate OpenAPI JSON
|
||||
# make sign → print signature for GitHub tarball
|
||||
# make release → upload release to Nextcloud App Store
|
||||
#
|
||||
|
||||
app_name=nextcloudapptemplate
|
||||
repo_path=your-user/nextcloud-$(app_name)
|
||||
build_tools_directory=$(CURDIR)/build/tools
|
||||
source_build_directory=$(CURDIR)/build/artifacts/source
|
||||
source_intermediate_directory=$(CURDIR)/build/artifacts/intermediate-source
|
||||
source_package_name=$(source_build_directory)/$(app_name)
|
||||
app_intermediate_directory=$(CURDIR)/build/artifacts/intermediate/$(app_name)
|
||||
appstore_build_directory=$(CURDIR)/build/artifacts/appstore
|
||||
appstore_package_name=$(appstore_build_directory)/$(app_name)
|
||||
pnpm=$(shell which pnpm 2> /dev/null)
|
||||
composer=$(shell which composer 2> /dev/null)
|
||||
composer_phar=build/tools/composer.phar
|
||||
|
||||
# Default target: install deps & build JS (and PHP if composer.json exists)
|
||||
all: build
|
||||
|
||||
# build:
|
||||
# - Composer install if composer.json exists (skips if vendor/ exists)
|
||||
# - pnpm install & build if package.json (root) or js/package.json exists
|
||||
.PHONY: build
|
||||
build:
|
||||
ifneq (,$(wildcard $(CURDIR)/composer.json))
|
||||
make composer
|
||||
endif
|
||||
ifneq (,$(wildcard $(CURDIR)/package.json))
|
||||
make pnpm
|
||||
endif
|
||||
ifneq (,$(wildcard $(CURDIR)/js/package.json))
|
||||
make pnpm
|
||||
endif
|
||||
|
||||
# composer:
|
||||
# - Use system composer if available, else download local composer.phar
|
||||
# - Skip install if vendor/ already exists
|
||||
.PHONY: composer
|
||||
composer:
|
||||
ifeq (, $(composer))
|
||||
@echo "No composer command available, downloading a copy from the web"
|
||||
mkdir -p $(build_tools_directory)
|
||||
curl -sS https://getcomposer.org/installer | php
|
||||
mv composer.phar $(composer_phar)
|
||||
endif
|
||||
ifneq ("$(wildcard vendor)","")
|
||||
@echo "Vendor directory already exists, skipping composer install"
|
||||
else
|
||||
@echo "Installing composer dependencies..."
|
||||
$(if $(composer),$(composer),php $(composer_phar)) install --prefer-dist
|
||||
endif
|
||||
|
||||
# pnpm:
|
||||
# - Install JS deps (frozen lockfile)
|
||||
# - Run build via root package.json if present, else fallback to js/ subdir
|
||||
.PHONY: pnpm
|
||||
pnpm:
|
||||
pnpm install --frozen-lockfile
|
||||
ifeq (,$(wildcard $(CURDIR)/package.json))
|
||||
cd js && $(pnpm) build
|
||||
else
|
||||
pnpm build
|
||||
endif
|
||||
|
||||
# clean:
|
||||
# - Remove build artifacts (but keep dependencies)
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf ./build
|
||||
|
||||
# distclean:
|
||||
# - Run clean and also remove PHP/JS dependencies
|
||||
.PHONY: distclean
|
||||
distclean: clean
|
||||
rm -rf vendor
|
||||
rm -rf node_modules
|
||||
rm -rf js/vendor
|
||||
rm -rf js/node_modules
|
||||
|
||||
# dist:
|
||||
# - Build both source and appstore tarballs
|
||||
.PHONY: dist
|
||||
dist:
|
||||
make source
|
||||
make appstore
|
||||
|
||||
# source:
|
||||
# - Create a source tarball (full source, excludes dev/test artifacts)
|
||||
# - Output: build/artifacts/source/$(app_name).tar.gz
|
||||
.PHONY: source
|
||||
source:
|
||||
rm -rf $(source_build_directory)
|
||||
mkdir -p $(source_build_directory)
|
||||
rm -rf $(appstore_package_name).tar.gz
|
||||
rsync -vtr \
|
||||
--exclude="**/.git/**/*" \
|
||||
--exclude="build" \
|
||||
--exclude="tests" \
|
||||
--exclude="src" \
|
||||
--exclude="js/node_modules" \
|
||||
--exclude="node_modules" \
|
||||
--exclude="*.log" \
|
||||
--exclude="dist/js/*.log" \
|
||||
$(CURDIR)/ $(source_intermediate_directory)
|
||||
cd $(source_intermediate_directory) && \
|
||||
tar czf $(source_package_name).tar.gz ../$(app_name)
|
||||
|
||||
# appstore:
|
||||
# - Create an App Store tarball (strips tests, dotfiles, dev configs)
|
||||
# - Output: build/artifacts/appstore/$(app_name).tar.gz
|
||||
.PHONY: appstore
|
||||
appstore:
|
||||
rm -rf $(appstore_build_directory)
|
||||
mkdir -p $(app_intermediate_directory)
|
||||
mkdir -p $(appstore_build_directory)
|
||||
rm -rf $(appstore_package_name).tar.gz
|
||||
rsync -vtr \
|
||||
--exclude="**/.git/**/*" \
|
||||
--exclude="**/.github/**/*" \
|
||||
--exclude="build" \
|
||||
--exclude="tests" \
|
||||
--exclude="Makefile" \
|
||||
--exclude="*.log" \
|
||||
--exclude="phpunit*xml" \
|
||||
--exclude="composer.*" \
|
||||
--exclude="node_modules" \
|
||||
--exclude="dist/js/node_modules" \
|
||||
--exclude="dist/js/tests" \
|
||||
--exclude="dist/js/test" \
|
||||
--exclude="dist/js/*.log" \
|
||||
--exclude="dist/js/package.json" \
|
||||
--exclude="dist/js/bower.json" \
|
||||
--exclude="dist/js/karma.*" \
|
||||
--exclude="dist/js/protractor.*" \
|
||||
--exclude="package.json" \
|
||||
--exclude="bower.json" \
|
||||
--exclude="karma.*" \
|
||||
--exclude="protractor\.*" \
|
||||
--exclude=".*" \
|
||||
--exclude="dist/js/.*" \
|
||||
--exclude="src" \
|
||||
$(CURDIR)/ $(app_intermediate_directory)
|
||||
cd $(app_intermediate_directory) && \
|
||||
tar czf $(appstore_package_name).tar.gz ../$(app_name)
|
||||
|
||||
# test:
|
||||
# - Run PHP unit tests (standard + optional integration config)
|
||||
.PHONY: test
|
||||
test: composer
|
||||
$(CURDIR)/vendor/phpunit/phpunit/phpunit -c tests/phpunit.xml
|
||||
( test ! -f tests/phpunit.integration.xml ) || $(CURDIR)/vendor/phpunit/phpunit/phpunit -c tests/phpunit.integration.xml
|
||||
|
||||
# lint:
|
||||
# - Lint JS via pnpm and PHP via composer script "lint"
|
||||
.PHONY: lint
|
||||
lint:
|
||||
pnpm lint
|
||||
$(composer_phar) run lint
|
||||
|
||||
# php-cs-fixer:
|
||||
# - Fix staged PHP files with PHP-CS-Fixer shim (checks syntax first)
|
||||
.PHONY: php-cs-fixer
|
||||
php-cs-fixer:
|
||||
@echo "\x1b[33mFixing PHP files...\x1b[0m"
|
||||
@FILES=$$(git diff --cached --name-only --diff-filter=ACM | grep '\.php$$' | grep -v '^gen/'); \
|
||||
if [ -z "$$FILES" ]; then \
|
||||
echo "No PHP files staged."; \
|
||||
else \
|
||||
echo "Running CS fixer on:" $$FILES; \
|
||||
php -l $$FILES || exit 1; \
|
||||
PHP_CS_FIXER_IGNORE_ENV=true php vendor-bin/cs-fixer/vendor/php-cs-fixer/shim/php-cs-fixer.phar --config=.php-cs-fixer.dist.php fix $$FILES || exit 1; \
|
||||
fi
|
||||
|
||||
# format:
|
||||
# - Format JS and PHP (composer script "cs:fix")
|
||||
.PHONY: format
|
||||
format:
|
||||
pnpm format
|
||||
PHP_CS_FIXER_IGNORE_ENV=true $(composer_phar) run cs:fix
|
||||
|
||||
# openapi:
|
||||
# - Generate OpenAPI spec via composer script "openapi"
|
||||
# - Output: build/openapi/openapi.json
|
||||
.PHONY: openapi
|
||||
openapi:
|
||||
@echo "\x1b[33mGenerating OpenAPI documentation...\x1b[0m"
|
||||
$(if $(composer),$(composer),php $(composer_phar)) run openapi
|
||||
@echo "\x1b[32mOpenAPI documentation generated at build/openapi/openapi.json\x1b[0m"
|
||||
|
||||
# sign:
|
||||
# - Print a base64 SHA-512 signature for the release tarball from GitHub.
|
||||
# - Requires a private key at ~/.nextcloud/certificates/$(app_name).key
|
||||
# - Reads version from version.txt
|
||||
.PHONY: sign
|
||||
sign:
|
||||
@VERSION="$$(cat version.txt)"; \
|
||||
TMPF="$$(mktemp)"; \
|
||||
KEY_FILE=~/.nextcloud/certificates/$(app_name).key; \
|
||||
if [ ! -f "$$KEY_FILE" ]; then \
|
||||
echo "\x1b[31m❌ Error: Private key not found at $$KEY_FILE\x1b[0m"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo "\x1b[33mSigning version $${VERSION}\x1b[0m"; \
|
||||
echo "\x1b[33mDownloading archive...\x1b[0m"; \
|
||||
curl -L https://github.com/$(repo_path)/releases/download/v$${VERSION}/$(app_name)-v$${VERSION}.tar.gz -o "$${TMPF}"; \
|
||||
FILESIZE=$$(stat -f%z "$${TMPF}" 2>/dev/null || stat -c%s "$${TMPF}"); \
|
||||
if [ "$${FILESIZE}" -lt 10240 ]; then \
|
||||
echo "\x1b[31mError: Downloaded file is too small (<10KB, actual: $${FILESIZE} bytes)\x1b[0m"; \
|
||||
rm -rf "$${TMPF}"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo "\x1b[33mSigning with key $$KEY_FILE\x1b[0m"; \
|
||||
echo; \
|
||||
echo "\x1b[32mDownload URL:\x1b[0m https://github.com/$(repo_path)/releases/download/v$${VERSION}/$(app_name)-v$${VERSION}.tar.gz"; \
|
||||
echo "\x1b[32mSignature:\x1b[0m"; \
|
||||
openssl dgst -sha512 -sign "$$KEY_FILE" "$${TMPF}" | openssl base64; \
|
||||
rm -rf "$${TMPF}"
|
||||
|
||||
# release:
|
||||
# - Upload release to Nextcloud App Store using NEXTCLOUD_API_TOKEN
|
||||
# - Downloads tarball from GitHub, signs it, and POSTs to App Store
|
||||
.PHONY: release
|
||||
release:
|
||||
@VERSION="$$(cat version.txt)"; \
|
||||
if [ -z "$$NEXTCLOUD_API_TOKEN" ]; then \
|
||||
printf "\x1b[33mNEXTCLOUD_API_TOKEN not set. Enter token: \x1b[0m"; \
|
||||
read -r NEXTCLOUD_API_TOKEN; \
|
||||
fi; \
|
||||
if [ -z "$$NEXTCLOUD_API_TOKEN" ]; then \
|
||||
echo "\x1b[31m❌ Error: NEXTCLOUD_API_TOKEN is missing\x1b[0m"; \
|
||||
exit 1; \
|
||||
else \
|
||||
echo "\x1b[32m✅ Using provided NEXTCLOUD_API_TOKEN\x1b[0m"; \
|
||||
fi; \
|
||||
TMPF="$$(mktemp)"; \
|
||||
DOWNLOAD_URL="https://github.com/$(repo_path)/releases/download/v$${VERSION}/$(app_name)-v$${VERSION}.tar.gz"; \
|
||||
KEY_FILE=~/.nextcloud/certificates/$(app_name).key; \
|
||||
if [ ! -f "$$KEY_FILE" ]; then \
|
||||
echo "\x1b[31m❌ Error: Private key not found at $$KEY_FILE\x1b[0m"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo "\x1b[33mDownloading archive for version $${VERSION}...\x1b[0m"; \
|
||||
curl -L "$${DOWNLOAD_URL}" -o "$${TMPF}"; \
|
||||
FILESIZE=$$(stat -f%z "$${TMPF}" 2>/dev/null || stat -c%s "$${TMPF}"); \
|
||||
if [ "$${FILESIZE}" -lt 10240 ]; then \
|
||||
echo "\x1b[31mError: Downloaded file is too small (<10KB, actual: $${FILESIZE} bytes)\x1b[0m"; \
|
||||
rm -f "$${TMPF}"; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
echo "\x1b[33mSigning with key $$KEY_FILE\x1b0m"; \
|
||||
echo; \
|
||||
SIGNATURE="$$(openssl dgst -sha512 -sign "$$KEY_FILE" "$${TMPF}" | openssl base64 | tr -d '\n')"; \
|
||||
rm -f "$${TMPF}"; \
|
||||
echo "\x1b[32mReleasing to Nextcloud App Store...\x1b[0m"; \
|
||||
RESPONSE="$$(mktemp)"; \
|
||||
HTTP_CODE=$$(curl -s -w "%{http_code}" -o "$${RESPONSE}" -X POST \
|
||||
-H "Authorization: Token $$NEXTCLOUD_API_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"download\":\"$${DOWNLOAD_URL}\", \"signature\":\"$${SIGNATURE}\"}" \
|
||||
https://apps.nextcloud.com/api/v1/apps/releases); \
|
||||
cat "$$RESPONSE"; echo; \
|
||||
if [ "$$HTTP_CODE" = "400" ]; then \
|
||||
echo "\x1b[31m❌ Error 400: Invalid data, app too large, signature/cert issue, or not registered\x1b[0m"; exit 1; \
|
||||
elif [ "$$HTTP_CODE" = "401" ]; then \
|
||||
echo "\x1b[31m❌ Error 401: Not authenticated\x1b[0m"; exit 1; \
|
||||
elif [ "$$HTTP_CODE" = "403" ]; then \
|
||||
echo "\x1b[31m❌ Error 403: Not authorized\x1b[0m"; exit 1; \
|
||||
elif [ "$$HTTP_CODE" -ge 300 ]; then \
|
||||
echo "\x1b[31m❌ Unexpected error (HTTP $$HTTP_CODE)\x1b[0m"; exit 1; \
|
||||
fi; \
|
||||
rm -f "$$RESPONSE"; \
|
||||
echo "\x1b[32m🎉 Release successful!\x1b[0m";
|
||||
408
README.md
Executable file
408
README.md
Executable file
@@ -0,0 +1,408 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: Your Name <your@email.com>
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
-->
|
||||
|
||||
# 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)
|
||||
- [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 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**
|
||||
|
||||
```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/<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 local `composer.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](#scaffolding) |
|
||||
|
||||
## Common workflows
|
||||
|
||||
**While developing (continuous build output):**
|
||||
|
||||
```bash
|
||||
pnpm dev
|
||||
# Edit files → Vite rebuilds to dist/ automatically.
|
||||
```
|
||||
|
||||
**Before pushing a branch (runs automatically using commit hooks):**
|
||||
|
||||
```bash
|
||||
pnpm lint
|
||||
pnpm build
|
||||
```
|
||||
|
||||
**Fix style issues quickly:**
|
||||
|
||||
```bash
|
||||
pnpm format
|
||||
```
|
||||
|
||||
**Fresh clone:**
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
# husky installs via "prepare"
|
||||
pnpm build
|
||||
```
|
||||
|
||||
### Scaffolding
|
||||
|
||||
Generate boilerplate for common app pieces with:
|
||||
|
||||
```bash
|
||||
pnpm gen <type> [name]
|
||||
```
|
||||
|
||||
- **`name` is required** for every type **except** `migration`.
|
||||
- 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 version
|
||||
- `dt` — a timestamp like `YYYYMMDDHHmmss` (via `date-fns`)
|
||||
|
||||
You don’t pass a name for migrations.
|
||||
|
||||
#### Examples
|
||||
|
||||
Create a Vue component:
|
||||
|
||||
```bash
|
||||
pnpm gen component UserListItem
|
||||
# → src/components/UserListItem.vue
|
||||
```
|
||||
|
||||
Create a Vue page:
|
||||
|
||||
```bash
|
||||
pnpm gen page Settings
|
||||
# → src/pages/Settings.vue
|
||||
```
|
||||
|
||||
Create an API controller:
|
||||
|
||||
```bash
|
||||
pnpm gen api Users
|
||||
# → lib/Controller/UsersController.php
|
||||
```
|
||||
|
||||
Create a service:
|
||||
|
||||
```bash
|
||||
pnpm gen service MyService
|
||||
# → lib/Service/MyService.php
|
||||
```
|
||||
|
||||
Create a queued job:
|
||||
|
||||
```bash
|
||||
pnpm gen task-queued UpdateUsers
|
||||
# → lib/Cron/UpdateUsers.php
|
||||
```
|
||||
|
||||
Create a migration (no name):
|
||||
|
||||
```bash
|
||||
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-timed` for scheduled runs, `task-queued` for 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](https://github.com/googleapis/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
|
||||
|
||||
1. **You merge PRs** that use Conventional Commits (e.g., `feat:`, `fix:`, `docs:`).
|
||||
2. 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**.
|
||||
|
||||
3. 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`).
|
||||
|
||||
4. As part of the release, the **app version in `appinfo/info.xml` is 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 a `BREAKING 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
|
||||
|
||||
1. Merge feature/fix PRs with Conventional Commits.
|
||||
2. Release Please opens/updates a **“release-please” PR** (you’ll see proposed version + changelog).
|
||||
3. **Merge the release PR.** This:
|
||||
|
||||
- Tags the repo (e.g., `v1.2.0`)
|
||||
- Creates the **GitHub Release**
|
||||
- Triggers build & artifact upload
|
||||
- Calls `make release` to publish to the **Nextcloud App Store** (if secrets are set)
|
||||
|
||||
### Troubleshooting
|
||||
|
||||
- **No release PR appears** → Ensure the `Release` workflow is enabled (moved from
|
||||
`.github/workflows.template/` by `./rename-template.sh`) and `RELEASE_PLEASE_TOKEN` is set.
|
||||
- **Version not updated in `appinfo/info.xml`** → Check the `Release` workflow logs; make sure the
|
||||
release PR included the XML bump (action handles this).
|
||||
- **App Store publish fails** → Verify `NEXTCLOUD_API_TOKEN` and `NEXTCLOUD_APP_PRIVATE_KEY`, and
|
||||
that `version.txt` matches the intended release version.
|
||||
- **Initial version is 1.0.0** → If you want to start from a custom version, change it in
|
||||
`version.txt` and in `.release-please-manifest.json`. The default is `0.0.0` which bumps the first
|
||||
release to `1.0.0` automatically. If you start from a version like `0.1.0`, the next release will
|
||||
not bump the major until a breaking change is introduced.
|
||||
|
||||
### Useful docs
|
||||
|
||||
- Release Please action:
|
||||
[https://github.com/googleapis/release-please](https://github.com/googleapis/release-please)
|
||||
- Conventional Commits: [https://www.conventionalcommits.org/](https://www.conventionalcommits.org/)
|
||||
- Nextcloud App publishing:
|
||||
[https://docs.nextcloud.com/server/latest/developer_manual/app_publishing/index.html](https://docs.nextcloud.com/server/latest/developer_manual/app_publishing/index.html)
|
||||
|
||||
## Resources
|
||||
|
||||
- **Nextcloud app development**
|
||||
|
||||
- [App dev guide](https://docs.nextcloud.com/server/latest/developer_manual/app/)
|
||||
- [OCS API](https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/index.html)
|
||||
- [Publishing to the App Store](https://docs.nextcloud.com/server/latest/developer_manual/app_publishing/index.html)
|
||||
- [App signing](https://docs.nextcloud.com/server/latest/developer_manual/app_publishing/signing.html)
|
||||
- [Server dev environment](https://docs.nextcloud.com/server/latest/developer_manual/general/devenv.html)
|
||||
|
||||
- **Nextcloud UI & components**
|
||||
|
||||
- [nextcloud-vue (components)](https://github.com/nextcloud/nextcloud-vue)
|
||||
- [Component docs/storybook](https://nextcloud.github.io/nextcloud-vue/)
|
||||
|
||||
- **Frontend stack**
|
||||
|
||||
- [Vue 3](https://vuejs.org/)
|
||||
- [Vue Router](https://router.vuejs.org/)
|
||||
- [Vite](https://vitejs.dev/guide/)
|
||||
- [pnpm](https://pnpm.io/)
|
||||
- [Axios](https://axios-http.com/)
|
||||
|
||||
- **Backend & tooling**
|
||||
|
||||
- [Composer](https://getcomposer.org/doc/)
|
||||
- [PHP CS Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer)
|
||||
- [ESLint](https://eslint.org/docs/latest/)
|
||||
- [Prettier](https://prettier.io/docs/en/)
|
||||
- [OpenAPI spec](https://spec.openapis.org/oas/latest.html)
|
||||
- [date-fns](https://date-fns.org/)
|
||||
58
appinfo/info.xml
Normal file
58
appinfo/info.xml
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0"?>
|
||||
<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
|
||||
<!--
|
||||
SPDX-FileCopyrightText: Your Name <your@email.com>
|
||||
SPDX-License-Identifier: CC0-1.0
|
||||
-->
|
||||
<id>nextcloudapptemplate</id>
|
||||
<name>Nextcloud App Template</name>
|
||||
<summary>Automatically fills the currency rates for your Cospend projects daily.</summary>
|
||||
<description><.
|
||||
>
|
||||
> Without Cospend, this app will not work.
|
||||
]]></description>
|
||||
<version>1.0.0</version>
|
||||
<licence>agpl</licence>
|
||||
<author mail="your@email.com" homepage="https://your.website">Your Name</author>
|
||||
<namespace>NextcloudAppTemplate</namespace>
|
||||
<documentation>
|
||||
<user>https://github.com/your-user/nextcloud-nextcloudapptemplate/blob/master/README.md</user>
|
||||
<admin>https://github.com/your-user/nextcloud-nextcloudapptemplate#installation</admin>
|
||||
<developer>https://github.com/your-user/nextcloud-nextcloudapptemplate#development</developer>
|
||||
</documentation>
|
||||
<category>organization</category>
|
||||
<category>tools</category>
|
||||
<website>https://github.com/your-user/nextcloud-nextcloudapptemplate</website>
|
||||
<bugs>https://github.com/your-user/nextcloud-nextcloudapptemplate/issues</bugs>
|
||||
<repository>https://github.com/your-user/nextcloud-nextcloudapptemplate</repository>
|
||||
<screenshot>https://raw.githubusercontent.com/your-user/nextcloud-nextcloudapptemplate/refs/heads/master/promo.png</screenshot>
|
||||
<donation>https://ko-fi.com/casraf</donation>
|
||||
<donation type="paypal"><![CDATA[https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TSH3C3ABGQM22¤cy_code=ILS&source=url]]></donation>
|
||||
<dependencies>
|
||||
<nextcloud min-version="29" max-version="32"/>
|
||||
</dependencies>
|
||||
<settings>
|
||||
<admin>OCA\NextcloudAppTemplate\Settings\Admin</admin>
|
||||
<admin-section>OCA\NextcloudAppTemplate\Sections\Admin</admin-section>
|
||||
</settings>
|
||||
<navigations>
|
||||
<navigation role="all">
|
||||
<name>Nextcloud App Template</name>
|
||||
<route>nextcloudapptemplate.page.index</route>
|
||||
<icon>app.svg</icon>
|
||||
<order>6</order>
|
||||
</navigation>
|
||||
</navigations>
|
||||
</info>
|
||||
50
composer.json
Normal file
50
composer.json
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "nextcloud/nextcloudapptemplate",
|
||||
"description": "Automatically fills the currency rates for your Cospend projects daily.",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Your Name",
|
||||
"email": "your@email.com",
|
||||
"homepage": "https://your.website"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"OCA\\NextcloudAppTemplate\\": "lib/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-install-cmd": [
|
||||
"@composer bin all install --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@composer bin all update --ansi"
|
||||
],
|
||||
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './vendor-bin/*' -not -path './gen/*' -not -path './build/*' -print0 | xargs -0 -n1 php -l",
|
||||
"cs:check": "php-cs-fixer fix --dry-run --diff",
|
||||
"cs:fix": "php-cs-fixer fix",
|
||||
"psalm": "psalm --threads=1 --no-cache",
|
||||
"test:unit": "phpunit tests -c tests/phpunit.xml --colors=always --fail-on-warning --fail-on-risky",
|
||||
"openapi": "generate-spec"
|
||||
},
|
||||
"require": {
|
||||
"bamarni/composer-bin-plugin": "^1.8",
|
||||
"php": "^8.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"nextcloud/ocp": "dev-stable29",
|
||||
"phpunit/phpunit": "^10.5",
|
||||
"roave/security-advisories": "dev-latest"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"bamarni/composer-bin-plugin": true
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true,
|
||||
"platform": {
|
||||
"php": "8.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
25
eslint.config.cjs
Normal file
25
eslint.config.cjs
Normal file
@@ -0,0 +1,25 @@
|
||||
const eslint = require('@eslint/js')
|
||||
const tseslint = require('typescript-eslint')
|
||||
|
||||
module.exports = [
|
||||
// {
|
||||
// extends: ['@nextcloud'],
|
||||
// rules: {
|
||||
// 'jsdoc/require-jsdoc': 'off',
|
||||
// 'vue/first-attribute-linebreak': 'off',
|
||||
// },
|
||||
// },
|
||||
...tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended),
|
||||
{
|
||||
rules: {
|
||||
'no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'warn',
|
||||
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: ['node_modules/', 'build/', 'dist/', 'gen/'],
|
||||
},
|
||||
]
|
||||
44
gen/gen/api/{{pascalCase name}}Controller.php
Normal file
44
gen/gen/api/{{pascalCase name}}Controller.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// SPDX-FileCopyrightText: Your Name <your@email.com>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\Jukebox\Controller;
|
||||
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Attribute\ApiRoute;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\OCSController;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class {{pascalCase name}}Controller extends OCSController {
|
||||
/**
|
||||
* {{pascalCase name}} constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
string $appName,
|
||||
IRequest $request,
|
||||
private IAppConfig $config,
|
||||
private IL10N $l,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* API index
|
||||
*
|
||||
* @return JSONResponse<Http::STATUS_OK, array{}, array{}>
|
||||
*
|
||||
* 200: Data returned
|
||||
*/
|
||||
#[ApiRoute(verb: 'GET', url: '/api/{{kebabCase name}}')]
|
||||
public function index(): JSONResponse {
|
||||
return new JSONResponse();
|
||||
}
|
||||
}
|
||||
39
gen/gen/command/{{pascalCase name}}.php
Normal file
39
gen/gen/command/{{pascalCase name}}.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// SPDX-FileCopyrightText: Your Name <casraf@pm.me>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\Jukebox\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class {{pascalCase name}} extends Command {
|
||||
/**
|
||||
* {{pascalCase name}} constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function configure(): void {
|
||||
parent::configure();
|
||||
$this->setName('jukebox:{{kebabCase name}}');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
22
gen/gen/component/{{pascalCase name}}.vue
Normal file
22
gen/gen/component/{{pascalCase name}}.vue
Normal file
@@ -0,0 +1,22 @@
|
||||
<template>
|
||||
|
||||
<div>{{ startCase name }}</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import NcComponentExample from '@nextcloud/vue/dist/Components/NcComponentExample.js'
|
||||
|
||||
//
|
||||
// import IconExample from 'vue-material-design-icons/Example.vue'
|
||||
|
||||
export default {
|
||||
name: '{{pascalCase name}}',
|
||||
components: {
|
||||
//
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
|
||||
48
gen/gen/migration/Version{{version}}Date{{dt}}.php
Normal file
48
gen/gen/migration/Version{{version}}Date{{dt}}.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Your Name <casraf@pm.me>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Jukebox\Migration;
|
||||
|
||||
use Closure;
|
||||
use OCP\DB\ISchemaWrapper;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
|
||||
class Version{{version}}Date{{dt}} extends SimpleMigrationStep {
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
*/
|
||||
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
* @return null|ISchemaWrapper
|
||||
*/
|
||||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
|
||||
/** @var ISchemaWrapper $schema */
|
||||
$schema = $schemaClosure();
|
||||
|
||||
// TODO add migration logic
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure(): ISchemaWrapper $schemaClosure
|
||||
* @param array $options
|
||||
*/
|
||||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
|
||||
}
|
||||
}
|
||||
30
gen/gen/model/{{pascalCase name}}.php
Executable file
30
gen/gen/model/{{pascalCase name}}.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// SPDX-FileCopyrightText: Your Name <your@email.com>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\Jukebox\Db;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
|
||||
/**
|
||||
* @method string getFieldName()
|
||||
* @method void setFieldName($value)
|
||||
*/
|
||||
class {{pascalCase name}} extends Entity implements JsonSerializable {
|
||||
// protected $fieldName;
|
||||
|
||||
public function __construct() {
|
||||
// $this->addType('fieldName', 'type');
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
// 'field_name' => $this->getFieldName(),
|
||||
];
|
||||
}
|
||||
}
|
||||
52
gen/gen/model/{{pascalCase name}}Mapper.php
Executable file
52
gen/gen/model/{{pascalCase name}}Mapper.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// SPDX-FileCopyrightText: Your Name <your@email.com>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\Jukebox\Db;
|
||||
|
||||
use OCA\Jukebox\AppInfo\Application;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Db\QBMapper;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
/**
|
||||
* @template-extends QBMapper<{{pascalCase name}}>
|
||||
*/
|
||||
class {{pascalCase name}}Mapper extends QBMapper {
|
||||
public function __construct(
|
||||
IDBConnection $db,
|
||||
) {
|
||||
parent::__construct($db, Application::tableName('{{snakeCase name}}s'), {{pascalCase name}}::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws DoesNotExistException
|
||||
*/
|
||||
public function find(string $id): {{pascalCase name}} {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from($this->getTableName())
|
||||
->where(
|
||||
$qb->expr()
|
||||
->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_STR))
|
||||
);
|
||||
return $this->findEntity($qb);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $projectId
|
||||
* @return array<{{pascalCase name}}>
|
||||
*/
|
||||
public function findAll(): array {
|
||||
/* @var $qb IQueryBuilder */
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')->from($this->getTableName());
|
||||
return $this->findEntities($qb);
|
||||
}
|
||||
}
|
||||
27
gen/gen/page/{{pascalCase name}}Page.vue
Normal file
27
gen/gen/page/{{pascalCase name}}Page.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
|
||||
<div class="jukebox-{{ kebabCase name }}">{{ startCase name }} Page</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import NcComponentExample from '@nextcloud/vue/components/NcComponentExample'
|
||||
|
||||
//
|
||||
// import IconExample from 'vue-material-design-icons/Example.vue'
|
||||
|
||||
export default {
|
||||
name: '{{pascalCase name}}Page',
|
||||
components: {
|
||||
//
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
/*
|
||||
#jukebox-{{ kebabCase name }} {
|
||||
}
|
||||
*/
|
||||
</style>
|
||||
|
||||
22
gen/gen/service/{{pascalCase name}}Service.php
Normal file
22
gen/gen/service/{{pascalCase name}}Service.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// SPDX-FileCopyrightText: Your Name <your@email.com>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\Jukebox\Service;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class {{pascalCase name}}Service {
|
||||
public function __construct(
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
// public function doSomething(): void {
|
||||
// // Do something
|
||||
// }
|
||||
}
|
||||
25
gen/gen/task-queued/{{pascalCase name}}Task.php
Normal file
25
gen/gen/task-queued/{{pascalCase name}}Task.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// SPDX-FileCopyrightText: Your Name <your@email.com>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\Jukebox\Cron;
|
||||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\QueuedJob;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class {{pascalCase name}}Task extends QueuedJob {
|
||||
public function __construct(
|
||||
ITimeFactory $time,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
parent::__construct($time);
|
||||
}
|
||||
|
||||
protected function run($arguments): void {
|
||||
// $this->myService->doCron($arguments['uid']);
|
||||
}
|
||||
}
|
||||
28
gen/gen/task-timed/{{pascalCase name}}Task.php
Normal file
28
gen/gen/task-timed/{{pascalCase name}}Task.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// SPDX-FileCopyrightText: Your Name <your@email.com>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\Jukebox\Cron;
|
||||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\TimedJob;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class {{pascalCase name}}Task extends TimedJob {
|
||||
public function __construct(
|
||||
ITimeFactory $time,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
parent::__construct($time);
|
||||
|
||||
// Run once an hour
|
||||
$this->setInterval(3600);
|
||||
}
|
||||
|
||||
protected function run($arguments): void {
|
||||
// $this->myService->doCron($arguments['uid']);
|
||||
}
|
||||
}
|
||||
22
gen/gen/util/{{pascalCase name}}Util.php
Normal file
22
gen/gen/util/{{pascalCase name}}Util.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// SPDX-FileCopyrightText: Your Name <your@email.com>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\Jukebox\Util;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class {{pascalCase name}}Util {
|
||||
public function __construct(
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
// public function doSomething(): void {
|
||||
// // Do something
|
||||
// }
|
||||
}
|
||||
1
img/app-dark.svg
Normal file
1
img/app-dark.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="currentColor"><path d="M0 0h24v24H0z" fill="none"/><path d="M11.8 10.9c-2.27-.59-3-1.2-3-2.15 0-1.09 1.01-1.85 2.7-1.85 1.78 0 2.44.85 2.5 2.1h2.21c-.07-1.72-1.12-3.3-3.21-3.81V3h-3v2.16c-1.94.42-3.5 1.68-3.5 3.61 0 2.31 1.91 3.46 4.7 4.13 2.5.6 3 1.48 3 2.41 0 .69-.49 1.79-2.7 1.79-2.06 0-2.87-.92-2.98-2.1h-2.2c.12 2.19 1.76 3.42 3.68 3.83V21h3v-2.15c1.95-.37 3.5-1.5 3.5-3.55 0-2.84-2.43-3.81-4.7-4.4z"/></svg>
|
||||
|
After Width: | Height: | Size: 508 B |
1
img/app.svg
Normal file
1
img/app.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#fff"><path d="M0 0h24v24H0z" fill="none"/><path d="M11.8 10.9c-2.27-.59-3-1.2-3-2.15 0-1.09 1.01-1.85 2.7-1.85 1.78 0 2.44.85 2.5 2.1h2.21c-.07-1.72-1.12-3.3-3.21-3.81V3h-3v2.16c-1.94.42-3.5 1.68-3.5 3.61 0 2.31 1.91 3.46 4.7 4.13 2.5.6 3 1.48 3 2.41 0 .69-.49 1.79-2.7 1.79-2.06 0-2.87-.92-2.98-2.1h-2.2c.12 2.19 1.76 3.42 3.68 3.83V21h3v-2.15c1.95-.37 3.5-1.5 3.5-3.55 0-2.84-2.43-3.81-4.7-4.4z"/></svg>
|
||||
|
After Width: | Height: | Size: 500 B |
0
l10n/.gitkeep
Normal file
0
l10n/.gitkeep
Normal file
28
lib/AppInfo/Application.php
Normal file
28
lib/AppInfo/Application.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\NextcloudAppTemplate\AppInfo;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
public const APP_ID = 'nextcloudapptemplate';
|
||||
public const DIST_DIR = '../dist';
|
||||
public const JS_DIR = self::DIST_DIR . '/js';
|
||||
public const CSS_DIR = self::DIST_DIR . '/css';
|
||||
|
||||
/** @psalm-suppress PossiblyUnusedMethod */
|
||||
public function __construct() {
|
||||
parent::__construct(self::APP_ID);
|
||||
}
|
||||
|
||||
public function register(IRegistrationContext $context): void {
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
}
|
||||
}
|
||||
107
lib/Controller/ApiController.php
Normal file
107
lib/Controller/ApiController.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\NextcloudAppTemplate\Controller;
|
||||
|
||||
use OCA\NextcloudAppTemplate\AppInfo;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Attribute\ApiRoute;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\OCSController;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
|
||||
final class ApiController extends OCSController {
|
||||
/** @var IAppConfig */
|
||||
private $config;
|
||||
|
||||
/** @var IL10N */
|
||||
private $l10n;
|
||||
|
||||
public function __construct(
|
||||
string $appName,
|
||||
IRequest $request,
|
||||
IAppConfig $config,
|
||||
IL10N $l10n,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
$this->config = $config;
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/hello
|
||||
*
|
||||
* Returns a simple hello message and the last time the server said hello.
|
||||
*
|
||||
* @return DataResponse<Http::STATUS_OK, array{message: string, at: string|null}, array{}>
|
||||
*
|
||||
* 200: Data returned successfully.
|
||||
*/
|
||||
#[ApiRoute(verb: 'GET', url: '/api/hello')]
|
||||
#[NoAdminRequired]
|
||||
public function getHello(): DataResponse {
|
||||
$lastAt = $this->config->getValueString(AppInfo\Application::APP_ID, 'last_hello_at', '');
|
||||
$at = $lastAt !== '' ? $lastAt : null;
|
||||
|
||||
$message = (string)$this->l10n->t('👋 Hello from server!');
|
||||
|
||||
return new DataResponse([
|
||||
'message' => $message,
|
||||
'at' => $at,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/hello
|
||||
*
|
||||
* Accepts example payload and returns a message + timestamp.
|
||||
*
|
||||
* @param array{
|
||||
* name?: string,
|
||||
* theme?: string,
|
||||
* items?: list<string>,
|
||||
* counter?: int
|
||||
* } $data Request payload for creating a hello message.
|
||||
*
|
||||
* @return DataResponse<Http::STATUS_OK, array{message: string, at: string}, array{}>
|
||||
*
|
||||
* 200: Data returned successfully.
|
||||
*/
|
||||
#[ApiRoute(verb: 'POST', url: '/api/hello')]
|
||||
#[NoAdminRequired]
|
||||
public function postHello(mixed $data = []): DataResponse {
|
||||
// Normalize incoming payload (be permissive for the example)
|
||||
$name = isset($data['name']) && is_string($data['name']) ? trim($data['name']) : '';
|
||||
$theme = isset($data['theme']) && is_string($data['theme']) ? $data['theme'] : null;
|
||||
$items = isset($data['items']) && is_array($data['items']) ? $data['items'] : [];
|
||||
$counter = isset($data['counter']) && is_int($data['counter']) ? $data['counter'] : 0;
|
||||
|
||||
// Build a friendly message (localized)
|
||||
$who = $name !== '' ? $name : (string)$this->l10n->t('there');
|
||||
$message = (string)$this->l10n->t('Hello, %s!', [$who]);
|
||||
|
||||
// Optionally include a tiny summary (kept simple for the example)
|
||||
if ($theme !== null) {
|
||||
$message .= ' ' . (string)$this->l10n->t('Theme: %s.', [$theme]);
|
||||
}
|
||||
if (!empty($items)) {
|
||||
$message .= ' ' . (string)$this->l10n->t('Items: %d.', [count($items)]);
|
||||
}
|
||||
if ($counter !== 0) {
|
||||
$message .= ' ' . (string)$this->l10n->t('Counter: %d.', [$counter]);
|
||||
}
|
||||
|
||||
// Stamp "now" and persist as the last hello time
|
||||
$now = (new \DateTimeImmutable('now', new \DateTimeZone('UTC')))->format(\DATE_ATOM);
|
||||
$this->config->setValueString(AppInfo\Application::APP_ID, 'last_hello_at', $now);
|
||||
|
||||
return new DataResponse([
|
||||
'message' => $message,
|
||||
'at' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
42
lib/Controller/PageController.php
Normal file
42
lib/Controller/PageController.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\NextcloudAppTemplate\Controller;
|
||||
|
||||
use OCA\NextcloudAppTemplate\AppInfo\Application;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IRequest;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class PageController extends Controller {
|
||||
public function __construct(
|
||||
string $appName,
|
||||
IRequest $request,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
$this->logger->info('NextcloudAppTemplate page controller loaded');
|
||||
parent::__construct($appName, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main app page
|
||||
*
|
||||
* @return TemplateResponse<Http::STATUS_OK,array{}>
|
||||
*
|
||||
* 200: OK
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
#[NoCSRFRequired]
|
||||
#[FrontpageRoute(verb: 'GET', url: '/')]
|
||||
public function index(): TemplateResponse {
|
||||
$this->logger->info('NextcloudAppTemplate main page loaded');
|
||||
return new TemplateResponse(Application::APP_ID, 'app', [
|
||||
'script' => 'app',
|
||||
]);
|
||||
}
|
||||
}
|
||||
34
lib/Sections/Admin.php
Normal file
34
lib/Sections/Admin.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\NextcloudAppTemplate\Sections;
|
||||
|
||||
use OCA\NextcloudAppTemplate\AppInfo;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\Settings\IIconSection;
|
||||
|
||||
class Admin implements IIconSection {
|
||||
private IL10N $l;
|
||||
private IURLGenerator $urlGenerator;
|
||||
|
||||
public function __construct(IL10N $l, IURLGenerator $urlGenerator) {
|
||||
$this->l = $l;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
public function getIcon(): string {
|
||||
return $this->urlGenerator->imagePath(AppInfo\Application::APP_ID, 'app-dark.svg');
|
||||
}
|
||||
|
||||
public function getID(): string {
|
||||
return AppInfo\Application::APP_ID;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->l->t('Nextcloud App Template');
|
||||
}
|
||||
|
||||
public function getPriority(): int {
|
||||
return 80;
|
||||
}
|
||||
}
|
||||
44
lib/Settings/Admin.php
Normal file
44
lib/Settings/Admin.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\NextcloudAppTemplate\Settings;
|
||||
|
||||
use OCA\NextcloudAppTemplate\AppInfo\Application;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\Settings\ISettings;
|
||||
use OCP\Util;
|
||||
|
||||
class Admin implements ISettings {
|
||||
private IL10N $l;
|
||||
private IAppConfig $config;
|
||||
|
||||
public function __construct(IAppConfig $config, IL10N $l) {
|
||||
$this->config = $config;
|
||||
$this->l = $l;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateResponse
|
||||
*/
|
||||
public function getForm(): TemplateResponse {
|
||||
Util::addScript(Application::APP_ID, Application::JS_DIR . '/nextcloudapptemplate-main');
|
||||
Util::addStyle(Application::APP_ID, Application::CSS_DIR . '/nextcloudapptemplate-style');
|
||||
return new TemplateResponse(Application::APP_ID, 'settings', [], '');
|
||||
}
|
||||
|
||||
public function getSection(): string {
|
||||
return Application::APP_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int whether the form should be rather on the top or bottom of
|
||||
* the admin section. The forms are arranged in ascending order of the
|
||||
* priority values. It is required to return a value between 0 and 100.
|
||||
*
|
||||
* E.g.: 70
|
||||
*/
|
||||
public function getPriority(): int {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
290
openapi.json
Normal file
290
openapi.json
Normal file
@@ -0,0 +1,290 @@
|
||||
{
|
||||
"openapi": "3.0.3",
|
||||
"info": {
|
||||
"title": "nextcloudapptemplate",
|
||||
"version": "0.0.1",
|
||||
"description": "Automatically fills the currency rates for your Cospend projects daily.",
|
||||
"license": {
|
||||
"name": "agpl"
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"securitySchemes": {
|
||||
"basic_auth": {
|
||||
"type": "http",
|
||||
"scheme": "basic"
|
||||
},
|
||||
"bearer_auth": {
|
||||
"type": "http",
|
||||
"scheme": "bearer"
|
||||
}
|
||||
},
|
||||
"schemas": {
|
||||
"OCSMeta": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"status",
|
||||
"statuscode"
|
||||
],
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string"
|
||||
},
|
||||
"statuscode": {
|
||||
"type": "integer"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"totalitems": {
|
||||
"type": "string"
|
||||
},
|
||||
"itemsperpage": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
"/ocs/v2.php/apps/nextcloudapptemplate/api/hello": {
|
||||
"get": {
|
||||
"operationId": "api-get-hello",
|
||||
"summary": "GET /api/hello",
|
||||
"description": "Returns a simple hello message and the last time the server said hello.",
|
||||
"tags": [
|
||||
"api"
|
||||
],
|
||||
"security": [
|
||||
{
|
||||
"bearer_auth": []
|
||||
},
|
||||
{
|
||||
"basic_auth": []
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "OCS-APIRequest",
|
||||
"in": "header",
|
||||
"description": "Required to be true for the API request to pass",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Data returned successfully.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ocs"
|
||||
],
|
||||
"properties": {
|
||||
"ocs": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"meta",
|
||||
"data"
|
||||
],
|
||||
"properties": {
|
||||
"meta": {
|
||||
"$ref": "#/components/schemas/OCSMeta"
|
||||
},
|
||||
"data": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"message",
|
||||
"at"
|
||||
],
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"at": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Current user is not logged in",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ocs"
|
||||
],
|
||||
"properties": {
|
||||
"ocs": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"meta",
|
||||
"data"
|
||||
],
|
||||
"properties": {
|
||||
"meta": {
|
||||
"$ref": "#/components/schemas/OCSMeta"
|
||||
},
|
||||
"data": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"operationId": "api-post-hello",
|
||||
"summary": "POST /api/hello",
|
||||
"description": "Accepts example payload and returns a message + timestamp.",
|
||||
"tags": [
|
||||
"api"
|
||||
],
|
||||
"security": [
|
||||
{
|
||||
"bearer_auth": []
|
||||
},
|
||||
{
|
||||
"basic_auth": []
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": false,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"default": {},
|
||||
"description": "Request payload for creating a hello message.",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"theme": {
|
||||
"type": "string"
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"counter": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "OCS-APIRequest",
|
||||
"in": "header",
|
||||
"description": "Required to be true for the API request to pass",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Data returned successfully.",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ocs"
|
||||
],
|
||||
"properties": {
|
||||
"ocs": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"meta",
|
||||
"data"
|
||||
],
|
||||
"properties": {
|
||||
"meta": {
|
||||
"$ref": "#/components/schemas/OCSMeta"
|
||||
},
|
||||
"data": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"message",
|
||||
"at"
|
||||
],
|
||||
"properties": {
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"at": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Current user is not logged in",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ocs"
|
||||
],
|
||||
"properties": {
|
||||
"ocs": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"meta",
|
||||
"data"
|
||||
],
|
||||
"properties": {
|
||||
"meta": {
|
||||
"$ref": "#/components/schemas/OCSMeta"
|
||||
},
|
||||
"data": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
51
package.json
Normal file
51
package.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"name": "nextcloudapptemplate",
|
||||
"version": "0.0.0",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": "^22.19.0",
|
||||
"pnpm": "^10.17.0"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite build --watch",
|
||||
"build": "vue-tsc -b && vite build",
|
||||
"lint": "eslint src",
|
||||
"format": "eslint --fix src && prettier --write {src/,README.md}",
|
||||
"prepare": "husky",
|
||||
"gen": "simple-scaffold -c . -k"
|
||||
},
|
||||
"browserslist": [
|
||||
"extends @nextcloud/browserslist-config"
|
||||
],
|
||||
"dependencies": {
|
||||
"@nextcloud/axios": "^2.5.1",
|
||||
"@nextcloud/l10n": "^3.4.0",
|
||||
"@nextcloud/router": "^3.0.1",
|
||||
"@nextcloud/vite-config": "2.3.5",
|
||||
"@nextcloud/vue": "9.0.0-rc.9",
|
||||
"date-fns": "^4.1.0",
|
||||
"linkifyjs": "^4.3.2",
|
||||
"vue": "^3.5.21",
|
||||
"vue-material-design-icons": "^5.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.36.0",
|
||||
"@nextcloud/browserslist-config": "^3.0.1",
|
||||
"@nextcloud/eslint-config": "^8.4.2",
|
||||
"@nextcloud/stylelint-config": "^3.1.0",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
"eslint": "^9.36.0",
|
||||
"husky": "^9.1.7",
|
||||
"lint-staged": "^16.1.6",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier-plugin-vue": "^1.1.6",
|
||||
"sass": "^1.93.0",
|
||||
"sass-embedded": "^1.93.0",
|
||||
"typescript": "5.9.2",
|
||||
"typescript-eslint": "^8.44.0",
|
||||
"vite": "^6.3.6",
|
||||
"vue-router": "^4.5.1",
|
||||
"vue-tsc": "^2.2.12"
|
||||
}
|
||||
}
|
||||
8335
pnpm-lock.yaml
generated
Normal file
8335
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
psalm.xml
Normal file
20
psalm.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="1"
|
||||
resolveFromConfigFile="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
findUnusedBaselineEntry="true"
|
||||
findUnusedCode="true"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="lib" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
<extraFiles>
|
||||
<directory name="vendor"/>
|
||||
</extraFiles>
|
||||
</psalm>
|
||||
15
release-please-config.json
Normal file
15
release-please-config.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
|
||||
"packages": {
|
||||
".": {
|
||||
"release-type": "simple",
|
||||
"extra-files": [
|
||||
{
|
||||
"type": "xml",
|
||||
"path": "appinfo/info.xml",
|
||||
"xpath": "/info/version"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
127
rename-template.sh
Executable file
127
rename-template.sh
Executable file
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env bash
|
||||
# Replace template names in all text files under the current directory.
|
||||
# Prompts for target names and replaces these sources:
|
||||
# $SOURCE_KEBAB -> <kebab-case input>
|
||||
# $SOURCE_PASCAL -> <PascalCase input>
|
||||
# $SOURCE_USER -> <username input> (default: your-user)
|
||||
# $SOURCE_FULL -> <full-name input> (default: Your Name)
|
||||
#
|
||||
# Defaults (override via env before running):
|
||||
# SOURCE_KEBAB=nextcloudapptemplate
|
||||
# SOURCE_PASCAL=NextcloudAppTemplate
|
||||
# SOURCE_USER=your-user
|
||||
# SOURCE_FULL=Your Name
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SOURCE_KEBAB="${SOURCE_KEBAB:-nextcloudapptemplate}"
|
||||
SOURCE_PASCAL="${SOURCE_PASCAL:-NextcloudAppTemplate}"
|
||||
SOURCE_USER="${SOURCE_USER:-your-user}"
|
||||
SOURCE_FULL="${SOURCE_FULL:-Your Name}"
|
||||
SOURCE_EMAIL="${SOURCE_EMAIL:-your@email.com}"
|
||||
SOURCE_WEBSITE="${SOURCE_WEBSITE:-https://your.website}"
|
||||
|
||||
printf "Enter kebab-case name (e.g., my-nextcloud-app): "
|
||||
IFS= read KEBAB
|
||||
printf "Enter PascalCase name (e.g., MyNextcloudApp): "
|
||||
IFS= read PASCAL
|
||||
printf "Enter username (e.g., myUsername): "
|
||||
IFS= read DEST_USER
|
||||
printf "Enter full name (e.g., My Full Name): "
|
||||
IFS= read DEST_FULL
|
||||
printf "Enter email (e.g., myemail@example.com): "
|
||||
IFS= read DEST_EMAIL
|
||||
printf "Enter website (e.g., https://mywebsite.com): "
|
||||
IFS= read DEST_WEBSITE
|
||||
|
||||
if [[ -z "${KEBAB}" || -z "${PASCAL}" || -z "${DEST_USER}" || -z "${DEST_FULL}" ]]; then
|
||||
echo "All values are required." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Replacing:"
|
||||
echo " ${SOURCE_KEBAB} -> ${KEBAB}"
|
||||
echo " ${SOURCE_PASCAL} -> ${PASCAL}"
|
||||
echo " ${SOURCE_USER} -> ${DEST_USER}"
|
||||
echo " ${SOURCE_FULL} -> ${DEST_FULL}"
|
||||
echo " ${SOURCE_EMAIL} -> ${DEST_EMAIL}"
|
||||
echo " ${SOURCE_WEBSITE} -> ${DEST_WEBSITE}"
|
||||
echo
|
||||
|
||||
changed=0
|
||||
checked=0
|
||||
|
||||
# Folders to skip
|
||||
SKIP_DIRS=(
|
||||
"*/.git/*"
|
||||
"*/node_modules/*"
|
||||
"*/vendor/*"
|
||||
"*/dist/*"
|
||||
"*/build/*"
|
||||
"*/.next/*"
|
||||
"*/.pnpm-store/*"
|
||||
"*/.cache/*"
|
||||
)
|
||||
|
||||
# Build the find prune expression
|
||||
PRUNE_EXPR=()
|
||||
for d in "${SKIP_DIRS[@]}"; do
|
||||
PRUNE_EXPR+=(-path "$d" -o)
|
||||
done
|
||||
unset 'PRUNE_EXPR[${#PRUNE_EXPR[@]}-1]'
|
||||
|
||||
# Export for Perl
|
||||
export KEBAB PASCAL DEST_USER DEST_FULL SOURCE_KEBAB SOURCE_PASCAL SOURCE_USER SOURCE_FULL SOURCE_EMAIL DEST_EMAIL SOURCE_WEBSITE DEST_WEBSITE
|
||||
|
||||
# Iterate files safely (null-delimited), skip binaries, replace in place with perl
|
||||
while IFS= read -r -d '' file; do
|
||||
[[ -f "$file" ]] || continue
|
||||
|
||||
# Skip binary files
|
||||
if ! LC_ALL=C grep -Iq . "$file"; then
|
||||
continue
|
||||
fi
|
||||
|
||||
checked=$((checked + 1))
|
||||
|
||||
perl -0777 -i.bak -pe '
|
||||
BEGIN {
|
||||
$src_k = $ENV{SOURCE_KEBAB};
|
||||
$src_p = $ENV{SOURCE_PASCAL};
|
||||
$src_u = $ENV{SOURCE_USER};
|
||||
$src_f = $ENV{SOURCE_FULL};
|
||||
$src_e = $ENV{SOURCE_EMAIL};
|
||||
$src_w = $ENV{SOURCE_WEBSITE};
|
||||
|
||||
$dst_k = $ENV{KEBAB};
|
||||
$dst_p = $ENV{PASCAL};
|
||||
$dst_u = $ENV{DEST_USER};
|
||||
$dst_f = $ENV{DEST_FULL};
|
||||
$dst_e = $ENV{DEST_EMAIL};
|
||||
$dst_w = $ENV{DEST_WEBSITE};
|
||||
}
|
||||
s/\Q$src_k\E/$dst_k/g;
|
||||
s/\Q$src_p\E/$dst_p/g;
|
||||
s/\Q$src_u\E/$dst_u/g;
|
||||
s/\Q$src_f\E/$dst_f/g;
|
||||
s/\Q$src_e\E/$dst_e/g;
|
||||
s/\Q$src_w\E/$dst_w/g;
|
||||
' -- "$file"
|
||||
|
||||
if ! cmp -s "$file" "$file.bak"; then
|
||||
changed=$((changed + 1))
|
||||
echo "Updated: $file"
|
||||
fi
|
||||
|
||||
rm -f -- "$file.bak"
|
||||
done < <(find . \( "${PRUNE_EXPR[@]}" \) -prune -o -type f -print0)
|
||||
|
||||
echo
|
||||
echo "Checked $checked text file(s). Updated $changed file(s). ✅"
|
||||
|
||||
if [ -d ".github/workflows.template" ]; then
|
||||
echo "Moving .github/workflows.template to .github/workflows"
|
||||
mkdir -p .github/workflows
|
||||
git mv .github/workflows.template/* .github/workflows/ 2>/dev/null || mv .github/workflows.template/* .github/workflows/
|
||||
rmdir .github/workflows.template 2>/dev/null || true
|
||||
fi
|
||||
77
scaffold.config.cjs
Normal file
77
scaffold.config.cjs
Normal file
@@ -0,0 +1,77 @@
|
||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
const { format } = require('date-fns')
|
||||
// eslint-disable-next-line no-undef
|
||||
const fs = require('node:fs')
|
||||
|
||||
function getLatestMigration() {
|
||||
const migrationDir = 'lib/Migration'
|
||||
const files = fs.readdirSync(migrationDir)
|
||||
const migrationFiles = files.sort((a, b) => a.localeCompare(b))
|
||||
const latestMigration = migrationFiles[migrationFiles.length - 1]
|
||||
const matches = /Version(\d+)/.exec(latestMigration)
|
||||
const version = matches ? Number(matches[1]) + 1 : 0
|
||||
return version
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
module.exports = () => {
|
||||
const latestMigrationVersion = getLatestMigration()
|
||||
return {
|
||||
component: {
|
||||
templates: ['gen/component'],
|
||||
output: 'src/components',
|
||||
subDir: false,
|
||||
},
|
||||
page: {
|
||||
templates: ['gen/page'],
|
||||
output: 'src/pages',
|
||||
subDir: false,
|
||||
},
|
||||
command: {
|
||||
templates: ['gen/command'],
|
||||
output: 'lib/Command',
|
||||
subDir: false,
|
||||
},
|
||||
model: {
|
||||
templates: ['gen/model'],
|
||||
output: 'lib/Db',
|
||||
subDir: false,
|
||||
},
|
||||
'task-queued': {
|
||||
templates: ['gen/task-queued'],
|
||||
output: 'lib/Cron',
|
||||
subDir: false,
|
||||
},
|
||||
'task-timed': {
|
||||
templates: ['gen/task-timed'],
|
||||
output: 'lib/Cron',
|
||||
subDir: false,
|
||||
},
|
||||
service: {
|
||||
templates: ['gen/service'],
|
||||
output: 'lib/Service',
|
||||
subDir: false,
|
||||
},
|
||||
util: {
|
||||
templates: ['gen/util'],
|
||||
output: 'lib/Util',
|
||||
subDir: false,
|
||||
},
|
||||
api: {
|
||||
templates: ['gen/api'],
|
||||
output: 'lib/Controller',
|
||||
subDir: false,
|
||||
},
|
||||
migration: {
|
||||
templates: ['gen/migration'],
|
||||
output: 'lib/Migration',
|
||||
name: '-',
|
||||
data: {
|
||||
version: latestMigrationVersion,
|
||||
dt: format(new Date(), 'yyyyMMddHHmmss'),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
179
src/App.vue
Normal file
179
src/App.vue
Normal file
@@ -0,0 +1,179 @@
|
||||
<template>
|
||||
<NcContent app-name="nextcloud-hello-world">
|
||||
<!-- Left sidebar -->
|
||||
<NcAppNavigation>
|
||||
<template #search>
|
||||
<NcAppNavigationSearch
|
||||
v-model="searchValue"
|
||||
:label="strings.searchLabel"
|
||||
:placeholder="strings.searchPlaceholder"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #list>
|
||||
<NcAppNavigationItem
|
||||
:name="strings.navHome"
|
||||
:to="{ path: '/' }"
|
||||
:active="$route.path === '/' || $route.path === ''"
|
||||
>
|
||||
<template #icon>
|
||||
<HomeIcon :size="20" />
|
||||
</template>
|
||||
</NcAppNavigationItem>
|
||||
|
||||
<NcAppNavigationItem
|
||||
:name="strings.navExamples"
|
||||
:to="{ path: basePath + '/examples' }"
|
||||
:active="isPrefixRoute(basePath + '/examples')"
|
||||
>
|
||||
<template #icon>
|
||||
<PuzzleIcon :size="20" />
|
||||
</template>
|
||||
</NcAppNavigationItem>
|
||||
|
||||
<NcAppNavigationItem
|
||||
:name="strings.navAbout"
|
||||
:to="{ path: basePath + '/about' }"
|
||||
:active="isPrefixRoute(basePath + '/about')"
|
||||
>
|
||||
<template #icon>
|
||||
<InfoIcon :size="20" />
|
||||
</template>
|
||||
</NcAppNavigationItem>
|
||||
</template>
|
||||
|
||||
<template #footer>
|
||||
<!-- Optional footer controls -->
|
||||
</template>
|
||||
</NcAppNavigation>
|
||||
|
||||
<!-- Main content -->
|
||||
<NcAppContent id="hello-main">
|
||||
<header class="page-header">
|
||||
<h2>{{ strings.title }}</h2>
|
||||
<p class="muted" v-html="strings.subtitle"></p>
|
||||
</header>
|
||||
|
||||
<div id="hello-router">
|
||||
<div v-if="isRouterLoading" class="router-loading">
|
||||
<NcLoadingIcon :size="48" />
|
||||
</div>
|
||||
<router-view v-else />
|
||||
</div>
|
||||
</NcAppContent>
|
||||
</NcContent>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import NcContent from '@nextcloud/vue/components/NcContent'
|
||||
import NcAppContent from '@nextcloud/vue/components/NcAppContent'
|
||||
import NcAppNavigation from '@nextcloud/vue/components/NcAppNavigation'
|
||||
import NcAppNavigationItem from '@nextcloud/vue/components/NcAppNavigationItem'
|
||||
import NcAppNavigationSearch from '@nextcloud/vue/components/NcAppNavigationSearch'
|
||||
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
|
||||
import HomeIcon from '@icons/Home.vue'
|
||||
import PuzzleIcon from '@icons/Puzzle.vue'
|
||||
import InfoIcon from '@icons/Information.vue'
|
||||
|
||||
export default {
|
||||
name: 'AppUserWrapper',
|
||||
components: {
|
||||
NcContent,
|
||||
NcAppContent,
|
||||
NcAppNavigation,
|
||||
NcAppNavigationItem,
|
||||
NcAppNavigationSearch,
|
||||
NcLoadingIcon,
|
||||
HomeIcon,
|
||||
PuzzleIcon,
|
||||
InfoIcon,
|
||||
},
|
||||
// Tell NcContent we *do* have a sidebar so it arranges layout properly
|
||||
provide() {
|
||||
return { 'NcContent:setHasAppNavigation': () => true }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
searchValue: '',
|
||||
isRouterLoading: false,
|
||||
// Mount path for this app section; adjust to your mount.
|
||||
basePath: '/apps/nextcloud-hello-world',
|
||||
strings: {
|
||||
title: t('nextcloud-hello-world', 'Hello World — App'),
|
||||
subtitle: t(
|
||||
'nextcloud-hello-world',
|
||||
'Use the sidebar to navigate between views. Backend calls use {cStart}axios{cEnd} and OCS responses.',
|
||||
{ cStart: '<code>', cEnd: '</code>' },
|
||||
undefined,
|
||||
{ escape: false },
|
||||
),
|
||||
searchLabel: t('nextcloud-hello-world', 'Search'),
|
||||
searchPlaceholder: t('nextcloud-hello-world', 'Type to filter…'),
|
||||
navHome: t('nextcloud-hello-world', 'Home'),
|
||||
navExamples: t('nextcloud-hello-world', 'Examples'),
|
||||
navAbout: t('nextcloud-hello-world', 'About'),
|
||||
},
|
||||
_removeBeforeEach: null,
|
||||
_removeAfterEach: null,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// Show a loading overlay while routes are changing
|
||||
this._removeBeforeEach = this.$router.beforeEach((to, from, next) => {
|
||||
this.isRouterLoading = true
|
||||
next()
|
||||
})
|
||||
this._removeAfterEach = this.$router.afterEach(() => {
|
||||
this.isRouterLoading = false
|
||||
})
|
||||
},
|
||||
beforeUnmount() {
|
||||
// Clean up router guards
|
||||
if (typeof this._removeBeforeEach === 'function') this._removeBeforeEach()
|
||||
if (typeof this._removeAfterEach === 'function') this._removeAfterEach()
|
||||
},
|
||||
methods: {
|
||||
isPrefixRoute(prefix) {
|
||||
return this.$route.path.startsWith(prefix)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
#hello-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
/* fills viewport next to sidebar */
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
padding: 1rem;
|
||||
padding-bottom: 0.5rem;
|
||||
|
||||
h2 {
|
||||
margin: 0 0 6px 0;
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: var(--color-text-maxcontrast);
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
|
||||
#hello-router {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.router-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
468
src/Settings.vue
Normal file
468
src/Settings.vue
Normal file
@@ -0,0 +1,468 @@
|
||||
<template>
|
||||
<div id="nextcloud-hello-world-content" class="section">
|
||||
<h2>{{ strings.title }}</h2>
|
||||
|
||||
<!-- Information / quick start -->
|
||||
<NcAppSettingsSection :name="strings.infoTitle">
|
||||
<p v-html="strings.infoIntro"></p>
|
||||
|
||||
<ol class="ol">
|
||||
<li v-for="li in strings.gettingStartedList" :key="li" v-html="li"></li>
|
||||
</ol>
|
||||
|
||||
<NcNoteCard type="info">
|
||||
<p v-html="strings.tipsNote"></p>
|
||||
</NcNoteCard>
|
||||
</NcAppSettingsSection>
|
||||
|
||||
<!-- Live examples -->
|
||||
<NcAppSettingsSection :name="strings.examplesHeader">
|
||||
<section class="example-grid">
|
||||
<!-- v-model example -->
|
||||
<div class="card">
|
||||
<h3 class="card-title">{{ strings.nameInputHeader }}</h3>
|
||||
<NcTextField
|
||||
v-model="name"
|
||||
:label="strings.nameInputLabel"
|
||||
:placeholder="strings.nameInputPlaceholder"
|
||||
/>
|
||||
<p class="mt-8">
|
||||
{{ strings.livePreview }} <b>{{ greeting }}</b>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Select + computed example -->
|
||||
<div class="card">
|
||||
<h3 class="card-title">{{ strings.themeHeader }}</h3>
|
||||
<NcSelect
|
||||
v-model="themeLabel"
|
||||
:options="themeOptionsLabels"
|
||||
:input-label="strings.themeLabel"
|
||||
/>
|
||||
<p class="mt-8">
|
||||
{{ strings.themePreview }}
|
||||
<code>{{ activeTheme.value }}</code>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Counter + events example -->
|
||||
<div class="card">
|
||||
<h3 class="card-title">{{ strings.counterHeader }}</h3>
|
||||
<div class="row gap-8">
|
||||
<NcButton @click="decrement">{{ strings.minus }}</NcButton>
|
||||
<span class="counter">{{ counter }}</span>
|
||||
<NcButton @click="increment">{{ strings.plus }}</NcButton>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</NcAppSettingsSection>
|
||||
|
||||
<!-- Table + add/remove items example -->
|
||||
<NcAppSettingsSection :name="strings.itemsHeader">
|
||||
<div class="row align-start gap-16">
|
||||
<div style="max-width: 320px">
|
||||
<NcTextField
|
||||
v-model="newItem"
|
||||
:label="strings.newItemLabel"
|
||||
:placeholder="strings.newItemPlaceholder"
|
||||
trailing-button-icon="plus"
|
||||
:show-trailing-button="newItem.trim() !== ''"
|
||||
@trailing-button-click="addItem"
|
||||
/>
|
||||
</div>
|
||||
<NcButton @click="addItem" :disabled="newItem.trim() === ''">{{ strings.add }}</NcButton>
|
||||
<NcButton type="secondary" @click="clearItems" :disabled="items.length === 0">
|
||||
{{ strings.clear }}
|
||||
</NcButton>
|
||||
</div>
|
||||
|
||||
<table class="mt-16">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 60%">{{ strings.tableItem }}</th>
|
||||
<th style="width: 40%">{{ strings.tableActions }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(item, idx) in items" :key="item.id">
|
||||
<td>
|
||||
<input class="inline-input" :aria-label="strings.editItemAria" v-model="item.label" />
|
||||
</td>
|
||||
<td>
|
||||
<div class="row gap-8">
|
||||
<NcButton type="tertiary" @click="duplicate(idx)">{{ strings.duplicate }}</NcButton>
|
||||
<NcButton type="error" @click="remove(idx)">{{ strings.remove }}</NcButton>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="items.length === 0">
|
||||
<td colspan="2" class="muted">{{ strings.noItems }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</NcAppSettingsSection>
|
||||
|
||||
<!-- Backend calls example -->
|
||||
<NcAppSettingsSection :name="strings.backendHeader">
|
||||
<form @submit.prevent @submit="save">
|
||||
<div class="row gap-16 align-center">
|
||||
<NcButton @click="fetchHello" :disabled="loading">{{ strings.fetchHello }}</NcButton>
|
||||
<NcButton native-type="submit" :disabled="loading">{{ strings.save }}</NcButton>
|
||||
|
||||
<span>
|
||||
<span v-if="loading">{{ strings.loading }}</span>
|
||||
<span v-else-if="lastHelloAt">
|
||||
{{ strings.lastHelloAt }}
|
||||
<NcDateTime :timestamp="lastHelloAt.valueOf()" />
|
||||
</span>
|
||||
<span v-else class="muted">{{ strings.never }}</span>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<NcNoteCard v-if="serverMessage" type="success" class="mt-12">
|
||||
<p>
|
||||
{{ strings.serverSaid }} <code>{{ serverMessage }}</code>
|
||||
</p>
|
||||
</NcNoteCard>
|
||||
</NcAppSettingsSection>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import NcAppSettingsSection from '@nextcloud/vue/components/NcAppSettingsSection'
|
||||
import NcSelect from '@nextcloud/vue/components/NcSelect'
|
||||
import NcButton from '@nextcloud/vue/components/NcButton'
|
||||
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
|
||||
import NcDateTime from '@nextcloud/vue/components/NcDateTime'
|
||||
import NcTextField from '@nextcloud/vue/components/NcTextField'
|
||||
|
||||
import axios from '@nextcloud/axios'
|
||||
import { t, n } from '@nextcloud/l10n'
|
||||
|
||||
export default {
|
||||
name: 'HelloWorld',
|
||||
components: {
|
||||
NcAppSettingsSection,
|
||||
NcButton,
|
||||
NcDateTime,
|
||||
NcNoteCard,
|
||||
NcSelect,
|
||||
NcTextField,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// UI state
|
||||
loading: false,
|
||||
|
||||
// Example: simple input
|
||||
name: '',
|
||||
|
||||
// Example: select with label <-> value mapping (like your intervals)
|
||||
themeLabel: null,
|
||||
themeOptions: [
|
||||
{ label: t('nextcloud-hello-world', 'Light'), value: 'light' },
|
||||
{ label: t('nextcloud-hello-world', 'Dark'), value: 'dark' },
|
||||
{
|
||||
label: n('nextcloud-hello-world', 'System (1 option)', 'System (%n options)', 2),
|
||||
value: 'system',
|
||||
},
|
||||
],
|
||||
|
||||
// Example: small counter
|
||||
counter: 0,
|
||||
|
||||
// Example: simple items table
|
||||
items: [],
|
||||
newItem: '',
|
||||
|
||||
// Example: tracking server interactions
|
||||
lastHelloAt: null,
|
||||
serverMessage: '',
|
||||
|
||||
// All user-visible strings go here
|
||||
strings: {
|
||||
// Titles / headers
|
||||
title: t('nextcloud-hello-world', 'Hello World — App Template'),
|
||||
infoTitle: t('nextcloud-hello-world', 'Information'),
|
||||
examplesHeader: t('nextcloud-hello-world', 'Quick Examples'),
|
||||
itemsHeader: t('nextcloud-hello-world', 'Editable List'),
|
||||
backendHeader: t('nextcloud-hello-world', 'Backend Calls'),
|
||||
|
||||
// Info
|
||||
infoIntro: t(
|
||||
'nextcloud-hello-world',
|
||||
'This view shows {bStart}small, focused examples{bEnd} for inputs, lists, selections, and backend calls.',
|
||||
{ bStart: '<b>', bEnd: '</b>' },
|
||||
undefined,
|
||||
{ escape: false },
|
||||
),
|
||||
|
||||
gettingStartedList: [
|
||||
t(
|
||||
'nextcloud-hello-world',
|
||||
'Import UI parts from {cStart}@nextcloud/vue{cEnd} and wire them with {cStart}v-model{cEnd}.',
|
||||
{ cStart: '<code>', cEnd: '</code>' },
|
||||
undefined,
|
||||
{ escape: false },
|
||||
),
|
||||
t(
|
||||
'nextcloud-hello-world',
|
||||
'Use {cStart}axios{cEnd} for API calls; return OCS data as needed.',
|
||||
{ cStart: '<code>', cEnd: '</code>' },
|
||||
undefined,
|
||||
{ escape: false },
|
||||
),
|
||||
t(
|
||||
'nextcloud-hello-world',
|
||||
'Keep user-facing text in a central {cStart}strings{cEnd} object with {cStart}t/n{cEnd}.',
|
||||
{ cStart: '<code>', cEnd: '</code>' },
|
||||
undefined,
|
||||
{ escape: false },
|
||||
),
|
||||
],
|
||||
|
||||
tipsNote: t(
|
||||
'nextcloud-hello-world',
|
||||
'Pro tip: keep labels in {cStart}label{cEnd} and values in {cStart}value{cEnd} to simplify mapping.',
|
||||
{ cStart: '<code>', cEnd: '</code>' },
|
||||
undefined,
|
||||
{ escape: false },
|
||||
),
|
||||
|
||||
// Name example
|
||||
nameInputHeader: t('nextcloud-hello-world', 'Your Name'),
|
||||
nameInputLabel: t('nextcloud-hello-world', 'Name'),
|
||||
nameInputPlaceholder: t('nextcloud-hello-world', 'e.g. Ada Lovelace'),
|
||||
livePreview: t('nextcloud-hello-world', 'Live preview:'),
|
||||
|
||||
// Theme example
|
||||
themeHeader: t('nextcloud-hello-world', 'Theme'),
|
||||
themeLabel: t('nextcloud-hello-world', 'Choose a theme'),
|
||||
themePreview: t('nextcloud-hello-world', 'Active value:'),
|
||||
|
||||
// Counter example
|
||||
counterHeader: t('nextcloud-hello-world', 'Counter'),
|
||||
plus: t('nextcloud-hello-world', '+1'),
|
||||
minus: t('nextcloud-hello-world', '-1'),
|
||||
|
||||
// Items table
|
||||
newItemLabel: t('nextcloud-hello-world', 'New item'),
|
||||
newItemPlaceholder: t('nextcloud-hello-world', 'e.g. Hello item'),
|
||||
add: t('nextcloud-hello-world', 'Add'),
|
||||
clear: t('nextcloud-hello-world', 'Clear'),
|
||||
tableItem: t('nextcloud-hello-world', 'Item'),
|
||||
tableActions: t('nextcloud-hello-world', 'Actions'),
|
||||
editItemAria: t('nextcloud-hello-world', 'Edit item'),
|
||||
duplicate: t('nextcloud-hello-world', 'Duplicate'),
|
||||
remove: t('nextcloud-hello-world', 'Remove'),
|
||||
noItems: t('nextcloud-hello-world', 'No items yet'),
|
||||
|
||||
// Backend
|
||||
fetchHello: t('nextcloud-hello-world', 'Fetch Hello'),
|
||||
save: t('nextcloud-hello-world', 'Save'),
|
||||
loading: t('nextcloud-hello-world', 'Loading…'),
|
||||
lastHelloAt: t('nextcloud-hello-world', 'Last hello at:'),
|
||||
never: t('nextcloud-hello-world', 'Never'),
|
||||
serverSaid: t('nextcloud-hello-world', 'Server said:'),
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// Load initial data if you want
|
||||
this.fetchHello()
|
||||
},
|
||||
computed: {
|
||||
// Map selected theme label -> full option
|
||||
activeTheme() {
|
||||
return this.themeOptions.find((x) => x.label === this.themeLabel) ?? this.themeOptions[0]
|
||||
},
|
||||
// Convenience list for NcSelect (labels only)
|
||||
themeOptionsLabels() {
|
||||
return this.themeOptions.map((x) => x.label)
|
||||
},
|
||||
// Live greeting preview (reacts to "name")
|
||||
greeting() {
|
||||
return this.name.trim() ? `Hello, ${this.name.trim()}!` : 'Hello!'
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// Counter handlers
|
||||
increment() {
|
||||
this.counter++
|
||||
},
|
||||
decrement() {
|
||||
this.counter--
|
||||
},
|
||||
|
||||
// Items handlers
|
||||
addItem() {
|
||||
const label = this.newItem.trim()
|
||||
if (!label) return
|
||||
this.items.push({ id: cryptoRandom(), label })
|
||||
this.newItem = ''
|
||||
},
|
||||
duplicate(index) {
|
||||
const src = this.items[index]
|
||||
if (!src) return
|
||||
this.items.splice(index + 1, 0, { id: cryptoRandom(), label: src.label })
|
||||
},
|
||||
remove(index) {
|
||||
this.items.splice(index, 1)
|
||||
},
|
||||
clearItems() {
|
||||
this.items = []
|
||||
},
|
||||
|
||||
// Backend examples (adjust endpoints to your app’s routes)
|
||||
async fetchHello() {
|
||||
try {
|
||||
this.loading = true
|
||||
// Example GET -> /hello (expects: { ocs: { data: { message: string, at: string }}})
|
||||
const resp = await axios.get('/hello')
|
||||
const data = resp.data?.ocs?.data ?? {}
|
||||
this.serverMessage = data.message ?? '👋'
|
||||
// If backend returns ISO date strings, store a Date instance
|
||||
if (data.at) this.lastHelloAt = new Date(data.at)
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch hello', e)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
async save() {
|
||||
try {
|
||||
this.loading = true
|
||||
// Example POST -> /hello (send minimal payload)
|
||||
const payload = {
|
||||
name: this.name.trim() || null,
|
||||
theme: this.activeTheme.value,
|
||||
items: this.items.map((x) => x.label),
|
||||
counter: this.counter,
|
||||
}
|
||||
const resp = await axios.post('/hello', { data: payload })
|
||||
const data = resp.data?.ocs?.data ?? {}
|
||||
// Update preview/message
|
||||
if (data.message) this.serverMessage = data.message
|
||||
if (data.at) this.lastHelloAt = new Date(data.at)
|
||||
} catch (e) {
|
||||
console.error('Failed to save hello', e)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
/** Small helper for local IDs (no crypto dep) */
|
||||
function cryptoRandom() {
|
||||
return Math.random().toString(36).slice(2, 10)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
#nextcloud-hello-world-content {
|
||||
h2:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.mt-8 {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.mt-12 {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.mt-16 {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
|
||||
&.align-start {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
&.align-center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&.gap-8 {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
&.gap-16 {
|
||||
gap: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.example-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
margin: 0 0 8px 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.counter {
|
||||
min-width: 3ch;
|
||||
text-align: center;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.inline-input {
|
||||
width: 100%;
|
||||
padding: 6px 8px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 6px;
|
||||
background: var(--color-main-background);
|
||||
color: var(--color-main-text);
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: var(--color-text-maxcontrast);
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.ol {
|
||||
padding-left: 2.5em;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border: 1px solid var(--color-border);
|
||||
margin-top: 8px;
|
||||
|
||||
tr:not(:last-child),
|
||||
thead tr {
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
thead,
|
||||
tbody tr {
|
||||
display: table;
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
td,
|
||||
th {
|
||||
padding: 6px 8px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
13
src/app.ts
Normal file
13
src/app.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import App from './App.vue'
|
||||
import './style.scss'
|
||||
import { createApp } from 'vue'
|
||||
import axios from '@nextcloud/axios'
|
||||
import { generateOcsUrl } from '@nextcloud/router'
|
||||
import router from './router'
|
||||
|
||||
const baseURL = generateOcsUrl('/apps/nextcloudapptemplate/api')
|
||||
axios.defaults.baseURL = baseURL
|
||||
|
||||
console.log('[DEBUG] Mounting NextcloudAppTemplate app')
|
||||
console.log('[DEBUG] Base URL:', baseURL)
|
||||
createApp(App).use(router).mount('#nextcloudapptemplate-app')
|
||||
5
src/axios.ts
Normal file
5
src/axios.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { generateOcsUrl } from '@nextcloud/router'
|
||||
import _axios from '@nextcloud/axios'
|
||||
|
||||
const baseURL = generateOcsUrl('/apps/jukebox/api')
|
||||
export const axios = _axios.create({ baseURL })
|
||||
12
src/router/index.ts
Normal file
12
src/router/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { createRouter, createWebHashHistory, type RouteRecordRaw } from 'vue-router'
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{ path: '/', component: () => import('@/views/AppView.vue') },
|
||||
]
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes,
|
||||
})
|
||||
|
||||
export default router
|
||||
8
src/settings.ts
Normal file
8
src/settings.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { axios } from './axios'
|
||||
import Settings from './Settings.vue'
|
||||
import './style.scss'
|
||||
import { createApp } from 'vue'
|
||||
|
||||
console.log('[DEBUG] Mounting NextcloudAppTemplate Settings')
|
||||
console.log('[DEBUG] Base URL:', axios.defaults.baseURL)
|
||||
createApp(Settings).mount('#jukebox-settings')
|
||||
3
src/style.scss
Normal file
3
src/style.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.action-button__text {
|
||||
cursor: pointer;
|
||||
}
|
||||
423
src/views/AppView.vue
Normal file
423
src/views/AppView.vue
Normal file
@@ -0,0 +1,423 @@
|
||||
<template>
|
||||
<div class="user-inner">
|
||||
<!-- Toolbar -->
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-left">
|
||||
<div style="max-width: 320px">
|
||||
<NcTextField v-model="search" :label="strings.searchLabel" :placeholder="strings.searchPlaceholder"
|
||||
trailing-button-icon="close" :show-trailing-button="search !== ''" @trailing-button-click="clearSearch" />
|
||||
</div>
|
||||
<NcButton @click="refresh" :disabled="loading">{{ strings.refresh }}</NcButton>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-right">
|
||||
<NcButton type="secondary" @click="toggleForm">
|
||||
{{ formOpen ? strings.hideForm : strings.showForm }}
|
||||
</NcButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Quick info / doc -->
|
||||
<NcNoteCard class="mt-12" type="info">
|
||||
<p v-html="strings.quickHelp"></p>
|
||||
</NcNoteCard>
|
||||
|
||||
<!-- Add item form -->
|
||||
<section v-if="formOpen" class="card mt-16">
|
||||
<h3 class="card-title">{{ strings.formHeader }}</h3>
|
||||
<div class="row gap-16 align-start">
|
||||
<div style="max-width: 260px">
|
||||
<NcTextField v-model="name" :label="strings.nameInputLabel" :placeholder="strings.nameInputPlaceholder" />
|
||||
</div>
|
||||
|
||||
<div style="max-width: 220px">
|
||||
<NcSelect v-model="themeLabel" :options="themeOptionsLabels" :input-label="strings.themeLabel" />
|
||||
</div>
|
||||
|
||||
<div class="row gap-8 align-center">
|
||||
<NcButton @click="addFromForm" :disabled="name.trim() === '' || loading">
|
||||
{{ strings.add }}
|
||||
</NcButton>
|
||||
<NcButton type="tertiary" @click="clearForm" :disabled="loading">
|
||||
{{ strings.clear }}
|
||||
</NcButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-12">
|
||||
{{ strings.livePreview }} <b>{{ previewGreeting }}</b>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<!-- Loading state -->
|
||||
<div class="center mt-16" v-if="loading">
|
||||
<NcLoadingIcon :size="32" />
|
||||
<span class="muted ml-8">{{ strings.loading }}</span>
|
||||
</div>
|
||||
|
||||
<!-- Empty state -->
|
||||
<NcEmptyContent v-else-if="filteredHellos.length === 0" :title="strings.emptyTitle" :description="strings.emptyDesc"
|
||||
class="mt-16">
|
||||
<template #action>
|
||||
<NcButton @click="seedOne">{{ strings.addExample }}</NcButton>
|
||||
</template>
|
||||
</NcEmptyContent>
|
||||
|
||||
<!-- List -->
|
||||
<section v-else class="mt-16">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 50%">{{ strings.colMessage }}</th>
|
||||
<th style="width: 30%">{{ strings.colAt }}</th>
|
||||
<th style="width: 20%">{{ strings.colActions }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(hello, idx) in filteredHellos" :key="hello.id">
|
||||
<td class="ellipsis">
|
||||
<span class="mono">{{ hello.message }}</span>
|
||||
</td>
|
||||
<td class="nowrap">
|
||||
<NcDateTime v-if="hello.at" :timestamp="new Date(hello.at).valueOf()" />
|
||||
<span v-else class="muted">{{ strings.never }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="row gap-8">
|
||||
<NcButton type="tertiary" @click="duplicate(idx)">{{ strings.duplicate }}</NcButton>
|
||||
<NcButton type="error" @click="remove(idx)">{{ strings.remove }}</NcButton>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Footer actions -->
|
||||
<div class="row gap-12 mt-12">
|
||||
<NcButton type="secondary" @click="refresh" :disabled="loading">{{ strings.refresh }}</NcButton>
|
||||
<NcButton type="secondary" @click="clearAll" :disabled="loading || hellos.length === 0">
|
||||
{{ strings.clearAll }}
|
||||
</NcButton>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* Inner view rendered inside AppUserWrapper via <router-view>.
|
||||
* Matches your style: Options API, Nextcloud UI, axios, i18n placeholders.
|
||||
* Uses the Hello controller (GET/POST /hello).
|
||||
*/
|
||||
import NcButton from '@nextcloud/vue/components/NcButton'
|
||||
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
|
||||
import NcTextField from '@nextcloud/vue/components/NcTextField'
|
||||
import NcSelect from '@nextcloud/vue/components/NcSelect'
|
||||
import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent'
|
||||
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
|
||||
import NcDateTime from '@nextcloud/vue/components/NcDateTime'
|
||||
|
||||
import axios from '@nextcloud/axios'
|
||||
import { t, n } from '@nextcloud/l10n'
|
||||
|
||||
export default {
|
||||
name: 'AppUserHome',
|
||||
components: {
|
||||
NcButton,
|
||||
NcNoteCard,
|
||||
NcTextField,
|
||||
NcSelect,
|
||||
NcEmptyContent,
|
||||
NcLoadingIcon,
|
||||
NcDateTime,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
formOpen: true,
|
||||
|
||||
// Toolbar
|
||||
search: '',
|
||||
|
||||
// Form data
|
||||
name: '',
|
||||
themeLabel: null,
|
||||
themeOptions: [
|
||||
{ label: t('nextcloud-hello-world', 'Light'), value: 'light' },
|
||||
{ label: t('nextcloud-hello-world', 'Dark'), value: 'dark' },
|
||||
{
|
||||
label: n('nextcloud-hello-world', 'System (1 option)', 'System (%n options)', 2),
|
||||
value: 'system',
|
||||
},
|
||||
],
|
||||
|
||||
// List of "hellos"
|
||||
hellos: [],
|
||||
|
||||
strings: {
|
||||
// Toolbar
|
||||
searchLabel: t('nextcloud-hello-world', 'Search'),
|
||||
searchPlaceholder: t('nextcloud-hello-world', 'Filter messages…'),
|
||||
refresh: t('nextcloud-hello-world', 'Refresh'),
|
||||
showForm: t('nextcloud-hello-world', 'Show form'),
|
||||
hideForm: t('nextcloud-hello-world', 'Hide form'),
|
||||
|
||||
// Info
|
||||
quickHelp: t(
|
||||
'nextcloud-hello-world',
|
||||
'Use the form to post a hello. The list shows recent hellos fetched from the server. All user-visible text is centralized in {cStart}strings{cEnd}.',
|
||||
{ cStart: '<code>', cEnd: '</code>' },
|
||||
undefined,
|
||||
{ escape: false },
|
||||
),
|
||||
|
||||
// Form
|
||||
formHeader: t('nextcloud-hello-world', 'Say hello'),
|
||||
nameInputLabel: t('nextcloud-hello-world', 'Name'),
|
||||
nameInputPlaceholder: t('nextcloud-hello-world', 'e.g. Ada'),
|
||||
themeLabel: t('nextcloud-hello-world', 'Theme'),
|
||||
add: t('nextcloud-hello-world', 'Add'),
|
||||
clear: t('nextcloud-hello-world', 'Clear'),
|
||||
livePreview: t('nextcloud-hello-world', 'Preview:'),
|
||||
|
||||
// List
|
||||
loading: t('nextcloud-hello-world', 'Loading…'),
|
||||
emptyTitle: t('nextcloud-hello-world', 'No hellos yet'),
|
||||
emptyDesc: t('nextcloud-hello-world', 'Try adding one using the form above.'),
|
||||
addExample: t('nextcloud-hello-world', 'Add example'),
|
||||
colMessage: t('nextcloud-hello-world', 'Message'),
|
||||
colAt: t('nextcloud-hello-world', 'Time'),
|
||||
colActions: t('nextcloud-hello-world', 'Actions'),
|
||||
duplicate: t('nextcloud-hello-world', 'Duplicate'),
|
||||
remove: t('nextcloud-hello-world', 'Remove'),
|
||||
clearAll: t('nextcloud-hello-world', 'Clear all'),
|
||||
never: t('nextcloud-hello-world', 'Never'),
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.refresh()
|
||||
},
|
||||
computed: {
|
||||
themeOptionsLabels() {
|
||||
return this.themeOptions.map((x) => x.label)
|
||||
},
|
||||
activeTheme() {
|
||||
return this.themeOptions.find((x) => x.label === this.themeLabel) ?? this.themeOptions[0]
|
||||
},
|
||||
previewGreeting() {
|
||||
const n = this.name.trim()
|
||||
return n ? `Hello, ${n}!` : 'Hello!'
|
||||
},
|
||||
filteredHellos() {
|
||||
const q = this.search.trim().toLowerCase()
|
||||
if (!q) return this.hellos
|
||||
return this.hellos.filter((h) => h.message.toLowerCase().includes(q))
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
toggleForm() {
|
||||
this.formOpen = !this.formOpen
|
||||
},
|
||||
clearForm() {
|
||||
this.name = ''
|
||||
this.themeLabel = null
|
||||
},
|
||||
clearSearch() {
|
||||
this.search = ''
|
||||
},
|
||||
|
||||
async refresh() {
|
||||
try {
|
||||
this.loading = true
|
||||
// GET /hello -> { ocs: { data: { message, at } } }
|
||||
const resp = await axios.get('/hello')
|
||||
const data = resp?.data?.ocs?.data ?? {}
|
||||
if (data?.message) {
|
||||
this.hellos.unshift({
|
||||
id: genId(),
|
||||
message: data.message,
|
||||
at: data.at ?? null,
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to refresh', e)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
async addFromForm() {
|
||||
const name = this.name.trim()
|
||||
if (!name) return
|
||||
try {
|
||||
this.loading = true
|
||||
const payload = {
|
||||
name,
|
||||
theme: this.activeTheme.value,
|
||||
items: [],
|
||||
counter: 0,
|
||||
}
|
||||
// POST /hello -> { ocs: { data: { message, at } } }
|
||||
const resp = await axios.post('/hello', { data: payload })
|
||||
const data = resp?.data?.ocs?.data ?? {}
|
||||
const message = data?.message ?? `Hello, ${name}!`
|
||||
const at = data?.at ?? new Date().toISOString()
|
||||
this.hellos.unshift({ id: genId(), message, at })
|
||||
this.clearForm()
|
||||
this.formOpen = false
|
||||
} catch (e) {
|
||||
console.error('Failed to add hello', e)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
duplicate(index) {
|
||||
const src = this.hellos[index]
|
||||
if (!src) return
|
||||
this.hellos.splice(index + 1, 0, { ...src, id: genId() })
|
||||
},
|
||||
|
||||
remove(index) {
|
||||
this.hellos.splice(index, 1)
|
||||
},
|
||||
|
||||
clearAll() {
|
||||
this.hellos = []
|
||||
},
|
||||
|
||||
seedOne() {
|
||||
this.hellos.push({
|
||||
id: genId(),
|
||||
message: '👋 Hello example',
|
||||
at: new Date().toISOString(),
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
function genId() {
|
||||
return Math.random().toString(36).slice(2, 10)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.user-inner {
|
||||
.muted {
|
||||
color: var(--color-text-maxcontrast);
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.mono {
|
||||
font-family: var(--font-monospace);
|
||||
}
|
||||
|
||||
.mt-8 {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.mt-12 {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.mt-16 {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.ml-8 {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
|
||||
.toolbar-left,
|
||||
.toolbar-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
|
||||
&.align-start {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
&.align-center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
&.gap-8 {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
&.gap-12 {
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
&.gap-16 {
|
||||
gap: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
background: var(--color-main-background);
|
||||
}
|
||||
|
||||
.card-title {
|
||||
margin: 0 0 8px 0;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border: 1px solid var(--color-border);
|
||||
|
||||
thead tr,
|
||||
tr:not(:last-child) {
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
thead,
|
||||
tbody tr {
|
||||
display: table;
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
padding: 8px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ellipsis {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
7
src/vite-env.d.ts
vendored
Normal file
7
src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare module '@icons/*.vue' {
|
||||
import type { DefineComponent } from 'vue'
|
||||
const component: DefineComponent<object, object, unknown>
|
||||
export default component
|
||||
}
|
||||
11
templates/app.php
Normal file
11
templates/app.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
use OCA\NextcloudAppTemplate\AppInfo\Application;
|
||||
use OCP\Util;
|
||||
|
||||
/* @var array $_ */
|
||||
$script = $_['script'];
|
||||
Util::addScript(Application::APP_ID, Application::JS_DIR . "/nextcloudapptemplate-$script");
|
||||
Util::addStyle(Application::APP_ID, Application::CSS_DIR . '/nextcloudapptemplate-style');
|
||||
?>
|
||||
<div id="nextcloudapptemplate-app"></div>
|
||||
1
templates/settings.php
Normal file
1
templates/settings.php
Normal file
@@ -0,0 +1 @@
|
||||
<div id="nextcloudapptemplate-settings"></div>
|
||||
9
tests/bootstrap.php
Normal file
9
tests/bootstrap.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../../tests/bootstrap.php';
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
\OC_App::loadApp(OCA\NextcloudAppTemplate\AppInfo\Application::APP_ID);
|
||||
OC_Hook::clear();
|
||||
12
tests/phpunit.xml
Normal file
12
tests/phpunit.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="bootstrap.php" timeoutForSmallTests="900" timeoutForMediumTests="900" timeoutForLargeTests="900" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" cacheDirectory=".phpunit.cache">
|
||||
<testsuite name="Auto Currency Tests">
|
||||
<directory suffix="Test.php">.</directory>
|
||||
</testsuite>
|
||||
<source>
|
||||
<include>
|
||||
<directory suffix=".php">../appinfo</directory>
|
||||
<directory suffix=".php">../lib</directory>
|
||||
</include>
|
||||
</source>
|
||||
</phpunit>
|
||||
29
tests/unit/Controller/ApiTest.php
Normal file
29
tests/unit/Controller/ApiTest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Controller;
|
||||
|
||||
use OCA\NextcloudAppTemplate\AppInfo\Application;
|
||||
use OCA\NextcloudAppTemplate\Controller\ApiController;
|
||||
use OCA\NextcloudAppTemplate\Service\FetchCurrenciesService;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ApiTest extends TestCase {
|
||||
public function testIndex(): void {
|
||||
$request = $this->createMock(IRequest::class);
|
||||
$config = $this->createMock(IAppConfig::class);
|
||||
$l = $this->createMock(IL10N::class);
|
||||
$service = $this->createMock(FetchCurrenciesService::class);
|
||||
|
||||
$controller = new ApiController(Application::APP_ID, $request, $config, $l, $service);
|
||||
|
||||
$resp = $controller->getCronInfo()->getData();
|
||||
echo json_encode($resp);
|
||||
$this->assertEquals(null, $resp['last_update']);
|
||||
$this->assertEquals(0, $resp['interval']);
|
||||
}
|
||||
}
|
||||
24
tsconfig.app.json
Normal file
24
tsconfig.app.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||
"include": [
|
||||
"src/env.d.ts",
|
||||
"src/**/*.ts",
|
||||
"src/**/*.d.ts",
|
||||
"src/**/*.vue"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"allowJs": true,
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"paths": {
|
||||
"@icons/*": [
|
||||
"node_modules/vue-material-design-icons/*"
|
||||
],
|
||||
"@/*": [
|
||||
"src/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
7
tsconfig.json
Normal file
7
tsconfig.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
24
tsconfig.node.json
Normal file
24
tsconfig.node.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
10
vendor-bin/cs-fixer/composer.json
Normal file
10
vendor-bin/cs-fixer/composer.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"require-dev": {
|
||||
"nextcloud/coding-standard": "^1.2"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
16
vendor-bin/openapi-extractor/composer.json
Normal file
16
vendor-bin/openapi-extractor/composer.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/nextcloud/openapi-extractor"
|
||||
}
|
||||
],
|
||||
"require-dev": {
|
||||
"nextcloud/openapi-extractor": "dev-main"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
10
vendor-bin/phpunit/composer.json
Normal file
10
vendor-bin/phpunit/composer.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^10.5"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
10
vendor-bin/psalm/composer.json
Normal file
10
vendor-bin/psalm/composer.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"require-dev": {
|
||||
"vimeo/psalm": "^5.23"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
1
version.txt
Normal file
1
version.txt
Normal file
@@ -0,0 +1 @@
|
||||
0.0.0
|
||||
39
vite.config.ts
Normal file
39
vite.config.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { createAppConfig } from '@nextcloud/vite-config'
|
||||
import path from 'path'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default createAppConfig(
|
||||
{
|
||||
app: path.resolve(path.join('src', 'app.ts')),
|
||||
settings: path.resolve(path.join('src', 'settings.ts')),
|
||||
},
|
||||
{
|
||||
config: {
|
||||
root: 'src',
|
||||
resolve: {
|
||||
alias: {
|
||||
'@icons': path.resolve(__dirname, 'node_modules/vue-material-design-icons'),
|
||||
'@': path.resolve(__dirname, 'src'),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
outDir: '../dist',
|
||||
cssCodeSplit: false,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (id.includes('node_modules')) {
|
||||
if (id.includes('@nextcloud/dialogs')) return 'nextcloud-dialogs'
|
||||
if (id.includes('@nextcloud/vue')) return 'nextcloud-vue'
|
||||
if (id.includes('vue')) return 'vue'
|
||||
if (id.includes('vue-router')) return 'vue-router'
|
||||
if (id.includes('axios')) return 'axios'
|
||||
return 'vendor' // fallback for other deps
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user