Fix TS issues and lint the release post tool by running `tsc` (#36412)

This commit is contained in:
Sam Seay 2023-01-18 18:43:22 +13:00 committed by GitHub
parent 141a0bd6b4
commit d181008ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 84 additions and 113 deletions

View File

@ -23,7 +23,7 @@ jobs:
uses: ./.github/actions/setup-woocommerce-monorepo
- name: Lint
run: pnpm run -r --filter='woocommerce/client/admin...' --filter='!@woocommerce/e2e*' --filter='!@woocommerce/api' --color lint
run: pnpm run -r --filter='release-posts' --filter='woocommerce/client/admin...' --filter='!@woocommerce/e2e*' --filter='!@woocommerce/api' --color lint
- name: Test
run: pnpm run test --filter='woocommerce/client/admin...' --filter='!@woocommerce/e2e*' --filter='!@woocommerce/api' --color

View File

@ -1862,6 +1862,7 @@ importers:
tools/cli-core:
specifiers:
'@tsconfig/node16': ^1.0.3
'@types/uuid': ^9.0.0
chalk: ^4.1.2
dotenv: ^10.0.0
ora: ^5.4.1
@ -1874,10 +1875,11 @@ importers:
dotenv: 10.0.0
ora: 5.4.1
simple-git: 3.14.0
ts-node: 10.9.1_suuodkax7fygvcgfx5vhk45yei
ts-node: 10.9.1_vqcafhj4xvr2nzknlrdklk55zm
uuid: 8.3.2
devDependencies:
'@tsconfig/node16': 1.0.3
'@types/uuid': 9.0.0
typescript: 4.8.4
tools/code-analyzer:
@ -1996,7 +1998,12 @@ importers:
'@commander-js/extra-typings': ^0.1.0
'@octokit/rest': ^19.0.4
'@tsconfig/node16': ^1.0.3
'@types/ejs': ^3.1.1
'@types/express': ^4.17.13
'@types/lodash.shuffle': ^4.2.7
'@types/node': ^18.11.18
'@types/node-fetch': ^2.6.2
'@types/semver': ^7.3.10
cli-core: workspace:*
code-analyzer: workspace:*
commander: 9.4.0
@ -2024,10 +2031,15 @@ importers:
node-fetch: 2.6.7
open: 8.4.0
semver: 7.3.7
ts-node: 10.9.1_suuodkax7fygvcgfx5vhk45yei
ts-node: 10.9.1_vqcafhj4xvr2nzknlrdklk55zm
devDependencies:
'@tsconfig/node16': 1.0.3
'@types/ejs': 3.1.1
'@types/express': 4.17.14
'@types/lodash.shuffle': 4.2.7
'@types/node': 18.11.18
'@types/node-fetch': 2.6.2
'@types/semver': 7.3.12
typescript: 4.8.4
tools/storybook:
@ -2108,7 +2120,7 @@ importers:
express: 4.18.1
ora: 5.4.1
semver: 7.3.7
ts-node: 10.9.1_suuodkax7fygvcgfx5vhk45yei
ts-node: 10.9.1_vqcafhj4xvr2nzknlrdklk55zm
devDependencies:
'@tsconfig/node16': 1.0.3
'@types/express': 4.17.14
@ -3347,7 +3359,7 @@ packages:
dependencies:
'@babel/core': 7.12.9
'@babel/helper-create-class-features-plugin': 7.17.6_@babel+core@7.12.9
'@babel/helper-plugin-utils': 7.19.0
'@babel/helper-plugin-utils': 7.18.9
transitivePeerDependencies:
- supports-color
dev: true
@ -3360,7 +3372,7 @@ packages:
dependencies:
'@babel/core': 7.16.12
'@babel/helper-create-class-features-plugin': 7.17.6_@babel+core@7.16.12
'@babel/helper-plugin-utils': 7.19.0
'@babel/helper-plugin-utils': 7.18.9
transitivePeerDependencies:
- supports-color
dev: false
@ -6320,9 +6332,9 @@ packages:
'@babel/core': ^7.0.0-0
dependencies:
'@babel/core': 7.16.12
'@babel/helper-module-imports': 7.18.6
'@babel/helper-plugin-utils': 7.19.0
babel-plugin-polyfill-corejs2: 0.3.3_@babel+core@7.16.12
'@babel/helper-module-imports': 7.16.0
'@babel/helper-plugin-utils': 7.14.5
babel-plugin-polyfill-corejs2: 0.3.0_@babel+core@7.16.12
babel-plugin-polyfill-corejs3: 0.4.0_@babel+core@7.16.12
babel-plugin-polyfill-regenerator: 0.3.0_@babel+core@7.16.12
semver: 6.3.0
@ -6337,9 +6349,9 @@ packages:
'@babel/core': ^7.0.0-0
dependencies:
'@babel/core': 7.17.8
'@babel/helper-module-imports': 7.18.6
'@babel/helper-plugin-utils': 7.19.0
babel-plugin-polyfill-corejs2: 0.3.3_@babel+core@7.17.8
'@babel/helper-module-imports': 7.16.0
'@babel/helper-plugin-utils': 7.14.5
babel-plugin-polyfill-corejs2: 0.3.0_@babel+core@7.17.8
babel-plugin-polyfill-corejs3: 0.4.0_@babel+core@7.17.8
babel-plugin-polyfill-regenerator: 0.3.0_@babel+core@7.17.8
semver: 6.3.0
@ -7251,8 +7263,8 @@ packages:
'@babel/core': ^7.0.0-0
dependencies:
'@babel/core': 7.16.12
'@babel/helper-plugin-utils': 7.19.0
'@babel/helper-validator-option': 7.18.6
'@babel/helper-plugin-utils': 7.18.9
'@babel/helper-validator-option': 7.16.7
'@babel/plugin-transform-typescript': 7.16.8_@babel+core@7.16.12
transitivePeerDependencies:
- supports-color
@ -8043,7 +8055,7 @@ packages:
engines: {node: '>= 10.14.2'}
dependencies:
'@jest/types': 26.6.2
'@types/node': 17.0.21
'@types/node': 18.11.18
chalk: 4.1.2
jest-message-util: 26.6.2
jest-util: 26.6.2
@ -9789,7 +9801,7 @@ packages:
resolution: {integrity: sha512-OkIJpiU2fz6HOJujhlhfIGrc8hB4ibqtf7nnbJQDerG0BqwZCfmgtK5sWzZ0TkXVRBKD5MpLrTmCYyMxoMCgPw==}
engines: {node: '>= 8.9.0', npm: '>= 5.5.1'}
dependencies:
'@types/node': 17.0.21
'@types/node': 18.11.18
dev: false
/@slack/logger/3.0.0:
@ -9816,7 +9828,7 @@ packages:
'@slack/logger': 2.0.0
'@slack/types': 1.10.0
'@types/is-stream': 1.1.0
'@types/node': 17.0.21
'@types/node': 18.11.18
axios: 0.21.4
eventemitter3: 3.1.2
form-data: 2.5.1
@ -13118,7 +13130,7 @@ packages:
resolution: {integrity: sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==}
dependencies:
'@types/connect': 3.4.35
'@types/node': 17.0.21
'@types/node': 18.11.18
dev: true
/@types/cacheable-request/6.0.2:
@ -13151,7 +13163,7 @@ packages:
/@types/connect/3.4.35:
resolution: {integrity: sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==}
dependencies:
'@types/node': 17.0.21
'@types/node': 18.11.18
dev: true
/@types/cookie/0.4.1:
@ -13180,6 +13192,10 @@ packages:
'@types/trusted-types': 2.0.2
dev: true
/@types/ejs/3.1.1:
resolution: {integrity: sha512-RQul5wEfY7BjWm0sYY86cmUN/pcXWGyVxWX93DFFJvcrxax5zKlieLwA3T77xJGwNcZW0YW6CYG70p1m8xPFmA==}
dev: true
/@types/eslint-scope/3.7.3:
resolution: {integrity: sha512-PB3ldyrcnAicT35TWPs5IcwKD8S333HMaa2VVv4+wdvebJkjWuW/xESoB8IwRcog8HYVYamb1g/R31Qv5Bx03g==}
dependencies:
@ -13209,7 +13225,7 @@ packages:
/@types/express-serve-static-core/4.17.31:
resolution: {integrity: sha512-DxMhY+NAsTwMMFHBTtJFNp5qiHKJ7TeqOo23zVEM9alT1Ml27Q3xcTH0xwxn7Q0BbMcVEJOs/7aQtUWupUQN3Q==}
dependencies:
'@types/node': 17.0.21
'@types/node': 18.11.18
'@types/qs': 6.9.7
'@types/range-parser': 1.2.4
dev: true
@ -13227,7 +13243,7 @@ packages:
resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==}
dependencies:
'@types/minimatch': 3.0.5
'@types/node': 17.0.21
'@types/node': 18.11.18
dev: true
/@types/graceful-fs/4.1.5:
@ -13312,6 +13328,12 @@ packages:
dependencies:
'@types/node': 17.0.21
/@types/lodash.shuffle/4.2.7:
resolution: {integrity: sha512-b+K0NBpB4WcNoQTfifuTmi5nm5mJXRw9DBdbFfBr1q1+EVoTKkClDxq/7r1sq2GZcRelMFRsFcGGHrHQgxRySg==}
dependencies:
'@types/lodash': 4.14.184
dev: true
/@types/lodash/4.14.180:
resolution: {integrity: sha512-XOKXa1KIxtNXgASAnwj7cnttJxS4fksBRywK/9LzRV5YxrF80BXZIGeQSuoESQ/VkUj30Ae0+YcuHc15wJCB2g==}
@ -13357,7 +13379,14 @@ packages:
/@types/node-fetch/2.6.1:
resolution: {integrity: sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==}
dependencies:
'@types/node': 17.0.21
'@types/node': 18.11.18
form-data: 3.0.1
dev: true
/@types/node-fetch/2.6.2:
resolution: {integrity: sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==}
dependencies:
'@types/node': 18.11.18
form-data: 3.0.1
dev: true
@ -13383,6 +13412,9 @@ packages:
/@types/node/17.0.21:
resolution: {integrity: sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ==}
/@types/node/18.11.18:
resolution: {integrity: sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==}
/@types/normalize-package-data/2.4.1:
resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==}
dev: true
@ -13527,7 +13559,7 @@ packages:
resolution: {integrity: sha512-z5xyF6uh8CbjAu9760KDKsH2FcDxZ2tFCsA4HIMWE6IkiYMXfVoa+4f9KX+FN0ZLsaMw1WNG2ETLA6N+/YA+cg==}
dependencies:
'@types/mime': 3.0.1
'@types/node': 17.0.21
'@types/node': 18.11.18
dev: true
/@types/sizzle/2.3.3:
@ -13583,11 +13615,15 @@ packages:
/@types/uuid/8.3.4:
resolution: {integrity: sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==}
/@types/uuid/9.0.0:
resolution: {integrity: sha512-kr90f+ERiQtKWMz5rP32ltJ/BtULDI5RVO0uavn1HQUOwjx0R1h0rnDYNL0CepF1zL5bSY6FISAfd9tOdDhU5Q==}
dev: true
/@types/vinyl/2.0.6:
resolution: {integrity: sha512-ayJ0iOCDNHnKpKTgBG6Q6JOnHTj9zFta+3j2b8Ejza0e4cvRyMn0ZoLEmbPrTHe5YYRlDYPvPWVdV4cTaRyH7g==}
dependencies:
'@types/expect': 1.20.4
'@types/node': 17.0.21
'@types/node': 18.11.18
dev: true
/@types/webpack-env/1.16.3:
@ -13597,7 +13633,7 @@ packages:
/@types/webpack-sources/0.1.9:
resolution: {integrity: sha512-bvzMnzqoK16PQIC8AYHNdW45eREJQMd6WG/msQWX5V2+vZmODCOPb4TJcbgRljTZZTwTM4wUMcsI8FftNA7new==}
dependencies:
'@types/node': 17.0.21
'@types/node': 18.11.18
'@types/source-list-map': 0.1.2
source-map: 0.6.1
dev: true
@ -13767,7 +13803,7 @@ packages:
resolution: {integrity: sha512-8uALY5LTvSuHgloDVUvWP3pIauILm+8/0pDMokuDYIoNsOkSwd5AiHBTSEJjKTDcZr5z8UpgOWZkxBF4iJftoA==}
requiresBuild: true
dependencies:
'@types/node': 17.0.21
'@types/node': 18.11.18
dev: true
optional: true
@ -18859,19 +18895,6 @@ packages:
- supports-color
dev: true
/babel-plugin-polyfill-corejs2/0.3.3_@babel+core@7.16.12:
resolution: {integrity: sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q==}
peerDependencies:
'@babel/core': ^7.0.0-0
dependencies:
'@babel/compat-data': 7.19.3
'@babel/core': 7.16.12
'@babel/helper-define-polyfill-provider': 0.3.3_@babel+core@7.16.12
semver: 6.3.0
transitivePeerDependencies:
- supports-color
dev: false
/babel-plugin-polyfill-corejs2/0.3.3_@babel+core@7.17.8:
resolution: {integrity: sha512-8hOdmFYFSZhqg2C/JgLUQ+t52o5nirNwaWM2B9LWteozwIvM14VSwdsCAUET10qT+kmySAlseadmfeeSWFCy+Q==}
peerDependencies:
@ -21243,7 +21266,7 @@ packages:
postcss-value-parser: 4.2.0
schema-utils: 2.7.1
semver: 6.3.0
webpack: 5.70.0
webpack: 5.70.0_webpack-cli@3.3.12
/css-loader/5.2.7_webpack@5.70.0:
resolution: {integrity: sha512-Q7mOvpBNBG7YrVGMxRxcBJZFL75o+cH2abNASdibkj/fffYD8qWbInZrD0S9ccI6vZclF3DsHE7njGlLtaHbhg==}
@ -28495,7 +28518,7 @@ packages:
'@jest/environment': 26.6.2
'@jest/fake-timers': 26.6.2
'@jest/types': 26.6.2
'@types/node': 17.0.21
'@types/node': 18.11.18
jest-mock: 26.6.2
jest-util: 26.6.2
jsdom: 16.7.0
@ -28758,7 +28781,7 @@ packages:
'@jest/source-map': 26.6.2
'@jest/test-result': 26.6.2
'@jest/types': 26.6.2
'@types/node': 17.0.21
'@types/node': 18.11.18
chalk: 4.1.2
co: 4.6.0
expect: 26.6.2
@ -29447,7 +29470,7 @@ packages:
resolution: {integrity: sha512-S5wqyz0DXnNJPd/xfIzZ5Xnp1HrJWBczg8mMfMpN78OJ5eDxXyf+Ygld9wX1DnUWbIbhM1YDY95NjR4CBXkb2g==}
engines: {node: '>= 10.14.2'}
dependencies:
'@types/node': 17.0.21
'@types/node': 18.11.18
graceful-fs: 4.2.9
/jest-serializer/27.5.1:
@ -29684,7 +29707,7 @@ packages:
dependencies:
'@jest/test-result': 26.6.2
'@jest/types': 26.6.2
'@types/node': 17.0.21
'@types/node': 18.11.18
ansi-escapes: 4.3.2
chalk: 4.1.2
jest-util: 26.6.2
@ -36855,7 +36878,7 @@ packages:
neo-async: 2.6.2
schema-utils: 3.1.1
semver: 7.3.5
webpack: 5.70.0
webpack: 5.70.0_webpack-cli@3.3.12
/sass-loader/12.6.0_sass@1.49.9+webpack@5.70.0:
resolution: {integrity: sha512-oLTaH0YCtX4cfnJZxKSLAyglED0naiYfNG1iXfU5w1LNZ+ukoA5DtyDIN5zmKVZwYNJP4KRc5Y3hkWga+7tYfA==}
@ -38792,7 +38815,7 @@ packages:
serialize-javascript: 6.0.0
source-map: 0.6.1
terser: 5.10.0_acorn@8.8.1
webpack: 5.70.0
webpack: 5.70.0_webpack-cli@3.3.12
transitivePeerDependencies:
- acorn
@ -39295,7 +39318,7 @@ packages:
yn: 3.1.1
dev: true
/ts-node/10.9.1_suuodkax7fygvcgfx5vhk45yei:
/ts-node/10.9.1_vqcafhj4xvr2nzknlrdklk55zm:
resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==}
hasBin: true
peerDependencies:
@ -39314,7 +39337,7 @@ packages:
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3
'@tsconfig/node16': 1.0.3
'@types/node': 17.0.21
'@types/node': 18.11.18
acorn: 8.7.0
acorn-walk: 8.2.0
arg: 4.1.3

