Skip to content

Commit

Permalink
Merge pull request #2 from PssbleTrngle/codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle authored Nov 7, 2023
2 parents 5ab74d2 + 99fce20 commit 1fe95da
Show file tree
Hide file tree
Showing 29 changed files with 739 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
resources/**/*.jar filter=lfs diff=lfs merge=lfs -text
test/resources/**/*.jar filter=lfs diff=lfs merge=lfs -text
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,5 @@ dist
# webstorm
.idea

test-output
test-output
generated
13 changes: 13 additions & 0 deletions @types/stub/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
declare module "@pssbletrngle/data-modifier/generated" {
export type RegistryId = string;

export type InferIds<T extends RegistryId> = string;

export type ItemId = string;

export type BlockId = string;

export type FluidId = string;

export type RecipeSerializerId = string;
}
15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "0.0.0-dev",
"description": "Data Modifier",
"main": "dist/index.js",
"bin": {
"datamod": "dist/cli/index.js"
},
"exports": {
".": "./dist/index.js",
"./parser": "./dist/parser/index.js",
Expand All @@ -11,7 +14,8 @@
"./parser/thermal": "./dist/parser/thermal.js",
"./parser/farmersdelight": "./dist/parser/farmersdelight.js",
"./parser/adAstra": "./dist/parser/adAstra.js",
"./parser/roots": "./dist/parser/roots.js"
"./parser/roots": "./dist/parser/roots.js",
"./ids": "./dist/schema/ids.js"
},
"typesVersions": {
"*": {
Expand All @@ -35,6 +39,9 @@
],
"parser/roots": [
"./dist/parser/roots.d.ts"
],
"ids": [
"./dist/schema/ids.d.ts"
]
}
},
Expand All @@ -46,7 +53,8 @@
"packageManager": "[email protected]",
"scripts": {
"build": "tsc",
"lint": "eslint \"{src,test}/**/*.ts\"",
"lint": "eslint \"{src,test,playground}/**/*.ts\"",
"cli": "pnpm run build && node dist/cli/index.js",
"test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" jest",
"test:ci": "pnpm run lint && pnpm run test --coverage"
},
Expand Down Expand Up @@ -78,9 +86,12 @@
"dependencies": {
"@pssbletrngle/pack-resolver": "^1.3.0",
"@pssbletrngle/resource-merger": "^1.2.4",
"@types/command-line-usage": "^5.0.4",
"@types/minimatch": "^3.0.5",
"@types/prettier": "^2.7.0",
"arg": "^5.0.2",
"chalk": "^5.0.1",
"command-line-usage": "^7.0.1",
"json5": "^2.2.3",
"lodash-es": "^4.17.21",
"minimatch": "^5.1.0",
Expand Down
12 changes: 12 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@pssbletrngle/data-modifier-playground",
"private": true,
"scripts": {
"build": "pnpm run codegen && tsc",
"codegen": "datamod codegen --output generated --registry-dump ../test/resources/dump"
},
"dependencies": {
"@pssbletrngle/data-modifier": "workspace:*",
"typescript": "^4.8.2"
}
}
14 changes: 14 additions & 0 deletions playground/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createId, createLogger, PackLoader } from '@pssbletrngle/data-modifier'
import type { InferIds, ItemId, WorldgenBiomeId } from '@pssbletrngle/data-modifier/generated'

const logger = createLogger()
const loader = new PackLoader(logger)

const item: ItemId = 'minecraft:acacia_boat'
const otherItem: InferIds<'minecraft:item'> = 'minecraft:acacia_door'
const biome: WorldgenBiomeId = 'minecraft:basalt_deltas'

createId(biome)

loader.recipes.replaceResult('minecraft:emerald', { item: 'minecraft:sapphire' })
loader.recipes.replaceResult(otherItem, { item })
17 changes: 17 additions & 0 deletions playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"typeRoots": [
"node_modules/@types",
"generated/@types"
]
},
"include": [
"src"
],
"exclude": [
"node_modules",
"dist",
]
}
Loading

0 comments on commit 1fe95da

Please sign in to comment.