Skip to content

Commit

Permalink
style: use app methods instead of functions (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
krissss authored Jan 6, 2025
1 parent 9e2c9d4 commit 6718f5f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 26 deletions.
13 changes: 8 additions & 5 deletions src/Components/Database/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function install(): void
$this->task(
'Creating a default SQLite database',
function () {
if (File::exists(database_path('database.sqlite'))) {
if (File::exists($this->app->databasePath('database.sqlite'))) {
return false;
}

Expand Down Expand Up @@ -107,24 +107,27 @@ function () {
$this->task(
'Creating default database configuration',
function () {
if (File::exists(config_path('database.php'))) {
if (File::exists($this->app->configPath('database.php'))) {
return false;
}

return File::copy(
self::CONFIG_FILE,
config_path('database.php')
$this->app->configPath('database.php')
);
}
);

$this->task(
'Updating .gitignore',
function () {
$gitignorePath = base_path('.gitignore');
$gitignorePath = $this->app->basePath('.gitignore');
if (File::exists($gitignorePath)) {
$contents = File::get($gitignorePath);
$neededLine = '/database/database.sqlite';
$neededLine = strtr($this->app->databasePath('database.sqlite'), [
$this->app->basePath() => '',
'\\' => '/',
]);
if (! Str::contains($contents, $neededLine)) {
File::append($gitignorePath, $neededLine.PHP_EOL);

Expand Down
10 changes: 5 additions & 5 deletions src/Components/Dotenv/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public function install(): void
$this->task(
'Creating .env',
function () {
if (! File::exists(base_path('.env'))) {
return File::put(base_path('.env'), 'CONSUMER_KEY=');
if (! File::exists($this->app->basePath('.env'))) {
return File::put($this->app->basePath('.env'), 'CONSUMER_KEY=');
}

return false;
Expand All @@ -51,8 +51,8 @@ function () {
$this->task(
'Creating .env.example',
function () {
if (! File::exists(base_path('.env.example'))) {
return File::put(base_path('.env.example'), 'CONSUMER_KEY=');
if (! File::exists($this->app->basePath('.env.example'))) {
return File::put($this->app->basePath('.env.example'), 'CONSUMER_KEY=');
}

return false;
Expand All @@ -62,7 +62,7 @@ function () {
$this->task(
'Updating .gitignore',
function () {
$gitignorePath = base_path('.gitignore');
$gitignorePath = $this->app->basePath('.gitignore');
if (File::exists($gitignorePath)) {
$contents = File::get($gitignorePath);
$neededLine = '.env';
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Log/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function install(): void
$this->task(
'Creating default logging configuration',
function () {
if (! File::exists(config_path('logging.php'))) {
if (! File::exists($this->app->configPath('logging.php'))) {
return File::copy(
static::CONFIG_FILE,
$this->app->configPath('logging.php')
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Queue/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function install(): void
$this->task(
'Creating default queue configuration',
function () {
if (! File::exists(config_path('queue.php'))) {
if (! File::exists($this->app->configPath('queue.php'))) {
return File::copy(
self::CONFIG_FILE,
$this->app->configPath('queue.php')
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Updater/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function register(): void
$this->app->singleton(Updater::class, function () use ($build) {
$updater = new PharUpdater($build->getPath(), false, PharUpdater::STRATEGY_GITHUB);

$composer = json_decode(file_get_contents(base_path('composer.json')), true);
$composer = json_decode(file_get_contents($this->app->basePath('composer.json')), true);
$name = $composer['name'];

$strategy = $this->app['config']->get('updater.strategy', GithubStrategy::class);
Expand Down
26 changes: 13 additions & 13 deletions src/Components/View/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public function install(): void
$this->task(
'Creating resources/views folder',
function () {
if (! File::exists(base_path('resources/views'))) {
File::makeDirectory(base_path('resources/views'), 0755, true, true);
if (! File::exists($this->app->resourcePath('views'))) {
File::makeDirectory($this->app->resourcePath('views'), 0755, true, true);

return true;
}
Expand All @@ -59,7 +59,7 @@ function () {
$this->task(
'Creating default view configuration',
function () {
if (! File::exists(config_path('view.php'))) {
if (! File::exists($this->app->configPath('view.php'))) {
return File::copy(
static::CONFIG_FILE,
$this->app->configPath('view.php')
Expand All @@ -73,26 +73,26 @@ function () {
$this->task(
'Creating cache storage folder',
function () {
if (File::exists(base_path('storage/app/.gitignore')) &&
File::exists(base_path('storage/framework/views/.gitignore'))
if (File::exists($this->app->storagePath('app/.gitignore')) &&
File::exists($this->app->storagePath('framework/views/.gitignore'))
) {
return false;
}

if (! File::exists(base_path('storage/app'))) {
File::makeDirectory(base_path('storage/app'), 0755, true, true);
if (! File::exists($this->app->storagePath('app'))) {
File::makeDirectory($this->app->storagePath('app'), 0755, true, true);
}

if (! File::exists(base_path('storage/app/.gitignore'))) {
File::append(base_path('storage/app/.gitignore'), "*\n!.gitignore");
if (! File::exists($this->app->storagePath('app/.gitignore'))) {
File::append($this->app->storagePath('app/.gitignore'), "*\n!.gitignore");
}

if (! File::exists(base_path('storage/framework/views'))) {
File::makeDirectory(base_path('storage/framework/views'), 0755, true, true);
if (! File::exists($this->app->storagePath('framework/views'))) {
File::makeDirectory($this->app->storagePath('framework/views'), 0755, true, true);
}

if (! File::exists(base_path('storage/framework/views/.gitignore'))) {
File::append(base_path('storage/framework/views/.gitignore'), "*\n!.gitignore");
if (! File::exists($this->app->storagePath('framework/views/.gitignore'))) {
File::append($this->app->storagePath('framework/views/.gitignore'), "*\n!.gitignore");
}

return true;
Expand Down

0 comments on commit 6718f5f

Please sign in to comment.