@financial-times/n-gage
Make it so next
Last updated 22 days ago by the-ft .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @financial-times/n-gage 
SYNC missed versions from official npm registry.

n-gage

Yak button

n-gage is in every Next project, giving a standard set of make tasks and ngage CLI to help with setting up, building and deployments.


Getting started

Starting a new repo? You can do the following:

mkdir my-new-project
cd my-new-project
npm init -y
npm install --save-dev --no-package-lock @financial-times/n-gage

then create a new Makefile file with the following:

# n-gage bootstrapping logic
node_modules/@financial-times/n-gage/index.mk:
	npm install --no-save --no-package-lock @financial-times/n-gage
	touch $@

-include node_modules/@financial-times/n-gage/index.mk

See here for more explanation of the bootstrapping logic. You will want to add unit-test, test, provision, smoke and deploy tasks to the Makefile. See other, similar Next projects for ideas.

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

Make tasks

See in index.mk for all the different tasks you can use in your Makefile.

CLI

This includes a CLI for you to use to do some things.

get-config

This tool helps you to obtain configuration for your project.

$ ngage
ngage get-config --help

$ ngage get-config --help
Options:
  --help      Show help                                                [boolean]
  --app                                            [default: "next-page-purger"]
  --env                  [choices: "dev", "prod", "ci", "test"] [default: "dev"]
  --filename                                                   [default: ".env"]
  --format                       [choices: "simple", "json"] [default: "simple"]
  --team                                                       [default: "next"]

$ ngage get-config --env ci --filename .env-ci --format json
Written next-page-purger's ci config to /Users/ben.fletcher/projects/next-page-purger/.env-ci

$ cat .env-ci
{
  "AWS_ACCESS_KEY_ID": "...",
  "AWS_SECRET_ACCESS_KEY": "...",
	...
}
$ ngage get-config --team myteam

The --team option lets you specify a team if not next (must match Vault path).

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:

Variable Description
TEST_SESSIONS_URL url to next-test-sessions-lambda
TEST_SESSIONS_API_KEY api_key for the lambda
TEST_USER_TYPES user 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

Variable Description
PA11Y_WAIT The time to wait before running tests in milliseconds
PA11Y_ROUTE_EXCEPTIONS api_key for the lambda
PA11Y_ROUTE_HEADERS user types to get the tokens for (options: premium, standard, expired)
PA11Y_HIDE A CSS selector to hide elements from testing, selectors can be comma separated
PA11Y_VIEWPORTS Set viewports for puppeteer (w1024h768,w375h667)

Deployment variables

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

Variable Description
VAULT_NAME [Required] The name of the app in vault. Should also be the name in package.json eg, ft-next-search-page
HEROKU_APP_STAGING [Required] The name of the Heroku staging app eg, ft-next-search-page-staging
HEROKU_APP_EU [Required] 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_US [Optional] The US Heroku app. Only needed if it is a multi region app
HEROKU_APP_CANARY [Optional] The canary Heroku app. Only needed if there is a canary app eg, ft-next-preflight-canary
HEROKU_APP_CANARY_SCALE [Optional] 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_OVERRIDES [Optional] 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"

Bootstrapping

Curious how the bootstrapping bit at top of the Makefile works? Here's the annotated code:

# 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

Current Tags

  • 5.1.2                                ...           latest (22 days ago)
  • 5.1.0-beta.1                                ...           pre-release (a month ago)

