create-a-theme-checklist.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. const theme = process.argv[ 2 ];
  2. if ( ! theme ) {
  3. console.error( '\x1b[41m', 'You must specify a theme!' );
  4. return;
  5. }
  6. const { Octokit } = require( 'octokit' );
  7. const octokit = new Octokit( {
  8. auth: `PUT YOUR ACCESS TOKEN HERE`,
  9. } );
  10. function sleep( ms ) {
  11. return new Promise( ( resolve ) => {
  12. setTimeout( resolve, ms );
  13. } );
  14. }
  15. async function createLabel() {
  16. try {
  17. await sleep( 1000 );
  18. return await octokit.request( 'POST /repos/Automattic/themes/labels', {
  19. name: '[Theme] ' + theme,
  20. color: 'c1f4a1',
  21. description: 'Automatically generated label for ' + theme + '.',
  22. } );
  23. } catch ( error ) {
  24. console.log( error );
  25. }
  26. }
  27. async function createMilestone() {
  28. try {
  29. await sleep( 1000 );
  30. return await octokit.request(
  31. 'POST /repos/Automattic/themes/milestones',
  32. {
  33. title: theme,
  34. description:
  35. 'Automatically generated milestone for ' + theme + '.',
  36. }
  37. );
  38. } catch ( error ) {
  39. console.error( '\x1b[41m', 'Milestone already created.' );
  40. }
  41. }
  42. async function createIssues( milestoneNumber ) {
  43. const issues = [
  44. 'Block Patterns',
  45. 'Create Base Theme',
  46. 'Styles: Colors',
  47. 'Styles: Typography — Fonts & Weights',
  48. 'Styles: Typography — Sizes & Line Height',
  49. 'Styles: Links',
  50. 'Styles: Buttons',
  51. 'Styles: Layout',
  52. 'Styles: Comments',
  53. 'Styles: Navigation',
  54. 'Styles: Quote',
  55. 'Styles: Variations',
  56. 'Templates: Search, Category, Tag',
  57. 'Templates: 404',
  58. 'Templates: Single',
  59. 'Templates: Page',
  60. 'Templates: Index',
  61. 'Templates: Header template part',
  62. 'Templates: Footer template part',
  63. 'Pre-launch: Screenshot, readme.txt & description',
  64. 'Pre-launch: Demo Site',
  65. 'Pre-launch: Showcase Entry',
  66. 'Pre-launch: Headstart Annotation',
  67. ];
  68. issues.forEach( async ( issue ) => {
  69. try {
  70. await sleep( 1000 );
  71. return await octokit.request(
  72. 'POST /repos/Automattic/themes/issues',
  73. {
  74. title: theme + ': ' + issue,
  75. labels: [ '[Theme] ' + theme ],
  76. milestone: milestoneNumber,
  77. }
  78. );
  79. // If you want to automatically add this to the Theme Dev Board, uncomment this.
  80. // .then( ( issueData ) => {
  81. // addIssueToProject( issueData );
  82. // } );
  83. } catch ( error ) {
  84. console.log( error );
  85. }
  86. } );
  87. }
  88. async function addIssueToProject( issueData ) {
  89. try {
  90. await sleep( 1000 );
  91. return await octokit.request( 'POST /projects/columns/11021541/cards', {
  92. note: null,
  93. content_id: issueData.data.id,
  94. content_url: issueData.data.url,
  95. content_type: 'Issue',
  96. mediaType: {
  97. previews: [ 'inertia' ],
  98. },
  99. } );
  100. } catch ( error ) {
  101. console.log( error );
  102. }
  103. }
  104. createLabel().then( () => {
  105. createMilestone().then( ( milestoneData ) => {
  106. const milestoneNumber = milestoneData.data.number;
  107. createIssues( milestoneNumber );
  108. } );
  109. } );