npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zed-sync

v0.3.15

Published

a command tool to sync files using zed editor's protocal

Downloads

67

Readme

zed-sync

自动监听本地文件改动并同步到 dae pre 环境

演示

http://asciinema.dapps.douban.com/asciicast/3Y3ZR6B4

背景

感谢我们的 dae 工程师们,我们终于可以在 dae pre 环境中通过 zed 编辑器在线编辑和热更新 pre 上的文件了(http://readthedocs.dapps.douban.com/docs/dae/dev/pre.html#id2)。

但是 zed 编辑器存在以下问题:

  1. 无法和本地文件同步
  2. 功能有限,用起来也很不习惯..

考虑到 zed 编辑器是完全使用前端技术实现的,猜想和后端的通信方式应该也是通过普通的 web api 请求实现的。 于是看了下 zed-editor 的源码,果然找到了写文件请求的接口:

https://github.com/zedapp/zed/blob/master/app/js/fs/web.js#L108

一开始是打算写成编辑器的插件,但是考虑到大家都习惯使用不同的编辑器/IDE,于是就用 nodejs 写了一个监听本地文件改动并自动上传到 zed 服务端的命令行工具,希望也能给大家在开发的过程中带来一些便利。。

安装

  1. 确保本地安装有 8 以上的 nodejs (查看 node 版本: node -v)
  2. 安装 zed-sync 到全局
  3. 在 doubandev3 上安装 dae sdk
npm i -g zed-sync

使用方法

  1. 根据 pre number 和 doubandev2 用户名自动获取 zed url (via run command over SSH)
# 自动获取 zed url 并监听当前目录
zed-sync -p <sshLoginName>@<preNum>
# e.g.
zed-sync -p yangzhen@69


# 获取 zed url 前先执行 dae pre update
zed-sync -p <sshLoginName>@<preNum> --up
# e.g.
zed-sync -p yangzhen@69 --up
  1. 手动获取 zed url dae prelease 环境可以通过 dae pre edit --pre <pre num> 得到 zed 实时编辑的服务端链接,具体可以参考 dae 文档: http://readthedocs.dapps.douban.com/docs/dae/dev/pre.html#id2

需要注意的是一定要在项目的根目录下运行该命令,这样才能计算出正确的路径。

npm i -g zed-sync

# 查看help
zed-sync -h

# 监听当前文件夹
zed-sync -u http://diggle1:7337/fs/321f6881cf9546ce9d41f6e26fc10412

# 监听指定文件夹
zed-sync -w <project root> -u http://diggle1:7337/fs/321f6881cf9546ce9d41f6e26fc10412

# 监听多个文件夹

zed-sync -w <dir1> <dir2> ... -u http://diggle1:7337/fs/321f6881cf9546ce9d41f6e26fc10412


zed-sync -u  http://diggle1:7337/fs/321f6881cf9546ce9d41f6e26fc10412 -s /path/to/sync/*

验证和缓存

为了避免出现监听错误的项目,在监听前会有以下验证

  1. 对第一次运行的分支进行缓存,如果同一个 zed 链接之后运行在了不同的分支,会提示错误并停止运行。过期时间为 5 天(重启后失效)。
  2. 会对本地与远程的 readme 内容进行比对,如果不一致会提示警告。

自动获取 zed 链接后会自动缓存到 tmp 目录(重启后失效,最多 5 天)。

跳过验证: -v=false