Skip to content

Commit

Permalink
Merge pull request #1044 from forcedotcom/sm/v4-prep
Browse files Browse the repository at this point in the history
fix: v7-prep
  • Loading branch information
mshanemc authored Apr 4, 2024
2 parents 3072845 + d0f2239 commit 092923b
Show file tree
Hide file tree
Showing 17 changed files with 1,795 additions and 1,439 deletions.
5 changes: 5 additions & 0 deletions .sfdevrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
"files": ["src/**/*.ts", "tsconfig.json", "messages", "messageTransformer"],
"output": ["lib/**", "*.tsbuildinfo"],
"clean": "if-file-deleted"
},
"link-check": {
"command": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || linkinator \"./*.md\" --skip \"examples/README.md|CHANGELOG.md|node_modules|test/|confluence.internal.salesforce.com|my.salesforce.com|%s\" --markdown --retry --directory-listing --verbosity error",
"files": ["./*.md", "./examples/**/*.md", "./messages/**/*.md", "./!(CHANGELOG).md"],
"output": []
}
}
}
50 changes: 0 additions & 50 deletions EXPORTED.md

This file was deleted.

20 changes: 16 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"compile": "wireit",
"docs": "sf-docs",
"format": "wireit",
"link-check": "wireit",
"lint": "wireit",
"lint-fix": "yarn sf-lint --fix",
"postcompile": "tsc -p typedocExamples",
Expand All @@ -39,9 +40,8 @@
],
"dependencies": {
"@salesforce/kit": "^3.1.0",
"@salesforce/schemas": "^1.6.1",
"@salesforce/schemas": "^1.7.0",
"@salesforce/ts-types": "^2.0.9",
"@types/semver": "^7.5.8",
"ajv": "^8.12.0",
"change-case": "^4.1.2",
"faye": "^1.4.0",
Expand All @@ -58,12 +58,13 @@
"ts-retry-promise": "^0.7.1"
},
"devDependencies": {
"@salesforce/dev-scripts": "^7.1.1",
"@salesforce/dev-scripts": "^8.4.2",
"@salesforce/ts-sinon": "^1.4.19",
"@types/benchmark": "^2.1.5",
"@types/chai-string": "^1.4.5",
"@types/jsonwebtoken": "9.0.6",
"@types/proper-lockfile": "^4.1.4",
"@types/semver": "^7.5.8",
"benchmark": "^2.1.4",
"chai-string": "^1.5.0",
"ts-node": "^10.9.2",
Expand Down Expand Up @@ -146,8 +147,19 @@
"test": {
"dependencies": [
"test:only",
"test:compile"
"test:compile",
"link-check"
]
},
"link-check": {
"command": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || linkinator \"./*.md\" --skip \"examples/README.md|CHANGELOG.md|node_modules|test/|confluence.internal.salesforce.com|my.salesforce.com|%s\" --markdown --retry --directory-listing --verbosity error",
"files": [
"./*.md",
"./examples/**/*.md",
"./messages/**/*.md",
"./!(CHANGELOG).md"
],
"output": []
}
}
}
1 change: 1 addition & 0 deletions src/messageTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import * as ts from 'typescript';
import { Messages, StoredMessageMap } from './messages';

Expand Down
2 changes: 1 addition & 1 deletion src/org/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export class Connection<S extends Schema = Schema> extends JSForceConnection<S>
const config: ConfigAggregator = await ConfigAggregator.create();
// take the limit from the calling function, then the config, then default 10,000
const maxFetch: number =
((config.getInfo(OrgConfigProperties.ORG_MAX_QUERY_LIMIT).value as number) || queryOptions.maxFetch) ?? 10000;
((config.getInfo(OrgConfigProperties.ORG_MAX_QUERY_LIMIT).value as number) || queryOptions.maxFetch) ?? 10_000;

const { tooling, ...queryOptionsWithoutTooling } = queryOptions;

