Skip to content

Commit

Permalink
NEW: @W-15652762@: Add configuration parsing and validation abilities (
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-carter-at-sf authored May 16, 2024
1 parent bed36c9 commit cc0ad68
Show file tree
Hide file tree
Showing 17 changed files with 584 additions and 75 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/verify-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ jobs:
exit 1
fi
run_tests:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down
72 changes: 38 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@
"package": "npm run package --workspaces --if-present",
"all": "npm run build && npm run test && npm run lint && npm run package",
"clean": "npm run clean --workspaces",
"postclean": "rimraf coverage"
"postclean": "rimraf coverage",
"showcoverage": "open ./coverage/lcov-report/index.html"
},
"devDependencies": {
"jest": "^29.0.0",
"ts-jest": "^29.0.0",
"rimraf": "*"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"coverageThreshold": {
"global": {
"branches": 80,
Expand All @@ -29,15 +28,12 @@
"statements": 80
}
},
"testMatch": [
"**/*.test.ts"
],
"testPathIgnorePatterns": [
"/node_modules/"
"projects": [
"<rootDir>/packages/*"
],
"collectCoverageFrom": [
"packages/**/src/**/*.ts",
"!packages/**/src/index.ts"
"src/**/*.ts",
"!src/index.ts"
]
}
}
7 changes: 5 additions & 2 deletions packages/code-analyzer-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"types": "dist/index.d.ts",
"dependencies": {
"@salesforce/code-analyzer-engine-api": "0.1.1",
"@types/node": "^20.0.0"
"@types/js-yaml": "^4.0.9",
"@types/node": "^20.0.0",
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@eslint/js": "^9.2.0",
Expand All @@ -41,7 +43,8 @@
"package": "npm pack",
"all": "npm run build && npm run test && npm run lint && npm run package",
"clean": "tsc --build tsconfig.build.json --clean",
"postclean": "rimraf dist && rimraf coverage && rimraf ./*.tgz"
"postclean": "rimraf dist && rimraf coverage && rimraf ./*.tgz",
"showcoverage": "open ./coverage/lcov-report/index.html"
},
"jest": {
"preset": "ts-jest",
Expand Down
18 changes: 2 additions & 16 deletions packages/code-analyzer-core/src/code-analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,13 @@ import {Event, EventType, LogLevel} from "./events"
import {getMessage} from "./messages";
import * as engApi from "@salesforce/code-analyzer-engine-api"
import {EventEmitter} from "node:events";
import {CodeAnalyzerConfig} from "./config";

export type RunOptions = {
filesToInclude: string[]
entryPoints?: string[]
}

// Currently we have no configuration abilities implemented. So this is just a placeholder for now.
export class CodeAnalyzerConfig {
public static withDefaults() {
return new CodeAnalyzerConfig();
}

private constructor() {
}

public getEngineSpecificConfig(_engineName: string): engApi.ConfigObject {
// To be implemented soon
return {}
}
}

export class CodeAnalyzer {
private readonly config: CodeAnalyzerConfig;
private readonly eventEmitter: EventEmitter = new EventEmitter();
Expand All @@ -42,7 +28,7 @@ export class CodeAnalyzer {
const enginePluginV1: engApi.EnginePluginV1 = enginePlugin as engApi.EnginePluginV1;

for (const engineName of getAvailableEngineNamesFromPlugin(enginePluginV1)) {
const engConf: engApi.ConfigObject = this.config.getEngineSpecificConfig(engineName);
const engConf: engApi.ConfigObject = this.config.getEngineSettingsFor(engineName);
const engine: engApi.Engine = createEngineFromPlugin(enginePluginV1, engineName, engConf);
this.addEngineIfValid(engineName, engine);
}
Expand Down
Loading

0 comments on commit cc0ad68

Please sign in to comment.