mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-07-05 14:05:11 +08:00
chore: 在 bundle 文件顶部添加版本号
This commit is contained in:
parent
ae1c738f70
commit
395c6e4e4a
@ -4,6 +4,10 @@ const path = require('path');
|
|||||||
const { build } = require('esbuild');
|
const { build } = require('esbuild');
|
||||||
|
|
||||||
!(async () => {
|
!(async () => {
|
||||||
|
const version = JSON.parse(
|
||||||
|
fs.readFileSync(path.join(__dirname, 'package.json'), 'utf-8'),
|
||||||
|
).version.trim();
|
||||||
|
|
||||||
const artifacts = [
|
const artifacts = [
|
||||||
{ src: 'src/main.js', dest: 'sub-store.min.js' },
|
{ src: 'src/main.js', dest: 'sub-store.min.js' },
|
||||||
{
|
{
|
||||||
@ -54,6 +58,16 @@ const { build } = require('esbuild');
|
|||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
outfile: 'dist/sub-store.bundle.js',
|
outfile: 'dist/sub-store.bundle.js',
|
||||||
});
|
});
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(__dirname, 'dist/sub-store.bundle.js'),
|
||||||
|
`// SUB_STORE_BACKEND_VERSION: ${version}
|
||||||
|
${fs.readFileSync(path.join(__dirname, 'dist/sub-store.bundle.js'), {
|
||||||
|
encoding: 'utf8',
|
||||||
|
})}`,
|
||||||
|
{
|
||||||
|
encoding: 'utf8',
|
||||||
|
},
|
||||||
|
);
|
||||||
})()
|
})()
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
@ -3,23 +3,49 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { build } = require('esbuild');
|
const { build } = require('esbuild');
|
||||||
|
|
||||||
let content = fs.readFileSync(path.join(__dirname, 'sub-store.min.js'), {
|
!(async () => {
|
||||||
encoding: 'utf8',
|
const version = JSON.parse(
|
||||||
});
|
fs.readFileSync(path.join(__dirname, 'package.json'), 'utf-8'),
|
||||||
content = content.replace(
|
).version.trim();
|
||||||
/eval\(('|")(require\(('|").*?('|")\))('|")\)/g,
|
|
||||||
'$2',
|
|
||||||
);
|
|
||||||
fs.writeFileSync(path.join(__dirname, 'dist/sub-store.no-bundle.js'), content, {
|
|
||||||
encoding: 'utf8',
|
|
||||||
});
|
|
||||||
|
|
||||||
build({
|
let content = fs.readFileSync(path.join(__dirname, 'sub-store.min.js'), {
|
||||||
entryPoints: ['dist/sub-store.no-bundle.js'],
|
encoding: 'utf8',
|
||||||
bundle: true,
|
});
|
||||||
minify: true,
|
content = content.replace(
|
||||||
sourcemap: true,
|
/eval\(('|")(require\(('|").*?('|")\))('|")\)/g,
|
||||||
platform: 'node',
|
'$2',
|
||||||
format: 'cjs',
|
);
|
||||||
outfile: 'dist/sub-store.bundle.js',
|
fs.writeFileSync(
|
||||||
});
|
path.join(__dirname, 'dist/sub-store.no-bundle.js'),
|
||||||
|
content,
|
||||||
|
{
|
||||||
|
encoding: 'utf8',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await build({
|
||||||
|
entryPoints: ['dist/sub-store.no-bundle.js'],
|
||||||
|
bundle: true,
|
||||||
|
minify: true,
|
||||||
|
sourcemap: true,
|
||||||
|
platform: 'node',
|
||||||
|
format: 'cjs',
|
||||||
|
outfile: 'dist/sub-store.bundle.js',
|
||||||
|
});
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(__dirname, 'dist/sub-store.bundle.js'),
|
||||||
|
`// SUB_STORE_BACKEND_VERSION: ${version}
|
||||||
|
${fs.readFileSync(path.join(__dirname, 'dist/sub-store.bundle.js'), {
|
||||||
|
encoding: 'utf8',
|
||||||
|
})}`,
|
||||||
|
{
|
||||||
|
encoding: 'utf8',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
})()
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
console.log('done');
|
||||||
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sub-store",
|
"name": "sub-store",
|
||||||
"version": "2.14.204",
|
"version": "2.14.205",
|
||||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||||
"main": "src/main.js",
|
"main": "src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user