-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
869 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/lib | ||
/test/fixtures | ||
/docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,22 @@ | ||
import run from '@dxcli/engine' | ||
import * as _ from 'lodash' | ||
|
||
import {expect, it, output} from '.' | ||
import {Options} from '.' | ||
|
||
export interface TestCommandOptions { | ||
description?: string | ||
stdout?: string | boolean | ||
stderr?: string | boolean | ||
exit?: number | ||
root?: string | ||
} | ||
|
||
export type TestCommandCallback<T> = (output: T) => Promise<void> | void | ||
|
||
export interface TestCommand { | ||
(args: string[], opts: TestCommandOptions & {stdout: true, stderr: true}, fn: TestCommandCallback<{stdout: string, stderr: string}>): void | ||
(args: string[], opts: TestCommandOptions & {stdout: true}, fn: TestCommandCallback<{stdout: string}>): void | ||
(args: string[], opts: TestCommandOptions & {stderr: true}, fn: TestCommandCallback<{stderr: string}>): void | ||
(args: string[], opts: TestCommandOptions, fn?: TestCommandCallback<{}>): void | ||
} | ||
|
||
export const testCommand: TestCommand = ( | ||
args: string[], | ||
opts: TestCommandOptions, | ||
fn?: TestCommandCallback<any> | ||
) => { | ||
const description = opts.description || args.join(' ') | ||
let test = it | ||
if (opts.stdout) test = test.stdout | ||
if (opts.stderr) test = test.stderr | ||
test(description, async () => { | ||
const exit = opts.exit || 0 | ||
try { | ||
export default (args: string[] | string, opts: Options = {}) => { | ||
return { | ||
async before() { | ||
args = _.castArray(args) | ||
await run(args, {root: opts.root || module.parent!.parent!.filename}) | ||
} catch (err) { | ||
if (err.code !== 'EEXIT') throw err | ||
if (err['cli-ux'].exit !== exit) { | ||
throw new Error(`Expected exit code to be ${exit} but got ${err['cli-ux'].exit}`) | ||
} | ||
} | ||
if (typeof opts.stdout === 'string') expect(output.stdout).to.equal(opts.stdout) | ||
if (typeof opts.stderr === 'string') expect(output.stderr).to.equal(opts.stderr) | ||
if (!fn) return | ||
let o: any = {} | ||
if (opts.stdout) o.stdout = output.stdout | ||
if (opts.stderr) o.stderr = output.stderr | ||
await fn(o) | ||
}) | ||
} | ||
} | ||
// const exit = opts.exit || 0 | ||
// try { | ||
// await run(args, {root: opts.root || module.parent!.parent!.filename}) | ||
// } catch (err) { | ||
// if (err.code !== 'EEXIT') throw err | ||
// if (err['cli-ux'].exit !== exit) { | ||
// throw new Error(`Expected exit code to be ${exit} but got ${err['cli-ux'].exit}`) | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {CLIError} from 'cli-ux' | ||
|
||
/** | ||
* ensures that a dxcli command or hook exits | ||
* | ||
* @param code - expected code | ||
* @default 0 | ||
*/ | ||
export default (code = 0) => { | ||
let err: CLIError | ||
return { | ||
catch(_: any, e: CLIError) { | ||
err = e | ||
if (!err['cli-ux'] || typeof err['cli-ux'].exit !== 'number') throw err | ||
if (err['cli-ux'].exit !== code) { | ||
throw new Error(`Expected hook to exit with ${code} but exited with ${err['cli-ux'].exit}`) | ||
} | ||
}, | ||
finally() { | ||
if (!err) throw new Error(`Expected hook to exit with code ${code} but it ran without exiting`) | ||
} | ||
} | ||
} |
Oops, something went wrong.