diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..31864ce --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,32 @@ +name: build +on: + workflow_dispatch: + push: + branches: [ 'main' ] + paths: + - 'node-proxy/**' + pull_request: + branches: [ 'main' ] + paths: + - 'node-proxy/**' + +jobs: + release: + name: Build + runs-on: ubuntu-latest + steps: + - name: Setup Node.js + uses: actions/setup-node@v3 + - name: Checkout + uses: actions/checkout@v3 + - name: Build + run: | + cd node-proxy + npm install && npm run build + - name: Upload artifact + if: ${{ success() }} + uses: actions/upload-artifact@v3 + with: + name: alist-encrypt-dev + path: | + node-proxy/build/* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 50d534a..ea5da8b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,9 +17,18 @@ jobs: run: | cd node-proxy npm install && npm run build + - name: Compress + if: ${{ success() }} + run: | + cd node-proxy/build + ls -1 | xargs -I {} zip {}.zip {} && \ + ls -1 *.zip | xargs -I {} shasum -a 256 {} >> sha256.txt - name: Upload assets + if: ${{ success() }} uses: softprops/action-gh-release@v1 with: - files: node-proxy/build/* + files: | + node-proxy/build/*.zip + node-proxy/build/sha256.txt prerelease: false token: ${{ secrets.REPO_TOKEN }} diff --git a/node-proxy/src/utils/levelDB.js b/node-proxy/src/utils/levelDB.js index a7d3343..baf8db0 100644 --- a/node-proxy/src/utils/levelDB.js +++ b/node-proxy/src/utils/levelDB.js @@ -2,11 +2,10 @@ import Datastore from 'nedb-promises' // let datastore = Datastore.create('/path/to/db.db') /** - * 继承接口,定义新方法 + * 封装新方法 */ -class Nedb extends Datastore { +class Nedb { constructor(dbFile) { - // this.super() this.datastore = Datastore.create(dbFile) } diff --git a/node-proxy/webpack.config.ts b/node-proxy/webpack.config.ts index 9cb0b5f..88192a2 100644 --- a/node-proxy/webpack.config.ts +++ b/node-proxy/webpack.config.ts @@ -46,7 +46,6 @@ export default () => { new PkgConfig(), ], target: 'node', - // externals: [nodeExternals()], mode: 'production', optimization: { minimize: true, @@ -80,14 +79,14 @@ export default () => { class PkgConfig { apply(compiler: webpack.Compiler) { - compiler.hooks.afterEmit.tap('DistConfig', () => { + compiler.hooks.afterEmit.tap('PkgConfig', () => { const conf = JSON.parse(fs.readFileSync(path.resolve('./package.json'), 'utf-8')) const pkg_conf = JSON.parse(fs.readFileSync(path.resolve('./pkgconfig.dist.json'), 'utf-8')) pkg_conf['name'] = conf['name'] pkg_conf['version'] = conf['version'] - const dist_conf_path = path.join(output.path, 'package.json') - fs.writeFileSync(dist_conf_path, JSON.stringify(pkg_conf), { encoding: 'utf-8' }) - console.log(dist_conf_path, pkg_conf) + const pkg_conf_path = path.join(output.path, 'package.json') + fs.writeFileSync(pkg_conf_path, JSON.stringify(pkg_conf), { encoding: 'utf-8' }) + console.log(pkg_conf_path, pkg_conf) }) } }