Implements Phases 1-8 of the TFTSR implementation plan. Rust backend (Tauri 2.x, src-tauri/): - Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama - PII detection engine: 11 regex patterns with overlap resolution - SQLCipher AES-256 encrypted database with 10 versioned migrations - 28 Tauri IPC commands for triage, analysis, document, and system ops - Ollama: hardware probe, model recommendations, pull/delete with events - RCA and blameless post-mortem Markdown document generators - PDF export via printpdf - Audit log: SHA-256 hash of every external data send - Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2) Frontend (React 18 + TypeScript + Vite, src/): - 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings - 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives - 3 Zustand stores: session, settings (persisted), history - Type-safe tauriCommands.ts matching Rust backend types exactly - 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs) DevOps: - .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push - .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload Verified: - cargo check: zero errors - tsc --noEmit: zero errors - vitest run: 13/13 unit tests passing Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
138 lines
4.0 KiB
JavaScript
138 lines
4.0 KiB
JavaScript
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const ansi = require('ansi-colors');
|
|
const debug = require('debug')('mocha:cli:run:helpers');
|
|
const minimatch = require('minimatch');
|
|
const {NO_FILES_MATCH_PATTERN} = require('../errors').constants;
|
|
const lookupFiles = require('./lookup-files');
|
|
const {castArray} = require('../utils');
|
|
|
|
/**
|
|
* Exports a function that collects test files from CLI parameters.
|
|
* @see module:lib/cli/run-helpers
|
|
* @see module:lib/cli/watch-run
|
|
* @module
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Smash together an array of test files in the correct order
|
|
* @param {FileCollectionOptions} [opts] - Options
|
|
* @returns {FileCollectionResponse} An object containing a list of files to test and unmatched files.
|
|
* @private
|
|
*/
|
|
module.exports = ({
|
|
ignore,
|
|
extension,
|
|
file: fileArgs,
|
|
recursive,
|
|
sort,
|
|
spec
|
|
} = {}) => {
|
|
const unmatchedSpecFiles = [];
|
|
const specFiles = spec.reduce((specFiles, arg) => {
|
|
try {
|
|
const moreSpecFiles = castArray(lookupFiles(arg, extension, recursive))
|
|
.filter(filename =>
|
|
ignore.every(
|
|
pattern =>
|
|
!minimatch(filename, pattern, {windowsPathsNoEscape: true})
|
|
)
|
|
)
|
|
.map(filename => path.resolve(filename));
|
|
return [...specFiles, ...moreSpecFiles];
|
|
} catch (err) {
|
|
if (err.code === NO_FILES_MATCH_PATTERN) {
|
|
unmatchedSpecFiles.push({message: err.message, pattern: err.pattern});
|
|
return specFiles;
|
|
}
|
|
|
|
throw err;
|
|
}
|
|
}, []);
|
|
|
|
// check that each file passed in to --file exists
|
|
|
|
const unmatchedFiles = [];
|
|
fileArgs.forEach(file => {
|
|
const fileAbsolutePath = path.resolve(file);
|
|
try {
|
|
// Used instead of fs.existsSync to ensure that file-ending less files are still resolved correctly
|
|
require.resolve(fileAbsolutePath);
|
|
} catch (err) {
|
|
if (err.code === 'MODULE_NOT_FOUND') {
|
|
unmatchedFiles.push({
|
|
pattern: file,
|
|
absolutePath: fileAbsolutePath
|
|
});
|
|
return;
|
|
}
|
|
|
|
throw err;
|
|
}
|
|
});
|
|
|
|
// ensure we don't sort the stuff from fileArgs; order is important!
|
|
if (sort) {
|
|
specFiles.sort();
|
|
}
|
|
|
|
// add files given through --file to be ran first
|
|
const files = [
|
|
...fileArgs.map(filepath => path.resolve(filepath)),
|
|
...specFiles
|
|
];
|
|
debug('test files (in order): ', files);
|
|
|
|
if (!files.length) {
|
|
// give full message details when only 1 file is missing
|
|
const noneFoundMsg =
|
|
unmatchedSpecFiles.length === 1
|
|
? `Error: No test files found: ${JSON.stringify(
|
|
unmatchedSpecFiles[0].pattern
|
|
)}` // stringify to print escaped characters raw
|
|
: 'Error: No test files found';
|
|
console.error(ansi.red(noneFoundMsg));
|
|
process.exit(1);
|
|
} else {
|
|
// print messages as a warning
|
|
unmatchedSpecFiles.forEach(warning => {
|
|
console.warn(ansi.yellow(`Warning: ${warning.message}`));
|
|
});
|
|
}
|
|
|
|
return {
|
|
files,
|
|
unmatchedFiles
|
|
};
|
|
};
|
|
|
|
/**
|
|
* An object to configure how Mocha gathers test files
|
|
* @private
|
|
* @typedef {Object} FileCollectionOptions
|
|
* @property {string[]} extension - File extensions to use
|
|
* @property {string[]} spec - Files, dirs, globs to run
|
|
* @property {string[]} ignore - Files, dirs, globs to ignore
|
|
* @property {string[]} file - List of additional files to include
|
|
* @property {boolean} recursive - Find files recursively
|
|
* @property {boolean} sort - Sort test files
|
|
*/
|
|
|
|
/**
|
|
* Diagnostic object containing unmatched files
|
|
* @typedef {Object} UnmatchedFile -
|
|
* @property {string} absolutePath - A list of unmatched files derived from the file arguments passed in.
|
|
* @property {string} pattern - A list of unmatched files derived from the file arguments passed in.
|
|
*
|
|
*/
|
|
|
|
/**
|
|
* Response object containing a list of files to test and unmatched files.
|
|
* @typedef {Object} FileCollectionResponse
|
|
* @property {string[]} files - A list of files to test
|
|
* @property {UnmatchedFile[]} unmatchedFiles - A list of unmatched files derived from the file arguments passed in.
|
|
*/
|