Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/cpu-profile-summarizer/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ function writeSummaryToTsv(tsvPath: string, summary: IProfileSummary): void {
}

class CpuProfileSummarizerCommandLineParser extends CommandLineParser {
private readonly _inputParameter: CommandLineStringListParameter;
private readonly _outputParameter: IRequiredCommandLineStringParameter;
readonly #inputParameter: CommandLineStringListParameter;
readonly #outputParameter: IRequiredCommandLineStringParameter;

public constructor() {
super({
Expand All @@ -130,15 +130,15 @@ class CpuProfileSummarizerCommandLineParser extends CommandLineParser {
'For example, those generated by running `node --cpu-prof`.'
});

this._inputParameter = this.defineStringListParameter({
this.#inputParameter = this.defineStringListParameter({
parameterLongName: '--input',
parameterShortName: '-i',
description: 'The directory containing .cpuprofile files to summarize',
argumentName: 'DIR',
required: true
});

this._outputParameter = this.defineStringParameter({
this.#outputParameter = this.defineStringParameter({
parameterLongName: '--output',
parameterShortName: '-o',
description: 'The output file to write the summary to',
Expand All @@ -148,8 +148,8 @@ class CpuProfileSummarizerCommandLineParser extends CommandLineParser {
}

protected override async onExecuteAsync(): Promise<void> {
const input: readonly string[] = this._inputParameter.values;
const output: string = this._outputParameter.value;
const input: readonly string[] = this.#inputParameter.values;
const output: string = this.#outputParameter.value;

if (input.length === 0) {
throw new Error('No input directories provided');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ function printUpdateNotification(
export class ExplorerCommandLineParser extends CommandLineParser {
public readonly globalTerminal: ITerminal;

private readonly _debugParameter: CommandLineFlagParameter;
private readonly _subspaceParameter: IRequiredCommandLineStringParameter;
readonly #debugParameter: CommandLineFlagParameter;
readonly #subspaceParameter: IRequiredCommandLineStringParameter;

public constructor(terminal: ITerminal) {
super({
Expand All @@ -61,13 +61,13 @@ export class ExplorerCommandLineParser extends CommandLineParser {
'Lockfile Explorer is a desktop app for investigating and solving version conflicts in a PNPM workspace.'
});

this._debugParameter = this.defineFlagParameter({
this.#debugParameter = this.defineFlagParameter({
parameterLongName: '--debug',
parameterShortName: '-d',
description: 'Show the full call stack if an error occurs while executing the tool'
});

this._subspaceParameter = this.defineStringParameter({
this.#subspaceParameter = this.defineStringParameter({
parameterLongName: '--subspace',
argumentName: 'SUBSPACE_NAME',
description: 'Specifies an individual Rush subspace to check.',
Expand All @@ -78,7 +78,7 @@ export class ExplorerCommandLineParser extends CommandLineParser {
}

public get isDebug(): boolean {
return this._debugParameter.value;
return this.#debugParameter.value;
}

protected override async onExecuteAsync(): Promise<void> {
Expand Down Expand Up @@ -106,7 +106,7 @@ export class ExplorerCommandLineParser extends CommandLineParser {
const appState: IAppState = init({
appVersion: LFX_VERSION,
debugMode: this.isDebug,
subspaceName: this._subspaceParameter.value
subspaceName: this.#subspaceParameter.value
});

const lfxWorkspace: IJsonLfxWorkspace = appState.lfxWorkspace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class LintCommandLineParser extends CommandLineParser {

this.globalTerminal = terminal;

this._populateActions();
this.#populateActions();
}

protected override async onExecuteAsync(): Promise<void> {
Expand All @@ -33,7 +33,7 @@ export class LintCommandLineParser extends CommandLineParser {
await super.onExecuteAsync();
}

private _populateActions(): void {
#populateActions(): void {
const terminal: ITerminal = this.globalTerminal;
this.addAction(new InitAction(terminal));
this.addAction(new CheckAction(terminal));
Expand Down
58 changes: 29 additions & 29 deletions apps/lockfile-explorer/src/cli/lint/actions/CheckAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export interface ILintIssue {
}

export class CheckAction extends CommandLineAction {
private readonly _terminal: ITerminal;
readonly #terminal: ITerminal;

private _rushConfiguration!: RushConfiguration;
private _checkedProjects: Set<RushConfigurationProject>;
private _docMap: Map<string, lockfileTypes.LockfileObject>;
#rushConfiguration!: RushConfiguration;
#checkedProjects: Set<RushConfigurationProject>;
#docMap: Map<string, lockfileTypes.LockfileObject>;

public constructor(terminal: ITerminal) {
super({
Expand All @@ -54,12 +54,12 @@ export class CheckAction extends CommandLineAction {
', reporting any problems found in your PNPM workspace.'
});

this._terminal = terminal;
this._checkedProjects = new Set();
this._docMap = new Map();
this.#terminal = terminal;
this.#checkedProjects = new Set();
this.#docMap = new Map();
}

private async _checkVersionCompatibilityAsync(
async #checkVersionCompatibilityAsync(
shrinkwrapFileMajorVersion: number,
packages: lockfileTypes.PackageSnapshots | undefined,
dependencyPath: pnpmTypes.DepPath,
Expand All @@ -79,7 +79,7 @@ export class CheckAction extends CommandLineAction {
await Promise.all(
Object.entries(packages[dependencyPath].dependencies ?? {}).map(
async ([dependencyPackageName, dependencyPackageVersion]) => {
await this._checkVersionCompatibilityAsync(
await this.#checkVersionCompatibilityAsync(
shrinkwrapFileMajorVersion,
packages,
splicePackageWithVersion(
Expand All @@ -96,22 +96,22 @@ export class CheckAction extends CommandLineAction {
}
}

private async _searchAndValidateDependenciesAsync(
async #searchAndValidateDependenciesAsync(
project: RushConfigurationProject,
requiredVersions: Record<string, string>
): Promise<void> {
this._terminal.writeLine(`Checking project "${project.packageName}"`);
this.#terminal.writeLine(`Checking project "${project.packageName}"`);

const projectFolder: string = project.projectFolder;
const subspace: Subspace = project.subspace;
const shrinkwrapFilename: string = subspace.getCommittedShrinkwrapFilePath();
let doc: lockfileTypes.LockfileObject;
if (this._docMap.has(shrinkwrapFilename)) {
doc = this._docMap.get(shrinkwrapFilename)!;
if (this.#docMap.has(shrinkwrapFilename)) {
doc = this.#docMap.get(shrinkwrapFilename)!;
} else {
const pnpmLockfileText: string = await FileSystem.readFileAsync(shrinkwrapFilename);
doc = yaml.load(pnpmLockfileText) as lockfileTypes.LockfileObject;
this._docMap.set(shrinkwrapFilename, doc);
this.#docMap.set(shrinkwrapFilename, doc);
}
const { importers, lockfileVersion, packages } = doc;
const shrinkwrapFileMajorVersion: number = getShrinkwrapFileMajorVersion(lockfileVersion);
Expand All @@ -136,13 +136,13 @@ export class CheckAction extends CommandLineAction {
) as pnpmTypes.DepPath;
if (fullDependencyPath.includes('link:')) {
const dependencyProject: RushConfigurationProject | undefined =
this._rushConfiguration.getProjectByName(dependencyName);
if (dependencyProject && !this._checkedProjects?.has(dependencyProject)) {
this._checkedProjects!.add(project);
await this._searchAndValidateDependenciesAsync(dependencyProject, requiredVersions);
this.#rushConfiguration.getProjectByName(dependencyName);
if (dependencyProject && !this.#checkedProjects?.has(dependencyProject)) {
this.#checkedProjects!.add(project);
await this.#searchAndValidateDependenciesAsync(dependencyProject, requiredVersions);
}
} else {
await this._checkVersionCompatibilityAsync(
await this.#checkVersionCompatibilityAsync(
shrinkwrapFileMajorVersion,
packages,
fullDependencyPath,
Expand All @@ -156,20 +156,20 @@ export class CheckAction extends CommandLineAction {
);
}

private async _performVersionRestrictionCheckAsync(
async #performVersionRestrictionCheckAsync(
requiredVersions: Record<string, string>,
projectName: string
): Promise<string | undefined> {
try {
const project: RushConfigurationProject | undefined =
this._rushConfiguration?.getProjectByName(projectName);
this.#rushConfiguration?.getProjectByName(projectName);
if (!project) {
throw new Error(
`Specified project "${projectName}" does not exist in ${LOCKFILE_LINT_JSON_FILENAME}`
);
}
this._checkedProjects.add(project);
await this._searchAndValidateDependenciesAsync(project, requiredVersions);
this.#checkedProjects.add(project);
await this.#searchAndValidateDependenciesAsync(project, requiredVersions);
return undefined;
} catch (e) {
return e.message;
Expand All @@ -183,10 +183,10 @@ export class CheckAction extends CommandLineAction {
'The "lockfile-explorer check" must be executed in a folder that is under a Rush workspace folder'
);
}
this._rushConfiguration = rushConfiguration!;
this.#rushConfiguration = rushConfiguration!;

const lintingFile: string = path.resolve(
this._rushConfiguration.commonFolder,
this.#rushConfiguration.commonFolder,
'config',
LOCKFILE_EXPLORER_FOLDERNAME,
LOCKFILE_LINT_JSON_FILENAME
Expand All @@ -201,7 +201,7 @@ export class CheckAction extends CommandLineAction {
async ({ requiredVersions, project, rule }) => {
switch (rule) {
case 'restrict-versions': {
const message: string | undefined = await this._performVersionRestrictionCheckAsync(
const message: string | undefined = await this.#performVersionRestrictionCheckAsync(
requiredVersions,
project
);
Expand All @@ -219,7 +219,7 @@ export class CheckAction extends CommandLineAction {
{ concurrency: 50 }
);
if (issues.length > 0) {
this._terminal.writeLine();
this.#terminal.writeLine();

// Deterministic order
for (const issue of issues.sort((a, b): number => {
Expand All @@ -233,13 +233,13 @@ export class CheckAction extends CommandLineAction {
}
return a.message.localeCompare(b.message);
})) {
this._terminal.writeLine(
this.#terminal.writeLine(
Colorize.red('PROBLEM: ') + Colorize.cyan(`[${issue.rule}] `) + issue.message + '\n'
);
}

throw new AlreadyReportedError();
}
this._terminal.writeLine(Colorize.green('SUCCESS: ') + 'All checks passed.');
this.#terminal.writeLine(Colorize.green('SUCCESS: ') + 'All checks passed.');
}
}
10 changes: 5 additions & 5 deletions apps/lockfile-explorer/src/cli/lint/actions/InitAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FileSystem } from '@rushstack/node-core-library';
import { LOCKFILE_EXPLORER_FOLDERNAME, LOCKFILE_LINT_JSON_FILENAME } from '../../../constants/common';

export class InitAction extends CommandLineAction {
private readonly _terminal: ITerminal;
readonly #terminal: ITerminal;

public constructor(terminal: ITerminal) {
super({
Expand All @@ -21,7 +21,7 @@ export class InitAction extends CommandLineAction {
`This command initializes a new ${LOCKFILE_LINT_JSON_FILENAME} config file.` +
` The created template file includes source code comments that document the settings.`
});
this._terminal = terminal;
this.#terminal = terminal;
}

protected override async onExecuteAsync(): Promise<void> {
Expand All @@ -43,12 +43,12 @@ export class InitAction extends CommandLineAction {
);

if (await FileSystem.existsAsync(outputFilePath)) {
this._terminal.writeError('The output file already exists:');
this._terminal.writeLine('\n ' + outputFilePath + '\n');
this.#terminal.writeError('The output file already exists:');
this.#terminal.writeLine('\n ' + outputFilePath + '\n');
throw new Error('Unable to write output file');
}

this._terminal.writeLine(Colorize.green('Writing file: ') + outputFilePath);
this.#terminal.writeLine(Colorize.green('Writing file: ') + outputFilePath);
await FileSystem.copyFileAsync({
sourcePath: inputFilePath,
destinationPath: outputFilePath
Expand Down
Loading
Loading