View File

@ -12,6 +12,7 @@
},
"devDependencies": {
"@tsconfig/node16": "^1.0.3",
"@types/uuid": "^9.0.0",
"typescript": "^4.8.3"
},
"dependencies": {

View File

@ -3,7 +3,6 @@
*/
import { Logger } from 'cli-core/src/logger';
export const getEnvVar = ( varName: string, isRequired = false ) => {
const value = process.env[ varName ];

View File

@ -3,6 +3,10 @@
*/
import { Octokit } from '@octokit/rest';
import shuffle from 'lodash.shuffle';
/**
* Internal dependencies
*/
import { getEnvVar } from './environment';
export type ContributorData = {

View File

@ -1,62 +0,0 @@
/**
* External dependencies
*/
import ora, { Ora } from 'ora';
import chalk from 'chalk';
/**
* Internal dependencies
*/
import { getEnvVar } from './environment';
const { log, error, warn } = console;
export class Logger {
private static lastSpinner: Ora | null;
private static get loggingLevel() {
return {
warn: 2,
silent: 1,
}[ getEnvVar( 'LOGGER_LEVEL' ) || 'warn' ] as number;
}
static error( message: string ) {
Logger.failTask();
error( chalk.red( message ) );
process.exit( 1 );
}
static warn( message: string ) {
if ( Logger.loggingLevel >= 2 ) {
warn( chalk.yellow( message ) );
}
}
static notice( message: string ) {
if ( Logger.loggingLevel >= 1 ) {
log( chalk.green( message ) );
}
}
static startTask( message: string ) {
if ( Logger.loggingLevel >= 1 ) {
const spinner = ora( chalk.green( `${ message }...` ) ).start();
Logger.lastSpinner = spinner;
}
}
static failTask() {
if ( Logger.lastSpinner ) {
Logger.lastSpinner.fail( `${ Logger.lastSpinner.text } failed.` );
Logger.lastSpinner = null;
}
}
static endTask() {
if ( Logger.loggingLevel > 1 && Logger.lastSpinner ) {
Logger.lastSpinner.succeed(
`${ Logger.lastSpinner.text } complete.`
);
Logger.lastSpinner = null;
}
}
}

View File

@ -8,14 +8,14 @@ const TEMPLATE_DIR = join( __dirname, '..', 'templates' );
export const renderTemplate = (
templateFile: string,
templateData: unknown
templateData: ejs.Data
) => {
return new Promise< string >( ( resolve, reject ) => {
ejs.renderFile(
join( TEMPLATE_DIR, templateFile ),
templateData,
{},
function ( err: Error, str: string ) {
function ( err: Error | null, str: string ) {
if ( err ) {
reject( err );
} else {

View File

@ -4,6 +4,7 @@
"description": "Automate release post generation for Wordpress plugins",
"main": " ",
"scripts": {
"lint": "tsc --noEmit",
"release-post": "node -r ts-node/register ./commands/release-post/index.ts"
},
"author": "Automattic",
@ -14,7 +15,12 @@
},
"devDependencies": {
"@tsconfig/node16": "^1.0.3",
"@types/ejs": "^3.1.1",
"@types/express": "^4.17.13",
"@types/lodash.shuffle": "^4.2.7",
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.2",
"@types/semver": "^7.3.10",
"typescript": "^4.8.3"
},
"dependencies": {