fixed script errors & added tests
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
interface ApplicationYaml {
|
||||
export interface ApplicationYaml {
|
||||
name: string;
|
||||
repositoryUrl: string;
|
||||
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