@nocobase/server 0.7.6-alpha.2 → 0.8.0-alpha.4

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,19 +1,18 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="koa-bodyparser" />
3
3
  import { ACL } from '@nocobase/acl';
4
+ import { Cache, ICacheConfig } from '@nocobase/cache';
4
5
  import Database, { Collection, CollectionOptions, IDatabaseOptions } from '@nocobase/database';
5
6
  import Resourcer, { ResourceOptions } from '@nocobase/resourcer';
6
- import { AsyncEmitter } from '@nocobase/utils';
7
+ import { AsyncEmitter, ToposortOptions } from '@nocobase/utils';
7
8
  import { Command, CommandOptions, ParseOptions } from 'commander';
8
9
  import { Server } from 'http';
9
10
  import { i18n, InitOptions } from 'i18next';
10
- import Koa from 'koa';
11
+ import Koa, { DefaultContext as KoaDefaultContext, DefaultState as KoaDefaultState } from 'koa';
11
12
  import { AppManager } from './app-manager';
12
13
  import { Plugin } from './plugin';
13
14
  import { InstallOptions, PluginManager } from './plugin-manager';
14
- import { ICacheConfig, Cache } from '@nocobase/cache';
15
15
  export declare type PluginConfiguration = string | [string, any];
16
- export declare type PluginsConfigurations = Array<PluginConfiguration>;
17
16
  export interface ResourcerOptions {
18
17
  prefix?: string;
19
18
  }
@@ -26,25 +25,21 @@ export interface ApplicationOptions {
26
25
  dataWrapping?: boolean;
27
26
  registerActions?: boolean;
28
27
  i18n?: i18n | InitOptions;
29
- plugins?: PluginsConfigurations;
28
+ plugins?: PluginConfiguration[];
29
+ acl?: boolean;
30
+ pmSock?: string;
30
31
  }
