Skip to content

Commit 457d488

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent e69ec9e commit 457d488

14 files changed

+478
-240
lines changed

.vscode/launch.json

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,32 @@
55
{
66
"version": "0.2.0",
77
"configurations": [
8+
{
9+
"name": "Attach",
10+
"port": 6009,
11+
"request": "attach",
12+
"skipFiles": [
13+
"<node_internals>/**"
14+
],
15+
"type": "node"
16+
},
817
{
918
"name": "Debug: vscode-extension",
1019
"type": "extensionHost",
1120
"request": "launch",
1221
"runtimeExecutable": "${execPath}",
1322
"args": [
1423
"--disable-extensions",
24+
"--verbose",
1525
"--extensionDevelopmentPath=${workspaceFolder}/packages/vscode-extension"
1626
],
1727
"outFiles": ["${workspaceFolder}/packages/vscode-extension/out/**/*.js"],
1828
"pauseForSourceMap": true,
19-
"skipFiles": ["<node_internals>/**/*.js", "async_hooks.js", "inspector_async_hook.js"],
29+
"skipFiles": ["<node_internals>/**/*", "async_hooks.js", "inspector_async_hook.js"],
2030
"preLaunchTask": "build-extension",
2131
"smartStep": true,
22-
"sourceMaps": true
32+
"sourceMaps": true,
33+
"autoAttachChildProcesses": true
2334
},
2435
{
2536
"type": "node",
@@ -32,6 +43,52 @@
3243
"smartStep": true,
3344
"sourceMaps": true
3445
},
46+
{
47+
"type": "node",
48+
"request": "launch",
49+
"showAsyncStacks": true,
50+
"program": "${workspaceRoot}/packages/cli/lib/index.js",
51+
"name": "Debug: CLI-impacted-tests (node)",
52+
"args": [
53+
"impacted-tests",
54+
"../kpn/kpn_esmee/src/core/classes/dataAccess/SObjectRepository.cls",
55+
"--sources", "../kpn/kpn_esmee/src",
56+
"--depth", "3"
57+
],
58+
"outFiles": [
59+
"${workspaceFolder}/packages/vlocity-deploy/lib/**/*.js",
60+
"${workspaceFolder}/packages/salesforce/lib/**/*.js",
61+
"${workspaceFolder}/packages/core/lib/**/*.js",
62+
"${workspaceFolder}/packages/util/lib/**/*.js",
63+
"${workspaceFolder}/packages/cli/lib/**/*.js",
64+
"${workspaceFolder}/packages/apex/lib/**/*.js"
65+
],
66+
"preLaunchTask": "watch-cli",
67+
"smartStep": true,
68+
"sourceMaps": true
69+
},
70+
{
71+
"type": "node",
72+
"request": "launch",
73+
"showAsyncStacks": true,
74+
"program": "${workspaceRoot}/packages/cli/lib/index.js",
75+
"name": "Debug: CLI-convert (node)",
76+
"args": [
77+
"convert",
78+
"../vlocode/.test-deploy/activationError/OmniScript",
79+
"-u", "peter@curlybracket.l.dnd "
80+
],
81+
"outFiles": [
82+
"${workspaceFolder}/packages/vlocity-deploy/lib/**/*.js",
83+
"${workspaceFolder}/packages/salesforce/lib/**/*.js",
84+
"${workspaceFolder}/packages/core/lib/**/*.js",
85+
"${workspaceFolder}/packages/util/lib/**/*.js",
86+
"${workspaceFolder}/packages/cli/lib/**/*.js"
87+
],
88+
"preLaunchTask": "watch-cli",
89+
"smartStep": true,
90+
"sourceMaps": true
91+
},
3592
{
3693
"type": "node",
3794
"request": "launch",

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
"typescript.tsdk": "node_modules\\typescript\\lib",
1111
"cSpell.words": ["Frontdoor", "jsforce", "SOQL", "Visualforce", "vlocode"],
1212
"cSpell.enabled": true,
13-
"eslint.packageManager": "pnpm"
13+
"vlocity.sfdxUsername": "peter.van.gulik@ses.com.prod.devpeter",
14+
"vlocity.salesforce.apiVersion": "63.0",
1415
}

jest.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@ module.exports = {
1515
],
1616
transform: {
1717
'^.+\\.ts$': ['ts-jest', { isolatedModules: true, esModuleInterop: true }]
18-
}
18+
},
19+
transformIgnorePatterns: [
20+
"/node_modules/"
21+
]
1922
};

