Skip to content

Commit

Permalink
fix: update lockfile and dependencies (#49)
Browse files Browse the repository at this point in the history
* fix(lockfile): update lockfile + fix vulnerabilities

* chore(deps): first wave of dep update

* fix(npm-scripts): move Husky hooks to NPM scripts

To be usable with the new major version of Husky

* chore(commit-hook): use the suggested script

Use the hook script suggested by the official docs to see if that exits from the shell it runs in
(the previous version doesn't)

* fix: fix issues highlighted by local Husky hooks

* fix(remark): fix Remark config

* fix(package): reverted `commander` bump to unbreak tests

* fix(package): reverted `commander` bump to unbreak tests

* style(remark-config): formatting

* fix(index): remove unneeded null coalescing

* test: add more tests [wip]

* refactor: clean-up and refactoring

* chore: bump commander to v6 + removed a blank line

* chore(dep): bumped commander to v6.2.0

v7.0.0 breaks several tests so I'll tackle that in another PR

* fix(transform): fix regression

* fix(transform): fix small issue
  • Loading branch information
Berkmann18 committed May 28, 2023
1 parent 1555b53 commit f5d69a1
Show file tree
Hide file tree
Showing 17 changed files with 19,009 additions and 20,272 deletions.
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Expand Up @@ -25,16 +25,16 @@
## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->
<!--- Include details of your testing environment and the tests you ran to -->
<!--- See how your change affects other areas of the code, etc. -->
<!--- Unit tests are expected for all changes. -->

## Screenshots (if appropriate):

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
<!--- If you need clarification on any of these, feel free to ask. We're here to help! -->

- [ ] I have updated the documentation (if required).
- [ ] I have read the **CONTRIBUTING** document.
Expand Down
4 changes: 4 additions & 0 deletions .husky/commit-msg
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ${1}
4 changes: 4 additions & 0 deletions .husky/post-merge
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm i
4 changes: 4 additions & 0 deletions .husky/pre-commit
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run precommit
4 changes: 4 additions & 0 deletions .husky/pre-push
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run lint && npm t
13 changes: 11 additions & 2 deletions .remarkrc
@@ -1,6 +1,15 @@
{
"plugins": [
"remark-preset-lint-recommended",
"remark-preset-lint-consistent"
"remark-preset-lint-consistent",
[
"remark-lint-no-undefined-references",
{
"allow": [
" ",
"[ ]"
]
}
]
]
}
}
1 change: 0 additions & 1 deletion __tests__/cli.test.js
Expand Up @@ -242,7 +242,6 @@ describe('HTML', () => {
});
});

