@nocobase/server 0.7.0-alpha.3 → 0.7.0-alpha.30

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,7 +1,7 @@
1
1
  /// <reference types="node" />
2
- import Application, { ApplicationOptions } from './application';
3
- import http, { IncomingMessage } from 'http';
4
2
  import EventEmitter from 'events';
3
+ import http, { IncomingMessage, ServerResponse } from 'http';
4
+ import Application, { ApplicationOptions } from './application';
5
5
  declare type AppSelector = (req: IncomingMessage) => Application | string | undefined | null;
6
6
  export declare class AppManager extends EventEmitter {
7
7
  private app;
@@ -13,7 +13,7 @@ export declare class AppManager extends EventEmitter {
13
13
  setAppSelector(selector: AppSelector): void;
14
14
  listen(...args: any[]): http.Server;
15
15
  getApplication(appName: string): Promise<null | Application>;
16
- callback(): (req: any, res: any) => Promise<void>;
16
+ callback(): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
17
17
  emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
18
18
  }
19
19
  export {};
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import Application from './application';
11
- import http from 'http';
12
- import EventEmitter from 'events';
13
10
  import { applyMixins, AsyncEmitter } from '@nocobase/utils';
11
+ import EventEmitter from 'events';
12
+ import http from 'http';
13
+ import Application from './application';
14
14
  export class AppManager extends EventEmitter {
15
15
  constructor(app) {
16
16
  super();
@@ -59,7 +59,18 @@ export class AppManager extends EventEmitter {
59
59
  return (req, res) => __awaiter(this, void 0, void 0, function* () {
60
60
  let handleApp = this.appSelector(req) || this.app;
61
61
  if (typeof handleApp === 'string') {
62
- handleApp = (yield this.getApplication(handleApp)) || this.app;
62
+ handleApp = yield this.getApplication(handleApp);
63
+ if (!handleApp) {
64
+ res.statusCode = 404;
65
+ return res.end(JSON.stringify({
66
+ redirectTo: process.env.APP_NOT_FOUND_REDIRECT_TO,
67
+ errors: [
68
+ {
69
+ message: 'Not Found',
70
+ },
71
+ ],
72
+ }));
73
+ }
63
74
  }
64
75
  handleApp.callback()(req, res);
65
76
  });
@@ -1 +1 @@
1
- {"version":3,"file":"app-manager.js","sourceRoot":"","sources":["../src/app-manager.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,WAAmC,MAAM,eAAe,CAAC;AAChE,OAAO,IAAyB,MAAM,MAAM,CAAC;AAC7C,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI5D,MAAM,OAAO,UAAW,SAAQ,YAAY;IAG1C,YAAoB,GAAgB;QAClC,KAAK,EAAE,CAAC;QADU,QAAG,GAAH,GAAG,CAAa;QAF7B,iBAAY,GAA6B,IAAI,GAAG,EAAuB,CAAC;QAkB/E,gBAAW,GAAgB,CAAC,GAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;QAb5D,GAAG,CAAC,EAAE,CAAC,YAAY,EAAE,CAAO,OAAO,EAAE,OAAO,EAAE,EAAE;YAC9C,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAC7F,CAAC;QACJ,CAAC,CAAA,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,cAAc,EAAE,CAAO,OAAO,EAAE,OAAO,EAAE,EAAE;YAChD,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAChG,CAAC;QACJ,CA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M,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC;aAChE;YAED,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjC,CAAC,CAAA,CAAC;IACJ,CAAC;CAGF;AAED,WAAW,CAAC,UAAU,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC","sourcesContent":["import Application, { ApplicationOptions } from './application';\nimport http, { IncomingMessage } from 'http';\nimport EventEmitter from 'events';\nimport { applyMixins, AsyncEmitter } from '@nocobase/utils';\n\ntype AppSelector = (req: IncomingMessage) => Application | string | undefined | null;\n\nexport class AppManager extends EventEmitter {\n public applications: Map<string, Application> = new Map<string, Application>();\n\n constructor(private app: Application) {\n super();\n\n app.on('beforeStop', async (mainApp, options) => {\n return await Promise.all(\n [...this.applications.values()].map((application: Application) => application.stop(options)),\n );\n });\n\n app.on('afterDestroy', async (mainApp, options) => {\n return await Promise.all(\n [...this.applications.values()].map((application: Application) => application.destroy(options)),\n );\n });\n }\n\n appSelector: AppSelector = (req: IncomingMessage) => this.app;\n\n createApplication(name: string, options: ApplicationOptions): Application {\n const application = new Application(options);\n this.applications.set(name, application);\n return application;\n }\n\n async removeApplication(name: string) {\n const application = this.applications.get(name);\n if (!application) {\n return;\n }\n\n await application.destroy();\n\n this.applications.delete(name);\n }\n\n setAppSelector(selector: AppSelector) {\n this.appSelector = selector;\n }\n\n listen(...args) {\n const server = http.createServer(this.callback());\n return server.listen(...args);\n }\n\n async getApplication(appName: string): Promise<null | Application> {\n await this.emitAsync('beforeGetApplication', {\n appManager: this,\n name: appName,\n });\n\n return this.applications.get(appName);\n }\n\n callback() {\n return async (req, res) => {\n let handleApp = this.appSelector(req) || this.app;\n\n if (typeof handleApp === 'string') {\n handleApp = (await this.getApplication(handleApp)) || this.app;\n }\n\n handleApp.callback()(req, res);\n };\n }\n\n emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;\n}\n\napplyMixins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AC;oBACrB,OAAO,GAAG,CAAC,GAAG,CACZ,IAAI,CAAC,SAAS,CAAC;wBACb,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;wBACjD,MAAM,EAAE;4BACN;gCACE,OAAO,EAAE,WAAW;6BACrB;yBACF;qBACF,CAAC,CACH,CAAC;iBACH;aACF;YAED,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjC,CAAC,CAAA,CAAC;IACJ,CAAC;CAGF;AAED,WAAW,CAAC,UAAU,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC","sourcesContent":["import { applyMixins, AsyncEmitter } from '@nocobase/utils';\nimport EventEmitter from 'events';\nimport http, { IncomingMessage, ServerResponse } from 'http';\nimport Application, { ApplicationOptions } from './application';\n\ntype AppSelector = (req: IncomingMessage) => Application | string | undefined | null;\n\nexport class AppManager extends EventEmitter {\n public applications: Map<string, Application> = new Map<string, Application>();\n\n constructor(private app: Application) {\n super();\n\n app.on('beforeStop', async (mainApp, options) => {\n return await Promise.all(\n [...this.applications.values()].map((application: Application) => application.stop(options)),\n );\n });\n\n app.on('afterDestroy', async (mainApp, options) => {\n return await Promise.all(\n [...this.applications.values()].map((application: Application) => application.destroy(options)),\n );\n });\n }\n\n appSelector: AppSelector = (req: IncomingMessage) => this.app;\n\n createApplication(name: string, options: ApplicationOptions): Application {\n const application = new Application(options);\n this.applications.set(name, application);\n return application;\n }\n\n async removeApplication(name: string) {\n const application = this.applications.get(name);\n if (!application) {\n return;\n }\n\n await application.destroy();\n\n this.applications.delete(name);\n }\n\n setAppSelector(selector: AppSelector) {\n this.appSelector = selector;\n }\n\n listen(...args) {\n const server = http.createServer(this.callback());\n return server.listen(...args);\n }\n\n async getApplication(appName: string): Promise<null | Application> {\n await this.emitAsync('beforeGetApplication', {\n appManager: this,\n name: appName,\n });\n\n return this.applications.get(appName);\n }\n\n callback() {\n return async (req: IncomingMessage, res: ServerResponse) => {\n let handleApp: any = this.appSelector(req) || this.app;\n\n if (typeof handleApp === 'string') {\n handleApp = await this.getApplication(handleApp);\n if (!handleApp) {\n res.statusCode = 404;\n return res.end(\n JSON.stringify({\n redirectTo: process.env.APP_NOT_FOUND_REDIRECT_TO,\n errors: [\n {\n message: 'Not Found',\n },\n ],\n }),\n );\n }\n }\n\n handleApp.callback()(req, res);\n };\n }\n\n emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;\n}\n\napplyMixins(AppManager, [AsyncEmitter]);\n"]}
@@ -0,0 +1,5 @@
1
+ declare const _default: ({ app, cliArgs }: {
2
+ app: any;
3
+ cliArgs: any;
4
+ }) => Promise<void>;
5
+ export default _default;
@@ -0,0 +1,14 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export default ({ app, cliArgs }) => __awaiter(void 0, void 0, void 0, function* () {
11
+ const [opts] = cliArgs;
12
+ yield app.db.auth({ repeat: opts.repeat || 10 });
13
+ });
14
+ //# sourceMappingURL=db-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-auth.js","sourceRoot":"","sources":["../../src/commands/db-auth.ts"],"names":[],"mappings":";;;;;;;;;AAAA,eAAe,CAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACvB,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC,CAAA,CAAC","sourcesContent":["export default async ({ app, cliArgs }) => {\n const [opts] = cliArgs;\n await app.db.auth({ repeat: opts.repeat || 10 });\n};\n"]}
@@ -1,3 +1,3 @@
1
- import Application from '../application';
2
1
  import { Command } from 'commander';
2
+ import Application from '../application';
3
3
  export declare function createCli(app: Application): Command;
@@ -12,9 +12,10 @@ export function createCli(app) {
12
12
  process.exit(1);
13
13
  });
14
14
  };
15
- program.command('start').description('start NocoBase application').action(runSubCommand('start'));
16
- program.command('install').option('-f, --force').option('-c, --clean').action(runSubCommand('install'));
15
+ program.command('start').description('start NocoBase application').option('-s, --silent').action(runSubCommand('start'));
16
+ program.command('install').option('-f, --force').option('-c, --clean').option('-s, --silent').action(runSubCommand('install'));
17
17
  program.command('db:sync').option('-f, --force').action(runSubCommand('db-sync'));
18
+ program.command('db:auth').option('-r, --repeat [repeat]').action(runSubCommand('db-auth'));
18
19
  program.command('console').action(runSubCommand('console'));
19
20
  program
20
21
  .command('create-plugin')
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,UAAU,SAAS,CAAC,GAAgB;IACxC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,MAAM,aAAa,GACjB,CAAC,IAAI,EAAE,EAAE,CACT,CAAC,GAAG,OAAO,EAAE,EAAE;QACb,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC;QAE7C,OAAO,CAAC,OAAO,EAAE;aACd,IAAI,CAAC,GAAG,EAAE;YACT,OAAO,OAAO,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;QACnC,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IAEJ,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAClG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACxG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAE5D,OAAO;SACJ,OAAO,CAAC,eAAe,CAAC;SACxB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SACpC,WAAW,CAAC,wBAAwB,CAAC;SACrC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;IAE1C,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import Application from '../application';\nimport { Command } from 'commander';\n\nexport function createCli(app: Application) {\n const program = new Command();\n\n const runSubCommand =\n (name) =>\n (...cliArgs) => {\n const command = require(`./${name}`).default;\n\n Promise.resolve()\n .then(() => {\n return command({ app, cliArgs });\n })\n .catch((error) => {\n console.error(error);\n process.exit(1);\n });\n };\n\n program.command('start').description('start NocoBase application').action(runSubCommand('start'));\n program.command('install').option('-f, --force').option('-c, --clean').action(runSubCommand('install'));\n program.command('db:sync').option('-f, --force').action(runSubCommand('db-sync'));\n program.command('console').action(runSubCommand('console'));\n\n program\n .command('create-plugin')\n .argument('<name>', 'name of plugin')\n .description('create NocoBase plugin')\n .action(runSubCommand('create-plugin'));\n\n return program;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,UAAU,SAAS,CAAC,GAAgB;IACxC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,MAAM,aAAa,GACjB,CAAC,IAAI,EAAE,EAAE,CACT,CAAC,GAAG,OAAO,EAAE,EAAE;QACb,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC;QAE7C,OAAO,CAAC,OAAO,EAAE;aACd,IAAI,CAAC,GAAG,EAAE;YACT,OAAO,OAAO,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;QACnC,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IAEJ,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IACzH,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/H,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAC5F,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAE5D,OAAO;SACJ,OAAO,CAAC,eAAe,CAAC;SACxB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SACpC,WAAW,CAAC,wBAAwB,CAAC;SACrC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;IAE1C,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { Command } from 'commander';\nimport Application from '../application';\n\nexport function createCli(app: Application) {\n const program = new Command();\n\n const runSubCommand =\n (name) =>\n (...cliArgs) => {\n const command = require(`./${name}`).default;\n\n Promise.resolve()\n .then(() => {\n return command({ app, cliArgs });\n })\n .catch((error) => {\n console.error(error);\n process.exit(1);\n });\n };\n\n program.command('start').description('start NocoBase application').option('-s, --silent').action(runSubCommand('start'));\n program.command('install').option('-f, --force').option('-c, --clean').option('-s, --silent').action(runSubCommand('install'));\n program.command('db:sync').option('-f, --force').action(runSubCommand('db-sync'));\n program.command('db:auth').option('-r, --repeat [repeat]').action(runSubCommand('db-auth'));\n program.command('console').action(runSubCommand('console'));\n\n program\n .command('create-plugin')\n .argument('<name>', 'name of plugin')\n .description('create NocoBase plugin')\n .action(runSubCommand('create-plugin'));\n\n return program;\n}\n"]}
@@ -7,8 +7,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import chalk from 'chalk';
10
11
  export default ({ app, cliArgs }) => __awaiter(void 0, void 0, void 0, function* () {
11
12
  const [opts] = cliArgs;
13
+ if (!(opts === null || opts === void 0 ? void 0 : opts.clean) && !(opts === null || opts === void 0 ? void 0 : opts.force)) {
14
+ const tables = yield app.db.sequelize.getQueryInterface().showAllTables();
15
+ if (tables.includes('collections')) {
16
+ if (!opts.silent) {
17
+ console.log();
18
+ console.log();
19
+ console.log(chalk.yellow('NocoBase is already installed. To reinstall, please execute:'));
20
+ console.log();
21
+ let command = 'yarn nocobase install -f';
22
+ console.log(chalk.yellow(command));
23
+ console.log();
24
+ console.log();
25
+ }
26
+ return;
27
+ }
28
+ }
29
+ if (!opts.silent) {
30
+ console.log(`NocoBase installing`);
31
+ }
12
32
  yield app.install({
13
33
  cliArgs,
14
34
  clean: opts.clean,
@@ -19,5 +39,8 @@ export default ({ app, cliArgs }) => __awaiter(void 0, void 0, void 0, function*
19
39
  yield app.stop({
20
40
  cliArgs,
21
41
  });
42
+ if (!opts.silent) {
43
+ console.log(`NocoBase installed`);
44
+ }
22
45
  });
23
46
  //# sourceMappingURL=install.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":";;;;;;;;;AAAA,eAAe,CAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACvB,MAAM,GAAG,CAAC,OAAO,CAAC;QAChB,OAAO;QACP,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE;YACJ,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB;KACF,CAAC,CAAC;IACH,MAAM,GAAG,CAAC,IAAI,CAAC;QACb,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAA,CAAC","sourcesContent":["export default async ({ app, cliArgs }) => {\n const [opts] = cliArgs;\n await app.install({\n cliArgs,\n clean: opts.clean,\n sync: {\n force: opts.force,\n },\n });\n await app.stop({\n cliArgs,\n });\n};\n"]}
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eA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,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;KACnC;AACH,CAAC,CAAA,CAAC","sourcesContent":["import chalk from 'chalk';\n\nexport default async ({ app, cliArgs }) => {\n const [opts] = cliArgs;\n\n if (!opts?.clean && !opts?.force) {\n const tables = await app.db.sequelize.getQueryInterface().showAllTables();\n if (tables.includes('collections')) {\n if (!opts.silent) {\n console.log();\n console.log();\n console.log(chalk.yellow('NocoBase is already installed. To reinstall, please execute:'));\n console.log();\n let command = 'yarn nocobase install -f';\n console.log(chalk.yellow(command));\n console.log();\n console.log();\n }\n return;\n }\n }\n\n if (!opts.silent) {\n console.log(`NocoBase installing`);\n }\n\n await app.install({\n cliArgs,\n clean: opts.clean,\n sync: {\n force: opts.force,\n },\n });\n\n await app.stop({\n cliArgs,\n });\n\n if (!opts.silent) {\n console.log(`NocoBase installed`);\n }\n};\n"]}
@@ -18,6 +18,8 @@ export default ({ app, cliArgs }) => __awaiter(void 0, void 0, void 0, function*
18
18
  host,
19
19
  },
20
20
  });
21
- console.log(`🚀 nocobase server had started at http://${host}:${port}`);
21
+ if (!opts.silent) {
22
+ console.log(`🚀 NocoBase server running at: http://${host === '0.0.0.0' ? 'localhost' : host}:${port}/`);
23
+ }
22
24
  });
23
25
  //# sourceMappingURL=start.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":";;;;;;;;;AAAA,eAAe,CAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC;IAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,SAAS,CAAC;IAE/D,MAAM,GAAG,CAAC,KAAK,CAAC;QACd,OAAO;QACP,MAAM,EAAE;YACN,IAAI;YACJ,IAAI;SACL;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,4CAA4C,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAA,CAAC","sourcesContent":["export default async ({ app, cliArgs }) => {\n const [opts] = cliArgs;\n const port = opts.port || process.env.SERVER_PORT || 3000;\n const host = opts.host || process.env.SERVER_HOST || '0.0.0.0';\n\n await app.start({\n cliArgs,\n listen: {\n port,\n host,\n },\n });\n\n console.log(`🚀 nocobase server had started at http://${host}:${port}`);\n};\n"]}
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":";;;;;;;;;AAAA,eAAe,CAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC;IAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,SAAS,CAAC;IAE/D,MAAM,GAAG,CAAC,KAAK,CAAC;QACd,OAAO;QACP,MAAM,EAAE;YACN,IAAI;YACJ,IAAI;SACL;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;QAChB,OAAO,CAAC,GAAG,CAAC,yCAAyC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC;KAC1G;AACH,CAAC,CAAA,CAAC","sourcesContent":["export default async ({ app, cliArgs }) => {\n const [opts] = cliArgs;\n const port = opts.port || process.env.SERVER_PORT || 3000;\n const host = opts.host || process.env.SERVER_HOST || '0.0.0.0';\n\n await app.start({\n cliArgs,\n listen: {\n port,\n host,\n },\n });\n\n if (!opts.silent) {\n console.log(`🚀 NocoBase server running at: http://${host === '0.0.0.0' ? 'localhost' : host}:${port}/`);\n }\n};\n"]}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
- import Application, { ApplicationOptions } from './application';
3
- import http, { IncomingMessage } from 'http';
4
2
  import EventEmitter from 'events';
3
+ import http, { IncomingMessage, ServerResponse } from 'http';
4
+ import Application, { ApplicationOptions } from './application';
5
5
  declare type AppSelector = (req: IncomingMessage) => Application | string | undefined | null;
6
6
  export declare class AppManager extends EventEmitter {
7
7
  private app;
@@ -13,7 +13,7 @@ export declare class AppManager extends EventEmitter {
13
13
  setAppSelector(selector: AppSelector): void;
14
14
  listen(...args: any[]): http.Server;
15
15
  getApplication(appName: string): Promise<null | Application>;
16
- callback(): (req: any, res: any) => Promise<void>;
16
+ callback(): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
17
17
  emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;
18
18
  }
19
19
  export {};
@@ -13,10 +13,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.AppManager = void 0;
16
- const application_1 = __importDefault(require("./application"));
17
- const http_1 = __importDefault(require("http"));
18
- const events_1 = __importDefault(require("events"));
19
16
  const utils_1 = require("@nocobase/utils");
17
+ const events_1 = __importDefault(require("events"));
18
+ const http_1 = __importDefault(require("http"));
19
+ const application_1 = __importDefault(require("./application"));
20
20
  class AppManager extends events_1.default {
21
21
  constructor(app) {
22
22
  super();
@@ -65,7 +65,18 @@ class AppManager extends events_1.default {
65
65
  return (req, res) => __awaiter(this, void 0, void 0, function* () {
66
66
  let handleApp = this.appSelector(req) || this.app;
67
67
  if (typeof handleApp === 'string') {
68
- handleApp = (yield this.getApplication(handleApp)) || this.app;
68
+ handleApp = yield this.getApplication(handleApp);
69
+ if (!handleApp) {
70
+ res.statusCode = 404;
71
+ return res.end(JSON.stringify({
72
+ redirectTo: process.env.APP_NOT_FOUND_REDIRECT_TO,
73
+ errors: [
74
+ {
75
+ message: 'Not Found',
76
+ },
77
+ ],
78
+ }));
79
+ }
69
80
  }
70
81
  handleApp.callback()(req, res);
71
82
  });
@@ -1 +1 @@
1
- {"version":3,"file":"app-manager.js","sourceRoot":"","sources":["../src/app-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gEAAgE;AAChE,gDAA6C;AAC7C,oDAAkC;AAClC,2CAA4D;AAI5D,MAAa,UAAW,SAAQ,gBAAY;IAG1C,YAAoB,GAAgB;QAClC,KAAK,EAAE,CAAC;QADU,QAAG,GAAH,GAAG,CAAa;QAF7B,iBAAY,GAA6B,IAAI,GAAG,EAAuB,CAAC;QAkB/E,gBAAW,GAAgB,CAAC,GAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;QAb5D,GAAG,CAAC,EAAE,CAAC,YAAY,EAAE,CAAO,OAAO,EAAE,OAAO,EAAE,EAAE;YAC9C,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAC7F,CAAC;QACJ,CAAC,CAAA,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,cAAc,EAAE,CAAO,OAAO,EAAE,OAAO,EAAE,EAAE;YAChD,OAAO,MAAM,OAAO,CAAC,GAAG,CACtB,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAChG,CAAC;QACJ,CAAC,CAAA,CAAC,CAAC;IACL,CAAC;IAID,iBAAiB,CAAC,IAAY,EAAE,OAA2B;QACzD,MAAM,WAAW,GAAG,I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C,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjC,CAAC,CAAA,CAAC;IACJ,CAAC;CAGF;AArED,gCAqEC;AAED,IAAA,mBAAW,EAAC,UAAU,EAAE,CAAC,oBAAY,CAAC,CAAC,CAAC","sourcesContent":["import Application, { ApplicationOptions } from './application';\nimport http, { IncomingMessage } from 'http';\nimport EventEmitter from 'events';\nimport { applyMixins, AsyncEmitter } from '@nocobase/utils';\n\ntype AppSelector = (req: IncomingMessage) => Application | string | undefined | null;\n\nexport class AppManager extends EventEmitter {\n public applications: Map<string, Application> = new Map<string, Application>();\n\n constructor(private app: Application) {\n super();\n\n app.on('beforeStop', async (mainApp, options) => {\n return await Promise.all(\n [...this.applications.values()].map((application: Application) => application.stop(options)),\n );\n });\n\n app.on('afterDestroy', async (mainApp, options) => {\n return await Promise.all(\n [...this.applications.values()].map((application: Application) => application.destroy(options)),\n );\n });\n }\n\n appSelector: AppSelector = (req: IncomingMessage) => this.app;\n\n createApplication(name: string, options: ApplicationOptions): Application {\n const application = new Application(options);\n this.applications.set(name, application);\n return application;\n }\n\n async removeApplication(name: string) {\n const application = this.applications.get(name);\n if (!application) {\n return;\n }\n\n await application.destroy();\n\n this.applications.delete(name);\n }\n\n setAppSelector(selector: AppSelector) {\n this.appSelector = selector;\n }\n\n listen(...args) {\n const server = http.createServer(this.callback());\n return server.listen(...args);\n }\n\n async getApplication(appName: string): Promise<null | Application> {\n await this.emitAsync('beforeGetApplication', {\n appManager: this,\n name: appName,\n });\n\n return this.applications.get(appName);\n }\n\n callback() {\n return async (req, res) => {\n let handleApp = this.appSelector(req) || this.app;\n\n if (typeof handleApp === 'string') {\n handleApp = (await this.getApplication(handleApp)) || this.app;\n }\n\n handleApp.callback()(req, res);\n };\n }\n\n emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;\n}\n\napplyMixins(AppManager, [AsyncEmitter]);\n"]}
1
+ {"version":3,"file":"app-manager.js","sourceRoot":"","sources":["../src/app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AC,CACH,CAAC;iBACH;aACF;YAED,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACjC,CAAC,CAAA,CAAC;IACJ,CAAC;CAGF;AAlFD,gCAkFC;AAED,IAAA,mBAAW,EAAC,UAAU,EAAE,CAAC,oBAAY,CAAC,CAAC,CAAC","sourcesContent":["import { applyMixins, AsyncEmitter } from '@nocobase/utils';\nimport EventEmitter from 'events';\nimport http, { IncomingMessage, ServerResponse } from 'http';\nimport Application, { ApplicationOptions } from './application';\n\ntype AppSelector = (req: IncomingMessage) => Application | string | undefined | null;\n\nexport class AppManager extends EventEmitter {\n public applications: Map<string, Application> = new Map<string, Application>();\n\n constructor(private app: Application) {\n super();\n\n app.on('beforeStop', async (mainApp, options) => {\n return await Promise.all(\n [...this.applications.values()].map((application: Application) => application.stop(options)),\n );\n });\n\n app.on('afterDestroy', async (mainApp, options) => {\n return await Promise.all(\n [...this.applications.values()].map((application: Application) => application.destroy(options)),\n );\n });\n }\n\n appSelector: AppSelector = (req: IncomingMessage) => this.app;\n\n createApplication(name: string, options: ApplicationOptions): Application {\n const application = new Application(options);\n this.applications.set(name, application);\n return application;\n }\n\n async removeApplication(name: string) {\n const application = this.applications.get(name);\n if (!application) {\n return;\n }\n\n await application.destroy();\n\n this.applications.delete(name);\n }\n\n setAppSelector(selector: AppSelector) {\n this.appSelector = selector;\n }\n\n listen(...args) {\n const server = http.createServer(this.callback());\n return server.listen(...args);\n }\n\n async getApplication(appName: string): Promise<null | Application> {\n await this.emitAsync('beforeGetApplication', {\n appManager: this,\n name: appName,\n });\n\n return this.applications.get(appName);\n }\n\n callback() {\n return async (req: IncomingMessage, res: ServerResponse) => {\n let handleApp: any = this.appSelector(req) || this.app;\n\n if (typeof handleApp === 'string') {\n handleApp = await this.getApplication(handleApp);\n if (!handleApp) {\n res.statusCode = 404;\n return res.end(\n JSON.stringify({\n redirectTo: process.env.APP_NOT_FOUND_REDIRECT_TO,\n errors: [\n {\n message: 'Not Found',\n },\n ],\n }),\n );\n }\n }\n\n handleApp.callback()(req, res);\n };\n }\n\n emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;\n}\n\napplyMixins(AppManager, [AsyncEmitter]);\n"]}
@@ -0,0 +1,5 @@
1
+ declare const _default: ({ app, cliArgs }: {
2
+ app: any;
3
+ cliArgs: any;
4
+ }) => Promise<void>;
5
+ export default _default;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.default = ({ app, cliArgs }) => __awaiter(void 0, void 0, void 0, function* () {
13
+ const [opts] = cliArgs;
14
+ yield app.db.auth({ repeat: opts.repeat || 10 });
15
+ });
16
+ //# sourceMappingURL=db-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db-auth.js","sourceRoot":"","sources":["../../src/commands/db-auth.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kBAAe,CAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACvB,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC,CAAA,CAAC","sourcesContent":["export default async ({ app, cliArgs }) => {\n const [opts] = cliArgs;\n await app.db.auth({ repeat: opts.repeat || 10 });\n};\n"]}
@@ -1,3 +1,3 @@
1
- import Application from '../application';
2
1
  import { Command } from 'commander';
2
+ import Application from '../application';
3
3
  export declare function createCli(app: Application): Command;
@@ -15,9 +15,10 @@ function createCli(app) {
15
15
  process.exit(1);
16
16
  });
17
17
  };
18
- program.command('start').description('start NocoBase application').action(runSubCommand('start'));
19
- program.command('install').option('-f, --force').option('-c, --clean').action(runSubCommand('install'));
18
+ program.command('start').description('start NocoBase application').option('-s, --silent').action(runSubCommand('start'));
19
+ program.command('install').option('-f, --force').option('-c, --clean').option('-s, --silent').action(runSubCommand('install'));
20
20
  program.command('db:sync').option('-f, --force').action(runSubCommand('db-sync'));
21
+ program.command('db:auth').option('-r, --repeat [repeat]').action(runSubCommand('db-auth'));
21
22
  program.command('console').action(runSubCommand('console'));
22
23
  program
23
24
  .command('create-plugin')
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AAEpC,SAAgB,SAAS,CAAC,GAAgB;IACxC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;IAE9B,MAAM,aAAa,GACjB,CAAC,IAAI,EAAE,EAAE,CACT,CAAC,GAAG,OAAO,EAAE,EAAE;QACb,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC;QAE7C,OAAO,CAAC,OAAO,EAAE;aACd,IAAI,CAAC,GAAG,EAAE;YACT,OAAO,OAAO,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;QACnC,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IAEJ,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAClG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IACxG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAClF,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAE5D,OAAO;SACJ,OAAO,CAAC,eAAe,CAAC;SACxB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SACpC,WAAW,CAAC,wBAAwB,CAAC;SACrC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;IAE1C,OAAO,OAAO,CAAC;AACjB,CAAC;AA9BD,8BA8BC","sourcesContent":["import Application from '../application';\nimport { Command } from 'commander';\n\nexport function createCli(app: Application) {\n const program = new Command();\n\n const runSubCommand =\n (name) =>\n (...cliArgs) => {\n const command = require(`./${name}`).default;\n\n Promise.resolve()\n .then(() => {\n return command({ app, cliArgs });\n })\n .catch((error) => {\n console.error(error);\n process.exit(1);\n });\n };\n\n program.command('start').description('start NocoBase application').action(runSubCommand('start'));\n program.command('install').option('-f, --force').option('-c, --clean').action(runSubCommand('install'));\n program.command('db:sync').option('-f, --force').action(runSubCommand('db-sync'));\n program.command('console').action(runSubCommand('console'));\n\n program\n .command('create-plugin')\n .argument('<name>', 'name of plugin')\n .description('create NocoBase plugin')\n .action(runSubCommand('create-plugin'));\n\n return program;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AA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CAAC,SAAS,CAAC,CAAC,CAAC;IAE5D,OAAO;SACJ,OAAO,CAAC,eAAe,CAAC;SACxB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SACpC,WAAW,CAAC,wBAAwB,CAAC;SACrC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;IAE1C,OAAO,OAAO,CAAC;AACjB,CAAC;AA/BD,8BA+BC","sourcesContent":["import { Command } from 'commander';\nimport Application from '../application';\n\nexport function createCli(app: Application) {\n const program = new Command();\n\n const runSubCommand =\n (name) =>\n (...cliArgs) => {\n const command = require(`./${name}`).default;\n\n Promise.resolve()\n .then(() => {\n return command({ app, cliArgs });\n })\n .catch((error) => {\n console.error(error);\n process.exit(1);\n });\n };\n\n program.command('start').description('start NocoBase application').option('-s, --silent').action(runSubCommand('start'));\n program.command('install').option('-f, --force').option('-c, --clean').option('-s, --silent').action(runSubCommand('install'));\n program.command('db:sync').option('-f, --force').action(runSubCommand('db-sync'));\n program.command('db:auth').option('-r, --repeat [repeat]').action(runSubCommand('db-auth'));\n program.command('console').action(runSubCommand('console'));\n\n program\n .command('create-plugin')\n .argument('<name>', 'name of plugin')\n .description('create NocoBase plugin')\n .action(runSubCommand('create-plugin'));\n\n return program;\n}\n"]}
@@ -8,9 +8,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ const chalk_1 = __importDefault(require("chalk"));
12
16
  exports.default = ({ app, cliArgs }) => __awaiter(void 0, void 0, void 0, function* () {
13
17
  const [opts] = cliArgs;
18
+ if (!(opts === null || opts === void 0 ? void 0 : opts.clean) && !(opts === null || opts === void 0 ? void 0 : opts.force)) {
19
+ const tables = yield app.db.sequelize.getQueryInterface().showAllTables();
20
+ if (tables.includes('collections')) {
21
+ if (!opts.silent) {
22
+ console.log();
23
+ console.log();
24
+ console.log(chalk_1.default.yellow('NocoBase is already installed. To reinstall, please execute:'));
25
+ console.log();
26
+ let command = 'yarn nocobase install -f';
27
+ console.log(chalk_1.default.yellow(command));
28
+ console.log();
29
+ console.log();
30
+ }
31
+ return;
32
+ }
33
+ }
34
+ if (!opts.silent) {
35
+ console.log(`NocoBase installing`);
36
+ }
14
37
  yield app.install({
15
38
  cliArgs,
16
39
  clean: opts.clean,
@@ -21,5 +44,8 @@ exports.default = ({ app, cliArgs }) => __awaiter(void 0, void 0, void 0, functi
21
44
  yield app.stop({
22
45
  cliArgs,
23
46
  });
47
+ if (!opts.silent) {
48
+ console.log(`NocoBase installed`);
49
+ }
24
50
  });
25
51
  //# sourceMappingURL=install.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kBAAe,CAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACvB,MAAM,GAAG,CAAC,OAAO,CAAC;QAChB,OAAO;QACP,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE;YACJ,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB;KACF,CAAC,CAAC;IACH,MAAM,GAAG,CAAC,IAAI,CAAC;QACb,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAA,CAAC","sourcesContent":["export default async ({ app, cliArgs }) => {\n const [opts] = cliArgs;\n await app.install({\n cliArgs,\n clean: opts.clean,\n sync: {\n force: opts.force,\n },\n });\n await app.stop({\n cliArgs,\n });\n};\n"]}
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/commands/install.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,kBAAe,CAAO,EAAE,G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G,CAAC,oBAAoB,CAAC,CAAC;KACnC;AACH,CAAC,CAAA,CAAC","sourcesContent":["import chalk from 'chalk';\n\nexport default async ({ app, cliArgs }) => {\n const [opts] = cliArgs;\n\n if (!opts?.clean && !opts?.force) {\n const tables = await app.db.sequelize.getQueryInterface().showAllTables();\n if (tables.includes('collections')) {\n if (!opts.silent) {\n console.log();\n console.log();\n console.log(chalk.yellow('NocoBase is already installed. To reinstall, please execute:'));\n console.log();\n let command = 'yarn nocobase install -f';\n console.log(chalk.yellow(command));\n console.log();\n console.log();\n }\n return;\n }\n }\n\n if (!opts.silent) {\n console.log(`NocoBase installing`);\n }\n\n await app.install({\n cliArgs,\n clean: opts.clean,\n sync: {\n force: opts.force,\n },\n });\n\n await app.stop({\n cliArgs,\n });\n\n if (!opts.silent) {\n console.log(`NocoBase installed`);\n }\n};\n"]}
@@ -20,6 +20,8 @@ exports.default = ({ app, cliArgs }) => __awaiter(void 0, void 0, void 0, functi
20
20
  host,
21
21
  },
22
22
  });
23
- console.log(`🚀 nocobase server had started at http://${host}:${port}`);
23
+ if (!opts.silent) {
24
+ console.log(`🚀 NocoBase server running at: http://${host === '0.0.0.0' ? 'localhost' : host}:${port}/`);
25
+ }
24
26
  });
25
27
  //# sourceMappingURL=start.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kBAAe,CAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC;IAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,SAAS,CAAC;IAE/D,MAAM,GAAG,CAAC,KAAK,CAAC;QACd,OAAO;QACP,MAAM,EAAE;YACN,IAAI;YACJ,IAAI;SACL;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,4CAA4C,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAA,CAAC","sourcesContent":["export default async ({ app, cliArgs }) => {\n const [opts] = cliArgs;\n const port = opts.port || process.env.SERVER_PORT || 3000;\n const host = opts.host || process.env.SERVER_HOST || '0.0.0.0';\n\n await app.start({\n cliArgs,\n listen: {\n port,\n host,\n },\n });\n\n console.log(`🚀 nocobase server had started at http://${host}:${port}`);\n};\n"]}
1
+ {"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kBAAe,CAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACvB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,IAAI,CAAC;IAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,SAAS,CAAC;IAE/D,MAAM,GAAG,CAAC,KAAK,CAAC;QACd,OAAO;QACP,MAAM,EAAE;YACN,IAAI;YACJ,IAAI;SACL;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;QAChB,OAAO,CAAC,GAAG,CAAC,yCAAyC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC;KAC1G;AACH,CAAC,CAAA,CAAC","sourcesContent":["export default async ({ app, cliArgs }) => {\n const [opts] = cliArgs;\n const port = opts.port || process.env.SERVER_PORT || 3000;\n const host = opts.host || process.env.SERVER_HOST || '0.0.0.0';\n\n await app.start({\n cliArgs,\n listen: {\n port,\n host,\n },\n });\n\n if (!opts.silent) {\n console.log(`🚀 NocoBase server running at: http://${host === '0.0.0.0' ? 'localhost' : host}:${port}/`);\n }\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "0.7.0-alpha.3",
3
+ "version": "0.7.0-alpha.30",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -18,10 +18,11 @@
18
18
  "dependencies": {
19
19
  "@koa/cors": "^3.1.0",
20
20
  "@koa/router": "^9.4.0",
21
- "@nocobase/acl": "0.7.0-alpha.3",
22
- "@nocobase/actions": "0.7.0-alpha.3",
23
- "@nocobase/database": "0.7.0-alpha.3",
24
- "@nocobase/resourcer": "0.7.0-alpha.3",
21
+ "@nocobase/acl": "0.7.0-alpha.30",
22
+ "@nocobase/actions": "0.7.0-alpha.30",
23
+ "@nocobase/database": "0.7.0-alpha.30",
24
+ "@nocobase/resourcer": "0.7.0-alpha.30",
25
+ "chalk": "^4.1.1",
25
26
  "commander": "^8.1.0",
26
27
  "dotenv": "^8.2.0",
27
28
  "find-package-json": "^1.2.0",
@@ -31,5 +32,5 @@
31
32
  "koa-static": "^5.0.0",
32
33
  "lodash": "^4.17.21"
33
34
  },
34
- "gitHead": "b12507f6e4bcb5f1fd8285670a43fb3807d90ea0"
35
+ "gitHead": "781fb0a999854341cd8c353d31ae5a11ecbbe775"
35
36
  }