Skip to content

Commit ed5e863

Browse files
author
mrazinshaikh
committed
allow option to run config:publish if not published already
1 parent 3eba181 commit ed5e863

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ A standalone migration tool using laravel illuminate/database.
2121
- expose artisan to vendor/bin folder. rename to migration.
2222
- attempt to use illuminate\database Create migration '\Illuminate\Database\Migrations\MigrationCreator'
2323

24+
- [ ] Add config:show command, to show parsed config.
25+
2426
- [ ] Extend migrate command to run specific migration file using --path option.
2527

2628
- [ ] Install [`nunomaduro/termwind`](https://github.com/nunomaduro/termwind)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mrazinshaikh/laravel-migration",
33
"description": "A standalone migration tool using laravel illuminate/database.",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"type": "library",
66
"license": "MIT",
77
"require": {

src/Commands/ConfigPublishCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function handle($options = [])
2929
$filesystem->makeDirectory($dir);
3030
}
3131
$filesystem->copy($source, $destination);
32+
info("Config file created. [$destination]");
3233
} else {
3334
warning("Config file already exists [$destination].");
3435
info('use --force option to publish again.');

src/config.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
'connection' => [
1515
'driver' => 'mysql',
1616
'host' => 'localhost',
17-
'database' => 'laravel-migration',
18-
'username' => 'root',
19-
'password' => '1234',
17+
'database' => 'laravel',
18+
'username' => '',
19+
'password' => '',
2020
'charset' => 'utf8',
2121
'collation' => 'utf8_unicode_ci',
2222
],

src/helpers.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
use Illuminate\Support\Str;
44
use Illuminate\Filesystem\Filesystem;
55
use Laravel\Prompts\Output\ConsoleOutput;
6+
use Mrazinshaikh\LaravelMigration\Commands\ConfigPublishCommand;
67

7-
use function Laravel\Prompts\error;
8+
use function Laravel\Prompts\{confirm, error};
89

910
if (! function_exists('extractTableName')) {
1011
function extractTableName(string $migrationName)
@@ -73,6 +74,10 @@ function config(?string $key = null, mixed $fallback = null): mixed
7374

7475
if (! $fs->exists(CONFIG_PATH)) {
7576
error('Config file not found on path [' . CONFIG_PATH . ']');
77+
if (confirm('Run config:publish command to publish config file?', default: false)) {
78+
(new ConfigPublishCommand)->handle();
79+
exit;
80+
}
7681
exit;
7782
}
7883
$config = require CONFIG_PATH;

0 commit comments

Comments
 (0)