Skip to content
Draft
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
16 changes: 9 additions & 7 deletions .github/scripts/build-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ const glob = require('glob');
const uglifyjs = require('uglify-js');
const helper = require('./helper');

const jsFileList = glob.sync(helper.buildPath + '/styles/**/theme/js/*.js').concat(glob.sync(helper.buildPath + '/adm/style/js/*.js'));
const jsFileList = glob
.sync(helper.buildPath + '/styles/**/theme/js/*.js')
.concat(glob.sync(helper.buildPath + '/adm/style/js/*.js'));

jsFileList.forEach(function(j) {
jsFileList.forEach((j) => {
if (j.endsWith('.min.js')) {
return;
}

const minFileName = j.replace('.js', '.min.js');
const isMinified = fs.existsSync(minFileName);

if (isMinified){
if (isMinified) {
return;
}

Expand All @@ -25,12 +27,12 @@ jsFileList.forEach(function(j) {
toplevel: true,
output: {
quote_style: 1,
shebang: false
shebang: false,
},
mangle: {
toplevel: true
}
toplevel: true,
},
});

fs.writeFileSync(minFileName, result.code, {mode: 0o644});
fs.writeFileSync(minFileName, result.code, { mode: 0o644 });
});
22 changes: 13 additions & 9 deletions .github/scripts/build-templates.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
'use strict';

const fs = require('fs');
const path = require('path');
const glob = require('glob');
const util = require('util');
const helper = require('./helper');

const templateFileList = glob.sync(helper.buildPath + '/styles/**/*.html').concat(glob.sync(helper.buildPath + '/adm/style/**/*.html'));
const cssFileList = glob.sync(helper.buildPath + '/styles/**/theme/css/*.css').concat(glob.sync(helper.buildPath + '/adm/style/css/*.css'));
const jsFileList = glob.sync(helper.buildPath + '/styles/**/theme/js/*.js').concat(glob.sync(helper.buildPath + '/adm/style/js/*.js'));
const templateFileList = glob
.sync(helper.buildPath + '/styles/**/*.html')
.concat(glob.sync(helper.buildPath + '/adm/style/**/*.html'));
const cssFileList = glob
.sync(helper.buildPath + '/styles/**/theme/css/*.css')
.concat(glob.sync(helper.buildPath + '/adm/style/css/*.css'));
const jsFileList = glob
.sync(helper.buildPath + '/styles/**/theme/js/*.js')
.concat(glob.sync(helper.buildPath + '/adm/style/js/*.js'));

templateFileList.forEach(function(t) {
templateFileList.forEach((t) => {
const oldHtml = fs.readFileSync(t).toString();
let html = oldHtml;

cssFileList.forEach(function(c) {
cssFileList.forEach((c) => {
html = helper.replaceAssetFile(c, html);
});

jsFileList.forEach(function(j) {
jsFileList.forEach((j) => {
html = helper.replaceAssetFile(j, html);
});

if (html === oldHtml) {
return;
}

fs.writeFileSync(t, html, {mode: 0o644});
fs.writeFileSync(t, html, { mode: 0o644 });
});
13 changes: 9 additions & 4 deletions .github/scripts/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ const fs = require('fs');
const path = require('path');

const rootPath = fs.realpathSync(__dirname + '../../../');
const schema = JSON.parse(fs.readFileSync(rootPath + '/composer.json').toString());
const schema = JSON.parse(
fs.readFileSync(rootPath + '/composer.json').toString()
);
const ext = schema.name.split('/');
const namespace = '@' + ext[0] + '_' + ext[1];
const buildPath = path.join(rootPath, 'build', 'package', ext[0], ext[1]);

if (!fs.existsSync(buildPath)) {
fs.mkdirSync(buildPath, {recursive: true, mode: 0o755});
fs.mkdirSync(buildPath, { recursive: true, mode: 0o755 });
}

exports.buildPath = buildPath;
exports.replaceAssetFile = function(file, html) {
exports.replaceAssetFile = (file, html) => {
const fileExt = path.extname(file);

if (file.endsWith('.min' + fileExt)) {
Expand All @@ -35,7 +37,10 @@ exports.replaceAssetFile = function(file, html) {
return html;
}

html = html.replace(twigNamespace, twigNamespace.replace(fileExt, '.min' + fileExt));
html = html.replace(
twigNamespace,
twigNamespace.replace(fileExt, '.min' + fileExt)
);

return html;
};
26 changes: 10 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ env:
IMAGE_ICC: 1
EPV: 1
EXECUTABLE_FILES: 1
PHPBB_BRANCH: 3.3.x
PHPBB_BRANCH: master

jobs:
basic-tests:
if: ${{ !contains(github.event.head_commit.message, 'skip ci') }}
name: php ${{ matrix.php-version }}, none none
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
env:
PHP_VERSION: ${{ matrix.php-version }}
strategy:
fail-fast: false
matrix:
php-version: ['7.4']
php-version: ['8.1']
steps:
- name: Checkout phpBB
uses: actions/checkout@v5
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
mysql-tests:
if: ${{ !contains(github.event.head_commit.message, 'skip ci') }}
name: php ${{ matrix.php-version }}, ${{ matrix.db-type }} ${{ matrix.db-version }}
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
services:
mysql:
image: ${{ (matrix.db-type == 'mysql' || matrix.db-type == 'mariadb') && matrix.db-type || 'mariadb' }}:${{ (matrix.db-type == 'mysql' || matrix.db-type == 'mariadb' && matrix.db-version != 'none') && matrix.db-version || 'latest' }}
Expand All @@ -129,15 +129,9 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: '7.4'
- php-version: '8.1'
db-type: 'mysql'
db-version: '8.0'
- php-version: '7.4'
db-type: 'mariadb'
db-version: '10.5'
- php-version: '8.0'
db-type: 'mariadb'
db-version: '10.5'
db-version: '5.7'
- php-version: '8.1'
db-type: 'mariadb'
db-version: '10.6'
Expand Down Expand Up @@ -222,7 +216,7 @@ jobs:
postgresql-tests:
if: ${{ !contains(github.event.head_commit.message, 'skip ci') }}
name: php ${{ matrix.php-version }}, ${{ matrix.db-type }} ${{ matrix.db-version }}
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
services:
postgres:
image: ${{ (matrix.db-type == 'postgres') && matrix.db-type || 'postgres' }}:${{ (matrix.db-type == 'postgres' && matrix.db-version != 'none') && matrix.db-version || 'alpine' }}
Expand All @@ -245,12 +239,12 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: '7.4'
- php-version: '8.1'
db-type: 'postgres'
db-version: '16-alpine'
db-version: '17-alpine'
- php-version: '8.4'
db-type: 'postgres'
db-version: '17-alpine'
db-version: '18-alpine'
steps:
- name: Checkout phpBB
uses: actions/checkout@v5
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"type": "phpbb-extension",
"description": "Mermaid Diagrams extension for phpBB",
"homepage": "https://github.com/AlfredoRamos/phpbb-ext-mermaid",
"version": "1.0.0",
"time": "2025-09-12",
"version": "2.0.0-dev",
"time": "2025-09-30",
"keywords": [
"phpbb",
"extension",
Expand Down Expand Up @@ -42,7 +42,7 @@
}
],
"require": {
"php": "^7.1.3 || ^8.0.0",
"php": "^8.1.0",
"composer/installers": "^2.2.0"
},
"require-dev": {
Expand All @@ -55,7 +55,7 @@
"extra": {
"display-name": "Mermaid Diagrams",
"soft-require": {
"phpbb/phpbb": "~3.3.0"
"phpbb/phpbb": "~4.0.0"
},
"version-check": {
"host": "alfredoramos.mx",
Expand Down
8 changes: 3 additions & 5 deletions ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
class ext extends base
{
/**
* Check whether or not the extension can be enabled.
*
* @return bool
*/
* {@inheritdoc}
*/
public function is_enableable()
{
return phpbb_version_compare(PHPBB_VERSION, '3.3.0', '>=');
return phpbb_version_compare(PHPBB_VERSION, '4.0.0-a1-dev', '>='); // TODO: Use stable version
}
}
Loading