From fc2ff8e98210c214655b7aaadf3332f9ddfedf61 Mon Sep 17 00:00:00 2001 From: Okabe Rintaro Date: Fri, 25 Mar 2022 15:36:58 +0200 Subject: [PATCH] Revert "use custom error to prevent logging of expected or too common issues" This reverts commit 076bb6f047c7de0e334d756e344c349bc9d1b6a0. --- .../magento-scripts/lib/commands/start.js | 6 +--- .../lib/tasks/requirements/docker/index.js | 23 ++++-------- .../lib/tasks/requirements/node-version.js | 7 ++-- .../lib/tasks/requirements/php-version.js | 7 ++-- .../lib/tasks/requirements/platform.js | 3 +- .../magento-scripts/lib/util/cma-error.js | 35 ------------------- 6 files changed, 13 insertions(+), 68 deletions(-) delete mode 100644 build-packages/magento-scripts/lib/util/cma-error.js diff --git a/build-packages/magento-scripts/lib/commands/start.js b/build-packages/magento-scripts/lib/commands/start.js index 2c66228b..9354e5d5 100644 --- a/build-packages/magento-scripts/lib/commands/start.js +++ b/build-packages/magento-scripts/lib/commands/start.js @@ -169,11 +169,7 @@ module.exports = (yargs) => { process.exit(0); } catch (e) { logger.error(e.message || e); - if (e && e.reportAnalytics) { - await googleAnalytics.trackError(e.message || e); - } else { - logger.logN('skipping reporting...'); - } + await googleAnalytics.trackError(e.message || e); process.exit(1); } } diff --git a/build-packages/magento-scripts/lib/tasks/requirements/docker/index.js b/build-packages/magento-scripts/lib/tasks/requirements/docker/index.js index 0c4ad1ac..17551943 100644 --- a/build-packages/magento-scripts/lib/tasks/requirements/docker/index.js +++ b/build-packages/magento-scripts/lib/tasks/requirements/docker/index.js @@ -1,6 +1,5 @@ const logger = require('@scandipwa/scandipwa-dev-utils/logger'); const os = require('os'); -const { CMAInstallError } = require('../../../util/cma-error'); const { execAsyncSpawn } = require('../../../util/exec-async-command'); const getIsWsl = require('../../../util/is-wsl'); const installDocker = require('./install'); @@ -34,36 +33,28 @@ NOTE: After installation it's recommended to log out and log back in so your gro task: (ctx) => { task.title = `Using docker version ${ctx.dockerVersion}`; - throw new CMAInstallError( + throw new Error( `Docker is installed successfully! Please log out and log back to so your group membership is re-evaluated! -Learn more here: ${ logger.style.link('https://docs.docker.com/engine/install/linux-postinstall/') }`, { - reportAnalytics: false - } +Learn more here: ${ logger.style.link('https://docs.docker.com/engine/install/linux-postinstall/') }` ); } } ]); } - throw new CMAInstallError('Docker is not installed!', { - reportAnalytics: false - }); + throw new Error('Docker is not installed!'); } else if (isWsl) { - throw new CMAInstallError( + throw new Error( `You don't have Docker installed! Follow this instructions to install Docker on Windows: -${ logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/windows-requirements#2-install-docker-desktop-for-windows') }`, { - reportAnalytics: false - } +${ logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/windows-requirements#2-install-docker-desktop-for-windows') }` ); } else { - throw new CMAInstallError( + throw new Error( `You don't have Docker installed! Follow this instructions to install Docker on Mac: -${ logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/installation-on-macos#3-install-docker-for-mac') }`, { - reportAnalytics: false - } +${ logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/installation-on-macos#3-install-docker-for-mac') }` ); } } diff --git a/build-packages/magento-scripts/lib/tasks/requirements/node-version.js b/build-packages/magento-scripts/lib/tasks/requirements/node-version.js index 4931e78a..7ca052ad 100644 --- a/build-packages/magento-scripts/lib/tasks/requirements/node-version.js +++ b/build-packages/magento-scripts/lib/tasks/requirements/node-version.js @@ -1,5 +1,4 @@ const semver = require('semver'); -const { CMAInstallError } = require('../../util/cma-error'); /** * @type {() => import('listr2').ListrTask} @@ -10,11 +9,9 @@ const checkNodeVersion = () => ({ const { node } = process.versions; if (!semver.gte(node, '12.0.0')) { - throw new CMAInstallError( + throw new Error( `Your Node.js version is out of date! -You need to upgrade Node.js to at lease version 12 to work with this software!`, { - reportAnalytics: false - } +You need to upgrade Node.js to at lease version 12 to work with this software!` ); } diff --git a/build-packages/magento-scripts/lib/tasks/requirements/php-version.js b/build-packages/magento-scripts/lib/tasks/requirements/php-version.js index de558be0..0ca8d559 100644 --- a/build-packages/magento-scripts/lib/tasks/requirements/php-version.js +++ b/build-packages/magento-scripts/lib/tasks/requirements/php-version.js @@ -3,7 +3,6 @@ const fs = require('fs'); const path = require('path'); const semver = require('semver'); const phpbrewConfig = require('../../config/phpbrew'); -const { CMAInstallError } = require('../../util/cma-error'); const { execAsyncSpawn } = require('../../util/exec-async-command'); const pathExists = require('../../util/path-exists'); const compileOptions = require('../php/compile-options'); @@ -83,11 +82,9 @@ export PHPBREW_PATH=${phpbrewConfig.homePath}/php/${phpbrewPHPName}/bin throw new Error(`Something went wrong when trying to switch PHP to ${phpbrewPHPName}!\n\n${e}`); } - throw new CMAInstallError(`You will need to restart your terminal and run ${logger.style.command('start')} again. + throw new Error(`You will need to restart your terminal and run ${logger.style.command('start')} again. -You can use keyboard shortcut ${logger.style.command('CTRL+D')} to close terminal.`, { - reportAnalytics: false - }); +You can use keyboard shortcut ${logger.style.command('CTRL+D')} to close terminal.`); }, options: { bottomBar: 10 diff --git a/build-packages/magento-scripts/lib/tasks/requirements/platform.js b/build-packages/magento-scripts/lib/tasks/requirements/platform.js index 07d8c225..d365843f 100644 --- a/build-packages/magento-scripts/lib/tasks/requirements/platform.js +++ b/build-packages/magento-scripts/lib/tasks/requirements/platform.js @@ -6,7 +6,6 @@ const { platforms, darwinMinimalVersion } = require('../../config'); const dependencyCheck = require('./dependency'); const { getArch } = require('../../util/arch'); const getIsWsl = require('../../util/is-wsl'); -const { CMAError } = require('../../util/cma-error'); /** * @type {() => import('listr2').ListrTask} @@ -17,7 +16,7 @@ const checkPlatform = () => ({ const currentPlatform = os.platform(); if (!platforms.includes(currentPlatform)) { - throw new CMAError( + throw new Error( `Your current OS platform is ${ logger.style.misc(currentPlatform) }. Unfortunately, currently we only support ${ platforms.map((platform) => logger.style.misc(platform)).join(',') }.` ); diff --git a/build-packages/magento-scripts/lib/util/cma-error.js b/build-packages/magento-scripts/lib/util/cma-error.js deleted file mode 100644 index a305f225..00000000 --- a/build-packages/magento-scripts/lib/util/cma-error.js +++ /dev/null @@ -1,35 +0,0 @@ -/* eslint-disable max-classes-per-file */ -class CMAError extends Error { - /** - * @param {String} message - * @param {{ reportAnalytics: boolean }} param1 - */ - constructor(message, { reportAnalytics = true } = {}) { - super(message); - this.name = 'CMA Error'; - /** - * @type {Boolean} - */ - this.reportAnalytics = reportAnalytics; - } -} - -class CMAInstallError extends CMAError { - constructor(...args) { - super(...args); - this.name = 'CMA Install Error'; - } -} - -class CMASetupError extends CMAError { - constructor(...args) { - super(...args); - this.name = 'CMA Setup Error'; - } -} - -module.exports = { - CMAError, - CMAInstallError, - CMASetupError -};