diff --git a/src/HandlesGeneralScaffolding.php b/src/HandlesGeneralScaffolding.php index 5b5aad0..8b056f2 100644 --- a/src/HandlesGeneralScaffolding.php +++ b/src/HandlesGeneralScaffolding.php @@ -41,6 +41,22 @@ protected static function updateComposerPackageArray(array $composer, string $de ], $composer); } + protected static function updatePackagesScripts(): void + { + if (!file_exists(base_path('package.json'))) { + return; + } + + $packages = json_decode(file_get_contents(base_path('package.json')), true); + + ksort($packages['scripts']); + + file_put_contents( + base_path('package.json'), + json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL + ); + } + protected static function scaffoldDefaults(): void { $filesystem = new Filesystem(); diff --git a/src/TtallPreset.php b/src/TtallPreset.php index f2eca37..98165a6 100644 --- a/src/TtallPreset.php +++ b/src/TtallPreset.php @@ -38,22 +38,6 @@ class TtallPreset extends Preset 'lodash', ]; - const SCRIPTS_TO_ADD = [ - 'development' => 'mix', - 'watch' => 'mix watch', - 'watch-poll' => 'mix watch -- --watch-options-poll=1000', - 'hot' => 'mix watch --hot', - 'production' => 'mix --production', - ]; - - const SCRIPTS_TO_REMOVE = [ - 'development', - 'watch', - 'watch-poll', - 'hot', - 'production', - ]; - public static function install(): void { static::updatePackages(); @@ -94,25 +78,4 @@ protected static function updatePackageArray(array $packages, string $dev): arra Arr::except($packages, static::NPM_PACKAGES_TO_REMOVE) ); } - - protected static function updatePackagesScripts(): void - { - if (! file_exists(base_path('package.json'))) { - return; - } - - $packages = json_decode(file_get_contents(base_path('package.json')), true); - - $packages['scripts'] = array_merge( - static::SCRIPTS_TO_ADD, - Arr::except($packages['scripts'], static::SCRIPTS_TO_REMOVE) - ); - - ksort($packages['scripts']); - - file_put_contents( - base_path('package.json'), - json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL - ); - } }