From 94dd25f55a24e806ea937aa2b54c73761c40fdfb Mon Sep 17 00:00:00 2001 From: liujuping Date: Thu, 1 Feb 2024 15:47:26 +0800 Subject: [PATCH] refactor(plugin-command): add plugin-command package --- packages/engine/package.json | 1 + packages/engine/src/engine-core.ts | 6 +++--- packages/plugin-command/jest.config.js | 27 ++++++++++++++++++++++++++ packages/plugin-command/package.json | 9 +++++++-- packages/plugin-command/src/index.ts | 8 +++++--- 5 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 packages/plugin-command/jest.config.js diff --git a/packages/engine/package.json b/packages/engine/package.json index 4b622eaa4..fb2b42fd0 100644 --- a/packages/engine/package.json +++ b/packages/engine/package.json @@ -28,6 +28,7 @@ "@alilc/lowcode-shell": "1.3.1", "@alilc/lowcode-utils": "1.3.1", "@alilc/lowcode-workspace": "1.3.1", + "@alilc/lowcode-plugin-command": "1.3.1", "react": "^16.8.1", "react-dom": "^16.8.1" }, diff --git a/packages/engine/src/engine-core.ts b/packages/engine/src/engine-core.ts index 5a2cbbc65..4dffa628b 100644 --- a/packages/engine/src/engine-core.ts +++ b/packages/engine/src/engine-core.ts @@ -66,7 +66,7 @@ import { defaultPanelRegistry } from './inner-plugins/default-panel-registry'; import { shellModelFactory } from './modules/shell-model-factory'; import { builtinHotkey } from './inner-plugins/builtin-hotkey'; import { defaultContextMenu } from './inner-plugins/default-context-menu'; -import { defaultCommand } from '@alilc/lowcode-plugin-command'; +import { CommandPlugin } from '@alilc/lowcode-plugin-command'; import { OutlinePlugin } from '@alilc/lowcode-plugin-outline-pane'; export * from './modules/skeleton-types'; @@ -84,7 +84,7 @@ async function registryInnerPlugin(designer: IDesigner, editor: IEditor, plugins await plugins.register(builtinHotkey); await plugins.register(registerDefaults, {}, { autoInit: true }); await plugins.register(defaultContextMenu); - await plugins.register(defaultCommand, {}); + await plugins.register(CommandPlugin, {}); return () => { plugins.delete(OutlinePlugin.pluginName); @@ -94,7 +94,7 @@ async function registryInnerPlugin(designer: IDesigner, editor: IEditor, plugins plugins.delete(builtinHotkey.pluginName); plugins.delete(registerDefaults.pluginName); plugins.delete(defaultContextMenu.pluginName); - plugins.delete(defaultCommand.pluginName); + plugins.delete(CommandPlugin.pluginName); }; } diff --git a/packages/plugin-command/jest.config.js b/packages/plugin-command/jest.config.js new file mode 100644 index 000000000..31a6eab6e --- /dev/null +++ b/packages/plugin-command/jest.config.js @@ -0,0 +1,27 @@ +const esModules = [ + '@recore/obx-react', + // '@ali/lowcode-editor-core', +].join('|'); + +module.exports = { + // transform: { + // '^.+\\.[jt]sx?$': 'babel-jest', + // // '^.+\\.(ts|tsx)$': 'ts-jest', + // // '^.+\\.(js|jsx)$': 'babel-jest', + // }, + // testMatch: ['(/tests?/.*(test))\\.[jt]s$'], + transformIgnorePatterns: [ + `/node_modules/(?!${esModules})/`, + ], + moduleFileExtensions: ['ts', 'tsx', 'js', 'json'], + collectCoverage: false, + collectCoverageFrom: [ + 'src/**/*.{ts,tsx}', + '!src/**/*.d.ts', + '!src/base/**', + '!src/fields/**', + '!src/prop.ts', + '!**/node_modules/**', + '!**/vendor/**', + ], +}; diff --git a/packages/plugin-command/package.json b/packages/plugin-command/package.json index 3c84e265e..5cdd99660 100644 --- a/packages/plugin-command/package.json +++ b/packages/plugin-command/package.json @@ -5,13 +5,15 @@ "author": "liujuping ", "homepage": "https://github.com/alibaba/lowcode-engine#readme", "license": "ISC", - "main": "lib/plugin-command.js", + "main": "lib/index.js", + "module": "es/index.js", "directories": { "lib": "lib", "test": "__tests__" }, "files": [ - "lib" + "lib", + "es" ], "publishConfig": { "access": "public" @@ -30,5 +32,8 @@ "dependencies": { "@alilc/lowcode-types": "^1.3.1", "@alilc/lowcode-utils": "^1.3.1" + }, + "devDependencies": { + "@alib/build-scripts": "^0.1.18" } } diff --git a/packages/plugin-command/src/index.ts b/packages/plugin-command/src/index.ts index 8e5d64ebc..fa6f32b32 100644 --- a/packages/plugin-command/src/index.ts +++ b/packages/plugin-command/src/index.ts @@ -2,7 +2,7 @@ import { IPublicModelPluginContext, IPublicTypePlugin } from '@alilc/lowcode-typ import { nodeCommand } from './node-command'; import { historyCommand } from './history-command'; -export const defaultCommand: IPublicTypePlugin = (ctx: IPublicModelPluginContext) => { +export const CommandPlugin: IPublicTypePlugin = (ctx: IPublicModelPluginContext) => { const { plugins } = ctx; return { @@ -17,7 +17,9 @@ export const defaultCommand: IPublicTypePlugin = (ctx: IPublicModelPluginContext }; }; -defaultCommand.pluginName = '___default_command___'; -defaultCommand.meta = { +CommandPlugin.pluginName = '___default_command___'; +CommandPlugin.meta = { commandScope: 'common', }; + +export default CommandPlugin; \ No newline at end of file