// Errors
describe('Errors', () => {
it('handles bad inputs', async () => {
try {
Expand Down
38 changes: 20 additions & 18 deletions __tests__/fixtures.js
Expand Up @@ -4,20 +4,18 @@ const INPUT = '13 / 94 / 86 / 75 / (0/3, 0/3, 2/7)';
const TWO_INPUTS = ['13 / 94 / 86 / 75 / (0, 0, 2)', '26 / 100 / 85 / 75 / (0, 0, 2)'];
const NAMES = ['a', 'b'];

const OUTPUT = [
{
perf: 0.13,
a11y: 0.94,
bp: 0.86,
seo: 0.75,
pwa: {
fnr: 0,
ins: 0,
po: 0.2857142857142857
},
average: AVG
}
];
const OUTPUT = [{
perf: 0.13,
a11y: 0.94,
bp: 0.86,
seo: 0.75,
pwa: {
fnr: 0,
ins: 0,
po: 0.2857142857142857
},
average: AVG
}];
const DIFF = {
perf: 0.13,
a11y: 0.06,
Expand Down Expand Up @@ -294,14 +292,16 @@ const HTML_SDP_OUTPUT = `<table>
</table>
`;

const OUTPUT_STR = `0.13 / 0.94 / 0.86 / 0.75 / (0, 0, ${OUTPUT[0].pwa.po}) => ${AVG}`;
const PARSED_OUTPUT = `"0.13 / 0.94 / 0.86 / 0.75 / (0, 0, ${OUTPUT[0].pwa.po})" => ${AVG}`;
const TEXT_OUTPUT = `Input => Average
"${INPUT}" => ${AVG}
`;
const TEXT_PERC_OUTPUT = `Input => Average
"${INPUT}" => ${PERC}
`;
const TEXT_SPLIT_OUTPUT = `Perf / A11y / BP / SEO / PWA => Average
0.13 / 0.94 / 0.86 / 0.75 / (0, 0, ${OUTPUT[0].pwa.po}) => ${AVG}
${OUTPUT_STR}
`;
const TEXT_SP_OUTPUT = `Perf / A11y / BP / SEO / PWA => Average
13% / 94% / 86% / 75% / (0%, 0%, ${PERC_OUTPUT[0].pwa.po}) => ${PERC}
Expand All @@ -314,12 +314,12 @@ const TEXT_NAMED_OUTPUT = `Name: Input => Average
${NAMES[0]}: "13 / 94 / 86 / 75 / (0/3, 0/3, 2/7)" => ${AVG}
`;
const TEXT_SD_OUTPUT = `Perf / A11y / BP / SEO / PWA => Average
0.13 / 0.94 / 0.86 / 0.75 / (0, 0, ${OUTPUT[0].pwa.po}) => ${AVG}
${OUTPUT_STR}
0.13 / 0.06000000000000005 / -0.010000000000000009 / 0 / (0, 0, 0) => ${DIFF.average}
`;

const TEXT_SN_OUTPUT = `Name: Perf / A11y / BP / SEO / PWA => Average
${NAMES[0]}: 0.13 / 0.94 / 0.86 / 0.75 / (0, 0, ${OUTPUT[0].pwa.po}) => ${AVG}
${NAMES[0]}: ${OUTPUT_STR}
`;
const TEXT_SDP_OUTPUT = `Perf / A11y / BP / SEO / PWA => Average
13% / 94% / 86% / 75% / (0%, 0%, ${PERC_OUTPUT[0].pwa.po}) => ${PERC}
Expand Down Expand Up @@ -384,5 +384,7 @@ module.exports = {
splitDiff: HTML_SD_OUTPUT,
splitNamed: HTML_SN_OUTPUT,
splitDiffPerc: HTML_SDP_OUTPUT
}
},
OUTPUT_STR,
PARSED_OUTPUT
};
44 changes: 44 additions & 0 deletions __tests__/process.test.js
@@ -0,0 +1,44 @@
const { scoreToString, generate } = require('../src/process.ts');
const { OUTPUT, PARSED_OUTPUT, INPUT, JSON_OUTPUT, CSV_OUTPUT, MD_OUTPUT, HTML_OUTPUT, TEXT_OUTPUT } = require('./fixtures.js');

test('scoreToString', () => {
expect(scoreToString(OUTPUT[0])).toBe(PARSED_OUTPUT);
});

//TODO: Add tests that properly check the output from the transformers used by generate()
describe('generate', () => {
test('JSON', () => {
expect(generate({
inputs: [INPUT],
format: 'json'
})).toBe(JSON_OUTPUT)
});

test('CSV', () => {
expect(generate({
inputs: [INPUT],
format: 'csv'
})).toBe(CSV_OUTPUT)
});

test('MD', () => {
expect(generate({
inputs: [INPUT],
format: 'md'
})).toBe(MD_OUTPUT)
});

test('HTML', () => {
expect(generate({
inputs: [INPUT],
format: 'html'
})).toBe(HTML_OUTPUT)
});

test('Text', () => {
expect(generate({
inputs: [INPUT],
format: 'text'
})).toBe(TEXT_OUTPUT)
});
});
7 changes: 6 additions & 1 deletion cli.js
Expand Up @@ -33,9 +33,11 @@ const findConfig = (configFromCli) => {

return new Promise((resolve, reject) => {
if (configFromCli) {
// console.log('cFC')
explorer
.load(configFromCli)
.then((result) => {
// console.log('got=', result)
if (result && !result.isEmpty) {
resolve({ ...options, ...result.config });
} else reject(result);
Expand All @@ -46,9 +48,11 @@ const findConfig = (configFromCli) => {
} else reject(err);
});
} else {
// console.log('Searching')
explorer
.search()
.then((result) => {
// console.log('found=', result)
if (result && !result.isEmpty) {
resolve({ ...options, ...result.config });
} else reject(result);
Expand Down Expand Up @@ -84,12 +88,13 @@ program
.option('-c, --config <config>', 'Use the configuration from the specified path')
.option(
'-m, --multi <multi>',
'Show multiple results (EXPERIMENTAL, please the config option for this)'
'Show multiple results (EXPERIMENTAL, please use the config option for this)'
)
.action(async (scoreStrings) => {
let options = {};
try {
options = await findConfig(program.config);
// console.log('opts=', options);
} catch (err) {
if (!scoreStrings.length) throw new Error('No input found!');
}
Expand Down

0 comments on commit f5d69a1

Please sign in to comment.