packages/cli/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"chalk": "^4.1.1",
6666
"commander": "^11.1.0",
6767
"esbuild-loader": "^4.0.3",
68-
"glob": "^11",
6968
"jest": "^29.7.0",
7069
"js-yaml": "^4.1.0",
7170
"log-symbols": "^4.0.0",

packages/core/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@
5252
"dependencies": {
5353
"@vlocode/util": "workspace:*",
5454
"chalk": "^4.1.1",
55-
"glob": "^11",
56-
"globby": "^11.0.4",
55+
"fast-glob": "^3.3.3",
5756
"luxon": "^3.4.4",
58-
"memfs": "^3.2.2",
57+
"memfs": "^4.17.0",
5958
"minimatch": "^9.0.3",
6059
"reflect-metadata": "^0.1.13",
6160
"unique-names-generator": "^4.6.0"

packages/core/src/fs/fileSystem.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { spreadAsync } from '@vlocode/util';
22
import * as fs from 'fs'
3-
import { globbyStream, Options as GlobbyOptions } from 'globby';
3+
import fg, { FileSystemAdapter } from 'fast-glob';
4+
import path from 'path';
45

56
export interface StatsOptions {
67
/**
@@ -166,7 +167,7 @@ export abstract class FileSystem {
166167

167168
/**
168169
* Find files and or folders matching the specified glob pattern as an async iterable. If the result is not iterated completely, the search is stopped.
169-
* When you need the results as an array, use the `Iterable.spreadAsync` method to convert the async interable into an array.
170+
* When you need the results as an array, use the `Iterable.spreadAsync` method to convert the async iterable into an array.
170171
*
171172
* By default the current working directory is used as the base directory for the search.
172173
*
@@ -187,36 +188,36 @@ export abstract class FileSystem {
187188
* ```
188189
*/
189190
public async *find(patterns: GlobPatterns, options?: FindOptions): AsyncGenerator<string> {
190-
const globs = (options?.cwd && Array.isArray(options.cwd) ? options.cwd : [ options?.cwd ]).map(
191-
(cwd: string | undefined) => globbyStream(patterns, {
192-
cwd,
193-
fs: this.globbyFs?.() ?? fs,
194-
ignore: options?.exclude ? Array.isArray(options?.exclude) ? options.exclude : [ options?.exclude ] : undefined,
191+
const cwdList = options?.cwd && Array.isArray(options.cwd) ? options.cwd : [ options?.cwd ];
192+
let limit = options?.limit;
193+
for (const cwd of cwdList) {
194+
// Ensure cwd is string or undefined
195+
const cwdStr = typeof cwd === 'string' ? cwd : undefined;
196+
const stream = fg.stream(patterns, {
197+
cwd: cwdStr,
198+
fs: this.globFs?.() ?? fs,
199+
ignore: options?.exclude ? (Array.isArray(options.exclude) ? options.exclude : [ options.exclude ]) : undefined,
195200
onlyDirectories: options?.findType === FindType.directory,
196201
onlyFiles: options?.findType === FindType.file,
197202
deep: options?.depth,
198-
unique: true,
199-
absolute: true,
200-
})
201-
);
202-
203-
let limit = options?.limit;
204-
205-
for (const glob of globs) {
206-
for await (const file of glob) {
203+
caseSensitiveMatch: options?.noCase === false,
204+
absolute: false,
205+
unique: true
206+
});
207+
for await (const file of stream) {
207208
if (typeof file !== 'string') {
208209
continue;
209210
}
210-
yield this.normalizeSeparators(file);
211+
yield cwdStr ? path.posix.join(cwdStr, file) : file;
211212
if (limit !== undefined && --limit === 0) {
212213
return;
213214
}
214215
}
215216
}
216217
}
217218

218-
private normalizeSeparators(path: string): string {
219-
// Normalize windows path separator to posix for globby
219+
private normalizePath(path: string): string {
220+
// Normalize windows path separator to posix
220221
return path.replace(/[/\\]+/g, '/');
221222
}
222223

@@ -270,5 +271,5 @@ export abstract class FileSystem {
270271
return spreadAsync(this.find(globPatterns, { findType: FindType.file }));
271272
}
272273

273-
protected globbyFs?(): GlobbyOptions['fs'];
274+
protected globFs?(): Partial<FileSystemAdapter>;
274275
}

packages/core/src/fs/nodeFileSystem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class NodeFileSystem extends FileSystem {
6666
}));
6767
}
6868

69-
protected globbyFs() {
69+
protected globFs() {
7070
return {
7171
lstat: this.innerFs.lstat.bind(this.innerFs),
7272
stat: this.innerFs.stat.bind(this.innerFs),

packages/salesforce/jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ module.exports = {
77
],
88
transform: {
99
'^.+\\.ts$': ['ts-jest', { isolatedModules: true, esModuleInterop: true }]
10+
},
11+
moduleNameMapper: {
12+
'^@vlocode/(.*)$': '<rootDir>/../$1/src'
1013
}
1114
};

packages/salesforce/src/__tests__/salesforcePackageBuilder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('SalesforcePackageBuilder', () => {
5151
// Trigger
5252
'src/triggers/myTrigger.trigger': 'trigger MyTrigger on Account (before insert, before update, after insert, after update) { }',
5353
'src/triggers/myTrigger.trigger-meta.xml': buildMetadataXml('ApexTrigger'),
54-
// decomposd object
54+
// decomposed object
5555
'src/objects/PetersCustomObject__c/fields/PetersField__c.field-meta.xml': buildXml('CustomField', { fullName: 'PetersField__c' }),
5656
'src/objects/PetersCustomObject__c/listViews/What_A_View.listview-meta.xml': buildXml('ListView', { fullName: 'What_A_View' }),
5757
'src/objects/PetersCustomObject__c/PetersCustomObject__c.object-meta.xml': buildXml('CustomObject', { fullName: 'PetersCustomObject__c' }),

packages/salesforce/src/visualforceRemoting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export class VisualforceRemoting {
182182
* @param remoteMethod Method to call
183183
* @param params Optional list of params to pass to the call
184184
*/
185-
public async invoke(method: RemoteMethodSignature | string, params?: object[]): Promise<VisualforceRemotingResponse> {
185+
public async invoke(method: RemoteMethodSignature | string, params?: unknown[]): Promise<VisualforceRemotingResponse> {
186186
if (!this.initialized) {
187187
throw new Error('Cannot invoke methods before Visualforce remoting is initialized');
188188
}

packages/vscode-extension/package.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"private": true,
44
"displayName": "Salesforce Vlocity Integration",
55
"description": "Salesforce and Vlocity development and deployment extension for VSCode",
6-
"version": "1.27.7",
6+
"version": "1.28.1",
77
"license": "MIT",
88
"icon": "resources/icon.png",
99
"author": {
@@ -147,6 +147,10 @@
147147
"command": "vlocode.exportDatapack",
148148
"title": "Datapack: Export from Org"
149149
},
150+
{
151+
"command": "vlocode.importMultipack",
152+
"title": "Datapack: Import Multipack..."
153+
},
150154
{
151155
"command": "vlocode.buildParentKeyFiles",
152156
"title": "Datapack: Repair dependencies"
@@ -1498,10 +1502,10 @@
14981502
"build-webpack-dev": "pnpm pre-build && webpack --config webpack/webpack.dev.mjs --env extension",
14991503
"watch": "webpack --watch --config webpack/webpack.dev.mjs --env extension",
15001504
"watch-prod": "webpack --watch --config webpack/webpack.prod.mjs --env extension",
1501-
"pack": "pnpm vsce package --no-dependencies --allow-star-activation",
1505+
"pack": "pnpx @vscode/vsce package --no-dependencies --allow-star-activation --allow-package-secrets npm",
15021506
"pre-build": "ts-node build/buildCommands.ts ./package.json ./commands.yaml",
15031507
"clean": "shx rm -rf ./out ./.ts-temp './src/**/*.{d.ts,ts.map,js.map,js}'",
1504-
"publish": "vsce publish --no-dependencies --allow-star-activation",
1508+
"publish": "pnpx @vscode/vsce publish --no-dependencies --allow-star-activation --allow-package-secrets npm",
15051509
"cp-changelog": "shx cp ../../CHANGELOG.md CHANGELOG.md",
15061510
"vscode:prepublish": "pnpm run clean && pnpm run cp-changelog && pnpm build-webpack"
15071511
},
@@ -1521,13 +1525,12 @@
15211525
"@vlocode/vlocity": "workspace:*",
15221526
"@vlocode/vlocity-deploy": "workspace:*",
15231527
"@vscode/test-electron": "^2.3.8",
1524-
"@vscode/vsce": "^3.0.0",
1528+
"@vscode/vsce": "^3.3.2",
15251529
"chalk": "^4.1.1",
15261530
"copy-webpack-plugin": "^9.1.0",
15271531
"esbuild-loader": "^4.0.3",
15281532
"escape-string-regexp": "^4.0.0",
15291533
"fs-extra": "^11.0",
1530-
"globby": "^11.0.4",
15311534
"jest": "^29.7.0",
15321535
"js-yaml": "^4.1.0",
15331536
"jsforce": "^1.11.0",
@@ -1545,8 +1548,11 @@
15451548
"typescript": "5.1.6",
15461549
"vlocity": "1.14.18",
15471550
"vscode-languageclient": "^8.1.0",
1548-
"webpack": "^5.97",
1551+
"webpack": "^5.99.7",
15491552
"webpack-cli": "^6.0",
15501553
"webpack-merge": "^6.0"
1554+
},
1555+
"dependencies": {
1556+
"fast-glob": "^3.3.3"
15511557
}
15521558
}

packages/vscode-extension/src/__tests__/DatapackExportQueries.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('DatapackExportQueries', () => {
3939
it('should use null when nummeric fields are empty string', async () => {
4040
// Arrange
4141
const types = { '%vlocity_namespace%__Version__c': 'double' };
42-
const fieds = [ 'Name', 'Version__c', 'Author__c' ];
42+
const fieds = [ 'Name', '%vlocity_namespace%__Version__c', '%vlocity_namespace%__Author__c' ];
4343
const sut = new DatapackExportQueries(mockMatchingKeyService(fieds), mockSchemaService(types), Logger.null);
4444
const entry = {
4545
datapackType: 'VlocityCard',

packages/vscode-extension/src/commands/metadata/createMetadataCommand.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import * as path from 'path';
22
import * as vscode from 'vscode';
33
import { formatString, sanitizePath } from '@vlocode/util';
44
import * as fs from 'fs-extra';
5+
import fg from 'fast-glob';
56
import itemTemplates, { NewItemTemplate } from '../../newItemTemplates.yaml';
6-
import globby from 'globby';
77
import { container } from '@vlocode/core';
88
import { VlocityNamespaceService } from '@vlocode/vlocity';
99
import MetadataCommand from './metadataCommand';
@@ -56,7 +56,7 @@ export default class CreateMetadataCommand extends MetadataCommand {
5656
try {
5757
await fs.ensureDir(path.dirname(fileUri.fsPath));
5858
await fs.writeFile(fileUri.fsPath, fileBody, { flag: 'wx' });
59-
} catch(e) {
59+
} catch {
6060
void vscode.window.showErrorMessage(`Unable to create the specified item; a file with the same name already exists: ${fileUri.fsPath}`);
6161
}
6262

@@ -95,7 +95,7 @@ export default class CreateMetadataCommand extends MetadataCommand {
9595

9696
const workspaceFolders = vscode.workspace.workspaceFolders.map(ws => sanitizePath(ws.uri.fsPath, path.posix.sep));
9797
const patterns = workspaceFolders.map(ws => path.posix.join(ws, '**', newItemType.folderName));
98-
const targetFolders: string[] = await globby(patterns, { onlyDirectories: true, absolute: true });
98+
const targetFolders: string[] = await fg.glob(patterns, { onlyDirectories: true, absolute: true });
9999

100100
if (targetFolders.length == 1) {
101101
return targetFolders[0];

0 commit comments

Comments
 (0)