Skip to content

Commit c753fe7

Browse files
authored
update ghcp instructions
1 parent 2fe58a7 commit c753fe7

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

.github/copilot-instructions.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,30 @@ Not all data is generated. Some data (like protocol schemas) is manually curated
5757

5858
### Protocol data
5959

60-
We use a special yaml-like DSL to generate protocol.json files. Refer to doc/protocol.md for info.
61-
These files are stored inside proto.yml files in the latest/ folder (like bedrock/latest/proto.yml) for the latest version, otherwise in the versioned folder (like pc/1.20/proto.yml).
60+
We use a special YAML-like DSL to generate protocol.json files. Refer to doc/protocol.md for info.
61+
These files are stored inside proto.yml (and an imported types.yml support file on bedrock) files in the latest/ folder (like bedrock/latest/proto.yml) for the latest version, otherwise in the versioned folder (like pc/1.20/proto.yml).
62+
63+
👉 Run `npm run build` in tools/js to regenerate protocol.json files after making changes to the protocol yaml files.
64+
65+
❌ Don't make changes to protocol.json files directly. Instead, update the relevant proto.yml file in latest/ and regenerate protocol.json by running `npm run build` in tools/js.
66+
67+
If you need to edit many files at once, consider writing a simple Node.js script to replace. E.g., from `cd tools/js && npm i && node __replace_something.js`):
68+
```js
69+
const cp = require('child_process')
70+
const fs = require('fs')
71+
const glob = require('glob')
72+
const pcVersionsOrdered = require('../../data/pc/common/versions.json')
73+
const after1_20_5 = pcVersionsOrdered.slice(pcVersionsOrdered.indexOf('1.20.5')) // everything after 1.20.5...
74+
for (const version of pcVersionsOrdered) {
75+
// globSync, fs.readFileSync...fs.writeFileSync ; avoid async
76+
}
77+
```
78+
79+
## Testing
6280

63-
Notably, run `npm run build` in tools/js to regenerate protocol.json files after making changes to the protocol yaml files. So, don't make changes to protocol.json files directly. Instead, update the relevant proto.yml file in latest/ and regenerate protocol.json by running `npm run build` in tools/js.
81+
**Always** go into `tools/js` and run tests after data changes to ensure local tests are passing:
82+
```sh
83+
cd tools/js
84+
npm install
85+
npm test -- --bail 2>&1 | tail -100
86+
```

tools/js/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/node_modules
22
1.*
33
bun.lock
4-
package-lock.json
4+
package-lock.json
5+
__*

0 commit comments

Comments
 (0)