当前位置: 首页 > 编程日记 > 正文

angular搭建项目步骤_建立健康的Angular项目应采取的步骤

angular搭建项目步骤

by Ashish Gaikwad

通过Ashish Gaikwad

建立健康的Angular项目应采取的步骤 (Steps you should take to build a healthy Angular project)

使用Jenkins + SonarQube创建您的“ Angular Fitbit” (Create your “Angular Fitbit” with Jenkins + SonarQube)

Just like the recent introduction of wearables to track our health, the software industry has long followed the practice of monitoring the health of software projects. The most common processes applied are unit tests, integration tests, continuous integration, and code coverage.

就像最近引入可穿戴设备来跟踪我们的健康状况一样,软件行业也长期遵循监视软件项目健康状况的做法。 应用最常见的过程是单元测试,集成测试,连续集成和代码覆盖率。

I recently struggled a bit in trying to setup the above mentioned processes for our project, so I wrote this post to document my experience. Since TypeScript is the default language for Angular 2 projects, existing JS setups do not work.

我最近在尝试为我们的项目设置上述流程时遇到了一些困难,因此我写了这篇文章来记录我的经验。 由于TypeScript是Angular 2项目的默认语言,因此现有的JS设置不起作用。

入门 (Getting started)

Here are the steps to setup a Jenkins CI environment for Angular projects with code coverage using SonarQube on a headless Linux server:

以下是在无头Linux服务器上使用SonarQube为覆盖代码的Angular项目设置Jenkins CI环境的步骤:

  • Download Jenkins and set it up on your build server. Make sure you have Java installed on it, as it is required by Jenkins. Note: Jenkins’ default configuration runs with jenkins user, so you might need to set JAVA_HOME for the jenkins user.

    下载Jenkins并将其设置在您的构建服务器上。 确保您已安装Jenkins要求的Java。 注意 :Jenkins的默认配置与jenkins用户一起运行,因此您可能需要为jenkins用户设置JAVA_HOME

  • Once Jenkins is setup, install or make sure you have the following plugins installed from the manage plugins menu:

    设置Jenkins后,请从“管理插件”菜单安装或确保已安装以下插件:
  • Make Git, Node, and SonarQube scanner available to Jenkins. This can be done from the Global Tool Configuration menu in the Manage Jenkins menu. You can either chose to install automatically or provide the installation path for these tools. For example:

    使Jenkins可以使用Git,Node和SonarQube扫描仪。 这可以从Manage Jenkins菜单中的Global Tool Configuration菜单中完成。 您可以选择自动安装,也可以提供这些工具的安装路径。 例如:

  • Lastly, make Jenkins aware of the SonarQube server installation from the Configure menu in Manage Jenkins. For example:

    最后,从Manage Jenkins中Configure菜单使Jenkins知道SonarQube服务器的安装。 例如:

Download SonarQube and set it up on your server. It is usually a simple package extraction on all platforms.

下载SonarQube并在您的服务器上进行设置。 通常,它是在所有平台上的简单软件包提取。

To enable Typescript support in SonarQube, we will use the SonarTsPlugin since SonarQube doesn’t yet have a default plugin for Typescript. Simply download the jar from the releases page of the plugin and place it in your SonarQube installations bin folder. Restart Jenkins once. That is all.

为了在SonarQube中启用Typescript支持,我们将使用SonarTsPlugin,因为SonarQube还没有Typescript的默认插件。 只需从插件的发行页面下载jar,然后将其放在SonarQube安装bin文件夹中。 重新启动詹金斯一次。 就这些。

In the Angular projects karma.conf.js file, change/add to the browsers section ChromeHeadless.

在Angular项目的karma.conf.js文件中,更改/添加到browsers部分ChromeHeadless

Example: browsers:['ChromeHeadless'] . From version 60 onwards Google Chrome supports headless mode on Windows as well. So you can continue to use this setting on local machine as well, in case you work on a Windows machine in an enterprise environment (as I do). I personally prefer the headless mode only for the 1–2 seconds that it saves me.

示例: browsers:['ChromeHeadless'] 。 从版本60开始, Google Chrome也支持 Windows的无头模式。 因此,如果您在企业环境中的Windows计算机上工作(就像我一样),那么您也可以继续在本地计算机上使用此设置。 我个人更喜欢无头模式,这种模式只为我节省了1-2秒。

Add the following to the scripts section in package.json file.

