Skip to content

Commit b5a59a9

Browse files
Sm/labels-nuts (#389)
* test: additional nuts for customLabels using mpd * test: consolidate NUTs with seeds * test: consolidate repeated asserts * chore: remove unused devDep * fix: push uses fullPath for defaultDir for consistency * chore: bump SDR + STL Co-authored-by: Willie Ruemmele <[email protected]>
1 parent 07cfafd commit b5a59a9

File tree

4 files changed

+98
-102
lines changed

4 files changed

+98
-102
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"@oclif/config": "^1.18.1",
99
"@salesforce/command": "^4.2.0",
1010
"@salesforce/core": "^2.31.0",
11-
"@salesforce/source-deploy-retrieve": "^5.9.1",
12-
"@salesforce/source-tracking": "^0.5.1",
11+
"@salesforce/source-deploy-retrieve": "^5.9.3",
12+
"@salesforce/source-tracking": "^1.0.0",
1313
"chalk": "^4.1.2",
1414
"cli-ux": "^5.6.3",
1515
"open": "^8.2.1",

src/commands/force/source/beta/pull.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export default class Pull extends SourceCommand {
143143
const mdapiRetrieve = await componentSet.retrieve({
144144
usernameOrConnection: this.org.getUsername(),
145145
merge: true,
146-
output: this.project.getDefaultPackage().path,
146+
output: this.project.getDefaultPackage().fullPath,
147147
});
148148

149149
this.ux.setSpinnerStatus('Retrieving metadata from the org');

test/nuts/seeds/mpd.retrieve.seed.ts

Lines changed: 45 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8+
import * as path from 'path';
9+
import * as fs from 'fs';
810
import { Dictionary } from '@salesforce/ts-types';
911
import { SourceTestkit } from '@salesforce/source-testkit';
1012

@@ -55,6 +57,23 @@ context('MPD Retrieve NUTs [exec: %EXECUTABLE%]', () => {
5557

5658
let originalState: Dictionary<string>;
5759

60+
const filesAreInOriginalState = async () => {
61+
return Promise.all([
62+
testkit.expect.filesToContainString(myAppLabels, '<fullName>my_app_Label_1</fullName>'),
63+
testkit.expect.filesToNotContainString(forceAppLabels, '<fullName>my_app_Label_1</fullName>'),
64+
testkit.expect.filesToContainString(
65+
forceAppLabels,
66+
'<fullName>force_app_Label_1</fullName>',
67+
'<fullName>force_app_Label_2</fullName>'
68+
),
69+
testkit.expect.filesToNotContainString(
70+
myAppLabels,
71+
'<fullName>force_app_Label_1</fullName>',
72+
'<fullName>force_app_Label_2</fullName>'
73+
),
74+
]);
75+
};
76+
5877
before(async () => {
5978
originalState = await testkit.readGlobs([forceAppLabels, myAppLabels]);
6079
});
@@ -71,12 +90,7 @@ context('MPD Retrieve NUTs [exec: %EXECUTABLE%]', () => {
7190
await testkit.retrieve({ args: '--metadata CustomLabels' });
7291

7392
await testkit.expect.filesToBeChanged([forceAppLabels, myAppLabels]);
74-
await testkit.expect.filesToNotContainString(forceAppLabels, '<fullName>my_app_Label_1</fullName>');
75-
await testkit.expect.filesToNotContainString(
76-
myAppLabels,
77-
'<fullName>force_app_Label_1</fullName>',
78-
'<fullName>force_app_Label_2</fullName>'
79-
);
93+
await filesAreInOriginalState();
8094
});
8195

8296
it('should put new labels into CustomLabels file in default package', async () => {
@@ -93,18 +107,12 @@ context('MPD Retrieve NUTs [exec: %EXECUTABLE%]', () => {
93107
);
94108
});
95109

96-
it('should put new labels into existing CustomLabels file', async () => {
110+
it('should put new labels into default CustomLabels file', async () => {
97111
// Delete local labels to simulate having new labels created in the org
98112
await testkit.deleteGlobs([forceAppLabels]);
99113
await testkit.retrieve({ args: '--metadata CustomLabels' });
100114

101-
await testkit.expect.filesToBeChanged([myAppLabels]);
102-
await testkit.expect.filesToContainString(
103-
myAppLabels,
104-
'<fullName>my_app_Label_1</fullName>',
105-
'<fullName>force_app_Label_1</fullName>',
106-
'<fullName>force_app_Label_2</fullName>'
107-
);
115+
await filesAreInOriginalState();
108116
});
109117

110118
it('should put all labels into default CustomLabels file when no labels exist locally', async () => {
@@ -119,25 +127,16 @@ context('MPD Retrieve NUTs [exec: %EXECUTABLE%]', () => {
119127
'<fullName>force_app_Label_1</fullName>',
120128
'<fullName>force_app_Label_2</fullName>'
121129
);
130+
await testkit.expect.filesToNotExist([myAppLabels]);
122131
});
123132
});
124133

125134
describe('--metadata CustomLabel:force_app_Label_1', () => {
126135
it('should put individual label into appropriate CustomLabels file', async () => {
127136
await testkit.retrieve({ args: '--metadata CustomLabel:force_app_Label_1' });
128137

129-
await testkit.expect.filesToBeChanged([forceAppLabels]);
130138
await testkit.expect.filesToNotBeChanged([myAppLabels]);
131-
await testkit.expect.filesToNotContainString(
132-
forceAppLabels,
133-
'<fullName>my_app_Label_1</fullName>',
134-
'<fullName>force_app_Label_2</fullName>'
135-
);
136-
await testkit.expect.filesToNotContainString(
137-
myAppLabels,
138-
'<fullName>force_app_Label_1</fullName>',
139-
'<fullName>force_app_Label_2</fullName>'
140-
);
139+
await filesAreInOriginalState();
141140
});
142141

143142
it('should put individual label into default CustomLabels file when no labels exist locally', async () => {
@@ -153,20 +152,29 @@ context('MPD Retrieve NUTs [exec: %EXECUTABLE%]', () => {
153152
'<fullName>force_app_Label_2</fullName>'
154153
);
155154
});
155+
156+
it('should put 1 new label into file and still have the OTHER label', async () => {
157+
// remove label2 and then retrieve it. Make sure label
158+
const forceAppLabelFile = path.normalize(path.join(testkit.projectDir, forceAppLabels));
159+
await fs.promises.writeFile(
160+
forceAppLabelFile,
161+
(
162+
await fs.promises.readFile(forceAppLabelFile, 'utf-8')
163+
).replace(/(<labels>\s*<fullName>force_app_Label_2.*<\/labels>)/gs, '')
164+
);
165+
await testkit.retrieve({ args: '--metadata CustomLabel:force_app_Label_2' });
166+
167+
await filesAreInOriginalState();
168+
});
156169
});
157170

158171
describe('--metadata CustomLabel:force_app_Label_1,CustomLabel:my_app_Label_1', () => {
159-
it('should put labels into appropriate CustomLabels file', async () => {
172+
it('should put 2 single labels into 2 CustomLabels files', async () => {
160173
await testkit.modifyLocalGlobs([forceAppLabels, myAppLabels]);
161174
await testkit.retrieve({ args: '--metadata CustomLabel:force_app_Label_1,CustomLabel:my_app_Label_1' });
162175

163176
await testkit.expect.filesToBeChanged([forceAppLabels, myAppLabels]);
164-
await testkit.expect.filesToNotContainString(forceAppLabels, '<fullName>my_app_Label_1</fullName>');
165-
await testkit.expect.filesToNotContainString(
166-
myAppLabels,
167-
'<fullName>force_app_Label_1</fullName>',
168-
'<fullName>force_app_Label_2</fullName>'
169-
);
177+
await filesAreInOriginalState();
170178
});
171179
});
172180

@@ -177,13 +185,7 @@ context('MPD Retrieve NUTs [exec: %EXECUTABLE%]', () => {
177185

178186
await testkit.expect.filesToBeChanged([forceAppLabels]);
179187
await testkit.expect.filesToNotBeChanged([myAppLabels]);
180-
181-
await testkit.expect.filesToNotContainString(forceAppLabels, '<fullName>my_app_Label_1</fullName>');
182-
await testkit.expect.filesToNotContainString(
183-
myAppLabels,
184-
'<fullName>force_app_Label_1</fullName>',
185-
'<fullName>force_app_Label_2</fullName>'
186-
);
188+
await filesAreInOriginalState();
187189
});
188190
});
189191

@@ -194,13 +196,7 @@ context('MPD Retrieve NUTs [exec: %EXECUTABLE%]', () => {
194196

195197
await testkit.expect.filesToBeChanged([myAppLabels]);
196198
await testkit.expect.filesToNotBeChanged([forceAppLabels]);
197-
198-
await testkit.expect.filesToNotContainString(forceAppLabels, '<fullName>my_app_Label_1</fullName>');
199-
await testkit.expect.filesToNotContainString(
200-
myAppLabels,
201-
'<fullName>force_app_Label_1</fullName>',
202-
'<fullName>force_app_Label_2</fullName>'
203-
);
199+
await filesAreInOriginalState();
204200
});
205201
});
206202

@@ -210,12 +206,7 @@ context('MPD Retrieve NUTs [exec: %EXECUTABLE%]', () => {
210206
await testkit.retrieve({ args: '--sourcepath force-app,my-app' });
211207

212208
await testkit.expect.filesToBeChanged([forceAppLabels, myAppLabels]);
213-
await testkit.expect.filesToNotContainString(forceAppLabels, '<fullName>my_app_Label_1</fullName>');
214-
await testkit.expect.filesToNotContainString(
215-
myAppLabels,
216-
'<fullName>force_app_Label_1</fullName>',
217-
'<fullName>force_app_Label_2</fullName>'
218-
);
209+
await filesAreInOriginalState();
219210
});
220211
});
221212

@@ -227,12 +218,7 @@ context('MPD Retrieve NUTs [exec: %EXECUTABLE%]', () => {
227218
await testkit.retrieve({ args: `--manifest ${packageXml}` });
228219

229220
await testkit.expect.filesToBeChanged([forceAppLabels, myAppLabels]);
230-
await testkit.expect.filesToNotContainString(forceAppLabels, '<fullName>my_app_Label_1</fullName>');
231-
await testkit.expect.filesToNotContainString(
232-
myAppLabels,
233-
'<fullName>force_app_Label_1</fullName>',
234-
'<fullName>force_app_Label_2</fullName>'
235-
);
221+
await filesAreInOriginalState();
236222
});
237223
});
238224

@@ -241,8 +227,7 @@ context('MPD Retrieve NUTs [exec: %EXECUTABLE%]', () => {
241227
const xml = '<types><members>force_app_Label_1</members><name>CustomLabel</name></types>';
242228
const packageXml = await testkit.createPackageXml(xml);
243229
await testkit.retrieve({ args: `--manifest ${packageXml}` });
244-
await testkit.expect.filesToContainString(forceAppLabels, '<fullName>force_app_Label_1</fullName>');
245-
await testkit.expect.filesToNotContainString(forceAppLabels, '<fullName>my_app_Label_1</fullName>');
230+
await filesAreInOriginalState();
246231
});
247232
});
248233
});

