Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
fix(apexlink): direct conversion to json breaks on large packages (#1306
Browse files Browse the repository at this point in the history
)

This fix is to ensure apex link's output is not getting truncated when directly fetched as a result
of a process execution. It now writes to a file and then the file is converted to JSON
  • Loading branch information
azlam-abdulsalam authored May 12, 2023
1 parent 71a1800 commit 256fe17
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 1,048 deletions.
63 changes: 59 additions & 4 deletions packages/apexlink/package-lock.json

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

3 changes: 2 additions & 1 deletion packages/apexlink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"dependencies": {
"@dxatscale/sfdx-process-wrapper": "0.1.0",
"@dxatscale/sfp-logger": "1.2.0",
"find-java-home": "2.0.0"
"find-java-home": "2.0.0",
"fs-extra": "11.1.1"
},
"devDependencies": {
"@babel/core": "7.18.2",
Expand Down
17 changes: 10 additions & 7 deletions packages/apexlink/src/ApexDepedencyCheckImpl.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import findJavaHome from 'find-java-home';
import ExecuteCommand from '@dxatscale/sfdx-process-wrapper/lib/commandExecutor/ExecuteCommand';
import { Logger, LoggerLevel } from '@dxatscale/sfp-logger';
import path from 'path';
import SFPLogger from '@dxatscale/sfp-logger';
import { ConsoleLogger } from '@dxatscale/sfp-logger';
import * as fs from 'fs-extra';
import path from 'path';

const jarFile = path.join(__dirname, '..', 'jars', 'apexlink-2.3.7.jar');
export default class ApexDepedencyCheckImpl {
Expand All @@ -13,19 +14,21 @@ export default class ApexDepedencyCheckImpl {

let apexLinkProcessExecutor = new ExecuteCommand(this.logger, LoggerLevel.INFO, false);
let generatedCommand = await this.getGeneratedCommandWithParams();
let result = await apexLinkProcessExecutor.execCommand(

await apexLinkProcessExecutor.execCommand(
generatedCommand,
process.cwd()
);
return JSON.parse(result);
let result = fs.readJSONSync(`${this.projectDirectory}/apexlink.json`)
return result;
}

private async getGeneratedCommandWithParams() {
let javaHome = await this.getJavaHome();

let javaHome:string = await this.getJavaHome();
//Replace Program Files with Progra~1 in Windows
javaHome = javaHome.replace(/Program Files/, "Progra~1");
let command = `${path.join(javaHome, 'bin', 'java')} -jar ${jarFile} -depends -json ${
this.projectDirectory
}`;
this.projectDirectory } > ${this.projectDirectory}/apexlink.json`;
return command;
}

Expand Down
Loading

0 comments on commit 256fe17

Please sign in to comment.