fixed script errors & added tests

This commit is contained in:
undergroundwires
2020-07-15 03:18:38 +01:00
parent 646a8e0b9f
commit 9e722ddfb3
5 changed files with 26 additions and 18 deletions

View File

@@ -1,20 +1,20 @@
import { Category } from '../../domain/Category';
import { Application } from '../../domain/Application';
import applicationFile from 'js-yaml-loader!./../application.yaml';
import { ApplicationYaml } from 'js-yaml-loader!./../application.yaml';
import { parseCategory } from './CategoryParser';
export function parseApplication(): Application {
export function parseApplication(content: ApplicationYaml): Application {
const categories = new Array<Category>();
if (!applicationFile.actions || applicationFile.actions.length <= 0) {
if (!content.actions || content.actions.length <= 0) {
throw new Error('Application does not define any action');
}
for (const action of applicationFile.actions) {
for (const action of content.actions) {
const category = parseCategory(action);
categories.push(category);
}
const app = new Application(
applicationFile.name,
applicationFile.repositoryUrl,
content.name,
content.repositoryUrl,
process.env.VUE_APP_VERSION,
categories);
return app;

View File

@@ -3,13 +3,14 @@ import { IUserFilter } from './Filter/IUserFilter';
import { ApplicationCode } from './Code/ApplicationCode';
import { UserSelection } from './Selection/UserSelection';
import { IUserSelection } from './Selection/IUserSelection';
import { AsyncLazy } from '../../infrastructure/Threading/AsyncLazy';
import { Signal } from '../../infrastructure/Events/Signal';
import { AsyncLazy } from '@/infrastructure/Threading/AsyncLazy';
import { Signal } from '@/infrastructure/Events/Signal';
import { parseApplication } from '../Parser/ApplicationParser';
import { IApplicationState } from './IApplicationState';
import { Script } from '../../domain/Script';
import { Application } from '../../domain/Application';
import { Script } from '@/domain/Script';
import { Application } from '@/domain/Application';
import { IApplicationCode } from './Code/IApplicationCode';
import applicationFile from 'js-yaml-loader!@/application/application.yaml';
/** Mutatable singleton application state that's the single source of truth throughout the application */
export class ApplicationState implements IApplicationState {
@@ -20,7 +21,7 @@ export class ApplicationState implements IApplicationState {
/** Application instance with all scripts. */
private static instance = new AsyncLazy<IApplicationState>(() => {
const application = parseApplication();
const application = parseApplication(applicationFile);
const selectedScripts = new Array<Script>();
const state = new ApplicationState(application, selectedScripts);
return Promise.resolve(state);

View File

@@ -304,14 +304,9 @@ actions:
SET /A dps_service_running=1
net stop DPS
)
REM del /F /S /Q /A "%windir%\System32\sru*"
IF !dps_service_running! == 1 (
echo "Was running"
net start DPS
) ELSE (
echo "Was not running"
)
endlocal
@@ -1146,7 +1141,7 @@ actions:
-
name: Disable Windows Defender
recommend: false
code: |
code: |-
netsh advfirewall set allprofiles state off
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /t REG_DWORD /d 1 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\MpsSvc" /v "Start" /t REG_DWORD /d 4 /f

View File

@@ -17,7 +17,7 @@ declare module 'js-yaml-loader!*' {
category: string;
}
interface ApplicationYaml {
export interface ApplicationYaml {
name: string;
repositoryUrl: string;
actions: ReadonlyArray<YamlCategory>;