Skip to content

Commit

Permalink
feat: convert to @dhis2/cli format
Browse files Browse the repository at this point in the history
BREAKING CHANGE: removes the binaries for `code-style.js` and
`commit-style.js` and instead exposes a binary named `d2-style` which is
the subcommand which the `d2` cli will use.
  • Loading branch information
varl committed Feb 6, 2019
1 parent 0a60c7e commit d95179c
Show file tree
Hide file tree
Showing 9 changed files with 2,045 additions and 27 deletions.
5 changes: 5 additions & 0 deletions bin/d2-style
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env node
const { makeEntryPoint } = require('@dhis2/cli-helpers-engine')
const command = require('..')

makeEntryPoint(command).parse()
12 changes: 0 additions & 12 deletions code-style.js

This file was deleted.

5 changes: 0 additions & 5 deletions commit-style.js

This file was deleted.

9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { namespace } = require('@dhis2/cli-helpers-engine')

const command = namespace('style', {
desc: 'DHIS2 programmatic style for commit msgs/code',
aliases: 's',
builder: require('./lib/cmds'),
})

module.exports = command
3 changes: 3 additions & 0 deletions lib/cmds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = yargs => {
yargs.commandDir('cmds')
}
4 changes: 2 additions & 2 deletions lib/cmds/fmt-code.js → lib/cmds/fmt-code-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ function cwd() {
}

// plugin
exports.command = '$0'
exports.command = 'js'

exports.describe = 'Format code according to DHIS2 rules.'
exports.describe = 'Format js code according to DHIS2 rules.'

exports.builder = {
all: { boolean: true },
Expand Down
2 changes: 1 addition & 1 deletion lib/cmds/fmt-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const load = require('@commitlint/load')
const lint = require('@commitlint/lint')
const format = require('@commitlint/format')

exports.command = '$0'
exports.command = 'commit'

exports.describe = 'Format commit messages according to DHIS2 rules.'

Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@dhis2/code-style",
"name": "@dhis2/cli-style",
"version": "1.7.1",
"description": "The JavaScript code style for DHIS2.",
"description": "The code and commit style for DHIS2.",
"bin": {
"code-style": "./code-style.js",
"commit-style": "./commit-style.js"
"d2-style": "bin/d2-style"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"format": "./code-style.js"
"release": "d2-packages release",
"format": "./bin/d2-style js"
},
"author": "Viktor Varland",
"license": "BSD-3-Clause",
Expand All @@ -18,6 +18,7 @@
"@commitlint/lint": "^7.2.1",
"@commitlint/load": "^7.2.1",
"@commitlint/read": "^7.1.2",
"@dhis2/cli-helpers-engine": "^0.10.1",
"prettier": "^1.15.3",
"yargs": "^12.0.5"
},
Expand All @@ -26,8 +27,8 @@
},
"husky": {
"hooks": {
"commit-msg": "./commit-style.js",
"pre-commit": "./code-style.js"
"commit-msg": "./bin/d2-style commit",
"pre-commit": "./bin/d2-style js"
}
}
}
Loading

0 comments on commit d95179c

Please sign in to comment.