Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
16 changes: 16 additions & 0 deletions .changeset/chatty-papers-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'gtx-cli': minor
'gt': minor
'@generaltranslation/react-core-linter': patch
'gt-next-middleware-e2e': patch
'gt-tanstack-start': patch
'@generaltranslation/react-core': patch
'@generaltranslation/gt-next-lint': patch
'next-ssg': patch
'@generaltranslation/compiler': patch
'locadex': patch
'gt-react': patch
'gt-next': patch
---

feat: add new gt package
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{ "repo": "generaltranslation/gt" }
],
"commit": false,
"fixed": [],
"fixed": [["gt", "gtx-cli"]],
"linked": [],
"access": "public",
"baseBranch": "main",
Expand Down
88 changes: 82 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,82 @@ jobs:
pnpm exec turbo build:turbopack --filter=general-cases...

test-cli-binaries:
strategy:
matrix:
include:
- os: ubuntu-latest
arch: x64
binary: gt-linux-x64
- os: ubuntu-latest
arch: arm64
binary: gt-linux-arm64
- os: macos-latest
arch: x64
binary: gt-darwin-x64
- os: macos-latest
arch: arm64
binary: gt-darwin-arm64
- os: windows-latest
arch: x64
binary: gt-win32-x64.exe
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check if CLI changed
id: gt_cli_changed
shell: bash
run: |
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q "^packages/cli/"; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi

- uses: pnpm/action-setup@v4
if: steps.gt_cli_changed.outputs.changed == 'true'
name: Install pnpm

- name: Setup Node.js
if: steps.gt_cli_changed.outputs.changed == 'true'
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'pnpm'

- name: Setup Bun
if: steps.gt_cli_changed.outputs.changed == 'true'
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Setup Rust
if: steps.gt_cli_changed.outputs.changed == 'true'
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip1

- name: Install dependencies
if: steps.gt_cli_changed.outputs.changed == 'true'
run: pnpm install

- name: Build packages
if: steps.gt_cli_changed.outputs.changed == 'true'
run: pnpm exec turbo build --filter='gt...'

- name: Build CLI binaries
if: steps.gt_cli_changed.outputs.changed == 'true'
run: cd packages/cli && pnpm run build:bin:clean

- name: Test CLI in test environment
if: steps.gt_cli_changed.outputs.changed == 'true'
shell: bash
run: cd tests/apps/cli-test-app && pnpm install && pnpm gt --help

test-gtx-cli-binaries:
strategy:
matrix:
include:
Expand All @@ -127,11 +203,11 @@ jobs:
with:
fetch-depth: 0

- name: Check if CLI changed
- name: Check if gtx-cli wrapper changed
id: gtx_cli_changed
shell: bash
run: |
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q "^packages/cli/"; then
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -qE "^packages/(cli|gtx-cli)/"; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -168,17 +244,17 @@ jobs:
if: steps.gtx_cli_changed.outputs.changed == 'true'
run: pnpm exec turbo build --filter='gtx-cli...'

- name: Build CLI binaries
- name: Build gtx-cli binaries
if: steps.gtx_cli_changed.outputs.changed == 'true'
run: cd packages/cli && pnpm run build:bin:clean
run: cd packages/gtx-cli && pnpm run build:bin:clean

- name: Test CLI in test environment
- name: Test gtx-cli in test environment
if: steps.gtx_cli_changed.outputs.changed == 'true'
shell: bash
run: cd tests/apps/cli-test-app && pnpm install && pnpm gtx-cli --help

run-tests:
needs: [tests, test-builds, test-cli-binaries]
needs: [tests, test-builds, test-cli-binaries, test-gtx-cli-binaries]
runs-on: ubuntu-latest
steps:
- run: echo "All tests passed"
64 changes: 59 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,66 @@ jobs:
event-type: release-published
client-payload: '{"publishedPackages": ${{ steps.changesets.outputs.publishedPackages }}}'

# gt (primary CLI package, lives in packages/cli/)
- name: Check if gt was published
id: check-gt
if: steps.changesets.outputs.published == 'true'
run: |
published_packages='${{ steps.changesets.outputs.publishedPackages }}'

if echo "$published_packages" | grep -q '"name": *"gt"'; then
echo "should_release_bin=true" >> $GITHUB_OUTPUT
else
echo "should_release_bin=false" >> $GITHUB_OUTPUT
fi

