Skip to content

Commit 2067d59

Browse files
committed
feat(packages): 添加 sqlite3 包并发布到 GitHub Packages 和 NPM
- 新增 sqlite3 包的构建和发布流程 - 更新 release-please 配置以支持 sqlite3 包的版本管理 - 创建 sqlite3 包的 README 文件 - 编写 sqlite3 包的 TypeScript 定义文件和配置文件 - 调整 pnpm 锁文件以使用指定版本的 sqlite3 依赖
1 parent 84493dd commit 2067d59

File tree

12 files changed

+286
-16
lines changed

12 files changed

+286
-16
lines changed

.github/workflows/release.yaml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
steps.release-please.outputs['packages/simple-git--release_created'] }}
2323
dotenv_rerelease: ${{ steps.release-please.outputs['packages/dotenv--release_created'] }}
2424
log4js_rerelease: ${{ steps.release-please.outputs['packages/log4js--release_created'] }}
25+
sqlite3_rerelease: ${{ steps.release-please.outputs['packages/sqlite3--release_created'] }}
2526
steps:
2627
- name: 获取token
2728
uses: actions/create-github-app-token@v2
@@ -323,4 +324,43 @@ jobs:
323324
package: packages/log4js
324325
access: public
325326
provenance: true
326-
327+
publish-sqlite3:
328+
needs: release
329+
if: ${{ needs.release.outputs.sqlite3_rerelease == 'true' }}
330+
runs-on: ubuntu-latest
331+
steps:
332+
- name: 检出代码
333+
uses: actions/checkout@v4
334+
with:
335+
ref: main
336+
fetch-depth: 0
337+
- name: 设置 pnpm
338+
uses: pnpm/action-setup@v4
339+
with:
340+
version: 10.12.4
341+
run_install: "- args: [--no-frozen-lockfile]"
342+
- name: 构建
343+
run: |-
344+
pnpm build
345+
mkdir -p ${{ runner.temp }}/temp/sqlite3
346+
cp -r package.json README.md dist ${{ runner.temp }}/temp/sqlite3
347+
working-directory: packages/sqlite3
348+
- name: 上传构建产物
349+
uses: actions/upload-artifact@v4
350+
with:
351+
name: sqlite3
352+
path: ${{ runner.temp }}/temp/sqlite3
353+
- name: 发布到 GitHub Packages
354+
uses: JS-DevTools/npm-publish@v3
355+
with:
356+
token: ${{ secrets.GITHUB_TOKEN }}
357+
registry: https://npm.pkg.github.com
358+
package: packages/sqlite3/package.json
359+
- name: 发布到 NPM
360+
uses: JS-DevTools/npm-publish@v3
361+
with:
362+
token: ${{ secrets.NPM_TOKEN }}
363+
registry: https://registry.npmjs.org/
364+
package: packages/sqlite3
365+
access: public
366+
provenance: true

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
node_modules
2-
package.json
32
dist/

.release-please-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@
112112
"component": "log4js",
113113
"tag-separator": "-",
114114
"scope": "log4js"
115+
},
116+
"packages/sqlite3": {
117+
"release-type": "node",
118+
"package-name": "@candriajs/sqlite3",
119+
"component": "sqlite3",
120+
"tag-separator": "-",
121+
"scope": "sqlite3"
115122
}
116123
},
117124
"commit-search-depth": 50

.release-please-manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"packages/lodash": "1.0.10",
66
"packages/simple-git": "1.1.2",
77
"packages/dotenv": "1.2.3",
8-
"packages/log4js": "1.1.7"
8+
"packages/log4js": "1.1.7",
9+
"packages/sqlite3": "1.0.0"
910
}

packages/cli/src/init.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const pack = (dir: string, name: string) => {
4343
}
4444

