Skip to content

Commit 5510ed1

Browse files
authored
Adding code format checks & Restructure scripts (JaylyDev#138)
* Adding code format checks * Restructure script codebase * fixes * Update CONTRIBUTING.md * Exclude checks in directories * Exclude docs directory
1 parent 36308df commit 5510ed1

131 files changed

Lines changed: 924 additions & 244 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cl.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1111

1212
jobs:
13-
debug:
13+
type-check:
1414
name: 'Type Check'
1515
runs-on: ubuntu-latest
1616

@@ -24,5 +24,22 @@ jobs:
2424
find ./scripts/* -maxdepth 2 -name package.json -execdir sh -c 'pwd && npm install' \;
2525
find ./docs/* -maxdepth 5 -name package.json -execdir sh -c 'pwd && npm install' \;
2626
27-
- name: tsc debug
28-
run: tsc -b --verbose
27+
- name: Build tsc
28+
run: tsc --build --verbose
29+
30+
format-check:
31+
name: 'Format Check'
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v3
37+
38+
- name: npm install
39+
run: npm install
40+
41+
- name: Build tools
42+
run: npm run tools
43+
44+
- name: Format Check
45+
run: node ./tools/index.js

.github/workflows/lint-md.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ jobs:
2525

2626
- name: Markdown links check
2727
uses: ruzickap/action-my-markdown-link-checker@v1
28+
with:
29+
exclude: |
30+
docs/

.gitignore

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
node_modules/
1+
# Dependency directories
2+
node_modules/
3+
4+
# Tools build files
5+
tools/*.js
6+
tools/*.js.map
7+
tools/*.d.ts
8+
9+
# Logs
10+
logs
11+
*.log
12+
npm-debug.log*
13+
yarn-debug.log*
14+
yarn-error.log*
15+
lerna-debug.log*
16+
.pnpm-debug.log*
17+
18+
# TypeScript cache
19+
*.tsbuildinfo

CONTRIBUTING.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@ Contributing infomation. This info changes because Script API is currently in ac
44

55
## Scripts
66

7-
When submitting a new package. The scripts are assumed that they can be used with the latest beta module of script modules in latest version of Minecraft Preview, the following is a reference of a manifest dependencies and NPM packages for meeting the criteria of submitting or updating a script sample:
7+
When submitting a new package. The scripts are assumed that they can be used with the latest beta module of script modules in latest version of Minecraft Preview, the following is a reference of a manifest dependencies and NPM packages for meeting the criteria of submitting or updating a script sample.
88

99
**manifest.json**
1010

11+
This repository may have scripts that requires the following dependencies with their latest module version:
12+
1113
```json
1214
"dependencies": [
1315
{
1416
"module_name": "@minecraft/server",
15-
"version": "1.1.0-beta"
17+
"version": "1.2.0-beta"
1618
},
19+
{
20+
"module_name": "@minecraft/server-editor",
21+
"version": "0.1.0-beta"
22+
}
1723
{
1824
"module_name": "@minecraft/server-ui",
1925
"version": "1.0.0-beta"
@@ -33,6 +39,15 @@ When submitting a new package. The scripts are assumed that they can be used wit
3339
]
3440
```
3541

42+
This repository may have scripts that requires the following capabilities:
43+
44+
```json
45+
"capabilities": [
46+
"editorExtension",
47+
"script_eval"
48+
]
49+
```
50+
3651
**NPM packages:**
3752

3853
- [`@minecraft/server@beta`](https://www.npmjs.com/package/@minecraft/server/v/beta)

README.md

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,62 @@ This repository is filled with community driven script samples for Minecraft Bed
77
- ### [scripts](./scripts/)
88
Community driven scripts that use Script API to do all kinds of crazy stuff in Minecraft.
99
> ⚠️ Some scripts might use `@minecraft/server-net` and `@minecraft/server-admin` module, which the modules are only available in [Bedrock Dedicated Servers](https://www.minecraft.net/en-us/download/server/bedrock) and cannot be used on Minecraft clients.
10-
11-
- ### [@minecraft/server](./docs/MinecraftApi/@minecraft/server/)
12-
Basic usage of manipulating Script API features within `@minecraft/server` module
13-
14-
- ### [@minecraft/server-gametest](./docs/MinecraftApi/@minecraft/server-gametest/)
15-
Basic usage of creating GameTests or spawning a simulated player using `@minecraft/server-gametest` module
16-
17-
- ### [@minecraft/server-ui](./docs/MinecraftApi/@minecraft/server-ui/)
18-
Basic usage of manipulating server forms available in `@minecraft/server-ui` module
19-
20-
- ### [@minecraft/server-admin](./docs/MinecraftApi/@minecraft/server-admin/)
21-
Basic usage of loading secrets and variables from `@minecraft/server-admin` module
2210
23-
- ### [@minecraft/server-net](./docs/MinecraftApi/@minecraft/server-net/)
24-
Basic usage of executing HTTP-based requests using `@minecraft/server-net` module
11+
- ### [docs](./docs/)
12+
Contains technical documentation of Script API features.
13+
> 🚫 Documentation are no longer being updated. Check out [Bedrock Wiki](https://wiki.bedrock.dev/) and [Microsoft Learn](https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/) for up-to-date infomation.
2514
2615
## Contributing
2716

2817
Please contribute to this repository if you can.
2918

19+
The repository features a Pull Request system that inspires heavily from [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped). This implementation serves to ensure the attribution of code ownership to the script authors who manages of their scripts.
20+
3021
To create a new script package, create a folder structure based on the following:
3122

32-
```
33-
JaylyDev/ScriptAPI (root)
34-
└───scripts
35-
└───my-package
36-
index.js
37-
index.ts (optional)
38-
LICENSE (optional)
39-
tests.js
40-
tests.ts (optional)
41-
README.md (optional)
23+
| File | Purpose |
24+
| ------------- | ------- |
25+
| `index.js` or `index.ts` | This is main file for the package. |
26+
| `tests.ts` | This contains sample code which tests the typings. This code does *not* run, but it is type-checked. |
27+
| `tsconfig.json` | This allows you to run `tsc` within the package. |
28+
| `README.md` | Infomation for the package. |
29+
30+
To add yourself as a script author:
31+
32+
Adding your name to the end of the line, as in `// Author: Alice <url>, Bob <url>`.
33+
Or if there are more people, it can be multiline
34+
```js
35+
// Author: Alice <url>
36+
// Bob <url>
37+
// Steve <url>
38+
// John <url>
4239
```
4340

44-
In the example `new-package` is the package name, you must include
45-
- a main file (e.g. `index.js` or `index.ts`)
46-
- a test file (e.g. `tests.js` or `tests.ts`).
41+
Each package is versioned via GitHub repository tags. In order to secure credentials for scripts, each main file requires basic credentials with the right format. For example, here are the first few lines of script example:
4742

48-
### Script modules version
43+
```js
44+
// Script example for ScriptAPI
45+
// Author: Alice <https://github.com/alice>
46+
// Bob <https://github.com/bob>
47+
// Steve <https://steve.com/>
48+
// Project: https://github.com/JaylyDev/ScriptAPI
49+
```
4950

50-
The script samples are intended to be used with the latest beta module of script modules in latest version of Minecraft Preview, and the latest version of Minecraft, this depends on the scale of changes happens in Scripting API in Minecraft Preview.
51+
### Script Versioning
5152

52-
For submitting or updating script samples, we recommend upload scripts that uses the latest version of Script API modules. For more infomation please visit [here](./CONTRIBUTING.md).
53+
The script samples are intended to be used within the latest version of Minecraft or Minecraft Preview, using latest development version of Script API modules.
5354

54-
### Acknowledgements
55+
For submitting or updating script samples, you must upload scripts that works in the latest version of Script API modules in latest Minecraft Preview. For more infomation please visit [here](./CONTRIBUTING.md).
5556

56-
When you submit a new package and you want to publicly declare your work, you are allowed to insert credits under the following files:
57+
To access older versions of scripts, this repository uses [GitHub's tags feature](https://github.com/JaylyDev/ScriptAPI/tags) to allow users to access previous versions of repository for scripts that uses a specific Minecraft version.
5758

58-
- `LICENSE` file with the license and your name
59-
- Adding your name to the end of the line, like `// Author: JaylyDev <https://github.com/JaylyDev>`.
60-
- Add your name in `README.md` file in the package
59+
![github_tags](https://user-images.githubusercontent.com/65847850/222926832-8c8db1d5-f6d6-41be-bfeb-f4efdd5d46b5.png)
6160

6261
## Script status
6362

6463
This repository uses TypeScript compiler to test script files by validing with declaration files of Script API modules, making sure they are up-to-date when using in the latest Minecraft versions.
6564

66-
<img src="https://user-images.githubusercontent.com/65847850/192581677-8d36e2ac-456a-46fd-8713-e87508be085a.png" align="left" width="500"></a>
65+
![success_checks](https://user-images.githubusercontent.com/65847850/222813970-7f24a869-37a5-4e73-b2fd-03f321fdb4d1.png)
6766

6867
Most of the time the checks succeed, which means scripts inside should not have any syntax errors when using in stable version of Minecraft.
6968

legacyPackages.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"packages": [
3+
"chat-rank",
4+
"chest-lock",
5+
"command-types",
6+
"dimension-entities",
7+
"dimensions",
8+
"get-scores",
9+
"is-host",
10+
"is-operator",
11+
"lz-string",
12+
"minecraft-language",
13+
"player-extra",
14+
"player-velocity-fix",
15+
"remove-permission",
16+
"run-command-async",
17+
"run-commands",
18+
"set-permission",
19+
"shopui",
20+
"timers"
21+
]
22+
}

package-lock.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"description": "this repository is filled with community driven scripts for Minecraft scripting",
44
"version": "1.0.0",
55
"scripts": {
6-
"test": "tsc"
6+
"test": "tsc",
7+
"build": "tsc --build",
8+
"tools": "cd tools && tsc",
9+
"ci": "cd scripts && tsc"
710
},
811
"repository": {
912
"type": "git",
@@ -15,7 +18,6 @@
1518
"url": "https://github.com/JaylyDev/ScriptAPI/issues"
1619
},
1720
"homepage": "https://github.com/JaylyDev/ScriptAPI#readme",
18-
"type": "module",
1921
"dependencies": {
2022
"@minecraft/server": "1.2.0-beta.1.19.80-preview.20",
2123
"@minecraft/server-admin": "1.0.0-beta.1.19.80-preview.20",
@@ -25,6 +27,8 @@
2527
},
2628
"devDependencies": {
2729
"@types/node": "^18.11.10",
30+
"@types/parsimmon": "1.10.6",
31+
"parsimmon": "1.18.1",
2832
"typescript": "^4.9.5"
2933
}
3034
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
// https://discord.com/channels/523663022053392405/854033525546942464/988466192383615066
1+
// Script example for ScriptAPI
2+
// Author: FrankyRayMS <https://github.com/FrankyRay>
3+
// Project: https://github.com/JaylyDev/ScriptAPI
4+
25
import { world } from "@minecraft/server";
36
import { ActionFormData } from "@minecraft/server-ui"
47

scripts/anti-32k-event/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Script example for ScriptAPI
2+
// Author: JaylyMC <https://github.com/JaylyDev>
3+
// Project: https://github.com/JaylyDev/ScriptAPI
4+
15
import { Enchantment, Entity, EntityInventoryComponent, ItemEnchantsComponent, ItemStack, system, TicksPerSecond, world } from '@minecraft/server';
26
const tickInterval = TicksPerSecond;
37
class IncompatibleEnchantmentAlertEvent {

0 commit comments

Comments
 (0)