diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 3915fddf53..ed514c9cd9 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -45,7 +45,7 @@ jobs: uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: ${{ matrix.node-version }} - cache: 'npm' + cache: "npm" - name: Install dependencies run: | @@ -77,33 +77,6 @@ jobs: sarif_file: eslint.sarif category: eslint - changetool-tests: - name: changetool unit tests - permissions: - contents: read - runs-on: ubuntu-slim - timeout-minutes: 10 - - concurrency: - cancel-in-progress: ${{ github.event_name == 'pull_request' || false }} - group: pr-checks-changetool-tests-${{ github.ref }}-${{ github.event_name }} - - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Set up Node.js - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - with: - node-version: 24 - cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Run changetool unit tests - run: npm --workspace changetool test - # These checks do not need to be run as part of the same matrix that we use for the `unit-tests` # job. other-checks: @@ -126,7 +99,7 @@ jobs: uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: 24 - cache: 'npm' + cache: "npm" - name: Install dependencies id: install-deps @@ -190,14 +163,14 @@ jobs: path: ${{ runner.temp }}/repo-size/ if-no-files-found: error - - name: 'Backport: Check out base ref' + - name: "Backport: Check out base ref" id: checkout-base if: ${{ startsWith(github.head_ref, 'backport-') }} uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: ref: ${{ github.base_ref }} - - name: 'Backport: Verify Node versions unchanged' + - name: "Backport: Verify Node versions unchanged" if: steps.checkout-base.outcome == 'success' env: HEAD_VERSION: ${{ steps.head-version.outputs.node_version }} diff --git a/eslint.config.mjs b/eslint.config.mjs index f82f071321..a64e92701d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -180,7 +180,7 @@ export default [ }, }, { - files: ["pr-checks/**/*.ts"], + files: ["pr-checks/**/*.ts", "pr-checks/**/*.mts"], languageOptions: { parserOptions: { @@ -209,18 +209,4 @@ export default [ ], }, }, - { - files: ["scripts/changetool/**/*.ts"], - - languageOptions: { - parserOptions: { - project: "./scripts/changetool/tsconfig.json", - }, - }, - - rules: { - "no-console": "off", - "import/extensions": "off", - }, - }, ]; diff --git a/package-lock.json b/package-lock.json index da14fd0ed6..354dc58bde 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,7 @@ "version": "4.37.10", "license": "MIT", "workspaces": [ - "pr-checks", - "scripts/changetool" + "pr-checks" ], "dependencies": { "@actions/artifact": "^5.0.3", @@ -3010,346 +3009,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/@typescript/typescript-aix-ppc64": { - "version": "7.0.2", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", - "integrity": "sha1-zcfOgdYPHgkDSWDd+x+4gNendrY=", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-darwin-arm64": { - "version": "7.0.2", - "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", - "integrity": "sha1-pV/fz6WN9Y0n2yI3zealweNacjU=", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-darwin-x64": { - "version": "7.0.2", - "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", - "integrity": "sha1-ONHJFygAqR1we+xk0qNwoBZjTbQ=", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-freebsd-arm64": { - "version": "7.0.2", - "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", - "integrity": "sha1-8f+IEAMLNdK1vg22otxlBGDqlPo=", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-freebsd-x64": { - "version": "7.0.2", - "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", - "integrity": "sha1-PYawPzU8WxupUWLrbONVM7/ClL0=", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-arm": { - "version": "7.0.2", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", - "integrity": "sha1-rZS0HhruKk3MaimMe2fEM0X94y4=", - "cpu": [ - "arm" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-arm64": { - "version": "7.0.2", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", - "integrity": "sha1-2TNNltbaxv+F2pyGVYiUjek56R8=", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-loong64": { - "version": "7.0.2", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", - "integrity": "sha1-KWWu5PyHM2ATnYk9qv5jl6KROK0=", - "cpu": [ - "loong64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-mips64el": { - "version": "7.0.2", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", - "integrity": "sha1-Goh6MRvtOoM/gL/Uqe03wnGTbPA=", - "cpu": [ - "mips64el" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-ppc64": { - "version": "7.0.2", - "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", - "integrity": "sha1-i2PJsvRFs5PrTkPsIdoiXa3jV30=", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-riscv64": { - "version": "7.0.2", - "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", - "integrity": "sha1-tuijXCibPql6kqQdRhqu7Q07NuE=", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-s390x": { - "version": "7.0.2", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", - "integrity": "sha1-Lvlmk75IYfbReWVCflsAnLvtGj4=", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-linux-x64": { - "version": "7.0.2", - "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", - "integrity": "sha1-cyacsLq6UK6gygYERaa4jlg/HOI=", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-netbsd-arm64": { - "version": "7.0.2", - "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", - "integrity": "sha1-OjZJ+X+vohC05uN5jBXgZgXIqQE=", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-netbsd-x64": { - "version": "7.0.2", - "resolved": "https://ms-feed-25.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", - "integrity": "sha1-R+xZSRpAxHDSgH3E0rglUo/Zeas=", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-openbsd-arm64": { - "version": "7.0.2", - "resolved": "https://ms-feed-17.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", - "integrity": "sha1-eWvo2gvZidij+5bygB44qDZbS68=", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-openbsd-x64": { - "version": "7.0.2", - "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", - "integrity": "sha1-03/ipynrlCwHbEVO5/GBX699Vg8=", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-sunos-x64": { - "version": "7.0.2", - "resolved": "https://ms-feed-17.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", - "integrity": "sha1-q6jTRkw1ZacER4m6upaRa9SrLIg=", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-win32-arm64": { - "version": "7.0.2", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", - "integrity": "sha1-ud5QoXGWOD9iYgtfnQovNK07YNc=", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/@typescript/typescript-win32-x64": { - "version": "7.0.2", - "resolved": "https://ms-feed-2.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", - "integrity": "sha1-zzt7DWzlY12spMjgHBic3N5H7Dw=", - "cpu": [ - "x64" - ], - "dev": true, - "license": "Apache-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=16.20.0" - } - }, "node_modules/@typespec/ts-http-runtime": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/@typespec/ts-http-runtime/-/ts-http-runtime-0.3.2.tgz", @@ -4496,10 +4155,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/changetool": { - "resolved": "scripts/changetool", - "link": true - }, "node_modules/character-entities": { "version": "2.0.2", "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/character-entities/-/character-entities-2.0.2.tgz", @@ -7582,8 +7237,8 @@ }, "node_modules/lite-matter": { "version": "0.1.2", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/lite-matter/-/lite-matter-0.1.2.tgz", - "integrity": "sha1-NlO1r/xDs8OnKQcf/kw4/a4O1Ws=", + "resolved": "https://registry.npmjs.org/lite-matter/-/lite-matter-0.1.2.tgz", + "integrity": "sha512-cGSYxO6vcipYZBSF5dUtDF3IqbkNxSjVQuvs5Ol3fO35URzHEvG2Ml0KbH5kvXXsx33SgbfwiVp6afwovarD8A==", "license": "MIT", "dependencies": { "yaml": "^2.9.0" @@ -7717,8 +7372,8 @@ }, "node_modules/mdast-util-from-markdown": { "version": "2.0.3", - "resolved": "https://ms-feed-17.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.3.tgz", - "integrity": "sha1-yVgiuRqrdfGKTL6LL1G4c+0s8Mc=", + "resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.3.tgz", + "integrity": "sha512-W4mAWTvSlKvf8L6J+VN9yLSqQ9AOAAvHuoDAmPkz4dHf553m5gVj2ejadHJhoJmcmxEnOv6Pa8XJhpxE93kb8Q==", "license": "MIT", "dependencies": { "@types/mdast": "^4.0.0", @@ -10724,6 +10379,8 @@ "@octokit/core": "^7.0.7", "@octokit/plugin-paginate-rest": ">=15.0.0", "@octokit/plugin-rest-endpoint-methods": "^18.0.0", + "lite-matter": "^0.1.2", + "mdast-util-from-markdown": "^2.0.3", "semver": "^7.8.5", "yaml": "^2.9.0" }, @@ -10731,71 +10388,6 @@ "@types/node": "^20.19.43", "tsx": "^4.23.12" } - }, - "scripts/changetool": { - "version": "1.0.0", - "license": "MIT", - "dependencies": { - "lite-matter": "^0.1.2", - "mdast-util-from-markdown": "^2.0.3" - }, - "devDependencies": { - "@types/node": "^26.2.0", - "tsx": "^4.23.12", - "typescript": "^7.0.2" - } - }, - "scripts/changetool/node_modules/@types/node": { - "version": "26.2.0", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/@types/node/-/node-26.2.0.tgz", - "integrity": "sha1-Wkh1qGL9qP3Ffej6pXm7gey6FoU=", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~8.3.0" - } - }, - "scripts/changetool/node_modules/typescript": { - "version": "7.0.2", - "resolved": "https://ms-feed-12.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/typescript/-/typescript-7.0.2.tgz", - "integrity": "sha1-nsdz15VKjBgsF8xbvVdaoovFFYI=", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc" - }, - "engines": { - "node": ">=16.20.0" - }, - "optionalDependencies": { - "@typescript/typescript-aix-ppc64": "7.0.2", - "@typescript/typescript-darwin-arm64": "7.0.2", - "@typescript/typescript-darwin-x64": "7.0.2", - "@typescript/typescript-freebsd-arm64": "7.0.2", - "@typescript/typescript-freebsd-x64": "7.0.2", - "@typescript/typescript-linux-arm": "7.0.2", - "@typescript/typescript-linux-arm64": "7.0.2", - "@typescript/typescript-linux-loong64": "7.0.2", - "@typescript/typescript-linux-mips64el": "7.0.2", - "@typescript/typescript-linux-ppc64": "7.0.2", - "@typescript/typescript-linux-riscv64": "7.0.2", - "@typescript/typescript-linux-s390x": "7.0.2", - "@typescript/typescript-linux-x64": "7.0.2", - "@typescript/typescript-netbsd-arm64": "7.0.2", - "@typescript/typescript-netbsd-x64": "7.0.2", - "@typescript/typescript-openbsd-arm64": "7.0.2", - "@typescript/typescript-openbsd-x64": "7.0.2", - "@typescript/typescript-sunos-x64": "7.0.2", - "@typescript/typescript-win32-arm64": "7.0.2", - "@typescript/typescript-win32-x64": "7.0.2" - } - }, - "scripts/changetool/node_modules/undici-types": { - "version": "8.3.0", - "resolved": "https://ms-feed-17.pkgs.visualstudio.com/1es-public/_packaging/npm-public/npm/registry/undici-types/-/undici-types-8.3.0.tgz", - "integrity": "sha1-ROn8nzJEZIzeo15Pm7LWgelBCAk=", - "dev": true, - "license": "MIT" } } } diff --git a/package.json b/package.json index 0e8fc4bb2a..c77b851044 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,7 @@ }, "license": "MIT", "workspaces": [ - "pr-checks", - "scripts/changetool" + "pr-checks" ], "dependencies": { "@actions/artifact": "^5.0.3", diff --git a/scripts/changetool/cli/validate.ts b/pr-checks/changelog/validate.mts similarity index 100% rename from scripts/changetool/cli/validate.ts rename to pr-checks/changelog/validate.mts diff --git a/scripts/changetool/cli/validate.test.ts b/pr-checks/changelog/validate.test.mts similarity index 84% rename from scripts/changetool/cli/validate.test.ts rename to pr-checks/changelog/validate.test.mts index ac54972fdf..a5ad97e97a 100644 --- a/scripts/changetool/cli/validate.test.ts +++ b/pr-checks/changelog/validate.test.mts @@ -10,12 +10,12 @@ import { isValidChangenoteFilename, hasValidChangenoteCategory, VALID_CHANGE_NOTE_CATEGORIES, -} from "./validate.ts"; +} from "./validate.mjs"; async function withTmpFile( baseFileName: string, contents: string, - body: (filePath: string) => Promise, + body: (filePath: string) => Promise | T, ): Promise { const tmpDir = fs.mkdtempSync( path.join(os.tmpdir(), "changetool-validate-test-"), @@ -23,14 +23,14 @@ async function withTmpFile( try { const filePath = path.join(tmpDir, baseFileName); fs.writeFileSync(filePath, contents); - return await body(filePath); + return await Promise.resolve(body(filePath)); } finally { fs.rmSync(tmpDir, { recursive: true, force: true }); } } await describe("isValidChangenoteContent", async () => { - await it("recognizes an unordered Markdown list", async () => { + await it("recognizes an unordered Markdown list", () => { const inputs = [ "- One changenote entry", "- First item\n- Second item", @@ -42,7 +42,7 @@ await describe("isValidChangenoteContent", async () => { } }); - await it("does not recognize non-Markdown text", async () => { + await it("does not recognize non-Markdown text", () => { const inputs = [ "This is not a list.", '["this", "is", "JSON"]', @@ -57,7 +57,7 @@ await describe("isValidChangenoteContent", async () => { } }); - await it("does not recognize ordered Markdown lists", async () => { + await it("does not recognize ordered Markdown lists", () => { const inputs = [ "1. First item\n2. Second item", "\n\n\n1. First item\n1. Second item", @@ -68,7 +68,7 @@ await describe("isValidChangenoteContent", async () => { } }); - await it("requires all list items to use a hyphen bullet", async () => { + await it("requires all list items to use a hyphen bullet", () => { const inputs = [ "* Fixed a bug\n* Added feature", "+ Fixed a bug\n+ Added feature", @@ -85,7 +85,7 @@ await describe("isValidChangenoteContent", async () => { } }); - await it("does not contain other Markdown elements", async () => { + await it("does not contain other Markdown elements", () => { const inputs = [ "- Fixed a bug\n\nParagraph of text", "- Fixed a bug\n\n* Added a feature", @@ -100,7 +100,7 @@ await describe("isValidChangenoteContent", async () => { }); await describe("isValidChangenoteFilename", async () => { - await it("accepts valid filenames", async () => { + await it("accepts valid filenames", () => { const inputs = [ "2023-01-01-fix-bug.md", "2023-12-31-add-feature.md", @@ -112,7 +112,7 @@ await describe("isValidChangenoteFilename", async () => { } }); - await it("rejects invalid filenames", async () => { + await it("rejects invalid filenames", () => { const inputs = [ "missing-date-from-filename.md", "2021-01-01.md", @@ -126,14 +126,14 @@ await describe("isValidChangenoteFilename", async () => { }); await describe("hasValidChangenoteCategory", async () => { - await it("accepts valid categories", async () => { + await it("accepts valid categories", () => { for (const category of Object.keys(VALID_CHANGE_NOTE_CATEGORIES)) { const frontmatter = { category }; assert.equal(hasValidChangenoteCategory(frontmatter), true); } }); - await it("rejects invalid categories", async () => { + await it("rejects invalid categories", () => { const inputs = [ "", "invalid-category", @@ -150,7 +150,7 @@ await describe("hasValidChangenoteCategory", async () => { } }); - await it("reject missing category", async () => { + await it("reject missing category", () => { assert.equal(hasValidChangenoteCategory({}), false); assert.equal(hasValidChangenoteCategory({ category: null }), false); assert.equal(hasValidChangenoteCategory({ category: undefined }), false); @@ -162,7 +162,7 @@ await describe("isValidChangenoteFile", async () => { await withTmpFile( "2026-01-01-fix-bug.md", "---\ncategory: fix\n---\n- Fixed a bug\n", - async (filePath) => { + (filePath) => { assert.equal(isValidChangenoteFile(filePath), true); }, ); @@ -172,7 +172,7 @@ await describe("isValidChangenoteFile", async () => { await withTmpFile( "fix-bug.md", "---\ncategory: fix\n---\n- Fixed a bug\n", - async (filePath) => { + (filePath) => { assert.equal(isValidChangenoteFile(filePath), false); }, ); @@ -182,7 +182,7 @@ await describe("isValidChangenoteFile", async () => { await withTmpFile( "2026-01-01-fix-bug.md", "- Fixed a bug\n", - async (filePath) => { + (filePath) => { assert.equal(isValidChangenoteFile(filePath), false); }, ); @@ -192,7 +192,7 @@ await describe("isValidChangenoteFile", async () => { await withTmpFile( "2026-01-01-fix-bug.md", "---\ncategory: fix\n---\n* Fixed a bug\n", - async (filePath) => { + (filePath) => { assert.equal(isValidChangenoteFile(filePath), false); }, ); diff --git a/pr-checks/package.json b/pr-checks/package.json index 00f4b813c2..b211d91898 100644 --- a/pr-checks/package.json +++ b/pr-checks/package.json @@ -1,12 +1,14 @@ { "private": true, - "description": "Dependencies for the sync.ts", + "description": "Dependencies for codeql-action scripts", "dependencies": { "@actions/core": "^2.0.3", "@actions/github": "^8.0.1", "@octokit/core": "^7.0.7", "@octokit/plugin-paginate-rest": ">=15.0.0", "@octokit/plugin-rest-endpoint-methods": "^18.0.0", + "lite-matter": "^0.1.2", + "mdast-util-from-markdown": "^2.0.3", "semver": "^7.8.5", "yaml": "^2.9.0" }, diff --git a/pr-checks/tsconfig.json b/pr-checks/tsconfig.json index b010827cf5..67f31d2cdb 100644 --- a/pr-checks/tsconfig.json +++ b/pr-checks/tsconfig.json @@ -6,8 +6,8 @@ "module": "preserve", "rootDir": "..", "sourceMap": false, - "noEmit": true, + "noEmit": true }, - "include": ["./*.ts", "../src/**/*.ts"], + "include": ["./**/*.ts", "./**/*.mts", "../src/**/*.ts"], "exclude": ["node_modules"] } diff --git a/scripts/changetool/index.ts b/pr-checks/validate-changelog.mts old mode 100644 new mode 100755 similarity index 86% rename from scripts/changetool/index.ts rename to pr-checks/validate-changelog.mts index 249448b3fb..6990fa6944 --- a/scripts/changetool/index.ts +++ b/pr-checks/validate-changelog.mts @@ -1,7 +1,9 @@ +#!/usr/bin/env npx tsx + import { pathToFileURL } from "node:url"; import { parseArgs } from "node:util"; -import { isValidChangenoteFile } from "./cli/validate.ts"; +import { isValidChangenoteFile } from "./changelog/validate.mjs"; const entryPoint = process.argv[1]; if (entryPoint && import.meta.url === pathToFileURL(entryPoint).href) { @@ -32,7 +34,7 @@ function main(): number { } function usage(): number { - console.log("Usage: changetool validate [ ...]"); + console.log(`Usage: validate-changelog.mts validate [ ...]`); return 0; } diff --git a/scripts/changetool/package.json b/scripts/changetool/package.json deleted file mode 100644 index 7eb8ceb9be..0000000000 --- a/scripts/changetool/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "changetool", - "version": "1.0.0", - "private": true, - "description": "Validates change-notes and merges them into CHANGELOG.md", - "license": "MIT", - "type": "module", - "scripts": { - "start": "tsx index.ts", - "test": "node --test --experimental-strip-types cli/*.test.ts" - }, - "devDependencies": { - "@types/node": "^26.2.0", - "tsx": "^4.23.12", - "typescript": "^7.0.2" - }, - "dependencies": { - "lite-matter": "^0.1.2", - "mdast-util-from-markdown": "^2.0.3" - } -} diff --git a/scripts/changetool/tsconfig.json b/scripts/changetool/tsconfig.json deleted file mode 100644 index ee76bd1869..0000000000 --- a/scripts/changetool/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "module": "preserve", - "allowImportingTsExtensions": true, - "rootDir": ".", - "sourceMap": false - }, - "include": ["./**/*.ts"], - "exclude": ["node_modules"] -} diff --git a/tsconfig.json b/tsconfig.json index d2b39b5ef1..66545447c5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,5 +37,5 @@ "@octokit/core/dist-types/types": ["./node_modules/@octokit/core/dist-types/types.d.ts"] }, }, - "exclude": ["node_modules", "pr-checks", "scripts/changetool"] + "exclude": ["node_modules", "pr-checks"] }