From 9501de5c67323d9f2bec60dcda223af312ffadc8 Mon Sep 17 00:00:00 2001 From: Alan Jaouen <14994179+alanjaouen@users.noreply.github.com> Date: Mon, 29 Jul 2024 09:12:56 +0000 Subject: [PATCH 1/2] feat(generateScratchOrgInfo): allow shema key --- src/org/scratchOrgInfoGenerator.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/org/scratchOrgInfoGenerator.ts b/src/org/scratchOrgInfoGenerator.ts index c4a7ef505..392147e23 100644 --- a/src/org/scratchOrgInfoGenerator.ts +++ b/src/org/scratchOrgInfoGenerator.ts @@ -322,6 +322,8 @@ const parseDefinitionFile = async (definitionFile: string): Promise; + // remove key '$schema' from the definition file + delete defFileContents['$schema']; return defFileContents; } catch (err) { const error = err as Error; From 4a5fdd9b075caf54b27849abb9403dbcd8a83634 Mon Sep 17 00:00:00 2001 From: Alan Jaouen Date: Thu, 8 Aug 2024 00:29:39 +0200 Subject: [PATCH 2/2] test(generateScratchOrgInfo): add unit test on $schema key removal from ScratchOrgInfo json --- test/unit/org/scratchOrgInfoGenerator.test.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/unit/org/scratchOrgInfoGenerator.test.ts b/test/unit/org/scratchOrgInfoGenerator.test.ts index 784c1d6fc..f3f7dfcef 100644 --- a/test/unit/org/scratchOrgInfoGenerator.test.ts +++ b/test/unit/org/scratchOrgInfoGenerator.test.ts @@ -1026,5 +1026,25 @@ describe('scratchOrgInfoGenerator', () => { expect(err).to.exist; } }); + it('Remove $schema key if it exist', async () => { + sandbox.restore(); + stubMethod(sandbox, fs.promises, 'readFile') + .withArgs('./my-file.json', 'utf8') + .resolves( + '{ "$schema": "https://forcedotcom.github.io/schemas/project-scratch-def.json/project-scratch-def.schema.json" }' + ); + expect( + await getScratchOrgInfoPayload({ + durationDays: 1, + definitionfile: './my-file.json', + }) + ).to.deep.equal({ + scratchOrgInfoPayload: { + durationDays: 1, + }, + ignoreAncestorIds: false, + warnings: [], + }); + }); }); });