@xiaozhi-client/config 1.9.4-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +580 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +37 -0
- package/project.json +38 -0
- package/src/__tests__/adapter.test.ts +233 -0
- package/src/adapter.ts +432 -0
- package/src/index.ts +2 -0
- package/src/json5-adapter.ts +52 -0
- package/src/manager.ts +2259 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +77 -0
- package/vitest.config.ts +23 -0
package/tsconfig.json
ADDED
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { defineConfig } from "tsup";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 递归复制目录
|
|
7
|
+
*/
|
|
8
|
+
function copyDirectory(src: string, dest: string): void {
|
|
9
|
+
if (!existsSync(dest)) {
|
|
10
|
+
mkdirSync(dest, { recursive: true });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const items = readdirSync(src);
|
|
14
|
+
|
|
15
|
+
for (const item of items) {
|
|
16
|
+
const srcPath = join(src, item);
|
|
17
|
+
const destPath = join(dest, item);
|
|
18
|
+
const stat = statSync(srcPath);
|
|
19
|
+
|
|
20
|
+
if (stat.isDirectory()) {
|
|
21
|
+
copyDirectory(srcPath, destPath);
|
|
22
|
+
} else {
|
|
23
|
+
copyFileSync(srcPath, destPath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default defineConfig({
|
|
29
|
+
entry: ["src/index.ts"],
|
|
30
|
+
format: ["esm"],
|
|
31
|
+
target: "node18",
|
|
32
|
+
outDir: "dist",
|
|
33
|
+
clean: true,
|
|
34
|
+
sourcemap: true,
|
|
35
|
+
dts: true,
|
|
36
|
+
minify: process.env.NODE_ENV === "production",
|
|
37
|
+
splitting: false,
|
|
38
|
+
bundle: true,
|
|
39
|
+
keepNames: true,
|
|
40
|
+
platform: "node",
|
|
41
|
+
esbuildOptions: (options) => {
|
|
42
|
+
// 在生产环境移除 console 和 debugger
|
|
43
|
+
if (process.env.NODE_ENV === "production") {
|
|
44
|
+
options.drop = ["console", "debugger"];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
options.resolveExtensions = [".ts", ".js", ".json"];
|
|
48
|
+
},
|
|
49
|
+
outExtension() {
|
|
50
|
+
return {
|
|
51
|
+
js: ".js",
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
external: [
|
|
55
|
+
// Node.js 内置模块
|
|
56
|
+
"fs",
|
|
57
|
+
"path",
|
|
58
|
+
"url",
|
|
59
|
+
"process",
|
|
60
|
+
"os",
|
|
61
|
+
"stream",
|
|
62
|
+
"events",
|
|
63
|
+
"util",
|
|
64
|
+
"crypto",
|
|
65
|
+
"http",
|
|
66
|
+
"https",
|
|
67
|
+
"child_process",
|
|
68
|
+
],
|
|
69
|
+
onSuccess: async () => {
|
|
70
|
+
// 复制构建产物到 dist/config
|
|
71
|
+
const srcDir = resolve("dist");
|
|
72
|
+
const destDir = resolve("../../dist/config");
|
|
73
|
+
|
|
74
|
+
copyDirectory(srcDir, destDir);
|
|
75
|
+
console.log("✅ 已复制 config 包构建产物到 dist/config/");
|
|
76
|
+
},
|
|
77
|
+
});
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { defineConfig } from "vitest/config";
|
|
4
|
+
|
|
5
|
+
// ESM 兼容的 __dirname
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
test: {
|
|
11
|
+
globals: true,
|
|
12
|
+
environment: "node",
|
|
13
|
+
testTimeout: 10000,
|
|
14
|
+
hookTimeout: 10000,
|
|
15
|
+
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
|
|
16
|
+
exclude: ["**/node_modules", "dist"],
|
|
17
|
+
},
|
|
18
|
+
resolve: {
|
|
19
|
+
alias: {
|
|
20
|
+
"@": __dirname,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|