@nocobase/server 0.19.0-alpha.4 → 0.19.0-alpha.6

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.
@@ -55,27 +55,27 @@ function dataWrapping() {
55
55
  ctx.body = {
56
56
  data: ctx.body
57
57
  };
58
- return;
59
- }
60
- if (ctx.body) {
61
- const { rows, ...meta } = ctx.body;
62
- if (rows) {
63
- ctx.body = {
64
- data: rows,
65
- meta
66
- };
67
- } else {
58
+ } else {
59
+ if (ctx.body) {
60
+ const { rows, ...meta } = ctx.body;
61
+ if (rows) {
62
+ ctx.body = {
63
+ data: rows,
64
+ meta
65
+ };
66
+ } else {
67
+ ctx.body = {
68
+ data: ctx.body
69
+ };
70
+ if (ctx.bodyMeta) {
71
+ ctx.body.meta = ctx.bodyMeta;
72
+ }
73
+ }
74
+ } else if (ctx.action) {
68
75
  ctx.body = {
69
76
  data: ctx.body
70
77
  };
71
- if (ctx.bodyMeta) {
72
- ctx.body.meta = ctx.bodyMeta;
73
- }
74
78
  }
75
- } else if (ctx.action) {
76
- ctx.body = {
77
- data: ctx.body
78
- };
79
79
  }
80
80
  if (ctx.body && ((_b = ctx.state.messages) == null ? void 0 : _b.length)) {
81
81
  ctx.body.messages = ctx.state.messages;
package/lib/plugin.d.ts CHANGED
@@ -37,7 +37,8 @@ export declare abstract class Plugin<O = any> implements PluginInterface {
37
37
  setOptions(options: any): void;
38
38
  getName(): any;
39
39
  createLogger(options: LoggerOptions): import("winston").Logger;
40
- get _sourceDir(): "src" | "dist" | "lib";
40
+ protected _sourceDir: string;
41
+ protected getSourceDir(): Promise<string>;
41
42
  loadCommands(): Promise<void>;
42
43
  loadMigrations(): Promise<{
43
44
  beforeLoad: any[];
@@ -59,6 +60,7 @@ export declare abstract class Plugin<O = any> implements PluginInterface {
59
60
  loadCollections(): Promise<void>;
60
61
  requiredPlugins(): any[];
61
62
  t(text: TFuncKey | TFuncKey[], options?: TOptions): import("i18next").TFunctionDetailedResult<object>;
63
+ protected isDev(): Promise<boolean>;
62
64
  toJSON(options?: any): Promise<any>;
63
65
  }
64
66
  export default Plugin;
package/lib/plugin.js CHANGED
@@ -86,18 +86,25 @@ const _Plugin = class _Plugin {
86
86
  createLogger(options) {
87
87
  return this.app.createLogger(options);
88
88
  }
89
- get _sourceDir() {
89
+ _sourceDir;
90
+ async getSourceDir() {
91
+ if (this._sourceDir) {
92
+ return this._sourceDir;
93
+ }
94
+ if (await this.isDev()) {
95
+ return this._sourceDir = "src";
96
+ }
90
97
  if ((0, import_path.basename)(__dirname) === "src") {
91
- return "src";
98
+ return this._sourceDir = "src";
92
99
  }
93
- return this.isPreset ? "lib" : "dist";
100
+ return this._sourceDir = this.isPreset ? "lib" : "dist";
94
101
  }
95
102
  async loadCommands() {
96
103
  const extensions = ["js", "ts"];
97
104
  const directory = (0, import_path.resolve)(
98
105
  process.env.NODE_MODULES_PATH,
99
106
  this.options.packageName,
100
- this._sourceDir,
107
+ await this.getSourceDir(),
101
108
  "server/commands"
102
109
  );
103
110
  const patten = `${directory}/*.{${extensions.join(",")}}`;
@@ -122,7 +129,7 @@ const _Plugin = class _Plugin {
122
129
  const directory = (0, import_path.resolve)(
123
130
  process.env.NODE_MODULES_PATH,
124
131
  this.options.packageName,
125
- this._sourceDir,
132
+ await this.getSourceDir(),
126
133
  "server/migrations"
127
134
  );
128
135
  return await this.app.loadMigrations({
@@ -164,7 +171,7 @@ const _Plugin = class _Plugin {
164
171
  const directory = (0, import_path.resolve)(
165
172
  process.env.NODE_MODULES_PATH,
166
173
  this.options.packageName,
167
- this._sourceDir,
174
+ await this.getSourceDir(),
168
175
  "server/collections"
169
176
  );
170
177
  if (await (0, import_utils.fsExists)(directory)) {
@@ -180,6 +187,18 @@ const _Plugin = class _Plugin {
180
187
  t(text, options = {}) {
181
188
  return this.app.i18n.t(text, { ns: this.options["packageName"], ...options });
182
189
  }
190
+ async isDev() {
191
+ if (!this.options.packageName) {
192
+ return false;
193
+ }
194
+ const file = await import_fs.default.promises.realpath(
195
+ (0, import_path.resolve)(process.env.NODE_MODULES_PATH || (0, import_path.resolve)(process.cwd(), "node_modules"), this.options.packageName)
196
+ );
197
+ if (file.startsWith((0, import_path.resolve)(process.cwd(), "packages"))) {
198
+ return !!process.env.IS_DEV_CMD;
199
+ }
200
+ return false;
201
+ }
183
202
  async toJSON(options = {}) {
184
203
  const { locale = "en-US" } = options;
185
204
  const { name, packageName, packageJson } = this.options;
@@ -190,10 +209,12 @@ const _Plugin = class _Plugin {
190
209
  }
191
210
  const results = {
192
211
  ...this.options,
212
+ keywords: packageJson.keywords,
193
213
  readmeUrl: (0, import_plugin_manager.getExposeReadmeUrl)(packageName, locale),
194
214
  changelogUrl: (0, import_plugin_manager.getExposeChangelogUrl)(packageName),
195
215
  displayName: packageJson[`displayName.${locale}`] || packageJson.displayName || name,
196
- description: packageJson[`description.${locale}`] || packageJson.description
216
+ description: packageJson[`description.${locale}`] || packageJson.description,
217
+ homepage: packageJson[`homepage.${locale}`] || packageJson.homepage
197
218
  };
198
219
  if (!options.withOutOpenFile) {
199
220
  const file = await import_fs.default.promises.realpath(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "0.19.0-alpha.4",
3
+ "version": "0.19.0-alpha.6",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -10,17 +10,17 @@
10
10
  "@koa/cors": "^3.1.0",
11
11
  "@koa/multer": "^3.0.2",
12
12
  "@koa/router": "^9.4.0",
13
- "@nocobase/acl": "0.19.0-alpha.4",
14
- "@nocobase/actions": "0.19.0-alpha.4",
15
- "@nocobase/auth": "0.19.0-alpha.4",
16
- "@nocobase/cache": "0.19.0-alpha.4",
17
- "@nocobase/database": "0.19.0-alpha.4",
18
- "@nocobase/evaluators": "0.19.0-alpha.4",
19
- "@nocobase/logger": "0.19.0-alpha.4",
20
- "@nocobase/resourcer": "0.19.0-alpha.4",
21
- "@nocobase/sdk": "0.19.0-alpha.4",
22
- "@nocobase/telemetry": "0.19.0-alpha.4",
23
- "@nocobase/utils": "0.19.0-alpha.4",
13
+ "@nocobase/acl": "0.19.0-alpha.6",
14
+ "@nocobase/actions": "0.19.0-alpha.6",
15
+ "@nocobase/auth": "0.19.0-alpha.6",
16
+ "@nocobase/cache": "0.19.0-alpha.6",
17
+ "@nocobase/database": "0.19.0-alpha.6",
18
+ "@nocobase/evaluators": "0.19.0-alpha.6",
19
+ "@nocobase/logger": "0.19.0-alpha.6",
20
+ "@nocobase/resourcer": "0.19.0-alpha.6",
21
+ "@nocobase/sdk": "0.19.0-alpha.6",
22
+ "@nocobase/telemetry": "0.19.0-alpha.6",
23
+ "@nocobase/utils": "0.19.0-alpha.6",
24
24
  "@types/decompress": "4.2.4",
25
25
  "@types/ini": "^1.3.31",
26
26
  "@types/koa-send": "^4.1.3",
@@ -53,5 +53,5 @@
53
53
  "@types/serve-handler": "^6.1.1",
54
54
  "@types/ws": "^8.5.5"
55
55
  },
56
- "gitHead": "9583023f7bea828da5192384a5c002782c341b65"
56
+ "gitHead": "2eb524db98c7f4136fe1a9a1b1259cd72cf6635f"
57
57
  }