Fix TypeScript dependencies and optimize Eclipse formatter build

- Install npm dependencies if node_modules missing
- Only rebuild Eclipse formatter if source is newer than JAR
- Make Eclipse formatter less verbose
This commit is contained in:
Mario Zechner 2025-07-16 04:58:41 +02:00
parent 6a7707282e
commit 62b38f9da8
8 changed files with 27 additions and 13 deletions

View File

@ -27,20 +27,21 @@ public class EclipseFormatter {
CodeFormatter formatter = new DefaultCodeFormatter(options);
// Format each file
int successCount = 0;
int changedCount = 0;
int errorCount = 0;
for (int i = 1; i < args.length; i++) {
try {
formatFile(formatter, args[i]);
successCount++;
if (formatFile(formatter, args[i])) {
changedCount++;
}
} catch (Exception e) {
System.err.println("Error formatting " + args[i] + ": " + e.getMessage());
errorCount++;
}
}
System.out.println("Formatting complete: " + successCount + " files formatted, " + errorCount + " errors");
System.out.println("Formatting complete: " + changedCount + " files changed, " + errorCount + " errors");
if (errorCount > 0) {
System.exit(1);
@ -83,12 +84,12 @@ public class EclipseFormatter {
}
}
System.out.println("Loaded " + settings.size() + " formatter settings from " + xmlPath);
// Removed verbose output
return settings;
}
private static void formatFile(CodeFormatter formatter, String filePath) throws Exception {
private static boolean formatFile(CodeFormatter formatter, String filePath) throws Exception {
Path path = Paths.get(filePath);
if (!Files.exists(path)) {
@ -119,8 +120,10 @@ public class EclipseFormatter {
if (!content.equals(formatted)) {
Files.writeString(path, formatted);
System.out.println("Formatted: " + filePath);
return true;
} else {
System.out.println("No changes: " + filePath);
// Silent when no changes
return false;
}
}
}

View File

@ -10,7 +10,10 @@ dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
pushd "$dir" > /dev/null
# Build the Eclipse formatter if needed
if [ ! -f "eclipse-formatter/target/eclipse-formatter-1.0.0-jar-with-dependencies.jar" ]; then
jar_file="eclipse-formatter/target/eclipse-formatter-1.0.0-jar-with-dependencies.jar"
src_file="eclipse-formatter/src/main/java/com/esotericsoftware/spine/formatter/EclipseFormatter.java"
if [ ! -f "$jar_file" ] || [ "$src_file" -nt "$jar_file" ]; then
echo "Building Eclipse formatter..."
pushd eclipse-formatter > /dev/null
mvn -q clean package

View File

@ -19,10 +19,18 @@ fi
# Format TypeScript files
pushd ../spine-ts > /dev/null
if [ ! -d "node_modules" ]; then
echo "Installing spine-ts dependencies..."
npm install
fi
npm run format
popd > /dev/null
pushd ../tests > /dev/null
if [ ! -d "node_modules" ]; then
echo "Installing tests dependencies..."
npm install
fi
npm run format
popd > /dev/null