Skip to content
This repository has been archived by the owner on Oct 7, 2019. It is now read-only.

Commit

Permalink
feat: upgrade to TypeScript (#8)
Browse files Browse the repository at this point in the history
 * Switched to TypeScript
 * Added tests and code coverage reports
 * Changed CI config to match other repos
 * Update CI to latest LTS of node
  • Loading branch information
adrianhopebailie committed Sep 12, 2018
1 parent 65d0941 commit c2d9bb0
Show file tree
Hide file tree
Showing 15 changed files with 4,298 additions and 139 deletions.
131 changes: 67 additions & 64 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,60 @@
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build_node_v10:
docker:
- image: circleci/node:10

working_directory: ~/repo
defaults: &defaults
working_directory: ~/repo
docker:
# Use active LTS release: https://github.com/nodejs/Release#release-schedule
- image: circleci/node:8.12

jobs:
test:
<<: *defaults
steps:

- run:
# By default node is installed as root and we are running as circleci
# Using sudo causes wierd issues so we just switch to installing globals in our home dir
name: Setup NPM to make global installs to home directory
command: |
echo "export PATH=$HOME/bin:$PATH" >> $BASH_ENV
npm set prefix=$HOME
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
keys:
# when lock file changes, use increasingly general patterns to restore cache
- "node-v1-{{ .Branch }}-{{ checksum \"package-lock.json\" }}"
- "node-v1-{{ .Branch }}-"
- "node-v1-"

- run:
name: Install Greenkeeper-Lockfile
command: sudo npm install -g greenkeeper-lockfile
command: npm install -g greenkeeper-lockfile

- run:
name: Update Lockfile (Greenkeeper)
command: greenkeeper-lockfile-update

- run: npm install

- run:
name: Install
command: npm install

- run:
name: Lint
command: npm run lint

- run:
name: Test
command: npm test

- run:
name: Upload Test Coverage to codecov.io
command: npm run codecov

- run:
name: Upload Lockfile (Greenkeeper)
Expand All @@ -33,63 +63,36 @@ jobs:
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

build_node_v8:
docker:
- image: circleci/node:8

working_directory: ~/repo
key: node-v1-{{ .Branch }}-{{ checksum "package-lock.json" }}

- persist_to_workspace:
root: ~/repo
paths: .
deploy:
<<: *defaults
steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: npm install

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

publish_to_npm:
docker:
- image: circleci/node:10

working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: mv npmrc-env .npmrc

- attach_workspace:
at: ~/repo
- run:
name: Publish to NPM (only if a new version has been tagged)
command: if [ "$(npm show ilp-logger version)" != "$(npm ls --depth=-1 2>/dev/null | head -1 | cut -f 1 -d " " | cut -f 2 -d @)" ] ; then npm publish ; fi

name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
- run:
name: Publish package
command: npm publish

workflows:
version: 2
build_and_publish:
test-deploy:
jobs:
- build_node_v10
- build_node_v8
- publish_to_npm:
- test:
filters:
tags:
only: /^v.*/
- deploy:
requires:
- build_node_v10
- test
filters:
tags:
only: /^v.*/
branches:
only:
- master
ignore: /.*/
1 change: 0 additions & 1 deletion .eslintrc

This file was deleted.

12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
node_modules/
.vscode
node_modules
**/*.js
**/*.js.map
**/*.d.ts
!example.js
!typedoc.js
!scripts/*
coverage
.nyc_output
doc
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@

## Usage

```
```js
// Javascript
const logger = require('ilp-logger')('DEBUG_NAMESPACE')

//TypeScript
import createLogger from 'ilp-logger'
const logger = createLogger('DEBUG_NAMESPACE')


logger.info('Informational output.')
logger.warn('Something you want to warn for.')
logger.error('Something error-relevant.')
Expand Down
20 changes: 0 additions & 20 deletions index.d.ts

This file was deleted.

38 changes: 0 additions & 38 deletions index.js

This file was deleted.

1 change: 0 additions & 1 deletion npmrc-env

This file was deleted.

0 comments on commit c2d9bb0

Please sign in to comment.