Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 27, 2018
0 parents commit 42ed767
Show file tree
Hide file tree
Showing 21 changed files with 5,171 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
version: 2
jobs:
node-latest: &test
docker:
- image: node:latest
working_directory: ~/cli
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
- v0-yarn-{{checksum ".circleci/config.yml"}}-master-
- run: .circleci/setup_git
- run: .circleci/yarn
- run: yarn test
- run: curl -s https://codecov.io/bash | bash
- store_test_results: &store_test_results
path: ~/cli/reports
- save_cache: &save_cache
key: v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
paths:
- ~/cli/node_modules
- /usr/local/share/.cache/yarn
- /usr/local/share/.config/yarn
node-8:
<<: *test
docker:
- image: node:8
steps:
- checkout
- restore_cache: *restore_cache
- run: .circleci/setup_git
- run: .circleci/yarn
- run: yarn test
- run: curl -s https://codecov.io/bash | bash
- store_test_results: *store_test_results
release:
<<: *test
steps:
- add_ssh_keys
- checkout
- restore_cache: *restore_cache
- run: .circleci/setup_git
- run: .circleci/yarn
- run: yarn exec nps release

workflows:
version: 2
"@dxcli/help":
jobs:
- node-latest
- node-8
- release:
context: org-global
filters:
branches: {only: master}
requires:
- node-latest
- node-8
12 changes: 12 additions & 0 deletions .circleci/setup_git
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e

if [[ ! -z "$GIT_EMAIL" ]] & [[ ! -z "$GIT_USERNAME" ]]; then
git config --global push.default simple
git config --global user.email "$GIT_EMAIL"
git config --global user.name "$GIT_USERNAME"
fi

git submodule sync
git submodule update --init --recursive
22 changes: 22 additions & 0 deletions .circleci/yarn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -e

PATH=/usr/local/share/.config/yarn/global/node_modules/.bin:$PATH

CLI_ENGINE_UTIL_YARN_ARGS="--frozen-lockfile"

