-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve system requirements checks (#4448)
Co-authored-by: Pavel Denisjuk <[email protected]>
- Loading branch information
Showing
20 changed files
with
480 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# and run "github-actions-wac build" (or "ghawac build") to regenerate this file. | ||
# For more information, run "github-actions-wac --help". | ||
name: Pull Requests | ||
'on': pull_request | ||
"on": pull_request | ||
concurrency: | ||
group: pr-${{ github.event.pull_request.number }} | ||
cancel-in-progress: true | ||
|
@@ -19,7 +19,7 @@ jobs: | |
- uses: webiny/[email protected] | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
validateCommitsDev: | ||
name: Validate commit messages (dev branch, 'feat' commits not allowed) | ||
|
@@ -34,7 +34,7 @@ jobs: | |
allowed-commit-types: fix,docs,style,refactor,test,build,perf,ci,chore,revert,merge,wip | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
constants: | ||
name: Create constants | ||
|
@@ -87,7 +87,7 @@ jobs: | |
$GITHUB_OUTPUT | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
assignMilestone: | ||
name: Assign milestone | ||
|
@@ -117,7 +117,7 @@ jobs: | |
milestone: ${{ steps.get-milestone-to-assign.outputs.milestone }} | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
build: | ||
name: Build | ||
|
@@ -149,7 +149,7 @@ jobs: | |
path: ${{ github.base_ref }}/.webiny/cached-packages | ||
key: ${{ needs.constants.outputs.run-cache-key }} | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
staticCodeAnalysis: | ||
needs: | ||
|
@@ -190,7 +190,7 @@ jobs: | |
working-directory: ${{ github.base_ref }} | ||
runs-on: ubuntu-latest | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
staticCodeAnalysisTs: | ||
name: Static code analysis (TypeScript) | ||
|
@@ -216,7 +216,7 @@ jobs: | |
run: yarn cy:ts | ||
working-directory: ${{ github.base_ref }} | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
jestTestsNoStorageConstants: | ||
needs: | ||
|
@@ -244,7 +244,7 @@ jobs: | |
echo '${{ | ||
steps.list-packages-to-jest-test.outputs.packages-to-jest-test }}' | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
jestTestsNoStorageRun: | ||
needs: | ||
|
@@ -265,7 +265,7 @@ jobs: | |
}} | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
AWS_REGION: eu-central-1 | ||
if: needs.jestTestsNoStorageConstants.outputs.packages-to-jest-test != '[]' | ||
|
@@ -363,7 +363,7 @@ jobs: | |
echo '${{ | ||
steps.list-packages-to-jest-test.outputs.packages-to-jest-test }}' | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
jestTestsddbRun: | ||
needs: | ||
|
@@ -383,7 +383,7 @@ jobs: | |
fromJson(needs.jestTestsddbConstants.outputs.packages-to-jest-test) }} | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
AWS_REGION: eu-central-1 | ||
if: needs.jestTestsddbConstants.outputs.packages-to-jest-test != '[]' | ||
|
@@ -480,7 +480,7 @@ jobs: | |
echo '${{ | ||
steps.list-packages-to-jest-test.outputs.packages-to-jest-test }}' | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
jestTestsddb-esRun: | ||
needs: | ||
|
@@ -501,7 +501,7 @@ jobs: | |
}} | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
AWS_REGION: eu-central-1 | ||
AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_ELASTIC_SEARCH_DOMAIN_NAME }} | ||
|
@@ -610,7 +610,7 @@ jobs: | |
echo '${{ | ||
steps.list-packages-to-jest-test.outputs.packages-to-jest-test }}' | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
jestTestsddb-osRun: | ||
needs: | ||
|
@@ -631,7 +631,7 @@ jobs: | |
}} | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
NODE_OPTIONS: '--max_old_space_size=4096' | ||
NODE_OPTIONS: "--max_old_space_size=4096" | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
AWS_REGION: eu-central-1 | ||
AWS_ELASTIC_SEARCH_DOMAIN_NAME: ${{ secrets.AWS_OPEN_SEARCH_DOMAIN_NAME }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,100 @@ | ||
#!/usr/bin/env node | ||
"use strict"; | ||
|
||
const chalk = require("chalk"); | ||
const execa = require("execa"); | ||
const semver = require("semver"); | ||
const currentNodeVersion = process.versions.node; | ||
// Suppress punycode warnings. This is a known issue which we can't fix. | ||
require("./utils/suppressPunycodeWarnings"); | ||
|
||
// Ensure system requirements are met. | ||
require("@webiny/system-requirements").ensureSystemRequirements(); | ||
|
||
const yargs = require("yargs"); | ||
|
||
// Disable help processing until after plugins are imported. | ||
yargs.help(false); | ||
|
||
// Loads environment variables from multiple sources. | ||
require("./utils/loadEnvVariables"); | ||
|
||
const { blue, red, bold, bgYellow } = require("chalk"); | ||
const context = require("./context"); | ||
const { createCommands } = require("./commands"); | ||
|
||
yargs | ||
.usage("Usage: $0 <command> [options]") | ||
.demandCommand(1) | ||
.recommendCommands() | ||
.scriptName("webiny") | ||
.epilogue( | ||
`To find more information, docs and tutorials, see ${blue("https://www.webiny.com/docs")}.` | ||
) | ||
.epilogue(`Want to contribute? ${blue("https://github.com/webiny/webiny-js")}.`) | ||
.fail(function (msg, error, yargs) { | ||
if (msg) { | ||
if (msg.includes("Not enough non-option arguments")) { | ||
console.log(); | ||
context.error(red("Command was not invoked as expected!")); | ||
context.info( | ||
`Some non-optional arguments are missing. See the usage examples printed below.` | ||
); | ||
console.log(); | ||
yargs.showHelp(); | ||
return; | ||
} | ||
|
||
if (msg.includes("Missing required argument")) { | ||
const args = msg | ||
.split(":")[1] | ||
.split(",") | ||
.map(v => v.trim()); | ||
|
||
console.log(); | ||
context.error(red("Command was not invoked as expected!")); | ||
context.info( | ||
`Missing required argument(s): ${args | ||
.map(arg => red(arg)) | ||
.join(", ")}. See the usage examples printed below.` | ||
); | ||
console.log(); | ||
yargs.showHelp(); | ||
return; | ||
} | ||
console.log(); | ||
context.error(red("Command execution was aborted!")); | ||
context.error(msg); | ||
console.log(); | ||
|
||
(async () => { | ||
if (!semver.satisfies(currentNodeVersion, ">=20")) { | ||
console.error( | ||
chalk.red( | ||
[ | ||
`You are running Node.js ${currentNodeVersion}, but Webiny requires version >=20.`, | ||
`Please switch to one of the required versions and try again.`, | ||
`For more information, please visit https://www.webiny.com/docs/get-started/install-webiny#prerequisites.` | ||
].join(" ") | ||
) | ||
); | ||
process.exit(1); | ||
} | ||
|
||
try { | ||
const { stdout } = await execa("yarn", ["--version"]); | ||
/** | ||
* TODO In 5.43.0 put >=4 as yarn version. | ||
* This is because of the existing yarn version (before doing the webiny upgrade) is v3.x.x. | ||
* When the upgrade is done (5.42.0), we can safely put to >=4. | ||
*/ | ||
const satisfiesYarnVersion = ">=3"; | ||
if (!semver.satisfies(stdout, satisfiesYarnVersion)) { | ||
console.error(chalk.red(`"@webiny/cli" requires yarn 4!`)); | ||
process.exit(1); | ||
} | ||
} catch (err) { | ||
console.error(chalk.red(`"@webiny/cli" requires yarn 4!`)); | ||
console.log( | ||
`Run ${chalk.blue("yarn set version 4.5.3")} to install a compatible version of yarn.` | ||
); | ||
|
||
console.log(); | ||
// Unfortunately, yargs doesn't provide passed args here, so we had to do it via process.argv. | ||
const debugEnabled = process.argv.includes("--debug"); | ||
if (debugEnabled) { | ||
context.debug(error); | ||
} else { | ||
context.error(error.message); | ||
} | ||
|
||
const gracefulError = error.cause?.gracefulError; | ||
if (gracefulError instanceof Error) { | ||
console.log(); | ||
console.log(bgYellow(bold("💡 How can I resolve this?"))); | ||
console.log(gracefulError.message); | ||
} | ||
|
||
const plugins = context.plugins.byType("cli-command-error"); | ||
for (let i = 0; i < plugins.length; i++) { | ||
const plugin = plugins[i]; | ||
plugin.handle({ | ||
error, | ||
context | ||
}); | ||
} | ||
|
||
process.exit(1); | ||
} | ||
}); | ||
|
||
require("./cli"); | ||
(async () => { | ||
await createCommands(yargs, context); | ||
// Enable help and run the CLI. | ||
yargs.help().argv; | ||
})(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
const execa = require("execa"); | ||
const { SystemRequirements } = require("@webiny/system-requirements"); | ||
|
||
module.exports.getNpmVersion = async () => { | ||
try { | ||
const { stdout } = await execa("npm", ["--version"]); | ||
return stdout; | ||
} catch (err) { | ||
return ""; | ||
} | ||
return SystemRequirements.getNpmVersion(); | ||
}; |
Oops, something went wrong.