From 0db2bc4e04fbc2b9de522822e226c601fe603f78 Mon Sep 17 00:00:00 2001 From: Hideaki Noshiro <46040697+noshiro-pf@users.noreply.github.com> Date: Wed, 28 Aug 2024 14:19:43 +0900 Subject: [PATCH] feat: create slack-archive-tools (#1286) --- .prettierignore | 2 + package.json | 2 +- .../others/slack-archive-tools/.gitignore | 2 + .../configs/rollup.config.ts | 11 ++++ .../configs/tsconfig.build.json | 13 +++++ .../configs/tsconfig.test.json | 7 +++ .../configs/vitest.config.ts | 18 +++++++ .../slack-archive-tools/eslint.config.js | 45 ++++++++++++++++ .../others/slack-archive-tools/package.json | 53 +++++++++++++++++++ .../others/slack-archive-tools/src/main.mts | 5 ++ .../others/slack-archive-tools/tsconfig.json | 7 +++ yarn.lock | 42 +++++---------- 12 files changed, 177 insertions(+), 30 deletions(-) create mode 100644 packages/others/slack-archive-tools/.gitignore create mode 100644 packages/others/slack-archive-tools/configs/rollup.config.ts create mode 100644 packages/others/slack-archive-tools/configs/tsconfig.build.json create mode 100644 packages/others/slack-archive-tools/configs/tsconfig.test.json create mode 100644 packages/others/slack-archive-tools/configs/vitest.config.ts create mode 100644 packages/others/slack-archive-tools/eslint.config.js create mode 100644 packages/others/slack-archive-tools/package.json create mode 100644 packages/others/slack-archive-tools/src/main.mts create mode 100644 packages/others/slack-archive-tools/tsconfig.json diff --git a/.prettierignore b/.prettierignore index 36867bbd7a..8dfa2c22aa 100644 --- a/.prettierignore +++ b/.prettierignore @@ -47,6 +47,8 @@ packages/strict-ts-lib/output-branded/diff packages/strict-ts-lib/output-branded/final packages/strict-ts-lib/output-branded/packages +packages/others/slack-archive-tools/archive + # Optional eslint cache .eslintcache .eslintcache-deps diff --git a/package.json b/package.json index 4d6282c9b4..676d520ab9 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "@rollup/plugin-typescript": "^11.1.6", "@types/argparse": "^2.0.16", "@types/jest": "^29.5.12", - "@types/node": "^20.11.24", + "@types/node": "20.12", "@types/nodemailer": "^6.4.4", "@types/react": "^18.2.61", "@types/react-dom": "^18.2.24", diff --git a/packages/others/slack-archive-tools/.gitignore b/packages/others/slack-archive-tools/.gitignore new file mode 100644 index 0000000000..4f0e12372f --- /dev/null +++ b/packages/others/slack-archive-tools/.gitignore @@ -0,0 +1,2 @@ +archive/**/* +archive/* diff --git a/packages/others/slack-archive-tools/configs/rollup.config.ts b/packages/others/slack-archive-tools/configs/rollup.config.ts new file mode 100644 index 0000000000..dce200a1dd --- /dev/null +++ b/packages/others/slack-archive-tools/configs/rollup.config.ts @@ -0,0 +1,11 @@ +/* eslint-disable import/no-default-export */ +/* eslint-disable import/no-internal-modules */ + +import { toThisDir } from '@noshiro/mono-scripts'; +import { defineRollupConfig } from '../../../../configs/define-rollup-config.mjs'; +import tsconfig from './tsconfig.build.json' assert { type: 'json' }; + +export default defineRollupConfig({ + configDir: toThisDir(import.meta.url), + outDirRelative: tsconfig.compilerOptions.outDir, +}); diff --git a/packages/others/slack-archive-tools/configs/tsconfig.build.json b/packages/others/slack-archive-tools/configs/tsconfig.build.json new file mode 100644 index 0000000000..5d190edb0f --- /dev/null +++ b/packages/others/slack-archive-tools/configs/tsconfig.build.json @@ -0,0 +1,13 @@ +{ + "extends": [ + "../../../../configs/tsconfig/tsconfig.lib.build.json", + "../../../../configs/tsconfig/tsconfig.vite.json" + ], + "compilerOptions": { + "outDir": "../dist", + "declarationDir": "../dist", + "rootDir": "../src" + }, + "include": ["../src"], + "exclude": ["../src/**/*.test.mts"] +} diff --git a/packages/others/slack-archive-tools/configs/tsconfig.test.json b/packages/others/slack-archive-tools/configs/tsconfig.test.json new file mode 100644 index 0000000000..4a6232c488 --- /dev/null +++ b/packages/others/slack-archive-tools/configs/tsconfig.test.json @@ -0,0 +1,7 @@ +{ + "extends": [ + "../../../../configs/tsconfig/tsconfig.test.json", + "../../../../configs/tsconfig/tsconfig.vite.json" + ], + "include": ["../src"] +} diff --git a/packages/others/slack-archive-tools/configs/vitest.config.ts b/packages/others/slack-archive-tools/configs/vitest.config.ts new file mode 100644 index 0000000000..ccf90bbe69 --- /dev/null +++ b/packages/others/slack-archive-tools/configs/vitest.config.ts @@ -0,0 +1,18 @@ +import { toThisDir } from '@noshiro/mono-scripts'; +import * as nodePath from 'node:path'; +import { defineConfig } from 'vitest/config'; + +const thisDir: string = toThisDir(import.meta.url); + +// https://github.com/vitest-dev/vitest/blob/v1.5.0/test/import-meta/vite.config.ts +export default defineConfig({ + test: { + globals: true, + dir: nodePath.resolve(thisDir, '../src'), + includeSource: [nodePath.resolve(thisDir, '../src/**/*.mts')], + typecheck: { + tsconfig: nodePath.resolve(thisDir, 'tsconfig.test.json'), + }, + passWithNoTests: true, + }, +}); diff --git a/packages/others/slack-archive-tools/eslint.config.js b/packages/others/slack-archive-tools/eslint.config.js new file mode 100644 index 0000000000..7c85228f15 --- /dev/null +++ b/packages/others/slack-archive-tools/eslint.config.js @@ -0,0 +1,45 @@ +/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */ + +import { + eslintFlatConfigForTypeScript, + eslintFlatConfigForVitest, + genEsLintRestrictedImportsDefFromDevDependencies, +} from '@noshiro/eslint-configs'; +import { toThisDir } from '@noshiro/mono-scripts'; +import * as nodePath from 'node:path'; +import packageJson from './package.json' assert { type: 'json' }; + +const thisDir = toThisDir(import.meta.url); + +/** @returns {Promise} */ +const defineConfig = async () => { + const restrictedImports = + await genEsLintRestrictedImportsDefFromDevDependencies( + packageJson.devDependencies, + ); + + /** @type {readonly FlatConfig[]} */ + const configs = [ + ...eslintFlatConfigForTypeScript({ + tsconfigRootDir: thisDir, + tsconfigFileName: './tsconfig.json', + packageDirs: [nodePath.resolve(thisDir, '../../..'), thisDir], + }), + eslintFlatConfigForVitest(), + + { + rules: { + '@typescript-eslint/no-restricted-imports': [ + 'error', + ...restrictedImports, + ], + 'security/detect-non-literal-fs-filename': 'off', + 'no-await-in-loop': 'off', + }, + }, + ]; + + return configs; +}; + +export default defineConfig(); diff --git a/packages/others/slack-archive-tools/package.json b/packages/others/slack-archive-tools/package.json new file mode 100644 index 0000000000..06e30ea35a --- /dev/null +++ b/packages/others/slack-archive-tools/package.json @@ -0,0 +1,53 @@ +{ + "name": "@noshiro/slack-archive-tools", + "version": "1.0.0", + "license": "MIT", + "author": "noshiro-pf ", + "sideEffects": true, + "type": "module", + "main": "main.mjs", + "scripts": { + "build": "wireit", + "clean": "run-p clean:build clean:wireit", + "clean:build": "rimraf esm", + "clean:src": "rimraf src/*.mts", + "clean:wireit": "rimraf .wireit/**", + "fmt": "yarn zz:prettier .", + "lint": "yarn zz:eslint:src", + "lint:fix": "yarn zz:eslint:src --fix", + "main": "wireit", + "test": "yarn zz:vitest run", + "testw": "yarn zz:vitest watch", + "tsc": "yarn type-check", + "tscw": "tsc --noEmit --watch", + "type-check": "tsc --noEmit", + "zz:eslint": "ESLINT_USE_FLAT_CONFIG=true TIMING=1 eslint", + "zz:eslint:print-config": "yarn zz:eslint --print-config src/index.mts", + "zz:eslint:src": "yarn zz:eslint --config eslint.config.js './src/**/*'", + "zz:prettier": "prettier --cache --cache-strategy content --ignore-path ../../../.prettierignore --write", + "zz:vitest": "vitest --config ./configs/vitest.config.ts" + }, + "dependencies": { + "@noshiro/io-ts": "*", + "@noshiro/ts-utils": "*" + }, + "devDependencies": { + "@noshiro/eslint-configs": "*", + "@noshiro/mono-scripts": "*", + "@noshiro/ts-type-utils": "*" + }, + "wireit": { + "build": { + "dependencies": [ + "clean:build" + ], + "command": "rollup --config ./configs/rollup.config.ts --configPlugin typescript" + }, + "main": { + "dependencies": [ + "build" + ], + "command": "node ./dist/main.mjs" + } + } +} diff --git a/packages/others/slack-archive-tools/src/main.mts b/packages/others/slack-archive-tools/src/main.mts new file mode 100644 index 0000000000..3fab837e64 --- /dev/null +++ b/packages/others/slack-archive-tools/src/main.mts @@ -0,0 +1,5 @@ +export const main = (): void => { + console.log('TODO'); +}; + +main(); diff --git a/packages/others/slack-archive-tools/tsconfig.json b/packages/others/slack-archive-tools/tsconfig.json new file mode 100644 index 0000000000..b97bffa617 --- /dev/null +++ b/packages/others/slack-archive-tools/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": [ + "../../../configs/tsconfig/tsconfig.lib.type-check.json", + "../../../configs/tsconfig/tsconfig.vite.json" + ], + "include": ["./src", "./configs"] +} diff --git a/yarn.lock b/yarn.lock index 1296fa3eed..4a3f68dc41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4617,13 +4617,20 @@ resolved "https://registry.yarnpkg.com/@types/ms/-/ms-0.7.34.tgz#10964ba0dee6ac4cd462e2795b6bebd407303433" integrity sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g== -"@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@^20.10.3", "@types/node@^20.11.24": +"@types/node@*", "@types/node@>=12.12.47", "@types/node@>=13.7.0", "@types/node@^20.10.3": version "20.11.24" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.24.tgz#cc207511104694e84e9fb17f9a0c4c42d4517792" integrity sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long== dependencies: undici-types "~5.26.4" +"@types/node@20.12": + version "20.12.14" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.12.14.tgz#0c5cf7ef26aedfd64b0539bba9380ed1f57dcc77" + integrity sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg== + dependencies: + undici-types "~5.26.4" + "@types/node@^16.9.2": version "16.18.69" resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.69.tgz#84853c5562baeabc6e864e36ea106f8c09495b24" @@ -16520,7 +16527,8 @@ string-length@^4.0.1: char-regex "^1.0.2" strip-ansi "^6.0.0" -"string-width-cjs@npm:string-width@^4.2.0": +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: + name string-width-cjs version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -16538,15 +16546,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.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - string-width@^5.0.1, string-width@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" @@ -16676,7 +16675,7 @@ stringify-entities@^4.0.0: character-entities-html4 "^2.0.0" character-entities-legacy "^3.0.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -16690,13 +16689,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^7.0.1, strip-ansi@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -18251,7 +18243,8 @@ wordwrapjs@^5.1.0: resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-5.1.0.tgz#4c4d20446dcc670b14fa115ef4f8fd9947af2b3a" integrity sha512-JNjcULU2e4KJwUNv6CHgI46UvDGitb6dGryHajXTDiLgg1/RiGoPSDw4kZfYnwGtEXf2ZMeIewDQgFGzkCB2Sg== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: + name wrap-ansi-cjs version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -18278,15 +18271,6 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"