Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 26, 2018
0 parents commit a915cec
Show file tree
Hide file tree
Showing 23 changed files with 5,173 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
version: 2
jobs:
node-latest: &test
docker:
- image: node:latest
working_directory: ~/cli
steps:
- checkout
- restore_cache: &restore_cache
keys:
- v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
- v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/config.yml"}}-master-
- run: ./.circleci/setup_git
- run: ./.circleci/greenkeeper
- run: yarn exec nps ci.test
- run: curl -s https://codecov.io/bash | bash
- store_test_results:
path: ~/cli/reports
- save_cache: &save_cache
key: v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{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
release:
<<: *test
steps:
- add_ssh_keys
- checkout
- restore_cache: *restore_cache
- run: ./.circleci/setup_git
- run: yarn --frozen-lockfile
- run: yarn exec nps ci.release
- save_cache: *save_cache

workflows:
version: 2
"@dxcli/plugins":
jobs:
- node-latest
- node-8
- release:
context: org-global
filters:
branches: {only: master}
requires:
- node-latest
- node-8
22 changes: 22 additions & 0 deletions .circleci/greenkeeper
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
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.user "$GIT_USERNAME"
fi

git submodule sync
git submodule update --init --recursive
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/plugins
==============

plugins plugin for dxcli

[![Version](https://img.shields.io/npm/v/@dxcli/plugins.svg)](https://npmjs.org/package/@dxcli/plugins)
[![CircleCI](https://circleci.com/gh/dxcli/plugins/tree/master.svg?style=svg)](https://circleci.com/gh/dxcli/plugins/tree/master)
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/dxcli/plugins?branch=master&svg=true)](https://ci.appveyor.com/project/heroku/plugins/branch/master)
[![Codecov](https://codecov.io/gh/dxcli/plugins/branch/master/graph/badge.svg)](https://codecov.io/gh/dxcli/plugins)
[![Greenkeeper](https://badges.greenkeeper.io/dxcli/plugins.svg)](https://greenkeeper.io/)
[![Known Vulnerabilities](https://snyk.io/test/npm/@dxcli/plugins/badge.svg)](https://snyk.io/test/npm/@dxcli/plugins)
[![Downloads/week](https://img.shields.io/npm/dw/@dxcli/plugins.svg)](https://npmjs.org/package/@dxcli/plugins)
[![License](https://img.shields.io/npm/l/@dxcli/plugins.svg)](https://github.com/dxcli/plugins/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:
- .\node_modules\.bin\nps ci.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

92 changes: 92 additions & 0 deletions package-scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
const {
concurrent,
crossEnv,
ifNotWindows,
ifWindows,
mkdirp,
series,
setColors,
} = require('nps-utils')
const pjson = require('./package.json')
const release = pjson.devDependencies.typedoc ? ['ci.release.semantic-release', 'ci.release.typedoc'] : ['ci.release.semantic-release']
const script = (script, description) => description ? {script, description} : {script}
const hidden = script => ({script, hiddenFromHelp: true})
const unixOrWindows = (unix, windows) => series(ifNotWindows(unix), ifWindows(windows))

setColors(['dim'])

let ciTests = [
'ci.test.eslint',
'ci.test.mocha',
'ci.test.tslint',
]

module.exports = {
scripts: {
build: 'rm -rf lib && tsc',
lint: {
default: concurrent.nps('lint.eslint', 'lint.commitlint', 'lint.tsc', 'lint.tslint'),
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'),
},
test: {
default: script(concurrent.nps('lint', 'test.mocha'), 'lint and run all tests'),
series: script(series.nps('lint', 'test.mocha'), 'lint and run all tests in series'),
mocha: {
default: script('mocha --forbid-only "test/**/*.test.ts"', 'run all mocha tests'),
coverage: {
default: hidden(series.nps('test.mocha.nyc nps test.mocha', 'test.mocha.coverage.report')),
report: hidden(series('nps "test.mocha.nyc report --reporter text-lcov" > coverage.lcov')),
},
junit: hidden(series(
crossEnv('MOCHA_FILE="reports/mocha.xml" ') + series.nps('test.mocha.nyc nps \\"test.mocha --reporter mocha-junit-reporter\\"'),
series.nps('test.mocha.coverage.report'),
)),
nyc: hidden('nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc'),
},
},
ci: {
test: {
default: hidden(series(
mkdirp('reports'),
unixOrWindows(
concurrent.nps(...ciTests),
series.nps(...ciTests),
),
)),
mocha: hidden(
unixOrWindows(
series.nps('test.mocha.junit'),
series.nps('test.mocha.coverage'),
)
),
eslint: hidden(
unixOrWindows(
series.nps('lint.eslint --format junit --output-file reports/eslint.xml'),
series.nps('lint.eslint'),
)
),
tslint: hidden(
unixOrWindows(
series.nps('lint.tslint --format junit > reports/tslint.xml'),
series.nps('lint.tslint'),
)
),
},
typedoc: hidden('typedoc --out /tmp/docs src/index.ts --excludeNotExported --mode file'),
release: {
default: hidden(series.nps(...release)),
'semantic-release': hidden('semantic-release -e @dxcli/dev-semantic-release'),
typedoc: hidden(series(
'git clone -b gh-pages $CIRCLE_REPOSITORY_URL gh-pages',
'nps ci.typedoc',
'rm -rf ./gh-pages/*',
'mv /tmp/docs/* ./gh-pages',
'cd gh-pages && git add . && git commit -m "updates from $CIRCLE_SHA1 [skip ci]" && git push',
)),
},
},
},
}
62 changes: 62 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "@dxcli/plugins",
"description": "plugins plugin for dxcli",
"version": "0.0.0",
"author": "Jeff Dickey @jdxcode",
"bugs": "https://github.com/jdxcode/plugins/issues",
"dependencies": {
"@dxcli/command": "^0.1.16",
"cli-ux": "^3.1.5"
},
"devDependencies": {
"@dxcli/config": "^0.1.24",
"@dxcli/dev-nyc-config": "^0.0.3",
"@dxcli/dev-semantic-release": "^0.1.0",
"@dxcli/dev-test": "^0.9.4",
"@dxcli/dev-tslint": "^0.0.15",
"@dxcli/engine": "^0.1.7",
"@types/ansi-styles": "^2.0.30",
"@types/chai": "^4.1.2",
"@types/lodash": "^4.14.96",
"@types/mocha": "^2.2.47",
"@types/nock": "^9.1.2",
"@types/node": "^9.3.0",
"@types/read-pkg": "^3.0.0",
"@types/strip-ansi": "^3.0.0",
"chai": "^4.1.2",
"eslint": "^4.16.0",
"eslint-config-dxcli": "^1.1.4",
"husky": "^0.14.3",
"mocha": "^5.0.0",
"mocha-junit-reporter": "^1.17.0",
"nps": "^5.7.1",
"nps-utils": "^1.5.0",
"nyc": "^11.4.1",
"ts-node": "^4.1.0",
"typescript": "^2.6.2"
},
"dxcli": {
"commands": "./lib/commands",
"hooks": {
"init": "./lib/hooks/init"
}
},
"engines": {
"node": ">=8.0.0"
},
"files": [
"/lib"
],
"homepage": "https://github.com/jdxcode/plugins",
"keywords": [
"dxcli-plugin"
],
"license": "MIT",
"repository": "dxcli/plugins",
"scripts": {
"commitmsg": "dxcli-dev-commitmsg",
"precommit": "nps lint",
"prepare": "nps build",
"test": "nps test"
}
}
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}!`)
}
}
8 changes: 8 additions & 0 deletions src/hooks/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {Hooks, IHook} from '@dxcli/config'
import cli from 'cli-ux'

const hook: IHook<Hooks['init']> = async opts => {
cli.info(`example hook running ${opts.id}\nDisable by deleting ./src/hooks/init.ts`)
}

export default hook
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'
9 changes: 9 additions & 0 deletions test/hooks/init.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {expect, test} from '@dxcli/dev-test'

describe('hooks', () => {
test
.stdout()
.hook('init', {id: 'mycommand'})
.do(output => expect(output.stdout).to.contain('example hook running mycommand'))
.it('shows a message')
})
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
6 changes: 6 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../tsconfig",
"include": [
"./**/*"
]
}
Loading

0 comments on commit a915cec

Please sign in to comment.