Compare commits
No commits in common. "master" and "0.2.0" have entirely different histories.
8 changed files with 2216 additions and 79 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1 @@
|
||||||
/vendor/
|
/vendor/
|
||||||
/composer.lock
|
|
||||||
|
|
14
.php_cs.dist
14
.php_cs.dist
|
@ -1,14 +0,0 @@
|
||||||
<?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
17
.travis.yml
|
@ -1,17 +0,0 @@
|
||||||
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,28 +1,7 @@
|
||||||
# Drupal Module Generator (dmg)
|
# Drupal Module Generator (dmg)
|
||||||
|
|
||||||
A scaffolding tool for generating new modules for Drupal 7 and (soon) 8.
|
A scaffolding tool for generating new modules for Drupal 7 and 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
|
||||||
|
|
||||||
### Drupal 7
|
TODO
|
||||||
|
|
||||||
```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('Drupal Module Generator');
|
$app = new Application();
|
||||||
|
|
||||||
$finder = new Finder();
|
$finder = new Finder();
|
||||||
$moduleNameConverter = new ModuleNameConverter();
|
$moduleNameConverter = new ModuleNameConverter();
|
||||||
|
|
|
@ -3,17 +3,16 @@
|
||||||
"description": "Generates boilerplate code for Drupal modules.",
|
"description": "Generates boilerplate code for Drupal modules.",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2",
|
"symfony/console": "^3.0 || ^4.0 || ^5.0",
|
||||||
"symfony/console": "^4.0 || ^5.0",
|
"symfony/dependency-injection": "^3.0 || ^4.0 || ^5.0",
|
||||||
"symfony/dependency-injection": "^4.0 || ^5.0",
|
"symfony/filesystem": "^3.0 || ^4.0 || ^5.0",
|
||||||
"symfony/filesystem": "^4.0 || ^5.0",
|
"symfony/finder": "^3.0 || ^4.0 || ^5.0",
|
||||||
"symfony/finder": "^4.0 || ^5.0",
|
|
||||||
"tightenco/collect": "^6.14"
|
"tightenco/collect": "^6.14"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"friendsofphp/php-cs-fixer": "^2.16",
|
"php": "5.6 || ^7.0",
|
||||||
"phpunit/phpunit": "^8.5",
|
"phpunit/phpunit": "^9.0",
|
||||||
"symfony/var-dumper": "^4.0 || ^5.0"
|
"symfony/var-dumper": "^3.0 || ^4.0 || ^5.0"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
@ -36,9 +35,6 @@
|
||||||
"bin/dmg"
|
"bin/dmg"
|
||||||
],
|
],
|
||||||
"config": {
|
"config": {
|
||||||
"platform": {
|
|
||||||
"php": "7.2.5"
|
|
||||||
},
|
|
||||||
"sort-packages": true
|
"sort-packages": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2200
composer.lock
generated
Normal file
2200
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -10,6 +10,7 @@ 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;
|
||||||
|
@ -41,7 +42,7 @@ final class GenerateDrupal7Command extends Command
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected static $defaultName = 'generate:drupal-7-module';
|
protected static $defaultName = 'generate-drupal-7-module';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -49,10 +50,8 @@ 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'])
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,8 +61,6 @@ 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);
|
||||||
|
@ -98,6 +95,7 @@ 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) {
|
||||||
|
@ -117,11 +115,7 @@ final class GenerateDrupal7Command extends Command
|
||||||
$createdFiles->push($filename);
|
$createdFiles->push($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($createdFiles->isNotEmpty()) {
|
$this->io->listing($createdFiles->filter()->sort()->toArray());
|
||||||
$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