Skip to content

Commit

Permalink
chore: naming
Browse files Browse the repository at this point in the history
  • Loading branch information
g-chao committed Jun 6, 2024
1 parent 82e34f3 commit 8f5ca35
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/pnpm-sync-lib/etc/pnpm-sync-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface IPnpmSyncCopyOptions {
export interface IPnpmSyncPrepareOptions {
dotPnpmFolder: string;
ensureFolderAsync: (folderPath: string) => Promise<void>;
identifier?: string;
lockfileId?: string;
lockfilePath: string;
logMessageCallback: (options: ILogMessageCallbackOptions) => void;
readPnpmLockfile: (lockfilePath: string, options: {
Expand Down
2 changes: 1 addition & 1 deletion packages/pnpm-sync-lib/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface IPnpmSyncJson {

export interface ITargetFolder {
folderPath: string;
identifier?: string;
lockfileId?: string;
}

export interface ISyncItem {
Expand Down
18 changes: 9 additions & 9 deletions packages/pnpm-sync-lib/src/pnpmSyncPrepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export interface IPnpmSyncPrepareOptions {
dotPnpmFolder: string;

/**
* An identifier that can be used to recognize the `pnpm-lock.yaml`
* A lockfileId that can be used to recognize the `pnpm-lock.yaml`
*/
identifier?: string;
lockfileId?: string;

/**
* Environment-provided API to avoid an NPM dependency.
Expand Down Expand Up @@ -69,7 +69,7 @@ export interface IPnpmSyncPrepareOptions {
* @beta
*/
export async function pnpmSyncPrepareAsync(options: IPnpmSyncPrepareOptions): Promise<void> {
const { identifier, ensureFolderAsync, readPnpmLockfile, logMessageCallback } = options;
const { lockfileId, ensureFolderAsync, readPnpmLockfile, logMessageCallback } = options;
let { lockfilePath, dotPnpmFolder } = options;

// get the pnpm-lock.yaml path
Expand Down Expand Up @@ -220,12 +220,12 @@ export async function pnpmSyncPrepareAsync(options: IPnpmSyncPrepareOptions): Pr

const actualPnpmSyncJsonVersion: string = existingPnpmSyncJsonFile?.version;
if (actualPnpmSyncJsonVersion === expectedPnpmSyncJsonVersion) {
// If an identifier is provided
// then all entries with this identifier should be deleted
// If a lockfileId is provided
// then all entries with this lockfileId should be deleted
// they will be regenerated later
if (identifier) {
if (lockfileId) {
const filteredTargetFolders = existingPnpmSyncJsonFile.postbuildInjectedCopy.targetFolders.filter(
(targetFolder) => targetFolder?.identifier !== identifier
(targetFolder) => targetFolder?.lockfileId !== lockfileId
);
existingPnpmSyncJsonFile.postbuildInjectedCopy.targetFolders = filteredTargetFolders;
}
Expand Down Expand Up @@ -262,8 +262,8 @@ export async function pnpmSyncPrepareAsync(options: IPnpmSyncPrepareOptions): Pr
folderPath: relativePath
};

if (identifier) {
targetFolderItem.identifier = identifier;
if (lockfileId) {
targetFolderItem.lockfileId = lockfileId;
}

pnpmSyncJsonFile.postbuildInjectedCopy.targetFolders.push(targetFolderItem);
Expand Down
12 changes: 6 additions & 6 deletions tests/pnpm-sync-api-test/src/test/pnpmSyncPrepare.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,17 @@ describe('pnpm-sync-api prepare test', () => {
{
folderPath:
'../../../../node_modules/.pnpm/[email protected]/node_modules/api-demo-sample-lib1',
identifier: 'identifier1'
lockfileId: 'identifier1'
},
{
folderPath:
'../../../../node_modules/.pnpm/[email protected]/node_modules/api-demo-sample-lib2',
identifier: 'identifier1'
lockfileId: 'identifier1'
},
{
folderPath:
'../../../../node_modules/.pnpm/[email protected]/node_modules/api-demo-sample-lib3',
identifier: 'identifier2'
lockfileId: 'identifier2'
}
]
}
Expand All @@ -244,7 +244,7 @@ describe('pnpm-sync-api prepare test', () => {
await pnpmSyncPrepareAsync({
lockfilePath: lockfilePath,
dotPnpmFolder: dotPnpmFolder,
identifier: 'identifier1',
lockfileId: 'identifier1',
ensureFolderAsync: FileSystem.ensureFolderAsync,
readPnpmLockfile,
logMessageCallback: (): void => {}
Expand All @@ -263,12 +263,12 @@ describe('pnpm-sync-api prepare test', () => {
{
folderPath:
'../../../../node_modules/.pnpm/[email protected]/node_modules/api-demo-sample-lib3',
identifier: 'identifier2'
lockfileId: 'identifier2'
},
{
folderPath:
'../../../../node_modules/.pnpm/[email protected]/node_modules/api-demo-sample-lib1',
identifier: 'identifier1'
lockfileId: 'identifier1'
}
]
}
Expand Down

0 comments on commit 8f5ca35

Please sign in to comment.