forked from Automattic/themes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-a-theme-checklist.js
100 lines (93 loc) · 2.6 KB
/
create-a-theme-checklist.js
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
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 from boilerplate',
'Create a demo site on dotcom',
'theme.json: Typography settings',
'theme.json: Color palette',
'theme.json: Alternative color palettes',
'theme.json: Margin/spacing settings + content layout',
'Templates: Page templates - Index',
'Templates: Page templates - Search',
'Templates: Page templates - 404',
'Templates: Page templates - Archive',
'Templates: Header template part (including mobile)',
'Templates: Footer template part (including mobile)',
'Block patterns (if needed)',
'Block styles (if needed)',
'Comment form styles (dotcom and dotorg) (if needed)',
'Navigation (if needed)',
'Core block settings (if needed)',
'Third party block settings (Jetpack, Woo, etc.) (if needed)',
'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 );
} );
} );