Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvdlinde authored Mar 27, 2023
0 parents commit 7a317d3
Show file tree
Hide file tree
Showing 28 changed files with 1,105 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/autocomment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#bassed on https://github.com/marketplace/actions/auto-comment
name: Auto Comment
on: [issues, pull_request]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: wow-actions/auto-comment@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
issuesOpened: |
👋 @{{ author }}
Thank you for raising an issue. We will investigate the matter and get back to you as soon as possible.
Please make sure you have given us as much context as possible.
pullRequestOpenedReactions: 'hooray, +1'
pullRequestOpenedComment: |
👋 @{{ author }}
Thank you for raising your pull request.
Please make sure you have followed our contributing guidelines. We will review it as soon as possible. In the meanwhile make sure your PR checks the following boxes
- [ ] Is based on an issue
- [ ] Has been locally tested
- [ ] Has been tested with the admin UI
- [ ] Has been discussed with the development team in an open channel
26 changes: 26 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# .github/workflows/documentation.yml
name: Docs

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: php-actions/composer@v6
with:
php_version: "7.4"
php_extensions: redis exif
version: 2.x
command: require clean/phpdoc-md
- name: Build the docs
run: vendor/bin/phpdoc-md
- name: Git commit
run: |
git config user.name "GitHub Actions"
git config user.email ""
git add docs/classes
git commit -m "Update phpdoc" || echo "No changes to commit"
git push
14 changes: 14 additions & 0 deletions .github/workflows/generateFiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Generate publiccode.yaml and .env files

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
create:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Uses the default file creation workflow from https://github.com/CommonGateway/workflows
jobs:
call-file-creation-workflow-from-default-workflows:
uses: CommonGateway/workflows/.github/workflows/generateFilesForBundle.yml@main
26 changes: 26 additions & 0 deletions .github/workflows/phpcbf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: php-cbf

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: cs2pr, phpcbf

- name: Run phpcbf
run: phpcbf .
continue-on-error: true
- name: Git commit
run: |
git config user.name "GitHub Actions"
git config user.email ""
git add src
git commit -m "Update src from PHP Codesniffer" || echo "No changes to commit"
git push
17 changes: 17 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: php-cs

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: cs2pr, phpcs
- name: Run phpcs
run: phpcs -q --report=checkstyle . | cs2pr
17 changes: 17 additions & 0 deletions .github/workflows/phpmd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: php-md

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: cs2pr, phpmd
- name: Run phpmd
run: phpmd src github phpmd.xml --not-strict
18 changes: 18 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: php-unit

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: php-actions/composer@v6
with:
php_version: "7.4"
php_extensions: redis exif
version: 2.x
command: require symfony/test-pack
- name: Run tests
run: php bin/phpunit --coverage-text
28 changes: 28 additions & 0 deletions .github/workflows/remarklint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: remark-lint

on: [pull_request,push]

env: # environment variables (available in any part of the action)
NODE_VERSION: 16

jobs:
remark-lint:
name: runner / remark-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install remark presets
run: npm install remark-cli remark-preset-lint-consistent remark-preset-lint-recommended remark-lint-list-item-indent
shell: bash
- name: run remark
run: npx remark . --output --use remark-preset-lint-consistent --use remark-preset-lint-recommended --use remark-lint-list-item-indent
- name: Git commit
run: |
git config user.name "GitHub Actions"
git config user.email ""
git add .
git reset package.json
git reset package-lock.json
git reset node_modules
git commit -m "Update src from remark-lint" || echo "No changes to commit"
git push
46 changes: 46 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# .github/workflows/version.yml
name: Git Version

on:
push:
branches:
- master
- main

jobs:
release-managment:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }} # checkout the correct branch name
fetch-depth: 0 # fetch the whole repo history

#Based on https://github.com/marketplace/actions/git-version
- name: Git Version
id: version
uses: codacy/[email protected]
with:
release-branch: main

- name: Use the version
run: |
echo ${{ steps.version.outputs.version }}
#https://github.com/marketplace/actions/zip-release
- name: Archive Release
uses: thedoctor0/zip-release@main
with:
type: 'zip'
filename: 'release.zip'
exclusions: '*.git* /*node_modules/* .editorconfig'
#https://github.com/marvinpinto/action-automatic-releases
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ steps.version.outputs.version }}
prerelease: false
title: "Release ${{ steps.version.outputs.version }}"
files: |
LICENSE.md
release.zip
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
composer.lock

/vendor

