Skip to content

Commit 7d58aa0

Browse files
authored
Sm/manifest-api-version (#636)
* fix: mdapi:retrieve respects manifest apiVersion * test: manually modify nut manifest version to assert
1 parent 4a3575a commit 7d58aa0

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/commands/force/mdapi/retrieve.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ export class Retrieve extends SourceCommand {
129129
this.ux.setSpinnerStatus(spinnerMessages.getMessage('retrieve.componentSetBuild'));
130130

131131
this.componentSet = await ComponentSetBuilder.build({
132-
apiversion: this.getFlag<string>('apiversion') ?? (await this.org.retrieveMaxApiVersion()),
132+
// use the apiVersion if provided.
133+
// Manifests default to their specified apiVersion(ComponentSetBuilder handles this)
134+
// and not specifying the apiVersion will use the max for the org/Connection
135+
apiversion: this.getFlag<string>('apiversion'),
133136
packagenames,
134137
sourcepath: this.sourceDir ? [this.sourceDir] : undefined,
135138
manifest: manifest && {

test/nuts/mdapi.nut.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,22 @@ describe('mdapi NUTs', () => {
332332
expect(result.zipFilePath).to.equal(zipFileLocation);
333333
});
334334

335+
it('retrieves content from manifest using manifest api version', async () => {
336+
// modify the manifest to use a different api version
337+
const targetApiVersion = '54.0';
338+
const manifestRelativePath = path.join(session.project.dir, manifestPath);
339+
340+
const original = await fs.promises.readFile(manifestRelativePath, 'utf8');
341+
await fs.promises.writeFile(
342+
manifestRelativePath,
343+
original.replace(/<version>.*<\/version>/g, `<version>${targetApiVersion}</version>`)
344+
);
345+
const retrieveTargetDir = 'mdRetrieveFromManifest';
346+
const cmd = `force:mdapi:retrieve -w 10 -r ${retrieveTargetDir} -k ${manifestPath}`;
347+
const rv = execCmd<RetrieveCommandResult>(cmd, { ensureExitCode: 0 }).shellOutput;
348+
expect(rv.stderr).to.include(targetApiVersion);
349+
});
350+
335351
it('retrieves single package', () => {
336352
const retrieveTargetDir = 'mdRetrieveSinglePackage';
337353
const retrieveTargetDirPath = path.join(session.project.dir, retrieveTargetDir);

0 commit comments

Comments
 (0)