如何使用Create React App DevOps自動化工作中所有無聊的部分

by James Y Rauhut

詹姆士·魯豪(James Y Rauhut)

如何使用Create React App DevOps自動化工作中所有無聊的部分 (How I automate all of the boring parts of my job with Create React App DevOps)

When you have responsibilities as one of the only designers — and possibly developer s— on your team, automation becomes your best friend.

當您作為團隊中僅有的設計師(甚至是開發人員)之一負責時,自動化將成為您最好的朋友。

At work, I have both responsibilities as a designer and sometimes as a lone developer. This means that there is not much time to configure the dev environment I am working on. Time is also wasted when I have to manually update the apps to their online environment.

在工作中,我既擔負設計師的職責,有時也承擔著獨自開發的職責。 這意味著沒有太多時間來配置我正在開發的開發環境。 當我不得不手動將應用程序更新到其在線環境時,也浪費了時間。

Thankfully, there are free tools that help us prototype and release in no time: Create React App, Bluemix, GitHub, and Travis CI. I’m going to share with you how I use all of these to automate all of the boring parts of my job with Create React App DevOps.

值得慶幸的是,有免費的工具可以幫助我們立即進行原型設計和發布:創建React App,Bluemix,GitHub和Travis CI。 我將與您分享如何使用所有這些通過Create React App DevOps自動執行工作中所有無聊的部分。

Update March 3rd, 2017: Thanks to a heads up from a commenter, I was warned not to use Babel-Node in production (on Bluemix). Create React App DevOps now reflects that with v1.1.0!

2017年3月3日更新:感謝評論者的注意,警告我不要在生產中使用Babel-Node(在Bluemix上)。 現在,使用v1.1.0可以創建React App DevOps !

There are three ways you can adapt this process yourself:

您可以通過三種方式自己調整此過程:

  • Follow along with this post as we write the project together

    在我們一起編寫項目時,跟隨這篇文章
  • Inspect the comparison between the initial Create React App use and the final commit: Github Comparison Between First and Last Commit

    檢查最初的Create React App使用和最終提交之間的比較 : Github第一次提交和最后一次提交之間的比較

  • Fork the repo and follow the instructions below: Fork Create React App DevOps

    分叉倉庫,并按照以下說明進行操作: 分叉創建React App DevOps

Check out the app live at: https://create-react-app-devops.mybluemix.net/

通過以下網址實時查看該應用程序:https ://create-react-app-devops.mybluemix.net/

If you want to know the guts of the project, then continue reading to make it with me! There will be six sections:

如果您想了解該項目的精髓,請繼續閱讀以與我合作! 將分為六個部分:

  1. Use Create React App to Get the UI Up

    使用Create React App來建立UI
  2. Setup Your Server with Node, Express, and Babel

    使用Node,Express和Babel設置服務器
  3. Run the App on the Web with Bluemix

    使用Bluemix在Web上運行應用程序
  4. Automagically Deploy from Github with Travis CI

    使用Travis CI從Github自動部署
  5. Fetch API Data While Keeping Keys Secure

    在保持密鑰安全的同時獲取API數據
  6. Create a Staging App for Experimentation

    創建暫存應用進行實驗

使用Create React App來建立UI (Use Create React App to Get the UI Up)

When I first started using React for front-end projects, I wasted a lot of time. A lot of that time was configuring Webpack and various plug-ins. Thankfully, Create React App was created to keep your projects configured properly. There is an option to “eject” your Create React App projects, but I avoid ejecting. That is so that I can continue receiving Facebook’s updates to the project.

當我第一次開始將React用于前端項目時,我浪費了很多時間。 大部分時間是配置Webpack和各種插件。 幸運的是,創建React應用程序是為了保持您的項目正確配置。 有一個選項可以“彈出”您的Create React App項目,但是我避免彈出。 這樣一來,我就可以繼續接收Facebook對項目的更新。

  1. Install Node to manage the packages we use and server.

    安裝Node來管理我們使用的軟件包和服務器。

  2. Install Yarn (optional) to speed up the installation of packages. If you choose not to, just keep in mind that terminal commands like yarn run --- are usually npm run ---.

    安裝紗線 (可選)以加快軟件包的安裝。 如果您選擇不這樣做,則請記住,諸如yarn run ---類的終端命令通常是npm run ---

  3. It is time to open up your terminal. Install Create React App globally: yarn global add create-react-app

    現在是時候打開您的終端了。 全局安裝Create React App: yarn global add create-react-app

  4. Now let Create React App make your project or you and navigate into it: create-react-app <app-name>; and cd <app-name>

    現在,讓Create React App創建您的項目或進入您的項目: create-react-app <app-na me> ; and cd < ; and cd <應用程序名稱>

