typo fixes + whitespace refactorings
This commit is contained in:
@@ -26,8 +26,9 @@ export class ApplicationParser {
|
||||
categories.push(category);
|
||||
}
|
||||
const app = new Application(name, version, categories);
|
||||
return {application: app, selectedScripts};
|
||||
return { application: app, selectedScripts };
|
||||
}
|
||||
|
||||
private static categoryIdCounter = 0;
|
||||
|
||||
private static parseCategory(category: YamlCategory, selectedScripts: Script[]): Category {
|
||||
@@ -43,9 +44,12 @@ export class ApplicationParser {
|
||||
} else if (ApplicationParser.isScript(categoryOrScript)) {
|
||||
const yamlScript = categoryOrScript as YamlScript;
|
||||
const script = new Script(
|
||||
/* name */ yamlScript.name,
|
||||
/* code */ yamlScript.code,
|
||||
/* docs */ this.parseDocUrls(yamlScript));
|
||||
/* name */
|
||||
yamlScript.name,
|
||||
/* code */
|
||||
yamlScript.code,
|
||||
/* docs */
|
||||
this.parseDocUrls(yamlScript));
|
||||
subScripts.push(script);
|
||||
if (yamlScript.default === true) {
|
||||
selectedScripts.push(script);
|
||||
@@ -56,11 +60,16 @@ export class ApplicationParser {
|
||||
}
|
||||
}
|
||||
return new Category(
|
||||
/*id*/ ApplicationParser.categoryIdCounter++,
|
||||
/*name*/ category.category,
|
||||
/*docs*/ this.parseDocUrls(category),
|
||||
/*categories*/ subCategories,
|
||||
/*scripts*/ subScripts,
|
||||
/*id*/
|
||||
ApplicationParser.categoryIdCounter++,
|
||||
/*name*/
|
||||
category.category,
|
||||
/*docs*/
|
||||
this.parseDocUrls(category),
|
||||
/*categories*/
|
||||
subCategories,
|
||||
/*scripts*/
|
||||
subScripts,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -97,6 +106,7 @@ export class ApplicationParser {
|
||||
private static isScript(categoryOrScript: any): boolean {
|
||||
return categoryOrScript.code && categoryOrScript.code.length > 0;
|
||||
}
|
||||
|
||||
private static isCategory(categoryOrScript: any): boolean {
|
||||
return categoryOrScript.category && categoryOrScript.category.length > 0;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import { IApplicationCode } from './Code/IApplicationCode';
|
||||
export class ApplicationState implements IApplicationState {
|
||||
/** Get singleton application state */
|
||||
public static GetAsync(): Promise<IApplicationState> {
|
||||
return ApplicationState.instance.getValueAsync();
|
||||
return ApplicationState.instance.getValueAsync();
|
||||
}
|
||||
|
||||
/** Application instance with all scripts. */
|
||||
@@ -36,10 +36,10 @@ export class ApplicationState implements IApplicationState {
|
||||
private readonly app: Application,
|
||||
/** Initially selected scripts */
|
||||
public readonly defaultScripts: Script[]) {
|
||||
this.selection = new UserSelection(app, defaultScripts);
|
||||
this.code = new ApplicationCode(this.selection, app.version.toString());
|
||||
this.filter = new UserFilter(app);
|
||||
}
|
||||
this.selection = new UserSelection(app, defaultScripts);
|
||||
this.code = new ApplicationCode(this.selection, app.version.toString());
|
||||
this.filter = new UserFilter(app);
|
||||
}
|
||||
|
||||
public getCategory(categoryId: number): ICategory | undefined {
|
||||
return this.app.findCategory(categoryId);
|
||||
|
||||
@@ -2,17 +2,19 @@ import { FunctionRenderer } from './FunctionRenderer';
|
||||
|
||||
export class AdminRightsFunctionRenderer {
|
||||
private readonly functionRenderer: FunctionRenderer;
|
||||
|
||||
constructor() {
|
||||
this.functionRenderer = new FunctionRenderer();
|
||||
}
|
||||
|
||||
public renderAdminRightsFunction() {
|
||||
const name = 'Ensure admin priviliges';
|
||||
const name = 'Ensure admin privileges';
|
||||
const code = 'fltmc >nul 2>&1 || (\n' +
|
||||
' echo This batch script requires administrator privileges. Right-click on\n' +
|
||||
' echo the script and select "Run as administrator".\n' +
|
||||
' pause\n' +
|
||||
' exit 1\n' +
|
||||
')';
|
||||
' echo This batch script requires administrator privileges. Right-click on\n' +
|
||||
' echo the script and select "Run as administrator".\n' +
|
||||
' pause\n' +
|
||||
' exit 1\n' +
|
||||
')';
|
||||
return this.functionRenderer.renderFunction(name, code);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,17 @@ import { CodeRenderer } from './CodeRenderer';
|
||||
|
||||
export class AsciiArtRenderer extends CodeRenderer {
|
||||
public renderAsciiArt(version: string): string {
|
||||
if (!version) { throw new Error('Version is not defined'); }
|
||||
if (!version) {
|
||||
throw new Error('Version is not defined');
|
||||
}
|
||||
return (
|
||||
'██████╗ ██████╗ ██╗██╗ ██╗ █████╗ ██████╗██╗ ██╗███████╗███████╗██╗ ██╗██╗ ██╗\n' +
|
||||
'██╔══██╗██╔══██╗██║██║ ██║██╔══██╗██╔════╝╚██╗ ██╔╝██╔════╝██╔════╝╚██╗██╔╝╚██╗ ██╔╝\n' +
|
||||
'██████╔╝██████╔╝██║██║ ██║███████║██║ ╚████╔╝ ███████╗█████╗ ╚███╔╝ ╚████╔╝ \n' +
|
||||
'██╔═══╝ ██╔══██╗██║╚██╗ ██╔╝██╔══██║██║ ╚██╔╝ ╚════██║██╔══╝ ██╔██╗ ╚██╔╝ \n' +
|
||||
'██║ ██║ ██║██║ ╚████╔╝ ██║ ██║╚██████╗ ██║██╗███████║███████╗██╔╝ ██╗ ██║ \n' +
|
||||
'╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ')
|
||||
.split('\n').map((line) => this.renderComment(line)).join('\n')
|
||||
+ `\n${this.renderComment(`https://privacy.sexy — v${version} — ${new Date().toUTCString()}`)}`;
|
||||
'██████╗ ██████╗ ██╗██╗ ██╗ █████╗ ██████╗██╗ ██╗███████╗███████╗██╗ ██╗██╗ ██╗\n' +
|
||||
'██╔══██╗██╔══██╗██║██║ ██║██╔══██╗██╔════╝╚██╗ ██╔╝██╔════╝██╔════╝╚██╗██╔╝╚██╗ ██╔╝\n' +
|
||||
'██████╔╝██████╔╝██║██║ ██║███████║██║ ╚████╔╝ ███████╗█████╗ ╚███╔╝ ╚████╔╝ \n' +
|
||||
'██╔═══╝ ██╔══██╗██║╚██╗ ██╔╝██╔══██║██║ ╚██╔╝ ╚════██║██╔══╝ ██╔██╗ ╚██╔╝ \n' +
|
||||
'██║ ██║ ██║██║ ╚████╔╝ ██║ ██║╚██████╗ ██║██╗███████║███████╗██╔╝ ██╗ ██║ \n' +
|
||||
'╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ')
|
||||
.split('\n').map((line) => this.renderComment(line)).join('\n') +
|
||||
`\n${this.renderComment(`https://privacy.sexy — v${version} — ${new Date().toUTCString()}`)}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ export class FunctionRenderer extends CodeRenderer {
|
||||
}
|
||||
|
||||
private renderFunctionName(functionName: string) {
|
||||
const autoFirstHypens = '-'.repeat(Math.floor((this.totalFunctionSeparatorChars - functionName.length) / 2));
|
||||
const secondHypens = '-'.repeat(Math.ceil((this.totalFunctionSeparatorChars - functionName.length) / 2));
|
||||
return `${this.renderComment()}${autoFirstHypens}${functionName}${secondHypens}`;
|
||||
const firstHyphens = '-'.repeat(Math.floor((this.totalFunctionSeparatorChars - functionName.length) / 2));
|
||||
const secondHyphens = '-'.repeat(Math.ceil((this.totalFunctionSeparatorChars - functionName.length) / 2));
|
||||
return `${this.renderComment()}${firstHyphens}${functionName}${secondHyphens}`;
|
||||
}
|
||||
|
||||
private renderFunctionEndComment(): string {
|
||||
|
||||
@@ -16,8 +16,8 @@ export class UserFilter implements IUserFilter {
|
||||
throw new Error('Filter must be defined and not empty. Use removeFilter() to remove the filter');
|
||||
}
|
||||
const filteredScripts = this.application.getAllScripts().filter(
|
||||
(script) => script.name.toLowerCase().includes(filter.toLowerCase())
|
||||
|| script.code.toLowerCase().includes(filter.toLowerCase()));
|
||||
(script) => script.name.toLowerCase().includes(filter.toLowerCase()) ||
|
||||
script.code.toLowerCase().includes(filter.toLowerCase()));
|
||||
|
||||
const matches: IFilterMatches = {
|
||||
scriptMatches: filteredScripts,
|
||||
|
||||
@@ -18,4 +18,3 @@ export interface IApplicationState {
|
||||
readonly defaultScripts: ReadonlyArray<IScript>;
|
||||
getCategory(categoryId: number): ICategory | undefined;
|
||||
}
|
||||
|
||||
|
||||
5
src/application/application.yaml.d.ts
vendored
5
src/application/application.yaml.d.ts
vendored
@@ -1,23 +1,28 @@
|
||||
declare module 'js-yaml-loader!*' {
|
||||
type CategoryOrScript = YamlCategory | YamlScript;
|
||||
type DocumentationUrls = ReadonlyArray<string> | string;
|
||||
|
||||
export interface YamlDocumentable {
|
||||
docs?: DocumentationUrls;
|
||||
}
|
||||
|
||||
export interface YamlScript extends YamlDocumentable {
|
||||
name: string;
|
||||
code: string;
|
||||
default: boolean;
|
||||
}
|
||||
|
||||
export interface YamlCategory extends YamlDocumentable {
|
||||
children: ReadonlyArray<CategoryOrScript>;
|
||||
category: string;
|
||||
}
|
||||
|
||||
interface ApplicationYaml {
|
||||
name: string;
|
||||
version: number;
|
||||
actions: ReadonlyArray<YamlCategory>;
|
||||
}
|
||||
|
||||
const content: ApplicationYaml;
|
||||
export default content;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user