Skip to content

Commit

Permalink
small improvements, add uiName parameter for the command
Browse files Browse the repository at this point in the history
  • Loading branch information
adomi committed Jan 4, 2021
1 parent 59e65bd commit 3cd535f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
32 changes: 16 additions & 16 deletions lib/cli/scripts/plugins/aae-plugin.ts
@@ -1,12 +1,12 @@
import { PlugInInterface } from './plugin-model';
import { PluginInterface } from './plugin-model';
import { logger } from '../logger';
import { PluginConfiguration } from './plugin-config';

export class ProcessAutomationPlugin {
config: PluginConfiguration;

constructor(
private plugInInfo: PlugInInterface,
private plugInInfo: PluginInterface,
private alfrescoJsApi: any
) {
this.config = new PluginConfiguration(
Expand All @@ -21,27 +21,18 @@ export class ProcessAutomationPlugin {
const isPluginEnabled = await this.config.isPluginEnabledFromAppConfiguration();
const isBackendActive = await this.checkBackendHealth();

if (!isPluginEnabled || !isBackendActive) {
logger.error(
`The plugin ${
this.plugInInfo.name
} has not been correctly configured`
);
process.exit(1);
} else {
if (isPluginEnabled && isBackendActive) {
logger.info(
`The plugin ${
this.plugInInfo.name
} has been correctly configured`
);
} else {
this.logConfigurationError();
process.exit(1);
}
} catch (e) {
logger.error(
`The plugin ${
this.plugInInfo.name
} has not been correctly configured`,
e
);
this.logConfigurationError(e);
process.exit(1);
}
}
Expand All @@ -66,4 +57,13 @@ export class ProcessAutomationPlugin {
return false;
}
}

private logConfigurationError(error?: any) {
logger.error(
`The plugin ${
this.plugInInfo.name
} has not been correctly configured`,
error
);
}
}
32 changes: 16 additions & 16 deletions lib/cli/scripts/plugins/aps-plugin.ts
@@ -1,11 +1,11 @@
import { PlugInInterface } from './plugin-model';
import { PluginInterface } from './plugin-model';
import { logger } from '../logger';
import { PluginConfiguration } from './plugin-config';

export class ProcessServicePlugin {
config: PluginConfiguration;

constructor(private plugInInfo: PlugInInterface, private alfrescoJsApi: any) {
constructor(private plugInInfo: PluginInterface, private alfrescoJsApi: any) {
this.config = new PluginConfiguration(this.plugInInfo, this.alfrescoJsApi, false);
}

Expand All @@ -14,27 +14,18 @@ export class ProcessServicePlugin {
const isPluginEnabled = await this.config.isPluginEnabledFromAppConfiguration();
const isBackendActive = await this.checkBackendHealth();

if (!isPluginEnabled || !isBackendActive) {
logger.error(
`The plugin ${
this.plugInInfo.name
} has not been correctly configured`
);
process.exit(1);
} else {
if (isPluginEnabled && isBackendActive) {
logger.info(
`The plugin ${
this.plugInInfo.name
} has been correctly configured`
);
} else {
this.logConfigurationError();
process.exit(1);
}
} catch (e) {
logger.error(
`The plugin ${
this.plugInInfo.name
} has not been correctly configured`,
e
);
this.logConfigurationError(e);
process.exit(1);
}
}
Expand All @@ -58,4 +49,13 @@ export class ProcessServicePlugin {
return false;
}
}

private logConfigurationError(error?: any) {
logger.error(
`The plugin ${
this.plugInInfo.name
} has not been correctly configured`,
error
);
}
}
7 changes: 5 additions & 2 deletions lib/cli/scripts/plugins/check-plugin-env.ts
Expand Up @@ -14,6 +14,7 @@ async function main() {
.option('--appName [type]', 'appName ')
.option('-p, --password [type]', 'password ')
.option('-u, --username [type]', 'username ')
.option('--ui, --uiName [type]', 'uiName')
.parse(process.argv);

pluginEnv = new CheckEnv(program.host, program.username, program.password);
Expand All @@ -33,7 +34,8 @@ async function checkProcessServicesPlugin() {
{
host: program.host,
name: PluginTarget.processService,
appName: null
appName: null,
uiName: null
},
pluginEnv.alfrescoJsApi
);
Expand All @@ -45,7 +47,8 @@ async function checkProcessAutomationPlugin() {
{
host: program.host,
name: PluginTarget.processAutomation,
appName: program.appName
appName: program.appName,
uiName: program.uiName
},
pluginEnv.alfrescoJsApi
);
Expand Down
10 changes: 3 additions & 7 deletions lib/cli/scripts/plugins/plugin-config.ts
@@ -1,9 +1,9 @@
import { PlugInInterface } from './plugin-model';
import { PluginInterface } from './plugin-model';
import { logger } from '../logger';

export class PluginConfiguration {
constructor(
private plugInInfo: PlugInInterface,
private plugInInfo: PluginInterface,
private alfrescoJsApi: any,
private isProcessAutomation: boolean
) {
Expand Down Expand Up @@ -41,11 +41,7 @@ export class PluginConfiguration {
}

async getAppConfig() {
let url = `${this.plugInInfo.host}/app.config.json`;

if (this.isProcessAutomation) {
url = `${this.plugInInfo.host}/${this.plugInInfo.appName}/ui/content/app.config.json`;
}
const url = this.isProcessAutomation ? `${this.plugInInfo.host}/${this.plugInInfo.appName}/ui/${this.plugInInfo.uiName}/app.config.json` : `${this.plugInInfo.host}/app.config.json`;
return this.callCustomApi(url);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/cli/scripts/plugins/plugin-model.ts
Expand Up @@ -4,8 +4,9 @@ export enum PluginTarget {
governance = 'governance'
}

export interface PlugInInterface {
export interface PluginInterface {
name: string;
host: string;
appName: string;
uiName: string;
}

0 comments on commit 3cd535f

Please sign in to comment.