From 46c964ccd3784d1bec7b06ff5c73858ee830e14d Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Mon, 17 Mar 2025 15:07:25 +0100 Subject: [PATCH 1/4] feat: pre-commit hook --- .github/workflows/docs.yaml | 3 +++ .github/workflows/test.yaml | 3 +++ .husky/pre-commit | 4 ++++ package-lock.json | 17 +++++++++++++++++ package.json | 4 +++- 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .husky/pre-commit diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index ee3a8b739d..09cefa2740 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -9,6 +9,9 @@ on: permissions: contents: read +env: + HUSKY: 0 + jobs: markdown_tables: name: Check Markdown Tables diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8024f01a7f..2459f4875f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,6 +9,9 @@ on: permissions: contents: read +env: + HUSKY: 0 + jobs: lint: name: Lint diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000000..c5badaf4b0 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +npm run fix:tables +npm run test:links +npm run test:build +git update-index --again \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d379cdcf65..25517c47e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "eslint": "^9.2.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", + "husky": "9.1.7", "js-yaml": "^4.1.0", "markdown-table-formatter": "^1.6.0", "mdast-util-from-markdown": "^2.0.1", @@ -1673,6 +1674,22 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/husky": { + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "dev": true, + "license": "MIT", + "bin": { + "husky": "bin.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/ignore": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", diff --git a/package.json b/package.json index bed473a411..6b5c4962c4 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ "test:build": "tsx tools/checkBuild.ts", "test:tables": "npx markdown-table-formatter \"docs/**/*.{md,mdx}\" --check", "fix:tables": "npx markdown-table-formatter \"docs/**/*.{md,mdx}\"", - "decorate:docs": "node tools/doxygen/generate-social-sdk-mapping.js && node tools/doxygen/decorate-social-sdk-references.js" + "decorate:docs": "node tools/doxygen/generate-social-sdk-mapping.js && node tools/doxygen/decorate-social-sdk-references.js", + "prepare": "npx husky || true" }, "devDependencies": { "@actions/core": "^1.10.1", @@ -41,6 +42,7 @@ "eslint": "^9.2.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", + "husky": "9.1.7", "js-yaml": "^4.1.0", "markdown-table-formatter": "^1.6.0", "mdast-util-from-markdown": "^2.0.1", From 6b5f69a932ecf3bbe6dfb622f82b50a9e9c00581 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Mon, 17 Mar 2025 18:04:32 +0100 Subject: [PATCH 2/4] chore: Added pre-requisites to CONTRIBUTING.md Not sure if this is actually needed, doing a separate commit to ensure we can revert this easily. --- CONTRIBUTING.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 42a8e0d605..71fe41b48e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,13 @@ See the [README](https://github.com/discord/discord-api-docs/blob/main/README.md) for licensing and legal information. +## Pre-requisites + +To contribute to the documentation, you need to have [Node.js](https://nodejs.org/en/download/) installed on your machine. +The recommended version is the latest LTS version. +After you install it, run `npm install` to install the required dependencies. +This will setup a pre-commit hook to ensure that the changes you are commiting are formatted correctly. + ## Types of Changes ### Wanted Changes From 337b6e911cc975403cce9ce97a23785dd6e1b09d Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Tue, 18 Mar 2025 14:00:38 +0100 Subject: [PATCH 3/4] fix: use is-ci for check --- .github/workflows/docs.yaml | 3 --- .github/workflows/test.yaml | 3 --- package-lock.json | 36 ++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 09cefa2740..ee3a8b739d 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -9,9 +9,6 @@ on: permissions: contents: read -env: - HUSKY: 0 - jobs: markdown_tables: name: Check Markdown Tables diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2459f4875f..8024f01a7f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,9 +9,6 @@ on: permissions: contents: read -env: - HUSKY: 0 - jobs: lint: name: Lint diff --git a/package-lock.json b/package-lock.json index 25517c47e1..4e4beb347f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,6 +20,7 @@ "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "husky": "9.1.7", + "is-ci": "4.1.0", "js-yaml": "^4.1.0", "markdown-table-formatter": "^1.6.0", "mdast-util-from-markdown": "^2.0.1", @@ -858,6 +859,22 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/ci-info": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-4.2.0.tgz", + "integrity": "sha512-cYY9mypksY8NRqgDB1XD1RiJL338v/551niynFTGkZOO2LHuB2OmOYxDIe/ttN9AHwrqdum1360G3ald0W9kCg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/collapse-white-space": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-2.1.0.tgz", @@ -1754,6 +1771,25 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/is-ci": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-4.1.0.tgz", + "integrity": "sha512-Ab9bQDQ11lWootZUI5qxgN2ZXwxNI5hTwnsvOc1wyxQ7zQ8OkEDw79mI0+9jI3x432NfwbVRru+3noJfXF6lSQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "license": "MIT", + "dependencies": { + "ci-info": "^4.1.0" + }, + "bin": { + "is-ci": "bin.js" + } + }, "node_modules/is-decimal": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz", diff --git a/package.json b/package.json index 6b5c4962c4..9e1ddb860f 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "test:tables": "npx markdown-table-formatter \"docs/**/*.{md,mdx}\" --check", "fix:tables": "npx markdown-table-formatter \"docs/**/*.{md,mdx}\"", "decorate:docs": "node tools/doxygen/generate-social-sdk-mapping.js && node tools/doxygen/decorate-social-sdk-references.js", - "prepare": "npx husky || true" + "prepare": "npx is-ci || npx husky" }, "devDependencies": { "@actions/core": "^1.10.1", @@ -43,6 +43,7 @@ "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.1.3", "husky": "9.1.7", + "is-ci": "4.1.0", "js-yaml": "^4.1.0", "markdown-table-formatter": "^1.6.0", "mdast-util-from-markdown": "^2.0.1", From 20d1022a010bd2bce429c1fb5c911c4ce0f4b728 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Thu, 20 Mar 2025 05:36:56 +0100 Subject: [PATCH 4/4] Apply suggestion from ckohen --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e1ddb860f..0ee5736ddd 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "test:tables": "npx markdown-table-formatter \"docs/**/*.{md,mdx}\" --check", "fix:tables": "npx markdown-table-formatter \"docs/**/*.{md,mdx}\"", "decorate:docs": "node tools/doxygen/generate-social-sdk-mapping.js && node tools/doxygen/decorate-social-sdk-references.js", - "prepare": "npx is-ci || npx husky" + "prepare": "is-ci || husky" }, "devDependencies": { "@actions/core": "^1.10.1",