-
Notifications
You must be signed in to change notification settings - Fork 838
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
975 additions
and
1,281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
.wrangler | ||
adapter | ||
dist | ||
doc | ||
node_modules | ||
adapter/local/node_modules | ||
plugins | ||
.gitattributes | ||
.gitignore | ||
config.json | ||
docker-compose.yaml | ||
Dockerfile | ||
eslint.config.js | ||
LICENSE | ||
README.md | ||
README_CN.md | ||
wrangler.toml | ||
wrangler-example.toml | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
FROM node:20 | ||
COPY . /app | ||
WORKDIR /app | ||
COPY adapter/local /app/adapter/local/ | ||
COPY src /app/src | ||
WORKDIR /app/adapter/local | ||
RUN npm install | ||
RUN pwd && ls -la && npm install && npm run build:local | ||
EXPOSE 8787 | ||
CMD ["npm", "run", "run:local"] | ||
CMD ["npm", "run", "start:local"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"database": { | ||
"type": "local", | ||
"path": "./data.json" | ||
}, | ||
"mode": "polling" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,67 @@ | ||
import { execSync } from 'node:child_process'; | ||
import * as fs from 'node:fs/promises'; | ||
import * as path from 'node:path'; | ||
import type { Plugin } from 'vite'; | ||
import { defineConfig } from 'vite'; | ||
import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
import cleanup from 'rollup-plugin-cleanup'; | ||
import checker from 'vite-plugin-checker'; | ||
import dts from 'vite-plugin-dts'; | ||
import { nodeExternals } from 'rollup-plugin-node-externals'; | ||
|
||
const TIMESTAMP_FILE = './dist/timestamp'; | ||
const BUILD_INFO_JSON = './dist/buildinfo.json'; | ||
const { BUILD_MODE } = process.env; | ||
|
||
const COMMIT_HASH = execSync('git rev-parse --short HEAD').toString().trim(); | ||
const TIMESTAMP = Math.floor(Date.now() / 1000); | ||
const plugins: Plugin[] = [ | ||
nodeResolve({ | ||
preferBuiltins: true, | ||
}), | ||
cleanup({ | ||
comments: 'none', | ||
extensions: ['js', 'ts'], | ||
}), | ||
dts({ | ||
rollupTypes: true, | ||
}), | ||
checker({ | ||
typescript: true, | ||
}), | ||
nodeExternals(), | ||
]; | ||
const define: Record<string, string> = {}; | ||
const entry = path.resolve(__dirname, BUILD_MODE === 'local' ? 'src/entry/local.ts' : 'src/index.ts'); | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
nodeResolve({ | ||
preferBuiltins: true, | ||
}), | ||
cleanup({ | ||
comments: 'none', | ||
extensions: ['js', 'ts'], | ||
}), | ||
dts({ | ||
rollupTypes: true, | ||
}), | ||
checker({ | ||
typescript: true, | ||
}), | ||
{ | ||
name: 'buildInfo', | ||
async closeBundle() { | ||
await fs.writeFile(TIMESTAMP_FILE, TIMESTAMP.toString()); | ||
await fs.writeFile(BUILD_INFO_JSON, JSON.stringify({ | ||
sha: COMMIT_HASH, | ||
timestamp: TIMESTAMP, | ||
})); | ||
}, | ||
if (BUILD_MODE !== 'local') { | ||
const TIMESTAMP_FILE = './dist/timestamp'; | ||
const BUILD_INFO_JSON = './dist/buildinfo.json'; | ||
const COMMIT_HASH = execSync('git rev-parse --short HEAD').toString().trim(); | ||
const TIMESTAMP = Math.floor(Date.now() / 1000); | ||
plugins.push({ | ||
name: 'buildInfo', | ||
async closeBundle() { | ||
await fs.writeFile(TIMESTAMP_FILE, TIMESTAMP.toString()); | ||
await fs.writeFile(BUILD_INFO_JSON, JSON.stringify({ | ||
sha: COMMIT_HASH, | ||
timestamp: TIMESTAMP, | ||
})); | ||
}, | ||
], | ||
}); | ||
define.__BUILD_VERSION__ = JSON.stringify(COMMIT_HASH); | ||
define.__BUILD_TIMESTAMP__ = TIMESTAMP.toString(); | ||
} else { | ||
define.__BUILD_VERSION__ = JSON.stringify('local'); | ||
define.__BUILD_TIMESTAMP__ = '0'; | ||
} | ||
|
||
export default defineConfig({ | ||
plugins, | ||
build: { | ||
target: 'esnext', | ||
lib: { | ||
entry: 'src/index.ts', | ||
entry, | ||
fileName: 'index', | ||
formats: ['es'], | ||
}, | ||
minify: false, | ||
rollupOptions: { | ||
external: ['node:buffer'], | ||
plugins: [ | ||
], | ||
}, | ||
}, | ||
define: { | ||
__BUILD_VERSION__: JSON.stringify(COMMIT_HASH), | ||
__BUILD_TIMESTAMP__: TIMESTAMP.toString(), | ||
}, | ||
define, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.