Side Note: Anytime you see “<app-name>” in this write-up, you can replace it with a unique name for your project like “super-cool-app”.

旁注 :只要在本文中看到“ <app-name>”,就可以用項目的唯一名稱替換它,例如“ super-cool-app”。

?????? (?????)

You can now work on all of the client-side (user interface) code! Run yarn start and Create React App will open a tab in your browser to show you the UI. Anytime you edit the client-side code in the <app-name>;/src/, the browser will refresh with the changes!?????

現在,您可以處理所有客戶端(用戶界面)代碼! 運行yarn start ,Create React App將在瀏覽器中打開一個標簽,向您顯示UI。 每當您在<app-name> ; / src /中編輯客戶端代碼時,瀏覽器都會刷新所做的更改!

使用Node,Express和Babel設置服務器 (Setup Your Server with Node, Express, and Babel)

Now let’s get a server running so that you can host the app online. Controlling your own Node server will also be important later to fetch data with an API from services like Github.

現在,讓服務器運行,以便您可以在線托管應用程序。 稍后,控制自己的Node服務器對于從Github之類的服務中使用API??獲取數據也很重要。

  1. Let’s add all of the packages for a Node server. The Babel related packages will allow you to use the latest Javascript functionality: yarn add babel-cli babel-preset-es2015 babel-preset-stage-2 compression express

    讓我們為節點服務器添加所有軟件包。 與Babel相關的軟件包將允許您使用最新的Javascript功能: yarn add babel-cli babel-preset-es2015 babel-preset-stage-2 compression express

  2. Now make an index.js file in the root of the project folder to represent our Node server:

    現在,在項目文件夾的根目錄中創建一個index.js文件,以表示我們的節點服務器:

import compression from 'compression';import express from 'express'; const app = express();const port = process.env.PORT || 8080;app.use(compression()); app.use(express.static('./build')); app.listen(port, (err) => { if (err) {   console.log(err);   return; }
console.log(`Server is live at http://localhost:${port}`);});

3. You can now see all of the dependencies we installed in package.json. Let’s add a script called “bluemix” to run the server and section called “babel” to configure Babel:

3.現在,您可以看到我們在package.json安裝的所有依賴項。 讓我們添加一個名為“ bluemix”的腳本來運行服務器,并添加一個名為“ babel”的部分來配置Babel:

"scripts": {  "bluemix": "babel-node index.js",  "start": "react-scripts start",  "build": "react-scripts build",  "test": "react-scripts test --env=jsdom",  "eject": "react-scripts eject",},"babel": {  "presets": [    "es2015",    "stage-2"  ]}

4. yarn build && yarn bluemix will build the app and run the server. However, we want to add a dev mode to the server similar to our client-side code. This way we see changes from just saving index.js when we are coding. Let’s add some dependencies that will let us do this: yarn add babel-watch concurrently --dev

4. yarn build && yarn bluemix將構建應用程序并運行服務器。 但是,我們希望向服務器添加類似于客戶端代碼的開發模式。 通過這種方式,我們看到了在編碼時僅保存index.js變化。 讓我們添加一些依賴關系,讓我們做到這一點: yarn add babel-watch concurrently --dev

5. Now update the “start” script in package.json so that we run Create React App’s dev mode and our server. We will also add a “proxy” line. This line tells Create React App that a server can take requests that are not found in the client-side code:

5.現在更新package.json中的“ start”腳本,以便我們運行Create React App的dev模式和我們的服務器。 我們還將添加“代理”行。 此行告訴Create React App服務器可以接受客戶端代碼中未找到的請求:

"proxy": "http://localhost:8081","scripts": {  "bluemix": "babel-node index.js",  "start": "concurrently \"PORT=8080 react-scripts start\" \"PORT=8081 babel-watch index.js\"",  "build": "react-scripts build",  "test": "react-scripts test --env=jsdom",  "eject": "react-scripts eject",},

?????? (?????)

You can now work on the server-side code in index.js! Run yarn start and both the Create React App dev mode and our server will respond to changes saved!?????

您現在可以在index.js的服務器端代碼上工作了! 運行yarn start和Create React App dev模式,我們的服務器將響應保存的更改!

使用Bluemix在Web上運行應用程序 (Run the App on the Web with Bluemix)

Since I work at IBM, Bluemix is our go-to hosting platform. Not only do we host our final products on Bluemix, but we also host any prototypes to share with peers and user test. I also use Bluemix for personal projects like this one because it has a solid free tier.

