Skip to content

Commit

Permalink
Switch to Laravel Pint
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanzweifel committed Dec 28, 2023
1 parent 9469989 commit 868cae7
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 65 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/laravel-pint-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Laravel Pint

on:
push:
branches:
- main

jobs:
pint:
uses: stefanzweifel/reusable-workflows/.github/workflows/laravel-pint-fixer.yml@main
11 changes: 0 additions & 11 deletions .github/workflows/php-cs-fixer.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.idea
.php_cs
.php_cs.cache
.phpunit.result.cache
build
composer.lock
Expand All @@ -11,6 +9,5 @@ phpstan.neon
testbench.yaml
vendor
node_modules
.php-cs-fixer.cache
.env
**/.DS_Store
40 changes: 0 additions & 40 deletions .php_cs.dist.php

This file was deleted.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
"spatie/laravel-package-tools": "^1.9.2"
},
"require-dev": {
"larastan/larastan": "^1.0|^2.0",
"laravel/pint": "^1.13",
"league/flysystem-aws-s3-v3": "^1.0|^2.0|^3.0",
"nunomaduro/collision": "^5.10|^6.0|^7.0|^8.0",
"larastan/larastan": "^1.0|^2.0",
"orchestra/testbench": "^6.22|^7.0|^8.0",
"pestphp/pest": "^1.21 | ^2.0",
"pestphp/pest-plugin-laravel": "^1.1 | ^2.0",
Expand Down
5 changes: 5 additions & 0 deletions config/sidecar-browsershot.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,37 @@
/**
* Define the allocated memory available to SidecarBrowsershot in megabytes. (Defaults to 2GB)
* We suggest to allocate at least 513 MB of memory to push Chrome/Puppeteer out of "low-spec" mode.
*
* @see https://hammerstone.dev/sidecar/docs/main/functions/customization#memory
* @see https://github.blog/2021-06-22-framework-building-open-graph-images/
*/
'memory' => env('SIDECAR_BROWSERSHOT_MEMORY', 2048),

/**
* The default ephemeral storage available to SidecarBrowsershot, in megabytes. (Defaults to 512MB)
*
* @see https://hammerstone.dev/sidecar/docs/main/functions/customization#storage
*/
'storage' => env('SIDECAR_BROWSERSHOT_STORAGE', 512),

/**
* The default timeout to use for SidecarBrowsershot, in seconds. (Defaults to 300)
*
* @see https://hammerstone.dev/sidecar/docs/main/functions/customization#timeout
*/
'timeout' => env('SIDECAR_BROWSERSHOT_TIMEOUT', 300),

/**
* Define the number of warming instances to boot.
*
* @see https://hammerstone.dev/sidecar/docs/main/functions/warming
*/
'warming' => env('SIDECAR_BROWSERSHOT_WARMING_INSTANCES', 0),

/**
* AWS Layer to use by Lambda. Defaults to "shelfio/chrome-aws-lambda-layer" in your AWS region.
* Must contain "chrome-aws-lambda".
*
* @see https://github.com/shelfio/chrome-aws-lambda-layer
* @deprecated
*/
Expand Down
17 changes: 8 additions & 9 deletions src/Functions/BrowsershotFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function package()
'browser.cjs' => $this->modifiedBrowserJs(),
])
->includeExactly([
__DIR__ . '/../../resources/lambda/browsershot.js' => 'browsershot.js',
__DIR__.'/../../resources/lambda/browsershot.js' => 'browsershot.js',
])
->includeExactly($this->customFonts());
}
Expand All @@ -41,14 +41,14 @@ protected function customFonts(): array
if (file_exists($fontDirectory)) {
// Loop through all files in the custom fonts folder.
foreach (scandir($fontDirectory) as $file) {
if (is_file($fontDirectory . $file)) {
$fonts->prepend("fonts/$file", $fontDirectory . $file);
if (is_file($fontDirectory.$file)) {
$fonts->prepend("fonts/$file", $fontDirectory.$file);
}
}
}

// By default, we include the NotoColorEmoji font.
$fonts->prepend('fonts/NotoColorEmoji.ttf', __DIR__ . '/../../resources/lambda/fonts/NotoColorEmoji.ttf');
$fonts->prepend('fonts/NotoColorEmoji.ttf', __DIR__.'/../../resources/lambda/fonts/NotoColorEmoji.ttf');

// Ensure that we only have unique font values.
return $fonts->unique()->toArray();
Expand All @@ -72,7 +72,7 @@ protected function modifiedBrowserJs()
$browser = str_replace('const puppet = (pup || require(\'puppeteer\'));', '', $browser);

// Use pupeteer-core instead.
return "const puppet = require('puppeteer-core'); \n" . $browser;
return "const puppet = require('puppeteer-core'); \n".$browser;
}

public function runtime()
Expand All @@ -86,7 +86,7 @@ public function memory()
}

/**
* @inheritDoc
* {@inheritDoc}
*/
public function storage()
{
Expand All @@ -95,7 +95,7 @@ public function storage()
}

/**
* @inheritDoc
* {@inheritDoc}
*/
public function timeout()
{
Expand All @@ -104,7 +104,7 @@ public function timeout()
}

/**
* @inheritDoc
* {@inheritDoc}
*/
public function architecture()
{
Expand All @@ -130,7 +130,6 @@ public function layers()
$chromeAwsLambdaVersion = 37;
}


// Add Layers that each contain `puppeteer-core` and `@sparticuz/chromium`
// https://github.com/stefanzweifel/sidecar-browsershot-layer
// https://github.com/shelfio/chrome-aws-lambda-layer
Expand Down
2 changes: 1 addition & 1 deletion tests/BrowsershotLambdaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
it('returns raw html from html', function () {
$html = BrowsershotLambda::html('<h1>Hello world!!</h1>')->bodyHtml();

$this->assertEquals("<html><head></head><body><h1>Hello world!!</h1></body></html>", $html);
$this->assertEquals('<html><head></head><body><h1>Hello world!!</h1></body></html>', $html);
});

it('throws LambdaExecutionException error if browsershot fails', function () {
Expand Down

0 comments on commit 868cae7

Please sign in to comment.