- name: Extract gt version
id: gt-version
if: steps.check-gt.outputs.should_release_bin == 'true'
run: |
published_packages='${{ steps.changesets.outputs.publishedPackages }}'
version=$(echo "$published_packages" | grep -A1 '"name": *"gt"' | grep '"version"' | sed 's/.*"version": *"\([^"]*\)".*/\1/')
echo "version=$version" >> $GITHUB_OUTPUT

- name: Build gt binaries
if: steps.check-gt.outputs.should_release_bin == 'true'
run: pnpm --filter gt run build:bin:clean

- name: Upload gt binaries to R2
if: steps.check-gt.outputs.should_release_bin == 'true'
uses: ryand56/r2-upload-action@v1.4
with:
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET_NAME }}
source-dir: packages/cli/binaries
destination-dir: cli/v${{ steps.gt-version.outputs.version }}

- name: Upload gt binaries to R2 (latest)
if: steps.check-gt.outputs.should_release_bin == 'true'
uses: ryand56/r2-upload-action@v1.4
with:
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET_NAME }}
source-dir: packages/cli/binaries
destination-dir: cli/latest

- name: Release gt binary to npm
if: steps.check-gt.outputs.should_release_bin == 'true'
run: pnpm --filter gt run bin:prep && pnpm --filter gt publish --tag bin --no-git-checks && pnpm --filter gt run bin:restore && pnpm --filter gt run build:clean
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# gtx-cli (backward-compat wrapper, lives in packages/gtx-cli/)
- name: Check if gtx-cli was published
id: check-gtx-cli
if: steps.changesets.outputs.published == 'true'
run: |
published_packages='${{ steps.changesets.outputs.publishedPackages }}'

if echo "$published_packages" | grep -q '"name": *"gtx-cli"'; then
echo "should_release_bin=true" >> $GITHUB_OUTPUT
else
Expand All @@ -103,8 +157,8 @@ jobs:
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET_NAME }}
source-dir: packages/cli/binaries
destination-dir: cli/v${{ steps.gtx-cli-version.outputs.version }}
source-dir: packages/gtx-cli/binaries
destination-dir: gtx-cli/v${{ steps.gtx-cli-version.outputs.version }}

- name: Upload gtx-cli binaries to R2 (latest)
if: steps.check-gtx-cli.outputs.should_release_bin == 'true'
Expand All @@ -114,8 +168,8 @@ jobs:
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
r2-bucket: ${{ secrets.R2_BUCKET_NAME }}
source-dir: packages/cli/binaries
destination-dir: cli/latest
source-dir: packages/gtx-cli/binaries
destination-dir: gtx-cli/latest

