mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-7100] migrate ADF projects to eslint (#7483)
* migrate content services to eslint * migrate insights to eslint * migrate extensions to eslint * migrate testing lib to eslint * migrate CLI to eslint * migrate process-services to eslint * migrate process-services-cloud to eslint * remove cli analytics [ci:force]
This commit is contained in:
@@ -38,7 +38,7 @@ function zipArtifact(output: string) {
|
||||
logger.info(response);
|
||||
}
|
||||
|
||||
export default function () {
|
||||
export default function() {
|
||||
main();
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ function awsCp(output: string) {
|
||||
logger.info(response);
|
||||
}
|
||||
|
||||
export default function () {
|
||||
export default function() {
|
||||
main();
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ export default function main(_args: string[], workingDir: string) {
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// tslint:disable-next-line: no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Running audit on ${packagePath}`);
|
||||
|
||||
const packageJson = JSON.parse(fs.readFileSync(packagePath).toString());
|
||||
@@ -75,7 +75,7 @@ export default function main(_args: string[], workingDir: string) {
|
||||
|
||||
fs.writeFileSync(outputFile, mdText);
|
||||
|
||||
// tslint:disable-next-line: no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Report saved as ${outputFile}`);
|
||||
resolve(0);
|
||||
}
|
||||
|
@@ -56,6 +56,7 @@ interface DiffOptions {
|
||||
|
||||
/**
|
||||
* Get the remote URL for the cloned git repository
|
||||
*
|
||||
* @param workingDir Repository directory
|
||||
* @returns URL pointing to the git remote
|
||||
*/
|
||||
@@ -68,6 +69,7 @@ function getRemote(workingDir: string): string {
|
||||
|
||||
/**
|
||||
* Get the list of commits based on the configuration options
|
||||
*
|
||||
* @param options Logging options
|
||||
* @returns Collection of Commit objects
|
||||
*/
|
||||
@@ -78,7 +80,7 @@ function getCommits(options: DiffOptions): Array<Commit> {
|
||||
.join('\|');
|
||||
|
||||
if (!authorFilter) {
|
||||
authorFilter = "bot\|Alfresco Build User";
|
||||
authorFilter = `bot\|Alfresco Build User`;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
const alfrescoApi = require('@alfresco/js-api');
|
||||
const program = require('commander');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
/* tslint:enable */
|
||||
/* eslint-enable */
|
||||
import { logger } from './logger';
|
||||
const MAX_RETRY = 3;
|
||||
const TIMEOUT = 20000;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
const alfrescoApi = require('@alfresco/js-api');
|
||||
const program = require('commander');
|
||||
/* tslint:enable */
|
||||
/* eslint-enable */
|
||||
import { logger } from './logger';
|
||||
const MAX_RETRY = 10;
|
||||
const TIMEOUT = 60000;
|
||||
|
@@ -19,6 +19,6 @@
|
||||
|
||||
import * as docker from './docker';
|
||||
|
||||
export default function (args: any) {
|
||||
export default function(args: any) {
|
||||
docker.default(args);
|
||||
}
|
||||
|
@@ -50,9 +50,9 @@ function loginPerform(args: PublishArgs) {
|
||||
function buildImagePerform(args: PublishArgs, tag: string) {
|
||||
logger.info(`Perform docker build...${args.dockerRepo}:${tag}`);
|
||||
|
||||
let buildArgs = [];
|
||||
const buildArgs = [];
|
||||
|
||||
if (typeof args.buildArgs === "string") {
|
||||
if (typeof args.buildArgs === 'string') {
|
||||
buildArgs.push(`--build-arg=${args.buildArgs}`);
|
||||
} else {
|
||||
args.buildArgs.forEach((envVar) => {
|
||||
@@ -88,7 +88,7 @@ function cleanImagePerform(args: PublishArgs, tag: string) {
|
||||
logger.info(response);
|
||||
}
|
||||
|
||||
export default function (args: PublishArgs) {
|
||||
export default function(args: PublishArgs) {
|
||||
main(args);
|
||||
}
|
||||
|
||||
|
@@ -19,13 +19,13 @@
|
||||
|
||||
import * as program from 'commander';
|
||||
|
||||
/* tslint:disable */
|
||||
/* 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;
|
||||
/* tslint:enable */
|
||||
/* eslint-enable */
|
||||
|
||||
let alfrescoJsApiModeler: any;
|
||||
let alfrescoJsApiDevops: any;
|
||||
@@ -53,9 +53,14 @@ export const AAE_MICROSERVICES = [
|
||||
async function healthCheck(nameService: string) {
|
||||
const url = `${args.host}/${nameService}/actuator/health`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const queryParams = {};
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
const health = await alfrescoJsApiModeler.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
@@ -63,7 +68,8 @@ async function healthCheck(nameService: string) {
|
||||
logger.error(`${nameService} is DOWN `);
|
||||
isValid = false;
|
||||
} else {
|
||||
const reset = '\x1b[0m', green = '\x1b[32m';
|
||||
const reset = '\x1b[0m';
|
||||
const green = '\x1b[32m';
|
||||
logger.info(`${green}${nameService} is UP!${reset}`);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -75,9 +81,14 @@ async function healthCheck(nameService: string) {
|
||||
async function getApplicationByStatus(status: string) {
|
||||
const url = `${args.host}/deployment-service/v1/applications/`;
|
||||
|
||||
const pathParams = {}, queryParams = { status: status },
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const queryParams = { status };
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
await alfrescoJsApiDevops.login(args.devopsUsername, args.devopsPassword);
|
||||
|
||||
@@ -95,9 +106,14 @@ async function getApplicationByStatus(status: string) {
|
||||
function getDescriptors() {
|
||||
const url = `${args.host}/deployment-service/v1/descriptors`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const queryParams = {};
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
return alfrescoJsApiDevops.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
@@ -111,9 +127,14 @@ function getDescriptors() {
|
||||
function getProjects() {
|
||||
const url = `${args.host}/modeling-service/v1/projects`;
|
||||
|
||||
const pathParams = {}, queryParams = { maxItems: 1000 },
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const queryParams = { maxItems: 1000 };
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
return alfrescoJsApiModeler.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
@@ -127,9 +148,14 @@ function getProjects() {
|
||||
function getProjectRelease(projectId: string) {
|
||||
const url = `${args.host}/modeling-service/v1/projects/${projectId}/releases`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const queryParams = {};
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
return alfrescoJsApiModeler.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
@@ -143,9 +169,14 @@ function getProjectRelease(projectId: string) {
|
||||
async function releaseProject(projectId: string) {
|
||||
const url = `${args.host}/modeling-service/v1/projects/${projectId}/releases`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const queryParams = {};
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
return alfrescoJsApiModeler.oauth2Auth.callCustomApi(url, 'POST', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
@@ -160,9 +191,14 @@ async function releaseProject(projectId: string) {
|
||||
function deleteProject(projectId: string) {
|
||||
const url = `${args.host}/modeling-service/v1/projects/${projectId}`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const queryParams = {};
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
return alfrescoJsApiModeler.oauth2Auth.callCustomApi(url, 'DELETE', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
@@ -194,9 +230,14 @@ async function importAndReleaseProject(absoluteFilePath: string) {
|
||||
function deleteDescriptor(name: string) {
|
||||
const url = `${args.host}/deployment-service/v1/descriptors/${name}`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const queryParams = {};
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
return alfrescoJsApiDevops.oauth2Auth.callCustomApi(url, 'DELETE', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
@@ -210,9 +251,14 @@ function deleteDescriptor(name: string) {
|
||||
function deploy(model: any) {
|
||||
const url = `${args.host}/deployment-service/v1/applications/`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = model,
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const queryParams = {};
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = model;
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
return alfrescoJsApiDevops.oauth2Auth.callCustomApi(url, 'POST', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts);
|
||||
@@ -248,7 +294,9 @@ async function deployMissingApps(tag?: string) {
|
||||
|
||||
if (failingApps.length > 0) {
|
||||
failingApps.forEach( app => {
|
||||
const reset = '\x1b[0m', bright = '\x1b[1m', red = '\x1b[31m';
|
||||
const reset = '\x1b[0m';
|
||||
const bright = '\x1b[1m';
|
||||
const red = '\x1b[31m';
|
||||
logger.error(`${red}${bright}ERROR: App ${app.entry.name} down or inaccessible ${reset}${red} with status ${app.entry.status}${reset}`);
|
||||
});
|
||||
process.exit(1);
|
||||
@@ -256,7 +304,8 @@ async function deployMissingApps(tag?: string) {
|
||||
logger.warn(`Missing apps: ${JSON.stringify(absentApps)}`);
|
||||
await checkIfAppIsReleased(absentApps, tag);
|
||||
} else {
|
||||
const reset = '\x1b[0m', green = '\x1b[32m';
|
||||
const reset = '\x1b[0m';
|
||||
const green = '\x1b[32m';
|
||||
logger.info(`${green}All the apps are correctly deployed${reset}`);
|
||||
}
|
||||
}
|
||||
@@ -269,9 +318,7 @@ async function checkIfAppIsReleased(missingApps: any [], tag?: string) {
|
||||
for (let i = 0; i < missingApps.length; i++) {
|
||||
noError = true;
|
||||
const currentAbsentApp = missingApps[i];
|
||||
const project = projectList.list.entries.find((currentApp: any) => {
|
||||
return currentAbsentApp.name === currentApp.entry.name;
|
||||
});
|
||||
const project = projectList.list.entries.find((currentApp: any) => currentAbsentApp.name === currentApp.entry.name);
|
||||
let projectRelease: any;
|
||||
|
||||
if (project === undefined) {
|
||||
@@ -360,11 +407,8 @@ async function importProjectAndRelease(app: any, tag?: string) {
|
||||
}
|
||||
|
||||
function findMissingApps(deployedApps: any []) {
|
||||
|
||||
Object.keys(ACTIVITI_CLOUD_APPS).forEach((key) => {
|
||||
const isPresent = deployedApps.find((currentApp: any) => {
|
||||
return ACTIVITI_CLOUD_APPS[key].name === currentApp.entry.name;
|
||||
});
|
||||
const isPresent = deployedApps.find((currentApp: any) => ACTIVITI_CLOUD_APPS[key].name === currentApp.entry.name);
|
||||
|
||||
if (!isPresent) {
|
||||
absentApps.push(ACTIVITI_CLOUD_APPS[key]);
|
||||
@@ -373,11 +417,8 @@ function findMissingApps(deployedApps: any []) {
|
||||
}
|
||||
|
||||
function findFailingApps(deployedApps: any []) {
|
||||
|
||||
Object.keys(ACTIVITI_CLOUD_APPS).forEach((key) => {
|
||||
const failingApp = deployedApps.filter((currentApp: any) => {
|
||||
return ACTIVITI_CLOUD_APPS[key].name === currentApp.entry.name && 'Running' !== currentApp.entry.status;
|
||||
});
|
||||
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);
|
||||
@@ -386,7 +427,7 @@ function findFailingApps(deployedApps: any []) {
|
||||
}
|
||||
|
||||
async function getFileFromRemote(url: string, name: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
request(url)
|
||||
.pipe(fs.createWriteStream(`${name}.zip`))
|
||||
.on('finish', () => {
|
||||
@@ -412,12 +453,11 @@ async function sleep(time: number) {
|
||||
return;
|
||||
}
|
||||
|
||||
export default async function (configArgs: ConfigArgs) {
|
||||
export default async function(configArgs: ConfigArgs) {
|
||||
await main(configArgs);
|
||||
}
|
||||
|
||||
async function main(configArgs: ConfigArgs) {
|
||||
|
||||
args = configArgs;
|
||||
|
||||
program
|
||||
@@ -445,7 +485,8 @@ async function main(configArgs: ConfigArgs) {
|
||||
});
|
||||
|
||||
await alfrescoJsApiModeler.login(args.modelerUsername, args.modelerPassword).then(() => {
|
||||
const reset = '\x1b[0m', green = '\x1b[32m';
|
||||
const reset = '\x1b[0m';
|
||||
const green = '\x1b[32m';
|
||||
logger.info(`${green}login SSO ok${reset}`);
|
||||
}, (error) => {
|
||||
logger.error(`login SSO error ${JSON.stringify(error)} ${args.modelerUsername}`);
|
||||
@@ -453,7 +494,8 @@ async function main(configArgs: ConfigArgs) {
|
||||
});
|
||||
|
||||
if (isValid) {
|
||||
const reset = '\x1b[0m', green = '\x1b[32m';
|
||||
const reset = '\x1b[0m';
|
||||
const green = '\x1b[32m';
|
||||
logger.info(`${green}The environment is up and running ${reset}`);
|
||||
alfrescoJsApiDevops = getAlfrescoJsApiInstance(args);
|
||||
await alfrescoJsApiDevops.login(args.devopsUsername, args.devopsPassword).then(() => {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
let alfrescoApi = require('@alfresco/js-api');
|
||||
let program = require('commander');
|
||||
let fs = require ('fs');
|
||||
@@ -9,11 +9,11 @@ let MAX_RETRY = 10;
|
||||
let counter = 0;
|
||||
let TIMEOUT = 6000;
|
||||
const ACS_DEFAULT = require('./resources').ACS_DEFAULT;
|
||||
/* tslint:enable */
|
||||
/* eslint-enable */
|
||||
|
||||
let alfrescoJsApi;
|
||||
|
||||
export default async function () {
|
||||
export default async function() {
|
||||
await main();
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ async function lockFile(nodeId) {
|
||||
|
||||
async function shareFile(nodeId) {
|
||||
const data = {
|
||||
nodeId: nodeId
|
||||
nodeId
|
||||
};
|
||||
try {
|
||||
await new SharedlinksApi(alfrescoJsApi).createSharedLink(data);
|
||||
@@ -179,7 +179,7 @@ async function checkEnv() {
|
||||
}
|
||||
}
|
||||
|
||||
/* tslint:enable */
|
||||
/* eslint-enable */
|
||||
|
||||
function sleep(delay) {
|
||||
const start = new Date().getTime();
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
let alfrescoApi = require('@alfresco/js-api');
|
||||
let program = require('commander');
|
||||
let fs = require ('fs');
|
||||
@@ -13,12 +13,12 @@ const TENANT_DEFAULT_ID = 1;
|
||||
const TENANT_DEFAULT_NAME = 'default';
|
||||
const CONTENT_DEFAULT_NAME = 'adw-content';
|
||||
const ACTIVITI_APPS = require('./resources').ACTIVITI_APPS;
|
||||
/* tslint:enable */
|
||||
/* eslint-enable */
|
||||
|
||||
let alfrescoJsApi;
|
||||
let alfrescoJsApiRepo;
|
||||
|
||||
export default async function () {
|
||||
export default async function() {
|
||||
await main();
|
||||
}
|
||||
|
||||
@@ -336,11 +336,11 @@ async function addContentRepoWithBasic(tenantId, name) {
|
||||
const body = {
|
||||
alfrescoTenantId: '',
|
||||
authenticationType: 'basic',
|
||||
name: name,
|
||||
name,
|
||||
repositoryUrl: `${program.host}/alfresco`,
|
||||
shareUrl: `${program.host}/share`,
|
||||
// sitesFolder: '', not working on activiti 1.11.1.1
|
||||
tenantId: tenantId,
|
||||
tenantId,
|
||||
version: '6.1.1'
|
||||
};
|
||||
|
||||
@@ -413,7 +413,7 @@ async function authorizeUserToContentWithBasic(username, contentId) {
|
||||
}
|
||||
}
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
async function downloadLicenseFile(apsLicensePath) {
|
||||
|
||||
try {
|
||||
@@ -428,7 +428,7 @@ async function downloadLicenseFile(apsLicensePath) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/* tslint:enable */
|
||||
/* eslint-enable */
|
||||
|
||||
function sleep(delay) {
|
||||
const start = new Date().getTime();
|
||||
|
@@ -20,9 +20,9 @@
|
||||
import * as program from 'commander';
|
||||
import moment from 'moment-es6';
|
||||
import { exec } from './exec';
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import { AlfrescoApi } from '@alfresco/js-api';
|
||||
/* tslint:enable */
|
||||
/* eslint-enable */
|
||||
|
||||
import { logger } from './logger';
|
||||
|
||||
@@ -82,8 +82,11 @@ async function deleteDescriptor(args: ConfigArgs, apiService: any, name: string)
|
||||
const pathParams = {};
|
||||
const bodyParam = {};
|
||||
|
||||
const headerParams = {}, formParams = {}, queryParams = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const queryParams = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
return await apiService.oauth2Auth.callCustomApi(url, 'DELETE', pathParams, queryParams, headerParams, formParams, bodyParam, contentTypes, accepts);
|
||||
@@ -100,8 +103,11 @@ async function deleteProject(args: ConfigArgs, apiService: any, projectId: strin
|
||||
const pathParams = {};
|
||||
const bodyParam = {};
|
||||
|
||||
const headerParams = {}, formParams = {}, queryParams = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const queryParams = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
return await apiService.oauth2Auth.callCustomApi(url, 'DELETE', pathParams, queryParams, headerParams, formParams, bodyParam, contentTypes, accepts);
|
||||
@@ -114,9 +120,13 @@ async function deleteProjectByName(args: ConfigArgs, apiService: any, name: stri
|
||||
logger.warn(`Get the project by name ${name}`);
|
||||
const url = `${args.host}/modeling-service/v1/projects?name=${name}`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const queryParams = {};
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
const data = await apiService.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
@@ -136,9 +146,13 @@ async function getApplicationsByName(args: ConfigArgs, apiService: any, name: st
|
||||
logger.warn(`Get the applications by name ${name}`);
|
||||
const url = `${args.host}/deployment-service/v1/applications?name=${name}`;
|
||||
|
||||
const pathParams = {}, queryParams = {},
|
||||
headerParams = {}, formParams = {}, bodyParam = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const queryParams = {};
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
const apps = await apiService.oauth2Auth.callCustomApi(url, 'GET', pathParams, queryParams, headerParams, formParams, bodyParam,
|
||||
@@ -158,8 +172,11 @@ async function undeployApplication(args: ConfigArgs, apiService: any, name: stri
|
||||
const pathParams = {};
|
||||
const bodyParam = {};
|
||||
|
||||
const headerParams = {}, formParams = {}, queryParams = {},
|
||||
contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const queryParams = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
return await apiService.oauth2Auth.callCustomApi(url, 'DELETE', pathParams, queryParams, headerParams, formParams, bodyParam, contentTypes, accepts);
|
||||
@@ -192,7 +209,7 @@ function useContext(args: ConfigArgs) {
|
||||
logger.info(response);
|
||||
}
|
||||
|
||||
export default async function (args: ConfigArgs) {
|
||||
export default async function(args: ConfigArgs) {
|
||||
await main(args);
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,7 @@ function deletePod(args: KubeArgs) {
|
||||
logger.info(response);
|
||||
}
|
||||
|
||||
export default function (args: KubeArgs) {
|
||||
export default function(args: KubeArgs) {
|
||||
main(args);
|
||||
}
|
||||
|
||||
|
@@ -85,7 +85,7 @@ function installPerform() {
|
||||
exec('curl', [`LO`, `${k8sRelease}`], {});
|
||||
}
|
||||
|
||||
export default function (args: KubeArgs) {
|
||||
export default function(args: KubeArgs) {
|
||||
main(args);
|
||||
}
|
||||
|
||||
|
@@ -108,19 +108,19 @@ export default function main(_args: string[], workingDir: string) {
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// tslint:disable-next-line: no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(`Checking ${packagePath}`);
|
||||
|
||||
checker.init({
|
||||
start: workingDir,
|
||||
production: true,
|
||||
failOn: 'GPL'
|
||||
}, function (err: any, packages: any[]) {
|
||||
}, function(err: any, packages: any[]) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
reject(err);
|
||||
} else {
|
||||
// tslint:disable-next-line: forin
|
||||
// eslint-disable-next-line guard-for-in
|
||||
for (const packageName in packages) {
|
||||
const pack = packages[packageName];
|
||||
pack['licenseExp'] = pack['licenses'].toString()
|
||||
@@ -148,7 +148,7 @@ export default function main(_args: string[], workingDir: string) {
|
||||
const packageJson: PackageInfo = getPackageFile(packagePath);
|
||||
|
||||
ejs.renderFile(templatePath, {
|
||||
packages: packages,
|
||||
packages,
|
||||
projVersion: packageJson.version,
|
||||
projName: packageJson.name
|
||||
}, {}, (ejsError: any, mdText: string) => {
|
||||
@@ -160,7 +160,7 @@ export default function main(_args: string[], workingDir: string) {
|
||||
const outputFile = path.join(outputPath, `license-info-${packageJson.version}.md`);
|
||||
|
||||
fs.writeFileSync(outputFile, mdText);
|
||||
// tslint:disable-next-line: no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Report saved as ${outputFile}`);
|
||||
resolve(0);
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
let log = null;
|
||||
|
||||
log = {
|
||||
@@ -31,4 +31,4 @@ log = {
|
||||
};
|
||||
|
||||
export let logger = log;
|
||||
/* tslint:enable */
|
||||
/* eslint-enable */
|
||||
|
@@ -104,7 +104,7 @@ function removeNpmConfig(args: PublishArgs, project: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export default async function (args: PublishArgs) {
|
||||
export default async function(args: PublishArgs) {
|
||||
await main(args);
|
||||
}
|
||||
|
||||
|
@@ -12,13 +12,14 @@ export class PluginConfiguration {
|
||||
}
|
||||
|
||||
async callCustomApi(url: string) {
|
||||
const pathParams = {},
|
||||
headerParams = {},
|
||||
formParams = {},
|
||||
bodyParam = {},
|
||||
queryParams = {},
|
||||
contentTypes = ['application/json'],
|
||||
accepts = ['application/json'];
|
||||
const pathParams = {};
|
||||
const headerParams = {};
|
||||
const formParams = {};
|
||||
const bodyParam = {};
|
||||
const queryParams = {};
|
||||
const contentTypes = ['application/json'];
|
||||
const accepts = ['application/json'];
|
||||
|
||||
try {
|
||||
const response = await this.alfrescoJsApi.oauth2Auth.callCustomApi(
|
||||
url,
|
||||
|
@@ -2,23 +2,28 @@ import { AlfrescoApi, PeopleApi, NodesApi, GroupsApi, SitesApi, SearchApi } from
|
||||
import * as program from 'commander';
|
||||
import { logger } from './logger';
|
||||
|
||||
interface PeopleTally { enabled: number; disabled: number; }
|
||||
interface RowToPrint { label: string; value: number; }
|
||||
interface PeopleTally { enabled: number; disabled: number }
|
||||
interface RowToPrint { label: string; value: number }
|
||||
|
||||
const MAX_ATTEMPTS = 1;
|
||||
const TIMEOUT = 180000;
|
||||
const MAX_PEOPLE_PER_PAGE = 100;
|
||||
const USERS_HOME_RELATIVE_PATH = 'User Homes';
|
||||
|
||||
const reset = '\x1b[0m', grey = '\x1b[90m', cyan = '\x1b[36m', yellow = '\x1b[33m',
|
||||
bright = '\x1b[1m', red = '\x1b[31m', green = '\x1b[32m';
|
||||
const reset = '\x1b[0m';
|
||||
const grey = '\x1b[90m';
|
||||
const cyan = '\x1b[36m';
|
||||
const yellow = '\x1b[33m';
|
||||
const bright = '\x1b[1m';
|
||||
const red = '\x1b[31m';
|
||||
const green = '\x1b[32m';
|
||||
|
||||
let jsApiConnection: any;
|
||||
let loginAttempts: number = 0;
|
||||
|
||||
export default async function main(_args: string[]) {
|
||||
|
||||
// tslint:disable-next-line: no-console
|
||||
// eslint-disable-next-line no-console
|
||||
console.log = () => {};
|
||||
|
||||
program
|
||||
@@ -35,22 +40,19 @@ export default async function main(_args: string[]) {
|
||||
const peopleCount = await getPeopleCount();
|
||||
rowsToPrint.push({ label: 'Active Users', value: peopleCount.enabled });
|
||||
rowsToPrint.push({ label: 'Deactivated Users', value: peopleCount.disabled });
|
||||
rowsToPrint.push({ label: "User's Home Folders", value: await getHomeFoldersCount() });
|
||||
rowsToPrint.push({ label: `User's Home Folders`, value: await getHomeFoldersCount() });
|
||||
rowsToPrint.push({ label: 'Groups', value: await getGroupsCount() });
|
||||
rowsToPrint.push({ label: 'Sites', value: await getSitesCount() });
|
||||
rowsToPrint.push({ label: 'Files', value: await getFilesCount() });
|
||||
|
||||
logger.info(generateTable(rowsToPrint));
|
||||
|
||||
}
|
||||
|
||||
function generateTable(rowsToPrint: Array<RowToPrint>) {
|
||||
const columnWidths = rowsToPrint.reduce((maxWidths, row: RowToPrint) => {
|
||||
return {
|
||||
const columnWidths = rowsToPrint.reduce((maxWidths, row: RowToPrint) => ({
|
||||
labelColumn: Math.max(maxWidths.labelColumn, row.label.length),
|
||||
valueColumn: Math.max(maxWidths.valueColumn, row.value.toString().length)
|
||||
};
|
||||
}, { labelColumn: 12, valueColumn: 1 });
|
||||
}), { labelColumn: 12, valueColumn: 1 });
|
||||
|
||||
const horizontalLine = ''.padEnd(columnWidths.labelColumn + columnWidths.valueColumn + 5, '═');
|
||||
const headerText = 'ENVIRONM'.padStart(Math.floor((columnWidths.labelColumn + columnWidths.valueColumn + 3) / 2), ' ')
|
||||
@@ -134,10 +136,14 @@ async function getPeopleCount(skipCount: number = 0): Promise<PeopleTally> {
|
||||
const apiResult = await peopleApi.listPeople({
|
||||
fields: ['enabled'],
|
||||
maxItems: MAX_PEOPLE_PER_PAGE,
|
||||
skipCount: skipCount
|
||||
skipCount
|
||||
});
|
||||
const result: PeopleTally = apiResult.list.entries.reduce((peopleTally: PeopleTally, currentPerson) => {
|
||||
if (currentPerson.entry.enabled) { peopleTally.enabled++; } else { peopleTally.disabled++; }
|
||||
if (currentPerson.entry.enabled) {
|
||||
peopleTally.enabled++;
|
||||
} else {
|
||||
peopleTally.disabled++;
|
||||
}
|
||||
return peopleTally;
|
||||
}, { enabled: 0, disabled: 0 });
|
||||
if (apiResult.list.pagination.hasMoreItems) {
|
||||
|
@@ -47,7 +47,7 @@ function replacePerform(args: CommitArgs, sha: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export default function (args: CommitArgs) {
|
||||
export default function(args: CommitArgs) {
|
||||
main(args);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user