Skip to content

Commit

Permalink
refactor dev to app root
Browse files Browse the repository at this point in the history
  • Loading branch information
jabberwoc committed Jan 26, 2024
1 parent e0a4f93 commit 1ece00a
Show file tree
Hide file tree
Showing 67 changed files with 224 additions and 12,479 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
# SPDX-License-Identifier: AGPL-3.0-or-later
*.iml
.idea
.idea
/.php-cs-fixer.cache
/.php_cs.cache
/build/
/vendor/
js/*hot-update.*
node_modules/
js/
File renamed without changes.
2 changes: 1 addition & 1 deletion test/.reuse/dep5 → .reuse/dep5
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Test
Upstream-Name: Template App
Upstream-Contact: Sebastian Stöcker <[email protected]>
Source: https://github.com/nextcloud/profiler

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Nextcloud app development example

This is an example nextcloud app development setup.

This repository features a [Docker Compose setup](dev/compose.yaml) to develop against a specific Nextcloud version and supports
hot module replacement of the app's frontend (Vue.js) components.

## Building the app

1. Install php dependencies:
```
make composer
```
2. Install npm dependencies:
```
npm ci
```

## Run the app

1. Start the webpack dev server (see [package.json](package.json) from your development IDE:
```
npm run serve
```
2. Start the Nextcloud Docker environment from the `dev` folder:
```
docker compose up -d
```

This starts the [nextcloud-docker-dev](https://github.com/juliushaertl/nextcloud-docker-dev) container.

## Enable apps

In order for Hot module replacement (HMR) to work the [HMR Enabler](https://github.com/nextcloud/hmr_enabler) app
which is already mounted into the container needs to be enabled.

1. Login to `http://localhost:8080` with user `admin` and password `admin`.
2. Go to _Apps_ and **HMR Enabler** and the **Template App**

You can now go the App's navigation item at the top to see the example app from the
[Nextcloud App Generator](https://apps.nextcloud.com/developer/apps/generate).

Changes to the Vue.js frontend code should now trigger the webpack-dev-server to rebuild the code and the browser to
reload the content.
16 changes: 8 additions & 8 deletions test/appinfo/info.xml → appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
SPDX-License-Identifier: CC0-1.0
-->
<id>test</id>
<name>Test</name>
<summary>Template app</summary>
<description><![CDATA[This is template app]]></description>
<id>templateapp</id>
<name>Template App</name>
<summary>Development example app</summary>
<description><![CDATA[Development example app]]></description>
<version>0.0.1</version>
<licence>agpl</licence>
<author mail="[email protected]" >Sebastian Stöcker</author>
<namespace>Test</namespace>
<namespace>TemplateApp</namespace>
<category>tools</category>
<bugs>https://github.com/diz-unimr/nc-template-app</bugs>
<bugs>https://github.com/diz-unimr/nc-app-template</bugs>
<dependencies>
<nextcloud min-version="27" max-version="27"/>
</dependencies>
<navigations>
<navigation>
<name>Test</name>
<route>test.page.index</route>
<name>Template App</name>
<route>templateapp.page.index</route>
</navigation>
</navigations>
</info>
2 changes: 1 addition & 1 deletion test/appinfo/routes.php → appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Create your routes in here. The name is the lowercase name of the controller
* without the controller part, the stuff after the hash is the method.
* e.g. page#index -> OCA\Test\Controller\PageController->index()
* e.g. page#index -> OCA\TemplateApp\Controller\PageController->index()
*
* The controller class has to be registered in the application.php file since
* it's instantiated in there
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions test/composer.json → composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nextcloud/test",
"description": "Template app",
"name": "nextcloud/templateapp",
"description": "Development example app",
"type": "project",
"license": "AGPL-3.0-or-later",
"authors": [
Expand All @@ -10,8 +10,6 @@
],
"require-dev": {
"phpunit/phpunit": "^9",
"sabre/dav": "^4.1",
"sabre/xml": "^2.2",
"symfony/event-dispatcher": "^5.3.11",
"nextcloud/ocp": "dev-stable27",
"psalm/phar": "^5.17.0",
Expand Down
4 changes: 2 additions & 2 deletions dev/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ services:
environment:
SERVER_BRANCH: v27.1.5
volumes:
- ./data/apps-extra:/var/www/html/apps-extra
- ./data/shared:/shared
- ../test:/var/www/html/apps-extra/test
- ./data/apps-extra/hmr_enabler:/var/www/html/apps-extra/hmr_enabler
- ../:/var/www/html/apps-extra/templateapp
ports:
- "8080:80"
extra_hosts:
Expand Down
Empty file removed dev/data/apps-extra/.gitkeep
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file removed dev/data/ssl/.gitkeep
Empty file.
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
// SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace OCA\Test\AppInfo;
namespace OCA\TemplateApp\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 = 'test';
public const APP_ID = 'templateapp';

public function __construct() {
parent::__construct(self::APP_ID);
Expand Down
4 changes: 2 additions & 2 deletions test/lib/Controller/Errors.php → lib/Controller/Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace OCA\Test\Controller;
namespace OCA\TemplateApp\Controller;

use Closure;

use OCA\Test\Service\NoteNotFound;
use OCA\TemplateApp\Service\NoteNotFound;
use OCP\AppFramework\Http;

use OCP\AppFramework\Http\DataResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace OCA\Test\Controller;
namespace OCA\TemplateApp\Controller;

use OCA\Test\AppInfo\Application;
use OCA\Test\Service\NoteService;
use OCA\TemplateApp\AppInfo\Application;
use OCA\TemplateApp\Service\NoteService;
use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace OCA\Test\Controller;
namespace OCA\TemplateApp\Controller;

use OCA\Test\AppInfo\Application;
use OCA\Test\Service\NoteService;
use OCA\TemplateApp\AppInfo\Application;
use OCA\TemplateApp\Service\NoteService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace OCA\Test\Controller;
namespace OCA\TemplateApp\Controller;

use OCA\Test\AppInfo\Application;
use OCA\TemplateApp\AppInfo\Application;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IRequest;
Expand All @@ -22,7 +22,7 @@ public function __construct(IRequest $request) {
* @NoCSRFRequired
*/
public function index(): TemplateResponse {
Util::addScript(Application::APP_ID, 'test-main');
Util::addScript(Application::APP_ID, 'templateapp-main');

return new TemplateResponse(Application::APP_ID, 'main');
}
Expand Down
2 changes: 1 addition & 1 deletion test/lib/Db/Note.php → lib/Db/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace OCA\Test\Db;
namespace OCA\TemplateApp\Db;

