Skip to content

Commit

Permalink
chore: remove TODOs in forceignore
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Sep 17, 2024
1 parent 5e08eb4 commit 42a9c8d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
5 changes: 1 addition & 4 deletions src/convert/replacements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ export const replacementIterations = async (input: string, replacements: MarkedR
const lifecycleInstance = Lifecycle.getInstance();
let output = input;
for (const replacement of replacements) {
// TODO: node 16+ has String.replaceAll for non-regex scenarios
const regex =
typeof replacement.toReplace === 'string' ? new RegExp(replacement.toReplace, 'g') : replacement.toReplace;
const replaced = output.replace(regex, replacement.replaceWith ?? '');
const replaced = output.replaceAll(new RegExp(replacement.toReplace, 'g'), replacement.replaceWith ?? '');

if (replaced !== output) {
output = replaced;
Expand Down
4 changes: 2 additions & 2 deletions src/resolve/forceIgnore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { dirname, join, relative } from 'node:path';
import ignore, { Ignore } from 'ignore/index';
import { readFileSync } from 'graceful-fs';
import { Lifecycle } from '@salesforce/core';
import { Lifecycle, Logger } from '@salesforce/core';
import { SourcePath } from '../common/types';
import { searchUp } from '../utils/fileSystemHandler';

Expand Down Expand Up @@ -42,7 +42,7 @@ export class ForceIgnore {
this.forceIgnoreDirectory = dirname(forceIgnorePath);
}
} catch (e) {
// TODO: log no force ignore
Logger.childFromRoot(this.constructor.name).info('no .forceignore found');
}
}

Expand Down
33 changes: 9 additions & 24 deletions test/resolve/forceIgnore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,15 @@ describe('ForceIgnore', () => {
forceIgnore = new ForceIgnore();
});

it('Should ignore files starting with a dot', () => {
const dotPath = join(root, '.xyz');

expect(forceIgnore.accepts(dotPath)).to.be.false;
expect(forceIgnore.denies(dotPath)).to.be.true;
});

it('Should ignore files ending in .dup', () => {
const dupPath = join(root, 'abc.dup');

expect(forceIgnore.accepts(dupPath)).to.be.false;
expect(forceIgnore.denies(dupPath)).to.be.true;
});

it('Should ignore files named package2-descriptor.json', () => {
const descriptorPath = join(root, 'package2-descriptor.json');
expect(forceIgnore.accepts(descriptorPath)).to.be.false;
expect(forceIgnore.denies(descriptorPath)).to.be.true;
});

it('Should ignore files named package2-manifest.json', () => {
const manifestPath = join(root, 'package2-manifest.json');
expect(forceIgnore.accepts(manifestPath)).to.be.false;
expect(forceIgnore.denies(manifestPath)).to.be.true;
// the example's index here is specific to the rules order in ForceIgnore.DEFAULT_IGNORE
const forceIgnoreExamples = ['abc.dup', '.xyz', 'package2-descriptor.json', 'package2-manifest.json'];
forceIgnoreExamples.map((ignore) => {
it(`Should ignore files starting with a ${ignore}`, () => {
const testPath = join(root, ignore);

expect(forceIgnore.accepts(testPath)).to.be.false;
expect(forceIgnore.denies(testPath)).to.be.true;
});
});

it('Should allow .forceignore file to override defaults', () => {
Expand Down

2 comments on commit 42a9c8d

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 42a9c8d Previous: d11c155 Ratio
eda-componentSetCreate-linux 245 ms 254 ms 0.96
eda-sourceToMdapi-linux 2356 ms 2549 ms 0.92
eda-sourceToZip-linux 1881 ms 2030 ms 0.93
eda-mdapiToSource-linux 2848 ms 3268 ms 0.87
lotsOfClasses-componentSetCreate-linux 426 ms 447 ms 0.95
lotsOfClasses-sourceToMdapi-linux 3789 ms 4316 ms 0.88
lotsOfClasses-sourceToZip-linux 3048 ms 3389 ms 0.90
lotsOfClasses-mdapiToSource-linux 3608 ms 4206 ms 0.86
lotsOfClassesOneDir-componentSetCreate-linux 734 ms 798 ms 0.92
lotsOfClassesOneDir-sourceToMdapi-linux 6507 ms 7451 ms 0.87
lotsOfClassesOneDir-sourceToZip-linux 5620 ms 5980 ms 0.94
lotsOfClassesOneDir-mdapiToSource-linux 6504 ms 7501 ms 0.87

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

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

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

Benchmark

Benchmark suite Current: 42a9c8d Previous: d11c155 Ratio
eda-componentSetCreate-win32 698 ms 616 ms 1.13
eda-sourceToMdapi-win32 4607 ms 4374 ms 1.05
eda-sourceToZip-win32 3199 ms 2975 ms 1.08
eda-mdapiToSource-win32 6178 ms 5783 ms 1.07
lotsOfClasses-componentSetCreate-win32 1323 ms 1194 ms 1.11
lotsOfClasses-sourceToMdapi-win32 8490 ms 7729 ms 1.10
lotsOfClasses-sourceToZip-win32 4983 ms 5149 ms 0.97
lotsOfClasses-mdapiToSource-win32 7822 ms 7797 ms 1.00
lotsOfClassesOneDir-componentSetCreate-win32 2091 ms 2117 ms 0.99
lotsOfClassesOneDir-sourceToMdapi-win32 14016 ms 13830 ms 1.01
lotsOfClassesOneDir-sourceToZip-win32 9571 ms 9066 ms 1.06
lotsOfClassesOneDir-mdapiToSource-win32 14312 ms 13994 ms 1.02

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

Please sign in to comment.