From f9be037c4fb0a9d85a56c4874ebbb7da41c210a7 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Tue, 8 Feb 2022 10:28:55 +0000 Subject: [PATCH] fix eslint issues in CLI project (#7492) --- lib/cli/.eslintrc.json | 8 +- lib/cli/scripts/changelog.ts | 2 + lib/cli/scripts/check-cs-env.ts | 20 ++--- lib/cli/scripts/docker.ts | 17 ++-- lib/cli/scripts/init-aae-env.ts | 13 ++- lib/cli/scripts/init-acs-env.ts | 13 ++- lib/cli/scripts/init-aps-env.ts | 33 ++++--- lib/cli/scripts/kube-utils.ts | 65 ++++++++++++++ lib/cli/scripts/kubectl-clean-app.ts | 51 +++-------- lib/cli/scripts/kubectl-delete.ts | 59 +++--------- lib/cli/scripts/kubectl-image.ts | 89 ++++--------------- lib/cli/scripts/licenses.ts | 6 +- lib/cli/scripts/plugins/check-env.ts | 12 +-- lib/cli/scripts/plugins/governance-health.ts | 2 + lib/cli/scripts/plugins/plugin-model.ts | 1 + .../process-automation-check-plugin.ts | 2 + .../plugins/process-service-check-plugin.ts | 2 + lib/cli/scripts/resources.ts | 14 +-- lib/cli/tooling/dotenv.ts | 12 +-- 19 files changed, 186 insertions(+), 235 deletions(-) create mode 100644 lib/cli/scripts/kube-utils.ts diff --git a/lib/cli/.eslintrc.json b/lib/cli/.eslintrc.json index 670429d4e2..3012970804 100644 --- a/lib/cli/.eslintrc.json +++ b/lib/cli/.eslintrc.json @@ -19,14 +19,14 @@ "eslint-plugin-rxjs" ], "rules": { - "prefer-arrow/prefer-arrow-functions": "warn", - "@typescript-eslint/no-var-requires": "warn", + "prefer-arrow/prefer-arrow-functions": "off", + "@typescript-eslint/no-var-requires": "off", "@typescript-eslint/naming-convention": "warn", "quote-props": "warn", "no-shadow": "warn", "@typescript-eslint/consistent-type-assertions": "warn", - "@typescript-eslint/prefer-for-of": "warn", - "no-underscore-dangle": "warn", + "@typescript-eslint/prefer-for-of": "off", + "no-underscore-dangle": ["error", { "allowAfterThis": true }], "@angular-eslint/component-selector": [ "error", diff --git a/lib/cli/scripts/changelog.ts b/lib/cli/scripts/changelog.ts index bcacd891be..e112815e42 100644 --- a/lib/cli/scripts/changelog.ts +++ b/lib/cli/scripts/changelog.ts @@ -17,6 +17,8 @@ * limitations under the License. */ +/* eslint-disable @typescript-eslint/naming-convention */ + import * as shell from 'shelljs'; import * as path from 'path'; import * as program from 'commander'; diff --git a/lib/cli/scripts/check-cs-env.ts b/lib/cli/scripts/check-cs-env.ts index 717fa21b64..59ab64525b 100755 --- a/lib/cli/scripts/check-cs-env.ts +++ b/lib/cli/scripts/check-cs-env.ts @@ -70,19 +70,19 @@ async function checkDiskSpaceFullEnv() { try { folder = await alfrescoJsApi.nodes.addNode('-my-', { - 'name': `try-env`, - 'relativePath': `Builds`, - 'nodeType': 'cm:folder' + name: `try-env`, + relativePath: `Builds`, + nodeType: 'cm:folder' }, {}, { - 'overwrite': true + overwrite: true }); } catch (error) { folder = await alfrescoJsApi.nodes.getNode('-my-', { - 'relativePath': `Builds/try-env`, - 'nodeType': 'cm:folder' + relativePath: `Builds/try-env`, + nodeType: 'cm:folder' }, {}, { - 'overwrite': true + overwrite: true }); } const pathFile = path.join(__dirname, '../', 'README.md'); @@ -95,9 +95,9 @@ async function checkDiskSpaceFullEnv() { folder.entry.id, null, { - 'name': 'README.md', - 'nodeType': 'cm:content', - 'autoRename': true + name: 'README.md', + nodeType: 'cm:content', + autoRename: true } ); diff --git a/lib/cli/scripts/docker.ts b/lib/cli/scripts/docker.ts index f60b609ff9..a6b24321b2 100644 --- a/lib/cli/scripts/docker.ts +++ b/lib/cli/scripts/docker.ts @@ -22,9 +22,10 @@ import * as program from 'commander'; import { logger } from './logger'; import { resolve } from 'path'; +// eslint-disable-next-line no-shadow enum TARGETS { - Publish = 'publish', - Link = 'link' + publish = 'publish', + link = 'link' } const DOCKER_FILENAME = 'Dockerfile'; @@ -105,7 +106,7 @@ function main(args) { .option('--sourceTag [type]', 'sourceTag') .option('--buildArgs [type...]', 'buildArgs') .option('--fileName [type...]', 'Docker file name', DOCKER_FILENAME) - .option('--target [type]', 'target: publish or link', TARGETS.Publish) + .option('--target [type]', 'target: publish or link', TARGETS.publish) .requiredOption('--dockerRepo [type]', 'docker repo') .requiredOption('--dockerTags [type]', ' tags') .parse(process.argv); @@ -120,13 +121,13 @@ function main(args) { process.exit(1); } - if (program.opts().target === TARGETS.Publish && args.buildArgs === undefined) { - logger.error(`error: required option --buildArgs [type] in case the target is ${TARGETS.Publish}`); + if (program.opts().target === TARGETS.publish && args.buildArgs === undefined) { + logger.error(`error: required option --buildArgs [type] in case the target is ${TARGETS.publish}`); process.exit(1); } - if (program.opts().target === TARGETS.Link && args.sourceTag === undefined) { - logger.error(`error: required option --sourceTag [type] in case the target is ${TARGETS.Link}`); + if (program.opts().target === TARGETS.link && args.sourceTag === undefined) { + logger.error(`error: required option --sourceTag [type] in case the target is ${TARGETS.link}`); process.exit(1); } @@ -147,7 +148,7 @@ function main(args) { args.dockerTags.split(',').forEach((tag, index) => { if (tag) { logger.info(`Analyzing tag:${tag} ... for target ${program.opts().target}`); - if (program.opts().target === TARGETS.Publish) { + if (program.opts().target === TARGETS.publish) { if (index === 0) { logger.info(`Build only once`); mainTag = tag; diff --git a/lib/cli/scripts/init-aae-env.ts b/lib/cli/scripts/init-aae-env.ts index 01dbe9612f..8e7026d2fd 100644 --- a/lib/cli/scripts/init-aae-env.ts +++ b/lib/cli/scripts/init-aae-env.ts @@ -18,14 +18,11 @@ */ import * as program from 'commander'; - -/* eslint-disable */ import request = require('request'); import * as fs from 'fs'; import { logger } from './logger'; import { AlfrescoApi } from '@alfresco/js-api'; const ACTIVITI_CLOUD_APPS = require('./resources').ACTIVITI_CLOUD_APPS; -/* eslint-enable */ let alfrescoJsApiModeler: any; let alfrescoJsApiDevops: any; @@ -369,11 +366,11 @@ async function checkIfAppIsReleased(missingApps: any [], tag?: string) { await checkDescriptorExist(currentAbsentApp.name); await sleep(TIME); const deployPayload = { - 'name': currentAbsentApp.name, - 'releaseId': projectRelease.entry.id, - 'security': currentAbsentApp.security, - 'infrastructure': currentAbsentApp.infrastructure, - 'variables': currentAbsentApp.variables + name: currentAbsentApp.name, + releaseId: projectRelease.entry.id, + security: currentAbsentApp.security, + infrastructure: currentAbsentApp.infrastructure, + variables: currentAbsentApp.variables }; await deploy(deployPayload); } diff --git a/lib/cli/scripts/init-acs-env.ts b/lib/cli/scripts/init-acs-env.ts index c85c7a8679..dac9435263 100755 --- a/lib/cli/scripts/init-acs-env.ts +++ b/lib/cli/scripts/init-acs-env.ts @@ -1,15 +1,14 @@ -/* eslint-disable */ -let alfrescoApi = require('@alfresco/js-api'); -let program = require('commander'); -let fs = require ('fs'); +const alfrescoApi = require('@alfresco/js-api'); +const program = require('commander'); +const fs = require ('fs'); const path = require('path'); import { logger } from './logger'; +// eslint-disable-next-line @typescript-eslint/naming-convention const { SharedlinksApi, FavoritesApi, NodesApi } = require('@alfresco/js-api'); -let MAX_RETRY = 10; +const MAX_RETRY = 10; let counter = 0; -let TIMEOUT = 6000; +const TIMEOUT = 6000; const ACS_DEFAULT = require('./resources').ACS_DEFAULT; -/* eslint-enable */ let alfrescoJsApi; diff --git a/lib/cli/scripts/init-aps-env.ts b/lib/cli/scripts/init-aps-env.ts index bd23b6c972..e6e20ab8aa 100755 --- a/lib/cli/scripts/init-aps-env.ts +++ b/lib/cli/scripts/init-aps-env.ts @@ -1,19 +1,18 @@ -/* eslint-disable */ -let alfrescoApi = require('@alfresco/js-api'); -let program = require('commander'); -let fs = require ('fs'); +const alfrescoApi = require('@alfresco/js-api'); +const program = require('commander'); +const fs = require ('fs'); const path = require('path'); import { logger } from './logger'; const { throwError } = require('rxjs'); +// eslint-disable-next-line @typescript-eslint/naming-convention const { AppDefinitionsApi, RuntimeAppDefinitionsApi } = require('@alfresco/js-api'); -let MAX_RETRY = 10; +const MAX_RETRY = 10; let counter = 0; -let TIMEOUT = 6000; +const TIMEOUT = 6000; const TENANT_DEFAULT_ID = 1; const TENANT_DEFAULT_NAME = 'default'; const CONTENT_DEFAULT_NAME = 'adw-content'; const ACTIVITI_APPS = require('./resources').ACTIVITI_APPS; -/* eslint-enable */ let alfrescoJsApi; let alfrescoJsApiRepo; @@ -162,9 +161,9 @@ async function hasDefaultTenant(tenantId, tenantName) { async function createDefaultTenant(tenantName) { const tenantPost = { - 'active': true, - 'maxUsers': 10000, - 'name' : tenantName + active: true, + maxUsers: 10000, + name : tenantName }; try { @@ -180,13 +179,13 @@ async function createUsers(tenandId, user) { logger.info(`Create user ${user.email} on tenant: ${tenandId}`); const passwordCamelCase = 'Password'; const userJson = { - 'email': user.email, - 'firstName': user.firstName, - 'lastName': user.lastName, - 'status': 'active', - 'type': 'enterprise', - 'password': passwordCamelCase, - 'tenantId': tenandId + email: user.email, + firstName: user.firstName, + lastName: user.lastName, + status: 'active', + type: 'enterprise', + password: passwordCamelCase, + tenantId: tenandId }; try { diff --git a/lib/cli/scripts/kube-utils.ts b/lib/cli/scripts/kube-utils.ts new file mode 100644 index 0000000000..4027453f65 --- /dev/null +++ b/lib/cli/scripts/kube-utils.ts @@ -0,0 +1,65 @@ +import { logger } from './logger'; +import { exec } from './exec'; + +export interface KubeArgs { + tag?: string; + installCheck?: boolean; + username?: string; + token?: string; + clusterEnv?: string; + clusterUrl?: string; + dockerRepo?: string; + label?: string; + namespaces?: string; +} + +export const setCluster = (clusterEnv: string, clusterUrl: string) => { + logger.info('Perform set-cluster...'); + const response = exec('kubectl', [`config`, `set-cluster`, `${clusterEnv}`, `--server=${clusterUrl}`], {}); + logger.info(response); +}; + +export const setCredentials = (username: string, token: string) => { + logger.info('Perform set-credentials...'); + const response = exec('kubectl', [`config`, `set-credentials`, `${username}`, `--token=${token}`], {}); + logger.info(response); +}; + +export const setContext = (clusterEnv: string, username: string) => { + logger.info('Perform set-context...'); + const response = exec('kubectl', [`config`, `set-context`, `${clusterEnv}`, `--cluster=${clusterEnv}`, `--user=${username}`], {}); + logger.info(response); +}; + +export const useContext = (clusterEnv: string) => { + logger.info('Perform use-context...'); + const response = exec('kubectl', [`config`, `use-context`, `${clusterEnv}`], {}); + logger.info(response); +}; + +export const deletePod = (args: KubeArgs) => { + logger.info('Perform delete pods...'); + const response = exec('kubectl', [`delete`, `pods`, `--all-namespaces`, `-l`, `app=${args.label}`], {}); + logger.info(response); +}; + +export const getNamespaces = (): string[] => { + logger.info('Perform get namespaces name...'); + const result = exec('kubectl', [`get`, `namespaces`, `-l`, `type=application`, `-o`, `name`], {}); + const namespaces = result.replace(/namespace[\/]+/g, '').split(/\r?\n/); + logger.info(`namespaces found: ${namespaces}`); + return namespaces; +}; + +export const getDeploymentName = (args: KubeArgs, namespace: string): string => { + logger.info('Perform get deployment name...'); + const result = exec('kubectl', [`get`, `deployments`, `--namespace=${namespace}`, `-l`, `app=${args.label}`, `-o`, `name`], {}); + logger.info(`deployment name: ${result}`); + return result; +}; + +export const setImage = (args: KubeArgs, deploymentName: string, serviceName: string, namespace: string) => { + logger.info('Perform set image...'); + const response = exec('kubectl', [`set`, `image`, `--namespace=${namespace}`, `${deploymentName}`, `${serviceName}=${args.dockerRepo}:${args.tag}`], {}); + logger.info(response); +}; diff --git a/lib/cli/scripts/kubectl-clean-app.ts b/lib/cli/scripts/kubectl-clean-app.ts index eaef0a418e..4ff87e89e2 100644 --- a/lib/cli/scripts/kubectl-clean-app.ts +++ b/lib/cli/scripts/kubectl-clean-app.ts @@ -19,13 +19,9 @@ import * as program from 'commander'; import moment from 'moment-es6'; -import { exec } from './exec'; -/* eslint-disable */ import { AlfrescoApi } from '@alfresco/js-api'; -/* eslint-enable */ - import { logger } from './logger'; - +import * as kube from './kube-utils'; export interface ConfigArgs { rancherUsername?: string; rancherToken?: string; @@ -42,7 +38,6 @@ export interface ConfigArgs { identityHost: boolean; enableLike: boolean; intervalTime: string; - } function getAlfrescoJsApiInstance(args: ConfigArgs) { @@ -185,36 +180,12 @@ async function undeployApplication(args: ConfigArgs, apiService: any, name: stri } } -function setCluster(args: ConfigArgs) { - logger.info('Perform set-cluster...'); - const response = exec('kubectl', [`config`, `set-cluster`, `${args.clusterEnv}`, `--server=${args.clusterUrl}`], {}); - logger.info(response); -} - -function setCredentials(args: ConfigArgs) { - logger.info('Perform set-credentials...'); - const response = exec('kubectl', [`config`, `set-credentials`, `${args.rancherUsername}`, `--token=${args.rancherToken}`], {}); - logger.info(response); -} - -function setContext(args: ConfigArgs) { - logger.info('Perform set-context...'); - const response = exec('kubectl', [`config`, `set-context`, `${args.clusterEnv}`, `--cluster=${args.clusterEnv}`, `--user=${args.rancherUsername}`], {}); - logger.info(response); -} - -function useContext(args: ConfigArgs) { - logger.info('Perform use-context...'); - const response = exec('kubectl', [`config`, `use-context`, `${args.clusterEnv}`], {}); - logger.info(response); -} - +// eslint-disable-next-line prefer-arrow/prefer-arrow-functions export default async function(args: ConfigArgs) { await main(args); } -async function main(args) { - +const main = async (args: ConfigArgs) => { program .version('0.1.0') .description('The following command is in charge of cleaning the releases/application/descriptor related to an app passed as input' + @@ -254,24 +225,27 @@ async function main(args) { }); if (args.apps !== undefined) { - setCluster(args); - setCredentials(args); - setContext(args); - useContext(args); + kube.setCluster(args.clusterEnv, args.clusterUrl); + kube.setCredentials(args.rancherUsername, args.rancherToken); + kube.setContext(args.clusterEnv, args.rancherUsername); + kube.useContext(args.clusterEnv); const applications = args.apps.includes(',') ? args.apps.split(',') : [args.apps]; const interval = args.intervalTime ? args.intervalTime : '30 min'; - const extractTimeRange = interval.split(' ')[0]; + const extractTimeRange = parseInt(interval.split(' ')[0], 10); logger.info(`Extract time ${extractTimeRange} from interval: ${interval}`); + for (let i = 0; i < applications.length; i++ ) { logger.info(`Perform action on app: ${applications[i]}`); if (args.enableLike) { const applicationsByName = await getApplicationsByName(args, alfrescoJsApiDevops, applications[i]); logger.info(`Found ${applicationsByName.length} apps`); + for (let y = 0; y < applicationsByName.length; y++ ) { const application = applicationsByName[y].entry; logger.info(`Analyze app: ${application.name} `); const diffAsMinutes = moment.duration(moment().diff(moment(application.createdAt))).asMinutes(); + if (diffAsMinutes > extractTimeRange) { logger.info(`The app: ${application} is older than ${interval}. Can delete it`); await undeployApplication(args, alfrescoJsApiDevops, application.name); @@ -288,5 +262,4 @@ async function main(args) { } } } - -} +}; diff --git a/lib/cli/scripts/kubectl-delete.ts b/lib/cli/scripts/kubectl-delete.ts index 8a448edc2c..e94bdbaf2a 100644 --- a/lib/cli/scripts/kubectl-delete.ts +++ b/lib/cli/scripts/kubectl-delete.ts @@ -17,54 +17,15 @@ * limitations under the License. */ -import { exec } from './exec'; import * as program from 'commander'; -import { logger } from './logger'; +import * as kube from './kube-utils'; -export interface KubeArgs { - username?: string; - token?: string; - clusterEnv?: string; - clusterUrl?: string; - label?: string; -} - -function setCluster(args: KubeArgs) { - logger.info('Perform set-cluster...'); - const response = exec('kubectl', [`config`, `set-cluster`, `${args.clusterEnv}`, `--server=${args.clusterUrl}`], {}); - logger.info(response); -} - -function setCredentials(args: KubeArgs) { - logger.info('Perform set-credentials...'); - const response = exec('kubectl', [`config`, `set-credentials`, `${args.username}`, `--token=${args.token}`], {}); - logger.info(response); -} - -function setContext(args: KubeArgs) { - logger.info('Perform set-context...'); - const response = exec('kubectl', [`config`, `set-context`, `${args.clusterEnv}`, `--cluster=${args.clusterEnv}`, `--user=${args.username}`], {}); - logger.info(response); -} - -function useContext(args: KubeArgs) { - logger.info('Perform use-context...'); - const response = exec('kubectl', [`config`, `use-context`, `${args.clusterEnv}`], {}); - logger.info(response); -} - -function deletePod(args: KubeArgs) { - logger.info('Perform delete pods...'); - const response = exec('kubectl', [`delete`, `pods`, `--all-namespaces`, `-l`, `app=${args.label}`], {}); - logger.info(response); -} - -export default function(args: KubeArgs) { +// eslint-disable-next-line prefer-arrow/prefer-arrow-functions +export default function(args: kube.KubeArgs) { main(args); } -function main(args) { - +const main = (args: kube.KubeArgs) => { program .version('0.1.0') .option('--username [type]', 'username') @@ -81,10 +42,10 @@ function main(args) { } if (args.label !== undefined) { - setCluster(args); - setCredentials(args); - setContext(args); - useContext(args); - deletePod(args); + kube.setCluster(args.clusterEnv, args.clusterUrl); + kube.setCredentials(args.username, args.token); + kube.setContext(args.clusterEnv, args.username); + kube.useContext(args.clusterEnv); + kube.deletePod(args); } -} +}; diff --git a/lib/cli/scripts/kubectl-image.ts b/lib/cli/scripts/kubectl-image.ts index 39326aae70..7def05a9e0 100644 --- a/lib/cli/scripts/kubectl-image.ts +++ b/lib/cli/scripts/kubectl-image.ts @@ -20,77 +20,21 @@ import { exec } from './exec'; import * as program from 'commander'; import { logger } from './logger'; +import * as kube from './kube-utils'; -export interface KubeArgs { - tag?: string; - installCheck?: boolean; - username?: string; - token?: string; - clusterEnv?: string; - clusterUrl?: string; - dockerRepo?: string; - label?: string; - namespaces?: string; -} - -function setCluster(args: KubeArgs) { - logger.info('Perform set-cluster...'); - const response = exec('kubectl', [`config`, `set-cluster`, `${args.clusterEnv}`, `--server=${args.clusterUrl}`], {}); - logger.info(response); -} - -function setCredentials(args: KubeArgs) { - logger.info('Perform set-credentials...'); - const response = exec('kubectl', [`config`, `set-credentials`, `${args.username}`, `--token=${args.token}`], {}); - logger.info(response); -} - -function setContext(args: KubeArgs) { - logger.info('Perform set-context...'); - const response = exec('kubectl', [`config`, `set-context`, `${args.clusterEnv}`, `--cluster=${args.clusterEnv}`, `--user=${args.username}`], {}); - logger.info(response); -} - -function useContext(args: KubeArgs) { - logger.info('Perform use-context...'); - const response = exec('kubectl', [`config`, `use-context`, `${args.clusterEnv}`], {}); - logger.info(response); -} - -function getNamespaces(): string [] { - logger.info('Perform get namespaces name...'); - const result = exec('kubectl', [`get`, `namespaces`, `-l`, `type=application`, `-o`, `name`], {}); - const namespaces = result.replace(/namespace[\/]+/g, '').split(/\r?\n/); - logger.info(`namespaces found: ${namespaces}`); - return namespaces; -} - -function getDeploymentName(args: KubeArgs, namespace: string): string { - logger.info('Perform get deployment name...'); - const result = exec('kubectl', [`get`, `deployments`, `--namespace=${namespace}`, `-l`, `app=${args.label}`, `-o`, `name`], {}); - logger.info(`deployment name: ${result}`); - return result; -} - -function setImage(args: KubeArgs, deploymentName: string, serviceName: string, namespace: string) { - logger.info('Perform set image...'); - const response = exec('kubectl', [`set`, `image`, `--namespace=${namespace}`, `${deploymentName}`, `${serviceName}=${args.dockerRepo}:${args.tag}`], {}); - logger.info(response); -} - -function installPerform() { +const installPerform = () => { logger.info('Perform install...'); const responseK8sStable = exec('curl', [`-s`, `https://storage.googleapis.com/kubernetes-release/release/stable.txt`], {}).trim(); const k8sRelease = `https://storage.googleapis.com/kubernetes-release/release/${responseK8sStable}/bin/linux/amd64/kubectl`; exec('curl', [`LO`, `${k8sRelease}`], {}); -} +}; -export default function(args: KubeArgs) { +// eslint-disable-next-line prefer-arrow/prefer-arrow-functions +export default function(args: kube.KubeArgs) { main(args); } -function main(args) { - +const main = (args: kube.KubeArgs) => { program .version('0.1.0') .description('his command allows you to update a specific service on the rancher env with a specific tag \n\n' + @@ -115,27 +59,28 @@ function main(args) { } if (args.tag !== undefined) { - setCluster(args); - setCredentials(args); - setContext(args); - useContext(args); + kube.setCluster(args.clusterEnv, args.clusterUrl); + kube.setCredentials(args.username, args.token); + kube.setContext(args.clusterEnv, args.username); + kube.useContext(args.clusterEnv); + let namespaces: string []; if (args.namespaces === null || args.namespaces === 'default') { logger.info(`No namespaces provided. Fetch all of them`); - namespaces = getNamespaces(); + namespaces = kube.getNamespaces(); } else { namespaces = args.namespaces.split(','); } - namespaces.forEach( (namespace) => { + + namespaces.forEach((namespace) => { logger.info(`Find deployment name based on label ${args.label} and namespace ${namespace}`); - const deploymentName = getDeploymentName(args, namespace); + const deploymentName = kube.getDeploymentName(args, namespace); if (deploymentName) { logger.info(`Found ${deploymentName}`); - setImage(args, deploymentName.trim(), '*', namespace); + kube.setImage(args, deploymentName.trim(), '*', namespace); } else { logger.info(`No container with the label app=${args.label} found`); } - }); } -} +}; diff --git a/lib/cli/scripts/licenses.ts b/lib/cli/scripts/licenses.ts index 41f0f9cfd7..93d03f745e 100644 --- a/lib/cli/scripts/licenses.ts +++ b/lib/cli/scripts/licenses.ts @@ -32,8 +32,8 @@ interface PackageInfo { const nonStandardLicenses = { 'public domain': 'PDDL-1.0', - 'apache': 'Apache-2.0', - 'bsd': 'BSD-2-Clause' + apache: 'Apache-2.0', + bsd: 'BSD-2-Clause' }; const missingRepositories = { @@ -44,7 +44,7 @@ const missingRepositories = { '@webassemblyjs/leb128': 'https://github.com/xtuc/webassemblyjs', 'adf-tslint-rules': 'https://github.com/Alfresco/alfresco-ng2-components', 'adf-monaco-extension': 'https://github.com/eromano/aca-monaco-extension', - 'indexof': 'https://github.com/component/indexof', + indexof: 'https://github.com/component/indexof', 'rxjs-compat': 'https://github.com/ReactiveX/rxjs/tree/master/compat' }; diff --git a/lib/cli/scripts/plugins/check-env.ts b/lib/cli/scripts/plugins/check-env.ts index e1562e222d..6ccdc2fb0c 100644 --- a/lib/cli/scripts/plugins/check-env.ts +++ b/lib/cli/scripts/plugins/check-env.ts @@ -1,10 +1,10 @@ import { logger } from './../logger'; import alfrescoApi = require('@alfresco/js-api'); +const TIMEOUT = 6000; +const MAX_RETRY = 10; export class CheckEnv { _alfrescoJsApi: any; - TIMEOUT = 6000; - MAX_RETRY = 10; counter = 0; constructor( @@ -15,7 +15,7 @@ export class CheckEnv { async checkEnv() { try { - this.alfrescoJsApi = new alfrescoApi.AlfrescoApiCompatibility( { + this.alfrescoJsApi = new alfrescoApi.AlfrescoApiCompatibility({ provider: 'ALL', hostBpm: this.host, hostEcm: this.host, @@ -25,7 +25,7 @@ export class CheckEnv { clientId: 'alfresco', scope: 'openid' } - }); + } as any); await this.alfrescoJsApi.login(this.username, this.password); } catch (e) { if (e.error.code === 'ETIMEDOUT') { @@ -34,14 +34,14 @@ export class CheckEnv { } logger.error('Login error environment down or inaccessible'); this.counter++; - if (this.MAX_RETRY === this.counter) { + if (MAX_RETRY === this.counter) { logger.error('Give up'); process.exit(1); } else { logger.error( `Retry in 1 minute at main();tempt N ${this.counter}` ); - this.sleep(this.TIMEOUT); + this.sleep(TIMEOUT); this.checkEnv(); } } diff --git a/lib/cli/scripts/plugins/governance-health.ts b/lib/cli/scripts/plugins/governance-health.ts index 616599803b..fee9effcc3 100644 --- a/lib/cli/scripts/plugins/governance-health.ts +++ b/lib/cli/scripts/plugins/governance-health.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/naming-convention */ + import { logger } from '../logger'; import { PluginInterface } from './plugin-model'; diff --git a/lib/cli/scripts/plugins/plugin-model.ts b/lib/cli/scripts/plugins/plugin-model.ts index 2f3be69a1d..cac5a689d3 100644 --- a/lib/cli/scripts/plugins/plugin-model.ts +++ b/lib/cli/scripts/plugins/plugin-model.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line no-shadow export enum PluginTarget { processService = 'processService', processAutomation = 'processAutomation', diff --git a/lib/cli/scripts/plugins/process-automation-check-plugin.ts b/lib/cli/scripts/plugins/process-automation-check-plugin.ts index 9093cf071d..835d636b12 100644 --- a/lib/cli/scripts/plugins/process-automation-check-plugin.ts +++ b/lib/cli/scripts/plugins/process-automation-check-plugin.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/naming-convention */ + import { PluginInterface } from './plugin-model'; import { logger } from '../logger'; import { ProcessAutomationHealth } from './process-automation-health'; diff --git a/lib/cli/scripts/plugins/process-service-check-plugin.ts b/lib/cli/scripts/plugins/process-service-check-plugin.ts index 79798e8285..4132f8be3b 100644 --- a/lib/cli/scripts/plugins/process-service-check-plugin.ts +++ b/lib/cli/scripts/plugins/process-service-check-plugin.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/naming-convention */ + import { PluginInterface } from './plugin-model'; import { logger } from '../logger'; import { ProcessServiceHealth } from './process-services-health'; diff --git a/lib/cli/scripts/resources.ts b/lib/cli/scripts/resources.ts index 517e81f256..962d38a9e6 100644 --- a/lib/cli/scripts/resources.ts +++ b/lib/cli/scripts/resources.ts @@ -16,6 +16,8 @@ */ /* cSpell:disable */ +/* eslint-disable @typescript-eslint/naming-convention */ + export const ACTIVITI_CLOUD_APPS: any = { SUB_PROCESS_APP: { name: 'subprocessapp', @@ -25,8 +27,8 @@ export const ACTIVITI_CLOUD_APPS: any = { processparent: 'processparent' }, security: [ - { 'role': 'ACTIVITI_ADMIN', 'groups': [], 'users': ['superadminuser'] }, - { 'role': 'ACTIVITI_USER', 'groups': ['hr', 'testgroup'], 'users': ['hruser'] } + { role: 'ACTIVITI_ADMIN', groups: [], users: ['superadminuser'] }, + { role: 'ACTIVITI_USER', groups: ['hr', 'testgroup'], users: ['hruser'] } ] }, CANDIDATE_BASE_APP: { @@ -64,8 +66,8 @@ export const ACTIVITI_CLOUD_APPS: any = { outputform: 'outputform' }, security: [ - { 'role': 'ACTIVITI_ADMIN', 'groups': [], 'users': ['superadminuser', 'processadminuser'] }, - { 'role': 'ACTIVITI_USER', 'groups': ['hr', 'testgroup'], 'users': ['hruser', 'salesuser'] } + { role: 'ACTIVITI_ADMIN', groups: [], users: ['superadminuser', 'processadminuser'] }, + { role: 'ACTIVITI_USER', groups: ['hr', 'testgroup'], users: ['hruser', 'salesuser'] } ], tasks: { uploadFileTask: 'UploadFileTask', @@ -195,8 +197,8 @@ export const ACTIVITI_CLOUD_APPS: any = { uploadSingleMultipleFiles: 'UploadSingleMultipleFiles' }, security: [ - { 'role': 'ACTIVITI_ADMIN', 'groups': [], 'users': ['superadminuser', 'processadminuser'] }, - { 'role': 'ACTIVITI_USER', 'groups': ['hr', 'sales', 'testgroup'], 'users': ['hruser'] } + { role: 'ACTIVITI_ADMIN', groups: [], users: ['superadminuser', 'processadminuser'] }, + { role: 'ACTIVITI_USER', groups: ['hr', 'sales', 'testgroup'], users: ['hruser'] } ], infrastructure: {connectors: {restconnector: {}}, bridges: {}} } diff --git a/lib/cli/tooling/dotenv.ts b/lib/cli/tooling/dotenv.ts index d00c07f951..a4c18d9954 100644 --- a/lib/cli/tooling/dotenv.ts +++ b/lib/cli/tooling/dotenv.ts @@ -15,10 +15,10 @@ * limitations under the License. */ -export function dotenv() { - return require('dotenv-expand')(require('dotenv')); -} +// eslint-disable-next-line @typescript-eslint/no-var-requires +const expand = require('dotenv-expand'); +// eslint-disable-next-line @typescript-eslint/no-var-requires +const nodeDotEnv = require('dotenv'); -export function dotenvConfig(params?: any) { - return require('dotenv-expand')(require('dotenv').config(params)); -} +export const dotenv = () => expand(nodeDotEnv); +export const dotenvConfig = (params?: any) => expand(nodeDotEnv.config(params));