yarn.lock

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -791,10 +791,10 @@
791791
sfdx-faye "^1.0.9"
792792
ts-retry-promise "^0.6.0"
793793

794-
"@salesforce/core@2.31.0", "@salesforce/core@^2.31.0":
795-
version "2.31.0"
796-
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-2.31.0.tgz#cdeaa9968060afb52f40c12bf5a4f9844a2a1909"
797-
integrity sha512-ROEjX/M0ZHpGlmRfNUoDKsE4ppOZUU5Hcl3XHr2pCO7F505imAmhKg8I+XfGSxXyj4bL/kftkNTK5xFffJ+6mw==
794+
"@salesforce/core@2.33.1", "@salesforce/core@^2.33.1":
795+
version "2.33.1"
796+
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-2.33.1.tgz#23c22953174ad0e809b2f1c7b2881b5ba8a89d9c"
797+
integrity sha512-jKVFYEvlV+loBoau5heBOVXmzsPO+RbYh6SPybJK6xF7khQmzu7+WAQbikY2eY8VaXcded2kka8L/FKuD/LKBg==
798798
dependencies:
799799
"@salesforce/bunyan" "^2.0.0"
800800
"@salesforce/kit" "^1.5.0"
@@ -804,13 +804,13 @@
804804
"@types/jsforce" "^1.9.35"
805805
"@types/mkdirp" "^1.0.1"
806806
debug "^3.1.0"
807+
faye "^1.4.0"
807808
graceful-fs "^4.2.4"
808809
jsen "0.6.6"
809810
jsforce "^1.11.0"
810811
jsonwebtoken "8.5.0"
811812
mkdirp "1.0.4"
812813
semver "^7.3.5"
813-
sfdx-faye "^1.0.9"
814814
ts-retry-promise "^0.6.0"
815815