31
- export interface DefaultState {
32
+ export interface DefaultState extends KoaDefaultState {
32
33
  currentUser?: any;
33
34
  [key: string]: any;
34
35
  }
35
- export interface DefaultContext {
36
+ export interface DefaultContext extends KoaDefaultContext {
36
37
  db: Database;
37
38
  cache: Cache;
38
39
  resourcer: Resourcer;
40
+ i18n: any;
39
41
  [key: string]: any;
40
42
  }
41
- interface MiddlewareOptions {
42
- name?: string;
43
- resourceName?: string;
44
- resourceNames?: string[];
45
- insertBefore?: string;
46
- insertAfter?: string;
47
- }
48
43
  interface ActionsOptions {
49
44
  resourceName?: string;
50
45
  resourceNames?: string[];
@@ -77,32 +72,44 @@ export declare class ApplicationVersion {
77
72
  }
78
73
  export declare class Application<StateT = DefaultState, ContextT = DefaultContext> extends Koa implements AsyncEmitter {
79
74
  options: ApplicationOptions;
80
- readonly db: Database;
81
- readonly cache: Cache;
82
- readonly resourcer: Resourcer;
83
- readonly cli: Command;
84
- readonly i18n: i18n;
85
- readonly pm: PluginManager;
86
- readonly acl: ACL;
87
- readonly appManager: AppManager;
88
- readonly version: ApplicationVersion;
75
+ protected _db: Database;
76
+ protected _resourcer: Resourcer;
77
+ protected _cache: Cache;
78
+ protected _cli: Command;
79
+ protected _i18n: i18n;
80
+ protected _pm: PluginManager;
81
+ protected _acl: ACL;
82
+ protected _appManager: AppManager;
83
+ protected _version: ApplicationVersion;
89
84
  protected plugins: Map<string, Plugin<any>>;
90
85
  listenServer: Server;
86
+ middleware: any;
91
87
  constructor(options: ApplicationOptions);
88
+ get db(): Database;
89
+ get cache(): Cache;
90
+ get resourcer(): Resourcer;
91
+ get cli(): Command;
92
+ get acl(): ACL;
93
+ get i18n(): i18n;
94
+ get pm(): PluginManager;
95
+ get version(): ApplicationVersion;
96
+ get appManager(): AppManager;
97
+ protected init(): void;
92
98
  private createDatabase;
93
99
  getVersion(): any;
94
- plugin<O = any>(pluginClass: any, options?: O): Plugin<O>;
95
- loadPluginConfig(pluginsConfigurations: PluginsConfigurations): void;
96
- use<NewStateT = {}, NewContextT = {}>(middleware: Koa.Middleware<StateT & NewStateT, ContextT & NewContextT>, options?: MiddlewareOptions): Koa<Koa.DefaultState & StateT & NewStateT, Koa.DefaultContext & ContextT & NewContextT>;
100
+ plugin<O = any>(pluginClass: any, options?: O): Plugin;
101
+ use<NewStateT = {}, NewContextT = {}>(middleware: Koa.Middleware<StateT & NewStateT, ContextT & NewContextT>, options?: ToposortOptions): this;
102
+ callback(): (req: any, res: any) => any;
97
103
  collection(options: CollectionOptions): Collection<any, any>;
98
104
  resource(options: ResourceOptions): import("@nocobase/resourcer").Resource;
99
105
  actions(handlers: any, options?: ActionsOptions): void;
100
106
  command(name: string, desc?: string, opts?: CommandOptions): Command;
101
107
  findCommand(name: string): Command;
102
- load(): Promise<void>;
108
+ load(options?: any): Promise<void>;
109
+ reload(options?: any): Promise<void>;
103
110
  getPlugin<P extends Plugin>(name: string): P;
104
111
  parse(argv?: string[]): Promise<Command>;
105
- runAsCLI(argv?: readonly string[], options?: ParseOptions): Promise<Command>;
112
+ runAsCLI(argv?: string[], options?: ParseOptions): Promise<Command>;
106
113
  start(options?: StartOptions): Promise<void>;
107
114
  listen(...args: any[]): Server;
108
115
  stop(options?: any): Promise<void>;
@@ -15,6 +15,16 @@ function _actions() {
15
15
  return data;
16
16
  }
17
17
 
18
+ function _cache() {
19
+ const data = require("@nocobase/cache");
20
+
21
+ _cache = function _cache() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
18
28
  function _database() {
19
29
  const data = _interopRequireDefault(require("@nocobase/database"));
20
30
 
@@ -55,6 +65,16 @@ function _koa() {
55
65
  return data;
56
66
  }
57
67
 
68
+ function _koaCompose() {
69
+ const data = _interopRequireDefault(require("koa-compose"));
70
+
71
+ _koaCompose = function _koaCompose() {
72
+ return data;
73
+ };
74
+
75
+ return data;
76
+ }
77
+
58
78
  function _lodash() {
59
79
  const data = require("lodash");
60
80
 
@@ -75,6 +95,16 @@ function _semver() {
75
95
  return data;
76
96
  }
77
97
 
98
+ function _util() {
99
+ const data = require("util");
100
+
101
+ _util = function _util() {
102
+ return data;
103
+ };
104
+
105
+ return data;
106
+ }
107
+
78
108
  var _acl = require("./acl");
79
109
 
80
110
  var _appManager = require("./app-manager");
@@ -85,24 +115,8 @@ var _helper = require("./helper");
85
115
 
86
116
  var _pluginManager = require("./plugin-manager");
87
117
 
88
- function _cache() {
89
- const data = require("@nocobase/cache");
90
-
91
- _cache = function _cache() {
92
- return data;
93
- };
94
-
95
- return data;
96
- }
97
-
98
118
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
99
119
 
100
- 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; } } }; }
101
-
102
- 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); }
103
-
104
- 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; }
105
-
106
120
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
107
121
 
