Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
39 changes: 9 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
max-parallel: 3
matrix:
php:
- '8.0'
- '8.1'
- '8.2'
- '8.3'
Expand All @@ -20,33 +19,17 @@ jobs:
normalize: [ false ]
validate: [ false ]
laravel:
- '8.22'
- '9.0'
- '10.0'
- '11.0.3'
- '12.0'
- '10.48.29'
- '11.45.1'
- '12.19.3'
exclude:
- php: '8.0'
laravel: '9.0'
- php: '8.0'
laravel: '10.0'
- php: '8.1'
laravel: '8.22'
laravel: '11.45.1'
- php: '8.1'
laravel: '9.0'
- php: '8.2'
laravel: '8.22'
- php: '8.2'
laravel: '9.0'
- php: '8.3'
laravel: '8.22'
- php: '8.3'
laravel: '9.0'
- php: '8.4'
laravel: '12.0'
laravel: '12.19.3'
include:
- php: '8.0'
laravel: '9.39.0'
- php: '8.1'
laravel: '10.48.29'
analysis: true
coverage: 'xdebug'
normalize: true
Expand All @@ -69,9 +52,6 @@ jobs:
if: matrix.validate == true
run: composer validate --strict

- name: Install Laravel legacy factories support
if: matrix.laravel != '7.0'
run: composer require "laravel/legacy-factories:^1.1" --dev --no-interaction --no-update

#- name: Install Laravel and Orchestra Testbench
# run: composer require "illuminate/contracts:${{ matrix.laravel }}" --no-interaction --no-update
Expand All @@ -94,14 +74,13 @@ jobs:
run: composer install --prefer-dist --no-progress

- name: Normalize composer file
if: matrix.normalize == true && matrix.php != '8.0'
if: matrix.normalize == true
run: composer normalize --dry-run

- name: Run test suite
run: vendor/bin/phpunit -v
run: vendor/bin/phpunit

- name: Run static code analysis
if: matrix.analysis == true
run: vendor/bin/phpstan --memory-limit=-1

- name: Upload coverage results
Expand Down
1 change: 1 addition & 0 deletions .phpunit.cache/test-results

Large diffs are not rendered by default.

57 changes: 28 additions & 29 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "kyon147/laravel-shopify",
"description": "Shopify package for Laravel to aide in app development",
"license": "MIT",
"keywords": [
"api",
"callback-url",
Expand All @@ -16,36 +17,52 @@
"shopify-app",
"webhook"
],
"license": "MIT",
"authors": [
{
"name": "Luke (Kyon147)",
"email": "support@appydesign.co.uk"
}
],
"support": {
"issues": "https://github.com/Kyon147/laravel-shopify/issues",
"forum": "https://github.com/Kyon147/laravel-shopify/discussions",
"wiki": "https://github.com/Kyon147/laravel-shopify/wiki",
"source": "https://github.com/Kyon147/laravel-shopify"
},
"require": {
"php": "^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4",
"php": ">=8.1",
"ext-json": "*",
"funeralzone/valueobjects": "^0.5",
"gnikyt/basic-shopify-api": "^11.0",
"jenssegers/agent": "^2.6",
"laravel/framework": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"gnikyt/basic-shopify-api": "^9.0 || ^10.0 || ^11.0"
"laravel/framework": "^10.0 || ^11.0 || ^12.0"
},
"require-dev": {
"laravel/legacy-factories": "^v1.3.0",
"ergebnis/composer-normalize": "^2.8",
"friendsofphp/php-cs-fixer": "^3.0",
"laravel/legacy-factories": "^1.3.0",
"mockery/mockery": "^1.0",
"orchestra/database": "~3.8 || ~4.0 || ~5.0 || ~6.0 || ~7.0 || ~8.0 || ~9.0",
"orchestra/testbench": "~3.8 || ~4.0 || ~5.0 || ~6.0 || ~7.0 || ~8.0 || ~9.0",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "~8.0 || ^9.0 || ^10.0 || ^11.0"
"orchestra/testbench": "^8.0 || ^9.0",
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^8.0 || ^9.0 || ^10.0 || ^11.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Osiset\\ShopifyApp\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Osiset\\ShopifyApp\\Test\\": "tests/"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"ergebnis/composer-normalize": true
}
},
"sort-packages": true
},
"extra": {
"laravel": {
Expand All @@ -54,28 +71,10 @@
]
}
},
"autoload": {
"psr-4": {
"Osiset\\ShopifyApp\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Osiset\\ShopifyApp\\Test\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"lint": "vendor/bin/php-cs-fixer fix",
"test": "vendor/bin/phpunit",
"test-html-cov": "vendor/bin/phpunit --coverage-html ./build/html/",
"test-no-cov": "vendor/bin/phpunit --no-coverage"
},
"support": {
"issues": "https://github.com/Kyon147/laravel-shopify/issues",
"forum": "https://github.com/Kyon147/laravel-shopify/discussions",
"wiki": "https://github.com/Kyon147/laravel-shopify/wiki",
"source": "https://github.com/Kyon147/laravel-shopify"
}
}
19 changes: 19 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
parameters:
ignoreErrors:
-
message: '#^Deprecated in PHP 8\.4\: Parameter \#3 \$params \(array\) is implicitly nullable via default value null\.$#'
identifier: parameter.implicitlyNullable
count: 1
path: tests/Stubs/Api.php

