Giter Site home page Giter Site logo

lisong / code-push-server Goto Github PK

View Code? Open in Web Editor NEW
1.8K 61.0 509.0 1.65 MB

CodePush service is hot update services which adapter react-native-code-push and cordova-plugin-code-push - 热更新

License: MIT License

JavaScript 94.87% CSS 0.48% Makefile 0.66% Dockerfile 0.11% Pug 3.88%
cordova react-native code-push code-push-server

code-push-server's Introduction

CodePush Server source

NPM

NPM Version Node.js Version Linux Status Windows Status Coverage Status Dependency Status Known Vulnerabilities Licenses

CodePush Server is a CodePush progam server! microsoft CodePush cloud is slow in China, we can use this to build our's. I use qiniu to store the files, because it's simple and quick! Or you can use [local/s3/oss/tencentcloud] storage, just modify config.js file, it's simple configure.

Support Storage mode

  • local storage bundle file in local machine
  • qiniu storage bundle file in qiniu
  • s3 storage bundle file in aws
  • oss storage bundle file in aliyun
  • tencentcloud storage bundle file in tencentcloud

正确使用code-push热更新

  • 苹果App允许使用热更新Apple's developer agreement, 为了不影响用户体验,规定必须使用静默更新。 Google Play不能使用静默更新,必须弹框告知用户App有更新。**的android市场必须采用静默更新(如果弹框提示,App会被“请上传最新版本的二进制应用包”原因驳回)。
  • react-native 不同平台bundle包不一样,在使用code-push-server的时候必须创建不同的应用来区分(eg. CodePushDemo-ios 和 CodePushDemo-android)
  • react-native-code-push只更新资源文件,不会更新java和Objective C,所以npm升级依赖包版本的时候,如果依赖包使用的本地化实现, 这时候必须更改应用版本号(ios修改Info.plist中的CFBundleShortVersionString, android修改build.gradle中的versionName), 然后重新编译app发布到应用商店。
  • 推荐使用code-push release-react 命令发布应用,该命令合并了打包和发布命令(eg. code-push release-react CodePushDemo-ios ios -d Production)
  • 每次向App Store提交新的版本时,也应该基于该提交版本同时向code-push-server发布一个初始版本。(因为后面每次向code-push-server发布版本时,code-puse-server都会和初始版本比较,生成补丁版本)

shell login

$ code-push login http://api.code-push.com #登录

访问:http://www.code-push.com

client eg.

ReactNative CodePushDemo

Cordova CodePushDemo

HOW TO INSTALL code-push-server

DEFAULT ACCOUNT AND PASSWORD

  • account: admin
  • password: 123456

HOW TO USE

ISSUES

code-push-server normal solution

An unknown error occurred

modify password

UPDATE TIME LINE

  • targetBinaryVersion support
    • *
    • 1.2.3
    • 1.2/1.2.*
    • 1.2.3 - 1.2.7
    • >=1.2.3 <1.2.7
    • ~1.2.3
    • ^1.2.3

Advance Feature

use google diff-match-patch calculate text file diff patch

  • support iOS and Android
  • use "react-native-code-push": "git+https://[email protected]/lisong/react-native-code-push.git" instead "react-native-code-push": "x.x.x" in package.json
  • change apps.is_use_diff_text to 1 in mysql codepush database

License

MIT License read

code-push-server's People

Contributors

chinachuner avatar chunge66 avatar devhyunjae avatar jeoy avatar kimown avatar lisong avatar openumbrella avatar rocwind avatar snyk-bot avatar starlight36 avatar taichiyi avatar xuepx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

code-push-server's Issues

初始化账号的问题

你好 首先感谢你的这个项目

这里想问几个关于 codepush 的问题

  1. 我看到你初始化设置了 账号 admin 和 密码 123456 我目前已经通过 code-push-cli 成功的 login 并且生成了我本地的 session config
    我的问题是这个初始的账号密码是否可以使用 code-push-cli 更换

  2. code-push-cli 是否只能记忆单次会话
    我之前是使用微软官方的公有云 在登出了之后我指定了本地 http://localhost:3000 作为参数生成了新的 config
    这是不是意味着以后我想再使用微软之前生成的账号 就需要再次先 logout 后重新 login 微软公有云才有效?

  3. 如果上述条目 2 成立 我在第一次指定了 code-push-cli login http://localhost:3000 之后的所有后续操作 比如 code-push app add <MyApp> 等等 是不是都不再需要指定本地的 url 参数了 会直接发送到 http://localhost:3000 的服务?

感谢回复

致意

一些疑问

