Fix Build; Update Documentation
ScriptCraft/pipeline/head There was a failure building this commit Details

This commit is contained in:
TheBrokenRail 2020-05-31 13:51:21 -04:00
parent 0e3b0cbc87
commit fbd01d2821
7 changed files with 32 additions and 38 deletions

26
docs/ARCHITECTURE.md Normal file
View 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
```

View File

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

View File

@ -7,5 +7,5 @@ All ScriptCraft mods have a folder called ```scriptcraft``` in the root of their
- ```.json```
## Extra Details
- If the import path is a folder, ScriptCraft will load the ```index``` file with one of the supported file types.
- 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 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 the specified import does not exist, it will try to load the import appended with each supported file type.

View File

@ -5,6 +5,6 @@
[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 File

@ -8,19 +8,4 @@ This is an example of a Minecraft mod made in TypeScript using ScriptCraft.
## Notes
- 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
- 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
```
- API JARs are not bundled

View File

@ -1,6 +1,6 @@
plugins {
id("fabric-loom") version "0.2.7-SNAPSHOT"
id("com.thebrokenrail.scriptcraft")
id("com.thebrokenrail.scriptcraft") version "1.0.0-SNAPSHOT"
}
java {

View File

@ -1,7 +1,7 @@
plugins {
id("fabric-loom") version "0.2.7-SNAPSHOT"
id("jni")
id("com.thebrokenrail.scriptcraft")
id("com.thebrokenrail.scriptcraft") version "1.0.0-SNAPSHOT"
`maven-publish`
}