@ai-dev-tools/csharp-copilot-core 0.0.31 → 0.0.32
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/out/analyze/cecil.d.ts +1 -0
- package/out/analyze/cecil.js +42 -0
- package/out/analyze/cecil.js.map +1 -0
- package/out/analyze/checkCodeSyntax.d.ts +7 -0
- package/out/analyze/checkCodeSyntax.js +67 -0
- package/out/analyze/checkCodeSyntax.js.map +1 -0
- package/out/analyze/generateCodeDependency.d.ts +6 -0
- package/out/analyze/generateCodeDependency.js +127 -0
- package/out/analyze/generateCodeDependency.js.map +1 -0
- package/out/analyze/installAnalyzerTool.d.ts +1 -0
- package/out/analyze/installAnalyzerTool.js +83 -0
- package/out/analyze/installAnalyzerTool.js.map +1 -0
- package/out/batch/generateCodeTests.d.ts +6 -0
- package/out/batch/generateCodeTests.js +163 -0
- package/out/batch/generateCodeTests.js.map +1 -0
- package/out/batch/getFolderCodeFile.d.ts +1 -0
- package/out/batch/getFolderCodeFile.js +19 -0
- package/out/batch/getFolderCodeFile.js.map +1 -0
- package/out/batch/getProjectCodeFile.d.ts +4 -0
- package/out/batch/getProjectCodeFile.js +86 -0
- package/out/batch/getProjectCodeFile.js.map +1 -0
- package/out/batch/getSolutionCodeFile.d.ts +8 -0
- package/out/batch/getSolutionCodeFile.js +70 -0
- package/out/batch/getSolutionCodeFile.js.map +1 -0
- package/out/benchmark/formatToMarkdown.d.ts +2 -0
- package/out/benchmark/formatToMarkdown.js +101 -0
- package/out/benchmark/formatToMarkdown.js.map +1 -0
- package/out/benchmark/generateBenchmarkReport.d.ts +1 -0
- package/out/benchmark/generateBenchmarkReport.js +82 -0
- package/out/benchmark/generateBenchmarkReport.js.map +1 -0
- package/out/codeCoverage/codeCoverage.d.ts +6 -0
- package/out/codeCoverage/codeCoverage.js +39 -0
- package/out/codeCoverage/codeCoverage.js.map +1 -0
- package/out/codeCoverage/codeCoverageReport.d.ts +6 -0
- package/out/codeCoverage/codeCoverageReport.js +76 -0
- package/out/codeCoverage/codeCoverageReport.js.map +1 -0
- package/out/codeCoverage/extractCodeCoverageInfo.d.ts +2 -0
- package/out/codeCoverage/extractCodeCoverageInfo.js +81 -0
- package/out/codeCoverage/extractCodeCoverageInfo.js.map +1 -0
- package/out/codeCoverage/extractCoverageReportPath.d.ts +1 -0
- package/out/codeCoverage/extractCoverageReportPath.js +25 -0
- package/out/codeCoverage/extractCoverageReportPath.js.map +1 -0
- package/out/codeCoverage/generateCodeCoverageReport.d.ts +1 -0
- package/out/codeCoverage/generateCodeCoverageReport.js +30 -0
- package/out/codeCoverage/generateCodeCoverageReport.js.map +1 -0
- package/out/codeCoverage/getCodeCoverageSetting.d.ts +1 -0
- package/out/codeCoverage/getCodeCoverageSetting.js +58 -0
- package/out/codeCoverage/getCodeCoverageSetting.js.map +1 -0
- package/out/codeCoverage/reportTool.d.ts +2 -0
- package/out/codeCoverage/reportTool.js +23 -0
- package/out/codeCoverage/reportTool.js.map +1 -0
- package/out/codeCoverage/simplifyCoverageXml.d.ts +2 -0
- package/out/codeCoverage/simplifyCoverageXml.js +117 -0
- package/out/codeCoverage/simplifyCoverageXml.js.map +1 -0
- package/out/codebk/250804prompt/buildAfGuidelines.liquid +15 -0
- package/out/codebk/250804prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
- package/out/codebk/250804prompt/general/generalUtGuidelines.liquid +18 -0
- package/out/codebk/250804prompt/generateUtAutoFix.liquid +19 -0
- package/out/codebk/250804prompt/generateUtGuidelines.liquid +13 -0
- package/out/codebk/250804prompt/generateUtSystem.liquid +5 -0
- package/out/codebk/250804prompt/generateUtUserInput.liquid +27 -0
- package/out/codebk/250804prompt/testAfGuidelines.liquid +6 -0
- package/out/codebk/250804prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
- package/out/codebk/250804prompt/xap/xapCodeCodeDependency.liquid +0 -0
- package/out/codebk/250804prompt/xap/xapCodeSample.liquid +38 -0
- package/out/codebk/250804prompt/xap/xapUtGuideline-240804.liquid +36 -0
- package/out/codebk/250804prompt/xap/xapUtGuideline.liquid +36 -0
- package/out/codebk/childProcessManager.d.ts +1 -0
- package/out/codebk/childProcessManager.js +50 -0
- package/out/codebk/childProcessManager.js.map +1 -0
- package/out/codebk/msBuidSpawn.d.ts +1 -0
- package/out/codebk/msBuidSpawn.js +58 -0
- package/out/codebk/msBuidSpawn.js.map +1 -0
- package/out/codebk/msBuild.d.ts +1 -0
- package/out/codebk/msBuild.js +123 -0
- package/out/codebk/msBuild.js.map +1 -0
- package/out/codebk/old/generateXapTestAutoFix.liquid +12 -0
- package/out/codebk/old/generateXapTestGuidelines-fm.liquid +68 -0
- package/out/codebk/old/generateXapTestGuidelines.liquid +28 -0
- package/out/codebk/old/xapGuideline-fm.liquid +149 -0
- package/out/codebk/old/xapGuideline.liquid +37 -0
- package/out/codebk/oldExec/checkCodeSyntax.d.ts +1 -0
- package/out/codebk/oldExec/checkCodeSyntax.js +81 -0
- package/out/codebk/oldExec/checkCodeSyntax.js.map +1 -0
- package/out/codebk/oldExec/codeCoverage.d.ts +1 -0
- package/out/codebk/oldExec/codeCoverage.js +54 -0
- package/out/codebk/oldExec/codeCoverage.js.map +1 -0
- package/out/codebk/oldExec/codeCoverageReport.d.ts +1 -0
- package/out/codebk/oldExec/codeCoverageReport.js +64 -0
- package/out/codebk/oldExec/codeCoverageReport.js.map +1 -0
- package/out/codebk/oldExec/containsMethods.d.ts +1 -0
- package/out/codebk/oldExec/containsMethods.js +74 -0
- package/out/codebk/oldExec/containsMethods.js.map +1 -0
- package/out/codebk/oldExec/generateCodeDependency.d.ts +1 -0
- package/out/codebk/oldExec/generateCodeDependency.js +95 -0
- package/out/codebk/oldExec/generateCodeDependency.js.map +1 -0
- package/out/codebk/oldExec/msBuild.d.ts +1 -0
- package/out/codebk/oldExec/msBuild.js +53 -0
- package/out/codebk/oldExec/msBuild.js.map +1 -0
- package/out/codebk/oldExec/vsTest.d.ts +1 -0
- package/out/codebk/oldExec/vsTest.js +71 -0
- package/out/codebk/oldExec/vsTest.js.map +1 -0
- package/out/codebk/prompts/general/generalUnitTestGuidelines-20250702.liquid +56 -0
- package/out/codebk/prompts/generateXapTestGuidelines-20250704.liquid +21 -0
- package/out/codebk/prompts/generateXapTestGuidelines-o.liquid +29 -0
- package/out/codebk/prompts/xap/xapGuideline-o.liquid +45 -0
- package/out/codebk/testbuildkill.d.ts +1 -0
- package/out/codebk/testbuildkill.js +37 -0
- package/out/codebk/testbuildkill.js.map +1 -0
- package/out/command/index.d.ts +2 -0
- package/out/command/index.js +90 -0
- package/out/command/index.js.map +1 -0
- package/out/command/utGenWrapper.d.ts +3 -0
- package/out/command/utGenWrapper.js +53 -0
- package/out/command/utGenWrapper.js.map +1 -0
- package/out/exit/childProcessManager.d.ts +2 -0
- package/out/exit/childProcessManager.js +43 -0
- package/out/exit/childProcessManager.js.map +1 -0
- package/out/exit/setupProcessSignalHandler.d.ts +1 -0
- package/out/exit/setupProcessSignalHandler.js +18 -0
- package/out/exit/setupProcessSignalHandler.js.map +1 -0
- package/out/gen/autoFix.d.ts +4 -0
- package/out/gen/autoFix.js +129 -0
- package/out/gen/autoFix.js.map +1 -0
- package/out/gen/csharpUtGen.d.ts +2 -0
- package/out/gen/csharpUtGen.js +125 -0
- package/out/gen/csharpUtGen.js.map +1 -0
- package/out/gen/ensureValidLLMResponse.d.ts +1 -0
- package/out/gen/ensureValidLLMResponse.js +19 -0
- package/out/gen/ensureValidLLMResponse.js.map +1 -0
- package/out/gen/postGen/addAiAnnotation.d.ts +1 -0
- package/out/gen/postGen/addAiAnnotation.js +57 -0
- package/out/gen/postGen/addAiAnnotation.js.map +1 -0
- package/out/gen/postGen/extractCodeFromResponse.d.ts +1 -0
- package/out/gen/postGen/extractCodeFromResponse.js +38 -0
- package/out/gen/postGen/extractCodeFromResponse.js.map +1 -0
- package/out/gen/postGen/postGenProcess.d.ts +1 -0
- package/out/gen/postGen/postGenProcess.js +39 -0
- package/out/gen/postGen/postGenProcess.js.map +1 -0
- package/out/gen/postGen/removeComments.d.ts +1 -0
- package/out/gen/postGen/removeComments.js +92 -0
- package/out/gen/postGen/removeComments.js.map +1 -0
- package/out/gen/postGen/removeSingleLines.d.ts +1 -0
- package/out/gen/postGen/removeSingleLines.js +29 -0
- package/out/gen/postGen/removeSingleLines.js.map +1 -0
- package/out/gen/postGen/repairRequiredNameSpaces.d.ts +2 -0
- package/out/gen/postGen/repairRequiredNameSpaces.js +142 -0
- package/out/gen/postGen/repairRequiredNameSpaces.js.map +1 -0
- package/out/gen/postGen/validateTestCode.d.ts +1 -0
- package/out/gen/postGen/validateTestCode.js +14 -0
- package/out/gen/postGen/validateTestCode.js.map +1 -0
- package/out/gen/preGen/excludeFileName.d.ts +1 -0
- package/out/gen/preGen/excludeFileName.js +49 -0
- package/out/gen/preGen/excludeFileName.js.map +1 -0
- package/out/gen/preGen/excludeSpecificTag.d.ts +1 -0
- package/out/gen/preGen/excludeSpecificTag.js +19 -0
- package/out/gen/preGen/excludeSpecificTag.js.map +1 -0
- package/out/gen/preGen/preGenProcess.d.ts +1 -0
- package/out/gen/preGen/preGenProcess.js +22 -0
- package/out/gen/preGen/preGenProcess.js.map +1 -0
- package/out/gen/preGen/validateCode.d.ts +3 -0
- package/out/gen/preGen/validateCode.js +63 -0
- package/out/gen/preGen/validateCode.js.map +1 -0
- package/out/index.d.ts +3 -0
- package/out/index.js +10 -0
- package/out/index.js.map +1 -0
- package/out/llm/model/Gpt.d.ts +1 -0
- package/out/llm/model/Gpt.js +93 -0
- package/out/llm/model/Gpt.js.map +1 -0
- package/out/llm/preparePrompt.d.ts +2 -0
- package/out/llm/preparePrompt.js +135 -0
- package/out/llm/preparePrompt.js.map +1 -0
- package/out/llm/prompt/buildAfGuidelines.liquid +15 -0
- package/out/llm/prompt/general/generalBuildAutofixGuidelines.liquid +13 -0
- package/out/llm/prompt/general/generalUtGuidelines.liquid +16 -0
- package/out/llm/prompt/generateUtAutoFix.liquid +23 -0
- package/out/llm/prompt/generateUtDependency.liquid +3 -0
- package/out/llm/prompt/generateUtSystem.liquid +5 -0
- package/out/llm/prompt/generateUtTemplate.liquid +32 -0
- package/out/llm/prompt/generateUtUserInput.liquid +4 -0
- package/out/llm/prompt/xap/xapBuildAutofixGuidelines.liquid +13 -0
- package/out/llm/prompt/xap/xapCodeCodeDependency.liquid +0 -0
- package/out/llm/prompt/xap/xapCodeSample.liquid +38 -0
- package/out/llm/prompt/xap/xapUtGuideline.liquid +37 -0
- package/out/llm/sendRequestToLLM.d.ts +4 -0
- package/out/llm/sendRequestToLLM.js +9 -0
- package/out/llm/sendRequestToLLM.js.map +1 -0
- package/out/llm/sendRequestToSelfHostLLM.d.ts +4 -0
- package/out/llm/sendRequestToSelfHostLLM.js +41 -0
- package/out/llm/sendRequestToSelfHostLLM.js.map +1 -0
- package/out/metrics/appInsightTelemetry.d.ts +6 -0
- package/out/metrics/appInsightTelemetry.js +77 -0
- package/out/metrics/appInsightTelemetry.js.map +1 -0
- package/out/metrics/machineId.d.ts +11 -0
- package/out/metrics/machineId.js +85 -0
- package/out/metrics/machineId.js.map +1 -0
- package/out/setup/setup.d.ts +1 -0
- package/out/setup/setup.js +10 -0
- package/out/setup/setup.js.map +1 -0
- package/out/setup/setupConsole.d.ts +1 -0
- package/out/setup/setupConsole.js +23 -0
- package/out/setup/setupConsole.js.map +1 -0
- package/out/setup/setupLLMRequest.d.ts +2 -0
- package/out/setup/setupLLMRequest.js +10 -0
- package/out/setup/setupLLMRequest.js.map +1 -0
- package/out/tools/devenvcom.cmd +13 -0
- package/out/tools/devenvexe.cmd +13 -0
- package/out/tools/msbuildexe.cmd +13 -0
- package/out/tools/vstestexe.cmd +13 -0
- package/out/types/benchmark.d.ts +11 -0
- package/out/types/benchmark.js +3 -0
- package/out/types/benchmark.js.map +1 -0
- package/out/types/buildResult.d.ts +8 -0
- package/out/types/buildResult.js +3 -0
- package/out/types/buildResult.js.map +1 -0
- package/out/types/constants.d.ts +10 -0
- package/out/types/constants.js +14 -0
- package/out/types/constants.js.map +1 -0
- package/out/types/genResult.d.ts +10 -0
- package/out/types/genResult.js +3 -0
- package/out/types/genResult.js.map +1 -0
- package/out/types/testResult.d.ts +12 -0
- package/out/types/testResult.js +3 -0
- package/out/types/testResult.js.map +1 -0
- package/out/types/verifyResult.d.ts +8 -0
- package/out/types/verifyResult.js +3 -0
- package/out/types/verifyResult.js.map +1 -0
- package/out/utils/checkTestProject.d.ts +2 -0
- package/out/utils/checkTestProject.js +79 -0
- package/out/utils/checkTestProject.js.map +1 -0
- package/out/utils/checkXapCode.d.ts +2 -0
- package/out/utils/checkXapCode.js +59 -0
- package/out/utils/checkXapCode.js.map +1 -0
- package/out/utils/delay.d.ts +1 -0
- package/out/utils/delay.js +7 -0
- package/out/utils/delay.js.map +1 -0
- package/out/utils/detectTestFramework.d.ts +1 -0
- package/out/utils/detectTestFramework.js +33 -0
- package/out/utils/detectTestFramework.js.map +1 -0
- package/out/utils/fileUtils.d.ts +2 -0
- package/out/utils/fileUtils.js +42 -0
- package/out/utils/fileUtils.js.map +1 -0
- package/out/utils/generateCodeSha256.d.ts +1 -0
- package/out/utils/generateCodeSha256.js +46 -0
- package/out/utils/generateCodeSha256.js.map +1 -0
- package/out/utils/getCodeStructurePath.d.ts +5 -0
- package/out/utils/getCodeStructurePath.js +155 -0
- package/out/utils/getCodeStructurePath.js.map +1 -0
- package/out/utils/getOrCreateDir.d.ts +2 -0
- package/out/utils/getOrCreateDir.js +63 -0
- package/out/utils/getOrCreateDir.js.map +1 -0
- package/out/utils/getTestCodeInfo.d.ts +2 -0
- package/out/utils/getTestCodeInfo.js +121 -0
- package/out/utils/getTestCodeInfo.js.map +1 -0
- package/out/utils/getTestFile.d.ts +13 -0
- package/out/utils/getTestFile.js +297 -0
- package/out/utils/getTestFile.js.map +1 -0
- package/out/utils/parseBuildResult.d.ts +3 -0
- package/out/utils/parseBuildResult.js +45 -0
- package/out/utils/parseBuildResult.js.map +1 -0
- package/out/utils/parseSyntaxCheckResult.d.ts +2 -0
- package/out/utils/parseSyntaxCheckResult.js +39 -0
- package/out/utils/parseSyntaxCheckResult.js.map +1 -0
- package/out/utils/parseVstestResult.d.ts +3 -0
- package/out/utils/parseVstestResult.js +62 -0
- package/out/utils/parseVstestResult.js.map +1 -0
- package/out/utils/removeFailedTestMethods.d.ts +3 -0
- package/out/utils/removeFailedTestMethods.js +208 -0
- package/out/utils/removeFailedTestMethods.js.map +1 -0
- package/out/utils/runCommand.d.ts +1 -0
- package/out/utils/runCommand.js +14 -0
- package/out/utils/runCommand.js.map +1 -0
- package/out/utils/spawnExec.d.ts +1 -0
- package/out/utils/spawnExec.js +80 -0
- package/out/utils/spawnExec.js.map +1 -0
- package/out/utils/verifyBuildErrorCausedFile.d.ts +1 -0
- package/out/utils/verifyBuildErrorCausedFile.js +60 -0
- package/out/utils/verifyBuildErrorCausedFile.js.map +1 -0
- package/out/utils/verifyTestCode.d.ts +2 -0
- package/out/utils/verifyTestCode.js +25 -0
- package/out/utils/verifyTestCode.js.map +1 -0
- package/out/utils/writeFailedVerifyResult.d.ts +1 -0
- package/out/utils/writeFailedVerifyResult.js +67 -0
- package/out/utils/writeFailedVerifyResult.js.map +1 -0
- package/out/utils/writeGenCode.d.ts +1 -0
- package/out/utils/writeGenCode.js +63 -0
- package/out/utils/writeGenCode.js.map +1 -0
- package/out/vs/msBuild.d.ts +13 -0
- package/out/vs/msBuild.js +49 -0
- package/out/vs/msBuild.js.map +1 -0
- package/out/vs/vsTest.d.ts +15 -0
- package/out/vs/vsTest.js +75 -0
- package/out/vs/vsTest.js.map +1 -0
- package/out/vs/vsTools.d.ts +7 -0
- package/out/vs/vsTools.js +177 -0
- package/out/vs/vsTools.js.map +1 -0
- package/out/vsPlugin/getVsPluginVerifyResult.d.ts +2 -0
- package/out/vsPlugin/getVsPluginVerifyResult.js +41 -0
- package/out/vsPlugin/getVsPluginVerifyResult.js.map +1 -0
- package/out/vsPlugin/interactionConstants.d.ts +2 -0
- package/out/vsPlugin/interactionConstants.js +10 -0
- package/out/vsPlugin/interactionConstants.js.map +1 -0
- package/out/vsPlugin/sendStdToVsPlugin.d.ts +1 -0
- package/out/vsPlugin/sendStdToVsPlugin.js +12 -0
- package/out/vsPlugin/sendStdToVsPlugin.js.map +1 -0
- package/out/vsPlugin/stdListener.d.ts +3 -0
- package/out/vsPlugin/stdListener.js +57 -0
- package/out/vsPlugin/stdListener.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.writeTestCode = writeTestCode;
|
|
7
|
+
exports.deleteTestFileIfExists = deleteTestFileIfExists;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
// split test file path detection out to a separate function
|
|
10
|
+
function writeTestCode(testCode, testFilePath) {
|
|
11
|
+
const validTestCode = !!testCode ? testCode : '';
|
|
12
|
+
// Write the test code to the specified file
|
|
13
|
+
try {
|
|
14
|
+
fs_1.default.writeFileSync(testFilePath, validTestCode, 'utf8');
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
console.error(`Failed to write test code: ${error.message}`);
|
|
18
|
+
// categorize the error based on its code
|
|
19
|
+
if (error.code === 'EACCES') {
|
|
20
|
+
console.error('can not write to the file, permission denied.');
|
|
21
|
+
}
|
|
22
|
+
else if (error.code === 'ENOENT') {
|
|
23
|
+
console.error(`can not write to the file, file or directory does not exist: ${testFilePath}`);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
console.error('unknown error:', error.message);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function deleteTestFileIfExists(testFilePath) {
|
|
31
|
+
if (fs_1.default.existsSync(testFilePath)) {
|
|
32
|
+
fs_1.default.unlink(testFilePath, (err) => {
|
|
33
|
+
if (err) {
|
|
34
|
+
console.error(`Failed to delete test file: ${err.message}`);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.log(`Deleted test file: ${testFilePath}`);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=fileUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileUtils.js","sourceRoot":"","sources":["../../src/utils/fileUtils.ts"],"names":[],"mappings":";;;;;AAGA,sCAgBC;AAGD,wDAUC;AAhCD,4CAAoB;AAEpB,4DAA4D;AAC5D,SAAgB,aAAa,CAAC,QAAgB,EAAE,YAAoB;IAChE,MAAM,aAAa,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,4CAA4C;IAC5C,IAAI,CAAC;QACD,YAAE,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,8BAA8B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7D,yCAAyC;QACzC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACjC,OAAO,CAAC,KAAK,CAAC,gEAAgE,YAAY,EAAE,CAAC,CAAC;QAClG,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QACnD,CAAC;IACL,CAAC;AACL,CAAC;AAGD,SAAgB,sBAAsB,CAAC,YAAoB;IACvD,IAAI,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,YAAE,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE;YAC5B,IAAI,GAAG,EAAE,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,+BAA+B,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;YAChE,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,GAAG,CAAC,sBAAsB,YAAY,EAAE,CAAC,CAAC;YACtD,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;AACL,CAAC","sourcesContent":["import fs from 'fs';\r\n\r\n// split test file path detection out to a separate function\r\nexport function writeTestCode(testCode: string, testFilePath: string) {\r\n const validTestCode = !!testCode ? testCode : '';\r\n // Write the test code to the specified file\r\n try {\r\n fs.writeFileSync(testFilePath, validTestCode, 'utf8');\r\n } catch (error) {\r\n console.error(`Failed to write test code: ${error.message}`);\r\n // categorize the error based on its code\r\n if (error.code === 'EACCES') {\r\n console.error('can not write to the file, permission denied.');\r\n } else if (error.code === 'ENOENT') {\r\n console.error(`can not write to the file, file or directory does not exist: ${testFilePath}`);\r\n } else {\r\n console.error('unknown error:', error.message);\r\n }\r\n }\r\n}\r\n\r\n\r\nexport function deleteTestFileIfExists(testFilePath: string): void {\r\n if (fs.existsSync(testFilePath)) {\r\n fs.unlink(testFilePath, (err) => {\r\n if (err) {\r\n console.error(`Failed to delete test file: ${err.message}`);\r\n } else {\r\n console.log(`Deleted test file: ${testFilePath}`);\r\n }\r\n });\r\n }\r\n}"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateCodeSha256(sourceCodePath: string): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.generateCodeSha256 = generateCodeSha256;
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
function generateCodeSha256(sourceCodePath) {
|
|
40
|
+
const fileBuffer = fs.readFileSync(sourceCodePath);
|
|
41
|
+
const hash = crypto.createHash('sha256').update(fileBuffer).digest('hex');
|
|
42
|
+
return hash;
|
|
43
|
+
}
|
|
44
|
+
// const sha256 = generateCodeSha256('D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Eplant\\RequestBuilders\\EplantRankRequestBuilder.cs');
|
|
45
|
+
// console.log(`SHA-256 hash of the file: ${sha256}`);
|
|
46
|
+
//# sourceMappingURL=generateCodeSha256.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateCodeSha256.js","sourceRoot":"","sources":["../../src/utils/generateCodeSha256.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,gDAIC;AAPD,+CAAiC;AACjC,uCAAyB;AAEzB,SAAgB,kBAAkB,CAAC,cAAsB;IACrD,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1E,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,kMAAkM;AAClM,sDAAsD","sourcesContent":["import * as crypto from 'crypto';\r\nimport * as fs from 'fs';\r\n\r\nexport function generateCodeSha256(sourceCodePath: string): string {\r\n const fileBuffer = fs.readFileSync(sourceCodePath);\r\n const hash = crypto.createHash('sha256').update(fileBuffer).digest('hex');\r\n return hash;\r\n}\r\n\r\n// const sha256 = generateCodeSha256('D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Eplant\\\\RequestBuilders\\\\EplantRankRequestBuilder.cs');\r\n// console.log(`SHA-256 hash of the file: ${sha256}`);"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function getSourceFileProjectDir(sourceCodePath: string): string;
|
|
2
|
+
export declare function getSourceFileCsprojFilePath(sourceCodePath: string): string;
|
|
3
|
+
export declare function getCodeRepoRoot(csFilePath: string): string;
|
|
4
|
+
export declare function getAssemblyName(csprojPath: string): string;
|
|
5
|
+
export declare function getBuiltDllPath(csprojPath: string): string;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getSourceFileProjectDir = getSourceFileProjectDir;
|
|
37
|
+
exports.getSourceFileCsprojFilePath = getSourceFileCsprojFilePath;
|
|
38
|
+
exports.getCodeRepoRoot = getCodeRepoRoot;
|
|
39
|
+
exports.getAssemblyName = getAssemblyName;
|
|
40
|
+
exports.getBuiltDllPath = getBuiltDllPath;
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
44
|
+
function getSourceFileProjectDir(sourceCodePath) {
|
|
45
|
+
let currentDir = path.dirname(sourceCodePath);
|
|
46
|
+
while (currentDir !== path.dirname(currentDir)) {
|
|
47
|
+
const files = fs.readdirSync(currentDir);
|
|
48
|
+
if (files.some(file => file.endsWith('.csproj'))) {
|
|
49
|
+
return currentDir;
|
|
50
|
+
}
|
|
51
|
+
currentDir = path.dirname(currentDir);
|
|
52
|
+
}
|
|
53
|
+
// Check root directory
|
|
54
|
+
const rootFiles = fs.readdirSync(currentDir);
|
|
55
|
+
if (rootFiles.some(file => file.endsWith('.csproj'))) {
|
|
56
|
+
return currentDir;
|
|
57
|
+
}
|
|
58
|
+
return null; // No .csproj file found
|
|
59
|
+
}
|
|
60
|
+
function getSourceFileCsprojFilePath(sourceCodePath) {
|
|
61
|
+
let currentDir = path.dirname(sourceCodePath);
|
|
62
|
+
while (currentDir !== path.dirname(currentDir)) {
|
|
63
|
+
const files = fs.readdirSync(currentDir);
|
|
64
|
+
const csprojFilePaths = files.filter(file => file.endsWith('.csproj'));
|
|
65
|
+
if (csprojFilePaths?.length > 0) {
|
|
66
|
+
return path.join(currentDir, csprojFilePaths[0]);
|
|
67
|
+
}
|
|
68
|
+
currentDir = path.dirname(currentDir);
|
|
69
|
+
}
|
|
70
|
+
// Check root directory
|
|
71
|
+
const rootFiles = fs.readdirSync(currentDir);
|
|
72
|
+
if (rootFiles.some(file => file.endsWith('.csproj'))) {
|
|
73
|
+
return currentDir;
|
|
74
|
+
}
|
|
75
|
+
return null; // No .csproj file found
|
|
76
|
+
}
|
|
77
|
+
// export function getSourceFileProjectName(sourceCodePath: string) {
|
|
78
|
+
// const projectPath = getSourceFileProjectPath(sourceCodePath);
|
|
79
|
+
// if (!projectPath) {
|
|
80
|
+
// console.warn(`No .csproj file found for ${sourceCodePath}`);
|
|
81
|
+
// return null;
|
|
82
|
+
// }
|
|
83
|
+
// const projectName = path.basename(projectPath, '.csproj');
|
|
84
|
+
// return projectName;
|
|
85
|
+
// }
|
|
86
|
+
// detect .git folder in the dir hierarchy of csFilePath, if exist, it's the code repo root
|
|
87
|
+
function getCodeRepoRoot(csFilePath) {
|
|
88
|
+
const rootDir = path.parse(csFilePath).root;
|
|
89
|
+
let currentDir = path.dirname(csFilePath);
|
|
90
|
+
;
|
|
91
|
+
while (currentDir !== rootDir) {
|
|
92
|
+
if (fs.existsSync(path.join(currentDir, ".git"))) {
|
|
93
|
+
return currentDir;
|
|
94
|
+
}
|
|
95
|
+
currentDir = path.dirname(currentDir);
|
|
96
|
+
}
|
|
97
|
+
console.log(`No .git folder found in the dir hierarchy of ${csFilePath}. Assuming root is ${rootDir}`);
|
|
98
|
+
return rootDir;
|
|
99
|
+
}
|
|
100
|
+
// export function getTestProjectDll(testProjectPath: string) {
|
|
101
|
+
// const testProjectDir = path.dirname(testProjectPath);
|
|
102
|
+
// const testProjectName = path.basename(testProjectPath, '.csproj');
|
|
103
|
+
// const dllName = `${testProjectName}.dll`;
|
|
104
|
+
// const dllPath = path.join(testProjectDir, 'bin', 'Debug', dllName);
|
|
105
|
+
// return dllPath;
|
|
106
|
+
// }
|
|
107
|
+
function getAssemblyName(csprojPath) {
|
|
108
|
+
const xmlContent = fs.readFileSync(csprojPath, "utf-8");
|
|
109
|
+
const parser = new fast_xml_parser_1.XMLParser();
|
|
110
|
+
const parsed = parser.parse(xmlContent);
|
|
111
|
+
const project = parsed.Project;
|
|
112
|
+
if (!project) {
|
|
113
|
+
throw new Error("can't parse .csproj 文件");
|
|
114
|
+
}
|
|
115
|
+
const propertyGroups = Array.isArray(project.PropertyGroup)
|
|
116
|
+
? project.PropertyGroup
|
|
117
|
+
: [project.PropertyGroup];
|
|
118
|
+
for (const group of propertyGroups) {
|
|
119
|
+
if (group.AssemblyName) {
|
|
120
|
+
return group.AssemblyName;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return path.basename(csprojPath, ".csproj");
|
|
124
|
+
}
|
|
125
|
+
function getDllPath(outputDir, assemblyName) {
|
|
126
|
+
if (!fs.existsSync(outputDir)) {
|
|
127
|
+
throw new Error(`The output dir doesn't exist: ${outputDir}`);
|
|
128
|
+
}
|
|
129
|
+
// xap dll path: "D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Tests\bin\Debug\SharedSegments.Tests.dll"
|
|
130
|
+
const dllPath = path.join(outputDir, `${assemblyName}.dll`);
|
|
131
|
+
if (fs.existsSync(dllPath)) {
|
|
132
|
+
return dllPath;
|
|
133
|
+
}
|
|
134
|
+
// general dll path: "D:\code\ai-dev-tools\csharp-ut-copilot\CSharpAnalyzer\CSharpAnalyzer\bin\Debug\net8.0\CSharpAnalyzer.dll"
|
|
135
|
+
const subdirs = fs.readdirSync(outputDir).filter((f) => fs.statSync(path.join(outputDir, f)).isDirectory());
|
|
136
|
+
for (const frameworkDir of subdirs) {
|
|
137
|
+
const dllPath = path.join(outputDir, frameworkDir, `${assemblyName}.dll`);
|
|
138
|
+
if (fs.existsSync(dllPath)) {
|
|
139
|
+
return dllPath;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
throw new Error(`can't get dll file: ${assemblyName}.dll`);
|
|
143
|
+
}
|
|
144
|
+
function getBuiltDllPath(csprojPath) {
|
|
145
|
+
if (!fs.existsSync(csprojPath)) {
|
|
146
|
+
throw new Error(`csproj doesn't exist: ${csprojPath}`);
|
|
147
|
+
}
|
|
148
|
+
const assemblyName = getAssemblyName(csprojPath);
|
|
149
|
+
const projectDir = path.dirname(csprojPath);
|
|
150
|
+
const outputBase = path.join(projectDir, "bin", "Debug");
|
|
151
|
+
return getDllPath(outputBase, assemblyName);
|
|
152
|
+
}
|
|
153
|
+
// const dllPath = getBuiltDllPath("D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\SharedSegments.Tests.csproj");
|
|
154
|
+
// console.log(`Test project DLL path: ${dllPath}`);
|
|
155
|
+
//# sourceMappingURL=getCodeStructurePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCodeStructurePath.js","sourceRoot":"","sources":["../../src/utils/getCodeStructurePath.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,0DAkBC;AAED,kEAmBC;AAcD,0CAaC;AAWD,0CAqBC;AA4BD,0CAUC;AA7ID,uCAAyB;AACzB,2CAA6B;AAE7B,qDAA4C;AAE5C,SAAgB,uBAAuB,CAAC,cAAsB;IAC1D,IAAI,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IAE9C,OAAO,UAAU,KAAK,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7C,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;YAC/C,OAAO,UAAU,CAAC;QACtB,CAAC;QACD,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC;IAED,uBAAuB;IACvB,MAAM,SAAS,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC7C,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EA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C,UAAU,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAEzD,OAAO,UAAU,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAChD,CAAC;AAGD,0JAA0J;AAC1J,oDAAoD","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nimport { XMLParser } from 'fast-xml-parser';\r\n\r\nexport function getSourceFileProjectDir(sourceCodePath: string) {\r\n let currentDir = path.dirname(sourceCodePath);\r\n\r\n while (currentDir !== path.dirname(currentDir)) {\r\n const files = fs.readdirSync(currentDir);\r\n if (files.some(file => file.endsWith('.csproj'))) {\r\n return currentDir;\r\n }\r\n currentDir = path.dirname(currentDir);\r\n }\r\n\r\n // Check root directory\r\n const rootFiles = fs.readdirSync(currentDir);\r\n if (rootFiles.some(file => file.endsWith('.csproj'))) {\r\n return currentDir;\r\n }\r\n\r\n return null; // No .csproj file found\r\n}\r\n\r\nexport function getSourceFileCsprojFilePath(sourceCodePath: string) {\r\n let currentDir = path.dirname(sourceCodePath);\r\n\r\n while (currentDir !== path.dirname(currentDir)) {\r\n const files = fs.readdirSync(currentDir);\r\n const csprojFilePaths = files.filter(file => file.endsWith('.csproj'));\r\n if (csprojFilePaths?.length > 0) {\r\n return path.join(currentDir, csprojFilePaths[0]);\r\n }\r\n currentDir = path.dirname(currentDir);\r\n }\r\n\r\n // Check root directory\r\n const rootFiles = fs.readdirSync(currentDir);\r\n if (rootFiles.some(file => file.endsWith('.csproj'))) {\r\n return currentDir;\r\n }\r\n\r\n return null; // No .csproj file found\r\n}\r\n\r\n// export function getSourceFileProjectName(sourceCodePath: string) {\r\n// const projectPath = getSourceFileProjectPath(sourceCodePath);\r\n// if (!projectPath) {\r\n// console.warn(`No .csproj file found for ${sourceCodePath}`);\r\n// return null;\r\n// }\r\n\r\n// const projectName = path.basename(projectPath, '.csproj');\r\n// return projectName;\r\n// }\r\n\r\n// detect .git folder in the dir hierarchy of csFilePath, if exist, it's the code repo root\r\nexport function getCodeRepoRoot(csFilePath: string) {\r\n const rootDir = path.parse(csFilePath).root;\r\n let currentDir = path.dirname(csFilePath);;\r\n\r\n while (currentDir !== rootDir) {\r\n if (fs.existsSync(path.join(currentDir, \".git\"))) {\r\n return currentDir;\r\n }\r\n currentDir = path.dirname(currentDir);\r\n }\r\n\r\n console.log(`No .git folder found in the dir hierarchy of ${csFilePath}. Assuming root is ${rootDir}`);\r\n return rootDir;\r\n}\r\n\r\n// export function getTestProjectDll(testProjectPath: string) {\r\n// const testProjectDir = path.dirname(testProjectPath);\r\n// const testProjectName = path.basename(testProjectPath, '.csproj');\r\n// const dllName = `${testProjectName}.dll`;\r\n// const dllPath = path.join(testProjectDir, 'bin', 'Debug', dllName);\r\n// return dllPath;\r\n// }\r\n\r\n\r\nexport function getAssemblyName(csprojPath: string): string {\r\n const xmlContent = fs.readFileSync(csprojPath, \"utf-8\");\r\n const parser = new XMLParser();\r\n const parsed = parser.parse(xmlContent);\r\n\r\n const project = parsed.Project;\r\n if (!project) {\r\n throw new Error(\"can't parse .csproj 文件\");\r\n }\r\n\r\n const propertyGroups = Array.isArray(project.PropertyGroup)\r\n ? project.PropertyGroup\r\n : [project.PropertyGroup];\r\n\r\n for (const group of propertyGroups) {\r\n if (group.AssemblyName) {\r\n return group.AssemblyName;\r\n }\r\n }\r\n\r\n return path.basename(csprojPath, \".csproj\");\r\n}\r\n\r\nfunction getDllPath(outputDir: string, assemblyName: string): string {\r\n if (!fs.existsSync(outputDir)) {\r\n throw new Error(`The output dir doesn't exist: ${outputDir}`);\r\n }\r\n\r\n // xap dll path: \"D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\bin\\Debug\\SharedSegments.Tests.dll\"\r\n const dllPath = path.join(outputDir, `${assemblyName}.dll`);\r\n if (fs.existsSync(dllPath)) {\r\n return dllPath;\r\n }\r\n\r\n // general dll path: \"D:\\code\\ai-dev-tools\\csharp-ut-copilot\\CSharpAnalyzer\\CSharpAnalyzer\\bin\\Debug\\net8.0\\CSharpAnalyzer.dll\"\r\n const subdirs = fs.readdirSync(outputDir).filter((f) =>\r\n fs.statSync(path.join(outputDir, f)).isDirectory()\r\n );\r\n\r\n for (const frameworkDir of subdirs) {\r\n const dllPath = path.join(outputDir, frameworkDir, `${assemblyName}.dll`);\r\n if (fs.existsSync(dllPath)) {\r\n return dllPath;\r\n }\r\n }\r\n\r\n throw new Error(`can't get dll file: ${assemblyName}.dll`);\r\n}\r\n\r\nexport function getBuiltDllPath(csprojPath: string): string {\r\n if (!fs.existsSync(csprojPath)) {\r\n throw new Error(`csproj doesn't exist: ${csprojPath}`);\r\n }\r\n\r\n const assemblyName = getAssemblyName(csprojPath);\r\n const projectDir = path.dirname(csprojPath);\r\n const outputBase = path.join(projectDir, \"bin\", \"Debug\");\r\n\r\n return getDllPath(outputBase, assemblyName);\r\n}\r\n\r\n\r\n// const dllPath = getBuiltDllPath(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\SharedSegments.Tests.csproj\");\r\n// console.log(`Test project DLL path: ${dllPath}`);"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getOrCreateDir = getOrCreateDir;
|
|
37
|
+
exports.getTmpCacheDir = getTmpCacheDir;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const TMPCACHE = '../atmpCache';
|
|
41
|
+
function getOrCreateDir(dir) {
|
|
42
|
+
try {
|
|
43
|
+
// Check if directory exists
|
|
44
|
+
if (!fs.existsSync(dir)) {
|
|
45
|
+
// Create directory recursively
|
|
46
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
47
|
+
console.log(`Directory created: ${dir}`);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.log(`Directory already exists: ${dir}`);
|
|
51
|
+
}
|
|
52
|
+
return dir;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.error('Error processing directory:', error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function getTmpCacheDir(dir) {
|
|
59
|
+
const tmpCacheDir = path.join(__dirname, TMPCACHE, dir);
|
|
60
|
+
const resolvedPath = path.resolve(tmpCacheDir);
|
|
61
|
+
return getOrCreateDir(resolvedPath);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=getOrCreateDir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrCreateDir.js","sourceRoot":"","sources":["../../src/utils/getOrCreateDir.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,wCAcC;AAED,wCAIC;AAxBD,uCAAyB;AACzB,2CAA6B;AAE7B,MAAM,QAAQ,GAAG,cAAc,CAAC;AAChC,SAAgB,cAAc,CAAC,GAAW;IACtC,IAAI,CAAC;QACD,4BAA4B;QAC5B,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,+BAA+B;YAC/B,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACvC,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,EAAE,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,6BAA6B,GAAG,EAAE,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;AACL,CAAC;AAED,SAAgB,cAAc,CAAC,GAAW;IACtC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;IACxD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/C,OAAO,cAAc,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import * as fs from 'fs';\r\nimport * as path from 'path';\r\n\r\nconst TMPCACHE = '../atmpCache';\r\nexport function getOrCreateDir(dir: string) {\r\n try {\r\n // Check if directory exists\r\n if (!fs.existsSync(dir)) {\r\n // Create directory recursively\r\n fs.mkdirSync(dir, { recursive: true });\r\n console.log(`Directory created: ${dir}`);\r\n } else {\r\n console.log(`Directory already exists: ${dir}`);\r\n }\r\n return dir;\r\n } catch (error) {\r\n console.error('Error processing directory:', error);\r\n }\r\n}\r\n\r\nexport function getTmpCacheDir(dir: string) {\r\n const tmpCacheDir = path.join(__dirname, TMPCACHE, dir);\r\n const resolvedPath = path.resolve(tmpCacheDir);\r\n return getOrCreateDir(resolvedPath);\r\n}"]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getTestCodeNamespace = getTestCodeNamespace;
|
|
37
|
+
exports.getTestClassName = getTestClassName;
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const getCodeStructurePath_1 = require("./getCodeStructurePath");
|
|
40
|
+
// get test code namespace from source code path
|
|
41
|
+
function getTestCodeNamespace(sourceCodePath) {
|
|
42
|
+
const sourceFileProjectPath = (0, getCodeStructurePath_1.getSourceFileProjectDir)(sourceCodePath);
|
|
43
|
+
const projectName = path.basename(sourceFileProjectPath, '.csproj');
|
|
44
|
+
const sourceFileName = path.basename(sourceCodePath);
|
|
45
|
+
const codeFileDir = sourceCodePath.replace(sourceFileProjectPath, "").replace(sourceFileName, "").replace(/\\/g, ".");
|
|
46
|
+
const namespacePart = codeFileDir.slice(1, -1);
|
|
47
|
+
return `${projectName}.Tests.${namespacePart}`;
|
|
48
|
+
}
|
|
49
|
+
function getTestClassName(testCode) {
|
|
50
|
+
const namespaceMatch = testCode.match(/namespace\s+([a-zA-Z0-9_.]+)/);
|
|
51
|
+
const classMatch = testCode.match(/class\s+([a-zA-Z0-9_]+)/);
|
|
52
|
+
if (namespaceMatch && classMatch) {
|
|
53
|
+
return `${namespaceMatch[1]}.${classMatch[1]}`;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
// export function extractSucceedTestCode(filePath: string, failedMethods: string[]) {
|
|
58
|
+
// const inputLines = fs.readFileSync(filePath, 'utf-8').split(/\r?\n/);
|
|
59
|
+
// const outputLines: string[] = [];
|
|
60
|
+
// let i = 0;
|
|
61
|
+
// while (i < inputLines.length) {
|
|
62
|
+
// const trimmed = inputLines[i].trim();
|
|
63
|
+
// if (trimmed !== '[TestMethod]') {
|
|
64
|
+
// outputLines.push(inputLines[i]);
|
|
65
|
+
// i++;
|
|
66
|
+
// continue;
|
|
67
|
+
// }
|
|
68
|
+
// const methodLine = inputLines[i + 1];
|
|
69
|
+
// const match = methodLine?.match(/public\s+void\s+(\w+)\s*\(\)/);
|
|
70
|
+
// if (!match) {
|
|
71
|
+
// outputLines.push(inputLines[i]);
|
|
72
|
+
// i++;
|
|
73
|
+
// continue;
|
|
74
|
+
// }
|
|
75
|
+
// const methodName = match[1];
|
|
76
|
+
// if (!failedMethods.includes(methodName)) {
|
|
77
|
+
// outputLines.push(inputLines[i]); // [TestMethod]
|
|
78
|
+
// outputLines.push(inputLines[i + 1]); // public void ...
|
|
79
|
+
// i += 2;
|
|
80
|
+
// continue;
|
|
81
|
+
// }
|
|
82
|
+
// i += 2;
|
|
83
|
+
// let braceCount = 0;
|
|
84
|
+
// let methodStarted = false;
|
|
85
|
+
// while (i < inputLines.length) {
|
|
86
|
+
// const line = inputLines[i];
|
|
87
|
+
// if (!methodStarted) {
|
|
88
|
+
// if (line.includes('{')) {
|
|
89
|
+
// braceCount += (line.match(/{/g) || []).length;
|
|
90
|
+
// braceCount -= (line.match(/}/g) || []).length;
|
|
91
|
+
// methodStarted = true;
|
|
92
|
+
// }
|
|
93
|
+
// } else {
|
|
94
|
+
// braceCount += (line.match(/{/g) || []).length;
|
|
95
|
+
// braceCount -= (line.match(/}/g) || []).length;
|
|
96
|
+
// }
|
|
97
|
+
// i++;
|
|
98
|
+
// if (methodStarted && braceCount === 0) {
|
|
99
|
+
// break;
|
|
100
|
+
// }
|
|
101
|
+
// }
|
|
102
|
+
// while (i < inputLines.length && inputLines[i].trim() === '') {
|
|
103
|
+
// i++;
|
|
104
|
+
// }
|
|
105
|
+
// const nextLine = inputLines[i]?.trim();
|
|
106
|
+
// if (nextLine === '[TestMethod]') {
|
|
107
|
+
// outputLines.push('');
|
|
108
|
+
// }
|
|
109
|
+
// console.log(`✅ Removed method: ${methodName}`);
|
|
110
|
+
// }
|
|
111
|
+
// return outputLines.join('\n');
|
|
112
|
+
// }
|
|
113
|
+
// D:\code\CS.Service.Fundamental\SharedSegments\SharedSegments\SharedSegments.Plugins\Workflows\Overview\HttpRequestParser\Utils\SqmidHelper.cs
|
|
114
|
+
// const namespace = generateTestCodeNamespacce("D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Overview\\HttpRequestParser\\Utils\\SqmidHelper.cs", "test code");
|
|
115
|
+
// console.log(namespace); // Outputs: SharedSegments.Tests.SharedSegments.Plugins.Workflows.Overview.HttpRequestParser.Utils
|
|
116
|
+
// const code = fs.readFileSync("D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\Workflows\\Overview\\HttpRequestParser\\Utils\\SqmidHelperTests.cs", 'utf-8');
|
|
117
|
+
// const classname = getTestClassName(code);
|
|
118
|
+
// console.log(classname); // Outputs: SharedSegments.Tests.SharedSegments.Plugins.Workflows.Overview.HttpRequestParser.Utils.SqmidHelperTests
|
|
119
|
+
// const testCode = extractSucceedTestCode("D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Tests\\Workflows\\Overview\\HttpRequestParser\\Utils\\SqmidHelperTests.cs", ["GetSqmidFromCookie_InvalidBlisIdFormat_ReturnsEmptyString", "GetSqmidFromCookie_MissingUsrLocCookie_ReturnsEmptyString"]);
|
|
120
|
+
// console.log(testCode);
|
|
121
|
+
//# sourceMappingURL=getTestCodeInfo.js.map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D,4CAA4C;AAC5C,+CAA+C;AAC/C,mBAAmB;AACnB,wBAAwB;AACxB,YAAY;AAEZ,gDAAgD;AAChD,2EAA2E;AAE3E,wBAAwB;AACxB,+CAA+C;AAC/C,mBAAmB;AACnB,wBAAwB;AACxB,YAAY;AAEZ,uCAAuC;AAEvC,qDAAqD;AACrD,mEAAmE;AACnE,sEAAsE;AACtE,sBAAsB;AACtB,wBAAwB;AACxB,YAAY;AAEZ,kBAAkB;AAClB,8BAA8B;AAC9B,qCAAqC;AAErC,0CAA0C;AAC1C,0CAA0C;AAC1C,oCAAoC;AACpC,4CAA4C;AAC5C,qEAAqE;AACrE,qEAAqE;AACrE,4CAA4C;AAC5C,oBAAoB;AACpB,uBAAuB;AACvB,iEAAiE;AACjE,iEAAiE;AACjE,gBAAgB;AAEhB,mBAAmB;AACnB,uDAAuD;AACvD,yBAAyB;AACzB,gBAAgB;AAChB,YAAY;AAEZ,yEAAyE;AACzE,mBAAmB;AACnB,YAAY;AAEZ,kDAAkD;AAClD,6CAA6C;AAC7C,oCAAoC;AACpC,YAAY;AAEZ,0DAA0D;AAC1D,QAAQ;AAER,qCAAqC;AACrC,IAAI;AACJ,gJAAgJ;AAChJ,wNAAwN;AACxN,6HAA6H;AAC7H,uMAAuM;AACvM,4CAA4C;AAC5C,8IAA8I;AAE9I,qUAAqU;AACrU,yBAAyB","sourcesContent":["import * as path from 'path';\r\n\r\nimport { getSourceFileProjectDir } from \"./getCodeStructurePath\";\r\n\r\n// get test code namespace from source code path\r\nexport function getTestCodeNamespace(sourceCodePath: string): string {\r\n const sourceFileProjectPath = getSourceFileProjectDir(sourceCodePath);\r\n const projectName = path.basename(sourceFileProjectPath, '.csproj');\r\n const sourceFileName = path.basename(sourceCodePath);\r\n const codeFileDir = sourceCodePath.replace(sourceFileProjectPath, \"\").replace(sourceFileName, \"\").replace(/\\\\/g, \".\");\r\n const namespacePart = codeFileDir.slice(1, -1);\r\n return `${projectName}.Tests.${namespacePart}`;\r\n}\r\n\r\nexport function getTestClassName(testCode: string): string {\r\n const namespaceMatch = testCode.match(/namespace\\s+([a-zA-Z0-9_.]+)/);\r\n const classMatch = testCode.match(/class\\s+([a-zA-Z0-9_]+)/);\r\n\r\n if (namespaceMatch && classMatch) {\r\n return `${namespaceMatch[1]}.${classMatch[1]}`;\r\n }\r\n\r\n return null;\r\n}\r\n\r\n\r\n// export function extractSucceedTestCode(filePath: string, failedMethods: string[]) {\r\n// const inputLines = fs.readFileSync(filePath, 'utf-8').split(/\\r?\\n/);\r\n// const outputLines: string[] = [];\r\n\r\n// let i = 0;\r\n// while (i < inputLines.length) {\r\n// const trimmed = inputLines[i].trim();\r\n\r\n// if (trimmed !== '[TestMethod]') {\r\n// outputLines.push(inputLines[i]);\r\n// i++;\r\n// continue;\r\n// }\r\n\r\n// const methodLine = inputLines[i + 1];\r\n// const match = methodLine?.match(/public\\s+void\\s+(\\w+)\\s*\\(\\)/);\r\n\r\n// if (!match) {\r\n// outputLines.push(inputLines[i]);\r\n// i++;\r\n// continue;\r\n// }\r\n\r\n// const methodName = match[1];\r\n\r\n// if (!failedMethods.includes(methodName)) {\r\n// outputLines.push(inputLines[i]); // [TestMethod]\r\n// outputLines.push(inputLines[i + 1]); // public void ...\r\n// i += 2;\r\n// continue;\r\n// }\r\n\r\n// i += 2;\r\n// let braceCount = 0;\r\n// let methodStarted = false;\r\n\r\n// while (i < inputLines.length) {\r\n// const line = inputLines[i];\r\n// if (!methodStarted) {\r\n// if (line.includes('{')) {\r\n// braceCount += (line.match(/{/g) || []).length;\r\n// braceCount -= (line.match(/}/g) || []).length;\r\n// methodStarted = true;\r\n// }\r\n// } else {\r\n// braceCount += (line.match(/{/g) || []).length;\r\n// braceCount -= (line.match(/}/g) || []).length;\r\n// }\r\n\r\n// i++;\r\n// if (methodStarted && braceCount === 0) {\r\n// break;\r\n// }\r\n// }\r\n\r\n// while (i < inputLines.length && inputLines[i].trim() === '') {\r\n// i++;\r\n// }\r\n\r\n// const nextLine = inputLines[i]?.trim();\r\n// if (nextLine === '[TestMethod]') {\r\n// outputLines.push('');\r\n// }\r\n\r\n// console.log(`✅ Removed method: ${methodName}`);\r\n// }\r\n\r\n// return outputLines.join('\\n');\r\n// }\r\n// D:\\code\\CS.Service.Fundamental\\SharedSegments\\SharedSegments\\SharedSegments.Plugins\\Workflows\\Overview\\HttpRequestParser\\Utils\\SqmidHelper.cs\r\n// const namespace = generateTestCodeNamespacce(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Plugins\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\SqmidHelper.cs\", \"test code\");\r\n// console.log(namespace); // Outputs: SharedSegments.Tests.SharedSegments.Plugins.Workflows.Overview.HttpRequestParser.Utils\r\n// const code = fs.readFileSync(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\SqmidHelperTests.cs\", 'utf-8');\r\n// const classname = getTestClassName(code);\r\n// console.log(classname); // Outputs: SharedSegments.Tests.SharedSegments.Plugins.Workflows.Overview.HttpRequestParser.Utils.SqmidHelperTests\r\n\r\n// const testCode = extractSucceedTestCode(\"D:\\\\code\\\\CS.Service.Fundamental\\\\SharedSegments\\\\SharedSegments\\\\SharedSegments.Tests\\\\Workflows\\\\Overview\\\\HttpRequestParser\\\\Utils\\\\SqmidHelperTests.cs\", [\"GetSqmidFromCookie_InvalidBlisIdFormat_ReturnsEmptyString\", \"GetSqmidFromCookie_MissingUsrLocCookie_ReturnsEmptyString\"]);\r\n// console.log(testCode);"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function getExistingTestFile(sourceCodePath: string): {
|
|
2
|
+
testFilePath: string;
|
|
3
|
+
testProjectPath: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function createTestFile(sourceCodePath: string): {
|
|
6
|
+
testFilePath: string;
|
|
7
|
+
testProjectPath: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function getOrCreatTestFile(sourceCodePath: string, testFilePath: string, isXapCode: boolean): {
|
|
10
|
+
testFilePath: string;
|
|
11
|
+
testProjectPath: any;
|
|
12
|
+
testFileExist: boolean;
|
|
13
|
+
};
|