.idea/
10 changes: 10 additions & 0 deletions .phpdoc-md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
return (object)[
'rootNamespace' => 'CommonGateway\PetStoreBundle',
'destDirectory' => 'docs/classes',
'format' => 'github',
'classes' => [
'\CommonGateway\PetStoreBundle\Service\InstallationService',
'\CommonGateway\PetStoreBundle\Service\PetStoreService'
],
];
10 changes: 10 additions & 0 deletions Installation/Data/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"https://opencatalogi.nl/example.schema.json": [
{
"_id": "906bd169-0256-433d-87be-4ed393a9511c",
"firstName": "John",
"lastName": "Doe",
"age": 21
}
]
}
22 changes: 22 additions & 0 deletions Installation/Schema/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$id": "https://opencatalogi.nl/example.schema.json",
"$schema": "https://docs.commongateway.nl/schemas/Entity.schema.json",
"version": "0.1",
"title": "Example",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name."
},
"age": {
"description": "Age in years which must be equal to or greater than zero.",
"type": "integer",
"minimum": 0
}
}
}
3 changes: 3 additions & 0 deletions Installation/installation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"installationService": "CommonGateway\\PetStoreBundle\\Service\\InstallationService"
}
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# PetStoreBundle [![Codacy Badge](https://app.codacy.com/project/badge/Grade/980ea2efc85a427ea909518f29506ff6)](https://app.codacy.com/gh/CommonGateway/PetStoreBundle/dashboard?utm_source=gh\&utm_medium=referral\&utm_content=\&utm_campaign=Badge_grade)

This repository is for creating PHP Symfony flex bundles. The Common Gateway ecosystem uses this template for rapid development to extend Gateway functionlity outside of the Core.

The first section is about installing plugins. The latter part is about custom plugins to extend Common Gateway functionality.

### Installation with the Common Gateway admin user-interface

Once a bundle is set up correctly (like this repository), the Common Gateway can discover the bundle without additional configuration. Head to the `Plugins` tab to search, select and install plugins.

#### Installing with PHP commands

To execute the following command, you will need [Composer](https://getcomposer.org/download/) or a dockerized installation that already has PHP and Composer.

The Composer method in the terminal and root folder:

> for the installation of the plugin
`$composer require common-gateway/pet-store-bundle:dev-main`

> for the installation of schemas
\`$php bin/console commongateway:install common-gateway/pet-store-bundle

The dockerized method in the terminal and root folder:

> for the installation of the plugin
`$docker-compose exec php composer require common-gateway/pet-store-bundle:dev-main`

> for the installation of schemas
`$docker-compose exec php bin/console commongateway:install common-gateway/pet-store-bundle`

***

## Creating your Bundle

This section is for developers who want to build plugins to extend Common Gateway functionality without adding to the core codebase.

The following knowledge is assumed and/or installed:

[Composer](https://getcomposer.org/download/)
[Packagist](https://packagist.org/)
[Docker](https://www.docker.com/products/docker-desktop/)
[Schema.json](https://json-schema.org/)
Basic knowledge of the [Common Gateway](https://github.com/CommonGateway)

### Using this template

This template is for rapid Symfony bundle development and meant as a model to base your custom plugin on. Follow the next steps to create your plugin within 45 minutes or less

1. Login on [GitHub](https://github.com)
2. Use [this template](https://github.com/CommonGateway/PetStoreBundle/generate)
3. Name your Bundle (CamelCase). The bundle needs to end with `Bundle` as per Symfony [naming](https://symfony.com/doc/current/bundles/best_practices.html#bundles-naming-conventions) conventions.
4. Press the green button `Create repository from template`
5. Update file names and namespace to your fitting :

* Open composer.json, and change the name to your fitting. The first word should be the namespace, and the second the bundle's name.

> Note: this is kebab-case. Also read: [naming your package](https://packagist.org/about#naming-your-package)
* Check the autoload field to be set accordingly.
* Open PetStoreBundle.php and change the Bundle `name` and `namespace`. The namespace should be the same as your package name in `composer.json` but in CamelCase. So `common-gateway/pet-store-bundle` becomes `CommonGateway/PetStoreBundle`
* Rename the `/Service` and `/ActionHandler` accordingly (or delete if not used).
* Rename the `/DependencyInjection/PetStoreExtension.php` to your `BundleNameExtension.php`
* Rename the `/Resources/config/services.yaml` namespaces

### Adding schemas

You can load [json schemas](https://json-schema.org/learn/getting-started-step-by-step.html#starting-the-schema) as Entities from your [`/Schema`](https://github.com/CommonGateway/PetStoreBundle/tree/main/Schema) folder to use in the Common Gateway and work with objects based on your schemas.

You can add existing schemas or create your own and add them to the`/Schema` folder. There is an example shown here in [`/Schema/example.json`](https://github.com/CommonGateway/PetStoreBundle/blob/main/Schema/example.json).

The following properties are required, and without them, the Gateway won't recognize the schema as valid:

- `version` can start on '0.1.0.'

> without this property, you can't update schemes
- `$schema` (https://json-schema.org/draft/2020-12/schema)
- `$id` (https://opencatalogi.nl/{Your scheme name}.schema.json)

> Unique `$id` to be relatable to other schemas.
- `type` must be 'object'
- `properties` must be schema properties

Once you add schemas to the repository, you can also add objects/data for those schemas. There is an example shown in the [`/Data`](https://github.com/CommonGateway/PetStoreBundle/tree/main/Data) folder.
Loading

0 comments on commit 7a317d3

Please sign in to comment.