mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-16884] init aae script fixes (#8957)
* [ci:force] init aae script fixes * [ci:force] improved typings * [ci:force] switch to http and remove useless test * [ci:force] simple change to trigger tests * [ci:force] remove debug logs
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
import program from 'commander';
|
||||
import https from 'https';
|
||||
import http from 'node:http';
|
||||
import * as fs from 'fs';
|
||||
import { logger } from './logger';
|
||||
import { AlfrescoApi, AlfrescoApiConfig } from '@alfresco/js-api';
|
||||
@@ -29,8 +29,6 @@ let alfrescoJsApiModeler: AlfrescoApi;
|
||||
let alfrescoJsApiDevops: AlfrescoApi;
|
||||
let args: ConfigArgs;
|
||||
let isValid = true;
|
||||
const absentApps: any[] = [];
|
||||
const failingApps: any[] = [];
|
||||
export interface ConfigArgs {
|
||||
modelerUsername: string;
|
||||
modelerPassword: string;
|
||||
@@ -91,15 +89,14 @@ async function healthCheck(nameService: string) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get deployed application by status
|
||||
* Get deployed application
|
||||
*
|
||||
* @param status application status
|
||||
*/
|
||||
async function getApplicationByStatus(status: string) {
|
||||
async function getApplications(): Promise<{ list: { entries: any[] } }> {
|
||||
const url = `${args.host}/deployment-service/v1/applications`;
|
||||
|
||||
const pathParams = {};
|
||||
const queryParams = { status };
|
||||
const queryParams = {};
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
@@ -461,9 +458,9 @@ function getAlfrescoJsApiInstance(configArgs: ConfigArgs): AlfrescoApi {
|
||||
* @param envs environments
|
||||
*/
|
||||
async function deployMissingApps(tag?: string, envs?: string[]) {
|
||||
const deployedApps = await getApplicationByStatus('');
|
||||
findMissingApps(deployedApps.list.entries);
|
||||
findFailingApps(deployedApps.list.entries);
|
||||
const deployedApps = await getApplications();
|
||||
const failingApps = findFailingApps(deployedApps.list.entries);
|
||||
const missingApps = findMissingApps(deployedApps.list.entries);
|
||||
|
||||
if (failingApps.length > 0) {
|
||||
failingApps.forEach((app) => {
|
||||
@@ -473,9 +470,9 @@ async function deployMissingApps(tag?: string, envs?: string[]) {
|
||||
logger.error(`${red}${bright}ERROR: App ${app.entry.name} down or inaccessible ${reset}${red} with status ${app.entry.status}${reset}`);
|
||||
});
|
||||
exit(1);
|
||||
} else if (absentApps.length > 0) {
|
||||
logger.warn(`Missing apps: ${JSON.stringify(absentApps)}`);
|
||||
await checkIfAppIsReleased(absentApps, tag, envs);
|
||||
} else if (missingApps.length > 0) {
|
||||
logger.warn(`Missing apps: ${JSON.stringify(missingApps)}`);
|
||||
await checkIfAppIsReleased(missingApps, tag, envs);
|
||||
} else {
|
||||
const reset = '\x1b[0m';
|
||||
const green = '\x1b[32m';
|
||||
@@ -564,7 +561,7 @@ async function checkIfAppIsReleased(missingApps: any[], tag?: string, envs?: str
|
||||
* @param projectRelease project release
|
||||
* @param envId environment id
|
||||
*/
|
||||
async function deployWithPayload(currentAbsentApp: any, projectRelease: any, envId?: string) {
|
||||
async function deployWithPayload(currentAbsentApp: any, projectRelease: any, envId?: string): Promise<void> {
|
||||
const deployPayload = {
|
||||
name: currentAbsentApp.name,
|
||||
releaseId: projectRelease.entry.id,
|
||||
@@ -608,10 +605,13 @@ async function checkDescriptorExist(name: string): Promise<boolean> {
|
||||
*/
|
||||
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}`);
|
||||
return projectRelease;
|
||||
}
|
||||
@@ -620,32 +620,42 @@ async function importProjectAndRelease(app: any, tag?: string) {
|
||||
* Find missing applications
|
||||
*
|
||||
* @param deployedApps applications
|
||||
* @returns list of missing apps
|
||||
*/
|
||||
function findMissingApps(deployedApps: any[]) {
|
||||
function findMissingApps(deployedApps: any[]): any[] {
|
||||
const result = [];
|
||||
|
||||
Object.keys(ACTIVITI_CLOUD_APPS).forEach((key) => {
|
||||
const isPresent = deployedApps.find((currentApp: any) => ACTIVITI_CLOUD_APPS[key].name === currentApp.entry.name);
|
||||
|
||||
if (!isPresent) {
|
||||
absentApps.push(ACTIVITI_CLOUD_APPS[key]);
|
||||
result.push(ACTIVITI_CLOUD_APPS[key]);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find failing applications
|
||||
*
|
||||
* @param deployedApps applications
|
||||
* @returns list of failing apps
|
||||
*/
|
||||
function findFailingApps(deployedApps: any[]) {
|
||||
function findFailingApps(deployedApps: any[]): any[] {
|
||||
const result = [];
|
||||
|
||||
Object.keys(ACTIVITI_CLOUD_APPS).forEach((key) => {
|
||||
const failingApp = deployedApps.filter(
|
||||
(currentApp: any) => ACTIVITI_CLOUD_APPS[key].name === currentApp.entry.name && 'Running' !== currentApp.entry.status
|
||||
);
|
||||
|
||||
if (failingApp?.length > 0) {
|
||||
failingApps.push(...failingApp);
|
||||
result.push(...failingApp);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -656,7 +666,7 @@ function findFailingApps(deployedApps: any[]) {
|
||||
*/
|
||||
async function getFileFromRemote(url: string, name: string) {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
https.get(url, (response) => {
|
||||
http.get(url, (response) => {
|
||||
if (response.statusCode !== 200) {
|
||||
reject(new Error(`HTTP error! Status: ${response.statusCode}`));
|
||||
return;
|
||||
|
@@ -1,30 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ProcessCloudModule } from './process-cloud.module';
|
||||
|
||||
describe('ProcessCloudModule', () => {
|
||||
let processCloudModule: ProcessCloudModule;
|
||||
|
||||
beforeEach(() => {
|
||||
processCloudModule = new ProcessCloudModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(processCloudModule).toBeTruthy();
|
||||
});
|
||||
});
|
@@ -89,7 +89,7 @@ export class StartProcessCloudService extends BaseCloudService {
|
||||
* Delete an existing process instance
|
||||
*
|
||||
* @param appName name of the Application
|
||||
* @param processInstanceId process instance to update
|
||||
* @param processInstanceId the identifier of the process instance to update
|
||||
* @returns Observable<void>
|
||||
*/
|
||||
deleteProcess(appName: string, processInstanceId: string): Observable<void> {
|
||||
|
Reference in New Issue
Block a user