Skip to content

Commit

Permalink
Initial upload (still WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-meyer committed Jan 3, 2024
1 parent 121cdf8 commit 0458364
Show file tree
Hide file tree
Showing 37 changed files with 8,165 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: sebastian-meyer
custom: "https://paypal.me/sebastianmeyer"
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "weekly"
assignees:
- "sebastian-meyer"
labels: [ ]
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
assignees:
- "sebastian-meyer"
labels: [ ]
40 changes: 40 additions & 0 deletions .github/workflows/phpmd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: PHP Mess Detector

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
PHPMD:
name: PHPMD Scanner
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read

steps:
- name: Checkout Source Code
uses: actions/checkout@v4

- name: Setup Environment
uses: shivammathur/setup-php@v2
with:
php-version: "8.0"
coverage: none
tools: phpmd

- name: Run PHPMD
run: phpmd . sarif codesize --reportfile phpmd-results.sarif
continue-on-error: true

- name: Upload Analysis Results
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: phpmd-results.sarif
wait-for-processing: true
35 changes: 35 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: PHP Static Analyzer

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
PHPStan:
name: PHPStan Scanner
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read

steps:
- name: Checkout Source Code
uses: actions/checkout@v4

- name: Setup Environment
uses: php-actions/composer@v6
with:
command: update
php_version: "8.0"

- name: Run PHPStan
uses: php-actions/phpstan@v3
with:
path: src/
configuration: phpstan.dist.neon
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
composer.phar
/.vscode/
/config/config.yml
/data/
/var/
/vendor/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
.php-cs-fixer.php
phpstan.neon
38 changes: 38 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/**
* Useful PHP Basics
* Copyright (C) 2023 Sebastian Meyer <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace PhpCsFixer;

/**
* Configuration for PHP-CS-Fixer.
* @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/config.rst
*
* @return ConfigInterface
*/
return (new Config())
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
])
->setFinder(
(new Finder())->in(__DIR__)
);
55 changes: 55 additions & 0 deletions bin/cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env php
<?php

/**
* OAI-PMH 2.0 Data Provider
* Copyright (C) 2023 Sebastian Meyer <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

declare(strict_types=1);

namespace OCC\OaiPmh2;

use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider;
use Exception;
use OCC\OaiPmh2\Console\AddRecordCommand;
use OCC\OaiPmh2\Console\BulkUpdateCommand;
use OCC\OaiPmh2\Console\DeleteRecordCommand;
use OCC\OaiPmh2\Console\PruneResumptionTokensCommand;
use OCC\OaiPmh2\Console\UpdateFormatsCommand;

require __DIR__ . '/../vendor/autoload.php';

$commands = [
new AddRecordCommand(),
new BulkUpdateCommand(),
new DeleteRecordCommand(),
new PruneResumptionTokensCommand(),
new UpdateFormatsCommand()
];

try {
ConsoleRunner::run(
new SingleManagerProvider(
Database::getInstance()->getEntityManager()
),
$commands
);
} catch (Exception $exception) {
echo '[ERROR] Exception ' . $exception->getCode() . ' thrown:' . PHP_EOL;
echo $exception->getMessage() . PHP_EOL;
}
86 changes: 86 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"name": "opencultureconsulting/oai-pmh2",
"description": "This is a stand-alone OAI-PMH 2.0 data provider. It serves records in any XML metadata format from a database, supports deleted records, resumption tokens and sets.",
"type": "project",
"keywords": [
"oai",
"oaipmh",
"oaipmh2",
"oai-pmh",
"oai-pmh2",
"code4lib"
],
"homepage": "https://github.com/opencultureconsulting/oai-pmh2",
"readme": "README.md",
"license": ["GPL-3.0-or-later"],
"authors": [
{
"name": "Sebastian Meyer",
"email": "[email protected]",
"homepage": "https://www.opencultureconsulting.com",
"role": "maintainer"
}
],
"support": {
"issues": "https://github.com/opencultureconsulting/oai-pmh2/issues",
"source": "https://github.com/opencultureconsulting/oai-pmh2",
"docs": "https://github.com/opencultureconsulting/oai-pmh2/blob/main/README.md"
},
"require": {
"php": "^8.1",
"ext-dom": "*",
"ext-libxml": "*",
"ext-sqlite3": "*",
"doctrine/dbal": "^3.7",
"doctrine/orm": "^2.17",
"opencultureconsulting/basics": "^1.0",
"opencultureconsulting/psr15": "^1.0",
"symfony/cache": "^6.4",
"symfony/console": "^6.4",
"symfony/filesystem": "^6.4",
"symfony/serializer":"^6.4",
"symfony/validator": "^6.4",
"symfony/yaml": "^6.4"
},
"require-dev": {
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-strict-rules": "^1.5",
"friendsofphp/php-cs-fixer": "^3.45"
},
"autoload": {
"psr-4": {
"OCC\\OaiPmh2\\": "src/"
}
},
"scripts": {
"pre-install-cmd": [
"@php -r \"!is_dir('./data') && mkdir('./data', 0775);\"",
"@php -r \"!file_exists('./config/config.yml') && copy('./config/config.dist.yml', './config/config.yml');\""
],
"post-install-cmd": [
"@doctrine:clear-cache --quiet",
"@php bin/cli orm:generate-proxies --quiet"
],
"post-create-project-cmd": [
"@doctrine:initialize-database --quiet"
],
"doctrine:clear-cache": [
"@php bin/cli orm:clear-cache:metadata --flush",
"@php bin/cli orm:clear-cache:query --flush",
"@php bin/cli orm:clear-cache:result --flush"
],
"doctrine:initialize-database": [
"@php bin/cli orm:schema-tool:update --complete --force",
"@oai:update-formats --quiet"
],
"oai:update-formats": [
"@php bin/cli oai:formats:update"
]
},
"scripts-descriptions": {
"doctrine:clear-cache": "Clears the Doctrine/ORM metadata, query and result caches",
"doctrine:generate-proxies": "Generates the Doctrine/ORM entity proxies",
"doctrine:initialize-database": "Initializes a new database (NOT RECOMMENDED IN PRODUCTION!)",
"oai:update-formats": "Updates supported metadata formats from configuration"
}
}
Loading

0 comments on commit 0458364

Please sign in to comment.