From b5a182d25c321af31a4ae317d19556249344fc0b Mon Sep 17 00:00:00 2001 From: Kazuki Tobita Date: Mon, 26 Jun 2023 20:43:51 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E3=81=AA=E9=99=90=E3=82=8AES=20Modules=E5=BD=A2?= =?UTF-8?q?=E5=BC=8F=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .lintstagedrc.js | 4 ++-- .svgrrc.js => .svgrrc.cjs | 0 changelog.config.js => changelog.config.cjs | 0 next.config.js | 5 +++-- package.json | 1 + src/scripts/generateImages.js | 6 +++--- src/scripts/lighthouse.js | 4 ++-- 7 files changed, 11 insertions(+), 9 deletions(-) rename .svgrrc.js => .svgrrc.cjs (100%) rename changelog.config.js => changelog.config.cjs (100%) diff --git a/.lintstagedrc.js b/.lintstagedrc.js index 7afe01e3..08447df9 100644 --- a/.lintstagedrc.js +++ b/.lintstagedrc.js @@ -1,4 +1,4 @@ -const path = require('path'); +import path from 'path'; const buildEslintCommand = (filenames) => { return `next lint --fix --file ${filenames @@ -6,7 +6,7 @@ const buildEslintCommand = (filenames) => { .join(' --file ')}`; }; -module.exports = { +export default { '*.{js,jsx,ts,tsx}': [buildEslintCommand], '*.{js,jsx,ts,tsx,json,html,css,yml,yaml}': 'yarn fix:prettier', '*.*': 'yarn lint:ls', diff --git a/.svgrrc.js b/.svgrrc.cjs similarity index 100% rename from .svgrrc.js rename to .svgrrc.cjs diff --git a/changelog.config.js b/changelog.config.cjs similarity index 100% rename from changelog.config.js rename to changelog.config.cjs diff --git a/next.config.js b/next.config.js index 9854f1d4..06bb7fe2 100644 --- a/next.config.js +++ b/next.config.js @@ -1,4 +1,5 @@ -const { createVanillaExtractPlugin } = require('@vanilla-extract/next-plugin'); +import { createVanillaExtractPlugin } from '@vanilla-extract/next-plugin'; + const withVanillaExtract = createVanillaExtractPlugin(); const nextConfig = { @@ -8,4 +9,4 @@ const nextConfig = { }, }; -module.exports = withVanillaExtract(nextConfig); +export default withVanillaExtract(nextConfig); diff --git a/package.json b/package.json index 5ec0a545..d2eac0ae 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "official", "version": "0.1.0", "private": true, + "type": "module", "scripts": { "dev": "next dev", "build": "yarn pathpida && next build && next export", diff --git a/src/scripts/generateImages.js b/src/scripts/generateImages.js index d25834e1..2337ea60 100644 --- a/src/scripts/generateImages.js +++ b/src/scripts/generateImages.js @@ -1,7 +1,7 @@ -const fs = require('fs'); -const path = require('path'); +import fs from 'fs'; +import path from 'path'; -const sharp = require('sharp'); +import sharp from 'sharp'; /** * スマホ用の画像を生成する diff --git a/src/scripts/lighthouse.js b/src/scripts/lighthouse.js index 7bebfaac..713b23bf 100644 --- a/src/scripts/lighthouse.js +++ b/src/scripts/lighthouse.js @@ -1,6 +1,6 @@ -const { execSync } = require('child_process'); +import { execSync } from 'child_process'; -const minimist = require('minimist'); +import minimist from 'minimist'; const argv = minimist(process.argv.slice(2)); const port = argv.p || 3000; From b0b28fe9c8cc522c311f40ccc5368864cb34be7a Mon Sep 17 00:00:00 2001 From: Kazuki Tobita Date: Tue, 27 Jun 2023 03:28:10 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E2=9C=A8=20feat:=20ts-node=E3=81=AE?= =?UTF-8?q?=E5=B0=8E=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 6 +- .../{generateImages.js => generateImages.ts} | 12 ++- src/scripts/{lighthouse.js => lighthouse.ts} | 0 yarn.lock | 101 ++++++++++++++++-- 4 files changed, 107 insertions(+), 12 deletions(-) rename src/scripts/{generateImages.js => generateImages.ts} (87%) rename src/scripts/{lighthouse.js => lighthouse.ts} (100%) diff --git a/package.json b/package.json index d2eac0ae..74bed016 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "build-storybook": "build-storybook -s public", "pathpida": "pathpida --enableStatic --ignorePath .pathpidaignore --output src/utils/ && prettier --write 'src/utils/$path.ts'", "icons": "svgr -d src/components/base/Icons src/assets/icons", - "images": "node src/scripts/generateImages.js", - "lighthouse": "node src/scripts/lighthouse.js" + "images": "ts-node --esm src/scripts/generateImages.ts", + "lighthouse": "ts-node --esm src/scripts/lighthouse.ts" }, "dependencies": { "@headlessui/react": "^1.7.4", @@ -42,6 +42,7 @@ "@storybook/manager-webpack5": "^6.5.15", "@storybook/react": "^6.5.15", "@svgr/cli": "^6.5.1", + "@types/minimist": "^1.2.2", "@types/node": "18.15.0", "@types/react": "18.0.28", "@types/react-dom": "18.0.11", @@ -66,6 +67,7 @@ "prettier": "^2.8.3", "sharp": "^0.32.1", "storybook-addon-next": "^1.7.1", + "ts-node": "^10.9.1", "typescript": "4.9.5" }, "engines": { diff --git a/src/scripts/generateImages.js b/src/scripts/generateImages.ts similarity index 87% rename from src/scripts/generateImages.js rename to src/scripts/generateImages.ts index 2337ea60..251a66d5 100644 --- a/src/scripts/generateImages.js +++ b/src/scripts/generateImages.ts @@ -1,17 +1,21 @@ import fs from 'fs'; import path from 'path'; +import { fileURLToPath } from 'url'; import sharp from 'sharp'; +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + /** * スマホ用の画像を生成する * @param {string} fullPath * @param {string} outputPath */ -const generateMobileImage = async (fullPath, outputPath) => { +const generateMobileImage = async (fullPath: any, outputPath: any) => { if (fs.existsSync(outputPath)) return; const image = sharp(fullPath); - const metadata = await image.metadata(); + const metadata: any = await image.metadata(); await image .resize({ width: Math.round(metadata.width / 2), @@ -25,7 +29,7 @@ const generateMobileImage = async (fullPath, outputPath) => { * @param {string} fullPath * @param {string} outputPath */ -const generateDesktopImage = async (fullPath, outputPath) => { +const generateDesktopImage = async (fullPath: any, outputPath: any) => { if (fs.existsSync(outputPath)) return; await sharp(fullPath).toFile(outputPath); }; @@ -35,7 +39,7 @@ const generateDesktopImage = async (fullPath, outputPath) => { * またそれぞれの拡張子に応じたスマホ用のファイルも生成する * @param {string} dirPath */ -const generateImages = async (dirPath) => { +const generateImages = async (dirPath: any) => { const entries = fs.readdirSync(dirPath, { withFileTypes: true }); const ignoreDirs = fs .readFileSync(path.join(__dirname, '../..', '.imagesignore'), 'utf-8') diff --git a/src/scripts/lighthouse.js b/src/scripts/lighthouse.ts similarity index 100% rename from src/scripts/lighthouse.js rename to src/scripts/lighthouse.ts diff --git a/yarn.lock b/yarn.lock index 170739e2..63264595 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1500,6 +1500,13 @@ resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== +"@cspotcode/source-map-support@^0.8.0": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== + dependencies: + "@jridgewell/trace-mapping" "0.3.9" + "@discoveryjs/json-ext@^0.5.3": version "0.5.7" resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" @@ -1651,6 +1658,14 @@ resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz#771a1d8d744eeb71b6adb35808e1a6c7b9b8c8ec" integrity sha512-Fg32GrJo61m+VqYSdRSjRXMjQ06j8YIYfcTqndLYVAaHmroZHLJZCydsWBOTDqXS2v+mjxohBWEMfg97GXmYQg== +"@jridgewell/trace-mapping@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping@^0.3.0": version "0.3.4" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.4.tgz#f6a0832dffd5b8a6aaa633b7d9f8e8e94c83a0c3" @@ -2986,6 +3001,26 @@ resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad" integrity sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA== +"@tsconfig/node10@^1.0.7": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" + integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== + +"@tsconfig/node12@^1.0.7": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" + integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== + +"@tsconfig/node14@^1.0.0": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" + integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== + +"@tsconfig/node16@^1.0.2": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" + integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== + "@types/eslint-scope@^3.7.3": version "3.7.4" resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.4.tgz#37fc1223f0786c39627068a12e94d6e6fc61de16" @@ -3108,6 +3143,11 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca" integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA== +"@types/minimist@^1.2.2": + version "1.2.2" + resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c" + integrity sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ== + "@types/node-fetch@^2.5.7": version "2.6.2" resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.2.tgz#d1a9c5fd049d9415dce61571557104dec3ec81da" @@ -3723,7 +3763,7 @@ acorn-walk@^7.2.0: resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-7.2.0.tgz#0de889a601203909b0fbe07b8938dc21d2e967bc" integrity sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA== -acorn-walk@^8.2.0: +acorn-walk@^8.1.1, acorn-walk@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== @@ -3738,16 +3778,16 @@ acorn@^7.4.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== +acorn@^8.4.1, acorn@^8.7.0: + version "8.9.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.9.0.tgz#78a16e3b2bcc198c10822786fa6679e245db5b59" + integrity sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ== + acorn@^8.5.0, acorn@^8.7.1: version "8.8.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8" integrity sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w== -acorn@^8.7.0: - version "8.9.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.9.0.tgz#78a16e3b2bcc198c10822786fa6679e245db5b59" - integrity sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ== - acorn@^8.8.0: version "8.8.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.1.tgz#0a3f9cbecc4ec3bea6f0a80b66ae8dd2da250b73" @@ -3940,6 +3980,11 @@ are-we-there-yet@^2.0.0: delegates "^1.0.0" readable-stream "^3.6.0" +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" @@ -5392,6 +5437,11 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: safe-buffer "^5.0.1" sha.js "^2.4.8" +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + cross-fetch@3.1.6: version "3.1.6" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.6.tgz#bae05aa31a4da760969756318feeee6e70f15d6c" @@ -5778,6 +5828,11 @@ devtools-protocol@0.0.1155343: resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.1155343.tgz#9e4ce46e9b05a1be6d6b629fbfaa1a38b1c18a3b" integrity sha512-oD9vGBV2wTc7fAzAM6KC0chSgs234V8+qDEeK+mcbRj2UvcuA7lgBztGi/opj/iahcXD3BSj8Ymvib628yy9FA== +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + diffie-hellman@^5.0.0: version "5.0.3" resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" @@ -8910,6 +8965,11 @@ make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0: dependencies: semver "^6.0.0" +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + makeerror@1.0.12: version "1.0.12" resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.12.tgz#3e5dd2079a82e812e983cc6610c4a2cb0eaa801a" @@ -12340,6 +12400,25 @@ ts-dedent@^2.0.0, ts-dedent@^2.2.0: resolved "https://registry.yarnpkg.com/ts-dedent/-/ts-dedent-2.2.0.tgz#39e4bd297cd036292ae2394eb3412be63f563bb5" integrity sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ== +ts-node@^10.9.1: + version "10.9.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" + integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== + dependencies: + "@cspotcode/source-map-support" "^0.8.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + v8-compile-cache-lib "^3.0.1" + yn "3.1.1" + ts-pnp@^1.1.6: version "1.2.0" resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92" @@ -12774,6 +12853,11 @@ uuid@^3.3.2: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== +v8-compile-cache-lib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + v8-to-istanbul@^9.0.0: version "9.0.1" resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.0.1.tgz#b6f994b0b5d4ef255e17a0d17dc444a9f5132fa4" @@ -13251,6 +13335,11 @@ yauzl@^2.10.0: buffer-crc32 "~0.2.3" fd-slicer "~1.1.0" +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" From 8f768c411c70de213b26591c317e905a7947ed62 Mon Sep 17 00:00:00 2001 From: Kazuki Tobita Date: Tue, 27 Jun 2023 03:32:36 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=8E=A8=20chore:=20=E3=82=AA=E3=83=97?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=A7=E3=81=AF=E3=81=AA=E3=81=8F?= =?UTF-8?q?tsconfig.json=E3=81=A7=E8=A8=AD=E5=AE=9A=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- tsconfig.json | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 74bed016..df14a02f 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,8 @@ "build-storybook": "build-storybook -s public", "pathpida": "pathpida --enableStatic --ignorePath .pathpidaignore --output src/utils/ && prettier --write 'src/utils/$path.ts'", "icons": "svgr -d src/components/base/Icons src/assets/icons", - "images": "ts-node --esm src/scripts/generateImages.ts", - "lighthouse": "ts-node --esm src/scripts/lighthouse.ts" + "images": "ts-node src/scripts/generateImages.ts", + "lighthouse": "ts-node src/scripts/lighthouse.ts" }, "dependencies": { "@headlessui/react": "^1.7.4", diff --git a/tsconfig.json b/tsconfig.json index 87e09173..fa7485c3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,5 +21,9 @@ "incremental": true }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], - "exclude": ["node_modules"] + "exclude": ["node_modules"], + "ts-node": { + "esm": true, + "experimentalSpecifierResolution": "node" + } } From 8c9d9061cd6153ac8297c83da169cf0b9b725aa6 Mon Sep 17 00:00:00 2001 From: Kazuki Tobita Date: Tue, 27 Jun 2023 03:45:34 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20=E5=9E=8B?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9=E3=82=92=E5=8E=B3=E5=AF=86=E3=81=AB=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/generateImages.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/scripts/generateImages.ts b/src/scripts/generateImages.ts index 251a66d5..77c5dcdc 100644 --- a/src/scripts/generateImages.ts +++ b/src/scripts/generateImages.ts @@ -12,10 +12,14 @@ const __dirname = path.dirname(__filename); * @param {string} fullPath * @param {string} outputPath */ -const generateMobileImage = async (fullPath: any, outputPath: any) => { +const generateMobileImage = async (fullPath: string, outputPath: string): Promise => { if (fs.existsSync(outputPath)) return; const image = sharp(fullPath); - const metadata: any = await image.metadata(); + const metadata = await image.metadata(); + + // 通常は発生しないフローだが型定義が`undefined`を許容しており、TSの警告を回避するために記述している + if (!metadata.width || !metadata.height) return; + await image .resize({ width: Math.round(metadata.width / 2), @@ -29,7 +33,7 @@ const generateMobileImage = async (fullPath: any, outputPath: any) => { * @param {string} fullPath * @param {string} outputPath */ -const generateDesktopImage = async (fullPath: any, outputPath: any) => { +const generateDesktopImage = async (fullPath: string, outputPath: string): Promise => { if (fs.existsSync(outputPath)) return; await sharp(fullPath).toFile(outputPath); }; @@ -39,7 +43,7 @@ const generateDesktopImage = async (fullPath: any, outputPath: any) => { * またそれぞれの拡張子に応じたスマホ用のファイルも生成する * @param {string} dirPath */ -const generateImages = async (dirPath: any) => { +const generateImages = async (dirPath: string): Promise => { const entries = fs.readdirSync(dirPath, { withFileTypes: true }); const ignoreDirs = fs .readFileSync(path.join(__dirname, '../..', '.imagesignore'), 'utf-8') From 90ef451b28baa753a3c84ba4483f4744a89ccdc8 Mon Sep 17 00:00:00 2001 From: Kazuki Tobita Date: Tue, 27 Jun 2023 03:49:34 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=92=84=20style:=20=E5=9E=8B=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=81=AB=E3=82=88=E3=82=8AJSDoc=E3=81=8C=E4=B8=8D?= =?UTF-8?q?=E8=A6=81=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F=E3=81=9F=E3=82=81?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/generateImages.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/scripts/generateImages.ts b/src/scripts/generateImages.ts index 77c5dcdc..f1d72e1d 100644 --- a/src/scripts/generateImages.ts +++ b/src/scripts/generateImages.ts @@ -9,8 +9,6 @@ const __dirname = path.dirname(__filename); /** * スマホ用の画像を生成する - * @param {string} fullPath - * @param {string} outputPath */ const generateMobileImage = async (fullPath: string, outputPath: string): Promise => { if (fs.existsSync(outputPath)) return; @@ -30,8 +28,6 @@ const generateMobileImage = async (fullPath: string, outputPath: string): Promis /** * デスクトップ用の画像を生成する - * @param {string} fullPath - * @param {string} outputPath */ const generateDesktopImage = async (fullPath: string, outputPath: string): Promise => { if (fs.existsSync(outputPath)) return; @@ -41,7 +37,6 @@ const generateDesktopImage = async (fullPath: string, outputPath: string): Promi /** * /public/images 以下のディレクトリ内にある png または jpg(jpeg) ファイルを元に webp と avif ファイルを生成する * またそれぞれの拡張子に応じたスマホ用のファイルも生成する - * @param {string} dirPath */ const generateImages = async (dirPath: string): Promise => { const entries = fs.readdirSync(dirPath, { withFileTypes: true }); From 69c55bd6537d204e9edff1cc78a96a94d0ca06c9 Mon Sep 17 00:00:00 2001 From: Kazuki Tobita Date: Tue, 18 Jul 2023 00:41:47 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=92=84=20style:=20package.json?= =?UTF-8?q?=E3=81=AEdeps=E3=81=AE=E9=A0=86=E7=95=AA=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 50919b06..fb196f64 100644 --- a/package.json +++ b/package.json @@ -64,9 +64,9 @@ "pathpida": "^0.20.1", "prettier": "^2.8.3", "sharp": "^0.32.1", + "storybook": "^7.0.26", "ts-node": "^10.9.1", "typescript": "4.9.5", - "storybook": "^7.0.26", "webpack-merge": "^5.9.0" }, "engines": {