2023-04-11 21:26:21 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { Command } from '@commander-js/extra-typings';
|
2023-04-27 20:40:44 +00:00
|
|
|
import figlet from 'figlet';
|
|
|
|
import chalk from 'chalk';
|
2023-04-11 21:26:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import CodeFreeze from './code-freeze/commands';
|
2023-05-11 05:23:19 +00:00
|
|
|
import Slack from './slack/commands/slack';
|
2023-05-26 00:02:20 +00:00
|
|
|
import Changefile from './changefile';
|
2023-05-11 05:23:19 +00:00
|
|
|
import { Logger } from './core/logger';
|
|
|
|
import { isGithubCI } from './core/environment';
|
2023-04-11 21:26:21 +00:00
|
|
|
|
2023-05-11 05:23:19 +00:00
|
|
|
if ( ! isGithubCI() ) {
|
|
|
|
Logger.notice(
|
|
|
|
chalk
|
|
|
|
.rgb( 150, 88, 138 )
|
|
|
|
.bold( figlet.textSync( 'WooCommerce \n Utils' ) )
|
|
|
|
);
|
|
|
|
}
|
2023-04-27 20:40:44 +00:00
|
|
|
|
2023-05-11 05:23:19 +00:00
|
|
|
const program = new Command()
|
2023-04-11 21:26:21 +00:00
|
|
|
.name( 'utils' )
|
|
|
|
.description( 'Monorepo utilities' )
|
2023-05-11 05:23:19 +00:00
|
|
|
.addCommand( CodeFreeze )
|
2023-05-26 00:02:20 +00:00
|
|
|
.addCommand( Slack )
|
|
|
|
.addCommand( Changefile );
|
2023-05-11 05:23:19 +00:00
|
|
|
|
|
|
|
program.exitOverride();
|
|
|
|
|
|
|
|
const run = async () => {
|
|
|
|
try {
|
|
|
|
// parseAsync handles cases where the action is async and not async.
|
|
|
|
await program.parseAsync( process.argv );
|
|
|
|
} catch ( e ) {
|
|
|
|
// if github ci, always error
|
|
|
|
if ( isGithubCI() ) {
|
|
|
|
Logger.error( e );
|
|
|
|
} else if ( e.code !== 'commander.help' ) {
|
|
|
|
// if not github ci, only error if not help
|
|
|
|
Logger.error( e );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
run();
|