Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit 1fad127

Browse files
committed
Update dependencies
1 parent b63880e commit 1fad127

9 files changed

Lines changed: 2005 additions & 1356 deletions

File tree

.github/scripts/build-js.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
11
'use strict';
22

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

9-
const jsFileList = glob.sync(helper.buildPath + '/styles/**/theme/js/*.js').concat(glob.sync(helper.buildPath + '/adm/style/js/*.js'));
9+
const jsFileList = sync(join(buildPath, 'styles/**/theme/js/*.js')).concat(
10+
sync(join(buildPath, 'adm/style/js/*.js'))
11+
);
1012

11-
jsFileList.forEach(function(j) {
13+
jsFileList.forEach((j) => {
1214
if (j.endsWith('.min.js')) {
1315
return;
1416
}
1517

1618
const minFileName = j.replace('.js', '.min.js');
17-
const isMinified = fs.existsSync(minFileName);
19+
const isMinified = existsSync(minFileName);
1820

19-
if (isMinified){
21+
if (isMinified) {
2022
return;
2123
}
2224

23-
const js = fs.readFileSync(j).toString();
24-
const result = uglifyjs.minify(js, {
25+
const js = readFileSync(j).toString();
26+
const result = minify(js, {
2527
toplevel: true,
2628
output: {
2729
quote_style: 1,
28-
shebang: false
30+
shebang: false,
2931
},
3032
mangle: {
31-
toplevel: true
32-
}
33+
toplevel: true,
34+
},
3335
});
3436

35-
fs.writeFileSync(minFileName, result.code, {mode: 0o644});
37+
writeFileSync(minFileName, result.code, { mode: 0o644 });
3638
});

.github/scripts/build-scss.js

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,30 @@
11
'use strict';
22

3-
const fs = require('fs');
4-
const path = require('path');
5-
const glob = require('glob');
6-
const sass = require('sass');
7-
const tailwind = require('tailwindcss');
8-
const autoprefixer = require('autoprefixer');
9-
const postcssImport = require('postcss-import');
10-
const postcss = require('postcss');
3+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
4+
import { dirname } from 'path';
5+
import { sync } from 'glob';
6+
import { compile } from 'sass-embedded';
7+
import autoprefixer from 'autoprefixer';
8+
import postcss from 'postcss';
119

12-
const modulesPath = path.join(__dirname, '../../node_modules');
13-
const sourcesPath = path.join(__dirname, '../../scss');
14-
const tailwindConfigFile = path.join(__dirname, '../../tailwind.config.js');
15-
const scssFileList = glob.sync('scss/themes/**/*.scss');
16-
17-
scssFileList.forEach(function(s) {
10+
const scssFileList = sync('scss/themes/**/*.scss');
11+
scssFileList.forEach((s) => {
1812
const normalFile = s.replace('scss/themes/', '').replace('.scss', '.css');
19-
const normalFilePath = path.dirname(normalFile);
13+
const normalFilePath = dirname(normalFile);
2014

21-
if (!fs.existsSync(normalFilePath)) {
22-
fs.mkdirSync(normalFilePath, {recursive: true, mode: 0o755});
15+
if (!existsSync(normalFilePath)) {
16+
mkdirSync(normalFilePath, { recursive: true, mode: 0o755 });
2317
}
2418

25-
const result = sass.renderSync({
26-
file: s,
27-
indentType: 'tab',
28-
indentWidth: 1,
29-
omitSourceMapUrl: true,
30-
outFile: normalFile,
31-
outputStyle: 'expanded',
32-
sourceMap: false,
33-
includePaths: [modulesPath]
34-
});
19+
const result = compile(s, { style: 'expanded', sourceMap: false });
3520

36-
postcss([
37-
postcssImport({path: [modulesPath, sourcesPath]}),
38-
tailwind(({config: tailwindConfigFile, path: [modulesPath, sourcesPath]})),
39-
autoprefixer({cascade: false})
40-
])
41-
.process(result.css, {from: normalFile})
42-
.then(function(res) {
43-
res.warnings().forEach(function(warn) {
44-
console.warn(warn.toString());
45-
});
21+
postcss([autoprefixer({ cascade: false })])
22+
.process(result.css, { from: result.css, to: normalFile })
23+
.then((res) => {
24+
res.warnings().forEach((warn) => {
25+
console.warn(warn.toString());
26+
});
4627

47-
fs.writeFileSync(normalFile, res.css, {mode: 0o644});
48-
});
28+
writeFileSync(normalFile, res.css, { mode: 0o644 });
29+
});
4930
});

.github/scripts/build-templates.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
'use strict';
22

3-
const fs = require('fs');
4-
const path = require('path');
5-
const glob = require('glob');
6-
const util = require('util');
7-
const helper = require('./helper');
3+
import { readFileSync, writeFileSync } from 'fs';
4+
import { sync } from 'glob';
5+
import { join } from 'path';
6+
import { buildPath, replaceAssetFile } from './helper.js';
87

9-
const templateFileList = glob.sync(helper.buildPath + '/styles/**/*.html').concat(glob.sync(helper.buildPath + '/adm/style/**/*.html'));
10-
const cssFileList = glob.sync(helper.buildPath + '/styles/**/theme/css/*.css').concat(glob.sync(helper.buildPath + '/adm/style/css/*.css'));
11-
const jsFileList = glob.sync(helper.buildPath + '/styles/**/theme/js/*.js').concat(glob.sync(helper.buildPath + '/adm/style/js/*.js'));
8+
const templateFileList = sync(join(buildPath, 'styles/**/*.html')).concat(
9+
sync(buildPath + '/adm/style/**/*.html')
10+
);
11+
const cssFileList = sync(join(buildPath, 'styles/**/theme/css/*.css')).concat(
12+
sync(buildPath + '/adm/style/css/*.css')
13+
);
14+
const jsFileList = sync(join(buildPath, 'styles/**/theme/js/*.js')).concat(
15+
sync(buildPath + '/adm/style/js/*.js')
16+
);
1217

13-
templateFileList.forEach(function(t) {
14-
const oldHtml = fs.readFileSync(t).toString();
18+
templateFileList.forEach((t) => {
19+
const oldHtml = readFileSync(t).toString();
1520
let html = oldHtml;
1621

17-
cssFileList.forEach(function(c) {
18-
html = helper.replaceAssetFile(c, html);
22+
cssFileList.forEach((c) => {
23+
html = replaceAssetFile(c, html);
1924
});
2025

21-
jsFileList.forEach(function(j) {
22-
html = helper.replaceAssetFile(j, html);
26+
jsFileList.forEach((j) => {
27+
html = replaceAssetFile(j, html);
2328
});
2429

2530
if (html === oldHtml) {
2631
return;
2732
}
2833

29-
fs.writeFileSync(t, html, {mode: 0o644});
34+
writeFileSync(t, html, { mode: 0o644 });
3035
});

.github/scripts/helper.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,48 @@
11
'use strict';
22

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

6-
const rootPath = fs.realpathSync(__dirname + '../../../');
7-
const schema = JSON.parse(fs.readFileSync(rootPath + '/composer.json').toString());
6+
const __filename = new URL(import.meta.url).pathname;
7+
const __dirname = dirname(__filename);
8+
9+
const rootPath = realpathSync(__dirname + '../../../');
10+
const schema = JSON.parse(readFileSync(rootPath + '/composer.json').toString());
811
const ext = schema.name.split('/');
912
const namespace = '@' + ext[0] + '_' + ext[1];
10-
const buildPath = path.join(rootPath, 'build', 'package', ext[0], ext[1]);
13+
const buildPath = join(rootPath, 'build', 'package', ext[0], ext[1]);
1114

12-
if (!fs.existsSync(buildPath)) {
13-
fs.mkdirSync(buildPath, {recursive: true, mode: 0o755});
15+
if (!existsSync(buildPath)) {
16+
mkdirSync(buildPath, { recursive: true, mode: 0o755 });
1417
}
1518

16-
exports.buildPath = buildPath;
17-
exports.replaceAssetFile = function(file, html) {
18-
const fileExt = path.extname(file);
19+
const replaceAssetFile = (file, html) => {
20+
const fileExt = extname(file);
1921

2022
if (file.endsWith('.min' + fileExt)) {
2123
return html;
2224
}
2325

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

2628
if (!isMinified) {
2729
return html;
2830
}
2931

30-
const filePath = path.basename(path.dirname(file));
31-
const fileName = path.basename(file);
32-
const twigNamespace = path.join(namespace, filePath, fileName);
32+
const filePath = basename(dirname(file));
33+
const fileName = basename(file);
34+
const twigNamespace = join(namespace, filePath, fileName);
3335

3436
if (!html.includes(twigNamespace)) {
3537
return html;
3638
}
3739

38-
html = html.replace(twigNamespace, twigNamespace.replace(fileExt, '.min' + fileExt));
40+
html = html.replace(
41+
twigNamespace,
42+
twigNamespace.replace(fileExt, '.min' + fileExt)
43+
);
3944

4045
return html;
4146
};
47+
48+
export { buildPath, replaceAssetFile };

0 commit comments

Comments
 (0)