想问下这是自己搭建私有的 code push server 嘛 官方文档貌似只找到 sdk 和 cli 的集成方法

有哪里提供官方的搭建 code push server 服务的文档么

感谢

targetBinaryVersion 参数问题

code-push release-cordova 使用 -t 参数,即--targetBinaryVersion 参数
一直报错不支持的版本号, 是该功能未实现么?

更新资源找不到路径

进入热更新 sdk 的逻辑下载失败 日志如下

2016-11-14 18:47:58.238 [info][tid:com.facebook.React.JavaScript] [CodePush] Error: 404: The specified resource does not exist.
RequestId:055a110c-0002-0139-0f64-3e17ec000000

我用 pm2 指定的 process.yml 信息如下

apps:
  - script : /Users/Jovi/work/mock/code-push-server/bin/www
    name   : code-push-server
    watch  : true
    env    :
      NODE_ENV: production
      PORT: 3000
      CONFIG_FILE: /Users/Jovi/work/mock/production/hotfix/config.js

对应的 config.js 如下

var config = {};
config.development = {
  //数据库配置
  db: {
    username: "jovi",
    password: "miaomiao",
    database: "codepush",
    host: "127.0.0.1",
    dialect: "mysql"
  },
  //七牛云存储配置 当storageType为qiniu时需要配置
  qiniu: {
    accessKey: "",
    secretKey: "",
    bucketName: "",
    downloadUrl: "" //文件下载域名地址
  },
  //文件存储在本地配置 当storageType为local时需要配置
  local: {
    storageDir: "/Users/jovi/work/mock/production/hotfix/workspaces/storage",
    //文件下载地址 CodePush Server 地址 + '/download' download对应app.js里面的地址
    downloadUrl: "http://localhost:3000/download"
  },
  common: {
    //登录jwt签名密钥,必须更改,否则有安全隐患,可以使用随机生成的字符串
    loginSecret: "CodePushServer",
    //当天登录密码错误尝试次数,超过次数帐户将会锁定。0:表示无限制,可能会出现暴力破解。 大于0:必须开启redis服务。
    tryLoginTimes: 0,
    //CodePush Web部署地址,也可以配置成CodePush Web地址
    //codePushWebUrl: "http://localhost:3001",
    //差异化更新版本生成数目 默认为3
    diffNums: 3,
    //数据目录,优化选项
    dataDir: "/Users/jovi/work/mock/production/hotfix/workspaces/data",
    //选择存储类型,目前支持local和qiniu配置
    storageType: "local"
  },
  //邮件配置,注册模块验证邮箱需要使用 参考https://github.com/nodemailer/nodemailer
  smtpConfig:{
    host: "smtp.mxhichina.com",
    port: 465,
    secure: true,
    auth: {
      user: "",
      pass: ""
    }
  },
  //配置redis, 注册时需要, 登录限制密码出错次数
  redis: {
    default: {
      host: "127.0.0.1",
      port: 6379,
      retry_strategy: function (options) {
        if (options.error.code === 'ECONNREFUSED') {
          // End reconnecting on a specific error and flush all commands with a individual error
          return new Error('The server refused the connection');
        }
        if (options.total_retry_time > 1000 * 60 * 60) {
            // End reconnecting after a specific timeout and flush all commands with a individual error
            return new Error('Retry time exhausted');
        }
        if (options.times_connected > 10) {
            // End reconnecting with built in error
            return undefined;
        }
        // reconnect after
        return Math.max(options.attempt * 100, 3000);
      }
    }
  }
}
config.production = Object.assign({}, config.development);
module.exports = config;

使用 code-push 推送资源成功后未发现报错 也确实看到了本地 storage 下存在了文件

image

我用命令行和浏览器访问 /download 也发现了 404 的返回结果

看到了 app.js 的逻辑是 app.use('/download', express.static(_.get(config, 'local.storageDir')))

想问下问题出在哪里

感谢

code-push patch 执行出错

code-push patch xbc-android Staging --des "asd"

服务器

