Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support HPOS #2

Merged
merged 6 commits into from
Dec 13, 2024
Merged
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trim_trailing_whitespace = true
indent_style = tab
indent_size = 4

[{.jshintrc,*.json,*.yml}]
[{.jshintrc,*.yml}]
indent_style = space
indent_size = 2

Expand Down
32 changes: 32 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Exclude these files from release archives.
#
/.browserslistrc export-ignore
/.editorconfig export-ignore
/.eslintrc export-ignore
/.git export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/.wp-env.json export-ignore
/bin export-ignore
/composer.template.yaml export-ignore
/composer.lock export-ignore
/package.json export-ignore
/package-lock.json export-ignore
/phpcs.ruleset.xml export-ignore
/phpunit.xml.dist export-ignore
/stylelint.config.js export-ignore
/tests export-ignore
/webpack.config.js export-ignore

/hametwoo.php export-ignore

#
# Auto detect text files and perform LF normalization
# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
#
* text=auto
*.md text
*.php text
*.json text
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI/CD

on:
pull_request:
branches:
- master
jobs:
# WordPress.org が治ったらもどす
# test:
# name: PHP Unit Test
# strategy:
# matrix:
# php: [ '8.2' ] #PHP versions to check.
# wp: [ 'latest' ] # WordPress version to check.
# uses: tarosky/workflows/.github/workflows/wp-unit-test.yml@main
# with:
# php_version: ${{ matrix.php }}
# wp_version: ${{ matrix.wp }}

lint:
name: PHP Syntax compatibility check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install Composer
run: composer install --no-interaction --no-progress --optimize-autoloader

- name: Run PHP Lint
run: composer lint

short-open-tag:
uses: tarosky/workflows/.github/workflows/php-short-open-tag.yml@main

status-check:
name: Status Check
runs-on: ubuntu-latest
if: always()
needs: [ short-open-tag, lint ]
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.DS_Store
Thumbs.db
wp-cli.local.yml
node_modules/
vendor/

composer.lock
/node_modules/
/vendor/
/wordpress/
.wp_install_path
*.cache
compose.yaml
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"phpVersion": "8.1",
"core": "WordPress/WordPress#6.6.2",
"config": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": true,
"WP_DEBUG_DISPLAY": true,
"WPMS_ON": true,
"WPMS_SMTP_HOST": "mailhog",
"WPMS_SMTP_PORT": 1025,
"WPMS_MAILER": "smtp",
"HAMAIL_DEBUG": true
},
"plugins": [
".",
"https://downloads.wordpress.org/plugin/query-monitor.latest-stable.zip",
"https://downloads.wordpress.org/plugin/woocommerce.7.9.1.zip",
"https://downloads.wordpress.org/plugin/wp-mail-smtp.latest-stable.zip"
],
"lifecycleScripts": {
"afterStart": "bash bin/after-start-scripts.sh"
}
}
52 changes: 50 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,70 @@
# hametwoo

A utility classes for WooCommerce development.

[![Build Status](https://travis-ci.org/hametuha/hametwoo.svg)](https://travis-ci.org/hametuha/hametwoo)

## How to Use

Include via composer. In your compsoer.json:
Include via composer. In your composer.json:

```
{
"require": {
"hametuha/hametwoo": "~0.8"
"hametuha/hametwoo": "~0.9"
}
}
```

This library is useful for making Payment Gateways.

## Development

Composer, Node.js, and Docker are required. At first, clone GitHub repository.

```
git clone git@github.com:hametuha/hametwoo.git
```

Then install dependencies.

```
composer install
npm install
```

Run local environment.

```
npm start
```

Run test.

```
# PHP Unit test in Docker.
npm test
# PHP Code Sniffer
composer lint
# PHP Code Beautifier
composer format
```

To enable mailhog for debug, follow the instruction below.

```
# Get docker container ID.
# Notice: run npm start before this step.
npm run path
# You will get container ID at the base name e.g. 0597019337936df00cda1cf5a15016e0
# Save it as .wp_install_path
touch .wp_install_path
echo 0597019337936df00cda1cf5a15016e0 > .wp_install_path
# Restart docker.
npm run update
# Open http://localhost:8025
```

## License

GPL 3.0 and later.
Expand Down
16 changes: 16 additions & 0 deletions bin/after-start-scripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 1. .wp_install_path からハッシュ値を読み込む、なければ終了。
if [ ! -f .wp_install_path ]; then
echo ".wp_install_path File not found. Skip installation mailhog"
exit 0
fi
hash_value=$(cat .wp_install_path)

# 2. Replace %network% in compose.template.yaml with hash
sed "s/%NETWORK_NAME%/${hash_value}/g" compose.template.yaml > compose.yaml

# 3. Display status
echo "Hash: ${hash_value} in compose.yml"

docker compose up -d

echo "mailhog http://localhost:8025"
4 changes: 0 additions & 4 deletions bin/hametwoo-sniff.sh

This file was deleted.

22 changes: 22 additions & 0 deletions compose.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
volumes:
maildir: {}

services:
mail:
image: mailhog/mailhog
container_name: mailhog
ports:
- 1025:1025
- 8025:8025
environment:
MH_STORAGE: maildir
MH_MAILDIR_PATH: /tmp
volumes:
- maildir:/tmp
networks:
- wpnetwork

networks:
wpnetwork:
name: %NETWORK_NAME%_default
external: true
78 changes: 54 additions & 24 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,56 @@
{
"name": "hametuha/hametwoo",
"description": "A utility classes for WooCommerce development",
"type": "library",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "fumikito",
"email": "guy@hametuha.com"
}
],
"minimum-stability": "stable",
"require": {
"php": ">=5.4"
},
"require-dev": {
"phpunit/phpunit": "~4.8",
"squizlabs/php_codesniffer": "~2.8",
"wp-coding-standards/wpcs": "~0.11"
},
"autoload": {
"psr-0": {
"Hametuha\\HametWoo": "src/"
}
}
"name": "hametuha/hametwoo",
"description": "A utility classes for WooCommerce development",
"type": "library",
"scripts": {
"test": "phpunit",
"lint": "phpcs --standard=phpcs.ruleset.xml",
"format": "phpcbf --standard=phpcs.ruleset.xml"
},
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "fumikito",
"email": "guy@hametuha.com"
}
],
"minimum-stability": "stable",
"repositories":[
{
"type":"composer",
"url":"https://wpackagist.org",
"only": [
"wpackagist-plugin/*",
"wpackagist-theme/*"
]
}
],
"require": {
"php": ">=7.4"
},
"require-dev": {
"phpunit/phpunit": "^6|^7|^8|^9",
"squizlabs/php_codesniffer": "^3.0",
"wp-coding-standards/wpcs": "^3.0.0",
"yoast/phpunit-polyfills": "^2.0.0",
"wpackagist-plugin/woocommerce": "^7.0"
},
"autoload": {
"psr-0": {
"Hametuha\\HametWoo": "src/"
}
},
"extra": {
"installer-paths": {
"vendor/plugins/{$name}/": [
"type:wordpress-plugin"
]
}
},
"config": {
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
Loading
Loading