Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/staging/
/packs/behavior/pack_icon.png
/packs/resource/pack_icon.png
/out

# misc
.DS_Store
Expand Down
19 changes: 1 addition & 18 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import importPlugin from 'eslint-plugin-import';
import jsonc from 'eslint-plugin-jsonc';
import minecraftLinting from 'eslint-plugin-minecraft-linting';
import promisePlugin from 'eslint-plugin-promise';
import sonarjs from 'eslint-plugin-sonarjs';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
import unusedImports from 'eslint-plugin-unused-imports';
import globals from 'globals';
Expand Down Expand Up @@ -37,20 +36,6 @@ export default tseslint.config(
// Base JS configuration
eslint.configs.recommended,

// SonarJS Configuration
sonarjs.configs.recommended,
{
rules: {
// Disable rules that conflict with strict TS or are too noisy for this project
'sonarjs/no-duplicate-string': 'off', // Common in Minecraft commands/IDs
'sonarjs/cognitive-complexity': ['warn', 60], // Increased limit for complex UI handlers
'sonarjs/no-nested-template-literals': 'off',
'sonarjs/todo-tag': 'warn',
'sonarjs/fixme-tag': 'warn',
'sonarjs/pseudo-random': 'off' // Safe for Minecraft game mechanics
}
},

// Unicorn Configuration
eslintPluginUnicorn.configs['flat/recommended'],
{
Expand Down Expand Up @@ -230,9 +215,7 @@ export default tseslint.config(
...jsonc.configs['flat/recommended-with-jsonc'],
{
files: ['**/*.json'],
rules: {
'sonarjs/no-empty-test-file': 'off'
}
rules: {}
},

// Prettier
Expand Down
20 changes: 9 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "<p align=\"center\"> <!-- TODO: Add a cool project logo/banner here. Example: <img src=\"link_to_your_logo.png\" alt=\"AddonExe Logo\" width=\"200\"/> --> <h1 align=\"center\">AddonExe for Minecraft BE</h1> </p>",
"main": "index.js",
"scripts": {
"preinstall": "node scripts/update-mc-deps.js",
"clean": "rimraf packs/behavior/scripts",
"reinstall": "rm -rf node_modules package-lock.json && npm install",
"check-types": "tsc --noEmit",
Expand Down Expand Up @@ -47,11 +46,11 @@
"@minecraft/common": "latest",
"@minecraft/core-build-tasks": "latest",
"@minecraft/creator-tools": "latest",
"@minecraft/debug-utilities": "1.0.0-beta.1.26.1-stable",
"@minecraft/debug-utilities": "beta",
"@minecraft/math": "latest",
"@minecraft/server": "2.6.0-beta.1.26.1-stable",
"@minecraft/server-gametest": "1.0.0-beta.1.26.1-stable",
"@minecraft/server-ui": "2.1.0-beta.1.26.1-stable",
"@minecraft/server": "beta",
"@minecraft/server-gametest": "beta",
"@minecraft/server-ui": "beta",
"@minecraft/vanilla-data": "latest",
"@types/jest": "latest",
"@types/node": "latest",
Expand All @@ -68,7 +67,6 @@
"eslint-plugin-jsonc": "latest",
"eslint-plugin-minecraft-linting": "latest",
"eslint-plugin-promise": "latest",
"eslint-plugin-sonarjs": "^3.0.6",
"eslint-plugin-unicorn": "latest",
"eslint-plugin-unused-imports": "latest",
"glob": "latest",
Expand All @@ -78,7 +76,7 @@
"prettier": "latest",
"prettier-plugin-organize-imports": "latest",
"rimraf": "latest",
"simple-git-hooks": "^2.13.1",
"simple-git-hooks": "latest",
"ts-jest": "latest",
"ts-node": "latest",
"tsc-alias": "latest",
Expand Down Expand Up @@ -129,10 +127,10 @@
},
"overrides": {
"@minecraft/common": "latest",
"@minecraft/debug-utilities": "1.0.0-beta.1.26.1-stable",
"@minecraft/server": "2.6.0-beta.1.26.1-stable",
"@minecraft/server-gametest": "1.0.0-beta.1.26.1-stable",
"@minecraft/server-ui": "2.1.0-beta.1.26.1-stable",
"@minecraft/debug-utilities": "beta",
"@minecraft/server": "beta",
"@minecraft/server-gametest": "beta",
"@minecraft/server-ui": "beta",
"@minecraft/vanilla-data": "latest"
}
}
10 changes: 10 additions & 0 deletions packs/resource/ui/_ui_defs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"ui_defs": [
"ui/hud_screen.json",
"ui/loading_messages.json",
"ui/pause_screen.json",
"ui/scoreboards.json",
"ui/server_form.json",
"ui/tic_tac_toe.json"
]
}
22 changes: 0 additions & 22 deletions packs/resource/ui/pause_screen.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,5 @@
}
}
]
},
"store_button_panel@pause.pause_button_template": {
"$pressed_button_name": "button.menu_settings",
"$button_text": "menu.settings"
},
"marketplace_icon": {
"type": "panel",
"size": [16, 16],
"controls": [
{
"icon": {
"type": "image",
"texture": "textures/ui/sidebar_icons/marketplace",
"size": [16, 16]
}
}
]
},
"settings_button_small@common_buttons.light_content_button": {
"$pressed_button_name": "button.menu_store",
"$button_tts_header": "menu.store",
"$button_content": "pause.marketplace_icon"
}
}
12 changes: 8 additions & 4 deletions packs/resource/ui/server_form.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"namespace": "server_form",
"long_form": {
"type": "panel",
"bindings": [
{ "binding_name": "#title_text" },
{ "binding_name": "#content_text" },
{ "binding_name": "#form_button_length" }
],
"controls": [
{
"client_content": {
Expand All @@ -19,8 +24,7 @@
"controls": [
{
"grid_view": {
"type": "custom",
"renderer": "ui_scene_renderer",
"type": "panel",
"layer": 1,
"anchor_from": "center",
"anchor_to": "center",
Expand All @@ -29,7 +33,7 @@
}
}
],
"visible": "(($title_text - '§t§t§t') = 'Tic Tac Toe')"
"visible": "($title_text = '§t§t§tTic Tac Toe')"
}
},
{
Expand Down Expand Up @@ -99,7 +103,7 @@
}
}
],
"visible": "(not (($title_text - '§t§t§t') = 'Tic Tac Toe'))"
"visible": "(not ($title_text = '§t§t§tTic Tac Toe'))"
}
}
]
Expand Down
59 changes: 40 additions & 19 deletions scripts/generate-manifests.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { exec } from 'node:child_process';
import fs from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { promisify } from 'node:util';