Expand Down
2 changes: 1 addition & 1 deletion src/org/org.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ export class Org extends AsyncOptionalCreatable<Org.Options> {
await stateAgg.aliases.unsetValuesAndSave(existingAliases);

// unset any configs referencing this org
[...existingAliases, username].flatMap((name) => this.configAggregator.unsetByValue(name));
await Promise.all([...existingAliases, username].flatMap((name) => this.configAggregator.unsetByValue(name)));

if (await this.isSandbox()) {
await this.deleteSandbox();
Expand Down
3 changes: 3 additions & 0 deletions src/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import * as fs from 'node:fs';
import { EventEmitter } from 'node:events';
import { tmpdir as osTmpdir } from 'node:os';
import { basename, join as pathJoin, dirname } from 'node:path';

// eslint-disable-next-line import/no-extraneous-dependencies
import { SinonSandbox, SinonStatic, SinonStub } from 'sinon';

import {
Expand Down Expand Up @@ -420,6 +422,7 @@ export class TestContext {
private requireSinon(sinon: Nullable<SinonStatic>): SinonStatic {
if (sinon) return sinon;
try {
// eslint-disable-next-line import/no-extraneous-dependencies
sinon = require('sinon');
} catch (e) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion src/util/lockRetryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
export const lockOptions = { stale: 10_000 };
export const lockRetryOptions = {
...lockOptions,
retries: { retries: 10, maxTimeout: 1_000, factor: 2 },
retries: { retries: 10, maxTimeout: 1000, factor: 2 },
};
2 changes: 1 addition & 1 deletion src/webOAuthServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export namespace WebOAuthServer {
* Handles the actions specific to the http server
*/
export class WebServer extends AsyncCreatable<WebServer.Options> {
public static DEFAULT_CLIENT_SOCKET_TIMEOUT = 20000;
public static DEFAULT_CLIENT_SOCKET_TIMEOUT = 20_000;
public server!: http.Server;
public port = WebOAuthServer.DEFAULT_PORT;
public host = 'localhost';
Expand Down
2 changes: 1 addition & 1 deletion test/unit/config/configAggregatorTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('ConfigAggregator', () => {
describe('locations', () => {
beforeEach(() => {
// @ts-expect-error there's a lot more properties we're not mocking
$$.SANDBOX.stub(fs.promises, 'stat').resolves({ mtimeNs: BigInt(new Date().valueOf() - 1_000 * 60 * 5) });
$$.SANDBOX.stub(fs.promises, 'stat').resolves({ mtimeNs: BigInt(new Date().valueOf() - 1000 * 60 * 5) });
});
it('local', async () => {
// @ts-expect-error async function signature not quite same as expected
Expand Down
8 changes: 4 additions & 4 deletions test/unit/config/configFileTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe('Config', () => {
it('uses passed in contents', async () => {
$$.SANDBOX.stub(fs.promises, 'readFile').resolves('{}');
// @ts-expect-error --> we're only mocking on prop of many
$$.SANDBOX.stub(fs.promises, 'stat').resolves({ mtimeNs: BigInt(Date.now() - 1_000 * 60 * 5) });
$$.SANDBOX.stub(fs.promises, 'stat').resolves({ mtimeNs: BigInt(Date.now() - 1000 * 60 * 5) });
$$.SANDBOX.stub(fs.promises, 'mkdir').resolves();
const lockStub = $$.SANDBOX.stub(lockfileLib, 'lock').resolves(() => Promise.resolve());

Expand All @@ -228,7 +228,7 @@ describe('Config', () => {
it('sync uses passed in contents', async () => {
$$.SANDBOX.stub(fs, 'readFileSync').returns('{}');
// @ts-expect-error --> we're only mocking on prop of many
$$.SANDBOX.stub(fs, 'statSync').returns({ mtimeNs: BigInt(Date.now() - 1_000 * 60 * 5) });
$$.SANDBOX.stub(fs, 'statSync').returns({ mtimeNs: BigInt(Date.now() - 1000 * 60 * 5) });
const lockStub = $$.SANDBOX.stub(lockfileLib, 'lockSync').returns(() => undefined);

const mkdirpStub = $$.SANDBOX.stub(fs, 'mkdirSync');
Expand Down Expand Up @@ -260,7 +260,7 @@ describe('Config', () => {
$$.SANDBOXES.CONFIG.restore();
readFileStub = $$.SANDBOX.stub(fs.promises, 'readFile');
// @ts-expect-error --> we're only mocking on prop of many
$$.SANDBOX.stub(fs.promises, 'stat').resolves({ mtimeNs: BigInt(Date.now() - 1_000 * 60 * 5) });
$$.SANDBOX.stub(fs.promises, 'stat').resolves({ mtimeNs: BigInt(Date.now() - 1000 * 60 * 5) });
});

it('caches file contents', async () => {
Expand Down Expand Up @@ -344,7 +344,7 @@ describe('Config', () => {
$$.SANDBOXES.CONFIG.restore();
readFileStub = $$.SANDBOX.stub(fs, 'readFileSync');
// @ts-expect-error --> we're only mocking on prop of many
$$.SANDBOX.stub(fs, 'statSync').returns({ mtimeNs: BigInt(Date.now() - 1_000 * 60 * 5) });
$$.SANDBOX.stub(fs, 'statSync').returns({ mtimeNs: BigInt(Date.now() - 1000 * 60 * 5) });
});

it('caches file contents', () => {
Expand Down
8 changes: 4 additions & 4 deletions test/unit/config/configStoreTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ describe('ConfigStore', () => {
const config = new TestConfig<{ '1': { a: string } }>();
config.set('1', { a: 'a' });

config.get('1')!.a = 'b';
config.get('1').a = 'b';

expect(config.get('1')!.a).to.equal('b');
expect(config.get('1').a).to.equal('b');
});

it('updates the object reference', async () => {
Expand All @@ -64,8 +64,8 @@ describe('ConfigStore', () => {

config.update('1', { b: 'c' });

expect(config.get('1')!.a).to.equal('a');
expect(config.get('1')!.b).to.equal('c');
expect(config.get('1').a).to.equal('a');
expect(config.get('1').b).to.equal('c');
});

it('undefined keys return undefined', async () => {
Expand Down
6 changes: 3 additions & 3 deletions test/unit/config/configTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('Config', () => {
stubMethod($$.SANDBOX, fs.promises, 'readFile').withArgs(config.getPath()).resolves(configFileContentsString);
stubMethod($$.SANDBOX, fs.promises, 'stat')
.withArgs(config.getPath())
.resolves({ mtimeNs: BigInt(new Date().valueOf() - 1_000 * 60 * 5) });
.resolves({ mtimeNs: BigInt(new Date().valueOf() - 1000 * 60 * 5) });
// Manipulate config.hasRead to force a read
// @ts-expect-error -> hasRead is protected. Ignore for testing.
config.hasRead = false;
Expand All @@ -92,7 +92,7 @@ describe('Config', () => {
beforeEach(() => {
$$.SANDBOX.stub(lockfileLib, 'lock').resolves(() => Promise.resolve());
stubMethod($$.SANDBOX, fs.promises, 'readFile').resolves(configFileContentsString);
stubMethod($$.SANDBOX, fs.promises, 'stat').resolves({ mtimeNs: BigInt(new Date().valueOf() - 1_000 * 60 * 5) });
stubMethod($$.SANDBOX, fs.promises, 'stat').resolves({ mtimeNs: BigInt(new Date().valueOf() - 1000 * 60 * 5) });
});
it('calls Config.write with updated file contents', async () => {
const writeStub = stubMethod($$.SANDBOX, fs.promises, 'writeFile');
Expand Down Expand Up @@ -231,7 +231,7 @@ describe('Config', () => {
it('calls Config.write with updated file contents', async () => {
$$.SANDBOX.stub(lockfileLib, 'lock').resolves(() => Promise.resolve());
stubMethod($$.SANDBOX, fs.promises, 'readFile').resolves(configFileContentsString);
stubMethod($$.SANDBOX, fs.promises, 'stat').resolves({ mtimeNs: BigInt(new Date().valueOf() - 1_000 * 60 * 5) });
stubMethod($$.SANDBOX, fs.promises, 'stat').resolves({ mtimeNs: BigInt(new Date().valueOf() - 1000 * 60 * 5) });
const writeStub = stubMethod($$.SANDBOX, fs.promises, 'writeFile');

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
4 changes: 2 additions & 2 deletions test/unit/config/ttlConfigTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ describe('TTLConfig', () => {
it('should return true if timestamp is older than TTL', async () => {
const config = await TestConfig.create();
config.set('1', { one: 'one' });
const isExpired = config.isExpired(new Date().getTime() + Duration.days(7).milliseconds, config.get('1')!);
const isExpired = config.isExpired(new Date().getTime() + Duration.days(7).milliseconds, config.get('1'));
expect(isExpired).to.be.true;
});

it('should return false if timestamp is not older than TTL', async () => {
const config = await TestConfig.create();
config.set('1', { one: 'one' });
const isExpired = config.isExpired(new Date().getTime(), config.get('1')!);
const isExpired = config.isExpired(new Date().getTime(), config.get('1'));
expect(isExpired).to.be.false;
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/status/streamingClientTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ describe('streaming client tests', () => {
});

it('subscribe should timeout setTimeout spy', async () => {
const JENNYS_NUMBER = 8675309;
const GHOSTBUSTERS_NUMBER = 5552368;
const JENNYS_NUMBER = 8_675_309;
const GHOSTBUSTERS_NUMBER = 5_552_368;

const setTimeoutSpy = spyMethod($$.SANDBOX, global, 'setTimeout');

Expand Down
8 changes: 4 additions & 4 deletions test/unit/util/mapKeysTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import mapKeys from '../../../src/util/mapKeys';
const SHALLOW_LOWECASE_OBJECT = {
name: 'Anna',
address: 'Ocean Drive 101',
phone: 123456789,
phone: 123_456_789,
alias: ['Anita', 'Anny'],
cars: {
primary: {
Expand All @@ -26,7 +26,7 @@ const SHALLOW_LOWECASE_OBJECT = {
const SHALLOW_UPPERECASE_OBJECT = {
Name: 'Anna',
Address: 'Ocean Drive 101',
Phone: 123456789,
Phone: 123_456_789,
Alias: ['Anita', 'Anny'],
Cars: {
primary: {
Expand All @@ -40,7 +40,7 @@ const SHALLOW_UPPERECASE_OBJECT = {
const NESTED_LOWECASE_OBJECT = {
name: 'Anna',
address: 'Ocean Drive 101',
phone: 123456789,
phone: 123_456_789,
pets: {
oliver: {
family: 'feline',
Expand Down Expand Up @@ -98,7 +98,7 @@ const NESTED_LOWECASE_OBJECT = {
const NESTED_UPPERECASE_OBJECT = {
Name: 'Anna',
Address: 'Ocean Drive 101',
Phone: 123456789,
Phone: 123_456_789,
Pets: {
Oliver: {
Family: 'feline',
Expand Down
Loading

0 comments on commit 092923b

Please sign in to comment.