@karinjs/plugin-basic 1.2.0 → 1.3.1

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.
@@ -1,129 +0,0 @@
1
- // src/root.ts
2
- import path from "node:path";
3
-
4
- // package.json
5
- var package_default = {
6
- name: "@karinjs/plugin-basic",
7
- version: "1.1.0",
8
- description: "karin plugin for basic functions",
9
- homepage: "https://github.com/KarinJS/karin-plugin-basic",
10
- bugs: {
11
- url: "https://github.com/KarinJS/karin-plugin-basic/issues"
12
- },
13
- repository: {
14
- type: "git",
15
- url: "git+https://github.com/KarinJS/karin-plugin-basic.git"
16
- },
17
- author: "shijin",
18
- type: "module",
19
- main: "dist/index.js",
20
- files: [
21
- "dist",
22
- "config",
23
- "resources",
24
- "LICENSE",
25
- "package.json",
26
- "README.md"
27
- ],
28
- scripts: {
29
- build: "tsc && tsup",
30
- pub: "npm publish --access public",
31
- sort: "npx sort-package-json",
32
- dev: "tsx src/app.ts",
33
- watch: "tsx watch src/index.ts",
34
- karin: "karin"
35
- },
36
- devDependencies: {
37
- "@types/node": "^24.0.1",
38
- eslint: "^9.29.0",
39
- neostandard: "^0.12.1",
40
- "node-karin": "^1.10.7",
41
- tsup: "^8.5.0",
42
- tsx: "^4.20.3",
43
- typescript: "^5.8.3"
44
- },
45
- publishConfig: {
46
- access: "public",
47
- registry: "https://registry.npmjs.org"
48
- },
49
- karin: {
50
- main: "src/index.ts",
51
- apps: [
52
- "dist/apps"
53
- ],
54
- "ts-apps": [
55
- "src/apps"
56
- ],
57
- static: [
58
- "resources"
59
- ],
60
- files: [
61
- "config"
62
- ],
63
- "ts-web": "src/web.config.ts",
64
- web: "dist/web.config.js"
65
- },
66
- dependencies: {
67
- "internal-ip": "^8.0.0"
68
- }
69
- };
70
-
71
- // src/root.ts
72
- import { fileURLToPath } from "node:url";
73
- var __filename = fileURLToPath(import.meta.url);
74
- var __dirname = path.dirname(__filename);
75
- var __pluginDir = path.resolve(__dirname, "../");
76
- var info = {
77
- /** 插件目录 */
78
- dir: __pluginDir,
79
- /** 插件名称 */
80
- name: package_default.name.replace(/\//g, "-"),
81
- /** 插件版本 */
82
- version: package_default.version,
83
- /** package.json */
84
- pkg: package_default
85
- };
86
-
87
- // src/utils/config.ts
88
- import fs from "node:fs";
89
- import path2 from "node:path";
90
- import {
91
- watch,
92
- basePath,
93
- filesByExt,
94
- copyConfigSync,
95
- requireFileSync
96
- } from "node-karin";
97
- var cache;
98
- var dir = path2.join(basePath, info.name, "config");
99
- var defConfig = path2.join(info.dir, "config");
100
- var main = () => {
101
- copyConfigSync(defConfig, dir, [".json"]);
102
- setTimeout(() => {
103
- const list = filesByExt(dir, ".json", "abs");
104
- list.forEach((file) => watch(file, (old, now) => {
105
- cache = void 0;
106
- }));
107
- }, 2e3);
108
- };
109
- var config = () => {
110
- if (cache) return cache;
111
- const user = requireFileSync(`${dir}/config.json`);
112
- const def = requireFileSync(`${defConfig}/config.json`);
113
- const result = { ...def, ...user };
114
- cache = result;
115
- return result;
116
- };
117
- var writeConfig = (config2) => {
118
- const def = requireFileSync(`${defConfig}/config.json`);
119
- const result = { ...def, ...config2 };
120
- cache = result;
121
- fs.writeFileSync(`${dir}/config.json`, JSON.stringify(result, null, 2));
122
- };
123
- main();
124
-
125
- export {
126
- info,
127
- config,
128
- writeConfig
129
- };