-
message: '#^Deprecated in PHP 8\.4\: Parameter \#2 \$requestInstance \(Illuminate\\Http\\Request\) is implicitly nullable via default value null\.$#'
identifier: parameter.implicitlyNullable
count: 1
path: tests/TestCase.php

-
message: '#^Deprecated in PHP 8\.4\: Parameter \#3 \$cb \(Closure\) is implicitly nullable via default value null\.$#'
identifier: parameter.implicitlyNullable
count: 1
path: tests/TestCase.php
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
includes:
- phpstan-baseline.neon

parameters:
level: 1
paths:
- src
- tests
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#Access to an undefined property Osiset\\ShopifyApp\\Storage\\Models\\.*::\$.*\.#'
- '#Access to an undefined property Osiset\\ShopifyApp\\Test\\Stubs\\.*::\$.*\.#'
Expand Down
56 changes: 25 additions & 31 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.0/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
backupGlobals="false"
colors="true"
processIsolation="false"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="false"
stopOnSkipped="false"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<coverage>
<testsuites>
<testsuite name="Laravel Shopify Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging />
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF" />
<env name="SHOPIFY_API_KEY" value="00000000000000000000000000000000" />
<env name="SHOPIFY_API_SECRET" value="00000000000000000000000000000000" />
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
Expand All @@ -26,20 +35,5 @@
<directory>src/Messaging/Events/</directory>
<file>src/ShopifyAppProvider.php</file>
</exclude>
<report>
<clover outputFile="build/logs/clover.xml"/>
<text outputFile="php://stdout"/>
</report>
</coverage>
<testsuites>
<testsuite name="Laravel Shopify Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging/>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="SHOPIFY_API_KEY" value="00000000000000000000000000000000"/>
<env name="SHOPIFY_API_SECRET" value="00000000000000000000000000000000"/>
</php>
</source>
</phpunit>
34 changes: 34 additions & 0 deletions src/Actions/FetchMainTheme.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Osiset\ShopifyApp\Actions;

use Illuminate\Support\Facades\Log;
use Osiset\ShopifyApp\Contracts\ShopModel;

final class FetchMainTheme
{
/**
* @return array{id: ?string, name: ?string}
*/
public function handle(ShopModel $shop): array
{
$response = $shop->api()->graph('{
themes(first: 1, roles: MAIN) {
nodes {
id
name
}
}
}');

if (blank(data_get($response['body']->toArray(), 'data.themes.userErrors'))) {
return data_get($response['body']->toArray(), 'data.themes.nodes.0', []);
}

Log::error('Fetching main theme error: '.json_encode(data_get($response['body']->toArray(), 'data.themes.userErrors')));

return [];
}
}
49 changes: 49 additions & 0 deletions src/Actions/FetchThemeAssets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace Osiset\ShopifyApp\Actions;

use Illuminate\Support\Facades\Log;
use Osiset\ShopifyApp\Contracts\ShopModel;

final class FetchThemeAssets
{
/**
* @param array<int, array{filename: string, content: string}> $filenames
*/
public function handle(ShopModel $shop, string $mainThemeId, array $filenames): array
{
$response = $shop->api()->graph('query ($id: ID!, $filenames: [String!]) {
theme(id: $id) {
id
name
role
files(filenames: $filenames) {
nodes {
filename
body {
... on OnlineStoreThemeFileBodyText {
content
}
}
}
}
}
}', [
'id' => $mainThemeId,
'filenames' => $filenames,
]);

if (blank(data_get($response['body']->toArray(), 'data.theme.userErrors'))) {
return array_map(fn (array $data) => [
'filename' => $data['filename'],
'content' => $data['body']['content'] ?? '',
], data_get($response['body']->toArray(), 'data.theme.files.nodes'));
}

Log::error('Fetching settings data error: '.json_encode(data_get($response['body']->toArray(), 'data.theme.userErrors')));

return [];
}
}
Loading
Loading