PATCH /apps/xbc-android/deployments/Staging/release 404 33.010 ms - 1580
Error: Not Found
at E:\code-push-server\app.js:71:13
at Layer.handle [as handle_request] (E:\code-push-server\node_modules\expres
s\lib\router\layer.js:95:5)
at trim_prefix (E:\code-push-server\node_modules\express\lib\router\index.js
:312:13)
at E:\code-push-server\node_modules\express\lib\router\index.js:280:7
at Function.process_params (E:\code-push-server\node_modules\express\lib\rou
ter\index.js:330:12)
at next (E:\code-push-server\node_modules\express\lib\router\index.js:271:10
)
at E:\code-push-server\node_modules\express\lib\router\index.js:618:15
at next (E:\code-push-server\node_modules\express\lib\router\index.js:256:14
)
at Function.handle (E:\code-push-server\node_modules\express\lib\router\inde
x.js:176:3)
at router (E:\code-push-server\node_modules\express\lib\router\index.js:46:1
2)
at Layer.handle [as handle_request] (E:\code-push-server\node_modules\expres
s\lib\router\layer.js:95:5)
at trim_prefix (E:\code-push-server\node_modules\express\lib\router\index.js
:312:13)
at E:\code-push-server\node_modules\express\lib\router\index.js:280:7
at Function.process_params (E:\code-push-server\node_modules\express\lib\rou
ter\index.js:330:12)
at next (E:\code-push-server\node_modules\express\lib\router\index.js:271:10
)
at E:\code-push-server\node_modules\express\lib\router\index.js:618:15

数据库连接问题

部署到数据库总是登录连接不上,有空帮忙看一下什么原因?qq1245880084

提示文件格式不对

bogon:code-push-demo-app-master jq$ code-push release CodePushDemo-android ./bundles/index.android.bundle 1.0.0 --deploymentName Production --description "1.支持文章缓存。" --mandatory true
Upload progress:[==================================================] 100% 0.0s
[Error] 上传的文件格式不对

关于更新包的Hash

CodePush 有个 package_hash 。
这个值是在客户端 code-push release 的时候在客户端产生然后发送给服务器保存的 ,
还是更新包zip文件发送到服务器端了之后,服务器端hash得到的值?

How to modify the password

After the installation is complete, open the address login, the default account password is admin, 123456

How do I change it

code-push release-react 部署包导致code-push-server进程退出

使用如下命令部署

code-push release-react finance-android android --description "13. 测试提示" -d "Production" -m

服务端错误日志:

0|code-pus | { Error: ENOENT: no such file or directory, chmod '/home/ubuntu/storage/FkrEhz92120pOEqjFY5zUhi9Teoz'
0|code-pus |   errno: -2,
0|code-pus |   code: 'ENOENT',
0|code-pus |   syscall: 'chmod',
0|code-pus |   path: '/home/ubuntu/storage/FkrEhz92120pOEqjFY5zUhi9Teoz' }
0|code-pus | Error: ENOENT: no such file or directory, open '/tmp/codepush_DZ6SFf4vUBZwgKvTzMLOpzn2ZElmjH2Y/FgJjaMWow7_70N7g29IezDkkwl19.zip'
PM2        | App [code-push-server] with id [0] and pid [21423], exited with code [1] via signal [SIGINT]
PM2        | Starting execution sequence in -fork mode- for app name:code-push-server id:0
PM2        | App name:code-push-server id:0 online

可以看出code-push-server进程是退出了,但是由于使用了pm2管理并开启watch,所以又重启了。

不知道为什么会出现这样的错误,还请指教

客户端获取更新报错-An unknown error occurred

我远程服务器上搭的push-code-server,配置的qiniu,发布更新qiniu bucket能收到文件,server的库表里也ok,但是客户端访问时报错An unknown error occurred(我复制的demo.js做rn客户端内容),每当客户端启动server都会报一次以下错误。
1

更新的时候出现unknown error

点击更新按钮之后,出现下载弹窗,然后点击安装后就会显示unknown error。查看了服务端发现有查询packages_diff表,但我看了一下那个表里是空的。请教一下可能是什么原因导致这个错误呢?

建议使用generator的形式

通过CLI的generate指令在指定目录下创建一个服务器实例,这样便于配置、管理(尤其是需要运行多个server实例时)和定制,同时也比clone github的代码更加友好。

我在 Linux 系统上安装报如下错误。

`npm ERR! Linux 2.6.32-504.el6.x86_64
npm ERR! argv "/weblogic/code-push/node-v6.6.0-linux-x64/bin/node" "/weblogic/code-push/node-v6.6.0-linux-x64/bin/npm" "install"
npm ERR! node v6.6.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /weblogic/code-push/code-push-server/npm-debug.log

`

无法上传index.android.bundle

我使用 code-push release ... ./bundle/index.android.bundle .... 会提示上传格式不对。
我使用 code-push release ... ./bundle .... 会提示 it must be publish it by ios type 。

请教一下,应该如何使用 code-push release 。

谢谢。

[Android] code-push issue with --mandatory option

  1. code-push cli command
code-push release-react MYAPP android -m true -d Production
  1. after complete if i look at my release history

screen shot 2016-12-29 at 5 25 34 pm

