Skip to content

Commit

Permalink
Switch to GitHub Actions for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
dguo committed Dec 7, 2019
1 parent 421d88f commit 29da468
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 14 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node: ["8", "10", "12"]

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Get the Yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install packages
run: yarn install --frozen-lockfile
- name: Check formatting
run: yarn run format:check
- name: Lint the code
run: yarn run lint
- name: Test the code
run: yarn run test
- name: Build the code
run: yarn run build
- name: Upload code coverage
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# format-stripe-metadata [![npm](https://img.shields.io/npm/v/format-stripe-metadata.svg)](https://www.npmjs.com/package/format-stripe-metadata) [![npm](https://img.shields.io/npm/l/format-stripe-metadata.svg)](https://github.com/sublimefund/format-stripe-metadata/blob/master/LICENSE) [![Build Status](https://travis-ci.org/sublimefund/format-stripe-metadata.svg?branch=master)](https://travis-ci.org/sublimefund/format-stripe-metadata) [![codecov](https://codecov.io/gh/sublimefund/format-stripe-metadata/branch/master/graph/badge.svg)](https://codecov.io/gh/sublimefund/format-stripe-metadata)
# format-stripe-metadata

[![npm](https://img.shields.io/npm/v/format-stripe-metadata.svg)](https://www.npmjs.com/package/format-stripe-metadata)
[![npm](https://img.shields.io/npm/l/format-stripe-metadata.svg)](https://github.com/sublimefund/format-stripe-metadata/blob/master/LICENSE)
[![CI status](https://github.com/sublimefund/format-stripe-metadata/workflows/CI/badge.svg)](https://github.com/sublimefund/format-stripe-metadata/actions?query=branch%3Amaster)
[![codecov](https://codecov.io/gh/sublimefund/format-stripe-metadata/branch/master/graph/badge.svg)](https://codecov.io/gh/sublimefund/format-stripe-metadata)

[Stripe](https://stripe.com/) allows attaching
[metadata](https://stripe.com/docs/api#metadata) to certain objects. However,
there are documented limits on the metadata, the data must be in a key/value
Expand All @@ -7,24 +13,28 @@ requirements aren't met, then calling the Stripe API will fail. This package
formats the input data to ensure compliance.

From the docs:
> You can specify up to 20 keys, with key names up to 40 characters long and values up to 500 characters long.
> You can specify up to 20 keys, with key names up to 40 characters long and
> values up to 500 characters long.
These values are used internally, but you can override them if necessary.

## Installation

```sh
$ yarn add format-stripe-metadata
# or
$ npm install --save format-stripe-metadata
```

## Usage

The returned object will contain a property called `_fullData` with a value of
either `'true'` or `'false'`. If the value is `'false'`, then information was
lost in the formatting process. Depending on how you are using the metadata
field, you may want to treat this situation as a bug, log a warning, etc.

Values are converted to strings as necesssary using [`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify).
Values are converted to strings as necesssary using
[`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify).

```js
import {formatStripeMetadata} from 'format-stripe-metadata';
Expand Down Expand Up @@ -57,4 +67,5 @@ formated = formatStripeMetadata(metadata, {
```

## License

[MIT](https://github.com/sublimefund/format-stripe-metadata/blob/master/LICENSE)

0 comments on commit 29da468

Please sign in to comment.