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.
This commit is contained in:
Daniel Scalzi
2019-07-28 14:28:38 -04:00
parent 68e09fbac7
commit b76ec4a346
7 changed files with 247 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
import yargs from 'yargs' /* tslint:disable:no-shadowed-variable */
import { resolve } from 'path' import { resolve } from 'path'
import yargs from 'yargs'
// Registering yargs configuration.
// tslint:disable-next-line:no-unused-expression
yargs yargs
.scriptName('') .scriptName('')
.coerce({ .coerce({
@@ -22,4 +25,4 @@ yargs
}) })
.demandCommand() .demandCommand()
.help() .help()
.argv .argv

25
src/model/artifact.ts Normal file
View File

@@ -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
}

35
src/model/distribution.ts Normal file
View File

@@ -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[]
}

50
src/model/module.ts Normal file
View File

@@ -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[]
}

14
src/model/required.ts Normal file
View File

@@ -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
}

81
src/model/server.ts Normal file
View File

@@ -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[]
}

37
tslint.json Normal file
View File

@@ -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"]
}
}