From 87a9de17479e8e6e00262f838458fbd918b28afb Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Tue, 11 Jun 2024 13:35:24 -0600 Subject: [PATCH 1/6] test: add NUT to verify CF retrieve [skip-validate-pr] --- test/nuts/retrieve/metadata.nut.ts | 9 +++- yarn.lock | 70 ++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 23 deletions(-) diff --git a/test/nuts/retrieve/metadata.nut.ts b/test/nuts/retrieve/metadata.nut.ts index bad269f7..3e63e740 100644 --- a/test/nuts/retrieve/metadata.nut.ts +++ b/test/nuts/retrieve/metadata.nut.ts @@ -15,7 +15,7 @@ import { RetrieveResultJson } from '../../../src/utils/types.js'; const ELECTRON = { id: '04t6A000002zgKSQAY', name: 'ElectronBranding' }; -describe('retrieve metadata NUTs', () => { +describe.only('retrieve metadata NUTs', () => { let testkit: SourceTestkit; before(async () => { @@ -49,6 +49,13 @@ describe('retrieve metadata NUTs', () => { await testkit.expect.filesToBeRetrieved(['force-app/main/default/classes/GeocodingService.cls']); }); + it('should retrieve named CustomField', async () => { + await testkit.retrieve({ args: '--metadata CustomField:Broker__c.Email__c ' }); + await testkit.expect.filesToBeRetrieved([ + 'force-app/main/default/objects/Broker__c/fields/Email__c.field-meta.xml', + ]); + }); + it('should retrieve multiple metadata types', async () => { await testkit.retrieve({ args: '--metadata ApexClass AuraDefinitionBundle' }); await testkit.expect.filesToBeRetrieved(['force-app/main/default/classes/*', 'force-app/main/default/aura/**/*']); diff --git a/yarn.lock b/yarn.lock index f080db25..cbe60c44 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1432,16 +1432,17 @@ ts-retry-promise "^0.8.1" "@salesforce/core@^7.2.0", "@salesforce/core@^7.3.10", "@salesforce/core@^7.3.6", "@salesforce/core@^7.3.8", "@salesforce/core@^7.3.9": - version "7.3.10" - resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-7.3.10.tgz#83da85c4e93ca625e2c13118aad9c1df2931bc0f" - integrity sha512-kEKoqkmhWNoiucAE3Ylv6FpC4iVgk4aE0dmcwSmNrMjxSbtjQJGUybprfO/itrLJv+56eM7/4FARQQ2gDbRzQQ== + version "7.3.11" + resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-7.3.11.tgz#1cfa847c200dfead19162bc841afe094885a86f7" + integrity sha512-mawE4Md0UyyLbKtHWRG/vrE92AFjxLmDdzD2lGKhWaD7VeMdk9QHhkWSxS2qYcBozDwMyr+8OIeXJlJdsrednA== dependencies: "@jsforce/jsforce-node" "^3.2.0" - "@salesforce/kit" "^3.1.1" + "@salesforce/kit" "^3.1.2" "@salesforce/schemas" "^1.9.0" "@salesforce/ts-types" "^2.0.9" ajv "^8.15.0" change-case "^4.1.2" + fast-levenshtein "^3.0.0" faye "^1.4.0" form-data "^4.0.0" js2xmlparser "^4.0.1" @@ -2359,9 +2360,9 @@ integrity sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg== "@types/node@^18.15.3", "@types/node@^18.19.32": - version "18.19.33" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.33.tgz#98cd286a1b8a5e11aa06623210240bcc28e95c48" - integrity sha512-NR9+KrpSajr2qBVp/Yt5TU/rp+b5Mayi3+OlMlcg2cVCfRmcG5PWZ7S4+MG9PZ5gWBoc9Pd0BKSRViuBCRPu0A== + version "18.19.34" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.34.tgz#c3fae2bbbdb94b4a52fe2d229d0dccce02ef3d27" + integrity sha512-eXF4pfBNV5DAMKGbI02NnDtWrQ40hAN558/2vvS4gMpMIxaf6JmD7YjnZbq0Q9TDSSkKBamime8ewRoomHdt4g== dependencies: undici-types "~5.26.4" @@ -3403,14 +3404,14 @@ csprng@*: sequin "*" csv-parse@^5.5.2: - version "5.5.5" - resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-5.5.5.tgz#68a271a9092877b830541805e14c8a80e6a22517" - integrity sha512-erCk7tyU3yLWAhk6wvKxnyPtftuy/6Ak622gOO7BCJ05+TYffnPCJF905wmOQm+BpkX54OdAl8pveJwUdpnCXQ== + version "5.5.6" + resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-5.5.6.tgz#0d726d58a60416361358eec291a9f93abe0b6b1a" + integrity sha512-uNpm30m/AGSkLxxy7d9yRXpJQFrZzVWLFBkS+6ngPcZkw/5k3L/jjFuj7tVnEpRn+QgmiXr21nDlhCiUK4ij2A== csv-stringify@^6.4.4: - version "6.4.6" - resolved "https://registry.yarnpkg.com/csv-stringify/-/csv-stringify-6.4.6.tgz#9ccf87cb8b017c96673a9fa061768c8ba83e8b98" - integrity sha512-h2V2XZ3uOTLilF5dPIptgUfN/o2ia/80Ie0Lly18LAnw5s8Eb7kt8rfxSUy24AztJZas9f6DPZpVlzDUtFt/ag== + version "6.5.0" + resolved "https://registry.yarnpkg.com/csv-stringify/-/csv-stringify-6.5.0.tgz#7b1491893c917e018a97de9bf9604e23b88647c2" + integrity sha512-edlXFVKcUx7r8Vx5zQucsuMg4wb/xT6qyz+Sr1vnLrdXqlLD1+UKyWNyZ9zn6mUW1ewmGxrpVwAcChGF0HQ/2Q== dargs@^7.0.0: version "7.0.0" @@ -6941,9 +6942,9 @@ samsam@1.3.0: integrity sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg== sax@>=0.6.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/sax/-/sax-1.3.0.tgz#a5dbe77db3be05c9d1ee7785dbd3ea9de51593d0" - integrity sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA== + version "1.4.1" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.4.1.tgz#44cc8988377f126304d3b3fc1010c733b929ef0f" + integrity sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg== secure-json-parse@^2.4.0: version "2.7.0" @@ -7333,7 +7334,16 @@ srcset@^5.0.0: resolved "https://registry.yarnpkg.com/srcset/-/srcset-5.0.1.tgz#e660a728f195419e4afa95121099bc9efb7a1e36" integrity sha512-/P1UYbGfJVlxZag7aABNRrulEXAwCSDo7fklafOQrantuPTDmYgijJMks2zusPCVzgW9+4P69mq7w6pYuZpgxw== -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -7402,7 +7412,14 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@6.0.1, strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -7623,9 +7640,9 @@ tslib@^1.11.1: integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== tslib@^2.0.1, tslib@^2.0.3, tslib@^2.3.1, tslib@^2.6.1, tslib@^2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" - integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + version "2.6.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" + integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== tunnel-agent@*, tunnel-agent@^0.6.0: version "0.6.0" @@ -7961,7 +7978,7 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -7979,6 +7996,15 @@ wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" From a18558c3629cc365ff0035300cae961e5ce8ef37 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Tue, 11 Jun 2024 13:36:14 -0600 Subject: [PATCH 2/6] test: remove .only --- test/nuts/retrieve/metadata.nut.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/nuts/retrieve/metadata.nut.ts b/test/nuts/retrieve/metadata.nut.ts index 3e63e740..a3a6e56e 100644 --- a/test/nuts/retrieve/metadata.nut.ts +++ b/test/nuts/retrieve/metadata.nut.ts @@ -15,7 +15,7 @@ import { RetrieveResultJson } from '../../../src/utils/types.js'; const ELECTRON = { id: '04t6A000002zgKSQAY', name: 'ElectronBranding' }; -describe.only('retrieve metadata NUTs', () => { +describe('retrieve metadata NUTs', () => { let testkit: SourceTestkit; before(async () => { From 8ac9b45bdf063bfa4843087a371d2e062f57cfd8 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Tue, 11 Jun 2024 13:51:19 -0600 Subject: [PATCH 3/6] chore: bump SDR, dedupe, ensure .object-meta.xml is full --- package.json | 2 +- test/nuts/retrieve/metadata.nut.ts | 18 ++++++++++++++++++ yarn.lock | 8 ++++---- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index fe344d28..ef3520cc 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "@salesforce/kit": "^3.1.2", "@salesforce/plugin-info": "^3.3.6", "@salesforce/sf-plugins-core": "^10.0.0", - "@salesforce/source-deploy-retrieve": "^11.6.6", + "@salesforce/source-deploy-retrieve": "^11.6.7", "@salesforce/source-tracking": "^6.5.1", "@salesforce/ts-types": "^2.0.9", "ansis": "^3.2.0" diff --git a/test/nuts/retrieve/metadata.nut.ts b/test/nuts/retrieve/metadata.nut.ts index a3a6e56e..8f6a00bd 100644 --- a/test/nuts/retrieve/metadata.nut.ts +++ b/test/nuts/retrieve/metadata.nut.ts @@ -8,6 +8,7 @@ import * as path from 'node:path'; import * as fs from 'node:fs'; import { fileURLToPath } from 'node:url'; +import * as os from 'node:os'; import { execCmd } from '@salesforce/cli-plugins-testkit'; import { SourceTestkit } from '@salesforce/source-testkit'; import { expect } from 'chai'; @@ -54,6 +55,23 @@ describe('retrieve metadata NUTs', () => { await testkit.expect.filesToBeRetrieved([ 'force-app/main/default/objects/Broker__c/fields/Email__c.field-meta.xml', ]); + expect( + fs + .readFileSync( + path.join( + testkit.projectDir, + 'force-app', + 'main', + 'default', + 'objects', + 'Broker__c', + 'Broker__c.object-meta.xml' + ), + 'utf8' + ) + .split(os.EOL).length + // 4 lines would be overwritten - ensures like W-15896939 is fixed + ).to.be.greaterThanOrEqual(30); }); it('should retrieve multiple metadata types', async () => { diff --git a/yarn.lock b/yarn.lock index 9ab76b0f..e2634ad1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1685,10 +1685,10 @@ string-width "^7.1.0" terminal-link "^3.0.0" -"@salesforce/source-deploy-retrieve@^11.6.5", "@salesforce/source-deploy-retrieve@^11.6.6": - version "11.6.6" - resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-11.6.6.tgz#0bec970d04cd528f68ae9009bdd52ec1db20a6b5" - integrity sha512-Wf7QCYtFsBwyLAFSPPuonyUnFMIz113yabDmZd9bBEeH3dKqPFQb6zHAV3HpoU5hwvHN/+xE8QDSxv3yjtyFPw== +"@salesforce/source-deploy-retrieve@^11.6.5", "@salesforce/source-deploy-retrieve@^11.6.7": + version "11.6.7" + resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-11.6.7.tgz#538042e31fdf92d6eeca9a45266d335e96d8af73" + integrity sha512-66KY6EfNGRom7rGDutNzLE7wr8UIPylAruLwyvShuWbXGwXKlUIQli2Vc33h6UfU15NmcrbfiaRxyCgg9oqENw== dependencies: "@salesforce/core" "^7.3.12" "@salesforce/kit" "^3.1.1" From 7a5f3b72e2a7a8c450ac2eb0db505e13f59da531 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Tue, 11 Jun 2024 15:01:31 -0600 Subject: [PATCH 4/6] test: try splitting with \n --- test/nuts/retrieve/metadata.nut.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/nuts/retrieve/metadata.nut.ts b/test/nuts/retrieve/metadata.nut.ts index 8f6a00bd..fe5697a2 100644 --- a/test/nuts/retrieve/metadata.nut.ts +++ b/test/nuts/retrieve/metadata.nut.ts @@ -8,7 +8,6 @@ import * as path from 'node:path'; import * as fs from 'node:fs'; import { fileURLToPath } from 'node:url'; -import * as os from 'node:os'; import { execCmd } from '@salesforce/cli-plugins-testkit'; import { SourceTestkit } from '@salesforce/source-testkit'; import { expect } from 'chai'; @@ -69,7 +68,7 @@ describe('retrieve metadata NUTs', () => { ), 'utf8' ) - .split(os.EOL).length + .split('\n').length // 4 lines would be overwritten - ensures like W-15896939 is fixed ).to.be.greaterThanOrEqual(30); }); From 6c611ef79569b9ae9eccf6dfd6d0287b30f2bce3 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Tue, 11 Jun 2024 15:28:53 -0600 Subject: [PATCH 5/6] chore: log content for debugging --- test/nuts/retrieve/metadata.nut.ts | 37 +++++++++++++++++++----------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/test/nuts/retrieve/metadata.nut.ts b/test/nuts/retrieve/metadata.nut.ts index fe5697a2..0da037c7 100644 --- a/test/nuts/retrieve/metadata.nut.ts +++ b/test/nuts/retrieve/metadata.nut.ts @@ -8,6 +8,7 @@ import * as path from 'node:path'; import * as fs from 'node:fs'; import { fileURLToPath } from 'node:url'; +import * as os from 'node:os'; import { execCmd } from '@salesforce/cli-plugins-testkit'; import { SourceTestkit } from '@salesforce/source-testkit'; import { expect } from 'chai'; @@ -54,21 +55,29 @@ describe('retrieve metadata NUTs', () => { await testkit.expect.filesToBeRetrieved([ 'force-app/main/default/objects/Broker__c/fields/Email__c.field-meta.xml', ]); + const content = fs.readFileSync( + path.join( + testkit.projectDir, + 'force-app', + 'main', + 'default', + 'objects', + 'Broker__c', + 'Broker__c.object-meta.xml' + ), + 'utf8' + ); + // eslint-disable-next-line no-console + console.log('content', content); + // eslint-disable-next-line no-console + console.log('length', content.split(os.EOL).length); + // eslint-disable-next-line no-console + console.log( + 'split', + content.split(os.EOL).map((c) => c) + ); expect( - fs - .readFileSync( - path.join( - testkit.projectDir, - 'force-app', - 'main', - 'default', - 'objects', - 'Broker__c', - 'Broker__c.object-meta.xml' - ), - 'utf8' - ) - .split('\n').length + content.split(os.EOL).length // 4 lines would be overwritten - ensures like W-15896939 is fixed ).to.be.greaterThanOrEqual(30); }); From 45354ab8209fdb595b858b4775be2b885e753f61 Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Tue, 11 Jun 2024 15:42:34 -0600 Subject: [PATCH 6/6] test: try splitting with \n --- test/nuts/retrieve/metadata.nut.ts | 37 +++++++++++------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/test/nuts/retrieve/metadata.nut.ts b/test/nuts/retrieve/metadata.nut.ts index 0da037c7..fe5697a2 100644 --- a/test/nuts/retrieve/metadata.nut.ts +++ b/test/nuts/retrieve/metadata.nut.ts @@ -8,7 +8,6 @@ import * as path from 'node:path'; import * as fs from 'node:fs'; import { fileURLToPath } from 'node:url'; -import * as os from 'node:os'; import { execCmd } from '@salesforce/cli-plugins-testkit'; import { SourceTestkit } from '@salesforce/source-testkit'; import { expect } from 'chai'; @@ -55,29 +54,21 @@ describe('retrieve metadata NUTs', () => { await testkit.expect.filesToBeRetrieved([ 'force-app/main/default/objects/Broker__c/fields/Email__c.field-meta.xml', ]); - const content = fs.readFileSync( - path.join( - testkit.projectDir, - 'force-app', - 'main', - 'default', - 'objects', - 'Broker__c', - 'Broker__c.object-meta.xml' - ), - 'utf8' - ); - // eslint-disable-next-line no-console - console.log('content', content); - // eslint-disable-next-line no-console - console.log('length', content.split(os.EOL).length); - // eslint-disable-next-line no-console - console.log( - 'split', - content.split(os.EOL).map((c) => c) - ); expect( - content.split(os.EOL).length + fs + .readFileSync( + path.join( + testkit.projectDir, + 'force-app', + 'main', + 'default', + 'objects', + 'Broker__c', + 'Broker__c.object-meta.xml' + ), + 'utf8' + ) + .split('\n').length // 4 lines would be overwritten - ensures like W-15896939 is fixed ).to.be.greaterThanOrEqual(30); });