File tree Expand file tree Collapse file tree 13 files changed +111
-15
lines changed Expand file tree Collapse file tree 13 files changed +111
-15
lines changed Original file line number Diff line number Diff line change
1
+ const { config } = require ( './index.js' )
2
+
1
3
module . exports = {
2
- extends : [ './ config/js/eslint.config.js' ] ,
4
+ extends : [ config . eslint ] ,
3
5
}
Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ module.exports = {
2
2
hooks : {
3
3
'commit-msg' : './bin/d2-style commit check' ,
4
4
'pre-commit' :
5
- './bin/d2-style validate --lint-staged-config .lint-stagedrc.js' ,
5
+ 'yarn test && ./bin/d2-style validate --lint-staged-config .lint-stagedrc.js' ,
6
6
} ,
7
7
}
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ const stage = process.env.CLI_STYLE_STAGE === 'true'
3
3
4
4
module . exports = {
5
5
'*.{js,jsx,ts,tsx}' : [
6
- 'yarn test' ,
7
6
`./bin/d2-style js ${ fix ? 'apply' : 'check' } ${
8
7
fix && stage ? '--stage' : ''
9
8
} `,
Original file line number Diff line number Diff line change 1
- module . exports = require ( './config/js/prettier.config.js' )
1
+ const { config } = require ( './index.js' )
2
+
3
+ module . exports = {
4
+ ...require ( config . prettier ) ,
5
+ }
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
const { makeEntryPoint } = require ( '@dhis2/cli-helpers-engine' )
3
- const command = require ( '..' )
3
+ const command = require ( '../src ' )
4
4
5
5
makeEntryPoint ( command )
Original file line number Diff line number Diff line change
1
+ const { config } = require ( '@dhis2/cli-style' )
2
+
1
3
module . exports = {
2
- extends : [ './node_modules/@dhis2/cli-style/ config/js/eslint.config.js' ] ,
4
+ extends : [ config . eslint ] ,
3
5
}
Original file line number Diff line number Diff line change
1
+ const { config } = require ( '@dhis2/cli-style' )
2
+
1
3
module . exports = {
2
- ...require ( '@dhis2/cli-style/ config/js/prettier.config.js' ) ,
4
+ ...require ( config . prettier ) ,
3
5
}
Original file line number Diff line number Diff line change 1
- const { namespace } = require ( '@dhis2/cli-helpers-engine' )
1
+ const { bundledConfigPaths } = require ( './src/groups.js' )
2
+ const command = require ( './src/index.js' )
2
3
3
- const command = namespace ( 'style' , {
4
- desc : 'DHIS2 programmatic style for commit msgs/code' ,
5
- aliases : 's' ,
6
- builder : require ( './src/cmds.js' ) ,
7
- } )
8
-
9
- module . exports = command
4
+ exports . config = bundledConfigPaths ( )
5
+ exports . command = command
Original file line number Diff line number Diff line change 2
2
"name" : " @dhis2/cli-style" ,
3
3
"version" : " 4.0.0" ,
4
4
"description" : " The code and commit style for DHIS2." ,
5
+ "main" : " index.js" ,
5
6
"bin" : {
6
7
"d2-style" : " bin/d2-style"
7
8
},
Original file line number Diff line number Diff line change @@ -238,6 +238,46 @@ const groupConfigs = selector => {
238
238
return [ ...result ]
239
239
}
240
240
241
+ /**
242
+ * Returns an object which contains the bundled configuration file for
243
+ * each tool in cli-style
244
+ */
245
+ const bundledConfigPaths = ( ) => {
246
+ const config = { }
247
+
248
+ for ( const selector of groups ) {
249
+ const groupName = selector [ 0 ]
250
+ const tools = selector [ 1 ]
251
+
252
+ for ( const identifier of tools ) {
253
+ const toolName = identifier [ 0 ]
254
+ const toolConfigs = identifier [ 1 ]
255
+ const sourceConfigPath = toolConfigs [ 0 ]
256
+
257
+ switch ( toolName ) {
258
+ /* Some tools have two configs, e.g. `*.config.js` and `*.local.js`.
259
+ * Usually we want the local configuration (see the
260
+ * groups array) since that is what we install to the
261
+ * local repo, but in this case we need the internal
262
+ * configuration file path, so we need to override it
263
+ * here.
264
+ */
265
+ case 'prettier' :
266
+ config . prettier = PRETTIER_CONFIG
267
+ break
268
+ case 'eslint' :
269
+ config . eslint = ESLINT_CONFIG
270
+ break
271
+ default :
272
+ config [ toolName ] = sourceConfigPath
273
+ break
274
+ }
275
+ }
276
+ }
277
+
278
+ return config
279
+ }
280
+
241
281
module . exports = {
242
282
groups,
243
283
projects,
@@ -247,4 +287,5 @@ module.exports = {
247
287
resolveProjectToGroups,
248
288
printGroups,
249
289
groupConfigs,
290
+ bundledConfigPaths,
250
291
}
You can’t perform that action at this time.
0 commit comments