diff --git a/.github/workflows/after_spliting_test.yaml b/.github/workflows/after_splitting_test.yaml
similarity index 89%
rename from .github/workflows/after_spliting_test.yaml
rename to .github/workflows/after_splitting_test.yaml
index 19543bc2d..9995aa3e4 100644
--- a/.github/workflows/after_spliting_test.yaml
+++ b/.github/workflows/after_splitting_test.yaml
@@ -40,26 +40,34 @@ jobs:
name: After Split Testing of ${{ matrix.package_name }}
steps:
- - uses: actions/checkout@v2
- - uses: shivammathur/setup-php@v2
+
+ - name: Checkout
+ uses: 'actions/checkout@v2'
+
+ - name: PHP Setup
+ uses: 'shivammathur/setup-php@v2'
with:
php-version: '8.1'
coverage: none
+
- name: Setup MySQL
- uses: shogo82148/actions-setup-mysql@v1
+ uses: 'shogo82148/actions-setup-mysql@v1'
with:
mysql-version: 8.0
distribution: mysql
auto-start: true
+
- name: Create Database
run: |
mysql -h 127.0.0.1 -uroot -e "CREATE DATABASE draw"
+
- name: 'Composer Setup'
run: |
composer install --no-progress
vendor-bin/monorepo/vendor/bin/monorepo-builder localize-composer-paths
cd packages/${{ matrix.package_name }}
composer update --no-progress
+
- name: 'Automation Test'
run: |
cd packages/${{ matrix.package_name }}
diff --git a/app/src/Maker/MakeDrawPackage.php b/app/src/Maker/MakeDrawPackage.php
new file mode 100644
index 000000000..dc2468e04
--- /dev/null
+++ b/app/src/Maker/MakeDrawPackage.php
@@ -0,0 +1,157 @@
+addArgument('type', InputArgument::REQUIRED, 'The type of the package:: (component|bundle)')
+ ->addArgument('name', InputArgument::REQUIRED, 'The name of the package: Example: my-package')
+ ->addArgument('description', InputArgument::REQUIRED, 'The description of the package');
+ }
+
+ public function configureDependencies(DependencyBuilder $dependencies): void
+ {
+ }
+
+ public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void
+ {
+ $type = $input->getArgument('type');
+ $packageName = $input->getArgument('name');
+
+ if (!\in_array($type, ['component', 'bundle'])) {
+ $io->error('Invalid package type');
+
+ return;
+ }
+
+ if (empty($packageName)) {
+ $io->error('Invalid package name');
+
+ return;
+ }
+
+ if ('bundle' === $type) {
+ if (!str_ends_with($packageName, '-bundle')) {
+ $io->error('Package name should end with -bundle');
+
+ return;
+ }
+ } else {
+ if (str_ends_with($packageName, '-bundle')) {
+ $io->error('Package name should not end with -bundle');
+
+ return;
+ }
+ }
+
+ $namespace = $this->getNamespace($packageName, $type);
+
+ $generator
+ ->dumpFile(
+ 'packages/'.$packageName.'/composer.json',
+ $this->environment->render(
+ $this->environment->createTemplate(file_get_contents(__DIR__.'/../Resources/skeleton/draw-package/composer.json.twig')),
+ [
+ 'packageName' => $packageName,
+ 'packageDescription' => $input->getArgument('description'),
+ 'namespace' => $namespace,
+ 'type' => $type,
+ ]
+ )
+ );
+
+ $generator
+ ->dumpFile(
+ 'packages/'.$packageName.'/phpunit.xml.dist',
+ file_get_contents(__DIR__.'/../Resources/skeleton/draw-package/phpunit.xml.dist')
+ );
+
+ $generator
+ ->dumpFile(
+ $this->kernelProjectDir.'/composer.json',
+ $this->getNewComposerContents($packageName, $namespace)
+ );
+
+ $generator
+ ->dumpFile(
+ $this->kernelProjectDir.'/.github/workflows/after_splitting_test.yaml',
+ $this->getNewGithubWorkflowsAfterSplittingTestContents($packageName)
+ );
+
+ $generator->writeChanges();
+ }
+
+ private function getNewComposerContents(string $packageName, string $namespace): string
+ {
+ $composer = json_decode(
+ file_get_contents($this->kernelProjectDir.'/composer.json'),
+ true
+ );
+
+ $composer['autoload']['psr-4'][$namespace.'\\'] = 'packages/'.$packageName.'/';
+
+ ksort($composer['autoload']['psr-4']);
+
+ $composer['replace']['draw/'.$packageName] = 'self.version';
+
+ ksort($composer['replace']);
+
+ return json_encode($composer, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES);
+ }
+
+ private function getNewGithubWorkflowsAfterSplittingTestContents(string $packageName): string
+ {
+ $yamlSourceManipulator = new YamlSourceManipulator(
+ file_get_contents($this->kernelProjectDir.'/.github/workflows/after_splitting_test.yaml')
+ );
+
+ $data = $yamlSourceManipulator->getData();
+
+ // Sorting doesn't work with the current implementation of YamlSourceManipulator
+ $data['jobs']['after_split_testing']['strategy']['matrix']['package_name'][] = $packageName;
+
+ $yamlSourceManipulator->setData($data);
+
+ return $yamlSourceManipulator->getContents();
+ }
+
+ private function getNamespace(string $packageName, string $type): string
+ {
+ $namespace = str_replace('-', ' ', $packageName);
+ $namespace = ucwords($namespace);
+ $namespace = str_replace(' ', '', $namespace);
+
+ return sprintf(
+ 'Draw\%s\%s',
+ 'component' === $type ? 'Component' : 'Bundle',
+ $namespace
+ );
+ }
+}
diff --git a/app/src/Resources/skeleton/draw-package/composer.json.twig b/app/src/Resources/skeleton/draw-package/composer.json.twig
new file mode 100644
index 000000000..d4361c84a
--- /dev/null
+++ b/app/src/Resources/skeleton/draw-package/composer.json.twig
@@ -0,0 +1,31 @@
+{
+ "name": "draw/{{ packageName }}",
+ "description": "{{ packageDescription }}",
+ "license": "MIT",
+ "type": "library",
+ "keywords": ["draw", "{{ type }}", "symfony"],
+ "authors": [
+ {
+ "name": "Martin Poirier Theoret",
+ "email": "mpoiriert@gmail.com"
+ }
+ ],
+ "require": {
+ "php": ">=8.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^10.0"
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true,
+ "autoload": {
+ "psr-4": {
+ "{{ namespace|replace({'\\':'\\\\'}) }}\\": ""
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.11-dev"
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/Resources/skeleton/draw-package/phpunit.xml.dist b/app/src/Resources/skeleton/draw-package/phpunit.xml.dist
new file mode 100644
index 000000000..8f9f9f262
--- /dev/null
+++ b/app/src/Resources/skeleton/draw-package/phpunit.xml.dist
@@ -0,0 +1,9 @@
+
+
+
+ ./Tests
+
+
+
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 9efe1f960..29d380a67 100644
--- a/composer.json
+++ b/composer.json
@@ -286,4 +286,4 @@
"vendor/bin/phpstan analyse --generate-baseline"
]
}
-}
+}
\ No newline at end of file
diff --git a/composer.lock b/composer.lock
index 0e59a3bee..bc9b0f56a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "356d8fab8d8ca53c97e5c10fe73aaccf",
+ "content-hash": "88b2508d973c11c3ef04509b8036dd3f",
"packages": [
{
"name": "aws/aws-crt-php",
@@ -13952,6 +13952,98 @@
],
"time": "2024-01-23T14:51:35+00:00"
},
+ {
+ "name": "symfony/maker-bundle",
+ "version": "v1.58.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/maker-bundle.git",
+ "reference": "c4f8d2c5d55950e1a49e822efc83a8511bee8a36"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/maker-bundle/zipball/c4f8d2c5d55950e1a49e822efc83a8511bee8a36",
+ "reference": "c4f8d2c5d55950e1a49e822efc83a8511bee8a36",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/inflector": "^2.0",
+ "nikic/php-parser": "^4.18|^5.0",
+ "php": ">=8.1",
+ "symfony/config": "^6.4|^7.0",
+ "symfony/console": "^6.4|^7.0",
+ "symfony/dependency-injection": "^6.4|^7.0",
+ "symfony/deprecation-contracts": "^2.2|^3",
+ "symfony/filesystem": "^6.4|^7.0",
+ "symfony/finder": "^6.4|^7.0",
+ "symfony/framework-bundle": "^6.4|^7.0",
+ "symfony/http-kernel": "^6.4|^7.0",
+ "symfony/process": "^6.4|^7.0"
+ },
+ "conflict": {
+ "doctrine/doctrine-bundle": "<2.10",
+ "doctrine/orm": "<2.15"
+ },
+ "require-dev": {
+ "composer/semver": "^3.0",
+ "doctrine/doctrine-bundle": "^2.5.0",
+ "doctrine/orm": "^2.15|^3",
+ "symfony/http-client": "^6.4|^7.0",
+ "symfony/phpunit-bridge": "^6.4.1|^7.0",
+ "symfony/security-core": "^6.4|^7.0",
+ "symfony/yaml": "^6.4|^7.0",
+ "twig/twig": "^3.0|^4.x-dev"
+ },
+ "type": "symfony-bundle",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Bundle\\MakerBundle\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.",
+ "homepage": "https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html",
+ "keywords": [
+ "code generator",
+ "dev",
+ "generator",
+ "scaffold",
+ "scaffolding"
+ ],
+ "support": {
+ "issues": "https://github.com/symfony/maker-bundle/issues",
+ "source": "https://github.com/symfony/maker-bundle/tree/v1.58.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2024-04-06T15:08:12+00:00"
+ },
{
"name": "symfony/monolog-bridge",
"version": "v6.4.4",
diff --git a/config/bundles.php b/config/bundles.php
index c63f56b1b..7ff01a3e6 100644
--- a/config/bundles.php
+++ b/config/bundles.php
@@ -27,4 +27,5 @@
Draw\Bundle\SonataIntegrationBundle\DrawSonataIntegrationBundle::class => ['all' => true],
Draw\Bundle\FrameworkExtraBundle\DrawFrameworkExtraBundle::class => ['all' => true],
Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle::class => ['all' => true],
+ Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
];
diff --git a/doc/create-new-packages.md b/doc/create-new-packages.md
new file mode 100644
index 000000000..9dff6432a
--- /dev/null
+++ b/doc/create-new-packages.md
@@ -0,0 +1,109 @@
+# Create a new package
+
+This document describes how to create a new package for in the monorepo structure.
+
+In this example we will create a new package called `draw/demo` and the namespace will be `Draw\Component\Demo`.
+
+> Except for the first step, you can run `bin/console make:draw-package` to create the package.
+
+### Step 1: Create the draw/demo repository on Github
+
+The repository must be an exact match of the package name.
+
+## Step 2: Create the folder
+
+Create the folder `packages/demo` in the root of the repository.
+
+## Step 3: Adjust the replace section of the root composer.json
+
+Add the package to the replace section:
+
+```json
+{
+ "replace": {
+ "draw/demo": "self.version"
+ }
+}
+```
+
+This is necessary since the package is available in the main repository and should not be installed from packagist.
+
+## Step 4: Adjust the autoload section of the root composer.json
+
+Add the package to the autoload section:
+
+```json
+{
+ "autoload": {
+ "psr-4": {
+ "Draw\\Component\\DemoPackage\\": "packages/demo/"
+ }
+ }
+}
+```
+
+## Step 5: Create package folder
+
+### Step 5.1: `packages/demo/composer.json`
+
+```json
+{
+ "name": "draw/demo",
+ "description": "Demo package",
+ "license": "MIT",
+ "type": "library",
+ "keywords": ["draw", "demo"],
+ "authors": [
+ {
+ "name": "Martin Poirier Theoret",
+ "email": "mpoiriert@gmail.com"
+ }
+ ],
+ "require": {
+ "php": ">=8.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^10.0"
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true,
+ "autoload": {
+ "psr-4": {
+ "Draw\\Component\\Demo\\": "packages/demo/"
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.11-dev"
+ }
+ }
+}
+```
+
+### Step 5.2: `packages/demo/phpunit.xml.dist`
+
+```xml
+
+
+
+ ./Tests
+
+
+
+```
+
+### Step 6: Adjust github action build script
+
+Edit the `.github/workflows/after_splitting_test.yaml` to add the package in the matrix.
+
+```yaml
+jobs:
+ after_split_testing:
+ strategy:
+ matrix:
+ package_name:
+ - demo
+```
+
diff --git a/symfony.lock b/symfony.lock
index 0448dc18b..44bccb478 100644
--- a/symfony.lock
+++ b/symfony.lock
@@ -580,6 +580,15 @@
"config/packages/mailer.yaml"
]
},
+ "symfony/maker-bundle": {
+ "version": "1.58",
+ "recipe": {
+ "repo": "github.com/symfony/recipes",
+ "branch": "main",
+ "version": "1.0",
+ "ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
+ }
+ },
"symfony/messenger": {
"version": "5.3",
"recipe": {