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

syncoss

v2.0.5

Published

Synchronizing local files and OSS.

Downloads

11

Readme

SyncOSS 阿里云OSS文件同步工具

同步本地与OSS文件,并自动刷新CDN。

优点

  1. 不仅有上传和更新功能,还带有删除功能,不会浪费OSS的容量(省钱)。
  2. 在程序启动时,程序会把OSS和本地的文件进行MD5对比,所以由始至终,本地和OSS的文件都是相同的。
  3. 带有CDN刷新功能,所以你不必手动刷新文件。

缺点

  1. 监视同步功能(默认关闭)会耗费大量内存,如果你开发机内存较小(如只有1G),则不建议使用。
  2. 暂只能以“本地文件为准”方式同步,日后会添加更多模式。
  3. 目前没在服务器上使用过,只在windows开发机上运行过

使用方法

1.安装

npm install syncoss -g

2.配置

请在项目根目录下放置syncossConf.json文件,参考下面的写法:(请删除注释,json是没有注释的)

{
  "AccessKeyId": "xxx",
  "AccessKeySecret": "xx",
  "cdn": {
    "domain": "cdn.lazycoffee.com"
  },
  "oss": {
    "securityToken": "", //TSS权限设置
    "endpoint": "http://oss-cn-hangzhou.aliyuncs.com", //oss地区
    "region": "oss-cn-hangzhou", //endpoint 和 region 必须要提供其中一个,当设置了endpoint,region会被忽略
    "internal": true, //配合region使用,如果指定internal为true,则访问内网节点,
    "secure": true, //配合region使用,如果指定了secure为true,则使用HTTPS访问
    "cname": "", //配合endpoint使用,如果指定了cname为true,则将endpoint视为用户绑定的自定义域名
    "timeout": 60, //默认为60秒,指定访问OSS的API的超时时间
    "autoRefreshCDN": true, //可选,文件更新后是否自动刷新CDN
    "contentEncoding": "" // 指定下载该文件时的Content-Encoding,除非有特殊需求,一般不需要填写
  },
  "AccessControlAllowOrigin": "www.lazycoffee.com",
  "bucket": "lazycoffee",
  "watch": {
    "ignored": ""
  },
  "keepWatching": false,
  "syncDir": "public", //要同步的文件夹
  "syncFilter": [ //文件夹过滤
    "js", "css", "vendor", "!images"//有叹号是不同步的文件夹,没叹号就是要同步的文件夹
  ]
}

3.运行

打开命令行,cd到项目根目录,运行:

syncOSS

调试模式:

syncoss --debug

文件监视模式:

syncoss --watch

工作流程

  1. 获取设定的OSS父文件夹下所有文件的信息,用于文件对比。
  2. 对比本地和OSS的文件,如ETag不同或者远程没有这个文件,那么就会上传或更新OSS的文件。如果OSS有,但本地没有的文件,那么SyncOSS就会将OSS这个文件删除。
  3. 监视本地文件夹,当发现有文件“增删改”,即会触发相应的同步行为。例如本地删除一个文件,OSS也同样会将这个文件删除。

Author 作者

James Yin[email protected]

License

Copyright (c) 2015 James Yin, [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.