Skip to content

Commit 3046b11

Browse files
committed
Set up local testing infrastructure for Kempt pre-release.
1 parent 17f568f commit 3046b11

3 files changed

Lines changed: 158 additions & 5 deletions

File tree

install-local.sh

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
3+
# Script to install Kempt locally for testing
4+
# This script sets up the pre-release version of Kempt for use in other projects
5+
6+
set -e
7+
8+
KEMPT_PACKAGE_PATH="/Users/craig/projects/kempt/local-packages/kempt-2.7.1-beta.1.tgz"
9+
PROJECTS_DIR="/Users/craig/projects"
10+
11+
# Check if the package exists
12+
if [[ ! -f "$KEMPT_PACKAGE_PATH" ]]; then
13+
echo "Error: Package not found at $KEMPT_PACKAGE_PATH"
14+
echo "Please run 'just pack' to create the package first"
15+
exit 1
16+
fi
17+
18+
# Function to set up Kempt for a project
19+
setup_kempt() {
20+
local project_path="$1"
21+
local project_name=$(basename "$project_path")
22+
23+
if [[ ! -d "$project_path" ]]; then
24+
echo "Skipping $project_name - directory not found"
25+
return
26+
fi
27+
28+
echo "Setting up Kempt for $project_name..."
29+
30+
# Check if it's a Node.js project
31+
if [[ -f "$project_path/package.json" ]]; then
32+
echo "📦 Node.js project detected - installing via npm"
33+
cd "$project_path"
34+
npm install --save-dev "$KEMPT_PACKAGE_PATH"
35+
36+
# Update prettier config if it exists
37+
if [[ -f .prettierrc.js ]]; then
38+
echo "Updating .prettierrc.js for $project_name..."
39+
sed -i '' 's/prettier-plugin-java/kempt/g' .prettierrc.js
40+
fi
41+
42+
if [[ -f .prettierrc.json ]]; then
43+
echo "Updating .prettierrc.json for $project_name..."
44+
sed -i '' 's/prettier-plugin-java/kempt/g' .prettierrc.json
45+
fi
46+
47+
if [[ -f .prettierrc ]]; then
48+
echo "Updating .prettierrc for $project_name..."
49+
sed -i '' 's/prettier-plugin-java/kempt/g' .prettierrc
50+
fi
51+
52+
echo "✅ Kempt installed successfully in $project_name"
53+
54+
# Check if it's a mise-based project
55+
elif [[ -f "$project_path/mise.toml" || -f "$project_path/.mise.toml" ]]; then
56+
echo "🔧 mise-based project detected"
57+
echo "📋 To use Kempt in $project_name:"
58+
echo " 1. Add to your mise.toml:"
59+
echo " \"npm:kempt\" = \"file:$KEMPT_PACKAGE_PATH\""
60+
echo " 2. Run: mise install"
61+
echo " 3. Update your justfile to use 'kempt' instead of 'prettier-plugin-java'"
62+
echo " 4. Or use directly: npx kempt --write '**/*.java'"
63+
64+
# Check if it's a Maven project
65+
elif [[ -f "$project_path/pom.xml" ]]; then
66+
echo "☕ Maven project detected"
67+
echo "📋 To use Kempt in $project_name:"
68+
echo " 1. Extract the package to a local directory:"
69+
echo " tar -xzf $KEMPT_PACKAGE_PATH -C /tmp/"
70+
echo " 2. Install the extracted package globally:"
71+
echo " npm install -g /tmp/package"
72+
echo " 3. Update your Maven configuration to use 'kempt' instead of 'prettier-plugin-java'"
73+
echo " 4. Or use directly: npx kempt --write '**/*.java'"
74+
75+
else
76+
echo "❓ Project type not recognized for $project_name"
77+
echo "📋 To use Kempt manually:"
78+
echo " 1. Extract and install the package:"
79+
echo " tar -xzf $KEMPT_PACKAGE_PATH -C /tmp/"
80+
echo " npm install -g /tmp/package"
81+
echo " 2. Use directly: npx kempt --write '**/*.java'"
82+
fi
83+
84+
echo ""
85+
}
86+
87+
# Set up in liftwizard
88+
setup_kempt "$PROJECTS_DIR/liftwizard"
89+
90+
# Set up in klass
91+
setup_kempt "$PROJECTS_DIR/klass"
92+
93+
# Return to original directory
94+
cd "$PROJECTS_DIR/kempt"
95+
96+
echo "🎉 Setup complete!"
97+
echo ""
98+
echo "📦 Package created at: $KEMPT_PACKAGE_PATH"
99+
echo "🧪 To test the formatting, you can run:"
100+
echo " npx kempt --write '**/*.java'"
101+
echo ""
102+
echo "💡 For Maven projects using Spotless, update your pom.xml to use 'kempt' instead of 'prettier-plugin-java'"

justfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Kempt - Prettier Java Plugin with Allman-style braces
2+
3+
# List all available commands
4+
default:
5+
@just --list --unsorted
6+
7+
# Build the project
8+
build:
9+
yarn build
10+
11+
# Run tests
12+
test:
13+
yarn test
14+
15+
# Run lint
16+
lint:
17+
yarn lint
18+
19+
# Run all checks (build, lint, test)
20+
ci:
21+
yarn ci
22+
23+
# Create a local package for testing
24+
pack:
25+
#!/usr/bin/env bash
26+
set -euo pipefail
27+
28+
# Ensure local-packages directory exists
29+
mkdir -p local-packages
30+
31+
# Create the package
32+
npm pack --pack-destination=./local-packages ./packages/prettier-plugin-java
33+
34+
echo "✅ Package created successfully!"
35+
echo "📦 Package location: ./local-packages/kempt-$(node -pe "require('./packages/prettier-plugin-java/package.json').version").tgz"
36+
37+
# Install the local package in other projects
38+
install-local:
39+
./install-local.sh
40+
41+
# Clean build artifacts
42+
clean:
43+
rm -rf packages/prettier-plugin-java/dist
44+
rm -rf packages/java-parser/dist
45+
rm -rf local-packages/*.tgz
46+
rm -rf node_modules
47+
rm -rf packages/*/node_modules
48+
49+
# Update test outputs
50+
update-test-outputs:
51+
yarn update-test-outputs

packages/prettier-plugin-java/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "prettier-plugin-java",
3-
"version": "2.7.4",
4-
"description": "Prettier Java Plugin",
2+
"name": "kempt",
3+
"version": "2.7.4-beta.1",
4+
"description": "Kempt - Prettier Java Plugin with Allman-style braces",
55
"type": "module",
66
"exports": {
77
"types": "./dist/index.d.ts",
@@ -10,8 +10,8 @@
1010
"files": [
1111
"dist"
1212
],
13-
"homepage": "https://jhipster.github.io/prettier-java/",
14-
"repository": "https://github.com/jhipster/prettier-java",
13+
"homepage": "https://github.com/craig-at-metaswitch/kempt",
14+
"repository": "https://github.com/craig-at-metaswitch/kempt",
1515
"license": "Apache-2.0",
1616
"dependencies": {
1717
"java-parser": "3.0.1"

0 commit comments

Comments
 (0)