Skip to content

Commit

Permalink
Merge branch 'main' into feat/optional
Browse files Browse the repository at this point in the history
  • Loading branch information
innocenzi authored Aug 30, 2024
2 parents 54d10e4 + 3a79c0c commit bfef506
Show file tree
Hide file tree
Showing 18 changed files with 354 additions and 348 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/psalm.yml

This file was deleted.

21 changes: 16 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,31 @@ jobs:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [8.0, 8.1]
laravel: [ 8.*, 9.* ]
php: [ 8.1, 8.2, 8.3 ]
laravel: [ 8.*, 9.* , 10.*, 11.* ]
dependency-version: [ prefer-lowest, prefer-stable ]
include:
- laravel: 8.*
testbench: 6.*
testbench: ^6.25
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*
exclude:
- php: 8.1
laravel: 11.*
- php: 8.2
laravel: 8.*
- php: 8.3
laravel: [8.*,9.*]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Cache dependencies
uses: actions/cache@v2
Expand All @@ -43,4 +54,4 @@ jobs:
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
- name: Execute tests
run: vendor/bin/phpunit
run: vendor/bin/pest
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ coverage
.idea
.php_cs.cache
.php-cs-fixer.cache

.idea
60 changes: 60 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,66 @@

All notable changes to `typescript-transformer` will be documented in this file

## 2.4.1 - 2024-05-03

### What's Changed

* Let artisan handle the exceptions by @Tofandel in https://github.com/spatie/laravel-typescript-transformer/pull/41
*

**Full Changelog**: https://github.com/spatie/laravel-typescript-transformer/compare/2.4.0...2.4.1

## 2.4.0 - 2024-02-16

- Laravel 11 support

**Full Changelog**: https://github.com/spatie/laravel-typescript-transformer/compare/2.3.2...2.4.0

## 2.3.2 - 2023-12-01

