Skip to content

Commit

Permalink
fix: upgrade to minimum of node 18 (#333)
Browse files Browse the repository at this point in the history
* fix: upgrade to minimum of node 18

@W-14196513@

* chore: apply review suggestions
  • Loading branch information
peternhale authored Dec 7, 2023
1 parent 9a451b2 commit e87eb9e
Show file tree
Hide file tree
Showing 29 changed files with 1,728 additions and 1,709 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ lerna-debug.log*
test-results.xml
xunit.xml
junit-custom.xml
path

# nyc test coverage
.nyc_output
Expand Down
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn commitlint --edit
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"printWidth": 80,
"tabWidth": 2,
"singleQuote": true
"singleQuote": true,
"trailingComma": "none"
}
73 changes: 35 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,47 @@
"main": "lib/src/index.js",
"dependencies": {
"@salesforce/core": "^5.3.18",
"@types/istanbul-reports": "^3.0.1",
"@salesforce/kit": "^3.0.15",
"@types/istanbul-reports": "^3.0.4",
"faye": "1.4.0",
"glob": "^8.0.3",
"istanbul-lib-coverage": "^3.2.0",
"glob": "^10.3.10",
"istanbul-lib-coverage": "^3.2.2",
"istanbul-lib-report": "^3.0.1",
"istanbul-reports": "^3.1.6"
"istanbul-reports": "^3.1.6",
"jsforce": "^2.0.0-beta.28"
},
"devDependencies": {
"@commitlint/config-conventional": "^17.6.7",
"@salesforce/ts-sinon": "^1.4.14",
"@salesforce/ts-types": "^2.0.6",
"@types/chai": "^4.3.5",
"@commitlint/config-conventional": "^18.1.0",
"@salesforce/ts-sinon": "^1.4.19",
"@salesforce/ts-types": "^2.0.9",
"@types/chai": "^4.3.10",
"@types/glob": "^8.1.0",
"@types/istanbul-lib-coverage": "^2.0.4",
"@types/istanbul-lib-report": "^3.0.0",
"@types/mocha": "^10",
"@types/node": "^14",
"@types/sinon": "^7.5.2",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"chai": "^4.3.7",
"commitlint": "^17.6.7",
"@types/istanbul-lib-coverage": "^2.0.6",
"@types/istanbul-lib-report": "^3.0.3",
"@types/mocha": "^10.0.4",
"@types/node": "^18",
"@types/sinon": "^17.0.1",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"chai": "^4.3.10",
"commitlint": "^18.2.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-header": "^3.0.0",
"eslint-plugin-jsdoc": "^19.1.0",
"eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5",
"lint-staged": "^10.2.11",
"mocha": "^10",
"mocha-junit-reporter": "^1.23.3",
"nyc": "^14.1.1",
"prettier": "1.19.1",
"eslint-plugin-jsdoc": "^46.8.2",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^8.0.0",
"lint-staged": "^15.0.2",
"mocha": "^10.2.0",
"mocha-junit-reporter": "^2.2.1",
"nyc": "^15.1.0",
"prettier": "^3.0.3",
"shx": "^0.3.4",
"sinon": "^7.3.1",
"sinon": "^17.0.1",
"source-map-support": "^0.5.16",
"ts-node": "^10.7.0",
"typescript": "4.6.4"
"typescript": "^5.2.2"
},
"homepage": "https://github.com/forcedotcom/salesforcedx-apex",
"keywords": [
Expand All @@ -67,13 +69,8 @@
"test": "nyc mocha ./test/**/*.test.ts",
"package": "yarn pack",
"prettier": "prettier ./**/*.{js,json,ts,md} --write",
"format:check": "prettier ./**/*.{js,json,ts,md} --debug-check"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
"format:check": "prettier ./**/*.{js,json,ts,md} --debug-check",
"prepare": "husky install"
},
"lint-staged": {
"./{src,test}/**/*.{ts,js}": [
Expand All @@ -82,11 +79,11 @@
},
"license": "BSD-3-Clause",
"engines": {
"node": ">=16.13.0"
"node": ">=18.18.2"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
}
2 changes: 1 addition & 1 deletion src/execute/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { soapTemplate, action, xmlCharMap } from './types';
import * as util from 'util';

function escapeXml(data: string): string {
return data.replace(/[<>&'"]/g, char => {
return data.replace(/[<>&'"]/g, (char) => {
return xmlCharMap[char];
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class Message implements LocalizationProvider {
possibleLabel = `${MISSING_LABEL_MSG} ${label}`;

if (Array.isArray(args) && args.length >= 1) {
args.forEach(arg => {
args.forEach((arg) => {
possibleLabel += ` (${arg})`;
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/logs/logService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class LogService {

if (typeof options.numberOfLogs === 'number') {
const logIdRecordList = await this.getLogRecords(options.numberOfLogs);
return logIdRecordList.map(logRecord => logRecord.Id);
return logIdRecordList.map((logRecord) => logRecord.Id);
}
return [options.logId];
}
Expand All @@ -65,7 +65,7 @@ export class LogService {
public async getLogs(options: ApexLogGetOptions): Promise<LogResult[]> {
const logIdList = await this.getLogIds(options);
const logPaths: string[] = [];
const connectionRequests = logIdList.map(async id => {
const connectionRequests = logIdList.map(async (id) => {
const url = `${this.connection.tooling._baseUrl()}/sobjects/ApexLog/${id}/Body`;
const logRecord = await this.toolingRequest(url);
if (options.outputDir) {
Expand All @@ -85,7 +85,7 @@ export class LogService {
return logMap;
}

return logs.map(log => {
return logs.map((log) => {
return { log };
});
}
Expand Down
13 changes: 7 additions & 6 deletions src/reporters/coverageReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class CoverageReporter {
coverageMap: this.coverageMap
});
const formats = this.options?.reportFormats || ['text-summary'];
formats.forEach(format => {
formats.forEach((format) => {
const report = reports.create(
format,
this.options?.reportOptions[format] || DefaultReportOptions[format]
Expand All @@ -125,22 +125,23 @@ export class CoverageReporter {
const coverageMap = libCoverage.createCoverageMap();
this.coverage.records.forEach(
(record: ApexCodeCoverageRecord | ApexCodeCoverageAggregateRecord) => {
const fileCoverageData: libCoverage.FileCoverageData = {} as libCoverage.FileCoverageData;
const fileCoverageData: libCoverage.FileCoverageData =
{} as libCoverage.FileCoverageData;
const fileRegEx = new RegExp(
`${record.ApexClassOrTrigger.Name}\.(cls|trigger)`
);
fileCoverageData.fnMap = {};
fileCoverageData.branchMap = {};
fileCoverageData.path = path.join(
this.sourceDir,
pathsToFiles.find(file => fileRegEx.test(file)) ||
pathsToFiles.find((file) => fileRegEx.test(file)) ||
record.ApexClassOrTrigger.Name
);
fileCoverageData.f = {};
fileCoverageData.b = {};
fileCoverageData.s = [
...record.Coverage.coveredLines.map(line => [line, 1]),
...record.Coverage.uncoveredLines.map(line => [line, 0])
...record.Coverage.coveredLines.map((line) => [line, 1]),
...record.Coverage.uncoveredLines.map((line) => [line, 0])
]
.map(([line, covered]) => [Number(line).toString(10), covered])
.reduce((acc, [line, value]) => {
Expand All @@ -159,7 +160,7 @@ export class CoverageReporter {
...record.Coverage.uncoveredLines
]
.sort()
.map(line => {
.map((line) => {
const statement: libCoverage.Range = {
start: {
line,
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/humanReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class HumanReporter {
: elem.message;

if (elem.perClassCoverage) {
elem.perClassCoverage.forEach(perClassCov => {
elem.perClassCoverage.forEach((perClassCov) => {
testRowArray.push({
name: elem.fullName,
coveredClassName: perClassCov.apexClassOrTriggerName,
Expand Down
10 changes: 5 additions & 5 deletions src/reporters/tapReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ export class TapReporter {

let out = '';
out = out.concat(`1..${testPointCount}\n`);
results.forEach(testPoint => {
results.forEach((testPoint) => {
out = out.concat(
`${testPoint.outcome} ${testPoint.testNumber} ${testPoint.description}\n`
);
testPoint.diagnostics.forEach(s => {
testPoint.diagnostics.forEach((s) => {
out = out.concat(`# ${s}\n`);
});
});

epilog?.forEach(c => {
epilog?.forEach((c) => {
out = out.concat(`# ${c}\n`);
});
return out;
Expand Down Expand Up @@ -61,7 +61,7 @@ export class TapReporter {
if (testResult.message) {
const startsWithNewlineRegex = new RegExp(/^[/\r\n|\r|\n][\w]*/gim);
if (startsWithNewlineRegex.test(testResult.message)) {
testResult.message.split(/\r\n|\r|\n/g).forEach(msg => {
testResult.message.split(/\r\n|\r|\n/g).forEach((msg) => {
if (msg && msg.length > 0) {
message.push(msg.trim());
}
Expand All @@ -74,7 +74,7 @@ export class TapReporter {
}

if (testResult.stackTrace) {
testResult.stackTrace.split('\n').forEach(line => {
testResult.stackTrace.split('\n').forEach((line) => {
message.push(line);
});
}
Expand Down
14 changes: 7 additions & 7 deletions src/streaming/streamingClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { Client } from 'faye';
import { Connection } from '@salesforce/core';
import {
RetreiveResultsInterval,
RetrieveResultsInterval,
StreamMessage,
StreamingErrors,
TestResultMessage
Expand All @@ -35,7 +35,7 @@ export class Deferred<T> {
public promise: Promise<T>;
public resolve: Function;
constructor() {
this.promise = new Promise(resolve => (this.resolve = resolve));
this.promise = new Promise((resolve) => (this.resolve = resolve));
}
}

Expand Down Expand Up @@ -149,7 +149,7 @@ export class StreamingClient {
}

public handshake(): Promise<void> {
return new Promise(resolve => {
return new Promise((resolve) => {
this.client.handshake(() => {
resolve();
});
Expand Down Expand Up @@ -188,7 +188,7 @@ export class StreamingClient {

if (action) {
action()
.then(id => {
.then((id) => {
this.subscribedTestRunId = id;
this.subscribedTestRunIdDeferred.resolve(id);

Expand All @@ -203,10 +203,10 @@ export class StreamingClient {
queueItem: result
});
}
}, RetreiveResultsInterval);
}, RetrieveResultsInterval);
}
})
.catch(e => {
.catch((e) => {
this.disconnect();
clearInterval(intervalId);
subscriptionReject(e);
Expand All @@ -226,7 +226,7 @@ export class StreamingClient {
queueItem: result
});
}
}, RetreiveResultsInterval);
}, RetrieveResultsInterval);
}
}
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion src/streaming/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ export const enum StreamingErrors {
ERROR_UNKNOWN_CLIENT_ID = '403::Unknown client'
}

export const RetreiveResultsInterval = 60 * 1000;
export const RetrieveResultsInterval = 60 * 1000;
Loading

0 comments on commit e87eb9e

Please sign in to comment.