refactor to read more from package.json
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { OperatingSystem } from '../OperatingSystem';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
import { DetectorBuilder } from './DetectorBuilder';
|
||||
import { IBrowserOsDetector } from './IBrowserOsDetector';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IBrowserOsDetector } from './IBrowserOsDetector';
|
||||
import { OperatingSystem } from '../OperatingSystem';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
|
||||
export class DetectorBuilder {
|
||||
private readonly existingPartsInUserAgent = new Array<string>();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { OperatingSystem } from '../OperatingSystem';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
|
||||
export interface IBrowserOsDetector {
|
||||
detect(userAgent: string): OperatingSystem;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BrowserOsDetector } from './BrowserOs/BrowserOsDetector';
|
||||
import { IBrowserOsDetector } from './BrowserOs/IBrowserOsDetector';
|
||||
import { IEnvironment } from './IEnvironment';
|
||||
import { OperatingSystem } from './OperatingSystem';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
|
||||
interface IEnvironmentVariables {
|
||||
readonly window: Window & typeof globalThis;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { OperatingSystem } from './OperatingSystem';
|
||||
import { OperatingSystem } from '@/domain/OperatingSystem';
|
||||
|
||||
export interface IEnvironment {
|
||||
isDesktop: boolean;
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
export enum OperatingSystem {
|
||||
macOS,
|
||||
Windows,
|
||||
Linux,
|
||||
KaiOS,
|
||||
ChromeOS,
|
||||
BlackBerryOS,
|
||||
BlackBerry,
|
||||
BlackBerryTabletOS,
|
||||
Android,
|
||||
iOS,
|
||||
WindowsPhone,
|
||||
Unknown,
|
||||
}
|
||||
@@ -1,24 +1,35 @@
|
||||
import { Category } from '@/domain/Category';
|
||||
import { Application } from '@/domain/Application';
|
||||
import { IApplication } from '@/domain/IApplication';
|
||||
import { IProjectInformation } from '@/domain/IProjectInformation';
|
||||
import { ApplicationYaml } from 'js-yaml-loader!./../application.yaml';
|
||||
import { parseCategory } from './CategoryParser';
|
||||
import { ProjectInformation } from '../../domain/ProjectInformation';
|
||||
|
||||
export function parseApplication(content: ApplicationYaml): IApplication {
|
||||
|
||||
export function parseApplication(content: ApplicationYaml, env: NodeJS.ProcessEnv = process.env): IApplication {
|
||||
validate(content);
|
||||
const categories = new Array<Category>();
|
||||
for (const action of content.actions) {
|
||||
const category = parseCategory(action);
|
||||
categories.push(category);
|
||||
}
|
||||
const info = readAppInformation(env);
|
||||
const app = new Application(
|
||||
content.name,
|
||||
content.repositoryUrl,
|
||||
process.env.VUE_APP_VERSION,
|
||||
info,
|
||||
categories);
|
||||
return app;
|
||||
}
|
||||
|
||||
function readAppInformation(environment): IProjectInformation {
|
||||
return new ProjectInformation(
|
||||
environment.VUE_APP_NAME,
|
||||
environment.VUE_APP_VERSION,
|
||||
environment.VUE_APP_REPOSITORY_URL,
|
||||
environment.VUE_APP_HOMEPAGE_URL,
|
||||
);
|
||||
}
|
||||
|
||||
function validate(content: ApplicationYaml): void {
|
||||
if (!content) {
|
||||
throw new Error('application is null or undefined');
|
||||
|
||||
@@ -39,7 +39,7 @@ export class ApplicationState implements IApplicationState {
|
||||
/** Initially selected scripts */
|
||||
public readonly defaultScripts: Script[]) {
|
||||
this.selection = new UserSelection(app, defaultScripts.map((script) => new SelectedScript(script, false)));
|
||||
this.code = new ApplicationCode(this.selection, app.version);
|
||||
this.code = new ApplicationCode(this.selection, app.info.version);
|
||||
this.filter = new UserFilter(app);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
# Structure documented in "./application.yaml.d.ts" (as code)
|
||||
name: privacy.sexy
|
||||
repositoryUrl: https://github.com/undergroundwires/privacy.sexy
|
||||
actions:
|
||||
-
|
||||
category: Privacy cleanup
|
||||
|
||||
2
src/application/application.yaml.d.ts
vendored
2
src/application/application.yaml.d.ts
vendored
@@ -19,8 +19,6 @@ declare module 'js-yaml-loader!*' {
|
||||
}
|
||||
|
||||
export interface ApplicationYaml {
|
||||
name: string;
|
||||
repositoryUrl: string;
|
||||
actions: ReadonlyArray<YamlCategory>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user