mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-6071] fix jsdoc warnings and errors (#8948)
* fix content docs * fix extensions docs * fix insights docs * [ci:force] fix jsdoc errors and warnings * enable jsdoc linter * [ci:force] fix demo shell jsdoc * [ci:force] fix e2e typings * fix typo * fix typo
This commit is contained in:
@@ -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')
|
||||
|
@@ -22,6 +22,11 @@ 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}`);
|
||||
|
||||
@@ -29,6 +34,11 @@ function zipArtifact(artifact: string) {
|
||||
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}`], {});
|
||||
@@ -36,6 +46,9 @@ function awsCp(output: string) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Artifact to S3 command
|
||||
*/
|
||||
export default function main() {
|
||||
program
|
||||
.version('0.1.0')
|
||||
|
@@ -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')
|
||||
|
@@ -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')
|
||||
|
@@ -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')
|
||||
@@ -42,6 +45,9 @@ export default async function main() {
|
||||
// await checkDiskSpaceFullEnv();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check environment
|
||||
*/
|
||||
async function checkEnv() {
|
||||
try {
|
||||
alfrescoJsApi = new AlfrescoApi({
|
||||
@@ -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) {}
|
||||
|
@@ -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')
|
||||
@@ -53,6 +56,9 @@ export default async function main(_args: string[]) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check PS plugin
|
||||
*/
|
||||
async function checkProcessServicesPlugin() {
|
||||
const processServiceCheckPlugin = new ProcessServiceCheckPlugin(
|
||||
{
|
||||
@@ -64,6 +70,9 @@ async function checkProcessServicesPlugin() {
|
||||
await processServiceCheckPlugin.checkProcessServicesPlugin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check APA plugin
|
||||
*/
|
||||
async function checkProcessAutomationPlugin() {
|
||||
const processAutomationCheckPlugin = new ProcessAutomationCheckPlugin(
|
||||
{
|
||||
@@ -77,6 +86,9 @@ async function checkProcessAutomationPlugin() {
|
||||
await processAutomationCheckPlugin.checkProcessAutomationPlugin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check AGS plugin
|
||||
*/
|
||||
async function checkGovernancePlugin() {
|
||||
const governancePluginCheck = new GovernanceCheckPlugin(
|
||||
{
|
||||
|
@@ -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')
|
||||
@@ -36,6 +39,9 @@ export default async function main() {
|
||||
await checkEnv();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check environment
|
||||
*/
|
||||
async function checkEnv() {
|
||||
try {
|
||||
const alfrescoJsApi = new AlfrescoApi({
|
||||
@@ -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) {}
|
||||
|
@@ -19,6 +19,11 @@
|
||||
|
||||
import * as docker from './docker';
|
||||
|
||||
/**
|
||||
* Docker publish command
|
||||
*
|
||||
* @param args command arguments
|
||||
*/
|
||||
export default function(args: any) {
|
||||
docker.default(args);
|
||||
}
|
||||
|
@@ -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 = [];
|
||||
@@ -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 {
|
||||
@@ -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')
|
||||
@@ -150,7 +191,7 @@ export default function main(args: PublishArgs) {
|
||||
}
|
||||
|
||||
if (args.loginCheck === true) {
|
||||
loginPerform(args);
|
||||
login(args);
|
||||
}
|
||||
|
||||
let mainTag: string;
|
||||
@@ -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 ...`);
|
||||
}
|
||||
|
@@ -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';
|
||||
|
@@ -48,6 +48,11 @@ export interface ConfigArgs {
|
||||
|
||||
export const AAE_MICROSERVICES = ['deployment-service', 'modeling-service', 'dmn-service'];
|
||||
|
||||
/**
|
||||
* Perform a health check
|
||||
*
|
||||
* @param nameService service name
|
||||
*/
|
||||
async function healthCheck(nameService: string) {
|
||||
const url = `${args.host}/${nameService}/actuator/health`;
|
||||
|
||||
@@ -85,6 +90,11 @@ async function healthCheck(nameService: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get deployed application by status
|
||||
*
|
||||
* @param status application status
|
||||
*/
|
||||
async function getApplicationByStatus(status: string) {
|
||||
const url = `${args.host}/deployment-service/v1/applications`;
|
||||
|
||||
@@ -120,6 +130,11 @@ async function getApplicationByStatus(status: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get descriptors
|
||||
*
|
||||
* @returns deployment service descriptors
|
||||
*/
|
||||
function getDescriptors() {
|
||||
const url = `${args.host}/deployment-service/v1/descriptors`;
|
||||
|
||||
@@ -149,6 +164,11 @@ function getDescriptors() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get projects
|
||||
*
|
||||
* @returns deployment service projects
|
||||
*/
|
||||
function getProjects() {
|
||||
const url = `${args.host}/modeling-service/v1/projects`;
|
||||
|
||||
@@ -178,6 +198,12 @@ function getProjects() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project release
|
||||
*
|
||||
* @param projectId project id
|
||||
* @returns project release
|
||||
*/
|
||||
function getProjectRelease(projectId: string) {
|
||||
const url = `${args.host}/modeling-service/v1/projects/${projectId}/releases`;
|
||||
|
||||
@@ -207,6 +233,11 @@ function getProjectRelease(projectId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Release project
|
||||
*
|
||||
* @param projectId project id
|
||||
*/
|
||||
async function releaseProject(projectId: string) {
|
||||
const url = `${args.host}/modeling-service/v1/projects/${projectId}/releases`;
|
||||
|
||||
@@ -237,6 +268,12 @@ async function releaseProject(projectId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete project
|
||||
*
|
||||
* @param projectId project id
|
||||
* @returns response payload
|
||||
*/
|
||||
function deleteProject(projectId: string) {
|
||||
const url = `${args.host}/modeling-service/v1/projects/${projectId}`;
|
||||
|
||||
@@ -266,6 +303,11 @@ function deleteProject(projectId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Import and release project
|
||||
*
|
||||
* @param absoluteFilePath path to project file
|
||||
*/
|
||||
async function importAndReleaseProject(absoluteFilePath: string) {
|
||||
const fileContent = fs.createReadStream(absoluteFilePath);
|
||||
|
||||
@@ -302,6 +344,12 @@ async function importAndReleaseProject(absoluteFilePath: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes descriptor
|
||||
*
|
||||
* @param name descriptor name
|
||||
* @returns response payload
|
||||
*/
|
||||
function deleteDescriptor(name: string) {
|
||||
const url = `${args.host}/deployment-service/v1/descriptors/${name}`;
|
||||
|
||||
@@ -331,6 +379,12 @@ function deleteDescriptor(name: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploys a model
|
||||
*
|
||||
* @param model model object
|
||||
* @returns response payload
|
||||
*/
|
||||
function deploy(model: any) {
|
||||
const url = `${args.host}/deployment-service/v1/applications`;
|
||||
|
||||
@@ -360,11 +414,23 @@ function deploy(model: any) {
|
||||
}
|
||||
}
|
||||
|
||||
function initializeDefaultToken(options) {
|
||||
/**
|
||||
* Initialise default endpoint token
|
||||
*
|
||||
* @param options token options
|
||||
* @returns options
|
||||
*/
|
||||
function initializeDefaultToken(options: any): any {
|
||||
options.tokenEndpoint = options.tokenEndpoint.replace('${clientId}', options.clientId);
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a new Alfresco Api instance
|
||||
*
|
||||
* @param configArgs command params
|
||||
* @returns a new instance of Alfresco Api client
|
||||
*/
|
||||
function getAlfrescoJsApiInstance(configArgs: ConfigArgs): AlfrescoApi {
|
||||
let ssoHost = configArgs.oauth;
|
||||
ssoHost = ssoHost ?? configArgs.host;
|
||||
@@ -388,6 +454,12 @@ function getAlfrescoJsApiInstance(configArgs: ConfigArgs): AlfrescoApi {
|
||||
return new AlfrescoApi(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy missing applications
|
||||
*
|
||||
* @param tag tag
|
||||
* @param envs environments
|
||||
*/
|
||||
async function deployMissingApps(tag?: string, envs?: string[]) {
|
||||
const deployedApps = await getApplicationByStatus('');
|
||||
findMissingApps(deployedApps.list.entries);
|
||||
@@ -411,6 +483,13 @@ async function deployMissingApps(tag?: string, envs?: string[]) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if application is released
|
||||
*
|
||||
* @param missingApps applications
|
||||
* @param tag tag
|
||||
* @param envs environments
|
||||
*/
|
||||
async function checkIfAppIsReleased(missingApps: any[], tag?: string, envs?: string[]) {
|
||||
const projectList = await getProjects();
|
||||
let TIME = 5000;
|
||||
@@ -478,6 +557,13 @@ async function checkIfAppIsReleased(missingApps: any[], tag?: string, envs?: str
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy with a payload
|
||||
*
|
||||
* @param currentAbsentApp current application
|
||||
* @param projectRelease project release
|
||||
* @param envId environment id
|
||||
*/
|
||||
async function deployWithPayload(currentAbsentApp: any, projectRelease: any, envId?: string) {
|
||||
const deployPayload = {
|
||||
name: currentAbsentApp.name,
|
||||
@@ -493,6 +579,11 @@ async function deployWithPayload(currentAbsentApp: any, projectRelease: any, env
|
||||
logger.info(`Deployed ${currentAbsentApp.name} ${envId ? 'on env: ' + envId : ''}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if descriptor exists
|
||||
*
|
||||
* @param name descriptor name
|
||||
*/
|
||||
async function checkDescriptorExist(name: string): Promise<boolean> {
|
||||
logger.info(`Check descriptor ${name} exist in the list `);
|
||||
const descriptorList = await getDescriptors();
|
||||
@@ -509,6 +600,12 @@ async function checkDescriptorExist(name: string): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Import and release project
|
||||
*
|
||||
* @param app application
|
||||
* @param tag tag
|
||||
*/
|
||||
async function importProjectAndRelease(app: any, tag?: string) {
|
||||
const appLocationReplaced = app.file_location(tag);
|
||||
logger.warn('App fileLocation ' + appLocationReplaced);
|
||||
@@ -519,6 +616,11 @@ async function importProjectAndRelease(app: any, tag?: string) {
|
||||
return projectRelease;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find missing applications
|
||||
*
|
||||
* @param deployedApps applications
|
||||
*/
|
||||
function findMissingApps(deployedApps: any[]) {
|
||||
Object.keys(ACTIVITI_CLOUD_APPS).forEach((key) => {
|
||||
const isPresent = deployedApps.find((currentApp: any) => ACTIVITI_CLOUD_APPS[key].name === currentApp.entry.name);
|
||||
@@ -529,6 +631,11 @@ function findMissingApps(deployedApps: any[]) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Find failing applications
|
||||
*
|
||||
* @param deployedApps applications
|
||||
*/
|
||||
function findFailingApps(deployedApps: any[]) {
|
||||
Object.keys(ACTIVITI_CLOUD_APPS).forEach((key) => {
|
||||
const failingApp = deployedApps.filter(
|
||||
@@ -541,6 +648,12 @@ function findFailingApps(deployedApps: any[]) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get file from the remote
|
||||
*
|
||||
* @param url url to file
|
||||
* @param name name
|
||||
*/
|
||||
async function getFileFromRemote(url: string, name: string) {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
https.get(url, (response) => {
|
||||
@@ -568,11 +681,21 @@ async function getFileFromRemote(url: string, name: string) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes local file
|
||||
*
|
||||
* @param name file name
|
||||
*/
|
||||
async function deleteLocalFile(name: string) {
|
||||
logger.info(`Deleting local file ${name}.zip`);
|
||||
fs.unlinkSync(`${name}.zip`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a timeout
|
||||
*
|
||||
* @param time delay in milliseconds
|
||||
*/
|
||||
async function sleep(time: number) {
|
||||
logger.info(`Waiting for ${time} sec...`);
|
||||
await new Promise((done) => setTimeout(done, time));
|
||||
@@ -580,12 +703,10 @@ async function sleep(time: number) {
|
||||
return;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line space-before-function-paren
|
||||
export default async function () {
|
||||
await main();
|
||||
}
|
||||
|
||||
async function main() {
|
||||
/**
|
||||
* Init AAE environment command
|
||||
*/
|
||||
export default async function main() {
|
||||
program
|
||||
.version('0.1.0')
|
||||
.description(
|
||||
|
@@ -28,12 +28,10 @@ const ACS_DEFAULT = require('./resources').ACS_DEFAULT;
|
||||
|
||||
let alfrescoJsApi: AlfrescoApi;
|
||||
|
||||
// eslint-disable-next-line space-before-function-paren
|
||||
export default async function () {
|
||||
await main();
|
||||
}
|
||||
|
||||
async function main() {
|
||||
/**
|
||||
* Init ACS environment command
|
||||
*/
|
||||
export default async function main() {
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('--host [type]', 'Remote environment host')
|
||||
@@ -48,6 +46,9 @@ async function main() {
|
||||
await initializeDefaultFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup default files
|
||||
*/
|
||||
async function initializeDefaultFiles() {
|
||||
const e2eFolder = ACS_DEFAULT.e2eFolder;
|
||||
const parentFolder = await createFolder(e2eFolder.name, '-my-');
|
||||
@@ -83,6 +84,12 @@ async function initializeDefaultFiles() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create folder
|
||||
*
|
||||
* @param folderName folder name
|
||||
* @param parentId parent folder id
|
||||
*/
|
||||
async function createFolder(folderName: string, parentId: string) {
|
||||
let createdFolder: NodeEntry;
|
||||
const body = {
|
||||
@@ -102,6 +109,12 @@ async function createFolder(folderName: string, parentId: string) {
|
||||
return createdFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload file
|
||||
*
|
||||
* @param fileName file name
|
||||
* @param fileDestination destination path
|
||||
*/
|
||||
async function uploadFile(fileName: string, fileDestination: string): Promise<NodeEntry> {
|
||||
const filePath = `../resources/content/${fileName}`;
|
||||
const file = fs.createReadStream(path.join(__dirname, filePath));
|
||||
@@ -120,6 +133,11 @@ async function uploadFile(fileName: string, fileDestination: string): Promise<No
|
||||
return uploadedFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock file node
|
||||
*
|
||||
* @param nodeId node id
|
||||
*/
|
||||
async function lockFile(nodeId: string): Promise<NodeEntry> {
|
||||
const data = {
|
||||
type: 'ALLOW_OWNER_CHANGES'
|
||||
@@ -133,6 +151,11 @@ async function lockFile(nodeId: string): Promise<NodeEntry> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Share file node
|
||||
*
|
||||
* @param nodeId node id
|
||||
*/
|
||||
async function shareFile(nodeId: string) {
|
||||
const data = {
|
||||
nodeId
|
||||
@@ -145,6 +168,11 @@ async function shareFile(nodeId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Favorite file node
|
||||
*
|
||||
* @param nodeId node id
|
||||
*/
|
||||
async function favoriteFile(nodeId: string) {
|
||||
const data = {
|
||||
target: {
|
||||
@@ -161,6 +189,9 @@ async function favoriteFile(nodeId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check environment state
|
||||
*/
|
||||
async function checkEnv() {
|
||||
try {
|
||||
alfrescoJsApi = new AlfrescoApi({
|
||||
@@ -195,8 +226,12 @@ async function checkEnv() {
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-enable */
|
||||
|
||||
/**
|
||||
* Perform a delay
|
||||
*
|
||||
* @param delay timeout in milliseconds
|
||||
*/
|
||||
function sleep(delay: number) {
|
||||
const start = new Date().getTime();
|
||||
while (new Date().getTime() < start + delay) {}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AdminTenantsApi, AdminUsersApi, AlfrescoApi, TenantRepresentation, AppDefinitionsApi, RuntimeAppDefinitionsApi, UserRepresentation } from '@alfresco/js-api';
|
||||
import { AdminTenantsApi, AdminUsersApi, AlfrescoApi, TenantRepresentation, AppDefinitionsApi, RuntimeAppDefinitionsApi, UserRepresentation, AppDefinitionUpdateResultRepresentation } from '@alfresco/js-api';
|
||||
import { argv, exit } from 'node:process';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { createReadStream } from 'node:fs';
|
||||
@@ -33,11 +33,10 @@ const ACTIVITI_APPS = require('./resources').ACTIVITI_APPS;
|
||||
|
||||
let alfrescoJsApi: AlfrescoApi;
|
||||
|
||||
export default async function() {
|
||||
await main();
|
||||
}
|
||||
|
||||
async function main() {
|
||||
/**
|
||||
* Init APS command
|
||||
*/
|
||||
export default async function main() {
|
||||
|
||||
program
|
||||
.version('0.1.0')
|
||||
@@ -114,6 +113,9 @@ async function main() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise default applications
|
||||
*/
|
||||
async function initializeDefaultApps() {
|
||||
for (let x = 0; x < ACTIVITI_APPS.apps.length; x++) {
|
||||
const appInfo = ACTIVITI_APPS.apps[x];
|
||||
@@ -126,6 +128,10 @@ async function initializeDefaultApps() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check environment
|
||||
*/
|
||||
async function checkEnv() {
|
||||
try {
|
||||
alfrescoJsApi = new AlfrescoApi({
|
||||
@@ -160,7 +166,14 @@ async function checkEnv() {
|
||||
}
|
||||
}
|
||||
|
||||
async function hasDefaultTenant(tenantId: number, tenantName: string) {
|
||||
/**
|
||||
* Check if the default tenant is present
|
||||
*
|
||||
* @param tenantId tenant id
|
||||
* @param tenantName tenant name
|
||||
* @returns `true` if tenant is found, otherwise `false`
|
||||
*/
|
||||
async function hasDefaultTenant(tenantId: number, tenantName: string): Promise<boolean> {
|
||||
let tenant: TenantRepresentation;
|
||||
|
||||
try {
|
||||
@@ -180,6 +193,11 @@ async function hasDefaultTenant(tenantId: number, tenantName: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create default tenant
|
||||
*
|
||||
* @param tenantName tenant name
|
||||
*/
|
||||
async function createDefaultTenant(tenantName: string) {
|
||||
const tenantPost = {
|
||||
active: true,
|
||||
@@ -197,6 +215,12 @@ async function createDefaultTenant(tenantName: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create users
|
||||
*
|
||||
* @param tenantId tenant id
|
||||
* @param user user object
|
||||
*/
|
||||
async function createUsers(tenantId: number, user: any) {
|
||||
logger.info(`Create user ${user.email} on tenant: ${tenantId}`);
|
||||
const passwordCamelCase = 'Password';
|
||||
@@ -220,6 +244,9 @@ async function createUsers(tenantId: number, user: any) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Activiti license
|
||||
*/
|
||||
async function updateLicense() {
|
||||
const fileContent = createReadStream(path.join(__dirname, '/activiti.lic'));
|
||||
|
||||
@@ -243,7 +270,13 @@ async function updateLicense() {
|
||||
}
|
||||
}
|
||||
|
||||
async function isDefaultAppDeployed(appName: string) {
|
||||
/**
|
||||
* Check if default application is deployed
|
||||
*
|
||||
* @param appName application name
|
||||
* @returns `true` if application is deployed, otherwise `false`
|
||||
*/
|
||||
async function isDefaultAppDeployed(appName: string): Promise<boolean> {
|
||||
logger.info(`Verify ${appName} already deployed`);
|
||||
try {
|
||||
const runtimeAppDefinitionsApi = new RuntimeAppDefinitionsApi(alfrescoJsApi);
|
||||
@@ -255,7 +288,12 @@ async function isDefaultAppDeployed(appName: string) {
|
||||
}
|
||||
}
|
||||
|
||||
async function importPublishApp(appName: string) {
|
||||
/**
|
||||
* Import and publish the application
|
||||
*
|
||||
* @param appName application name
|
||||
*/
|
||||
async function importPublishApp(appName: string): Promise<AppDefinitionUpdateResultRepresentation> {
|
||||
const appNameExtension = `../resources/${appName}.zip`;
|
||||
logger.info(`Import app ${appNameExtension}`);
|
||||
const pathFile = path.join(__dirname, appNameExtension);
|
||||
@@ -271,6 +309,11 @@ async function importPublishApp(appName: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deploy application
|
||||
*
|
||||
* @param appDefinitionId app definition id
|
||||
*/
|
||||
async function deployApp(appDefinitionId: number) {
|
||||
logger.info(`Deploy app with id ${appDefinitionId}`);
|
||||
const body = {
|
||||
@@ -286,6 +329,9 @@ async function deployApp(appDefinitionId: number) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if Activiti app has license
|
||||
*/
|
||||
async function hasLicense(): Promise<boolean> {
|
||||
try {
|
||||
const license = await alfrescoJsApi.oauth2Auth.callCustomApi(
|
||||
@@ -310,6 +356,9 @@ async function hasLicense(): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default users from the realm
|
||||
*/
|
||||
async function getDefaultApsUsersFromRealm() {
|
||||
try {
|
||||
const users: any[] = await alfrescoJsApi.oauth2Auth.callCustomApi(
|
||||
@@ -332,6 +381,12 @@ async function getDefaultApsUsersFromRealm() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that ACS repo for Activiti is present
|
||||
*
|
||||
* @param tenantId tenant id
|
||||
* @param contentName content service name
|
||||
*/
|
||||
async function isContentRepoPresent(tenantId: number, contentName: string): Promise<boolean> {
|
||||
try {
|
||||
const contentRepos = await alfrescoJsApi.oauth2Auth.callCustomApi(
|
||||
@@ -351,6 +406,12 @@ async function isContentRepoPresent(tenantId: number, contentName: string): Prom
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add content service with basic auth
|
||||
*
|
||||
* @param tenantId tenant id
|
||||
* @param name content name
|
||||
*/
|
||||
async function addContentRepoWithBasic(tenantId: number, name: string) {
|
||||
logger.info(`Create Content with name ${name} and basic auth`);
|
||||
|
||||
@@ -384,6 +445,11 @@ async function addContentRepoWithBasic(tenantId: number, name: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorize activiti user to ACS repo
|
||||
*
|
||||
* @param user user object
|
||||
*/
|
||||
async function authorizeUserToContentRepo(user: any) {
|
||||
logger.info(`Authorize user ${user.email}`);
|
||||
try {
|
||||
@@ -412,6 +478,12 @@ async function authorizeUserToContentRepo(user: any) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorize user with content using basic auth
|
||||
*
|
||||
* @param username username
|
||||
* @param contentId content id
|
||||
*/
|
||||
async function authorizeUserToContentWithBasic(username: string, contentId: string) {
|
||||
logger.info(`Authorize ${username} on contentId: ${contentId} in basic auth`);
|
||||
try {
|
||||
@@ -434,6 +506,11 @@ async function authorizeUserToContentWithBasic(username: string, contentId: stri
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download APS license file
|
||||
*
|
||||
* @param apsLicensePath path to license file
|
||||
*/
|
||||
async function downloadLicenseFile(apsLicensePath: string) {
|
||||
const args = [
|
||||
`s3`,
|
||||
@@ -454,6 +531,11 @@ async function downloadLicenseFile(apsLicensePath: string) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a delay
|
||||
*
|
||||
* @param delay timeout in milliseconds
|
||||
*/
|
||||
function sleep(delay: number) {
|
||||
const start = new Date().getTime();
|
||||
while (new Date().getTime() < start + delay) { }
|
||||
|
@@ -41,6 +41,12 @@ export interface ConfigArgs {
|
||||
intervalTime: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Alfresco Api instance
|
||||
*
|
||||
* @param args command parameters
|
||||
* @returns Alfresco Api instance
|
||||
*/
|
||||
function getAlfrescoJsApiInstance(args: ConfigArgs): AlfrescoApi {
|
||||
const config: AlfrescoApiConfig = {
|
||||
provider: 'BPM',
|
||||
@@ -60,6 +66,13 @@ function getAlfrescoJsApiInstance(args: ConfigArgs): AlfrescoApi {
|
||||
return new AlfrescoApi(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform login
|
||||
*
|
||||
* @param username username
|
||||
* @param password password
|
||||
* @param alfrescoJsApi api client
|
||||
*/
|
||||
async function login(username: string, password: string, alfrescoJsApi: AlfrescoApi) {
|
||||
logger.info(`Perform login...`);
|
||||
try {
|
||||
@@ -71,6 +84,13 @@ async function login(username: string, password: string, alfrescoJsApi: Alfresco
|
||||
logger.info(`Perform done...`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes deployment descriptor
|
||||
*
|
||||
* @param args command arguments
|
||||
* @param apiService api client
|
||||
* @param name descriptor name
|
||||
*/
|
||||
async function deleteDescriptor(args: ConfigArgs, apiService: AlfrescoApi, name: string) {
|
||||
logger.warn(`Delete the descriptor ${name}`);
|
||||
|
||||
@@ -104,6 +124,13 @@ async function deleteDescriptor(args: ConfigArgs, apiService: AlfrescoApi, name:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes modeling project
|
||||
*
|
||||
* @param args arguments
|
||||
* @param apiService api client
|
||||
* @param projectId project id
|
||||
*/
|
||||
async function deleteProject(args: ConfigArgs, apiService: AlfrescoApi, projectId: string) {
|
||||
logger.warn(`Delete the project ${projectId}`);
|
||||
|
||||
@@ -137,6 +164,13 @@ async function deleteProject(args: ConfigArgs, apiService: AlfrescoApi, projectI
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes modeling project by name
|
||||
*
|
||||
* @param args arguments
|
||||
* @param apiService api client
|
||||
* @param name project name
|
||||
*/
|
||||
async function deleteProjectByName(args: ConfigArgs, apiService: AlfrescoApi, name: string) {
|
||||
logger.warn(`Get the project by name ${name}`);
|
||||
const url = `${args.host}/modeling-service/v1/projects?name=${name}`;
|
||||
@@ -172,6 +206,13 @@ async function deleteProjectByName(args: ConfigArgs, apiService: AlfrescoApi, na
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get applications by name
|
||||
*
|
||||
* @param args command arguments
|
||||
* @param apiService api client
|
||||
* @param name application name
|
||||
*/
|
||||
async function getApplicationsByName(args: ConfigArgs, apiService: AlfrescoApi, name: string) {
|
||||
logger.warn(`Get the applications by name ${name}`);
|
||||
const url = `${args.host}/deployment-service/v1/applications?name=${name}`;
|
||||
@@ -203,6 +244,13 @@ async function getApplicationsByName(args: ConfigArgs, apiService: AlfrescoApi,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undeploy applications by name
|
||||
*
|
||||
* @param args command arguments
|
||||
* @param apiService api client
|
||||
* @param name application name
|
||||
*/
|
||||
async function undeployApplication(args: ConfigArgs, apiService: AlfrescoApi, name: string) {
|
||||
logger.warn(`Undeploy the application ${name}`);
|
||||
|
||||
@@ -236,11 +284,6 @@ async function undeployApplication(args: ConfigArgs, apiService: AlfrescoApi, na
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions,space-before-function-paren
|
||||
export default async function (args: ConfigArgs) {
|
||||
await main(args);
|
||||
}
|
||||
|
||||
const main = async (args: ConfigArgs) => {
|
||||
program
|
||||
.version('0.1.0')
|
||||
@@ -330,3 +373,5 @@ const main = async (args: ConfigArgs) => {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default main;
|
||||
|
@@ -49,6 +49,12 @@ const missingRepositories = {
|
||||
'rxjs-compat': 'https://github.com/ReactiveX/rxjs/tree/master/compat'
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a license with MD link
|
||||
*
|
||||
* @param licenseExp license expression
|
||||
* @returns license
|
||||
*/
|
||||
function licenseWithMDLinks(licenseExp: string): string {
|
||||
let licenseUrl = '';
|
||||
|
||||
@@ -69,6 +75,12 @@ function licenseWithMDLinks(licenseExp: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get package file
|
||||
*
|
||||
* @param packagePath package.json path
|
||||
* @returns package model
|
||||
*/
|
||||
function getPackageFile(packagePath: string): PackageInfo {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(packagePath).toString());
|
||||
@@ -78,6 +90,13 @@ function getPackageFile(packagePath: string): PackageInfo {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Licenses command
|
||||
*
|
||||
* @param _args (not used)
|
||||
* @param workingDir working directory
|
||||
* @returns void function
|
||||
*/
|
||||
export default function main(_args: string[], workingDir: string) {
|
||||
program
|
||||
.description('Generate a licences report')
|
||||
|
@@ -34,6 +34,12 @@ export interface PublishArgs {
|
||||
|
||||
const projects = ['cli', 'core', 'insights', 'testing', 'content-services', 'process-services', 'process-services-cloud', 'extensions'];
|
||||
|
||||
/**
|
||||
* Publish to NPM command
|
||||
*
|
||||
* @param args command arguments
|
||||
* @param project project name
|
||||
*/
|
||||
async function npmPublish(args: PublishArgs, project: string) {
|
||||
if (args.dryrun) {
|
||||
logger.info(`Dry run mode, no publish will be done`);
|
||||
@@ -70,7 +76,14 @@ async function npmPublish(args: PublishArgs, project: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function npmCheckExist(project: string, version: string) {
|
||||
/**
|
||||
* Checks the library exists on npm already
|
||||
*
|
||||
* @param project project name
|
||||
* @param version project version
|
||||
* @returns `true` if given project exists on NPM, otherwise `false`
|
||||
*/
|
||||
function npmCheckExist(project: string, version: string): boolean {
|
||||
logger.info(`Check if lib ${project} is already in npm with version ${version}`);
|
||||
let exist = '';
|
||||
try {
|
||||
@@ -82,6 +95,12 @@ function npmCheckExist(project: string, version: string) {
|
||||
return exist !== '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Change NPM registry
|
||||
*
|
||||
* @param args command parameters
|
||||
* @param project project name
|
||||
*/
|
||||
function changeRegistry(args: PublishArgs, project: string) {
|
||||
logger.info(`Change registry... to ${args.npmRegistry} `);
|
||||
const folder = `${args.pathProject}/dist/libs/${project}`;
|
||||
@@ -98,6 +117,12 @@ always-auth=true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes custom `.npmrc` configuration file
|
||||
*
|
||||
* @param args command arguments
|
||||
* @param project project name
|
||||
*/
|
||||
function removeNpmConfig(args: PublishArgs, project: string) {
|
||||
logger.info(`Removing file from ${project}`);
|
||||
try {
|
||||
@@ -108,6 +133,11 @@ function removeNpmConfig(args: PublishArgs, project: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish to NPM command
|
||||
*
|
||||
* @param args command arguments
|
||||
*/
|
||||
export default async function main(args: PublishArgs) {
|
||||
program
|
||||
.version('0.1.0')
|
||||
@@ -132,6 +162,11 @@ export default async function main(args: PublishArgs) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a timeout
|
||||
*
|
||||
* @param ms timeout in milliseconds
|
||||
*/
|
||||
async function sleep(ms: number) {
|
||||
logger.info(`Waiting for ${ms} milliseconds...`);
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
@@ -45,7 +45,10 @@ const green = '\x1b[32m';
|
||||
let alfrescoApi: AlfrescoApi;
|
||||
let loginAttempts: number = 0;
|
||||
|
||||
export default async function main(_args: string[]) {
|
||||
/**
|
||||
* Scan environment command
|
||||
*/
|
||||
export default async function main() {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log = () => {};
|
||||
|
||||
@@ -72,6 +75,12 @@ export default async function main(_args: string[]) {
|
||||
logger.info(generateTable(rowsToPrint));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate table
|
||||
*
|
||||
* @param rowsToPrint list of table rows to print
|
||||
* @returns table as a string
|
||||
*/
|
||||
function generateTable(rowsToPrint: Array<RowToPrint>) {
|
||||
const columnWidths = rowsToPrint.reduce(
|
||||
(maxWidths, row: RowToPrint) => ({
|
||||
@@ -99,6 +108,9 @@ ${grey}╞${horizontalLine}╡${reset}`;
|
||||
return tableString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to login
|
||||
*/
|
||||
async function attemptLogin() {
|
||||
logger.info(` Logging into ${yellow}${program.host}${reset} with user ${yellow}${program.username}${reset}`);
|
||||
try {
|
||||
@@ -123,6 +135,11 @@ async function attemptLogin() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles login error
|
||||
*
|
||||
* @param loginError error object
|
||||
*/
|
||||
async function handleLoginError(loginError) {
|
||||
if (loginAttempts === 0) {
|
||||
logger.error(` ${red}Login SSO error${reset}`);
|
||||
@@ -150,6 +167,11 @@ async function handleLoginError(loginError) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check environment is reachable
|
||||
*
|
||||
* @param loginError error object
|
||||
*/
|
||||
function checkEnvReachable(loginError) {
|
||||
const failingErrorCodes = ['ENOTFOUND', 'ETIMEDOUT', 'ECONNREFUSED'];
|
||||
if (typeof loginError === 'object' && failingErrorCodes.indexOf(loginError.code) > -1) {
|
||||
@@ -158,6 +180,11 @@ function checkEnvReachable(loginError) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get people count
|
||||
*
|
||||
* @param skipCount skip count
|
||||
*/
|
||||
async function getPeopleCount(skipCount: number = 0): Promise<PeopleTally> {
|
||||
if (skipCount === 0) {
|
||||
logger.info(` Fetching number of users`);
|
||||
@@ -191,6 +218,9 @@ async function getPeopleCount(skipCount: number = 0): Promise<PeopleTally> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the amount of Home folders
|
||||
*/
|
||||
async function getHomeFoldersCount(): Promise<number> {
|
||||
logger.info(` Fetching number of home folders`);
|
||||
try {
|
||||
@@ -205,6 +235,9 @@ async function getHomeFoldersCount(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the amount of groups
|
||||
*/
|
||||
async function getGroupsCount(): Promise<number> {
|
||||
logger.info(` Fetching number of groups`);
|
||||
try {
|
||||
@@ -216,6 +249,9 @@ async function getGroupsCount(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the amount of sites
|
||||
*/
|
||||
async function getSitesCount(): Promise<number> {
|
||||
logger.info(` Fetching number of sites`);
|
||||
try {
|
||||
@@ -227,6 +263,9 @@ async function getSitesCount(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the amount of files
|
||||
*/
|
||||
async function getFilesCount(): Promise<number> {
|
||||
logger.info(` Fetching number of files`);
|
||||
try {
|
||||
@@ -246,9 +285,14 @@ async function getFilesCount(): Promise<number> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle error
|
||||
*
|
||||
* @param error error object
|
||||
*/
|
||||
function handleError(error) {
|
||||
logger.error(` ${red}Error encountered${reset}`);
|
||||
if (error && error.response && error?.response?.text) {
|
||||
if (error?.response && error?.response?.text) {
|
||||
try {
|
||||
const parsedJson = JSON.parse(error?.response?.text);
|
||||
if (typeof parsedJson === 'object' && parsedJson.error) {
|
||||
@@ -262,11 +306,19 @@ function handleError(error) {
|
||||
failScript();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log the error and exit
|
||||
*/
|
||||
function failScript() {
|
||||
logger.error(`${red}${bright}Environment scan failed. Exiting${reset}`);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait with a certain period
|
||||
*
|
||||
* @param ms timeout in milliseconds
|
||||
*/
|
||||
async function wait(ms: number) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms);
|
||||
|
@@ -28,6 +28,12 @@ export interface CommitArgs {
|
||||
skipGnu: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get commit SHA
|
||||
*
|
||||
* @param args command arguments
|
||||
* @returns commit SHA value
|
||||
*/
|
||||
function getSha(args: CommitArgs): string {
|
||||
logger.info('Check commit sha...');
|
||||
|
||||
@@ -36,7 +42,13 @@ function getSha(args: CommitArgs): string {
|
||||
return exec('git', [`rev-parse`, `${gitPointer}`], {}).trim();
|
||||
}
|
||||
|
||||
function replacePerform(args: CommitArgs, sha: string) {
|
||||
/**
|
||||
* Performs the sha replacement
|
||||
*
|
||||
* @param args command parameters
|
||||
* @param sha value to use
|
||||
*/
|
||||
function performReplace(args: CommitArgs, sha: string) {
|
||||
logger.info(`Replace commit ${sha} in package...`);
|
||||
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
@@ -49,6 +61,11 @@ function replacePerform(args: CommitArgs, sha: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update commit SHA command
|
||||
*
|
||||
* @param args command arguments
|
||||
*/
|
||||
export default function main(args: CommitArgs) {
|
||||
program
|
||||
.version('0.1.0')
|
||||
@@ -70,5 +87,5 @@ export default function main(args: CommitArgs) {
|
||||
|
||||
const sha = getSha(args);
|
||||
|
||||
replacePerform(args, sha);
|
||||
performReplace(args, sha);
|
||||
}
|
||||
|
@@ -37,6 +37,12 @@ export interface PackageInfo {
|
||||
devDependencies?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse alfresco libraries in package.json file
|
||||
*
|
||||
* @param workingDir working directory
|
||||
* @returns package info model
|
||||
*/
|
||||
function parseAlfrescoLibs(workingDir: string): PackageInfo {
|
||||
const packagePath = path.resolve(path.join(workingDir, 'package.json'));
|
||||
|
||||
@@ -57,10 +63,23 @@ function parseAlfrescoLibs(workingDir: string): PackageInfo {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Format npm command
|
||||
*
|
||||
* @param deps dependencies
|
||||
* @param tag tag
|
||||
* @returns npm command to execute
|
||||
*/
|
||||
function formatNpmCommand(deps: string[], tag: string): string {
|
||||
return ['npm i -E', deps.map((name) => `${name}@${tag}`).join(' ')].join(' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run npm command
|
||||
*
|
||||
* @param command command to execute
|
||||
* @param workingDir working directory
|
||||
*/
|
||||
function runNpmCommand(command: string, workingDir: string) {
|
||||
if (shell.exec(command, { cwd: workingDir }).code !== 0) {
|
||||
shell.echo('Error running NPM command');
|
||||
@@ -68,6 +87,13 @@ function runNpmCommand(command: string, workingDir: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update libraries
|
||||
*
|
||||
* @param pkg package info model
|
||||
* @param tag tag name
|
||||
* @param workingDir working directory
|
||||
*/
|
||||
function updateLibs(pkg: PackageInfo, tag: string, workingDir: string) {
|
||||
if (pkg.dependencies && pkg.dependencies.length > 0) {
|
||||
runNpmCommand(formatNpmCommand(pkg.dependencies, tag), workingDir);
|
||||
@@ -78,6 +104,12 @@ function updateLibs(pkg: PackageInfo, tag: string, workingDir: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse tag
|
||||
*
|
||||
* @param args update arguments
|
||||
* @returns tag value
|
||||
*/
|
||||
function parseTag(args: UpdateArgs): string {
|
||||
if (args.alpha) {
|
||||
return 'alpha';
|
||||
@@ -90,6 +122,12 @@ function parseTag(args: UpdateArgs): string {
|
||||
return args.version || 'latest';
|
||||
}
|
||||
|
||||
/**
|
||||
* update version command
|
||||
*
|
||||
* @param args arguments
|
||||
* @param workingDir working directory
|
||||
*/
|
||||
export default function main(args: UpdateArgs, workingDir: string) {
|
||||
program
|
||||
.description(
|
||||
|
Reference in New Issue
Block a user