179 Versions

  • 5.1.2                                ...           22 days ago
  • 5.1.1                                ...           a month ago
  • 5.1.0                                ...           a month ago
  • 5.1.0-beta.1                                ...           a month ago
  • 5.0.0                                ...           3 months ago
  • 4.0.0                                ...           3 months ago
  • 4.0.0-beta.3                                ...           3 months ago
  • 4.0.0-beta.2                                ...           6 months ago
  • 4.0.0-beta.1                                ...           6 months ago
  • 3.12.0                                ...           7 months ago
  • 3.11.2                                ...           10 months ago
  • 3.11.1                                ...           10 months ago
  • 3.11.0                                ...           10 months ago
  • 3.10.1                                ...           a year ago
  • 3.10.0                                ...           a year ago
  • 3.9.2                                ...           a year ago
  • 3.9.1                                ...           a year ago
  • 3.9.0                                ...           a year ago
  • 3.9.0-beta.1                                ...           a year ago
  • 3.8.1                                ...           a year ago
  • 3.8.0                                ...           a year ago
  • 3.7.2                                ...           a year ago
  • 3.7.1                                ...           a year ago
  • 3.7.0                                ...           a year ago
  • 3.6.0                                ...           a year ago
  • 3.5.0                                ...           a year ago
  • 3.4.3                                ...           a year ago
  • 3.4.2                                ...           a year ago
  • 3.4.1                                ...           a year ago
  • 3.4.0                                ...           a year ago
  • 3.3.0                                ...           a year ago
  • 3.2.0                                ...           a year ago
  • 3.1.0                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 3.0.0-beta.27                                ...           a year ago
  • 2.2.2                                ...           a year ago
  • 3.0.0-beta.26                                ...           a year ago
  • 3.0.0-beta.25                                ...           a year ago
  • 3.0.0-beta.24                                ...           a year ago
  • 3.0.0-beta.23                                ...           a year ago
  • 3.0.0-beta.22                                ...           a year ago
  • 3.0.0-beta.21                                ...           a year ago
  • 3.0.0-beta.20                                ...           a year ago
  • 3.0.0-beta.19                                ...           a year ago
  • 3.0.0-beta.18                                ...           a year ago
  • 3.0.0-beta.17                                ...           a year ago
  • 3.0.0-beta.16                                ...           a year ago
  • 3.0.0-beta.15                                ...           a year ago
  • 3.0.0-beta.14                                ...           2 years ago
  • 3.0.0-beta.13                                ...           2 years ago
  • 3.0.0-beta.12                                ...           2 years ago
  • 3.0.0-beta.11                                ...           2 years ago
  • 3.0.0-beta.10                                ...           2 years ago
  • 3.0.0-beta.9                                ...           2 years ago
  • 2.2.1                                ...           2 years ago
  • 3.0.0-beta.8                                ...           2 years ago
  • 3.0.0-beta.7                                ...           2 years ago
  • 3.0.0-beta.6                                ...           2 years ago
  • 3.0.0-beta.5                                ...           2 years ago
  • 3.0.0-beta.4                                ...           2 years ago
  • 3.0.0-beta.3                                ...           2 years ago
  • 3.0.0-beta.2                                ...           2 years ago
  • 3.0.0-beta.1                                ...           2 years ago
  • 2.2.0                                ...           2 years ago
  • 2.2.0-beta.1                                ...           2 years ago
  • 2.1.3-beta.1                                ...           2 years ago
  • 2.1.2                                ...           2 years ago
  • 2.1.1                                ...           2 years ago
  • 2.1.0                                ...           2 years ago
  • 2.0.4                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.2-beta.1                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.19.14                                ...           2 years ago
  • 1.19.13                                ...           2 years ago
  • 1.19.12                                ...           2 years ago
  • 1.19.11                                ...           2 years ago
  • 1.19.10                                ...           2 years ago
  • 1.19.9                                ...           2 years ago
  • 1.19.8                                ...           2 years ago
  • 1.19.7                                ...           2 years ago
  • 1.19.6                                ...           2 years ago
  • 1.19.5                                ...           2 years ago
  • 1.19.4                                ...           2 years ago
  • 1.19.3                                ...           2 years ago
  • 1.19.2                                ...           2 years ago
  • 1.19.1                                ...           2 years ago
  • 1.19.0                                ...           2 years ago
  • 1.18.0                                ...           2 years ago
  • 1.17.5                                ...           2 years ago
  • 1.17.4                                ...           2 years ago
  • 1.17.3                                ...           2 years ago
  • 1.17.2                                ...           2 years ago
  • 1.17.1                                ...           2 years ago
  • 1.17.0                                ...           2 years ago
  • 1.17.0-beta.9                                ...           2 years ago
  • 1.17.0-beta.8                                ...           2 years ago
  • 1.17.0-beta.7                                ...           2 years ago
  • 1.17.0-beta.6                                ...           2 years ago
  • 1.17.0-beta.5                                ...           3 years ago
  • 1.17.0-beta.4                                ...           3 years ago
  • 1.17.0-beta.3                                ...           3 years ago
  • 1.17.0-beta.2                                ...           3 years ago
  • 1.17.0-beta.1                                ...           3 years ago
  • 1.16.0                                ...           3 years ago
  • 1.15.0                                ...           3 years ago
  • 1.14.0                                ...           3 years ago
  • 1.13.0                                ...           3 years ago
  • 1.12.0                                ...           3 years ago
  • 1.11.0                                ...           3 years ago
  • 1.10.0                                ...           3 years ago
  • 1.9.5                                ...           3 years ago
  • 1.9.4                                ...           3 years ago
  • 1.9.3                                ...           3 years ago
  • 1.9.2                                ...           3 years ago
  • 1.9.1                                ...           3 years ago
  • 1.9.0                                ...           3 years ago
  • 1.8.27                                ...           3 years ago
  • 1.8.26                                ...           3 years ago
  • 1.8.25                                ...           3 years ago
  • 1.8.24                                ...           3 years ago
  • 1.8.24-beta.1                                ...           3 years ago
  • 1.8.23                                ...           3 years ago
  • 1.8.22                                ...           3 years ago
  • 1.8.21                                ...           3 years ago
  • 1.8.20                                ...           3 years ago
  • 1.8.19                                ...           3 years ago
  • 1.8.18                                ...           3 years ago
  • 1.8.17                                ...           3 years ago
  • 1.8.16                                ...           3 years ago
  • 1.8.15                                ...           3 years ago
  • 1.8.14                                ...           3 years ago
  • 1.8.13                                ...           3 years ago
  • 1.8.12                                ...           3 years ago
  • 1.8.11                                ...           3 years ago
  • 1.8.10                                ...           3 years ago
  • 1.8.9                                ...           3 years ago
  • 1.8.8                                ...           3 years ago
  • 1.8.7                                ...           3 years ago
  • 1.8.6                                ...           3 years ago
  • 1.8.5                                ...           3 years ago
  • 1.8.4                                ...           3 years ago
  • 1.8.3                                ...           3 years ago
  • 1.8.2                                ...           3 years ago
  • 1.8.1                                ...           3 years ago
  • 1.8.0                                ...           3 years ago
  • 1.7.8                                ...           3 years ago
  • 1.7.7                                ...           3 years ago
  • 1.7.6                                ...           3 years ago
  • 1.7.5                                ...           3 years ago
  • 1.7.4                                ...           3 years ago
  • 1.7.3                                ...           3 years ago
  • 1.7.2                                ...           3 years ago
  • 1.7.1                                ...           3 years ago
  • 1.7.0                                ...           3 years ago
  • 1.6.2                                ...           3 years ago
  • 1.6.1                                ...           3 years ago
  • 1.6.0                                ...           3 years ago
  • 1.5.2                                ...           3 years ago
  • 1.5.1                                ...           3 years ago
  • 1.5.0                                ...           3 years ago
  • 1.4.1                                ...           3 years ago
  • 1.4.0                                ...           3 years ago
  • 1.3.0                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.10                                ...           3 years ago
  • 1.1.9                                ...           3 years ago
  • 1.1.8                                ...           3 years ago
  • 1.1.7                                ...           3 years ago
  • 1.1.6                                ...           3 years ago
  • 1.1.5                                ...           3 years ago
  • 1.1.4                                ...           3 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0-beta.1                                ...           3 years ago

Copyright 2014 - 2016 © taobao.org |