Skip to content

Commit a3098bd

Browse files
authored
Merge pull request #561 from forcedotcom/sm/refactor-interfaces
fix: interfaces to types, no-param-reassign for windows normalization
2 parents e7f3944 + e59ac5a commit a3098bd

7 files changed

+34
-37
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@oclif/core": "^3.26.0",
4848
"@salesforce/core": "^6.7.6",
4949
"@salesforce/kit": "^3.1.0",
50-
"@salesforce/source-deploy-retrieve": "^10.9.0",
50+
"@salesforce/source-deploy-retrieve": "^10.9.1",
5151
"@salesforce/ts-types": "^2.0.9",
5252
"fast-xml-parser": "^4.3.6",
5353
"graceful-fs": "^4.2.11",
@@ -61,7 +61,7 @@
6161
"eslint-plugin-sf-plugin": "^1.17.4",
6262
"ts-node": "^10.9.2",
6363
"ts-patch": "^3.1.2",
64-
"typescript": "^5.4.3"
64+
"typescript": "^5.4.4"
6565
},
6666
"config": {},
6767
"publishConfig": {

src/shared/localComponentSetArray.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ import {
1717
import { sourceComponentGuard } from './guards';
1818
import { supportsPartialDelete, pathIsInFolder } from './functions';
1919

20-
interface GroupedFileInput {
20+
type GroupedFileInput = {
2121
packageDirs: NamedPackageDir[];
2222
nonDeletes: string[];
2323
deletes: string[];
24-
}
25-
interface GroupedFile {
24+
};
25+
type GroupedFile = {
2626
path: string;
2727
nonDeletes: string[];
2828
deletes: string[];
29-
}
29+
};
3030

3131
export const getGroupedFiles = (input: GroupedFileInput, byPackageDir = false): GroupedFile[] =>
3232
(byPackageDir ? getSequential(input) : getNonSequential(input)).filter(

src/shared/localShadowRepo.ts

+10-13
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ const redirectToCliRepoError = (e: unknown): never => {
3434
throw e;
3535
};
3636

37-
interface ShadowRepoOptions {
37+
type ShadowRepoOptions = {
3838
orgId: string;
3939
projectPath: string;
4040
packageDirs: NamedPackageDir[];
41-
}
41+
};
4242

4343
// https://isomorphic-git.org/docs/en/statusMatrix#docsNav
4444
type StatusRow = [file: string, head: number, workdir: number, stage: number];
@@ -48,12 +48,12 @@ const FILE = 0;
4848
const HEAD = 1;
4949
const WORKDIR = 2;
5050

51-
interface CommitRequest {
51+
type CommitRequest = {
5252
deployedFiles?: string[];
5353
deletedFiles?: string[];
5454
message?: string;
5555
needsUpdatedStatus?: boolean;
56-
}
56+
};
5757

5858
export class ShadowRepo {
5959
private static instanceMap = new Map<string, ShadowRepo>();
@@ -256,16 +256,13 @@ export class ShadowRepo {
256256
deployedFiles: deployedFiles.length,
257257
deletedFiles: deletedFiles.length,
258258
});
259-
// these are stored in posix/style/path format. We have to convert inbound stuff from windows
260-
if (this.isWindows) {
261-
this.logger.trace('start: transforming windows paths to posix');
262-
deployedFiles = deployedFiles.map(normalize).map(ensurePosix);
263-
deletedFiles = deletedFiles.map(normalize).map(ensurePosix);
264-
this.logger.trace('done: transforming windows paths to posix');
265-
}
266259

267260
if (deployedFiles.length) {
268-
const chunks = chunkArray([...new Set(deployedFiles)], this.maxFileAdd);
261+
const chunks = chunkArray(
262+
// these are stored in posix/style/path format. We have to convert inbound stuff from windows
263+
[...new Set(this.isWindows ? deployedFiles.map(normalize).map(ensurePosix) : deployedFiles)],
264+
this.maxFileAdd
265+
);
269266
for (const chunk of chunks) {
270267
try {
271268
this.logger.debug(`adding ${chunk.length} files of ${deployedFiles.length} deployedFiles to git`);
@@ -297,7 +294,7 @@ export class ShadowRepo {
297294
}
298295
}
299296

300-
for (const filepath of [...new Set(deletedFiles)]) {
297+
for (const filepath of [...new Set(this.isWindows ? deletedFiles.map(normalize).map(ensurePosix) : deletedFiles)]) {
301298
try {
302299
// these need to be done sequentially because isogit manages file locking. Isogit remove does not support multiple files at once
303300
// eslint-disable-next-line no-await-in-loop

src/shared/remoteSourceTrackingService.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ const CONSECUTIVE_EMPTY_POLLING_RESULT_LIMIT =
4242
(env.getNumber('SFDX_SOURCE_MEMBER_POLLING_TIMEOUT') ?? 120) / Duration.milliseconds(POLLING_DELAY_MS).seconds;
4343

4444
/** Options for RemoteSourceTrackingService.getInstance */
45-
export interface RemoteSourceTrackingServiceOptions {
45+
export type RemoteSourceTrackingServiceOptions = {
4646
org: Org;
4747
projectPath: string;
48-
}
48+
};
4949

5050
/**
5151
* This service handles source tracking of metadata between a local project and an org.

src/shared/types.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import { FileResponse, SourceComponent } from '@salesforce/source-deploy-retrieve';
99
import { SfError } from '@salesforce/core';
1010

11-
export interface ChangeOptions {
11+
export type ChangeOptions = {
1212
origin: 'local' | 'remote';
1313
state: 'add' | 'delete' | 'modify' | 'nondelete';
1414
format: 'ChangeResult' | 'SourceComponent' | 'string' | 'ChangeResultWithPaths';
15-
}
15+
};
1616

1717
export type RemoteSyncInput = Pick<FileResponse, 'fullName' | 'filePath' | 'type' | 'state'>;
1818

@@ -21,10 +21,10 @@ export type StatusOutputRow = Pick<FileResponse, 'fullName' | 'filePath' | 'type
2121
ignored?: boolean;
2222
} & Pick<ChangeOptions, 'origin' | 'state'>;
2323

24-
export interface LocalUpdateOptions {
24+
export type LocalUpdateOptions = {
2525
files?: string[];
2626
deletedFiles?: string[];
27-
}
27+
};
2828

2929
export type RemoteChangeElement = {
3030
name: string;
@@ -57,12 +57,12 @@ export type SourceMember = {
5757
ignored?: boolean;
5858
};
5959

60-
export interface ConflictResponse {
60+
export type ConflictResponse = {
6161
state: 'Conflict';
6262
fullName: string;
6363
type: string;
6464
filePath: string;
65-
}
65+
};
6666

6767
// this and the related class are not enforced but a convention of this library.
6868
// This helps the consumers get correct typing--if the error name matches SourceConflictError,

src/sourceTracking.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ import { populateFilePaths } from './shared/populateFilePaths';
6868
import { populateTypesAndNames } from './shared/populateTypesAndNames';
6969
import { getComponentSets, getGroupedFiles } from './shared/localComponentSetArray';
7070
import { sourceComponentIsCustomLabel } from './shared/functions';
71-
export interface SourceTrackingOptions {
71+
export type SourceTrackingOptions = {
7272
org: Org;
7373
project: SfProject;
7474

@@ -87,7 +87,7 @@ export interface SourceTrackingOptions {
8787
* If you're using STL as part of a long running process (ex: vscode extensions), set this to false
8888
*/
8989
ignoreLocalCache?: boolean;
90-
}
90+
};
9191

9292
type RemoteChangesResults = {
9393
componentSetFromNonDeletes: ComponentSet;

yarn.lock

+8-8
Original file line numberDiff line numberDiff line change
@@ -670,10 +670,10 @@
670670
resolved "https://registry.yarnpkg.com/@salesforce/schemas/-/schemas-1.7.0.tgz#b7e0af3ee414ae7160bce351c0184d77ccb98fe3"
671671
integrity sha512-Z0PiCEV55khm0PG+DsnRYCjaDmacNe3HDmsoSm/CSyYvJJm+D5vvkHKN9/PKD/gaRe8XAU836yfamIYFblLINw==
672672

673-
"@salesforce/source-deploy-retrieve@^10.9.0":
674-
version "10.9.0"
675-
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-10.9.0.tgz#eb7b824a9ec643828bae22317f44327af617ca92"
676-
integrity sha512-BOcOsoizC9rOTciNUmzvu5R51GJIXdcrLwdR+MwAWohIvQNa90R7BdxBS3YSIep7epi5lXUWQpPGQAKDumuaZA==
673+
"@salesforce/source-deploy-retrieve@^10.9.1":
674+
version "10.9.1"
675+
resolved "https://registry.yarnpkg.com/@salesforce/source-deploy-retrieve/-/source-deploy-retrieve-10.9.1.tgz#315981e58e684b4fe49dd812b3e3c6a3daf92bf6"
676+
integrity sha512-FmSO6F4DFv7CqtFIzs0v8yuMlEie+hG2fq7QrBmhBxd6+1WNfk7wM3vXZyO0zOv9uarkILStB5+Dy91DYVrRHw==
677677
dependencies:
678678
"@salesforce/core" "^6.7.3"
679679
"@salesforce/kit" "^3.1.0"
@@ -5656,10 +5656,10 @@ typedoc@^0.25.12:
56565656
minimatch "^9.0.3"
56575657
shiki "^0.14.7"
56585658

5659-
"typescript@^4.6.4 || ^5.0.0", typescript@^5.4.3:
5660-
version "5.4.3"
5661-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.3.tgz#5c6fedd4c87bee01cd7a528a30145521f8e0feff"
5662-
integrity sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==
5659+
"typescript@^4.6.4 || ^5.0.0", typescript@^5.4.3, typescript@^5.4.4:
5660+
version "5.4.4"
5661+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.4.tgz#eb2471e7b0a5f1377523700a21669dce30c2d952"
5662+
integrity sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==
56635663

56645664
unbox-primitive@^1.0.2:
56655665
version "1.0.2"

0 commit comments

Comments
 (0)