This repository was archived by the owner on Aug 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 9 files changed +65
-16
lines changed Expand file tree Collapse file tree 9 files changed +65
-16
lines changed Original file line number Diff line number Diff line change 12
12
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-{{checksum "yarn.lock"}}
13
13
- v0-yarn-{{checksum ".circleci/config.yml"}}-{{ .Branch }}-
14
14
- v0-yarn-{{checksum ".circleci/config.yml"}}-master-
15
- - run : .circleci/setup_git
16
- - run : .circleci/yarn
17
- - run : yarn test
18
- - run : curl -s https://codecov.io/bash | bash
15
+ - run : .circleci/test
19
16
- store_test_results : &store_test_results
20
17
path : ~/cli/reports
21
18
- save_cache : &save_cache
@@ -31,21 +28,15 @@ jobs:
31
28
steps :
32
29
- checkout
33
30
- restore_cache : *restore_cache
34
- - run : .circleci/setup_git
35
- - run : .circleci/yarn
36
- - run : yarn test
37
- - run : curl -s https://codecov.io/bash | bash
31
+ - run : .circleci/test
38
32
- store_test_results : *store_test_results
39
33
release :
40
34
<< : *test
41
35
steps :
42
36
- add_ssh_keys
43
37
- checkout
44
38
- restore_cache : *restore_cache
45
- - run : .circleci/setup_git
46
- - run : .circleci/yarn
47
- - run : yarn add -D @dxcli/semantic-release@1
48
- - run : yarn exec nps release
39
+ - run : .circleci/release
49
40
50
41
workflows :
51
42
version : 2
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -ex
4
+
5
+ .circleci/setup_git
6
+
7
+ PATH=/usr/local/share/.config/yarn/global/node_modules/.bin:$PATH
8
+
9
+ yarn global add @dxcli/semantic-release@1 semantic-release@12
10
+ yarn install --frozen-lockfile
11
+ semantic-release -e @dxcli/semantic-release
Original file line number Diff line number Diff line change 2
2
3
3
set -ex
4
4
5
+ .circleci/setup_git
6
+
5
7
PATH=/usr/local/share/.config/yarn/global/node_modules/.bin:$PATH
6
8
7
9
CLI_ENGINE_UTIL_YARN_ARGS=" --frozen-lockfile"
@@ -20,3 +22,8 @@ yarn install $CLI_ENGINE_UTIL_YARN_ARGS
20
22
if [[ " $CLI_ENGINE_GREENKEEPER_BRANCH " == 1 ]]; then
21
23
greenkeeper-lockfile-upload
22
24
fi
25
+
26
+ yarn add -D nyc @dxcli/nyc-config
27
+ yarn test
28
+
29
+ curl -s https://codecov.io/bash | bash
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ install:
10
10
- git submodule update --init --recursive
11
11
- git config --global user.email "dxcli@example.com"
12
12
- git config --global user.name "dxcli"
13
- - yarn
13
+ - yarn add -D nyc @dxcli/nyc-config
14
14
test_script :
15
15
- yarn test
16
16
after_test :
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ setColors(['dim'])
13
13
const script = ( script , description ) => description ? { script, description} : { script}
14
14
15
15
const linters = {
16
- eslint : script ( 'tsc && eslint .' , 'lint js files' ) ,
16
+ eslint : script ( 'eslint .' , 'lint js files' ) ,
17
17
commitlint : script ( 'commitlint --from origin/master' , 'ensure that commits are in valid conventional-changelog format' ) ,
18
18
tsc : script ( 'tsc -p test --noEmit' , 'syntax check with tsc' ) ,
19
19
tslint : script ( 'tslint -p test' , 'lint ts files' ) ,
@@ -49,6 +49,5 @@ module.exports = {
49
49
lint : concurrent ( linters ) ,
50
50
test,
51
51
mocha,
52
- release : 'dxcli-semantic-release -e @dxcli/semantic-release' ,
53
52
} ,
54
53
}
Original file line number Diff line number Diff line change 16
16
"@dxcli/nyc-config" : " ^0.0.4" ,
17
17
"@dxcli/tslint" : " ^0.1.3" ,
18
18
"@heroku/linewrap" : " ^1.0.0" ,
19
+ "@types/chai" : " ^4.1.2" ,
20
+ "@types/lodash" : " ^4.14.98" ,
21
+ "@types/mocha" : " ^2.2.47" ,
22
+ "@types/nock" : " ^9.1.2" ,
23
+ "@types/node" : " ^9.4.0" ,
24
+ "@types/node-notifier" : " ^0.0.28" ,
25
+ "@types/read-pkg" : " ^3.0.0" ,
19
26
"chai" : " ^4.1.2" ,
20
27
"eslint" : " ^4.16.0" ,
21
28
"eslint-config-dxcli" : " ^1.2.1" ,
Original file line number Diff line number Diff line change @@ -62,6 +62,19 @@ export const integer = build({
62
62
} ,
63
63
} )
64
64
65
+ export interface EnumFlagOptions < T > extends Partial < IOptionFlag < T > > {
66
+ options : string [ ]
67
+ }
68
+
69
+ const _enum = < T = string > ( opts : EnumFlagOptions < T > ) => build < T > ( {
70
+ parse ( input ) {
71
+ if ( ! opts . options . includes ( input ) ) throw new Error ( `Expected --${ this . name } =${ input } to be one of: ${ opts . options . join ( ', ' ) } ` )
72
+ return input
73
+ } ,
74
+ ...opts as any ,
75
+ } )
76
+ export { _enum as enum }
77
+
65
78
export function option < T > ( options : { parse : IOptionFlag < T > [ 'parse' ] } & Partial < IOptionFlag < T > > ) {
66
79
return build < T > ( options ) ( )
67
80
}
Original file line number Diff line number Diff line change @@ -371,4 +371,25 @@ See more help with --help`)
371
371
expect ( out . flags ) . to . deep . include ( { foo : 'bar' } )
372
372
} )
373
373
} )
374
+
375
+ describe ( 'enum' , ( ) => {
376
+ it ( 'accepts valid option' , ( ) => {
377
+ const foo = flags . enum < 'myopt' | 'myotheropt' > ( { options : [ 'myopt' , 'myotheropt' ] } )
378
+ const out = parse ( {
379
+ argv : [ '--foo' , 'myotheropt' ] ,
380
+ flags : { foo : foo ( ) } ,
381
+ } )
382
+ expect ( out . flags . foo ) . to . equal ( 'myotheropt' )
383
+ } )
384
+
385
+ it ( 'fails when invalid' , ( ) => {
386
+ const foo = flags . enum ( { options : [ 'myopt' , 'myotheropt' ] } )
387
+ expect ( ( ) => {
388
+ parse ( {
389
+ argv : [ '--foo' , 'bar' ] ,
390
+ flags : { foo : foo ( ) } ,
391
+ } )
392
+ } ) . to . throw ( 'Expected --foo=bar to be one of: myopt, myotheropt' )
393
+ } )
394
+ } )
374
395
} )
Original file line number Diff line number Diff line change 154
154
version "4.1.2"
155
155
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.1.2.tgz#f1af664769cfb50af805431c407425ed619daa21"
156
156
157
- " @types/lodash@^4.14.97 " :
157
+ " @types/lodash@^4.14.97" , "@types/lodash@^4.14.98" :
158
158
version "4.14.98"
159
159
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.98.tgz#aaf012ae443e657e7885e605a4c1b340db160609"
160
160
You can’t perform that action at this time.
0 commit comments