Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Node.js versions and standardize the format #2098

Merged
merged 2 commits into from
Nov 14, 2024
Merged
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
18 changes: 10 additions & 8 deletions src/bin/vip-validate-preflight.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { parseEnvAliasFromArgv } from '../lib/cli/envAlias';
import * as exit from '../lib/cli/exit';
import { trackEvent } from '../lib/tracker';

const ALLOWED_NODEJS_VERSIONS = [ '14', '16', '18' ];
const ALLOWED_NODEJS_VERSIONS = [ '18', '20', '22' ];

export const appQuery = `
id
Expand All @@ -50,7 +50,7 @@ export const appQuery = `
`;

let suppressOutput = false;
let outputJson = false;
let outputFormat = 'table';

let harmoniaArgs = [];

Expand Down Expand Up @@ -382,7 +382,7 @@ async function handleResults( harmonia, results ) {
} );

// If the output is JSON, reenable the logToConsole output and print-out the json format.
if ( outputJson ) {
if ( outputFormat === 'json' ) {
suppressOutput = false;
logToConsole( harmonia.resultsJSON() );
process.exit( 0 );
Expand Down Expand Up @@ -490,9 +490,9 @@ async function validateArgs( opt ) {
}

// If the JSON option is enabled, all the stdout should be suppressed to prevent polluting the output.
if ( opt.json ) {
if ( opt.format === 'json' ) {
suppressOutput = true;
outputJson = true;
outputFormat = 'json';
}

if ( opt.app ) {
Expand Down Expand Up @@ -588,7 +588,9 @@ command( commandOpts )
)
.option(
'node-version',
'Select a specific target Node.JS version in semver format (MAJOR.MINOR.PATCH) or a MAJOR'
`Select a specific target Node.JS version in semver format (MAJOR.MINOR.PATCH) or a MAJOR (${ ALLOWED_NODEJS_VERSIONS.join(
', '
) })`
)
.option(
'wait',
Expand All @@ -599,7 +601,7 @@ command( commandOpts )
[ 'p', 'port' ],
'Configure the port to use for the app (defaults to a random port between 3001 and 3999)'
)
.option( 'json', 'Output the results as JSON', false )
.option( 'format', 'Output the log lines in CSV or JSON format', 'table' )
.option( [ 'P', 'path' ], 'Path to the app to be tested', process.cwd() )
.examples( [
{
Expand All @@ -608,7 +610,7 @@ command( commandOpts )
'Runs the preflight tests to validate if your application is ready to be deployed to VIP Go',
},
{
usage: 'vip @mysite.production validate preflight --json > results.json',
usage: 'vip @mysite.production validate preflight --format json > results.json',
description:
'Runs the preflight tests, but output the results in JSON format, and redirect the output to a file',
},
Expand Down
11 changes: 9 additions & 2 deletions src/lib/config/software.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ interface VersionChoice {
message: string;
value: string;
disabled?: boolean;
deprecated?: boolean;
}

interface VersionChoices {
Expand All @@ -175,16 +176,19 @@ const _optionsForVersion = ( softwareSettings: SoftwareSetting ): VersionChoice[
versionChoices.deprecated.push( {
message: `${ option.version } (deprecated)`,
value: option.version,
deprecated: option.deprecated,
} );
} else if ( option.unstable ) {
versionChoices.test.push( {
message: `${ option.version } (test)`,
value: option.version,
deprecated: option.deprecated,
} );
} else {
versionChoices.supported.push( {
message: option.version,
value: option.version,
deprecated: option.deprecated,
} );
}
}
Expand Down Expand Up @@ -431,9 +435,12 @@ export const formatSoftwareSettings = (
};

if ( includes.includes( 'available_versions' ) ) {
result.available_versions = _optionsForVersion( softwareSetting ).map( option => option.value );
result.available_versions = _optionsForVersion( softwareSetting )
.filter( option => ! option.deprecated )
.map( option => option.value );

if ( format !== 'json' ) {
result.available_versions = result.available_versions.join( ',' );
result.available_versions = result.available_versions.sort().join( ',' );
}
}

Expand Down