#deployment #developer-tools #github #row #operations #lezeh #productivity

lezeh-deployment

与部署操作相关的 CLI 工具,主要用于提高工作中使用部署时的生产力,适用于个人使用。有关详细信息,请参阅 https://github.com/sendyhalim/lezeh。

6 个版本

0.0.6 2023 年 2 月 3 日
0.0.5 2023 年 1 月 30 日
0.0.3 2022 年 10 月 11 日
0.0.2 2022 年 9 月 22 日

2731命令行工具 中排名

每月 44 次下载
lezeh 中使用

MIT 许可证

71KB
1.5K SLoC

Lezeh

lezeh 是一个 CLI 工具,可简化日常工程操作,例如

  • 选择数据库行及其关系
  • 可视化数据库行关系的图形表示
  • 将功能分支(按惯例,使用 phabricator 任务号)合并到 master 中,这包括清理(删除)已合并的功能分支
  • 合并并运行部署命令

Crates.io Crates.io

安装

下载二进制文件

前往最新版本并下载二进制文件 此处

二进制文件 操作系统
lezeh-x86_64-未知-linux-gnu.zip Linux
lezeh-x86_64-apple-darwin.zip macOS

使用 cargo

cargo install lezeh

手动构建

这需要 rust

make install

设置

首先在 ~/.lezeh 创建配置文件,我们使用 YAML 格式。每个顶级键的名称以 lezeh 子命令命名

  • url 映射到 lezeh url ... 命令
  • db 映射到 lezeh db ... 子命令
  • 等等...
url:
  bitly:
    api_token: test123

db:
  db_connection_by_name:
    testdb:
      host: localhost
      port: 5432
      database: db_name
      username: ....
      password: ....

deployment:
  phab:
    api_token: test125
    pkcs12_path: /path/to/pkcs12
    host: 'yourphabricatorhost.com'
    pkcs12_password: abcdefg

  ghub:
    api_token: test124

  repositories:
      # This is a unique key that will be used as hashmap key
      # for the repo.
    - key: "repo-key"
      path: "repo-local-path"
      github_path: "username/reponame"
      deployment_scheme_by_key:
        stg:
          name: "Deploy to stg"
          default_pull_request_title: "Merge into stg"
          merge_from_branch: "master"
          merge_into_branch: "stg"
        prod:
          name: "Deploy to prod"
          default_pull_request_title: "Merge into prod"
          merge_from_branch: "stg"
          merge_into_branch: "prod"

用法

URL CLI

lezeh url shorten {longUrl}

数据库 CLI

主要与数据库操作相关的工具。目前仅支持 PostgreSQL。

cherry-pick

假设你有一个表行,你想要复制,但无法轻易复制,因为它有关系,你需要递归地复制父项和子项。这就是 cherry-pick 🍒 可以发挥作用的地方,它会获取与给定列-值对匹配的行及其关系,然后从它构建一个图,该图可以序列化为插入语句(默认选项)或 graphviz(用于可视化图)

lezeh db cherry-pick \
  # Fetch from test_db, this one is based on the config
  --source-db=testdb \

  # As of now only supports 1 value, but it will change in the future
  --values=123 \

  # Table that the value will be fetched from
  --table=orders \

  # [Optional] which column that contains the given values, defaults to id
  --column=id \

  # [Optional] Db schema, defaults to public
  --schema=public \

  # [Optional], defaults to insert-statement. If supplied Graphviz then it'll serialize
  # the graph representation that can be represented in a graphviz format
  # see https://graphviz.cpp.org.cn/ for more details.
  # The output can be used on online graphviz visualizer:
  # * https://edotor.net
  # * https://dreampuf.github.io/GraphvizOnline
  --output-format=insert-statement|graphviz \

  # [Optional]
  # The option will be used if you choose pass `--output-format=graphviz`.
  # Set the table columns that will be displayed on each node, if not set it'll
  # default to only show the row id, format:
  # '{table_1}:{column_1}|{column_2}|{column_n},{table_n}:{column_n}'
  #
  # Suppose you pass `--graph-table-columns='users:id|name|email, orders:code'`, it will
  # * Show id, name and email column value for all fetched rows from users table
  # * Show code column value for all fetched rows from orders table
  # * The other rows from other tables will still only show row id because
  #   it's not overriden
  --graph-table-columns='{table_1}:{column_1}|{column_2}|{column_n},{table_n}:{column_n}, {table_n}:{column_n}'

部署 CLI

# Below command will iterate all repositories under deployment.repositories config
# and do the following operations:
# * Make sure your local git data is updated by pulling remote git data from GH.
# * For each remote branches that contains the given task numbers:
#    - Print out phabricator task owner (assigned) for that specific branch.
#    - Create a PR for the matched branch.
#    - Merge the branch into master with SQUASH strategy
#    - Delete the remote branch
lezeh deployment merge-feature-branches \
  {task_number} {task_number} {task_number} ... \
  
  # Set number of concurrency limit when merging feature branches. Defaults to 1, meaning it will 
  # sequentially merge feature branches per repository. If you set it to N then it will run in 
  # parallel at most N repositories at a time. At the repository level, merging should be sequential 
  # otherwise it'll race with other pull requests.
  --concurrency-limit=1


# Merge repo (given repo key) based on given deployment scheme config.
#
# Example usage (based on above config example):
# lezeh deployment deploy repo-key stg
lezeh deployment deploy {repo_key} {scheme_key}

依赖项

~22–36MB
~600K SLoC