@nocobase/server 0.7.3-alpha.1 → 0.7.4-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/lib/application.d.ts +2 -1
- package/lib/application.js +44 -36
- package/package.json +6 -6
package/lib/application.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ACL } from '@nocobase/acl';
|
|
|
4
4
|
import Database, { Collection, CollectionOptions, IDatabaseOptions } from '@nocobase/database';
|
|
5
5
|
import Resourcer, { ResourceOptions } from '@nocobase/resourcer';
|
|
6
6
|
import { AsyncEmitter } from '@nocobase/utils';
|
|
7
|
-
import { Command, CommandOptions } from 'commander';
|
|
7
|
+
import { Command, CommandOptions, ParseOptions } from 'commander';
|
|
8
8
|
import { Server } from 'http';
|
|
9
9
|
import { i18n, InitOptions } from 'i18next';
|
|
10
10
|
import Koa from 'koa';
|
|
@@ -98,6 +98,7 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
|
|
|
98
98
|
load(): Promise<void>;
|
|
99
99
|
getPlugin<P extends Plugin>(name: string): P;
|
|
100
100
|
parse(argv?: string[]): Promise<Command>;
|
|
101
|
+
runAsCLI(argv?: readonly string[], options?: ParseOptions): Promise<Command>;
|
|
101
102
|
start(options?: StartOptions): Promise<void>;
|
|
102
103
|
listen(...args: any[]): Server;
|
|
103
104
|
stop(options?: any): Promise<void>;
|
package/lib/application.js
CHANGED
|
@@ -297,27 +297,35 @@ class Application extends _koa().default {
|
|
|
297
297
|
var _this5 = this;
|
|
298
298
|
|
|
299
299
|
return _asyncToGenerator(function* () {
|
|
300
|
-
|
|
301
|
-
return _this5.cli.parseAsync(argv);
|
|
300
|
+
return _this5.runAsCLI(argv);
|
|
302
301
|
})();
|
|
303
302
|
}
|
|
304
303
|
|
|
305
|
-
|
|
304
|
+
runAsCLI(argv, options) {
|
|
306
305
|
var _this6 = this;
|
|
307
306
|
|
|
307
|
+
return _asyncToGenerator(function* () {
|
|
308
|
+
yield _this6.load();
|
|
309
|
+
return _this6.cli.parseAsync(argv, options);
|
|
310
|
+
})();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
start(options = {}) {
|
|
314
|
+
var _this7 = this;
|
|
315
|
+
|
|
308
316
|
return _asyncToGenerator(function* () {
|
|
309
317
|
var _options$listen;
|
|
310
318
|
|
|
311
319
|
// reconnect database
|
|
312
|
-
if (
|
|
313
|
-
yield
|
|
320
|
+
if (_this7.db.closed()) {
|
|
321
|
+
yield _this7.db.reconnect();
|
|
314
322
|
}
|
|
315
323
|
|
|
316
|
-
yield
|
|
324
|
+
yield _this7.emitAsync('beforeStart', _this7, options);
|
|
317
325
|
|
|
318
326
|
if (options === null || options === void 0 ? void 0 : (_options$listen = options.listen) === null || _options$listen === void 0 ? void 0 : _options$listen.port) {
|
|
319
327
|
const listen = () => new Promise((resolve, reject) => {
|
|
320
|
-
const Server =
|
|
328
|
+
const Server = _this7.listen(options === null || options === void 0 ? void 0 : options.listen, () => {
|
|
321
329
|
resolve(Server);
|
|
322
330
|
});
|
|
323
331
|
|
|
@@ -328,14 +336,14 @@ class Application extends _koa().default {
|
|
|
328
336
|
|
|
329
337
|
try {
|
|
330
338
|
//@ts-ignore
|
|
331
|
-
|
|
339
|
+
_this7.listenServer = yield listen();
|
|
332
340
|
} catch (e) {
|
|
333
341
|
console.error(e);
|
|
334
342
|
process.exit(1);
|
|
335
343
|
}
|
|
336
344
|
}
|
|
337
345
|
|
|
338
|
-
yield
|
|
346
|
+
yield _this7.emitAsync('afterStart', _this7, options);
|
|
339
347
|
})();
|
|
340
348
|
}
|
|
341
349
|
|
|
@@ -344,28 +352,28 @@ class Application extends _koa().default {
|
|
|
344
352
|
}
|
|
345
353
|
|
|
346
354
|
stop(options = {}) {
|
|
347
|
-
var
|
|
355
|
+
var _this8 = this;
|
|
348
356
|
|
|
349
357
|
return _asyncToGenerator(function* () {
|
|
350
|
-
yield
|
|
358
|
+
yield _this8.emitAsync('beforeStop', _this8, options);
|
|
351
359
|
|
|
352
360
|
try {
|
|
353
361
|
// close database connection
|
|
354
362
|
// silent if database already closed
|
|
355
|
-
yield
|
|
363
|
+
yield _this8.db.close();
|
|
356
364
|
} catch (e) {
|
|
357
365
|
console.log(e);
|
|
358
366
|
} // close http server
|
|
359
367
|
|
|
360
368
|
|
|
361
|
-
if (
|
|
369
|
+
if (_this8.listenServer) {
|
|
362
370
|
const closeServer = () => new Promise((resolve, reject) => {
|
|
363
|
-
|
|
371
|
+
_this8.listenServer.close(err => {
|
|
364
372
|
if (err) {
|
|
365
373
|
return reject(err);
|
|
366
374
|
}
|
|
367
375
|
|
|
368
|
-
|
|
376
|
+
_this8.listenServer = null;
|
|
369
377
|
resolve(true);
|
|
370
378
|
});
|
|
371
379
|
});
|
|
@@ -373,64 +381,64 @@ class Application extends _koa().default {
|
|
|
373
381
|
yield closeServer();
|
|
374
382
|
}
|
|
375
383
|
|
|
376
|
-
yield
|
|
384
|
+
yield _this8.emitAsync('afterStop', _this8, options);
|
|
377
385
|
})();
|
|
378
386
|
}
|
|
379
387
|
|
|
380
388
|
destroy(options = {}) {
|
|
381
|
-
var
|
|
389
|
+
var _this9 = this;
|
|
382
390
|
|
|
383
391
|
return _asyncToGenerator(function* () {
|
|
384
|
-
yield
|
|
385
|
-
yield
|
|
386
|
-
yield
|
|
392
|
+
yield _this9.emitAsync('beforeDestroy', _this9, options);
|
|
393
|
+
yield _this9.stop(options);
|
|
394
|
+
yield _this9.emitAsync('afterDestroy', _this9, options);
|
|
387
395
|
})();
|
|
388
396
|
}
|
|
389
397
|
|
|
390
398
|
install(options = {}) {
|
|
391
|
-
var
|
|
399
|
+
var _this10 = this;
|
|
392
400
|
|
|
393
401
|
return _asyncToGenerator(function* () {
|
|
394
|
-
yield
|
|
395
|
-
const r = yield
|
|
396
|
-
mysql: '8.
|
|
402
|
+
yield _this10.emitAsync('beforeInstall', _this10, options);
|
|
403
|
+
const r = yield _this10.db.version.satisfies({
|
|
404
|
+
mysql: '>=8.0.17',
|
|
397
405
|
sqlite: '3.x',
|
|
398
406
|
postgres: '>=10'
|
|
399
407
|
});
|
|
400
408
|
|
|
401
409
|
if (!r) {
|
|
402
|
-
console.log('The database only supports MySQL 8.
|
|
410
|
+
console.log('The database only supports MySQL 8.0.17 and above, SQLite 3.x and PostgreSQL 10+');
|
|
403
411
|
return;
|
|
404
412
|
}
|
|
405
413
|
|
|
406
414
|
if (options === null || options === void 0 ? void 0 : options.clean) {
|
|
407
|
-
yield
|
|
415
|
+
yield _this10.db.clean((0, _lodash().isBoolean)(options.clean) ? {
|
|
408
416
|
drop: options.clean
|
|
409
417
|
} : options.clean);
|
|
410
418
|
}
|
|
411
419
|
|
|
412
|
-
yield
|
|
413
|
-
yield
|
|
414
|
-
yield
|
|
415
|
-
yield
|
|
420
|
+
yield _this10.db.sync(options === null || options === void 0 ? void 0 : options.sync);
|
|
421
|
+
yield _this10.pm.install(options);
|
|
422
|
+
yield _this10.version.update();
|
|
423
|
+
yield _this10.emitAsync('afterInstall', _this10, options);
|
|
416
424
|
})();
|
|
417
425
|
}
|
|
418
426
|
|
|
419
427
|
upgrade(options = {}) {
|
|
420
|
-
var
|
|
428
|
+
var _this11 = this;
|
|
421
429
|
|
|
422
430
|
return _asyncToGenerator(function* () {
|
|
423
|
-
yield
|
|
431
|
+
yield _this11.emitAsync('beforeUpgrade', _this11, options);
|
|
424
432
|
const force = false;
|
|
425
|
-
yield
|
|
426
|
-
yield
|
|
433
|
+
yield _this11.db.migrator.up();
|
|
434
|
+
yield _this11.db.sync({
|
|
427
435
|
force,
|
|
428
436
|
alter: {
|
|
429
437
|
drop: force
|
|
430
438
|
}
|
|
431
439
|
});
|
|
432
|
-
yield
|
|
433
|
-
yield
|
|
440
|
+
yield _this11.version.update();
|
|
441
|
+
yield _this11.emitAsync('afterUpgrade', _this11, options);
|
|
434
442
|
})();
|
|
435
443
|
}
|
|
436
444
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4-alpha.7",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@koa/cors": "^3.1.0",
|
|
15
15
|
"@koa/router": "^9.4.0",
|
|
16
|
-
"@nocobase/acl": "0.7.
|
|
17
|
-
"@nocobase/actions": "0.7.
|
|
18
|
-
"@nocobase/database": "0.7.
|
|
19
|
-
"@nocobase/resourcer": "0.7.
|
|
16
|
+
"@nocobase/acl": "0.7.4-alpha.7",
|
|
17
|
+
"@nocobase/actions": "0.7.4-alpha.7",
|
|
18
|
+
"@nocobase/database": "0.7.4-alpha.7",
|
|
19
|
+
"@nocobase/resourcer": "0.7.4-alpha.7",
|
|
20
20
|
"chalk": "^4.1.1",
|
|
21
21
|
"commander": "^9.2.0",
|
|
22
22
|
"find-package-json": "^1.2.0",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/semver": "^7.3.9"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "77f22e6da464d19be111835316faf4b94cd80413"
|
|
34
34
|
}
|