Skip to content

Commit 2f1e040

Browse files
committed
Update script to be able to close v2 prs as well
1 parent 949dd8d commit 2f1e040

File tree

3 files changed

+64
-12
lines changed

3 files changed

+64
-12
lines changed

.github/workflows/close-v2-issues.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
name: 🚪 Close v2 Issues
1+
name: 🚪 Close v2 Issues/PRs
22

33
on:
44
workflow_dispatch:
55
inputs:
6+
type:
7+
type: choice
8+
description: Type
9+
options:
10+
- issues
11+
- prs
12+
required: true
613
prior_to_date:
714
required: true
815

916
concurrency: ${{ github.workflow }}-${{ github.ref }}
1017

1118
jobs:
1219
experimental:
13-
name: 🚪 Close v2 Issues
20+
name: 🚪 Close v2 Issues/PRs
1421
if: github.repository == 'remix-run/remix'
1522
runs-on: ubuntu-latest
1623
env:
@@ -33,4 +40,4 @@ jobs:
3340
run: pnpm install --frozen-lockfile
3441

3542
- name: 🚪 Close Issues
36-
run: node ./scripts/close-v2-issues.mjs --date ${{ github.event.inputs.prior_to_date }}
43+
run: node ./scripts/close-v2-issues.mjs --type ${{ github.event.inputs.type }} --date ${{ github.event.inputs.prior_to_date }}

scripts/close-v2-issues.mjs

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,21 @@ const { values: args } = parseArgs({
1212
short: "d",
1313
default: new Date(oneYearAgo).toISOString().substring(0, 10),
1414
},
15+
type: {
16+
type: "string",
17+
short: "t",
18+
default: "issues", // issues | prs
19+
},
1520
},
1621
strict: true,
1722
});
1823

19-
if (!args.date || !/^\d{4}-\d{2}-\d{2}$/.test(args.date)) {
24+
console.log(args);
25+
26+
if (!args.type || !["issues", "prs"].includes(args.type)) {
27+
console.error("Missing or invalid date - expected YYYY-MM-DD.");
28+
process.exit(1);
29+
} else if (!args.date || !/^\d{4}-\d{2}-\d{2}$/.test(args.date)) {
2030
console.error("Missing or invalid date - expected YYYY-MM-DD.");
2131
process.exit(1);
2232
} else {
@@ -27,33 +37,51 @@ async function run() {
2737
/** @type {(ms: number) => Promise<void>} */
2838
let sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
2939

40+
let isPullRequests = args.type === "prs";
41+
3042
/** @type {(q: string) => string} */
31-
let getIssuesCmd = (q) => `gh issue list --search "${q}" --json number`;
43+
let getQueryCmd = (q) =>
44+
isPullRequests
45+
? `gh pr list --search "${q}" --json number`
46+
: `gh issue list --search "${q}" --json number`;
3247

3348
/** @type {(n: number) => string} */
3449
let getCommentCmd = (n) =>
35-
`gh issue comment ${n} -F ./scripts/close-v2-issues-comment.md`;
50+
isPullRequests
51+
? `gh pr comment ${n} -F ./scripts/close-v2-prs-comment.md`
52+
: `gh issue comment ${n} -F ./scripts/close-v2-issues-comment.md`;
3653

3754
/** @type {(n: number) => string} */
38-
let getCloseCmd = (n) => `gh issue close ${n} -r "not planned"`;
55+
let getCloseCmd = (n) =>
56+
isPullRequests
57+
? `gh pr close ${n}`
58+
: `gh issue close ${n} -r "not planned"`;
3959

40-
let issueCmd = getIssuesCmd(`is:issue state:open updated:<${args.date}`);
60+
let query = isPullRequests
61+
? `is:pr is:open updated:<${args.date}`
62+
: `is:issue state:open updated:<${args.date}`;
63+
let issueCmd = getQueryCmd(query);
4164
console.log(`Executing command: ${issueCmd}`);
65+
4266
let result = execSync(issueCmd).toString();
4367
console.log(`Result: ${result}`);
4468

4569
let issues = JSON.parse(result).map((i) => i.number);
4670
if (issues.length > 50) {
47-
console.log("❌ Refusing to close more than 50 issues at once, exiting.");
71+
console.log(
72+
"❌ Refusing to close more than 50 issues/PRs at once, exiting."
73+
);
4874
process.exit(1);
4975
}
5076

51-
console.log(`Parsed ${issues.length} issues`);
77+
let label = isPullRequests ? "PR" : "issue";
78+
79+
console.log(`Parsed ${issues.length} ${label}s`);
5280

5381
for (let issue of issues) {
54-
console.log(`--- Processing issue #${issue} ---`);
82+
console.log(`--- Processing ${label} #${issue} ---`);
5583
let commentResult = runCmdIfTokenExists(getCommentCmd(issue));
56-
console.log(`Commented on issue #${issue}: ${commentResult}`);
84+
console.log(`Commented on ${label} #${issue}: ${commentResult}`);
5785
await sleep(250);
5886

5987
runCmdIfTokenExists(getCloseCmd(issue));

scripts/close-v2-prs-comment.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Thank you for opening this pull request, and our apologies we haven't gotten around to it yet!
2+
3+
With the release of [React Router v7](https://remix.run/blog/react-router-v7) we are sun-setting continued development/maintenance on Remix v2. If you have not already [upgraded to React Router v7](https://reactrouter.com/upgrading/remix), we recommend you do so. We've tried to make the upgrade process as smooth as possible with our [Future Flags](https://remix.run/docs/en/main/start/future-flags). We are now in the process of cleaning up outdated issues and pull requests to improve the overall hygiene of our repositories.
4+
5+
We plan to continue to address 2 types of issues in Remix v2:
6+
7+
- Bugs that pose security concerns
8+
- Bugs that prevent upgrading to React Router v7
9+
10+
If you believe this pull request meets one of those criteria, please respond or create a new pull request so it pops up on our radar (since github notifications may get lost in the noise 😕).
11+
12+
For all other issues/changes, ongoing maintenance will be happening in React Router v7, so:
13+
14+
- If this is a bug fix, please reopen against [React Router v7](https://github.com/remix-run/react-router)
15+
- If this is a new feature, please open a new [Proposal Discussion](https://github.com/remix-run/react-router/discussions/new?category=proposals) in React Router, and if it gets enough community support it can be considered for implementation
16+
17+
If you have any questions you can always reach out on [Discord](https://rmx.as/discord). Thanks again for providing feedback and helping us make our framework even better!

0 commit comments

Comments
 (0)