diff --git a/.github/workflows/create-release-branch.yml b/.github/workflows/create-release-branch.yml index 8cc12ae..3e0e810 100644 --- a/.github/workflows/create-release-branch.yml +++ b/.github/workflows/create-release-branch.yml @@ -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 diff --git a/.github/workflows/create-vsix-artifact.yml b/.github/workflows/create-vsix-artifact.yml index 5a9b6ea..1ae147e 100644 --- a/.github/workflows/create-vsix-artifact.yml +++ b/.github/workflows/create-vsix-artifact.yml @@ -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 - 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' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3a55d5a..b8d1705 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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' diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e5023b0..29c199b 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -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: @@ -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 diff --git a/.github/workflows/validate-pr.yml b/.github/workflows/validate-pr.yml index f26daf7..bc9fb57 100644 --- a/.github/workflows/validate-pr.yml +++ b/.github/workflows/validate-pr.yml @@ -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 diff --git a/package.json b/package.json index 77748ad..708d7b8 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,9 @@ "SFCA" ], "dependencies": { + "@salesforce/vscode-service-provider": "^1.3.0-rc.6.2", "cross-spawn": "^7.0.3", + "einstein-shared": "https://github.com/forcedotcom/salesforcedx-vscode-einstein-shared#semver:0.3.9", "glob": "^8.0.3", "globby": "^11.0.0", "semver": "^7.5.4" diff --git a/src/extension.ts b/src/extension.ts index 9109a8b..fd0d7e0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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; @@ -171,10 +172,41 @@ export async function activate(context: vscode.ExtensionContext): Promise { + 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, diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 6d94694..842090a 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -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'; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 99071da..3440226 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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/aix-ppc64@0.23.1": version "0.23.1" resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz#51299374de171dbd80bb7d838e1cfce9af36f353" @@ -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" @@ -1483,6 +1500,16 @@ ecdsa-sig-formatter@1.0.11: 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" @@ -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" @@ -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" @@ -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" @@ -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" @@ -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"