@nocobase/server 2.1.0-alpha.17 → 2.1.0-alpha.19
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/lib/aes-encryptor.js +3 -2
- package/lib/ai/create-docs-index.js +2 -1
- package/lib/commands/create-migration.js +1 -1
- package/lib/commands/start.js +2 -2
- package/lib/event-queue.js +1 -1
- package/lib/gateway/index.js +9 -6
- package/lib/plugin-manager/options/resource.js +10 -4
- package/lib/plugin-manager/plugin-manager.js +2 -2
- package/lib/plugin-manager/utils.d.ts +0 -1
- package/lib/plugin-manager/utils.js +1 -8
- package/lib/plugin.js +1 -1
- package/package.json +17 -17
package/lib/aes-encryptor.js
CHANGED
|
@@ -44,6 +44,7 @@ module.exports = __toCommonJS(aes_encryptor_exports);
|
|
|
44
44
|
var import_crypto = __toESM(require("crypto"));
|
|
45
45
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
46
46
|
var import_path = __toESM(require("path"));
|
|
47
|
+
var import_utils = require("@nocobase/utils");
|
|
47
48
|
const _AesEncryptor = class _AesEncryptor {
|
|
48
49
|
key;
|
|
49
50
|
constructor(key) {
|
|
@@ -99,12 +100,12 @@ const _AesEncryptor = class _AesEncryptor {
|
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
static async getKeyPath(appName) {
|
|
102
|
-
const appKeyPath =
|
|
103
|
+
const appKeyPath = (0, import_utils.storagePathJoin)("apps", appName, "aes_key.dat");
|
|
103
104
|
const appKeyExists = await import_fs_extra.default.exists(appKeyPath);
|
|
104
105
|
if (appKeyExists) {
|
|
105
106
|
return appKeyPath;
|
|
106
107
|
}
|
|
107
|
-
const envKeyPath =
|
|
108
|
+
const envKeyPath = (0, import_utils.storagePathJoin)("environment-variables", appName, "aes_key.dat");
|
|
108
109
|
const envKeyExists = await import_fs_extra.default.exists(envKeyPath);
|
|
109
110
|
if (envKeyExists) {
|
|
110
111
|
return envKeyPath;
|
|
@@ -43,10 +43,11 @@ module.exports = __toCommonJS(create_docs_index_exports);
|
|
|
43
43
|
var import_fast_glob = __toESM(require("fast-glob"));
|
|
44
44
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
45
45
|
var import_path = __toESM(require("path"));
|
|
46
|
+
var import_utils = require("@nocobase/utils");
|
|
46
47
|
var import_ai = require("@nocobase/ai");
|
|
47
48
|
var import_findPackageNames = require("../plugin-manager/findPackageNames");
|
|
48
49
|
var import_plugin_manager = require("../plugin-manager");
|
|
49
|
-
const DOCS_STORAGE_DIR =
|
|
50
|
+
const DOCS_STORAGE_DIR = (0, import_utils.storagePathJoin)("ai", "docs");
|
|
50
51
|
const REFERENCE_START = "<!-- docs:references:start -->";
|
|
51
52
|
const REFERENCE_END = "<!-- docs:references:end -->";
|
|
52
53
|
const SPLIT_REFERENCE_START = "<!-- docs:splits:start -->";
|
|
@@ -76,6 +76,6 @@ export default class extends Migration {
|
|
|
76
76
|
`;
|
|
77
77
|
await import_fs.default.promises.mkdir((0, import_path.dirname)(filename), { recursive: true });
|
|
78
78
|
await import_fs.default.promises.writeFile(filename, data, "utf8");
|
|
79
|
-
|
|
79
|
+
console.log(`migration file in ${filename}`);
|
|
80
80
|
});
|
|
81
81
|
}, "default");
|
package/lib/commands/start.js
CHANGED
|
@@ -41,14 +41,14 @@ __export(start_exports, {
|
|
|
41
41
|
});
|
|
42
42
|
module.exports = __toCommonJS(start_exports);
|
|
43
43
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
44
|
-
var
|
|
44
|
+
var import_utils = require("@nocobase/utils");
|
|
45
45
|
var import_create_docs_index = require("../ai/create-docs-index");
|
|
46
46
|
var import_application_not_install = require("../errors/application-not-install");
|
|
47
47
|
/* istanbul ignore file -- @preserve */
|
|
48
48
|
var start_default = /* @__PURE__ */ __name((app) => {
|
|
49
49
|
app.command("start").auth().option("--db-sync").option("--quickstart").action(async (...cliArgs) => {
|
|
50
50
|
const [options] = cliArgs;
|
|
51
|
-
const file = (0,
|
|
51
|
+
const file = (0, import_utils.storagePathJoin)(".upgrading");
|
|
52
52
|
const upgrading = await import_fs_extra.default.exists(file);
|
|
53
53
|
if (upgrading) {
|
|
54
54
|
if (!process.env.VITEST) {
|
package/lib/event-queue.js
CHANGED
|
@@ -71,7 +71,7 @@ const _MemoryEventQueueAdapter = class _MemoryEventQueueAdapter {
|
|
|
71
71
|
return null;
|
|
72
72
|
}
|
|
73
73
|
get storagePath() {
|
|
74
|
-
return
|
|
74
|
+
return (0, import_utils.storagePathJoin)("apps", this.options.appName, "event-queue.json");
|
|
75
75
|
}
|
|
76
76
|
listen = /* @__PURE__ */ __name((channel) => {
|
|
77
77
|
if (!this.connected) {
|
package/lib/gateway/index.js
CHANGED
|
@@ -56,6 +56,7 @@ var import_fs = __toESM(require("fs"));
|
|
|
56
56
|
var import_http = __toESM(require("http"));
|
|
57
57
|
var import_koa_compose = __toESM(require("koa-compose"));
|
|
58
58
|
var import_node_util = require("node:util");
|
|
59
|
+
var import_node_os = require("node:os");
|
|
59
60
|
var import_path = require("path");
|
|
60
61
|
var import_qs = __toESM(require("qs"));
|
|
61
62
|
var import_serve_handler = __toESM(require("serve-handler"));
|
|
@@ -77,11 +78,14 @@ function normalizeBasePath(path = "") {
|
|
|
77
78
|
}
|
|
78
79
|
__name(normalizeBasePath, "normalizeBasePath");
|
|
79
80
|
function getSocketPath() {
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
return
|
|
81
|
+
const socketPath = import_node_process.default.env.SOCKET_PATH;
|
|
82
|
+
if (socketPath) {
|
|
83
|
+
return (0, import_path.isAbsolute)(socketPath) ? socketPath : (0, import_path.resolve)(import_node_process.default.cwd(), socketPath);
|
|
83
84
|
}
|
|
84
|
-
|
|
85
|
+
if (import_node_process.default.env.NOCOBASE_RUNNING_IN_DOCKER === "true") {
|
|
86
|
+
return (0, import_path.resolve)((0, import_node_os.homedir)(), ".nocobase", "gateway.sock");
|
|
87
|
+
}
|
|
88
|
+
return (0, import_utils.storagePathJoin)("gateway.sock");
|
|
85
89
|
}
|
|
86
90
|
__name(getSocketPath, "getSocketPath");
|
|
87
91
|
const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
@@ -96,7 +100,7 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
96
100
|
loggers = new import_utils.Registry();
|
|
97
101
|
port = import_node_process.default.env.APP_PORT ? parseInt(import_node_process.default.env.APP_PORT) : null;
|
|
98
102
|
host = "0.0.0.0";
|
|
99
|
-
socketPath = (
|
|
103
|
+
socketPath = getSocketPath();
|
|
100
104
|
v2IndexTemplateCache = null;
|
|
101
105
|
terminating = false;
|
|
102
106
|
onTerminate = /* @__PURE__ */ __name(async (signal) => {
|
|
@@ -129,7 +133,6 @@ const _Gateway = class _Gateway extends import_events.EventEmitter {
|
|
|
129
133
|
constructor() {
|
|
130
134
|
super();
|
|
131
135
|
this.reset();
|
|
132
|
-
this.socketPath = getSocketPath();
|
|
133
136
|
import_node_process.default.once("SIGTERM", this.onTerminate);
|
|
134
137
|
import_node_process.default.once("SIGINT", this.onTerminate);
|
|
135
138
|
}
|
|
@@ -143,6 +143,9 @@ var resource_default = {
|
|
|
143
143
|
name: "pm",
|
|
144
144
|
actions: {
|
|
145
145
|
async add(ctx, next) {
|
|
146
|
+
if (process.env.DISABLE_PM_ADD === "true") {
|
|
147
|
+
ctx.throw(403, "The current environment does not allow adding plugins online");
|
|
148
|
+
}
|
|
146
149
|
const app = ctx.app;
|
|
147
150
|
const { values = {} } = ctx.action.params;
|
|
148
151
|
if (values == null ? void 0 : values.packageName) {
|
|
@@ -158,12 +161,12 @@ var resource_default = {
|
|
|
158
161
|
}
|
|
159
162
|
app.runAsCLI(["pm", "add", values.packageName, ...args], { from: "user" });
|
|
160
163
|
} else if (ctx.file) {
|
|
161
|
-
const tmpDir =
|
|
164
|
+
const tmpDir = (0, import_utils.storagePathJoin)("tmp");
|
|
162
165
|
try {
|
|
163
166
|
await import_fs.default.promises.mkdir(tmpDir, { recursive: true });
|
|
164
167
|
} catch (error) {
|
|
165
168
|
}
|
|
166
|
-
const tempFile = import_path.default.join(
|
|
169
|
+
const tempFile = import_path.default.join(tmpDir, (0, import_utils.uid)() + import_path.default.extname(ctx.file.originalname));
|
|
167
170
|
await import_fs.default.promises.writeFile(tempFile, ctx.file.buffer, "binary");
|
|
168
171
|
app.runAsCLI(["pm", "add", tempFile], { from: "user" });
|
|
169
172
|
} else if (values.compressedFileUrl) {
|
|
@@ -173,6 +176,9 @@ var resource_default = {
|
|
|
173
176
|
await next();
|
|
174
177
|
},
|
|
175
178
|
async update(ctx, next) {
|
|
179
|
+
if (process.env.DISABLE_PM_ADD === "true") {
|
|
180
|
+
ctx.throw(403, "The current environment does not allow adding plugins online");
|
|
181
|
+
}
|
|
176
182
|
const app = ctx.app;
|
|
177
183
|
const values = ctx.action.params.values || {};
|
|
178
184
|
const args = [];
|
|
@@ -187,12 +193,12 @@ var resource_default = {
|
|
|
187
193
|
}
|
|
188
194
|
if (ctx.file) {
|
|
189
195
|
values.packageName = ctx.request.body.packageName;
|
|
190
|
-
const tmpDir =
|
|
196
|
+
const tmpDir = (0, import_utils.storagePathJoin)("tmp");
|
|
191
197
|
try {
|
|
192
198
|
await import_fs.default.promises.mkdir(tmpDir, { recursive: true });
|
|
193
199
|
} catch (error) {
|
|
194
200
|
}
|
|
195
|
-
const tempFile = import_path.default.join(
|
|
201
|
+
const tempFile = import_path.default.join(tmpDir, (0, import_utils.uid)() + import_path.default.extname(ctx.file.originalname));
|
|
196
202
|
await import_fs.default.promises.writeFile(tempFile, ctx.file.buffer, "binary");
|
|
197
203
|
values.compressedFileUrl = tempFile;
|
|
198
204
|
}
|
|
@@ -775,7 +775,7 @@ const _PluginManager = class _PluginManager {
|
|
|
775
775
|
if (process.env.VITEST) {
|
|
776
776
|
return;
|
|
777
777
|
}
|
|
778
|
-
const file = (0,
|
|
778
|
+
const file = (0, import_utils.storagePathJoin)(".upgrading");
|
|
779
779
|
this.app.log.debug("pending upgrade");
|
|
780
780
|
await import_fs_extra.default.writeFile(file, "upgrading");
|
|
781
781
|
}, "writeFile");
|
|
@@ -860,7 +860,7 @@ const _PluginManager = class _PluginManager {
|
|
|
860
860
|
});
|
|
861
861
|
return;
|
|
862
862
|
}
|
|
863
|
-
const file = (0,
|
|
863
|
+
const file = (0, import_utils.storagePathJoin)("app-upgrading");
|
|
864
864
|
await import_fs_extra.default.writeFile(file, "", "utf-8");
|
|
865
865
|
await (0, import_helper.tsxRerunning)();
|
|
866
866
|
await (0, import_execa.default)("yarn", ["nocobase", "pm2-restart"], {
|
|
@@ -17,7 +17,6 @@ import Application from '../application';
|
|
|
17
17
|
* getTempDir() => '/tmp/nocobase'
|
|
18
18
|
*/
|
|
19
19
|
export declare function getTempDir(): Promise<string>;
|
|
20
|
-
export declare function getPluginStoragePath(): string;
|
|
21
20
|
export declare function getLocalPluginPackagesPathArr(): string[];
|
|
22
21
|
export declare function getStoragePluginDir(packageName: string): string;
|
|
23
22
|
export declare function getLocalPluginDir(packageDirBasename: string): string;
|
|
@@ -59,7 +59,6 @@ __export(utils_exports, {
|
|
|
59
59
|
getPackagesFromFiles: () => getPackagesFromFiles,
|
|
60
60
|
getPluginBasePath: () => getPluginBasePath,
|
|
61
61
|
getPluginInfoByNpm: () => getPluginInfoByNpm,
|
|
62
|
-
getPluginStoragePath: () => getPluginStoragePath,
|
|
63
62
|
getServerPackages: () => getServerPackages,
|
|
64
63
|
getStoragePluginDir: () => getStoragePluginDir,
|
|
65
64
|
getTempDir: () => getTempDir,
|
|
@@ -97,11 +96,6 @@ async function getTempDir() {
|
|
|
97
96
|
return import_path.default.join(temporaryDirectory, import_constants.APP_NAME);
|
|
98
97
|
}
|
|
99
98
|
__name(getTempDir, "getTempDir");
|
|
100
|
-
function getPluginStoragePath() {
|
|
101
|
-
const pluginStoragePath = process.env.PLUGIN_STORAGE_PATH || import_constants.DEFAULT_PLUGIN_STORAGE_PATH;
|
|
102
|
-
return import_path.default.isAbsolute(pluginStoragePath) ? pluginStoragePath : import_path.default.join(process.cwd(), pluginStoragePath);
|
|
103
|
-
}
|
|
104
|
-
__name(getPluginStoragePath, "getPluginStoragePath");
|
|
105
99
|
function getLocalPluginPackagesPathArr() {
|
|
106
100
|
const pluginPackagesPathArr = process.env.PLUGIN_PATH || import_constants.DEFAULT_PLUGIN_PATH;
|
|
107
101
|
return pluginPackagesPathArr.split(",").map((pluginPackagesPath) => {
|
|
@@ -111,7 +105,7 @@ function getLocalPluginPackagesPathArr() {
|
|
|
111
105
|
}
|
|
112
106
|
__name(getLocalPluginPackagesPathArr, "getLocalPluginPackagesPathArr");
|
|
113
107
|
function getStoragePluginDir(packageName) {
|
|
114
|
-
const pluginStoragePath =
|
|
108
|
+
const pluginStoragePath = (0, import_utils.resolvePluginStoragePath)();
|
|
115
109
|
return import_path.default.join(pluginStoragePath, packageName);
|
|
116
110
|
}
|
|
117
111
|
__name(getStoragePluginDir, "getStoragePluginDir");
|
|
@@ -579,7 +573,6 @@ __name(pmListSummary, "pmListSummary");
|
|
|
579
573
|
getPackagesFromFiles,
|
|
580
574
|
getPluginBasePath,
|
|
581
575
|
getPluginInfoByNpm,
|
|
582
|
-
getPluginStoragePath,
|
|
583
576
|
getServerPackages,
|
|
584
577
|
getStoragePluginDir,
|
|
585
578
|
getTempDir,
|
package/lib/plugin.js
CHANGED
|
@@ -293,7 +293,7 @@ const _Plugin = class _Plugin {
|
|
|
293
293
|
...await (0, import_utils2.checkAndGetCompatible)(packageName),
|
|
294
294
|
lastUpdated: (await import_fs.default.promises.stat(file)).ctime,
|
|
295
295
|
file,
|
|
296
|
-
updatable: file.startsWith(
|
|
296
|
+
updatable: file.startsWith((0, import_utils.resolvePluginStoragePath)())
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
299
|
return results;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.19",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,21 +10,21 @@
|
|
|
10
10
|
"@koa/cors": "^5.0.0",
|
|
11
11
|
"@koa/multer": "^3.1.0",
|
|
12
12
|
"@koa/router": "^13.1.0",
|
|
13
|
-
"@nocobase/acl": "2.1.0-alpha.
|
|
14
|
-
"@nocobase/actions": "2.1.0-alpha.
|
|
15
|
-
"@nocobase/ai": "2.1.0-alpha.
|
|
16
|
-
"@nocobase/auth": "2.1.0-alpha.
|
|
17
|
-
"@nocobase/cache": "2.1.0-alpha.
|
|
18
|
-
"@nocobase/data-source-manager": "2.1.0-alpha.
|
|
19
|
-
"@nocobase/database": "2.1.0-alpha.
|
|
20
|
-
"@nocobase/evaluators": "2.1.0-alpha.
|
|
21
|
-
"@nocobase/lock-manager": "2.1.0-alpha.
|
|
22
|
-
"@nocobase/logger": "2.1.0-alpha.
|
|
23
|
-
"@nocobase/resourcer": "2.1.0-alpha.
|
|
24
|
-
"@nocobase/sdk": "2.1.0-alpha.
|
|
25
|
-
"@nocobase/snowflake-id": "2.1.0-alpha.
|
|
26
|
-
"@nocobase/telemetry": "2.1.0-alpha.
|
|
27
|
-
"@nocobase/utils": "2.1.0-alpha.
|
|
13
|
+
"@nocobase/acl": "2.1.0-alpha.19",
|
|
14
|
+
"@nocobase/actions": "2.1.0-alpha.19",
|
|
15
|
+
"@nocobase/ai": "2.1.0-alpha.19",
|
|
16
|
+
"@nocobase/auth": "2.1.0-alpha.19",
|
|
17
|
+
"@nocobase/cache": "2.1.0-alpha.19",
|
|
18
|
+
"@nocobase/data-source-manager": "2.1.0-alpha.19",
|
|
19
|
+
"@nocobase/database": "2.1.0-alpha.19",
|
|
20
|
+
"@nocobase/evaluators": "2.1.0-alpha.19",
|
|
21
|
+
"@nocobase/lock-manager": "2.1.0-alpha.19",
|
|
22
|
+
"@nocobase/logger": "2.1.0-alpha.19",
|
|
23
|
+
"@nocobase/resourcer": "2.1.0-alpha.19",
|
|
24
|
+
"@nocobase/sdk": "2.1.0-alpha.19",
|
|
25
|
+
"@nocobase/snowflake-id": "2.1.0-alpha.19",
|
|
26
|
+
"@nocobase/telemetry": "2.1.0-alpha.19",
|
|
27
|
+
"@nocobase/utils": "2.1.0-alpha.19",
|
|
28
28
|
"@types/decompress": "4.2.7",
|
|
29
29
|
"@types/ini": "^1.3.31",
|
|
30
30
|
"@types/koa-send": "^4.1.3",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@types/serve-handler": "^6.1.1",
|
|
62
62
|
"@types/ws": "^8.5.5"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "3d13700360eac1c0f9dbf6a5f167ed396a294a3c"
|
|
65
65
|
}
|