Skip to content

Commit

Permalink
feat: bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Aug 28, 2023
1 parent bd510a9 commit f94a12b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: build
on:
on:
push:
branches:
- master
paths:
- 'backend/package.json'
- "backend/package.json"
pull_request:
branches:
- master
paths:
- 'backend/package.json'
- "backend/package.json"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: 'master'
ref: "master"
- name: Set up Node.js
uses: actions/setup-node@v3
with:
Expand All @@ -34,6 +34,11 @@ jobs:
run: |
cd backend
pnpm run build
- name: Bundle
run: |
cd backend
pnpm i -D estrella
pnpm run bundle
- id: tag
name: Generate release tag
run: |
Expand All @@ -52,3 +57,4 @@ jobs:
./backend/dist/sub-store-1.min.js
./backend/dist/sub-store-parser.loon.min.js
./backend/dist/cron-sync-artifacts.min.js
./backend/dist/sub-store.bundle.js
23 changes: 23 additions & 0 deletions backend/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env node
const fs = require('fs');

const path = require('path');

let content = fs.readFileSync(path.join(__dirname, 'sub-store.min.js'), {
encoding: 'utf8',
});
content = content.replace(
/eval\(('|")(require\(('|").*?('|")\))('|")\)/g,
'$2',
);
fs.writeFileSync(path.join(__dirname, 'dist/sub-store.no-bundle.js'), content, {
encoding: 'utf8',
});

const { build } = require('estrella');
build({
entry: 'dist/sub-store.no-bundle.js',
outfile: 'dist/sub-store.bundle.js',
bundle: true,
platform: 'node',
});
5 changes: 3 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "sub-store",
"version": "2.14.37",
"version": "2.14.38",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
"preinstall": "npx only-allow pnpm",
"test": "gulp peggy && npx cross-env BABEL_ENV=test mocha src/test/**/*.spec.js --require @babel/register --recursive",
"serve": "node sub-store.min.js",
"start": "nodemon -w src -w package.json --exec babel-node src/main.js",
"build": "gulp"
"build": "gulp",
"bundle": "node bundle.js"
},
"author": "Peng-YM",
"license": "GPL-3.0",
Expand Down
2 changes: 1 addition & 1 deletion backend/src/utils/resource-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ResourceCache {
}

set(id, value) {
this.resourceCache[id] = { time: new Date().getTime(), data: value }
this.resourceCache[id] = { time: new Date().getTime(), data: value };
this._persist();
}
}
Expand Down

0 comments on commit f94a12b

Please sign in to comment.