9.0.1 • Published 2 years ago

@financial-times/n-gage v9.0.1

Weekly downloads
1,608
License
ISC
Repository
github
Last release
2 years ago

n-gage CircleCI

⚠️ n-gage is unsupported. FT.com projects should migrate to Tool Kit.

n-gage gives a standard set of make tasks and the ngage CLI to help set up, build and deploy projects.

Requirements

  • Node version defined by .nvmrc (run command nvm use to switch your local Node version to the one in this file).
  • Vault

Installation

git clone git@github.com:Financial-Times/n-gage.git
cd n-gage
make install

Development

Testing

In order to run the tests locally you'll need to run:

make test

Install from NPM

npm install --save-dev --no-package-lock @financial-times/n-gage

Usage

Create a new Makefile file with the following:

# This task tells `make` how to 'build' n-gage. It npm installs n-gage, and
# Once that's done it overwrites the file with its own contents - this
# ensures the timestamp on the file is recent, so `make` won't think the file
# is out of date and try to rebuild it every time
node_modules/@financial-times/n-gage/index.mk:
	npm install --no-save @financial-times/n-gage
	touch $@

# If, by the end of parsing your `Makefile`, `make` finds that any files
# referenced with `-include` don't exist or are out of date, it will run any
# tasks it finds that match the missing file. So if n-gage *is* installed
# it will just be included; if not, it will look for a task to run
-include node_modules/@financial-times/n-gage/index.mk

Make tasks

TaskDescription
a11yRun automated accessibility tests
buildBuild the repository
build-productionBuild the repository for production
cleanGit clean the repository
deploy-assetsUploads static files such as CSS and JS to S3
deploy-productionDeploy staging to production eu and us apps. Also scale down canary app
deploy-canaryDeploy canary app to staging
deploy-stagingDeploy the app to staging
deploy-promotePromote the staging app to production
deployDeploy the app to heroku
.envDownloads environment variables from Vault
fix-lintspacesAutofix common lintspaces issues
helpShow this help message
initClean the repository and start from a fresh build
installInstall dependencies and copy common dotfiles
test-review-appCreate and test a review app on heroku. To override custom environment variables when running nht configure, add: REVIEW_APP_CONFIGURE_OVERRIDES="NODE_ENV=branch,OTHER_VAR=something" to the Makefile
smokeRun smoke tests on the local or review app, by setting the TEST_URL environment variable
verifyCheck files for linting errors
watchWatch for static asset changes

Git hooks

By default n-gage will automatically configure some git hooks to be run by Husky. If you want to disable this behaviour, add the following line to the very top of your Makefile:

DISABLE_GITHOOKS=true

CLI

This tool helps you to obtain configuration for your project.

$ ngage get-config

get environment variables from Vault

Options:
  --version     Show version number                            [boolean]
  --help        Show help                                      [boolean]
  --app                                     [default: "ft-next-article"]
  --env                           [choices: "dev", "prod", "ci", "test"]
  --custom-env
  --filename                                           [default: ".env"]
  --format               [choices: "simple", "json"] [default: "simple"]
  --team                                               [default: "next"]

For example, to fetch the ci environment variables:

$ ngage get-config --env ci --filename .env-ci --format json
# {
#   "AWS_ACCESS_KEY_ID": "...",
#   "AWS_SECRET_ACCESS_KEY": "...",
# 	...
# }

There is an additional --team flag that lets you specify a team if not next (must match Vault path).

$ ngage get-config --team myteam

FT User Sessions

To get FTSession and FTSession_s environment variables to be populated with up-to-date session tokens from test users, add the following environment variables to your development and/or continuous-integration configs in the Vault:

VariableDescription
TEST_SESSIONS_URLurl to next-test-sessions-lambda
TEST_SESSIONS_API_KEYapi_key for the lambda
TEST_USER_TYPESuser types to get the tokens for (options: premium, standard, expired)

