提交 40525e6f 编写于 作者: chitanda's avatar chitanda

feat: 输出布局JSON文件

上级 602cd140
......@@ -13,4 +13,7 @@
*.log
.DS_Store
temp-pub
./src/*
\ No newline at end of file
./src/*
out
layout-out
\ No newline at end of file
{
"name": "output-layout-panel-dsl",
"version": "1.0.0",
"type": "module",
"main": "index.js",
"scripts": {
"dev": "tsc --watch",
"build": "node ./build.js"
},
"author": "",
"license": "MIT",
"dependencies": {
"@ibiz/model-core": "^0.0.6",
"@ibiz/rt-model-api": "^0.0.1-beta.10"
},
"devDependencies": {
"@types/fs-extra": "^11.0.1",
"fs-extra": "^11.1.1",
"ts-node": "^10.9.1"
}
}
lockfileVersion: '6.0'
dependencies:
'@ibiz/model-core':
specifier: ^0.0.6
version: 0.0.6
'@ibiz/rt-model-api':
specifier: ^0.0.1-beta.10
version: 0.0.1-beta.10
devDependencies:
'@types/fs-extra':
specifier: ^11.0.1
version: 11.0.1
fs-extra:
specifier: ^11.1.1
version: 11.1.1
ts-node:
specifier: ^10.9.1
version: 10.9.1(@types/node@18.16.1)(typescript@5.0.4)
packages:
/@cspotcode/source-map-support@0.8.1:
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
engines: {node: '>=12'}
dependencies:
'@jridgewell/trace-mapping': 0.3.9
dev: true
/@ibiz/model-core@0.0.6:
resolution: {integrity: sha512-coLoWZ8CcROS1iUSdNnsw//Y/296vMpy5z3BnBFo7DwBgfS2WW0NmJPJyePUtCEZim6zH2+5RZxkv2GgdTXTjQ==}
dev: false
/@ibiz/rt-model-api@0.0.1-beta.10:
resolution: {integrity: sha512-hHOBlmfgOk0fzbGA0DGoaRn3KCk9zjV6sZ2tKMBxjJDYmf9wQPqcM/h4ScLVtJvDDZgqryHhu4eX0qEhxYIt6w==}
dev: false
/@jridgewell/resolve-uri@3.1.1:
resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==}
engines: {node: '>=6.0.0'}
dev: true
/@jridgewell/sourcemap-codec@1.4.15:
resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
dev: true
/@jridgewell/trace-mapping@0.3.9:
resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==}
dependencies:
'@jridgewell/resolve-uri': 3.1.1
'@jridgewell/sourcemap-codec': 1.4.15
dev: true
/@tsconfig/node10@1.0.9:
resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==}
dev: true
/@tsconfig/node12@1.0.11:
resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==}
dev: true
/@tsconfig/node14@1.0.3:
resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==}
dev: true
/@tsconfig/node16@1.0.3:
resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==}
dev: true
/@types/fs-extra@11.0.1:
resolution: {integrity: sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==}
dependencies:
'@types/jsonfile': 6.1.1
'@types/node': 18.16.1
dev: true
/@types/jsonfile@6.1.1:
resolution: {integrity: sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png==}
dependencies:
'@types/node': 18.16.1
dev: true
/@types/node@18.16.1:
resolution: {integrity: sha512-DZxSZWXxFfOlx7k7Rv4LAyiMroaxa3Ly/7OOzZO8cBNho0YzAi4qlbrx8W27JGqG57IgR/6J7r+nOJWw6kcvZA==}
dev: true
/acorn-walk@8.2.0:
resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==}
engines: {node: '>=0.4.0'}
dev: true
/acorn@8.8.2:
resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==}
engines: {node: '>=0.4.0'}
hasBin: true
dev: true
/arg@4.1.3:
resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==}
dev: true
/create-require@1.1.1:
resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}
dev: true
/diff@4.0.2:
resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==}
engines: {node: '>=0.3.1'}
dev: true
/fs-extra@11.1.1:
resolution: {integrity: sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==}
engines: {node: '>=14.14'}
dependencies:
graceful-fs: 4.2.11
jsonfile: 6.1.0
universalify: 2.0.0
dev: true
/graceful-fs@4.2.11:
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
dev: true
/jsonfile@6.1.0:
resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==}
dependencies:
universalify: 2.0.0
optionalDependencies:
graceful-fs: 4.2.11
dev: true
/make-error@1.3.6:
resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==}
dev: true
/ts-node@10.9.1(@types/node@18.16.1)(typescript@5.0.4):
resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==}
hasBin: true
peerDependencies:
'@swc/core': '>=1.2.50'
'@swc/wasm': '>=1.2.50'
'@types/node': '*'
typescript: '>=2.7'
peerDependenciesMeta:
'@swc/core':
optional: true
'@swc/wasm':
optional: true
dependencies:
'@cspotcode/source-map-support': 0.8.1
'@tsconfig/node10': 1.0.9
'@tsconfig/node12': 1.0.11
'@tsconfig/node14': 1.0.3
'@tsconfig/node16': 1.0.3
'@types/node': 18.16.1
acorn: 8.8.2
acorn-walk: 8.2.0
arg: 4.1.3
create-require: 1.1.1
diff: 4.0.2
make-error: 1.3.6
typescript: 5.0.4
v8-compile-cache-lib: 3.0.1
yn: 3.1.1
dev: true
/typescript@5.0.4:
resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==}
engines: {node: '>=12.20'}
hasBin: true
dev: true
/universalify@2.0.0:
resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==}
engines: {node: '>= 10.0.0'}
dev: true
/v8-compile-cache-lib@3.0.1:
resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==}
dev: true
/yn@3.1.1:
resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==}
engines: {node: '>=6'}
dev: true
import { DSLHelper } from '@ibiz/rt-model-api';
import { IAppView } from '@ibiz/model-core';
import fs from 'fs-extra';
import path from 'path';
// 当前所有的
const layoutViews = ['ViewLayoutModelRepositoryGridViewLayout'];
// 输出目录
const output = path.resolve(process.cwd(), 'layout-out');
// 模型目录
const basePath = '/root/workspace/train/TrainSys/trainsys-core/src/main/resources/model/cn/ibizlab/trainsys';
// 应用目录
const appPath = 'PSSYSAPPS/Web';
// dsl 转换器
const helper = new DSLHelper();
// 根据模型路径读取模型
async function getModel(pathStr: string): Promise<IModel> {
return new Promise(resolve => {
pathStr = pathStr.replace(appPath, '');
fs.readFile(path.join(basePath, appPath, pathStr), 'utf-8').then((data: string) => {
resolve(JSON.parse(data));
});
});
}
// 输出目录不存在则创建
if (fs.existsSync(output) === false) {
fs.mkdirSync(output);
}
// 输出 json 文件
function writeJsonFile(view: IAppView) {
fs.writeFileSync(path.resolve(output, `${view.codeName}.json`), JSON.stringify(view.viewLayoutPanel, null ,2));
}
async function main(): Promise<void> {
const app = await getModel('PSSYSAPP.json');
const viewModels: IModel[] = app.getAllPSAppViews || [];
const views = await Promise.all(viewModels.map(ref => getModel(ref.path)));
const dslViews = helper.appViews(views.filter(item => {
return item.getPSViewLayoutPanel.useDefaultLayout !== true && layoutViews.includes(item.codeName);
})) as IAppView[];
dslViews.forEach(item => {
writeJsonFile(item);
});
}
main();
\ No newline at end of file
此差异已折叠。
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册