Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
fix: remove rxjs
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 20, 2018
1 parent dcbad25 commit 7fbc05c
Show file tree
Hide file tree
Showing 22 changed files with 1,053 additions and 487 deletions.
13 changes: 7 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:
- checkout
- restore_cache: &restore_cache
keys:
- 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 test
- 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 "scripts/circleci"}}-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
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
Expand All @@ -30,7 +30,8 @@ jobs:
steps:
- checkout
- restore_cache: *restore_cache
- run: ./scripts/circleci release
- run: yarn --frozen-lockfile
- run: ./node_modules/.bin/nps ci.release
- save_cache: *save_cache

workflows:
Expand Down
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
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: series.nps('ci.mocha.nyc cross-env MOCHA_FILE="reports/mocha.xml" 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: 'yarn --frozen-lockfile && dxcli-dev-semantic-release',
hiddenFromHelp: true,
},
},
},
}
33 changes: 8 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,29 @@
"fs-extra": "^5.0.0",
"lodash": "^4.17.4",
"password-prompt": "^1.0.3",
"rxjs": "^5.5.6",
"semver": "^5.5.0",
"strip-ansi": "^4.0.0",
"supports-color": "^5.1.0"
},
"devDependencies": {
"@dxcli/dev": "^1.1.3",
"@dxcli/dev-semantic-release": "^0.0.3",
"@dxcli/dev-test": "^0.2.2",
"@dxcli/dev-test": "^0.4.0",
"@dxcli/dev-tslint": "^0.0.15",
"@types/fs-extra": "^5.0.0",
"@types/node": "^9.3.0",
"@types/semver": "^5.4.0",
"@types/supports-color": "^3.1.0",
"eslint": "^4.15.0",
"cross-env": "^5.1.3",
"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": {
"workflows": {
"test": [
"eslint .",
"tsc -p test --noEmit",
"tslint -p test",
"commitlint --from origin/master",
"mocha \"test/**/*.ts\""
],
"lint": [
"eslint .",
"tsc -p test --noEmit",
"tslint -p test",
"commitlint --from origin/master"
]
}
},
"engines": {
"node": ">=8.0.0"
},
Expand All @@ -67,10 +51,9 @@
"repository": "dxcli/cli-ux",
"scripts": {
"commitmsg": "dxcli-dev-commitmsg",
"lint": "dxcli-dev lint",
"precommit": "dxcli-dev lint",
"prepare": "rm -rf lib && tsc",
"test": "dxcli-dev test"
"precommit": "nps lint",
"prepare": "nps build",
"test": "nps test"
},
"types": "lib/index.d.ts"
}
65 changes: 0 additions & 65 deletions scripts/circleci

This file was deleted.

35 changes: 24 additions & 11 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import Rx = require('rxjs/Rx')
import * as EventEmitter from 'events'
import * as semver from 'semver'

import {ActionBase} from './action/base'
import {ConfigMessage} from './message'

const version = semver.parse(require('../package.json').version)!

export type Levels = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace'

export interface ConfigMessage {
type: 'config'
prop: string
value: any
}

const globals = global['cli-ux'] || (global['cli-ux'] = {})

const actionType = (
Expand All @@ -20,29 +25,37 @@ const actionType = (

const Action = actionType === 'spinner' ? require('./action/spinner').default : require('./action/simple').default

export class Config extends Rx.Subject<ConfigMessage> {
export class Config extends EventEmitter {
logLevel: Levels = 'warn'
outputLevel: Levels = 'info'
debug = process.env.DEBUG === '*'
_debug = false
action: ActionBase = new Action()
errorsHandled = false

constructor() {
super()
this.debug = process.env.DEBUG === '*'
}

get errlog(): string | undefined { return globals.errlog }
set errlog(errlog: string | undefined) {
globals.errlog = errlog
this.next({type: 'config', prop: 'errlog', value: errlog})
this.emit('errlog', errlog)
}
}

function current() {
if (!globals[version.major] || globals[version.major].closed) return
return globals[version.major]
get debug(): boolean {
return this._debug
}
set debug(v: boolean) {
this._debug = v
if (this._debug && this.outputLevel !== 'trace') this.outputLevel = 'debug'
}
}

function fetch() {
let subject = current()
if (subject) return subject
if (globals[version.major]) return globals[version.major]
return globals[version.major] = new Config()
}

export const config: Config = fetch()
export default config
13 changes: 11 additions & 2 deletions src/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import ansiStyles = require('ansi-styles')
import {Chalk} from 'chalk'
import stripAnsi = require('strip-ansi')

import Prompt = require('./prompt')
import prompt = require('./prompt')
import styledHeader = require('./styled/header')
import styledJSON = require('./styled/json')
import styledObject = require('./styled/object')
import table = require('./styled/table')

export const deps = {
get chalk(): Chalk { return fetch('chalk') },
Expand All @@ -12,7 +16,12 @@ export const deps = {
get ansiEscapes(): any { return fetch('ansi-escapes') },
get passwordPrompt(): any { return fetch('password-prompt') },
get screen(): typeof screen { return fetch('@dxcli/screen') },
get prompt(): typeof Prompt { return fetch('./prompt') },

get prompt(): typeof prompt.default { return fetch('./prompt').default },
get styledObject(): typeof styledObject.default { return fetch('./styled/object').default },
get styledHeader(): typeof styledHeader.default { return fetch('./styled/header').default },
get styledJSON(): typeof styledJSON.default { return fetch('./styled/json').default },
get table(): typeof table.default { return fetch('./styled/table').default },
}

const cache: any = {}
Expand Down
Loading

0 comments on commit 7fbc05c

Please sign in to comment.