自從我在IBM工作以來,Bluemix是我們的首選托管平臺。 我們不僅將最終產品托管在Bluemix上,而且還托管任何原型以與同行和用戶測試共享。 我還將Bluemix用于這樣的個人項目,因為它具有可靠的免費層。

  1. Create a free account on Bluemix.

    在Bluemix上創建一個免費帳戶。

  2. Install the Cloud Foundry CLI. Since Bluemix is built on top of an open-source project called Cloud Foundry, you will see “cf” in a lot of our commands.

    安裝Cloud Foundry CLI 。 由于Bluemix是建立在一個名為Cloud Foundry的開源項目之上的,因此您會在許多命令中看到“ cf”。

  3. Similar to .gitignore files, we should make a file to prevent unnecessary files from being uploaded to Bluemix. Make .cfignore in the project’s root folder to do this:

    .gitignore文件類似,我們應該制作一個文件,以防止將不必要的文件上傳到Bluemix。 在項目的根文件夾.cfignore為執行以下操作:

/node_modules .DS_Store npm-debug.log* yarn-debug.log* yarn-error.log*

4. Now we can tell Bluemix all of our app’s settings for the deploy with a manifest.yml file in the root of the project:

4.現在,我們可以在項目根目錄中使用manifest.yml文件來告訴Bluemix我們所有應用程序的設置設置:

---applications:- name: <app-name>  buildpack: https://github.com/cloudfoundry/nodejs-buildpack  command: npm run bluemix  disk_quota: 256MB  memory: 128MB

5. Finally, login into Bluemix from your terminal with cf login -a https://api.ng.bluemix.net, build your app with yarn build, and then push your app into the world with cf push.

5.最后,使用cf login -a https://api.ng.bluemix.net從您的終端登錄Bluemix,使用yarn build構建您的應用程序,然后使用cf push將您的應用程序推向世界。

?????? (?????)

After about five minutes, your terminal should say the app is live at <app-name>.mybluemix.net! Now the world can see it. A common error is that your app name has already been taken on Bluemix. Simply choose a more unique name and it should work!?????

大約五分鐘后,您的終端應顯示該應用程序已在<app-name> .mybluemix.net上運行! 現在世界可以看到它。 一個常見的錯誤是您的應用程序名稱已在Bluemix上獲取。 只需選擇一個更獨特的名稱,它就可以工作!

使用Travis CI從Github自動部署 (Automagically Deploy from Github with Travis CI)

One of the most tedious parts of managing an app is deploying it every time you have changes ready. I would even get lazy and batch my deploys whenever I finally felt like doing it. Thanks to Travis CI (Continuous Integration), deploying can become as simple as managing your Github repo.

每次準備好進行更改時,管理應用程序中最繁瑣的工作之一就是對其進行部署。 每當我最終想做的時候,我什至會變得懶惰并批處理我的部署。 借助Travis CI(持續集成),部署可以像管理Github倉庫一樣簡單。

  1. First, you need to make a Github account and set up the Git on your computer.

    首先,您需要注冊一個Github帳戶并在計算機上設置Git 。

  2. Next, create a new repo on Github.com and then follow the terminal instructions provided to push your project to Github:

    接下來,在Github.com上創建一個新的倉庫 ,然后按照提供的終端說明將項目推送到Github:

git initgit add .git commit -m 'Initial commit'git remote add origin https://github.com/<github-username/<app-name>.gitgit push -u origin master

3. Now head over to Travis CI to login with your Github credentials. Hit the “+” icon to activate your new repo. If you do not see the repo you just created, click “Sync account” and then it should show up.

3.現在轉到Travis CI ,使用您的Github憑據登錄。 點擊“ +”圖標激活您的新倉庫。 如果沒有看到您剛剛創建的存儲庫,請單擊“同步帳戶”,然后它將顯示。

4. Then click on the project’s settings in Travis to choose the following options:

4.然后在Travis中單擊項目的設置以選擇以下選項:

Build only if .travis.yml is present = OnBuild pushes = OnLimit concurrent jobs = OffBuild pull requests = On (This will allow Github to still run any automated tests you add in the future for opened PRs.)Environment Variables: BLUEMIX_PASSWORD = <Your-bluemix-password>

僅當存在.travis.yml時才進行構建= OnBuild推送= OnLimit并發作業= OffBuild拉取請求= On(這將使Github仍可以運行您將來為打開的PR添加的任何自動化測試。)環境變量: BLUEMIX_PASSWORD = <Your-bluemix-passwo rd>

