Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW (Extension) @W-17330890@ A4D SFCA Integration - Integrate with UnifiedDiff UI #155

Merged
merged 32 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8460e3b
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
24b3c71
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
2ed57d0
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
6f15d44
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
348ad56
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
05f2b03
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
e23b896
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
3f2550d
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
96928bf
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
61a4dfb
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
274beb0
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
9395918
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
01e1437
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
be17f8e
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
c426de0
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
bd88bb6
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
419042d
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
1d8319c
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
02d8772
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
9720838
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
641bc73
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 17, 2025
5bb5a8b
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 21, 2025
d73d392
NEW (Extension) @W-17330890@ A4D SFCA Integration - Code Fixes for Ap…
jag-j Jan 21, 2025
49cb938
NEW (Extension) @W-17330890@ A4D SFCA Integration - Update yarn lock …
jag-j Jan 21, 2025
c160d33
NEW (Extension) @W-17330890@ A4D SFCA Integration - Remove not requir…
jag-j Jan 21, 2025
de4c81d
NEW (Extension) @W-17330890@ A4D SFCA Integration - Readd auth
jag-j Jan 21, 2025
e340124
NEW (Extension) @W-17330890@ A4D SFCA Integration - Remove not requir…
jag-j Jan 21, 2025
dc4df97
NEW (Extension) @W-17330890@ A4D SFCA Integration - Add github auth t…
jag-j Jan 21, 2025
afa1c54
NEW (Extension) @W-17330890@ A4D SFCA Integration - Inherit secrets f…
jag-j Jan 21, 2025
43457e1
NEW (Extension) @W-17330890@ A4D SFCA Integration - Inherit secrets f…
jag-j Jan 21, 2025
6f293d6
NEW (Extension) @W-17330890@ A4D SFCA Integration - clean ups
jag-j Jan 21, 2025
a6ee646
NEW (Extension) @W-17330890@ A4D SFCA Integration - clean ups
jag-j Jan 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/create-release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,4 @@ jobs:
# not what's *already* published.
use-scanner-tarball: true
target-branch: ${{ needs.create-release-branch.outputs.branch-name }}
secrets: inherit
4 changes: 4 additions & 0 deletions .github/workflows/create-vsix-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ jobs:
steps:
- name: 'Check out the code'
uses: actions/checkout@v4
with:
token: ${{ secrets.IDEE_GH_TOKEN }} # So we can access internal repo to pull shared ui components
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lets us run as idee bot user so we can access the internal private repo.

- name: 'Set up NodeJS'
uses: actions/setup-node@v4
with:
node-version: 'lts/*' # Node LTS should always be fine.
- name: Configure Git for private repo access
run: git config --global --add url."https://${{ secrets.IDEE_GH_TOKEN }}@github.com/".insteadOf "https://github.com/"
- name: 'Install node dependencies'
run: yarn install --frozen-lockfile
- name: 'Create VSIX'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
# Before publishing, we want to test the extension against whatever
# version of the scanner is currently live.
use-scanner-tarball: false
secrets: inherit

