Skip to content

Commit 3830c9b

Browse files
committed
Updates installation command to synchronize scripts, GitHub workflows, and .editorconfig files.
Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
1 parent f06e614 commit 3830c9b

7 files changed

Lines changed: 42 additions & 20 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ composer dev-tools wiki
5252
# Generate documentation frontpage and related reports
5353
composer dev-tools reports
5454

55-
# Installs and synchronizes development scripts in the root composer.json
56-
composer dev-tools install-scripts
55+
# Installs and synchronizes dev-tools scripts, GitHub Actions workflows, and .editorconfig
56+
composer dev-tools install
5757
```
5858

5959
## 📄 License

docs/running/specialized-commands.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ Structurally consolidates distinct reporting commands, accurately aggregating te
7373
7474
composer dev-tools reports
7575
76-
8. Install Scripts (``install-scripts``)
77-
----------------------------------------
76+
8. Install (``install``)
77+
------------------------
7878

79-
Adds or updates useful development tool scripts directly in your ``composer.json``, making it easier to standardize your team's workflow. This command ensures that all recommended scripts for QA and automation are present and up to date.
79+
Adds or updates dev-tools scripts in your ``composer.json``, copies reusable GitHub Actions workflows, and ensures the ``.editorconfig`` file is present and up to date. This command helps standardize your team's workflow and automation setup.
8080

8181
.. code-block:: bash
8282
83-
composer dev-tools install-scripts
83+
composer dev-tools install
Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* Represents the command responsible for installing development scripts into `composer.json`.
3030
* This class MUST NOT be overridden and SHALL rely on the `ScriptsInstallerTrait`.
3131
*/
32-
final class InstallScriptsCommand extends AbstractCommand
32+
final class InstallCommand extends AbstractCommand
3333
{
3434
/**
3535
* Configures the current command.
@@ -42,9 +42,9 @@ final class InstallScriptsCommand extends AbstractCommand
4242
protected function configure(): void
4343
{
4444
$this
45-
->setName('install-scripts')
46-
->setDescription('Installs and synchronizes development scripts in the root composer.json.')
47-
->setHelp('This command adds common development tool scripts to your composer.json file.');
45+
->setName('install')
46+
->setDescription('Installs and synchronizes dev-tools scripts, GitHub Actions workflows, and .editorconfig in the root project.')
47+
->setHelp('This command adds or updates dev-tools scripts in composer.json, copies reusable GitHub Actions workflows, and ensures .editorconfig is present and up to date.');
4848
}
4949

5050
/**
@@ -64,6 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6464

6565
$this->updateComposerJson();
6666
$this->createGitHubActionWorkflows();
67+
$this->copyEditorConfig();
6768

6869
return self::SUCCESS;
6970
}
@@ -120,7 +121,7 @@ private function updateComposerJson(): void
120121
*
121122
* @return void
122123
*/
123-
public function createGitHubActionWorkflows(): void
124+
private function createGitHubActionWorkflows(): void
124125
{
125126
$finder = Finder::create()
126127
->files()
@@ -138,4 +139,25 @@ public function createGitHubActionWorkflows(): void
138139
$this->filesystem->dumpFile($targetPath, $content);
139140
}
140141
}
142+
143+
/**
144+
* Installs or updates the .editorconfig file in the root project directory.
145+
*
146+
* This method copies the .editorconfig from the package resources to the project root,
147+
* always overwriting to ensure it is up to date.
148+
*
149+
* @return void
150+
*/
151+
private function copyEditorConfig(): void
152+
{
153+
$source = $this->getConfigFile('.editorconfig');
154+
$target = $this->getConfigFile('.editorconfig', true);
155+
156+
if ($this->filesystem->exists($target)) {
157+
return;
158+
}
159+
160+
$content = $this->filesystem->readFile($source);
161+
$this->filesystem->dumpFile($target, $content);
162+
}
141163
}

src/Composer/Capability/DevToolsCommandProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
use FastForward\DevTools\Command\StandardsCommand;
2929
use FastForward\DevTools\Command\TestsCommand;
3030
use FastForward\DevTools\Command\WikiCommand;
31-
use FastForward\DevTools\Command\InstallScriptsCommand;
31+
use FastForward\DevTools\Command\InstallCommand;
3232

3333
/**
3434
* Provides a registry of custom dev-tools commands mapped for Composer integration.
@@ -55,7 +55,7 @@ public function getCommands()
5555
new StandardsCommand(),
5656
new ReportsCommand(),
5757
new WikiCommand(),
58-
new InstallScriptsCommand(),
58+
new InstallCommand(),
5959
];
6060
}
6161
}

src/Composer/Plugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function onPostInstall(Event $event): void
7979
{
8080
$event->getComposer()
8181
->getEventDispatcher()
82-
->dispatchScript('install-scripts', true);
82+
->dispatchScript('install', true);
8383
}
8484

8585
/**
@@ -96,7 +96,7 @@ public function onPostUpdate(Event $event): void
9696
{
9797
$event->getComposer()
9898
->getEventDispatcher()
99-
->dispatchScript('install-scripts', true);
99+
->dispatchScript('install', true);
100100
}
101101

102102
/**

tests/Composer/Capability/DevToolsCommandProviderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use FastForward\DevTools\Command\AbstractCommand;
2222
use FastForward\DevTools\Command\CodeStyleCommand;
2323
use FastForward\DevTools\Command\DocsCommand;
24-
use FastForward\DevTools\Command\InstallScriptsCommand;
24+
use FastForward\DevTools\Command\InstallCommand;
2525
use FastForward\DevTools\Command\PhpDocCommand;
2626
use FastForward\DevTools\Command\RefactorCommand;
2727
use FastForward\DevTools\Command\ReportsCommand;
@@ -43,7 +43,7 @@
4343
#[UsesClass(StandardsCommand::class)]
4444
#[UsesClass(ReportsCommand::class)]
4545
#[UsesClass(WikiCommand::class)]
46-
#[UsesClass(InstallScriptsCommand::class)]
46+
#[UsesClass(InstallCommand::class)]
4747
final class DevToolsCommandProviderTest extends TestCase
4848
{
4949
private DevToolsCommandProvider $commandProvider;
@@ -72,7 +72,7 @@ public function getCommandsWillReturnAllSupportedCommandsInExpectedOrder(): void
7272
new StandardsCommand(),
7373
new ReportsCommand(),
7474
new WikiCommand(),
75-
new InstallScriptsCommand(),
75+
new InstallCommand(),
7676
],
7777
$this->commandProvider->getCommands(),
7878
);

tests/Composer/PluginTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function onPostInstallWillInstallScripts(): void
138138

139139
// Mock EventDispatcher
140140
$eventDispatcher = $this->prophesize(EventDispatcher::class);
141-
$eventDispatcher->dispatchScript('install-scripts', true)
141+
$eventDispatcher->dispatchScript('install', true)
142142
->willReturn(0);
143143
$this->composer->getEventDispatcher()
144144
->willReturn($eventDispatcher->reveal());
@@ -170,7 +170,7 @@ public function onPostUpdateWillInstallScripts(): void
170170

171171
// Mock EventDispatcher
172172
$eventDispatcher = $this->prophesize(EventDispatcher::class);
173-
$eventDispatcher->dispatchScript('install-scripts', true)
173+
$eventDispatcher->dispatchScript('install', true)
174174
->willReturn(0);
175175
$this->composer->getEventDispatcher()
176176
->willReturn($eventDispatcher->reveal());

0 commit comments

Comments
 (0)