Skip to content

Commit b5b32c0

Browse files
Merge remote-tracking branch 'origin/main' into feat/disable-key-naming-by-default
# Conflicts: # CHANGELOG.md # src/Command/ValidateTranslationCommand.php
2 parents 5cd3858 + 2ec30b1 commit b5b32c0

56 files changed

Lines changed: 2017 additions & 751 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/.gitattributes export-ignore
1010
/.gitignore export-ignore
1111
/.php-cs-fixer.php export-ignore
12+
/box.json export-ignore
1213
/codecov.yml export-ignore
1314
/composer.lock export-ignore
1415
/Dockerfile export-ignore

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
fetch-depth: 0
3131

3232
- name: Setup Node
33-
uses: actions/setup-node@v6
33+
uses: actions/setup-node@v7
3434
with:
3535
node-version: 24
3636
cache: npm

.github/workflows/phar.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: PHAR
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
pull_request:
7+
branches:
8+
- '**'
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
phar:
16+
runs-on: ubuntu-latest
17+
name: Build PHAR
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v7
21+
with:
22+
fetch-depth: 0
23+
persist-credentials: false
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: '8.4'
29+
extensions: libxml, mbstring, simplexml, dom, intl
30+
tools: composer, box
31+
32+
- name: Install Composer dependencies (production only)
33+
run: composer install --no-dev --no-interaction --no-progress
34+
35+
- name: Compile PHAR
36+
run: box compile --no-interaction
37+
38+
- name: Smoke test (valid files -> exit 0)
39+
run: php composer-translation-validator.phar tests/src/Fixtures/translations/xliff/success
40+
41+
- name: Smoke test (invalid files -> exit 1)
42+
run: |
43+
set +e
44+
php composer-translation-validator.phar tests/src/Fixtures/translations/xliff/fail
45+
code=$?
46+
set -e
47+
if [ "$code" -ne 1 ]; then
48+
echo "Expected exit code 1 for invalid fixtures, got $code" >&2
49+
exit 1
50+
fi
51+
52+
- name: Generate checksum
53+
if: startsWith(github.ref, 'refs/tags/')
54+
run: sha256sum composer-translation-validator.phar > composer-translation-validator.phar.sha256
55+
56+
- name: Attach PHAR to release
57+
if: startsWith(github.ref, 'refs/tags/')
58+
uses: softprops/action-gh-release@v2
59+
with:
60+
files: |
61+
composer-translation-validator.phar
62+
composer-translation-validator.phar.sha256

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
/tests/composer.lock
1111
/tests/vendor
1212

13+
# PHAR build artifacts
14+
/*.phar
15+
1316
# Node.js / VitePress
1417
node_modules/
1518
docs/.vitepress/cache/

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
- feat[!!!]: skip KeyNamingConventionValidator by default (opt-in to reduce false positives)
11+
- feat: provide a standalone PHAR distribution for CI and non-Composer projects
1112

1213
## [1.5.0] - 2026-06-29
1314

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Supports XLIFF, YAML, JSON and PHP translation files.
3232
composer require --dev move-elevator/composer-translation-validator
3333
```
3434

35+
Alternatively, a dependency-free [standalone PHAR](https://move-elevator.github.io/composer-translation-validator/getting-started/installation#standalone-phar) is available for CI or non-Composer projects.
36+
3537
## 📊 Usage
3638

3739
Validate your translation files by running the command:

bin/composer-translation-validator

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
declare(strict_types=1);
5+
6+
/*
7+
* This file is part of the "composer-translation-validator" Composer plugin.
8+
*
9+
* (c) 2025-2026 Konrad Michalik <km@move-elevator.de>
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
14+
15+
use MoveElevator\ComposerTranslationValidator\Command\StandaloneValidateTranslationCommand;
16+
use Symfony\Component\Console\Application;
17+
18+
(static function (): void {
19+
$autoloads = [
20+
__DIR__.'/../vendor/autoload.php', // running from source / inside the PHAR
21+
__DIR__.'/../../../autoload.php', // installed as a dependency
22+
];
23+
24+
foreach ($autoloads as $autoload) {
25+
if (is_file($autoload)) {
26+
require $autoload;
27+
28+
return;
29+
}
30+
}
31+
32+
fwrite(\STDERR, 'Composer autoloader not found. Run "composer install".'.\PHP_EOL);
33+
exit(1);
34+
})();
35+
36+
// Replaced with the git tag by Box at compile time; stays literal when run from
37+
// source. The '@' check must not reference the placeholder string itself,
38+
// otherwise Box would replace it here too.
39+
$version = '@git_version@';
40+
if (str_contains($version, '@')) {
41+
$version = 'dev';
42+
}
43+
44+
$application = new Application('composer-translation-validator', $version);
45+
// The PHAR bundles the Symfony version pinned in composer.lock (>= 8), where
46+
// Application::addCommand() replaced the removed add().
47+
$application->addCommand(new StandaloneValidateTranslationCommand());
48+
$application->setDefaultCommand('validate-translations', true);
49+
50+
exit($application->run());

box.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/box-project/box/main/res/schema.json",
3+
"main": "bin/composer-translation-validator",
4+
"output": "composer-translation-validator.phar",
5+
"compression": "GZ",
6+
"git": "git_version",
7+
"check-requirements": true,
8+
"exclude-dev-files": true,
9+
"blacklist": [
10+
"src/Plugin.php",
11+
"src/Capability/ValidateTranslationCommandProvider.php"
12+
]
13+
}

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
],
1313
"require": {
1414
"php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
15+
"ext-dom": "*",
1516
"ext-libxml": "*",
1617
"ext-mbstring": "*",
1718
"ext-simplexml": "*",
1819
"composer-plugin-api": "^1.0 || ^2.0",
1920
"justinrainbow/json-schema": "^5.3 || ^6.4",
21+
"nikic/php-parser": "^5.0",
2022
"psr/log": "^1.0 || ^2.0 || ^3.0",
2123
"symfony/config": "^6.0 || ^7.0 || ^8.0",
2224
"symfony/console": "^6.0 || ^7.0 || ^8.0",

0 commit comments

Comments
 (0)