Skip to content

Commit

Permalink
feat: bump @salesforce/core from v7 to v8 (#5665)
Browse files Browse the repository at this point in the history
* feat: migrate @salesforce/core from v7 to v8

* fix: import getDefaultApiVersion() from baseGenerator instead of TemplateService

* chore: bump stuffs

* refactor: check salesforceApiVersion using extensions major release version instead of Templates

* refactor: replace execSync with fs.readFileSync

* test: remove validation of Templates contents

* refactor: use readFileSync instead of execSync in Github Issues Management

---------

Co-authored-by: mingxuanzhang <[email protected]>
  • Loading branch information
daphne-sfdc and mingxuanzhangsfdx authored Jul 2, 2024
1 parent 9ad179b commit e015f74
Show file tree
Hide file tree
Showing 21 changed files with 977 additions and 3,411 deletions.
4 changes: 2 additions & 2 deletions .github/actions/validate-issue/lib/src/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .github/actions/validate-issue/lib/src/index.js.map

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .github/actions/validate-issue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ async function run() {
const currentDirectory = execSync(`pwd`).toString();
// currentDirectory contains a newline at the end
const packageJsonDirectory = currentDirectory.slice(0, -1) + "/packages/salesforcedx-vscode-core/package.json";
const result = execSync(`cat ${packageJsonDirectory}`).toString();
const packageJsonContent = readFileSync(packageJsonDirectory, 'utf8');
// The VSCode version has a carat in front that needs to be removed
return JSON.parse(result).engines.vscode.substring(1);
return JSON.parse(packageJsonContent).engines.vscode.substring(1);
}

function getFile(
Expand Down
4,190 changes: 950 additions & 3,240 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/salesforcedx-sobjects-faux-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"main": "out/src",
"dependencies": {
"@jsforce/jsforce-node": "3.2.0",
"@salesforce/core-bundle": "7.5.0",
"@jsforce/jsforce-node": "3.2.2",
"@salesforce/core-bundle": "8.1.0",
"@salesforce/salesforcedx-utils-vscode": "61.3.0",
"shelljs": "0.8.5"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/salesforcedx-utils-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
],
"main": "out/src",
"dependencies": {
"@salesforce/core-bundle": "7.5.0",
"@salesforce/source-deploy-retrieve-bundle": "11.6.10",
"@salesforce/source-tracking-bundle": "6.5.1",
"@salesforce/core-bundle": "8.1.0",
"@salesforce/source-deploy-retrieve-bundle": "12.1.4",
"@salesforce/source-tracking-bundle": "7.0.4",
"applicationinsights": "1.0.7",
"cross-spawn": "7.0.3",
"rxjs": "^5.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"Debuggers"
],
"dependencies": {
"@salesforce/apex-node-bundle": "6.1.3",
"@salesforce/core-bundle": "7.5.0",
"@salesforce/apex-node-bundle": "7.0.2",
"@salesforce/core-bundle": "8.1.0",
"@salesforce/salesforcedx-apex-replay-debugger": "61.3.0",
"@salesforce/salesforcedx-utils": "61.3.0",
"@salesforce/salesforcedx-utils-vscode": "61.3.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/salesforcedx-vscode-apex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"Programming Languages"
],
"dependencies": {
"@salesforce/apex-node-bundle": "6.1.3",
"@salesforce/apex-node-bundle": "7.0.2",
"@salesforce/apex-tmlanguage": "1.8.0",
"@salesforce/core-bundle": "7.5.0",
"@salesforce/core-bundle": "8.1.0",
"@salesforce/salesforcedx-utils-vscode": "61.3.0",
"expand-home-dir": "0.0.3",
"find-java-home": "0.2.0",
Expand Down
14 changes: 7 additions & 7 deletions packages/salesforcedx-vscode-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
"Other"
],
"dependencies": {
"@jsforce/jsforce-node": "3.2.0",
"@salesforce/core-bundle": "7.5.0",
"@jsforce/jsforce-node": "3.2.2",
"@salesforce/core-bundle": "8.1.0",
"@salesforce/salesforcedx-sobjects-faux-generator": "61.3.0",
"@salesforce/salesforcedx-utils-vscode": "61.3.0",
"@salesforce/schemas": "^1.6.1",
"@salesforce/source-deploy-retrieve-bundle": "11.6.10",
"@salesforce/templates-bundle": "61.0.1",
"@salesforce/ts-types": "2.0.9",
"@salesforce/schemas": "1.9.0",
"@salesforce/source-deploy-retrieve-bundle": "12.1.4",
"@salesforce/templates-bundle": "61.2.0",
"@salesforce/ts-types": "2.0.10",
"@salesforce/vscode-service-provider": "1.0.4",
"adm-zip": "0.5.10",
"applicationinsights": "1.0.7",
Expand Down Expand Up @@ -100,7 +100,7 @@
"dependencies": {
"applicationinsights": "1.0.7",
"shelljs": "0.8.5",
"@salesforce/templates-bundle": "61.0.1"
"@salesforce/templates-bundle": "61.2.0"
},
"devDependencies": {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { ConfigUtil } from '@salesforce/salesforcedx-utils-vscode';
import { TemplateService } from '@salesforce/templates-bundle';
import { nls as templatesNls } from '@salesforce/templates-bundle/lib/i18n';
import * as path from 'path';
import * as shell from 'shelljs';
Expand Down Expand Up @@ -81,20 +80,7 @@ describe('Apex Generate Class', () => {
await apexGenerateClass();

// assert
const defaultApiVersion = TemplateService.getDefaultApiVersion();
assert.file([apexClassPath, apexClassMetaPath]);
assert.fileContent(
apexClassPath,
'public with sharing class TestApexClass'
);
assert.fileContent(
apexClassMetaPath,
`<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>${defaultApiVersion}</apiVersion>
<status>Active</status>
</ApexClass>`
);
sinon.assert.calledOnce(openTextDocumentStub);
sinon.assert.calledWith(openTextDocumentStub, apexClassPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { TemplateService } from '@salesforce/templates-bundle';
import * as path from 'path';
import * as shell from 'shelljs';
import { SinonStub, stub } from 'sinon';
Expand Down Expand Up @@ -67,21 +66,6 @@ describe('Apex Generate Trigger', () => {
await apexGenerateTrigger();

// assert
const defaultApiVersion = TemplateService.getDefaultApiVersion();
assert.file([apexTriggerPath, apexTriggerMetaPath]);
assert.fileContent(
apexTriggerPath,
`trigger TestApexTrigger on SOBJECT (before insert) {
}`
);
assert.fileContent(
apexTriggerMetaPath,
`<?xml version='1.0' encoding='UTF-8'?>
<ApexTrigger xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>${defaultApiVersion}</apiVersion>
<status>Active</status>
</ApexTrigger>`
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { ConfigUtil } from '@salesforce/salesforcedx-utils-vscode';
import { TemplateService } from '@salesforce/templates-bundle';
import { nls as templatesNls } from '@salesforce/templates-bundle/lib/i18n';
import * as path from 'path';
import * as shell from 'shelljs';
Expand Down Expand Up @@ -93,20 +92,7 @@ describe('Custom Templates Create', () => {
await apexGenerateClass();

// assert
const defaultApiVersion = TemplateService.getDefaultApiVersion();
assert.file([apexClassPath, apexClassMetaPath]);
assert.fileContent(
apexClassPath,
'public with sharing class CustomTestApexClass'
);
assert.fileContent(
apexClassMetaPath,
`<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>${defaultApiVersion}</apiVersion>
<status>Inactive</status>
</ApexClass>`
);
sinon.assert.calledOnce(openTextDocumentStub);
sinon.assert.calledWith(openTextDocumentStub, apexClassPath);

Expand Down Expand Up @@ -248,23 +234,7 @@ describe('Custom Templates Create', () => {
await lightningGenerateLwc();

// assert
const defaultApiVersion = TemplateService.getDefaultApiVersion();
assert.file([lwcHtmlPath, lwcJsPath, lwcJsMetaPath]);
assert.fileContent(lwcHtmlPath, '<template>\n \n</template>');
assert.fileContent(
lwcJsPath,
`import { LightningElement } from 'lwc';
export default class TestLwc extends LightningElement {}`
);
assert.fileContent(
lwcJsMetaPath,
`<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>${defaultApiVersion}</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>`
);
sinon.assert.calledOnce(openTextDocumentStub);
sinon.assert.calledWith(openTextDocumentStub, lwcJsPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* 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 { TemplateService } from '@salesforce/templates-bundle';
import * as path from 'path';
import * as shell from 'shelljs';
import { SinonStub, stub } from 'sinon';
Expand Down Expand Up @@ -86,20 +85,7 @@ describe('Lightning Generate Event', () => {
await lightningGenerateEvent();

// assert
const defaultApiVersion = TemplateService.getDefaultApiVersion();
assert.file([auraEventPath, auraEventMetaPath]);
assert.fileContent(
auraEventPath,
'<aura:event type="APPLICATION" description="Event template"/>'
);
assert.fileContent(
auraEventMetaPath,
`<?xml version="1.0" encoding="UTF-8"?>
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>${defaultApiVersion}</apiVersion>
<description>A Lightning Event Bundle</description>
</AuraDefinitionBundle>`
);
sinon.assert.calledOnce(openTextDocumentStub);
sinon.assert.calledWith(openTextDocumentStub, auraEventPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* 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 { TemplateService } from '@salesforce/templates-bundle';
import * as path from 'path';
import * as shell from 'shelljs';
import * as sinon from 'sinon';
Expand Down Expand Up @@ -86,22 +85,7 @@ describe('Lightning Generate Interface', () => {
await lightningGenerateInterface();

// assert
const defaultApiVersion = TemplateService.getDefaultApiVersion();
assert.file([auraInterfacePath, auraInterfaceMetaPath]);
assert.fileContent(
auraInterfacePath,
`<aura:interface description="Interface template">
<aura:attribute name="example" type="String" default="" description="An example attribute."/>
</aura:interface>`
);
assert.fileContent(
auraInterfaceMetaPath,
`<?xml version="1.0" encoding="UTF-8"?>
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>${defaultApiVersion}</apiVersion>
<description>A Lightning Interface Bundle</description>
</AuraDefinitionBundle>`
);
sinon.assert.calledOnce(openTextDocumentStub);
sinon.assert.calledWith(openTextDocumentStub, auraInterfacePath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* 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 { TemplateService } from '@salesforce/templates-bundle';
import * as path from 'path';
import * as shell from 'shelljs';
import * as sinon from 'sinon';
Expand Down Expand Up @@ -92,23 +91,7 @@ describe('Generate Lightning Web Component', () => {
await lightningGenerateLwc();

// assert
const defaultApiVersion = TemplateService.getDefaultApiVersion();
assert.file([lwcHtmlPath, lwcJsPath, lwcJsMetaPath]);
assert.fileContent(lwcHtmlPath, '<template>\n \n</template>');
assert.fileContent(
lwcJsPath,
`import { LightningElement } from 'lwc';
export default class TestLwc extends LightningElement {}`
);
assert.fileContent(
lwcJsMetaPath,
`<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>${defaultApiVersion}</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>`
);
sinon.assert.calledOnce(openTextDocumentStub);
sinon.assert.calledWith(openTextDocumentStub, lwcJsPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* 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 { TemplateService } from '@salesforce/templates-bundle';
import * as path from 'path';
import * as shell from 'shelljs';
import * as sinon from 'sinon';
Expand Down Expand Up @@ -73,25 +72,7 @@ describe('Visualforce Generate Component', () => {
await visualforceGenerateComponent();

// assert
const defaultApiVersion = TemplateService.getDefaultApiVersion();
assert.file([vfCmpPath, vfCmpMetaPath]);
assert.fileContent(
vfCmpPath,
`<apex:component>
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Component
<!-- End Default Content REMOVE THIS -->
</apex:component>`
);
assert.fileContent(
vfCmpMetaPath,
`<?xml version="1.0" encoding="UTF-8"?>
<ApexComponent xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>${defaultApiVersion}</apiVersion>
<label>testVFCmp</label>
</ApexComponent>`
);
sinon.assert.calledOnce(openTextDocumentStub);
sinon.assert.calledWith(openTextDocumentStub, vfCmpPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* 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 { TemplateService } from '@salesforce/templates-bundle';
import * as path from 'path';
import * as shell from 'shelljs';
import * as sinon from 'sinon';
Expand Down Expand Up @@ -71,24 +70,7 @@ describe('Visualforce Generate Page', () => {
await visualforceGeneratePage();

// assert
const defaultApiVersion = TemplateService.getDefaultApiVersion();
assert.file([vfPagePath, vfPageMetaPath]);
assert.fileContent(
vfPagePath,
`<apex:page>
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations</h1>
This is your new Page
<!-- End Default Content REMOVE THIS -->
</apex:page>`
);
assert.fileContent(
vfPageMetaPath,
`<?xml version="1.0" encoding="UTF-8"?>
<ApexPage xmlns="http://soap.sforce.com/2006/04/metadata"> \n <apiVersion>${defaultApiVersion}</apiVersion>
<label>testVFPage</label>
</ApexPage>`
);
sinon.assert.calledOnce(openTextDocumentStub);
sinon.assert.calledWith(openTextDocumentStub, vfPagePath);

Expand Down
2 changes: 1 addition & 1 deletion packages/salesforcedx-vscode-lightning/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"dependencies": {
"@salesforce/aura-language-server": "4.8.0",
"@salesforce/core-bundle": "7.5.0",
"@salesforce/core-bundle": "8.1.0",
"@salesforce/lightning-lsp-common": "4.8.0",
"@salesforce/salesforcedx-utils-vscode": "61.3.0",
"applicationinsights": "1.0.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/salesforcedx-vscode-lwc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"Programming Languages"
],
"dependencies": {
"@salesforce/core-bundle": "7.5.0",
"@salesforce/core-bundle": "8.1.0",
"@salesforce/eslint-config-lwc": "3.5.1",
"@salesforce/lightning-lsp-common": "4.8.0",
"@salesforce/lwc-language-server": "4.8.0",
Expand Down
Loading

0 comments on commit e015f74

Please sign in to comment.