const execAsync = promisify(exec);
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

Expand Down Expand Up @@ -51,23 +54,36 @@ function parseVersion(versionString) {
}

/**
* Extracts the module version from the NPM version string.
* e.g., "2.5.0-beta.1.21.132-stable" -> "2.5.0-beta"
* "1.0.0" -> "1.0.0"
* Fetches the latest stable version of a package from npm.
* @param {string} pkgName The name of the package.
* @returns {Promise<string>} The latest version.
*/
function extractModuleVersion(npmVersion) {
async function fetchLatestVersion(pkgName) {
try {
console.log(`Fetching latest version for ${pkgName}...`);
const { stdout } = await execAsync(`npm view ${pkgName} version`);
return stdout.trim();
} catch (error) {
console.warn(`Failed to fetch version for ${pkgName}, defaulting to 1.0.0. Error: ${error.message}`);
return '1.0.0';
}
}

/**
* Resolves the module version from the NPM version string.
*/
async function resolveModuleVersion(pkgName, npmVersion) {
if (!npmVersion) return '1.0.0';
if (npmVersion === 'latest') return 'beta';

// Strip range characters like ^, ~, >=
const cleanVersion = npmVersion.replace(/^[^\d]*/, '');
if (npmVersion === 'beta') return 'beta';

// Regex to capture x.y.z(-tag)?
const match = cleanVersion.match(/^(\d+\.\d+\.\d+(?:-(?:beta|rc|preview))?)/);
if (match) {
return match[1];
if (npmVersion === 'latest') {
const version = await fetchLatestVersion(pkgName);
return version;
}
return cleanVersion;

// Strip range characters like ^, ~, >= if explicit version provided
return npmVersion.replace(/^[^\d]*/, '');
}

async function generateManifests() {
Expand Down Expand Up @@ -116,14 +132,19 @@ async function generateManifests() {

const dependencies = [];

for (const mod of modulesToInclude) {
if (devDeps[mod]) {
dependencies.push({
// Process modules in parallel to speed up npm fetches
const modulePromises = modulesToInclude
.filter((mod) => devDeps[mod])
.map(async (mod) => {
const version = await resolveModuleVersion(mod, devDeps[mod]);
return {
module_name: mod,
version: extractModuleVersion(devDeps[mod])
});
}
}
version: version
};
});

const resolvedModules = await Promise.all(modulePromises);
dependencies.push(...resolvedModules);

// Always add RP dependency
dependencies.push({
Expand Down
Loading
Loading