As a result of this, {USER_TYPE}_FTSession and {USER_TYPE}_FTSession_s environment variables will be populated in the .env file.

Multiple user types can be specified in the TEST_USER_TYPES variable.

Example

If you set TEST_USER_TYPES environment variable to premium,standard, these variables will be populated in the .env file: PREMIUM_FTSession, PREMIUM_FTSession_s, STANDARD_FTSession, STANDARD_FTSession_s

Pa11y environment variables

Pa11y configuration has been moved to n-config-pa11y. You can follow the instructions there on how to setup Pa11y. Alternativelly, n-gage will keep this original setup until migration is complete.

VariableDescription
PA11Y_WAITThe time to wait before running tests in milliseconds
PA11Y_ROUTE_EXCEPTIONSapi_key for the lambda
PA11Y_ROUTE_HEADERSuser types to get the tokens for (options: premium, standard, expired)
PA11Y_HIDEA CSS selector to hide elements from testing, selectors can be comma separated
PA11Y_VIEWPORTSSet viewports for puppeteer (w1024h768,w375h667)

Deployment variables

These variables should be declared in the Makefile to set up deployment tasks using Heroku pipelines.

VariableDescription
VAULT_NAMERequired The name of the app in vault. Should also be the name in package.json eg, ft-next-search-page
HEROKU_APP_STAGINGRequired The name of the Heroku staging app eg, ft-next-search-page-staging
HEROKU_APP_EURequired The main Heroku app or the EU Heroku app if it is a multi-region app eg, ft-next-search-page-eu for multi region or ft-next-video-page for single region
HEROKU_APP_USOptional The US Heroku app. Only needed if it is a multi region app
HEROKU_APP_CANARYOptional The canary Heroku app. Only needed if there is a canary app eg, ft-next-preflight-canary-eu
HEROKU_APP_CANARY_SCALEOptional Canary apps only. Specify the number of web dynos for the canary app. If not specified, it will use the HEROKU_APP_EU scale configuration
REVIEW_APP_CONFIGURE_OVERRIDESOptional Override environment variables for the review apps. By default it is NODE_ENV=branch, so to add new ones add REVIEW_APP_CONFIGURE_OVERRIDES="NODE_ENV=branch,OTHER_VAR=something"
9.0.1

2 years ago

9.0.0

2 years ago

8.3.2

3 years ago

8.3.1

3 years ago

8.3.0

3 years ago

8.2.0

3 years ago

8.1.1

3 years ago

8.1.0

3 years ago

8.0.0

4 years ago

7.0.0

4 years ago

6.3.0-beta.1

4 years ago

6.2.1

4 years ago

6.2.0

4 years ago

6.1.0

4 years ago

6.0.1

4 years ago

6.0.0

4 years ago

5.1.2

4 years ago

5.1.1

4 years ago

5.1.0

4 years ago

5.1.0-beta.1

4 years ago

5.0.0

4 years ago

4.0.0

4 years ago

4.0.0-beta.3

4 years ago

4.0.0-beta.2

4 years ago

4.0.0-beta.1

4 years ago

3.12.0

5 years ago

3.11.2

5 years ago

3.11.1

5 years ago

3.11.0

5 years ago

3.10.1

5 years ago

3.10.0

5 years ago

3.9.2

5 years ago

3.9.1

5 years ago

3.9.0

5 years ago

3.9.0-beta.1

5 years ago

3.8.1

5 years ago

3.8.0

5 years ago

3.7.2

5 years ago

3.7.1

5 years ago

3.7.0

5 years ago

3.6.0

5 years ago

3.5.0

5 years ago

3.4.3

5 years ago

3.4.2

5 years ago

3.4.1

5 years ago

3.4.0

5 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

3.0.0-beta.27

5 years ago

2.2.2

5 years ago

3.0.0-beta.26

5 years ago

3.0.0-beta.25

5 years ago