5. The biggest step here is adding the blueprint for Travis as a .travis.yml file in the project’s root:

5.這里最大的步驟是將Travis的藍圖作為.travis.yml文件添加到項目根目錄中:

sudo: truelanguage: node_jsnode_js:- '5.7'cache:  yarn: true  directories:    - node_modulesenv:  global:  - CF_API=https://api.ng.bluemix.net/  - CF_USERNAME=<Your-bluemix-email>  - CF_ORG=<Your-bluemix-email>  - CF_SPACE=devbefore_deploy:  - wget https://s3.amazonaws.com/go-cli/releases/v6.12.4/cf-cli_amd64.deb -qO temp.deb && sudo dpkg -i temp.deb  - rm temp.deb  - cf login -a ${CF_API} -u ${CF_USERNAME} -p ${BLUEMIX_PASSWORD} -o ${CF_ORG} -s ${CF_SPACE}  - cf install-plugin autopilot -r CF-Community  - yarn builddeploy:  - edge: true    provider: script    script: if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cf zero-downtime-push <My-app> -f ./manifest.yml; else echo "PR skip deploy"; fi    skip_cleanup: true    on:      branch: master

Important: Notice that there two places where you insert your Bluemix email and one place where you insert the name of the app on Bluemix!

重要:請注意,有兩個地方可以插入您的Bluemix電子郵件,一個地方可以在Bluemix上插入應用程序的名稱!

There is a lot going on here. So I will try to summarize it: In the before_deploy section, Travis is building the app, logging into Bluemix as you, and then downloading a Cloud Foundry plugin called Autopilot. Then in the deploy section, Travis decides if the deploy is an open pull request or an actual commit to the Github master branch. If it is an actual commit, run Autopilot to deploy the app.

這里有很多事情。 因此,我將嘗試總結一下:在before_deploy部分中,Travis正在構建應用程序,以您的身份登錄到Bluemix,然后下載一個名為Autopilot的Cloud Foundry插件。 然后,在“部署”部分中,Travis決定部署是開放拉取請求還是對Github master分支的實際提交。 如果是實際提交,請運行Autopilot部署應用程序。

Autopilot practices Blue-Green Deployment. This means that the new version of your app will be given the name <my-app>-venerable on Bluemix. If the new version builds and runs successfully, the old version of the app is deleted and the new version renames itself to the original name. If the deploy fails, <my-app&gt;-venerable stays up so that you can debug the logs and the old version of the app keeps running so your users see zero downtime!

自動駕駛儀實行藍綠色部署。 這意味著您的應用程序的新版本將被命名為<my-app>-ven在Bluemix上具有較高的聲譽。 如果新版本生成并成功運行,則該應用的舊版本將被刪除,新版本會將其自身重命名為原始名稱。 如果部署ails, <my-app&g t; -venerable會保持運行狀態,以便您可以調試日志,并且舊版本的應用程序將繼續運行,從而使用戶看到的停機時間為零!

?????? (?????)

Dope DevOps, Batman! Navigate to https://travis-ci.org/<github-username>/<app-name>/builds and you should see a Travis build about to happen. If you click into it, you can watch it start and follow it deploying for you!?????

Dope DevOps,蝙蝠俠! 導航至https://travis-ci.org/<github-username>/<app-nam e> / builds,您應該看到Travis構建即將發生。 如果單擊它,您可以觀看它的啟動并為您部署它!

在保持密鑰安全的同時獲取API數據 (Fetch API Data While Keeping Keys Secure)

Most apps use data from different sources to put together their offerring. For an app to get external data, they use an API to fetch the data. For the API to make sure the right app is fetching data, the app is given a key to identify itself. We need to keep this key secret from our Github repo though!

大多數應用程序使用來自不同來源的數據來匯總其報價。 為了使應用程序獲取外部數據,他們使用API??來獲取數據。 為了使API確保正確的應用程序正在獲取數據,將為該應用程序提供一個用于標識自身的密鑰。 不過,我們需要從我們的Github存儲庫中保守這個關鍵秘密!

  1. First, let’s ask the Github API for a key. Under “Select scopes”, we will check public_repo to get your repo information. Click “Generate token” and then you will get a key next to a green checkmark!

    首先,讓我們向Github API索要密鑰 。 在“選擇范圍”下,我們將檢查public_repo以獲取您的回購信息。 單擊“生成令牌”,然后您將在綠色復選標記旁邊看到一個密鑰!

  2. It is time to add the key to our project locally as keys.json in the root of our project:

    現在是時候在項目根目錄中將key作為keys.json本地添加到我們的項目中了:

