@salesforce-ux/slds-linter 0.2.0-alpha.6 → 0.2.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/package.json +7 -3
- package/build/commands/emit.d.ts +0 -2
- package/build/commands/emit.js +0 -49
- package/build/commands/emit.js.map +0 -7
- package/build/commands/lint.d.ts +0 -2
- package/build/commands/lint.js +0 -56
- package/build/commands/lint.js.map +0 -7
- package/build/commands/report.d.ts +0 -2
- package/build/commands/report.js +0 -67
- package/build/commands/report.js.map +0 -7
- package/build/executor/__tests__/executor.test.js +0 -190
- package/build/executor/__tests__/executor.test.js.map +0 -7
- package/build/executor/index.d.ts +0 -20
- package/build/executor/index.js +0 -79
- package/build/executor/index.js.map +0 -7
- package/build/index.d.ts +0 -2
- package/build/index.js +0 -34
- package/build/index.js.map +0 -7
- package/build/services/__tests__/file-scanner.test.js +0 -48
- package/build/services/__tests__/file-scanner.test.js.map +0 -7
- package/build/services/artifact-processor.d.ts +0 -6
- package/build/services/artifact-processor.js +0 -38
- package/build/services/artifact-processor.js.map +0 -7
- package/build/services/batch-processor.d.ts +0 -29
- package/build/services/batch-processor.js +0 -85
- package/build/services/batch-processor.js.map +0 -7
- package/build/services/config.resolver.d.ts +0 -6
- package/build/services/config.resolver.js +0 -21
- package/build/services/config.resolver.js.map +0 -7
- package/build/services/file-patterns.d.ts +0 -3
- package/build/services/file-patterns.js +0 -22
- package/build/services/file-patterns.js.map +0 -7
- package/build/services/file-scanner.d.ts +0 -26
- package/build/services/file-scanner.js +0 -72
- package/build/services/file-scanner.js.map +0 -7
- package/build/services/lint-runner.d.ts +0 -17
- package/build/services/lint-runner.js +0 -70
- package/build/services/lint-runner.js.map +0 -7
- package/build/services/report-generator.d.ts +0 -43
- package/build/services/report-generator.js +0 -187
- package/build/services/report-generator.js.map +0 -7
- package/build/types/index.d.ts +0 -75
- package/build/types/index.js +0 -1
- package/build/types/index.js.map +0 -7
- package/build/utils/config-utils.d.ts +0 -33
- package/build/utils/config-utils.js +0 -69
- package/build/utils/config-utils.js.map +0 -7
- package/build/utils/editorLinkUtil.d.ts +0 -21
- package/build/utils/editorLinkUtil.js +0 -22
- package/build/utils/editorLinkUtil.js.map +0 -7
- package/build/utils/lintResultsUtil.d.ts +0 -21
- package/build/utils/lintResultsUtil.js +0 -71
- package/build/utils/lintResultsUtil.js.map +0 -7
- package/build/utils/logger.d.ts +0 -8
- package/build/utils/logger.js +0 -29
- package/build/utils/logger.js.map +0 -7
- package/build/utils/nodeVersionUtil.d.ts +0 -19
- package/build/utils/nodeVersionUtil.js +0 -43
- package/build/utils/nodeVersionUtil.js.map +0 -7
- package/build/workers/base.worker.d.ts +0 -15
- package/build/workers/base.worker.js +0 -45
- package/build/workers/base.worker.js.map +0 -7
- package/build/workers/eslint.worker.d.ts +0 -1
- package/build/workers/eslint.worker.js +0 -51
- package/build/workers/eslint.worker.js.map +0 -7
- package/build/workers/stylelint.worker.d.ts +0 -1
- package/build/workers/stylelint.worker.js +0 -41
- package/build/workers/stylelint.worker.js.map +0 -7
package/build/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/index.ts
|
|
4
|
-
import { Command } from "commander";
|
|
5
|
-
import { registerLintCommand } from "./commands/lint.js";
|
|
6
|
-
import { registerReportCommand } from "./commands/report.js";
|
|
7
|
-
import { registerEmitCommand } from "./commands/emit.js";
|
|
8
|
-
import { Logger } from "./utils/logger.js";
|
|
9
|
-
import { validateNodeVersion } from "./utils/nodeVersionUtil.js";
|
|
10
|
-
validateNodeVersion();
|
|
11
|
-
process.on("unhandledRejection", (error) => {
|
|
12
|
-
Logger.error(`Unhandled rejection: ${error}`);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
});
|
|
15
|
-
process.on("uncaughtException", (error) => {
|
|
16
|
-
Logger.error(`Uncaught exception: ${error}`);
|
|
17
|
-
process.exit(1);
|
|
18
|
-
});
|
|
19
|
-
var program = new Command();
|
|
20
|
-
program.name("npx @salesforce-ux/slds-linter@latest").showHelpAfterError();
|
|
21
|
-
function registerVersion() {
|
|
22
|
-
program.description("SLDS Linter CLI tool for linting styles and components").version("0.2.0-alpha.5");
|
|
23
|
-
}
|
|
24
|
-
registerLintCommand(program);
|
|
25
|
-
registerReportCommand(program);
|
|
26
|
-
registerEmitCommand(program);
|
|
27
|
-
registerVersion();
|
|
28
|
-
program.configureHelp({
|
|
29
|
-
subcommandTerm: (cmd) => {
|
|
30
|
-
return cmd.name();
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
program.parse(process.argv);
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport { registerLintCommand } from './commands/lint';\nimport { registerReportCommand } from './commands/report';\nimport { registerEmitCommand } from './commands/emit';\nimport { Logger } from './utils/logger';\nimport { validateNodeVersion } from './utils/nodeVersionUtil';\n\n// Validate Node.js version before proceeding\nvalidateNodeVersion();\n\nprocess.on('unhandledRejection', (error) => {\n Logger.error(`Unhandled rejection: ${error}`);\n process.exit(1);\n});\n\nprocess.on('uncaughtException', (error) => {\n Logger.error(`Uncaught exception: ${error}`);\n process.exit(1);\n});\n\nconst program = new Command();\n\nprogram\n .name('npx @salesforce-ux/slds-linter@latest')\n .showHelpAfterError();\n\nfunction registerVersion(){\n // resolving version and description from env props. check gulp file\n program.description(process.env.CLI_DESCRIPTION)\n .version(process.env.CLI_VERSION);\n}\n\nregisterLintCommand(program);\nregisterReportCommand(program);\nregisterEmitCommand(program);\nregisterVersion();\nprogram.configureHelp({ \n subcommandTerm:(cmd)=>{\n return cmd.name();\n },\n})\n\nprogram.parse(process.argv); "],
|
|
5
|
-
"mappings": ";;;AAEA,SAAS,eAAe;AACxB,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,cAAc;AACvB,SAAS,2BAA2B;AAGpC,oBAAoB;AAEpB,QAAQ,GAAG,sBAAsB,CAAC,UAAU;AAC1C,SAAO,MAAM,wBAAwB,KAAK,EAAE;AAC5C,UAAQ,KAAK,CAAC;AAChB,CAAC;AAED,QAAQ,GAAG,qBAAqB,CAAC,UAAU;AACzC,SAAO,MAAM,uBAAuB,KAAK,EAAE;AAC3C,UAAQ,KAAK,CAAC;AAChB,CAAC;AAED,IAAM,UAAU,IAAI,QAAQ;AAE5B,QACG,KAAK,uCAAuC,EAC5C,mBAAmB;AAEtB,SAAS,kBAAiB;AAExB,UAAQ,YAAY,wDAA2B,EAC9C,QAAQ,eAAuB;AAClC;AAEA,oBAAoB,OAAO;AAC3B,sBAAsB,OAAO;AAC7B,oBAAoB,OAAO;AAC3B,gBAAgB;AAChB,QAAQ,cAAc;AAAA,EACpB,gBAAe,CAAC,QAAM;AACpB,WAAO,IAAI,KAAK;AAAA,EAClB;AACF,CAAC;AAED,QAAQ,MAAM,QAAQ,IAAI;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// src/services/__tests__/file-scanner.test.ts
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { FileScanner } from "../file-scanner.js";
|
|
4
|
-
import { StyleFilePatterns } from "../file-patterns.js";
|
|
5
|
-
import { mkdir, writeFile, rm } from "fs/promises";
|
|
6
|
-
import { fileURLToPath } from "url";
|
|
7
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
var __dirname = path.dirname(__filename);
|
|
9
|
-
describe("FileScanner", () => {
|
|
10
|
-
const testDir = path.join(__dirname, "fixtures");
|
|
11
|
-
beforeAll(async () => {
|
|
12
|
-
await mkdir(testDir, { recursive: true });
|
|
13
|
-
await writeFile(
|
|
14
|
-
path.join(testDir, "test.css"),
|
|
15
|
-
"body { color: red; }"
|
|
16
|
-
);
|
|
17
|
-
await writeFile(
|
|
18
|
-
path.join(testDir, "test.scss"),
|
|
19
|
-
"$color: red;"
|
|
20
|
-
);
|
|
21
|
-
});
|
|
22
|
-
afterAll(async () => {
|
|
23
|
-
await rm(testDir, { recursive: true });
|
|
24
|
-
});
|
|
25
|
-
it("should scan and batch files correctly", async () => {
|
|
26
|
-
const options = {
|
|
27
|
-
patterns: StyleFilePatterns,
|
|
28
|
-
batchSize: 1
|
|
29
|
-
};
|
|
30
|
-
const batches = await FileScanner.scanFiles(testDir, options);
|
|
31
|
-
expect(batches).toHaveLength(2);
|
|
32
|
-
expect(batches[0]).toHaveLength(1);
|
|
33
|
-
expect(batches[1]).toHaveLength(1);
|
|
34
|
-
expect(batches[0][0]).toMatch(/test\.(css|scss)$/);
|
|
35
|
-
expect(batches[1][0]).toMatch(/test\.(css|scss)$/);
|
|
36
|
-
});
|
|
37
|
-
it("should handle invalid files gracefully", async () => {
|
|
38
|
-
const options = {
|
|
39
|
-
patterns: {
|
|
40
|
-
extensions: ["nonexistent"],
|
|
41
|
-
exclude: []
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const batches = await FileScanner.scanFiles(testDir, options);
|
|
45
|
-
expect(batches).toHaveLength(0);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=file-scanner.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/services/__tests__/file-scanner.test.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\nimport { FileScanner, ScanOptions } from '../file-scanner';\nimport { StyleFilePatterns } from '../file-patterns';\nimport {mkdir, writeFile, rm} from \"fs/promises\";\nimport { fileURLToPath } from 'url';\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\ndescribe('FileScanner', () => {\n const testDir = path.join(__dirname , 'fixtures');\n\n beforeAll(async () => {\n // Create test directory and files for testing\n await mkdir(testDir, { recursive: true });\n await writeFile(\n path.join(testDir, 'test.css'),\n 'body { color: red; }'\n );\n await writeFile(\n path.join(testDir, 'test.scss'),\n '$color: red;'\n );\n });\n\n afterAll(async () => {\n // Clean up test files\n await rm(testDir, { recursive: true });\n });\n\n it('should scan and batch files correctly', async () => {\n const options: ScanOptions = {\n patterns: StyleFilePatterns,\n batchSize: 1\n };\n\n const batches = await FileScanner.scanFiles(testDir, options);\n \n expect(batches).toHaveLength(2);\n expect(batches[0]).toHaveLength(1);\n expect(batches[1]).toHaveLength(1);\n expect(batches[0][0]).toMatch(/test\\.(css|scss)$/);\n expect(batches[1][0]).toMatch(/test\\.(css|scss)$/);\n });\n\n it('should handle invalid files gracefully', async () => {\n const options: ScanOptions = {\n patterns: {\n extensions: ['nonexistent'],\n exclude: []\n }\n };\n\n const batches = await FileScanner.scanFiles(testDir, options);\n expect(batches).toHaveLength(0);\n });\n}); "],
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,mBAAgC;AACzC,SAAS,yBAAyB;AAClC,SAAQ,OAAO,WAAW,UAAS;AACnC,SAAS,qBAAqB;AAC9B,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;AAEzC,SAAS,eAAe,MAAM;AAC5B,QAAM,UAAU,KAAK,KAAK,WAAY,UAAU;AAEhD,YAAU,YAAY;AAEpB,UAAM,MAAM,SAAS,EAAE,WAAW,KAAK,CAAC;AACxC,UAAM;AAAA,MACJ,KAAK,KAAK,SAAS,UAAU;AAAA,MAC7B;AAAA,IACF;AACA,UAAM;AAAA,MACJ,KAAK,KAAK,SAAS,WAAW;AAAA,MAC9B;AAAA,IACF;AAAA,EACF,CAAC;AAED,WAAS,YAAY;AAEnB,UAAM,GAAG,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACvC,CAAC;AAED,KAAG,yCAAyC,YAAY;AACtD,UAAM,UAAuB;AAAA,MAC3B,UAAU;AAAA,MACV,WAAW;AAAA,IACb;AAEA,UAAM,UAAU,MAAM,YAAY,UAAU,SAAS,OAAO;AAE5D,WAAO,OAAO,EAAE,aAAa,CAAC;AAC9B,WAAO,QAAQ,CAAC,CAAC,EAAE,aAAa,CAAC;AACjC,WAAO,QAAQ,CAAC,CAAC,EAAE,aAAa,CAAC;AACjC,WAAO,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,mBAAmB;AACjD,WAAO,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,mBAAmB;AAAA,EACnD,CAAC;AAED,KAAG,0CAA0C,YAAY;AACvD,UAAM,UAAuB;AAAA,MAC3B,UAAU;AAAA,QACR,YAAY,CAAC,aAAa;AAAA,QAC1B,SAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAEA,UAAM,UAAU,MAAM,YAAY,UAAU,SAAS,OAAO;AAC5D,WAAO,OAAO,EAAE,aAAa,CAAC;AAAA,EAChC,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// src/services/artifact-processor.ts
|
|
2
|
-
import path from "path";
|
|
3
|
-
import fs from "fs/promises";
|
|
4
|
-
import crypto from "crypto";
|
|
5
|
-
var BATCH_SIZE = 10;
|
|
6
|
-
async function processArtifacts(artifacts) {
|
|
7
|
-
const batches = Array.from(
|
|
8
|
-
{ length: Math.ceil(artifacts.length / BATCH_SIZE) },
|
|
9
|
-
(_, i) => artifacts.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE)
|
|
10
|
-
);
|
|
11
|
-
for (const batch of batches) {
|
|
12
|
-
await Promise.all(
|
|
13
|
-
batch.map(async (artifact) => {
|
|
14
|
-
try {
|
|
15
|
-
artifact.sourceLanguage = "html";
|
|
16
|
-
if (!artifact.location?.uri) {
|
|
17
|
-
console.warn("Warning: Artifact missing location URI");
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const filePath = path.join(process.cwd(), artifact.location.uri);
|
|
21
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
22
|
-
artifact.length = content.length;
|
|
23
|
-
const hash = crypto.createHash("sha256");
|
|
24
|
-
hash.update(content);
|
|
25
|
-
artifact.hashes = {
|
|
26
|
-
"sha-256": hash.digest("hex")
|
|
27
|
-
};
|
|
28
|
-
} catch (error) {
|
|
29
|
-
console.warn(`Warning: Could not process artifact ${artifact.location?.uri}: ${error.message}`);
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export {
|
|
36
|
-
processArtifacts
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=artifact-processor.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/services/artifact-processor.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\nimport fs from 'fs/promises';\nimport crypto from 'crypto';\nimport { Artifact as SarifArtifact } from 'sarif';\n\nconst BATCH_SIZE = 10;\n\n/**\n * Process artifacts and add file content properties\n * @param artifacts Array of artifacts to process\n */\nexport async function processArtifacts(artifacts: SarifArtifact[]): Promise<void> {\n // Create batches first\n const batches = Array.from(\n { length: Math.ceil(artifacts.length / BATCH_SIZE) },\n (_, i) => artifacts.slice(i * BATCH_SIZE, (i + 1) * BATCH_SIZE)\n );\n\n // Process batches sequentially\n for (const batch of batches) {\n // Process items within batch concurrently\n await Promise.all(\n batch.map(async (artifact) => {\n try {\n \n // default to html\n artifact.sourceLanguage = 'html';\n \n if (!artifact.location?.uri) {\n console.warn('Warning: Artifact missing location URI');\n return;\n }\n\n const filePath = path.join(process.cwd(), artifact.location.uri);\n const content = await fs.readFile(filePath, 'utf-8');\n \n // Calculate content length\n artifact.length = content.length;\n \n // Calculate content hash using SHA-256\n const hash = crypto.createHash('sha256');\n hash.update(content);\n artifact.hashes = {\n \"sha-256\": hash.digest('hex')\n };\n } catch (error) {\n console.warn(`Warning: Could not process artifact ${artifact.location?.uri}: ${error.message}`);\n }\n })\n );\n }\n} "],
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,YAAY;AAGnB,IAAM,aAAa;AAMnB,eAAsB,iBAAiB,WAA2C;AAEhF,QAAM,UAAU,MAAM;AAAA,IACpB,EAAE,QAAQ,KAAK,KAAK,UAAU,SAAS,UAAU,EAAE;AAAA,IACnD,CAAC,GAAG,MAAM,UAAU,MAAM,IAAI,aAAa,IAAI,KAAK,UAAU;AAAA,EAChE;AAGA,aAAW,SAAS,SAAS;AAE3B,UAAM,QAAQ;AAAA,MACZ,MAAM,IAAI,OAAO,aAAa;AAC5B,YAAI;AAGF,mBAAS,iBAAiB;AAE1B,cAAI,CAAC,SAAS,UAAU,KAAK;AAC3B,oBAAQ,KAAK,wCAAwC;AACrD;AAAA,UACF;AAEA,gBAAM,WAAW,KAAK,KAAK,QAAQ,IAAI,GAAG,SAAS,SAAS,GAAG;AAC/D,gBAAM,UAAU,MAAM,GAAG,SAAS,UAAU,OAAO;AAGnD,mBAAS,SAAS,QAAQ;AAG1B,gBAAM,OAAO,OAAO,WAAW,QAAQ;AACvC,eAAK,OAAO,OAAO;AACnB,mBAAS,SAAS;AAAA,YAChB,WAAW,KAAK,OAAO,KAAK;AAAA,UAC9B;AAAA,QACF,SAAS,OAAO;AACd,kBAAQ,KAAK,uCAAuC,SAAS,UAAU,GAAG,KAAK,MAAM,OAAO,EAAE;AAAA,QAChG;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export interface BatchProcessorOptions {
|
|
2
|
-
maxWorkers?: number;
|
|
3
|
-
timeoutMs?: number;
|
|
4
|
-
}
|
|
5
|
-
export interface BatchTask<T> {
|
|
6
|
-
files: string[];
|
|
7
|
-
config: T;
|
|
8
|
-
}
|
|
9
|
-
export interface BatchResult {
|
|
10
|
-
success: boolean;
|
|
11
|
-
error?: string;
|
|
12
|
-
results: any[];
|
|
13
|
-
}
|
|
14
|
-
export declare class BatchProcessor {
|
|
15
|
-
private static DEFAULT_MAX_WORKERS;
|
|
16
|
-
private static DEFAULT_TIMEOUT_MS;
|
|
17
|
-
/**
|
|
18
|
-
* Process batches of files in parallel using worker threads
|
|
19
|
-
* @param batches Array of file batches to process
|
|
20
|
-
* @param workerScript Path to the worker script
|
|
21
|
-
* @param taskConfig Configuration to pass to each worker
|
|
22
|
-
* @param options Processing options
|
|
23
|
-
*/
|
|
24
|
-
static processBatches<T>(batches: string[][], workerScript: string, taskConfig: T, options?: BatchProcessorOptions): Promise<BatchResult[]>;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a new worker with timeout handling
|
|
27
|
-
*/
|
|
28
|
-
private static createWorker;
|
|
29
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// src/services/batch-processor.ts
|
|
2
|
-
import { Worker } from "worker_threads";
|
|
3
|
-
import os from "os";
|
|
4
|
-
import { Logger } from "../utils/logger.js";
|
|
5
|
-
var AVAILABLE_CPUS = os.cpus().length - 1;
|
|
6
|
-
var BatchProcessor = class {
|
|
7
|
-
static DEFAULT_MAX_WORKERS = Math.max(1, Math.min(4, AVAILABLE_CPUS));
|
|
8
|
-
static DEFAULT_TIMEOUT_MS = 3e5;
|
|
9
|
-
// 5 minutes
|
|
10
|
-
/**
|
|
11
|
-
* Process batches of files in parallel using worker threads
|
|
12
|
-
* @param batches Array of file batches to process
|
|
13
|
-
* @param workerScript Path to the worker script
|
|
14
|
-
* @param taskConfig Configuration to pass to each worker
|
|
15
|
-
* @param options Processing options
|
|
16
|
-
*/
|
|
17
|
-
static async processBatches(batches, workerScript, taskConfig, options = {}) {
|
|
18
|
-
const maxWorkers = options.maxWorkers || this.DEFAULT_MAX_WORKERS;
|
|
19
|
-
const timeoutMs = options.timeoutMs || this.DEFAULT_TIMEOUT_MS;
|
|
20
|
-
Logger.debug(`Starting batch processing with ${maxWorkers} workers`);
|
|
21
|
-
Logger.debug(`Processing ${batches.length} batches`);
|
|
22
|
-
const results = [];
|
|
23
|
-
const activeWorkers = /* @__PURE__ */ new Set();
|
|
24
|
-
let currentBatchIndex = 0;
|
|
25
|
-
try {
|
|
26
|
-
while (currentBatchIndex < batches.length || activeWorkers.size > 0) {
|
|
27
|
-
while (activeWorkers.size < maxWorkers && currentBatchIndex < batches.length) {
|
|
28
|
-
const batchIndex = currentBatchIndex++;
|
|
29
|
-
const batch = batches[batchIndex];
|
|
30
|
-
const worker = this.createWorker(
|
|
31
|
-
workerScript,
|
|
32
|
-
{ files: batch, config: taskConfig },
|
|
33
|
-
timeoutMs
|
|
34
|
-
);
|
|
35
|
-
activeWorkers.add(worker);
|
|
36
|
-
worker.on("message", (result) => {
|
|
37
|
-
results.push(result);
|
|
38
|
-
activeWorkers.delete(worker);
|
|
39
|
-
Logger.debug(`Completed batch ${batchIndex} of ${batches.length}`);
|
|
40
|
-
}).on("error", (error) => {
|
|
41
|
-
results.push({
|
|
42
|
-
success: false,
|
|
43
|
-
error: error.message,
|
|
44
|
-
results: []
|
|
45
|
-
});
|
|
46
|
-
activeWorkers.delete(worker);
|
|
47
|
-
Logger.error(`Worker error in batch ${batchIndex}: ${error.message}`);
|
|
48
|
-
}).on("exit", (code) => {
|
|
49
|
-
if (code !== 0) {
|
|
50
|
-
Logger.warning(`Worker exited with code ${code}`);
|
|
51
|
-
}
|
|
52
|
-
activeWorkers.delete(worker);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
56
|
-
}
|
|
57
|
-
return results;
|
|
58
|
-
} catch (error) {
|
|
59
|
-
Logger.error(`Batch processing failed: ${error.message}`);
|
|
60
|
-
throw error;
|
|
61
|
-
} finally {
|
|
62
|
-
for (const worker of activeWorkers) {
|
|
63
|
-
worker.terminate();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Creates a new worker with timeout handling
|
|
69
|
-
*/
|
|
70
|
-
static createWorker(scriptPath, task, timeoutMs) {
|
|
71
|
-
const worker = new Worker(scriptPath, {
|
|
72
|
-
workerData: task
|
|
73
|
-
});
|
|
74
|
-
const timeoutId = setTimeout(() => {
|
|
75
|
-
Logger.warning(`Worker timeout after ${timeoutMs}ms`);
|
|
76
|
-
worker.terminate();
|
|
77
|
-
}, timeoutMs);
|
|
78
|
-
worker.once("exit", () => clearTimeout(timeoutId));
|
|
79
|
-
return worker;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
export {
|
|
83
|
-
BatchProcessor
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=batch-processor.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/services/batch-processor.ts"],
|
|
4
|
-
"sourcesContent": ["import { Worker } from 'worker_threads';\nimport path from 'path';\nimport os from \"os\";\nimport { Logger } from '../utils/logger';\n\nconst AVAILABLE_CPUS = os.cpus().length - 1;\n\nexport interface BatchProcessorOptions {\n maxWorkers?: number;\n timeoutMs?: number;\n}\n\nexport interface BatchTask<T> {\n files: string[];\n config: T;\n}\n\nexport interface BatchResult {\n success: boolean;\n error?: string;\n results: any[];\n}\n\nexport class BatchProcessor {\n private static DEFAULT_MAX_WORKERS = Math.max(1, Math.min(4, AVAILABLE_CPUS));\n private static DEFAULT_TIMEOUT_MS = 300000; // 5 minutes\n\n /**\n * Process batches of files in parallel using worker threads\n * @param batches Array of file batches to process\n * @param workerScript Path to the worker script\n * @param taskConfig Configuration to pass to each worker\n * @param options Processing options\n */\n static async processBatches<T>(\n batches: string[][],\n workerScript: string,\n taskConfig: T,\n options: BatchProcessorOptions = {}\n ): Promise<BatchResult[]> {\n const maxWorkers = options.maxWorkers || this.DEFAULT_MAX_WORKERS;\n const timeoutMs = options.timeoutMs || this.DEFAULT_TIMEOUT_MS;\n\n Logger.debug(`Starting batch processing with ${maxWorkers} workers`);\n Logger.debug(`Processing ${batches.length} batches`);\n\n const results: BatchResult[] = [];\n const activeWorkers = new Set<Worker>();\n let currentBatchIndex = 0;\n\n try {\n while (currentBatchIndex < batches.length || activeWorkers.size > 0) {\n // Start new workers if we have capacity and batches remaining\n while (\n activeWorkers.size < maxWorkers &&\n currentBatchIndex < batches.length\n ) {\n const batchIndex = currentBatchIndex++;\n const batch = batches[batchIndex];\n const worker = this.createWorker(\n workerScript,\n { files: batch, config: taskConfig },\n timeoutMs\n );\n activeWorkers.add(worker);\n\n // Handle worker completion\n worker\n .on('message', (result: BatchResult) => {\n results.push(result);\n activeWorkers.delete(worker);\n Logger.debug(`Completed batch ${batchIndex} of ${batches.length}`);\n })\n .on('error', (error) => {\n results.push({\n success: false,\n error: error.message,\n results: []\n });\n activeWorkers.delete(worker);\n Logger.error(`Worker error in batch ${batchIndex}: ${error.message}`);\n })\n .on('exit', (code) => {\n if (code !== 0) {\n Logger.warning(`Worker exited with code ${code}`);\n }\n activeWorkers.delete(worker);\n });\n }\n\n // Wait for any worker to complete\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n\n return results;\n } catch (error: any) {\n Logger.error(`Batch processing failed: ${error.message}`);\n throw error;\n } finally {\n // Cleanup any remaining workers\n for (const worker of activeWorkers) {\n worker.terminate();\n }\n }\n }\n\n /**\n * Creates a new worker with timeout handling\n */\n private static createWorker<T>(\n scriptPath: string,\n task: BatchTask<T>,\n timeoutMs: number\n ): Worker {\n const worker = new Worker(scriptPath, {\n workerData: task\n });\n\n // Set up timeout\n const timeoutId = setTimeout(() => {\n Logger.warning(`Worker timeout after ${timeoutMs}ms`);\n worker.terminate();\n }, timeoutMs);\n\n // Clear timeout when worker is done\n worker.once('exit', () => clearTimeout(timeoutId));\n\n return worker;\n }\n} "],
|
|
5
|
-
"mappings": ";AAAA,SAAS,cAAc;AAEvB,OAAO,QAAQ;AACf,SAAS,cAAc;AAEvB,IAAM,iBAAiB,GAAG,KAAK,EAAE,SAAS;AAkBnC,IAAM,iBAAN,MAAqB;AAAA,EAC1B,OAAe,sBAAsB,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,cAAc,CAAC;AAAA,EAC5E,OAAe,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASpC,aAAa,eACX,SACA,cACA,YACA,UAAiC,CAAC,GACV;AACxB,UAAM,aAAa,QAAQ,cAAc,KAAK;AAC9C,UAAM,YAAY,QAAQ,aAAa,KAAK;AAE5C,WAAO,MAAM,kCAAkC,UAAU,UAAU;AACnE,WAAO,MAAM,cAAc,QAAQ,MAAM,UAAU;AAEnD,UAAM,UAAyB,CAAC;AAChC,UAAM,gBAAgB,oBAAI,IAAY;AACtC,QAAI,oBAAoB;AAExB,QAAI;AACF,aAAO,oBAAoB,QAAQ,UAAU,cAAc,OAAO,GAAG;AAEnE,eACE,cAAc,OAAO,cACrB,oBAAoB,QAAQ,QAC5B;AACA,gBAAM,aAAa;AACnB,gBAAM,QAAQ,QAAQ,UAAU;AAChC,gBAAM,SAAS,KAAK;AAAA,YAClB;AAAA,YACA,EAAE,OAAO,OAAO,QAAQ,WAAW;AAAA,YACnC;AAAA,UACF;AACA,wBAAc,IAAI,MAAM;AAGxB,iBACG,GAAG,WAAW,CAAC,WAAwB;AACtC,oBAAQ,KAAK,MAAM;AACnB,0BAAc,OAAO,MAAM;AAC3B,mBAAO,MAAM,mBAAmB,UAAU,OAAO,QAAQ,MAAM,EAAE;AAAA,UACnE,CAAC,EACA,GAAG,SAAS,CAAC,UAAU;AACtB,oBAAQ,KAAK;AAAA,cACX,SAAS;AAAA,cACT,OAAO,MAAM;AAAA,cACb,SAAS,CAAC;AAAA,YACZ,CAAC;AACD,0BAAc,OAAO,MAAM;AAC3B,mBAAO,MAAM,yBAAyB,UAAU,KAAK,MAAM,OAAO,EAAE;AAAA,UACtE,CAAC,EACA,GAAG,QAAQ,CAAC,SAAS;AACpB,gBAAI,SAAS,GAAG;AACd,qBAAO,QAAQ,2BAA2B,IAAI,EAAE;AAAA,YAClD;AACA,0BAAc,OAAO,MAAM;AAAA,UAC7B,CAAC;AAAA,QACL;AAGA,cAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAG,CAAC;AAAA,MACzD;AAEA,aAAO;AAAA,IACT,SAAS,OAAY;AACnB,aAAO,MAAM,4BAA4B,MAAM,OAAO,EAAE;AACxD,YAAM;AAAA,IACR,UAAE;AAEA,iBAAW,UAAU,eAAe;AAClC,eAAO,UAAU;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAe,aACb,YACA,MACA,WACQ;AACR,UAAM,SAAS,IAAI,OAAO,YAAY;AAAA,MACpC,YAAY;AAAA,IACd,CAAC;AAGD,UAAM,YAAY,WAAW,MAAM;AACjC,aAAO,QAAQ,wBAAwB,SAAS,IAAI;AACpD,aAAO,UAAU;AAAA,IACnB,GAAG,SAAS;AAGZ,WAAO,KAAK,QAAQ,MAAM,aAAa,SAAS,CAAC;AAEjD,WAAO;AAAA,EACT;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const DEFAULT_ESLINT_CONFIG_PATH: string;
|
|
2
|
-
export declare const DEFAULT_STYLELINT_CONFIG_PATH: string;
|
|
3
|
-
export declare const STYLELINT_VERSION: string;
|
|
4
|
-
export declare const ESLINT_VERSION: string;
|
|
5
|
-
export declare const LINTER_CLI_VERSION: string;
|
|
6
|
-
export declare const getRuleDescription: (ruleId: string) => string;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// src/services/config.resolver.ts
|
|
2
|
-
import { ruleMetadata } from "@salesforce-ux/stylelint-plugin-slds";
|
|
3
|
-
import { resolvePath } from "../utils/nodeVersionUtil.js";
|
|
4
|
-
var DEFAULT_ESLINT_CONFIG_PATH = resolvePath("@salesforce-ux/eslint-plugin-slds/.eslintrc.yml", import.meta);
|
|
5
|
-
var DEFAULT_STYLELINT_CONFIG_PATH = resolvePath("@salesforce-ux/stylelint-plugin-slds/.stylelintrc.yml", import.meta);
|
|
6
|
-
var STYLELINT_VERSION = "16.14.1";
|
|
7
|
-
var ESLINT_VERSION = "8.57.1";
|
|
8
|
-
var LINTER_CLI_VERSION = "0.2.0-alpha.5";
|
|
9
|
-
var getRuleDescription = (ruleId) => {
|
|
10
|
-
const ruleIdWithoutNameSpace = `${ruleId}`.replace(/\@salesforce-ux\//, "");
|
|
11
|
-
return ruleMetadata(ruleIdWithoutNameSpace)?.ruleDesc || "--";
|
|
12
|
-
};
|
|
13
|
-
export {
|
|
14
|
-
DEFAULT_ESLINT_CONFIG_PATH,
|
|
15
|
-
DEFAULT_STYLELINT_CONFIG_PATH,
|
|
16
|
-
ESLINT_VERSION,
|
|
17
|
-
LINTER_CLI_VERSION,
|
|
18
|
-
STYLELINT_VERSION,
|
|
19
|
-
getRuleDescription
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=config.resolver.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/services/config.resolver.ts"],
|
|
4
|
-
"sourcesContent": ["// TODO:Move rule meta to metadata package\nimport {ruleMetadata} from '@salesforce-ux/stylelint-plugin-slds';\nimport { resolvePath } from '../utils/nodeVersionUtil';\n\nexport const DEFAULT_ESLINT_CONFIG_PATH = resolvePath('@salesforce-ux/eslint-plugin-slds/.eslintrc.yml', import.meta);\nexport const DEFAULT_STYLELINT_CONFIG_PATH = resolvePath('@salesforce-ux/stylelint-plugin-slds/.stylelintrc.yml', import.meta);\nexport const STYLELINT_VERSION = process.env.STYLELINT_VERSION;\nexport const ESLINT_VERSION = process.env.ESLINT_VERSION;\nexport const LINTER_CLI_VERSION = process.env.CLI_VERSION;\n\nexport const getRuleDescription = (ruleId:string)=>{\n const ruleIdWithoutNameSpace = `${ruleId}`.replace(/\\@salesforce-ux\\//, '');\n return ruleMetadata(ruleIdWithoutNameSpace)?.ruleDesc || '--';\n}"],
|
|
5
|
-
"mappings": ";AACA,SAAQ,oBAAmB;AAC3B,SAAS,mBAAmB;AAErB,IAAM,6BAA6B,YAAY,mDAAmD,WAAW;AAC7G,IAAM,gCAAgC,YAAY,yDAAyD,WAAW;AACtH,IAAM,oBAAoB;AAC1B,IAAM,iBAAiB;AACvB,IAAM,qBAAqB;AAE3B,IAAM,qBAAqB,CAAC,WAAgB;AAC/C,QAAM,yBAAyB,GAAG,MAAM,GAAG,QAAQ,qBAAqB,EAAE;AAC1E,SAAO,aAAa,sBAAsB,GAAG,YAAY;AAC7D;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// src/services/file-patterns.ts
|
|
2
|
-
var StyleFilePatterns = {
|
|
3
|
-
extensions: ["css", "scss", "less", "sass"],
|
|
4
|
-
exclude: [
|
|
5
|
-
"**/node_modules/**",
|
|
6
|
-
"**/dist/**",
|
|
7
|
-
"**/build/**"
|
|
8
|
-
]
|
|
9
|
-
};
|
|
10
|
-
var ComponentFilePatterns = {
|
|
11
|
-
extensions: ["html", "cmp", "component", "app", "page", "interface"],
|
|
12
|
-
exclude: [
|
|
13
|
-
"**/node_modules/**",
|
|
14
|
-
"**/dist/**",
|
|
15
|
-
"**/build/**"
|
|
16
|
-
]
|
|
17
|
-
};
|
|
18
|
-
export {
|
|
19
|
-
ComponentFilePatterns,
|
|
20
|
-
StyleFilePatterns
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=file-patterns.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/services/file-patterns.ts"],
|
|
4
|
-
"sourcesContent": ["import { FilePattern } from './file-scanner';\n\nexport const StyleFilePatterns: FilePattern = {\n extensions:['css', 'scss', 'less','sass'],\n exclude: [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**'\n ]\n};\n\nexport const ComponentFilePatterns: FilePattern = {\n extensions:['html', 'cmp', 'component', 'app', 'page', 'interface'], \n exclude: [\n '**/node_modules/**',\n '**/dist/**',\n '**/build/**'\n ]\n}; "],
|
|
5
|
-
"mappings": ";AAEO,IAAM,oBAAiC;AAAA,EAC5C,YAAW,CAAC,OAAO,QAAQ,QAAO,MAAM;AAAA,EACxC,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,IAAM,wBAAqC;AAAA,EAChD,YAAW,CAAC,QAAQ,OAAO,aAAa,OAAO,QAAQ,WAAW;AAAA,EAClE,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export interface FilePattern {
|
|
2
|
-
extensions: string[];
|
|
3
|
-
exclude?: string[];
|
|
4
|
-
}
|
|
5
|
-
export interface ScanOptions {
|
|
6
|
-
patterns: FilePattern;
|
|
7
|
-
batchSize?: number;
|
|
8
|
-
}
|
|
9
|
-
export declare class FileScanner {
|
|
10
|
-
private static DEFAULT_BATCH_SIZE;
|
|
11
|
-
/**
|
|
12
|
-
* Scans directory for files matching the given patterns
|
|
13
|
-
* @param directory Base directory to scan
|
|
14
|
-
* @param options Scanning options including patterns and batch size
|
|
15
|
-
* @returns Array of file paths in batches
|
|
16
|
-
*/
|
|
17
|
-
static scanFiles(directory: string, options: ScanOptions): Promise<string[][]>;
|
|
18
|
-
/**
|
|
19
|
-
* Validates that files exist and are readable
|
|
20
|
-
*/
|
|
21
|
-
private static validateFiles;
|
|
22
|
-
/**
|
|
23
|
-
* Splits array of files into batches
|
|
24
|
-
*/
|
|
25
|
-
private static createBatches;
|
|
26
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
// src/services/file-scanner.ts
|
|
2
|
-
import { promises as fs } from "fs";
|
|
3
|
-
import { Logger } from "../utils/logger.js";
|
|
4
|
-
import { globby } from "globby";
|
|
5
|
-
import { extname } from "path";
|
|
6
|
-
var FileScanner = class {
|
|
7
|
-
static DEFAULT_BATCH_SIZE = 100;
|
|
8
|
-
/**
|
|
9
|
-
* Scans directory for files matching the given patterns
|
|
10
|
-
* @param directory Base directory to scan
|
|
11
|
-
* @param options Scanning options including patterns and batch size
|
|
12
|
-
* @returns Array of file paths in batches
|
|
13
|
-
*/
|
|
14
|
-
static async scanFiles(directory, options) {
|
|
15
|
-
try {
|
|
16
|
-
Logger.debug(`Scanning directory: ${directory}`);
|
|
17
|
-
const allFiles = await globby(directory, {
|
|
18
|
-
cwd: process.cwd(),
|
|
19
|
-
expandDirectories: true,
|
|
20
|
-
unique: true,
|
|
21
|
-
ignore: options.patterns.exclude,
|
|
22
|
-
onlyFiles: true,
|
|
23
|
-
dot: true,
|
|
24
|
-
// Include.dot files
|
|
25
|
-
absolute: true,
|
|
26
|
-
gitignore: true
|
|
27
|
-
}).then((matches) => matches.filter((match) => {
|
|
28
|
-
const fileExt = extname(match).substring(1);
|
|
29
|
-
return options.patterns.extensions.includes(fileExt);
|
|
30
|
-
}));
|
|
31
|
-
const validFiles = await this.validateFiles(allFiles);
|
|
32
|
-
const batchSize = options.batchSize || this.DEFAULT_BATCH_SIZE;
|
|
33
|
-
const batches = this.createBatches(validFiles, batchSize);
|
|
34
|
-
Logger.debug(
|
|
35
|
-
`Found ${validFiles.length} files, split into ${batches.length} batches`
|
|
36
|
-
);
|
|
37
|
-
return batches;
|
|
38
|
-
} catch (error) {
|
|
39
|
-
Logger.error(`Failed to scan files: ${error.message}`);
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Validates that files exist and are readable
|
|
45
|
-
*/
|
|
46
|
-
static async validateFiles(files) {
|
|
47
|
-
const validFiles = [];
|
|
48
|
-
for (const file of files) {
|
|
49
|
-
try {
|
|
50
|
-
await fs.access(file, fs.constants.R_OK);
|
|
51
|
-
validFiles.push(file);
|
|
52
|
-
} catch (error) {
|
|
53
|
-
Logger.warning(`Skipping inaccessible file: ${file}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return validFiles;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Splits array of files into batches
|
|
60
|
-
*/
|
|
61
|
-
static createBatches(files, batchSize) {
|
|
62
|
-
const batches = [];
|
|
63
|
-
for (let i = 0; i < files.length; i += batchSize) {
|
|
64
|
-
batches.push(files.slice(i, i + batchSize));
|
|
65
|
-
}
|
|
66
|
-
return batches;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
export {
|
|
70
|
-
FileScanner
|
|
71
|
-
};
|
|
72
|
-
//# sourceMappingURL=file-scanner.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/services/file-scanner.ts"],
|
|
4
|
-
"sourcesContent": ["import { promises as fs } from \"fs\";\nimport { Logger } from \"../utils/logger\";\nimport {globby} from 'globby';\nimport {extname} from \"path\";\n\nexport interface FilePattern {\n extensions:string[];\n exclude?: string[];\n}\n\nexport interface ScanOptions {\n patterns: FilePattern;\n batchSize?: number;\n}\n\nexport class FileScanner {\n private static DEFAULT_BATCH_SIZE = 100;\n\n /**\n * Scans directory for files matching the given patterns\n * @param directory Base directory to scan\n * @param options Scanning options including patterns and batch size\n * @returns Array of file paths in batches\n */\n static async scanFiles(\n directory: string,\n options: ScanOptions\n ): Promise<string[][]> {\n try {\n Logger.debug(`Scanning directory: ${directory}`);\n\n const allFiles: string[] = await globby(directory, {\n cwd: process.cwd(),\n expandDirectories:true,\n unique:true,\n ignore: options.patterns.exclude,\n onlyFiles: true,\n dot: true, // Include.dot files\n absolute: true,\n gitignore:true\n }).then(matches => matches.filter(match => {\n const fileExt = extname(match).substring(1);\n return options.patterns.extensions.includes(fileExt);\n }));\n\n // Validate files exist and are readable\n const validFiles = await this.validateFiles(allFiles);\n\n // Split into batches\n const batchSize = options.batchSize || this.DEFAULT_BATCH_SIZE;\n const batches = this.createBatches(validFiles, batchSize);\n\n Logger.debug(\n `Found ${validFiles.length} files, split into ${batches.length} batches`\n );\n return batches;\n } catch (error: any) {\n Logger.error(`Failed to scan files: ${error.message}`);\n throw error;\n }\n }\n\n /**\n * Validates that files exist and are readable\n */\n private static async validateFiles(files: string[]): Promise<string[]> {\n const validFiles: string[] = [];\n\n for (const file of files) {\n try {\n await fs.access(file, fs.constants.R_OK);\n validFiles.push(file);\n } catch (error) {\n Logger.warning(`Skipping inaccessible file: ${file}`);\n }\n }\n\n return validFiles;\n }\n\n /**\n * Splits array of files into batches\n */\n private static createBatches(files: string[], batchSize: number): string[][] {\n const batches: string[][] = [];\n for (let i = 0; i < files.length; i += batchSize) {\n batches.push(files.slice(i, i + batchSize));\n }\n return batches;\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,YAAY,UAAU;AAC/B,SAAS,cAAc;AACvB,SAAQ,cAAa;AACrB,SAAQ,eAAc;AAYf,IAAM,cAAN,MAAkB;AAAA,EACvB,OAAe,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpC,aAAa,UACX,WACA,SACqB;AACrB,QAAI;AACF,aAAO,MAAM,uBAAuB,SAAS,EAAE;AAE/C,YAAM,WAAqB,MAAM,OAAO,WAAW;AAAA,QACjD,KAAK,QAAQ,IAAI;AAAA,QACjB,mBAAkB;AAAA,QAClB,QAAO;AAAA,QACP,QAAQ,QAAQ,SAAS;AAAA,QACzB,WAAW;AAAA,QACX,KAAK;AAAA;AAAA,QACL,UAAU;AAAA,QACV,WAAU;AAAA,MACZ,CAAC,EAAE,KAAK,aAAW,QAAQ,OAAO,WAAS;AACzC,cAAM,UAAU,QAAQ,KAAK,EAAE,UAAU,CAAC;AAC1C,eAAO,QAAQ,SAAS,WAAW,SAAS,OAAO;AAAA,MACrD,CAAC,CAAC;AAGF,YAAM,aAAa,MAAM,KAAK,cAAc,QAAQ;AAGpD,YAAM,YAAY,QAAQ,aAAa,KAAK;AAC5C,YAAM,UAAU,KAAK,cAAc,YAAY,SAAS;AAExD,aAAO;AAAA,QACL,SAAS,WAAW,MAAM,sBAAsB,QAAQ,MAAM;AAAA,MAChE;AACA,aAAO;AAAA,IACT,SAAS,OAAY;AACnB,aAAO,MAAM,yBAAyB,MAAM,OAAO,EAAE;AACrD,YAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,aAAqB,cAAc,OAAoC;AACrE,UAAM,aAAuB,CAAC;AAE9B,eAAW,QAAQ,OAAO;AACxB,UAAI;AACF,cAAM,GAAG,OAAO,MAAM,GAAG,UAAU,IAAI;AACvC,mBAAW,KAAK,IAAI;AAAA,MACtB,SAAS,OAAO;AACd,eAAO,QAAQ,+BAA+B,IAAI,EAAE;AAAA,MACtD;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,OAAe,cAAc,OAAiB,WAA+B;AAC3E,UAAM,UAAsB,CAAC;AAC7B,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,WAAW;AAChD,cAAQ,KAAK,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;AAAA,IAC5C;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { LintResult } from '../types';
|
|
2
|
-
export interface LintOptions {
|
|
3
|
-
fix?: boolean;
|
|
4
|
-
configPath?: string;
|
|
5
|
-
maxWorkers?: number;
|
|
6
|
-
timeoutMs?: number;
|
|
7
|
-
}
|
|
8
|
-
export declare class LintRunner {
|
|
9
|
-
/**
|
|
10
|
-
* Run linting on batches of files
|
|
11
|
-
*/
|
|
12
|
-
static runLinting(fileBatches: string[][], workerType: 'style' | 'component', options?: LintOptions): Promise<LintResult[]>;
|
|
13
|
-
/**
|
|
14
|
-
* Process and normalize worker results
|
|
15
|
-
*/
|
|
16
|
-
private static processResults;
|
|
17
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// src/services/lint-runner.ts
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { BatchProcessor } from "./batch-processor.js";
|
|
4
|
-
import { Logger } from "../utils/logger.js";
|
|
5
|
-
import { resolveDirName } from "../utils/nodeVersionUtil.js";
|
|
6
|
-
var LintRunner = class {
|
|
7
|
-
/**
|
|
8
|
-
* Run linting on batches of files
|
|
9
|
-
*/
|
|
10
|
-
static async runLinting(fileBatches, workerType, options = {}) {
|
|
11
|
-
try {
|
|
12
|
-
const workerScript = path.resolve(
|
|
13
|
-
resolveDirName(import.meta),
|
|
14
|
-
"../workers",
|
|
15
|
-
workerType === "style" ? "stylelint.worker.js" : "eslint.worker.js"
|
|
16
|
-
);
|
|
17
|
-
const workerConfig = {
|
|
18
|
-
configPath: options.configPath,
|
|
19
|
-
fix: options.fix
|
|
20
|
-
};
|
|
21
|
-
const results = await BatchProcessor.processBatches(
|
|
22
|
-
fileBatches,
|
|
23
|
-
workerScript,
|
|
24
|
-
workerConfig,
|
|
25
|
-
{
|
|
26
|
-
maxWorkers: options.maxWorkers,
|
|
27
|
-
timeoutMs: options.timeoutMs
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
return this.processResults(results);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
Logger.error(`Linting failed: ${error.message}`);
|
|
33
|
-
throw error;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Process and normalize worker results
|
|
38
|
-
*/
|
|
39
|
-
static processResults(batchResults) {
|
|
40
|
-
const results = [];
|
|
41
|
-
for (const batch of batchResults) {
|
|
42
|
-
if (!batch.success || !batch.results) {
|
|
43
|
-
Logger.warning(`Batch failed: ${batch.error}`);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
for (const result of batch.results) {
|
|
47
|
-
if (result.error) {
|
|
48
|
-
Logger.warning(`File processing failed: ${result.file} - ${result.error}`);
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
results.push({
|
|
52
|
-
filePath: result.file,
|
|
53
|
-
errors: result.errors?.map((e) => ({
|
|
54
|
-
...e,
|
|
55
|
-
severity: 2
|
|
56
|
-
})) || [],
|
|
57
|
-
warnings: result.warnings?.map((w) => ({
|
|
58
|
-
...w,
|
|
59
|
-
severity: 1
|
|
60
|
-
})) || []
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return results;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
export {
|
|
68
|
-
LintRunner
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=lint-runner.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/services/lint-runner.ts"],
|
|
4
|
-
"sourcesContent": ["import path from 'path';\nimport { BatchProcessor, BatchResult } from './batch-processor';\nimport { WorkerConfig, WorkerResult, LintResult } from '../types';\nimport { Logger } from '../utils/logger';\nimport { resolveDirName } from '../utils/nodeVersionUtil';\n\nexport interface LintOptions {\n fix?: boolean;\n configPath?: string;\n maxWorkers?: number;\n timeoutMs?: number;\n}\n\nexport class LintRunner {\n /**\n * Run linting on batches of files\n */\n static async runLinting(\n fileBatches: string[][],\n workerType: 'style' | 'component',\n options: LintOptions = {}\n ): Promise<LintResult[]> {\n try {\n const workerScript = path.resolve(\n resolveDirName(import.meta) ,\n '../workers',\n workerType === 'style' ? 'stylelint.worker.js' : 'eslint.worker.js'\n );\n\n const workerConfig: WorkerConfig = {\n configPath: options.configPath,\n fix: options.fix\n };\n\n const results = await BatchProcessor.processBatches(\n fileBatches,\n workerScript,\n workerConfig,\n {\n maxWorkers: options.maxWorkers,\n timeoutMs: options.timeoutMs\n }\n );\n\n return this.processResults(results);\n } catch (error: any) {\n Logger.error(`Linting failed: ${error.message}`);\n throw error;\n }\n }\n\n /**\n * Process and normalize worker results\n */\n private static processResults(batchResults: BatchResult[]): LintResult[] {\n const results: LintResult[] = [];\n\n for (const batch of batchResults) {\n if (!batch.success || !batch.results) {\n Logger.warning(`Batch failed: ${batch.error}`);\n continue;\n }\n\n for (const result of batch.results as WorkerResult[]) {\n if (result.error) {\n Logger.warning(`File processing failed: ${result.file} - ${result.error}`);\n continue;\n }\n\n results.push({\n filePath: result.file,\n errors: result.errors?.map(e => ({\n ...e,\n severity: 2\n })) || [],\n warnings: result.warnings?.map(w => ({\n ...w,\n severity: 1\n })) || []\n });\n }\n }\n\n return results;\n }\n} "],
|
|
5
|
-
"mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,sBAAmC;AAE5C,SAAS,cAAc;AACvB,SAAS,sBAAsB;AASxB,IAAM,aAAN,MAAiB;AAAA;AAAA;AAAA;AAAA,EAItB,aAAa,WACX,aACA,YACA,UAAuB,CAAC,GACD;AACvB,QAAI;AACF,YAAM,eAAe,KAAK;AAAA,QACxB,eAAe,WAAW;AAAA,QAC1B;AAAA,QACA,eAAe,UAAU,wBAAwB;AAAA,MACnD;AAEA,YAAM,eAA6B;AAAA,QACjC,YAAY,QAAQ;AAAA,QACpB,KAAK,QAAQ;AAAA,MACf;AAEA,YAAM,UAAU,MAAM,eAAe;AAAA,QACnC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,UACE,YAAY,QAAQ;AAAA,UACpB,WAAW,QAAQ;AAAA,QACrB;AAAA,MACF;AAEA,aAAO,KAAK,eAAe,OAAO;AAAA,IACpC,SAAS,OAAY;AACnB,aAAO,MAAM,mBAAmB,MAAM,OAAO,EAAE;AAC/C,YAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAe,eAAe,cAA2C;AACvE,UAAM,UAAwB,CAAC;AAE/B,eAAW,SAAS,cAAc;AAChC,UAAI,CAAC,MAAM,WAAW,CAAC,MAAM,SAAS;AACpC,eAAO,QAAQ,iBAAiB,MAAM,KAAK,EAAE;AAC7C;AAAA,MACF;AAEA,iBAAW,UAAU,MAAM,SAA2B;AACpD,YAAI,OAAO,OAAO;AAChB,iBAAO,QAAQ,2BAA2B,OAAO,IAAI,MAAM,OAAO,KAAK,EAAE;AACzE;AAAA,QACF;AAEA,gBAAQ,KAAK;AAAA,UACX,UAAU,OAAO;AAAA,UACjB,QAAQ,OAAO,QAAQ,IAAI,QAAM;AAAA,YAC/B,GAAG;AAAA,YACH,UAAU;AAAA,UACZ,EAAE,KAAK,CAAC;AAAA,UACR,UAAU,OAAO,UAAU,IAAI,QAAM;AAAA,YACnC,GAAG;AAAA,YACH,UAAU;AAAA,UACZ,EAAE,KAAK,CAAC;AAAA,QACV,CAAC;AAAA,MACH;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { LintResult } from '../types';
|
|
2
|
-
import { Readable } from 'stream';
|
|
3
|
-
export interface ReportOptions {
|
|
4
|
-
outputPath?: string;
|
|
5
|
-
toolName: string;
|
|
6
|
-
toolVersion: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class ReportGenerator {
|
|
9
|
-
/**
|
|
10
|
-
* Generate SARIF report from lint results with file output
|
|
11
|
-
*/
|
|
12
|
-
static generateSarifReport(results: LintResult[], options: ReportOptions): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Generate SARIF report as a stream without creating a file
|
|
15
|
-
*/
|
|
16
|
-
static generateSarifReportStream(results: LintResult[], options: ReportOptions): Promise<Readable>;
|
|
17
|
-
/**
|
|
18
|
-
* Build SARIF report data in memory
|
|
19
|
-
*/
|
|
20
|
-
static buildSarifReport(results: LintResult[], options: ReportOptions): Promise<any>;
|
|
21
|
-
/**
|
|
22
|
-
* Extract unique rules from results
|
|
23
|
-
*/
|
|
24
|
-
private static extractRules;
|
|
25
|
-
/**
|
|
26
|
-
* Add lint results to SARIF report
|
|
27
|
-
*/
|
|
28
|
-
private static addResultsToSarif;
|
|
29
|
-
}
|
|
30
|
-
export declare class CsvReportGenerator {
|
|
31
|
-
/**
|
|
32
|
-
* Generate CSV report and write to file
|
|
33
|
-
*/
|
|
34
|
-
static generate(results: any[]): Promise<string>;
|
|
35
|
-
/**
|
|
36
|
-
* Generate CSV string from lint results
|
|
37
|
-
*/
|
|
38
|
-
static generateCsvString(results: any[]): string;
|
|
39
|
-
/**
|
|
40
|
-
* Convert lint results to CSV-compatible data format
|
|
41
|
-
*/
|
|
42
|
-
private static convertResultsToCsvData;
|
|
43
|
-
}
|