mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ACA-4229] [ADW-AGS] Move Governance plugin check script to ADF CLI (#6523)
* [ACA-4229] [ADW-AGS] Move Governance plugin check script to ADF CLI * * Added description
This commit is contained in:
parent
5712b50d62
commit
cf1bb700ae
@ -44,6 +44,7 @@ In develop mode, the CLI takes the prebuilt scripts from the dist folder.
|
||||
|--- |--- |
|
||||
|check-cs-env |Check cs env is up |
|
||||
|check-ps-env |Check ps env is up |
|
||||
|check-plugin-env |Check plugin status |
|
||||
|artifact-from-s3 |Get artifact from S3 |
|
||||
|artifact-to-s3 |Get artifact to S3 |
|
||||
|docker-publish |publish docker image|
|
||||
@ -183,3 +184,12 @@ TEST_APP: {
|
||||
}]
|
||||
},
|
||||
```
|
||||
|
||||
### Checks plugin status
|
||||
|
||||
The following command is in charge of checking plugin status by given plugin name:
|
||||
|
||||
```bash
|
||||
adf-cli check-plugin-env --host "gateway_env" --pluginName "Name of the plugin" --appName "appName" -u "username" -p "password"
|
||||
--ui "uiName"
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ import { CheckEnv } from './plugins/check-env';
|
||||
import program = require('commander');
|
||||
import { ProcessServiceCheckPlugin } from './plugins/process-service-check-plugin';
|
||||
import { ProcessAutomationCheckPlugin } from './plugins/process-automation-check-plugin';
|
||||
import { GovernanceCheckPlugin } from './plugins/governance-check-plugin';
|
||||
|
||||
let pluginEnv;
|
||||
|
||||
@ -10,11 +11,11 @@ export default async function main(_args: string[]) {
|
||||
program
|
||||
.version('0.1.0')
|
||||
.option('--host [type]', 'Remote environment host')
|
||||
.option('--pluginName [type]', 'pluginName ')
|
||||
.option('--appName [type]', 'appName ')
|
||||
.option('--pluginName [type]', 'pluginName')
|
||||
.option('--appName [type]', 'appName ', 'Deployed appName on activiti-cloud')
|
||||
.option('-p, --password [type]', 'password ')
|
||||
.option('-u, --username [type]', 'username ')
|
||||
.option('--ui, --uiName [type]', 'uiName')
|
||||
.option('--ui, --uiName [type]', 'uiName', 'Deployed app UI type on activiti-cloud')
|
||||
.parse(process.argv);
|
||||
|
||||
pluginEnv = new CheckEnv(program.host, program.username, program.password);
|
||||
@ -27,15 +28,17 @@ export default async function main(_args: string[]) {
|
||||
if (program.pluginName === PluginTarget.processAutomation) {
|
||||
await checkProcessAutomationPlugin();
|
||||
}
|
||||
|
||||
if (program.pluginName === PluginTarget.governance) {
|
||||
await checkGovernancePlugin();
|
||||
}
|
||||
}
|
||||
|
||||
async function checkProcessServicesPlugin() {
|
||||
const processServiceCheckPlugin = new ProcessServiceCheckPlugin(
|
||||
{
|
||||
host: program.host,
|
||||
name: PluginTarget.processService,
|
||||
appName: null,
|
||||
uiName: null
|
||||
name: PluginTarget.processService
|
||||
},
|
||||
pluginEnv.alfrescoJsApi
|
||||
);
|
||||
@ -54,3 +57,15 @@ async function checkProcessAutomationPlugin() {
|
||||
);
|
||||
await processAutomationCheckPlugin.checkProcessAutomationPlugin();
|
||||
}
|
||||
|
||||
async function checkGovernancePlugin() {
|
||||
const governancePluginCheck = new GovernanceCheckPlugin(
|
||||
{
|
||||
host: program.host,
|
||||
name: PluginTarget.governance
|
||||
},
|
||||
pluginEnv.alfrescoJsApi
|
||||
);
|
||||
|
||||
await governancePluginCheck.checkRecordManagement();
|
||||
}
|
||||
|
26
lib/cli/scripts/plugins/governance-check-plugin.ts
Normal file
26
lib/cli/scripts/plugins/governance-check-plugin.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { PluginInterface } from './plugin-model';
|
||||
import { GovernanceHealth } from './governance-health';
|
||||
|
||||
export class GovernanceCheckPlugin {
|
||||
governanceHealth: GovernanceHealth;
|
||||
constructor(
|
||||
private pluginInfo: PluginInterface,
|
||||
private alfrescoJsApi: any
|
||||
) {
|
||||
this.governanceHealth = new GovernanceHealth(this.alfrescoJsApi);
|
||||
}
|
||||
|
||||
async checkRecordManagement() {
|
||||
let pluginStatus;
|
||||
|
||||
const isAvailable = await this.governanceHealth.isRecordManagementAvailable();
|
||||
if (!isAvailable) {
|
||||
await this.governanceHealth.createRecordManagementSite();
|
||||
pluginStatus = [{ PluginName: this.pluginInfo.name, Status: 'Active', RecordManagement: 'Created'}];
|
||||
console.table(pluginStatus);
|
||||
} else {
|
||||
pluginStatus = [{ PluginName: this.pluginInfo.name, Status: 'Active', RecordManagement: 'Available' }];
|
||||
console.table(pluginStatus);
|
||||
}
|
||||
}
|
||||
}
|
41
lib/cli/scripts/plugins/governance-health.ts
Normal file
41
lib/cli/scripts/plugins/governance-health.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { logger } from '../logger';
|
||||
|
||||
export class GovernanceHealth {
|
||||
constructor(private alfrescoJsApi: any) {}
|
||||
|
||||
async isRecordManagementAvailable() {
|
||||
try {
|
||||
const site = await this.alfrescoJsApi.gsCore.gsSitesApi.getRMSite();
|
||||
logger.info(
|
||||
`Record Management site is present: ${site.entry.title}`
|
||||
);
|
||||
return true;
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Record Management site get failed: ${
|
||||
JSON.parse(error.message).error.errorKey
|
||||
}`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async createRecordManagementSite() {
|
||||
const body = { title: 'Records Management' };
|
||||
const opts = { skipAddToFavorites: false }; // | Flag to indicate whether the RM site should not be added to the user's site favorites.
|
||||
|
||||
try {
|
||||
const site = await this.alfrescoJsApi.gsCore.gsSitesApi.createRMSite(
|
||||
body,
|
||||
opts
|
||||
);
|
||||
logger.info('Record Management site: created' + site);
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
`Record Management site creation failed: ${
|
||||
JSON.parse(error.message).error.errorKey
|
||||
}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,6 @@ export enum PluginTarget {
|
||||
export interface PluginInterface {
|
||||
name: string;
|
||||
host: string;
|
||||
appName: string;
|
||||
uiName: string;
|
||||
appName?: string;
|
||||
uiName?: string;
|
||||
}
|
||||
|
@ -28,17 +28,17 @@ export class ProcessAutomationCheckPlugin {
|
||||
} has been correctly configured`
|
||||
);
|
||||
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Active', BE: 'Enabled', FE: 'Enabled' }];
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Active', BE: 'UP', FE: 'Enabled' }];
|
||||
console.table(pluginStatus);
|
||||
} else {
|
||||
this.logConfigurationError();
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: isBackendActive ? 'Enabled' : 'Disabled', FE: isPluginEnabled ? 'Enabled' : 'Disabled' }];
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: isBackendActive ? 'UP' : 'DOWN', FE: isPluginEnabled ? 'Enabled' : 'Disabled' }];
|
||||
console.table(pluginStatus);
|
||||
process.exit(1);
|
||||
}
|
||||
} catch (e) {
|
||||
this.logConfigurationError(e);
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: 'Disabled', FE: 'Disabled' }];
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: 'DOWN', FE: 'Disabled' }];
|
||||
console.table(pluginStatus);
|
||||
process.exit(1);
|
||||
}
|
||||
|
@ -27,17 +27,17 @@ export class ProcessServiceCheckPlugin {
|
||||
this.plugInInfo.name
|
||||
} has been correctly configured`
|
||||
);
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: `${'Active'}`, BE: 'Enabled', FE: 'Enabled' }];
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: `${'Active'}`, BE: 'UP', FE: 'Enabled' }];
|
||||
console.table(pluginStatus);
|
||||
} else {
|
||||
this.logConfigurationError();
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: isBackendActive ? 'Enabled' : 'Disabled', FE: isPluginEnabled ? 'Enabled' : 'Disabled' }];
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: isBackendActive ? 'UP' : 'DOWN', FE: isPluginEnabled ? 'Enabled' : 'Disabled' }];
|
||||
console.table(pluginStatus);
|
||||
process.exit(1);
|
||||
}
|
||||
} catch (e) {
|
||||
this.logConfigurationError(e);
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: 'Disabled', FE: 'Disabled' }];
|
||||
pluginStatus = [{ PluginName: this.plugInInfo.name, Status: 'Inactive', BE: 'DOWN', FE: 'Disabled' }];
|
||||
console.table(pluginStatus);
|
||||
process.exit(1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user