816816
"@salesforce/core@^2.28.0":
@@ -835,6 +835,28 @@
835835
sfdx-faye "^1.0.9"
836836
ts-retry-promise "^0.6.0"
837837

838+
"@salesforce/core@^2.31.0":
839+
version "2.31.0"
840+
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-2.31.0.tgz#cdeaa9968060afb52f40c12bf5a4f9844a2a1909"
841+
integrity sha512-ROEjX/M0ZHpGlmRfNUoDKsE4ppOZUU5Hcl3XHr2pCO7F505imAmhKg8I+XfGSxXyj4bL/kftkNTK5xFffJ+6mw==
842+
dependencies:
843+
"@salesforce/bunyan" "^2.0.0"
844+
"@salesforce/kit" "^1.5.0"
845+
"@salesforce/schemas" "^1.0.1"
846+
"@salesforce/ts-types" "^1.5.13"
847+
"@types/graceful-fs" "^4.1.5"
848+
"@types/jsforce" "^1.9.35"
849+
"@types/mkdirp" "^1.0.1"
850+
debug "^3.1.0"
851+
graceful-fs "^4.2.4"
852+
jsen "0.6.6"
853+
jsforce "^1.11.0"
854+
jsonwebtoken "8.5.0"
855+
mkdirp "1.0.4"
856+
semver "^7.3.5"
857+
sfdx-faye "^1.0.9"
858+
ts-retry-promise "^0.6.0"
859+
838860
"@salesforce/dev-config@^2.1.2":
839861
version "2.1.2"
840862
resolved "https://registry.npmjs.org/@salesforce/dev-config/-/dev-config-2.1.2.tgz#b4e206f860e87065d068bf8ba3994a032389ad81"
@@ -957,35 +979,19 @@
957979
unzipper "0.10.11"
958980
xmldom-sfdx-encoding "^0.1.29"
959981