4545
const tsdown = (dir: string) => {
46-
const template = `import { defineConfig, type Options } from 'tsup'
46+
const template = `import { defineConfig, type Options } from 'tsdown'
4747
4848
export const options: Options = ({
4949
entry: ['src/index.ts'],
@@ -63,8 +63,7 @@ export default defineConfig(options)
6363
}
6464

6565
const vite = (dir: string) => {
66-
const template = `
67-
import { defineConfig } from 'vite'
66+
const template = `import { defineConfig } from 'vite'
6867
import { builtinModules } from 'node:module'
6968
7069
export default defineConfig({

packages/sqlite3/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# sqlite3

packages/sqlite3/package.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "@candriajs/sqlite3",
3+
"version": "1.0.0",
4+
"description": "一些常用包以及常用函数进行封装,并打包优化, 此包为sqlite3封装",
5+
"keywords": [
6+
"sqlite3"
7+
],
8+
"homepage": "https://github.com/CandriaJS/core-lib",
9+
"bugs": {
10+
"url": "https://github.com/CandriaJS/core-lib/issues"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "git+https://github.com/CandriaJS/core-lib.git"
15+
},
16+
"license": "GNU AGPL-3.0",
17+
"author": "CandriaJS",
18+
"type": "module",
19+
"main": "./dist/index.js",
20+
"types": "./dist/index.d.ts",
21+
"files": [
22+
"dist",
23+
"index.js"
24+
],
25+
"scripts": {
26+
"build": "vite build && tsdown",
27+
"sync": "curl -X PUT \"https://registry-direct.npmmirror.com/-/package/@candriajs/sqlite3/syncs\""
28+
},
29+
"engines": {
30+
"node": ">=18"
31+
},
32+
"devDependencies": {
33+
"sqlite3": "npm:@karinjs/sqlite3@^0.1.3"
34+
}
35+
}

packages/sqlite3/src/index.ts

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import * as sqlite3 from 'sqlite3'
2+
import { Database, Statement, verbose, cached } from 'sqlite3'
3+
4+
const {
5+
OPEN_READONLY,
6+
OPEN_READWRITE,
7+
OPEN_CREATE,
8+
OPEN_FULLMUTEX,
9+
OPEN_SHAREDCACHE,
10+
OPEN_PRIVATECACHE,
11+
OPEN_URI,
12+
VERSION,
13+
SOURCE_ID,
14+
VERSION_NUMBER,
15+
OK,
16+
ERROR,
17+
INTERNAL,
18+
PERM,
19+
ABORT,
20+
BUSY,
21+
LOCKED,
22+
NOMEM,
23+
READONLY,
24+
INTERRUPT,
25+
IOERR,
26+
CORRUPT,
27+
NOTFOUND,
28+
FULL,
29+
CANTOPEN,
30+
PROTOCOL,
31+
EMPTY,
32+
SCHEMA,
33+
TOOBIG,
34+
CONSTRAINT,
35+
MISMATCH,
36+
MISUSE,
37+
NOLFS,
38+
AUTH,
39+
FORMAT,
40+
RANGE,
41+
NOTADB,
42+
LIMIT_LENGTH,
43+
LIMIT_SQL_LENGTH,
44+
LIMIT_COLUMN,
45+
LIMIT_EXPR_DEPTH,
46+
LIMIT_COMPOUND_SELECT,
47+
LIMIT_VDBE_OP,
48+
LIMIT_FUNCTION_ARG,
49+
LIMIT_ATTACHED,
50+
LIMIT_LIKE_PATTERN_LENGTH,
51+
LIMIT_VARIABLE_NUMBER,
52+
LIMIT_TRIGGER_DEPTH,
53+
LIMIT_WORKER_THREADS,
54+
} = sqlite3
55+
56+
export {
57+
cached,
58+
verbose,
59+
Statement,
60+
Database,
61+
sqlite3 as default,
62+
OPEN_READONLY,
63+
OPEN_READWRITE,
64+
OPEN_CREATE,
65+
OPEN_FULLMUTEX,
66+
OPEN_SHAREDCACHE,
67+
OPEN_PRIVATECACHE,
68+
OPEN_URI,
69+
VERSION,
70+
SOURCE_ID,
71+
VERSION_NUMBER,
72+
OK,
73+
ERROR,
74+
INTERNAL,
75+
PERM,
76+
ABORT,
77+
BUSY,
78+
LOCKED,
79+
NOMEM,
80+
READONLY,
81+
INTERRUPT,
82+
IOERR,
83+
CORRUPT,
84+
NOTFOUND,
85+
FULL,
86+
CANTOPEN,
87+
PROTOCOL,
88+
EMPTY,
89+
SCHEMA,
90+
TOOBIG,
91+
CONSTRAINT,
92+
MISMATCH,
93+
MISUSE,
94+
NOLFS,
95+
AUTH,
96+
FORMAT,
97+
RANGE,
98+
NOTADB,
99+
LIMIT_LENGTH,
100+
LIMIT_SQL_LENGTH,
101+
LIMIT_COLUMN,
102+
LIMIT_EXPR_DEPTH,
103+
LIMIT_COMPOUND_SELECT,
104+
LIMIT_VDBE_OP,
105+
LIMIT_FUNCTION_ARG,
106+
LIMIT_ATTACHED,
107+
LIMIT_LIKE_PATTERN_LENGTH,
108+
LIMIT_VARIABLE_NUMBER,
109+
LIMIT_TRIGGER_DEPTH,
110+
LIMIT_WORKER_THREADS,
111+
}
112+
113+
export type {
114+
sqlite3,
115+
RunResult,
116+
} from 'sqlite3'

packages/sqlite3/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"outDir": "./dist",
5+
"rootDir": "./src"
6+
},
7+
"include": [
8+
"src/**/*"
9+
],
10+
"exclude": [
11+
"node_modules",
12+
"dist"
13+
]
14+
}

packages/sqlite3/tsdown.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig, type Options } from 'tsdown'
2+
3+
export const options: Options = ({
4+
entry: ['src/index.ts'],
5+
format: 'esm',
6+
dts: { resolve: true, emitDtsOnly: true, sourcemap: false },
7+
outDir: 'dist',
8+
target: 'node22',
9+
platform: 'node',
10+
minify: true,
11+
clean: false,
12+
sourcemap: false
13+
})
14+
export default defineConfig(options)

0 commit comments

Comments
 (0)