Skip to content

Commit

Permalink
[ci:force] fix jsdoc errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysVuika committed Sep 28, 2023
1 parent 306cc25 commit 6f1a749
Show file tree
Hide file tree
Showing 27 changed files with 686 additions and 78 deletions.
18 changes: 18 additions & 0 deletions lib/cli/scripts/artifact-from-s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,41 @@ import { exec } from './exec';
import { logger } from './logger';
import program from 'commander';

/**
* Perform a test
*
* @param output output path
*/
function test(output: string) {
const response = exec('test !', [`-d ${output} && mkdir ${output}`], {});
logger.info(response);
}

/**
* Copy AWS S3
*
* @param artifact artifact name
*/
function awsCp(artifact: string) {
logger.info(`aws s3 cp ${artifact}`);
const response = exec(`aws s3 cp ${artifact}`, [`./s3-artifact.tmp ${artifact}`], {});
logger.info(response);
}

/**
* Zip artifact
*
* @param output output name
*/
function zipArtifact(output: string) {
logger.info(`Perform zip artifact ${output}`);
const response = exec('tar', ['-xvf', `./s3-artifact.tmp`, '-C ' + program.output], {});
logger.info(response);
}

/**
* Artifact from S3 command
*/
export default function main() {
program
.version('0.1.0')
Expand Down
13 changes: 13 additions & 0 deletions lib/cli/scripts/artifact-to-s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,33 @@ import { exec } from './exec';
import { logger } from './logger';
import program from 'commander';

/**
* Zip artifact
*
* @param artifact artifact name
*/
function zipArtifact(artifact: string) {
logger.info(`Perform zip artifact ${artifact}`);

const response = exec(`tar cvfj ./s3-artifact.tmp -C ${program.artifact} ls ${program.artifact}`, [], {});
logger.info(response);
}

/**
* Copy to AWS S3
*
* @param output output path
*/
function awsCp(output: string) {
logger.info(`aws s3 cp ${output}`);
const response = exec('aws s3 cp', [`./s3-artifact.tmp ${output}`], {});
logger.info(response);
}


/**
* Artifact to S3 command
*/
export default function main() {
program
.version('0.1.0')
Expand Down
7 changes: 7 additions & 0 deletions lib/cli/scripts/audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ import * as fs from 'fs';
import { argv, exit } from 'node:process';
import program from 'commander';

/**
* Audit report command
*
* @param _args (unused)
* @param workingDir working directory
* @returns void
*/
export default function main(_args: string[], workingDir: string) {
program
.description('Generate an audit report')
Expand Down
14 changes: 14 additions & 0 deletions lib/cli/scripts/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,25 @@ function getCommits(options: DiffOptions): Array<Commit> {
.filter((commit: Commit) => commitAuthorAllowed(commit, authorFilter));
}

/**
* Check if commit author is allowed
*
* @param commit git commit
* @param authorFilter filter
* @returns `true` if author is allowed, otherwise `false`
*/
function commitAuthorAllowed(commit: Commit, authorFilter: string): boolean {
const filterRegex = RegExp(authorFilter);
return !(filterRegex.test(commit.author) || filterRegex.test(commit.author_email));
}

/**
* Changelog command
*
* @param _args (unused)
* @param workingDir working directory
* @returns void
*/
export default function main(_args: string[], workingDir: string) {
program
.description('Generate changelog report for two branches of git repository')
Expand Down
11 changes: 11 additions & 0 deletions lib/cli/scripts/check-cs-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const TIMEOUT = 20000;
let counter = 0;
let alfrescoJsApi: AlfrescoApi;

/**
* Check CS environment command
*/
export default async function main() {
program
.version('0.1.0')
Expand All @@ -42,6 +45,9 @@ export default async function main() {
// await checkDiskSpaceFullEnv();
}

/**
* Check environment
*/
async function checkEnv() {
try {
alfrescoJsApi = new AlfrescoApi({
Expand Down Expand Up @@ -111,6 +117,11 @@ async function checkDiskSpaceFullEnv() {
}
*/

/**
* Perform a delay
*
* @param delay timeout in milliseconds
*/
function sleep(delay: number) {
const start = new Date().getTime();
while (new Date().getTime() < start + delay) {}
Expand Down
14 changes: 13 additions & 1 deletion lib/cli/scripts/check-plugin-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import { GovernanceCheckPlugin } from './plugins/governance-check-plugin';

let pluginEnv: CheckEnv;

export default async function main(_args: string[]) {
/**
* Check environment plugin
*/
export default async function main() {
program
.version('0.1.0')
.option('--host [type]', 'Remote environment host')
Expand Down Expand Up @@ -53,6 +56,9 @@ export default async function main(_args: string[]) {
}
}

/**
* Check PS plugin
*/
async function checkProcessServicesPlugin() {
const processServiceCheckPlugin = new ProcessServiceCheckPlugin(
{
Expand All @@ -64,6 +70,9 @@ async function checkProcessServicesPlugin() {
await processServiceCheckPlugin.checkProcessServicesPlugin();
}

/**
* Check APA plugin
*/
async function checkProcessAutomationPlugin() {
const processAutomationCheckPlugin = new ProcessAutomationCheckPlugin(
{
Expand All @@ -77,6 +86,9 @@ async function checkProcessAutomationPlugin() {
await processAutomationCheckPlugin.checkProcessAutomationPlugin();
}

/**
* Check AGS plugin
*/
async function checkGovernancePlugin() {
const governancePluginCheck = new GovernanceCheckPlugin(
{
Expand Down
11 changes: 11 additions & 0 deletions lib/cli/scripts/check-ps-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const MAX_RETRY = 10;
const TIMEOUT = 60000;
let counter = 0;

/**
* Check PS environment command
*/
export default async function main() {
program
.version('0.1.0')
Expand All @@ -36,6 +39,9 @@ export default async function main() {
await checkEnv();
}

/**
* Check environment
*/
async function checkEnv() {
try {
const alfrescoJsApi = new AlfrescoApi({
Expand Down Expand Up @@ -63,6 +69,11 @@ async function checkEnv() {
}
}

/**
* Perform a delay
*
* @param delay timeout in milliseconds
*/
function sleep(delay: number) {
const start = new Date().getTime();
while (new Date().getTime() < start + delay) {}
Expand Down
5 changes: 5 additions & 0 deletions lib/cli/scripts/docker-publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

import * as docker from './docker';

/**
* Docker publish command
*
* @param args command arguments
*/
export default function(args: any) {
docker.default(args);
}
69 changes: 55 additions & 14 deletions lib/cli/scripts/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,24 @@ export interface PublishArgs {
sourceTag?: string;
}

function loginPerform(args: PublishArgs) {
/**
* Perform a login
*
* @param args arguments
*/
function login(args: PublishArgs) {
logger.info(`Perform docker login...${args.loginRepo}`);
const loginDockerRes = exec('docker', ['login', `-u=${args.loginUsername}`, `-p=${args.loginPassword}`, `${args.loginRepo}`]);
logger.info(loginDockerRes);
}

function buildImagePerform(args: PublishArgs, tag: string) {
/**
* Build Docker image
*
* @param args command arguments
* @param tag tag
*/
function buildImage(args: PublishArgs, tag: string) {
logger.info(`Perform docker build...${args.dockerRepo}:${tag}`);

const buildArgs = [];
Expand All @@ -71,19 +82,38 @@ function buildImagePerform(args: PublishArgs, tag: string) {
logger.info(response);
}

function tagImagePerform(args: PublishArgs, tagImage: string, newTag: string) {
logger.info(`Perform docker tag... ${args.dockerRepo}:${tagImage} on ${args.dockerRepo}:${newTag}`);
const response = exec('docker', ['tag', `${args.dockerRepo}:${tagImage}`, `${args.dockerRepo}:${newTag}`], {});
/**
* Tag Docker image
*
* @param args command arguments
* @param imageTag image tag
* @param newTag new image tag
*/
function tagImage(args: PublishArgs, imageTag: string, newTag: string) {
logger.info(`Perform docker tag... ${args.dockerRepo}:${imageTag} on ${args.dockerRepo}:${newTag}`);
const response = exec('docker', ['tag', `${args.dockerRepo}:${imageTag}`, `${args.dockerRepo}:${newTag}`], {});
logger.info(response);
}

function pullImagePerform(dockerRepo: string, sourceTag: string) {
/**
* Pull Docker image
*
* @param dockerRepo repository
* @param sourceTag tag
*/
function pullImage(dockerRepo: string, sourceTag: string) {
logger.info(`Perform docker pull... ${dockerRepo}:${sourceTag}`);
const response = exec('docker', ['pull', `${dockerRepo}:${sourceTag}`], {});
logger.info(response);
}

function pushImagePerform(args: PublishArgs, tag: string) {
/**
* Push Docker image
*
* @param args command arguments
* @param tag tag
*/
function pushImage(args: PublishArgs, tag: string) {
if (args.dryrun) {
logger.info(`Dry-run Perform docker push... ${args.dockerRepo}:${tag}`);
} else {
Expand All @@ -93,12 +123,23 @@ function pushImagePerform(args: PublishArgs, tag: string) {
}
}

function cleanImagePerform(args: PublishArgs, tag: string) {
/**
* Clean Docker image
*
* @param args command arguments
* @param tag tag
*/
function cleanImage(args: PublishArgs, tag: string) {
logger.info(`Perform docker clean on tag:${tag}...`);
const response = exec('docker', ['rmi', `-f`, `${args.dockerRepo}:${tag}`], {});
logger.info(response);
}

/**
* Publish to Docker command
*
* @param args command arguments
*/
export default function main(args: PublishArgs) {
program
.version('0.1.0')
Expand Down Expand Up @@ -150,7 +191,7 @@ export default function main(args: PublishArgs) {
}

if (args.loginCheck === true) {
loginPerform(args);
login(args);
}

let mainTag: string;
Expand All @@ -162,17 +203,17 @@ export default function main(args: PublishArgs) {
if (index === 0) {
logger.info(`Build only once`);
mainTag = tag;
buildImagePerform(args, mainTag);
buildImage(args, mainTag);
}
} else {
mainTag = args.sourceTag;
pullImagePerform(args.dockerRepo, mainTag);
pullImage(args.dockerRepo, mainTag);
}
tagImagePerform(args, mainTag, tag);
pushImagePerform(args, tag);
tagImage(args, mainTag, tag);
pushImage(args, tag);
}
});
cleanImagePerform(args, mainTag);
cleanImage(args, mainTag);
} else {
logger.error(`dockerTags cannot be empty ...`);
}
Expand Down
14 changes: 13 additions & 1 deletion lib/cli/scripts/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,19 @@
import { spawnSync } from 'child_process';
import { logger } from './logger';

export function exec(command: string, args?: string[], opts?: { cwd?: string }) {
export interface ExecOptions {
cwd?: string;
}

/**
* Exec function
*
* @param command command to execute
* @param args command arguments
* @param opts optional settings
* @returns void function
*/
export function exec(command: string, args?: string[], opts?: ExecOptions) {
if (process.platform.startsWith('win')) {
args.unshift('/c', command);
command = 'cmd.exe';
Expand Down
Loading

0 comments on commit 6f1a749

Please sign in to comment.