Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Braimbridge, Adam authored and Braimbridge, Adam committed Mar 4, 2019
1 parent 4dd30a5 commit ae14335
Show file tree
Hide file tree
Showing 31 changed files with 1,594 additions and 11 deletions.
145 changes: 145 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
version: 2.1

executors:
circleci-node-10:
docker:
- image: circleci/node:10.15.2
working_directory: ~/project/build

commands:
npm-install:
description: "npm install without generating a package-lock file"
steps:
- run:
name: "Install project dependencies"
command: npm install --no-package-lock

references:

#
# Workspace
#

workspace_root: &workspace_root
~/project

attach_workspace: &attach_workspace
attach_workspace:
at: *workspace_root

#
# Cache keys
#
cache_keys_root: &cache_keys_root
keys:
- cache-root-v1-{{ .Branch }}-{{ checksum "./package.json" }}

#
# Cache creation
#

create_cache_root: &create_cache_root
save_cache:
key: cache-root-v1-{{ .Branch }}-{{ checksum "./package.json" }}
paths:
- ./node_modules/

#
# Cache restoration
#

restore_cache_root: &restore_cache_root
restore_cache:
<<: *cache_keys_root

#
# Filters
#

filters_branch_build: &filters_branch_build
tags:
ignore: /.*/

filters_release_package_build: &filters_release_package_build
tags:
only:
- /^[a-z\-]+-v\d+\.\d+\.\d+(\-\w+\.\d+)?$/
branches:
ignore: /.*/

jobs:

build:
executor: circleci-node-10
steps:
- checkout
- *restore_cache_root
- npm-install
- *create_cache_root
- persist_to_workspace:
root: *workspace_root
paths:
- build

test:
executor: circleci-node-10
steps:
- *attach_workspace
- run:
name: Run tests
command: npm test

publish:
executor: circleci-node-10
steps:
- *attach_workspace
- run:
name: Configure registry.npmjs.org auth token
command: echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > ${HOME}/.npmrc
- run:
name: Extract package name and semver from git tag
command: |
# https://circleci.com/docs/2.0/env-vars/#using-bash_env-to-set-environment-variables
export RELEASE_SEMVER='v[0-9]{1,3}\.[0-9]{1,2}\.[0-9]{1,2}(-[a-z]+\.[0-9])?';
export TARGET_VERSION=$(echo $CIRCLE_TAG | grep -o -E $RELEASE_SEMVER);
export TARGET_MODULE=$(echo $CIRCLE_TAG | sed -E "s/-${RELEASE_SEMVER}//g");
echo "export TARGET_VERSION=$TARGET_VERSION" >> $BASH_ENV;
echo "export TARGET_MODULE=$TARGET_MODULE" >> $BASH_ENV;
echo "Creating release ${TARGET_VERSION} for ${TARGET_MODULE}";
- run:
name: Bump package version
command: npx athloi -F ${TARGET_MODULE} version ${TARGET_VERSION}
- run:
name: Publish package to npm
command: npx athloi -F ${TARGET_MODULE} publish -- --access=public

workflows:

version: 2

build-test:
jobs:
- build:
filters:
<<: *filters_branch_build
- test:
filters:
<<: *filters_branch_build
requires:
- build

build-test-publish:
jobs:
- build:
filters:
<<: *filters_release_package_build
- test:
filters:
<<: *filters_release_package_build
requires:
- build
- publish:
filters:
<<: *filters_release_package_build
requires:
- test
1 change: 1 addition & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_extends: github-apps-config-next
1 change: 1 addition & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_extends: github-apps-config-next
84 changes: 84 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Generated files
package-lock.json
test-results/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.15.2
4 changes: 4 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See https://help.github.com/articles/about-code-owners/ for more information
# about this file.

* @adambraimbridge
20 changes: 10 additions & 10 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
MIT License

Copyright (c) 2019 Financial Times
The MIT License (MIT)
Copyright (c) 2019 The Financial Times Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -12,10 +11,11 @@ furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.

52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
# github
This package is a wrapper around the official GitHub REST API client for JavaScript [@octokit/rest](https://github.com/octokit/rest.js) - it exposes a library and a command line interface (CLI).

This package is a wrapper around the official GitHub REST API client for
JavaScript [@octokit/rest](https://github.com/octokit/rest.js) - it exposes a
library and a command line interface (CLI).

_Note:_ Requires a [GitHub personal access token](#github-personal-access-token-security)
for GitHub API requests that require authentication.

## Usage

### Library

```
npm install @financial-times/github
```

```javascript
const github = require('@financial-times/github')({
personalAccessToken: process.env.GITHUB_PERSONAL_ACCESS_TOKEN
});
```

See [`examples/examples.js`](examples/examples.js) for a full set of
usage examples.

See [`src/index.js`](src/index.js) for all available methods.

### Command line interface (CLI)

```
$ npx @financial-times/github --help
github <command>
Commands:
github project:add-pull-request Add a pull request to a project
github project:create Create a new project
github pull-request:create Create a new pull request
Options:
--version Show version number [boolean]
--help Show help [boolean]
```

## GitHub personal access token security

<!-- TODO: Update the wording -->

Some of the tooling helpers require a GitHub personal access token with all
`repo` scopes. This is _very powerful_ as it has access to modify a
repository's settings, so it is strongly recommended that you follow the guide
on [How to store and access a GitHub personal access token securely](https://github.com/Financial-Times/next/wiki/How-to-store-and-access-a-GitHub-personal-access-token-securely).
Loading

0 comments on commit ae14335

Please sign in to comment.