{  "github": "<your-github-key>"}

However, we do not want your precious key to be uploaded to your Github repo. So, add this file to your .gitignore file:

但是,我們不希望將您的寶貴密鑰上傳到您的Github存儲庫中。 因此,將此文件添加到您的.gitignore文件中:

# misc.DS_Store.envnpm-debug.log*yarn-debug.log*yarn-error.log*keys.json

3. Now that we have your key, we can add a server request. Install Request to your project with yarn add request and then edit your server’s index.js:

3.現在我們有了您的密鑰,我們可以添加服務器請求。 使用yarn add request將Request安裝到項目中,然后編輯服務器的index.js

import compression from 'compression';import express from 'express';import fs from 'fs';import request from 'request';
const app = express();const port = process.env.PORT || 8080;app.use(compression());
let keys;if (fs.existsSync('./keys.json')) {  keys = require('./keys.json');} else {  keys = JSON.parse(process.env.VCAP_SERVICES)['user-provided'][0].credentials;}
app.get('/github', (req, res) => {  request({    url: `https://api.github.com/user/repos?affiliation=owner,collaborator&access_token=${keys.github}`,    headers: {      'user-agent': 'node.js',    },  }, (err, response, body) => {    if (!err && response.statusCode === 200) {      res.send(body);    }  });});
app.use(express.static('./build'));
app.listen(port, (err) => {  if (err) {    console.log(err);    return;  }  console.log(`Server is live at http://localhost:${port}`);});

You will first notice an if statement checking if we have the local keys.json file. The “else” in that statement will cover when the app is on Bluemix later. We then have an endpoint where pinging http://localhost:8080/github will return your profile’s repos!

您將首先注意到一條if語句,用于檢查我們是否具有本地keys.json文件。 該語句中的“其他”將覆蓋應用程序稍后在Bluemix上使用的時間。 然后,我們有了一個終結點,在該終結點上ping http://localhost:8080/github將返回您的配置文件的存儲庫!

4. Open up src/App.js to fetch that data to your UI from your server. After these additions, yarn start should show all of your project’s repos listed :

4.打開src/App.js以將數據從服務器獲取到UI中。 添加完這些之后, yarn start應該會列出您項目的所有存儲庫:

