Compare commits
	
		
			8 Commits
		
	
	
		
			568e5abbc3
			...
			main
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 79d46bdad1 | |||
| 74a724c287 | |||
| 6c3889d2a0 | |||
| dcaa4a7365 | |||
| 3e48f9c97c | |||
| 8402546cf8 | |||
| 423f014219 | |||
| e57810d9d3 | 
							
								
								
									
										90
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,90 @@ | ||||
| <h1>SpyglassMC Action</h1> | ||||
|  | ||||
| This action lets you validate your Minecraft datapack using [SpyglassMC](https://spyglassmc.com/). | ||||
| All JSON and MCFunction files are checked for syntax errors. | ||||
|  | ||||
| <details> | ||||
| <summary><strong>Table of Contents</strong></summary> | ||||
|  | ||||
| --- | ||||
| - [Basic workflow](#basic-workflow) | ||||
| - [Input parameters](#input-parameters) | ||||
| - [GitHub vs. Gitea](#github-vs-gitea) | ||||
|   - [Gitea](#gitea) | ||||
|   - [GitHub](#github) | ||||
| --- | ||||
|  | ||||
| </details> | ||||
|  | ||||
|  | ||||
| ## Basic workflow | ||||
| Here is a simple example showing how to use this action: | ||||
|  | ||||
| ```yaml | ||||
| name: Check datapack | ||||
| on: | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - main | ||||
| jobs: | ||||
|   check: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Checkout code | ||||
|         uses: actions/checkout@v4 | ||||
|  | ||||
|       - name: Check syntax and schemas | ||||
|         uses: https://git.kb28.ch/HEL/spyglassmc-action@v1.1.4 | ||||
| ``` | ||||
|  | ||||
| ## Input parameters | ||||
| The following parameters can be passed using the `with` section: | ||||
| |Parameter|Type|Default|Description| | ||||
| |:---|:---|:---:|:---| | ||||
| |`rootDir`        |Path   |`./`   |Root datapack directory (containing the data folder and pack.mcmeta file)| | ||||
| |`version`        |String |`auto` |The Minecraft version to use. If not specified or set to 'auto', will try to use the version indicated in `pack.mcmeta`| | ||||
| |`reportAllErrors`|Boolean|`false`|Whether to report all errors or only the first one| | ||||
| |`verbose`        |Boolean|`false`|Whether to provide details on errors or just the number of errors| | ||||
|  | ||||
|  | ||||
| ## GitHub vs. Gitea | ||||
|  | ||||
| Depending on where you want to execute this action, you should be mindful of the following points | ||||
|  | ||||
| ### Gitea | ||||
| If your workflow will be running on Gitea, you might need to set a specific runner image (see https://gitea.com/gitea/runner-images#migration). For example: | ||||
| ```yaml | ||||
| ... | ||||
| jobs: | ||||
|   check: | ||||
|     runs-on: ubuntu-latest | ||||
|     container: catthehacker/ubuntu:act-latest | ||||
| ... | ||||
| ``` | ||||
|  | ||||
| ### GitHub | ||||
| If your workflow will be running on GitHub, you will not be able to simply use the action from this Gitea repository.\ | ||||
| Instead, you need to add a step to clone this repository, and use the action locally | ||||
|  | ||||
| ```yaml | ||||
| name: Check datapack | ||||
| on: | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - main | ||||
| jobs: | ||||
|   deploy: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|       - name: Checkout code | ||||
|         uses: actions/checkout@v4 | ||||
|  | ||||
|       - name: Checkout action | ||||
|         run: | | ||||
|           git clone https://git.kb28.ch/HEL/spyglassmc-action ./.github/actions/spyglassmc-action | ||||
|  | ||||
|       - name: Check syntax and schemas | ||||
|         uses: ./.github/actions/spyglassmc-action | ||||
| ``` | ||||
|  | ||||
| You might also want to `git checkout` a specific tagged version | ||||
							
								
								
									
										10
									
								
								action.yml
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								action.yml
									
									
									
									
									
								
							| @@ -15,7 +15,15 @@ inputs: | ||||
|     description: The Minecraft version to use. If not specified or set to 'auto', will try to use the version indicated in `pack.mcmeta` | ||||
|     required: false | ||||
|     default: 'auto' | ||||
|   reportAllErrors: | ||||
|     description: Whether to report all errors or only the first one | ||||
|     required: false | ||||
|     default: 'false' | ||||
|   verbose: | ||||
|     description: Whether to provide details on errors or just the number of errors | ||||
|     required: false | ||||
|     default: 'false' | ||||
|  | ||||
| runs: | ||||
|   using: 'node24' | ||||
|   using: 'node20' | ||||
|   main: 'dist/index.js' | ||||
|   | ||||
							
								
								
									
										17
									
								
								dist/143.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								dist/143.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										17
									
								
								dist/379.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								dist/379.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										17
									
								
								dist/576.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								dist/576.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										17
									
								
								dist/611.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								dist/611.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										17
									
								
								dist/694.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								dist/694.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										17
									
								
								dist/699.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								dist/699.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										17
									
								
								dist/766.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								dist/766.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| export const id = 766; | ||||
| export const ids = [766]; | ||||
| export const modules = { | ||||
|  | ||||
| /***/ 1766: | ||||
| /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { | ||||
|  | ||||
| __webpack_require__.r(__webpack_exports__); | ||||
| /* harmony export */ __webpack_require__.d(__webpack_exports__, { | ||||
| /* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__) | ||||
| /* harmony export */ }); | ||||
| /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({"boolean":"un booleano","code-action.block-state-sort-keys":"Ordina stato blocco","code-action.fix-file":"Aggiusta tutti i problemi auto-aggiustabili in questo file","code-action.fix-workspace":"Aggiusta tutti i problemi auto-aggiustabili nel spazio di lavoro","code-action.id-attribute-datafix":"Aggiorna il nome di questo attributo a 1.16","code-action.id-complete-default-namespace":"Completa il namespace predefinito","code-action.id-omit-default-namespace":"Ommetti il namespace predefinito","code-action.id-zombified-piglin-datafix":"Cambia questo ID a quello di un Piglin Zombificato","code-action.nbt-compound-sort-keys":"Ordina i tag NBT composti","code-action.nbt-type-to-byte":"Converti in un tag NBT di byte","code-action.nbt-type-to-double":"Converti in un tag NBT double","code-action.nbt-type-to-float":"Converti in un tag NBT float","code-action.nbt-type-to-int":"Converti in un tag NBT int","code-action.nbt-type-to-long":"Converti in un tag NBT long","code-action.nbt-type-to-short":"Converti in un tag NBT short","code-action.nbt-uuid-datafix":"Aggiorna questo UUID a 1.16","code-action.selector-sort-keys":"Ordina gli argomenti di selettore","code-action.string-double-quote":"Quota questa stringa con doppie virgolette","code-action.string-single-quote":"Quota questa stringa con singole virgolette","code-action.string-unquote":"De-quota questa stringa","code-action.vector-align-0.0":"Allinea questo vettore all'origine del blocco","code-action.vector-align-0.5":"Allinea questo vettore al centro del blocco","conjunction.and_2":"e ","conjunction.and_3+_1":",","conjunction.and_3+_2":", e","conjunction.or_2":"o","conjunction.or_3+_1":",","conjunction.or_3+_2":", o","duplicate-key":"Chiave duplicate %0%","ending-quote":"quotazione finale %0%","entity":"un'entità","expected":"Previsto %0%","expected-got":"Aspettato %0% ma ricevuto %1%","integer":"un numero intero","integer.between":"un numero intero da %0% a %1%","key-not-following-convention":"Chiave invalida %0% che non segue il convegno %1%","long":"un long","mcfunction.parser.leading-slash.unexpected":"Barra '/' inaspettata","not-matching-any-child":"Fallito a combaciare con qualsiasi figli nell'albero del sintassi del commando","nothing":"niente","number":"un numero","number-range":"un intervallo di numeri","number-range.missing-min-and-max":"Aspettato un valore minimo o massimo","number.<=":"un numero meno o uguale a %0%","number.>=":"un numero maggiore o uguale a %0%","number.between":"un numero da %0% a %1%","objective":"un oggettivo","punc.period":".","punc.quote":"'%0%'","quote":"una quotazione ('\"o\"')","score-holder":"un contenitore di punteggio","server.new-version":"Il Server di Linguaggio Datapack é stato aggiornato a una nuova versione: %0%","server.remove-cache-file":"Il file del cache di DHP è stato spostato in un luogo in memoria da VSCose. Ora puoi tranquillamente cancellare il brutto file '.datapack' nel tuo spazio di lavoro.","server.show-release-notes":"Mostra appunti di pubblicazione","string":"uno string","tag":"un tag","team":"una squadra","time-unit":"un unità di tempo","too-many-block-affected":"Troppi blocchi nell'area (massimo: %0%, specificati: %1%)","unexpected-character":"Trovati caratteri che non sono da a-z, da 0-9 o [/._-]","unexpected-datapack-tag":"I tag non sono permessi qui","unexpected-default-namespace":"Namespace predefinito dovrebbe essere ommesso qui","unexpected-local-coordinate":"La coordinata locale %0% non è permessa","unexpected-nbt":"Questo tag non esiste qui","unexpected-nbt-array-type":"Tipo di array invalido %0%. Deve essere un tipo 'B', 'I' o 'L'","unexpected-nbt-path-filter":"Filtri composti sono esclusivamente usati per i tag composti","unexpected-nbt-path-index":"Gli indici sono solo usati per le liste, gli tag e gli array","unexpected-nbt-path-key":"Le chiavi sono solo usati per i tag composti","unexpected-nbt-path-sub":"Il tag corrente non ha elementi extra","unexpected-omitted-default-namespace":"Il namespace predefinito non può essere omesso qui","unexpected-relative-coordinate":"Coordinata %0% non è permessa","unexpected-scoreboard-sub-slot":"Solo il 'sidebar' ha sub-posti","unknown-command":"Commando sconosciuto","unknown-key":"Chiave sconisciuta","unquoted-string":"una stringa non quotata","unsorted-keys":"Chiavi non ordinati","uuid":"un UUID","vector":"Un vettore"}); | ||||
|  | ||||
|  | ||||
| /***/ }) | ||||
|  | ||||
| }; | ||||
							
								
								
									
										17
									
								
								dist/944.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								dist/944.index.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										26
									
								
								dist/check_datapack.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								dist/check_datapack.d.ts
									
									
									
									
										vendored
									
									
								
							| @@ -1 +1,25 @@ | ||||
| export declare function checkDatapack(rootDir: String, version: String): Promise<void>; | ||||
| import * as core from '@spyglassmc/core'; | ||||
| export interface ActionOptions { | ||||
|     /** | ||||
|      * If set to true, all errors are reported. If set to false, only the first error is reported | ||||
|      */ | ||||
|     reportAllErrors: boolean; | ||||
|     /** | ||||
|      * If set to true, each error is described, indicating the exact issue. If set to false, only the number of errors in each file is reported | ||||
|      */ | ||||
|     verbose: boolean; | ||||
| } | ||||
| export declare class CustomService extends core.Service { | ||||
|     rootDir: string; | ||||
|     options: ActionOptions; | ||||
|     constructor(rootDir: string, version: string, options: ActionOptions); | ||||
|     shutdown(): Promise<void>; | ||||
|     private listFilesByExtension; | ||||
|     private makeFileUrl; | ||||
|     private getFileContent; | ||||
|     private getLineAndColumn; | ||||
|     private getErrorProperties; | ||||
|     checkFile(filePath: string, lang: string): Promise<boolean>; | ||||
|     checkAllFiles(): Promise<boolean>; | ||||
| } | ||||
| export declare function checkDatapack(rootDir: string, version: string, reportAll: boolean, verbose: boolean): Promise<void>; | ||||
|   | ||||
							
								
								
									
										2
									
								
								dist/check_datapack.d.ts.map
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/check_datapack.d.ts.map
									
									
									
									
										vendored
									
									
								
							| @@ -1 +1 @@ | ||||
| {"version":3,"file":"","sourceRoot":"","sources":["file:///home/louis/Documents/spyglassmc-action/src/check_datapack.ts"],"names":[],"mappings":"AAAA,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnF"} | ||||
| {"version":3,"file":"","sourceRoot":"","sources":["file:///home/louis/Documents/spyglassmc-action/src/check_datapack.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAA;AAQxC,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,eAAe,EAAE,OAAO,CAAA;IAExB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAA;CACnB;AAkBD,qBAAa,aAAc,SAAQ,IAAI,CAAC,OAAO;IAC3C,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,aAAa,CAAA;gBAEV,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa;IAiD9D,QAAQ;IAMd,OAAO,CAAC,oBAAoB;IAI5B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,kBAAkB;IAUpB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAgC3D,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC;CA2B1C;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBzH"} | ||||
							
								
								
									
										60242
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										60242
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "spyglassmc-action", | ||||
|   "version": "1.0.0", | ||||
|   "version": "1.1.4", | ||||
|   "description": "Check your Minecraft datapack for syntax or schema errors using SpyglassMC", | ||||
|   "main": "index.js", | ||||
|   "scripts": { | ||||
|   | ||||
| @@ -125,26 +125,27 @@ export class CustomService extends core.Service { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     async checkFile(path: string, lang: string): Promise<boolean> { | ||||
|         const url = this.makeFileUrl(path) | ||||
|         const content = this.getFileContent(path) | ||||
|     async checkFile(filePath: string, lang: string): Promise<boolean> { | ||||
|         const url = this.makeFileUrl(filePath) | ||||
|         const content = this.getFileContent(filePath) | ||||
|         this.project.onDidOpen(url, lang, 0, content) | ||||
|         const docAndNode = this.project.getClientManaged(url) | ||||
|         if (!docAndNode) { | ||||
|             action.error(`File ${path} is not loaded`) | ||||
|             action.error(`File ${filePath} is not loaded`) | ||||
|             return false | ||||
|         } | ||||
|         const { node } = docAndNode | ||||
|         const errors = core.FileNode.getErrors(node) | ||||
|         if (errors.length !== 0) { | ||||
|             const msg = `${errors.length} error${errors.length > 1 ? "s" : ""} in ${path}` | ||||
|             const relPath = path.relative(this.rootDir, filePath) | ||||
|             const msg = `${errors.length} error${errors.length > 1 ? "s" : ""} in ${relPath}` | ||||
|              | ||||
|             if (this.options.verbose) { | ||||
|                 action.startGroup(msg) | ||||
|                 for (const err of errors) { | ||||
|                     action.error( | ||||
|                         err.message, | ||||
|                         this.getErrorProperties(err, path, content) | ||||
|                         this.getErrorProperties(err, filePath, content) | ||||
|                     ) | ||||
|                 } | ||||
|                 action.endGroup() | ||||
| @@ -166,7 +167,7 @@ export class CustomService extends core.Service { | ||||
|         ) | ||||
|         let success = true | ||||
|         for (const jsonFile of jsonFiles) { | ||||
|             if (!this.checkFile(jsonFile, "json")) { | ||||
|             if (!(await this.checkFile(jsonFile, "json"))) { | ||||
|                 success = false | ||||
|                 if (!this.options.reportAllErrors) { | ||||
|                     return false | ||||
| @@ -174,7 +175,7 @@ export class CustomService extends core.Service { | ||||
|             } | ||||
|         } | ||||
|         for (const funcFile of funcFiles) { | ||||
|             if (!this.checkFile(funcFile, "mcfunction")) { | ||||
|             if (!(await this.checkFile(funcFile, "mcfunction"))) { | ||||
|                 success = false | ||||
|                 if (!this.options.reportAllErrors) { | ||||
|                     return false | ||||
|   | ||||
		Reference in New Issue
	
	Block a user