publish-vscode:
name: 'Publish to VSCode Marketplace'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ inputs.target-branch }}
token: ${{ secrets.IDEE_GH_TOKEN }} # So we can access internal repo to pull shared ui components
- name: 'Set up NodeJS'
uses: actions/setup-node@v4
with:
Expand All @@ -34,6 +35,8 @@ jobs:
with:
distribution: 'temurin'
java-version: '11' # Always use Java v11 for running tests.
- name: Configure Git for private repo access
run: git config --global --add url."https://${{ secrets.IDEE_GH_TOKEN }}@github.com/".insteadOf "https://github.com/"
- name: 'Install node module dependencies'
run: yarn install --frozen-lockfile
# We'll need to install the CLI tool, since some of the tests
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ jobs:
# We want to validate the extension against whatever version of the scanner we
# *plan* to publish, not what's *already* published.
use-scanner-tarball: true
secrets: inherit
# BUILD A VSIX ARTIFACT
# Additionally, build a VSIX that can be downloaded by the user if needed.
create-vsix-artifact:
name: 'Upload VSIX as artifact'
uses: ./.github/workflows/create-vsix-artifact.yml
secrets: inherit
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
"SFCA"
],
"dependencies": {
"@salesforce/vscode-service-provider": "^1.3.0-rc.6.2",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We access the LLM model via this package.

"cross-spawn": "^7.0.3",
"einstein-shared": "https://github.com/forcedotcom/salesforcedx-vscode-einstein-shared#semver:0.3.9",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the shared module repository and since the package cannot be open sourced yet, we depend on it this way.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When installing our vscode extention… will the new dependency
einstein-shared": "https://github.com/forcedotcom/salesforcedx-vscode-einstein-shared#semver:0.3.9",
get pulled during install or is it installed into the vsix file?

That is... can we even ship this line of code or will it break users during install?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can ship with this line of code. This is bundled into the vsix.

"glob": "^8.0.3",
"globby": "^11.0.0",
"semver": "^7.5.4"
Expand Down
32 changes: 32 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import * as ApexGuruFunctions from './apexguru/apex-guru-service';
import * as DeltaRunFunctions from './deltarun/delta-run-service';
import * as os from 'os';
import * as fs from 'fs';
import { VSCodeUnifiedDiff, DiffHunk } from 'einstein-shared';

export type RunInfo = {
diagnosticCollection?: vscode.DiagnosticCollection;
Expand Down Expand Up @@ -171,10 +172,41 @@ export async function activate(context: vscode.ExtensionContext): Promise<vscode
context.subscriptions.push(documentSaveListener);

TelemetryService.sendExtensionActivationEvent(extensionHrStart);
setupUnifiedDiff(context);
outputChannel.appendLine(`Extension sfdx-code-analyzer-vscode activated.`);
return Promise.resolve(context);
}


function setupUnifiedDiff(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand(Constants.UNIFIED_DIFF, async (code: string, file?: string) => {
await VSCodeUnifiedDiff.singleton.unifiedDiff(code, file);
})
);
context.subscriptions.push(
vscode.commands.registerCommand(Constants.UNIFIED_DIFF_ACCEPT, async (hunk: DiffHunk) => {
await VSCodeUnifiedDiff.singleton.unifiedDiffAccept(hunk);
})
);
context.subscriptions.push(
vscode.commands.registerCommand(Constants.UNIFIED_DIFF_REJECT, async (hunk: DiffHunk) => {
await VSCodeUnifiedDiff.singleton.unifiedDiffReject(hunk);
})
);
context.subscriptions.push(
vscode.commands.registerCommand(Constants.UNIFIED_DIFF_ACCEPT_ALL, async () => {
await VSCodeUnifiedDiff.singleton.unifiedDiffAcceptAll();
})
);
context.subscriptions.push(
vscode.commands.registerCommand(Constants.UNIFIED_DIFF_REJECT_ALL, async () => {
await VSCodeUnifiedDiff.singleton.unifiedDiffRejectAll();
})
);
VSCodeUnifiedDiff.singleton.activate(context);
}

