13 Commits

Author SHA1 Message Date
27bbee8d1c Update src/Extend/EnableRedis.php 2024-10-13 11:35:13 +00:00
22d94274d4 Update src/Extend/EnableRedis.php 2024-10-12 16:56:42 +00:00
Davide Iadeluca
2f2cce1abe chore: remove sync workflow 2024-01-31 11:21:07 +01:00
flarum-bot
78082dc842 Bundled output for commit e02001333b
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2024-01-31 09:45:51 +00:00
Davide Iadeluca
e02001333b Merge pull request #2 from glowingblue/di/update-deps
chore(deps): update dependencies
2024-01-31 10:45:12 +01:00
Davide Iadeluca
44fa68c278 chore: add custom repository 2024-01-31 10:37:20 +01:00
Davide Iadeluca
139d687e1b ci: update workflows 2024-01-31 10:25:04 +01:00
Davide Iadeluca
9061552db9 chore(deps): update dependencies 2024-01-30 13:59:01 +01:00
Rafael Horvat
eab24f9adc fix build workflow 2023-08-09 17:05:25 +02:00
Rafael Horvat
94049c5183 Refactoring and made some methods public static(to be able to reuse them) 2023-08-09 17:04:59 +02:00
Rafael Horvat
96af9b58f6 Added and/or updated config files 2023-01-25 14:50:01 +01:00
flarum-bot
69c73e2397 Bundled output for commit c2ddd30cd7
Includes transpiled JS/TS.

[skip ci]
2022-04-26 11:23:43 +00:00
Rafael Horvat
c2ddd30cd7 Infra updates & require flarum 1.2 2022-04-26 13:22:18 +02:00
11 changed files with 1430 additions and 3297 deletions

11
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,11 @@
**Resolves**
<!-- include a link to the issue -->
**Changes proposed in this pull request:**
<!-- mention the pages and/or components which have been impacted -->
**Reviewers should focus on:**
<!-- ask for feedback on specific changes you are unsure about -->
**Screenshot**
<!-- include an image of the most relevant user-facing change, if any -->

16
.github/workflows/backend.yml vendored Normal file
View File

@@ -0,0 +1,16 @@
name: GB Redis Setup PHP
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@1.x
with:
enable_backend_testing: false
enable_phpstan: false
php_versions: '["7.4", "8.0", "8.1", "8.2", "8.3"]'
backend_directory: .
secrets:
composer_auth: '{"bearer":{"extiverse.com": "${{secrets.EXTIVERSE_COMPOSER_TOKEN}}"}}'

20
.github/workflows/frontend.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: GB Redis Setup JS
on: [workflow_dispatch, push, pull_request]
jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@1.x
with:
enable_bundlewatch: false
enable_prettier: true
enable_typescript: false
frontend_directory: ./js
backend_directory: .
js_package_manager: yarn
main_git_branch: master
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
composer_auth: '{"bearer":{"extiverse.com": "${{secrets.EXTIVERSE_COMPOSER_TOKEN}}"}}'

View File

@@ -1,91 +0,0 @@
name: JS
on: [workflow_dispatch, push, pull_request]
env:
NODE_VERSION: 16
jobs:
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
cache-dependency-path: js/yarn.lock
- name: Install JS dependencies
run: yarn install --immutable
working-directory: ./js
- name: Check JS formatting
run: yarn run format-check
working-directory: ./js
build-prod:
name: Build and commit
runs-on: ubuntu-latest
needs: [prettier]
# Only commit JS on push to master branch
# Remember to change in `build-test` job too
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
cache-dependency-path: js/yarn.lock
# Our action will install node, npm and yarn, cd into `./js`, run `yarn run build` (and
# `yarn run build-typings` if desired), then commit and upload any changes
- name: Build production JS
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: yarn
# typings_script: build-typings
build-test:
name: Test build
runs-on: ubuntu-latest
needs: [prettier]
# Inverse check of `build-prod`
# Remember to change in `build-prod` job too
if: github.ref != 'refs/heads/master' || github.event_name != 'push'
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
cache-dependency-path: js/yarn.lock
# Our action will install node, npm and yarn, cd into `./js`, run `yarn run build` (and
# `yarn run build-typings` if desired). It will NOT commit and upload.
- name: Build production JS
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: yarn
# typings_script: build-typings
do_not_commit: true