use JsonSerializable;

Expand Down
8 changes: 4 additions & 4 deletions test/lib/Db/NoteMapper.php → lib/Db/NoteMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace OCA\Test\Db;
namespace OCA\TemplateApp\Db;

use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\QBMapper;
Expand All @@ -16,7 +16,7 @@
*/
class NoteMapper extends QBMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'test', Note::class);
parent::__construct($db, 'templateapp', Note::class);
}

/**
Expand All @@ -27,7 +27,7 @@ public function find(int $id, string $userId): Note {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('test')
->from('templateapp')
->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
return $this->findEntity($qb);
Expand All @@ -41,7 +41,7 @@ public function findAll(string $userId): array {
/* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('test')
->from('templateapp')
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
return $this->findEntities($qb);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace OCA\Test\Migration;
namespace OCA\TemplateApp\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
Expand All @@ -23,8 +23,8 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

if (!$schema->hasTable('test')) {
$table = $schema->createTable('test');
if (!$schema->hasTable('templateapp')) {
$table = $schema->createTable('templateapp');
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
Expand All @@ -43,7 +43,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
]);

$table->setPrimaryKey(['id']);
$table->addIndex(['user_id'], 'test_user_id_index');
$table->addIndex(['user_id'], 'templateapp_user_id_index');
}
return $schema;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace OCA\Test\Service;
namespace OCA\TemplateApp\Service;

class NoteNotFound extends \Exception {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
// SPDX-FileCopyrightText: Sebastian Stöcker <[email protected]>
// SPDX-License-Identifier: AGPL-3.0-or-later

namespace OCA\Test\Service;
namespace OCA\TemplateApp\Service;

use Exception;

use OCA\Test\Db\Note;
use OCA\Test\Db\NoteMapper;
use OCA\TemplateApp\Db\Note;
use OCA\TemplateApp\Db\NoteMapper;

use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
Expand Down
Loading

0 comments on commit 1ece00a

Please sign in to comment.