diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 9e97c93b..00000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -cartridges/int_alma/cartridge/static/ -coverage diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 58c16410..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "root": true, - "extends": "airbnb-base/legacy", - "parserOptions": { - "ecmaVersion": 2020 - }, - "rules": { - "import/no-unresolved": "off", - "indent": ["error", 4, { "SwitchCase": 1, "VariableDeclarator": 1 }], - "func-names": "off", - "require-jsdoc": "error", - "valid-jsdoc": ["error", { "preferType": { "Boolean": "boolean", "Number": "number", "object": "Object", "String": "string" }, "requireReturn": false}], - "vars-on-top": "off", - "global-require": "off", - "no-shadow": ["error", { "allow": ["err", "callback"]}], - "max-len": "off", - "no-param-reassign": 0 - } -} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e8ae2340..597c7e19 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,4 +50,4 @@ repos: hooks: - id: check-branch-name args: - - "-r^((chore|ci|dependabot|devx|docs|feature|fix|release|hotfix|hotfix-backport|infra|other|perf|refactor|security|test)\/.+|(snyk)-.+|main|HEAD|develop)$$" + - "-r^((chore|ci|dependabot|devx|docs|feature|fix|release|hotfix|hotfix-backport|infra|other|perf|refactor|security|test|renovate)\/.+|(snyk)-.+|main|HEAD|develop)$$" diff --git a/cartridges/int_alma/cartridge/controllers/.eslintrc.json b/cartridges/int_alma/cartridge/controllers/.eslintrc.json deleted file mode 100644 index beba3427..00000000 --- a/cartridges/int_alma/cartridge/controllers/.eslintrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "plugins": ["sitegenesis"], - "rules": { - "sitegenesis/no-global-require": ["error"] - } -} diff --git a/cartridges/int_alma/cartridge/controllers/Alma.js b/cartridges/int_alma/cartridge/controllers/Alma.js index 0a258f20..08682717 100644 --- a/cartridges/int_alma/cartridge/controllers/Alma.js +++ b/cartridges/int_alma/cartridge/controllers/Alma.js @@ -1,5 +1,3 @@ -'use strict'; - var server = require('server'); var logger = require('dw/system/Logger').getLogger('alma'); @@ -122,14 +120,14 @@ server.get('PaymentSuccess', function (req, res, next) { var paymentHelper = require('*/cartridge/scripts/helpers/almaPaymentHelper'); var orderHelper = require('*/cartridge/scripts/helpers/almaOrderHelper'); var configHelper = require('*/cartridge/scripts/helpers/almaConfigHelper'); - var paymentObj = null; + var paymentObj; try { paymentObj = buildPaymentObj(req.querystring.pid); } catch (e) { res.setStatusCode(500); res.render('error', { - message: 'Can not find any payment for this order. Your order will fail.' + message: 'Can not find any payment for this order. Your order will fail. Error message: ' + e.toString() }); return next(); } @@ -168,7 +166,7 @@ server.get('PaymentSuccess', function (req, res, next) { buildViewParams(paymentObj, order, req.locale.id, req.currentCustomer.profile) ); - req.session.raw.custom.orderID = req.querystring.pid; // eslint-disable-line no-param-reassign + req.session.raw.custom.orderID = req.querystring.pid; return next(); }); @@ -201,7 +199,7 @@ server.get('IPN', function (req, res, next) { var orderHelper = require('*/cartridge/scripts/helpers/almaOrderHelper'); var almaSecurityHelper = require('*/cartridge/scripts/helpers/almaSecurityHelper'); var almaHelpers = require('*/cartridge/scripts/helpers/almaHelpers'); - var paymentObj = null; + var paymentObj; var paymentId = req.querystring.pid; var signature = req.httpHeaders.get('X-Alma-Signature'); @@ -220,7 +218,7 @@ server.get('IPN', function (req, res, next) { } catch (e) { res.setStatusCode(500); res.render('error', { - message: 'Can not find any payment for this order. Your order will fail.' + message: 'Can not find any payment for this order. Your order will fail. Error message: ' + e.toString() }); return next(); } @@ -319,7 +317,7 @@ server.post('CreatePaymentUrl', server.middleware.https, function (req, res, nex } catch (e) { res.setStatusCode(500); res.render('error', { - message: 'Could not create payment on Alma side' + message: 'Could not create payment on Alma side. Error message: ' + e.toString() }); } return next(); diff --git a/cartridges/int_alma/cartridge/controllers/Cart.js b/cartridges/int_alma/cartridge/controllers/Cart.js index 31a7759a..4ce3af26 100644 --- a/cartridges/int_alma/cartridge/controllers/Cart.js +++ b/cartridges/int_alma/cartridge/controllers/Cart.js @@ -1,5 +1,3 @@ -'use strict'; - var server = require('server'); server.extend(module.superModule); diff --git a/cartridges/int_alma/cartridge/controllers/Checkout.js b/cartridges/int_alma/cartridge/controllers/Checkout.js index 7303e7be..b4e84675 100644 --- a/cartridges/int_alma/cartridge/controllers/Checkout.js +++ b/cartridges/int_alma/cartridge/controllers/Checkout.js @@ -1,5 +1,3 @@ -'use strict'; - var server = require('server'); /** diff --git a/cartridges/int_alma/cartridge/controllers/Product.js b/cartridges/int_alma/cartridge/controllers/Product.js index d270cd6f..781391f9 100644 --- a/cartridges/int_alma/cartridge/controllers/Product.js +++ b/cartridges/int_alma/cartridge/controllers/Product.js @@ -1,5 +1,3 @@ -'use strict'; - var server = require('server'); var almaWidgetHelper = require('*/cartridge/scripts/helpers/almaWidgetHelper'); diff --git a/cartridges/int_alma/cartridge/models/order.js b/cartridges/int_alma/cartridge/models/order.js index e9484d25..66370fd3 100644 --- a/cartridges/int_alma/cartridge/models/order.js +++ b/cartridges/int_alma/cartridge/models/order.js @@ -1,5 +1,3 @@ -'use strict'; - var base = module.superModule; /** diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaAddressHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaAddressHelper.js index 92a1afd1..475db58f 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaAddressHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaAddressHelper.js @@ -1,5 +1,3 @@ -'use strict'; - /** * format address for eligibility service * @param {dw.order.OrderAddress} address the customer address diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaCheckoutHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaCheckoutHelper.js index 4d6df048..c3072baa 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaCheckoutHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaCheckoutHelper.js @@ -1,5 +1,3 @@ -'use strict'; - var Resource = require('dw/web/Resource'); var formatCurrency = require('*/cartridge/scripts/util/formatting').formatCurrency; var isOnShipmentPaymentEnabled = require('*/cartridge/scripts/helpers/almaOnShipmentHelper').isOnShipmentPaymentEnabled; diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaConfigHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaConfigHelper.js index 31445c07..d0aad0cd 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaConfigHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaConfigHelper.js @@ -1,5 +1,3 @@ -'use strict'; - var Site = require('dw/system/Site'); /** diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaEligibilityHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaEligibilityHelper.js index 50507c7d..5329ed65 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaEligibilityHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaEligibilityHelper.js @@ -1,5 +1,3 @@ -'use strict'; - var logger = require('dw/system/Logger').getLogger('alma'); var formatAddress = require('*/cartridge/scripts/helpers/almaAddressHelper').formatAddress; diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaHelpers.js b/cartridges/int_alma/cartridge/scripts/helpers/almaHelpers.js index 935f8319..684b1ff3 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaHelpers.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaHelpers.js @@ -1,5 +1,3 @@ -'use strict'; - var Site = require('dw/system/Site'); var System = require('dw/system/System'); var logger = require('dw/system/Logger').getLogger('alma'); @@ -50,7 +48,7 @@ function addHeaders(service) { */ function getUrl(path) { if (typeof path === 'undefined') { - path = ''; // eslint-disable-line no-param-reassign + path = ''; } var url = Site.getCurrent().getCustomPreferenceValue('ALMA_APIUrl') + path; diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaOnShipmentHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaOnShipmentHelper.js index ad5d77f3..bb849e19 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaOnShipmentHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaOnShipmentHelper.js @@ -1,5 +1,3 @@ -'use strict'; - /** * Returns true if 'On shipment' payment is Enabled * @param {number} installmentsCount number of installments @@ -8,7 +6,7 @@ */ function isOnShipmentPaymentEnabled(installmentsCount, deferredDays) { var Site = require('dw/system/Site'); - deferredDays = (typeof deferredDays !== 'undefined') ? deferredDays : 0; // eslint-disable-line no-param-reassign + deferredDays = (typeof deferredDays !== 'undefined') ? deferredDays : 0; var getAllowedPlans = require('*/cartridge/scripts/helpers/almaPlanHelper').getAllowedPlans; var find = require('*/cartridge/scripts/helpers/almaUtilsHelper').find; diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaOrderHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaOrderHelper.js index 4fd6d428..b3672c0c 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaOrderHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaOrderHelper.js @@ -1,5 +1,3 @@ -'use strict'; - var Transaction = require('dw/system/Transaction'); /** @@ -9,7 +7,6 @@ var Transaction = require('dw/system/Transaction'); */ function addPidToOrder(order, pid) { Transaction.wrap(function () { - // eslint-disable-next-line no-param-reassign order.custom.almaPaymentId = pid; }); } @@ -21,7 +18,6 @@ function addPidToOrder(order, pid) { */ function addAlmaPaymentDetails(order, payDetail) { Transaction.wrap(function () { - // eslint-disable-next-line no-param-reassign order.custom.ALMA_ResponseDetails = payDetail; }); } @@ -35,14 +31,12 @@ function addAlmaPaymentDetails(order, payDetail) { function setAlmaDeferredCaptureFields(order, deferredCaptureStatus, amount) { if (amount) { Transaction.wrap(function () { - // eslint-disable-next-line no-param-reassign order.custom.ALMA_Deferred_Capture_Status = deferredCaptureStatus; order.custom.ALMA_Deferred_Capture_Partial_Amount_Captured = amount; order.custom.ALMA_Deferred_Capture_Partial_Amount = null; }); } else { Transaction.wrap(function () { - // eslint-disable-next-line no-param-reassign order.custom.ALMA_Deferred_Capture_Status = deferredCaptureStatus; order.custom.ALMA_Deferred_Capture_Partial_Amount = null; }); diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaPaymentHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaPaymentHelper.js index 38645795..e930495d 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaPaymentHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaPaymentHelper.js @@ -1,5 +1,3 @@ -'use strict'; - var pkg = require('../../../package.json'); var CAPTURE = { diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaPlanHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaPlanHelper.js index 56f36376..7743d8f8 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaPlanHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaPlanHelper.js @@ -1,5 +1,3 @@ -'use strict'; - var Site = require('dw/system/Site'); var logger = require('dw/system/Logger').getLogger('alma'); var almaUtilsHelpers = require('*/cartridge/scripts/helpers/almaUtilsHelper'); @@ -23,7 +21,7 @@ function getFeePlans() { try { return JSON.parse(plansString); } catch (e) { - logger.error('Configuration Error, please run \'npm run build:sitepref\' and import site_template.zip again.'); + logger.error('Configuration Error, please run \'npm run build:sitepref\' and import site_template.zip again. Error message: ' + e.toString()); } return []; } diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaProductHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaProductHelper.js index a596ca9b..09c6db18 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaProductHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaProductHelper.js @@ -1,5 +1,3 @@ -'use strict'; - /** * Get product id * @param {Object} product product diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaRefundHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaRefundHelper.js index d1239de2..830d7121 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaRefundHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaRefundHelper.js @@ -1,5 +1,3 @@ -'use strict'; - /** * @param {dw.order.Order} order order to refund * @param {int|null} amount amount for refund @@ -54,11 +52,10 @@ exports.refundPaymentForOrder = function (order, amount) { } Transaction.wrap(function () { - // eslint-disable-next-line no-param-reassign order.custom.almaRefundedAmount += amount ? Math.round(amount) : order.getTotalGrossPrice(); - // eslint-disable-next-line no-param-reassign + order.custom.almaWantedRefundAmount = 0; - // eslint-disable-next-line no-param-reassign + order.custom.almaRefundType = null; }); }; diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaSecurityHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaSecurityHelper.js index 063a77a6..54174acd 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaSecurityHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaSecurityHelper.js @@ -1,5 +1,3 @@ -'use strict'; - var Mac = require('dw/crypto/Mac'); var Encoding = require('dw/crypto/Encoding'); diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaUtilsHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaUtilsHelper.js index 5e49edc3..c25a621e 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaUtilsHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaUtilsHelper.js @@ -1,5 +1,3 @@ -'use strict'; - /** * A forOf function to mimic for..of . :') * @param {array|Object} iterable any iterable item diff --git a/cartridges/int_alma/cartridge/scripts/helpers/almaWidgetHelper.js b/cartridges/int_alma/cartridge/scripts/helpers/almaWidgetHelper.js index d766017d..86f61bc3 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/almaWidgetHelper.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/almaWidgetHelper.js @@ -1,5 +1,3 @@ -'use strict'; - var Site = require('dw/system/Site'); var almaHelpers = require('*/cartridge/scripts/helpers/almaHelpers'); var utils = require('*/cartridge/scripts/helpers/almaUtilsHelper'); diff --git a/cartridges/int_alma/cartridge/scripts/helpers/request.js b/cartridges/int_alma/cartridge/scripts/helpers/request.js index 0eed9695..8ac77832 100644 --- a/cartridges/int_alma/cartridge/scripts/helpers/request.js +++ b/cartridges/int_alma/cartridge/scripts/helpers/request.js @@ -1,5 +1,3 @@ -'use strict'; - var URLUtils = require('dw/web/URLUtils'); var pkg = require('../../../package.json'); diff --git a/cartridges/int_alma/cartridge/scripts/hooks/payment/processor/alma.js b/cartridges/int_alma/cartridge/scripts/hooks/payment/processor/alma.js index ef9cee69..3a2d5b8d 100644 --- a/cartridges/int_alma/cartridge/scripts/hooks/payment/processor/alma.js +++ b/cartridges/int_alma/cartridge/scripts/hooks/payment/processor/alma.js @@ -1,5 +1,3 @@ -'use strict'; - var Resource = require('dw/web/Resource'); var Transaction = require('dw/system/Transaction'); var OrderMgr = require('dw/order/OrderMgr'); @@ -77,7 +75,7 @@ function Authorize(orderNumber, paymentInstrument, paymentProcessor) { } catch (e) { error = true; serverErrors.push( - Resource.msg('error.technical', 'checkout', null) + Resource.msg('error.technical Error message: ' + e.toString(), 'checkout', null) ); } diff --git a/cartridges/int_alma/cartridge/scripts/hooks/payment/processor/alma_form_processor.js b/cartridges/int_alma/cartridge/scripts/hooks/payment/processor/alma_form_processor.js index 22121026..b06ba4aa 100644 --- a/cartridges/int_alma/cartridge/scripts/hooks/payment/processor/alma_form_processor.js +++ b/cartridges/int_alma/cartridge/scripts/hooks/payment/processor/alma_form_processor.js @@ -1,5 +1,3 @@ -'use strict'; - /** * Verifies the required information for billing form is provided. * @param {Object} req - The request object diff --git a/cartridges/int_alma/cartridge/scripts/services/alma.js b/cartridges/int_alma/cartridge/scripts/services/alma.js index d5621efe..f88e0e70 100644 --- a/cartridges/int_alma/cartridge/scripts/services/alma.js +++ b/cartridges/int_alma/cartridge/scripts/services/alma.js @@ -1,5 +1,3 @@ -'use strict'; - var LocalServiceRegistry = require('dw/svc/LocalServiceRegistry'); var almaHelpers = require('*/cartridge/scripts/helpers/almaHelpers'); @@ -16,7 +14,7 @@ function createPayment() { */ createRequest: function (service, params) { service.setRequestMethod('POST'); - service.URL = almaHelpers.getUrl('/v1/payments'); // eslint-disable-line no-param-reassign + service.URL = almaHelpers.getUrl('/v1/payments'); almaHelpers.addHeaders(service); return JSON.stringify(params); @@ -39,7 +37,7 @@ function triggerPayment() { */ createRequest: function (service, params) { service.setRequestMethod('POST'); - service.URL = almaHelpers.getUrl('/v1/payments/' + params.pid + '/trigger'); // eslint-disable-line no-param-reassign + service.URL = almaHelpers.getUrl('/v1/payments/' + params.pid + '/trigger'); almaHelpers.addHeaders(service); }, parseResponse: function (svc, client) { @@ -60,7 +58,7 @@ function getPaymentDetails() { */ createRequest: function (service, params) { service.setRequestMethod('GET'); - service.URL = almaHelpers.getUrl('/v1/payments/' + params.pid); // eslint-disable-line no-param-reassign + service.URL = almaHelpers.getUrl('/v1/payments/' + params.pid); almaHelpers.addHeaders(service); }, parseResponse: function (svc, client) { @@ -82,7 +80,7 @@ function checkEligibility() { */ createRequest: function (service, params) { service.setRequestMethod('POST'); - service.URL = almaHelpers.getUrl('/v2/payments/eligibility'); // eslint-disable-line no-param-reassign + service.URL = almaHelpers.getUrl('/v2/payments/eligibility'); almaHelpers.addHeaders(service); return JSON.stringify(params); @@ -106,7 +104,7 @@ function refundPayment() { */ createRequest: function (service, params) { service.setRequestMethod('POST'); - service.URL = almaHelpers.getUrl('/v1/payments/' + params.pid + '/refunds'); // eslint-disable-line no-param-reassign + service.URL = almaHelpers.getUrl('/v1/payments/' + params.pid + '/refunds'); almaHelpers.addHeaders(service); return JSON.stringify(params); @@ -130,7 +128,7 @@ function flagAsPotentialFraud() { */ createRequest: function (service, params) { service.setRequestMethod('POST'); - service.URL = almaHelpers.getUrl('/v1/payments/' + params.pid + '/potential-fraud'); // eslint-disable-line no-param-reassign + service.URL = almaHelpers.getUrl('/v1/payments/' + params.pid + '/potential-fraud'); almaHelpers.addHeaders(service); return JSON.stringify(params); @@ -154,7 +152,7 @@ function setOrderMerchantReferenceAPI() { */ createRequest: function (service, params) { service.setRequestMethod('POST'); - service.URL = almaHelpers.getUrl('/v1/payments/' + params.pid + '/orders'); // eslint-disable-line no-param-reassign + service.URL = almaHelpers.getUrl('/v1/payments/' + params.pid + '/orders'); almaHelpers.addHeaders(service); return JSON.stringify(params); @@ -178,7 +176,7 @@ function captures() { */ createRequest: function (service, params) { service.setRequestMethod('POST'); - service.URL = almaHelpers.getUrl('/v1/payments/' + params.external_id + '/captures'); // eslint-disable-line no-param-reassign + service.URL = almaHelpers.getUrl('/v1/payments/' + params.external_id + '/captures'); almaHelpers.addHeaders(service); return JSON.stringify(params); @@ -202,7 +200,7 @@ function cancelAlmaPayment() { */ createRequest: function (service, params) { service.setRequestMethod('PUT'); - service.URL = almaHelpers.getUrl('/v1/payments/' + params.external_id + '/cancel'); // eslint-disable-line no-param-reassign + service.URL = almaHelpers.getUrl('/v1/payments/' + params.external_id + '/cancel'); almaHelpers.addHeaders(service); return JSON.stringify(params); diff --git a/cartridges/int_alma/cartridge/scripts/steps/.eslintrc.json b/cartridges/int_alma/cartridge/scripts/steps/.eslintrc.json deleted file mode 100644 index beba3427..00000000 --- a/cartridges/int_alma/cartridge/scripts/steps/.eslintrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "plugins": ["sitegenesis"], - "rules": { - "sitegenesis/no-global-require": ["error"] - } -} diff --git a/cartridges/int_alma/cartridge/scripts/steps/CapturePaymentOrders.js b/cartridges/int_alma/cartridge/scripts/steps/CapturePaymentOrders.js index fa91f631..0f395634 100644 --- a/cartridges/int_alma/cartridge/scripts/steps/CapturePaymentOrders.js +++ b/cartridges/int_alma/cartridge/scripts/steps/CapturePaymentOrders.js @@ -1,5 +1,3 @@ -'use strict'; - var Order = require('dw/order/Order'); var Status = require('dw/system/Status'); @@ -30,7 +28,7 @@ function makeCaptureWhileHaveAnOrder(orders, CAPTURE) { Logger.info(captureType.description + ' payment: order id: {0} - payment id: {1} - capture id : {2}', [order.orderNo, order.custom.almaPaymentId, capture.id]); } catch (e) { almaOrderHelper.setAlmaDeferredCaptureFields(order, CAPTURE.failed.code); - Logger.warn(CAPTURE.failed.description + ' payment: order id: {0}, payment id: {1}', [order.orderNo, order.custom.almaPaymentId]); + Logger.warn(CAPTURE.failed.description + ' payment: order id: {0}, payment id: {1}. Error message: {2}', [order.orderNo, order.custom.almaPaymentId, e.toString()]); } } } diff --git a/cartridges/int_alma/cartridge/scripts/steps/CheckRefund.js b/cartridges/int_alma/cartridge/scripts/steps/CheckRefund.js index 51f522dd..719c83d8 100644 --- a/cartridges/int_alma/cartridge/scripts/steps/CheckRefund.js +++ b/cartridges/int_alma/cartridge/scripts/steps/CheckRefund.js @@ -1,5 +1,3 @@ -'use strict'; - /** * Check if we should refund the payment * @param {dw.order.Order} order to be paid @@ -58,14 +56,14 @@ function cancelDeferredCapturePaymentForARefund(orderItem, Logger) { } /* jshint loopfunc: true */ - // eslint-disable-next-line no-loop-func + Transaction.wrap(function () { orderItem.custom.ALMA_Deferred_Capture_Status = deferredStatus; - // eslint-disable-next-line no-param-reassign + orderItem.custom.almaRefundedAmount = amount; - // eslint-disable-next-line no-param-reassign + orderItem.custom.almaWantedRefundAmount = 0; - // eslint-disable-next-line no-param-reassign + orderItem.custom.almaRefundType = null; }); } diff --git a/cartridges/int_alma/cartridge/scripts/steps/CheckShippingStatus.js b/cartridges/int_alma/cartridge/scripts/steps/CheckShippingStatus.js index 7bfba747..7a6127c5 100644 --- a/cartridges/int_alma/cartridge/scripts/steps/CheckShippingStatus.js +++ b/cartridges/int_alma/cartridge/scripts/steps/CheckShippingStatus.js @@ -1,5 +1,3 @@ -'use strict'; - /** * Check if we should trigger the payment for an Order that have been shipped * @param {dw.order.Order} order to be paid @@ -40,7 +38,7 @@ function triggerPaymentForOrder(triggerService, order) { } Transaction.wrap(function () { - order.custom.ALMA_ResponseDetails = 'Shipping'; // eslint-disable-line no-param-reassign + order.custom.ALMA_ResponseDetails = 'Shipping'; order.setPaymentStatus(Order.PAYMENT_STATUS_PAID); }); } diff --git a/commitlint.config.js b/commitlint.config.js index 0cf61d7e..422b1944 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,3 +1 @@ -'use strict'; - module.exports = { extends: ['@commitlint/config-conventional'] }; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..be74d3db --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,51 @@ +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import js from '@eslint/js'; +import { FlatCompat } from '@eslint/eslintrc'; +import stylisticJs from '@stylistic/eslint-plugin-js'; + +const filename = fileURLToPath(import.meta.url); +const dirname = path.dirname(filename); +const compat = new FlatCompat({ + baseDirectory: dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [ + { + ignores: ['cartridges/int_alma/cartridge/static/', '**/coverage', '**/test'] + }, + ...compat.extends('airbnb-base/legacy'), { + languageOptions: { + ecmaVersion: 2020, + sourceType: 'module' + }, + plugins: { + '@stylistic/js': stylisticJs + }, + rules: { + '@stylistic/js/indent': ['error', 4, { + SwitchCase: 1, + VariableDeclarator: 1 + }], + '@stylistic/js/max-len': 'off', + // complexity: ['error', 5], + 'func-names': 'off', + 'global-require': 'off', // deprecated if needed, use eslint-plugin-n + 'import/no-unresolved': 'off', + indent: 'off', // deprecated, use @stylistic/js/indent + 'max-len': 'off', // deprecated, use @stylistic/js/max-len + 'no-compare-neg-zero': 'error', + 'no-console': 'off', + 'no-fallthrough': 'error', + 'no-inner-declarations': 'error', + 'no-param-reassign': 'off', + 'no-shadow': ['error', { + allow: ['err', 'callback'] + }], + 'no-unused-vars': 'error', + 'no-useless-assignment': 'error', + 'vars-on-top': 'off' + } + }]; diff --git a/ismllinter.config.js b/ismllinter.config.js index 72c66eb4..b0475d21 100644 --- a/ismllinter.config.js +++ b/ismllinter.config.js @@ -1,5 +1,3 @@ -'use strict'; - // Please check all available configurations and rules // at https://www.npmjs.com/package/isml-linter. diff --git a/package-lock.json b/package-lock.json index d3ed4919..f558fcc4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ }, "devDependencies": { "@commitlint/config-conventional": "^19.5.0", + "@stylistic/eslint-plugin-js": "^2.13.0", "@types/chai": "^5.0.1", "chai": "^5.1.2", "chai-subset": "^1.6.0", @@ -24,7 +25,7 @@ "del": "^8.0.0", "dotenv": "^16.4.5", "dw": "^1.0.1", - "eslint": "^8.57.1", + "eslint": "^9.0.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-sitegenesis": "~1.0.0", @@ -33,7 +34,7 @@ "husky": "^9.1.6", "isml-linter": "^5.43.9", "istanbul": "^0.4.5", - "mocha": "^10.8.2", + "mocha": "^11.0.0", "mocha-junit-reporter": "^2.2.1", "node-fetch": "^3.3.2", "postcss-loader": "^8.1.1", @@ -46,7 +47,7 @@ "sinon": "^19.0.2", "style-loader": "^4.0.0", "stylelint": "^16.10.0", - "stylelint-config-standard": "^36.0.1", + "stylelint-config-standard": "^37.0.0", "stylelint-scss": "^6.9.0", "xml2js": "^0.6.2" }, @@ -830,17 +831,45 @@ "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, + "node_modules/@eslint/config-array": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.19.1.tgz", + "integrity": "sha512-fo6Mtm5mWyKjA/Chy1BYTdn5mGJoDNjC7C64ug20ADsRDGrA85bN3uK3MaKbeRkRuuIEAR5N33Jr1pbm411/PA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.5", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.10.0.tgz", + "integrity": "sha512-gFHJ+xBOo4G3WRlR1e/3G8A6/KZAH6zcE/hkLRCZTi/B9avAG365QhFA8uOGzTMqgTghpn7/fSnscW++dpMSAw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/@eslint/eslintrc": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", - "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.2.0.tgz", + "integrity": "sha512-grOjVNN8P3hjJn/eIETF1wwd12DdnwFDoyceUJLYYdkpbwq3nLi+4fqrTAONx7XDALqlL220wC/RHSC/QTI/0w==", "dev": true, "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.6.0", - "globals": "^13.19.0", + "espree": "^10.0.1", + "globals": "^14.0.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", @@ -848,7 +877,7 @@ "strip-json-comments": "^3.1.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -871,6 +900,19 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@eslint/eslintrc/node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -879,13 +921,37 @@ "license": "MIT" }, "node_modules/@eslint/js": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", - "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.18.0.tgz", + "integrity": "sha512-fK6L7rxcq6/z+AaQMtiFTkvbHkBLNlwyRxHpKawP0x3u9+NC6MQTnFW+AdpwC6gfHTW0051cokQgtTN2FqlxQA==", "dev": true, "license": "MIT", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.5.tgz", + "integrity": "sha512-o0bhxnL89h5Bae5T318nFoFzGy+YE5i/gGkoPAgkmTVdRKTiv3p8JHevPiPaMwoloKfEiiaHlawCqaZMqRm+XQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.5.tgz", + "integrity": "sha512-lB05FkqEdUg2AA0xEbUz0SnkXT1LcCTa438W4IWTUh4hdOnVbQyOJ81OrDXsJk/LSiJHubgGEFoR5EHq1NsH1A==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.10.0", + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@gulpjs/messages": { @@ -911,20 +977,42 @@ "node": ">=10.13.0" } }, - "node_modules/@humanwhocodes/config-array": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", - "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", - "deprecated": "Use @eslint/config-array instead", + "node_modules/@humanfs/core": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.6", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", + "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@humanwhocodes/object-schema": "^2.0.3", - "debug": "^4.3.1", - "minimatch": "^3.0.5" + "@humanfs/core": "^0.19.1", + "@humanwhocodes/retry": "^0.3.0" }, "engines": { - "node": ">=10.10.0" + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", + "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" } }, "node_modules/@humanwhocodes/module-importer": { @@ -941,13 +1029,122 @@ "url": "https://github.com/sponsors/nzakas" } }, - "node_modules/@humanwhocodes/object-schema": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", - "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", - "deprecated": "Use @eslint/object-schema instead", + "node_modules/@humanwhocodes/retry": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.1.tgz", + "integrity": "sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==", "dev": true, - "license": "BSD-3-Clause" + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", @@ -1519,6 +1716,17 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@popperjs/core": { "version": "2.11.8", "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", @@ -1606,6 +1814,36 @@ "dev": true, "license": "(Unlicense OR Apache-2.0)" }, + "node_modules/@stylistic/eslint-plugin-js": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-2.13.0.tgz", + "integrity": "sha512-GPPDK4+fcbsQD58a3abbng2Dx+jBoxM5cnYjBM4T24WFZRZdlNSKvR19TxP8CPevzMOodQ9QVzNeqWvMXzfJRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/@tridnguyen/config": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/@tridnguyen/config/-/config-2.3.1.tgz", @@ -1718,13 +1956,6 @@ "@types/node": "*" } }, - "node_modules/@ungap/structured-clone": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", - "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", - "dev": true, - "license": "ISC" - }, "node_modules/@webassemblyjs/ast": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz", @@ -3170,9 +3401,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", - "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "license": "MIT", "dependencies": { @@ -3906,6 +4137,13 @@ "node": ">= 10.13.0" } }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, + "license": "MIT" + }, "node_modules/easy-transform-stream": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/easy-transform-stream/-/easy-transform-stream-1.0.1.tgz", @@ -4266,60 +4504,63 @@ } }, "node_modules/eslint": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", - "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", - "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.18.0.tgz", + "integrity": "sha512-+waTfRWQlSbpt3KWE+CjrPPYnbq9kfZIYUqapc0uBXyjTp8aYXZDsUH16m39Ryq3NjAVP4tjuF7KaukeqoCoaA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.57.1", - "@humanwhocodes/config-array": "^0.13.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.19.0", + "@eslint/core": "^0.10.0", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "9.18.0", + "@eslint/plugin-kit": "^0.2.5", + "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "@ungap/structured-clone": "^1.2.0", + "@humanwhocodes/retry": "^0.4.1", + "@types/estree": "^1.0.6", + "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", + "cross-spawn": "^7.0.6", "debug": "^4.3.2", - "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.3", - "espree": "^9.6.1", - "esquery": "^1.4.2", + "eslint-scope": "^8.2.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", + "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "graphemer": "^1.4.0", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.3", - "strip-ansi": "^6.0.1", - "text-table": "^0.2.0" + "optionator": "^0.9.3" }, "bin": { "eslint": "bin/eslint.js" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://opencollective.com/eslint" + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } } }, "node_modules/eslint-config-airbnb-base": { @@ -4480,9 +4721,9 @@ } }, "node_modules/eslint-scope": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", - "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", + "integrity": "sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -4490,7 +4731,7 @@ "estraverse": "^5.2.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -4569,6 +4810,32 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/eslint/node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -4586,20 +4853,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "node_modules/eslint/node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", "dev": true, "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, "engines": { - "node": ">=8" + "node": ">=16" } }, - "node_modules/eslint/node_modules/is-path-inside": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "node_modules/eslint/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, "license": "MIT", "engines": { @@ -4698,18 +4969,31 @@ } }, "node_modules/espree": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", - "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", + "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.9.0", + "acorn": "^8.14.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.1" + "eslint-visitor-keys": "^4.2.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -5694,13 +5978,6 @@ "dev": true, "license": "ISC" }, - "node_modules/graphemer": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", - "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", - "dev": true, - "license": "MIT" - }, "node_modules/growly": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", @@ -7687,6 +7964,22 @@ "which": "bin/which" } }, + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, "node_modules/jest-worker": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz", @@ -8526,6 +8819,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/mkdirp": { "version": "0.5.6", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", @@ -8540,9 +8843,9 @@ } }, "node_modules/mocha": { - "version": "10.8.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", - "integrity": "sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-11.0.1.tgz", + "integrity": "sha512-+3GkODfsDG71KSCQhc4IekSW+ItCK/kiez1Z28ksWvYhKXV/syxMlerR/sC7whDp7IyreZ4YxceMLdTs5hQE8A==", "dev": true, "license": "MIT", "dependencies": { @@ -8553,7 +8856,7 @@ "diff": "^5.2.0", "escape-string-regexp": "^4.0.0", "find-up": "^5.0.0", - "glob": "^8.1.0", + "glob": "^10.4.5", "he": "^1.2.0", "js-yaml": "^4.1.0", "log-symbols": "^4.1.0", @@ -8572,7 +8875,7 @@ "mocha": "bin/mocha.js" }, "engines": { - "node": ">= 14.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/mocha-junit-reporter": { @@ -8647,22 +8950,55 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/mocha/node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "deprecated": "Glob versions prior to v9 are no longer supported", + "node_modules/mocha/node_modules/foreground-child": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", + "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", "dev": true, "license": "ISC", "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" }, "engines": { - "node": ">=12" + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/glob/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -8749,6 +9085,19 @@ "node": ">=8" } }, + "node_modules/mocha/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/mocha/node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", @@ -9604,6 +9953,13 @@ "node": ">=8" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, "node_modules/pako": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", @@ -9735,6 +10091,30 @@ "node": ">=0.10.0" } }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, "node_modules/path-to-regexp": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", @@ -10968,6 +11348,16 @@ "node": ">=0.10.0" } }, + "node_modules/sgmf-scripts/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, "node_modules/sgmf-scripts/node_modules/chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -10985,6 +11375,41 @@ "node": ">=0.10.0" } }, + "node_modules/sgmf-scripts/node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/sgmf-scripts/node_modules/cliui/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/sgmf-scripts/node_modules/cliui/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/sgmf-scripts/node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -10995,6 +11420,54 @@ "node": ">=0.8.0" } }, + "node_modules/sgmf-scripts/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/sgmf-scripts/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/sgmf-scripts/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/sgmf-scripts/node_modules/levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -11009,6 +11482,100 @@ "node": ">= 0.8.0" } }, + "node_modules/sgmf-scripts/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/sgmf-scripts/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sgmf-scripts/node_modules/mocha": { + "version": "10.8.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.8.2.tgz", + "integrity": "sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", + "chokidar": "^3.5.3", + "debug": "^4.3.5", + "diff": "^5.2.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^8.1.0", + "he": "^1.2.0", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^5.1.6", + "ms": "^2.1.3", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^6.5.1", + "yargs": "^16.2.0", + "yargs-parser": "^20.2.9", + "yargs-unparser": "^2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/sgmf-scripts/node_modules/mocha/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/sgmf-scripts/node_modules/mocha/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/sgmf-scripts/node_modules/optionator": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", @@ -11027,6 +11594,48 @@ "node": ">= 0.8.0" } }, + "node_modules/sgmf-scripts/node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/sgmf-scripts/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/sgmf-scripts/node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/sgmf-scripts/node_modules/prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", @@ -11072,6 +11681,38 @@ "node": ">= 0.8.0" } }, + "node_modules/sgmf-scripts/node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sgmf-scripts/node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -11491,6 +12132,22 @@ "node": ">=8" } }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/string.prototype.trim": { "version": "1.2.9", "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.9.tgz", @@ -11556,6 +12213,20 @@ "node": ">=8" } }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-bom": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", @@ -11597,9 +12268,9 @@ } }, "node_modules/stylelint": { - "version": "16.13.0", - "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-16.13.0.tgz", - "integrity": "sha512-muxVjMhZB8BrDFSKNva0dmvD2tM0o/szrvuZuXYcAnN9a8nQmbGLqNUOemSgumaCMCPQ+0USYyG3hA5vJjUC1Q==", + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/stylelint/-/stylelint-16.13.1.tgz", + "integrity": "sha512-691JjSIIcP6f9QJFz0J0/AMG3lupE9RqYAgYCON3wiqp5nQiKqDYIsz321GeTOYNznoRPNh0Mf6VjzP1eBVz/Q==", "dev": true, "funding": [ { @@ -11631,7 +12302,7 @@ "globby": "^11.1.0", "globjoin": "^0.1.4", "html-tags": "^3.3.1", - "ignore": "^7.0.0", + "ignore": "^7.0.1", "imurmurhash": "^0.1.4", "is-plain-object": "^5.0.0", "known-css-properties": "^0.35.0", @@ -11660,9 +12331,9 @@ } }, "node_modules/stylelint-config-recommended": { - "version": "14.0.1", - "resolved": "https://registry.npmjs.org/stylelint-config-recommended/-/stylelint-config-recommended-14.0.1.tgz", - "integrity": "sha512-bLvc1WOz/14aPImu/cufKAZYfXs/A/owZfSMZ4N+16WGXLoX5lOir53M6odBxvhgmgdxCVnNySJmZKx73T93cg==", + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/stylelint-config-recommended/-/stylelint-config-recommended-15.0.0.tgz", + "integrity": "sha512-9LejMFsat7L+NXttdHdTq94byn25TD+82bzGRiV1Pgasl99pWnwipXS5DguTpp3nP1XjvLXVnEJIuYBfsRjRkA==", "dev": true, "funding": [ { @@ -11679,13 +12350,13 @@ "node": ">=18.12.0" }, "peerDependencies": { - "stylelint": "^16.1.0" + "stylelint": "^16.13.0" } }, "node_modules/stylelint-config-standard": { - "version": "36.0.1", - "resolved": "https://registry.npmjs.org/stylelint-config-standard/-/stylelint-config-standard-36.0.1.tgz", - "integrity": "sha512-8aX8mTzJ6cuO8mmD5yon61CWuIM4UD8Q5aBcWKGSf6kg+EC3uhB+iOywpTK4ca6ZL7B49en8yanOFtUW0qNzyw==", + "version": "37.0.0", + "resolved": "https://registry.npmjs.org/stylelint-config-standard/-/stylelint-config-standard-37.0.0.tgz", + "integrity": "sha512-+6eBlbSTrOn/il2RlV0zYGQwRTkr+WtzuVSs1reaWGObxnxLpbcspCUYajVQHonVfxVw2U+h42azGhrBvcg8OA==", "dev": true, "funding": [ { @@ -11699,13 +12370,13 @@ ], "license": "MIT", "dependencies": { - "stylelint-config-recommended": "^14.0.1" + "stylelint-config-recommended": "^15.0.0" }, "engines": { "node": ">=18.12.0" }, "peerDependencies": { - "stylelint": "^16.1.0" + "stylelint": "^16.13.0" } }, "node_modules/stylelint-scss": { @@ -11731,6 +12402,43 @@ "stylelint": "^16.0.2" } }, + "node_modules/stylelint-scss/node_modules/postcss-selector-parser": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-7.0.0.tgz", + "integrity": "sha512-9RbEr1Y7FFfptd/1eEdntyjMwLeghW1bHX9GWjXo19vx4ytPQhANltvVxDggzJl7mnWM+dX28kb6cyS/4iQjlQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/stylelint/node_modules/@csstools/selector-specificity": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@csstools/selector-specificity/-/selector-specificity-5.0.0.tgz", + "integrity": "sha512-PCqQV3c4CoVm3kdPhyeZ07VmBRdH2EpMFA/pd9OASpOEC3aXNGoqPDAZ80D0cLpMBxnmk0+yNhGsEx31hq7Gtw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "postcss-selector-parser": "^7.0.0" + } + }, "node_modules/stylelint/node_modules/array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -11830,9 +12538,9 @@ } }, "node_modules/stylelint/node_modules/ignore": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.0.tgz", - "integrity": "sha512-lcX8PNQygAa22u/0BysEY8VhaFRzlOkvdlKczDPnJvrkJD1EuqzEky5VYYKM2iySIuaVIDv9N190DfSreSLw2A==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.3.tgz", + "integrity": "sha512-bAH5jbK/F3T3Jls4I0SO1hmPR0dKU0a7+SY6n1yzRtG54FLO8d6w/nxLFX2Nb7dBu6cCWXPaAME6cYqFUMmuCA==", "dev": true, "license": "MIT", "engines": { @@ -12985,6 +13693,25 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index 9567a891..c34f040d 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "homepage": "https://github.com/alma/sfcc-plugin", "devDependencies": { "@commitlint/config-conventional": "^19.5.0", + "@stylistic/eslint-plugin-js": "^2.13.0", "@types/chai": "^5.0.1", "chai": "^5.1.2", "chai-subset": "^1.6.0", @@ -22,7 +23,7 @@ "del": "^8.0.0", "dotenv": "^16.4.5", "dw": "^1.0.1", - "eslint": "^8.57.1", + "eslint": "^9.0.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-plugin-import": "^2.31.0", "eslint-plugin-sitegenesis": "~1.0.0", @@ -31,7 +32,7 @@ "husky": "^9.1.6", "isml-linter": "^5.43.9", "istanbul": "^0.4.5", - "mocha": "^10.8.2", + "mocha": "^11.0.0", "mocha-junit-reporter": "^2.2.1", "node-fetch": "^3.3.2", "postcss-loader": "^8.1.1", @@ -44,7 +45,7 @@ "sinon": "^19.0.2", "style-loader": "^4.0.0", "stylelint": "^16.10.0", - "stylelint-config-standard": "^36.0.1", + "stylelint-config-standard": "^37.0.0", "stylelint-scss": "^6.9.0", "xml2js": "^0.6.2" }, diff --git a/site_preference_builder/.eslintrc.json b/site_preference_builder/.eslintrc.json deleted file mode 100644 index 12725ba4..00000000 --- a/site_preference_builder/.eslintrc.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "root": true, - "extends": "airbnb-base/legacy", - "rules": { - "import/no-unresolved": "off", - "indent": ["error", 2, { "SwitchCase": 1, "VariableDeclarator": 1 }], - "func-names": "off", - "require-jsdoc": "error", - "valid-jsdoc": ["error", { "preferType": { "Boolean": "boolean", "Number": "number", "object": "Object", "String": "string" }, "requireReturn": false}], - "vars-on-top": "off", - "global-require": "off", - "no-shadow": ["error", { "allow": ["err", "callback"]}] - }, - "parserOptions": { - "ecmaVersion": 2017 - }, - "env": { - "es6": true - } -} \ No newline at end of file diff --git a/site_preference_builder/api.cjs b/site_preference_builder/api.cjs index 9a7c3757..0894e030 100644 --- a/site_preference_builder/api.cjs +++ b/site_preference_builder/api.cjs @@ -1,29 +1,26 @@ -'use strict'; - let fetch; const API_VERSION = 'v1'; async function loadFetch() { - if (!fetch) { - fetch = (await import('node-fetch')).default; - } + if (!fetch) { + fetch = (await import('node-fetch')).default; + } } exports.getFeePlansFromAPI = async function (baseurl, key) { - await loadFetch(); - const url = `${baseurl}/${API_VERSION}/me/fee-plans?kind=general&only=all&deferred=true`; - try { - const response = await fetch(url, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - Authorization: `Alma-Auth ${key}` - } - }); - return response.json(); - } catch (e) { - /* eslint-disable no-console */ - console.error(`Could not reach API : "${url}", please check your .env`); - } - return {}; + await loadFetch(); + const url = `${baseurl}/${API_VERSION}/me/fee-plans?kind=general&only=all&deferred=true`; + try { + const response = await fetch(url, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + Authorization: `Alma-Auth ${key}` + } + }); + return response.json(); + } catch (e) { + console.error(`Could not reach API : "${url}", please check your .env Error message: ${e.toString()}`); + } + return {}; }; diff --git a/site_preference_builder/compress.cjs b/site_preference_builder/compress.cjs index 22792f22..2d535462 100644 --- a/site_preference_builder/compress.cjs +++ b/site_preference_builder/compress.cjs @@ -1,10 +1,7 @@ -/* eslint-disable no-console */ -'use strict'; - const gulp = require('gulp'); const path = require('path'); require('dotenv').config({ - path: path.resolve(__dirname, '../.env'), + path: path.resolve(__dirname, '../.env') }); const { createDir } = require('./fs'); @@ -16,45 +13,45 @@ let zip; * Charge dynamiquement les modules ESM nécessaires */ async function loadDependencies() { - if (!deleteSync || !zip) { - const del = await import('del'); - deleteSync = del.deleteSync; - zip = (await import('gulp-zip')).default; - } + if (!deleteSync || !zip) { + const del = await import('del'); + deleteSync = del.deleteSync; + zip = (await import('gulp-zip')).default; + } } /** * Create payment processor and payment methods files */ async function createPaymentRefFiles() { - const siteDir = `./metadata/site_template/sites/${process.env.SFCC_SITE_NAME}/`; - createDir(siteDir); + const siteDir = `./metadata/site_template/sites/${process.env.SFCC_SITE_NAME}/`; + createDir(siteDir); - console.log('Copying ref. files'); - const paymentRefFiles = './site_preference_builder/ref/payment/*.xml'; - gulp.src(paymentRefFiles) - .pipe(gulp.dest(siteDir)); + console.log('Copying ref. files'); + const paymentRefFiles = './site_preference_builder/ref/payment/*.xml'; + gulp.src(paymentRefFiles) + .pipe(gulp.dest(siteDir)); } /** * Create services file */ async function copyServiceFile() { - console.log('Copying service file'); - gulp.src('./site_preference_builder/ref/services.xml') - .pipe(gulp.dest('./metadata/site_template/')); + console.log('Copying service file'); + gulp.src('./site_preference_builder/ref/services.xml') + .pipe(gulp.dest('./metadata/site_template/')); } /** * Create Archive */ async function createZipFile() { - console.log('Creating archive'); - await loadDependencies(); // Charger les modules ESM nécessaires - deleteSync(['./site_template.zip']); - gulp.src('./metadata/**') - .pipe(zip('site_template.zip')) - .pipe(gulp.dest('./')); + console.log('Creating archive'); + await loadDependencies(); // Charger les modules ESM nécessaires + deleteSync(['./site_template.zip']); + gulp.src('./metadata/**') + .pipe(zip('site_template.zip')) + .pipe(gulp.dest('./')); } /** @@ -62,19 +59,19 @@ async function createZipFile() { * @returns {number} 0|1 0 is success, 1 is an error */ async function main() { - if (!process.env.SFCC_SITE_NAME) { - console.error('Undefined env variable SFCC_SITE_NAME. Please go to your .env file to configure it'); - return 1; - } - console.log(`Your SFCC site name : ${process.env.SFCC_SITE_NAME}`); + if (!process.env.SFCC_SITE_NAME) { + console.error('Undefined env variable SFCC_SITE_NAME. Please go to your .env file to configure it'); + return 1; + } + console.log(`Your SFCC site name : ${process.env.SFCC_SITE_NAME}`); - await createPaymentRefFiles(); - await copyServiceFile(); - await createZipFile(); + await createPaymentRefFiles(); + await copyServiceFile(); + await createZipFile(); - console.log('Done'); + console.log('Done'); - return 0; + return 0; } main(); diff --git a/site_preference_builder/customSitePrefBuilder.js b/site_preference_builder/customSitePrefBuilder.js index 3f7a6dac..5215cb92 100644 --- a/site_preference_builder/customSitePrefBuilder.js +++ b/site_preference_builder/customSitePrefBuilder.js @@ -1,22 +1,20 @@ -'use strict'; - const fs = require('fs'); const xml2js = require('xml2js'); const { - ConfigException + ConfigException } = require('./error'); const path = require('path'); require('dotenv').config({ - path: path.resolve(__dirname, '../.env') + path: path.resolve(__dirname, '../.env') }); let localisationFile = './messages.json'; const locale = process.env.LOCALE; if (locale !== 'en_GB' && fs.existsSync(path.join(__dirname, `messages-${locale}.json`))) { - localisationFile = `./messages-${locale}.json`; + localisationFile = `./messages-${locale}.json`; } const messages = require(localisationFile); @@ -24,50 +22,50 @@ const messages = require(localisationFile); // we also remove 1x that isn't deferred, as the api will provide it, // but we don't want to display it const filterAllowedPlan = (plan) => { - return plan.allowed; + return plan.allowed; }; const getMessageKey = (installments, deferredDays) => { - if (installments > 1 && deferredDays > 0) { - return 'x_times_deferred_payment'; - } - if (deferredDays > 0) { - return 'deferred_payment'; - } - if (installments >= 1) { - return 'x_times_payment'; - } - throw new ConfigException('could not find this type of payment'); + if (installments > 1 && deferredDays > 0) { + return 'x_times_deferred_payment'; + } + if (deferredDays > 0) { + return 'deferred_payment'; + } + if (installments >= 1) { + return 'x_times_payment'; + } + throw new ConfigException('could not find this type of payment'); }; const getSitePrefDisplayInfos = (plan) => { - const installments = plan.installments_count; - const deferredDays = plan.deferred_days; - const minAmount = plan.min_purchase_amount / 100; - const maxAmount = plan.max_purchase_amount / 100; - - const message = messages[getMessageKey(installments, deferredDays)]; - // use of another variable to avoid side effects - const currentMessage = {}; - // TODO: use Object.entries when we refactor code to match Node >=22 - // eslint-disable-next-line no-restricted-syntax - for (let messageKey of Object.keys(message)) { - currentMessage[messageKey] = message[messageKey] - .replace('[[installments]]', installments) - .replace('[[deferredDays]]', deferredDays); - } - - return { - id: `ALMA_general_${installments}_${deferredDays}`, - lang: 'x-default', - text: currentMessage.title, - min: currentMessage.min, - min_disclaimer: currentMessage.min_disclaimer.replace('[[amount]]', minAmount), - max: currentMessage.max, - max_disclaimer: currentMessage.max_disclaimer.replace('[[amount]]', maxAmount), - group: currentMessage.group, - group_id: `ALMA_${installments}_${deferredDays}` - }; + const installments = plan.installments_count; + const deferredDays = plan.deferred_days; + const minAmount = plan.min_purchase_amount / 100; + const maxAmount = plan.max_purchase_amount / 100; + + const message = messages[getMessageKey(installments, deferredDays)]; + // use of another variable to avoid side effects + const currentMessage = {}; + // TODO: use Object.entries when we refactor code to match Node >=22 + // eslint-disable-next-line no-restricted-syntax + for (let messageKey of Object.keys(message)) { + currentMessage[messageKey] = message[messageKey] + .replace('[[installments]]', installments) + .replace('[[deferredDays]]', deferredDays); + } + + return { + id: `ALMA_general_${installments}_${deferredDays}`, + lang: 'x-default', + text: currentMessage.title, + min: currentMessage.min, + min_disclaimer: currentMessage.min_disclaimer.replace('[[amount]]', minAmount), + max: currentMessage.max, + max_disclaimer: currentMessage.max_disclaimer.replace('[[amount]]', maxAmount), + group: currentMessage.group, + group_id: `ALMA_${installments}_${deferredDays}` + }; }; /** @@ -77,53 +75,53 @@ const getSitePrefDisplayInfos = (plan) => { * @returns {Object} the created custom site preference */ const buildCustomSitePrefObject = (sitePref) => { - /** + /** * Site pref attributes need to be inputted in a specific order * and js is not very good with that */ - const customSitePref = { - $: { - 'attribute-id': sitePref.id - }, - 'display-name': [{ - _: sitePref.name, - $: { - 'xml:lang': 'x-default' - } - }] - }; - - if (sitePref.description) { - customSitePref.description = [{ - _: sitePref.description, - $: { - 'xml:lang': 'x-default' - } - }]; - } - customSitePref.type = [sitePref.type]; - customSitePref['mandatory-flag'] = ['false']; - if (sitePref.mandatory) { - customSitePref['mandatory-flag'] = [String(sitePref.mandatory)]; - } - customSitePref['externally-managed-flag'] = ['false']; - if (sitePref.externallyManaged) { - customSitePref['externally-managed-flag'] = [String(sitePref.externallyManaged)]; - } - if (sitePref.defaultValue) { - customSitePref['default-value'] = [sitePref.defaultValue]; - } - if (sitePref.valueDefinitions) { - customSitePref['value-definitions'] = { - 'value-definition': [] + const customSitePref = { + $: { + 'attribute-id': sitePref.id + }, + 'display-name': [{ + _: sitePref.name, + $: { + 'xml:lang': 'x-default' + } + }] }; - sitePref.valueDefinitions.forEach((value) => { - customSitePref['value-definitions']['value-definition'].push({ - value: value - }); - }); - } - return customSitePref; + + if (sitePref.description) { + customSitePref.description = [{ + _: sitePref.description, + $: { + 'xml:lang': 'x-default' + } + }]; + } + customSitePref.type = [sitePref.type]; + customSitePref['mandatory-flag'] = ['false']; + if (sitePref.mandatory) { + customSitePref['mandatory-flag'] = [String(sitePref.mandatory)]; + } + customSitePref['externally-managed-flag'] = ['false']; + if (sitePref.externallyManaged) { + customSitePref['externally-managed-flag'] = [String(sitePref.externallyManaged)]; + } + if (sitePref.defaultValue) { + customSitePref['default-value'] = [sitePref.defaultValue]; + } + if (sitePref.valueDefinitions) { + customSitePref['value-definitions'] = { + 'value-definition': [] + }; + sitePref.valueDefinitions.forEach((value) => { + customSitePref['value-definitions']['value-definition'].push({ + value: value + }); + }); + } + return customSitePref; }; /** @@ -134,210 +132,210 @@ const buildCustomSitePrefObject = (sitePref) => { * @returns {Object} created group */ const buildCustomGroupObject = (id, name, attributes) => { - const group = { - $: { - 'group-id': id - }, - 'display-name': [{ - _: name, - $: { - 'xml:lang': 'x-default' - } - }], - attribute: [] - }; - - attributes.forEach((attr) => { - group.attribute.push({ - $: { - 'attribute-id': attr - } + const group = { + $: { + 'group-id': id + }, + 'display-name': [{ + _: name, + $: { + 'xml:lang': 'x-default' + } + }], + attribute: [] + }; + + attributes.forEach((attr) => { + group.attribute.push({ + $: { + 'attribute-id': attr + } + }); }); - }); - return group; + return group; }; exports.xmlToJson = async (fileContent) => xml2js.parseStringPromise(fileContent); exports.jsonToXML = (jsonSitePref) => { - const builder = new xml2js.Builder(); - return builder.buildObject(jsonSitePref); + const builder = new xml2js.Builder(); + return builder.buildObject(jsonSitePref); }; exports.addFeePlans = (file, plans) => { - // only keep needed fields - const plansToSerialize = plans.map((plan) => { - return { - allowed: plan.allowed, - deferred_days: plan.deferred_days, - deferred_trigger_limit_days: plan.deferred_trigger_limit_days, - installments_count: plan.installments_count, - max_purchase_amount: plan.max_purchase_amount, - min_purchase_amount: plan.min_purchase_amount - }; - }); - - file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( - buildCustomSitePrefObject({ - id: 'ALMA_FEE_PLANS', - name: 'Advanced Alma plan management', - type: 'string', - description: 'Can be used to update your alma plans', - mandatory: false, - externallyManaged: false, - defaultValue: JSON.stringify(plansToSerialize) - }) - ); - - return file; -}; + // only keep needed fields + const plansToSerialize = plans.map((plan) => { + return { + allowed: plan.allowed, + deferred_days: plan.deferred_days, + deferred_trigger_limit_days: plan.deferred_trigger_limit_days, + installments_count: plan.installments_count, + max_purchase_amount: plan.max_purchase_amount, + min_purchase_amount: plan.min_purchase_amount + }; + }); -exports.addAPIInfo = (file, url, merchantId) => { - // add ALMA_APIKey as a custom site pref - file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( - buildCustomSitePrefObject({ - id: 'ALMA_APIKey', - name: 'Your Alma API key', - type: 'password', - mandatory: false, - externallyManaged: false - }) - ); - - // add ALMA_Merchant_Id as a custom site pref - file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( - buildCustomSitePrefObject({ - id: 'ALMA_Merchant_Id', - name: 'Your Alma Merchant Id', - type: 'string', - mandatory: false, - externallyManaged: false, - defaultValue: merchantId - }) - ); - - // add ALMA_APIUrl as a custom site pref - file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( - buildCustomSitePrefObject({ - id: 'ALMA_APIUrl', - name: 'Alma API Url', - type: 'string', - mandatory: false, - externallyManaged: false, - defaultValue: url - }) - ); - - return file; + file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( + buildCustomSitePrefObject({ + id: 'ALMA_FEE_PLANS', + name: 'Advanced Alma plan management', + type: 'string', + description: 'Can be used to update your alma plans', + mandatory: false, + externallyManaged: false, + defaultValue: JSON.stringify(plansToSerialize) + }) + ); + + return file; }; -exports.addCustomAttrFromPlan = (file, plans) => { - plans - .filter(filterAllowedPlan) - .forEach((plan) => { - const { - id, - text, - min, - max, - min_disclaimer: minDisclaimer, - max_disclaimer: maxDisclaimer - } = getSitePrefDisplayInfos(plan); - - file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( +exports.addAPIInfo = (file, url, merchantId) => { + // add ALMA_APIKey as a custom site pref + file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( buildCustomSitePrefObject({ - id: id, - name: text, - type: 'boolean' + id: 'ALMA_APIKey', + name: 'Your Alma API key', + type: 'password', + mandatory: false, + externallyManaged: false }) - ); - file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( + ); + + // add ALMA_Merchant_Id as a custom site pref + file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( buildCustomSitePrefObject({ - id: `${id}_min`, - name: min, - type: 'double', - description: minDisclaimer + id: 'ALMA_Merchant_Id', + name: 'Your Alma Merchant Id', + type: 'string', + mandatory: false, + externallyManaged: false, + defaultValue: merchantId }) - ); - file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( + ); + + // add ALMA_APIUrl as a custom site pref + file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( buildCustomSitePrefObject({ - id: `${id}_max`, - name: max, - type: 'double', - description: maxDisclaimer + id: 'ALMA_APIUrl', + name: 'Alma API Url', + type: 'string', + mandatory: false, + externallyManaged: false, + defaultValue: url }) - ); - }); + ); - return file; + return file; }; -exports.addCustomGroupFromPlan = (file, plans) => { - plans - .filter(filterAllowedPlan) - .forEach((plan) => { - const { - id, - group, - group_id: groupId - } = getSitePrefDisplayInfos(plan); - - file.metadata['type-extension'][2]['group-definitions'][0]['attribute-group'].push( - buildCustomGroupObject(groupId, group, [`${id}`, `${id}_min`, `${id}_max`]) - ); - }); +exports.addCustomAttrFromPlan = (file, plans) => { + plans + .filter(filterAllowedPlan) + .forEach((plan) => { + const { + id, + text, + min, + max, + min_disclaimer: minDisclaimer, + max_disclaimer: maxDisclaimer + } = getSitePrefDisplayInfos(plan); + + file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( + buildCustomSitePrefObject({ + id: id, + name: text, + type: 'boolean' + }) + ); + file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( + buildCustomSitePrefObject({ + id: `${id}_min`, + name: min, + type: 'double', + description: minDisclaimer + }) + ); + file.metadata['type-extension'][2]['custom-attribute-definitions'][0]['attribute-definition'].push( + buildCustomSitePrefObject({ + id: `${id}_max`, + name: max, + type: 'double', + description: maxDisclaimer + }) + ); + }); + + return file; +}; - return file; +exports.addCustomGroupFromPlan = (file, plans) => { + plans + .filter(filterAllowedPlan) + .forEach((plan) => { + const { + id, + group, + group_id: groupId + } = getSitePrefDisplayInfos(plan); + + file.metadata['type-extension'][2]['group-definitions'][0]['attribute-group'].push( + buildCustomGroupObject(groupId, group, [`${id}`, `${id}_min`, `${id}_max`]) + ); + }); + + return file; }; exports.addRefundCustomAttributes = (file) => { - file.metadata['type-extension'][0]['custom-attribute-definitions'][0]['attribute-definition'].push( - buildCustomSitePrefObject({ - id: 'almaRefundedAmount', - name: messages.almaRefundedAmount.name, - type: 'double', - mandatory: false, - externallyManaged: true - }) - ); - file.metadata['type-extension'][0]['custom-attribute-definitions'][0]['attribute-definition'].push( - buildCustomSitePrefObject({ - id: 'almaWantedRefundAmount', - name: messages.almaWantedRefundAmount.name, - type: 'double', - mandatory: false, - externallyManaged: false - }) - ); - file.metadata['type-extension'][0]['custom-attribute-definitions'][0]['attribute-definition'].push( - buildCustomSitePrefObject({ - id: 'almaRefundType', - name: messages.almaRefundType.name, - description: messages.almaRefundType.description, - type: 'enum-of-string', - mandatory: false, - externallyManaged: false, - valueDefinitions: [ - messages.almaRefundType.valueDefinitions.total, - messages.almaRefundType.valueDefinitions.partial - ] - }) - ); - - return file; + file.metadata['type-extension'][0]['custom-attribute-definitions'][0]['attribute-definition'].push( + buildCustomSitePrefObject({ + id: 'almaRefundedAmount', + name: messages.almaRefundedAmount.name, + type: 'double', + mandatory: false, + externallyManaged: true + }) + ); + file.metadata['type-extension'][0]['custom-attribute-definitions'][0]['attribute-definition'].push( + buildCustomSitePrefObject({ + id: 'almaWantedRefundAmount', + name: messages.almaWantedRefundAmount.name, + type: 'double', + mandatory: false, + externallyManaged: false + }) + ); + file.metadata['type-extension'][0]['custom-attribute-definitions'][0]['attribute-definition'].push( + buildCustomSitePrefObject({ + id: 'almaRefundType', + name: messages.almaRefundType.name, + description: messages.almaRefundType.description, + type: 'enum-of-string', + mandatory: false, + externallyManaged: false, + valueDefinitions: [ + messages.almaRefundType.valueDefinitions.total, + messages.almaRefundType.valueDefinitions.partial + ] + }) + ); + + return file; }; exports.addRefundCustomAttributesGroup = (file) => { - file.metadata['type-extension'][0]['group-definitions'][0]['attribute-group'].push( - buildCustomGroupObject( - 'AlmaRefund', - messages.AlmaRefund.name, - [ - 'almaRefundedAmount', - 'almaRefundType', - 'almaWantedRefundAmount' - ] - ) - ); - - return file; + file.metadata['type-extension'][0]['group-definitions'][0]['attribute-group'].push( + buildCustomGroupObject( + 'AlmaRefund', + messages.AlmaRefund.name, + [ + 'almaRefundedAmount', + 'almaRefundType', + 'almaWantedRefundAmount' + ] + ) + ); + + return file; }; diff --git a/site_preference_builder/error.js b/site_preference_builder/error.js index 39dd79bc..5a68e744 100644 --- a/site_preference_builder/error.js +++ b/site_preference_builder/error.js @@ -1,8 +1,6 @@ -'use strict'; - exports.ConfigException = class { - constructor(message) { - this.message = message; - this.name = 'ConfigException'; - } + constructor(message) { + this.message = message; + this.name = 'ConfigException'; + } }; diff --git a/site_preference_builder/fs.js b/site_preference_builder/fs.js index abcff7b1..3656527f 100644 --- a/site_preference_builder/fs.js +++ b/site_preference_builder/fs.js @@ -1,24 +1,20 @@ -'use strict'; - const fs = require('fs'); exports.readFile = function (filename) { - try { - return fs.readFileSync(filename, 'utf8'); - } catch (err) { - /* eslint-disable no-console */ - console.error(err); - } - return ''; + try { + return fs.readFileSync(filename, 'utf8'); + } catch (err) { + console.error(err); + } + return ''; }; exports.writeFile = function (filename, fileContent) { - try { - fs.writeFileSync(filename, fileContent, { flag: 'w+' }); - } catch (err) { - /* eslint-disable no-console */ - console.error(err); - } + try { + fs.writeFileSync(filename, fileContent, { flag: 'w+' }); + } catch (err) { + console.error(err); + } }; /** @@ -26,10 +22,10 @@ exports.writeFile = function (filename, fileContent) { * @param {string} dir the directory */ exports.createDir = function (dir) { - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir, { recursive: true }); - console.log(`Creating directory : ${dir}`); - return; - } - console.log(`Directory ${dir} already exist, skipping`); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, { recursive: true }); + console.log(`Creating directory : ${dir}`); + return; + } + console.log(`Directory ${dir} already exist, skipping`); }; diff --git a/site_preference_builder/jobs.js b/site_preference_builder/jobs.js index 3bd90ff2..6f7fc1b9 100644 --- a/site_preference_builder/jobs.js +++ b/site_preference_builder/jobs.js @@ -1,5 +1,3 @@ -'use strict'; - const { readFileSync, writeFileSync } = require('fs'); const builder = require('./customSitePrefBuilder'); @@ -10,50 +8,50 @@ const INPUT_JOBS_FILE = './site_preference_builder/ref/jobs/jobs.xml'; const OUTPUT_JOB_SHIPMENT_FILE = './metadata/site_template/jobs.xml'; const allJobs = { - job: [] + job: [] }; const merchantHasOnShipment = (plans) => { - return plans.some((plan) => plan.deferred_trigger_limit_days !== null); + return plans.some((plan) => plan.deferred_trigger_limit_days !== null); }; exports.merchantHasOnShipment = merchantHasOnShipment; const getJobShipment = async (plans, siteName) => { - if (merchantHasOnShipment(plans)) { - const jobShipment = readFileSync(INPUT_JOB_SHIPMENT_FILE) - .toString(); - const onShipmentJob = await builder.xmlToJson(jobShipment.replace('[[SITENAME]]', siteName)); - allJobs.job.push(onShipmentJob.job); - } + if (merchantHasOnShipment(plans)) { + const jobShipment = readFileSync(INPUT_JOB_SHIPMENT_FILE) + .toString(); + const onShipmentJob = await builder.xmlToJson(jobShipment.replace('[[SITENAME]]', siteName)); + allJobs.job.push(onShipmentJob.job); + } }; const getJobDeferredCapture = async (siteName) => { - const jobDeferredCapture = readFileSync(INPUT_JOB_DEFERRED_CAPTURE_FILE) - .toString(); - const deferredCaptureJob = await builder.xmlToJson( - jobDeferredCapture.replace('[[SITENAME]]', siteName) - ); - allJobs.job.push(deferredCaptureJob.job); + const jobDeferredCapture = readFileSync(INPUT_JOB_DEFERRED_CAPTURE_FILE) + .toString(); + const deferredCaptureJob = await builder.xmlToJson( + jobDeferredCapture.replace('[[SITENAME]]', siteName) + ); + allJobs.job.push(deferredCaptureJob.job); }; const getJobRefund = async (toggleRefund, siteName) => { - if (toggleRefund === 'off') { - return; - } - const jobRefund = readFileSync(INPUT_JOB_REFUND_FILE) - .toString(); - const onRefundJob = await builder.xmlToJson(jobRefund.replace('[[SITENAME]]', siteName)); - allJobs.job.push(onRefundJob.job); + if (toggleRefund === 'off') { + return; + } + const jobRefund = readFileSync(INPUT_JOB_REFUND_FILE) + .toString(); + const onRefundJob = await builder.xmlToJson(jobRefund.replace('[[SITENAME]]', siteName)); + allJobs.job.push(onRefundJob.job); }; exports.writeJobsFile = async (toggleRefund, plans, siteName) => { - await getJobShipment(plans, siteName); - await getJobRefund(toggleRefund, siteName); - await getJobDeferredCapture(siteName); + await getJobShipment(plans, siteName); + await getJobRefund(toggleRefund, siteName); + await getJobDeferredCapture(siteName); - const jobs = readFileSync(INPUT_JOBS_FILE); - const jobsContent = await builder.xmlToJson(jobs); + const jobs = readFileSync(INPUT_JOBS_FILE); + const jobsContent = await builder.xmlToJson(jobs); - jobsContent.jobs = Object.assign(jobsContent.jobs, allJobs); - writeFileSync(OUTPUT_JOB_SHIPMENT_FILE, builder.jsonToXML(jobsContent)); + jobsContent.jobs = Object.assign(jobsContent.jobs, allJobs); + writeFileSync(OUTPUT_JOB_SHIPMENT_FILE, builder.jsonToXML(jobsContent)); }; diff --git a/site_preference_builder/main.cjs b/site_preference_builder/main.cjs index 62043b81..df2992bc 100644 --- a/site_preference_builder/main.cjs +++ b/site_preference_builder/main.cjs @@ -1,38 +1,36 @@ -'use strict'; - const { - getFeePlansFromAPI + getFeePlansFromAPI } = require('./api.cjs'); const { - readFile, - writeFile, - createDir + readFile, + writeFile, + createDir } = require('./fs.js'); const { - xmlToJson, - jsonToXML, - addCustomAttrFromPlan, - addCustomGroupFromPlan, - addFeePlans, - addAPIInfo, - addRefundCustomAttributes, - addRefundCustomAttributesGroup + xmlToJson, + jsonToXML, + addCustomAttrFromPlan, + addCustomGroupFromPlan, + addFeePlans, + addAPIInfo, + addRefundCustomAttributes, + addRefundCustomAttributesGroup } = require('./customSitePrefBuilder.js'); const path = require('path'); const { writeJobsFile } = require('./jobs'); require('dotenv').config({ - path: path.resolve(__dirname, '../.env') + path: path.resolve(__dirname, '../.env') }); const LIVE_MODE = { - url: 'https://api.getalma.eu/', - apiKey: process.env.ALMA_LIVE_API_KEY + url: 'https://api.getalma.eu/', + apiKey: process.env.ALMA_LIVE_API_KEY }; const TEST_MODE = { - url: 'https://api.sandbox.getalma.eu/', - apiKey: process.env.ALMA_TEST_API_KEY + url: 'https://api.sandbox.getalma.eu/', + apiKey: process.env.ALMA_TEST_API_KEY }; const METADIR = './metadata/site_template/meta/'; @@ -47,48 +45,47 @@ const REFUND_IS_DISABLED = 'off'; * @returns {string} merchantId */ function getMerchantIdFromFeePlans(feePlans) { - if (!feePlans || feePlans.length === 0) { - throw new Error('Fee plans are undefined or empty'); - } - return feePlans[0].merchant; + if (!feePlans || feePlans.length === 0) { + throw new Error('Fee plans are undefined or empty'); + } + return feePlans[0].merchant; } /** * Script entry point */ -// eslint-disable-next-line consistent-return,require-jsdoc +// eslint-disable-next-line consistent-return async function main() { - if (!process.env.SFCC_SITE_NAME) { - console.error('Undefined env variable SFCC_SITE_NAME. Please go to your .env file to configure it'); - return 1; - } + if (!process.env.SFCC_SITE_NAME) { + console.error('Undefined env variable SFCC_SITE_NAME. Please go to your .env file to configure it'); + return 1; + } - createDir(METADIR); + createDir(METADIR); - const fileContent = readFile(INPUT_FILE); + const fileContent = readFile(INPUT_FILE); - const sitePref = await xmlToJson(fileContent); + const sitePref = await xmlToJson(fileContent); - const { - url, - apiKey - } = process.env.ALMA_API_MODE === 'live' ? LIVE_MODE : TEST_MODE; - const plans = await getFeePlansFromAPI(url, apiKey); - const merchantId = getMerchantIdFromFeePlans(plans); + const { + url, + apiKey + } = process.env.ALMA_API_MODE === 'live' ? LIVE_MODE : TEST_MODE; + const plans = await getFeePlansFromAPI(url, apiKey); + const merchantId = getMerchantIdFromFeePlans(plans); - let updatedSitePref = addCustomAttrFromPlan(sitePref, plans); - updatedSitePref = addCustomGroupFromPlan(updatedSitePref, plans); - updatedSitePref = addFeePlans(updatedSitePref, plans); - updatedSitePref = addAPIInfo(updatedSitePref, url, merchantId); + let updatedSitePref = addCustomAttrFromPlan(sitePref, plans); + updatedSitePref = addCustomGroupFromPlan(updatedSitePref, plans); + updatedSitePref = addFeePlans(updatedSitePref, plans); + updatedSitePref = addAPIInfo(updatedSitePref, url, merchantId); - if (process.env.TOGGLE_REFUND !== REFUND_IS_DISABLED) { - updatedSitePref = addRefundCustomAttributes(updatedSitePref); - updatedSitePref = addRefundCustomAttributesGroup(updatedSitePref); - } + if (process.env.TOGGLE_REFUND !== REFUND_IS_DISABLED) { + updatedSitePref = addRefundCustomAttributes(updatedSitePref); + updatedSitePref = addRefundCustomAttributesGroup(updatedSitePref); + } - await writeJobsFile(process.env.TOGGLE_REFUND, plans, process.env.SFCC_SITE_NAME); - writeFile(OUTPUT_FILE, jsonToXML(updatedSitePref)); + await writeJobsFile(process.env.TOGGLE_REFUND, plans, process.env.SFCC_SITE_NAME); + writeFile(OUTPUT_FILE, jsonToXML(updatedSitePref)); } -/* eslint-disable no-console */ main().then().catch((e) => console.log(e)); diff --git a/test/.eslintrc.json b/test/.eslintrc.json deleted file mode 100644 index 13ee7674..00000000 --- a/test/.eslintrc.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "env": { - "mocha": true - }, - "rules": { - "require-jsdoc": "off", - "max-len": "off", - "quote-props": "off", - "no-new": "off", - "valid-jsdoc": "off" - } -} diff --git a/test/mocks/.eslintrc.json b/test/mocks/.eslintrc.json deleted file mode 100644 index b184a215..00000000 --- a/test/mocks/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "parserOptions": { - "sourceType": "module" - }, - "env": { - "mocha": true, - "es6": true - }, - "rules": { - "max-len": "off", - "no-use-before-define": "off", - "require-jsdoc": "off", - "no-unused-vars": "off" - }, - "globals": { - "browser": true - } -}