Skip to content

Commit

Permalink
feat: refresh a project
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Aug 13, 2024
1 parent 6124ca6 commit ebdb003
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/sfProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ export class SfProjectJson extends ConfigFile<ConfigFile.Options, ProjectJson> {
return contents;
}

/** force a reread of the project contents if you know they may have been modified */
public refreshSync(): SfProjectJson {
super.readSync(false, true);
return this;
}

public readSync(): ProjectJson {
const contents = super.readSync();
this.validateKeys();
Expand Down Expand Up @@ -369,6 +375,14 @@ export class SfProject {
*/
protected constructor(private path: string) {}

/**
* Clear the cache to force reading from disk.
*
* *NOTE: Only call this method if you must and you know what you are doing.*
*/
public static clearInstances(): void {
SfProject.instances.clear();
}
/**
* Get a Project from a given path or from the working directory.
*
Expand Down
3 changes: 1 addition & 2 deletions src/testSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,7 @@ export const restoreContext = (testContext: TestContext): void => {
testContext.configStubs = {};
// Give each test run a clean StateAggregator
StateAggregator.clearInstance();
// @ts-expect-error accessing a private property
SfProject.instances.clear();
SfProject.clearInstances();
// Allow each test to have their own config aggregator
// @ts-ignore clear for testing.
delete ConfigAggregator.instance;
Expand Down

3 comments on commit ebdb003

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - ubuntu-latest

Benchmark suite Current: ebdb003 Previous: 09fc350 Ratio
Child logger creation 467269 ops/sec (±2.84%) 470394 ops/sec (±0.97%) 1.01
Logging a string on root logger 821285 ops/sec (±8.05%) 776371 ops/sec (±8.73%) 0.95
Logging an object on root logger 646915 ops/sec (±6.68%) 628784 ops/sec (±7.04%) 0.97
Logging an object with a message on root logger 20088 ops/sec (±186.20%) 6522 ops/sec (±210.81%) 0.32
Logging an object with a redacted prop on root logger 505135 ops/sec (±9.65%) 432748 ops/sec (±8.07%) 0.86
Logging a nested 3-level object on root logger 21101 ops/sec (±185.24%) 380539 ops/sec (±8.30%) 18.03

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Logger Benchmarks - ubuntu-latest'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: ebdb003 Previous: 09fc350 Ratio
Logging a nested 3-level object on root logger 21101 ops/sec (±185.24%) 380539 ops/sec (±8.30%) 18.03

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - windows-latest

Benchmark suite Current: ebdb003 Previous: 09fc350 Ratio
Child logger creation 341942 ops/sec (±0.37%) 328670 ops/sec (±0.69%) 0.96
Logging a string on root logger 815333 ops/sec (±5.74%) 765884 ops/sec (±6.46%) 0.94
Logging an object on root logger 599823 ops/sec (±6.65%) 577180 ops/sec (±5.96%) 0.96
Logging an object with a message on root logger 5513 ops/sec (±205.50%) 7153 ops/sec (±201.59%) 1.30
Logging an object with a redacted prop on root logger 448937 ops/sec (±12.12%) 441001 ops/sec (±11.42%) 0.98
Logging a nested 3-level object on root logger 309332 ops/sec (±5.79%) 343507 ops/sec (±4.86%) 1.11

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.