将以下内容添加到package.json文件中的scripts部分。

The above command makes sure that the build is only triggered if all the tests are successful. The --cc flag is a short code for --code-coverage. This flag will produce the projects coverage report in a new folder named coverage within the project directory. The report file is named lcov.info.

上面的命令确保仅在所有测试成功后才触发构建。 --cc标志是--code-coverage的简短代码。 该标志将在项目目录中名为coverage的新文件夹中生成项目coverage报告。 该报告文件名为lcov.info

The default configuration uses Istanbul reporter to show the code coverage report. To publish this coverage report to SonarQube server, the Jenkins SonarQube scanner plugin requires a configuration which can be added as a sonar-project.properties file to the project or within the Jenkins project configuration. Example properties file:

默认配置使用Istanbul报告程序显示代码覆盖率报告。 要将覆盖报告发布到SonarQube服务器,Jenkins SonarQube扫描器插件需要一个配置,该配置可以作为sonar-project.properties文件添加到项目中或在Jenkins项目配置中。 示例属性文件:

组态 (Configuration)

With the above steps done, the project configuration in Jenkins is fairly simple.

完成上述步骤后,Jenkins中的项目配置非常简单。

First create a new configuration using New Item menu and then a Freestyle project.

首先使用New Item菜单创建一个新配置,然后使用Freestyle项目

Next in the Source Code Management section enable Git and setup the projects repo URL:

接下来,在“ 源代码管理”部分中启用Git并设置项目存储库URL:

In the Build Environment section, enable the checkbox for providing the node and npm environment to the build configuration.

在“ 构建环境”部分中,启用复选框以将节点和npm环境提供给构建配置。

Then in the Build sectionn add two build steps. First Execute Shell and second Execute SonarQube Scanner.

然后在“ 构建”部分中添加两个构建步骤。 第一个执行Shell和第二个执行SonarQube Scanner

The shell step is to run the cibuild npm script and the latter to trigger the coverage report analysis. As mentioned above, the sonar properties can be set in the build configuration as well. Example build configuration:

Shell步骤是运行cibuild npm脚本,然后运行cibuild npm脚本来触发coverage报告分析。 如上所述,声纳属性也可以在构建配置中设置。 示例构建配置:

That is all. Now a build can be triggered using the Build Now menu on the projects home page.

就这些。 现在,可以使用项目主页上的“ 立即构建”菜单来触发构建

The build log will show the test results, the build logs, and the publish log to SonarQube server. It is ideal to setup remote triggers or web hooks to trigger the project build. This will ensure the stability of the project whenever there is a change in the repo.

构建日志将显示测试结果,构建日志以及将日志发布到SonarQube服务器。 设置远程触发器或Web挂钩以触发项目构建的理想选择。 每当回购发生变化时,这将确保项目的稳定性。

Finally, on visiting the SonarQube server, the project details should be visible with all the metrics captured from code coverage report. Example:

最后,在访问SonarQube服务器时,应该使用从代码覆盖率报告中捕获的所有指标显示项目详细信息。 例:

This is only the first step towards creating a healthier code base. The Jenkins build can be further enhanced to create a pipeline build for better control and granular modifications.

这只是创建更健康的代码库的第一步。 可以进一步增强Jenkins构建,以创建管道构建,以实现更好的控制和精细的修改。

Originally published at medium.com on September 16, 2017.

最初于2017年9月16日发布在medium.com上。

翻译自: https://www.freecodecamp.org/news/steps-you-should-take-to-build-a-healthy-angular-project-84eea6608d5f/

angular搭建项目步骤

相关文章:

数据库的三大范式和事物

来源:http://blog.csdn.net/w__yi/article/details/19934319 1.1 第一范式(1NF)无重复的列 1.2 第二范式(2NF)属性完全依赖于主键 [ 消除部分子函数依赖 ] 1.3 第三范式(3NF)属性不依赖于其它非…

过滤器和包装器

作者:禅楼望月 过滤器要做的事情 请求过滤器 完成安全检查 重新格式化请求首部或体 建立请求审计或日志响应过滤器 压缩响应流 追加或修改响应流 创建一个完全不同的响应注意不能把过滤器的顺序依赖性硬编码进程序中,它应该由DD控制。 过滤器很像Servlet…

