Skip to content

Commit

Permalink
Merge pull request #1910 from Automattic/dependabot/npm_and_yarn/auto…
Browse files Browse the repository at this point in the history
…mattic/eslint-plugin-wpvip-0.12.0

build(deps-dev): bump @automattic/eslint-plugin-wpvip from 0.11.0 to 0.12.0
  • Loading branch information
sjinks authored Jun 28, 2024
2 parents 05a2a83 + 7cdeec5 commit 2bb77f6
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 114 deletions.
14 changes: 7 additions & 7 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
},
"homepage": "https://github.com/Automattic/vip#readme",
"devDependencies": {
"@automattic/eslint-plugin-wpvip": "0.11.0",
"@automattic/eslint-plugin-wpvip": "0.12.0",
"@babel/cli": "7.24.7",
"@babel/core": "7.24.7",
"@babel/preset-env": "7.24.7",
Expand Down
28 changes: 14 additions & 14 deletions src/commands/backup-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ async function createBackupJob( appId: number, envId: number ) {

// Library for a possible command in the future: vip backup db @app.env
export class BackupDBCommand {
app: App;
env: AppEnvironment;
job?: Job;
jobStatus?: string;
jobAge?: number;
backupName?: string;
silent?: boolean;
steps = {
public app: App;
public env: AppEnvironment;
public job?: Job;
public jobStatus?: string;
public jobAge?: number;
public backupName?: string;
public silent?: boolean;
public steps = {
PREPARE: 'prepare',
GENERATE: 'generate',
};
track: CommandTracker;
public track: CommandTracker;
private progressTracker: ProgressTracker;

constructor( app: App, env: AppEnvironment, trackerFn: CommandTracker = async () => {} ) {
Expand All @@ -111,14 +111,14 @@ export class BackupDBCommand {
this.track = trackerFn;
}

log( msg: string ) {
public log( msg: string ) {
if ( this.silent ) {
return;
}
console.log( msg );
}

isDone( job?: Job ) {
private isDone( job?: Job ) {
return ! job?.inProgressLock;
}

Expand All @@ -127,12 +127,12 @@ export class BackupDBCommand {
*
* @return {void}
*/
stopProgressTracker() {
private stopProgressTracker() {
this.progressTracker.print();
this.progressTracker.stopPrinting();
}

async loadBackupJob() {
public async loadBackupJob() {
this.job = await getBackupJob( this.app.id ?? 0, this.env.id ?? 0 );
this.backupName =
this.job?.metadata?.find( meta => meta?.name === 'backupName' )?.value ?? 'Unknown';
Expand All @@ -148,7 +148,7 @@ export class BackupDBCommand {
return this.job;
}

async run( silent = false ) {
public async run( silent = false ) {
this.silent = silent;

await this.loadBackupJob();
Expand Down
22 changes: 11 additions & 11 deletions src/commands/phpmyadmin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ async function getPhpMyAdminStatus( appId: number, envId: number ): Promise< str
}

export class PhpMyAdminCommand {
app: App;
env: AppEnvironment;
silent?: boolean;
track: CommandTracker;
steps = {
private app: App;
private env: AppEnvironment;
private silent?: boolean;
private track: CommandTracker;
private steps = {
ENABLE: 'enable',
GENERATE: 'generate',
};
Expand All @@ -138,28 +138,28 @@ export class PhpMyAdminCommand {
] );
}

log( msg: string ): void {
private log( msg: string ): void {
if ( this.silent ) {
return;
}
console.log( msg );
}

stopProgressTracker(): void {
private stopProgressTracker(): void {
this.progressTracker.print();
this.progressTracker.stopPrinting();
}

async openUrl( url: string ): Promise< void > {
public async openUrl( url: string ): Promise< void > {
const { default: open } = await import( 'open' );
void open( url, { wait: false } );
}

async getStatus(): Promise< string > {
public async getStatus(): Promise< string > {
return await getPhpMyAdminStatus( this.app.id as number, this.env.id as number );
}

async maybeEnablePhpMyAdmin(): Promise< void > {
private async maybeEnablePhpMyAdmin(): Promise< void > {
const status = await this.getStatus();
if ( ! [ 'running', 'enabled' ].includes( status ) ) {
await enablePhpMyAdmin( this.env.id as number );
Expand All @@ -170,7 +170,7 @@ export class PhpMyAdminCommand {
}
}

async run( silent = false ): Promise< void > {
public async run( silent = false ): Promise< void > {
this.silent = silent;

if ( ! this.app.id ) {
Expand Down
9 changes: 6 additions & 3 deletions src/lib/analytics/clients/pendo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Pendo implements AnalyticsClient {
private userId: string;
private context: Env & Record< string, unknown > & { userId?: string };

static readonly ENDPOINT = '/pendo';
public static readonly ENDPOINT = '/pendo';

constructor( options: PendoOptions ) {
this.eventPrefix = options.eventPrefix;
Expand All @@ -32,7 +32,7 @@ export default class Pendo implements AnalyticsClient {
this.context = { ...options.env };
}

async trackEvent(
public async trackEvent(
eventName: string,
eventProps: Record< string, unknown > = {}
): Promise< Response | false > {
Expand All @@ -58,7 +58,10 @@ export default class Pendo implements AnalyticsClient {
}
}

async send( eventName: string, eventProps: Record< string, unknown > ): Promise< Response > {
public async send(
eventName: string,
eventProps: Record< string, unknown >
): Promise< Response > {
const body = {
context: this.context,
event: eventName,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/analytics/clients/tracks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class Tracks implements AnalyticsClient {
private userAgent: string;
private baseParams: BaseParams;

static readonly ENDPOINT = 'https://public-api.wordpress.com/rest/v1.1/tracks/record';
public static readonly ENDPOINT = 'https://public-api.wordpress.com/rest/v1.1/tracks/record';

constructor( userId: string, userType: string, eventPrefix: string, env: Env ) {
this.eventPrefix = eventPrefix;
Expand All @@ -44,7 +44,7 @@ export default class Tracks implements AnalyticsClient {
};
}

async trackEvent(
public async trackEvent(
name: string,
eventProps: Record< string, unknown > = {}
): Promise< Response | false > {
Expand Down Expand Up @@ -111,7 +111,7 @@ export default class Tracks implements AnalyticsClient {
return false;
}

send( extraParams: Record< string, unknown > ): Promise< Response > {
public send( extraParams: Record< string, unknown > ): Promise< Response > {
const params = { ...this.baseParams, ...extraParams };

const method = 'POST';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Analytics {
this.clients = clients;
}

async trackEvent(
public async trackEvent(
name: string,
props: Record< string, unknown > = {}
): Promise< ( Response | false )[] > {
Expand Down
30 changes: 15 additions & 15 deletions src/lib/backup-storage-availability/backup-storage-availability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export interface PromptStatus {
}

export class BackupStorageAvailability {
archiveSize: number;
private archiveSize: number;

constructor( archiveSize: number ) {
this.archiveSize = archiveSize;
}

static createFromDbCopyJob( job: Job ): BackupStorageAvailability {
public static createFromDbCopyJob( job: Job ): BackupStorageAvailability {
const bytesWrittenMeta = job.metadata?.find( meta => meta?.name === 'bytesWritten' );
if ( ! bytesWrittenMeta?.value ) {
throw new Error( 'Meta not found' );
Expand All @@ -32,15 +32,15 @@ export class BackupStorageAvailability {
return new BackupStorageAvailability( Number( bytesWrittenMeta.value ) );
}

getDockerStorageKiBRaw(): string | undefined {
public getDockerStorageKiBRaw(): string | undefined {
return exec( `docker run --rm alpine df -k`, { silent: true } )
.grep( /\/dev\/vda1/ )
.head( { '-n': 1 } )
.replace( /\s+/g, ' ' )
.split( ' ' )[ 3 ];
}

getDockerStorageAvailable(): number {
public getDockerStorageAvailable(): number {
const kiBLeft = this.getDockerStorageKiBRaw();

if ( ! kiBLeft || Number.isNaN( Number( kiBLeft ) ) ) {
Expand All @@ -50,48 +50,48 @@ export class BackupStorageAvailability {
return Number( kiBLeft ) * 1024;
}

bytesToHuman( bytes: number ) {
public bytesToHuman( bytes: number ) {
return formatMetricBytes( bytes );
}

async getStorageAvailableInVipPath() {
public async getStorageAvailableInVipPath() {
const vipDir = path.join( xdgBasedir.data ?? os.tmpdir(), 'vip' );

const diskSpace = await checkDiskSpace( vipDir );
return diskSpace.free;
}

getReserveSpace(): number {
public getReserveSpace(): number {
return oneGiBInBytes;
}

getSqlSize(): number {
public getSqlSize(): number {
// We estimated that it'd be about 3.5x the archive size.
return this.archiveSize * 3.5;
}

getArchiveSize(): number {
public getArchiveSize(): number {
return this.archiveSize;
}

getStorageRequiredInMainMachine(): number {
public getStorageRequiredInMainMachine(): number {
return this.getArchiveSize() + this.getSqlSize() + this.getReserveSpace();
}

getStorageRequiredInDockerMachine(): number {
public getStorageRequiredInDockerMachine(): number {
return this.getSqlSize() + this.getReserveSpace();
}

async isStorageAvailableInMainMachine(): Promise< boolean > {
public async isStorageAvailableInMainMachine(): Promise< boolean > {
return ( await this.getStorageAvailableInVipPath() ) > this.getStorageRequiredInMainMachine();
}

isStorageAvailableInDockerMachine(): boolean {
public isStorageAvailableInDockerMachine(): boolean {
return this.getDockerStorageAvailable() > this.getStorageRequiredInDockerMachine();
}

// eslint-disable-next-line id-length
async validateAndPromptDiskSpaceWarningForBackupImport(): Promise< PromptStatus > {
public async validateAndPromptDiskSpaceWarningForBackupImport(): Promise< PromptStatus > {
const isStorageAvailable =
( await this.getStorageAvailableInVipPath() ) > this.getArchiveSize();
if ( ! isStorageAvailable ) {
Expand All @@ -115,7 +115,7 @@ export class BackupStorageAvailability {
}

// eslint-disable-next-line id-length
async validateAndPromptDiskSpaceWarningForDevEnvBackupImport(): Promise< PromptStatus > {
public async validateAndPromptDiskSpaceWarningForDevEnvBackupImport(): Promise< PromptStatus > {
let storageAvailableInMainMachinePrompted = false;

// there's two prompts, so as long as one prompt is shown, we need to set isPromptShown
Expand Down
6 changes: 3 additions & 3 deletions src/lib/cli/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,19 @@ export function capitalize( str: unknown ): string {
export const RUNNING_SPRITE_GLYPHS = [ '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' ];

export class RunningSprite {
count: number;
private count: number;

constructor() {
this.count = 0;
}

next() {
public next() {
if ( ++this.count >= RUNNING_SPRITE_GLYPHS.length ) {
this.count = 0;
}
}

toString() {
public toString() {
const glyph = RUNNING_SPRITE_GLYPHS[ this.count ];
this.next(); // TODO: throttle
return glyph;
Expand Down
Loading

0 comments on commit 2bb77f6

Please sign in to comment.