import React, { Component } from 'react';import logo from './logo.svg';import './App.css';
class App extends Component {
state = {    repos: [],  }
componentDidMount() {    fetch('/github')    .then(response => response.json())    .then((data) => {      const repos = data.map((repo) =>        <p key={repo.id}>{repo.name}</p>      );
this.setState({ repos })    });  }
render() {    return (      <div className="App">        <div className="App-header">          <img src={logo} className="App-logo" alt="logo" />          <h2>Welcome to React</h2>        </div>        <p className="App-intro">          To get started, edit <code>src/App.js&lt;/code> and save to reload.        </p>        <h3>App Creator's Repos:</h3>        {this.state.repos}      </div>    );  }}
export default App;

5. Now that we can use the Github API securely in dev mode, let’s make sure your Bluemix app can also get the API key. We are going to create a user-provided service on Bluemix in the terminal: cf cups keys -p keys.json. Then tell the manifest.json that the app should always bind itself to that service:

5.現在我們可以在開發人員模式下安全地使用Github API,讓我們確保您的Bluemix應用程序也可以獲取API密鑰。 我們將在終端上的Bluemix上創建一個用戶提供的服務: cf cups keys -p keys.json 。 然后告訴manifest.json應用程序應始終將自身綁定到該服務:

---applications:- name: <app-name>  buildpack: https://github.com/cloudfoundry/nodejs-buildpack  command: npm run bluemix  disk_quota: 256MB  memory: 128MB  services:     - keys

Side Note: If you ever need to update the keys on Bluemix, you can run cf uups keys -p keys.json!

旁注:如果需要更新Bluemix上的鍵,則可以運行cf uups keys -p keys.json

?????? (?????)

After Travis updates your Bluemix app, you should see the UI fetching all of your repos live on the web! We did go through a lot of trouble keeping the keys off of github.com. This is because other devs can abuse your API keys if they get a lot of them.?????

Travis更新您的Bluemix應用程序之后,您應該會看到UI實時在網絡上獲取所有存儲庫! 在將密鑰保留在github.com上的過程中,我們確實遇到了很多麻煩。 這是因為其他開發人員如果得到很多,則會濫用您的API密鑰。

創建暫存應用進行實驗 (Create a Staging App for Experimentation)

Now that our production version of the app has DevOps set up, let’s build a staging app. This will help us share works-in-progress for user testing and peer review!

現在我們的應用程序生產版本已設置DevOps,讓我們構建一個臨時應用程序。 這將幫助我們共享正在進行的工作,以進行用戶測試和同行評審!

  1. We need to make a manifest file for Bluemix that specifies our new staging app now. In the root of your project, make a manifest-staging.yml file:

    我們需要為Bluemix創建一個清單文件,該清單文件現在指定我們的新暫存應用程序。 在項目的根目錄中,創建一個manifest-staging.yml文件:

---applications:- name: <my-app>-staging  buildpack: https://github.com/cloudfoundry/nodejs-buildpack  command: npm run bluemix  disk_quota: 256MB  memory: 128MB  services:     - keys

2. Go ahead and deploy this staging app directly to Bluemix with the new manifest file: cf push -f manifest-staging.yml

2.繼續,使用新的清單文件將這個登臺應用程序直接部署到Bluemix: cf push -f manifest-staging.yml

3. Then we are going to edit the deploy scripts in .travis.yml. We need to change the original deploy script for when we commit to master to update the new staging app. We also need to add a new deploy script for the original production app:

3.然后,我們將在.travis.yml編輯部署腳本。 當我們承諾掌握更新新的登臺應用程序時,我們需要更改原始的部署腳本。 我們還需要為原始生產應用添加新的部署腳本:

deploy:  - edge: true    provider: script    script: if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cf zero-downtime-push <my-app>-staging -f ./manifest-staging.yml; else echo "PR skip deploy"; fi    skip_cleanup: true    on:      branch: master  - edge: true    provider: script    script: if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cf zero-downtime-push <my-app> -f ./manifest.yml; else echo "PR skip deploy"; fi    skip_cleanup: true    on:      tags: true

So now that we update the staging app by committing to the Github master branch, how do we update the production app? You will use Github’s Releases functionality as if your app is a real offerring. ?

因此,現在我們通過提交到Github master分支來更新登臺應用程序,我們如何更新生產應用程序? 您將使用Github的Releases功能 ,就好像您的應用程序是真正的產品一樣。 ?

4. Go ahead and push your latest changes to Github! Then navigate to “Releases” on the Github repo and create a new release.

4.繼續并將最新更改推送到Github! 然后導航到Github存儲庫上的“發布”并創建一個新版本。

?????? (?????)

Based on the last step, you should see two builds in queue on Travis CI. One will be the staging app updating because of the latest commit. The other will be your production app updating because of the new release!?????

基于最后一步,您應該在Travis CI上看到兩個構建隊列。 其中之一將是登臺應用程序更新,因為最新的提交。 另一個將是由于新版本而更新您的生產應用程序!

DevOps的最終,最重要的價值 (The Final, Most Important Value of DevOps)

I want to end this write-up by stressing the most important part of DevOps: automated testing. Whenever Travis runs, including in opened pull requests, it will check that the command yarn test passes before taking action. Create React App already has yarn test configured with Jest. However, you can add accessibility, linting, and any other testing framework you are familiar with!

我想通過強調DevOps的最重要部分: 自動化測試來結束本文。 每當Travis運行時,包括在打開的拉取請求中,它將在執行操作之前檢查命令yarn test通過。 Create React App已經使用Jest配置了yarn test 。 但是,您可以添加可訪問性,棉絨和您熟悉的任何其他測試框架!

To recap what we have done: First, we quickly got our React project configured thanks to Create React App. Then we built a simple server. We pushed the app into the world. Next, we got Travis deploying the app (with zero downtime) for any of our changes. Then we used the Github API while keeping our key away from public eyes. Lastly, we also set up a staging app so that we could test pre-release.

回顧一下我們所做的事情:首先,借助Create React App,我們快速配置了React項目。 然后,我們構建了一個簡單的服務器。 我們將應用程序推向了世界。 接下來,我們讓Travis為我們的任何更改部署了應用程序(停機時間為零)。 然后,我們使用Github API,同時使我們的密鑰遠離公眾。 最后,我們還設置了一個臨時應用程序,以便我們可以測試預發布版本。

I hope this project has helped make your workflow easier as you make epic web apps! A big ? goes to the contributors of Babel, Create React App, Express, Node, and all other packages used. Also, all the ??? goes to Bluemix, Github, and Travis CI for their free tiers.

我希望這個項目可以幫助您在制作史詩般的Web應用程序時簡化工作流程! 一個大的 ? 歸功于 B abel, C reate React App, Express, N ode和所有其他使用的軟件包的貢獻者。 而且,所有???都可以免費獲得Bluemix,Github和Travis CI。

Please share in the comments or tweet me if this helped you! I also would love to hear of different workflows!

請分享評論或通過推特發給我,如果這對您有幫助! 我也很想聽聽不同的工作流程!

You can also contact me by leaving a comment, emailing me, or tweeting to @seejamescode. I work in ATX for IBM Design, and always love conversations with the web design community.

您還可以通過發表評論, 給我發送電子郵件或發推文到@seejamescode來與我聯系。 我在ATX for IBM Design工作,并且一直喜歡與Web設計社區的對話。

You may also like…

您可能還喜歡…

How to crank your progressive web app’s Google Lighthouse score up to 100If there’s one message the Chrome Dev Team wants to drive home to developers, it’s this: performance matters.medium.freecodecamp.com

如何提高您的漸進式網絡應用的Google Lighthouse得分(最高可達100分) 如果有一條消息,Chrome開發團隊想帶回家給開發人員,那就是:性能至關重要。 medium.freecodecamp.com

在Github上查看Create React App DevOps (Check out Create React App DevOps on Github)

翻譯自: https://www.freecodecamp.org/news/lets-write-create-react-app-devops-together-dc19512c6fbb/

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/395709.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/395709.shtml
英文地址,請注明出處:http://en.pswp.cn/news/395709.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

java 無侵入監控_MyPerf4J 一個高性能、無侵入的Java性能監控和統計工具

MyPerf4J一個針對高并發、低延遲應用設計的高性能且無侵入的實時Java性能監控和統計工具。 受 perf4j 和 TProfiler啟發而來。MyPerf4J具有以下幾個特性&#xff1a;無侵入: 采用JavaAgent方式&#xff0c;對應用程序完全無侵入&#xff0c;無需修改應用代碼高性能: 性能消耗非…

Apple Swift編程語言新手教程

文件夾 1 簡單介紹2 Swift入門3 簡單值4 控制流5 函數與閉包6 對象與類7 枚舉與結構1 簡單介紹 今天凌晨Apple剛剛公布了Swift編程語言&#xff0c;本文從其公布的書籍《The Swift Programming Language》中摘錄和提取而成。希望對各位的iOS&OSX開發有所幫…

javascript 減少回流

減少回流&#xff08;REFLOWS&#xff09; 當瀏覽器重新渲染文檔中的元素時需要 重新計算它們的位置和幾何形狀&#xff0c;我們稱之為回流。回流會阻塞用戶在瀏覽器中的操作&#xff0c;因此理解提升回流時間是非常有幫助的。 回流時間圖表 你應該批量地觸發回流或重繪&#x…

[國家集訓隊] 特技飛行

題目背景 1.wqs愛好模擬飛行。 2.clj開了一家神犇航空&#xff0c;由于clj還要玩游戲&#xff0c;所以公司的事務由你來打理。 注意&#xff1a;題目中只是用了這樣一個背景&#xff0c;并不與真實/模擬飛行相符 題目描述 神犇航空開展了一項載客特技飛行業務。每次飛行長N個單…

react 手指移開_代碼簡介:React的五個死亡手指

react 手指移開Here are three stories we published this week that are worth your time:這是我們本周發布的三個值得您關注的故事&#xff1a; React’s Five Fingers of Death. Master these five concepts, then master React: 10 minute read React的五指死亡。 掌握這五…

java lock接口_Java Lock接口

Java Lock接口java.util.concurrent.locks.Lock接口用作線程同步機制&#xff0c;類似于同步塊。新的鎖定機制更靈活&#xff0c;提供比同步塊更多的選項。 鎖和同步塊之間的主要區別如下&#xff1a;序列的保證 - 同步塊不提供對等待線程進行訪問的序列的任何保證&#xff0c;…

springcloud-05-ribbon中不使用eureka

ribbon在有eureka的情況下, 可以不使用eureka, 挺簡單, 直接上代碼 application.xml server:port: 7002 spring:# 設置eureka中注冊的名稱, 全小寫, 否則大小寫混雜出現問題application:name: microservice-consumer-movie-ribben-ymllogging:level:root: INFOorg.hibernate: I…

SQL mysql優化

慢查詢 如何通過慢查日志發現有問題的SQL&#xff1f; 查詢次數多且每次查詢占用時間長的SQL pt-query-digest分析前幾個查詢IO大的SQL pt-query-diges分析中的Rows examine項未命中索引的SQL pt-query-digest分析中Rows examine 和Rows Send的對比如何分析SQL查詢 使用explain…

轉: 關于 ssl的建立鏈接的過程

轉自&#xff1a; http://www.ruanyifeng.com/blog/2014/02/ssl_tls.html SSL/TLS協議運行機制的概述 作者&#xff1a; 阮一峰 日期&#xff1a; 2014年2月 5日 互聯網的通信安全&#xff0c;建立在SSL/TLS協議之上。 本文簡要介紹SSL/TLS協議的運行機制。文章的重點是設計思…

第一章第一個c#程序上機_我從第一個#100DaysOfCode中學到的東西

第一章第一個c#程序上機On May 17th, I completed my first round of #100DaysOfCode. In case you haven’t heard, #100DaysOfCode is a challenge, or movement, started by Alexander Kallaway for people interested in coding. The basis of the challenge is that you p…

[Swift通天遁地]一、超級工具-(2)制作美觀大方的環形進度條

★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★?微信公眾號&#xff1a;山青詠芝&#xff08;shanqingyongzhi&#xff09;?博客園地址&#xff1a;山青詠芝&#xff08;https://www.cnblogs.com/strengthen/&#xff09;?GitHub地址&a…

SPOJ QTREE6 lct

題目鏈接 島娘出的題。還是比較easy的 #include <iostream> #include <fstream> #include <string> #include <time.h> #include <vector> #include <map> #include <queue> #include <algorithm> #include <stack> #in…

使用charles 抓取手機上的操作

Charles上的設置要截取iPhone上的網絡請求&#xff0c;我們首先需要將Charles的代理功能打開。在Charles的菜單欄上選擇“Proxy”->“Proxy Settings”&#xff0c;填入代理端口8888&#xff0c;并且勾上”Enable transparent HTTP proxying” 就完成了在Charles上的設置。如…

FreeCodeCamp納什維爾聚會的回顧

by Seth Alexander塞斯亞歷山大(Seth Alexander) FreeCodeCamp納什維爾聚會的回顧 (A Recap from the freeCodeCamp Nashville Meetup) At a recent freeCodeCamp meetup, a small group of campers got together to solve some coding challenges and we talk shop.在最近的f…

php查詢車位系統代碼,php車輛違章查詢數據示例

方便有車一族隨時了解自己是否有過交通違章&#xff0c;避免因遺忘或逾期處理違章罰單而造成的不必要損失。本代碼示例是基于聚合數據全國車輛違章查詢API的調用&#xff0c;有需要的可以往下看。使用前你需要&#xff1a;一、引入封裝好的請求類class.juhe.wz.phpheader(Conte…

[HNOI2011]XOR和路徑

嘟嘟嘟 一看到異或&#xff0c;就想到按位處理&#xff0e; 當處理到第\(i\)位的時候&#xff0c;\(f[u]\)表示節點\(u\)到\(n\)的路徑&#xff0c;這一位為\(1\)的期望&#xff0c;那么為\(0\)就是\(1 - f[u]\)&#xff0c;于是有\[f[u] \frac{1}{d[u]} (\sum _ {v \in V, w …

PHP 文件加密Zend Guard Loader 學習和使用(如何安裝ioncube擴展對PHP代碼加密)

一、大體流程圖 二、PHP 項目文件加密 下表列出了Zend產品中的PHP版本及其內部API版本和Zend產品版本。 如何加密請往后看 三、如何使用 第一步&#xff1a;確認當前環境 Amai Phalcon 前&#xff0c;請確認您具備以下兩個條件&#xff0c;如果您的環境不滿足此條件&#xff0c…

前向聲明

前向聲明的定義&#xff1a;有些時候我們可以聲明一些類但是并不去定義它&#xff0c;當然這個類的作用也很有限了。 如&#xff1a;class A; 聲明一個foo類&#xff0c;這個聲明&#xff0c;有時候也叫做前向聲明(forward declaration)&#xff0c;在聲明完這個foo類之后&…

php尋找文本,PHP文本數據庫的搜索方法_php

//php文本數據庫的搜索方法searchstr("/".preg_quote($searchstr)."/");//$searchstr是查找的關鍵字$recordsfile($file);//獲取所有的記錄數http://www.gaodaima.com/45906.htmlPHP文本數據庫的搜索方法_php//$file是查找的數據文件$search_reocrdspreg_g…

react vs 2017_我在React Europe 2017上學到了什么

react vs 2017by Nicolas Cuillery由Nicolas Cuillery 我在React Europe 2017上學到了什么 (What I learned at React Europe 2017) Few days ago, the 3rd edition of the biggest React conference in Europe took place in Paris. No heatwave or transportation strike th…