diff --git a/gen/gen/api/{{pascalCase name}}Controller.php b/gen/gen/api/{{pascalCase name}}Controller.php new file mode 100644 index 0000000..4bc4da1 --- /dev/null +++ b/gen/gen/api/{{pascalCase name}}Controller.php @@ -0,0 +1,44 @@ + +// 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 + * + * 200: Data returned + */ + #[ApiRoute(verb: 'GET', url: '/api/{{kebabCase name}}')] + public function index(): JSONResponse { + return new JSONResponse(); + } +} diff --git a/gen/gen/command/{{pascalCase name}}.php b/gen/gen/command/{{pascalCase name}}.php new file mode 100644 index 0000000..991f346 --- /dev/null +++ b/gen/gen/command/{{pascalCase name}}.php @@ -0,0 +1,41 @@ + + * 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; + } +} diff --git a/gen/gen/component/{{pascalCase name}}.vue b/gen/gen/component/{{pascalCase name}}.vue new file mode 100644 index 0000000..48af6a0 --- /dev/null +++ b/gen/gen/component/{{pascalCase name}}.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/gen/gen/migration/Version{{version}}Date{{dt}}.php b/gen/gen/migration/Version{{version}}Date{{dt}}.php new file mode 100644 index 0000000..24265a6 --- /dev/null +++ b/gen/gen/migration/Version{{version}}Date{{dt}}.php @@ -0,0 +1,48 @@ + + * 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 { + } +} diff --git a/gen/gen/model/{{pascalCase name}}.php b/gen/gen/model/{{pascalCase name}}.php new file mode 100755 index 0000000..9b60fdf --- /dev/null +++ b/gen/gen/model/{{pascalCase name}}.php @@ -0,0 +1,30 @@ + +// 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(), + ]; + } +} diff --git a/gen/gen/model/{{pascalCase name}}Mapper.php b/gen/gen/model/{{pascalCase name}}Mapper.php new file mode 100755 index 0000000..916a0ef --- /dev/null +++ b/gen/gen/model/{{pascalCase name}}Mapper.php @@ -0,0 +1,52 @@ + +// 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); + } +} diff --git a/gen/gen/page/{{pascalCase name}}Page.vue b/gen/gen/page/{{pascalCase name}}Page.vue new file mode 100644 index 0000000..002631b --- /dev/null +++ b/gen/gen/page/{{pascalCase name}}Page.vue @@ -0,0 +1,24 @@ + + + + + diff --git a/gen/gen/service/{{pascalCase name}}Service.php b/gen/gen/service/{{pascalCase name}}Service.php new file mode 100644 index 0000000..af74544 --- /dev/null +++ b/gen/gen/service/{{pascalCase name}}Service.php @@ -0,0 +1,22 @@ + +// 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 + // } +} diff --git a/gen/gen/task-queued/{{pascalCase name}}Task.php b/gen/gen/task-queued/{{pascalCase name}}Task.php new file mode 100644 index 0000000..90e3692 --- /dev/null +++ b/gen/gen/task-queued/{{pascalCase name}}Task.php @@ -0,0 +1,25 @@ + +// 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']); + } +} diff --git a/gen/gen/task-timed/{{pascalCase name}}Task.php b/gen/gen/task-timed/{{pascalCase name}}Task.php new file mode 100644 index 0000000..0d46f59 --- /dev/null +++ b/gen/gen/task-timed/{{pascalCase name}}Task.php @@ -0,0 +1,28 @@ + +// 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']); + } +} diff --git a/gen/gen/util/{{pascalCase name}}Util.php b/gen/gen/util/{{pascalCase name}}Util.php new file mode 100644 index 0000000..5523e61 --- /dev/null +++ b/gen/gen/util/{{pascalCase name}}Util.php @@ -0,0 +1,22 @@ + +// 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 + // } +} diff --git a/package.json b/package.json index d5d0530..891be3e 100644 --- a/package.json +++ b/package.json @@ -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"