From 0a18ec61a9f308d9db5e1f414ec6448f9803dc3d Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Wed, 19 Jan 2022 12:07:27 +0000 Subject: [PATCH] Being able to load a dynamic file location (#7456) --- lib/cli/scripts/init-aae-env.ts | 18 +++++++++++------- lib/cli/scripts/resources.ts | 6 +++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/cli/scripts/init-aae-env.ts b/lib/cli/scripts/init-aae-env.ts index 1f781d0723..6b928217bd 100644 --- a/lib/cli/scripts/init-aae-env.ts +++ b/lib/cli/scripts/init-aae-env.ts @@ -41,6 +41,7 @@ export interface ConfigArgs { clientId: string; host: string; identityHost: boolean; + tag: string; } export const AAE_MICROSERVICES = [ @@ -240,7 +241,7 @@ function getAlfrescoJsApiInstance(configArgs: ConfigArgs) { return new AlfrescoApi(config); } -async function deployMissingApps() { +async function deployMissingApps(tag?: string) { const deployedApps = await getApplicationByStatus(''); findMissingApps(deployedApps.list.entries); findFailingApps(deployedApps.list.entries); @@ -253,14 +254,14 @@ async function deployMissingApps() { process.exit(1); } else if (absentApps.length > 0) { logger.warn(`Missing apps: ${JSON.stringify(absentApps)}`); - await checkIfAppIsReleased(absentApps); + await checkIfAppIsReleased(absentApps, tag); } else { const reset = '\x1b[0m', green = '\x1b[32m'; logger.info(`${green}All the apps are correctly deployed${reset}`); } } -async function checkIfAppIsReleased(missingApps: any []) { +async function checkIfAppIsReleased(missingApps: any [], tag?: string) { const projectList = await getProjects(); let TIME = 5000; let noError = true; @@ -278,7 +279,7 @@ async function checkIfAppIsReleased(missingApps: any []) { logger.warn('Missing project: Create the project for ' + currentAbsentApp.name); try { - projectRelease = await importProjectAndRelease(currentAbsentApp); + projectRelease = await importProjectAndRelease(currentAbsentApp, tag); } catch (error) { logger.info(`error status ${error.status}`); @@ -348,8 +349,10 @@ async function checkDescriptorExist(name: string) { return false; } -async function importProjectAndRelease(app: any) { - await getFileFromRemote(app.file_location, app.name); +async function importProjectAndRelease(app: any, tag?: string) { + const appLocationReplaced = app.file_location(tag); + logger.warn('App fileLocation ' + appLocationReplaced); + await getFileFromRemote(appLocationReplaced, app.name); logger.warn('Project imported ' + app.name); const projectRelease = await importAndReleaseProject(`${app.name}.zip`); await deleteLocalFile(`${app.name}`); @@ -427,6 +430,7 @@ async function main(configArgs: ConfigArgs) { .option('--modelerPassword [type]', 'modeler password') .option('--devopsUsername [type]', 'username of a user with role ACTIVIT_DEVOPS') .option('--devopsPassword [type]', 'devops password') + .option('--tag [type]', 'tag name of the codebase') .parse(process.argv); if (process.argv.includes('-h') || process.argv.includes('--help')) { @@ -459,7 +463,7 @@ async function main(configArgs: ConfigArgs) { process.exit(1); }); - await deployMissingApps(); + await deployMissingApps(args.tag); } else { logger.error('The environment is not up'); process.exit(1); diff --git a/lib/cli/scripts/resources.ts b/lib/cli/scripts/resources.ts index f8aecc633a..517e81f256 100644 --- a/lib/cli/scripts/resources.ts +++ b/lib/cli/scripts/resources.ts @@ -19,7 +19,7 @@ export const ACTIVITI_CLOUD_APPS: any = { SUB_PROCESS_APP: { name: 'subprocessapp', - file_location: 'https://github.com/Alfresco/alfresco-ng2-components/blob/develop/e2e/resources/activiti7/subprocessapp.zip?raw=true', + file_location: (TAG = 'develop') => `https://github.com/Alfresco/alfresco-ng2-components/blob/${TAG}/e2e/resources/activiti7/subprocessapp.zip?raw=true`, processes: { processchild: 'processchild', processparent: 'processparent' @@ -31,7 +31,7 @@ export const ACTIVITI_CLOUD_APPS: any = { }, CANDIDATE_BASE_APP: { name: 'candidatebaseapp', - file_location: 'https://github.com/Alfresco/alfresco-ng2-components/blob/develop/e2e/resources/activiti7/candidatebaseapp.zip?raw=true', + file_location: (TAG = 'develop') => `https://github.com/Alfresco/alfresco-ng2-components/blob/${TAG}/e2e/resources/activiti7/candidatebaseapp.zip?raw=true`, processes: { candidateUserProcess: 'candidateuserprocess', candidateGroupProcess: 'candidategroupprocess', @@ -74,7 +74,7 @@ export const ACTIVITI_CLOUD_APPS: any = { }, SIMPLE_APP: { name: 'simpleapp', - file_location: 'https://github.com/Alfresco/alfresco-ng2-components/blob/develop/e2e/resources/activiti7/simpleapp.zip?raw=true', + file_location: (TAG = 'develop') => `https://github.com/Alfresco/alfresco-ng2-components/blob/${TAG}/e2e/resources/activiti7/simpleapp.zip?raw=true`, processes: { processwithvariables: 'processwithvariables', simpleProcess: 'simpleprocess',