From 4fdb56bfad38464388f4cbda07adc4224629ca66 Mon Sep 17 00:00:00 2001 From: Deepty Thampy Date: Fri, 11 Apr 2025 18:57:18 -0500 Subject: [PATCH 1/8] chore: add a warning when non-supported node version is used --- src/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/index.js b/src/index.js index 8d76e7df..d5c0c2d4 100644 --- a/src/index.js +++ b/src/index.js @@ -11,6 +11,8 @@ */ const { Command, run, Config } = require('@oclif/core') +const semver = require('semver'); +const chalk = require('chalk'); class AIOCommand extends Command { } @@ -25,6 +27,17 @@ AIOCommand.run = async (argv, opts) => { // || module.parent && module.parent.parent && module.parent.parent.filename const config = await Config.load(opts || __dirname) + // Check Node.js version + const nodeVersion = process.version; + if (semver.major(nodeVersion) > 22) { + console.log(chalk.yellow('⚠️ Warning: You are using Node.js version ' + nodeVersion + ', which is not officially supported by Adobe I/O CLI.')); + console.log(chalk.yellow(' Supported versions are Node.js 18, 20, and 22.')); + console.log(chalk.yellow(' To use a supported Node.js version, please consider using nvm (Node Version Manager).')); + console.log(chalk.yellow(' To find the nvm documentation visit:')); + console.log(chalk.yellow(' https://github.com/nvm-sh/nvm')); + console.log(); + } + // the second parameter is the root path to the CLI containing the command try { return await run(argv, config.options) From bfcb852284b1f78da67b0457379fc3ae4019533b Mon Sep 17 00:00:00 2001 From: Deepty Thampy Date: Fri, 11 Apr 2025 19:16:31 -0500 Subject: [PATCH 2/8] fix: lint error --- src/index.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/index.js b/src/index.js index d5c0c2d4..88734e50 100644 --- a/src/index.js +++ b/src/index.js @@ -11,8 +11,8 @@ */ const { Command, run, Config } = require('@oclif/core') -const semver = require('semver'); -const chalk = require('chalk'); +const semver = require('semver') +const chalk = require('chalk') class AIOCommand extends Command { } @@ -28,14 +28,14 @@ AIOCommand.run = async (argv, opts) => { const config = await Config.load(opts || __dirname) // Check Node.js version - const nodeVersion = process.version; + const nodeVersion = process.version if (semver.major(nodeVersion) > 22) { - console.log(chalk.yellow('⚠️ Warning: You are using Node.js version ' + nodeVersion + ', which is not officially supported by Adobe I/O CLI.')); - console.log(chalk.yellow(' Supported versions are Node.js 18, 20, and 22.')); - console.log(chalk.yellow(' To use a supported Node.js version, please consider using nvm (Node Version Manager).')); - console.log(chalk.yellow(' To find the nvm documentation visit:')); - console.log(chalk.yellow(' https://github.com/nvm-sh/nvm')); - console.log(); + console.log(chalk.yellow('⚠️ Warning: You are using Node.js version ' + nodeVersion + ', which is not officially supported by Adobe I/O CLI.')) + console.log(chalk.yellow(' Supported versions are Node.js 18, 20, and 22.')) + console.log(chalk.yellow(' To use a supported Node.js version, please consider using nvm (Node Version Manager).')) + console.log(chalk.yellow(' To find the nvm documentation visit:')) + console.log(chalk.yellow(' https://github.com/nvm-sh/nvm')) + console.log() } // the second parameter is the root path to the CLI containing the command From 3d23583a02907e8980b01645b85f0e6419432799 Mon Sep 17 00:00:00 2001 From: Deepty Thampy Date: Mon, 14 Apr 2025 09:30:17 -0500 Subject: [PATCH 3/8] chore: add test coverage --- test/index.test.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/test/index.test.js b/test/index.test.js index 64e9bcef..c7f7b090 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -45,3 +45,49 @@ describe('run command', () => { process.argv = temp }) }) + +describe('Node.js version check', () => { + const originalVersion = process.version + let logSpy + + beforeEach(() => { + logSpy = jest.spyOn(console, 'log').mockImplementation() + }) + + afterEach(() => { + jest.restoreAllMocks() + Object.defineProperty(process, 'version', { + value: originalVersion + }) + }) + + test('should not show warning for supported Node.js version', async () => { + // Mock Node.js version to v22.0.0 + Object.defineProperty(process, 'version', { + value: 'v22.14.0' + }) + + const AIOCommand = require('../src/index') + await AIOCommand.run(['--version']) + + // Check that warning was not displayed + expect(logSpy).not.toHaveBeenCalledWith( + expect.stringContaining('Warning: You are using Node.js version') + ) + }) + + test('should show warning for unsupported Node.js version', async () => { + // Mock Node.js version to v23.0.0 + Object.defineProperty(process, 'version', { + value: 'v23.0.0' + }) + + const AIOCommand = require('../src/index') + await AIOCommand.run(['--version']) + + // Check that warning was displayed + expect(logSpy).toHaveBeenCalledWith( + expect.stringContaining('Warning: You are using Node.js version') + ) + }) +}) From ca030eeb75353000df07b6254cfb212e5ae651dd Mon Sep 17 00:00:00 2001 From: Deepty Thampy Date: Mon, 14 Apr 2025 09:46:06 -0500 Subject: [PATCH 4/8] fix: comments --- test/index.test.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/index.test.js b/test/index.test.js index c7f7b090..497edb17 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -62,7 +62,6 @@ describe('Node.js version check', () => { }) test('should not show warning for supported Node.js version', async () => { - // Mock Node.js version to v22.0.0 Object.defineProperty(process, 'version', { value: 'v22.14.0' }) @@ -70,14 +69,13 @@ describe('Node.js version check', () => { const AIOCommand = require('../src/index') await AIOCommand.run(['--version']) - // Check that warning was not displayed + // Check warning is not displayed expect(logSpy).not.toHaveBeenCalledWith( expect.stringContaining('Warning: You are using Node.js version') ) }) test('should show warning for unsupported Node.js version', async () => { - // Mock Node.js version to v23.0.0 Object.defineProperty(process, 'version', { value: 'v23.0.0' }) @@ -85,7 +83,7 @@ describe('Node.js version check', () => { const AIOCommand = require('../src/index') await AIOCommand.run(['--version']) - // Check that warning was displayed + // Check warning is displayed expect(logSpy).toHaveBeenCalledWith( expect.stringContaining('Warning: You are using Node.js version') ) From 5cd5315f4045d8cf605441cc2ac1ca262a2a4f2c Mon Sep 17 00:00:00 2001 From: Deepty Thampy Date: Tue, 15 Apr 2025 16:23:41 -0500 Subject: [PATCH 5/8] fix: using Config object takes care of reading and parsing the package.json file and updated unit tests --- package.json | 2 +- test/hookerror.test.js | 8 +++++++- test/index.test.js | 13 ++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index f32dff12..2aab0209 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "typescript": "^5.3.3" }, "engines": { - "node": ">=18" + "node": "^18 || ^20 || ^22" }, "files": [ "/bin", diff --git a/test/hookerror.test.js b/test/hookerror.test.js index 96c9c14c..e9e9e6c6 100644 --- a/test/hookerror.test.js +++ b/test/hookerror.test.js @@ -28,7 +28,13 @@ jest.mock('@oclif/core', () => { Config: { load: () => { return { - runHook: mockRunHook + pjson: { + engines: { + node: '>=18 <23' + } + }, + runHook: mockRunHook, + options: {} } } }, diff --git a/test/index.test.js b/test/index.test.js index 497edb17..31e27097 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -16,7 +16,14 @@ jest.mock('@oclif/core', () => { return { ...jest.requireActual('@oclif/core'), Config: { - load: () => ({}) + load: () => ({ + pjson: { + engines: { + node: '>=18 <23' + } + }, + options: {} + }) }, Command: jest.fn(), run: async function (cmd) { @@ -71,7 +78,7 @@ describe('Node.js version check', () => { // Check warning is not displayed expect(logSpy).not.toHaveBeenCalledWith( - expect.stringContaining('Warning: You are using Node.js version') + expect.stringContaining('Warning: Node.js version') ) }) @@ -85,7 +92,7 @@ describe('Node.js version check', () => { // Check warning is displayed expect(logSpy).toHaveBeenCalledWith( - expect.stringContaining('Warning: You are using Node.js version') + expect.stringContaining('Warning: Node.js version v23.0.0 is not supported') ) }) }) From 66c3b90e90d6adc0a2699b0244ce76e81707d2c3 Mon Sep 17 00:00:00 2001 From: Deepty Thampy Date: Tue, 15 Apr 2025 16:24:33 -0500 Subject: [PATCH 6/8] fix: missed the fix --- src/index.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index 88734e50..f209dae1 100644 --- a/src/index.js +++ b/src/index.js @@ -29,13 +29,8 @@ AIOCommand.run = async (argv, opts) => { // Check Node.js version const nodeVersion = process.version - if (semver.major(nodeVersion) > 22) { - console.log(chalk.yellow('⚠️ Warning: You are using Node.js version ' + nodeVersion + ', which is not officially supported by Adobe I/O CLI.')) - console.log(chalk.yellow(' Supported versions are Node.js 18, 20, and 22.')) - console.log(chalk.yellow(' To use a supported Node.js version, please consider using nvm (Node Version Manager).')) - console.log(chalk.yellow(' To find the nvm documentation visit:')) - console.log(chalk.yellow(' https://github.com/nvm-sh/nvm')) - console.log() + if (!semver.satisfies(nodeVersion, config.pjson.engines.node)) { + console.log(chalk.yellow(`⚠️ Warning: Node.js version ${nodeVersion} is not supported. Supported versions are Node.js 18, 20, and 22.`)) } // the second parameter is the root path to the CLI containing the command From fdf63fc7aa29774477f96010f0907ac51616e7dd Mon Sep 17 00:00:00 2001 From: Deepty Thampy Date: Tue, 15 Apr 2025 18:57:54 -0500 Subject: [PATCH 7/8] chore: show the supported versions from package json --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index f209dae1..e21edb1c 100644 --- a/src/index.js +++ b/src/index.js @@ -30,7 +30,7 @@ AIOCommand.run = async (argv, opts) => { // Check Node.js version const nodeVersion = process.version if (!semver.satisfies(nodeVersion, config.pjson.engines.node)) { - console.log(chalk.yellow(`⚠️ Warning: Node.js version ${nodeVersion} is not supported. Supported versions are Node.js 18, 20, and 22.`)) + console.log(chalk.yellow(`⚠️ Warning: Node.js version ${nodeVersion} is not supported. Supported versions are ${config.pjson.engines.node}.`)) } // the second parameter is the root path to the CLI containing the command From 9876902092e404fe283793ff98af4df67266eece Mon Sep 17 00:00:00 2001 From: Deepty Thampy Date: Wed, 16 Apr 2025 20:10:51 -0500 Subject: [PATCH 8/8] 10.3.4 --- README.md | 8 ++++---- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 915e93c3..0bcd3011 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ $ npm install -g @adobe/aio-cli $ aio COMMAND running command... $ aio (--version|-v) -@adobe/aio-cli/10.3.3 darwin-arm64 node-v20.18.2 +@adobe/aio-cli/10.3.4 darwin-arm64 node-v20.18.2 $ aio --help [COMMAND] USAGE $ aio COMMAND @@ -3438,7 +3438,7 @@ ALIASES $ aio plugins discover ``` -_See code: [src/commands/discover.ts](https://github.com/adobe/aio-cli/blob/10.3.3/src/commands/discover.ts)_ +_See code: [src/commands/discover.ts](https://github.com/adobe/aio-cli/blob/10.3.4/src/commands/discover.ts)_ ## `aio event` @@ -4600,7 +4600,7 @@ DESCRIPTION Clears all installed plugins. ``` -_See code: [src/commands/rollback.ts](https://github.com/adobe/aio-cli/blob/10.3.3/src/commands/rollback.ts)_ +_See code: [src/commands/rollback.ts](https://github.com/adobe/aio-cli/blob/10.3.4/src/commands/rollback.ts)_ ## `aio rt` @@ -13846,7 +13846,7 @@ DESCRIPTION - update user-installed plugins that are not core ``` -_See code: [src/commands/update.ts](https://github.com/adobe/aio-cli/blob/10.3.3/src/commands/update.ts)_ +_See code: [src/commands/update.ts](https://github.com/adobe/aio-cli/blob/10.3.4/src/commands/update.ts)_ ## `aio where` diff --git a/package-lock.json b/package-lock.json index 00394d8a..0f9594aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@adobe/aio-cli", - "version": "10.3.3", + "version": "10.3.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@adobe/aio-cli", - "version": "10.3.3", + "version": "10.3.4", "license": "Apache-2.0", "dependencies": { "@adobe/aio-cli-plugin-app": "^13", diff --git a/package.json b/package.json index 2aab0209..26cb5c85 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@adobe/aio-cli", "description": "Adobe I/O Extensible CLI\n\n******* *******\n****** ******\n***** *****\n**** * ****\n*** *** ***\n** ***** **\n* ** *\n", - "version": "10.3.3", + "version": "10.3.4", "author": "Adobe Inc.", "bin": { "aio": "bin/run"