Fix Build; Update Documentation
Some checks failed
ScriptCraft/pipeline/head There was a failure building this commit
Some checks failed
ScriptCraft/pipeline/head There was a failure building this commit
This commit is contained in:
parent
0e3b0cbc87
commit
fbd01d2821
26
docs/ARCHITECTURE.md
Normal file
26
docs/ARCHITECTURE.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Architecture
|
||||||
|
|
||||||
|
## JavaScript
|
||||||
|
Inside the JAR, JS source files are in ```<JAR Root>/scriptcraft```, and inside a typical Gradle project they are in ```src/main/resources/scriptcraft```.
|
||||||
|
|
||||||
|
### External Libraries
|
||||||
|
An external libraries API can be accessed using an ```import``` statement.
|
||||||
|
|
||||||
|
## TypeScript
|
||||||
|
TypeScript-based projects use thw ```com.thebrokenrail.scriptcraft``` Gradle plugin, this plugin will handle installing TypeScript and download any API type declarations. The TypeScript root using this Gradle plugin is at ```src/main/ts```.
|
||||||
|
|
||||||
|
### External Libraries
|
||||||
|
To access an external libraries' API in addition to an ```import``` statement, the TypeScript compiler must have access to the external libraries' type declarations. The ScriptCraft Gradle plugin generates and downloads these using JAR files called API JARs.
|
||||||
|
|
||||||
|
To generate an API JAr from your project, run ```./gradlew apiJar```, or add the ```apiJar``` task to your Maven publication.
|
||||||
|
|
||||||
|
To add an API JAR to your project, add it to the ```typescript``` configuration in your ```dependencies``` block.
|
||||||
|
|
||||||
|
#### API JAR File Structure
|
||||||
|
```
|
||||||
|
- API JAR Root
|
||||||
|
- src/
|
||||||
|
- Source Root
|
||||||
|
- types/
|
||||||
|
- File structure of node_modules/@types
|
||||||
|
```
|
@ -1,17 +0,0 @@
|
|||||||
# File Structure
|
|
||||||
```
|
|
||||||
- Jar Root
|
|
||||||
- scriptcraft/
|
|
||||||
- Source Root
|
|
||||||
```
|
|
||||||
|
|
||||||
## Recommended Source Structure
|
|
||||||
```
|
|
||||||
- Source Root
|
|
||||||
- ModID/
|
|
||||||
- index.js/index.ts
|
|
||||||
- Other Modules
|
|
||||||
```
|
|
||||||
|
|
||||||
### Why is an index file necessary?
|
|
||||||
Because of the way module resolution in ScriptCraft works, you cannot load a module with ```import 'module-name';``` and no index file. Without an index file you would need to use ```import 'module-name/main';``` to load it and specify ```module-name/main``` as your entry-point.
|
|
@ -7,5 +7,5 @@ All ScriptCraft mods have a folder called ```scriptcraft``` in the root of their
|
|||||||
- ```.json```
|
- ```.json```
|
||||||
|
|
||||||
## Extra Details
|
## Extra Details
|
||||||
- If the import path is a folder, ScriptCraft will load the ```index``` file with one of the supported file types.
|
- If the import path is a folder, ScriptCraft will load the ```index``` file, and if it doesn't exist it will try to load ```<Folder>/index```.
|
||||||
- If an extension does not exist in the import path it will look for a file with the same name and one of the supported extensions.
|
- If the specified import does not exist, it will try to load the import appended with each supported file type.
|
@ -5,6 +5,6 @@
|
|||||||
|
|
||||||
[View Bridges](BRIDGES.md)
|
[View Bridges](BRIDGES.md)
|
||||||
|
|
||||||
[View File Structure](FILE_STRUCTURE.md)
|
[View Architecture](ARCHITECTURE.md)
|
||||||
|
|
||||||
[View TypeDoc](https://jenkins.thebrokenrail.com/job/ScriptCraft/job/master/TypeDoc/)
|
[View TypeDoc](https://jenkins.thebrokenrail.com/job/ScriptCraft/job/master/TypeDoc/)
|
@ -9,18 +9,3 @@ This is an example of a Minecraft mod made in TypeScript using ScriptCraft.
|
|||||||
- This will also work with JavaScript if you set ```compilerOptions.allowJs``` and optionally ```compilerOptions.checkJs``` in ```src/main/ts/tsconfig.json``` to ```true```
|
- This will also work with JavaScript if you set ```compilerOptions.allowJs``` and optionally ```compilerOptions.checkJs``` in ```src/main/ts/tsconfig.json``` to ```true```
|
||||||
- NPM dependencies are not bundled
|
- NPM dependencies are not bundled
|
||||||
- API JARs are not bundled
|
- API JARs are not bundled
|
||||||
|
|
||||||
## API JARs
|
|
||||||
An API JAR can be built with ```./gradlew apiJar```.
|
|
||||||
|
|
||||||
### ```typescript``` Gradle Configuration
|
|
||||||
The ```typescript``` gradle configuration will extract the specified API JAR into ```src/main/ts/build/dependencies```. It will not be bundled with the mod.
|
|
||||||
|
|
||||||
### File Structure
|
|
||||||
```
|
|
||||||
- API JAR Root
|
|
||||||
- src/
|
|
||||||
- Source Root
|
|
||||||
- types/
|
|
||||||
- File structure of node_modules/@types
|
|
||||||
```
|
|
@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("fabric-loom") version "0.2.7-SNAPSHOT"
|
id("fabric-loom") version "0.2.7-SNAPSHOT"
|
||||||
id("com.thebrokenrail.scriptcraft")
|
id("com.thebrokenrail.scriptcraft") version "1.0.0-SNAPSHOT"
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("fabric-loom") version "0.2.7-SNAPSHOT"
|
id("fabric-loom") version "0.2.7-SNAPSHOT"
|
||||||
id("jni")
|
id("jni")
|
||||||
id("com.thebrokenrail.scriptcraft")
|
id("com.thebrokenrail.scriptcraft") version "1.0.0-SNAPSHOT"
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user