Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@
"dependencies": {
"@apexdevtools/apex-ls": "^5.10.0",
"@apexdevtools/apex-parser": "^4.4.0",
"@apexdevtools/sfdx-auth-helper": "^2.1.0",
"@salesforce/apex-node": "^1.6.2"
"@salesforce/apex-node": "^8.4.6",
"@salesforce/core": "^8.25.1"
},
"devDependencies": {
"@types/node": "~22.16.3",
Expand Down
17 changes: 5 additions & 12 deletions lana/src/salesforce/logs/GetLogFile.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
/*
* Copyright (c) 2020 Certinia Inc. All rights reserved.
*/
import { getSalesforceConnection } from './SalesforceConnection.js';

export class GetLogFile {
static async apply(wsPath: string, logDir: string, logId: string): Promise<void> {
const connection = await getSalesforceConnection(wsPath);

// Dynamic import for code splitting. Improves performance by reducing the amount of JS that is loaded and parsed at the start.
// eslint-disable-next-line @typescript-eslint/naming-convention
const { AuthHelper } = await import('@apexdevtools/sfdx-auth-helper');

const ah = await AuthHelper.instance(wsPath);
const connection = await ah.connect(await ah.getDefaultUsername());

if (connection) {
// Dynamic import for code splitting. Improves performance by reducing the amount of JS that is loaded and parsed at the start.
// eslint-disable-next-line @typescript-eslint/naming-convention
const { LogService } = await import('@salesforce/apex-node');
await new LogService(connection).getLogs({ logId: logId, outputDir: logDir });
}
return new Promise((resolve) => resolve());
const { LogService } = await import('@salesforce/apex-node');
await new LogService(connection).getLogs({ logId: logId, outputDir: logDir });
}
}
17 changes: 6 additions & 11 deletions lana/src/salesforce/logs/GetLogFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@
*/
import { type LogRecord } from '@salesforce/apex-node';

import { getSalesforceConnection } from './SalesforceConnection.js';

export class GetLogFiles {
static async apply(wsPath: string): Promise<LogRecord[]> {
const connection = await getSalesforceConnection(wsPath);

// Dynamic import for code splitting. Improves performance by reducing the amount of JS that is loaded and parsed at the start.
// eslint-disable-next-line @typescript-eslint/naming-convention
const { AuthHelper } = await import('@apexdevtools/sfdx-auth-helper');
const ah = await AuthHelper.instance(wsPath);
const connection = await ah.connect(await ah.getDefaultUsername());

if (connection) {
// Dynamic import for code splitting. Improves performance by reducing the amount of JS that is loaded and parsed at the start.
// eslint-disable-next-line @typescript-eslint/naming-convention
const { LogService } = await import('@salesforce/apex-node');
return new LogService(connection).getLogRecords();
}
return [];
const { LogService } = await import('@salesforce/apex-node');
return new LogService(connection).getLogRecords();
}
}
25 changes: 25 additions & 0 deletions lana/src/salesforce/logs/SalesforceConnection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2020 Certinia Inc. All rights reserved.
*/
import type { Connection } from '@salesforce/core';

import { setupPinoBundlerPaths } from '../setupPinoPaths.js';

export async function getSalesforceConnection(wsPath: string): Promise<Connection> {
// Must be called before importing @salesforce packages that use pino
setupPinoBundlerPaths();

// Dynamic import for code splitting. Improves performance by reducing the amount of JS that is loaded and parsed at the start.
// eslint-disable-next-line @typescript-eslint/naming-convention
const { ConfigAggregator, OrgConfigProperties, Org } = await import('@salesforce/core');

const aggregator = await ConfigAggregator.create({ projectPath: wsPath });
const aliasOrUsername = aggregator.getPropertyValue<string>(OrgConfigProperties.TARGET_ORG);

if (!aliasOrUsername) {
throw new Error('No default org configured for workspace');
}

const org = await Org.create({ aliasOrUsername });
return org.getConnection();
}
26 changes: 26 additions & 0 deletions lana/src/salesforce/setupPinoPaths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2020 Certinia Inc. All rights reserved.
*/
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

/**
* Sets up pino bundler path overrides for worker threads.
* Must be called before any @salesforce/* imports that use pino.
*
* Pino uses worker threads that need to load files from disk at runtime.
* When bundled with rollup, the paths break. This injects the correct
* paths to the separately copied worker files.
*/
export function setupPinoBundlerPaths(): void {
if ('__bundlerPathsOverrides' in globalThis) return;

const __dirname = dirname(fileURLToPath(import.meta.url));

(globalThis as Record<string, unknown>).__bundlerPathsOverrides = {
'thread-stream-worker': join(__dirname, 'thread-stream-worker.js'),
'pino-worker': join(__dirname, 'pino-worker.js'),
'pino/file': join(__dirname, 'pino-file.js'),
'../../lib/logger/transformStream': join(__dirname, 'salesforce-transform-stream.js'),
};
}
13 changes: 1 addition & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"prepare": "husky",
"bump-prerelease": "node ./scripts/pre-release.js",
"build": "NODE_ENV=production pnpm run build:dev",
"build:fast": "NODE_ENV=production pnpm run build:dev",
"build:fast": "NODE_ENV=production pnpm run build:dev:fast",
"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'",
"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'",
"watch": "rm -rf lana/out && rollup -w -c rollup.config.mjs",
Expand All @@ -51,16 +51,5 @@
},
"lint-staged": {
"*.{ts,css,md,scss}": "prettier --cache --write --experimental-cli"
},
"pnpm": {
"patchedDependencies": {
"@salesforce/bunyan@2.0.0": "patches/@salesforce__bunyan@2.0.0.patch"
},
"overrides": {
"@salesforce/core>jsforce": "^2.0.0-beta.27",
"@salesforce/apex-node>@salesforce/core": "^4.3.11",
"@apexdevtools/sfdx-auth-helper>jsforce": "^2.0.0-beta.27",
"@apexdevtools/sfdx-auth-helper>@salesforce/core": "^4.3.11"
}
}
}
Loading
Loading