Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:firefly-iii/data-importer into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
JC5 committed Nov 17, 2024
2 parents 45117d1 + 9a141f8 commit 5b8a4ec
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/Console/AutoImports.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,17 @@ private function importFile(string $directory, string $file): int

if (count($this->importErrors) > 0 || count($this->conversionRateLimits) > 0) {
app('log')->error(sprintf('Exit code is %s.', ExitCode::GENERAL_ERROR->name));

return ExitCode::GENERAL_ERROR->value;
}
if (0 === count($messages) && 0 === count($warnings) && 0 === count($errors)) {
app('log')->error(sprintf('Exit code is %s.', ExitCode::NOTHING_WAS_IMPORTED->name));

return ExitCode::NOTHING_WAS_IMPORTED->value;
}

app('log')->error(sprintf('Exit code is %s.', ExitCode::SUCCESS->name));

return ExitCode::SUCCESS->value;
}

Expand Down
6 changes: 6 additions & 0 deletions app/Console/Commands/AutoImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function handle(): int
if (false === $access) {
$this->error(sprintf('[a] No access, or no connection is possible to your local Firefly III instance at %s.', config('importer.url')));
app('log')->error(sprintf('Exit code is %s.', ExitCode::NO_CONNECTION->name));

return ExitCode::NO_CONNECTION->value;
}

Expand All @@ -72,12 +73,14 @@ public function handle(): int
if (false === $directory) {
$this->error(sprintf('Path "%s" is not a valid location.', $argument));
app('log')->error(sprintf('Exit code is %s.', ExitCode::INVALID_PATH->name));

return ExitCode::INVALID_PATH->value;
}
if (!$this->isAllowedPath($directory)) {
$this->error(sprintf('Path "%s" is not in the list of allowed paths (IMPORT_DIR_ALLOWLIST).', $directory));

app('log')->error(sprintf('Exit code is %s.', ExitCode::NOT_ALLOWED_PATH->name));

return ExitCode::NOT_ALLOWED_PATH->value;
}
$this->line(sprintf('Going to automatically import everything found in %s (%s)', $directory, $argument));
Expand All @@ -89,6 +92,7 @@ public function handle(): int
$this->info('https://docs.firefly-iii.org/');

app('log')->error(sprintf('Exit code is %s.', ExitCode::NO_FILES_FOUND->name));

return ExitCode::NO_FILES_FOUND->value;
}
$this->line(sprintf('Found %d (importable +) JSON file sets in %s', count($files), $directory));
Expand All @@ -105,9 +109,11 @@ public function handle(): int
$this->warn(sprintf('File %s returned code #%d', $file, $code));
}
app('log')->error(sprintf('Exit code is %s.', ExitCode::GENERAL_ERROR->name));

return ExitCode::GENERAL_ERROR->value;
}
app('log')->error(sprintf('Exit code is %s.', ExitCode::SUCCESS->name));

return ExitCode::SUCCESS->value;
}
}
7 changes: 6 additions & 1 deletion app/Console/Commands/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
use App\Exceptions\ImporterErrorException;
use App\Services\Shared\Configuration\Configuration;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

/**
* Class Import
Expand Down Expand Up @@ -71,6 +70,7 @@ public function handle(): int
if (false === $access) {
$this->error(sprintf('No access granted, or no connection is possible to your local Firefly III instance at %s.', config('importer.url')));
app('log')->error(sprintf('Exit code is %s.', ExitCode::NO_CONNECTION->name));

return ExitCode::NO_CONNECTION->value;
}

Expand All @@ -85,6 +85,7 @@ public function handle(): int
if (!$this->isAllowedPath($directory)) {
$this->error(sprintf('Path "%s" is not in the list of allowed paths (IMPORT_DIR_ALLOWLIST).', $directory));
app('log')->error(sprintf('Exit code is %s.', ExitCode::INVALID_PATH->name));

return ExitCode::INVALID_PATH->value;
}
}
Expand All @@ -95,6 +96,7 @@ public function handle(): int
if (!$this->isAllowedPath($directory)) {
$this->error(sprintf('Path "%s" is not in the list of allowed paths (IMPORT_DIR_ALLOWLIST).', $directory));
app('log')->error(sprintf('Exit code is %s.', ExitCode::NOT_ALLOWED_PATH->name));

return ExitCode::NOT_ALLOWED_PATH->value;
}
}
Expand All @@ -104,6 +106,7 @@ public function handle(): int
$this->error($message);
app('log')->error($message);
app('log')->error(sprintf('Exit code is %s.', ExitCode::CANNOT_READ_CONFIG->name));

return ExitCode::CANNOT_READ_CONFIG->value;
}

Expand All @@ -112,6 +115,7 @@ public function handle(): int
$message = 'The importer can\'t import: could not decode the JSON in the config file.';
$this->error($message);
app('log')->error(sprintf('Exit code is %s.', ExitCode::CANNOT_PARSE_CONFIG->name));

return ExitCode::CANNOT_PARSE_CONFIG->value;
}
$configuration = Configuration::fromArray(json_decode(file_get_contents($config), true));
Expand All @@ -121,6 +125,7 @@ public function handle(): int
app('log')->error($message);

app('log')->error(sprintf('Exit code is %s.', ExitCode::IMPORTABLE_FILE_NOT_FOUND->name));

return ExitCode::IMPORTABLE_FILE_NOT_FOUND->value;
}

Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5b8a4ec

Please sign in to comment.