Missing space before value for key 'path'vue.js解决空格报错

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 找到 webpack.base.config.js文件注释掉下面的东西!! module: { rules: [ /*{ test: /\.(js|vue)$/, loader: eslint-loader, enforce: "p…

现代hy-9600音响_从音响工程师到软件工程师-为什么我要学习编码

现代hy-9600音响by Kalalau Cantrell通过Kalalau Cantrell 从音响工程师到软件工程师-为什么我要学习编码 (From Sound Engineer to Software Engineer — Why I’m Learning to Code) I seriously started teaching myself to code several months ago. I say “seriously” …

微信服务号、公众号、企业号注册

转载于:https://www.cnblogs.com/zhoulaoshi/p/6536850.html

a标签onclick事件解析

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 简单介绍<a>标签的常用点击事件的写法及作用 a href"javascript:void(0);" οnclick"js_method()" //javascript:void(0);作用是返回undefined&#xff0c;地址不发生跳转&am…

安卓版文字扫描识别软件

安卓版文字扫描识别软件 文字识别软件被越来越多的人使用&#xff0c;在使用的过程中也发现了一些问题。总结这些问题发现&#xff0c;很多人对软件能够批量识别这个问题比较关注。如果实现批量识别就可以节省时间。但是一些软件还不能实现批量识别&#xff0c;还有的软件能够做…

中级前端笔试_在短短8个月内如何获得中级前端开发人员的角色

中级前端笔试by Matthew Burfield通过马修伯菲尔德(Matthew Burfield) 在短短8个月内如何获得中级前端开发人员的角色 (How I got a mid-level front end developer role in just 8 months) Three weeks ago I landed a mid-level front-end developer role at a startup. Our…

用stm32f10x建立新的工程重要步骤

stm32f10x系列新建空的工程主要原理&#xff1a; 1.添加启动文件 不同的芯片类型的启动文件的容量是不同的&#xff0c;选择适合该芯片的容量作为启动文件。 注意&#xff1a;启动文件是汇编语言编写的&#xff0c;所以文件的后缀名为.s 2.添加时钟配置 配置文件 stm32f10x.的系…

随机生成6位图片验证码

1. [代码][C#]代码 /// <summary> /// PicHandler1 的摘要说明 /// </summary> public class PicHandler1 : IHttpHandler, IRequiresSessionState { private string mCheckNo string.Empty; protected ImgBuilder _ImgBuilder new I…

html 页面传值

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 直接上代码&#xff0c;JS保存全局变量的三种方式。 创建一个新的JS文件&#xff0c; //quanju.js window.localStorage.JQa"JQA"; window.localStorage.setItem(JQb,JQB);//利用localStora…

node.js的开发流程_Node.js子流程:您需要了解的一切

node.js的开发流程by Samer Buna通过Samer Buna Node.js子流程&#xff1a;您需要了解的一切 (Node.js Child Processes: Everything you need to know) 如何使用spawn()&#xff0c;exec()&#xff0c;execFile()和fork() (How to use spawn(), exec(), execFile(), and fork…

对象存在性检测集中管理

在中大型业务系统中&#xff0c; 常常需要从数据库中查询某个实体对象。 在进行处理之前&#xff0c; 必须先检测该实体是否存在&#xff0c;以增强系统的健壮性。 不过&#xff0c; 检测代码充斥在主业务流程中又会大大降低业务逻辑的清晰性&#xff0c; 最好集中起来进行管理…

20155204 2016-2017-2 《Java程序设计》第3周学习总结

20155204 2016-2017-2 《Java程序设计》第3周学习总结 教材学习内容总结 一个原始码中可以有多个类定义&#xff0c;但只能有一个公开类。留心Scanner对于每一种类型的nextxxxx()方法以Java开头的都是API提供的类使用Integer.valueOf()也是为基本类型建立打包器的方式之一Integ…

js表单提交,支持图片上传,包含后端php代码

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 <html><head><meta http-equiv"Content-Type" content"charsetutf-8" /><title>图片上传成功</title></head><body><form name"…

如何破解汽车-快速的速成课程

by Kenny Kuchera肯尼库切拉(Kenny Kuchera) 如何破解汽车-快速的速成课程 (How to hack a car — a quick crash-course) The goal of this article is to get you started hacking cars — fast, cheap, and easy. In order to do this, we’ll spoof the RPM gauge as an e…

367. Valid Perfect Square

题目&#xff1a; Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library function such as sqrt. Example 1: Input: 16 Returns: TrueExample 2: Input: 14 Returns: False 链接…

使用reuseport和recvmmsg优化UDP服务器

http://skoo.me/system/2014/03/18/udp-server-performance/ http://www.helplib.net/s/linux.die/65_3223/man-2-recvmmsg.shtml recvmmsg(2) - Linux man page转载于:https://www.cnblogs.com/jingzhishen/p/4145732.html

js把for循环出来的数据存入数组

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 var obj [];for(var i 0;i<obj.length;i){arr.push(obj[i]);}; console.obj(arr); 1&#xff1a;obj是一个数组对象 2&#xff1a;push()方法是数组的栈底添加 意思是往数组的底部添加 3&#xff1a…

flexbox布局_这是您可以使用FlexBox制作的5种布局

flexbox布局The CSS Flexible Box Layout — Flexbox — provides a simple solution to the design and layout problems designers and developers have faced with CSS. Let me show you how to use it to generate some common layouts and challenges that you will face …

数据结构之线性表

数据结构之线性表 目录 概述顺表特点 顺表的操作 准备 创建顺表 查询顺表长度 遍历顺表 按序查找 按值查找 插入 删除 链表实际使用概述 线性表是一种线性的存储结构&#xff0c;表头有唯一后继元素&#xff0c;表尾有唯一前驱元素&#xff0c;表中的元素既有前驱又有后继 顺表…

【BZOJ-3456】城市规划 CDQ分治 + NTT

题目链接 http://www.lydsy.com/JudgeOnline/problem.php?id3456 Solution 这个问题可以考虑dp&#xff0c;利用补集思想 N个点的简单图总数量为$2^{\binom{N}{2}}$&#xff0c;要求的是简单联通图&#xff0c;所以可以用总量减不连通的。 不连通的可以通过枚举与某个固定点的…

微信小程序获取openid和session_key并且把openid存入数据库

微信小程序开发交流qq群 581478349 微信小程序获取openid和session_key并且把openid存入数据库。已经调用openid的demo 前后端代码都有&#xff0c;后端php实现 在其它地方同步调用openid。&#xff08;确保用户完成登录再进行后续的操作&#xff09;&#xff1b; onLoad…

如何通过五个简单步骤成为更好的Stack Overflow用户

by Artem Stepanenko由Artem Stepanenko 如何通过五个简单步骤成为更好的Stack Overflow用户 (How to become a better Stack Overflow user in five simple steps) Software developers cannot imagine their lives without Stack Overflow.没有堆栈溢出&#xff0c;软件开发…

wm_concat

select org_name,department,to_char(wm_concat(ebs_org_num)) from GHB.org_add_tmp group by org_name,department ; 转载于:https://www.cnblogs.com/pier22/p/6546726.html

5 MySQL索引

目录&#xff1a; 1. 索引概述 1.1 为什么引入索引 1.2 什么是索引 1.3 索引的好处 1.4 索引的不足 1.5 索引分类 2. 索引设计原则 3. 索引建立和删除 3.1 索引创建 3.2 索引删除 4. 索引实验 1. 索引概述 1.1 为什么引入索引[1] 问题&#xff1a;假设数据库中一个表有10^6条记…

js多维数组渲染HTML js for循环渲染页面

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 直接上代码&#xff0c;有不懂的可以留言。 <!DOCTYPE html> <html><head><meta charset"UTF-8"><script src"https://cdn.bootcss.com/jquery/2.1.1/jquery…

使用TensorFlow跟踪千年猎鹰

by Nick Bourdakos由Nick Bourdakos 使用TensorFlow跟踪千年猎鹰 (Tracking the Millennium Falcon with TensorFlow) At the time of writing this post, most of the big tech companies (such as IBM, Google, Microsoft, and Amazon) have easy-to-use visual recognition…

POJ2387 Til the Cows Come Home -DIJKSTRA 练习

题目大意是&#xff1a;有N个牛棚和T条边相连&#xff0c;每条边有个权值&#xff0c;问1号到N号牛棚之间的最短距离 本题是又是DIJKSTRA最短路水题&#xff0c;注意任何两个牛棚之间可能有多条路相连&#xff0c;输入时先输入边&#xff0c;再输入点&#xff0c;程序如下&…

<a>标签带参数跳转并在下一个页面接收

微信小程序开发交流qq群 581478349 承接微信小程序开发。扫码加微信。 正文&#xff1a; <a href"home.html?id1">跳转</a> //home.html <script type"text/javascript"> var aGetRequest();console.log("id:"a[id]) //…