108
122
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -191,51 +205,118 @@ class Application extends _koa().default {
191
205
  constructor(options) {
192
206
  super();
193
207
  this.options = void 0;
194
- this.db = void 0;
195
- this.cache = void 0;
196
- this.resourcer = void 0;
197
- this.cli = void 0;
198
- this.i18n = void 0;
199
- this.pm = void 0;
200
- this.acl = void 0;
201
- this.appManager = void 0;
202
- this.version = void 0;
208
+ this._db = void 0;
209
+ this._resourcer = void 0;
210
+ this._cache = void 0;
211
+ this._cli = void 0;
212
+ this._i18n = void 0;
213
+ this._pm = void 0;
214
+ this._acl = void 0;
215
+ this._appManager = void 0;
216
+ this._version = void 0;
203
217
  this.plugins = new Map();
204
218
  this.listenServer = void 0;
205
219
  this.options = options;
206
- this.acl = (0, _acl.createACL)();
207
- this.db = this.createDatabase(options);
208
- this.cache = (0, _cache().createCache)(options.cache);
209
- this.resourcer = (0, _helper.createResourcer)(options);
210
- this.cli = new (_commander().Command)('nocobase').usage('[command] [options]');
211
- this.i18n = (0, _helper.createI18n)(options);
212
- this.pm = new _pluginManager.PluginManager({
213
- app: this
214
- });
215
- this.appManager = new _appManager.AppManager(this);
220
+ this.init();
221
+ }
222
+
223
+ get db() {
224
+ return this._db;
225
+ }
226
+
227
+ get cache() {
228
+ return this._cache;
229
+ }
230
+
231
+ get resourcer() {
232
+ return this._resourcer;
233
+ }
234
+
235
+ get cli() {
236
+ return this._cli;
237
+ }
238
+
239
+ get acl() {
240
+ return this._acl;
241
+ }
242
+
243
+ get i18n() {
244
+ return this._i18n;
245
+ }
246
+
247
+ get pm() {
248
+ return this._pm;
249
+ }
250
+
251
+ get version() {
252
+ return this._version;
253
+ }
254
+
255
+ get appManager() {
256
+ return this._appManager;
257
+ }
258
+
259
+ init() {
260
+ const options = this.options; // @ts-ignore
261
+
262
+ this._events = []; // @ts-ignore
263
+
264
+ this._eventsCount = [];
265
+ this.removeAllListeners();
266
+ this.middleware = new (_utils().Toposort)();
267
+ this.plugins = new Map();
268
+ this._acl = (0, _acl.createACL)();
269
+
270
+ if (this._db) {
271
+ // MaxListenersExceededWarning
272
+ this._db.removeAllListeners();
273
+ }
274
+
275
+ this._db = this.createDatabase(options);
276
+ this._resourcer = (0, _helper.createResourcer)(options);
277
+ this._cli = new (_commander().Command)('nocobase').usage('[command] [options]');
278
+ this._i18n = (0, _helper.createI18n)(options);
279
+ this._cache = (0, _cache().createCache)(options.cache);
280
+ this.context.db = this._db;
281
+ this.context.resourcer = this._resourcer;
282
+ this.context.cache = this._cache;
283
+
284
+ if (this._pm) {
285
+ this._pm = this._pm.clone();
286
+ } else {
287
+ this._pm = new _pluginManager.PluginManager({
288
+ app: this,
289
+ plugins: options.plugins
290
+ });
291
+ }
292
+
293
+ this._appManager = new _appManager.AppManager(this);
294
+
295
+ if (this.options.acl !== false) {
296
+ this._resourcer.use(this._acl.middleware(), {
297
+ tag: 'acl',
298
+ after: ['parseToken']
299
+ });
300
+ }
301
+
216
302
  (0, _helper.registerMiddlewares)(this, options);
217
303
 
218
304
  if (options.registerActions !== false) {
219
305
  (0, _actions().registerActions)(this);
220
306
  }
221
307
 
222
- this.loadPluginConfig(options.plugins || []);
223
308
  (0, _commands.registerCli)(this);
224
- this.version = new ApplicationVersion(this);
309
+ this._version = new ApplicationVersion(this);
225
310
  }
226
311
 
227
312
  createDatabase(options) {
228
- if (options.database instanceof _database().default) {
229
- return options.database;
230
- } else {
231
- return new (_database().default)(_objectSpread(_objectSpread({}, options.database), {}, {
232
- migrator: {
233
- context: {
234
- app: this
235
- }
313
+ return new (_database().default)(_objectSpread(_objectSpread({}, options.database instanceof _database().default ? options.database.options : options.database), {}, {
314
+ migrator: {
315
+ context: {
316
+ app: this
236
317
  }
237
- }));
238
- }
318
+ }
319
+ }));
239
320
  }
240
321
 
241
322
  getVersion() {
@@ -243,36 +324,26 @@ class Application extends _koa().default {
243
324
  }
244
325
 
245
326
  plugin(pluginClass, options) {
246
- return this.pm.add(pluginClass, options);
247
- }
327
+ return this.pm.addStatic(pluginClass, options);
328
+ } // @ts-ignore
248
329
 
249
- loadPluginConfig(pluginsConfigurations) {
250
- var _iterator = _createForOfIteratorHelper(pluginsConfigurations),
251
- _step;
252
330
 
253
- try {
254
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
255
- let pluginConfiguration = _step.value;
331
+ use(middleware, options) {
332
+ this.middleware.add(middleware, options);
333
+ return this;
334
+ }
256
335
 
257
- if (typeof pluginConfiguration == 'string') {
258
- pluginConfiguration = [pluginConfiguration, {}];
259
- }
336
+ callback() {
337
+ const fn = (0, _koaCompose().default)(this.middleware.nodes);
338
+ if (!this.listenerCount('error')) this.on('error', this.onerror);
260
339
 
261
- const plugin = _pluginManager.PluginManager.resolvePlugin(pluginConfiguration[0]);
340
+ const handleRequest = (req, res) => {
341
+ const ctx = this.createContext(req, res); // @ts-ignore
262
342
 
263
- const pluginOptions = pluginConfiguration[1];
264
- this.plugin(plugin, pluginOptions);
265
- }
266
- } catch (err) {
267
- _iterator.e(err);
268
- } finally {
269
- _iterator.f();
270
- }
271
- }
343
+ return this.handleRequest(ctx, fn);
344
+ };
272
345
 
273
- use(middleware, options) {
274
- // @ts-ignore
275
- return super.use(middleware);
346
+ return handleRequest;
276
347
  }
277
348
 
278
349
  collection(options) {
@@ -295,11 +366,31 @@ class Application extends _koa().default {
295
366
  return this.cli._findCommand(name);
296
367
  }
297
368
 
298
- load() {
369
+ load(options) {
299
370
  var _this4 = this;
300
371
 
301
372
  return _asyncToGenerator(function* () {
302
- yield _this4.pm.load();
373
+ if (options === null || options === void 0 ? void 0 : options.reload) {
374
+ const oldDb = _this4._db;
375
+
376
+ _this4.init();
377
+
378
+ yield oldDb.close();
379
+ }
380
+
381
+ yield _this4.emitAsync('beforeLoad', _this4, options);
382
+ yield _this4.pm.load(options);
383
+ yield _this4.emitAsync('afterLoad', _this4, options);
384
+ })();
385
+ }
386
+
387
+ reload(options) {
388
+ var _this5 = this;
389
+
390
+ return _asyncToGenerator(function* () {
391
+ yield _this5.load(_objectSpread(_objectSpread({}, options), {}, {
392
+ reload: true
393
+ }));
303
394
  })();
304
395
  }
305
396
 
@@ -308,56 +399,63 @@ class Application extends _koa().default {
308
399
  }
309
400
 
310
401
  parse(argv = process.argv) {
311
- var _this5 = this;
402
+ var _this6 = this;
312
403
 
313
404
  return _asyncToGenerator(function* () {
314
- return _this5.runAsCLI(argv);
405
+ return _this6.runAsCLI(argv);
315
406
  })();
316
407
  }
317
408
 
318
- runAsCLI(argv, options) {
319
- var _this6 = this;
409
+ runAsCLI(argv = process.argv, options) {
410
+ var _this7 = this;
320
411
 
321
412
  return _asyncToGenerator(function* () {
322
- yield _this6.load();
323
- return _this6.cli.parseAsync(argv, options);
413
+ yield _this7.load({
414
+ method: argv === null || argv === void 0 ? void 0 : argv[2]
415
+ });
416
+ return _this7.cli.parseAsync(argv, options);
324
417
  })();
325
418
  }
326
419
 
327
420
  start(options = {}) {
328
- var _this7 = this;
421
+ var _this8 = this;
329
422
 
330
423
  return _asyncToGenerator(function* () {
331
424
  var _options$listen;
332
425
 
333
426
  // reconnect database
334
- if (_this7.db.closed()) {
335
- yield _this7.db.reconnect();
427
+ if (_this8.db.closed()) {
428
+ yield _this8.db.reconnect();
336
429
  }
337
430
 
338
- yield _this7.emitAsync('beforeStart', _this7, options);
431
+ yield _this8.emitAsync('beforeStart', _this8, options);
339
432
 
340
433
  if (options === null || options === void 0 ? void 0 : (_options$listen = options.listen) === null || _options$listen === void 0 ? void 0 : _options$listen.port) {
434
+ const pmServer = yield _this8.pm.listen();
435
+
341
436
  const listen = () => new Promise((resolve, reject) => {
342
- const Server = _this7.listen(options === null || options === void 0 ? void 0 : options.listen, () => {
437
+ const Server = _this8.listen(options === null || options === void 0 ? void 0 : options.listen, () => {
343
438
  resolve(Server);
344
439
  });
345
440
 
346
441
  Server.on('error', err => {
347
442
  reject(err);
348
443
  });
444
+ Server.on('close', () => {
445
+ pmServer.close();
446
+ });
349
447
  });
350
448
 
351
449
  try {
352
450
  //@ts-ignore
353
- _this7.listenServer = yield listen();
451
+ _this8.listenServer = yield listen();
354
452
  } catch (e) {
355
453
  console.error(e);
356
454
  process.exit(1);
357
455
  }
358
456
  }
359
457
 
360
- yield _this7.emitAsync('afterStart', _this7, options);
458
+ yield _this8.emitAsync('afterStart', _this8, options);
361
459
  })();
362
460
  }
363
461
 
@@ -366,55 +464,46 @@ class Application extends _koa().default {
366
464
  }
367
465
 
368
466
  stop(options = {}) {
369
- var _this8 = this;
467
+ var _this9 = this;
370
468
 
371
469
  return _asyncToGenerator(function* () {
372
- yield _this8.emitAsync('beforeStop', _this8, options);
470
+ yield _this9.emitAsync('beforeStop', _this9, options);
373
471
 
374
472
  try {
375
473
  // close database connection
376
474
  // silent if database already closed
377
- yield _this8.db.close();
475
+ if (!_this9.db.closed()) {
476
+ yield _this9.db.close();
477
+ }
378
478
  } catch (e) {
379
479
  console.log(e);
380
480
  } // close http server
381
481
 
382
482
 
383
- if (_this8.listenServer) {
384
- const closeServer = () => new Promise((resolve, reject) => {
385
- _this8.listenServer.close(err => {
386
- if (err) {
387
- return reject(err);
388
- }
389
-
390
- _this8.listenServer = null;
391
- resolve(true);
392
- });
393
- });
394
-
395
- yield closeServer();
483
+ if (_this9.listenServer) {
484
+ yield (0, _util().promisify)(_this9.listenServer.close).call(_this9.listenServer);
485
+ _this9.listenServer = null;
396
486
  }
397
487
 
398
- yield _this8.emitAsync('afterStop', _this8, options);
488
+ yield _this9.emitAsync('afterStop', _this9, options);
399
489
  })();
400
490
  }
401
491
 
402
492
  destroy(options = {}) {
403
- var _this9 = this;
493
+ var _this10 = this;
404
494
 
405
495
  return _asyncToGenerator(function* () {
406
- yield _this9.emitAsync('beforeDestroy', _this9, options);
407
- yield _this9.stop(options);
408
- yield _this9.emitAsync('afterDestroy', _this9, options);
496
+ yield _this10.emitAsync('beforeDestroy', _this10, options);
497
+ yield _this10.stop(options);
498
+ yield _this10.emitAsync('afterDestroy', _this10, options);
409
499
  })();
410
500
  }
411
501
 
412
502
  install(options = {}) {
413
- var _this10 = this;
503
+ var _this11 = this;
414
504
 
415
505
  return _asyncToGenerator(function* () {
416
- yield _this10.emitAsync('beforeInstall', _this10, options);
417
- const r = yield _this10.db.version.satisfies({
506
+ const r = yield _this11.db.version.satisfies({
418
507
  mysql: '>=8.0.17',
419
508
  sqlite: '3.x',
420
509
  postgres: '>=10'
@@ -426,33 +515,37 @@ class Application extends _koa().default {
426
515
  }
427
516
 
428
517
  if (options === null || options === void 0 ? void 0 : options.clean) {
429
- yield _this10.db.clean((0, _lodash().isBoolean)(options.clean) ? {
518
+ yield _this11.db.clean((0, _lodash().isBoolean)(options.clean) ? {
430
519
  drop: options.clean
431
520
  } : options.clean);
521
+ yield _this11.reload({
522
+ method: 'install'
523
+ });
432
524
  }
433
525
 
434
- yield _this10.db.sync(options === null || options === void 0 ? void 0 : options.sync);
435
- yield _this10.pm.install(options);
436
- yield _this10.version.update();
437
- yield _this10.emitAsync('afterInstall', _this10, options);
526
+ yield _this11.emitAsync('beforeInstall', _this11, options);
527
+ yield _this11.db.sync(options === null || options === void 0 ? void 0 : options.sync);
528
+ yield _this11.pm.install(options);
529
+ yield _this11.version.update();
530
+ yield _this11.emitAsync('afterInstall', _this11, options);
438
531
  })();
439
532
  }
440
533
 
441
534
  upgrade(options = {}) {
442
- var _this11 = this;
535
+ var _this12 = this;
443
536
 
444
537
  return _asyncToGenerator(function* () {
445
- yield _this11.emitAsync('beforeUpgrade', _this11, options);
538
+ yield _this12.emitAsync('beforeUpgrade', _this12, options);
446
539
  const force = false;
447
- yield _this11.db.migrator.up();
448
- yield _this11.db.sync({
540
+ yield _this12.db.migrator.up();
541
+ yield _this12.db.sync({
449
542
  force,
450
543
  alter: {
451
544
  drop: force
452
545
  }
453
546
  });
454
- yield _this11.version.update();
455
- yield _this11.emitAsync('afterUpgrade', _this11, options);
547
+ yield _this12.version.update();
548
+ yield _this12.emitAsync('afterUpgrade', _this12, options);
456
549
  })();
457
550
  }
458
551
 
@@ -20,7 +20,9 @@ function registerCli(app) {
20
20
 
21
21
  require('./start').default(app);
22
22
 
23
- require('./upgrade').default(app); // development only with @nocobase/cli
23
+ require('./upgrade').default(app);
24
+
25
+ require('./pm').default(app); // development only with @nocobase/cli
24
26
 
25
27
 
26
28
  app.command('build').argument('[packages...]');
@@ -0,0 +1,3 @@
1
+ import Application from '../application';
2
+ declare const _default: (app: Application) => void;
3
+ export 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('pm').argument('<method>').arguments('<plugins...>').action( /*#__PURE__*/function () {
14
+ var _ref = _asyncToGenerator(function* (method, plugins, options, ...args) {
15
+ app.pm.clientWrite({
16
+ method,
17
+ plugins
18
+ });
19
+ });
20
+
21
+ return function (_x, _x2, _x3) {
22
+ return _ref.apply(this, arguments);
23
+ };
24
+ }());
25
+ };
26
+
27
+ exports.default = _default;