AAE-39314 Break dependencies on the "commander" lib in the CLI (#11299)

This commit is contained in:
Denys Vuika
2025-10-23 12:22:40 -04:00
committed by GitHub
parent 1c8af0467e
commit e202c693c1
11 changed files with 502 additions and 132 deletions
+51 -11
View File
@@ -17,7 +17,7 @@
import { AlfrescoApi, SharedlinksApi, FavoritesApi, NodesApi, UploadApi, NodeEntry } from '@alfresco/js-api';
import { exit, argv } from 'node:process';
import { Command } from 'commander';
import { parseArgs } from 'node:util';
import { createReadStream } from 'fs';
import * as path from 'path';
import { logger } from './logger';
@@ -28,8 +28,6 @@ interface InitAcsEnvArgs {
username?: string;
password?: string;
}
const program = new Command();
const MAX_RETRY = 10;
let counter = 0;
const TIMEOUT = 6000;
@@ -41,15 +39,57 @@ let alfrescoJsApi: AlfrescoApi;
* Init ACS environment command
*/
export default async function main() {
program
.version('0.1.0')
.option('--host [type]', 'Remote environment host')
.option('--clientId [type]', 'sso client', 'alfresco')
.option('-p, --password [type]', 'password ')
.option('-u, --username [type]', 'username ')
.parse(argv);
if (argv.includes('-h') || argv.includes('--help')) {
console.log(`
Usage: init-acs-env [options]
Initialize ACS environment
Options:
-v, --version Output the version number
--host <host> Remote environment host
--clientId <id> SSO client (default: "alfresco")
-p, --password <pass> Password
-u, --username <user> Username
-h, --help Display help for command
`);
exit(0);
}
if (argv.includes('-v') || argv.includes('--version')) {
console.log('0.1.0');
exit(0);
}
const { values } = parseArgs({
args: argv.slice(2),
options: {
host: {
type: 'string'
},
clientId: {
type: 'string',
default: 'alfresco'
},
password: {
type: 'string',
short: 'p'
},
username: {
type: 'string',
short: 'u'
}
},
allowPositionals: true
});
const opts: InitAcsEnvArgs = {
host: values.host as string | undefined,
clientId: values.clientId as string | undefined,
username: values.username as string | undefined,
password: values.password as string | undefined
};
const opts = program.opts();
await checkEnv(opts);
logger.info(`***** Step initialize ACS *****`);