Skip to content
156 changes: 96 additions & 60 deletions npm-shrinkwrap.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"https-proxy-agent": "^7.0.6",
"js-yaml": "^4.1.0",
"jwt-decode": "4.0.0",
"lando": "github:automattic/lando-cli#bff037ea318948a1bac623c12ede017928cb99db",
"lando": "github:automattic/lando-cli#459ac2d44ac3db17719493e879d52178410ff70e",
"node-fetch": "^3.3.2",
"node-stream-zip": "1.15.0",
"open": "^11.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/bin/vip-dev-env-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
processStringOrBooleanOption,
processSlug,
ensureValidPathsInOptions,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import {
getConfigurationFileOptions,
Expand Down Expand Up @@ -102,7 +103,7 @@ cmd.argv( process.argv, async ( arg, opt ) => {
slug = await getEnvironmentName( environmentNameOptions );
}

const lando = await bootstrapLando();
const lando = await bootstrapLando( { logFile: getDevEnvLogFile( slug ) } );
validateDependencies( lando );

debug( 'Args: ', arg, 'Options: ', opt );
Expand Down
3 changes: 2 additions & 1 deletion src/bin/vip-dev-env-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
handleCLIException,
processSlug,
validateDependencies,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import { destroyEnvironment } from '../lib/dev-environment/dev-environment-core';
import { bootstrapLando } from '../lib/dev-environment/dev-environment-lando';
Expand Down Expand Up @@ -50,7 +51,7 @@ command( {
.argv( process.argv, async ( arg, opt ) => {
const slug = await getEnvironmentName( opt );

const lando = await bootstrapLando();
const lando = await bootstrapLando( { logFile: getDevEnvLogFile( slug ) } );
validateDependencies( lando );

const trackingInfo = getEnvTrackingInfo( slug );
Expand Down
3 changes: 2 additions & 1 deletion src/bin/vip-dev-env-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
processBooleanOption,
processSlug,
validateDependencies,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import { exec, getEnvironmentPath } from '../lib/dev-environment/dev-environment-core';
import { bootstrapLando, isEnvUp } from '../lib/dev-environment/dev-environment-lando';
Expand Down Expand Up @@ -56,7 +57,7 @@ command( {
.examples( examples )
.argv( process.argv, async ( unmatchedArgs, opt ) => {
const slug = await getEnvironmentName( opt );
const lando = await bootstrapLando();
const lando = await bootstrapLando( { logFile: getDevEnvLogFile( slug ) } );
validateDependencies( lando );

const trackingInfo = getEnvTrackingInfo( slug );
Expand Down
5 changes: 3 additions & 2 deletions src/bin/vip-dev-env-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
handleCLIException,
processSlug,
validateDependencies,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import {
printEnvironmentInfo,
Expand Down Expand Up @@ -47,16 +48,16 @@ command( {
.argv( process.argv, async ( arg, opt ) => {
let trackingInfo;
let slug;
const lando = await bootstrapLando();

if ( opt.all ) {
trackingInfo = { all: true };
slug = '';
slug = undefined;
} else {
slug = await getEnvironmentName( opt );
trackingInfo = getEnvTrackingInfo( slug );
}

const lando = await bootstrapLando( { logFile: getDevEnvLogFile( slug ) } );
validateDependencies( lando );
await trackEvent( 'dev_env_info_command_execute', trackingInfo );

Expand Down
3 changes: 2 additions & 1 deletion src/bin/vip-dev-env-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import command from '../lib/cli/command';
import {
handleCLIException,
validateDependencies,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import { printAllEnvironmentsInfo } from '../lib/dev-environment/dev-environment-core';
import { bootstrapLando } from '../lib/dev-environment/dev-environment-lando';
Expand All @@ -24,7 +25,7 @@ command( {
} )
.examples( examples )
.argv( process.argv, async () => {
const lando = await bootstrapLando();
const lando = await bootstrapLando( { logFile: getDevEnvLogFile() } );
lando.events.constructor.prototype.setMaxListeners( 1024 );
validateDependencies( lando );

Expand Down
3 changes: 2 additions & 1 deletion src/bin/vip-dev-env-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
handleCLIException,
processSlug,
validateDependencies,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import { showLogs } from '../lib/dev-environment/dev-environment-core';
import { bootstrapLando } from '../lib/dev-environment/dev-environment-lando';
Expand Down Expand Up @@ -51,7 +52,7 @@ command( {
.argv( process.argv, async ( arg, opt ) => {
const slug = await getEnvironmentName( opt );

const lando = await bootstrapLando();
const lando = await bootstrapLando( { logFile: getDevEnvLogFile( slug ) } );
validateDependencies( lando );

const trackingInfo = getEnvTrackingInfo( slug );
Expand Down
3 changes: 2 additions & 1 deletion src/bin/vip-dev-env-purge.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
handleCLIException,
validateDependencies,
promptForBoolean,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import {
destroyEnvironment,
Expand Down Expand Up @@ -57,7 +58,7 @@ command( {
debug( 'Args: ', arg, 'Options: ', opt );

const allEnvNames = getAllEnvironmentNames();
const lando = await bootstrapLando();
const lando = await bootstrapLando( { logFile: getDevEnvLogFile() } );

if ( allEnvNames.length === 0 ) {
console.log( 'No environments to purge!' );
Expand Down
3 changes: 2 additions & 1 deletion src/bin/vip-dev-env-shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getEnvironmentName,
handleCLIException,
processSlug,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import { getEnvironmentPath } from '../lib/dev-environment/dev-environment-core';
import { bootstrapLando, landoShell } from '../lib/dev-environment/dev-environment-lando';
Expand Down Expand Up @@ -90,7 +91,7 @@ command( {
.argv( process.argv, async ( args, opt ) => {
const slug = await getEnvironmentName( opt );

const lando = await bootstrapLando();
const lando = await bootstrapLando( { logFile: getDevEnvLogFile( slug ) } );
validateDependencies( lando );

const trackingInfo = getEnvTrackingInfo( slug );
Expand Down
3 changes: 2 additions & 1 deletion src/bin/vip-dev-env-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
handleCLIException,
postStart,
processSlug,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import { startEnvironment } from '../lib/dev-environment/dev-environment-core';
import { bootstrapLando } from '../lib/dev-environment/dev-environment-lando';
Expand Down Expand Up @@ -76,7 +77,7 @@ command( {
.examples( examples )
.argv( process.argv, async ( arg, opt ) => {
const slug = await getEnvironmentName( opt );
const lando = await bootstrapLando();
const lando = await bootstrapLando( { logFile: getDevEnvLogFile( slug ) } );
validateDependencies( lando );

const startProcessing = new Date();
Expand Down
11 changes: 8 additions & 3 deletions src/bin/vip-dev-env-stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
getEnvironmentName,
processSlug,
validateDependencies,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import {
getAllEnvironmentNames,
Expand Down Expand Up @@ -44,24 +45,28 @@ command( {
.option( 'all', 'Stop all local environments.' )
.examples( examples )
.argv( process.argv, async ( arg, opt ) => {
const lando = await bootstrapLando();
validateDependencies( lando );

debug( 'Args: ', arg, 'Options: ', opt );

/** @type {Record< string, unknown >} */
let trackingInfo;
/** @type {string[]} */
let environments;
/** @type {string|undefined} */
let logSlug;
if ( opt.all ) {
trackingInfo = { all: true };
environments = getAllEnvironmentNames();
logSlug = undefined;
} else {
const slug = await getEnvironmentName( opt );
trackingInfo = getEnvTrackingInfo( slug );
environments = [ slug ];
logSlug = slug;
}

const lando = await bootstrapLando( { logFile: getDevEnvLogFile( logSlug ) } );
validateDependencies( lando );

await trackEvent( 'dev_env_stop_command_execute', trackingInfo );

for ( const slug of environments ) {
Expand Down
3 changes: 2 additions & 1 deletion src/bin/vip-dev-env-sync-sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getEnvironmentName,
processBooleanOption,
processSlug,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import { bootstrapLando, isContainerRunning } from '../lib/dev-environment/dev-environment-lando';
import { parseLiveBackupCopyCLIOptions } from '../lib/live-backup-copy';
Expand Down Expand Up @@ -114,7 +115,7 @@ command( {
} );
await trackerFn( 'execute' );

const lando = await bootstrapLando();
const lando = await bootstrapLando( { logFile: getDevEnvLogFile( slug ) } );

const isUp = (
await Promise.all( [
Expand Down
3 changes: 2 additions & 1 deletion src/bin/vip-dev-env-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
promptForArguments,
validateDependencies,
ensureValidPathsInOptions,
getDevEnvLogFile,
} from '../lib/dev-environment/dev-environment-cli';
import {
getConfigurationFileOptions,
Expand Down Expand Up @@ -68,7 +69,7 @@ cmd.examples( examples );
cmd.argv( process.argv, async ( arg, opt ) => {
const slug = await getEnvironmentName( opt );

const lando = await bootstrapLando();
const lando = await bootstrapLando( { logFile: getDevEnvLogFile( slug ) } );
validateDependencies( lando );

const trackingInfo = getEnvTrackingInfo( slug );
Expand Down
3 changes: 2 additions & 1 deletion src/commands/dev-env-import-sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as exit from '../lib/cli/exit';
import { getFileMeta, unzipFile } from '../lib/client-file-uploader';
import { getSqlDumpDetails, SqlDumpDetails, SqlDumpType } from '../lib/database';
import {
getDevEnvLogFile,
processBooleanOption,
validateDependencies,
} from '../lib/dev-environment/dev-environment-cli';
Expand Down Expand Up @@ -39,7 +40,7 @@ export class DevEnvImportSQLCommand {
) {}

public async run(): Promise< void > {
const lando = await bootstrapLando();
const lando = await bootstrapLando( { logFile: getDevEnvLogFile( this.slug ) } );
validateDependencies( lando );

validateImportFileExtension( this.fileName );
Expand Down
13 changes: 13 additions & 0 deletions src/lib/dev-environment/dev-environment-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,19 @@ export function processSlug( value: unknown ): string {
return ( value ?? '' ).toString().toLowerCase();
}

export function formatDevEnvLogTimestamp( date: Date ): string {
return date.toISOString().replace( /\..*$/, '' ).replace( /[-:]/g, '' ).replace( 'T', '-' );
}

export function formatDevEnvLogSlug( slug: string ): string {
return slug.replace( /[^a-z0-9_-]+/gi, '-' ).toLowerCase();
}

export function getDevEnvLogFile( slug?: string ): string {
const slugPart = slug ? formatDevEnvLogSlug( slug ) : 'all';
return `vip-dev-env-${ slugPart }-${ formatDevEnvLogTimestamp( new Date() ) }.log`;
}

declare function isNaN( value: unknown ): boolean;
declare function parseFloat( value: unknown ): number;

Expand Down
Loading