@nocobase/plugin-multi-app-manager 0.14.0-alpha.6 → 0.14.0-alpha.7
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/externalVersion.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@nocobase/client": "0.14.0-alpha.
|
|
2
|
+
"@nocobase/client": "0.14.0-alpha.7",
|
|
3
3
|
"antd": "5.8.6",
|
|
4
4
|
"react": "18.2.0",
|
|
5
5
|
"@formily/react": "2.2.27",
|
|
6
6
|
"react-router-dom": "6.14.1",
|
|
7
7
|
"react-i18next": "11.18.6",
|
|
8
|
-
"@nocobase/database": "0.14.0-alpha.
|
|
9
|
-
"@nocobase/server": "0.14.0-alpha.
|
|
8
|
+
"@nocobase/database": "0.14.0-alpha.7",
|
|
9
|
+
"@nocobase/server": "0.14.0-alpha.7",
|
|
10
10
|
"async-mutex": "0.3.2",
|
|
11
11
|
"lodash": "4.17.21",
|
|
12
12
|
"mysql2": "2.3.3",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"qs","description":"A querystring parser that supports nesting and arrays, with a depth limit","homepage":"https://github.com/ljharb/qs","version":"6.11.2","repository":{"type":"git","url":"https://github.com/ljharb/qs.git"},"funding":{"url":"https://github.com/sponsors/ljharb"},"main":"lib/index.js","contributors":[{"name":"Jordan Harband","email":"ljharb@gmail.com","url":"http://ljharb.codes"}],"keywords":["querystring","qs","query","url","parse","stringify"],"engines":{"node":">=0.6"},"dependencies":{"side-channel":"^1.0.4"},"devDependencies":{"@ljharb/eslint-config":"^21.0.1","aud":"^2.0.2","browserify":"^16.5.2","eclint":"^2.8.1","eslint":"=8.8.0","evalmd":"^0.0.19","for-each":"^0.3.3","has-override-mistake":"^1.0.0","has-property-descriptors":"^1.0.0","has-symbols":"^1.0.3","iconv-lite":"^0.5.1","in-publish":"^2.0.1","mkdirp":"^0.5.5","mock-property":"^1.0.0","npmignore":"^0.3.0","nyc":"^10.3.2","object-inspect":"^1.12.3","qs-iconv":"^1.0.4","safe-publish-latest":"^2.0.0","safer-buffer":"^2.1.2","tape":"^5.6.3"},"scripts":{"prepack":"npmignore --auto --commentLines=autogenerated","prepublishOnly":"safe-publish-latest && npm run dist","prepublish":"not-in-publish || npm run prepublishOnly","pretest":"npm run --silent readme && npm run --silent lint","test":"npm run tests-only","tests-only":"nyc tape 'test/**/*.js'","posttest":"aud --production","readme":"evalmd README.md","postlint":"eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git' | grep -v dist/)","lint":"eslint --ext=js,mjs .","dist":"mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js"},"license":"BSD-3-Clause","publishConfig":{"ignore":["!dist/*","bower.json","component.json",".github/workflows"]},"_lastModified":"2023-
|
|
1
|
+
{"name":"qs","description":"A querystring parser that supports nesting and arrays, with a depth limit","homepage":"https://github.com/ljharb/qs","version":"6.11.2","repository":{"type":"git","url":"https://github.com/ljharb/qs.git"},"funding":{"url":"https://github.com/sponsors/ljharb"},"main":"lib/index.js","contributors":[{"name":"Jordan Harband","email":"ljharb@gmail.com","url":"http://ljharb.codes"}],"keywords":["querystring","qs","query","url","parse","stringify"],"engines":{"node":">=0.6"},"dependencies":{"side-channel":"^1.0.4"},"devDependencies":{"@ljharb/eslint-config":"^21.0.1","aud":"^2.0.2","browserify":"^16.5.2","eclint":"^2.8.1","eslint":"=8.8.0","evalmd":"^0.0.19","for-each":"^0.3.3","has-override-mistake":"^1.0.0","has-property-descriptors":"^1.0.0","has-symbols":"^1.0.3","iconv-lite":"^0.5.1","in-publish":"^2.0.1","mkdirp":"^0.5.5","mock-property":"^1.0.0","npmignore":"^0.3.0","nyc":"^10.3.2","object-inspect":"^1.12.3","qs-iconv":"^1.0.4","safe-publish-latest":"^2.0.0","safer-buffer":"^2.1.2","tape":"^5.6.3"},"scripts":{"prepack":"npmignore --auto --commentLines=autogenerated","prepublishOnly":"safe-publish-latest && npm run dist","prepublish":"not-in-publish || npm run prepublishOnly","pretest":"npm run --silent readme && npm run --silent lint","test":"npm run tests-only","tests-only":"nyc tape 'test/**/*.js'","posttest":"aud --production","readme":"evalmd README.md","postlint":"eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git' | grep -v dist/)","lint":"eslint --ext=js,mjs .","dist":"mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js"},"license":"BSD-3-Clause","publishConfig":{"ignore":["!dist/*","bower.json","component.json",".github/workflows"]},"_lastModified":"2023-10-07T08:31:01.365Z"}
|
package/dist/server/server.d.ts
CHANGED
|
@@ -2,11 +2,14 @@ import { IDatabaseOptions, Transactionable } from '@nocobase/database';
|
|
|
2
2
|
import Application, { Plugin } from '@nocobase/server';
|
|
3
3
|
export type AppDbCreator = (app: Application, transaction?: Transactionable) => Promise<void>;
|
|
4
4
|
export type AppOptionsFactory = (appName: string, mainApp: Application) => any;
|
|
5
|
+
export type SubAppUpgradeHandler = (mainApp: Application) => Promise<void>;
|
|
5
6
|
export declare class PluginMultiAppManager extends Plugin {
|
|
6
7
|
appDbCreator: AppDbCreator;
|
|
7
8
|
appOptionsFactory: AppOptionsFactory;
|
|
9
|
+
subAppUpgradeHandler: SubAppUpgradeHandler;
|
|
8
10
|
private beforeGetApplicationMutex;
|
|
9
11
|
static getDatabaseConfig(app: Application): IDatabaseOptions;
|
|
12
|
+
setSubAppUpgradeHandler(handler: SubAppUpgradeHandler): void;
|
|
10
13
|
setAppOptionsFactory(factory: AppOptionsFactory): void;
|
|
11
14
|
setAppDbCreator(appDbCreator: AppDbCreator): void;
|
|
12
15
|
beforeLoad(): void;
|
package/dist/server/server.js
CHANGED
|
@@ -38,6 +38,40 @@ var import_path = __toESM(require("path"));
|
|
|
38
38
|
var import_qs = __toESM(require("qs"));
|
|
39
39
|
var import_url = require("url");
|
|
40
40
|
var import_server2 = require("../server");
|
|
41
|
+
const defaultSubAppUpgradeHandle = async (mainApp) => {
|
|
42
|
+
const repository = mainApp.db.getRepository("applications");
|
|
43
|
+
const findOptions = {};
|
|
44
|
+
const appSupervisor = import_server.AppSupervisor.getInstance();
|
|
45
|
+
if (appSupervisor.runningMode == "single") {
|
|
46
|
+
findOptions["filter"] = {
|
|
47
|
+
name: appSupervisor.singleAppName
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const instances = await repository.find(findOptions);
|
|
51
|
+
for (const instance of instances) {
|
|
52
|
+
const instanceOptions = instance.get("options");
|
|
53
|
+
if ((instanceOptions == null ? void 0 : instanceOptions.standaloneDeployment) && appSupervisor.runningMode !== "single") {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const beforeSubAppStatus = import_server.AppSupervisor.getInstance().getAppStatus(instance.name);
|
|
57
|
+
const subApp = await appSupervisor.getApp(instance.name, {
|
|
58
|
+
upgrading: true
|
|
59
|
+
});
|
|
60
|
+
console.log({ beforeSubAppStatus });
|
|
61
|
+
try {
|
|
62
|
+
mainApp.setMaintainingMessage(`upgrading sub app ${instance.name}...`);
|
|
63
|
+
console.log(`${instance.name}: upgrading...`);
|
|
64
|
+
await subApp.runAsCLI(["upgrade"], { from: "user" });
|
|
65
|
+
if (!beforeSubAppStatus && import_server.AppSupervisor.getInstance().getAppStatus(instance.name) === "initialized") {
|
|
66
|
+
await import_server.AppSupervisor.getInstance().removeApp(instance.name);
|
|
67
|
+
}
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.log(`${instance.name}: upgrade failed`);
|
|
70
|
+
mainApp.logger.error(error);
|
|
71
|
+
console.error(error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
41
75
|
const defaultDbCreator = async (app) => {
|
|
42
76
|
const databaseOptions = app.options.database;
|
|
43
77
|
const { host, port, username, password, dialect, database } = databaseOptions;
|
|
@@ -90,11 +124,15 @@ const defaultAppOptionsFactory = (appName, mainApp) => {
|
|
|
90
124
|
class PluginMultiAppManager extends import_server.Plugin {
|
|
91
125
|
appDbCreator = defaultDbCreator;
|
|
92
126
|
appOptionsFactory = defaultAppOptionsFactory;
|
|
127
|
+
subAppUpgradeHandler = defaultSubAppUpgradeHandle;
|
|
93
128
|
beforeGetApplicationMutex = new import_async_mutex.Mutex();
|
|
94
129
|
static getDatabaseConfig(app) {
|
|
95
130
|
const oldConfig = app.options.database instanceof import_database.Database ? app.options.database.options : app.options.database;
|
|
96
131
|
return import_lodash.default.cloneDeep(import_lodash.default.omit(oldConfig, ["migrator"]));
|
|
97
132
|
}
|
|
133
|
+
setSubAppUpgradeHandler(handler) {
|
|
134
|
+
this.subAppUpgradeHandler = handler;
|
|
135
|
+
}
|
|
98
136
|
setAppOptionsFactory(factory) {
|
|
99
137
|
this.appOptionsFactory = factory;
|
|
100
138
|
}
|
|
@@ -216,39 +254,7 @@ class PluginMultiAppManager extends import_server.Plugin {
|
|
|
216
254
|
}
|
|
217
255
|
});
|
|
218
256
|
this.app.on("afterUpgrade", async (app, options) => {
|
|
219
|
-
|
|
220
|
-
const repository = this.db.getRepository("applications");
|
|
221
|
-
const findOptions = {};
|
|
222
|
-
const appSupervisor = import_server.AppSupervisor.getInstance();
|
|
223
|
-
if (appSupervisor.runningMode == "single") {
|
|
224
|
-
findOptions["filter"] = {
|
|
225
|
-
name: appSupervisor.singleAppName
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
const instances = await repository.find(findOptions);
|
|
229
|
-
for (const instance of instances) {
|
|
230
|
-
const instanceOptions = instance.get("options");
|
|
231
|
-
if ((instanceOptions == null ? void 0 : instanceOptions.standaloneDeployment) && appSupervisor.runningMode !== "single") {
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
const beforeSubAppStatus = import_server.AppSupervisor.getInstance().getAppStatus(instance.name);
|
|
235
|
-
const subApp = await appSupervisor.getApp(instance.name, {
|
|
236
|
-
upgrading: true
|
|
237
|
-
});
|
|
238
|
-
console.log({ beforeSubAppStatus });
|
|
239
|
-
try {
|
|
240
|
-
this.app.setMaintainingMessage(`upgrading sub app ${instance.name}...`);
|
|
241
|
-
console.log(`${instance.name}: upgrading...`);
|
|
242
|
-
await subApp.runAsCLI(["upgrade"], { from: "user" });
|
|
243
|
-
if (!beforeSubAppStatus && import_server.AppSupervisor.getInstance().getAppStatus(instance.name) === "initialized") {
|
|
244
|
-
await import_server.AppSupervisor.getInstance().removeApp(instance.name);
|
|
245
|
-
}
|
|
246
|
-
} catch (error) {
|
|
247
|
-
console.log(`${instance.name}: upgrade failed`);
|
|
248
|
-
this.app.logger.error(error);
|
|
249
|
-
console.error(error);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
257
|
+
await this.subAppUpgradeHandler(app);
|
|
252
258
|
});
|
|
253
259
|
this.app.resourcer.registerActionHandlers({
|
|
254
260
|
"applications:listPinned": async (ctx, next) => {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "多应用管理器",
|
|
5
5
|
"description": "Dynamically create multiple apps without separate deployments",
|
|
6
6
|
"description.zh-CN": "无需单独部署即可动态创建多个应用",
|
|
7
|
-
"version": "0.14.0-alpha.
|
|
7
|
+
"version": "0.14.0-alpha.7",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"devDependencies": {
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"@nocobase/test": "0.x",
|
|
26
26
|
"@nocobase/utils": "0.x"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "dc958417d27ed0753439bcef192be91a03dfc30f"
|
|
29
29
|
}
|