Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
chore: eslint-ify
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 14, 2018
1 parent 6a0d985 commit 7c305e7
Show file tree
Hide file tree
Showing 34 changed files with 3,126 additions and 2,216 deletions.
54 changes: 32 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,49 @@
---
version: 2
jobs:
node-6: &test-build
node-latest: &test
docker:
- image: node:6
working_directory: /cli
- image: node:latest
working_directory: ~/cli
steps:
- checkout
- restore_cache:
- restore_cache: &restore_cache
keys:
- v0-yarn-{{ .Branch }}-{{checksum "yarn.lock"}}
- v0-yarn-{{ .Branch }}-
- v0-yarn-master
- run: node -v
- run: yarn
- run: yarn test --coverage
- run: curl -s https://codecov.io/bash | bash
- save_cache:
key: v0-yarn-{{ .Branch }}-{{checksum "yarn.lock"}}
- v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
- v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
- v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-master-
- run: ./scripts/circleci
- store_test_results:
path: ~/cli/reports
- save_cache: &save_cache
key: v0-yarn-{{ .Environment.CIRCLE_JOB }}-{{checksum "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
paths:
- /cli/node_modules
- ~/cli/node_modules
- /usr/local/share/.cache/yarn
- /usr/local/share/.config/yarn
node-8:
<<: *test-build
<<: *test
docker:
- image: node:8
node-9:
<<: *test-build
docker:
- image: node:latest
release:
<<: *test
steps:
- checkout
- restore_cache: *restore_cache
- run: yarn
- run: ./node_modules/.bin/dxcli-dev-semantic-release
- save_cache: *save_cache

workflows:
version: 2
test:
"@dxcli/parser":
jobs:
- node-6
- node-latest
- node-8
- node-9
- release:
context: org-global
filters:
branches: {only: master}
requires:
- node-latest
- node-8
5 changes: 3 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ root = true
[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
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"
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
*-debug.log
*-error.log
/coverage
/node_modules
/tmp
/lib
/.nyc_output
8 changes: 0 additions & 8 deletions .lintstagedrc

This file was deleted.

1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

4 changes: 0 additions & 4 deletions .prettierrc

This file was deleted.

18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
cli-flags
=========

[![CircleCI](https://circleci.com/gh/heroku/cli-flags/tree/master.svg?style=svg)](https://circleci.com/gh/heroku/cli-flags/tree/master)
[![codecov](https://codecov.io/gh/heroku/cli-flags/branch/master/graph/badge.svg)](https://codecov.io/gh/heroku/cli-flags)
@dxcli/parser
=============

arg and flag parser for dxcli

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

CLI flag parser.

Expand Down
19 changes: 19 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
environment:
nodejs_version: "9"
cache:
- '%LOCALAPPDATA%\Yarn -> appveyor.yml'
- node_modules -> package.json

install:
- ps: Install-Product node $env:nodejs_version x64
- 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

8 changes: 5 additions & 3 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/* eslint-disable no-console */

const {flags: Flags, parse} = require('.') // replace '.' with 'cli-flags'

const {flags, args} = parse({
flags: {
'output-file': Flags.string({char: 'o'}),
force: Flags.boolean({char: 'f'})
force: Flags.boolean({char: 'f'}),
},
args: [
{name: 'input', required: true}
]
{name: 'input', required: true},
],
})

if (flags.force) {
Expand Down
8 changes: 0 additions & 8 deletions jest.config.js

This file was deleted.

84 changes: 48 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,63 @@
{
"name": "cli-flags",
"description": "basic CLI flag parser",
"version": "2.0.7",
"author": "Jeff Dickey",
"bugs": "https://github.com/heroku/cli-flags/issues",
"name": "@dxcli/parser",
"description": "arg and flag parser for dxcli",
"version": "0.0.0",
"author": "Jeff Dickey @jdxcode",
"dependencies": {
"@cli-engine/screen": "^0.0.0",
"@heroku/linewrap": "^1.0.0",
"ts-lodash": "^4.0.8"
"@dxcli/screen": "^0.0.0",
"chalk": "^2.3.0",
"lodash": "^4.17.4"
},
"devDependencies": {
"@types/chalk": "2.2.0",
"@types/jest": "^22.0.0",
"@types/lodash": "^4.14.91",
"@types/node": "^8.5.2",
"babel-core": "^6.26.0",
"chalk": "^2.3.0",
"del-cli": "^1.1.0",
"@dxcli/dev": "^1.1.2",
"@dxcli/dev-semantic-release": "^0.0.3",
"@dxcli/dev-test": "^0.0.1",
"@dxcli/dev-tslint": "^0.0.6",
"@heroku/linewrap": "^1.0.0",
"@types/chalk": "^2.2.0",
"@types/node": "^9.3.0",
"eslint": "^4.15.0",
"eslint-config-dxcli": "^1.1.4",
"husky": "^0.14.3",
"jest": "^22.0.4",
"lint-staged": "^6.0.0",
"prettier": "^1.9.2",
"ts-jest": "^22.0.0",
"mocha": "^4.1.0",
"nyc": "^11.4.1",
"ts-node": "^4.1.0",
"tslint": "^5.8.0",
"tslint-config-prettier": "^1.6.0",
"typescript": "^2.6.2"
},
"dxcli": {
"workflows": {
"test": [
"eslint .",
"tsc",
"tslint -p .",
"commitlint --from master",
"tsc -p test --noEmit",
"mocha \"test/**/*.ts\""
],
"lint": [
"eslint .",
"tsc",
"tslint -p .",
"commitlint --from master",
"tsc -p test --noEmit"
]
}
},
"engines": {
"node": ">=6.0.0"
"node": ">=8.0.0"
},
"files": [
"lib"
],
"homepage": "https://github.com/heroku/cli-flags",
"keywords": [
"cli"
"/lib"
],
"license": "ISC",
"main": "./lib/index.js",
"repository": "heroku/cli-flags",
"license": "MIT",
"main": "lib/index.js",
"repository": "dxcli/parser",
"scripts": {
"posttest": "tslint -p .",
"precommit": "lint-staged",
"prepare": "del lib && tsc && del 'lib/**/*.test.js' 'lib/**/*.test.d.ts'",
"pretest": "tsc",
"test": "jest"
"commitmsg": "dxcli-dev-commitmsg",
"lint": "dxcli-dev lint",
"precommit": "dxcli-dev lint",
"prepare": "rm -rf lib && tsc",
"test": "dxcli-dev test"
},
"types": "./lib/index.d.ts"
"types": "lib/index.d.ts"
}
34 changes: 34 additions & 0 deletions scripts/circleci
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -ex

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

CWD=$(pwd)
NYC="./node_modules/.bin/nyc --nycrc-path node_modules/@dxcli/dev-nyc-config/.nycrc"
mkdir -p reports
MOCHA_FILE="$CWD/reports/mocha.xml" \
DXCLI_MOCHA_OPTS="--reporter mocha-junit-reporter" \
DXCLI_ESLINT_OPTS="--format junit --output-file $CWD/reports/eslint.xml" \
DXCLI_TSLINT_OPTS="--format junit > $CWD/reports/tslint.xml" \
$NYC yarn test
$NYC report --reporter=text-lcov > coverage.lcov

curl -s https://codecov.io/bash | bash
4 changes: 2 additions & 2 deletions src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface IArg<T = string> {
default?: T | (() => T)
}

export type ArgBase<T> = {
export interface ArgBase<T> {
name?: string
description?: string
hidden?: boolean
Expand All @@ -31,7 +31,7 @@ export type OptionalArg<T> = ArgBase<T> & {
export type Arg<T> = RequiredArg<T> | OptionalArg<T>

export function newArg<T>(arg: IArg<T> & { Parse: ParseFn<T> }): Arg<T>
export function newArg<T = string>(arg: IArg<string>): Arg<string>
export function newArg(arg: IArg): Arg<string>
export function newArg(arg: IArg<any>): any {
return {
parse: (i: string) => i,
Expand Down
10 changes: 5 additions & 5 deletions src/deps.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import screen = require('@dxcli/screen')
import chalk = require('chalk')

import args = require('./args')
import errors = require('./errors')
import flags = require('./flags')
import list = require('./list')
import parse = require('./parse')
import validate = require('./validate')
import errors = require('./errors')

import chalk = require('chalk')
import list = require('./list')
import screen = require('@cli-engine/screen')

export const deps = {
// local
Expand Down
Loading

0 comments on commit 7c305e7

Please sign in to comment.