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); CodeFormatter formatter = new DefaultCodeFormatter(options);
// Format each file // Format each file
int successCount = 0; int changedCount = 0;
int errorCount = 0; int errorCount = 0;
for (int i = 1; i < args.length; i++) { for (int i = 1; i < args.length; i++) {
try { try {
formatFile(formatter, args[i]); if (formatFile(formatter, args[i])) {
successCount++; changedCount++;
}
} catch (Exception e) { } catch (Exception e) {
System.err.println("Error formatting " + args[i] + ": " + e.getMessage()); System.err.println("Error formatting " + args[i] + ": " + e.getMessage());
errorCount++; errorCount++;
} }
} }
System.out.println("Formatting complete: " + successCount + " files formatted, " + errorCount + " errors"); System.out.println("Formatting complete: " + changedCount + " files changed, " + errorCount + " errors");
if (errorCount > 0) { if (errorCount > 0) {
System.exit(1); 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; 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); Path path = Paths.get(filePath);
if (!Files.exists(path)) { if (!Files.exists(path)) {
@ -119,8 +120,10 @@ public class EclipseFormatter {
if (!content.equals(formatted)) { if (!content.equals(formatted)) {
Files.writeString(path, formatted); Files.writeString(path, formatted);
System.out.println("Formatted: " + filePath); System.out.println("Formatted: " + filePath);
return true;
} else { } 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 pushd "$dir" > /dev/null
# Build the Eclipse formatter if needed # 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..." echo "Building Eclipse formatter..."
pushd eclipse-formatter > /dev/null pushd eclipse-formatter > /dev/null
mvn -q clean package mvn -q clean package

View File

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

View File

@ -52,7 +52,7 @@ Bone::Bone(Bone &bone, Bone *parent)
} }
Bone *Bone::getParent() { Bone *Bone::getParent() {
return _parent; return _parent ;
} }
Array<Bone *> &Bone::getChildren() { Array<Bone *> &Bone::getChildren() {

View File

@ -73,7 +73,7 @@ namespace Spine {
bone = new Bone(boneData, parent); bone = new Bone(boneData, parent);
parent.children.Add(bone); parent.children.Add(bone);
} }
this.bones.Add(bone); this.bones.Add(bone) ;
} }
slots = new ExposedList<Slot>(data.slots.Count); slots = new ExposedList<Slot>(data.slots.Count);

View File

@ -102,7 +102,7 @@ class Skeleton {
* See Skeleton.update(). */ * See Skeleton.update(). */
public var time:Float = 0; public var time:Float = 0;
public var windX:Float = 1; public var windX:Float = 1 ;
public var windY:Float = 0; public var windY:Float = 0;
public var gravityX:Float = 0; public var gravityX:Float = 0;
public var gravityY:Float = 1; public var gravityY:Float = 1;

View File

@ -53,7 +53,7 @@ public class Bone extends PosedActive<BoneData, BoneLocal, BonePose> {
/** Copy constructor. Does not copy the {@link #getChildren()} bones. */ /** Copy constructor. Does not copy the {@link #getChildren()} bones. */
public Bone (Bone bone, @Null Bone parent) { public Bone (Bone bone, @Null Bone parent) {
this(bone.data, parent); this(bone.data, parent);
pose.set(bone.pose); pose.set(bone.pose) ;
} }
/** The parent bone, or null if this is the root bone. */ /** The parent bone, or null if this is the root bone. */

View File

@ -57,7 +57,7 @@ export class Bone extends PosedActive<BoneData, BoneLocal, BonePose> {
copy (parent: Bone | null): Bone { copy (parent: Bone | null): Bone {
const copy = new Bone(this.data, parent); const copy = new Bone(this.data, parent);
copy.pose.set(this.pose); copy.pose.set(this.pose);
return copy; return copy ;
} }
} }