if [[ "$CIRCLE_BRANCH" == greenkeeper/* ]]; then
CLI_ENGINE_GREENKEEPER_BRANCH=1
CLI_ENGINE_UTIL_YARN_ARGS=""
if [[ ! -x "$(command -v greenkeeper-lockfile-update)" ]]; then
yarn global add greenkeeper-lockfile@1
fi
greenkeeper-lockfile-update
fi

yarn install $CLI_ENGINE_UTIL_YARN_ARGS

if [[ "$CLI_ENGINE_GREENKEEPER_BRANCH" == 1 ]]; then
greenkeeper-lockfile-upload
fi
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/lib
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "dxcli"
}
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto
*.js text eol=lf
*.ts text eol=lf
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*-debug.log
*-error.log
/.nyc_output
/coverage
/coverage.lcov
/lib
/node_modules
/tmp
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@dxcli/help
===========

standard help for dxcli

[![Version](https://img.shields.io/npm/v/@dxcli/help.svg)](https://npmjs.org/package/@dxcli/help)
[![CircleCI](https://circleci.com/gh/dxcli/help/tree/master.svg?style=svg)](https://circleci.com/gh/dxcli/help/tree/master)
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/dxcli/help?branch=master&svg=true)](https://ci.appveyor.com/project/heroku/help/branch/master)
[![Codecov](https://codecov.io/gh/dxcli/help/branch/master/graph/badge.svg)](https://codecov.io/gh/dxcli/help)
[![Greenkeeper](https://badges.greenkeeper.io/dxcli/help.svg)](https://greenkeeper.io/)
[![Known Vulnerabilities](https://snyk.io/test/npm/@dxcli/help/badge.svg)](https://snyk.io/test/npm/@dxcli/help)
[![Downloads/week](https://img.shields.io/npm/dw/@dxcli/help.svg)](https://npmjs.org/package/@dxcli/help)
[![License](https://img.shields.io/npm/l/@dxcli/help.svg)](https://github.com/dxcli/help/blob/master/package.json)
23 changes: 23 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
environment:
nodejs_version: "9"
cache:
- '%LOCALAPPDATA%\Yarn -> appveyor.yml'
- node_modules -> yarn.lock

install:
- ps: Install-Product node $env:nodejs_version x64
- git submodule sync
- git submodule update --init --recursive
- git config --global user.email "[email protected]"
- git config --global user.name "dxcli"
- yarn
test_script:
- yarn test
after_test:
- ps: |
$env:PATH = 'C:\msys64\usr\bin;' + $env:PATH
Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
bash codecov.sh
build: off

44 changes: 44 additions & 0 deletions package-scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const {
setColors,
concurrent,
crossEnv,
mkdirp,
series,
} = require('nps-utils')

setColors(['dim'])

const script = (script, description) => description ? {script, description} : {script}

const linters = {
eslint: script('eslint .', 'lint js files'),
commitlint: script('commitlint --from origin/master', 'ensure that commits are in valid conventional-changelog format'),
tsc: script('tsc -p test --noEmit', 'syntax check with tsc'),
tslint: script('tslint -p test', 'lint ts files'),
}

const scripts = {
...linters,
lint: concurrent(linters),
test: script(concurrent.nps(...Object.keys(linters), 'mocha'), 'lint and run all tests'),
mocha: script('mocha --forbid-only "test/**/*.test.ts"', 'run all mocha tests'),
}

if (process.env.CI) {
if (process.env.CIRCLECI) {
scripts.test.script = series(mkdirp('reports'), scripts.test.script)
// add mocha junit reporter
scripts.mocha.script = crossEnv(`MOCHA_FILE=reports/mocha.xml ${scripts.mocha.script} --reporter mocha-junit-reporter`)
// add eslint reporter
scripts.eslint.script = `${scripts.eslint.script} --format junit --output-file reports/eslint.xml`
// add tslint reporter
scripts.tslint.script = `${scripts.tslint.script} --format junit > reports/tslint.xml`
scripts.release = 'semantic-release -e @dxcli/dev-semantic-release'
}
// add code coverage reporting with nyc
const nyc = 'nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc'
const nycReport = `${nyc} report --reporter text-lcov > coverage.lcov`
scripts.mocha.script = series(`${nyc} ${scripts.mocha.script}`, nycReport)
}

module.exports = {scripts}
40 changes: 40 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@dxcli/help",
"description": "standard help for dxcli",
"version": "0.0.0",
"author": "Jeff Dickey @jdxcode",
"bugs": "https://github.com/jdxcode/help/issues",
"dependencies": {
"@dxcli/command": "^0.1.19",
"cli-ux": "^3.2.1"
},
"devDependencies": {
"@dxcli/config": "^0.1.26",
"@dxcli/dev": "^2.0.3",
"@dxcli/dev-test": "^0.9.11",
"@dxcli/engine": "^0.1.12",
"husky": "^0.14.3",
"nps-utils": "^1.5.0"
},
"dxcli": {
"commands": "./lib/commands"
},
"engines": {
"node": ">=8.0.0"
},
"files": [
"/lib"
],
"homepage": "https://github.com/jdxcode/help",
"keywords": [
"dxcli-plugin"
],
"license": "MIT",
"repository": "dxcli/help",
"scripts": {
"commitmsg": "dxcli-dev-commitmsg",
"precommit": "nps lint -l warn",
"prepare": "rm -rf lib && tsc",
"test": "nps test -l warn"
}
}
13 changes: 13 additions & 0 deletions src/commands/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Command, {flags} from '@dxcli/command'
import cli from 'cli-ux'

export default class CLI extends Command {
static flags = {
name: flags.string({char: 'n', description: 'name to print'})
}

async run() {
const name = this.flags.name || 'world'
cli.log(`hello ${name}!`)
}
}
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// this file is just here to make typescript not flatten the outDir
// we can't use rootDir as this doesn't allow us to use linked plugins typescript files
export default {}
17 changes: 17 additions & 0 deletions test/commands/hello.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {expect, test} from '@dxcli/dev-test'

describe('command', () => {
test
.stdout()
.command(['hello'])
.it('says hello', output => {
expect(output.stdout).to.contain('hello world!')
})

test
.stdout()
.command(['hello', '--name', 'jeff'])
.it('says hello jeff', output => {
expect(output.stdout).to.contain('hello jeff!')
})
})
1 change: 1 addition & 0 deletions test/helpers/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
process.env.TS_NODE_PROJECT = 'test'
7 changes: 7 additions & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--require test/helpers/init.js
--require ts-node/register
--require source-map-support/register
--watch-extensions ts
--recursive
--reporter spec
--timeout 5000
7 changes: 7 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig",
"include": [
"./**/*",
"../src/**/*"
]
}
20 changes: 20 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"declaration": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"module": "commonjs",
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./lib",
"rootDirs": [
"./src"
],
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"include": [
"./src/**/*"
]
}
3 changes: 3 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@dxcli/dev-tslint"
}
Loading

0 comments on commit 42ed767

Please sign in to comment.