Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
PavlosIsaris committed Feb 2, 2025
1 parent a2876e3 commit 288981e
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 172 deletions.
10 changes: 6 additions & 4 deletions configure.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php

const COMPOSER_JSON_FILE = __DIR__ . '/composer.json';

function ask(string $question, string $default = ''): string {
$answer = readline($question . ($default ? " ({$default})" : null) . ': ');

Expand Down Expand Up @@ -73,19 +75,19 @@ function remove_prefix(string $prefix, string $content): string {
}

function remove_composer_deps(array $names) {
$data = json_decode(file_get_contents(__DIR__ . '/composer.json'), true);
$data = json_decode(file_get_contents(COMPOSER_JSON_FILE), true);

foreach ($data['require-dev'] as $name => $version) {
if (in_array($name, $names, true)) {
unset($data['require-dev'][$name]);
}
}

file_put_contents(__DIR__ . '/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
file_put_contents(COMPOSER_JSON_FILE, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
}

function remove_composer_script($scriptName) {
$data = json_decode(file_get_contents(__DIR__ . '/composer.json'), true);
$data = json_decode(file_get_contents(COMPOSER_JSON_FILE), true);

foreach ($data['scripts'] as $name => $script) {
if ($scriptName === $name) {
Expand All @@ -94,7 +96,7 @@ function remove_composer_script($scriptName) {
}
}

file_put_contents(__DIR__ . '/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
file_put_contents(COMPOSER_JSON_FILE, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
}

function remove_readme_paragraphs(string $file): void {
Expand Down
Loading

0 comments on commit 288981e

Please sign in to comment.