@nocobase/server 0.7.0-alpha.6 → 0.7.0-alpha.62
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.d.ts +3 -3
- package/lib/app-manager.js +151 -72
- package/lib/application.d.ts +3 -2
- package/lib/application.js +291 -153
- package/lib/commands/console.d.ts +2 -3
- package/lib/commands/console.js +33 -24
- package/lib/commands/db-auth.d.ts +3 -0
- package/lib/commands/db-auth.js +26 -0
- 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 -29
- package/lib/commands/install.d.ts +2 -4
- package/lib/commands/install.js +68 -20
- package/lib/commands/start.d.ts +2 -4
- package/lib/commands/start.js +28 -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 +65 -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 +8 -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 -69
- package/esm/app-manager.js.map +0 -1
- package/esm/application.d.ts +0 -97
- package/esm/application.js +0 -156
- 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-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 -26
- package/esm/commands/index.js.map +0 -1
- package/esm/commands/install.d.ts +0 -5
- package/esm/commands/install.js +0 -23
- package/esm/commands/install.js.map +0 -1
- package/esm/commands/start.d.ts +0 -5
- package/esm/commands/start.js +0 -23
- 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-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
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
|
-
export function dataWrapping() {
|
|
22
|
-
return function dataWrapping(ctx, next) {
|
|
23
|
-
var _a;
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
yield next();
|
|
26
|
-
if (ctx.withoutDataWrapping) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (!((_a = ctx === null || ctx === void 0 ? void 0 : ctx.action) === null || _a === void 0 ? void 0 : _a.params)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (ctx.body instanceof Buffer) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (!ctx.body) {
|
|
36
|
-
ctx.body = {};
|
|
37
|
-
}
|
|
38
|
-
const _b = ctx.body, { rows } = _b, meta = __rest(_b, ["rows"]);
|
|
39
|
-
if (rows) {
|
|
40
|
-
ctx.body = {
|
|
41
|
-
data: rows,
|
|
42
|
-
meta,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
ctx.body = {
|
|
47
|
-
data: ctx.body,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export default dataWrapping;
|
|
54
|
-
//# sourceMappingURL=data-wrapping.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-wrapping.js","sourceRoot":"","sources":["../../src/middlewares/data-wrapping.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,UAAU,YAAY;IAC1B,OAAO,SAAe,YAAY,CAAC,GAAY,EAAE,IAAU;;;YACzD,MAAM,IAAI,EAAE,CAAC;YACb,IAAI,GAAG,CAAC,mBAAmB,EAAE;gBAC3B,OAAO;aACR;YACD,IAAI,CAAC,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,MAAM,CAAA,EAAE;gBACxB,OAAO;aACR;YACD,IAAI,GAAG,CAAC,IAAI,YAAY,MAAM,EAAE;gBAC9B,OAAO;aACR;YACD,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;gBACb,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC;aACf;YACD,MAAM,KAAoB,GAAG,CAAC,IAAI,EAA5B,EAAE,IAAI,OAAsB,EAAjB,IAAI,cAAf,QAAiB,CAAW,CAAC;YACnC,IAAI,IAAI,EAAE;gBACR,GAAG,CAAC,IAAI,GAAG;oBACT,IAAI,EAAE,IAAI;oBACV,IAAI;iBACL,CAAC;aACH;iBAAM;gBACL,GAAG,CAAC,IAAI,GAAG;oBACT,IAAI,EAAE,GAAG,CAAC,IAAI;iBACf,CAAC;aACH;;KACF,CAAC;AACJ,CAAC;AAED,eAAe,YAAY,CAAC","sourcesContent":["import { Context, Next } from '@nocobase/actions';\n\nexport function dataWrapping() {\n return async function dataWrapping(ctx: Context, next: Next) {\n await next();\n if (ctx.withoutDataWrapping) {\n return;\n }\n if (!ctx?.action?.params) {\n return;\n }\n if (ctx.body instanceof Buffer) {\n return;\n }\n if (!ctx.body) {\n ctx.body = {};\n }\n const { rows, ...meta } = ctx.body;\n if (rows) {\n ctx.body = {\n data: rows,\n meta,\n };\n } else {\n ctx.body = {\n data: ctx.body,\n };\n }\n };\n}\n\nexport default dataWrapping;\n"]}
|
package/esm/middlewares/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './table2resource';\nexport * from './data-wrapping';\n"]}
|
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
import { getNameByParams, parseRequest } from '@nocobase/resourcer';
|
|
11
|
-
export function table2resource() {
|
|
12
|
-
return function table2resource(ctx, next) {
|
|
13
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
const resourcer = ctx.resourcer;
|
|
15
|
-
const database = ctx.db;
|
|
16
|
-
let params = parseRequest({
|
|
17
|
-
path: ctx.request.path,
|
|
18
|
-
method: ctx.request.method,
|
|
19
|
-
}, {
|
|
20
|
-
prefix: resourcer.options.prefix,
|
|
21
|
-
accessors: resourcer.options.accessors,
|
|
22
|
-
});
|
|
23
|
-
if (!params) {
|
|
24
|
-
return next();
|
|
25
|
-
}
|
|
26
|
-
const resourceName = getNameByParams(params);
|
|
27
|
-
// 如果资源名称未被定义
|
|
28
|
-
if (resourcer.isDefined(resourceName)) {
|
|
29
|
-
return next();
|
|
30
|
-
}
|
|
31
|
-
const [collectionName, fieldName] = resourceName.split('.');
|
|
32
|
-
// 如果经过加载后是已经定义的表
|
|
33
|
-
if (!database.hasCollection(collectionName)) {
|
|
34
|
-
return next();
|
|
35
|
-
}
|
|
36
|
-
const collection = database.getCollection(collectionName);
|
|
37
|
-
let resourceType = 'single';
|
|
38
|
-
if (fieldName && collection.hasField(fieldName)) {
|
|
39
|
-
const field = collection.getField(fieldName);
|
|
40
|
-
resourceType = field.type;
|
|
41
|
-
}
|
|
42
|
-
resourcer.define({
|
|
43
|
-
type: resourceType,
|
|
44
|
-
name: resourceName,
|
|
45
|
-
});
|
|
46
|
-
return next();
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
export default table2resource;
|
|
51
|
-
//# sourceMappingURL=table2resource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"table2resource.js","sourceRoot":"","sources":["../../src/middlewares/table2resource.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAkC,MAAM,qBAAqB,CAAC;AAGpG,MAAM,UAAU,cAAc;IAC5B,OAAO,SAAe,cAAc,CAAC,GAAwC,EAAE,IAAwB;;YACrG,MAAM,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;YAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,MAAM,GAAG,YAAY,CACvB;gBACE,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI;gBACtB,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM;aAC3B,EACD;gBACE,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,MAAM;gBAChC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS;aACvC,CACF,CAAC;YACF,IAAI,CAAC,MAAM,EAAE;gBACX,OAAO,IAAI,EAAE,CAAC;aACf;YACD,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;YAC7C,aAAa;YACb,IAAI,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE;gBACrC,OAAO,IAAI,EAAE,CAAC;aACf;YACD,MAAM,CAAC,cAAc,EAAE,SAAS,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5D,iBAAiB;YACjB,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE;gBAC3C,OAAO,IAAI,EAAE,CAAC;aACf;YACD,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;YAC1D,IAAI,YAAY,GAAiB,QAAQ,CAAC;YAC1C,IAAI,SAAS,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAC/C,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBAC7C,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC;aAC3B;YACD,SAAS,CAAC,MAAM,CAAC;gBACf,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,YAAY;aACnB,CAAC,CAAC;YACH,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;KAAA,CAAC;AACJ,CAAC;AAED,eAAe,cAAc,CAAC","sourcesContent":["import { getNameByParams, parseRequest, ResourcerContext, ResourceType } from '@nocobase/resourcer';\nimport Database from '@nocobase/database';\n\nexport function table2resource() {\n return async function table2resource(ctx: ResourcerContext & { db: Database }, next: () => Promise<any>) {\n const resourcer = ctx.resourcer;\n const database = ctx.db;\n let params = parseRequest(\n {\n path: ctx.request.path,\n method: ctx.request.method,\n },\n {\n prefix: resourcer.options.prefix,\n accessors: resourcer.options.accessors,\n },\n );\n if (!params) {\n return next();\n }\n const resourceName = getNameByParams(params);\n // 如果资源名称未被定义\n if (resourcer.isDefined(resourceName)) {\n return next();\n }\n const [collectionName, fieldName] = resourceName.split('.');\n // 如果经过加载后是已经定义的表\n if (!database.hasCollection(collectionName)) {\n return next();\n }\n const collection = database.getCollection(collectionName);\n let resourceType: ResourceType = 'single';\n if (fieldName && collection.hasField(fieldName)) {\n const field = collection.getField(fieldName);\n resourceType = field.type;\n }\n resourcer.define({\n type: resourceType,\n name: resourceName,\n });\n return next();\n };\n}\n\nexport default table2resource;\n"]}
|
package/esm/plugin-manager.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { CleanOptions, SyncOptions } from '@nocobase/database';
|
|
2
|
-
import Application from './application';
|
|
3
|
-
import { Plugin } from './plugin';
|
|
4
|
-
interface PluginManagerOptions {
|
|
5
|
-
app: Application;
|
|
6
|
-
}
|
|
7
|
-
export interface InstallOptions {
|
|
8
|
-
cliArgs?: any[];
|
|
9
|
-
clean?: CleanOptions | boolean;
|
|
10
|
-
sync?: SyncOptions;
|
|
11
|
-
}
|
|
12
|
-
export declare class PluginManager {
|
|
13
|
-
app: Application;
|
|
14
|
-
protected plugins: Map<string, Plugin<any>>;
|
|
15
|
-
constructor(options: PluginManagerOptions);
|
|
16
|
-
getPlugins(): Map<string, Plugin<any>>;
|
|
17
|
-
get(name: string): Plugin<any>;
|
|
18
|
-
add<P = Plugin, O = any>(pluginClass: any, options?: O): P;
|
|
19
|
-
load(): Promise<void>;
|
|
20
|
-
install(options?: InstallOptions): Promise<void>;
|
|
21
|
-
static resolvePlugin(pluginName: string): any;
|
|
22
|
-
}
|
|
23
|
-
export {};
|
package/esm/plugin-manager.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
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 class PluginManager {
|
|
11
|
-
constructor(options) {
|
|
12
|
-
this.plugins = new Map();
|
|
13
|
-
this.app = options.app;
|
|
14
|
-
}
|
|
15
|
-
getPlugins() {
|
|
16
|
-
return this.plugins;
|
|
17
|
-
}
|
|
18
|
-
get(name) {
|
|
19
|
-
return this.plugins.get(name);
|
|
20
|
-
}
|
|
21
|
-
add(pluginClass, options) {
|
|
22
|
-
const instance = new pluginClass(this.app, options);
|
|
23
|
-
const name = instance.getName();
|
|
24
|
-
if (this.plugins.has(name)) {
|
|
25
|
-
throw new Error(`plugin name [${name}] `);
|
|
26
|
-
}
|
|
27
|
-
this.plugins.set(name, instance);
|
|
28
|
-
return instance;
|
|
29
|
-
}
|
|
30
|
-
load() {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
yield this.app.emitAsync('beforeLoadAll');
|
|
33
|
-
for (const [name, plugin] of this.plugins) {
|
|
34
|
-
yield plugin.beforeLoad();
|
|
35
|
-
}
|
|
36
|
-
for (const [name, plugin] of this.plugins) {
|
|
37
|
-
yield this.app.emitAsync('beforeLoadPlugin', plugin);
|
|
38
|
-
yield plugin.load();
|
|
39
|
-
yield this.app.emitAsync('afterLoadPlugin', plugin);
|
|
40
|
-
}
|
|
41
|
-
yield this.app.emitAsync('afterLoadAll');
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
install(options) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
for (const [name, plugin] of this.plugins) {
|
|
47
|
-
yield this.app.emitAsync('beforeInstallPlugin', plugin, options);
|
|
48
|
-
yield plugin.install(options);
|
|
49
|
-
yield this.app.emitAsync('afterInstallPlugin', plugin, options);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
static resolvePlugin(pluginName) {
|
|
54
|
-
return require(pluginName).default;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=plugin-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-manager.js","sourceRoot":"","sources":["../src/plugin-manager.ts"],"names":[],"mappings":";;;;;;;;;AAcA,MAAM,OAAO,aAAa;IAIxB,YAAY,OAA6B;QAF/B,YAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;QAG5C,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IACzB,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,GAAG,CAAsB,WAAgB,EAAE,OAAW;QACpD,MAAM,QAAQ,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAEpD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;QAEhC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC;SAC3C;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAEjC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEK,IAAI;;YACR,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;YAE1C,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE;gBACzC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;aAC3B;YAED,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE;gBACzC,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;gBACrD,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBACpB,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;aACrD;YAED,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAC3C,CAAC;KAAA;IAEK,OAAO,CAAC,OAAwB;;YACpC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE;gBACzC,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,qBAAqB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;gBACjE,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC9B,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;aACjE;QACH,CAAC;KAAA;IAED,MAAM,CAAC,aAAa,CAAC,UAAkB;QACrC,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;IACrC,CAAC;CACF","sourcesContent":["import { CleanOptions, SyncOptions } from '@nocobase/database';\nimport Application from './application';\nimport { Plugin } from './plugin';\n\ninterface PluginManagerOptions {\n app: Application;\n}\n\nexport interface InstallOptions {\n cliArgs?: any[];\n clean?: CleanOptions | boolean;\n sync?: SyncOptions;\n}\n\nexport class PluginManager {\n app: Application;\n protected plugins = new Map<string, Plugin>();\n\n constructor(options: PluginManagerOptions) {\n this.app = options.app;\n }\n\n getPlugins() {\n return this.plugins;\n }\n\n get(name: string) {\n return this.plugins.get(name);\n }\n\n add<P = Plugin, O = any>(pluginClass: any, options?: O): P {\n const instance = new pluginClass(this.app, options);\n\n const name = instance.getName();\n\n if (this.plugins.has(name)) {\n throw new Error(`plugin name [${name}] `);\n }\n\n this.plugins.set(name, instance);\n\n return instance;\n }\n\n async load() {\n await this.app.emitAsync('beforeLoadAll');\n\n for (const [name, plugin] of this.plugins) {\n await plugin.beforeLoad();\n }\n\n for (const [name, plugin] of this.plugins) {\n await this.app.emitAsync('beforeLoadPlugin', plugin);\n await plugin.load();\n await this.app.emitAsync('afterLoadPlugin', plugin);\n }\n\n await this.app.emitAsync('afterLoadAll');\n }\n\n async install(options?: InstallOptions) {\n for (const [name, plugin] of this.plugins) {\n await this.app.emitAsync('beforeInstallPlugin', plugin, options);\n await plugin.install(options);\n await this.app.emitAsync('afterInstallPlugin', plugin, options);\n }\n }\n\n static resolvePlugin(pluginName: string) {\n return require(pluginName).default;\n }\n}\n"]}
|
package/esm/plugin.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Database } from '@nocobase/database';
|
|
2
|
-
import { Application } from './application';
|
|
3
|
-
import { InstallOptions } from './plugin-manager';
|
|
4
|
-
export interface PluginInterface {
|
|
5
|
-
beforeLoad?: () => void;
|
|
6
|
-
load(): any;
|
|
7
|
-
getName(): string;
|
|
8
|
-
}
|
|
9
|
-
export interface PluginOptions {
|
|
10
|
-
activate?: boolean;
|
|
11
|
-
displayName?: string;
|
|
12
|
-
description?: string;
|
|
13
|
-
version?: string;
|
|
14
|
-
install?: (this: Plugin) => void;
|
|
15
|
-
load?: (this: Plugin) => void;
|
|
16
|
-
plugin?: typeof Plugin;
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
}
|
|
19
|
-
export declare type PluginType = typeof Plugin;
|
|
20
|
-
export declare abstract class Plugin<O = any> implements PluginInterface {
|
|
21
|
-
options: O;
|
|
22
|
-
app: Application;
|
|
23
|
-
db: Database;
|
|
24
|
-
constructor(app: Application, options?: O);
|
|
25
|
-
setOptions(options: O): void;
|
|
26
|
-
abstract getName(): string;
|
|
27
|
-
beforeLoad(): void;
|
|
28
|
-
install(options?: InstallOptions): Promise<void>;
|
|
29
|
-
load(): Promise<void>;
|
|
30
|
-
collectionPath(): any;
|
|
31
|
-
protected getPackageName(dirname: string): any;
|
|
32
|
-
}
|
package/esm/plugin.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
import finder from 'find-package-json';
|
|
11
|
-
export class Plugin {
|
|
12
|
-
constructor(app, options) {
|
|
13
|
-
this.app = app;
|
|
14
|
-
this.db = app.db;
|
|
15
|
-
this.setOptions(options);
|
|
16
|
-
}
|
|
17
|
-
setOptions(options) {
|
|
18
|
-
this.options = options || {};
|
|
19
|
-
}
|
|
20
|
-
beforeLoad() { }
|
|
21
|
-
install(options) {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () { });
|
|
23
|
-
}
|
|
24
|
-
load() {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const collectionPath = this.collectionPath();
|
|
27
|
-
if (collectionPath) {
|
|
28
|
-
yield this.db.import({
|
|
29
|
-
directory: collectionPath,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
collectionPath() {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
getPackageName(dirname) {
|
|
38
|
-
const f = finder(dirname);
|
|
39
|
-
const packageObj = f.next().value;
|
|
40
|
-
return packageObj['name'];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=plugin.js.map
|
package/esm/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAuBvC,MAAM,OAAgB,MAAM;IAK1B,YAAY,GAAgB,EAAE,OAAW;QACvC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC;QACjB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAED,UAAU,CAAC,OAAU;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,IAAK,EAAU,CAAC;IACxC,CAAC;IAID,UAAU,KAAI,CAAC;IAET,OAAO,CAAC,OAAwB;8DAAG,CAAC;KAAA;IAEpC,IAAI;;YACR,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YAC7C,IAAI,cAAc,EAAE;gBAClB,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;oBACnB,SAAS,EAAE,cAAc;iBAC1B,CAAC,CAAC;aACJ;QACH,CAAC;KAAA;IAED,cAAc;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAES,cAAc,CAAC,OAAe;QACtC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1B,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;QAClC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;CACF","sourcesContent":["import { Database } from '@nocobase/database';\nimport { Application } from './application';\nimport finder from 'find-package-json';\n\nimport { InstallOptions } from './plugin-manager';\n\nexport interface PluginInterface {\n beforeLoad?: () => void;\n load();\n getName(): string;\n}\n\nexport interface PluginOptions {\n activate?: boolean;\n displayName?: string;\n description?: string;\n version?: string;\n install?: (this: Plugin) => void;\n load?: (this: Plugin) => void;\n plugin?: typeof Plugin;\n [key: string]: any;\n}\n\nexport type PluginType = typeof Plugin;\n\nexport abstract class Plugin<O = any> implements PluginInterface {\n options: O;\n app: Application;\n db: Database;\n\n constructor(app: Application, options?: O) {\n this.app = app;\n this.db = app.db;\n this.setOptions(options);\n }\n\n setOptions(options: O) {\n this.options = options || ({} as any);\n }\n\n public abstract getName(): string;\n\n beforeLoad() {}\n\n async install(options?: InstallOptions) {}\n\n async load() {\n const collectionPath = this.collectionPath();\n if (collectionPath) {\n await this.db.import({\n directory: collectionPath,\n });\n }\n }\n\n collectionPath() {\n return null;\n }\n\n protected getPackageName(dirname: string) {\n const f = finder(dirname);\n const packageObj = f.next().value;\n return packageObj['name'];\n }\n}\n"]}
|
package/esm/read-config.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function readConfig(dir: string): Promise<{}>;
|
|
2
|
-
export declare class ConfigurationRepository {
|
|
3
|
-
protected items: Map<string, any>;
|
|
4
|
-
get(key: string, defaultValue?: any): any;
|
|
5
|
-
set(key: string, value: any): Map<string, any>;
|
|
6
|
-
toObject(): {};
|
|
7
|
-
}
|
|
8
|
-
export declare function loadConfiguration(configurationDir: string, repository: ConfigurationRepository): Promise<void>;
|
package/esm/read-config.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
import lodash from 'lodash';
|
|
11
|
-
import fs from 'fs';
|
|
12
|
-
import path from 'path';
|
|
13
|
-
export function readConfig(dir) {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
const repository = new ConfigurationRepository();
|
|
16
|
-
yield loadConfiguration(dir, repository);
|
|
17
|
-
return repository.toObject();
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
export class ConfigurationRepository {
|
|
21
|
-
constructor() {
|
|
22
|
-
this.items = new Map();
|
|
23
|
-
}
|
|
24
|
-
get(key, defaultValue = undefined) {
|
|
25
|
-
if (this.items.has(key)) {
|
|
26
|
-
return this.items.get(key);
|
|
27
|
-
}
|
|
28
|
-
return defaultValue;
|
|
29
|
-
}
|
|
30
|
-
set(key, value) {
|
|
31
|
-
return this.items.set(key, value);
|
|
32
|
-
}
|
|
33
|
-
toObject() {
|
|
34
|
-
const result = {};
|
|
35
|
-
for (const [key, value] of this.items.entries()) {
|
|
36
|
-
lodash.set(result, key, value);
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export function loadConfiguration(configurationDir, repository) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const getConfigurationFiles = (dir, prefix = []) => __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const files = yield fs.promises.readdir(dir, { withFileTypes: true });
|
|
45
|
-
for (const file of files) {
|
|
46
|
-
if (file.isDirectory()) {
|
|
47
|
-
yield getConfigurationFiles(path.join(dir, file.name), [...prefix, file.name]);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
if (!['ts', 'js'].includes(file.name.split('.').slice(1).join('.'))) {
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const filePath = path.join(dir, file.name);
|
|
54
|
-
const keyName = path.parse(filePath).name;
|
|
55
|
-
const configuration = require(filePath).default;
|
|
56
|
-
repository.set([...prefix, keyName].join('.'), configuration);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
yield getConfigurationFiles(configurationDir);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=read-config.js.map
|
package/esm/read-config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read-config.js","sourceRoot":"","sources":["../src/read-config.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,UAAgB,UAAU,CAAC,GAAW;;QAC1C,MAAM,UAAU,GAAG,IAAI,uBAAuB,EAAE,CAAC;QACjD,MAAM,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QACzC,OAAO,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC/B,CAAC;CAAA;AAED,MAAM,OAAO,uBAAuB;IAApC;QACY,UAAK,GAAG,IAAI,GAAG,EAAe,CAAC;IAuB3C,CAAC;IArBC,GAAG,CAAC,GAAW,EAAE,YAAY,GAAG,SAAS;QACvC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACvB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAC5B;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,KAAU;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,QAAQ;QACN,MAAM,MAAM,GAAG,EAAE,CAAC;QAElB,KAAK,M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,IAAI,CAAC,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC;iBAC/D;aACF;QACH,CAAC,CAAA,CAAC;QAEF,MAAM,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IAChD,CAAC;CAAA","sourcesContent":["import lodash from 'lodash';\nimport fs from 'fs';\nimport path from 'path';\n\nexport async function readConfig(dir: string) {\n const repository = new ConfigurationRepository();\n await loadConfiguration(dir, repository);\n return repository.toObject();\n}\n\nexport class ConfigurationRepository {\n protected items = new Map<string, any>();\n\n get(key: string, defaultValue = undefined) {\n if (this.items.has(key)) {\n return this.items.get(key);\n }\n\n return defaultValue;\n }\n\n set(key: string, value: any) {\n return this.items.set(key, value);\n }\n\n toObject() {\n const result = {};\n\n for (const [key, value] of this.items.entries()) {\n lodash.set(result, key, value);\n }\n\n return result;\n }\n}\n\nexport async function loadConfiguration(configurationDir: string, repository: ConfigurationRepository) {\n const getConfigurationFiles = async (dir: string, prefix = []) => {\n const files = await fs.promises.readdir(dir, { withFileTypes: true });\n for (const file of files) {\n if (file.isDirectory()) {\n await getConfigurationFiles(path.join(dir, file.name), [...prefix, file.name]);\n } else {\n if (!['ts', 'js'].includes(file.name.split('.').slice(1).join('.'))) {\n continue;\n }\n\n const filePath = path.join(dir, file.name);\n const keyName = path.parse(filePath).name;\n const configuration = require(filePath).default;\n\n repository.set([...prefix, keyName].join('.'), configuration);\n }\n }\n };\n\n await getConfigurationFiles(configurationDir);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"available-action.js","sourceRoot":"","sources":["../../src/acl/available-action.ts"],"names":[],"mappings":";;;AAEA,MAAM,gBAAgB,GAElB;IACF,MAAM,EAAE;QACN,WAAW,EAAE,kBAAkB;QAC/B,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,IAAI;QACjB,oBAAoB,EAAE,IAAI;KAC3B;IACD,YAAY;IACZ,oCAAoC;IACpC,sBAAsB;IACtB,kBAAkB;IAClB,KAAK;IACL,MAAM,EAAE;QACN,WAAW,EAAE,iBAAiB;QAC9B,IAAI,EAAE,UAAU;QAChB,oBAAoB,EAAE,IAAI;KAC3B;IACD,IAAI,EAAE;QACJ,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;QACxB,oBAAoB,EAAE,IAAI;KAC3B;IACD,MAAM,EAAE;QACN,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC3B,oBAAoB,EAAE,IAAI;KAC3B;IACD,OAAO,EAAE;QACP,WAAW,EAAE,iBAAiB;QAC9B,IAAI,EAAE,UAAU;KACjB;CACF,CAAC;AAEO,4CAAgB","sourcesContent":["import { AvailableActionOptions } from '@nocobase/acl';\n\nconst availableActions: {\n [key: string]: AvailableActionOptions;\n} = {\n create: {\n displayName: '{{t(\"Add new\")}}',\n type: 'new-data',\n onNewRecord: true,\n allowConfigureFields: true,\n },\n // import: {\n // displayName: '{{t(\"Import\")}}',\n // type: 'new-data',\n // scope: false,\n // },\n export: {\n displayName: '{{t(\"Export\")}}',\n type: 'old-data',\n allowConfigureFields: true,\n },\n view: {\n displayName: '{{t(\"View\")}}',\n type: 'old-data',\n aliases: ['get', 'list'],\n allowConfigureFields: true,\n },\n update: {\n displayName: '{{t(\"Edit\")}}',\n type: 'old-data',\n aliases: ['update', 'move'],\n allowConfigureFields: true,\n },\n destroy: {\n displayName: '{{t(\"Delete\")}}',\n type: 'old-data',\n },\n};\n\nexport { availableActions };\n"]}
|
package/lib/acl/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/acl/index.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AACpC,yDAAsD;AAEtD,MAAM,kBAAkB,GAAG;IACzB,OAAO;IACP,aAAa;IACb,mBAAmB;IACnB,iBAAiB;IACjB,sBAAsB;IACtB,kBAAkB;CACnB,CAAC;AAEF,SAAgB,SAAS;IACvB,MAAM,GAAG,GAAG,IAAI,SAAG,EAAE,CAAC;IAEtB,KAAK,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,mCAAgB,CAAC,EAAE;QACzE,GAAG,CAAC,kBAAkB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;KAClD;IAED,GAAG,CAAC,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;IAEhD,OAAO,GAAG,CAAC;AACb,CAAC;AAVD,8BAUC","sourcesContent":["import { ACL } from '@nocobase/acl';\nimport { availableActions } from './available-action';\n\nconst configureResources = [\n 'roles',\n 'collections',\n 'roles.collections',\n 'roles.resources',\n 'rolesResourcesScopes',\n 'availableActions',\n];\n\nexport function createACL() {\n const acl = new ACL();\n\n for (const [actionName, actionParams] of Object.entries(availableActions)) {\n acl.setAvailableAction(actionName, actionParams);\n }\n\n acl.registerConfigResources(configureResources);\n\n return acl;\n}\n"]}
|
package/lib/app-manager.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,YA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IAEK,cAAc,CAAC,OAAe;;YAClC,MAAM,IAAI,CAAC,SAAS,CAAC,sBAAsB,EAAE;gBAC3C,UAAU,EAAE,IAAI;gBAChB,IAAI,EAAE,OAAO;aACd,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;KAAA;IAED,QAAQ;QACN,OAAO,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;YACxB,IAAI,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC;YAElD,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;gBACjC,SAAS,GAAG,CAAC,MAAM,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;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"]}
|
package/lib/application.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+CAAoD;AAGpD,2CAA4D;AAI5D,8CAAsB;AACtB,mCAAmC;AACnC,+BAAkC;AAClC,+CAA2C;AAC3C,yCAAuC;AACvC,qCAA4F;AAE5F,qDAAiE;AAgEjE,MAAa,WAA8D,SAAQ,aAAG;IAmBpF,YAAmB,OAA2B;QAC5C,KAAK,EAAE,CAAC;QADS,YAAO,GAAP,OAAO,CAAoB;QAJpC,YAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;QAO5C,IAAI,CAAC,GAAG,GAAG,IAAA,eAAS,GAAE,CAAC;QACvB,IAAI,CAAC,EAAE,GAAG,IAAA,uBAAc,EAAC,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,SAAS,GAAG,IAAA,wBAAe,EAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,CAAC,GAAG,GAAG,IAAA,oBAAS,EAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAA,mBAAU,EAAC,OAA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AC,CAAC;QACnD,CAAC;KAAA;IAEK,OAAO,CAAC,OAAa;;YACzB,MAAM,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YACrD,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzB,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;KAAA;IAEK,OAAO,CAAC,OAAwB;;YACpC,MAAM,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YAErD,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,EAAE;gBAClB,MAAM,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAA,kBAAS,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;aACzF;YAED,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC,CAAC;YAClC,MAAM,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC/B,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QACtD,CAAC;KAAA;CAGF;AAjLD,kCAiLC;AAED,IAAA,mBAAW,EAAC,WAAW,EAAE,CAAC,oBAAY,CAAC,CAAC,CAAC;AAEzC,kBAAe,WAAW,CAAC","sourcesContent":["import { ACL } from '@nocobase/acl';\nimport { registerActions } from '@nocobase/actions';\nimport Database, { CollectionOptions, IDatabaseOptions } from '@nocobase/database';\nimport Resourcer, { ResourceOptions } from '@nocobase/resourcer';\nimport { applyMixins, AsyncEmitter } from '@nocobase/utils';\nimport { Command, CommandOptions } from 'commander';\nimport { Server } from 'http';\nimport { i18n, InitOptions } from 'i18next';\nimport Koa from 'koa';\nimport { isBoolean } from 'lodash';\nimport { createACL } from './acl';\nimport { AppManager } from './app-manager';\nimport { createCli } from './commands';\nimport { createDatabase, createI18n, createResourcer, registerMiddlewares } from './helper';\nimport { Plugin } from './plugin';\nimport { InstallOptions, PluginManager } from './plugin-manager';\n\nexport type PluginConfiguration = string | [string, any];\nexport type PluginsConfigurations = Array<PluginConfiguration>;\n\nexport interface ResourcerOptions {\n prefix?: string;\n}\n\nexport interface ApplicationOptions {\n database?: IDatabaseOptions | Database;\n resourcer?: ResourcerOptions;\n bodyParser?: any;\n cors?: any;\n dataWrapping?: boolean;\n registerActions?: boolean;\n i18n?: i18n | InitOptions;\n plugins?: PluginsConfigurations;\n}\n\ninterface DefaultState {\n currentUser?: any;\n [key: string]: any;\n}\n\ninterface DefaultContext {\n db: Database;\n resourcer: Resourcer;\n [key: string]: any;\n}\n\ninterface MiddlewareOptions {\n name?: string;\n resourceName?: string;\n resourceNames?: string[];\n insertBefore?: string;\n insertAfter?: string;\n}\n\ninterface ActionsOptions {\n resourceName?: string;\n resourceNames?: string[];\n}\n\ninterface ListenOptions {\n port?: number | undefined;\n host?: string | undefined;\n backlog?: number | undefined;\n path?: string | undefined;\n exclusive?: boolean | undefined;\n readableAll?: boolean | undefined;\n writableAll?: boolean | undefined;\n /**\n * @default false\n */\n ipv6Only?: boolean | undefined;\n signal?: AbortSignal | undefined;\n}\n\ninterface StartOptions {\n cliArgs?: any[];\n listen?: ListenOptions;\n}\n\nexport class Application<StateT = DefaultState, ContextT = DefaultContext> extends Koa implements AsyncEmitter {\n public readonly db: Database;\n\n public readonly resourcer: Resourcer;\n\n public readonly cli: Command;\n\n public readonly i18n: i18n;\n\n public readonly pm: PluginManager;\n\n public readonly acl: ACL;\n\n public readonly appManager: AppManager;\n\n protected plugins = new Map<string, Plugin>();\n\n public listenServer: Server;\n\n constructor(public options: ApplicationOptions) {\n super();\n\n this.acl = createACL();\n this.db = createDatabase(options);\n this.resourcer = createResourcer(options);\n this.cli = createCli(this);\n this.i18n = createI18n(options);\n\n this.pm = new PluginManager({\n app: this,\n });\n\n this.appManager = new AppManager(this);\n\n registerMiddlewares(this, options);\n\n if (options.registerActions !== false) {\n registerActions(this);\n }\n\n this.loadPluginConfig(options.plugins || []);\n }\n\n plugin<O = any>(pluginClass: any, options?: O): Plugin<O> {\n return this.pm.add(pluginClass, options);\n }\n\n loadPluginConfig(pluginsConfigurations: PluginsConfigurations) {\n for (let pluginConfiguration of pluginsConfigurations) {\n if (typeof pluginConfiguration == 'string') {\n pluginConfiguration = [pluginConfiguration, {}];\n }\n\n const plugin = PluginManager.resolvePlugin(pluginConfiguration[0]);\n const pluginOptions = pluginConfiguration[1];\n\n this.plugin(plugin, pluginOptions);\n }\n }\n\n use<NewStateT = {}, NewContextT = {}>(\n middleware: Koa.Middleware<StateT & NewStateT, ContextT & NewContextT>,\n options?: MiddlewareOptions,\n ) {\n // @ts-ignore\n return super.use(middleware);\n }\n\n collection(options: CollectionOptions) {\n return this.db.collection(options);\n }\n\n resource(options: ResourceOptions) {\n return this.resourcer.define(options);\n }\n\n actions(handlers: any, options?: ActionsOptions) {\n return this.resourcer.registerActions(handlers);\n }\n\n command(name: string, desc?: string, opts?: CommandOptions): Command {\n return this.cli.command(name, desc, opts);\n }\n\n findCommand(name: string): Command {\n return (<any>this.cli)._findCommand(name);\n }\n\n async load() {\n await this.pm.load();\n }\n\n getPlugin<P extends Plugin>(name: string) {\n return this.pm.get(name) as P;\n }\n\n async parse(argv = process.argv) {\n await this.load();\n return this.cli.parseAsync(argv);\n }\n\n async start(options?: StartOptions) {\n // reconnect database\n if (this.db.closed()) {\n await this.db.reconnect();\n }\n\n await this.emitAsync('beforeStart', this, options);\n\n if (options?.listen?.port) {\n const listen = () =>\n new Promise((resolve) => {\n const Server = this.listen(options?.listen, () => {\n resolve(Server);\n });\n });\n\n // @ts-ignore\n this.listenServer = await listen();\n }\n\n await this.emitAsync('afterStart', this, options);\n }\n\n listen(...args): Server {\n return this.appManager.listen(...args);\n }\n\n async stop(options?: any) {\n await this.emitAsync('beforeStop', this, options);\n\n try {\n // close database connection\n // silent if database already closed\n await this.db.close();\n } catch (e) {\n console.log(e);\n }\n\n // close http server\n if (this.listenServer) {\n const closeServer = () =>\n new Promise((resolve, reject) => {\n this.listenServer.close((err) => {\n if (err) {\n return reject(err);\n }\n this.listenServer = null;\n resolve(true);\n });\n });\n\n await closeServer();\n }\n\n await this.emitAsync('afterStop', this, options);\n }\n\n async destroy(options?: any) {\n await this.emitAsync('beforeDestroy', this, options);\n await this.stop(options);\n await this.emitAsync('afterDestroy', this, options);\n }\n\n async install(options?: InstallOptions) {\n await this.emitAsync('beforeInstall', this, options);\n\n if (options?.clean) {\n await this.db.clean(isBoolean(options.clean) ? { drop: options.clean } : options.clean);\n }\n\n await this.db.sync(options?.sync);\n await this.pm.install(options);\n await this.emitAsync('afterInstall', this, options);\n }\n\n emitAsync: (event: string | symbol, ...args: any[]) => Promise<boolean>;\n}\n\napplyMixins(Application, [AsyncEmitter]);\n\nexport default Application;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/commands/console.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAE7B,kBAAe,CAAO,EAAE,GAAG,EAAE,EAAE,EAAE;IAC/B,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC;IAClB,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAE3D,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,UAAgB,GAAG;;YACjC,IAAI,GAAG,EAAE;gBACP,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;YAED,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;KAAA,CAAC,CAAC;AACL,CAAC,CAAA,CAAC","sourcesContent":["const REPL = require('repl');\n\nexport default async ({ app }) => {\n await app.start();\n const repl = (REPL.start('nocobase > ').context.app = app);\n\n repl.on('exit', async function (err) {\n if (err) {\n console.log(err);\n process.exit(1);\n }\n\n await app.stop();\n process.exit(0);\n });\n};\n"]}
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
const chalk = require('chalk');
|
|
13
|
-
const fse = require('fs-extra');
|
|
14
|
-
const { join } = require('path');
|
|
15
|
-
const createPackageJson = require('./resources/templates/package-json');
|
|
16
|
-
const createPluginClass = require('./resources/templates/plugin');
|
|
17
|
-
exports.default = (name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const pluginName = `plugin-${name}`;
|
|
19
|
-
const pluginPath = join(process.cwd(), `packages/${pluginName}`);
|
|
20
|
-
const resourcePath = join(__dirname, 'resources');
|
|
21
|
-
console.log(`Creating a new NocoBase plugin at ${chalk.green(pluginPath)}.`);
|
|
22
|
-
yield fse.copy(join(resourcePath, 'files'), pluginPath);
|
|
23
|
-
yield fse.outputFile(join(pluginPath, 'src/server/index.ts'), createPluginClass({ name }));
|
|
24
|
-
// write server package.json
|
|
25
|
-
yield fse.writeJson(join(pluginPath, 'package.json'), createPackageJson({
|
|
26
|
-
name: pluginName,
|
|
27
|
-
}), {
|
|
28
|
-
spaces: 2,
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=create-plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-plugin.js","sourceRoot":"","sources":["../../../src/commands/create-plugin/create-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAChC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACjC,MAAM,iBAAiB,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAC;AACxE,MAAM,iBAAiB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAElE,kBAAe,CAAO,IAAI,EAAE,EAAE;IAC5B,MAAM,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;IAEpC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,UAAU,EAAE,CAAC,CAAC;IACjE,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAElD,OAAO,CAAC,GAAG,CAAC,qCAAqC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC7E,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;IAExD,MAAM,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,qBAAqB,CAAC,EAAE,iBAAiB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAE3F,4BAA4B;IAC5B,MAAM,GAAG,CAAC,SAAS,CACjB,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,EAChC,iBAAiB,CAAC;QAChB,IAAI,EAAE,UAAU;KACjB,CAAC,EACF;QACE,MAAM,EAAE,CAAC;KACV,CACF,CAAC;AACJ,CAAC,CAAA,CAAC","sourcesContent":["const chalk = require('chalk');\nconst fse = require('fs-extra');\nconst { join } = require('path');\nconst createPackageJson = require('./resources/templates/package-json');\nconst createPluginClass = require('./resources/templates/plugin');\n\nexport default async (name) => {\n const pluginName = `plugin-${name}`;\n\n const pluginPath = join(process.cwd(), `packages/${pluginName}`);\n const resourcePath = join(__dirname, 'resources');\n\n console.log(`Creating a new NocoBase plugin at ${chalk.green(pluginPath)}.`);\n await fse.copy(join(resourcePath, 'files'), pluginPath);\n\n await fse.outputFile(join(pluginPath, 'src/server/index.ts'), createPluginClass({ name }));\n\n // write server package.json\n await fse.writeJson(\n join(pluginPath, 'package.json'),\n createPackageJson({\n name: pluginName,\n }),\n {\n spaces: 2,\n },\n );\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/create-plugin/index.ts"],"names":[],"mappings":";;AAAA,MAAM,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAChD,kBAAe,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACxB,YAAY,CAAC,IAAI,CAAC,CAAC;AACrB,CAAC,CAAC","sourcesContent":["const createPlugin = require('./create-plugin');\nexport default ({ app, cliArgs }) => {\n const name = cliArgs[0];\n createPlugin(name);\n};\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = ({ name }) => {
|
|
4
|
-
return {
|
|
5
|
-
name: name,
|
|
6
|
-
version: '0.1.0',
|
|
7
|
-
main: 'server.js',
|
|
8
|
-
dependencies: {
|
|
9
|
-
'@nocobase/server': '^0.6.0-alpha.0',
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=package-json.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-json.js","sourceRoot":"","sources":["../../../../../src/commands/create-plugin/resources/templates/package-json.ts"],"names":[],"mappings":";;AAAA,kBAAe,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC1B,OAAO;QACL,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,WAAW;QACjB,YAAY,EAAE;YACZ,kBAAkB,EAAE,gBAAgB;SACrC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["export default ({ name }) => {\n return {\n name: name,\n version: '0.1.0',\n main: 'server.js',\n dependencies: {\n '@nocobase/server': '^0.6.0-alpha.0',\n },\n };\n};\n"]}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const _ = __importStar(require("lodash"));
|
|
23
|
-
const fs = __importStar(require("fs"));
|
|
24
|
-
const path = __importStar(require("path"));
|
|
25
|
-
exports.default = ({ name }) => {
|
|
26
|
-
const tmpl = fs.readFileSync(path.join(__dirname, 'plugin-class.template'), { encoding: 'utf-8' });
|
|
27
|
-
const compile = _.template(tmpl);
|
|
28
|
-
return compile({
|
|
29
|
-
name,
|
|
30
|
-
className: _.startCase(_.camelCase(name)),
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../../src/commands/create-plugin/resources/templates/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4B;AAC5B,uCAAyB;AACzB,2CAA6B;AAE7B,kBAAe,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC1B,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,uBAAuB,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACnG,MAAM,OAAO,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEjC,OAAO,OAAO,CAAC;QACb,IAAI;QACJ,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import * as _ from 'lodash';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nexport default ({ name }) => {\n const tmpl = fs.readFileSync(path.join(__dirname, 'plugin-class.template'), { encoding: 'utf-8' });\n const compile = _.template(tmpl);\n\n return compile({\n name,\n className: _.startCase(_.camelCase(name)),\n });\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db-sync.js","sourceRoot":"","sources":["../../src/commands/db-sync.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,kBAAe,CAAO,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IACxC,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC1B,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CACf,IAAI,CAAC,KAAK;QACR,CAAC,CAAC;YACE,KAAK,EAAE,IAAI;YACX,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI;aACX;SACF;QACH,CAAC,CAAC,EAAE,CACP,CAAC;IACF,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 console.log('db sync...');\n await app.db.sync(\n opts.force\n ? {\n force: true,\n alter: {\n drop: true,\n },\n }\n : {},\n );\n await app.stop({\n cliArgs,\n });\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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"]}
|