mandatory option shows no. both v6, v7 was released with mandatory option

  1. If i open the app to get the new code-pushed bundle, the app crashes

  2. And then, when i reopen the app, now the app works with the new pushed bundle.

Any clues to guess? 😰

npm install 安装报错

npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/root/.nvm/versions/node/v6.9.1/bin/node" "/root/.nvm/versions/node/v6.9.1/bin/npm" "install" "code-push-server" "-g"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /usr/local/app/code-push-server/npm-debug.log
npm ERR! code 1

请问下如何修改账户信息

看到默认使用的账户是 [email protected]

使用 code-push register http://[myhost] 后发现到了登录界面 输入数据库里初始的用户名密码后发现后台报错

image

。。想默默问下怎么注册新的邮箱账户

感谢 :)

不支持windows [运行code-push-server出错]

Please create dir /Users/tablee/workspaces/storage

C:\Users\Administrator\AppData\Roaming\npm\node_modules\code-push-server\app.js:57
throw new Error(Please create dir ${dir});

在windows下创建上述目录失败,因为这是linux系统下的路径格式,能否支持一下window路径?

Error: If encoding is specified then the first argument must be a string

Hi, I follow the tutorial, but when I run code-push-server-db init --dbhost localhost —dbuser root --dbpassword 123456, error occurs, here is the log

$ code-push-server-db init --dbhost localhost —dbuser root --dbpassword  123456
/home/google/.tnvm/versions/alinode/v2.0.8/lib/node_modules/code-push-server/node_modules/mysql/lib/protocol/Parser.js:79
        throw err; // Rethrow non-MySQL errors
        ^

Error: If encoding is specified then the first argument must be a string
    at new Buffer (buffer.js:74:13)

Login一进去就是404

请问是还有什么没说明清楚的要做的步骤吗?因为是这方面的新手可能有些地方不是很明白,谢谢了。

报错,找不到文件,请帮忙看看,谢谢了

报找不到文件的错误

GET //download/Fqh9cD7XMY223d5g_SbncGC7FNh4 404 3.040 ms - 1907
Error: Not Found
    at /Users/jq/React-native/code-push-server/app.js:70:13
    at Layer.handle [as handle_request] (/Users/jq/React-native/code-push-server/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/jq/React-native/code-p
   ush-server/node_modules/express/lib/router/index.js:312:13)
    at /Users/jq/React-native/code-push-server/node_modules/express/lib/router/index.js:280:7
    at Function.process_params (/Users/jq/React-native/code-push-server/node_modules/express/lib/router/index.js:330:12)
    at next (/Users/jq/React-native/code-push-server/node_modules/express/lib/router/index.js:271:10)
    at /Users/jq/React-native/code-push-server/node_modules/express/lib/router/index.js:618:15
    at next (/Users/jq/React-native/code-push-server/node_modules/express/lib/router/index.js:256:14)
    at Function.handle (/Users/jq/React-native/code-push-server/node_modules/express/lib/router/index.js:176:3)

我的config配置如下:

** local: {
    // Binary files storage dir, Do not use tmpdir and it's public download dir.
    storageDir: "/Users/jq/code-push-storage",
    // Binary files download host address which Code Push Server listen to. the files storage in storageDir.
    downloadUrl: "http://10.2.8.208:3000/download",
    // public static download spacename.
    public: '/download'
  },
  jwt: {
    // Recommended: 63 random alpha-numeric characters
    // Generate using: https://www.grc.com/passwords.htm
    tokenSecret: 'INSERT_RANDOM_TOKEN_KEY'
  },
  common: {
    /*
     * tryLoginTimes is control login error times to avoid force attack.
     * if value is 0, no limit for login auth, it may not safe for account. when it's a number, it means you can
     * try that times today. but it need config redis server.
     */
    tryLoginTimes: 0,
    // CodePush Web(https://github.com/lisong/code-push-web) login address.
    //codePushWebUrl: "http://localhost:3001/login",
    // create patch updates's number. default value is 3
    diffNums: 3,
    // data dir for caclulate diff files. it's optimization.
    dataDir: "/Users/jq/code-push-storage",
    // storageType which is your binary package files store. options value is ("local" | "qiniu" | "s3")
    storageType: "local",
    // options value is (true | false), when it's true, it will cache updateCheck results in redis.
    updateCheckCache: false
  },

code-push-server-db init --dbhost localhost --dbuser root --dbpassword 报错

当我执行
code-push-server-db init --dbhost localhost --dbuser root --dbpassword
的时候报错
{ [Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: NO)]
cause:
{ [Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: NO)]
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlState: '28000',
fatal: true },
isOperational: true,
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlState: '2800

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.