Skip to content

Commit 4772e8a

Browse files
committed
Adds Dependabot configuration and updates the Sync command to copy the dependabot.yml file.
Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
1 parent be27d36 commit 4772e8a

3 files changed

Lines changed: 52 additions & 4 deletions

File tree

.github/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "composer"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
commit-message:
8+
prefix: "Composer"
9+
include: "scope"
10+
labels:
11+
- "composer"
12+
- "dependencies"
13+
14+
- package-ecosystem: "github-actions"
15+
directory: "/"
16+
schedule:
17+
interval: "weekly"
18+
commit-message:
19+
prefix: "GitHub Actions"
20+
include: "scope"
21+
labels:
22+
- "github-actions"
23+
- "continuous-integration"

bin/dev-tools.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818

1919
namespace FastForward\DevTools;
2020

21+
use Symfony\Component\Console\Input\ArgvInput;
22+
2123
$projectVendorAutoload = \dirname(__DIR__, 4) . '/vendor/autoload.php';
2224
$pluginVendorAutoload = \dirname(__DIR__) . '/vendor/autoload.php';
2325

2426
require_once file_exists($projectVendorAutoload) ? $projectVendorAutoload : $pluginVendorAutoload;
2527

2628
$application = new DevTools();
27-
$application->run();
29+
$application->run(new ArgvInput([...$argv, '--no-plugins']));

src/Command/SyncCommand.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
use Symfony\Component\Finder\Finder;
2727
use Symfony\Component\Process\Process;
2828

29+
use function Safe\file_get_contents;
30+
2931
/**
3032
* Represents the command responsible for installing development scripts into `composer.json`.
3133
* This class MUST NOT be overridden and SHALL rely on the `ScriptsInstallerTrait`.
@@ -70,6 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7072
$this->updateComposerJson();
7173
$this->createGitHubActionWorkflows();
7274
$this->copyEditorConfig();
75+
$this->copyDependabotConfig();
7376
$this->addRepositoryWikiGitSubmodule();
7477

7578
return self::SUCCESS;
@@ -91,7 +94,7 @@ private function updateComposerJson(): void
9194
return;
9295
}
9396

94-
$contents = $this->filesystem->readFile($file);
97+
$contents = file_get_contents($file);
9598
$manipulator = new JsonManipulator($contents);
9699

97100
$scripts = [
@@ -141,7 +144,7 @@ private function createGitHubActionWorkflows(): void
141144
continue;
142145
}
143146

144-
$content = $this->filesystem->readFile($file->getRealPath());
147+
$content = file_get_contents($file->getRealPath());
145148
$this->filesystem->dumpFile($targetPath, $content);
146149
}
147150
}
@@ -163,7 +166,27 @@ private function copyEditorConfig(): void
163166
return;
164167
}
165168

166-
$content = $this->filesystem->readFile($source);
169+
$content = file_get_contents($source);
170+
$this->filesystem->dumpFile($target, $content);
171+
}
172+
173+
/**
174+
* Installs the dependabot.yml configuration file in the .github directory if it does not exist.
175+
*
176+
* This method copies the dependabot.yml from the package resources to .github/dependabot.yml if it is not already present.
177+
*
178+
* @return void
179+
*/
180+
private function copyDependabotConfig(): void
181+
{
182+
$source = parent::getDevToolsFile('dependabot.yml');
183+
$target = parent::getConfigFile('.github/dependabot.yml', true);
184+
185+
if ($this->filesystem->exists($target)) {
186+
return;
187+
}
188+
189+
$content = file_get_contents($source);
167190
$this->filesystem->dumpFile($target, $content);
168191
}
169192

0 commit comments

Comments
 (0)