通过patch 方式解决cube.js 集成cratedb 的问题

今天有写过一个简单的cube.js 集成cratedb 的说明,主要是在driver 上的兼容问题,处理方法是删除不兼容的代码
实际上我们也可以通过类似linux c 开发中的patch 方式解决,简化手工干预

生成patch 文件

  • 安装npm 依赖
 
yarn
  • 生成patch
    重命名原有的文件(进入npm 包目录)
    cp PostgresDriver.js PostgresDriver-origin.js
    修改PostgresDriver.js ,删除不兼容的部分:

生成patch

diff -Nur node_modules/@cubejs-backend/postgres-driver/driver/PostgresDriver-origin.js node_modules/@cubejs-backend/post
gres-driver/driver/PostgresDriver.js > cratedb-driver-patch.patch

恢复原有文件内容

新项目应用patch

需要先安装依赖,同时copy patch 文件

patch < cratedb-driver-patch.patch

效果

patch < cratedb-driver-patch.patch 
can't find file to patch at input line 3
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|--- node_modules/@cubejs-backend/postgres-driver/driver/PostgresDriver-origin.js 2019-08-19 13:03:59.000000000 +0800
|+++ node_modules/@cubejs-backend/postgres-driver/driver/PostgresDriver.js 2019-08-19 13:04:05.000000000 +0800
--------------------------
File to patch: node_modules/@cubejs-backend/postgres-driver/driver/PostgresDriver.js
patching file node_modules/@cubejs-backend/postgres-driver/driver/PostgresDriver.js

说明

以上是一个简单的借鉴linux c patch 处理的方式解决cube.js 兼容cratedb 的问题,就是一个简单的学习

参考资料

https://github.com/rongfengliang/cube.js-cratedb-patch-demo

猜你喜欢

转载自www.cnblogs.com/rongfengliang/p/11376596.html