@nocobase/server 0.7.0-alpha.34 → 0.7.0-alpha.57
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/acl/available-action.js +37 -35
- package/lib/acl/index.js +45 -21
- package/lib/app-manager.js +151 -83
- package/lib/application.d.ts +3 -2
- package/lib/application.js +291 -162
- package/lib/commands/console.d.ts +2 -3
- package/lib/commands/console.js +33 -24
- package/lib/commands/db-auth.d.ts +2 -4
- package/lib/commands/db-auth.js +23 -13
- package/lib/commands/db-clean.d.ts +3 -0
- package/lib/commands/db-clean.js +27 -0
- package/lib/commands/db-sync.d.ts +2 -4
- package/lib/commands/db-sync.js +25 -23
- package/lib/commands/index.d.ts +1 -2
- package/lib/commands/index.js +29 -30
- package/lib/commands/install.d.ts +2 -4
- package/lib/commands/install.js +64 -42
- package/lib/commands/start.d.ts +2 -4
- package/lib/commands/start.js +26 -22
- package/lib/commands/upgrade.d.ts +6 -0
- package/lib/commands/upgrade.js +45 -0
- package/lib/helper.js +132 -61
- package/lib/index.js +85 -32
- package/lib/middlewares/data-wrapping.js +63 -55
- package/lib/middlewares/index.js +30 -14
- package/lib/middlewares/table2resource.js +89 -52
- package/lib/plugin-manager.js +124 -55
- package/lib/plugin.js +65 -45
- package/lib/read-config.js +159 -64
- package/package.json +7 -13
- package/esm/acl/available-action.d.ts +0 -5
- package/esm/acl/available-action.js +0 -36
- package/esm/acl/available-action.js.map +0 -1
- package/esm/acl/index.d.ts +0 -2
- package/esm/acl/index.js +0 -19
- package/esm/acl/index.js.map +0 -1
- package/esm/app-manager.d.ts +0 -19
- package/esm/app-manager.js +0 -80
- package/esm/app-manager.js.map +0 -1
- package/esm/application.d.ts +0 -97
- package/esm/application.js +0 -165
- package/esm/application.js.map +0 -1
- package/esm/commands/console.d.ts +0 -4
- package/esm/commands/console.js +0 -25
- package/esm/commands/console.js.map +0 -1
- package/esm/commands/create-plugin/create-plugin.d.ts +0 -2
- package/esm/commands/create-plugin/create-plugin.js +0 -29
- package/esm/commands/create-plugin/create-plugin.js.map +0 -1
- package/esm/commands/create-plugin/index.d.ts +0 -5
- package/esm/commands/create-plugin/index.js +0 -6
- package/esm/commands/create-plugin/index.js.map +0 -1
- package/esm/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
- package/esm/commands/create-plugin/resources/templates/package-json.js +0 -11
- package/esm/commands/create-plugin/resources/templates/package-json.js.map +0 -1
- package/esm/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
- package/esm/commands/create-plugin/resources/templates/plugin.js +0 -12
- package/esm/commands/create-plugin/resources/templates/plugin.js.map +0 -1
- package/esm/commands/db-auth.d.ts +0 -5
- package/esm/commands/db-auth.js +0 -14
- package/esm/commands/db-auth.js.map +0 -1
- package/esm/commands/db-sync.d.ts +0 -5
- package/esm/commands/db-sync.js +0 -25
- package/esm/commands/db-sync.js.map +0 -1
- package/esm/commands/index.d.ts +0 -3
- package/esm/commands/index.js +0 -27
- package/esm/commands/index.js.map +0 -1
- package/esm/commands/install.d.ts +0 -5
- package/esm/commands/install.js +0 -46
- package/esm/commands/install.js.map +0 -1
- package/esm/commands/start.d.ts +0 -5
- package/esm/commands/start.js +0 -25
- package/esm/commands/start.js.map +0 -1
- package/esm/helper.d.ts +0 -7
- package/esm/helper.js +0 -59
- package/esm/helper.js.map +0 -1
- package/esm/index.d.ts +0 -7
- package/esm/index.js +0 -9
- package/esm/index.js.map +0 -1
- package/esm/middlewares/data-wrapping.d.ts +0 -3
- package/esm/middlewares/data-wrapping.js +0 -54
- package/esm/middlewares/data-wrapping.js.map +0 -1
- package/esm/middlewares/index.d.ts +0 -2
- package/esm/middlewares/index.js +0 -3
- package/esm/middlewares/index.js.map +0 -1
- package/esm/middlewares/table2resource.d.ts +0 -6
- package/esm/middlewares/table2resource.js +0 -51
- package/esm/middlewares/table2resource.js.map +0 -1
- package/esm/plugin-manager.d.ts +0 -23
- package/esm/plugin-manager.js +0 -57
- package/esm/plugin-manager.js.map +0 -1
- package/esm/plugin.d.ts +0 -32
- package/esm/plugin.js +0 -43
- package/esm/plugin.js.map +0 -1
- package/esm/read-config.d.ts +0 -8
- package/esm/read-config.js +0 -63
- package/esm/read-config.js.map +0 -1
- package/lib/acl/available-action.js.map +0 -1
- package/lib/acl/index.js.map +0 -1
- package/lib/app-manager.js.map +0 -1
- package/lib/application.js.map +0 -1
- package/lib/commands/console.js.map +0 -1
- package/lib/commands/create-plugin/create-plugin.d.ts +0 -2
- package/lib/commands/create-plugin/create-plugin.js +0 -31
- package/lib/commands/create-plugin/create-plugin.js.map +0 -1
- package/lib/commands/create-plugin/index.d.ts +0 -5
- package/lib/commands/create-plugin/index.js +0 -8
- package/lib/commands/create-plugin/index.js.map +0 -1
- package/lib/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
- package/lib/commands/create-plugin/resources/templates/package-json.js +0 -13
- package/lib/commands/create-plugin/resources/templates/package-json.js.map +0 -1
- package/lib/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
- package/lib/commands/create-plugin/resources/templates/plugin.js +0 -33
- package/lib/commands/create-plugin/resources/templates/plugin.js.map +0 -1
- package/lib/commands/db-auth.js.map +0 -1
- package/lib/commands/db-sync.js.map +0 -1
- package/lib/commands/index.js.map +0 -1
- package/lib/commands/install.js.map +0 -1
- package/lib/commands/start.js.map +0 -1
- package/lib/helper.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/middlewares/data-wrapping.js.map +0 -1
- package/lib/middlewares/index.js.map +0 -1
- package/lib/middlewares/table2resource.js.map +0 -1
- package/lib/plugin-manager.js.map +0 -1
- package/lib/plugin.js.map +0 -1
- package/lib/read-config.js.map +0 -1
- package/tsconfig.build.json +0 -9
package/lib/application.js
CHANGED
|
@@ -1,172 +1,301 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.Application = void 0;
|
|
7
|
+
|
|
8
|
+
function _actions() {
|
|
9
|
+
const data = require("@nocobase/actions");
|
|
10
|
+
|
|
11
|
+
_actions = function _actions() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _utils() {
|
|
19
|
+
const data = require("@nocobase/utils");
|
|
20
|
+
|
|
21
|
+
_utils = function _utils() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _commander() {
|
|
29
|
+
const data = require("commander");
|
|
30
|
+
|
|
31
|
+
_commander = function _commander() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _koa() {
|
|
39
|
+
const data = _interopRequireDefault(require("koa"));
|
|
40
|
+
|
|
41
|
+
_koa = function _koa() {
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _lodash() {
|
|
49
|
+
const data = require("lodash");
|
|
50
|
+
|
|
51
|
+
_lodash = function _lodash() {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var _acl = require("./acl");
|
|
59
|
+
|
|
60
|
+
var _appManager = require("./app-manager");
|
|
61
|
+
|
|
62
|
+
var _commands = require("./commands");
|
|
63
|
+
|
|
64
|
+
var _helper = require("./helper");
|
|
65
|
+
|
|
66
|
+
var _pluginManager = require("./plugin-manager");
|
|
67
|
+
|
|
68
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
69
|
+
|
|
70
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
71
|
+
|
|
72
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
73
|
+
|
|
74
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
75
|
+
|
|
76
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
77
|
+
|
|
78
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
79
|
+
|
|
80
|
+
const packageJson = require('../package.json');
|
|
81
|
+
|
|
82
|
+
class Application extends _koa().default {
|
|
83
|
+
constructor(options) {
|
|
84
|
+
super();
|
|
85
|
+
this.options = void 0;
|
|
86
|
+
this.db = void 0;
|
|
87
|
+
this.resourcer = void 0;
|
|
88
|
+
this.cli = void 0;
|
|
89
|
+
this.i18n = void 0;
|
|
90
|
+
this.pm = void 0;
|
|
91
|
+
this.acl = void 0;
|
|
92
|
+
this.appManager = void 0;
|
|
93
|
+
this.plugins = new Map();
|
|
94
|
+
this.listenServer = void 0;
|
|
95
|
+
this.options = options;
|
|
96
|
+
this.acl = (0, _acl.createACL)();
|
|
97
|
+
this.db = (0, _helper.createDatabase)(options);
|
|
98
|
+
this.resourcer = (0, _helper.createResourcer)(options);
|
|
99
|
+
this.cli = new (_commander().Command)('nocobase').usage('[command] [options]');
|
|
100
|
+
this.i18n = (0, _helper.createI18n)(options);
|
|
101
|
+
this.pm = new _pluginManager.PluginManager({
|
|
102
|
+
app: this
|
|
9
103
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
exports.Application = void 0;
|
|
16
|
-
const actions_1 = require("@nocobase/actions");
|
|
17
|
-
const utils_1 = require("@nocobase/utils");
|
|
18
|
-
const koa_1 = __importDefault(require("koa"));
|
|
19
|
-
const lodash_1 = require("lodash");
|
|
20
|
-
const acl_1 = require("./acl");
|
|
21
|
-
const app_manager_1 = require("./app-manager");
|
|
22
|
-
const commands_1 = require("./commands");
|
|
23
|
-
const helper_1 = require("./helper");
|
|
24
|
-
const plugin_manager_1 = require("./plugin-manager");
|
|
25
|
-
class Application extends koa_1.default {
|
|
26
|
-
constructor(options) {
|
|
27
|
-
super();
|
|
28
|
-
this.options = options;
|
|
29
|
-
this.plugins = new Map();
|
|
30
|
-
this.acl = (0, acl_1.createACL)();
|
|
31
|
-
this.db = (0, helper_1.createDatabase)(options);
|
|
32
|
-
this.resourcer = (0, helper_1.createResourcer)(options);
|
|
33
|
-
this.cli = (0, commands_1.createCli)(this);
|
|
34
|
-
this.i18n = (0, helper_1.createI18n)(options);
|
|
35
|
-
this.pm = new plugin_manager_1.PluginManager({
|
|
36
|
-
app: this,
|
|
37
|
-
});
|
|
38
|
-
this.appManager = new app_manager_1.AppManager(this);
|
|
39
|
-
(0, helper_1.registerMiddlewares)(this, options);
|
|
40
|
-
if (options.registerActions !== false) {
|
|
41
|
-
(0, actions_1.registerActions)(this);
|
|
42
|
-
}
|
|
43
|
-
this.loadPluginConfig(options.plugins || []);
|
|
104
|
+
this.appManager = new _appManager.AppManager(this);
|
|
105
|
+
(0, _helper.registerMiddlewares)(this, options);
|
|
106
|
+
|
|
107
|
+
if (options.registerActions !== false) {
|
|
108
|
+
(0, _actions().registerActions)(this);
|
|
44
109
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
110
|
+
|
|
111
|
+
this.loadPluginConfig(options.plugins || []);
|
|
112
|
+
(0, _commands.registerCli)(this);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
getVersion() {
|
|
116
|
+
return packageJson.version;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
plugin(pluginClass, options) {
|
|
120
|
+
return this.pm.add(pluginClass, options);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
loadPluginConfig(pluginsConfigurations) {
|
|
124
|
+
var _iterator = _createForOfIteratorHelper(pluginsConfigurations),
|
|
125
|
+
_step;
|
|
126
|
+
|
|
127
|
+
try {
|
|
128
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
129
|
+
let pluginConfiguration = _step.value;
|
|
130
|
+
|
|
131
|
+
if (typeof pluginConfiguration == 'string') {
|
|
132
|
+
pluginConfiguration = [pluginConfiguration, {}];
|
|
56
133
|
}
|
|
134
|
+
|
|
135
|
+
const plugin = _pluginManager.PluginManager.resolvePlugin(pluginConfiguration[0]);
|
|
136
|
+
|
|
137
|
+
const pluginOptions = pluginConfiguration[1];
|
|
138
|
+
this.plugin(plugin, pluginOptions);
|
|
139
|
+
}
|
|
140
|
+
} catch (err) {
|
|
141
|
+
_iterator.e(err);
|
|
142
|
+
} finally {
|
|
143
|
+
_iterator.f();
|
|
57
144
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
use(middleware, options) {
|
|
148
|
+
// @ts-ignore
|
|
149
|
+
return super.use(middleware);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
collection(options) {
|
|
153
|
+
return this.db.collection(options);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
resource(options) {
|
|
157
|
+
return this.resourcer.define(options);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
actions(handlers, options) {
|
|
161
|
+
return this.resourcer.registerActions(handlers);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
command(name, desc, opts) {
|
|
165
|
+
return this.cli.command(name, desc, opts).allowUnknownOption();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
findCommand(name) {
|
|
169
|
+
return this.cli._findCommand(name);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
load() {
|
|
173
|
+
var _this = this;
|
|
174
|
+
|
|
175
|
+
return _asyncToGenerator(function* () {
|
|
176
|
+
yield _this.pm.load();
|
|
177
|
+
})();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
getPlugin(name) {
|
|
181
|
+
return this.pm.get(name);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
parse(argv = process.argv) {
|
|
185
|
+
var _this2 = this;
|
|
186
|
+
|
|
187
|
+
return _asyncToGenerator(function* () {
|
|
188
|
+
yield _this2.load();
|
|
189
|
+
return _this2.cli.parseAsync(argv);
|
|
190
|
+
})();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
start(options = {}) {
|
|
194
|
+
var _this3 = this;
|
|
195
|
+
|
|
196
|
+
return _asyncToGenerator(function* () {
|
|
197
|
+
var _options$listen;
|
|
198
|
+
|
|
199
|
+
// reconnect database
|
|
200
|
+
if (_this3.db.closed()) {
|
|
201
|
+
yield _this3.db.reconnect();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
yield _this3.emitAsync('beforeStart', _this3, options);
|
|
205
|
+
|
|
206
|
+
if (options === null || options === void 0 ? void 0 : (_options$listen = options.listen) === null || _options$listen === void 0 ? void 0 : _options$listen.port) {
|
|
207
|
+
const listen = () => new Promise((resolve, reject) => {
|
|
208
|
+
const Server = _this3.listen(options === null || options === void 0 ? void 0 : options.listen, () => {
|
|
209
|
+
resolve(Server);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
Server.on('error', err => {
|
|
213
|
+
reject(err);
|
|
214
|
+
});
|
|
80
215
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
listen(...args) {
|
|
121
|
-
return this.appManager.listen(...args);
|
|
122
|
-
}
|
|
123
|
-
stop(options = {}) {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
yield this.emitAsync('beforeStop', this, options);
|
|
126
|
-
try {
|
|
127
|
-
// close database connection
|
|
128
|
-
// silent if database already closed
|
|
129
|
-
yield this.db.close();
|
|
130
|
-
}
|
|
131
|
-
catch (e) {
|
|
132
|
-
console.log(e);
|
|
133
|
-
}
|
|
134
|
-
// close http server
|
|
135
|
-
if (this.listenServer) {
|
|
136
|
-
const closeServer = () => new Promise((resolve, reject) => {
|
|
137
|
-
this.listenServer.close((err) => {
|
|
138
|
-
if (err) {
|
|
139
|
-
return reject(err);
|
|
140
|
-
}
|
|
141
|
-
this.listenServer = null;
|
|
142
|
-
resolve(true);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
yield closeServer();
|
|
146
|
-
}
|
|
147
|
-
yield this.emitAsync('afterStop', this, options);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
destroy(options = {}) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
yield this.emitAsync('beforeDestroy', this, options);
|
|
153
|
-
yield this.stop(options);
|
|
154
|
-
yield this.emitAsync('afterDestroy', this, options);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
install(options = {}) {
|
|
158
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
yield this.emitAsync('beforeInstall', this, options);
|
|
160
|
-
if (options === null || options === void 0 ? void 0 : options.clean) {
|
|
161
|
-
yield this.db.clean((0, lodash_1.isBoolean)(options.clean) ? { drop: options.clean } : options.clean);
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
//@ts-ignore
|
|
219
|
+
_this3.listenServer = yield listen();
|
|
220
|
+
} catch (e) {
|
|
221
|
+
console.error(e);
|
|
222
|
+
process.exit(1);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
yield _this3.emitAsync('afterStart', _this3, options);
|
|
227
|
+
})();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
listen(...args) {
|
|
231
|
+
return this.appManager.listen(...args);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
stop(options = {}) {
|
|
235
|
+
var _this4 = this;
|
|
236
|
+
|
|
237
|
+
return _asyncToGenerator(function* () {
|
|
238
|
+
yield _this4.emitAsync('beforeStop', _this4, options);
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
// close database connection
|
|
242
|
+
// silent if database already closed
|
|
243
|
+
yield _this4.db.close();
|
|
244
|
+
} catch (e) {
|
|
245
|
+
console.log(e);
|
|
246
|
+
} // close http server
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
if (_this4.listenServer) {
|
|
250
|
+
const closeServer = () => new Promise((resolve, reject) => {
|
|
251
|
+
_this4.listenServer.close(err => {
|
|
252
|
+
if (err) {
|
|
253
|
+
return reject(err);
|
|
162
254
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
255
|
+
|
|
256
|
+
_this4.listenServer = null;
|
|
257
|
+
resolve(true);
|
|
258
|
+
});
|
|
166
259
|
});
|
|
167
|
-
|
|
260
|
+
|
|
261
|
+
yield closeServer();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
yield _this4.emitAsync('afterStop', _this4, options);
|
|
265
|
+
})();
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
destroy(options = {}) {
|
|
269
|
+
var _this5 = this;
|
|
270
|
+
|
|
271
|
+
return _asyncToGenerator(function* () {
|
|
272
|
+
yield _this5.emitAsync('beforeDestroy', _this5, options);
|
|
273
|
+
yield _this5.stop(options);
|
|
274
|
+
yield _this5.emitAsync('afterDestroy', _this5, options);
|
|
275
|
+
})();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
install(options = {}) {
|
|
279
|
+
var _this6 = this;
|
|
280
|
+
|
|
281
|
+
return _asyncToGenerator(function* () {
|
|
282
|
+
yield _this6.emitAsync('beforeInstall', _this6, options);
|
|
283
|
+
|
|
284
|
+
if (options === null || options === void 0 ? void 0 : options.clean) {
|
|
285
|
+
yield _this6.db.clean((0, _lodash().isBoolean)(options.clean) ? {
|
|
286
|
+
drop: options.clean
|
|
287
|
+
} : options.clean);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
yield _this6.db.sync(options === null || options === void 0 ? void 0 : options.sync);
|
|
291
|
+
yield _this6.pm.install(options);
|
|
292
|
+
yield _this6.emitAsync('afterInstall', _this6, options);
|
|
293
|
+
})();
|
|
294
|
+
}
|
|
295
|
+
|
|
168
296
|
}
|
|
297
|
+
|
|
169
298
|
exports.Application = Application;
|
|
170
|
-
(0,
|
|
171
|
-
|
|
172
|
-
|
|
299
|
+
(0, _utils().applyMixins)(Application, [_utils().AsyncEmitter]);
|
|
300
|
+
var _default = Application;
|
|
301
|
+
exports.default = _default;
|
package/lib/commands/console.js
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
+
|
|
10
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
+
|
|
12
12
|
const REPL = require('repl');
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
var _default = app => {
|
|
15
|
+
app.command('console').action( /*#__PURE__*/_asyncToGenerator(function* () {
|
|
14
16
|
yield app.start();
|
|
15
|
-
const repl =
|
|
16
|
-
repl.on('exit', function (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
const repl = REPL.start('nocobase > ').context.app = app;
|
|
18
|
+
repl.on('exit', /*#__PURE__*/function () {
|
|
19
|
+
var _ref2 = _asyncToGenerator(function* (err) {
|
|
20
|
+
if (err) {
|
|
21
|
+
console.log(err);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
yield app.stop();
|
|
26
|
+
process.exit(0);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return function (_x) {
|
|
30
|
+
return _ref2.apply(this, arguments);
|
|
31
|
+
};
|
|
32
|
+
}());
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
exports.default = _default;
|
package/lib/commands/db-auth.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
+
|
|
10
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
+
|
|
12
|
+
var _default = app => {
|
|
13
|
+
app.command('db:auth').option('-r, --repeat [repeat]').action( /*#__PURE__*/function () {
|
|
14
|
+
var _ref = _asyncToGenerator(function* (opts) {
|
|
15
|
+
yield app.db.auth({
|
|
16
|
+
repeat: opts.repeat || 10
|
|
17
|
+
});
|
|
9
18
|
});
|
|
19
|
+
|
|
20
|
+
return function (_x) {
|
|
21
|
+
return _ref.apply(this, arguments);
|
|
22
|
+
};
|
|
23
|
+
}());
|
|
10
24
|
};
|
|
11
|
-
|
|
12
|
-
exports.default =
|
|
13
|
-
const [opts] = cliArgs;
|
|
14
|
-
yield app.db.auth({ repeat: opts.repeat || 10 });
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=db-auth.js.map
|
|
25
|
+
|
|
26
|
+
exports.default = _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
+
|
|
10
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
+
|
|
12
|
+
var _default = app => {
|
|
13
|
+
app.command('db:clean').option('-y, --yes').action( /*#__PURE__*/function () {
|
|
14
|
+
var _ref = _asyncToGenerator(function* (opts) {
|
|
15
|
+
console.log('Clearing database');
|
|
16
|
+
yield app.db.clean({
|
|
17
|
+
drop: opts.yes
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return function (_x) {
|
|
22
|
+
return _ref.apply(this, arguments);
|
|
23
|
+
};
|
|
24
|
+
}());
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.default = _default;
|