mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-09-21 03:16:24 +00:00
chore: 升级依赖并适配 Vitest 5
This commit is contained in:
parent
489a1143b7
commit
77e9f86efb
1
.gitignore
vendored
1
.gitignore
vendored
@ -28,6 +28,7 @@ pnpm-debug.log*
|
||||
*.sw?
|
||||
|
||||
coverage
|
||||
.vitest
|
||||
|
||||
auto-imports.d.ts
|
||||
components.d.ts
|
||||
|
||||
@ -11,15 +11,15 @@
|
||||
"dependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@stylistic/eslint-plugin": "^5.10.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.66.0",
|
||||
"@typescript-eslint/parser": "^8.66.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.70.0",
|
||||
"@typescript-eslint/parser": "^8.70.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-prettier": "^5.5.6",
|
||||
"eslint-plugin-simple-import-sort": "^14.0.0",
|
||||
"eslint-plugin-vue": "^10.10.0",
|
||||
"globals": "^17.9.0",
|
||||
"typescript-eslint": "^8.66.0",
|
||||
"eslint-plugin-vue": "^10.11.0",
|
||||
"globals": "^17.12.0",
|
||||
"typescript-eslint": "^8.70.0",
|
||||
"vue-eslint-parser": "^10.4.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
42
package.json
42
package.json
@ -6,7 +6,7 @@
|
||||
"packageManager": "pnpm@11.21.0",
|
||||
"scripts": {
|
||||
"bootstrap": "pnpm i && pnpm build",
|
||||
"clean:top": "rimraf packages/*/dist packages/*/types runtime/*/dist runtime/*/types vue-components/*/dist vue-components/*/types react-components/*/dist react-components/*/types playground/dist coverage dwt* temp packages/cli/lib",
|
||||
"clean:top": "rimraf packages/*/dist packages/*/types runtime/*/dist runtime/*/types vue-components/*/dist vue-components/*/types react-components/*/dist react-components/*/types playground/dist coverage .vitest dwt* temp packages/cli/lib",
|
||||
"clean:modules": "rimraf node_modules **/node_modules **/**/node_modules",
|
||||
"clean:all": "pnpm clean:top && pnpm clean:modules",
|
||||
"lint": "eslint --cache .",
|
||||
@ -41,44 +41,44 @@
|
||||
"url": "https://github.com/Tencent/tmagic-editor.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^21.2.1",
|
||||
"@commitlint/config-conventional": "^21.2.0",
|
||||
"@commitlint/cli": "^21.2.3",
|
||||
"@commitlint/config-conventional": "^21.2.3",
|
||||
"@tmagic/eslint-config": "workspace:*",
|
||||
"@types/node": "26.1.2",
|
||||
"@vitejs/plugin-vue": "^6.0.8",
|
||||
"@vitest/coverage-v8": "^4.1.10",
|
||||
"@types/node": "26.6.2",
|
||||
"@vitejs/plugin-vue": "^6.0.9",
|
||||
"@vitest/coverage-v8": "^5.0.1",
|
||||
"@vue/compiler-sfc": "catalog:",
|
||||
"c8": "^12.0.0",
|
||||
"commitizen": "^4.3.2",
|
||||
"conventional-changelog-cli": "^5.0.0",
|
||||
"cosmiconfig": "^10.0.0",
|
||||
"cosmiconfig": "^10.0.1",
|
||||
"cz-conventional-changelog": "^3.3.0",
|
||||
"element-plus": "catalog:",
|
||||
"enquirer": "^2.4.1",
|
||||
"eslint": "^10.8.1",
|
||||
"eslint": "^10.11.0",
|
||||
"execa": "^10.0.1",
|
||||
"happy-dom": "^20.11.2",
|
||||
"highlight.js": "^11.11.1",
|
||||
"happy-dom": "^20.14.5",
|
||||
"highlight.js": "^11.12.0",
|
||||
"husky": "^9.1.7",
|
||||
"jsdom": "^30.0.1",
|
||||
"lint-staged": "^17.3.0",
|
||||
"jsdom": "^30.1.0",
|
||||
"lint-staged": "^17.5.1",
|
||||
"minimist": "^1.2.8",
|
||||
"picocolors": "^1.1.1",
|
||||
"prettier": "^3.9.6",
|
||||
"prettier": "^3.9.8",
|
||||
"recast": "^0.23.20",
|
||||
"rimraf": "^6.1.3",
|
||||
"rolldown": "^1.2.3",
|
||||
"rolldown-plugin-dts": "^0.28.1",
|
||||
"sass-embedded": "^1.100.0",
|
||||
"rolldown": "^1.2.9",
|
||||
"rolldown-plugin-dts": "^0.28.6",
|
||||
"sass-embedded": "^1.104.1",
|
||||
"semver": "^7.8.5",
|
||||
"serialize-javascript": "^7.1.0",
|
||||
"serialize-javascript": "^7.1.1",
|
||||
"shx": "^0.4.0",
|
||||
"typescript": "catalog:",
|
||||
"vite": "catalog:",
|
||||
"vitepress": "2.0.0-alpha.19",
|
||||
"vitest": "^4.1.10",
|
||||
"vue": "^3.5.41",
|
||||
"vue-tsc": "^3.3.9"
|
||||
"vitepress": "2.0.0-alpha.20",
|
||||
"vitest": "^5.0.1",
|
||||
"vue": "^3.5.43",
|
||||
"vue-tsc": "^3.3.11"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
|
||||
@ -37,8 +37,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/node": "^26.1.2",
|
||||
"rolldown": "^1.2.2",
|
||||
"rolldown-plugin-dts": "^0.28.0"
|
||||
"@types/node": "^26.6.2",
|
||||
"rolldown": "^1.2.9",
|
||||
"rolldown-plugin-dts": "^0.28.6"
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
"keycon": "^1.4.0",
|
||||
"lodash-es": "^4.18.1",
|
||||
"moveable": "^0.53.0",
|
||||
"serialize-javascript": "^7.0.7",
|
||||
"serialize-javascript": "^7.1.1",
|
||||
"sortablejs": "^1.15.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -74,7 +74,7 @@
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/serialize-javascript": "^5.0.4",
|
||||
"@types/sortablejs": "^1.15.9",
|
||||
"@vue/test-utils": "^2.4.11"
|
||||
"@vue/test-utils": "^2.5.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tmagic/core": "workspace:*",
|
||||
|
||||
@ -118,7 +118,7 @@ const emit = defineEmits<{
|
||||
change: [v: string[]];
|
||||
}>();
|
||||
|
||||
const modelValue = defineModel<string[] | any>('modelValue', { default: [] });
|
||||
const modelValue = defineModel<string[] | any>('modelValue', { default: () => [] });
|
||||
|
||||
const optionComponent = getDesignConfig('components')?.option;
|
||||
|
||||
|
||||
@ -90,21 +90,16 @@ vi.mock('@editor/utils/editor', () => ({
|
||||
getGuideLineFromCache: vi.fn(() => []),
|
||||
}));
|
||||
|
||||
const localStorageMock = {
|
||||
setItem: vi.fn(),
|
||||
removeItem: vi.fn(),
|
||||
getItem: vi.fn(),
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
StageCoreCtor.mockClear();
|
||||
Object.keys(stageInstance.handlers).forEach((k) => delete stageInstance.handlers[k]);
|
||||
vi.clearAllMocks();
|
||||
globalThis.localStorage = localStorageMock as any;
|
||||
vi.spyOn(globalThis.localStorage, 'setItem').mockImplementation(() => undefined);
|
||||
vi.spyOn(globalThis.localStorage, 'removeItem').mockImplementation(() => undefined);
|
||||
vi.spyOn(globalThis.localStorage, 'getItem').mockImplementation(() => null);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete (globalThis as any).localStorage;
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('useStage', () => {
|
||||
@ -262,14 +257,14 @@ describe('useStage', () => {
|
||||
test('change-guides 事件: 写入 localStorage', () => {
|
||||
useStage({} as any);
|
||||
stageInstance.handlers['change-guides'][0]({ type: 'h', guides: [10, 20] });
|
||||
expect(localStorageMock.setItem).toHaveBeenCalled();
|
||||
expect(globalThis.localStorage.setItem).toHaveBeenCalled();
|
||||
expect(uiService.set).toHaveBeenCalledWith('showGuides', true);
|
||||
});
|
||||
|
||||
test('change-guides 事件: 空 guides 删除 localStorage', () => {
|
||||
useStage({} as any);
|
||||
stageInstance.handlers['change-guides'][0]({ type: 'v', guides: [] });
|
||||
expect(localStorageMock.removeItem).toHaveBeenCalled();
|
||||
expect(globalThis.localStorage.removeItem).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('page-el-update 事件 重置 stageLoading', () => {
|
||||
|
||||
@ -340,12 +340,12 @@ describe('select', () => {
|
||||
expect(page?.id).toBe(NodeId.PAGE_ID);
|
||||
});
|
||||
|
||||
test('参数是id undefined', () => {
|
||||
expect(() => editorService.select(NodeId.ERROR_NODE_ID)).rejects.toThrowError('获取不到组件信息');
|
||||
test('参数是id undefined', async () => {
|
||||
await expect(editorService.select(NodeId.ERROR_NODE_ID)).rejects.toThrowError('获取不到组件信息');
|
||||
});
|
||||
|
||||
test('参数是config 没有id', () => {
|
||||
expect(() => editorService.select({ id: '', type: 'text' })).rejects.toThrowError('没有ID,无法选中');
|
||||
test('参数是config 没有id', async () => {
|
||||
await expect(editorService.select({ id: '', type: 'text' })).rejects.toThrowError('没有ID,无法选中');
|
||||
});
|
||||
});
|
||||
|
||||
@ -399,11 +399,11 @@ describe('add', () => {
|
||||
expect(rootNode?.items.length).toBe(2);
|
||||
});
|
||||
|
||||
test('往root下添加普通节点', () => {
|
||||
test('往root下添加普通节点', async () => {
|
||||
editorService.set('root', cloneDeep(root));
|
||||
// 根节点下只能加页面
|
||||
const rootNode = editorService.get('root');
|
||||
expect(() =>
|
||||
await expect(
|
||||
editorService.add(
|
||||
{
|
||||
type: 'text',
|
||||
@ -556,7 +556,7 @@ describe('remove', () => {
|
||||
});
|
||||
|
||||
test('undefine', async () => {
|
||||
expect(() => editorService.remove({ id: NodeId.ERROR_NODE_ID, type: 'text' })).rejects.toThrow();
|
||||
await expect(editorService.remove({ id: NodeId.ERROR_NODE_ID, type: 'text' })).rejects.toThrow();
|
||||
});
|
||||
|
||||
test('doNotSelect: true 不更新选中节点', async () => {
|
||||
|
||||
@ -46,14 +46,14 @@
|
||||
"@element-plus/icons-vue": "^2.3.2",
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"async-validator": "^4.2.5",
|
||||
"dayjs": "^1.11.21",
|
||||
"dayjs": "^1.11.23",
|
||||
"lodash-es": "^4.18.1",
|
||||
"sortablejs": "^1.15.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/sortablejs": "^1.15.9",
|
||||
"@vue/test-utils": "^2.4.11"
|
||||
"@vue/test-utils": "^2.5.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tmagic/design": "workspace:*",
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@vue/test-utils": "^2.4.11"
|
||||
"@vue/test-utils": "^2.5.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tmagic/design": "workspace:*",
|
||||
|
||||
@ -17,21 +17,21 @@
|
||||
"@tmagic/editor": "1.8.0-beta.28",
|
||||
"@tmagic/element-plus-adapter": "1.8.0-beta.28",
|
||||
"@tmagic/tdesign-vue-next-adapter": "1.8.0-beta.28",
|
||||
"@tmagic/tmagic-form-runtime": "1.1.6",
|
||||
"@tmagic/tmagic-form-runtime": "1.1.8",
|
||||
"element-plus": "catalog:",
|
||||
"lodash-es": "^4.18.1",
|
||||
"monaco-editor": "^0.56.0",
|
||||
"serialize-javascript": "^7.1.0",
|
||||
"tdesign-vue-next": "^1.20.5",
|
||||
"serialize-javascript": "^7.1.1",
|
||||
"tdesign-vue-next": "^1.20.8",
|
||||
"vue": "catalog:",
|
||||
"vue-router": "^5.2.0"
|
||||
"vue-router": "^5.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^26.1.2",
|
||||
"@types/node": "^26.6.2",
|
||||
"@types/serialize-javascript": "^5.0.4",
|
||||
"@vitejs/plugin-legacy": "^8.2.3",
|
||||
"@vitejs/plugin-vue": "^6.0.8",
|
||||
"@vitejs/plugin-vue": "^6.0.9",
|
||||
"@vitejs/plugin-vue-jsx": "^5.1.6",
|
||||
"@vue/compiler-sfc": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
|
||||
3200
pnpm-lock.yaml
generated
3200
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -18,12 +18,12 @@ allowBuilds:
|
||||
esbuild: true
|
||||
|
||||
catalog:
|
||||
"@vue/compiler-sfc": ^3.5.41
|
||||
"@vue/compiler-sfc": ^3.5.43
|
||||
typescript: "^6.0.3"
|
||||
vite: ^8.2.1
|
||||
vue: ^3.5.41
|
||||
element-plus: ^2.14.4
|
||||
vite: ^8.3.0
|
||||
vue: ^3.5.43
|
||||
element-plus: ^2.14.6
|
||||
|
||||
overrides:
|
||||
element-plus: ^2.14.4
|
||||
vue: ^3.5.41
|
||||
element-plus: ^2.14.6
|
||||
vue: ^3.5.43
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4"
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4"
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4"
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4"
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4"
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4"
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4"
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4"
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4"
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4"
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,6 +49,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/react": "^19.2.18"
|
||||
"@types/react": "^19.3.0"
|
||||
}
|
||||
}
|
||||
@ -19,17 +19,17 @@
|
||||
"@tmagic/core": "1.8.0-beta.28",
|
||||
"@tmagic/react-runtime-help": "0.2.2",
|
||||
"@tmagic/stage": "1.8.0-beta.28",
|
||||
"axios": "^1.19.0",
|
||||
"axios": "^1.20.0",
|
||||
"qrcode": "^1.5.4",
|
||||
"react": "^19.2.8",
|
||||
"react-dom": "^19.2.8"
|
||||
"react": "^19.3.0",
|
||||
"react-dom": "^19.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tmagic/cli": "1.8.0-beta.28",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/react": "^19.2.18",
|
||||
"@types/react-dom": "^19.2.4",
|
||||
"@vitejs/plugin-legacy": "^8.2.2",
|
||||
"@types/react": "^19.3.0",
|
||||
"@types/react-dom": "^19.3.0",
|
||||
"@vitejs/plugin-legacy": "^8.2.3",
|
||||
"@vitejs/plugin-react-refresh": "^1.3.6",
|
||||
"fs-extra": "^11.4.0",
|
||||
"typescript": "catalog:",
|
||||
|
||||
@ -44,6 +44,6 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/test-utils": "^2.4.11"
|
||||
"@vue/test-utils": "^2.5.1"
|
||||
}
|
||||
}
|
||||
@ -19,15 +19,15 @@
|
||||
"@tmagic/core": "1.8.0-beta.28",
|
||||
"@tmagic/stage": "1.8.0-beta.28",
|
||||
"@tmagic/vue-runtime-help": "^2.0.4",
|
||||
"axios": "^1.19.0",
|
||||
"axios": "^1.20.0",
|
||||
"vue": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tmagic/cli": "1.8.0-beta.28",
|
||||
"@tmagic/cli": "workspace:*",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/node": "^26.1.2",
|
||||
"@vitejs/plugin-legacy": "^8.2.2",
|
||||
"@vitejs/plugin-vue": "^6.0.8",
|
||||
"@types/node": "^26.6.2",
|
||||
"@vitejs/plugin-legacy": "^8.2.3",
|
||||
"@vitejs/plugin-vue": "^6.0.9",
|
||||
"@vitejs/plugin-vue-jsx": "^5.1.6",
|
||||
"@vue/compiler-sfc": "catalog:",
|
||||
"fs-extra": "^11.4.0",
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { resolve } from 'path';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import { defineConfig } from 'vitest/config';
|
||||
import Vue from '@vitejs/plugin-vue';
|
||||
|
||||
const r = (p: string) => resolve(__dirname, p);
|
||||
const r = (p: string) => resolve(import.meta.dirname, p);
|
||||
|
||||
const alias = {
|
||||
'@editor': r('./packages/editor/src'),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user