-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate eslint, auto-changelog, prettier and jest as commands
- Loading branch information
Showing
15 changed files
with
5,158 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "./shared/eslint.json", | ||
"rules": { | ||
"global-require": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"./shared/prettier.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# core-commons | ||
|
||
Lifion's development setup in one command for our public Node.js projects. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const chalk = require('chalk'); | ||
const path = require('path'); | ||
const yargs = require('yargs'); | ||
|
||
async function start() { | ||
const argv = process.argv.slice(2); | ||
const header = 'Development framework by and for the Core Team.'; | ||
const learnMore = 'Read the manual at https://core.lifion.oneadp.com/libs/core-commons'; | ||
const { npm_lifecycle_event: lifecycleEvent } = process.env; | ||
|
||
if (lifecycleEvent) { | ||
argv.push(lifecycleEvent); | ||
} | ||
|
||
yargs(argv) | ||
.usage(`${header}\n\n${chalk.bold('USAGE')}\n $0 <command> [options]`) | ||
.epilogue(`${chalk.bold('LEARN MORE')}\n ${learnMore}`) | ||
.commandDir(path.resolve(__dirname, '../lib/commands')) | ||
.demandCommand() | ||
.recommendCommands() | ||
.strict() | ||
.help() | ||
.updateStrings({ | ||
'Commands:': chalk.bold('COMMANDS'), | ||
'Options:': chalk.bold('OPTIONS') | ||
}) | ||
.parse(); | ||
} | ||
|
||
start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
async function handler() { | ||
process.argv.push( | ||
...[['.'], ['--ext', '.js,.json,.md'], ['--ignore-pattern', '!.*.*']].flatMap((i) => i) | ||
); | ||
require('eslint/bin/eslint'); | ||
} | ||
|
||
module.exports = { | ||
command: path.parse(__filename).name, | ||
describe: 'Check the codebase with ESLint.', | ||
handler | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
async function handler() { | ||
const exts = ['hbs', 'js', 'json', 'md', 'ts']; | ||
process.argv.push('--write', `**/*.{${exts.join(',')}}`, '.*rc', '!reports/*'); | ||
require('prettier/bin-prettier'); | ||
} | ||
|
||
module.exports = { | ||
command: path.parse(__filename).name, | ||
describe: 'Format the codebase with Prettier.', | ||
handler | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
async function handler() { | ||
const cfg = { | ||
collectCoverage: true, | ||
collectCoverageFrom: ['**/*.js'], | ||
coverageDirectory: path.resolve(process.cwd(), 'coverage'), | ||
coverageReporters: ['clover', 'lcov', 'text'], | ||
coverageThreshold: { | ||
global: { | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
statements: 100 | ||
} | ||
}, | ||
rootDir: path.resolve(process.cwd(), 'lib'), | ||
testEnvironment: 'node' | ||
}; | ||
process.argv.push('--config', JSON.stringify(cfg)); | ||
require('jest/bin/jest'); | ||
} | ||
|
||
module.exports = { | ||
command: path.parse(__filename).name, | ||
describe: 'Run tests with Jest.', | ||
handler | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
async function handler() { | ||
process.argv.push( | ||
...[ | ||
['--package'], | ||
['--commit-limit', 'false'], | ||
['--template', path.resolve(__dirname, '../../shared/CHANGELOG.hbs')] | ||
].flatMap((i) => i) | ||
); | ||
require('auto-changelog'); | ||
} | ||
|
||
module.exports = { | ||
command: path.parse(__filename).name, | ||
describe: 'Generate the changelog.', | ||
handler | ||
}; |
Oops, something went wrong.