From 2889552b3ed3abc3dfb4f476dc8388a1ec73fe35 Mon Sep 17 00:00:00 2001 From: ibulog <20479184+ibulog@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:56:13 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20Airtable=E3=81=8B=E3=82=89=E3=83=AB?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E5=87=BA=E5=8A=9B=E3=81=99=E3=82=8B=E9=81=8B?= =?UTF-8?q?=E7=94=A8=E3=82=92=E3=82=84=E3=82=81=E3=82=8B=20(#568)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: Airtableからルール出力する運用をやめる * chore: 環境変数は読み込む必要がなくなる --- .env.example | 2 - .../PullRequestAndExportAirtable.yml | 35 -------- package.json | 11 +-- scripts/export-airtable-rules.ts | 89 ------------------- yarn.lock | 63 ------------- 5 files changed, 4 insertions(+), 196 deletions(-) delete mode 100644 .env.example delete mode 100644 .github/workflows/PullRequestAndExportAirtable.yml delete mode 100644 scripts/export-airtable-rules.ts diff --git a/.env.example b/.env.example deleted file mode 100644 index 6dac0ae..0000000 --- a/.env.example +++ /dev/null @@ -1,2 +0,0 @@ -AIRTABLE_API_KEY=XXXXXXXXXXXXXX -AIRTABLE_BASE_ID=XXXXXXXXXXXXXX \ No newline at end of file diff --git a/.github/workflows/PullRequestAndExportAirtable.yml b/.github/workflows/PullRequestAndExportAirtable.yml deleted file mode 100644 index a491cc6..0000000 --- a/.github/workflows/PullRequestAndExportAirtable.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: PullRequest and Export Airtable - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup NodeJS - uses: actions/setup-node@v4 - - - name: Create .env file - run: | - touch .env - echo -e "AIRTABLE_API_KEY=${{ secrets.AIRTABLE_API_KEY }}" >> .env - echo -e "AIRTABLE_BASE_ID=${{ secrets.AIRTABLE_BASE_ID }}" >> .env - - - name: Install dependencies - run: yarn install --frozen-lockfile --ignore-engines - - - run: yarn export:airtable - - run: yarn build - - - name: Test - run: yarn test - - - name: craete pull request - uses: peter-evans/create-pull-request@v7 - with: - title: 'feat: Airtableの最新ルールを反映' diff --git a/package.json b/package.json index 4bd91c3..6d2f9a9 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,7 @@ "build": "textlint-scripts build", "prepublishOnly": "npm run --if-present build", "release": "standard-version", - "release:dryrun": "standard-version --dry-run", - "export:airtable": "ts-node ./scripts/export-airtable-rules.ts" + "release:dryrun": "standard-version --dry-run" }, "devDependencies": { "@commitlint/cli": "^19.5.0", @@ -33,18 +32,16 @@ "@textlint/types": "^14.3.0", "@types/js-yaml": "^4.0.9", "@types/node": "^18.19.59", - "airtable": "^0.12.2", - "dotenv": "^16.4.5", "fs": "^0.0.1-security", "husky": "^9.1.6", "js-yaml": "^4.1.0", "prettier": "^3.3.3", "standard-version": "^9.3.2", - "textlint-tester": "^14.3.0", + "textlint": "^14.3.0", "textlint-scripts": "^14.3.0", + "textlint-tester": "^14.3.0", "ts-node": "^10.9.2", - "typescript": "^5.6.3", - "textlint": "^14.3.0" + "typescript": "^5.6.3" }, "dependencies": { "@textlint-rule/textlint-rule-no-unmatched-pair": "^2.0.3", diff --git a/scripts/export-airtable-rules.ts b/scripts/export-airtable-rules.ts deleted file mode 100644 index ed2abaa..0000000 --- a/scripts/export-airtable-rules.ts +++ /dev/null @@ -1,89 +0,0 @@ -import * as fs from 'fs' -import * as path from 'path' -import * as yaml from 'js-yaml' -import Airtable from 'airtable' - -require('dotenv').config() - -type Dict = { - [key: string]: string | string[] | Spec[] -} -type Spec = { - from: string - to: string -} - -const DIST_PATH_NAME = path.join(__dirname, '../dict/prh-idiomatic-usage.yml') - -Airtable.configure({ - endpointUrl: process.env.AIRTABLE_ENDPOINT_URL, - apiKey: process.env.AIRTABLE_API_KEY, -}) - -const baseId = process.env.AIRTABLE_BASE_ID ? process.env.AIRTABLE_BASE_ID : '' -const base = Airtable.base(baseId) - -const main = async () => { - let records; - try { - records = await base('用字用語:一覧').select({ - view: 'textlint用' - }).all(); - } catch (error){ - console.log(error); - return; - }; - - if (records) { - const ymlArray = records - .map((record) => { - let rule: Dict = {} - - // Memo: どの値もStringが入ってくる想定 - const expected = record.get('expected') - const pattern = record.get('pattern') - const prh = record.get('prh') - const specFrom = record.get('spec:from') - const specTo = record.get('spec:to') - - if (typeof expected === 'string') { - rule = { ...rule, expected: expected } - } - if (typeof pattern === 'string') { - rule = { ...rule, pattern: pattern.split(',') } - } - if (typeof prh === 'string') { - rule = { ...rule, prh: prh } - } - if (typeof specFrom === 'string' && typeof specTo === 'string') { - // Memo: 必ずどちらも同数の値が入ることを前提としている - const specFromArray = specFrom.split(',') - const specToArray = specTo.split(',') - const specsArray = specFromArray.map((item, index) => { - return { - from: item, - to: specToArray[index], - } - }) - rule = { ...rule, specs: specsArray } - } - return rule - }) - .filter((dict) => { - return Object.keys(dict).length - }) - - const yamlString = yaml.dump({ rules: ymlArray }) - fs.writeFile(DIST_PATH_NAME, yamlString, 'utf8', (err: any) => { - if (err) { - console.error(err.message) - process.exit(1) - } - console.log(`データ出力完了しました。`) - }) - } else { - console.warn(`出力するデータがありません。`) - } - }; - - main(); diff --git a/yarn.lock b/yarn.lock index 4c781ac..b38614a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1446,11 +1446,6 @@ dependencies: undici-types "~5.26.4" -"@types/node@>=8.0.0 <15": - version "14.17.33" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.33.tgz#011ee28e38dc7aee1be032ceadf6332a0ab15b12" - integrity sha512-noEeJ06zbn3lOh4gqe2v7NMGS33jrulfNqYFDjjEbhpDEHR5VTxgYNQSBqBlJIsBJW3uEYDgD6kvMnrrhGzq8g== - "@types/node@^18.19.59": version "18.19.59" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.59.tgz#2de1b95b0b468089b616b2feb809755d70a74949" @@ -1476,18 +1471,6 @@ JSONStream@^1.0.4, JSONStream@^1.3.5: jsonparse "^1.2.0" through ">=2.2.7 <3" -abort-controller@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" - integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== - dependencies: - event-target-shim "^5.0.0" - -abortcontroller-polyfill@^1.4.0: - version "1.7.3" - resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.3.tgz#1b5b487bd6436b5b764fd52a612509702c3144b5" - integrity sha512-zetDJxd89y3X99Kvo4qFx8GKlt6GsvN3UcRZHwU6iFA/0KiOmhkTVhe8oRoTBiTVPZu09x3vCra47+w8Yz1+2Q== - acorn-walk@^8.1.1: version "8.1.1" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.1.1.tgz#3ddab7f84e4a7e2313f6c414c5b7dac85f4e3ebc" @@ -1503,17 +1486,6 @@ add-stream@^1.0.0: resolved "https://registry.yarnpkg.com/add-stream/-/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa" integrity sha1-anmQQ3ynNtXhKI25K9MmbV9csqo= -airtable@^0.12.2: - version "0.12.2" - resolved "https://registry.yarnpkg.com/airtable/-/airtable-0.12.2.tgz#e53e66db86744f9bc684faa58881d6c9c12f0e6f" - integrity sha512-HS3VytUBTKj8A0vPl7DDr5p/w3IOGv6RXL0fv7eczOWAtj9Xe8ri4TAiZRXoOyo+Z/COADCj+oARFenbxhmkIg== - dependencies: - "@types/node" ">=8.0.0 <15" - abort-controller "^3.0.0" - abortcontroller-polyfill "^1.4.0" - lodash "^4.17.21" - node-fetch "^2.6.7" - ajv@^8.0.1, ajv@^8.11.0: version "8.12.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1" @@ -2285,11 +2257,6 @@ dot-prop@^5.1.0: dependencies: is-obj "^2.0.0" -dotenv@^16.4.5: - version "16.4.5" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" - integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== - dotgitignore@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/dotgitignore/-/dotgitignore-2.1.0.tgz#a4b15a4e4ef3cf383598aaf1dfa4a04bcc089b7b" @@ -2372,11 +2339,6 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== -event-target-shim@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" - integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== - events@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" @@ -3751,13 +3713,6 @@ neotraverse@^0.6.15: resolved "https://registry.yarnpkg.com/neotraverse/-/neotraverse-0.6.15.tgz#dc4abb64700c52440f13bc53635b559862420360" integrity sha512-HZpdkco+JeXq0G+WWpMJ4NsX3pqb5O7eR9uGz3FfoFt+LYzU8iRWp49nJtud6hsDoywM8tIrDo3gjgmOqJA8LA== -node-fetch@^2.6.7: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - node-releases@^2.0.18: version "2.0.18" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.18.tgz#f010e8d35e2fe8d6b2944f03f70213ecedc4ca3f" @@ -5159,11 +5114,6 @@ to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= - traverse@^0.6.7: version "0.6.8" resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.8.tgz#5e5e0c41878b57e4b73ad2f3d1e36a715ea4ab15" @@ -5406,19 +5356,6 @@ web-namespaces@^1.1.2: resolved "https://registry.yarnpkg.com/web-namespaces/-/web-namespaces-1.1.4.tgz#bc98a3de60dadd7faefc403d1076d529f5e030ec" integrity sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw== -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - which@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"