fixed script errors & added tests
This commit is contained in:
@@ -1,20 +1,20 @@
|
|||||||
import { Category } from '../../domain/Category';
|
import { Category } from '../../domain/Category';
|
||||||
import { Application } from '../../domain/Application';
|
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';
|
import { parseCategory } from './CategoryParser';
|
||||||
|
|
||||||
export function parseApplication(): Application {
|
export function parseApplication(content: ApplicationYaml): Application {
|
||||||
const categories = new Array<Category>();
|
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');
|
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);
|
const category = parseCategory(action);
|
||||||
categories.push(category);
|
categories.push(category);
|
||||||
}
|
}
|
||||||
const app = new Application(
|
const app = new Application(
|
||||||
applicationFile.name,
|
content.name,
|
||||||
applicationFile.repositoryUrl,
|
content.repositoryUrl,
|
||||||
process.env.VUE_APP_VERSION,
|
process.env.VUE_APP_VERSION,
|
||||||
categories);
|
categories);
|
||||||
return app;
|
return app;
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ import { IUserFilter } from './Filter/IUserFilter';
|
|||||||
import { ApplicationCode } from './Code/ApplicationCode';
|
import { ApplicationCode } from './Code/ApplicationCode';
|
||||||
import { UserSelection } from './Selection/UserSelection';
|
import { UserSelection } from './Selection/UserSelection';
|
||||||
import { IUserSelection } from './Selection/IUserSelection';
|
import { IUserSelection } from './Selection/IUserSelection';
|
||||||
import { AsyncLazy } from '../../infrastructure/Threading/AsyncLazy';
|
import { AsyncLazy } from '@/infrastructure/Threading/AsyncLazy';
|
||||||
import { Signal } from '../../infrastructure/Events/Signal';
|
import { Signal } from '@/infrastructure/Events/Signal';
|
||||||
import { parseApplication } from '../Parser/ApplicationParser';
|
import { parseApplication } from '../Parser/ApplicationParser';
|
||||||
import { IApplicationState } from './IApplicationState';
|
import { IApplicationState } from './IApplicationState';
|
||||||
import { Script } from '../../domain/Script';
|
import { Script } from '@/domain/Script';
|
||||||
import { Application } from '../../domain/Application';
|
import { Application } from '@/domain/Application';
|
||||||
import { IApplicationCode } from './Code/IApplicationCode';
|
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 */
|
/** Mutatable singleton application state that's the single source of truth throughout the application */
|
||||||
export class ApplicationState implements IApplicationState {
|
export class ApplicationState implements IApplicationState {
|
||||||
@@ -20,7 +21,7 @@ export class ApplicationState implements IApplicationState {
|
|||||||
|
|
||||||
/** Application instance with all scripts. */
|
/** Application instance with all scripts. */
|
||||||
private static instance = new AsyncLazy<IApplicationState>(() => {
|
private static instance = new AsyncLazy<IApplicationState>(() => {
|
||||||
const application = parseApplication();
|
const application = parseApplication(applicationFile);
|
||||||
const selectedScripts = new Array<Script>();
|
const selectedScripts = new Array<Script>();
|
||||||
const state = new ApplicationState(application, selectedScripts);
|
const state = new ApplicationState(application, selectedScripts);
|
||||||
return Promise.resolve(state);
|
return Promise.resolve(state);
|
||||||
|
|||||||
@@ -304,14 +304,9 @@ actions:
|
|||||||
SET /A dps_service_running=1
|
SET /A dps_service_running=1
|
||||||
net stop DPS
|
net stop DPS
|
||||||
)
|
)
|
||||||
|
|
||||||
REM del /F /S /Q /A "%windir%\System32\sru*"
|
REM del /F /S /Q /A "%windir%\System32\sru*"
|
||||||
|
|
||||||
IF !dps_service_running! == 1 (
|
IF !dps_service_running! == 1 (
|
||||||
echo "Was running"
|
|
||||||
net start DPS
|
net start DPS
|
||||||
) ELSE (
|
|
||||||
echo "Was not running"
|
|
||||||
)
|
)
|
||||||
endlocal
|
endlocal
|
||||||
|
|
||||||
@@ -1146,7 +1141,7 @@ actions:
|
|||||||
-
|
-
|
||||||
name: Disable Windows Defender
|
name: Disable Windows Defender
|
||||||
recommend: false
|
recommend: false
|
||||||
code: |
|
code: |-
|
||||||
netsh advfirewall set allprofiles state off
|
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\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
|
reg add "HKLM\SYSTEM\CurrentControlSet\Services\MpsSvc" /v "Start" /t REG_DWORD /d 4 /f
|
||||||
|
|||||||
2
src/application/application.yaml.d.ts
vendored
2
src/application/application.yaml.d.ts
vendored
@@ -17,7 +17,7 @@ declare module 'js-yaml-loader!*' {
|
|||||||
category: string;
|
category: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ApplicationYaml {
|
export interface ApplicationYaml {
|
||||||
name: string;
|
name: string;
|
||||||
repositoryUrl: string;
|
repositoryUrl: string;
|
||||||
actions: ReadonlyArray<YamlCategory>;
|
actions: ReadonlyArray<YamlCategory>;
|
||||||
|
|||||||
12
tests/unit/application/Parser/ApplicationParser.spec.ts
Normal file
12
tests/unit/application/Parser/ApplicationParser.spec.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import applicationFile from 'js-yaml-loader!@/application/application.yaml';
|
||||||
|
import { parseApplication } from '@/application/Parser/ApplicationParser';
|
||||||
|
import 'mocha';
|
||||||
|
import { expect } from 'chai';
|
||||||
|
|
||||||
|
describe('ApplicationParser', () => {
|
||||||
|
describe('parseApplication', () => {
|
||||||
|
it('can parse current application file', () => {
|
||||||
|
expect(() => parseApplication(applicationFile)).to.not.throw();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user