async function runMethodLevelDfa(context: vscode.ExtensionContext, methodLevelTarget: string[]) {
await vscode.window.withProgress({
location: vscode.ProgressLocation.Window,
Expand Down
10 changes: 8 additions & 2 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ export const WORKSPACE_DFA_PROCESS = 'dfaScanProcess';
// apex guru APIS
export const APEX_GURU_AUTH_ENDPOINT = '/services/data/v62.0/apexguru/validate'
export const APEX_GURU_REQUEST = '/services/data/v62.0/apexguru/request'

// feature gates
export const APEX_GURU_MAX_TIMEOUT_SECONDS = 60;
export const APEX_GURU_RETRY_INTERVAL_MILLIS = 1000;

// A4D Integration
export const A4D_FIX_AVAILABLE_RULES = ['ApexCRUDViolation'];
export const UNIFIED_DIFF = 'unifiedDiff';
export const UNIFIED_DIFF_ACCEPT = 'unifiedDiff.accept';
export const UNIFIED_DIFF_REJECT = 'unifiedDiff.reject';
export const UNIFIED_DIFF_ACCEPT_ALL = 'unifiedDiff.acceptAll';
export const UNIFIED_DIFF_REJECT_ALL = 'unifiedDiff.rejectAll';
66 changes: 66 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,18 @@
dependencies:
"@jridgewell/trace-mapping" "0.3.9"

"@datastructures-js/heap@^4.3.3":
version "4.3.3"
resolved "https://registry.yarnpkg.com/@datastructures-js/heap/-/heap-4.3.3.tgz#824c10f092ab03180702f0dea8ce96227ffe50a8"
integrity sha512-UcUu/DLh/aM4W3C8zZfwxxm6/6FIZUlm3mcAXuNOCa6Aj4iizNvNXQyb8DjZQH2jKSQbMRyNlngP6TPimuGjpQ==

"@datastructures-js/priority-queue@^6.3.0":
version "6.3.2"
resolved "https://registry.yarnpkg.com/@datastructures-js/priority-queue/-/priority-queue-6.3.2.tgz#970a57c16a4a901ca9e34bc1991dc9962bf6d10e"
integrity sha512-hPmWlbmYRegOkZsWJuOzZw+BYcrOJ9B5xwy8Sz/QtEtLUPHtJbX9OpPpCB+KQPgOVb1QonqFqiddVDud/i5afw==
dependencies:
"@datastructures-js/heap" "^4.3.3"

"@esbuild/[email protected]":
version "0.23.1"
resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz#51299374de171dbd80bb7d838e1cfce9af36f353"
Expand Down Expand Up @@ -529,6 +541,11 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@salesforce/vscode-service-provider@^1.3.0-rc.6.2":
version "1.3.0-rc.6.3"
resolved "https://registry.yarnpkg.com/@salesforce/vscode-service-provider/-/vscode-service-provider-1.3.0-rc.6.3.tgz#8db9257cb1d29aaeab7b487d4826b0fd42c83605"
integrity sha512-4It/mYoCqTWbhQC5YDTGGdNF9PbCR09HY+7jSKkUgYdFoSgoyTQUoueeSLs/3DNudF1kai0rHbs/PLrf/X00iQ==

"@sinonjs/commons@^3.0.0", "@sinonjs/commons@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-3.0.1.tgz#1029357e44ca901a615585f6d27738dbc89084cd"
Expand Down Expand Up @@ -1483,6 +1500,16 @@ [email protected]:
dependencies:
safe-buffer "^5.0.1"

"einstein-shared@https://github.com/forcedotcom/salesforcedx-vscode-einstein-shared#semver:0.3.9":
version "0.3.9"
resolved "https://github.com/forcedotcom/salesforcedx-vscode-einstein-shared#a1a8286c0558cf613efab31220f8982f17f8d2da"
dependencies:
"@datastructures-js/priority-queue" "^6.3.0"
diff "^5.1.0"
minimatch "^9.0.3"
uuid "^9.0.0"
vscode-dts "^0.3.3"

electron-to-chromium@^1.5.41:
version "1.5.45"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.45.tgz#fa592ce6a88b44d23acbc7453a2feab98996e6c9"
Expand Down Expand Up @@ -2413,6 +2440,11 @@ keyv@^4.5.3:
dependencies:
json-buffer "3.0.1"

kleur@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==

leven@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2"
Expand Down Expand Up @@ -2635,6 +2667,13 @@ minimatch@^5.0.1, minimatch@^5.1.6:
dependencies:
brace-expansion "^2.0.1"

minimatch@^9.0.3:
version "9.0.5"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.5.tgz#d74f9dd6b57d83d8e98cfb82133b03978bc929e5"
integrity sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==
dependencies:
brace-expansion "^2.0.1"

minimist@^1.2.0, minimist@^1.2.3:
version "1.2.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
Expand Down Expand Up @@ -3032,6 +3071,14 @@ process-on-spawn@^1.0.0:
dependencies:
fromentries "^1.2.0"

prompts@^2.1.0:
version "2.4.2"
resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069"
integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==
dependencies:
kleur "^3.0.3"
sisteransi "^1.0.5"

proxyquire@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/proxyquire/-/proxyquire-2.1.3.tgz#2049a7eefa10a9a953346a18e54aab2b4268df39"
Expand Down Expand Up @@ -3299,6 +3346,11 @@ sinon@^15.1.0:
nise "^5.1.4"
supports-color "^7.2.0"

sisteransi@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==

slash@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
Expand Down Expand Up @@ -3618,11 +3670,25 @@ uuid@^8.3.0, uuid@^8.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

uuid@^9.0.0:
version "9.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==

v8-compile-cache-lib@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf"
integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==

vscode-dts@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/vscode-dts/-/vscode-dts-0.3.3.tgz#e5ef3afe76182875b252cca7f449938e4a0bf28a"
integrity sha512-JfOsWL0NvfVw0UF9bcTjlv1Onz3Ted7cgpPWKWMnHGB+72t/tn8WFDeKLZO42l2k9KJq/NGS9rFC5gZbyI4FTg==
dependencies:
minimist "^1.2.0"
prompts "^2.1.0"
rimraf "^3.0.0"

whatwg-encoding@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz#d0f4ef769905d426e1688f3e34381a99b60b76e5"
Expand Down
Loading