From b76ec4a3464f88a8243c27b5f046419d1c2927d9 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Sun, 28 Jul 2019 14:28:38 -0400 Subject: [PATCH] Added model files, tslint. Model files will likely be externalized to its own 'spec' project when the rest of the project is rewritten in typescript. That module will likely contain processing utilities. --- src/index.ts | 7 +++- src/model/artifact.ts | 25 ++++++++++++ src/model/distribution.ts | 35 +++++++++++++++++ src/model/module.ts | 50 ++++++++++++++++++++++++ src/model/required.ts | 14 +++++++ src/model/server.ts | 81 +++++++++++++++++++++++++++++++++++++++ tslint.json | 37 ++++++++++++++++++ 7 files changed, 247 insertions(+), 2 deletions(-) create mode 100644 src/model/artifact.ts create mode 100644 src/model/distribution.ts create mode 100644 src/model/module.ts create mode 100644 src/model/required.ts create mode 100644 src/model/server.ts create mode 100644 tslint.json diff --git a/src/index.ts b/src/index.ts index efa9439..beac586 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,9 @@ -import yargs from 'yargs' +/* tslint:disable:no-shadowed-variable */ import { resolve } from 'path' +import yargs from 'yargs' +// Registering yargs configuration. +// tslint:disable-next-line:no-unused-expression yargs .scriptName('') .coerce({ @@ -22,4 +25,4 @@ yargs }) .demandCommand() .help() -.argv \ No newline at end of file +.argv diff --git a/src/model/artifact.ts b/src/model/artifact.ts new file mode 100644 index 0000000..910e968 --- /dev/null +++ b/src/model/artifact.ts @@ -0,0 +1,25 @@ +export interface Artifact { + + /** + * The size of the artifact. + */ + size: number + + /** + * The MD5 hash of the artifact. This will be used to validate local artifacts. + */ + MD5: string + + /** + * The artifact's download url. + */ + url: string + + /** + * A relative path to where the file will be saved. This is appended to the base + * path for the module's declared type. + * If this is not specified, the path will be resolved based on the module's ID. + */ + path?: string + +} diff --git a/src/model/distribution.ts b/src/model/distribution.ts new file mode 100644 index 0000000..44c5a02 --- /dev/null +++ b/src/model/distribution.ts @@ -0,0 +1,35 @@ +import { Server } from './server' + +export interface Distribution { + + version: string + + /** + * Global settings for Discord Rich Presence. + */ + discord: { + /** + * Client ID for the Application registered with Discord. + */ + clientId: string, + /** + * Tootltip for the smallImageKey. + */ + smallImageText: string, + /** + * Name of the uploaded image for the small profile artwork. + */ + smallImageKey: string + } + + /** + * A URL to a RSS feed. Used for loading news. + */ + rss: string + + /** + * Array of server objects. + */ + servers: Server[] + +} diff --git a/src/model/module.ts b/src/model/module.ts new file mode 100644 index 0000000..a895d41 --- /dev/null +++ b/src/model/module.ts @@ -0,0 +1,50 @@ +import { Artifact } from './artifact' +import { Required } from './required' + +export interface Module { + + /** + * The ID of the module. All modules that are not of type File MUST use a maven identifier. + * Version information and other metadata is pulled from the identifier. Modules which are + * stored maven style use the identifier to resolve the destination path. If the extension + * is not provided, it defaults to jar. + * + * Template + * + * my.group:arifact:version@extension + * + * my/group/artifact/version/artifact-version.extension + * + * If the module's artifact does not declare the path property, its path will be resolved from the ID. + */ + id: string + + /** + * The name of the module. Used on the UI. + */ + name: string + + /** + * The type of the module. + */ + type: string + + /** + * Defines whether or not the module is required. If omitted, then the module will be required. + */ + required?: Required + + /** + * The download artifact for the module. + */ + artifact: Artifact + + /** + * An array of sub modules declared by this module. Typically, files which require other files + * are declared as submodules. A quick example would be a mod, and the configuration file for + * that mod. Submodules can also declare submodules of their own. The file is parsed recursively, + * so there is no limit. + */ + subModules?: Module[] + +} diff --git a/src/model/required.ts b/src/model/required.ts new file mode 100644 index 0000000..e16d385 --- /dev/null +++ b/src/model/required.ts @@ -0,0 +1,14 @@ +export interface Required { + + /** + * If the module is required. Defaults to true if this property is omited. + */ + value?: boolean + + /** + * If the module is enabled by default. Has no effect unless Required.value + * is false. Defaults to true if this property is omited. + */ + def?: boolean + +} diff --git a/src/model/server.ts b/src/model/server.ts new file mode 100644 index 0000000..58eca80 --- /dev/null +++ b/src/model/server.ts @@ -0,0 +1,81 @@ +import { Module } from './module' + +export interface Server { + + /** + * The ID of the server. The launcher saves mod configurations and selected servers + * by ID. If the ID changes, all data related to the old ID will be wiped. + */ + id: string + + /** + * The name of the server. This is what users see on the UI. + */ + name: string + + /** + * A brief description of the server. Displayed on the UI to provide users more information. + */ + description: string + + /** + * A URL to the server's icon. Will be displayed on the UI. + */ + icon: string + + /** + * The version of the server configuration. + */ + version: string + + /** + * The server's IP address. + */ + address: string + + /** + * The version of minecraft that the server is running. + */ + minecraftVersion: string + + /** + * Server specific settings used for Discord Rich Presence. + */ + discord: { + /** + * Short ID for the server. Displayed on the second status line as Server: shortId. + */ + shortId: string, + /** + * Ttooltip for the largeImageKey. + */ + largeImageText: string + /** + * Name of the uploaded image for the large profile artwork. + */ + largeImageKey: string + } + + /** + * Only one server in the array should have the mainServer property enabled. This + * will tell the launcher that this is the default server to select if either the + * previously selected server is invalid, or there is no previously selected server. + * If this field is not defined by any server (avoid this), the first server will + * be selected as the default. If multiple servers have mainServer enabled, the first + * one the launcher finds will be the effective value. Servers which are not the default + * may omit this property rather than explicitly setting it to false. + */ + mainServer?: boolean + + /** + * Whether or not the server can be autoconnected to. If false, the server will + * not be autoconnected to even when the user has the autoconnect setting enabled. + */ + autoconnect: boolean + + /** + * An array of module objects. + */ + modules: Module[] + +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..e6e96f1 --- /dev/null +++ b/tslint.json @@ -0,0 +1,37 @@ +{ + "extends": "tslint:latest", + "rules": { + "semicolon": [ + true, + "never" + ], + "quotemark": [ + true, + "single" + ], + "trailing-comma": [ + true, + { + "multiline": "never", + "singleline": "never" + } + ], + "triple-equals": [ + true, + "allow-null-check", + "allow-undefined-check" + ], + "no-console": [ + false + ], + "no-string-literal": [ + false + ], + "prefer-conditional-expression": [ + false + ], + "no-var-requires": false, + "object-literal-sort-keys": false, + "interface-name": [true, "never-prefix"] + } + } \ No newline at end of file