Skip to content

Commit

Permalink
feat: stub out the validate command
Browse files Browse the repository at this point in the history
  • Loading branch information
dominykas committed Oct 21, 2020
1 parent 40b979e commit 70e592f
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .wiby.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"dependents": [
{
"repository": "https://github.com/wiby-test/partial"
},
{
"repository": "https://github.com/wiby-test/fail"
},
{
"repository": "https://github.com/wiby-test/pass"
}
]
}
16 changes: 16 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,19 @@ Options:
--dependent URL of a dependent [string] [required]
```


## `wiby validate`



Check the structure of the configuration file.

```
Options:
--version Show version number [boolean]
--help Show help [boolean]
--config Path to the configuration file. By default it will try to load the
configuration from the first file it finds in the current working
directory: `.wiby.json`, `.wiby.js` [string]
```

13 changes: 13 additions & 0 deletions bin/commands/validate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

const wiby = require('../..')

exports.desc = 'Check the structure of the configuration file.'

exports.builder = (yargs) => yargs
.option('config', {
desc: 'Path to the configuration file. By default it will try to load the configuration from the first file it finds in the current working directory: `.wiby.json`, `.wiby.js`',
type: 'string'
})

exports.handler = (params) => wiby.validate(params)
8 changes: 8 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'

const path = require('path')

exports.validate = ({ config }) => {
const contents = require(path.join(process.cwd(), '.wiby.json'))
console.log(contents)
}
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
exports.test = require('./test')

exports.result = require('./result')

exports.validate = require('./config').validate
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"chalk": "^4.1.0",
"dotenv": "^8.2.0",
"git-url-parse": "^11.1.2",
"joi": "^17.2.1",
"node-fetch": "^2.6.0",
"yargs": "^16.0.0"
},
Expand Down
8 changes: 8 additions & 0 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ tap.test('result command', async (tap) => {
tap.end()
})
})

tap.test('validate command', async (tap) => {
tap.test('should pass on wiby itself', async (tap) => {
const result = childProcess.execSync(`${wibyCommand} validate`, { cwd: cwd }).toString()
console.info(result)
tap.end()
})
})
9 changes: 9 additions & 0 deletions test/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

const tap = require('tap')
const wiby = require('..')

tap.test('Exists', (tap) => {
wiby.validate({})
tap.end()
})

0 comments on commit 70e592f

Please sign in to comment.