Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 20, 2018
0 parents commit 0146fd0
Show file tree
Hide file tree
Showing 20 changed files with 5,130 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
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/test"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/test"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
- v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/test"}}-{{checksum ".circleci/config.yml"}}-master-
- run: ./.circleci/test
- store_test_results:
path: ~/cli/reports
- save_cache: &save_cache
key: v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum ".circleci/test"}}-{{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:
- checkout
- restore_cache: *restore_cache
- run: yarn --frozen-lockfile
- run: ./node_modules/.bin/nps ci.release
- save_cache: *save_cache

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

set -ex

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

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

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

mkdir -p reports
./node_modules/.bin/nps ci
curl -s https://codecov.io/bash | bash
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/not-found
================

&#34;did you mean&#34; for dxcli

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

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

module.exports = {
scripts: {
build: 'rm -rf lib && tsc',
lint: {
default: concurrent.nps('lint.eslint', 'lint.commitlint', 'lint.tsc', 'lint.tslint'),
eslint: {
script: 'eslint .',
description: 'lint js files',
},
commitlint: {
script: 'commitlint --from origin/master',
description: 'ensure that commits are in valid conventional-changelog format',
},
tsc: {
script: 'tsc -p test --noEmit',
description: 'syntax check with tsc',
},
tslint: {
script: 'tslint -p test',
description: 'lint ts files',
},
},
test: {
default: {
script: concurrent.nps('lint', 'test.mocha'),
description: 'lint and run all tests',
},
mocha: {
script: 'mocha "test/**/*.test.ts"',
description: 'run all mocha tests',
},
},
ci: {
default: {
script: concurrent.nps(
'ci.mocha',
'ci.eslint',
'ci.tslint',
),
hiddenFromHelp: true,
},
mocha: {
default: {
script: series.nps('ci.mocha.test', 'ci.mocha.report'),
hiddenFromHelp: true,
},
test: {
script: 'MOCHA_FILE="reports/mocha.xml" nps "ci.mocha.nyc nps \\"test.mocha --reporter mocha-junit-reporter\\""',
hiddenFromHelp: true,
},
report: {
script: series.nps('ci.mocha.nyc report --reporter text-lcov > coverage.lcov'),
hiddenFromHelp: true,
},
nyc: {
script: 'nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc',
hiddenFromHelp: true,
},
},
eslint: {
script: series.nps('lint.eslint --format junit --output-file reports/eslint.xml'),
hiddenFromHelp: true,
},
tslint: {
script: series.nps('lint.tslint --format junit > reports/tslint.xml'),
hiddenFromHelp: true,
},
release: {
script: 'dxcli-dev-semantic-release',
hiddenFromHelp: true,
},
},
},
}
48 changes: 48 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "@dxcli/not-found",
"description": "\"did you mean\" for dxcli",
"version": "0.0.0",
"author": "Jeff Dickey @jdxcode",
"bugs": "https://github.com/jdxcode/not-found/issues",
"dependencies": {
"@dxcli/command": "^0.1.13",
"cli-ux": "^3.1.3"
},
"devDependencies": {
"@dxcli/dev-semantic-release": "^0.0.3",
"@dxcli/dev-test": "^0.5.2",
"@dxcli/dev-tslint": "^0.0.15",
"@types/node": "^9.3.0",
"@types/read-pkg": "^3.0.0",
"eslint": "^4.16.0",
"eslint-config-dxcli": "^1.1.4",
"husky": "^0.14.3",
"mocha": "^5.0.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"
},
"engines": {
"node": ">=8.0.0"
},
"files": [
"/lib"
],
"homepage": "https://github.com/jdxcode/not-found",
"keywords": [
"dxcli-plugin"
],
"license": "MIT",
"repository": "dxcli/not-found",
"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}!`)
}
}
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 {}
14 changes: 14 additions & 0 deletions test/commands/hello.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {describe, expect, it, output} from '@dxcli/dev-test'

import cmd from '../../src/commands/hello'

describe.stdout('command', () => {
it('says hello world!', async () => {
await cmd.run([])
expect(output.stdout).to.equal('hello world!\n')
})
it('says hello jeff!', async () => {
await cmd.run(['--name', 'jeff'])
expect(output.stdout).to.equal('hello jeff!\n')
})
})
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
10 changes: 10 additions & 0 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig",
"compilerOptions": {
"rootDir": ".."
},
"include": [
"../src/**/*",
"../test/**/*"
]
}
21 changes: 21 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"declaration": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"module": "commonjs",
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./lib",
"rootDirs": [
"./src"
],
"sourceMap": true,
"strict": true,
"strictFunctionTypes": false,
"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 0146fd0

Please sign in to comment.