From d438d60aa5b84ef029d3c0cbaa2ca6ff22df94e7 Mon Sep 17 00:00:00 2001 From: O M Date: Tue, 27 Oct 2026 10:23:52 -0400 Subject: [PATCH 1/2] Ignore TypeScript 7 until Astro check accepts it. A monthly workflow comments on issue 5 when @astrojs/check allows typescript@7. Co-authored-by: Cursor --- .github/dependabot.yml | 5 ++ .github/workflows/typescript-7.yml | 90 ++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 .github/workflows/typescript-7.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e1a8e3b..1059227 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,6 +7,11 @@ updates: schedule: interval: weekly open-pull-requests-limit: 5 + ignore: + # @astrojs/check does not accept TypeScript 7 yet. The monthly + # TypeScript 7 workflow comments on issue 5 when that changes. + - dependency-name: "typescript" + versions: ["7.x"] - package-ecosystem: github-actions directory: / schedule: diff --git a/.github/workflows/typescript-7.yml b/.github/workflows/typescript-7.yml new file mode 100644 index 0000000..f76fced --- /dev/null +++ b/.github/workflows/typescript-7.yml @@ -0,0 +1,90 @@ +# Copyright 2026 OpenSourceOM +# SPDX-License-Identifier: Apache-2.0 +name: TypeScript 7 + +on: + schedule: + # 15:00 UTC on the 1st. Stays quiet until @astrojs/check accepts TypeScript 7. + - cron: "0 15 1 * *" + workflow_dispatch: + +permissions: + contents: read + issues: write + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Comment on issue 5 when TypeScript 7 is accepted + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + range_json=$(npm view @astrojs/check@latest peerDependencies.typescript --json) + version_json=$(npm view @astrojs/check@latest version --json) + ready=$(RANGE_JSON="$range_json" node --input-type=module <<'EOF' + const raw = process.env.RANGE_JSON; + if (!raw || raw === "null" || raw === "undefined") { + process.stdout.write("missing"); + process.exit(0); + } + const range = JSON.parse(raw); + process.stdout.write(allowsTypeScript7(range) ? "true" : "false"); + + function allowsTypeScript7(peerRange) { + return String(peerRange) + .split("||") + .map((clause) => clause.trim()) + .filter(Boolean) + .some((clause) => clauseAllowsMajor(clause, 7)); + } + + function clauseAllowsMajor(clause, major) { + if (clause === "*" || clause === "x" || clause === "X") return true; + const caret = clause.match(/^\^(\d+)\./); + if (caret) return Number(caret[1]) === major; + const tilde = clause.match(/^~(\d+)\./); + if (tilde) return Number(tilde[1]) === major; + const exact = clause.match(/^(\d+)\.\d+\.\d+$/); + if (exact) return Number(exact[1]) === major; + let min = null; + let maxExclusive = Infinity; + for (const match of clause.matchAll(/(>=|>|<=|<)\s*(\d+)(?:\.\d+){0,2}/g)) { + const bound = Number(match[2]); + if (match[1] === ">=") min = Math.max(min ?? -Infinity, bound); + if (match[1] === ">") min = Math.max(min ?? -Infinity, bound + 1); + if (match[1] === "<") maxExclusive = Math.min(maxExclusive, bound); + if (match[1] === "<=") maxExclusive = Math.min(maxExclusive, bound + 1); + } + return min !== null && min <= major && major < maxExclusive; + } + EOF + ) + version=$(node --input-type=module -e 'process.stdout.write(JSON.parse(process.argv[1]))' "$version_json") + range=$(node --input-type=module -e 'const raw = process.argv[1]; process.stdout.write(!raw || raw === "null" ? "(no typescript peer)" : JSON.parse(raw))' "$range_json") + echo "@astrojs/check@${version} typescript peer: ${range} (ready=${ready})" + if [ "$ready" = "false" ]; then + exit 0 + fi + marker="" + if gh api --paginate "repos/${GITHUB_REPOSITORY}/issues/5/comments" --jq '.[].body' | grep -F -q "$marker"; then + echo "Issue 5 already records that TypeScript 7 is accepted." + exit 0 + fi + state=$(gh issue view 5 --repo "$GITHUB_REPOSITORY" --json state --jq .state) + if [ "$state" = "CLOSED" ]; then + gh issue reopen 5 --repo "$GITHUB_REPOSITORY" + fi + if [ "$ready" = "missing" ]; then + detail="\`@astrojs/check@${version}\` no longer declares a \`typescript\` peer dependency." + else + detail="\`@astrojs/check@${version}\` now accepts TypeScript 7 (\`${range}\`)." + fi + gh issue comment 5 --repo "$GITHUB_REPOSITORY" --body "$(cat < Date: Wed, 28 Oct 2026 18:19:34 -0400 Subject: [PATCH 2/2] Match TypeScript 7 in the peer string instead of parsing semver. Co-authored-by: Cursor --- .github/dependabot.yml | 3 +- .github/workflows/typescript-7.yml | 65 ++++-------------------------- 2 files changed, 8 insertions(+), 60 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1059227..a84a7a4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,8 +8,7 @@ updates: interval: weekly open-pull-requests-limit: 5 ignore: - # @astrojs/check does not accept TypeScript 7 yet. The monthly - # TypeScript 7 workflow comments on issue 5 when that changes. + # Issue 5: @astrojs/check does not accept TypeScript 7 yet. - dependency-name: "typescript" versions: ["7.x"] - package-ecosystem: github-actions diff --git a/.github/workflows/typescript-7.yml b/.github/workflows/typescript-7.yml index f76fced..b983884 100644 --- a/.github/workflows/typescript-7.yml +++ b/.github/workflows/typescript-7.yml @@ -21,70 +21,19 @@ jobs: GH_TOKEN: ${{ github.token }} run: | set -euo pipefail - range_json=$(npm view @astrojs/check@latest peerDependencies.typescript --json) - version_json=$(npm view @astrojs/check@latest version --json) - ready=$(RANGE_JSON="$range_json" node --input-type=module <<'EOF' - const raw = process.env.RANGE_JSON; - if (!raw || raw === "null" || raw === "undefined") { - process.stdout.write("missing"); - process.exit(0); - } - const range = JSON.parse(raw); - process.stdout.write(allowsTypeScript7(range) ? "true" : "false"); - - function allowsTypeScript7(peerRange) { - return String(peerRange) - .split("||") - .map((clause) => clause.trim()) - .filter(Boolean) - .some((clause) => clauseAllowsMajor(clause, 7)); - } - - function clauseAllowsMajor(clause, major) { - if (clause === "*" || clause === "x" || clause === "X") return true; - const caret = clause.match(/^\^(\d+)\./); - if (caret) return Number(caret[1]) === major; - const tilde = clause.match(/^~(\d+)\./); - if (tilde) return Number(tilde[1]) === major; - const exact = clause.match(/^(\d+)\.\d+\.\d+$/); - if (exact) return Number(exact[1]) === major; - let min = null; - let maxExclusive = Infinity; - for (const match of clause.matchAll(/(>=|>|<=|<)\s*(\d+)(?:\.\d+){0,2}/g)) { - const bound = Number(match[2]); - if (match[1] === ">=") min = Math.max(min ?? -Infinity, bound); - if (match[1] === ">") min = Math.max(min ?? -Infinity, bound + 1); - if (match[1] === "<") maxExclusive = Math.min(maxExclusive, bound); - if (match[1] === "<=") maxExclusive = Math.min(maxExclusive, bound + 1); - } - return min !== null && min <= major && major < maxExclusive; - } - EOF - ) - version=$(node --input-type=module -e 'process.stdout.write(JSON.parse(process.argv[1]))' "$version_json") - range=$(node --input-type=module -e 'const raw = process.argv[1]; process.stdout.write(!raw || raw === "null" ? "(no typescript peer)" : JSON.parse(raw))' "$range_json") - echo "@astrojs/check@${version} typescript peer: ${range} (ready=${ready})" - if [ "$ready" = "false" ]; then - exit 0 - fi + range=$(npm view @astrojs/check@latest peerDependencies.typescript) + echo "typescript peer: ${range}" + # Published ranges look like "^5.0.0 || ^6.0.0". + printf '%s\n' "$range" | grep -Eq '(^|[^0-9])7\.' || exit 0 marker="" if gh api --paginate "repos/${GITHUB_REPOSITORY}/issues/5/comments" --jq '.[].body' | grep -F -q "$marker"; then - echo "Issue 5 already records that TypeScript 7 is accepted." exit 0 fi - state=$(gh issue view 5 --repo "$GITHUB_REPOSITORY" --json state --jq .state) - if [ "$state" = "CLOSED" ]; then - gh issue reopen 5 --repo "$GITHUB_REPOSITORY" - fi - if [ "$ready" = "missing" ]; then - detail="\`@astrojs/check@${version}\` no longer declares a \`typescript\` peer dependency." - else - detail="\`@astrojs/check@${version}\` now accepts TypeScript 7 (\`${range}\`)." - fi + gh issue reopen 5 --repo "$GITHUB_REPOSITORY" || true gh issue comment 5 --repo "$GITHUB_REPOSITORY" --body "$(cat <