Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,28 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [8.2, 8.1, 8.0]
laravel: [9.*]
php: [8.4, 8.3]
laravel: [13.*, 12.*]
dependency-version: [prefer-stable]
include:
- laravel: 9.*
testbench: 7.*
- laravel: 12.*
testbench: 10.*
- laravel: 13.*
testbench: 11.*

steps:
- uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: ${{ matrix.php }}
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v4
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
run: ./vendor/bin/phpstan analyse --error-format=github
29 changes: 8 additions & 21 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.4, 8.3, 8.2, 8.1]
laravel: [10.*, 9.*]
php: [8.5, 8.4, 8.3]
laravel: [13.*, 12.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 9.*
testbench: 7.*
carbon: ^2.63
- laravel: 10.*
testbench: 8.*
carbon: ^2.63
exclude:
- laravel: 10.*
php: 8.0
- laravel: 12.*
testbench: 10.*
- laravel: 13.*
testbench: 11.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand All @@ -40,24 +35,16 @@ jobs:
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Set Minimum PHP 8.2 Versions
uses: nick-fields/retry@v4
with:
timeout_minutes: 5
max_attempts: 5
command: composer require guzzlehttp/psr7:~2.4 --no-interaction --no-update
if: matrix.php >= 8.2

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "nesbot/carbon:${{ matrix.carbon }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: List Installed Dependencies
run: composer show -D

- name: Execute tests
run: vendor/bin/pest
run: vendor/bin/pest
4 changes: 3 additions & 1 deletion classAliases.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?php

class_alias(\Askdkc\LivewireCsv\LivewireCsvManager::class, 'livewire-csv');
use Askdkc\LivewireCsv\LivewireCsvManager;

class_alias(LivewireCsvManager::class, 'livewire-csv');
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
}
],
"require": {
"php": "^8.0",
"illuminate/contracts": "^9.0|^10.0",
"php": "^8.2",
"illuminate/contracts": "^12.0|^13.0",
"league/csv": "^9.15.0",
"livewire/livewire": "^2.10",
"spatie/laravel-package-tools": "^1.9.2"
"livewire/livewire": "^4.0",
"spatie/laravel-package-tools": "^1.93"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^6.0|^7.0",
"nunomaduro/larastan": "^2.0",
"orchestra/testbench": "^7.0|~8.15.0",
"orchestra/testbench-core": "^7.0|~8.15.0",
"pestphp/pest": "^1.21|^2.0",
"pestphp/pest-plugin-laravel": "^1.1",
"pestphp/pest-plugin-livewire": "^1.0",
"larastan/larastan": "^3.10",
"laravel/pint": "^1.29",
"nunomaduro/collision": "^8.9",
"orchestra/testbench": "^10.0|^11.1",
"orchestra/testbench-core": "^10.0|^11.2",
"pestphp/pest": "^4.7",
"pestphp/pest-plugin-laravel": "^4.0",
"pestphp/pest-plugin-livewire": "^4.1",
"phpstan/extension-installer": "^1.2",
"phpunit/phpunit": "^9.5|^10.0"
"phpunit/phpunit": "^12.5"
},
"autoload": {
"files": [
Expand Down
1 change: 0 additions & 1 deletion config/livewire_csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
*/
'set_delimiter' => ',',


/*
|--------------------------------------------------------------------------
| Max Upload File Size
Expand Down
8 changes: 2 additions & 6 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ includes:
- phpstan-baseline.neon

parameters:
level: 6
level: 5
paths:
- src
- config
- database
- tests/Models/User.php
tmpDir: build/phpstan
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
bootstrapFiles:
- classAliases.php



54 changes: 17 additions & 37 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<php>
<env name="DB_CONNECTION" value="testing"/>
</php>
<testsuites>
<testsuite name="Askdkc Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="false" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<php>
<env name="DB_CONNECTION" value="testing"/>
</php>
<testsuites>
<testsuite name="Askdkc Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
6 changes: 3 additions & 3 deletions resources/views/components/button.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<button
{{ $attributes }}
x-data
x-on:click="window.livewire.emitTo('csv-importer', 'toggle')">
x-data
x-on:click="Livewire.dispatchTo('csv-importer', 'toggle')">
{{ $slot }}
</button>
</button>
4 changes: 2 additions & 2 deletions resources/views/livewire/tailwindcss/csv-importer.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="relative z-10" x-data="{ open: @entangle('open') }" x-show="open" x-cloak>
<div class="relative z-10" x-data="{ open: $wire.entangle('open') }" x-show="open" x-cloak>
<div class="fixed inset-0"></div>

<div class="fixed inset-0 overflow-hidden">
Expand Down Expand Up @@ -78,7 +78,7 @@
{{ $columnLabels[$column] ?? ucfirst(str_replace(['_', '-'], ' ', $column)) }}<span class="text-red-600 font-bold text-sm">{{ in_array('columnsToMap.' . $column, array_keys($requiredColumns)) ? '*': ''}}</span>
</label>
<div class="mt-1 sm:mt-0 sm:col-span-3">
<select wire:model.defer="columnsToMap.{{$column}}" type="text" name="{{ $column }}" id="{{ $column }}" class="max-w-lg block w-full dark:bg-gray-700 dark:text-white shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:max-w-xs sm:text-sm border-gray-300 rounded-md">
<select wire:model="columnsToMap.{{$column}}" type="text" name="{{ $column }}" id="{{ $column }}" class="max-w-lg block w-full dark:bg-gray-700 dark:text-white shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:max-w-xs sm:text-sm border-gray-300 rounded-md">
<option value="">{{ __('Select a column or keep if not required') }}</option>
@foreach ($fileHeaders as $fileHeader)
<option value="{{$fileHeader}}">{{ $fileHeader }}</option>
Expand Down
29 changes: 15 additions & 14 deletions src/Commands/LiveSetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Askdkc\LivewireCsv\Commands;

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Artisan;

class LiveSetupCommand extends Command
Expand All @@ -17,24 +16,24 @@ public function handle(): void
$this->info('Preparing Livewire-CSV necessary migrations / 必要なマイグレーションを準備します');
$this->comment('Publishing migration... / マイグレーションファイル準備中');

if(!$this->migrationExists('create_jobs_table')) {
Artisan::call("queue:table");
if (! $this->migrationExists('create_jobs_table')) {
Artisan::call('queue:table');
$this->comment('Migration Jobs created successfully / Jobsテーブル作成');
}

if(!$this->migrationExists('create_job_batches_table')) {
Artisan::call("queue:batches-table");
if (! $this->migrationExists('create_job_batches_table')) {
Artisan::call('queue:batches-table');
$this->comment('Migration Job Batches created successfully / Job Batches テーブル作成');
}

if(!$this->migrationExists('create_csv_imports_table')) {
$this->callSilently("vendor:publish", [
'--tag' => "livewire-csv-migrations",
if (! $this->migrationExists('create_csv_imports_table')) {
$this->callSilently('vendor:publish', [
'--tag' => 'livewire-csv-migrations',
]);
$this->comment('Migration Csv Imports created successfully / Csv Importsテーブル作成');
}

if ($this->confirm('Would you like to set your locale to Japanese? / 言語を日本語にしますか?')) {
if ($this->confirm('Would you like to set your locale to Japanese? / 言語を日本語にしますか?')) {
$this->info('config/app.phpのlocaleをjaにします');
// Read the contents of the file into a string
$configfile = file_get_contents(base_path('config/app.php'));
Expand All @@ -52,7 +51,7 @@ public function handle(): void
'--tag' => 'livewire-csv-config',
]);

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

if ($this->confirm('Would you like to run the migrations now? / マイグレーションを実行しますか?')) {
$this->comment('Running migrations... / 実行中...');
Expand All @@ -61,7 +60,7 @@ public function handle(): void
}

if ($this->confirm("Would you like to star our repo on GitHub? \n GitHubリポジトリにスターの御協力をお願いします🙏", true)) {
$repoUrl = "https://github.com/askdkc/livewire-csv";
$repoUrl = 'https://github.com/askdkc/livewire-csv';

if (PHP_OS_FAMILY == 'Darwin') {
exec("open {$repoUrl}");
Expand All @@ -77,16 +76,18 @@ public function handle(): void
}
}

private function migrationExists(string $filename): Bool
private function migrationExists(string $filename): bool
{
$path = database_path('migrations/');
$files = scandir($path);
$pos = false;
foreach ($files as $value) {
$pos = strpos($value, $filename);
if($pos !== false) return true;
if ($pos !== false) {
return true;
}
}

return false;
}

}
2 changes: 1 addition & 1 deletion src/Concerns/HasCsvImports.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait HasCsvImports
/**
* Has imports relationship
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany<Import>
* @return HasMany<Import, $this>
*/
public function imports(): HasMany
{
Expand Down
11 changes: 3 additions & 8 deletions src/Concerns/HasCsvProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@
use Illuminate\Support\MessageBag;
use League\Csv\Reader;
use League\Csv\Statement;
use League\Csv\SyntaxError;
use League\Csv\TabularDataReader;

/**
* Askdkc\LivewireCsv\Concerns\HasCsvProperties
*
* @property Reader $readCsv
* @property \League\Csv\TabularDataReader $csvRecords
* @property TabularDataReader $csvRecords
*/
trait HasCsvProperties
{
use InteractsWithCsvFiles;

/**
* Read CSV Property
*
* @return Reader
*/
public function getReadCsvProperty(): Reader
{
Expand All @@ -30,8 +29,6 @@ public function getReadCsvProperty(): Reader

/**
* Get CSV Records Property
*
* @return TabularDataReader
*/
public function getCsvRecordsProperty(): TabularDataReader
{
Expand All @@ -40,8 +37,6 @@ public function getCsvRecordsProperty(): TabularDataReader

/**
* Handle CSV Information properties from the given file
*
* @return array|\Illuminate\Support\MessageBag
*/
public function handleCsvProperties(): array|MessageBag
{
Expand All @@ -50,7 +45,7 @@ public function handleCsvProperties(): array|MessageBag
$fileRowCount = $this->csvRecords->count();

return [$fileHeaders, $fileRowCount];
} catch (\League\Csv\SyntaxError $exception) {
} catch (SyntaxError $exception) {
Log::warning($exception->getMessage());

return $this->addError(
Expand Down
Loading