Skip to content

Commit 6828911

Browse files
remove tie to lwc-dev-mobile-core and sf-plugins-core (#185)
* remove tie to lwc-dev-mobile-core and sf-plugins-core * address pr comments
1 parent ac00ce6 commit 6828911

File tree

10 files changed

+1222
-3424
lines changed

10 files changed

+1222
-3424
lines changed

package-lock.json

Lines changed: 1146 additions & 3410 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,19 @@
108108
"@babel/core": "^7.26.0",
109109
"@babel/preset-env": "^7.27.2",
110110
"@istanbuljs/nyc-config-typescript": "^1.0.2",
111+
"@jsforce/jsforce-node": "^3.9.1",
111112
"@types/babel__traverse": "7.20.7",
112113
"@types/babel-core": "6.25.10",
113114
"@types/cli-progress": "^3.11.6",
114115
"@types/inquirer": "^9.0.8",
115116
"@types/mocha": "^10.0.9",
116-
"@types/node": "^22.8.6",
117+
"@types/node": "22.16.3",
118+
"@types/semver": "^7.7.0",
117119
"@types/sinon": "^17.0.3",
118120
"@types/vscode": "1.77.0",
119121
"@types/yaml": "^1.9.7",
120-
"@typescript-eslint/eslint-plugin": "^8.35.0",
121-
"@typescript-eslint/parser": "^8.12.2",
122+
"@typescript-eslint/eslint-plugin": "^8.36.0",
123+
"@typescript-eslint/parser": "^8.36.0",
122124
"@vscode/l10n-dev": "^0.0.35",
123125
"@vscode/test-electron": "^2.5.2",
124126
"@vscode/vsce": "^3.5.0",
@@ -140,9 +142,7 @@
140142
"@babel/traverse": "^7.27.4",
141143
"@graphql-tools/graphql-tag-pluck": "^8.3.19",
142144
"@graphql-tools/utils": "^10.5.4",
143-
"@salesforce/core": "^5.3.12",
144-
"@salesforce/lwc-dev-mobile-core": "^3.3.1",
145-
"@salesforce/sf-plugins-core": "^12.2.2",
145+
"@salesforce/core": "^8.18.1",
146146
"@vscode/l10n": "^0.0.18",
147147
"graphql-tag": "^2.12.6",
148148
"vscode-html-languageservice": "^5.5.0",

src/commands/wizard/briefcaseCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import { ProgressLocation, Uri, window, l10n } from 'vscode';
9-
import { CommonUtils } from '@salesforce/lwc-dev-mobile-core/lib/common/CommonUtils';
9+
import { CommonUtils } from '../../utils/commonUtils';
1010
import { InstructionsWebviewProvider } from '../../webviews/instructions';
1111

1212
export class BriefcaseCommand {

src/commands/wizard/configureProjectCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { Uri, WebviewPanel, commands, l10n, window } from 'vscode';
99
import * as process from 'process';
10-
import { CommonUtils } from '@salesforce/lwc-dev-mobile-core/lib/common/CommonUtils';
10+
import { CommonUtils } from '../../utils/commonUtils';
1111
import { InstructionsWebviewProvider } from '../../webviews/instructions';
1212
import { wizardCommand } from './onboardingWizard';
1313
import { CoreExtensionService } from '../../services/CoreExtensionService';

src/commands/wizard/lwcGenerationCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { access } from 'fs/promises';
1010
import { InstructionsWebviewProvider } from '../../webviews/instructions';
1111
import { UEMParser } from '../../utils/uemParser';
1212
import { WorkspaceUtils } from '../../utils/workspaceUtils';
13-
import { CommonUtils } from '@salesforce/lwc-dev-mobile-core';
13+
import { CommonUtils } from '../../utils/commonUtils';
1414
import { OrgUtils } from '../../utils/orgUtils';
1515
import * as fs from 'fs';
1616
import { CodeBuilder } from '../../utils/codeBuilder';
@@ -115,7 +115,7 @@ export class LwcGenerationCommand {
115115
try {
116116
await access(landingPagePath);
117117
const uem = CommonUtils.loadJsonFromFile(landingPagePath);
118-
getSObjectsStatus.sobjects = UEMParser.findSObjects(uem);
118+
getSObjectsStatus.sobjects = UEMParser.findSObjects(uem as any);
119119
resolve(getSObjectsStatus);
120120
} catch (err) {
121121
console.warn(

src/lsp/server/utils/gqlUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ export function generateEntityTree(rootASTNode: ASTNode): RootNode {
161161
let parentEntity = undefined;
162162
try {
163163
parentEntity = resolveEntityNodeForProperty(ancestors);
164-
} catch (e) {}
164+
} catch (e) {
165+
/* empty */
166+
}
165167
if (parentEntity === undefined) {
166168
return;
167169
}

src/utils/commonUtils.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2021, salesforce.com, inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: MIT
5+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6+
*/
7+
import * as childProcess from 'node:child_process';
8+
import { Logger } from '@salesforce/core';
9+
import { AnyJson } from '@salesforce/ts-types';
10+
import * as fs from 'fs';
11+
12+
export class CommonUtils {
13+
/**
14+
* Given the path to a JSON file, it will load the content of the file.
15+
*
16+
* @param file The path to the JSON file.
17+
* @returns Content of the file as JSON object.
18+
*/
19+
public static loadJsonFromFile(file: string): AnyJson {
20+
const fileContent = fs.readFileSync(file, 'utf8');
21+
const json = JSON.parse(fileContent) as AnyJson;
22+
return json;
23+
}
24+
25+
/**
26+
* Execute a command asynchronously using child_process.exec()
27+
*
28+
* @param command The command to be executed.
29+
* @returns A promise containing the results of stdout and stderr
30+
*/
31+
public static async executeCommandAsync(
32+
command: string,
33+
logger?: Logger
34+
): Promise<{ stdout: string; stderr: string }> {
35+
return new Promise<{ stdout: string; stderr: string }>(
36+
(resolve, reject) => {
37+
logger?.debug(`Executing command: '${command}'`);
38+
childProcess.exec(command, (error, stdout, stderr) => {
39+
if (error) {
40+
logger?.error(`Error executing command '${command}':`);
41+
42+
// also include stderr & stdout for more detailed error
43+
let msg = error.message;
44+
if (stderr && stderr.length > 0) {
45+
msg = `${msg}\nstderr:\n${stderr}`;
46+
}
47+
if (stdout && stdout.length > 0) {
48+
msg = `${msg}\nstdout:\n${stdout}`;
49+
}
50+
51+
logger?.error(msg);
52+
reject(error);
53+
} else {
54+
resolve({ stdout, stderr });
55+
}
56+
});
57+
}
58+
);
59+
}
60+
}

test/suite/commands/wizard/briefcaseCommand.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import * as sinon from 'sinon';
1010
import { afterEach, beforeEach } from 'mocha';
1111
import { BriefcaseCommand } from '../../../../src/commands/wizard/briefcaseCommand';
1212
import { Uri, l10n, window, Progress, CancellationToken } from 'vscode';
13-
import { CommonUtils } from '@salesforce/lwc-dev-mobile-core/lib/common/CommonUtils';
13+
import { CommonUtils } from '../../../../src/utils/commonUtils';
1414
import { InstructionsWebviewProvider } from '../../../../src/webviews/instructions';
1515

1616
suite('Briefcase Command Test Suite', () => {

test/suite/commands/wizard/configureProjectCommand.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { writeFile } from 'fs/promises';
1010
import { afterEach, beforeEach } from 'mocha';
1111
import * as path from 'path';
1212
import * as process from 'process';
13-
import { CommonUtils } from '@salesforce/lwc-dev-mobile-core/lib/common/CommonUtils';
13+
import { CommonUtils } from '../../../../src/utils/commonUtils';
1414
import * as sinon from 'sinon';
1515
import { l10n, Uri, window } from 'vscode';
1616
import {

test/suite/utils/orgUtils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
DescribeGlobalResult,
2020
DescribeSObjectResult,
2121
Field as FieldType
22-
} from 'jsforce';
22+
} from '@jsforce/jsforce-node';
2323
import { CoreExtensionService } from '../../../src/services';
2424

2525
suite('Org Utils Test Suite', () => {

0 commit comments

Comments
 (0)