3.0.0-beta.24

5 years ago

3.0.0-beta.23

5 years ago

3.0.0-beta.22

5 years ago

3.0.0-beta.21

5 years ago

3.0.0-beta.20

5 years ago

3.0.0-beta.19

5 years ago

3.0.0-beta.18

5 years ago

3.0.0-beta.17

5 years ago

3.0.0-beta.16

5 years ago

3.0.0-beta.15

5 years ago

3.0.0-beta.14

5 years ago

3.0.0-beta.13

5 years ago

3.0.0-beta.12

5 years ago

3.0.0-beta.11

5 years ago

3.0.0-beta.10

5 years ago

3.0.0-beta.9

5 years ago

2.2.1

5 years ago

3.0.0-beta.8

5 years ago

3.0.0-beta.7

5 years ago

3.0.0-beta.6

5 years ago

3.0.0-beta.5

6 years ago

3.0.0-beta.4

6 years ago

3.0.0-beta.3

6 years ago

3.0.0-beta.2

6 years ago

3.0.0-beta.1

6 years ago

2.2.0

6 years ago

2.2.0-beta.1

6 years ago

2.1.3-beta.1

6 years ago

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.2-beta.1

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.19.14

6 years ago

1.19.13

6 years ago

1.19.12

6 years ago

1.19.11

6 years ago

1.19.10

6 years ago

1.19.9

6 years ago

1.19.8

6 years ago

1.19.7

6 years ago

1.19.6

6 years ago

1.19.5

6 years ago

1.19.4

6 years ago

1.19.3

6 years ago

1.19.2

6 years ago

1.19.1

6 years ago

1.19.0

6 years ago

1.18.0

6 years ago

1.17.5

6 years ago

1.17.4

6 years ago

1.17.3

6 years ago

1.17.2

6 years ago

1.17.1

6 years ago

1.17.0

6 years ago

1.17.0-beta.9

6 years ago

1.17.0-beta.8

6 years ago

1.17.0-beta.7

6 years ago

1.17.0-beta.6

6 years ago

1.17.0-beta.5

6 years ago

1.17.0-beta.4

7 years ago

1.17.0-beta.3

7 years ago

1.17.0-beta.2

7 years ago

1.17.0-beta.1

7 years ago

1.16.0

7 years ago

1.15.0

7 years ago

1.14.0

7 years ago

1.13.0

7 years ago

1.12.0

7 years ago

1.11.0

7 years ago

1.10.0

7 years ago

1.9.5

7 years ago

1.9.4

7 years ago

1.9.3

7 years ago

1.9.2

7 years ago

1.9.1

7 years ago

1.9.0

7 years ago

1.8.27

7 years ago

1.8.26

7 years ago

1.8.25

7 years ago

1.8.24

7 years ago

1.8.24-beta.1

7 years ago

1.8.23

7 years ago

1.8.22

7 years ago

1.8.21

7 years ago

1.8.20

7 years ago

1.8.19

7 years ago

1.8.18

7 years ago

1.8.17

7 years ago

1.8.16

7 years ago

1.8.15

7 years ago

1.8.14

7 years ago

1.8.13

7 years ago

1.8.12

7 years ago

1.8.11

7 years ago

1.8.10

7 years ago

1.8.9

7 years ago

1.8.8

7 years ago

1.8.7

7 years ago

1.8.6

7 years ago

1.8.5

7 years ago

1.8.4

7 years ago

1.8.3

7 years ago

1.8.2

7 years ago

1.8.1

7 years ago

1.8.0

7 years ago

1.7.8

7 years ago

1.7.7

7 years ago

1.7.6

7 years ago

1.7.5

7 years ago

1.7.4

7 years ago

1.7.3

7 years ago

1.7.2

7 years ago

1.7.1

7 years ago

1.7.0

7 years ago

1.6.2

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.0.1

7 years ago

1.0.0-beta.1

7 years ago