【问题标题】:Verify that npm version has increased in CI build验证 npm 版本是否在 CI 构建中增加
【发布时间】:2020-08-07 20:11:00
【问题描述】:

在持续集成 (CI) 管道中,作为检查的一部分,我想验证包的版本是否已增加。

对最佳方法有什么想法吗?

当前管道正在运行

  • npm run lint 用于 linting。
  • npm run test 用于单元测试覆盖率。
  • npm run build 生成生产版本。

如果其中任何一个失败,分支将无法合并。目前,我们必须记住增加软件包版本,但很多时候人们忘记了。由于我们在微服务基础架构中使用它们,我们确实需要它来升级版本。最好包括一张支票。

【问题讨论】:

    标签: node.js npm continuous-integration microservices


    【解决方案1】:

    您需要通过代码在 NPM 注册处调用包的最新版本,并在该阶段检查版本。以下代码从注册处获取包版本:

    const { spawn } = require("child_process");
    
    const ver = spawn("npm", ["view", "<packagename>", "version"]);
    
    ver.stdout.on("data", data =>{
        // you would have the latest version of the package from npm
        // check packages here
    });
    
    ver.stderr.on("data", err => console.error(err));
    
    ver.on("exit", code => {
        if(code ===0 ){
            // process finished succesfully and do whatever you want
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-01
      • 2017-06-21
      • 2019-09-26
      • 1970-01-01
      • 2018-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多