Skip to content

Commit 97c6dfc

Browse files
authored
Merge pull request #3 from prismosoft/prismosoft-patch-1
fix: stop overwriting user controller; publish + one-time seed
2 parents 76beab8 + 2fcb37e commit 97c6dfc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/KeysmithReactServiceProvider.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,25 @@ public function boot()
1818
require __DIR__.'/../routes/web.php';
1919
});
2020

21-
if ($this->app->runningInConsole()) {
21+
if ($this->app->runningInConsole()) {
2222
$this->publishes([
2323
__DIR__.'/../config/config.php' => config_path('keysmith.php'),
2424
], 'keysmith-config');
2525

26-
(new Filesystem)->ensureDirectoryExists(app_path('Http/Controllers/APITokens'));
27-
(new Filesystem)->copy(__DIR__.'/../stubs/app/Http/Controllers/APITokens/TokenController.php', app_path('Http/Controllers/APITokens/TokenController.php'));
26+
$fs = new Filesystem();
27+
$source = __DIR__.'/../stubs/app/Http/Controllers/APITokens/TokenController.php';
28+
$target = app_path('Http/Controllers/APITokens/TokenController.php');
29+
30+
// Publish mapping so users can explicitly re-publish if needed
31+
$this->publishes([
32+
$source => $target,
33+
], 'keysmith-controllers');
34+
35+
// One-time seed for fresh installs only (do NOT overwrite user code)
36+
if (! $fs->exists($target)) {
37+
$fs->ensureDirectoryExists(dirname($target));
38+
$fs->copy($source, $target);
39+
}
2840
}
2941

3042
$this->commands([

0 commit comments

Comments
 (0)