chore: add generator files

This commit is contained in:
2025-06-18 09:43:52 +03:00
parent 323568c53d
commit acfdcfb2ec
12 changed files with 357 additions and 1 deletions

View 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();
}
}

View 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;
}
}

View 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>

View 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 {
}
}

View 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(),
];
}
}

View 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);
}
}

View 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>

View 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
// }
}

View 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']);
}
}

View 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']);
}
}

View 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
// }
}

View File

@@ -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"