Skip to content

Commit

Permalink
Merge pull request #32 from askdkc/update-setup-command
Browse files Browse the repository at this point in the history
Update SetUp command
  • Loading branch information
askdkc authored Dec 11, 2022
2 parents c510f39 + 937d4ed commit e63208d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
14 changes: 13 additions & 1 deletion README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ QUEUE_CONNECTION=database

## セットアップコマンドの実行

以下のコマンドを実行すると必要なマイグレーションファイルおよび日本語版バリデーションファイルが自動生成されます
以下のコマンドを実行すると必要なマイグレーションファイル、configファイルおよび日本語版バリデーションファイルが自動生成されます

```bash
php artisan livecsv-setup
Expand Down Expand Up @@ -323,6 +323,16 @@ return [
|
*/
'layout' => 'tailwindcss',

/*
|--------------------------------------------------------------------------
| Default File Type
|--------------------------------------------------------------------------
|
| If you change file_type to tsv, it can handle tsv files.
|
*/
'file_type' => 'csv',

/*
|--------------------------------------------------------------------------
Expand All @@ -340,6 +350,8 @@ return [

`layout` オプションはCSSの選択肢となりますが、今のところ`tailwindcss`しか使えないので弄らないでください。将来別のCSSでこのパッケージ用のblade.phpを作った時にはここを変更するだけで切り替え可能に😏

`file_type` オプションはアップロードするファイルがCSVかTSVかを指定します。デフォルトはCSVですが、TSVにしたい場合は`tsv`に変更してください

`file_upload_size` はアップロードされるCSVファイルの最大サイズのバリデーションに使われます(初期値は約100MB)。Livewireを使っているので[livewire config](https://github.com/livewire/livewire/blob/master/config/livewire.php#L100) ファイルを変更して対応させることも可能です

オプションとして、CSVインポート用の画面のデザインを下記コマンドを実行して出力されるファイルから行うことができます
Expand Down
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
- [Introduction](#introduction)
- [Installation](#installation)
- [Setup Command](#setup-command)
- [Configuration](#configuration)
- [Usage](#usage)
- [CSV Importer Component](#csv-importer-component)
- [Button Component](#button-component)
Expand Down Expand Up @@ -41,7 +40,7 @@ composer require askdkc/livewire-csv

## Setup Command

You can run `livecsv-setup` command to publish nessesary migration files for this packkage.
You can run `livecsv-setup` command to publish nessesary migration files and config file for this packkage.

```bash
php artisan livecsv-setup
Expand Down Expand Up @@ -155,6 +154,16 @@ return [
|
*/
'layout' => 'tailwindcss',

/*
|--------------------------------------------------------------------------
| Default File Type
|--------------------------------------------------------------------------
|
| If you change file_type to tsv, it can handle tsv files.
|
*/
'file_type' => 'csv',

/*
|--------------------------------------------------------------------------
Expand All @@ -172,6 +181,8 @@ return [

The `layout` option is for choosing which CSS framework you are using and currently supports only `tailwindcss`. We are working on other CSS frameworks to implement in the future.

The `file_type` option is for choosing either CSV or TSV file. If your file is TSV type, change this to `tsv`.

The `file_upload_size` is for validation rules, and it defines the maximum file size of uploaded files. You may also define this value from the [livewire config](https://github.com/livewire/livewire/blob/master/config/livewire.php#L100) file.

Optionally, you can publish the views using
Expand Down
7 changes: 6 additions & 1 deletion src/Commands/LiveSetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function handle(): void
(new Filesystem)->ensureDirectoryExists(lang_path());
(new Filesystem)->copyDirectory(__DIR__.'/../../resources/lang/stub', lang_path());

$this->comment('Publishing Config file... / 設定ファイルを出力します');
$this->call('vendor:publish', [
'--tag' => 'livewire-csv-config',
]);

$this->info("Done! / 完了!");

if ($this->confirm('Would you like to run the migrations now? / マイグレーションを実行しますか?')) {
Expand All @@ -58,7 +63,7 @@ public function handle(): void
if (PHP_OS_FAMILY == 'Linux') {
exec("xdg-open {$repoUrl}");
}

$this->line('Thank you! / ありがとう💓');
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/SetupCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
$this->assertTrue($this->migrationExists('csv_imports_table'));
$this->assertTrue($this->migrationExists('create_jobs_table'));
$this->assertTrue($this->migrationExists('create_csv_imports_table'));
$this->assertFileExists(config_path('livewire_csv.php'));
$this->assertFileExists(lang_path('ja/validation.php'));
$this->assertFileExists(lang_path('ja.json'));
});
11 changes: 11 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ protected function setUp(): void
);

$this->registerLivewireComponents();

// コマンドが出力したファイルがテスト前に残っていたら消す
if (is_dir(__DIR__.'/../vendor/orchestra/testbench-core/laravel/lang/ja')) {
unlink(__DIR__.'/../vendor/orchestra/testbench-core/laravel/lang/ja.json');
unlink(__DIR__.'/../vendor/orchestra/testbench-core/laravel/lang/ja/validation.php');
rmdir(__DIR__.'/../vendor/orchestra/testbench-core/laravel/lang/ja');
}

if(is_file(__DIR__.'/../vendor/orchestra/testbench-core/laravel/configlivewire_csv.php')) {
unlink(__DIR__.'/../vendor/orchestra/testbench-core/laravel/configlivewire_csv.php');
}
}

protected function getPackageProviders($app)
Expand Down

0 comments on commit e63208d

Please sign in to comment.