Compare commits
12 commits
Author | SHA1 | Date | |
---|---|---|---|
eb5ee10f70 | |||
51bb9927ff | |||
8d5effa151 | |||
82ba102094 | |||
c5dc5a6b88 | |||
7f10ecb7d3 | |||
df583e31d8 | |||
88147ec4e5 | |||
a186fcf721 | |||
bee4a6b5d8 | |||
41c23185c4 | |||
66e358b802 |
8 changed files with 79 additions and 2216 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
/vendor/
|
/vendor/
|
||||||
|
/composer.lock
|
||||||
|
|
14
.php_cs.dist
Normal file
14
.php_cs.dist
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$finder = PhpCsFixer\Finder::create()
|
||||||
|
->in(__DIR__)
|
||||||
|
->exclude(['fixtures']);
|
||||||
|
|
||||||
|
return PhpCsFixer\Config::create()
|
||||||
|
->setRules([
|
||||||
|
'@PSR2' => true,
|
||||||
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
|
'ordered_imports' => true,
|
||||||
|
'phpdoc_order' => true,
|
||||||
|
])
|
||||||
|
->setFinder($finder);
|
17
.travis.yml
Normal file
17
.travis.yml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
language: php
|
||||||
|
|
||||||
|
php:
|
||||||
|
- 7.2
|
||||||
|
- 7.3
|
||||||
|
- 7.4
|
||||||
|
|
||||||
|
env:
|
||||||
|
matrix:
|
||||||
|
- COMPOSER_FLAGS="--prefer-lowest"
|
||||||
|
- COMPOSER_FLAGS=""
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- composer install --dev --prefer-source --no-interaction
|
||||||
|
|
||||||
|
script:
|
||||||
|
- vendor/bin/phpunit
|
25
README.md
25
README.md
|
@ -1,7 +1,28 @@
|
||||||
# Drupal Module Generator (dmg)
|
# Drupal Module Generator (dmg)
|
||||||
|
|
||||||
A scaffolding tool for generating new modules for Drupal 7 and 8.
|
A scaffolding tool for generating new modules for Drupal 7 and (soon) 8.
|
||||||
|
|
||||||
|
[Watch a short demo][demo].
|
||||||
|
|
||||||
|
[demo]: https://opdavi.es/6i3YZ 'A short demo video on YouTube'
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
The Drupal Module Generator is installed via [Composer][]:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
composer global require opdavies/drupal-module-generator
|
||||||
|
```
|
||||||
|
|
||||||
|
[composer]: https://getcomposer.org
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
TODO
|
### Drupal 7
|
||||||
|
|
||||||
|
```bash
|
||||||
|
dmg generate:drupal-7-module {name}
|
||||||
|
```
|
||||||
|
|
||||||
|
Generated Drupal 7 modules contain the appropriately named `.info` and `.module` files,
|
||||||
|
as well as a test case located in `src/Tests/Functional` which [is loaded automatically](https://www.oliverdavies.uk/articles/psr4-autoloading-test-cases-drupal-7).
|
||||||
|
|
2
bin/dmg
2
bin/dmg
|
@ -13,7 +13,7 @@ if (file_exists(__DIR__.'/../../../autoload.php')) {
|
||||||
require __DIR__.'/../vendor/autoload.php';
|
require __DIR__.'/../vendor/autoload.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
$app = new Application();
|
$app = new Application('Drupal Module Generator');
|
||||||
|
|
||||||
$finder = new Finder();
|
$finder = new Finder();
|
||||||
$moduleNameConverter = new ModuleNameConverter();
|
$moduleNameConverter = new ModuleNameConverter();
|
||||||
|
|
|
@ -3,16 +3,17 @@
|
||||||
"description": "Generates boilerplate code for Drupal modules.",
|
"description": "Generates boilerplate code for Drupal modules.",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"symfony/console": "^3.0 || ^4.0 || ^5.0",
|
"php": "^7.2",
|
||||||
"symfony/dependency-injection": "^3.0 || ^4.0 || ^5.0",
|
"symfony/console": "^4.0 || ^5.0",
|
||||||
"symfony/filesystem": "^3.0 || ^4.0 || ^5.0",
|
"symfony/dependency-injection": "^4.0 || ^5.0",
|
||||||
"symfony/finder": "^3.0 || ^4.0 || ^5.0",
|
"symfony/filesystem": "^4.0 || ^5.0",
|
||||||
|
"symfony/finder": "^4.0 || ^5.0",
|
||||||
"tightenco/collect": "^6.14"
|
"tightenco/collect": "^6.14"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"php": "5.6 || ^7.0",
|
"friendsofphp/php-cs-fixer": "^2.16",
|
||||||
"phpunit/phpunit": "^9.0",
|
"phpunit/phpunit": "^8.5",
|
||||||
"symfony/var-dumper": "^3.0 || ^4.0 || ^5.0"
|
"symfony/var-dumper": "^4.0 || ^5.0"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
@ -35,6 +36,9 @@
|
||||||
"bin/dmg"
|
"bin/dmg"
|
||||||
],
|
],
|
||||||
"config": {
|
"config": {
|
||||||
|
"platform": {
|
||||||
|
"php": "7.2.5"
|
||||||
|
},
|
||||||
"sort-packages": true
|
"sort-packages": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2200
composer.lock
generated
2200
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -10,7 +10,6 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
|
||||||
use Symfony\Component\Finder\Finder;
|
use Symfony\Component\Finder\Finder;
|
||||||
use Symfony\Component\Finder\SplFileInfo;
|
use Symfony\Component\Finder\SplFileInfo;
|
||||||
use Tightenco\Collect\Support\Collection;
|
use Tightenco\Collect\Support\Collection;
|
||||||
|
@ -42,7 +41,7 @@ final class GenerateDrupal7Command extends Command
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected static $defaultName = 'generate-drupal-7-module';
|
protected static $defaultName = 'generate:drupal-7-module';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -50,8 +49,10 @@ final class GenerateDrupal7Command extends Command
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->setDescription('Generate a new Drupal 7 module.')
|
->setDescription('Generate a new Drupal 7 module')
|
||||||
->addArgument('module-name', InputArgument::REQUIRED, 'The name of the module to create');
|
->addArgument('module-name', InputArgument::REQUIRED, 'The name of the module to create')
|
||||||
|
->setAliases(['d7', 'drupal7'])
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,6 +62,8 @@ final class GenerateDrupal7Command extends Command
|
||||||
{
|
{
|
||||||
$this->io = new SymfonyStyle($input, $output);
|
$this->io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
|
$this->io->title("Drupal Module Generator (D7)");
|
||||||
|
|
||||||
$this->machineName = $input->getArgument('module-name');
|
$this->machineName = $input->getArgument('module-name');
|
||||||
$this->moduleName = $this->moduleNameConverter->__invoke($this->machineName);
|
$this->moduleName = $this->moduleNameConverter->__invoke($this->machineName);
|
||||||
$this->testName = $this->testNameConverter->__invoke($this->machineName);
|
$this->testName = $this->testNameConverter->__invoke($this->machineName);
|
||||||
|
@ -95,7 +98,6 @@ final class GenerateDrupal7Command extends Command
|
||||||
private function createFiles()
|
private function createFiles()
|
||||||
{
|
{
|
||||||
$createdFiles = new Collection();
|
$createdFiles = new Collection();
|
||||||
$testNameConverter = new TestNameConverter();
|
|
||||||
|
|
||||||
/** @var SplFileInfo $file */
|
/** @var SplFileInfo $file */
|
||||||
foreach ($this->finder->in(__DIR__.'/../../fixtures/drupal7_module')->files() as $file) {
|
foreach ($this->finder->in(__DIR__.'/../../fixtures/drupal7_module')->files() as $file) {
|
||||||
|
@ -115,7 +117,11 @@ final class GenerateDrupal7Command extends Command
|
||||||
$createdFiles->push($filename);
|
$createdFiles->push($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->io->listing($createdFiles->filter()->sort()->toArray());
|
if ($createdFiles->isNotEmpty()) {
|
||||||
|
$this->io->block('Files generated:');
|
||||||
|
|
||||||
|
$this->io->listing($createdFiles->sort()->toArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateFileContents($contents)
|
private function updateFileContents($contents)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue