-
-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
382 changed files
with
10,600 additions
and
4,543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# ./github/actions/ci | ||
|
||
Standalone files may be stored directly in this directory. (as long as they are used for the ci workflows) | ||
|
||
Those that have dependencies (e.g. node_modules for node & composer for php) are stored in subdirectories. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const fsp = require('fs/promises'); | ||
|
||
fsp | ||
.readFile('kubejs/exported/kubejs-server-export.json') | ||
.then(data => { | ||
const exported = JSON.parse(data.toString()); | ||
|
||
let blacklisted = exported.tags.fluids['create:no_infinite_draining']; | ||
let whitelisted = exported.registries.fluids.filter(fluid_id => !blacklisted.includes(fluid_id)); | ||
|
||
whitelisted = whitelisted.filter(fluid_id => { | ||
const fluid_name = fluid_id.split(':')[1]; | ||
|
||
if (fluid_name.startsWith('flowing_')) return false; | ||
if (fluid_name.endsWith('_flowing')) return false; | ||
|
||
if (fluid_name.startsWith('fluid_')) return false; | ||
if (fluid_name.endsWith('_fluid')) return false; | ||
|
||
return true; | ||
}); | ||
|
||
console.log(whitelisted); | ||
console.log(`::notice::${whitelisted.length} fluids can be used with the hose pulley.`); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules/ | ||
/artifact.zip | ||
/artifact/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const { exec, execSync } = require("child_process") | ||
const fs = require("fs") | ||
const util = require('node:util') | ||
|
||
const negative = '\x1B[31m- #' | ||
const positive = '\x1B[32m+\x1B[m\x1B[32m #' | ||
|
||
const a = __dirname + '/artifact' // base | ||
const b = __dirname + '/../../../..' // head | ||
|
||
const kubejs = { | ||
[a]: JSON.parse(fs.readFileSync(`${a}/kubejs/exported/kubejs-server-export.json`)), | ||
[b]: JSON.parse(fs.readFileSync(`${b}/kubejs/exported/kubejs-server-export.json`)), | ||
} | ||
|
||
let changes = 0 | ||
let notices = [] | ||
|
||
// [ 'blocks', 'items', 'fluids', 'entity_types' ] | ||
const types = Object.keys({...kubejs[a].tags, ...kubejs[b].tags}) | ||
|
||
types.forEach(type => { | ||
[a, b].forEach(c => { | ||
let lines = [] | ||
|
||
const keys = Object.keys(kubejs[c].tags[type]).sort() | ||
keys.forEach(key => { | ||
kubejs[c].tags[type][key].sort().forEach(item => lines.push(` #${key} > ${item}`)) | ||
lines.push('') | ||
}) | ||
|
||
fs.writeFileSync(`${c}/kubejs/exported/tags/${type}.txt`, lines.join('\n')) | ||
}) | ||
|
||
let diff = execSync(`git --no-pager diff --color --no-index '${a}/kubejs/exported/tags/${type}.txt' '${b}/kubejs/exported/tags/${type}.txt' || true`).toString() | ||
|
||
let positives = 0 | ||
let negatives = 0 | ||
|
||
diff.split('\n').forEach(line => { | ||
if (diff == '') return | ||
|
||
// remove the + and - for empty lines | ||
if (line == '\x1B[31m-\x1B[m' || line == '\x1B[32m+\x1B[m') line = '\x1B[m' | ||
console.log(line) // debug: console.log(util.inspect(line, {colors: false})) | ||
|
||
if (line.startsWith(positive)) { | ||
positives++ | ||
changes++ | ||
} else | ||
if (line.startsWith(negative)) { | ||
negatives++ | ||
changes++ | ||
} | ||
}) | ||
|
||
notices.push(`${type}(+${positives} -${negatives})`) | ||
}) | ||
|
||
console.log(`::notice::${changes} changes to tags: ${notices.join(' ')}`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// This script runs for pull requests, it downloads the artifact for the target branch. | ||
|
||
const { default: axios } = require("axios") | ||
const { exec } = require("child_process") | ||
const fsp = require("fs/promises") | ||
|
||
const arg_repo = process.argv[2] | ||
const arg_hash = process.argv[3] | ||
const arg_mode = process.argv[4] | ||
const arg_auth = process.argv[5] | ||
|
||
const name = `server (${arg_mode})` | ||
|
||
axios.defaults.headers.common = { | ||
'Accept': 'application/vnd.github.v3+json', | ||
'Authorization': `token ${arg_auth}`, | ||
} | ||
|
||
// axios.get('https://api.github.com/user').then(response => { | ||
// console.log(response.data); | ||
// }) | ||
|
||
axios | ||
.get(`https://api.github.com/repos/${arg_repo}/actions/artifacts`) | ||
.then(response => { | ||
let artifact = response.data.artifacts.find(artifact => { | ||
return artifact.name == name && artifact.workflow_run.head_sha == arg_hash | ||
}) | ||
|
||
console.log(artifact) | ||
if (!artifact) throw new Error(`Artifact not found.`) | ||
|
||
// ensure unzip target does not exist | ||
exec(`rm -r '${__dirname}/artifact'`) | ||
|
||
axios.get(artifact.archive_download_url, {responseType: 'stream'}).then(response => { | ||
console.log('downloaded, saving...') | ||
fsp.writeFile(`${__dirname}/artifact.zip`, response.data).then(() => { | ||
console.log('saved, unzipping...') | ||
exec(`unzip '${__dirname}/artifact.zip' -d '${__dirname}/artifact'`, (error, stdout, stderr) => console.log(stdout)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const fs = require('fs') | ||
const clc = require('cli-color'); | ||
|
||
// each of the kubejs log files | ||
const filenames = ['startup', 'client', 'server']; | ||
|
||
const loaded_script = / Loaded script (.*) in /; | ||
const new_global = / - new global variable: (.*)/; | ||
|
||
// color the string from the point where `Loaded script` & `- new global` starts | ||
function console_log(color, line) { | ||
const matches = line.match(/\[INFO ] (SourceFile:\d+: )?(.*)/); | ||
console.log(color(matches[2])); | ||
} | ||
|
||
// filter out the lines that do not relate to `new global variable` and its context | ||
filenames.forEach(filename => { | ||
console.log(clc.blue(`${filename}.txt:`)); | ||
const lines = fs.readFileSync(`./logs/kubejs/${filename}.txt`).toString().split('\n'); | ||
|
||
let color = null; | ||
|
||
lines.forEach((line, i) => { | ||
|
||
if (new_global.test(line)) { | ||
const previous_line = lines[i-1]; | ||
if (loaded_script.test(previous_line)) { | ||
|
||
// - anything that likely shouldn't be global is red | ||
// - anything defined the constants becomes is green | ||
// - anything defined in the function file is yellow | ||
|
||
color = clc.red; | ||
if (previous_line.includes('constants')) color = clc.green; | ||
if (previous_line.includes('functions')) color = clc.yellow; | ||
|
||
console_log(color, previous_line); | ||
} | ||
console_log(color, line); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.