Skip to content

Commit

Permalink
v1.2.0 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
dscalzi authored Mar 20, 2023
1 parent fb19a88 commit dd9330c
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 119 deletions.
2 changes: 2 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export * from './spec/artifact'
export * from './spec/distribution'
export * from './spec/java'
export * from './spec/module'
export * from './spec/required'
export * from './spec/server'
export * from './spec/system'
export * from './spec/type'
147 changes: 147 additions & 0 deletions lib/spec/java.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import { Platform, Architecture } from './system'

/**
* Supported JDK Distributions
*
* @since 1.2.0
*/
export enum JdkDistribution {
/**
* Amazon Corretto
* @see https://aws.amazon.com/corretto/
* @since 1.2.0
*/
CORRETTO = 'CORRETTO',
/**
* Eclipse Temurin
* @see https://projects.eclipse.org/projects/adoptium.temurin
* @since 1.2.0
*/
TEMURIN = 'TEMURIN',
}

/**
* Properties used to specify version information.
* @since 1.2.0
*/
export interface JavaVersionProps {
/**
* Preferred JDK distribution to download if no applicable installation could
* be found.
* If omitted, the client will decide (decision may be platform-specific).
* @since 1.2.0
*/
distribution?: JdkDistribution

/**
* A semver range of supported JDK versions.
*
* Java version syntax is platform dependent.
*
* JDK 8 and prior
* 1.{major}.{minor}_{patch}-b{build}
* Ex. 1.8.0_152-b16
*
* JDK 9+
* {major}.{minor}.{patch}+{build}
* Ex. 11.0.12+7
*
* For processing, all versions will be translated into a
* semver compliant string. JDK 9+ is already semver. For
* versions 8 and below, 1.{major}.{minor}_{patch}-b{build}
* will be translated to {major}.{minor}.{patch}+{build}.
*
* If specified, you must also specify suggestedMajor.
*
* If omitted, the client will decide based on the game version.
* @see https://github.com/npm/node-semver#ranges
* @since 1.2.0
*/
supported?: string

/**
* The suggested major Java version. The suggested major
* should comply with the version range specified by supported,
* if defined. This will be used in messages displayed to the
* end user, and to automatically fetch a Java version.
*
* NOTE If supported is specified, suggestedMajor must be set.
* The launcher's default value may not comply with your custom
* major supported range.
*
* Common use case:
* supported: >=17.x
* suggestedMajor: 17
*
* More involved:
* supported: >=16 <20
* suggestedMajor: 17
*
* Given a wider support range, it becomes necessary to specify which
* major version in the range is the suggested.
* @since 1.2.0
*/
suggestedMajor?: number
}

/**
* Java validation rules for a specific platform.
*
* @since 1.2.0
*/
export interface JavaPlatformOptions extends JavaVersionProps {
/**
* The platform that this validation matrix applies to.
* @since 1.2.0
*/
platform: Platform
/**
* The architecture that this validation matrix applies to.
* If omitted, applies to all architectures.
* @since 1.2.0
*/
architecture?: Architecture
}

/**
* Java options.
* @since 1.2.0
*/
export interface JavaOptions extends JavaVersionProps {

/**
* Platform-specific java rules for this server configuration.
* Validation rules will be delegated to the client for
* any undefined properties. Java validation can be configured
* for specific platforms and architectures. The most specific
* ruleset will be applied.
*
* Maxtrix Precedence (Highest - Lowest)
* - Current platform, current architecture (ex. win32 x64)
* - Current platform, any architecture (ex. win32)
* - Java Options base properties (defined on this object)
* - Client logic (default logic in the client)
*
* @since 1.2.0
*/
platformOptions?: JavaPlatformOptions[]

/**
* RAM settings.
* If omitted, legacy client logic will be used to determine these values.
* @since 1.2.0
*/
ram?: {
/**
* The recommended amount of RAM in megabytes. Must be an interval of 512.
* @since 1.2.0
*/
recommended: number
/**
* The absolute minimum amount of RAM in megabytes. Must be an interval of 512.
* @since 1.2.0
*/
minimum: number
}

}
2 changes: 2 additions & 0 deletions lib/spec/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export interface Module {
* Only applicable to modules of type Library.
*
* Defaults to true when not present.
*
* @since 1.1.0
*/
classpath?: boolean

Expand Down
7 changes: 7 additions & 0 deletions lib/spec/server.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { JavaOptions } from './java'
import { Module } from './module'

export interface Server {
Expand Down Expand Up @@ -38,6 +39,12 @@ export interface Server {
*/
minecraftVersion: string

/**
* Java options.
* @since 1.2.0
*/
javaOptions?: JavaOptions

/**
* Server specific settings used for Discord Rich Presence.
*/
Expand Down
38 changes: 38 additions & 0 deletions lib/spec/system.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Supported platforms.
* @since 1.2.0
*/
export enum Platform {
/**
* macOS
* @since 1.2.0
*/
DARWIN = 'darwin',
/**
* Linux
* @since 1.2.0
*/
LINUX = 'linux',
/**
* Windows
* @since 1.2.0
*/
WIN32 = 'win32'
}

/**
* Supported architectures.
* @since 1.2.0
*/
export enum Architecture {
/**
* arm64
* @since 1.2.0
*/
ARM64 = 'arm64',
/**
* x64
* @since 1.2.0
*/
X64 = 'x64'
}
Loading

0 comments on commit dd9330c

Please sign in to comment.