themes-wordpress/create-a-theme-checklist.js
Sarah Norris 3bba9aeffc
Update Create Theme Checklist items (#5697)
* Update checklist items

* Remove theme.json: Alternative color palettes

* Rename Core Block Settings

* Remove Navigation

* Rename page.html title
2022-03-17 15:29:47 +00:00

98 lines
2.4 KiB
JavaScript

const theme = process.argv[2];
if (!theme) {
console.error('\x1b[41m', 'You must specify a theme!');
return;
}
const { Octokit } = require('octokit');
const octokit = new Octokit({ auth: `PUT YOUR TOKEN HERE` });
async function createLabel() {
try {
return await octokit.request('POST /repos/Automattic/themes/labels', {
name: '[Theme] ' + theme,
color: 'c1f4a1',
description: 'Automatically generated label for ' + theme + '.',
});
} catch (error) {
console.log(error);
}
}
async function createMilestone() {
try {
return await octokit.request(
'POST /repos/Automattic/themes/milestones',
{
title: theme,
description:
'Automatically generated milestone for ' + theme + '.',
}
);
} catch (error) {
console.error('\x1b[41m', 'Milestone already created.');
}
}
async function createIssues(milestoneNumber) {
const issues = [
'Create base theme',
'Create a demo site on dotcom',
'theme.json: Typography settings',
'theme.json: Color palette',
'theme.json: Margin/spacing settings + content layout',
'Templates: Page templates - Index',
'Templates: Page templates - Search',
'Templates: Page templates - 404',
'Templates: Page templates - Archive',
'Templates: Post templates - Single',
'Templates: page.html',
'Templates: Header template part',
'Templates: Footer template part',
'Block patterns',
'Comment form styles (dotcom and dotorg)',
'theme.json: Core block settings',
'Pre-launch: readme.txt',
'Pre-launch: screenshot.png',
'Pre-launch: style.css tags',
];
issues.forEach(async (issue) => {
try {
return await octokit
.request('POST /repos/Automattic/themes/issues', {
title: theme + ': ' + issue,
labels: ['[Theme] ' + theme],
milestone: milestoneNumber,
})
.then((issueData) => {
addIssueToProject(issueData);
});
} catch (error) {
console.log(error);
}
});
}
async function addIssueToProject(issueData) {
try {
return await octokit.request('POST /projects/columns/11021541/cards', {
note: null,
content_id: issueData.data.id,
content_url: issueData.data.url,
content_type: 'Issue',
mediaType: {
previews: ['inertia'],
},
});
} catch (error) {
console.log(error);
}
}
createLabel().then(() => {
createMilestone().then((milestoneData) => {
const milestoneNumber = milestoneData.data.number;
createIssues(milestoneNumber);
});
});