|
@@ -1,27 +1,37 @@
|
|
|
-const theme = process.argv[2];
|
|
|
+const theme = process.argv[ 2 ];
|
|
|
|
|
|
-if (!theme) {
|
|
|
- console.error('\x1b[41m', 'You must specify a theme!');
|
|
|
+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` });
|
|
|
+const { Octokit } = require( 'octokit' );
|
|
|
+const octokit = new Octokit( {
|
|
|
+ auth: `PUT YOUR ACCESS TOKEN HERE`,
|
|
|
+} );
|
|
|
+
|
|
|
+function sleep( ms ) {
|
|
|
+ return new Promise( ( resolve ) => {
|
|
|
+ setTimeout( resolve, ms );
|
|
|
+ } );
|
|
|
+}
|
|
|
|
|
|
async function createLabel() {
|
|
|
try {
|
|
|
- return await octokit.request('POST /repos/Automattic/themes/labels', {
|
|
|
+ await sleep( 1000 );
|
|
|
+ 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);
|
|
|
+ } );
|
|
|
+ } catch ( error ) {
|
|
|
+ console.log( error );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async function createMilestone() {
|
|
|
try {
|
|
|
+ await sleep( 1000 );
|
|
|
return await octokit.request(
|
|
|
'POST /repos/Automattic/themes/milestones',
|
|
|
{
|
|
@@ -30,69 +40,78 @@ async function createMilestone() {
|
|
|
'Automatically generated milestone for ' + theme + '.',
|
|
|
}
|
|
|
);
|
|
|
- } catch (error) {
|
|
|
- console.error('\x1b[41m', 'Milestone already created.');
|
|
|
+ } catch ( error ) {
|
|
|
+ console.error( '\x1b[41m', 'Milestone already created.' );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-async function createIssues(milestoneNumber) {
|
|
|
+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',
|
|
|
+ 'Block Patterns',
|
|
|
+ 'Create Base Theme',
|
|
|
+ 'Styles: Colors',
|
|
|
+ 'Styles: Typography — Fonts & Weights',
|
|
|
+ 'Styles: Typography — Sizes & Line Height',
|
|
|
+ 'Styles: Links',
|
|
|
+ 'Styles: Buttons',
|
|
|
+ 'Styles: Layout',
|
|
|
+ 'Styles: Comments',
|
|
|
+ 'Styles: Navigation',
|
|
|
+ 'Styles: Quote',
|
|
|
+ 'Styles: Variations',
|
|
|
+ 'Templates: Search, Category, Tag',
|
|
|
+ 'Templates: 404',
|
|
|
+ 'Templates: Single',
|
|
|
+ 'Templates: Page',
|
|
|
+ 'Templates: Index',
|
|
|
'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',
|
|
|
+ 'Pre-launch: Screenshot, readme.txt & description',
|
|
|
+ 'Pre-launch: Demo Site',
|
|
|
+ 'Pre-launch: Showcase Entry',
|
|
|
+ 'Pre-launch: Headstart Annotation',
|
|
|
];
|
|
|
- issues.forEach(async (issue) => {
|
|
|
+ issues.forEach( async ( issue ) => {
|
|
|
try {
|
|
|
- return await octokit
|
|
|
- .request('POST /repos/Automattic/themes/issues', {
|
|
|
+ await sleep( 1000 );
|
|
|
+ return await octokit.request(
|
|
|
+ 'POST /repos/Automattic/themes/issues',
|
|
|
+ {
|
|
|
title: theme + ': ' + issue,
|
|
|
- labels: ['[Theme] ' + theme],
|
|
|
+ labels: [ '[Theme] ' + theme ],
|
|
|
milestone: milestoneNumber,
|
|
|
- })
|
|
|
- .then((issueData) => {
|
|
|
- addIssueToProject(issueData);
|
|
|
- });
|
|
|
- } catch (error) {
|
|
|
- console.log(error);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ // If you want to automatically add this to the Theme Dev Board, uncomment this.
|
|
|
+ // .then( ( issueData ) => {
|
|
|
+ // addIssueToProject( issueData );
|
|
|
+ // } );
|
|
|
+ } catch ( error ) {
|
|
|
+ console.log( error );
|
|
|
}
|
|
|
- });
|
|
|
+ } );
|
|
|
}
|
|
|
|
|
|
-async function addIssueToProject(issueData) {
|
|
|
+async function addIssueToProject( issueData ) {
|
|
|
try {
|
|
|
- return await octokit.request('POST /projects/columns/11021541/cards', {
|
|
|
+ await sleep( 1000 );
|
|
|
+ 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'],
|
|
|
+ previews: [ 'inertia' ],
|
|
|
},
|
|
|
- });
|
|
|
- } catch (error) {
|
|
|
- console.log(error);
|
|
|
+ } );
|
|
|
+ } catch ( error ) {
|
|
|
+ console.log( error );
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-createLabel().then(() => {
|
|
|
- createMilestone().then((milestoneData) => {
|
|
|
+createLabel().then( () => {
|
|
|
+ createMilestone().then( ( milestoneData ) => {
|
|
|
const milestoneNumber = milestoneData.data.number;
|
|
|
- createIssues(milestoneNumber);
|
|
|
- });
|
|
|
-});
|
|
|
+ createIssues( milestoneNumber );
|
|
|
+ } );
|
|
|
+} );
|