Skip to content

Commit d95179c

Browse files
committed
feat: convert to @dhis2/cli format
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.
1 parent 0a60c7e commit d95179c

File tree

9 files changed

+2045
-27
lines changed

9 files changed

+2045
-27
lines changed

bin/d2-style

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node
2+
const { makeEntryPoint } = require('@dhis2/cli-helpers-engine')
3+
const command = require('..')
4+
5+
makeEntryPoint(command).parse()

code-style.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

commit-style.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const { namespace } = require('@dhis2/cli-helpers-engine')
2+
3+
const command = namespace('style', {
4+
desc: 'DHIS2 programmatic style for commit msgs/code',
5+
aliases: 's',
6+
builder: require('./lib/cmds'),
7+
})
8+
9+
module.exports = command

lib/cmds.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = yargs => {
2+
yargs.commandDir('cmds')
3+
}

lib/cmds/fmt-code.js renamed to lib/cmds/fmt-code-js.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ function cwd() {
3030
}
3131

3232
// plugin
33-
exports.command = '$0'
33+
exports.command = 'js'
3434

35-
exports.describe = 'Format code according to DHIS2 rules.'
35+
exports.describe = 'Format js code according to DHIS2 rules.'
3636

3737
exports.builder = {
3838
all: { boolean: true },

lib/cmds/fmt-commit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const load = require('@commitlint/load')
33
const lint = require('@commitlint/lint')
44
const format = require('@commitlint/format')
55

6-
exports.command = '$0'
6+
exports.command = 'commit'
77

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

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"name": "@dhis2/code-style",
2+
"name": "@dhis2/cli-style",
33
"version": "1.7.1",
4-
"description": "The JavaScript code style for DHIS2.",
4+
"description": "The code and commit style for DHIS2.",
55
"bin": {
6-
"code-style": "./code-style.js",
7-
"commit-style": "./commit-style.js"
6+
"d2-style": "bin/d2-style"
87
},
98
"scripts": {
109
"test": "echo \"Error: no test specified\" && exit 1",
11-
"format": "./code-style.js"
10+
"release": "d2-packages release",
11+
"format": "./bin/d2-style js"
1212
},
1313
"author": "Viktor Varland",
1414
"license": "BSD-3-Clause",
@@ -18,6 +18,7 @@
1818
"@commitlint/lint": "^7.2.1",
1919
"@commitlint/load": "^7.2.1",
2020
"@commitlint/read": "^7.1.2",
21+
"@dhis2/cli-helpers-engine": "^0.10.1",
2122
"prettier": "^1.15.3",
2223
"yargs": "^12.0.5"
2324
},
@@ -26,8 +27,8 @@
2627
},
2728
"husky": {
2829
"hooks": {
29-
"commit-msg": "./commit-style.js",
30-
"pre-commit": "./code-style.js"
30+
"commit-msg": "./bin/d2-style commit",
31+
"pre-commit": "./bin/d2-style js"
3132
}
3233
}
3334
}

0 commit comments

Comments
 (0)