remove old logger implementation and deps (#2495)

* remove old logger implementation and deps

* remove logger.js
This commit is contained in:
Denys Vuika
2022-04-11 10:05:01 +01:00
committed by GitHub
parent bacd9e5c10
commit 32bb39cf9c
10 changed files with 1 additions and 808 deletions

View File

@@ -1,55 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ParamType } from './params';
export type CommanderProcessor = (arg1: any, arg2: any) => void;
export type CommanderOptionParams = [string, string, CommanderProcessor?, any?];
export interface BaseParamOptions {
name: string;
alias: string;
title: string;
required: boolean;
processor?: CommanderProcessor;
default?: any;
}
export abstract class BaseParam {
protected type: ParamType;
constructor(protected options: BaseParamOptions) {}
abstract get commanderOption(): CommanderOptionParams;
abstract get inquirerOption(): any;
get isRequired() {
return this.options.required;
}
get name() {
return this.options.name;
}
}

View File

@@ -1,57 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ParamType } from './params';
import { CommanderOptionParams, BaseParam } from './base-param';
export class BooleanParam extends BaseParam {
protected type = ParamType.confirm;
get commanderOption(): CommanderOptionParams {
const optionParams: CommanderOptionParams = [`-${this.options.alias}, --${this.options.name}`, this.options.title];
if (this.options.processor !== undefined) {
optionParams.push(this.options.processor);
} else {
optionParams.push((value, previousValue) => {
return value !== undefined ? !!value : previousValue;
});
}
if (this.options.default !== undefined) {
optionParams.push(this.options.default);
}
return optionParams;
}
get inquirerOption() {
return {
type: this.type,
name: this.options.name,
message: this.options.title
};
}
}

View File

@@ -1,75 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ParamType } from './params';
import { BaseParamOptions, CommanderOptionParams, BaseParam } from './base-param';
export interface ComplexCheckboxChoice {
name: string;
value?: any;
checked?: boolean;
short?: string;
}
export interface ChekboxParamOptions extends BaseParamOptions {
choices: string[] | ComplexCheckboxChoice[];
default?: any[];
}
export class CheckboxParam extends BaseParam {
protected type = ParamType.checkbox;
constructor(protected options: ChekboxParamOptions) {
super(options);
}
get commanderOption(): CommanderOptionParams {
const optionParams: CommanderOptionParams = [`-${this.options.alias}, --${this.options.name} <${this.options.name}>`, this.options.title];
if (this.options.processor !== undefined) {
optionParams.push(this.options.processor);
} else {
optionParams.push((value, previousValue) => {
return value !== undefined ? value.split(',') : previousValue;
});
}
if (this.options.default !== undefined) {
optionParams.push(this.options.default);
}
return optionParams;
}
get inquirerOption() {
return {
type: this.type,
name: this.options.name,
message: this.options.title,
choices: this.options.choices,
default: this.options.default
};
}
}

View File

@@ -1,72 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import commander, { program } from 'commander';
import * as inquirer from 'inquirer';
import { BooleanParam } from './boolean-param';
import { InputParam } from './input-param';
import { ListParam } from './list-param';
import { CheckboxParam } from './checkbox-param';
import * as logger from '../../tools/helpers/logger';
export type CliParam = ListParam | InputParam | BooleanParam | CheckboxParam;
export class CliReader {
private program: commander.Command;
constructor(name: string, usage: string, description: string, version: string) {
this.program = program;
this.program
.name(name)
.usage(usage)
.description(description)
.version(version)
.option('-d, --debug <level>', 'Set the output information level (silly, debug, verbose, info, warn, error)', 'info');
}
*getReader(params: CliParam[], cliArgs: string[]): Generator {
params.forEach((param) => {
program.option.apply(this.program, param.commanderOption);
});
this.program.parse(cliArgs);
logger.level = this.program.debug;
const commanderParams = params
.filter((param) => this.program[param.name] !== undefined)
.reduce((paramsAcc, param) => ({ ...paramsAcc, [param.name]: this.program[param.name] }), {});
yield commanderParams;
let unsetRequiredParams;
if (Object.keys(commanderParams).length) {
unsetRequiredParams = params.filter((param) => param.isRequired && this.program[param.name] === undefined).map((param) => param.inquirerOption);
} else {
unsetRequiredParams = params.map((param) => param.inquirerOption);
}
return yield inquirer.prompt(unsetRequiredParams).then((inquiredParams) => ({ ...commanderParams, ...inquiredParams }));
}
}

View File

@@ -1,53 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ParamType } from './params';
import { BaseParam, CommanderOptionParams } from './base-param';
export class InputParam extends BaseParam {
protected type = ParamType.input;
get commanderOption(): CommanderOptionParams {
const optionParams: CommanderOptionParams = [`-${this.options.alias}, --${this.options.name} <${this.options.name}>`, this.options.title];
if (this.options.processor !== undefined) {
optionParams.push(this.options.processor);
}
if (this.options.default !== undefined) {
optionParams.push(this.options.default);
}
return optionParams;
}
get inquirerOption() {
return {
type: this.type,
name: this.options.name,
message: this.options.title
};
}
}

View File

@@ -1,71 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ParamType } from './params';
import { BaseParamOptions, CommanderOptionParams, BaseParam } from './base-param';
export interface ComplexListChoice {
name: string;
value?: any;
disabled?: boolean;
short?: string;
}
export interface ListParamOptions extends BaseParamOptions {
choices: string[] | ComplexListChoice[];
pageSize?: number;
}
export class ListParam extends BaseParam {
protected type = ParamType.list;
constructor(protected options: ListParamOptions) {
super(options);
}
get commanderOption(): CommanderOptionParams {
const optionParams: CommanderOptionParams = [`-${this.options.alias}, --${this.options.name} <${this.options.name}>`, this.options.title];
if (this.options.processor !== undefined) {
optionParams.push(this.options.processor);
}
if (this.options.default !== undefined) {
optionParams.push(this.options.default);
}
return optionParams;
}
get inquirerOption() {
return {
type: this.type,
name: this.options.name,
message: this.options.title,
choices: this.options.choices,
pageSize: this.options.pageSize
};
}
}

View File

@@ -1,31 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2020 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
export enum ParamType {
input = 'input',
list = 'list',
checkbox = 'checkbox',
confirm = 'confirm'
}