@rigour-labs/core 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/discovery.d.ts +5 -0
- package/dist/discovery.js +32 -0
- package/dist/gates/base.d.ts +11 -0
- package/dist/gates/base.js +21 -0
- package/dist/gates/content.d.ts +11 -0
- package/dist/gates/content.js +39 -0
- package/dist/gates/file.d.ts +10 -0
- package/dist/gates/file.js +30 -0
- package/dist/gates/runner.d.ts +13 -0
- package/dist/gates/runner.js +96 -0
- package/dist/gates/structure.d.ts +10 -0
- package/dist/gates/structure.js +32 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +21 -0
- package/dist/smoke.test.d.ts +1 -0
- package/dist/smoke.test.js +19 -0
- package/dist/templates/index.d.ts +8 -0
- package/dist/templates/index.js +70 -0
- package/dist/types/index.d.ts +199 -0
- package/dist/types/index.js +46 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.js +44 -0
- package/dist/utils/scanner.d.ts +11 -0
- package/dist/utils/scanner.js +35 -0
- package/package.json +30 -0
- package/src/discovery.ts +30 -0
- package/src/gates/base.ts +21 -0
- package/src/gates/content.ts +47 -0
- package/src/gates/file.ts +38 -0
- package/src/gates/runner.ts +101 -0
- package/src/gates/structure.ts +36 -0
- package/src/index.ts +5 -0
- package/src/smoke.test.ts +18 -0
- package/src/templates/index.ts +76 -0
- package/src/types/index.ts +56 -0
- package/src/utils/logger.ts +43 -0
- package/src/utils/scanner.ts +37 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { globby } from 'globby';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
export interface ScannerOptions {
|
|
6
|
+
cwd: string;
|
|
7
|
+
patterns?: string[];
|
|
8
|
+
ignore?: string[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class FileScanner {
|
|
12
|
+
private static DEFAULT_PATTERNS = ['**/*.{ts,js,py,css,html,md}'];
|
|
13
|
+
private static DEFAULT_IGNORE = [
|
|
14
|
+
'**/node_modules/**',
|
|
15
|
+
'**/dist/**',
|
|
16
|
+
'**/package-lock.json',
|
|
17
|
+
'**/pnpm-lock.yaml',
|
|
18
|
+
'**/.git/**',
|
|
19
|
+
'rigour-report.json'
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
static async findFiles(options: ScannerOptions): Promise<string[]> {
|
|
23
|
+
return globby(options.patterns || this.DEFAULT_PATTERNS, {
|
|
24
|
+
cwd: options.cwd,
|
|
25
|
+
ignore: options.ignore || this.DEFAULT_IGNORE,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static async readFiles(cwd: string, files: string[]): Promise<Map<string, string>> {
|
|
30
|
+
const contents = new Map<string, string>();
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
const filePath = path.join(cwd, file);
|
|
33
|
+
contents.set(file, await fs.readFile(filePath, 'utf-8'));
|
|
34
|
+
}
|
|
35
|
+
return contents;
|
|
36
|
+
}
|
|
37
|
+
}
|