960-
"@salesforce/source-deploy-retrieve@^5.8.0":
961-
version "5.8.0"
962-
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-5.8.0.tgz#f9358874d282d6cdd27506819964c037ad1dfee7"
963-
integrity sha512-Z2Wh0guPL0ZEjD2HqNCPT8Gih6FMN85v9xGB+oss5yrrsx8QwD9UBNFivLojeCNduuNRF0BMOwp9mMt7QlpdJA==
964-
dependencies:
965-
"@salesforce/core" "2.31.0"
966-
"@salesforce/kit" "^1.5.0"
967-
"@salesforce/ts-types" "^1.4.2"
968-
archiver "^5.3.0"
969-
fast-xml-parser "^3.17.4"
970-
graceful-fs "^4.2.8"
971-
ignore "^5.1.8"
972-
mime "2.4.6"
973-
unzipper "0.10.11"
974-
xmldom-sfdx-encoding "^0.1.29"
975-
976-
"@salesforce/source-deploy-retrieve@^5.9.1":
977-
version "5.9.1"
978-
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-5.9.1.tgz#aa6d609bb2c2b66ec58fc86b7553bd31c785c17b"
979-
integrity sha512-9E6Z2VBfsKsW3ugWLVb91uy4Lk7lKoueNhuvo35XKcF/msnL2EGFHbK39N2rhvU2Q6p5FxA2EEQkuVEHHeQNGQ==
982+
"@salesforce/source-deploy-retrieve@^5.9.3":
983+
version "5.9.3"
984+
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-5.9.3.tgz#e1da99a0f85b01e31821c681b4196296125892bb"
985+
integrity sha512-kqMI72Wk63Od4HgEiIkkmVBPWizdRdZGu/5ZzWkxphuSZmOgmaFKlIbsR03IR4D5n38bAs7vrSMNZvKp7HwhyQ==
980986
dependencies:
981-
"@salesforce/core" "2.31.0"
987+
"@salesforce/core" "2.33.1"
982988
"@salesforce/kit" "^1.5.0"
983989
"@salesforce/ts-types" "^1.4.2"
984990
archiver "^5.3.0"
985991
fast-xml-parser "^3.17.4"
986992
graceful-fs "^4.2.8"
987993
ignore "^5.1.8"
988-
mime "2.4.6"
994+
mime "2.6.0"
989995
unzipper "0.10.11"
990996
xmldom-sfdx-encoding "^0.1.29"
991997