View File

@@ -65,6 +65,7 @@
"bmewburn.vscode-intelephense-client", "bmewburn.vscode-intelephense-client",
"dbaeumer.vscode-eslint", "dbaeumer.vscode-eslint",
"esbenp.prettier-vscode", "esbenp.prettier-vscode",
"felixfbecker.php-debug" "xdebug.php-debug",
"firefox-devtools.vscode-firefox-debug"
] ]
} }

View File

@@ -18,7 +18,7 @@
}, },
"homepage": "https://glowingblue.com", "homepage": "https://glowingblue.com",
"require": { "require": {
"flarum/core": "^1.0.4", "flarum/core": "^1.2.0",
"blomstra/flarum-redis": "^0.4.0" "blomstra/flarum-redis": "^0.4.0"
}, },
"authors": [ "authors": [

2
js/dist/admin.js vendored
View File

@@ -1,2 +1,2 @@
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t){e.exports=flarum.core.compat["admin/app"]},function(e,t){e.exports=flarum.core.compat["common/extend"]},function(e,t){e.exports=flarum.core.compat["admin/components/StatusWidget"]},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),a=r(1),i=r(2),l=r.n(i),u="glowingblue-redis-setup";function s(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return c(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var f=o.a.translator.trans.bind(o.a.translator),d=u+".admin.settings";o.a.initializers.add(u,(function(){o.a.extensionData.for(u).registerSetting({setting:"glowingblue-redis.enableCache",type:"boolean",label:f(d+".enable_cache")}).registerSetting({setting:"glowingblue-redis.redisSessions",type:"boolean",label:f(d+".enable_redis_sessions")}).registerSetting({setting:"glowingblue-redis.enableQueue",type:"boolean",label:f(d+".enable_queue")}),o.a.initializers.has("blomstra/horizon")&&o.a.extensionData.for(u).registerSetting({setting:"glowingblue-redis.horizonConfig",type:"textarea",label:f(d+".horizon_config"),help:f(d+".horizon_help_text")}),Object(a.extend)(l.a.prototype,"items",(function(e){var t=o.a.data.blomstraQueuesLoad;if(void 0!==t)for(var r,n=s(o.a.data.blomstraQueuesSeen);!(r=n()).done;){var a=r.value,i=t[a]||null;e.add("blomstra-queue-size-"+a,[m("strong",null,"Queue ",a),m("br",null),i||"0"])}}))}))}]); (()=>{var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";e.r(t);const r=flarum.core.compat["admin/app"];var n=e.n(r);const o=flarum.core.compat["common/extend"],a=flarum.core.compat["admin/components/StatusWidget"];var i=e.n(a),l="glowingblue-redis-setup";function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var u=n().translator.trans.bind(n().translator),d=l+".admin.settings";n().initializers.add(l,(function(){n().extensionData.for(l).registerSetting({setting:"glowingblue-redis.enableCache",type:"boolean",label:u(d+".enable_cache")}).registerSetting({setting:"glowingblue-redis.redisSessions",type:"boolean",label:u(d+".enable_redis_sessions")}).registerSetting({setting:"glowingblue-redis.enableQueue",type:"boolean",label:u(d+".enable_queue")}),n().initializers.has("blomstra/horizon")&&n().extensionData.for(l).registerSetting({setting:"glowingblue-redis.horizonConfig",type:"textarea",label:u(d+".horizon_config"),help:u(d+".horizon_help_text")}),(0,o.extend)(i().prototype,"items",(function(e){var t=n().data.blomstraQueuesLoad;if(void 0!==t)for(var r,o=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(n().data.blomstraQueuesSeen);!(r=o()).done;){var a=r.value,i=t[a]||null;e.add("blomstra-queue-size-"+a,[m("strong",null,"Queue ",a),m("br",null),i||"0"])}}))}))})(),module.exports=t})();
//# sourceMappingURL=admin.js.map //# sourceMappingURL=admin.js.map

File diff suppressed because one or more lines are too long

View File

@@ -4,8 +4,8 @@
"private": true, "private": true,
"prettier": "@glowingblue-dev/prettier-config", "prettier": "@glowingblue-dev/prettier-config",
"dependencies": { "dependencies": {
"flarum-webpack-config": "^1.0.0", "flarum-webpack-config": "^2.0.0",
"webpack": "^4.26.0", "webpack": "^5.72.0",
"webpack-cli": "^4.9.2" "webpack-cli": "^4.9.2"
}, },
"devDependencies": { "devDependencies": {

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
/* /*
* This file is part of glowingblue/redis-setup. * This file is part of glowingblue/redis-setup.
* *
* Copyright (c) 2022 Glowing Blue AG. * Copyright (c) 2023 Glowing Blue AG.
* Authors: Ian Morland, iPurpl3x, Rafael Horvat. * Authors: Ian Morland, iPurpl3x, Rafael Horvat.
* *
* For the full copyright and license information, please view the LICENSE.md * For the full copyright and license information, please view the LICENSE.md
@@ -58,28 +58,23 @@ class EnableRedis implements ExtenderInterface
private function buildConfig($config = []): array private function buildConfig($config = []): array
{ {
$cache = [ $base = [
'host' => $this->getHost(), 'host' => $this->getHost(),
'password' => $this->getPassword(), 'password' => $this->getPassword(),
'port' => $this->getPort(), 'port' => $this->getPort(),
'database' => $this->getCacheDatabase(),
'prefix' => $this->getPrefix(), 'prefix' => $this->getPrefix(),
]; ];
$queue = [ $cache = $base + [
'host' => $this->getHost(), 'database' => static::getCacheDatabase(),
'password' => $this->getPassword(),
'port' => $this->getPort(),
'database' => $this->getQueueDatabase(),
'prefix' => $this->getPrefix(),
]; ];
$session = [ $queue = $base + [
'host' => $this->getHost(), 'database' => static::getQueueDatabase(),
'password' => $this->getPassword(), ];
'port' => $this->getPort(),
'database' => $this->getSessionDatabase(), $session = $base + [
'prefix' => $this->getPrefix(), 'database' => static::getSessionDatabase(),
]; ];
$config = Arr::add($config, self::CACHE_KEY, $cache); $config = Arr::add($config, self::CACHE_KEY, $cache);
@@ -89,37 +84,37 @@ class EnableRedis implements ExtenderInterface
return $config; return $config;
} }
private function getHost(): string public static function getHost(): string
{ {
return getenv('REDIS_HOST') ? getenv('REDIS_HOST') : '127.0.0.1'; return getenv('REDIS_HOST') ? getenv('REDIS_HOST') : 'redis';
} }
private function getPassword(): ?string public static function getPassword(): ?string
{ {
return getenv('REDIS_PASSWORD') ? getenv('REDIS_PASSWORD') : null; return getenv('REDIS_PASSWORD') ? getenv('REDIS_PASSWORD') : null;
} }
private function getPort(): string public static function getPort(): string
{ {
return getenv('REDIS_PORT') ? getenv('REDIS_PORT') : '6379'; return getenv('REDIS_PORT') ? getenv('REDIS_PORT') : '6379';
} }
private function getCacheDatabase(): int public static function getCacheDatabase(): int
{ {
return (int) getenv('REDIS_DATABASE_CACHE') ? getenv('REDIS_DATABASE_CACHE') : 1; return (int) getenv('REDIS_DATABASE_CACHE') ? getenv('REDIS_DATABASE_CACHE') : 1;
} }
private function getQueueDatabase(): int public static function getQueueDatabase(): int
{ {
return (int) getenv('REDIS_DATABASE_QUEUE') ? getenv('REDIS_DATABASE_QUEUE') : 2; return (int) getenv('REDIS_DATABASE_QUEUE') ? getenv('REDIS_DATABASE_QUEUE') : 2;
} }
private function getSessionDatabase(): int public static function getSessionDatabase(): int
{ {
return (int) getenv('REDIS_DATABASE_SESSION') ? getenv('REDIS_DATABASE_SESSION') : 3; return (int) getenv('REDIS_DATABASE_SESSION') ? getenv('REDIS_DATABASE_SESSION') : 3;
} }
private function getPrefix(): string public static function getPrefix(): string
{ {
return getenv('REDIS_PREFIX') ? getenv('REDIS_PREFIX') : 'flarum_'; return getenv('REDIS_PREFIX') ? getenv('REDIS_PREFIX') : 'flarum_';
} }