From 7a03127ae12d40159cced20e91ce1b820868b5cf Mon Sep 17 00:00:00 2001 From: Toby Allen Date: Sun, 12 May 2024 18:55:12 +0100 Subject: [PATCH 1/3] allow changes to docto companion to be pushed --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 90bc197..04816ec 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,7 @@ test/Generated* test/InputFiles3* test/test1/* newdir2/ -/companion + /releases src/docto.exe *.rsm From 623e85d808cf89a33b88bd1060d4463840338c96 Mon Sep 17 00:00:00 2001 From: Toby Allen Date: Sun, 12 May 2024 19:09:48 +0100 Subject: [PATCH 2/3] New gather service --- companion/app/Services/FileGatherService.php | 26 +++++++++++++++++++ .../Remove/RemoveInputFilePestTest.php | 9 ++++--- .../output/OutputDirCreationPestTest.php | 7 +++++ 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 companion/app/Services/FileGatherService.php create mode 100644 companion/tests/Feature/output/OutputDirCreationPestTest.php diff --git a/companion/app/Services/FileGatherService.php b/companion/app/Services/FileGatherService.php new file mode 100644 index 0000000..285e2da --- /dev/null +++ b/companion/app/Services/FileGatherService.php @@ -0,0 +1,26 @@ +each(function ($dir) use ($tempDirName, $tempDirPath){ + $inputfilesdir = \Illuminate\Support\Facades\Storage::path('inputfiles\\' . $dir ); + $cmd = "xcopy \"$inputfilesdir\" \"$tempDirPath\\\" "; + $result = \Illuminate\Support\Facades\Process::run( $cmd ); + echo "\n" . $result->output() . "\n"; + }); + return collect(Storage::listContents($tempDirName)); + } + } diff --git a/companion/tests/Feature/Remove/RemoveInputFilePestTest.php b/companion/tests/Feature/Remove/RemoveInputFilePestTest.php index 8dd20b3..6e0cfc1 100644 --- a/companion/tests/Feature/Remove/RemoveInputFilePestTest.php +++ b/companion/tests/Feature/Remove/RemoveInputFilePestTest.php @@ -5,7 +5,7 @@ if (\Illuminate\Support\Facades\Storage::exists('inputfilestemp')){ \Illuminate\Support\Facades\Storage::deleteDirectory('inputfilestemp'); } - $testinputfilesdir = \Illuminate\Support\Facades\Storage::path('inputfiles\\plain'); + // $testinputfilesdir = \Illuminate\Support\Facades\Storage::path('inputfiles\\plain'); $testinputfilesdir_temp = \Illuminate\Support\Facades\Storage::path('inputfilestemp'); @@ -13,12 +13,13 @@ $testoutputdir_temp = \Illuminate\Support\Facades\Storage::path('outputtemp2'); // echo "\n". $testoutputdir_temp; \Illuminate\Support\Facades\Storage::createDirectory('outputtemp2'); - $cmd = "xcopy \"$testinputfilesdir\" \"$testinputfilesdir_temp\\\" "; + // $cmd = "xcopy \"$testinputfilesdir\" \"$testinputfilesdir_temp\\\" "; // echo "\n". $cmd; - $result = \Illuminate\Support\Facades\Process::run( $cmd ); + // $result = \Illuminate\Support\Facades\Process::run( $cmd ); //echo "\n" . $result->output() . "\n"; - $dirfiles = collect(\Illuminate\Support\Facades\Storage::listContents('inputfilestemp')); + // $dirfiles = collect(\Illuminate\Support\Facades\Storage::listContents('inputfilestemp')); + $dirfiles = \App\Services\FileGatherService::GatherFiles(collect(['plain']),'inputfilestemp'); $docfiles = $dirfiles->filter(function ($item){ return str($item->path())->endsWith('.doc'); }); diff --git a/companion/tests/Feature/output/OutputDirCreationPestTest.php b/companion/tests/Feature/output/OutputDirCreationPestTest.php new file mode 100644 index 0000000..b46239f --- /dev/null +++ b/companion/tests/Feature/output/OutputDirCreationPestTest.php @@ -0,0 +1,7 @@ +get('/'); + + $response->assertStatus(200); +}); From 342288bf0df1b923087980f68096f74b5c91ae57 Mon Sep 17 00:00:00 2001 From: Toby Allen Date: Sun, 12 May 2024 23:45:37 +0100 Subject: [PATCH 3/3] move config --- companion/config/services.php | 4 ++++ .../Feature/Remove/RemoveInputFilePestTest.php | 8 ++------ .../Feature/output/OutputDirCreationPestTest.php | 16 +++++++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/companion/config/services.php b/companion/config/services.php index 0ace530..d7fcf9a 100644 --- a/companion/config/services.php +++ b/companion/config/services.php @@ -14,6 +14,10 @@ | */ + 'docto' => [ + 'path' => env('DOCTO_PATH','..\\exe\\32\\docto.exe'), + ], + 'mailgun' => [ 'domain' => env('MAILGUN_DOMAIN'), 'secret' => env('MAILGUN_SECRET'), diff --git a/companion/tests/Feature/Remove/RemoveInputFilePestTest.php b/companion/tests/Feature/Remove/RemoveInputFilePestTest.php index 6e0cfc1..58d9bee 100644 --- a/companion/tests/Feature/Remove/RemoveInputFilePestTest.php +++ b/companion/tests/Feature/Remove/RemoveInputFilePestTest.php @@ -2,9 +2,6 @@ it('test deletes files from directory', function (){ // setup - if (\Illuminate\Support\Facades\Storage::exists('inputfilestemp')){ - \Illuminate\Support\Facades\Storage::deleteDirectory('inputfilestemp'); - } // $testinputfilesdir = \Illuminate\Support\Facades\Storage::path('inputfiles\\plain'); $testinputfilesdir_temp = \Illuminate\Support\Facades\Storage::path('inputfilestemp'); @@ -29,9 +26,8 @@ $dirfilescount = $dirfiles->count(); // do conversion - $doctocmd = <<output(); diff --git a/companion/tests/Feature/output/OutputDirCreationPestTest.php b/companion/tests/Feature/output/OutputDirCreationPestTest.php index b46239f..53b9066 100644 --- a/companion/tests/Feature/output/OutputDirCreationPestTest.php +++ b/companion/tests/Feature/output/OutputDirCreationPestTest.php @@ -1,7 +1,17 @@ get('/'); + use Illuminate\Support\Facades\Process; + + test('can create non existant directory', function () { + $gatherdir = uniqid(); + $outputdir = uniqid(); + $files = \App\Services\FileGatherService::GatherFiles(collect(['single']),$gatherdir); + $docto = config('services.docto.path'); + $inputdir = \Illuminate\Support\Facades\Storage::path($gatherdir); + $outputdir = \Illuminate\Support\Facades\Storage::path($outputdir); + $cmd = "$docto -WD -f $inputdir -o $outputdir -t wdFormatHTML"; + echo $cmd; + $output = Process::run($cmd); + expect(\Illuminate\Support\Facades\Storage::exists($outputdir))->toBeTrue(); - $response->assertStatus(200); });