Skip to content

Commit

Permalink
Changes supporting microsoft/rushstack#4594
Browse files Browse the repository at this point in the history
  • Loading branch information
octogonz committed Mar 26, 2024
1 parent ffd4dfd commit 4103d50
Show file tree
Hide file tree
Showing 6 changed files with 283 additions and 181 deletions.
90 changes: 48 additions & 42 deletions packages/pnpm-sync-lib/etc/pnpm-sync-lib.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,7 @@ export interface ILockfilePackage {
// @beta (undocumented)
export interface ILogMessageCallbackOptions {
// (undocumented)
details: {
messageIdentifier: LogMessageIdentifier.PREPARE_STARTING;
lockfilePath: string;
dotPnpmFolderPath: string;
} | {
messageIdentifier: LogMessageIdentifier.PREPARE_PROCESSING;
lockfilePath: string;
dotPnpmFolderPath: string;
} | {
messageIdentifier: LogMessageIdentifier.PREPARE_FINISHING;
lockfilePath: string;
dotPnpmFolderPath: string;
executionTimeInMs: string;
} | {
messageIdentifier: LogMessageIdentifier.COPY_STARTING;
pnpmSyncJsonPath: string;
} | {
messageIdentifier: LogMessageIdentifier.COPY_PROCESSING;
pnpmSyncJsonPath: string;
} | {
messageIdentifier: LogMessageIdentifier.COPY_FINISHING;
pnpmSyncJsonPath: string;
fileCount: number;
executionTimeInMs: string;
};
details: LogMessageDetails;
// (undocumented)
message: string;
// (undocumented)
Expand All @@ -72,34 +48,24 @@ export interface ILogMessageCallbackOptions {

// @beta (undocumented)
export interface IPnpmSyncCopyOptions {
// (undocumented)
ensureFolder: (folderPath: string) => Promise<void>;
// (undocumented)
forEachAsyncWithConcurrency: <TItem>(iterable: Iterable<TItem>, callback: (item: TItem) => Promise<void>, options: {
concurrency: number;
}) => Promise<void>;
// (undocumented)
getPackageIncludedFiles: (packagePath: string) => Promise<string[]>;
// (undocumented)
logMessageCallback: (options: ILogMessageCallbackOptions) => void;
// (undocumented)
pnpmSyncJsonPath?: string;
pnpmSyncJsonPath: string;
}

// @beta (undocumented)
export interface IPnpmSyncPrepareOptions {
// (undocumented)
dotPnpmFolder: string;
ensureFolder: (folderPath: string) => Promise<void>;
// (undocumented)
lockfilePath: string;
// (undocumented)
logMessageCallback: (options: ILogMessageCallbackOptions) => void;
// (undocumented)
readPnpmLockfile: (lockfilePath: string, options: {
ignoreIncompatible: boolean;
}) => Promise<ILockfile | undefined>;
// (undocumented)
storePath: string;
}

// @beta (undocumented)
Expand All @@ -108,20 +74,60 @@ export type IVersionSpecifier = string | {
version: string;
};

// @beta (undocumented)
export type LogMessageDetails = {
messageIdentifier: LogMessageIdentifier.PREPARE_STARTING;
lockfilePath: string;
dotPnpmFolder: string;
} | {
messageIdentifier: LogMessageIdentifier.PREPARE_ERROR_UNSUPPORTED_FORMAT;
lockfilePath: string;
lockfileVersion: string | undefined;
} | {
messageIdentifier: LogMessageIdentifier.PREPARE_PROCESSING;
lockfilePath: string;
dotPnpmFolderPath: string;
} | {
messageIdentifier: LogMessageIdentifier.PREPARE_WRITING_FILE;
pnpmSyncJsonPath: string;
projectFolder: string;
} | {
messageIdentifier: LogMessageIdentifier.PREPARE_FINISHING;
lockfilePath: string;
dotPnpmFolder: string;
executionTimeInMs: number;
} | {
messageIdentifier: LogMessageIdentifier.COPY_STARTING;
pnpmSyncJsonPath: string;
} | {
messageIdentifier: LogMessageIdentifier.COPY_ERROR_NO_SYNC_FILE;
pnpmSyncJsonPath: string;
} | {
messageIdentifier: LogMessageIdentifier.COPY_FINISHING;
pnpmSyncJsonPath: string;
fileCount: number;
sourcePath: string;
executionTimeInMs: number;
};

// @beta (undocumented)
export enum LogMessageIdentifier {
// (undocumented)
COPY_FINISHING = "copy-finishing",
COPY_ERROR_NO_SYNC_FILE = "copy-error-no-sync-file",
// (undocumented)
COPY_PROCESSING = "copy-processing",
COPY_FINISHING = "copy-finishing",
// (undocumented)
COPY_STARTING = "copy-starting",
// (undocumented)
PREPARE_ERROR_UNSUPPORTED_FORMAT = "prepare-error-unsupported-format",
// (undocumented)
PREPARE_FINISHING = "prepare-finishing",
// (undocumented)
PREPARE_PROCESSING = "prepare-processing",
// (undocumented)
PREPARE_STARTING = "prepare-starting"
PREPARE_STARTING = "prepare-starting",
// (undocumented)
PREPARE_WRITING_FILE = "prepare-writing-file"
}

// @beta (undocumented)
Expand All @@ -137,9 +143,9 @@ export enum LogMessageKind {
}

// @beta
export function pnpmSyncCopyAsync({ pnpmSyncJsonPath, getPackageIncludedFiles, forEachAsyncWithConcurrency, ensureFolder, logMessageCallback }: IPnpmSyncCopyOptions): Promise<void>;
export function pnpmSyncCopyAsync(options: IPnpmSyncCopyOptions): Promise<void>;

// @beta
export function pnpmSyncPrepareAsync({ lockfilePath, storePath, ensureFolder, readPnpmLockfile, logMessageCallback }: IPnpmSyncPrepareOptions): Promise<void>;
export function pnpmSyncPrepareAsync(options: IPnpmSyncPrepareOptions): Promise<void>;

```
2 changes: 1 addition & 1 deletion packages/pnpm-sync-lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

export { pnpmSyncCopyAsync, type IPnpmSyncCopyOptions } from './pnpmSyncCopy';
export { pnpmSyncPrepareAsync, type IPnpmSyncPrepareOptions } from './pnpmSyncPrepare';
export { LogMessageIdentifier, LogMessageKind } from './interfaces';
export { LogMessageIdentifier, LogMessageKind, LogMessageDetails } from './interfaces';
export type {
ILockfile,
ILockfileImporter,
Expand Down
85 changes: 53 additions & 32 deletions packages/pnpm-sync-lib/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,51 +29,72 @@ export enum LogMessageKind {
* @beta
*/
export enum LogMessageIdentifier {
// pnpmSyncPrepareAsync() messages
PREPARE_STARTING = 'prepare-starting',
PREPARE_ERROR_UNSUPPORTED_FORMAT = 'prepare-error-unsupported-format',
PREPARE_PROCESSING = 'prepare-processing',
PREPARE_WRITING_FILE = 'prepare-writing-file',
PREPARE_FINISHING = 'prepare-finishing',

// pnpmSyncCopyAsync() messages
COPY_STARTING = 'copy-starting',
COPY_PROCESSING = 'copy-processing',
COPY_ERROR_NO_SYNC_FILE = 'copy-error-no-sync-file',
COPY_FINISHING = 'copy-finishing'
}

/**
* @beta
*/
export type LogMessageDetails =
| {
messageIdentifier: LogMessageIdentifier.PREPARE_STARTING;
lockfilePath: string;
dotPnpmFolder: string;
}
| {
messageIdentifier: LogMessageIdentifier.PREPARE_ERROR_UNSUPPORTED_FORMAT;
lockfilePath: string;
lockfileVersion: string | undefined;
}
| {
messageIdentifier: LogMessageIdentifier.PREPARE_PROCESSING;
lockfilePath: string;
dotPnpmFolderPath: string;
}
| {
messageIdentifier: LogMessageIdentifier.PREPARE_WRITING_FILE;
pnpmSyncJsonPath: string;
projectFolder: string;
}
| {
messageIdentifier: LogMessageIdentifier.PREPARE_FINISHING;
lockfilePath: string;
dotPnpmFolder: string;
executionTimeInMs: number;
}
| {
messageIdentifier: LogMessageIdentifier.COPY_STARTING;
pnpmSyncJsonPath: string;
}
| {
messageIdentifier: LogMessageIdentifier.COPY_ERROR_NO_SYNC_FILE;
pnpmSyncJsonPath: string;
}
| {
messageIdentifier: LogMessageIdentifier.COPY_FINISHING;
pnpmSyncJsonPath: string;
fileCount: number;
sourcePath: string;
executionTimeInMs: number;
};

/**
* @beta
*/
export interface ILogMessageCallbackOptions {
message: string;
messageKind: LogMessageKind;
details:
| {
messageIdentifier: LogMessageIdentifier.PREPARE_STARTING;
lockfilePath: string;
dotPnpmFolderPath: string;
}
| {
messageIdentifier: LogMessageIdentifier.PREPARE_PROCESSING;
lockfilePath: string;
dotPnpmFolderPath: string;
}
| {
messageIdentifier: LogMessageIdentifier.PREPARE_FINISHING;
lockfilePath: string;
dotPnpmFolderPath: string;
executionTimeInMs: string;
}
| {
messageIdentifier: LogMessageIdentifier.COPY_STARTING;
pnpmSyncJsonPath: string;
}
| {
messageIdentifier: LogMessageIdentifier.COPY_PROCESSING;
pnpmSyncJsonPath: string;
}
| {
messageIdentifier: LogMessageIdentifier.COPY_FINISHING;
pnpmSyncJsonPath: string;
fileCount: number;
executionTimeInMs: string;
};
details: LogMessageDetails;
}

/**
Expand Down
Loading

0 comments on commit 4103d50

Please sign in to comment.