mirror of
https://github.com/chenasraf/nextcloud-autocurrency.git
synced 2026-05-17 17:28:06 +00:00
chore: add generator files
This commit is contained in:
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: Chen Asraf <contact@casraf.dev>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\AutoCurrency\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();
|
||||
}
|
||||
}
|
||||
41
gen/gen/command/{{pascalCase name}}.php
Normal file
41
gen/gen/command/{{pascalCase name}}.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Chen Asraf <casraf@pm.me>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\AutoCurrency\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('autocurrency:{{kebabCase name}}');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
19
gen/gen/component/{{pascalCase name}}.vue
Normal file
19
gen/gen/component/{{pascalCase name}}.vue
Normal file
@@ -0,0 +1,19 @@
|
||||
<template>
|
||||
<div>{{ startCase name }}</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import NcComponentExample from '@nextcloud/vue/components/NcComponentExample'
|
||||
|
||||
//
|
||||
// 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: Chen Asraf <casraf@pm.me>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\AutoCurrency\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: Chen Asraf <contact@casraf.dev>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\AutoCurrency\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: Chen Asraf <contact@casraf.dev>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\AutoCurrency\Db;
|
||||
|
||||
use OCA\AutoCurrency\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);
|
||||
}
|
||||
}
|
||||
24
gen/gen/page/{{pascalCase name}}Page.vue
Normal file
24
gen/gen/page/{{pascalCase name}}Page.vue
Normal file
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<div class="autocurrency-{{ 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">
|
||||
/*
|
||||
#autocurrency-{{ 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: Chen Asraf <contact@casraf.dev>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\AutoCurrency\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: Chen Asraf <contact@casraf.dev>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\AutoCurrency\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: Chen Asraf <contact@casraf.dev>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\AutoCurrency\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: Chen Asraf <contact@casraf.dev>
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
namespace OCA\AutoCurrency\Util;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class {{pascalCase name}}Util {
|
||||
public function __construct(
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
// public function doSomething(): void {
|
||||
// // Do something
|
||||
// }
|
||||
}
|
||||
@@ -12,7 +12,8 @@
|
||||
"build": "vue-tsc -b && vite build",
|
||||
"lint": "eslint src",
|
||||
"format": "eslint --fix src && prettier --write src",
|
||||
"prepare": "husky"
|
||||
"prepare": "husky",
|
||||
"gen": "simple-scaffold -c . -k"
|
||||
},
|
||||
"browserslist": [
|
||||
"extends @nextcloud/browserslist-config"
|
||||
|
||||
Reference in New Issue
Block a user