Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.
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: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
* text=auto
scss/ export-ignore
tests/ export-ignore
.github/ export-ignore
.vscode/ export-ignore
Expand All @@ -16,4 +15,3 @@ tailwind.config.js export-ignore
.stylelintrc.json export-ignore
.tool-versions export-ignore
*.md export-ignore
*.scss export-ignore
32 changes: 17 additions & 15 deletions .github/scripts/build-js.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
'use strict';

const fs = require('fs');
const path = require('path');
const glob = require('glob');
const uglifyjs = require('uglify-js');
const helper = require('./helper');
import { existsSync, readFileSync, writeFileSync } from 'fs';
import { sync } from 'glob';
import { minify } from 'uglify-js';
import { join } from 'path';
import { buildPath } from './helper.js';

const jsFileList = glob.sync(helper.buildPath + '/styles/**/theme/js/*.js').concat(glob.sync(helper.buildPath + '/adm/style/js/*.js'));
const jsFileList = sync(join(buildPath, 'styles/**/theme/js/*.js')).concat(
sync(join(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);
const isMinified = existsSync(minFileName);

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

const js = fs.readFileSync(j).toString();
const result = uglifyjs.minify(js, {
const js = readFileSync(j).toString();
const result = minify(js, {
toplevel: true,
output: {
quote_style: 1,
shebang: false
shebang: false,
},
mangle: {
toplevel: true
}
toplevel: true,
},
});

fs.writeFileSync(minFileName, result.code, {mode: 0o644});
writeFileSync(minFileName, result.code, { mode: 0o644 });
});
49 changes: 0 additions & 49 deletions .github/scripts/build-scss.js

This file was deleted.

35 changes: 20 additions & 15 deletions .github/scripts/build-templates.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
'use strict';

const fs = require('fs');
const path = require('path');
const glob = require('glob');
const util = require('util');
const helper = require('./helper');
import { readFileSync, writeFileSync } from 'fs';
import { sync } from 'glob';
import { join } from 'path';
import { buildPath, replaceAssetFile } from './helper.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'));
const templateFileList = sync(join(buildPath, 'styles/**/*.html')).concat(
sync(buildPath + '/adm/style/**/*.html')
);
const cssFileList = sync(join(buildPath, 'styles/**/theme/css/*.css')).concat(
sync(buildPath + '/adm/style/css/*.css')
);
const jsFileList = sync(join(buildPath, 'styles/**/theme/js/*.js')).concat(
sync(buildPath + '/adm/style/js/*.js')
);

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

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

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

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

fs.writeFileSync(t, html, {mode: 0o644});
writeFileSync(t, html, { mode: 0o644 });
});
37 changes: 22 additions & 15 deletions .github/scripts/helper.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
'use strict';

const fs = require('fs');
const path = require('path');
import { realpathSync, readFileSync, existsSync, mkdirSync } from 'fs';
import { join, extname, basename, dirname } from 'path';

const rootPath = fs.realpathSync(__dirname + '../../../');
const schema = JSON.parse(fs.readFileSync(rootPath + '/composer.json').toString());
const __filename = new URL(import.meta.url).pathname;
const __dirname = dirname(__filename);

const rootPath = realpathSync(__dirname + '../../../');
const schema = JSON.parse(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]);
const buildPath = join(rootPath, 'build', 'package', ext[0], ext[1]);

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

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

if (file.endsWith('.min' + fileExt)) {
return html;
}

const isMinified = fs.existsSync(file.replace(fileExt, '.min' + fileExt));
const isMinified = existsSync(file.replace(fileExt, '.min' + fileExt));

if (!isMinified) {
return html;
}

const filePath = path.basename(path.dirname(file));
const fileName = path.basename(file);
const twigNamespace = path.join(namespace, filePath, fileName);
const filePath = basename(dirname(file));
const fileName = basename(file);
const twigNamespace = join(namespace, filePath, fileName);

if (!html.includes(twigNamespace)) {
return html;
}

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

return html;
};

export { buildPath, replaceAssetFile };
Loading
Loading