From 16b5fb3533b5830e1a9fa49d52f666cb63270d43 Mon Sep 17 00:00:00 2001 From: shibafu Date: Tue, 21 Jul 2020 23:39:48 +0900 Subject: [PATCH 01/23] =?UTF-8?q?Tissue=E5=86=85=E3=81=AEURL=E3=81=AB?= =?UTF-8?q?=E5=AF=BE=E3=81=99=E3=82=8B=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E5=8F=96=E5=BE=97=E3=81=AF=E6=8B=92=E5=90=A6=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/MetadataResolveService.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Services/MetadataResolveService.php b/app/Services/MetadataResolveService.php index 405ae9f..55372bd 100644 --- a/app/Services/MetadataResolveService.php +++ b/app/Services/MetadataResolveService.php @@ -27,6 +27,11 @@ class MetadataResolveService // URLの正規化 $url = $this->formatter->normalizeUrl($url); + // 自分自身は解決しない + if (parse_url($url, PHP_URL_HOST) === parse_url(config('app.url'), PHP_URL_HOST)) { + abort(403); + } + // 無かったら取得 // TODO: ある程度古かったら再取得とかありだと思う $metadata = Metadata::find($url); From 0a9920b11cf1e0cfad654944e60a96a50478c5b7 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 23 Jul 2020 13:08:20 +0900 Subject: [PATCH 02/23] =?UTF-8?q?=E3=81=95=E3=81=99=E3=81=8C=E3=81=ABServi?= =?UTF-8?q?ce=E3=81=8B=E3=82=89HttpException=E3=81=AF=E9=9B=91=E3=81=99?= =?UTF-8?q?=E3=81=8E=E3=81=9F=E3=81=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/CardController.php | 7 ++++- app/Listeners/LinkCollector.php | 3 ++ app/MetadataResolver/DeniedHostException.php | 30 ++++++++++++++++++++ app/Services/MetadataResolveService.php | 3 +- 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 app/MetadataResolver/DeniedHostException.php diff --git a/app/Http/Controllers/Api/CardController.php b/app/Http/Controllers/Api/CardController.php index 8cdf980..38f56f7 100644 --- a/app/Http/Controllers/Api/CardController.php +++ b/app/Http/Controllers/Api/CardController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Api; +use App\MetadataResolver\DeniedHostException; use App\Services\MetadataResolveService; use Illuminate\Http\Request; @@ -13,7 +14,11 @@ class CardController 'url:required|url' ]); - $metadata = $service->execute($request->input('url')); + try { + $metadata = $service->execute($request->input('url')); + } catch (DeniedHostException $e) { + abort(403, $e->getMessage()); + } $metadata->load('tags'); $response = response($metadata); diff --git a/app/Listeners/LinkCollector.php b/app/Listeners/LinkCollector.php index 6c10e21..d3a1b37 100644 --- a/app/Listeners/LinkCollector.php +++ b/app/Listeners/LinkCollector.php @@ -3,6 +3,7 @@ namespace App\Listeners; use App\Events\LinkDiscovered; +use App\MetadataResolver\DeniedHostException; use App\Services\MetadataResolveService; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Queue\InteractsWithQueue; @@ -32,6 +33,8 @@ class LinkCollector { try { $this->metadataResolveService->execute($event->url); + } catch (DeniedHostException $e) { + // ignored } catch (\Exception $e) { // 今のところこのイベントは同期実行されるので、上流をクラッシュさせないために雑catchする report($e); diff --git a/app/MetadataResolver/DeniedHostException.php b/app/MetadataResolver/DeniedHostException.php new file mode 100644 index 0000000..dac13b2 --- /dev/null +++ b/app/MetadataResolver/DeniedHostException.php @@ -0,0 +1,30 @@ +url = $url; + } + + public function getUrl(): string + { + return $this->url; + } + + public function getHost(): string + { + return parse_url($this->url, PHP_URL_HOST); + } +} diff --git a/app/Services/MetadataResolveService.php b/app/Services/MetadataResolveService.php index 55372bd..e622813 100644 --- a/app/Services/MetadataResolveService.php +++ b/app/Services/MetadataResolveService.php @@ -3,6 +3,7 @@ namespace App\Services; use App\Metadata; +use App\MetadataResolver\DeniedHostException; use App\MetadataResolver\MetadataResolver; use App\Tag; use App\Utilities\Formatter; @@ -29,7 +30,7 @@ class MetadataResolveService // 自分自身は解決しない if (parse_url($url, PHP_URL_HOST) === parse_url(config('app.url'), PHP_URL_HOST)) { - abort(403); + throw new DeniedHostException($url); } // 無かったら取得 From 978eccd643cd3fa628ce7347b7e375ecabcfe9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D8=B1=D8=B2=D9=85=20=D8=A7=D9=84=D9=8A=D9=8E=D8=BA?= =?UTF-8?q?=D9=85=D9=8A=D8=B5=D8=A7=D8=A1?= <68658332+Al-aighumaisa@users.noreply.github.com> Date: Thu, 23 Jul 2020 02:42:42 +0900 Subject: [PATCH 03/23] =?UTF-8?q?=E3=82=BF=E3=82=B0=E3=81=AE=E7=A2=BA?= =?UTF-8?q?=E5=AE=9A=E6=99=82=E3=81=AB=E7=A9=BA=E7=99=BD=E6=96=87=E5=AD=97?= =?UTF-8?q?=E3=82=92=E7=BD=AE=E6=8F=9B=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #414. --- resources/assets/js/components/TagInput.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/components/TagInput.vue b/resources/assets/js/components/TagInput.vue index 5dd2bad..9fad41f 100644 --- a/resources/assets/js/components/TagInput.vue +++ b/resources/assets/js/components/TagInput.vue @@ -41,7 +41,7 @@ export default class TagInput extends Vue { case 'Enter': case ' ': if ((event as any).isComposing !== true) { - this.tags.push(this.buffer.trim()); + this.tags.push(this.buffer.trim().replace(/\s+/g, '_')); this.buffer = ''; } event.preventDefault(); @@ -49,7 +49,7 @@ export default class TagInput extends Vue { case 'Unidentified': // 実際にテキストボックスに入力されている文字を見に行く (フォールバック処理) if (event.srcElement && (event.srcElement as HTMLInputElement).value.slice(-1) == ' ') { - this.tags.push(this.buffer.trim()); + this.tags.push(this.buffer.trim().replace(/\s+/g, '_')); this.buffer = ''; event.preventDefault(); } From d69fe6a22a23eb685c4e04db84bb03f2c57311a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Jul 2020 12:41:43 +0900 Subject: [PATCH 04/23] Bump laravel/framework from 6.18.25 to 6.18.26 (#444) Bumps [laravel/framework](https://github.com/laravel/framework) from 6.18.25 to 6.18.26. - [Release notes](https://github.com/laravel/framework/releases) - [Changelog](https://github.com/laravel/framework/blob/7.x/CHANGELOG-6.x.md) - [Commits](https://github.com/laravel/framework/compare/v6.18.25...v6.18.26) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.lock | 516 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 369 insertions(+), 147 deletions(-) diff --git a/composer.lock b/composer.lock index f2192cf..5a68ddc 100644 --- a/composer.lock +++ b/composer.lock @@ -394,6 +394,20 @@ "sqlserver", "sqlsrv" ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", + "type": "tidelift" + } + ], "time": "2020-04-20T17:19:26+00:00" }, { @@ -547,6 +561,20 @@ "uppercase", "words" ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", + "type": "tidelift" + } + ], "time": "2020-05-29T15:13:26+00:00" }, { @@ -609,6 +637,20 @@ "parser", "php" ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer", + "type": "tidelift" + } + ], "time": "2020-05-25T17:44:05+00:00" }, { @@ -1148,16 +1190,16 @@ }, { "name": "laravel/framework", - "version": "v6.18.25", + "version": "v6.18.26", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "fd4c42cb49b8777473d1161ef15d1104b2a33d6c" + "reference": "d11b6168c65251ffa81ae0dfaf017ad2f30013da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/fd4c42cb49b8777473d1161ef15d1104b2a33d6c", - "reference": "fd4c42cb49b8777473d1161ef15d1104b2a33d6c", + "url": "https://api.github.com/repos/laravel/framework/zipball/d11b6168c65251ffa81ae0dfaf017ad2f30013da", + "reference": "d11b6168c65251ffa81ae0dfaf017ad2f30013da", "shasum": "" }, "require": { @@ -1292,7 +1334,7 @@ "framework", "laravel" ], - "time": "2020-07-10T16:41:03+00:00" + "time": "2020-07-21T14:25:39+00:00" }, { "name": "laravel/helpers", @@ -1413,16 +1455,16 @@ }, { "name": "league/commonmark", - "version": "1.5.1", + "version": "1.5.3", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "6d74caf6abeed5fd85d6ec20da23d7269cd0b46f" + "reference": "2574454b97e4103dc4e36917bd783b25624aefcd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/6d74caf6abeed5fd85d6ec20da23d7269cd0b46f", - "reference": "6d74caf6abeed5fd85d6ec20da23d7269cd0b46f", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/2574454b97e4103dc4e36917bd783b25624aefcd", + "reference": "2574454b97e4103dc4e36917bd783b25624aefcd", "shasum": "" }, "require": { @@ -1441,7 +1483,7 @@ "michelf/php-markdown": "~1.4", "mikehaertl/php-shellcommand": "^1.4", "phpstan/phpstan": "^0.12", - "phpunit/phpunit": "^7.5", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.2", "scrutinizer/ocular": "^1.5", "symfony/finder": "^4.2" }, @@ -1504,7 +1546,7 @@ "type": "tidelift" } ], - "time": "2020-06-27T12:50:08+00:00" + "time": "2020-07-19T22:47:30+00:00" }, { "name": "league/csv", @@ -1575,6 +1617,12 @@ "transform", "write" ], + "funding": [ + { + "url": "https://github.com/sponsors/nyamsprod", + "type": "github" + } + ], "time": "2020-03-17T15:15:35+00:00" }, { @@ -1659,6 +1707,12 @@ "sftp", "storage" ], + "funding": [ + { + "url": "https://offset.earth/frankdejonge", + "type": "other" + } + ], "time": "2020-05-18T15:13:39+00:00" }, { @@ -1785,6 +1839,16 @@ "logging", "psr-3" ], + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", + "type": "tidelift" + } + ], "time": "2020-05-22T08:12:19+00:00" }, { @@ -2509,24 +2573,24 @@ }, { "name": "phpoption/phpoption", - "version": "1.7.4", + "version": "1.7.5", "source": { "type": "git", "url": "https://github.com/schmittjoh/php-option.git", - "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3" + "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", - "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3", + "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/994ecccd8f3283ecf5ac33254543eb0ac946d525", + "reference": "994ecccd8f3283ecf5ac33254543eb0ac946d525", "shasum": "" }, "require": { "php": "^5.5.9 || ^7.0 || ^8.0" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.3", - "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0" + "bamarni/composer-bin-plugin": "^1.4.1", + "phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0 || ^8.0 || ^9.0" }, "type": "library", "extra": { @@ -2570,7 +2634,7 @@ "type": "tidelift" } ], - "time": "2020-06-07T10:40:07+00:00" + "time": "2020-07-20T17:29:33+00:00" }, { "name": "psr/container", @@ -4359,16 +4423,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.17.1", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d" + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", - "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", "shasum": "" }, "require": { @@ -4380,7 +4444,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4431,20 +4495,20 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-iconv", - "version": "v1.17.1", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-iconv.git", - "reference": "ba6c9c18db36235b859cc29b8372d1c01298c035" + "reference": "6c2f78eb8f5ab8eaea98f6d414a5915f2e0fce36" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/ba6c9c18db36235b859cc29b8372d1c01298c035", - "reference": "ba6c9c18db36235b859cc29b8372d1c01298c035", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/6c2f78eb8f5ab8eaea98f6d414a5915f2e0fce36", + "reference": "6c2f78eb8f5ab8eaea98f6d414a5915f2e0fce36", "shasum": "" }, "require": { @@ -4456,7 +4520,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4508,25 +4572,26 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.17.1", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "a57f8161502549a742a63c09f0a604997bf47027" + "reference": "bc6549d068d0160e0f10f7a5a23c7d1406b95ebe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/a57f8161502549a742a63c09f0a604997bf47027", - "reference": "a57f8161502549a742a63c09f0a604997bf47027", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/bc6549d068d0160e0f10f7a5a23c7d1406b95ebe", + "reference": "bc6549d068d0160e0f10f7a5a23c7d1406b95ebe", "shasum": "" }, "require": { "php": ">=5.3.3", - "symfony/polyfill-mbstring": "^1.3", + "symfony/polyfill-intl-normalizer": "^1.10", + "symfony/polyfill-php70": "^1.10", "symfony/polyfill-php72": "^1.10" }, "suggest": { @@ -4535,7 +4600,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4559,6 +4624,10 @@ "name": "Laurent Bassin", "email": "laurent@bassin.info" }, + { + "name": "Trevor Rowbotham", + "email": "trevor.rowbotham@pm.me" + }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" @@ -4588,20 +4657,101 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { - "name": "symfony/polyfill-mbstring", - "version": "v1.17.1", + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.18.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7110338d81ce1cbc3e273136e4574663627037a7" + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "37078a8dd4a2a1e9ab0231af7c6cb671b2ed5a7e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7110338d81ce1cbc3e273136e4574663627037a7", - "reference": "7110338d81ce1cbc3e273136e4574663627037a7", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/37078a8dd4a2a1e9ab0231af7c6cb671b2ed5a7e", + "reference": "37078a8dd4a2a1e9ab0231af7c6cb671b2ed5a7e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", "shasum": "" }, "require": { @@ -4613,7 +4763,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4665,20 +4815,97 @@ "type": "tidelift" } ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/polyfill-php70", + "version": "v1.17.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/471b096aede7025bace8eb356b9ac801aaba7e2d", + "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "~1.0|~2.0|~9.99", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.17-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php70\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-06-06T08:46:27+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.17.0", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "f048e612a3905f34931127360bdd2def19a5e582" + "reference": "639447d008615574653fb3bc60d1986d7172eaae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/f048e612a3905f34931127360bdd2def19a5e582", - "reference": "f048e612a3905f34931127360bdd2def19a5e582", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/639447d008615574653fb3bc60d1986d7172eaae", + "reference": "639447d008615574653fb3bc60d1986d7172eaae", "shasum": "" }, "require": { @@ -4687,7 +4914,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -4720,20 +4951,34 @@ "portable", "shim" ], - "time": "2020-05-12T16:47:27+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.17.1", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a" + "reference": "fffa1a52a023e782cdcc221d781fe1ec8f87fcca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fa0837fe02d617d31fbb25f990655861bb27bd1a", - "reference": "fa0837fe02d617d31fbb25f990655861bb27bd1a", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fffa1a52a023e782cdcc221d781fe1ec8f87fcca", + "reference": "fffa1a52a023e782cdcc221d781fe1ec8f87fcca", "shasum": "" }, "require": { @@ -4742,7 +4987,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4796,20 +5041,20 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.17.1", + "version": "v1.18.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2" + "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4a5b6bba3259902e386eb80dd1956181ee90b5b2", - "reference": "4a5b6bba3259902e386eb80dd1956181ee90b5b2", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/d87d5766cbf48d72388a9f6b85f280c8ad51f981", + "reference": "d87d5766cbf48d72388a9f6b85f280c8ad51f981", "shasum": "" }, "require": { @@ -4818,7 +5063,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4876,7 +5121,7 @@ "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-uuid", @@ -5491,22 +5736,22 @@ }, { "name": "vlucas/phpdotenv", - "version": "v3.6.6", + "version": "v3.6.7", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "4669484ccbc38fe7c4e0c50456778f2010566aad" + "reference": "2065beda6cbe75e2603686907b2e45f6f3a5ad82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/4669484ccbc38fe7c4e0c50456778f2010566aad", - "reference": "4669484ccbc38fe7c4e0c50456778f2010566aad", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2065beda6cbe75e2603686907b2e45f6f3a5ad82", + "reference": "2065beda6cbe75e2603686907b2e45f6f3a5ad82", "shasum": "" }, "require": { "php": "^5.4 || ^7.0 || ^8.0", "phpoption/phpoption": "^1.5.2", - "symfony/polyfill-ctype": "^1.16" + "symfony/polyfill-ctype": "^1.17" }, "require-dev": { "ext-filter": "*", @@ -5560,7 +5805,7 @@ "type": "tidelift" } ], - "time": "2020-06-02T14:08:54+00:00" + "time": "2020-07-14T19:04:52+00:00" } ], "packages-dev": [ @@ -5630,6 +5875,12 @@ "profiler", "webprofiler" ], + "funding": [ + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], "time": "2020-05-05T10:53:32+00:00" }, { @@ -5701,6 +5952,12 @@ "phpstorm", "sublime" ], + "funding": [ + { + "url": "https://github.com/barryvdh", + "type": "github" + } + ], "time": "2020-04-22T09:57:26+00:00" }, { @@ -5806,6 +6063,16 @@ "ssl", "tls" ], + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], "time": "2020-04-08T08:27:21+00:00" }, { @@ -5887,6 +6154,16 @@ "dependency", "package" ], + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], "time": "2020-05-06T08:28:10+00:00" }, { @@ -6259,6 +6536,12 @@ "flare", "reporting" ], + "funding": [ + { + "url": "https://www.patreon.com/spatie", + "type": "patreon" + } + ], "time": "2020-03-02T15:52:04+00:00" }, { @@ -7805,6 +8088,12 @@ "highlight.php", "syntax" ], + "funding": [ + { + "url": "https://github.com/allejo", + "type": "github" + } + ], "time": "2020-03-02T05:59:21+00:00" }, { @@ -8469,6 +8758,16 @@ "parser", "validator" ], + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/seld/jsonlint", + "type": "tidelift" + } + ], "time": "2020-04-30T19:05:18+00:00" }, { @@ -8579,83 +8878,6 @@ ], "time": "2020-05-30T20:35:19+00:00" }, - { - "name": "symfony/polyfill-php70", - "version": "v1.17.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/471b096aede7025bace8eb356b9ac801aaba7e2d", - "reference": "471b096aede7025bace8eb356b9ac801aaba7e2d", - "shasum": "" - }, - "require": { - "paragonie/random_compat": "~1.0|~2.0|~9.99", - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.17-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php70\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2020-06-06T08:46:27+00:00" - }, { "name": "symfony/stopwatch", "version": "v5.1.2", @@ -8810,8 +9032,8 @@ "authors": [ { "name": "Arne Blankerts", - "role": "Developer", - "email": "arne@blankerts.de" + "email": "arne@blankerts.de", + "role": "Developer" } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", From c7aa0026251c884ce6ad5ab92e7889aeec827cb6 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 30 Jul 2020 00:46:33 +0900 Subject: [PATCH 05/23] =?UTF-8?q?=E3=81=AA=E3=82=93=E3=82=82=E3=82=8F?= =?UTF-8?q?=E3=81=8B=E3=82=89=E3=82=93=E3=82=8F=E3=83=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/NormalizeTags.php | 50 ++++++++++++++++++++++++++ app/Utilities/Formatter.php | 11 ++++++ 2 files changed, 61 insertions(+) create mode 100644 app/Console/Commands/NormalizeTags.php diff --git a/app/Console/Commands/NormalizeTags.php b/app/Console/Commands/NormalizeTags.php new file mode 100644 index 0000000..4e9d8ed --- /dev/null +++ b/app/Console/Commands/NormalizeTags.php @@ -0,0 +1,50 @@ +formatter = $formatter; + } + + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + foreach (Tag::query()->orderBy('name')->cursor() as $tag) { + $normalizedName = $this->formatter->normalizeToSearchIndex($tag->name); + $this->line("{$tag->name} : {$normalizedName}"); + } + } +} diff --git a/app/Utilities/Formatter.php b/app/Utilities/Formatter.php index 7ac108b..aa09c78 100644 --- a/app/Utilities/Formatter.php +++ b/app/Utilities/Formatter.php @@ -132,4 +132,15 @@ class Formatter return $bytes . 'B'; } + + public function normalizeToSearchIndex(string $text): string + { + $text = \Normalizer::normalize($text, \Normalizer::FORM_KC); +// $text = \Transliterator::create('Katakana-Hiragana')->transliterate($text); + $text = mb_convert_kana($text, 'c'); + $text = preg_replace('/[^\p{L}\p{N}]/u', '', $text); + $text = mb_strtolower($text); + + return $text; + } } From e2c43fef802dbdc7ab046bf5c5cc6fd61eb5d634 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 30 Jul 2020 22:42:10 +0900 Subject: [PATCH 06/23] tags.normalized_name --- app/Console/Commands/NormalizeTags.php | 19 ++++++++--- app/Tag.php | 10 ++++++ app/Utilities/Formatter.php | 11 +++---- ..._30_221302_add_normalized_name_to_tags.php | 32 +++++++++++++++++++ 4 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 database/migrations/2020_07_30_221302_add_normalized_name_to_tags.php diff --git a/app/Console/Commands/NormalizeTags.php b/app/Console/Commands/NormalizeTags.php index 4e9d8ed..9d6cf30 100644 --- a/app/Console/Commands/NormalizeTags.php +++ b/app/Console/Commands/NormalizeTags.php @@ -4,6 +4,7 @@ namespace App\Console\Commands; use App\Tag; use App\Utilities\Formatter; +use DB; use Illuminate\Console\Command; class NormalizeTags extends Command @@ -42,9 +43,19 @@ class NormalizeTags extends Command */ public function handle() { - foreach (Tag::query()->orderBy('name')->cursor() as $tag) { - $normalizedName = $this->formatter->normalizeToSearchIndex($tag->name); - $this->line("{$tag->name} : {$normalizedName}"); - } + $start = hrtime(true); + + DB::transaction(function () { + /** @var Tag $tag */ + foreach (Tag::query()->cursor() as $tag) { + $normalizedName = $this->formatter->normalizeTagName($tag->name); + $this->line("{$tag->name} : {$normalizedName}"); + $tag->normalized_name = $normalizedName; + $tag->save(); + } + }); + + $elapsed = (hrtime(true) - $start) / 1e+9; + $this->info("Done! ({$elapsed} sec)"); } } diff --git a/app/Tag.php b/app/Tag.php index df057f5..895492e 100644 --- a/app/Tag.php +++ b/app/Tag.php @@ -2,6 +2,7 @@ namespace App; +use App\Utilities\Formatter; use Illuminate\Database\Eloquent\Model; class Tag extends Model @@ -15,6 +16,15 @@ class Tag extends Model 'name' ]; + protected static function boot() + { + parent::boot(); + + self::creating(function (Tag $tag) { + $tag->normalized_name = app(Formatter::class)->normalizeTagName($tag->name); + }); + } + public function ejaculations() { return $this->belongsToMany('App\Ejaculation')->withTimestamps(); diff --git a/app/Utilities/Formatter.php b/app/Utilities/Formatter.php index aa09c78..f15901a 100644 --- a/app/Utilities/Formatter.php +++ b/app/Utilities/Formatter.php @@ -133,14 +133,11 @@ class Formatter return $bytes . 'B'; } - public function normalizeToSearchIndex(string $text): string + public function normalizeTagName(string $name) { - $text = \Normalizer::normalize($text, \Normalizer::FORM_KC); -// $text = \Transliterator::create('Katakana-Hiragana')->transliterate($text); - $text = mb_convert_kana($text, 'c'); - $text = preg_replace('/[^\p{L}\p{N}]/u', '', $text); - $text = mb_strtolower($text); + $name = \Normalizer::normalize($name, \Normalizer::FORM_KC); + $name = mb_strtolower($name); - return $text; + return $name; } } diff --git a/database/migrations/2020_07_30_221302_add_normalized_name_to_tags.php b/database/migrations/2020_07_30_221302_add_normalized_name_to_tags.php new file mode 100644 index 0000000..eead2a0 --- /dev/null +++ b/database/migrations/2020_07_30_221302_add_normalized_name_to_tags.php @@ -0,0 +1,32 @@ +string('normalized_name')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('tags', function (Blueprint $table) { + $table->dropColumn('normalized_name'); + }); + } +} From d18f245129116b84fef34e36964de4de0cfde11d Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 30 Jul 2020 23:04:39 +0900 Subject: [PATCH 07/23] Docker: use php-intl --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index fd99670..d8530ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,8 @@ FROM php:7.3-apache ENV APACHE_DOCUMENT_ROOT /var/www/html/public RUN apt-get update \ - && apt-get install -y git libpq-dev unzip \ - && docker-php-ext-install pdo_pgsql \ + && apt-get install -y git libpq-dev unzip libicu-dev \ + && docker-php-ext-install pdo_pgsql intl \ && pecl install xdebug \ && curl -sS https://getcomposer.org/installer | php \ && mv composer.phar /usr/local/bin/composer \ From 561c9d028da59549356e1a70f54e2d4388fa8f43 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 30 Jul 2020 23:12:29 +0900 Subject: [PATCH 08/23] =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E6=99=82=E3=81=AB?= =?UTF-8?q?=E3=81=AFtags.normalized=5Fname=E3=82=92=E4=BD=BF=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/SearchController.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 0487344..ee4b5c0 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -4,20 +4,30 @@ namespace App\Http\Controllers; use App\Ejaculation; use App\Tag; +use App\Utilities\Formatter; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; class SearchController extends Controller { + /** @var Formatter */ + private $formatter; + + public function __construct(Formatter $formatter) + { + $this->formatter = $formatter; + } + public function index(Request $request) { $inputs = $request->validate([ 'q' => 'required' ]); + $q = $this->normalizeQuery($inputs['q']); $results = Ejaculation::query() - ->whereHas('tags', function ($query) use ($inputs) { - $query->where('name', 'like', "%{$inputs['q']}%"); + ->whereHas('tags', function ($query) use ($q) { + $query->where('normalized_name', 'like', "%{$q}%"); }) ->whereHas('user', function ($query) { $query->where('is_protected', false); @@ -41,11 +51,17 @@ class SearchController extends Controller 'q' => 'required' ]); + $q = $this->normalizeQuery($inputs['q']); $results = Tag::query() - ->where('name', 'like', "%{$inputs['q']}%") + ->where('normalized_name', 'like', "%{$q}%") ->paginate(50) ->appends($inputs); return view('search.relatedTag')->with(compact('inputs', 'results')); } + + private function normalizeQuery(string $query): string + { + return $this->formatter->normalizeTagName($query); + } } From c9efcb538cae0b2a68f60c3b4df36efc86c1e210 Mon Sep 17 00:00:00 2001 From: shibafu Date: Fri, 31 Jul 2020 22:21:31 +0900 Subject: [PATCH 09/23] add extension requirements --- composer.json | 6 +++ composer.lock | 104 +++++--------------------------------------------- 2 files changed, 16 insertions(+), 94 deletions(-) diff --git a/composer.json b/composer.json index c262a1c..f5a796c 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,12 @@ ], "require": { "php": "^7.2", + "ext-dom": "*", + "ext-intl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-pdo": "*", "anhskohbo/no-captcha": "^3.0", "doctrine/dbal": "^2.9", "erusev/parsedown": "^1.7", diff --git a/composer.lock b/composer.lock index 5a68ddc..a0f42c5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2c0bd951a595d4856079c5a13a72e651", + "content-hash": "1bba68b609be6a0dcdaf05d72e8eb759", "packages": [ { "name": "anhskohbo/no-captcha", @@ -394,20 +394,6 @@ "sqlserver", "sqlsrv" ], - "funding": [ - { - "url": "https://www.doctrine-project.org/sponsorship.html", - "type": "custom" - }, - { - "url": "https://www.patreon.com/phpdoctrine", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", - "type": "tidelift" - } - ], "time": "2020-04-20T17:19:26+00:00" }, { @@ -1617,12 +1603,6 @@ "transform", "write" ], - "funding": [ - { - "url": "https://github.com/sponsors/nyamsprod", - "type": "github" - } - ], "time": "2020-03-17T15:15:35+00:00" }, { @@ -1707,12 +1687,6 @@ "sftp", "storage" ], - "funding": [ - { - "url": "https://offset.earth/frankdejonge", - "type": "other" - } - ], "time": "2020-05-18T15:13:39+00:00" }, { @@ -1839,16 +1813,6 @@ "logging", "psr-3" ], - "funding": [ - { - "url": "https://github.com/Seldaek", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", - "type": "tidelift" - } - ], "time": "2020-05-22T08:12:19+00:00" }, { @@ -5875,12 +5839,6 @@ "profiler", "webprofiler" ], - "funding": [ - { - "url": "https://github.com/barryvdh", - "type": "github" - } - ], "time": "2020-05-05T10:53:32+00:00" }, { @@ -5952,12 +5910,6 @@ "phpstorm", "sublime" ], - "funding": [ - { - "url": "https://github.com/barryvdh", - "type": "github" - } - ], "time": "2020-04-22T09:57:26+00:00" }, { @@ -6063,16 +6015,6 @@ "ssl", "tls" ], - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], "time": "2020-04-08T08:27:21+00:00" }, { @@ -6154,16 +6096,6 @@ "dependency", "package" ], - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], "time": "2020-05-06T08:28:10+00:00" }, { @@ -6536,12 +6468,6 @@ "flare", "reporting" ], - "funding": [ - { - "url": "https://www.patreon.com/spatie", - "type": "patreon" - } - ], "time": "2020-03-02T15:52:04+00:00" }, { @@ -8088,12 +8014,6 @@ "highlight.php", "syntax" ], - "funding": [ - { - "url": "https://github.com/allejo", - "type": "github" - } - ], "time": "2020-03-02T05:59:21+00:00" }, { @@ -8758,16 +8678,6 @@ "parser", "validator" ], - "funding": [ - { - "url": "https://github.com/Seldaek", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/seld/jsonlint", - "type": "tidelift" - } - ], "time": "2020-04-30T19:05:18+00:00" }, { @@ -9032,8 +8942,8 @@ "authors": [ { "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" + "role": "Developer", + "email": "arne@blankerts.de" } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", @@ -9097,7 +9007,13 @@ "prefer-stable": true, "prefer-lowest": false, "platform": { - "php": "^7.2" + "php": "^7.2", + "ext-dom": "*", + "ext-intl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-pdo": "*" }, "platform-dev": [], "plugin-api-version": "1.1.0" From b5901f26bfce09d86d8dd89b288cb655fd67f768 Mon Sep 17 00:00:00 2001 From: shibafu Date: Fri, 31 Jul 2020 23:10:54 +0900 Subject: [PATCH 10/23] add test --- tests/Unit/Utilities/FormatterTest.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/Unit/Utilities/FormatterTest.php b/tests/Unit/Utilities/FormatterTest.php index 843e60f..1708e4b 100644 --- a/tests/Unit/Utilities/FormatterTest.php +++ b/tests/Unit/Utilities/FormatterTest.php @@ -70,4 +70,30 @@ class FormatterTest extends TestCase $formatter->profileImageSrcSet($profileImageProvider, 128, 2) ); } + + /** + * @dataProvider provideNormalizeTagName + */ + public function testNormalizeTagName($input, $expected) + { + $formatter = new Formatter(); + + $normalized = $formatter->normalizeTagName($input); + $this->assertSame($expected, $normalized); + $this->assertSame($expected, $formatter->normalizeTagName($normalized)); + } + + public function provideNormalizeTagName() + { + return [ + 'LowerCase' => ['example', 'example'], + 'UpperCase' => ['EXAMPLE', 'example'], + 'HalfWidthKana' => ['ティッシュ', 'ティッシュ'], + 'FullWidthAlphabet' => ['Tissue', 'tissue'], + '組み文字1' => ['13㎝', '13cm'], + '組み文字2' => ['13㌢㍍', '13センチメートル'], + 'Script' => ['ℬ𝒶𝒷𝓊𝓂𝒾', 'babumi'], + '分割された濁点' => ['オカス゛', 'オカズ'], + ]; + } } From 18ae64a8704c826a58401fbe34e281e5ccb55cc6 Mon Sep 17 00:00:00 2001 From: shibafu Date: Fri, 31 Jul 2020 23:19:35 +0900 Subject: [PATCH 11/23] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=81=84=E3=81=AE=E3=81=AFNFD=E3=81=A0=E3=81=A3?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Unit/Utilities/FormatterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Unit/Utilities/FormatterTest.php b/tests/Unit/Utilities/FormatterTest.php index 1708e4b..46718fa 100644 --- a/tests/Unit/Utilities/FormatterTest.php +++ b/tests/Unit/Utilities/FormatterTest.php @@ -93,7 +93,7 @@ class FormatterTest extends TestCase '組み文字1' => ['13㎝', '13cm'], '組み文字2' => ['13㌢㍍', '13センチメートル'], 'Script' => ['ℬ𝒶𝒷𝓊𝓂𝒾', 'babumi'], - '分割された濁点' => ['オカス゛', 'オカズ'], + 'NFD' => ['オカズ', 'オカズ'], ]; } } From f8a93fdf454d7b970aad296f143f52ef48b008de Mon Sep 17 00:00:00 2001 From: shibafu Date: Sat, 1 Aug 2020 17:26:38 +0900 Subject: [PATCH 12/23] =?UTF-8?q?Metadata=E8=A7=A3=E6=B1=BA=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E3=83=88=E3=83=A9=E3=83=B3=E3=82=B6=E3=82=AF?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E5=86=85=E3=81=A7=E5=AE=9F=E8=A1=8C?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/MetadataResolveService.php | 49 +++++++++++++------------ 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/app/Services/MetadataResolveService.php b/app/Services/MetadataResolveService.php index e622813..48a4246 100644 --- a/app/Services/MetadataResolveService.php +++ b/app/Services/MetadataResolveService.php @@ -8,6 +8,7 @@ use App\MetadataResolver\MetadataResolver; use App\Tag; use App\Utilities\Formatter; use GuzzleHttp\Exception\TransferException; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; class MetadataResolveService @@ -33,32 +34,34 @@ class MetadataResolveService throw new DeniedHostException($url); } - // 無かったら取得 - // TODO: ある程度古かったら再取得とかありだと思う - $metadata = Metadata::find($url); - if ($metadata == null || ($metadata->expires_at !== null && $metadata->expires_at < now())) { - try { - $resolved = $this->resolver->resolve($url); - $metadata = Metadata::updateOrCreate(['url' => $url], [ - 'title' => $resolved->title, - 'description' => $resolved->description, - 'image' => $resolved->image, - 'expires_at' => $resolved->expires_at - ]); + return DB::transaction(function () use ($url) { + // 無かったら取得 + // TODO: ある程度古かったら再取得とかありだと思う + $metadata = Metadata::find($url); + if ($metadata == null || ($metadata->expires_at !== null && $metadata->expires_at < now())) { + try { + $resolved = $this->resolver->resolve($url); + $metadata = Metadata::updateOrCreate(['url' => $url], [ + 'title' => $resolved->title, + 'description' => $resolved->description, + 'image' => $resolved->image, + 'expires_at' => $resolved->expires_at + ]); - $tagIds = []; - foreach ($resolved->normalizedTags() as $tagName) { - $tag = Tag::firstOrCreate(['name' => $tagName]); - $tagIds[] = $tag->id; + $tagIds = []; + foreach ($resolved->normalizedTags() as $tagName) { + $tag = Tag::firstOrCreate(['name' => $tagName]); + $tagIds[] = $tag->id; + } + $metadata->tags()->sync($tagIds); + } catch (TransferException $e) { + // 何らかの通信エラーによってメタデータの取得に失敗した時、とりあえずエラーログにURLを残す + Log::error(self::class . ': メタデータの取得に失敗 URL=' . $url); + throw $e; } - $metadata->tags()->sync($tagIds); - } catch (TransferException $e) { - // 何らかの通信エラーによってメタデータの取得に失敗した時、とりあえずエラーログにURLを残す - Log::error(self::class . ': メタデータの取得に失敗 URL=' . $url); - throw $e; } - } - return $metadata; + return $metadata; + }); } } From 54e112fa577315718893c803d16223f9a9a66a01 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 1 Aug 2020 10:11:59 +0000 Subject: [PATCH 13/23] Bump elliptic from 6.5.2 to 6.5.3 (#449) --- yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index d181104..96ceb48 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1496,9 +1496,9 @@ bluebird@^3.1.1, bluebird@^3.5.5: integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: - version "4.11.8" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" - integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== + version "4.11.9" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828" + integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw== body-parser@1.19.0: version "1.19.0" @@ -2865,9 +2865,9 @@ elegant-spinner@^1.0.1: integrity sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4= elliptic@^6.0.0: - version "6.5.2" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.2.tgz#05c5678d7173c049d8ca433552224a495d0e3762" - integrity sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw== + version "6.5.3" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6" + integrity sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw== dependencies: bn.js "^4.4.0" brorand "^1.0.1" From 82bb10ae2463ab13250ef4dea5900a297db748db Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 6 Aug 2020 01:05:33 +0900 Subject: [PATCH 14/23] =?UTF-8?q?SourceMap=E3=81=8C=E6=AC=B2=E3=81=97?= =?UTF-8?q?=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webpack.mix.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/webpack.mix.js b/webpack.mix.js index 6fe6635..1baf0c4 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -1,5 +1,6 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires const mix = require('laravel-mix'); -require('laravel-mix-bundle-analyzer') +require('laravel-mix-bundle-analyzer'); /* |-------------------------------------------------------------------------- @@ -22,17 +23,23 @@ mix.ts('resources/assets/js/app.ts', 'public/js') .ts('resources/assets/js/checkin.ts', 'public/js') .sass('resources/assets/sass/app.scss', 'public/css') .autoload({ - 'jquery': ['$', 'jQuery', 'window.jQuery'] + jquery: ['$', 'jQuery', 'window.jQuery'], }) .extract(['jquery', 'bootstrap']) .extract(['chart.js', 'chartjs-color', 'color-name', 'moment', 'cal-heatmap', 'd3'], 'public/js/vendor/chart') .version() - .webpackConfig(webpack => ({ + .webpackConfig((_webpack) => ({ externals: { - moment: 'moment' - } + moment: 'moment', + }, })); if (process.argv.includes('-a')) { mix.bundleAnalyzer({ analyzerMode: 'static' }); } + +if (!mix.inProduction()) { + mix.webpackConfig({ + devtool: 'source-map', + }); +} From 8f1a4d3e88a413a5ce50751d0d34a13c7da29a5b Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 6 Aug 2020 01:26:11 +0900 Subject: [PATCH 15/23] =?UTF-8?q?=E3=81=93=E3=82=8C=E3=81=A7=E3=81=84?= =?UTF-8?q?=E3=81=91=E3=82=8B=E3=81=98=E3=82=83=E3=82=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webpack.mix.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/webpack.mix.js b/webpack.mix.js index 1baf0c4..3e1a6dd 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -39,7 +39,5 @@ if (process.argv.includes('-a')) { } if (!mix.inProduction()) { - mix.webpackConfig({ - devtool: 'source-map', - }); + mix.sourceMaps(); } From 87c97d27a8d7837013b95006a459327a12f841d0 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 6 Aug 2020 01:27:47 +0900 Subject: [PATCH 16/23] generateForProduction: false --- webpack.mix.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/webpack.mix.js b/webpack.mix.js index 3e1a6dd..16ed4e0 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -28,6 +28,7 @@ mix.ts('resources/assets/js/app.ts', 'public/js') .extract(['jquery', 'bootstrap']) .extract(['chart.js', 'chartjs-color', 'color-name', 'moment', 'cal-heatmap', 'd3'], 'public/js/vendor/chart') .version() + .sourceMaps(false) .webpackConfig((_webpack) => ({ externals: { moment: 'moment', @@ -37,7 +38,3 @@ mix.ts('resources/assets/js/app.ts', 'public/js') if (process.argv.includes('-a')) { mix.bundleAnalyzer({ analyzerMode: 'static' }); } - -if (!mix.inProduction()) { - mix.sourceMaps(); -} From 422891e237c12c508cc4c57ac200e49ba84572b7 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 6 Aug 2020 02:26:51 +0900 Subject: [PATCH 17/23] fetch wrapper --- package.json | 4 +- resources/assets/js/fetch.ts | 57 +++++++++++++++++++++++++++++ resources/assets/js/tissue.ts | 69 ++++++++++++++++++----------------- yarn.lock | 10 +++++ 4 files changed, 106 insertions(+), 34 deletions(-) create mode 100644 resources/assets/js/fetch.ts diff --git a/package.json b/package.json index 9f6056f..af8a402 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@types/chart.js": "^2.9.22", "@types/jquery": "^3.3.38", "@types/js-cookie": "^2.2.0", + "@types/qs": "^6.9.4", "@typescript-eslint/eslint-plugin": "^3.1.0", "@typescript-eslint/parser": "^3.1.0", "bootstrap": "^4.5.0", @@ -37,6 +38,7 @@ "open-iconic": "^1.1.1", "popper.js": "^1.14.7", "prettier": "^2.0.5", + "qs": "^6.9.4", "resolve-url-loader": "^3.1.1", "sass": "^1.26.8", "sass-loader": "^7.1.0", @@ -62,7 +64,7 @@ "stylelint --fix", "git add" ], - "*.{ts,js,vue}" : [ + "*.{ts,js,vue}": [ "eslint --fix", "git add" ], diff --git a/resources/assets/js/fetch.ts b/resources/assets/js/fetch.ts new file mode 100644 index 0000000..d683e62 --- /dev/null +++ b/resources/assets/js/fetch.ts @@ -0,0 +1,57 @@ +import { stringify } from 'qs'; + +const token = document.head.querySelector('meta[name="csrf-token"]'); +if (!token) { + console.error('CSRF token not found'); +} + +const headers = { + 'X-CSRF-TOKEN': token?.content ?? '', +}; + +type QueryParams = { [key: string]: string }; + +const joinParamsToPath = (path: string, params: QueryParams) => + Object.keys(params).length === 0 ? path : `${path}?${stringify(params)}`; + +const fetchWrapper = (path: string, options: RequestInit = {}) => + fetch(path, { + credentials: 'same-origin', + headers, + ...options, + }); + +const fetchWithJson = (path: string, body: any, options: RequestInit = {}) => + fetchWrapper(path, { + body: JSON.stringify(body), + headers: { 'Content-Type': 'application/json' }, + ...options, + }); + +const fetchWithForm = (path: string, body: any, options: RequestInit = {}) => + fetchWrapper(path, { + body: stringify(body), + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + ...options, + }); + +export const fetchGet = (path: string, params: QueryParams = {}, options: RequestInit = {}) => + fetchWrapper(joinParamsToPath(path, params), { method: 'GET', ...options }); + +export const fetchPostJson = (path: string, body: any, options: RequestInit = {}) => + fetchWithJson(path, body, { method: 'POST', ...options }); + +export const fetchPostForm = (path: string, body: any, options: RequestInit = {}) => + fetchWithForm(path, body, { method: 'POST', ...options }); + +export const fetchPutJson = (path: string, body: any, options: RequestInit = {}) => + fetchWithJson(path, body, { method: 'PUT', ...options }); + +export const fetchPutForm = (path: string, body: any, options: RequestInit = {}) => + fetchWithForm(path, body, { method: 'PUT', ...options }); + +export const fetchDeleteJson = (path: string, body: any, options: RequestInit = {}) => + fetchWithJson(path, body, { method: 'DELETE', ...options }); + +export const fetchDeleteForm = (path: string, body: any, options: RequestInit = {}) => + fetchWithForm(path, body, { method: 'DELETE', ...options }); diff --git a/resources/assets/js/tissue.ts b/resources/assets/js/tissue.ts index 1b7fe32..e059c75 100644 --- a/resources/assets/js/tissue.ts +++ b/resources/assets/js/tissue.ts @@ -1,3 +1,5 @@ +import { fetchGet } from './fetch'; + (function ($) { $.fn.linkCard = function (options) { const settings = $.extend( @@ -9,43 +11,44 @@ return this.each(function () { const $this = $(this); - $.ajax({ - url: settings.endpoint, - method: 'get', - type: 'json', - data: { - url: $this.find('a').attr('href'), - }, - }).then(function (data) { - const $metaColumn = $this.find('.col-12:last-of-type'); - const $imageColumn = $this.find('.col-12:first-of-type'); - const $title = $this.find('.card-title'); - const $desc = $this.find('.card-text'); - const $image = $imageColumn.find('img'); - if (data.title === '') { - $title.hide(); - } else { - $title.text(data.title); - } + const url = $this.find('a').attr('href'); + if (!url) { + return; + } - if (data.description === '') { - $desc.hide(); - } else { - $desc.text(data.description); - } + fetchGet(settings.endpoint, { url }) + .then((response) => response.json()) + .then((data) => { + const $metaColumn = $this.find('.col-12:last-of-type'); + const $imageColumn = $this.find('.col-12:first-of-type'); + const $title = $this.find('.card-title'); + const $desc = $this.find('.card-text'); + const $image = $imageColumn.find('img'); - if (data.image === '') { - $imageColumn.hide(); - $metaColumn.removeClass('col-md-6'); - } else { - $image.attr('src', data.image); - } + if (data.title === '') { + $title.hide(); + } else { + $title.text(data.title); + } - if (data.title !== '' || data.description !== '' || data.image !== '') { - $this.removeClass('d-none'); - } - }); + if (data.description === '') { + $desc.hide(); + } else { + $desc.text(data.description); + } + + if (data.image === '') { + $imageColumn.hide(); + $metaColumn.removeClass('col-md-6'); + } else { + $image.attr('src', data.image); + } + + if (data.title !== '' || data.description !== '' || data.image !== '') { + $this.removeClass('d-none'); + } + }); }); }; diff --git a/yarn.lock b/yarn.lock index 96ceb48..95f4a21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -849,6 +849,11 @@ resolved "https://registry.yarnpkg.com/@types/q/-/q-1.5.2.tgz#690a1475b84f2a884fd07cd797c00f5f31356ea8" integrity sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw== +"@types/qs@^6.9.4": + version "6.9.4" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.4.tgz#a59e851c1ba16c0513ea123830dd639a0a15cb6a" + integrity sha512-+wYo+L6ZF6BMoEjtf8zB2esQsqdV6WsjRK/GP9WOgLPrq87PbNWgIxS76dS5uvl/QXtHGakZmwTznIfcPXcKlQ== + "@types/sizzle@*": version "2.3.2" resolved "https://registry.yarnpkg.com/@types/sizzle/-/sizzle-2.3.2.tgz#a811b8c18e2babab7d542b3365887ae2e4d9de47" @@ -6684,6 +6689,11 @@ qs@6.7.0: resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== +qs@^6.9.4: + version "6.9.4" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.9.4.tgz#9090b290d1f91728d3c22e54843ca44aea5ab687" + integrity sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ== + querystring-es3@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" From 126e44bcd937360e86bbf83a3c9cbe8ccd713a00 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 6 Aug 2020 09:08:37 +0900 Subject: [PATCH 18/23] =?UTF-8?q?=E4=BB=8A=E6=97=A5=E3=81=8B=E3=82=89jQuer?= =?UTF-8?q?y.ajax=E7=A6=81=E6=AD=A2=E3=81=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 4 +++- package.json | 1 + yarn.lock | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 315b9d6..9c54f9b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,10 +19,12 @@ module.exports = { parser: '@typescript-eslint/parser', sourceType: 'module', }, - plugins: ['prettier', 'vue', '@typescript-eslint'], + plugins: ['prettier', 'vue', '@typescript-eslint', 'jquery'], rules: { '@typescript-eslint/explicit-module-boundary-types': 0, '@typescript-eslint/no-explicit-any': 0, '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }], + 'jquery/no-ajax': 2, + 'jquery/no-ajax-events': 2, }, }; diff --git a/package.json b/package.json index af8a402..ccaf01b 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "date-fns": "^1.30.1", "eslint": "^7.2.0", "eslint-config-prettier": "^6.11.0", + "eslint-plugin-jquery": "^1.5.1", "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-vue": "^6.2.2", "husky": "^1.3.1", diff --git a/yarn.lock b/yarn.lock index 95f4a21..34ff6b3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3035,6 +3035,11 @@ eslint-config-prettier@^6.11.0: dependencies: get-stdin "^6.0.0" +eslint-plugin-jquery@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jquery/-/eslint-plugin-jquery-1.5.1.tgz#d6bac643acf9484ce76394e27e2b07baca06662e" + integrity sha512-L7v1eaK5t80C0lvUXPFP9MKnBOqPSKhCOYyzy4LZ0+iK+TJwN8S9gAkzzP1AOhypRIwA88HF6phQ9C7jnOpW8w== + eslint-plugin-prettier@^3.1.4: version "3.1.4" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.4.tgz#168ab43154e2ea57db992a2cd097c828171f75c2" From 77620c1699f0080b39f0b67405d070524438ca09 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 6 Aug 2020 09:53:50 +0900 Subject: [PATCH 19/23] =?UTF-8?q?x-csrf-token=E3=81=8C=E9=80=81=E3=82=89?= =?UTF-8?q?=E3=82=8C=E3=81=AD=E3=81=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/app.ts | 73 +++++++++++++++--------------------- resources/assets/js/fetch.ts | 40 +++++++++++++------- 2 files changed, 58 insertions(+), 55 deletions(-) diff --git a/resources/assets/js/app.ts b/resources/assets/js/app.ts index 7267f57..1196678 100644 --- a/resources/assets/js/app.ts +++ b/resources/assets/js/app.ts @@ -1,5 +1,5 @@ import * as Cookies from 'js-cookie'; -import jqXHR = JQuery.jqXHR; +import { fetchPostJson, fetchDeleteJson, ResponseError } from './fetch'; require('./bootstrap'); @@ -41,57 +41,46 @@ $(() => { const isLiked = $this.data('liked'); if (isLiked) { - const callback = (data: any) => { - $this.data('liked', false); - $this.find('.oi-heart').removeClass('text-danger'); - - const count = data.ejaculation ? data.ejaculation.likes_count : 0; - $this.find('.like-count').text(count ? count : ''); - }; - - $.ajax({ - url: '/api/likes/' + encodeURIComponent(targetId), - method: 'delete', - type: 'json', - }) - .then(callback) - .catch(function (xhr: jqXHR) { - if (xhr.status === 404) { - callback(JSON.parse(xhr.responseText)); - return; + fetchDeleteJson(`/api/likes/${encodeURIComponent(targetId)}`) + .then((response) => { + if (response.status === 200 || response.status === 404) { + return response.json(); } + throw new ResponseError(response); + }) + .then((data) => { + $this.data('liked', false); + $this.find('.oi-heart').removeClass('text-danger'); - console.error(xhr); + const count = data.ejaculation ? data.ejaculation.likes_count : 0; + $this.find('.like-count').text(count ? count : ''); + }) + .catch((e) => { + console.error(e); alert('いいねを解除できませんでした。'); }); } else { - const callback = (data: any) => { - $this.data('liked', true); - $this.find('.oi-heart').addClass('text-danger'); + fetchPostJson('/api/likes', { id: targetId }) + .then((response) => { + if (response.status === 200 || response.status === 409) { + return response.json(); + } + throw new ResponseError(response); + }) + .then((data) => { + $this.data('liked', true); + $this.find('.oi-heart').addClass('text-danger'); - const count = data.ejaculation ? data.ejaculation.likes_count : 0; - $this.find('.like-count').text(count ? count : ''); - }; - - $.ajax({ - url: '/api/likes', - method: 'post', - type: 'json', - data: { - id: targetId, - }, - }) - .then(callback) - .catch(function (xhr: jqXHR) { - if (xhr.status === 409) { - callback(JSON.parse(xhr.responseText)); - return; - } else if (xhr.status === 401) { + const count = data.ejaculation ? data.ejaculation.likes_count : 0; + $this.find('.like-count').text(count ? count : ''); + }) + .catch((e) => { + if (e instanceof ResponseError && e.response.status === 401) { alert('いいねするためにはログインしてください。'); return; } - console.error(xhr); + console.error(e); alert('いいねできませんでした。'); }); } diff --git a/resources/assets/js/fetch.ts b/resources/assets/js/fetch.ts index d683e62..128aec4 100644 --- a/resources/assets/js/fetch.ts +++ b/resources/assets/js/fetch.ts @@ -17,41 +17,55 @@ const joinParamsToPath = (path: string, params: QueryParams) => const fetchWrapper = (path: string, options: RequestInit = {}) => fetch(path, { credentials: 'same-origin', - headers, + headers: { ...headers, ...options.headers }, ...options, }); -const fetchWithJson = (path: string, body: any, options: RequestInit = {}) => +const fetchWithJson = (path: string, body?: any, options: RequestInit = {}) => fetchWrapper(path, { - body: JSON.stringify(body), - headers: { 'Content-Type': 'application/json' }, + body: body && JSON.stringify(body), + headers: { 'Content-Type': 'application/json', ...options.headers }, ...options, }); -const fetchWithForm = (path: string, body: any, options: RequestInit = {}) => +const fetchWithForm = (path: string, body?: any, options: RequestInit = {}) => fetchWrapper(path, { - body: stringify(body), - headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + body: body && stringify(body), + headers: { 'Content-Type': 'application/x-www-form-urlencoded', ...options.headers }, ...options, }); export const fetchGet = (path: string, params: QueryParams = {}, options: RequestInit = {}) => fetchWrapper(joinParamsToPath(path, params), { method: 'GET', ...options }); -export const fetchPostJson = (path: string, body: any, options: RequestInit = {}) => +export const fetchPostJson = (path: string, body?: any, options: RequestInit = {}) => fetchWithJson(path, body, { method: 'POST', ...options }); -export const fetchPostForm = (path: string, body: any, options: RequestInit = {}) => +export const fetchPostForm = (path: string, body?: any, options: RequestInit = {}) => fetchWithForm(path, body, { method: 'POST', ...options }); -export const fetchPutJson = (path: string, body: any, options: RequestInit = {}) => +export const fetchPutJson = (path: string, body?: any, options: RequestInit = {}) => fetchWithJson(path, body, { method: 'PUT', ...options }); -export const fetchPutForm = (path: string, body: any, options: RequestInit = {}) => +export const fetchPutForm = (path: string, body?: any, options: RequestInit = {}) => fetchWithForm(path, body, { method: 'PUT', ...options }); -export const fetchDeleteJson = (path: string, body: any, options: RequestInit = {}) => +export const fetchDeleteJson = (path: string, body?: any, options: RequestInit = {}) => fetchWithJson(path, body, { method: 'DELETE', ...options }); -export const fetchDeleteForm = (path: string, body: any, options: RequestInit = {}) => +export const fetchDeleteForm = (path: string, body?: any, options: RequestInit = {}) => fetchWithForm(path, body, { method: 'DELETE', ...options }); + +export class ResponseError extends Error { + response: Response; + + constructor(response: Response, ...rest: any) { + super(...rest); + if (Error.captureStackTrace) { + Error.captureStackTrace(this, ResponseError); + } + + this.name = 'ResponseError'; + this.response = response; + } +} From 3a1ec763ea4897217192fcff16a291a028c5a566 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 6 Aug 2020 21:15:36 +0900 Subject: [PATCH 20/23] =?UTF-8?q?fetch:=20=E5=85=B1=E9=80=9Aheader?= =?UTF-8?q?=E3=81=8C=E9=80=81=E3=82=89=E3=82=8C=E3=81=A6=E3=81=AA=E3=81=8B?= =?UTF-8?q?=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/fetch.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/assets/js/fetch.ts b/resources/assets/js/fetch.ts index 128aec4..01e1431 100644 --- a/resources/assets/js/fetch.ts +++ b/resources/assets/js/fetch.ts @@ -17,22 +17,22 @@ const joinParamsToPath = (path: string, params: QueryParams) => const fetchWrapper = (path: string, options: RequestInit = {}) => fetch(path, { credentials: 'same-origin', - headers: { ...headers, ...options.headers }, ...options, + headers: { ...headers, ...options.headers }, }); const fetchWithJson = (path: string, body?: any, options: RequestInit = {}) => fetchWrapper(path, { + ...options, body: body && JSON.stringify(body), headers: { 'Content-Type': 'application/json', ...options.headers }, - ...options, }); const fetchWithForm = (path: string, body?: any, options: RequestInit = {}) => fetchWrapper(path, { + ...options, body: body && stringify(body), headers: { 'Content-Type': 'application/x-www-form-urlencoded', ...options.headers }, - ...options, }); export const fetchGet = (path: string, params: QueryParams = {}, options: RequestInit = {}) => From 7c32ab068d3c745147640e49d02e96224b6dfedf Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 6 Aug 2020 21:31:53 +0900 Subject: [PATCH 21/23] =?UTF-8?q?jQuery.ajax=E3=81=AE=E6=9D=91=E3=82=92?= =?UTF-8?q?=E6=BB=85=E3=81=BC=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/checkin.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/resources/assets/js/checkin.ts b/resources/assets/js/checkin.ts index 7902965..4a1bf50 100644 --- a/resources/assets/js/checkin.ts +++ b/resources/assets/js/checkin.ts @@ -1,6 +1,7 @@ import Vue from 'vue'; import TagInput from './components/TagInput.vue'; import MetadataPreview from './components/MetadataPreview.vue'; +import { fetchGet, ResponseError } from './fetch'; export const bus = new Vue({ name: 'EventBus' }); @@ -47,19 +48,18 @@ new Vue({ fetchMetadata(url: string) { this.metadataLoadState = MetadataLoadState.Loading; - $.ajax({ - url: '/api/checkin/card', - method: 'get', - type: 'json', - data: { - url, - }, - }) + fetchGet('/api/checkin/card', { url }) + .then((response) => { + if (!response.ok) { + throw new ResponseError(response); + } + return response.json(); + }) .then((data) => { this.metadata = data; this.metadataLoadState = MetadataLoadState.Success; }) - .catch((_e) => { + .catch(() => { this.metadata = null; this.metadataLoadState = MetadataLoadState.Failed; }); From 1482c33448c37182bc2fa0fd55ed3575678fac53 Mon Sep 17 00:00:00 2001 From: shibafu Date: Thu, 6 Aug 2020 21:31:59 +0900 Subject: [PATCH 22/23] =?UTF-8?q?jQuery.ajax=E5=90=91=E3=81=91=E3=81=AECSR?= =?UTF-8?q?F=20Token=E8=A8=AD=E5=AE=9A=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/bootstrap.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/resources/assets/js/bootstrap.ts b/resources/assets/js/bootstrap.ts index 99d9e9b..fbfc914 100644 --- a/resources/assets/js/bootstrap.ts +++ b/resources/assets/js/bootstrap.ts @@ -1,17 +1,5 @@ // jQuery import './tissue'; -// Setup global request header -const token = document.head.querySelector('meta[name="csrf-token"]'); -if (!token) { - console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); -} else { - $.ajaxSetup({ - headers: { - 'X-CSRF-TOKEN': token.content, - }, - }); -} - // Bootstrap import 'bootstrap'; From 65077571e7d86cede3ada3e6b1b4dec0cba383cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Aug 2020 14:24:53 +0000 Subject: [PATCH 23/23] Bump eslint from 7.2.0 to 7.6.0 (#456) --- package.json | 2 +- yarn.lock | 253 +++++++++++---------------------------------------- 2 files changed, 52 insertions(+), 203 deletions(-) diff --git a/package.json b/package.json index ccaf01b..63acde8 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "chart.js": "^2.7.1", "cross-env": "^5.2.0", "date-fns": "^1.30.1", - "eslint": "^7.2.0", + "eslint": "^7.6.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-jquery": "^1.5.1", "eslint-plugin-prettier": "^3.1.4", diff --git a/yarn.lock b/yarn.lock index 34ff6b3..e287e43 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,20 +2,13 @@ # yarn lockfile v1 -"@babel/code-frame@^7.0.0": +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.8.3": version "7.10.1" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.1.tgz#d5481c5095daa1c57e16e54c6f9198443afb49ff" integrity sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw== dependencies: "@babel/highlight" "^7.10.1" -"@babel/code-frame@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e" - integrity sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g== - dependencies: - "@babel/highlight" "^7.8.3" - "@babel/compat-data@^7.8.0", "@babel/compat-data@^7.8.1": version "7.8.1" resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.8.1.tgz#fc0bbbb7991e4fb2b47e168e60f2cc2c41680be9" @@ -253,15 +246,6 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/highlight@^7.8.3": - version "7.8.3" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.8.3.tgz#28f173d04223eaaa59bc1d439a3836e6d1265797" - integrity sha512-PX4y5xQUvy0fnEVHrYOarRPXVWafSjTW9T0Hab8gVIawpl2Sj0ORyrygANq+KjcNlSSTw0YCLSNA8OyZ1I4yEg== - dependencies: - chalk "^2.0.0" - esutils "^2.0.2" - js-tokens "^4.0.0" - "@babel/parser@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.8.3.tgz#790874091d2001c9be6ec426c2eed47bc7679081" @@ -1118,11 +1102,16 @@ acorn@^6.0.7, acorn@^6.2.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.1.tgz#531e58ba3f51b9dacb9a6646ca4debf5b14ca474" integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA== -acorn@^7.1.1, acorn@^7.2.0: +acorn@^7.1.1: version "7.2.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.2.0.tgz#17ea7e40d7c8640ff54a694c889c26f31704effe" integrity sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ== +acorn@^7.3.1: + version "7.4.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.0.tgz#e1ad486e6c54501634c6c397c5c121daa383607c" + integrity sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w== + adjust-sourcemap-loader@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/adjust-sourcemap-loader/-/adjust-sourcemap-loader-2.0.0.tgz#6471143af75ec02334b219f54bc7970c52fb29a4" @@ -1144,17 +1133,7 @@ ajv-keywords@^3.1.0, ajv-keywords@^3.4.1: resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.4.1.tgz#ef916e271c64ac12171fd8384eaae6b2345854da" integrity sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ== -ajv@^6.1.0, ajv@^6.10.2: - version "6.11.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.11.0.tgz#c3607cbc8ae392d8a5a536f25b21f8e5f3f87fe9" - integrity sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA== - dependencies: - fast-deep-equal "^3.1.1" - fast-json-stable-stringify "^2.0.0" - json-schema-traverse "^0.4.1" - uri-js "^4.2.2" - -ajv@^6.10.0: +ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2: version "6.12.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.2.tgz#c629c5eced17baf314437918d2da88c99d5958cd" integrity sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ== @@ -1174,18 +1153,16 @@ ansi-colors@^3.0.0: resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.4.tgz#e3a3da4bfbae6c86a9c285625de124a234026fbf" integrity sha512-hHUXGagefjN2iRrID63xckIvotOXOojhQKWIPUZ4mNUZ9nLZW+7FMNoE1lOkEhNWYsx/7ysGIuJYCiMAA9FnrA== +ansi-colors@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + ansi-escapes@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ== -ansi-escapes@^4.2.1: - version "4.3.1" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.1.tgz#a5c47cc43181f1f38ffd7076837700d395522a61" - integrity sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA== - dependencies: - type-fest "^0.11.0" - ansi-html@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e" @@ -1830,14 +1807,6 @@ chalk@^1.0.0, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-3.0.0.tgz#3f73c2bf526591f574cc492c51e2456349f844e4" - integrity sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - chalk@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.0.0.tgz#6e98081ed2d17faab615eb52ac66ec1fe6209e72" @@ -1866,11 +1835,6 @@ character-reference-invalid@^1.0.0: resolved "https://registry.yarnpkg.com/character-reference-invalid/-/character-reference-invalid-1.1.4.tgz#083329cda0eae272ab3dbbf37e9a382c13af1560" integrity sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg== -chardet@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" - integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== - charenc@~0.0.1: version "0.0.2" resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" @@ -1987,13 +1951,6 @@ cli-cursor@^2.0.0, cli-cursor@^2.1.0: dependencies: restore-cursor "^2.0.0" -cli-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" - integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== - dependencies: - restore-cursor "^3.1.0" - cli-truncate@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-0.2.1.tgz#9f15cfbb0705005369216c626ac7d05ab90dd574" @@ -2002,11 +1959,6 @@ cli-truncate@^0.2.1: slice-ansi "0.0.4" string-width "^1.0.1" -cli-width@^2.0.0: - version "2.2.1" - resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.1.tgz#b0433d0b4e9c847ef18868a4ef16fd5fc8271c48" - integrity sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw== - cliui@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49" @@ -2887,11 +2839,6 @@ emoji-regex@^7.0.1: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - emojis-list@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" @@ -2927,6 +2874,13 @@ enhanced-resolve@^4.0.0, enhanced-resolve@^4.1.0: memory-fs "^0.5.0" tapable "^1.0.0" +enquirer@^2.3.5: + version "2.3.6" + resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" + integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== + dependencies: + ansi-colors "^4.1.1" + entities@^1.1.1: version "1.1.2" resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56" @@ -3072,22 +3026,22 @@ eslint-scope@^5.0.0, eslint-scope@^5.1.0: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-utils@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.0.0.tgz#7be1cc70f27a72a76cd14aa698bcabed6890e1cd" - integrity sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA== +eslint-utils@^2.0.0, eslint-utils@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" + integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== dependencies: eslint-visitor-keys "^1.1.0" -eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.2.0.tgz#74415ac884874495f78ec2a97349525344c981fa" - integrity sha512-WFb4ihckKil6hu3Dp798xdzSfddwKKU3+nGniKF6HfeW6OLd2OUDEPP7TcHtB5+QXOKg2s6B2DaMPE1Nn/kxKQ== +eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" + integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== -eslint@^7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.2.0.tgz#d41b2e47804b30dbabb093a967fb283d560082e6" - integrity sha512-B3BtEyaDKC5MlfDa2Ha8/D6DsS4fju95zs0hjS3HdGazw+LNayai38A25qMppK37wWGWNYSPOR6oYzlz5MHsRQ== +eslint@^7.6.0: + version "7.6.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.6.0.tgz#522d67cfaea09724d96949c70e7a0550614d64d6" + integrity sha512-QlAManNtqr7sozWm5TF4wIH9gmUm2hE3vNRUvyoYAa4y1l5/jxD/PQStEjBMQtCqZmSep8UxrcecI60hOpe61w== dependencies: "@babel/code-frame" "^7.0.0" ajv "^6.10.0" @@ -3095,10 +3049,11 @@ eslint@^7.2.0: cross-spawn "^7.0.2" debug "^4.0.1" doctrine "^3.0.0" + enquirer "^2.3.5" eslint-scope "^5.1.0" - eslint-utils "^2.0.0" - eslint-visitor-keys "^1.2.0" - espree "^7.1.0" + eslint-utils "^2.1.0" + eslint-visitor-keys "^1.3.0" + espree "^7.2.0" esquery "^1.2.0" esutils "^2.0.2" file-entry-cache "^5.0.1" @@ -3108,12 +3063,11 @@ eslint@^7.2.0: ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" - inquirer "^7.0.0" is-glob "^4.0.0" js-yaml "^3.13.1" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" - lodash "^4.17.14" + lodash "^4.17.19" minimatch "^3.0.4" natural-compare "^1.4.0" optionator "^0.9.1" @@ -3135,14 +3089,14 @@ espree@^6.2.1: acorn-jsx "^5.2.0" eslint-visitor-keys "^1.1.0" -espree@^7.1.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-7.1.0.tgz#a9c7f18a752056735bf1ba14cb1b70adc3a5ce1c" - integrity sha512-dcorZSyfmm4WTuTnE5Y7MEN1DyoPYy1ZR783QW1FJoenn7RailyWFsq/UL6ZAAA7uXurN9FIpYyUs3OfiIW+Qw== +espree@^7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-7.2.0.tgz#1c263d5b513dbad0ac30c4991b93ac354e948d69" + integrity sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g== dependencies: - acorn "^7.2.0" + acorn "^7.3.1" acorn-jsx "^5.2.0" - eslint-visitor-keys "^1.2.0" + eslint-visitor-keys "^1.3.0" esprima@^4.0.0: version "4.0.1" @@ -3316,15 +3270,6 @@ extend@^3.0.0: resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== -external-editor@^3.0.3: - version "3.1.0" - resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" - integrity sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew== - dependencies: - chardet "^0.7.0" - iconv-lite "^0.4.24" - tmp "^0.0.33" - extglob@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" @@ -3420,13 +3365,6 @@ figures@^2.0.0: dependencies: escape-string-regexp "^1.0.5" -figures@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-3.2.0.tgz#625c18bd293c604dc4a8ddb2febf0c88341746af" - integrity sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg== - dependencies: - escape-string-regexp "^1.0.5" - file-entry-cache@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-4.0.0.tgz#633567d15364aefe0b299e1e217735e8f3a9f6e8" @@ -3701,20 +3639,13 @@ glob-parent@^3.1.0: is-glob "^3.1.0" path-dirname "^1.0.0" -glob-parent@^5.0.0: +glob-parent@^5.0.0, glob-parent@~5.1.0: version "5.1.1" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== dependencies: is-glob "^4.0.1" -glob-parent@~5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.0.tgz#5f4c1d1e748d30cd73ad2944b3577a81b081e8c2" - integrity sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw== - dependencies: - is-glob "^4.0.1" - glob-to-regexp@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab" @@ -4130,7 +4061,7 @@ husky@^1.3.1: run-node "^1.0.0" slash "^2.0.0" -iconv-lite@0.4.24, iconv-lite@^0.4.24: +iconv-lite@0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -4284,25 +4215,6 @@ ini@^1.3.4, ini@^1.3.5: resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== -inquirer@^7.0.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.1.0.tgz#1298a01859883e17c7264b82870ae1034f92dd29" - integrity sha512-5fJMWEmikSYu0nv/flMc475MhGbB7TSPd/2IpFV4I4rMklboCH2rQjYY5kKiYGHqUF9gvaambupcJFFG9dvReg== - dependencies: - ansi-escapes "^4.2.1" - chalk "^3.0.0" - cli-cursor "^3.1.0" - cli-width "^2.0.0" - external-editor "^3.0.3" - figures "^3.0.0" - lodash "^4.17.15" - mute-stream "0.0.8" - run-async "^2.4.0" - rxjs "^6.5.3" - string-width "^4.1.0" - strip-ansi "^6.0.0" - through "^2.3.6" - internal-ip@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/internal-ip/-/internal-ip-4.3.0.tgz#845452baad9d2ca3b69c635a137acb9a0dad0907" @@ -4529,11 +4441,6 @@ is-fullwidth-code-point@^2.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - is-glob@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" @@ -5043,10 +4950,10 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.17.5: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== +lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.17.5: + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== log-symbols@^1.0.2: version "1.0.2" @@ -5346,7 +5253,7 @@ mimic-fn@^1.0.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== -mimic-fn@^2.0.0, mimic-fn@^2.1.0: +mimic-fn@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== @@ -5467,11 +5374,6 @@ multicast-dns@^6.0.1: dns-packet "^1.3.1" thunky "^1.0.2" -mute-stream@0.0.8: - version "0.0.8" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" - integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== - nan@^2.12.1: version "2.14.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c" @@ -5769,13 +5671,6 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" -onetime@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.0.tgz#fff0f3c91617fe62bb50189636e99ac8a6df7be5" - integrity sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q== - dependencies: - mimic-fn "^2.1.0" - open-iconic@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/open-iconic/-/open-iconic-1.1.1.tgz#9dcfc8c7cd3c61cdb4a236b1a347894c97adc0c6" @@ -5834,11 +5729,6 @@ os-locale@^3.0.0, os-locale@^3.1.0: lcid "^2.0.0" mem "^4.0.0" -os-tmpdir@~1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" - integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= - p-defer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" @@ -7082,14 +6972,6 @@ restore-cursor@^2.0.0: onetime "^2.0.0" signal-exit "^3.0.2" -restore-cursor@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" - integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== - dependencies: - onetime "^5.1.0" - signal-exit "^3.0.2" - ret@~0.1.10: version "0.1.15" resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" @@ -7145,11 +7027,6 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^3.0.0" inherits "^2.0.1" -run-async@^2.4.0: - version "2.4.1" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" - integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== - run-node@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/run-node/-/run-node-1.0.0.tgz#46b50b946a2aa2d4947ae1d886e9856fd9cabe5e" @@ -7169,13 +7046,6 @@ rxjs@^6.3.3: dependencies: tslib "^1.9.0" -rxjs@^6.5.3: - version "6.5.5" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.5.tgz#c5c884e3094c8cfee31bf27eb87e54ccfc87f9ec" - integrity sha512-WfQI+1gohdf0Dai/Bbmk5L5ItH5tYqm3ki2c5GdWhKjalzjg93N3avFjVStyZZz+A2Em+ZxKH5bNghw9UeylGQ== - dependencies: - tslib "^1.9.0" - safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" @@ -7697,15 +7567,6 @@ string-width@^3.0.0, string-width@^3.1.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" -string-width@^4.1.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" - integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" - string.prototype.trimleft@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz#9bdb8ac6abd6d602b17a4ed321870d2f8dcefc74" @@ -8022,7 +7883,7 @@ through2@^2.0.0: readable-stream "~2.3.6" xtend "~4.0.1" -through@^2.3.6, through@~2.3.6: +through@~2.3.6: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= @@ -8044,13 +7905,6 @@ timsort@^0.3.0: resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4" integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q= -tmp@^0.0.33: - version "0.0.33" - resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" - integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== - dependencies: - os-tmpdir "~1.0.2" - to-arraybuffer@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" @@ -8168,11 +8022,6 @@ type-check@^0.4.0, type-check@~0.4.0: dependencies: prelude-ls "^1.2.1" -type-fest@^0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1" - integrity sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ== - type-fest@^0.8.1: version "0.8.1" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"