#trace #process #drive #ngrok #cargo #concepts #github

app cargo-ngrok

使用 ngrok 跟踪来驱动您的开发过程

3 个版本

0.1.2 2020年3月8日
0.1.1 2020年3月8日
0.1.0 2020年3月8日

#537Cargo 插件

MIT 许可证

27KB
576

cargo-ngrok

使用 ngrok 跟踪来驱动您的开发过程。

这主要受到 Dark 的 "跟踪驱动开发" 概念的启发,如 https://darklang.github.io/docs/trace-driven-development 中所述。

目前只是一个草图,但我期望 mvp 命令行将如下所示

USAGE:
    cargo ngrok <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    404s           list requests for turning into new handlers
    500s           list requests for turning into regression tests
    develop        run your project with tracing (TODO)
    help           Prints this message or the help of the given subcommand(s)
    new-handler    make a new route handler from the latest 404 error
    new-test       make a regression test from the latest 500 error
    replay-404     replay the latest 404 error (TODO)
    replay-500     replay the latest 500 error (TODO)

The following subcommands are forwarded to ngrok for convenience:
    authtoken
    credits
    http
    start
    tcp
    tls
    update
    version
    help

MVP 只支持生成以下形式的 actix-web 请求处理器

#[get("/")]
async fn no_params() -> &'static str {
    "Hello world!\r\n"
}

开发

MVP 的进展可以在 https://github.com/alsuren/cargo-ngrok/projects/1 跟踪

我还在尝试决定 MVP 之后要做什么。如果您有任何建议,请在此 https://github.com/alsuren/cargo-ngrok/issues/2 上评论或在我的 gitter 上打扰我。或者,您可以自行实现想法并发送补丁。我对给予有激情的人合并权限持开放态度。

在我的当前开发工作流程中,我打开了以下标签

  1. ~/src/actix/examples/template_yarte$cargo watch-x test-x run
    1. 每当有任何更改时都运行测试
    2. 当它们通过时,启动 web 服务器,直到我们再次更改(如果您需要,可以减少停机时间)。
  2. $ngrok http 8080
    1. 启动隧道,并将其指向 web 服务器。
  3. $ curl https://xyz.ngrok.io/whatever 以造成 404 错误。
  4. ~/src/cargo-ngrok$cargo watch-x help-x fmt-x test-x build
    1. 监视 cargo-ngrok 仓库并测试/构建它
    2. -x help 添加一段灰色文本,这样您可以知道一组编译器输出何时结束以及下一组何时开始。
    3. 在创建新的 cargo-ngrok 调试二进制文件之前,必须先通过测试(这对于下面的步骤很有用)。
  5. ~/src/actix/examples/template_yarte$watchexec--no-ignore--verbose--watch~/src/cargo-ngrok/target/debug/cargo-ngrok-- "git stash && cargo ngrok new-handler && cargo fmt && GIT_PAGER=cat git diff && cargo test"
    1. 每当我有一个新的 cargo-ngrok 构建(来自上一步)
      1. 清理工作目录
      2. 创建一个新的骨架 / whatever
      3. 显示差异并运行测试。
      4. 请注意,这仅因为我已将 ~/src/cargo-ngrok/target/debug/cargo-ngrok 链接到我的 $PATH,所以才能工作。

我发现这让我能够快速原型设计。我还一直在尝试 cargo-fixeq,这就是为什么我的某些测试需要绕圈子,以便让第二个 assert_eq!() 参数成为一个字符串字面量。

依赖项

约11–16MB
约303K SLoC