Repository navigation
Expand file tree
/
Copy pathrunAll.js
More file actions
237 lines (216 loc) · 7.36 KB
/
Copy pathrunAll.js
File metadata and controls
237 lines (216 loc) · 7.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// runAll.js
import { execSync } from "child_process";
import dotenv from "dotenv";
import { hideBin } from "yargs/helpers";
import inquirer from "inquirer";
dotenv.config();
let originRepo = "Template",
targetRepo,
projectStartDate;
const args = hideBin(process.argv);
if (args.length >= 2) {
[targetRepo, projectStartDate] = args;
} else {
const readline = await import("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const ask = (q) => new Promise((res) => rl.question(q, res));
targetRepo = await ask(
"Enter target repo name (also used as project name): "
);
rl.close();
targetRepo = targetRepo.trim();
}
if (!projectStartDate) {
const { startDate } = await inquirer.prompt([
{
type: "input",
name: "startDate",
message: "Enter project start date (YYYY-MM-DD):",
validate: (input) =>
/\d{4}-\d{2}-\d{2}/.test(input) || "Please use format YYYY-MM-DD",
},
]);
projectStartDate = startDate;
}
function addDays(dateStr, days) {
const date = new Date(dateStr);
date.setDate(date.getDate() + days);
return date.toISOString().split("T")[0];
}
const sprintEndDate = addDays(projectStartDate, 79);
async function confirmWithChoices(question, actionMessage) {
const { answer } = await inquirer.prompt([
{
type: "list",
name: "answer",
message: question,
choices: ["Yes", "No"],
},
]);
if (answer === "No") {
console.log("\n" + actionMessage);
await inquirer.prompt([
{
type: "input",
name: "continue",
message: "Press Enter to continue...",
},
]);
}
}
// Initial confirmations before execution
const initialSetup = async () => {
await confirmWithChoices(
"Did you create the repository?",
"Please create the repository on GitHub, then press Enter to continue."
);
await confirmWithChoices(
"Did you start the wiki in the repository?",
"Please open the repository wiki and create an empty page, then press Enter to continue."
);
await confirmWithChoices(
"Did you create a copy of the [Template] project?",
"Please go to GitHub Projects, create a copy from [Template], then press Enter to continue."
);
await confirmWithChoices(
"Did you add the issues workflow?",
`Please go to the project >> Workflow >> Add to project >> Paste this line:
is:issue,pr is:open label:Task
Then press Enter to continue.`
);
await confirmWithChoices(
"Did you link the project to the repository?",
"Please link the GitHub Project to the repository, then press Enter to continue."
);
await confirmWithChoices(
"Is the repository correct in the workflow?",
"Make sure the workflow uses the correct repository, then press Enter to continue."
);
await confirmWithChoices(
"Is the repository in the workflow the same as the project?",
"Please choose the same repository used in the project, then press Enter to continue."
);
await confirmWithChoices(
`Did you update the sprint dates from ${projectStartDate} to ${sprintEndDate}?`,
`Please change the sprint date range in the project settings to:
Start: ${projectStartDate}
End: ${sprintEndDate}
Then press Enter to continue.`
);
};
await initialSetup();
const steps = [
{
name: "Clone and migrate repository",
command: `node index.js ${originRepo} ${targetRepo}`,
},
{
name: "Update GitHub Project fields",
command: `node project.js "${targetRepo}" "${projectStartDate}"`,
},
{
name: "Link parent-child issues",
command: `node subIssue.js "${targetRepo}"`,
},
];
(async () => {
for (const step of steps) {
console.log(`\n🚀 Starting: ${step.name}`);
try {
execSync(step.command, { stdio: "inherit", shell: true });
console.log(`✅ Completed: ${step.name}`);
} catch (error) {
console.error(`❌ Failed during: ${step.name}`);
console.error(error.message);
process.exit(1);
}
}
console.log("\n🎯 All steps completed successfully.");
// Post-setup manual tasks
const finalTasks = [
{
question:
"Did you enable 'Require contributors to sign off on web-based commits'?",
message:
"Please enable 'Require contributors to sign off on web-based commits' in the repo settings, then press Enter to continue.",
},
{
question: "Did you enable Discussions?",
message:
"Please enable Discussions from the repository settings tab, then press Enter to continue.",
},
{
question:
"Did you change 'Allow merge commits' default message to 'Pull request title and description'?",
message:
"Please update the default message for merge commits to 'Pull request title and description', then press Enter to continue.",
},
{
question:
"Did you change 'Allow squash merging' default message to 'Pull request title and commit details'?",
message:
"Please update the default squash commit message accordingly, then press Enter to continue.",
},
{
question:
"Did you check 'Always suggest updating pull request branches'?",
message:
"Please enable 'Always suggest updating pull request branches' in the repo settings, then press Enter to continue.",
},
{
question:
"Did you check 'Limit how many branches and tags can be updated in a single push'?",
message: "Please enable the limit option, then press Enter to continue.",
},
{
question: "Did you set the limit to 3 branches/tags per push?",
message:
"Please set the number limit to 3 branches/tags in the push settings, then press Enter to continue.",
},
{
question:
"Did you export rulesets from Template repo and import them to the new repo?",
message:
"Go to Template repo >> Settings >> Rulesets >> Export all, then go to the new repo and import them. Press Enter to continue.",
},
{
question: "Did you add the development sprint to all issues?",
message:
"Go to the GitHub Project board and make sure all issues are assigned to the development sprint. Then press Enter to continue.",
},
{
question: "Did you add a meeting discussion category?",
message:
"Please go to Discussions and add a 'Meetings' category for meeting notes. Press Enter to continue.",
},
{
question: "Did you create the standard discussion sections?",
message: `Please create the following discussion sections:
#️⃣ Brain Storming
💡 Ideas - Share ideas for new features
🗳️ Polls - Take a vote from the community
#️⃣ General
💬 General - Chat about anything and everything here
🙏 Q&A - Answers enabled · Ask the community for help
🙌 Show and tell - Show off something you've made
#️⃣ Project Documentations
📣 Announcements - Updates from maintainers
#️⃣ Meetings - Meetings Notes will be in this category.
Then press Enter to continue.`,
},
{
question: "Did you change the wiki sidebar link to the project name?",
message:
"Please rename the wiki sidebar link to match the project name, then press Enter to continue.",
},
];
for (const task of finalTasks) {
await confirmWithChoices(task.question, task.message);
}
console.log(
"\n📘 Please go to the wiki and begin updating it according to the project documentation and structure."
);
})();