Skip to content

Commit 3cacf0f

Browse files
Merge pull request #723 from lukecotter/chore-update-sf-core
chore: update @salesforce/core to latest (8.25.1)
2 parents e068d8e + 4e241b9 commit 3cacf0f

9 files changed

Lines changed: 752 additions & 2753 deletions

File tree

lana/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@
308308
"dependencies": {
309309
"@apexdevtools/apex-ls": "^5.10.0",
310310
"@apexdevtools/apex-parser": "^4.4.0",
311-
"@apexdevtools/sfdx-auth-helper": "^2.1.0",
312-
"@salesforce/apex-node": "^1.6.2"
311+
"@salesforce/apex-node": "^8.4.6",
312+
"@salesforce/core": "^8.25.1"
313313
},
314314
"devDependencies": {
315315
"@types/node": "~22.16.3",
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
/*
22
* Copyright (c) 2020 Certinia Inc. All rights reserved.
33
*/
4+
import { getSalesforceConnection } from './SalesforceConnection.js';
45

56
export class GetLogFile {
67
static async apply(wsPath: string, logDir: string, logId: string): Promise<void> {
8+
const connection = await getSalesforceConnection(wsPath);
9+
710
// Dynamic import for code splitting. Improves performance by reducing the amount of JS that is loaded and parsed at the start.
811
// eslint-disable-next-line @typescript-eslint/naming-convention
9-
const { AuthHelper } = await import('@apexdevtools/sfdx-auth-helper');
10-
11-
const ah = await AuthHelper.instance(wsPath);
12-
const connection = await ah.connect(await ah.getDefaultUsername());
13-
14-
if (connection) {
15-
// Dynamic import for code splitting. Improves performance by reducing the amount of JS that is loaded and parsed at the start.
16-
// eslint-disable-next-line @typescript-eslint/naming-convention
17-
const { LogService } = await import('@salesforce/apex-node');
18-
await new LogService(connection).getLogs({ logId: logId, outputDir: logDir });
19-
}
20-
return new Promise((resolve) => resolve());
12+
const { LogService } = await import('@salesforce/apex-node');
13+
await new LogService(connection).getLogs({ logId: logId, outputDir: logDir });
2114
}
2215
}

lana/src/salesforce/logs/GetLogFiles.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,15 @@
33
*/
44
import { type LogRecord } from '@salesforce/apex-node';
55

6+
import { getSalesforceConnection } from './SalesforceConnection.js';
7+
68
export class GetLogFiles {
79
static async apply(wsPath: string): Promise<LogRecord[]> {
10+
const connection = await getSalesforceConnection(wsPath);
11+
812
// Dynamic import for code splitting. Improves performance by reducing the amount of JS that is loaded and parsed at the start.
913
// eslint-disable-next-line @typescript-eslint/naming-convention
10-
const { AuthHelper } = await import('@apexdevtools/sfdx-auth-helper');
11-
const ah = await AuthHelper.instance(wsPath);
12-
const connection = await ah.connect(await ah.getDefaultUsername());
13-
14-
if (connection) {
15-
// Dynamic import for code splitting. Improves performance by reducing the amount of JS that is loaded and parsed at the start.
16-
// eslint-disable-next-line @typescript-eslint/naming-convention
17-
const { LogService } = await import('@salesforce/apex-node');
18-
return new LogService(connection).getLogRecords();
19-
}
20-
return [];
14+
const { LogService } = await import('@salesforce/apex-node');
15+
return new LogService(connection).getLogRecords();
2116
}
2217
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2020 Certinia Inc. All rights reserved.
3+
*/
4+
import type { Connection } from '@salesforce/core';
5+
6+
import { setupPinoBundlerPaths } from '../setupPinoPaths.js';
7+
8+
export async function getSalesforceConnection(wsPath: string): Promise<Connection> {
9+
// Must be called before importing @salesforce packages that use pino
10+
setupPinoBundlerPaths();
11+
12+
// Dynamic import for code splitting. Improves performance by reducing the amount of JS that is loaded and parsed at the start.
13+
// eslint-disable-next-line @typescript-eslint/naming-convention
14+
const { ConfigAggregator, OrgConfigProperties, Org } = await import('@salesforce/core');
15+
16+
const aggregator = await ConfigAggregator.create({ projectPath: wsPath });
17+
const aliasOrUsername = aggregator.getPropertyValue<string>(OrgConfigProperties.TARGET_ORG);
18+
19+
if (!aliasOrUsername) {
20+
throw new Error('No default org configured for workspace');
21+
}
22+
23+
const org = await Org.create({ aliasOrUsername });
24+
return org.getConnection();
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2020 Certinia Inc. All rights reserved.
3+
*/
4+
import { dirname, join } from 'path';
5+
import { fileURLToPath } from 'url';
6+
7+
/**
8+
* Sets up pino bundler path overrides for worker threads.
9+
* Must be called before any @salesforce/* imports that use pino.
10+
*
11+
* Pino uses worker threads that need to load files from disk at runtime.
12+
* When bundled with rollup, the paths break. This injects the correct
13+
* paths to the separately copied worker files.
14+
*/
15+
export function setupPinoBundlerPaths(): void {
16+
if ('__bundlerPathsOverrides' in globalThis) return;
17+
18+
const __dirname = dirname(fileURLToPath(import.meta.url));
19+
20+
(globalThis as Record<string, unknown>).__bundlerPathsOverrides = {
21+
'thread-stream-worker': join(__dirname, 'thread-stream-worker.js'),
22+
'pino-worker': join(__dirname, 'pino-worker.js'),
23+
'pino/file': join(__dirname, 'pino-file.js'),
24+
'../../lib/logger/transformStream': join(__dirname, 'salesforce-transform-stream.js'),
25+
};
26+
}

package.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"prepare": "husky",
4040
"bump-prerelease": "node ./scripts/pre-release.js",
4141
"build": "NODE_ENV=production pnpm run build:dev",
42-
"build:fast": "NODE_ENV=production pnpm run build:dev",
42+
"build:fast": "NODE_ENV=production pnpm run build:dev:fast",
4343
"build:dev": "rm -rf lana/out && concurrently -r -g 'rollup -c rollup.config.mjs' 'tsc --noemit --skipLibCheck -p apex-log-parser/tsconfig.json' 'tsc --noemit --skipLibCheck -p log-viewer/tsconfig.json' 'tsc --noemit --skipLibCheck -p lana/tsconfig.json'",
4444
"build:dev:fast": "rm -rf lana/out && concurrently -r -g 'rolldown -c rolldown.config.ts' 'tsc --noemit --skipLibCheck -p apex-log-parser/tsconfig.json' 'tsc --noemit --skipLibCheck -p log-viewer/tsconfig.json' 'tsc --noemit --skipLibCheck -p lana/tsconfig.json'",
4545
"watch": "rm -rf lana/out && rollup -w -c rollup.config.mjs",
@@ -51,16 +51,5 @@
5151
},
5252
"lint-staged": {
5353
"*.{ts,css,md,scss}": "prettier --cache --write --experimental-cli"
54-
},
55-
"pnpm": {
56-
"patchedDependencies": {
57-
"@salesforce/bunyan@2.0.0": "patches/@salesforce__bunyan@2.0.0.patch"
58-
},
59-
"overrides": {
60-
"@salesforce/core>jsforce": "^2.0.0-beta.27",
61-
"@salesforce/apex-node>@salesforce/core": "^4.3.11",
62-
"@apexdevtools/sfdx-auth-helper>jsforce": "^2.0.0-beta.27",
63-
"@apexdevtools/sfdx-auth-helper>@salesforce/core": "^4.3.11"
64-
}
6554
}
6655
}

0 commit comments

Comments
 (0)