rtsa-client/scripts/proto.cjs

92 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

2024-09-13 08:50:08 +08:00
/**
* 将proto文件编译到 src/proto/
*/
const { readdirSync } = require('fs');
const { resolve } = require('path');
const os = require('os');
const { exec } = require('child_process');
Squashed commit of the following: commit a4e63a4ab6976f8e7decf6630aec7a934a27c916 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Mon Nov 18 17:07:07 2024 +0800 电子地图管理 commit 2544f5e131d79a99b83e366de142646477c6c67a Author: joylink_fanyuhong <18706759286@163.com> Date: Thu Nov 14 14:23:30 2024 +0800 代码调整 commit 5400acf7e3f249d8d39644701dc7d872de488cde Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Wed Nov 13 17:59:00 2024 +0800 电子地图绘制备用 commit c06acfd0b8b283d25d6f9fd4a9a5836a020d1381 Merge: 3c41293 fdca6c4 Author: joylink_fanyuhong <18706759286@163.com> Date: Tue Nov 12 13:41:21 2024 +0800 Merge branch 'develop' of https://gitea.joylink.club/joylink/rtsa-client into develop commit 3c41293f0b91fc4e62cdbb11b1e9a227b2d3b772 Author: joylink_fanyuhong <18706759286@163.com> Date: Tue Nov 12 13:41:17 2024 +0800 获取用户id调整 commit fdca6c490ba0ba178e5b24a7a1c479e115067b4c Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Tue Nov 12 13:18:57 2024 +0800 密码去掉加盐 commit b429bf5ce34fd7e1966a54e18b6a79e9c29bbd68 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Tue Nov 12 10:51:32 2024 +0800 登录注册备用 commit 1d2c1c337ef3f3fc2b6db8e4c9e625074fe0ec57 Author: joylink_fanyuhong <18706759286@163.com> Date: Mon Nov 11 17:56:21 2024 +0800 代码调整 commit dee2b5ca7f2072a2a12790fb7b8c13e14dee3b88 Author: joylink_fanyuhong <18706759286@163.com> Date: Mon Nov 11 17:30:55 2024 +0800 烟感设备调整 commit f4812c7187e8dc68d38f5c116e9eebb7cb854ba7 Author: joylink_fanyuhong <18706759286@163.com> Date: Fri Nov 8 09:52:43 2024 +0800 代码提交 commit 23ed471da1b75b847cf93e3b3295d6d70f3ce84d Author: joylink_fanyuhong <18706759286@163.com> Date: Thu Nov 7 17:30:32 2024 +0800 代码暂提 commit 429d6679f42cfd4c77fa4de15cf25baa8d0c744a Author: joylink_fanyuhong <18706759286@163.com> Date: Wed Nov 6 21:12:19 2024 +0800 问题调整 commit 28859d0fc1f0637139a9066dd1c8e6bfa5c9fe96 Merge: cffefa0 f76ec13 Author: joylink_fanyuhong <18706759286@163.com> Date: Wed Nov 6 20:59:49 2024 +0800 Merge branch 'develop' of https://gitea.joylink.club/joylink/rtsa-client into develop commit cffefa06c639b467dd08259bf8fbb0512df79268 Author: joylink_fanyuhong <18706759286@163.com> Date: Wed Nov 6 20:59:43 2024 +0800 代码暂提 commit f76ec139406c738efb0f9d005fe2146d9761037c Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Wed Nov 6 16:54:44 2024 +0800 模式控制暂提 commit d353afa5dd253173cd3506c257eb099a34bde4fd Author: joylink_fanyuhong <18706759286@163.com> Date: Tue Nov 5 18:05:09 2024 +0800 代码暂提 commit 9e5905cb55543b58b12feb06afe62950c5a87a88 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Thu Oct 31 16:58:01 2024 +0800 更新子模块 commit cac4f38d64c4d92c144f89109f6959822cbd2fdc Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Thu Oct 31 16:53:45 2024 +0800 删除旧的子模块 commit a36b425b120b84b90ee459061e25a0310f771b4b Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Wed Oct 30 10:15:47 2024 +0800 调整 commit 8260753cf7bb13cefe7db9e51d8f2d94be9d6c93 Merge: 3f240a7 9e0bc3e Author: joylink_fanyuhong <18706759286@163.com> Date: Tue Oct 29 13:29:38 2024 +0800 Merge branch 'develop' of https://gitea.joylink.club/joylink/rtss-simulation-app-client into develop commit 3f240a7b573fda5ec3fbb0a87394adefa1bfbf41 Author: joylink_fanyuhong <18706759286@163.com> Date: Tue Oct 29 13:29:36 2024 +0800 代码提交 commit 9e0bc3ea0bb15380a57d2a71600a62544fc0c461 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Mon Oct 28 16:53:12 2024 +0800 屏蔽门系统图 commit 3c67d4b5b73371f901989c71b4435cabfd403f16 Merge: f5d87ac eb9d073 Author: joylink_fanyuhong <18706759286@163.com> Date: Thu Oct 24 09:30:11 2024 +0800 Merge branch 'develop' of https://gitea.joylink.club/joylink/rtss-simulation-app-client into develop commit f5d87acd4cecf378d160bac3581f3be7907f7d1e Author: joylink_fanyuhong <18706759286@163.com> Date: Thu Oct 24 09:29:44 2024 +0800 fas设备添加 commit eb9d0734ae3f1caedab9dca58c6a45d7365ff232 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Wed Oct 23 15:51:18 2024 +0800 垂直电梯备用 commit afd27d4b3ebcc3943c0a53f073a062e2ac80ab05 Author: joylink_fanyuhong <18706759286@163.com> Date: Tue Oct 22 17:52:37 2024 +0800 消防泵代码提交 commit 61911d9ee5931308e44b40ab582dbc58d397dee0 Merge: 98b1db6 a7968d1 Author: joylink_fanyuhong <18706759286@163.com> Date: Tue Oct 22 17:20:47 2024 +0800 Merge branch 'develop' of https://gitea.joylink.club/joylink/rtss-simulation-app-client into develop commit 98b1db62901cc0914467b4cfd936d8b984f0b02c Author: joylink_fanyuhong <18706759286@163.com> Date: Tue Oct 22 17:16:24 2024 +0800 设备添加 commit a7968d11da28f3dc5406d6efc5bc8f488f7eed28 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Mon Oct 21 18:03:30 2024 +0800 bas自动扶梯备用 commit d16bedfbf47cfeffdafddb0dcf3b4205a0120044 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Fri Oct 18 16:21:27 2024 +0800 绘制组件调整 commit 124c9a27842919ddaf1cebb4472fc3f7671b82c7 Merge: b451f4f 07b35b5 Author: joylink_fanyuhong <18706759286@163.com> Date: Thu Oct 17 17:52:03 2024 +0800 Merge branch 'develop' of https://gitea.joylink.club/joylink/rtss-simulation-app-client into develop commit b451f4fa3e9b0f8cf8fe59771587dc2b4cf0578e Author: joylink_fanyuhong <18706759286@163.com> Date: Thu Oct 17 17:52:02 2024 +0800 FAS新增设备 commit 07b35b5360c41b2abebdf3423e48d13074694683 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Thu Oct 17 14:50:52 2024 +0800 cctv加分层 commit d03f30d4cca892dd8a337205a99a243e713c0070 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Thu Oct 17 13:50:52 2024 +0800 CCTV设备布局图 commit 31d09306b4fc7c064e4cb72076da04a77c64bfb6 Author: joylink_fanyuhong <18706759286@163.com> Date: Thu Oct 17 11:45:40 2024 +0800 调整icon commit cfc5adb9531d2d4c5f9ec7b65299b6d1a503b898 Author: joylink_fanyuhong <18706759286@163.com> Date: Thu Oct 17 11:45:18 2024 +0800 调整警铃icon commit 083c17edd1be8cd34dd251f270ea62d83dc245e2 Author: joylink_fanyuhong <18706759286@163.com> Date: Thu Oct 17 11:31:38 2024 +0800 添加火灾警铃设备 commit dbed83df26413f90cc803bdcfdc4e499da50018f Merge: 5bddef1 259d351 Author: joylink_fanyuhong <18706759286@163.com> Date: Thu Oct 17 09:34:31 2024 +0800 Merge branch 'develop' of https://gitea.joylink.club/joylink/rtss-simulation-app-client into develop commit 5bddef10cd980427841c05fac7ac539790b3d21f Author: joylink_fanyuhong <18706759286@163.com> Date: Thu Oct 17 09:32:55 2024 +0800 添加火灾报警主机 commit 259d3518bb59a667292b2c6bd14560f6ce883ec0 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Wed Oct 16 17:25:10 2024 +0800 增加button label颜色 commit 3c91608189184de8dd0774290b763d52bfc73e57 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Wed Oct 16 17:09:36 2024 +0800 通用的button-类似组件button commit f5bc7c9aa9776d06e92e1974bb61ec2c07aca5e4 Author: fan <fanyuhong@joylink.club> Date: Wed Oct 16 16:55:57 2024 +0800 protoc commit 7ab75c722e3a49a608599b5705fd78f0be05c54d Author: fan <fanyuhong@joylink.club> Date: Wed Oct 16 16:54:53 2024 +0800 fas数据调整 commit d8c55a011b097fedcc83b009cdb095a17788cd78 Author: joylink_fanyuhong <18706759286@163.com> Date: Wed Oct 16 14:01:58 2024 +0800 添加FAS平面图分区 commit 9948e87fa078a3a430430c2f24f219bb80caaabc Author: fan <fanyuhong@joylink.club> Date: Wed Oct 16 09:39:34 2024 +0800 protoc commit 702cc229a3aa7c7a73bc8d6178ce34b18b033466 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Tue Oct 15 18:16:18 2024 +0800 加滚动条 commit ed3392d3781d5a8926a3c01ca7c37b1ad24b3928 Author: joylink_zhaoerwei <Bob_Engineer@163.com> Date: Tue Oct 15 17:37:56 2024 +0800 绘制加组件显示 commit 1891981a23ffe5eb169578608d36eaefd54bfddd Author: joylink_fanyuhong <18706759286@163.com> Date: Tue Oct 15 16:50:36 2024 +0800 抽屉调整
2024-11-18 17:10:59 +08:00
const messageDir = resolve(__dirname, '../rtsa-proto-msg');
2024-09-13 08:50:08 +08:00
const protoDir = resolve(messageDir, 'src');
const destDir = resolve(__dirname, '../src/protos');
/**
* 递归处理所有proto文件生成
* @param {*} file 文件
* @param {*} path 目录
*/
function recursiveGenerate(file, path = [], cmds = []) {
if (file.isFile()) {
// 文件,生成
if (file.name.endsWith('.proto')) {
cmds.push(buildGenerateCmd(file.name, path));
} else {
console.warn('不是proto文件', file.name);
}
} else if (file.isDirectory()) {
// 文件夹,递归
readdirSync(resolve(protoDir, ...path, file.name), {
withFileTypes: true,
}).forEach((f) => {
const subPath = [...path, file.name];
recursiveGenerate(f, subPath, cmds);
});
}
}
const isLinux = os.type().toLowerCase().includes('linux');
function buildGenerateCmd(name, path = []) {
const protoPath = resolve(protoDir, ...path);
const tsPath = resolve(destDir, ...path);
let cmd = ['protoc', `-I=${protoPath}`, `--ts_out=${tsPath}`, `${name}`];
let cmdStr = cmd.join(' ');
return cmdStr;
}
function main() {
2024-09-13 13:38:04 +08:00
const protocDir = resolve(
messageDir,
`protoc/protoc-27.4-${isLinux ? 'linux-x86_64' : 'win64'}`
2024-09-13 08:50:08 +08:00
);
2024-09-13 13:38:04 +08:00
const protocBin = resolve(protocDir, 'bin');
2024-09-13 08:50:08 +08:00
const prepareCmds = [];
const setPathCmd = isLinux
? ['export', `PATH=${protocBin}:${protocDir}:"$PATH"`].join(' ')
: ['set', `PATH=${protocBin};${protocDir};%PATH%`].join(' ');
const protocVersionCmd = ['protoc', '--version'].join(' ');
prepareCmds.push(setPathCmd);
prepareCmds.push(protocVersionCmd);
readdirSync(protoDir, {
withFileTypes: true,
}).forEach((f) => {
recursiveGenerate(f, [], prepareCmds);
});
// console.log(prepareCmds);
exec(
prepareCmds.join(' && '),
{
maxBuffer: 1024 * 2000,
},
(err, stdout, stderr) => {
if (err) {
console.error(err);
throw err;
} else if (stderr.length > 0) {
console.error(stderr.toString());
throw new Error(stderr.toString());
} else {
console.log(stdout);
}
}
);
}
// 执行
main();