Skip to content

Commit d29488c

Browse files
committed
chore: depedencies for html report
1 parent ffc699b commit d29488c

File tree

6 files changed

+699
-40
lines changed

6 files changed

+699
-40
lines changed

cli/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ suite away from test smells.
88
```sh
99
npm run cli -- path/to/file/test.js typescript
1010
```
11+
12+
## Resources
13+
14+
- [Tailwind CSS Table - Flowbite](https://flowbite.com/docs/components/tables)

cli/package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"main": "dist/cli.js",
77
"types": "./types/src/index.d.ts",
88
"dependencies": {
9-
"esprima": "^4.0.1"
9+
"esprima": "^4.0.1",
10+
"handlebars": "^4.7.8"
1011
},
1112
"repository": {
1213
"url": "https://github.com/marabesi/smelly-test/tree/main/cli"
@@ -15,15 +16,19 @@
1516
"@stryker-mutator/mocha-runner": "^8.5.0",
1617
"@stryker-mutator/typescript-checker": "^8.5.0",
1718
"@types/esprima": "^4.0.6",
18-
"@types/mocha": "^10.0.1",
19-
"@types/node": "^18.19.44",
19+
"@types/expect": "^24.3.0",
20+
"@types/mocha": "^10.0.8",
21+
"@types/node": "^20.14.8",
22+
"@types/sinon": "^17.0.3",
2023
"@typescript-eslint/eslint-plugin": "^5.53.0",
2124
"@typescript-eslint/parser": "^5.53.0",
2225
"eslint": "^8.34.0",
2326
"mocha": "^10.2.0",
2427
"nodemon": "^3.1.4",
2528
"nyc": "^15.1.0",
29+
"sinon": "^19.0.2",
2630
"ts-loader": "*",
31+
"ts-mocha": "^10.0.0",
2732
"ts-node": "^10.9.2",
2833
"webpack": "*",
2934
"webpack-cli": "*"
@@ -35,9 +40,9 @@
3540
"compile-tests": "npm run clean && tsc -p . --outDir out",
3641
"watch-tests": "tsc -p . -w --outDir out",
3742
"lint": "eslint . --ext ts",
38-
"test": "mocha -r ts-node/register ./**/**.test.ts",
43+
"test": "ts-mocha -p tsconfig.json ./**/**.test.ts",
3944
"test:watch": "nodemon --exec 'npm run test' --watch 'src/**' --ext 'ts' --delay 5",
40-
"test:coverage": "nyc --reporter=lcov mocha -r ts-node/register ./**/**.test.ts",
45+
"test:coverage": "nyc --reporter=lcov ts-mocha -p tsconfig.json ts-node/register ./**/**.test.ts",
4146
"test:mutation": "stryker run",
4247
"coveralls": "npm run test:coverage && coveralls --verbose < coverage/lcov.info",
4348
"cli": "ts-node src/bin/find-smells.ts"

cli/src/bin/find-smells.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
//@ts-nocheck
2+
import path from 'path';
3+
//@ts-nocheck
24
import fs, { readdir } from 'node:fs/promises';
5+
//@ts-nocheck
36
import { SmellDetector, SupportedLanguages } from '../index';
47
import { join } from 'node:path';
8+
import { SmellsAggreagtor, SmellsList } from '../reporters/Html';
59

610
const args = process.argv;
711
const fileName = args[2];
812
const language = args[3] || SupportedLanguages.javascript;
13+
const report = args[4];
914

1015
if (!fileName) {
1116
console.error('[SMELLY] please provide a test file');
@@ -29,11 +34,30 @@ async function execute() {
2934
console.info(smellDetector.findAll());
3035
return;
3136
}
37+
3238
const allFiles = await walk(fileName);
33-
const path = allFiles.flat(Number.POSITIVE_INFINITY);
39+
const pathWithAllFilesFound = allFiles.flat(Number.POSITIVE_INFINITY);
40+
41+
if (report) {
42+
const aggregator: SmellsList[] = [];
43+
44+
for (const file of pathWithAllFilesFound) {
45+
const fileContents = await fs.readFile(file, { encoding: 'utf8' });
46+
const smellDetector = new SmellDetector(fileContents, language);
47+
const smells = smellDetector.findAll();
48+
aggregator.push({ fileName: file, smells, language });
49+
}
50+
51+
const to = path.resolve(`${__dirname}/../..`);
52+
const report = new SmellsAggreagtor(aggregator, { to });
53+
report.build();
54+
55+
console.info('Report HTML generated');
56+
return;
57+
}
3458

3559
const output: any[] = [];
36-
for (const file of path) {
60+
for (const file of pathWithAllFilesFound) {
3761
const fileContents = await fs.readFile(file, { encoding: 'utf8' });
3862
const smellDetector = new SmellDetector(fileContents, language);
3963
const result = smellDetector.findAll();
@@ -44,9 +68,11 @@ async function execute() {
4468
});
4569
}
4670
}
71+
4772
console.info(output.flat(Number.POSITIVE_INFINITY));
4873
} catch (err) {
4974
console.log(`[SMELLY] error: ${err}`);
75+
console.log(err);
5076
}
5177
}
5278

cli/tsconfig.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"compilerOptions": {
3-
"module": "node16",
4-
"moduleResolution": "Node16",
5-
"target": "ES2020",
3+
"module": "CommonJS",
4+
"target": "ESNext",
65
"esModuleInterop": true,
76
"lib": [
87
"ES2020",
@@ -11,12 +10,12 @@
1110
"sourceMap": true,
1211
"rootDir": ".",
1312
"typeRoots": [
14-
"./types"
13+
"./types",
1514
],
1615
"strict": true, /* enable all strict type-checking options */
1716
"declaration": true,
1817
"declarationDir": "./types",
19-
"types": []
18+
"types": ["node"]
2019
/* Additional Checks */
2120
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
2221
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

0 commit comments

Comments
 (0)