- Use Laravel typescript transformer by default (#34)
- Replace CarbonInterface with a string (#33)

## 2.3.1 - 2023-10-12

- Replace CarbonInterface with a string (#33)

## 2.3.0 - 2023-04-14

- Drop support for PHP 8.0
- Enable collecting of enums by default

## 2.2.0 - 2023-03-24

- Add a native enum transformer by default

## 2.1.7 - 2023-01-24

### What's Changed

- Refactor tests to pest by @AyoobMH in https://github.com/spatie/laravel-typescript-transformer/pull/18
- Add Laravel 10 support by @njoguamos in https://github.com/spatie/laravel-typescript-transformer/pull/20

### New Contributors

- @AyoobMH made their first contribution in https://github.com/spatie/laravel-typescript-transformer/pull/18
- @njoguamos made their first contribution in https://github.com/spatie/laravel-typescript-transformer/pull/20

**Full Changelog**: https://github.com/spatie/laravel-typescript-transformer/compare/2.1.6...2.1.7

## 2.1.6 - 2022-11-18

- composer bump for typescript-transformer
- add test suite for php 8.2

## 2.1.5 - 2022-08-22

- do not fail when spatie/enum is not installed

## 2.1.4 - 2022-08-22

- use package service provider to fix publishing config

## 2.1.3 - 2022-01-25

## What's Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ This will be transformed to:

```ts
export type User = {
int: number;
id: number;
name: string;
address: string | null;
}
Expand Down
37 changes: 21 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@
}
],
"require" : {
"php" : "^8.0",
"spatie/typescript-transformer" : "^2.1.3",
"illuminate/console" : "^8.69|^9.0"
"php": "^8.1",
"illuminate/console": "^8.83|^9.30|^10.0|^11.0",
"spatie/laravel-package-tools": "^1.12",
"spatie/typescript-transformer" : "^2.1.13"
},
"require-dev" : {
"orchestra/testbench" : "^6.0|^7.0",
"mockery/mockery" : "^1.4",
"phpunit/phpunit" : "^9.0",
"spatie/temporary-directory" : "^1.2",
"spatie/phpunit-snapshot-assertions": "^4.2",
"spatie/data-transfer-object" : "^2.0",
"friendsofphp/php-cs-fixer": "^3.0",
"spatie/laravel-model-states" : "^1.6|^2.0",
"spatie/enum" : "^3.0",
"vimeo/psalm": "^4.2"
"mockery/mockery": "^1.4",
"nesbot/carbon": "^2.63",
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0",
"pestphp/pest": "^1.22|^2.0",
"phpunit/phpunit": "^9.0|^10.0|^11.0",
"spatie/data-transfer-object": "^2.0",
"spatie/enum": "^3.0",
"spatie/laravel-model-states": "^1.6|^2.0",
"spatie/pest-plugin-snapshots": "^1.1|^2.0",
"spatie/phpunit-snapshot-assertions": "^4.2|^5.0",
"spatie/temporary-directory": "^1.2"
},
"autoload" : {
"psr-4" : {
Expand All @@ -43,13 +46,15 @@
}
},
"scripts" : {
"test" : "vendor/bin/phpunit",
"test-coverage" : "vendor/bin/phpunit --coverage-html coverage",
"psalm": "./vendor/bin/psalm -c psalm.xml",
"test" : "vendor/bin/pest",
"test-coverage" : "vendor/bin/pest --coverage",
"format": "./vendor/bin/php-cs-fixer fix --allow-risky=yes"
},
"config" : {
"sort-packages" : true
"sort-packages" : true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
},
"extra" : {
"laravel" : {
Expand Down
7 changes: 5 additions & 2 deletions config/typescript-transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
/*
* Collectors will search for classes in the `auto_discover_types` paths and choose the correct
* transformer to transform them. By default, we include a DefaultCollector which will search
* for @typescript annotated and ![TypeScript] attributed classes to transform.
* for @typescript annotated and #[TypeScript] attributed classes to transform.
*/

'collectors' => [
Spatie\TypeScriptTransformer\Collectors\DefaultCollector::class,
Spatie\TypeScriptTransformer\Collectors\EnumCollector::class,
],

/*
Expand All @@ -27,8 +28,9 @@

'transformers' => [
Spatie\LaravelTypeScriptTransformer\Transformers\SpatieStateTransformer::class,
Spatie\TypeScriptTransformer\Transformers\EnumTransformer::class,
Spatie\TypeScriptTransformer\Transformers\SpatieEnumTransformer::class,
Spatie\TypeScriptTransformer\Transformers\DtoTransformer::class,
Spatie\LaravelTypeScriptTransformer\Transformers\DtoTransformer::class,
],

/*
Expand All @@ -40,6 +42,7 @@
'default_type_replacements' => [
DateTime::class => 'string',
DateTimeImmutable::class => 'string',
Carbon\CarbonInterface::class => 'string',
Carbon\CarbonImmutable::class => 'string',
Carbon\Carbon::class => 'string',
],
Expand Down
45 changes: 19 additions & 26 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Spatie Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<testsuites>
<testsuite name="Spatie Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
28 changes: 28 additions & 0 deletions phpunit.xml.dist.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Spatie Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
4 changes: 2 additions & 2 deletions src/Commands/TypeScriptTransformCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public function handle(

try {
$this->ensureConfiguredCorrectly();

$collection = $transformer->transform();
} catch (Exception $exception) {
$this->error($exception->getMessage());

return 1;
}

$collection = $transformer->transform();

$this->table(
['PHP class', 'TypeScript entity'],
collect($collection)->map(fn (TransformedType $type, string $class) => [
Expand Down
27 changes: 9 additions & 18 deletions src/TypeScriptTransformerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,24 @@
namespace Spatie\LaravelTypeScriptTransformer;

use Illuminate\Support\Arr;
use Illuminate\Support\ServiceProvider;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Spatie\LaravelTypeScriptTransformer\Commands\TypeScriptTransformCommand;
use Spatie\TypeScriptTransformer\TypeScriptTransformerConfig;
use Spatie\TypeScriptTransformer\Writers\TypeDefinitionWriter;

class TypeScriptTransformerServiceProvider extends ServiceProvider
class TypeScriptTransformerServiceProvider extends PackageServiceProvider
{
public function boot(): void
public function configurePackage(Package $package): void
{
if ($this->app->runningInConsole()) {
$this->commands([
TypeScriptTransformCommand::class,
]);
}

$this->publishes([
__DIR__ . '/../config/typescript-transformer.php' => config_path('typescript-transformer.php'),
]);
$package
->name('laravel-typescript-transformer')
->hasConfigFile()
->hasCommand(TypeScriptTransformCommand::class);
}

public function register(): void
public function packageRegistered(): void
{
$this->mergeConfigFrom(
__DIR__ . '/../config/typescript-transformer.php',
'typescript-transformer'
);

$this->app->bind(
TypeScriptTransformerConfig::class,
fn () => TypeScriptTransformerConfig::create()
Expand Down
Loading

0 comments on commit bfef506

Please sign in to comment.