- name: Release gtx-cli binary to npm
if: steps.check-gtx-cli.outputs.should_release_bin == 'true'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Visit [https://generaltranslation.com/docs](https://generaltranslation.com/docs)
| [gt-next](packages/next) | Automatic i18n for Next.js |
| [gt-react](packages/react) | Automatic i18n for React |
| [gt-i18n](packages/i18n) | Pure JavaScript i18n library |
| [gtx-cli](packages/cli) | CLI tool for continuous localization |
| [gt](packages/cli) | CLI tool for continuous localization |
| [gt-sanity](packages/sanity) | Plugin for Sanity Studio v3 |
| [locadex](packages/locadex) | AI agent for automating i18n in complex codebases |
| [generaltranslation](packages/core) | Core TypeScript library (internal) |
Expand All @@ -45,7 +45,7 @@ Visit [https://generaltranslation.com/docs](https://generaltranslation.com/docs)
Run the setup wizard:

```bash
npx gtx-cli@latest
npx gt@latest
```

Or use [Locadex](https://generaltranslation.com/dashboard/api/integrations/github/start?returnTo=%2Fproject%2Flocadex) to set your project up for you.
Expand Down
28 changes: 14 additions & 14 deletions assets/install.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/sh
# gtx-cli installer
# gt CLI installer
# Usage: curl -fsSL https://assets.gtx.dev/install.sh | sh
#
# This script downloads and installs the gtx-cli binary for your platform.
# This script downloads and installs the gt CLI binary for your platform.

set -e

# Configuration
BASE_URL="https://assets.gtx.dev/cli/latest"
BINARY_NAME="gtx"
INSTALL_DIR="${GTX_INSTALL_DIR:-/usr/local/bin}"
BINARY_NAME="gt"
INSTALL_DIR="${GT_INSTALL_DIR:-/usr/local/bin}"

# Colors for output
RED='\033[0;31m'
Expand Down Expand Up @@ -69,9 +69,9 @@ get_download_url() {
local arch="$2"

if [ "$os" = "windows" ]; then
echo "${BASE_URL}/gtx-cli-win32-x64.exe"
echo "${BASE_URL}/gt-win32-x64.exe"
else
echo "${BASE_URL}/gtx-cli-${os}-${arch}"
echo "${BASE_URL}/gt-${os}-${arch}"
fi
}

Expand All @@ -85,7 +85,7 @@ download_binary() {
local url="$1"
local output="$2"

info "Downloading gtx-cli from ${url}..."
info "Downloading gt from ${url}..."

if command_exists curl; then
curl -fsSL "$url" -o "$output"
Expand All @@ -98,7 +98,7 @@ download_binary() {

# Main installation function
main() {
info "Installing gtx-cli..."
info "Installing gt..."

# Detect platform
local os=$(detect_os)
Expand All @@ -108,7 +108,7 @@ main() {

# Windows is not fully supported for this installer
if [ "$os" = "windows" ]; then
warn "Windows detected. Consider using npm install -g gtx-cli instead."
warn "Windows detected. Consider using npm install -g gt instead."
warn "Continuing with installation..."
arch="x64"
fi
Expand All @@ -118,7 +118,7 @@ main() {

# Create temp directory
local tmp_dir=$(mktemp -d)
local tmp_file="${tmp_dir}/gtx-cli"
local tmp_file="${tmp_dir}/gt"

# Download binary
download_binary "$url" "$tmp_file"
Expand All @@ -137,7 +137,7 @@ main() {
if command_exists sudo; then
sudo mv "$tmp_file" "$install_path"
else
error "Cannot write to ${INSTALL_DIR} and sudo is not available. Try setting GTX_INSTALL_DIR to a writable directory."
error "Cannot write to ${INSTALL_DIR} and sudo is not available. Try setting GT_INSTALL_DIR to a writable directory."
fi
fi

Expand All @@ -146,10 +146,10 @@ main() {

# Verify installation
if command_exists "$BINARY_NAME"; then
info "gtx-cli installed successfully!"
info "Run 'gtx-cli --help' to get started."
info "gt installed successfully!"
info "Run 'gt --help' to get started."
else
warn "gtx-cli was installed to ${install_path}"
warn "gt was installed to ${install_path}"
warn "Add the following to your shell profile (~/.bashrc, ~/.zshrc, etc.):"
warn " export PATH=\"${INSTALL_DIR}:\$PATH\""
fi
Expand Down
4 changes: 2 additions & 2 deletions examples/create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"@testing-library/react": "^16.2.0",
"@testing-library/user-event": "^13.5.0",
"gt-react": "latest",
"gtx-cli": "latest",
"gt": "latest",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "npx gtx-cli translate && react-scripts build",
"build": "npx gt translate && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/next-chatbot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev --turbo",
"build": "tsx lib/db/migrate && npx gtx-cli translate && next build",
"build": "tsx lib/db/migrate && npx gt translate && next build",
"start": "next start",
"lint": "next lint && biome lint --write --unsafe",
"lint:fix": "next lint --fix && biome lint --write --unsafe",
Expand Down Expand Up @@ -52,7 +52,7 @@
"framer-motion": "^11.3.19",
"geist": "^1.3.1",
"gt-next": "latest",
"gtx-cli": "latest",
"gt": "latest",
"lucide-react": "^0.446.0",
"nanoid": "^5.0.8",
"next": "15.5.9",
Expand Down
4 changes: 2 additions & 2 deletions examples/next-create-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "npx gtx-cli translate && next build",
"build": "npx gt translate && next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"gt-next": "latest",
"gtx-cli": "latest",
"gt": "latest",
"next": "15.5.9",
"react": "^19.2.3",
"react-dom": "^19.2.2"
Expand Down
Loading
Loading