1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-21 23:32:35 +00:00

ci: automatically regenerate package.json.buildonly (#7198)

This commit is contained in:
Yat Ho 2024-10-29 04:45:29 +08:00 committed by GitHub
parent d5d950e1cf
commit c36a62e171
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 0 deletions

View file

@ -111,6 +111,7 @@ jobs:
echo
echo Please undo your changes to these files:
git diff --exit-code --name-only --merge-base "origin/$GITHUB_BASE_REF" -- \
web/package.json.buildonly \
web/public_html/transmission-app.css \
web/public_html/transmission-app.css.LEGAL.txt \
web/public_html/transmission-app.css.map \
@ -140,6 +141,7 @@ jobs:
set -e # abort if any command fails
npm --prefix web ci
npm --prefix web run build
npm --prefix web run generate-buildonly
git diff --name-only
git add --update web
- name: Create pull request

24
web/generate-buildonly.js Normal file
View file

@ -0,0 +1,24 @@
import fs from 'node:fs';
import path from 'node:path';
const __dirname = import.meta.dirname;
const obj = JSON.parse(
fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'),
);
obj.scripts = (({ build }) => {
return { build };
})(obj.scripts);
obj.devDependencies = (({
esbuild,
'esbuild-sass-plugin': esbuild_saas_plugin,
}) => {
return { esbuild, 'esbuild-sass-plugin': esbuild_saas_plugin };
})(obj.devDependencies);
// the replace() call adds a trailing newline if it doesn't exist
fs.writeFileSync(
path.join(__dirname, 'package.json.buildonly'),
JSON.stringify(obj, null, 2).replace(/^(.*?[^\n])$/s, '$1\n'),
);

View file

@ -6,6 +6,7 @@
"scripts": {
"build": "node esbuild.mjs",
"dev": "DEV=true node esbuild.mjs",
"generate-buildonly": "node generate-buildonly.js",
"lint": "run-p --silent lint:eslint lint:stylelint lint:prettier",
"lint:fix": "run-s lint:eslint:fix lint:stylelint:fix lint:prettier:fix",
"lint:eslint": "eslint src/*.js",