From 8079b846fc854544e5764ae164bc1de88bca5887 Mon Sep 17 00:00:00 2001 From: pulkit0555 Date: Fri, 22 Nov 2024 23:00:42 +0530 Subject: [PATCH 1/3] fix: download site bundle correctly if site name has special chars (#262) * fix: updated special chars in site name * fix: minor fix * fix: refactored code * chore: change test naming --------- Co-authored-by: Nicolas Kruk Co-authored-by: Nicolas Kruk --- src/shared/experience/expSite.ts | 2 ++ test/spec/expSite.test.ts | 49 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/spec/expSite.test.ts diff --git a/src/shared/experience/expSite.ts b/src/shared/experience/expSite.ts index 233dc7bc..ab78c734 100644 --- a/src/shared/experience/expSite.ts +++ b/src/shared/experience/expSite.ts @@ -37,6 +37,8 @@ export class ExperienceSite { this.org = org; this.siteDisplayName = siteName.trim(); this.siteName = this.siteDisplayName.replace(' ', '_'); + // Replace any special characters in site name with underscore + this.siteName = this.siteName.replace(/[^a-zA-Z0-9]/g, '_'); } /** diff --git a/test/spec/expSite.test.ts b/test/spec/expSite.test.ts new file mode 100644 index 00000000..f29d3aae --- /dev/null +++ b/test/spec/expSite.test.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023, salesforce.com, inc. + * All rights reserved. + * Licensed under the BSD 3-Clause license. + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause + */ +import { expect } from 'chai'; +import { Connection, Org } from '@salesforce/core'; +import sinon from 'sinon'; +import { ExperienceSite } from '../../src/shared/experience/expSite.js'; + +describe('getRemoteMetadata', () => { + it('should return remote metadata when it exists', async () => { + const org = new Org(); + const siteName = 'site@with#special-chars'; + const experienceSite = new ExperienceSite(org, siteName); + + // Create a mock Connection instance using sinon + const mockConnection = sinon.createStubInstance(Connection); + + // Configure the mock to return the desired result when calling query + mockConnection.query.resolves({ + done: true, + totalSize: 1, + records: [ + { + Name: 'MRT_experience_00DSG00000ECBfZ_0DMSG000001CfA6_site_with_special_chars_10-30_12-47', + LastModifiedDate: '2024-11-12', + }, + ], + }); + + // Replace the original connection with the mocked connection + org.getConnection = () => mockConnection; + + const remoteMetadata = await experienceSite.getRemoteMetadata(); + + // Check if the called query matches the expected pattern + const calledQuery = mockConnection.query.args[0][0]; + const expectedPattern = + /SELECT Name, LastModifiedDate FROM StaticResource WHERE Name LIKE 'MRT_experience_%_site_with_special_chars/; + expect(calledQuery).to.match(expectedPattern); + + expect(remoteMetadata).to.deep.equal({ + bundleName: 'MRT_experience_00DSG00000ECBfZ_0DMSG000001CfA6_site_with_special_chars_10-30_12-47', + bundleLastModified: '2024-11-12', + }); + }); +}); From 0b3d6d2163a4c9cb2763a8149d05342038164be5 Mon Sep 17 00:00:00 2001 From: "pulkit.jain" Date: Mon, 25 Nov 2024 22:27:08 +0530 Subject: [PATCH 2/3] fix: added yarn version 1 --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4f097748..9e1fbb76 100644 --- a/package.json +++ b/package.json @@ -219,6 +219,7 @@ "exports": "./lib/index.js", "type": "module", "volta": { - "node": "20.11.0" + "node": "20.11.0", + "yarn": "1.22.22" } } From 58024a487c9962b05f81e6f64222c62d17b27ef0 Mon Sep 17 00:00:00 2001 From: svc-cli-bot Date: Wed, 4 Dec 2024 09:48:06 +0000 Subject: [PATCH 3/3] chore(release): 1.9.5-test.0 [skip ci] --- README.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2be6f127..36195b72 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,7 @@ EXAMPLES $ sf lightning dev app --target-org myOrg --device-type ios --device-id "iPhone 15 Pro Max" ``` -_See code: [src/commands/lightning/dev/app.ts](https://github.com/salesforcecli/plugin-lightning-dev/blob/1.9.4/src/commands/lightning/dev/app.ts)_ +_See code: [src/commands/lightning/dev/app.ts](https://github.com/salesforcecli/plugin-lightning-dev/blob/1.9.5-test.0/src/commands/lightning/dev/app.ts)_ ## `sf lightning dev site` @@ -244,6 +244,6 @@ EXAMPLES $ sf lightning dev site --name "Partner Central" --target-org myOrg ``` -_See code: [src/commands/lightning/dev/site.ts](https://github.com/salesforcecli/plugin-lightning-dev/blob/1.9.4/src/commands/lightning/dev/site.ts)_ +_See code: [src/commands/lightning/dev/site.ts](https://github.com/salesforcecli/plugin-lightning-dev/blob/1.9.5-test.0/src/commands/lightning/dev/site.ts)_ diff --git a/package.json b/package.json index 529e2682..f46116fd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@salesforce/plugin-lightning-dev", "description": "Lightning development tools for LEX, Mobile, and Experience Sites", - "version": "1.9.4", + "version": "1.9.5-test.0", "author": "Salesforce", "bugs": "https://github.com/forcedotcom/cli/issues", "dependencies": {