Skip to content

Commit 19eb917

Browse files
liujupingJackLian
authored andcommitted
refactor(plugin-command): add plugin-command package
1 parent 501ad87 commit 19eb917

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed

packages/engine/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@alilc/lowcode-shell": "1.3.1",
2929
"@alilc/lowcode-utils": "1.3.1",
3030
"@alilc/lowcode-workspace": "1.3.1",
31+
"@alilc/lowcode-plugin-command": "1.3.1",
3132
"react": "^16.8.1",
3233
"react-dom": "^16.8.1"
3334
},

packages/engine/src/engine-core.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ import { defaultPanelRegistry } from './inner-plugins/default-panel-registry';
6666
import { shellModelFactory } from './modules/shell-model-factory';
6767
import { builtinHotkey } from './inner-plugins/builtin-hotkey';
6868
import { defaultContextMenu } from './inner-plugins/default-context-menu';
69-
import { defaultCommand } from '@alilc/lowcode-plugin-command';
69+
import { CommandPlugin } from '@alilc/lowcode-plugin-command';
7070
import { OutlinePlugin } from '@alilc/lowcode-plugin-outline-pane';
7171

7272
export * from './modules/skeleton-types';
@@ -84,7 +84,7 @@ async function registryInnerPlugin(designer: IDesigner, editor: IEditor, plugins
8484
await plugins.register(builtinHotkey);
8585
await plugins.register(registerDefaults, {}, { autoInit: true });
8686
await plugins.register(defaultContextMenu);
87-
await plugins.register(defaultCommand, {});
87+
await plugins.register(CommandPlugin, {});
8888

8989
return () => {
9090
plugins.delete(OutlinePlugin.pluginName);
@@ -94,7 +94,7 @@ async function registryInnerPlugin(designer: IDesigner, editor: IEditor, plugins
9494
plugins.delete(builtinHotkey.pluginName);
9595
plugins.delete(registerDefaults.pluginName);
9696
plugins.delete(defaultContextMenu.pluginName);
97-
plugins.delete(defaultCommand.pluginName);
97+
plugins.delete(CommandPlugin.pluginName);
9898
};
9999
}
100100

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const fs = require('fs');
2+
const { join } = require('path');
3+
const esModules = [].join('|');
4+
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));
5+
6+
const jestConfig = {
7+
transformIgnorePatterns: [
8+
`/node_modules/(?!${esModules})/`,
9+
],
10+
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
11+
collectCoverage: true,
12+
collectCoverageFrom: [
13+
'src/**/*.ts',
14+
'src/**/*.tsx',
15+
],
16+
};
17+
18+
// 只对本仓库内的 pkg 做 mapping
19+
jestConfig.moduleNameMapper = {};
20+
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';
21+
22+
module.exports = jestConfig;

packages/plugin-command/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
"author": "liujuping <[email protected]>",
66
"homepage": "https://github.com/alibaba/lowcode-engine#readme",
77
"license": "ISC",
8-
"main": "lib/plugin-command.js",
8+
"main": "lib/index.js",
9+
"module": "es/index.js",
910
"directories": {
1011
"lib": "lib",
1112
"test": "__tests__"
1213
},
1314
"files": [
14-
"lib"
15+
"lib",
16+
"es"
1517
],
1618
"publishConfig": {
1719
"access": "public"
@@ -30,5 +32,8 @@
3032
"dependencies": {
3133
"@alilc/lowcode-types": "^1.3.1",
3234
"@alilc/lowcode-utils": "^1.3.1"
35+
},
36+
"devDependencies": {
37+
"@alib/build-scripts": "^0.1.18"
3338
}
3439
}

packages/plugin-command/src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { IPublicModelPluginContext, IPublicTypePlugin } from '@alilc/lowcode-typ
22
import { nodeCommand } from './node-command';
33
import { historyCommand } from './history-command';
44

5-
export const defaultCommand: IPublicTypePlugin = (ctx: IPublicModelPluginContext) => {
5+
export const CommandPlugin: IPublicTypePlugin = (ctx: IPublicModelPluginContext) => {
66
const { plugins } = ctx;
77

88
return {
@@ -17,7 +17,9 @@ export const defaultCommand: IPublicTypePlugin = (ctx: IPublicModelPluginContext
1717
};
1818
};
1919

20-
defaultCommand.pluginName = '___default_command___';
21-
defaultCommand.meta = {
20+
CommandPlugin.pluginName = '___default_command___';
21+
CommandPlugin.meta = {
2222
commandScope: 'common',
2323
};
24+
25+
export default CommandPlugin;

0 commit comments

Comments
 (0)