@@ -1006,14 +1012,14 @@
10061012
sinon "^10.0.0"
10071013
strip-ansi "^6.0.0"
10081014

1009-
"@salesforce/source-tracking@^0.5.1":
1010-
version "0.5.1"
1011-
resolved "https://registry.yarnpkg.com/@salesforce/source-tracking/-/source-tracking-0.5.1.tgz#1be69d4cd5ec51e6a09a863d0a1b15ac8f4af7be"
1012-
integrity sha512-unbwKIwCg/ZwHC5cNjm65oxhkpQBT3Pc5XEwTtRNpgyGhHMuNS74zcZSmABjXrGbQDsYf4TbwC+NMKwvErY3Qg==
1015+
"@salesforce/source-tracking@^1.0.0":
1016+
version "1.0.0"
1017+
resolved "https://registry.yarnpkg.com/@salesforce/source-tracking/-/source-tracking-1.0.0.tgz#577edcf2ad0d4a86b26b0fc007f46d15fa1aec2f"
1018+
integrity sha512-4HmAeD3s8OJGG54jkpv9BLufLcNXpFLbrmjefkRcUpnLBeGlS8L2l0wm/GtRE5LVtxFKD85j6BaciyjVv4TYfA==
10131019
dependencies:
1014-
"@salesforce/core" "^2.31.0"
1020+
"@salesforce/core" "^2.33.1"
10151021
"@salesforce/kit" "^1.5.17"
1016-
"@salesforce/source-deploy-retrieve" "^5.8.0"
1022+
"@salesforce/source-deploy-retrieve" "^5.9.3"
10171023
isomorphic-git "^1.9.2"
10181024
ts-retry-promise "^0.6.0"
10191025

@@ -3364,9 +3370,9 @@ fast-levenshtein@^2.0.6:
33643370
integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=
33653371

33663372
fast-xml-parser@^3.17.4:
3367-
version "3.20.3"
3368-
resolved "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.20.3.tgz#c171425356d4d929efeca4e4f67f24231a31c786"
3369-
integrity sha512-FfHJ/QCpo4K2gquBX7dIAcmShSBG4dMtYJ3ghSiR4w7YqlUujuamrM57C+mKLNWS3mvZzmm2B2Qx8Q6Gfw+lDQ==
3373+
version "3.21.1"
3374+
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-3.21.1.tgz#152a1d51d445380f7046b304672dd55d15c9e736"
3375+
integrity sha512-FTFVjYoBOZTJekiUsawGsSYV9QL0A+zDYCRj7y34IO6Jg+2IMYEtQa+bbictpdpV8dHxXywqU7C0gRDEOFtBFg==
33703376
dependencies:
33713377
strnum "^1.0.4"
33723378

@@ -5527,6 +5533,11 @@ [email protected]:
55275533
resolved "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz#e5b407c90db442f2beb5b162373d07b69affa4d1"
55285534
integrity sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==
55295535

5536+
5537+
version "2.6.0"
5538+
resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367"
5539+
integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==
5540+
55305541
mimic-fn@^1.0.0:
55315542
version "1.2.0"
55325543
resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
@@ -7428,9 +7439,9 @@ [email protected], strip-json-comments@^3.1.0, strip-json-comments@^3.1.
74287439
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
74297440

74307441
strnum@^1.0.4:
7431-
version "1.0.4"
7432-
resolved "https://registry.npmjs.org/strnum/-/strnum-1.0.4.tgz#e97e36a7d6ba9f93d0d6b496b2ed0678d422832b"
7433-
integrity sha512-lMzNMfDpaQOLt4B2mEbfzYS0+T7dvCXeojnlGf6f1AygvWDMcWyXYaLbyICfjVu29sErR8fnRagQfBW/N/hGgw==
7442+
version "1.0.5"
7443+
resolved "https://registry.yarnpkg.com/strnum/-/strnum-1.0.5.tgz#5c4e829fe15ad4ff0d20c3db5ac97b73c9b072db"
7444+
integrity sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==
74347445

74357446
[email protected], supports-color@^8.1.0:
74367447
version "8.1.1"

0 commit comments

Comments
 (0)