Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自动编译 #37

Merged
merged 4 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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/*
11 changes: 10 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
5 changes: 2 additions & 3 deletions node-proxy/src/utils/levelDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
9 changes: 4 additions & 5 deletions node-proxy/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default () => {
new PkgConfig(),
],
target: 'node',
// externals: [nodeExternals()],
mode: 'production',
optimization: {
minimize: true,
Expand Down Expand Up @@ -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)
})
}
}