Skip to content

Commit

Permalink
Upgrade to Craft v4
Browse files Browse the repository at this point in the history
  • Loading branch information
peteeveleigh authored and johnnynotsolucky committed Sep 11, 2023
1 parent 8c61618 commit c22f8f2
Show file tree
Hide file tree
Showing 131 changed files with 2,490 additions and 2,470 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
@@ -0,0 +1,18 @@
# EditorConfig is awesome: https://EditorConfig.org

# Top-most EditorConfig file
root = true

# All files
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

# PHP files
[{*.php,*.json}]
indent_style = space
indent_size = 4
10 changes: 6 additions & 4 deletions .github/workflows/test.yml
@@ -1,13 +1,15 @@
name: Codeception

on:
workflow_dispatch:
push:
branches:
- master
- main
- develop
- craft4
pull_request:
branches:
- master
- main

jobs:
test:
Expand All @@ -17,7 +19,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ["7.1", "7.2", "7.3", "7.4"]
php-versions: ["8.0", "8.1"]
db: ["mysql", "pgsql"]
env:
DEFAULT_COMPOSER_FLAGS: "--no-interaction --no-ansi --no-progress --no-suggest"
Expand Down Expand Up @@ -50,7 +52,7 @@ jobs:
- uses: actions/checkout@v2

- name: Setup PHP Action
uses: shivammathur/setup-php@2.5.0
uses: shivammathur/setup-php@2.25.5
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, gd, imagick, zip, dom, pdo_mysql, pdo_pgsql, fileinfo
Expand Down
13 changes: 11 additions & 2 deletions changelog.md
@@ -1,5 +1,14 @@
# Snipcart Changelog

## 2.0 - 2023-09-11

- Update plugin to work with Craft 4
- Move to using native Craft content table instead of custom `product_details` table
- Add migration to move product data from the custom `product_details` table to Craft native content tables
- Add convenience console command to remove legacy `product_details` table when required
- Command is `snipcart/cleanup`
- Removes legacy class alias for field type

## 1.6.0 - 2023-06-20

### Added
Expand Down Expand Up @@ -108,7 +117,7 @@
### Fixed
- Fixed custom email notifications.
- Order notification email subjects are now translatable.
- Admin order email notifications will only display a ShipStation ID when it’s not empty.
- Admin order email notifications will only display a ShipStation ID when it’s not empty.

### Changed
- The Recent Orders summary now uses relative timestamps rather than `m/d` format.
Expand Down Expand Up @@ -324,7 +333,7 @@

## 1.0.3 - 2019-03-05
### Fixed
- Fixed a bug where passing a `null` value for Product Details `customOptions` would throw a warning in PHP 7.2.
- Fixed a bug where passing a `null` value for Product Details `customOptions` would throw a warning in PHP 7.2.

## 1.0.2 - 2019-03-04
### Fixed
Expand Down
28 changes: 22 additions & 6 deletions composer.json
Expand Up @@ -2,13 +2,13 @@
"name": "fostercommerce/craft-snipcart",
"description": "Craft CMS e-commerce in a day.",
"type": "craft-plugin",
"version": "1.6.0",
"version": "2.0.0",
"keywords": [
"craft",
"cms",
"craftcms",
"craft-plugin",
"craft3",
"craft4",
"snipcart"
],
"support": {
Expand All @@ -24,14 +24,17 @@
],
"require": {
"php": "^8.0",
"craftcms/cms": "^3.3.0",
"craftcms/cms": "^4.0.0",
"pelago/emogrifier": "*"
},
"require-dev": {
"roave/security-advisories": "dev-master",
"craftcms/ecs": "dev-main",
"craftcms/phpstan": "dev-main",
"craftcms/rector": "dev-main",
"roave/security-advisories": "dev-latest",
"fakerphp/faker": "^1.23",
"vlucas/phpdotenv": "^3.4",
"codeception/codeception": "^4.0.0",
"fzaninotto/faker": "^1.8",
"codeception/module-phpbrowser": "^1.0.0",
"codeception/module-asserts": "^1.0.0",
"codeception/module-rest": "^1.0.0",
Expand All @@ -44,7 +47,11 @@
}
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"yiisoft/yii2-composer": true,
"craftcms/plugin-installer": true
}
},
"extra": {
"name": "Snipcart",
Expand All @@ -53,5 +60,14 @@
"hasCpSection": true,
"changelogUrl": "https://github.com/FosterCommerce/snipcart-craft-plugin/changelog.md",
"class": "fostercommerce\\snipcart\\Snipcart"
},
"prefer-stable": true,
"minimum-stability": "dev",
"scripts": {
"phpstan": "phpstan --memory-limit=1G",
"ecs-check": "ecs check --ansi --memory-limit=1G",
"ecs-fix": "ecs check --ansi --fix --memory-limit=1G",
"rector": "rector process",
"rector-dry-run": "rector process --dry-run"
}
}
32 changes: 32 additions & 0 deletions ecs.php
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

use craft\ecs\SetList as CraftSetList;
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function(ECSConfig $ecsConfig): void {
$ecsConfig->parallel();
$ecsConfig->paths([
__DIR__ . '/src',
__FILE__,
]);

$ecsConfig->sets([
SetList::ARRAY,
SetList::COMMENTS,
// SetList::CONTROL_STRUCTURES,
SetList::DOCBLOCK,
SetList::NAMESPACES,
SetList::PHPUNIT,
SetList::SPACES,
SetList::STRICT,
SetList::CLEAN_CODE,
SetList::PSR_12,
CraftSetList::CRAFT_CMS_4,
]);

$ecsConfig->services()->remove(DeclareStrictTypesFixer::class);
};
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "snipcart-craft-plugin",
"version": "1.5.1.1",
"version": "2.1.1",
"description": "![Snipcart](resources/hero.svg)",
"directories": {
"doc": "docs",
Expand Down
7 changes: 7 additions & 0 deletions phpstan.neon
@@ -0,0 +1,7 @@
includes:
- vendor/craftcms/phpstan/phpstan.neon

parameters:
level: 0
paths:
- src
41 changes: 41 additions & 0 deletions rector.php
@@ -0,0 +1,41 @@
<?php
declare(strict_types = 1);

use craft\rector\SetList as CraftSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Config\RectorConfig;

return static function(RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__FILE__,
]);

$rectorConfig->importNames(true, false);
$rectorConfig->importShortClasses(false);

$rectorConfig->sets([
SetList::PHP_80,
SetList::PHP_74,
SetList::PHP_73,
SetList::PHP_72,
SetList::PHP_71,
SetList::PHP_70,
SetList::PHP_56,
SetList::PHP_55,
SetList::PHP_54,
SetList::PHP_53,
SetList::PHP_52,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
// SetList::DEAD_CODE,
SetList::STRICT_BOOLEANS,
SetList::NAMING,
SetList::TYPE_DECLARATION,
SetList::EARLY_RETURN,
// SetList::INSTANCEOF,
CraftSetList::CRAFT_CMS_40,
CraftSetList::CRAFT_COMMERCE_40,
]);

};

0 comments on commit c22f8f2

Please sign in to comment.