From c592c8314e85926a909e607b774ea2473e6d212b Mon Sep 17 00:00:00 2001 From: Peter Schmalfeldt Date: Sat, 23 Jul 2022 03:37:51 -0400 Subject: [PATCH 1/4] Pushing up initial testing for windows fixes NOTE: This does not actually work yet, just moving computers and wanted to get the code up ;) --- extension.code-workspace | 2 + extension/Cache.js | 9 +++- extension/CartridgeOverridesProvider.js | 18 +++++-- extension/Cartridges.js | 64 +++++++++++++++---------- extension/CartridgesProvider.js | 7 +-- extension/constants.js | 12 +++++ extension/index.js | 3 +- extension/util.js | 64 ++++++++++++------------- package-lock.json | 2 +- package.json | 2 +- 10 files changed, 114 insertions(+), 69 deletions(-) create mode 100644 extension/constants.js diff --git a/extension.code-workspace b/extension.code-workspace index f9db50b..72b99ff 100644 --- a/extension.code-workspace +++ b/extension.code-workspace @@ -7,6 +7,8 @@ "settings": { "window.title": "VS Code Extension${separator}SFCC Cartridge Overrides${separator}${activeEditorShort}", "cSpell.words": [ + "mikepenz", + "pjson", "sfra" ] } diff --git a/extension/Cache.js b/extension/Cache.js index 01f3c34..f6dcab3 100644 --- a/extension/Cache.js +++ b/extension/Cache.js @@ -1,5 +1,7 @@ 'use strict' +var pjson = require('../package.json') + /** * @class Cache * @desc A module for use in developing a Visual Studio Code extension. It allows an extension to cache values across sessions with optional expiration times using the ExtensionContext.globalState. @@ -18,6 +20,9 @@ const Cache = function (context, namespace) { // Namespace of the context's globalState this.namespace = namespace || 'cache' + // Append Package Version to Cache Namespace + this.namespace = this.namespace.concat(`-${pjson.version}`) + // Local cache object this.cache = this.context.globalState.get(this.namespace, {}) } @@ -78,7 +83,7 @@ Cache.prototype.get = function (key, defaultValue) { return undefined } // Otherwise return the value - return this.cache[key].value + return this.cache[key] ? this.cache[key].value : null } } @@ -138,7 +143,7 @@ Cache.prototype.keys = function () { Cache.prototype.all = function () { let items = {} for (let key in this.cache) { - items[key] = this.cache[key].value + items[key] = this.cache[key] ? this.cache[key].value : null } return items } diff --git a/extension/CartridgeOverridesProvider.js b/extension/CartridgeOverridesProvider.js index c41eb4a..6104048 100644 --- a/extension/CartridgeOverridesProvider.js +++ b/extension/CartridgeOverridesProvider.js @@ -4,6 +4,7 @@ const vscode = require('vscode') const { init, localize } = require('vscode-nls-i18n') const util = require('./util') +const { REGEXP_PATH } = require('./constants') /** * SFCC Cartridge Overrides Tree View Provider @@ -33,12 +34,13 @@ class CartridgeOverridesProvider { /** * Default Tree Generator - * @param {Object} data Data to Generat Tree + * @param {Object} data Data to Generate Tree * @param {String} type Tree Type [controllers, models, templates, scripts, properties] * @returns Object */ defaultGenerator(data, type) { - const key = `${data.cartridge}_${data.name.replace(/[\/.]/g, '-')}` + const key = `${data.cartridge}_${data.name.replace(REGEXP_PATH, '-')}` + if (this.lastOpened === key) { return } @@ -76,7 +78,8 @@ class CartridgeOverridesProvider { * @returns object */ generateControllerTree(data) { - const key = `${data.cartridge}_${data.name.replace(/[\/.]/g, '-')}` + const key = `${data.cartridge}_${data.name.replace(REGEXP_PATH, '-')}` + if (this.lastOpened === key) { return } @@ -109,6 +112,7 @@ class CartridgeOverridesProvider { const foundPrepends = [...text.matchAll(/server\.prepend\(([^'"]+)?['"]([^'"]+)['"]/g)] const foundReplaces = [...text.matchAll(/server\.replace\(([^'"]+)?['"]([^'"]+)['"]/g)] + // Process GET Routes foundGets.forEach((found) => { if (found.length > 2) { const routeName = found[2] @@ -146,6 +150,7 @@ class CartridgeOverridesProvider { } }) + // Process POST Routes foundPosts.forEach((found) => { if (found.length > 2) { const routeName = found[2] @@ -183,6 +188,7 @@ class CartridgeOverridesProvider { } }) + // Process USE Routes foundUses.forEach((found) => { if (found.length > 2) { const routeName = found[2] @@ -220,6 +226,7 @@ class CartridgeOverridesProvider { } }) + // Process APPEND Routes foundAppends.forEach((found) => { if (found.length > 2) { const routeName = found[2] @@ -257,6 +264,7 @@ class CartridgeOverridesProvider { } }) + // Process PREPEND Routes foundPrepends.forEach((found) => { if (found.length > 2) { const routeName = found[2] @@ -294,6 +302,7 @@ class CartridgeOverridesProvider { } }) + // Process REPLACE Routes foundReplaces.forEach((found) => { if (found.length > 2) { const routeName = found[2] @@ -417,7 +426,8 @@ class CartridgeOverridesProvider { * @returns object */ generatePropertiesTree(data) { - const key = `${data.cartridge}_${data.name.replace(/[\/.]/g, '-')}` + const key = `${data.cartridge}_${data.name.replace(REGEXP_PATH, '-')}` + if (this.lastOpened === key) { return } diff --git a/extension/Cartridges.js b/extension/Cartridges.js index 0b06773..9be56d0 100644 --- a/extension/Cartridges.js +++ b/extension/Cartridges.js @@ -1,10 +1,12 @@ 'use strict' +const path = require('path') const vscode = require('vscode') const { init, localize } = require('vscode-nls-i18n') const Cache = require('./Cache') const util = require('./util') +const { REGEXP_CARTRIDGE, REGEXP_PATH } = require('./constants') /** * SFCC Cartridges @@ -18,8 +20,8 @@ class Cartridges { init(context.extensionPath) // Create Cache Instances - this.cacheFiles = new Cache(context, 'files') - this.cacheOverrides = new Cache(context, 'overrides') + this.cacheFiles = new Cache(context, 'sfcc-files') + this.cacheOverrides = new Cache(context, 'sfcc-overrides') // Establish VS Code Context this.context = context @@ -36,6 +38,7 @@ class Cartridges { // Do initial load of data using cache this.refresh(true) + // Get Cartridges and Start Loading Data this.getCartridgesFromConfig().then((updateCartridgePath) => { if (updateCartridgePath) { // Refetch Cartridge since the settings changed @@ -145,6 +148,10 @@ class Cartridges { return cartridgesArray.filter((cartridge) => ignoredCartridges.indexOf(cartridge) === -1) } + /** + * Get Cartridge Names from Config File + * @returns Promise + */ getCartridgesFromConfig() { return new Promise((resolve) => { // Get current cartridge path from settings @@ -168,7 +175,7 @@ class Cartridges { // Check which message to show const message = cartridgePath && cartridgePath.length > 0 ? localize('config.properties.path.changed') : localize('config.properties.path.found') - // Looks like the local dw.json is differnt than VS Code Settings, check if we should save the dw.json into VS Code + // Looks like the local dw.json is different than VS Code Settings, check if we should save the dw.json into VS Code vscode.window.showInformationMessage(message, localize('ui.dialog.yes'), localize('ui.dialog.no')).then((answer) => { if (answer === localize('ui.dialog.yes')) { // Update VS Code Settings and reload @@ -202,8 +209,8 @@ class Cartridges { } /** - * - * @returns + * Get Cartridge Files + * @returns Promise */ getCartridges() { // Fetch Config for Override Visibility @@ -230,7 +237,7 @@ class Cartridges { */ const getOverrides = (cartridge, relativeKey, skipCacheWrite) => { // Generate Cache Key for Override Lookup - const cacheKey = `${cartridge}${relativeKey ? relativeKey.replace(/[\/.]/g, '-') : ''}` + const cacheKey = `${cartridge}${relativeKey ? relativeKey.replace(REGEXP_PATH, '-') : ''}` // Return Cache if Present ( calculating overrides is a time consuming process ) if (this.cacheOverrides.has(cacheKey)) { @@ -287,6 +294,12 @@ class Cartridges { return overrides } + /** + * Process Cartridge Files + * @param {Array} files Cartridge Files + * @param {Boolean} skipCacheWrite Whether to Skip Writing to Cache + * @returns Object + */ const processFiles = (files, skipCacheWrite) => { let filesClone @@ -308,11 +321,10 @@ class Cartridges { // Loop through files and look for overrides filesClone.forEach((file) => { // Pattern to grab some cartridge data about this file - const regexPattern = /^(.+)\/cartridges\/([^/]+)\/cartridge\/(.+)$/ - const fileParts = file.match(regexPattern) + const fileParts = file.match(REGEXP_CARTRIDGE) // Make sure this is a cartridge file - if (fileParts.length === 4) { + if (fileParts && fileParts.length === 4) { // Map file parts to more helpful names const cartridgeName = fileParts[2] const relativeFilePath = fileParts[3] @@ -349,10 +361,10 @@ class Cartridges { // Loop through Cartridge Path in the order they were listed this.cartridgesPath.forEach((cartridge) => { // Filter Detected files to just the files in the current cartridge - const cartridgeFiles = filesClone.filter((file) => file.indexOf(`cartridges/${cartridge}/cartridge`) > -1) + const cartridgeFiles = filesClone.filter((file) => file.indexOf(`cartridges${path.sep}${cartridge}${path.sep}cartridge`) > -1) // Check if Cartridge is missing - if (cartridgeFiles.length === 0 && !Object.prototype.hasOwnProperty.call(cartridges, cartridge) && !overridesOnly) { + if (cartridgeFiles && cartridgeFiles.length === 0 && !Object.prototype.hasOwnProperty.call(cartridges, cartridge) && !overridesOnly) { cartridges[cartridge] = { missing: true, overrides: null, @@ -369,16 +381,15 @@ class Cartridges { // Loop through Cartridge Files cartridgeFiles.forEach((file) => { // Create RegEx pattern to find information from file path - const regex = /^(.+)\/cartridges\/([^/]+)\/cartridge\/(.+)$/ - const parts = file.match(regex) + const parts = file.match(REGEXP_CARTRIDGE) // Sanity check that we have all the info we need - if (parts.length === 4) { + if (parts && parts.length === 4) { // Break out file parts into variables const base = parts[1] const cartridge = parts[2] const relativePath = parts[3] - const splitRelativePath = relativePath.split('/') + const splitRelativePath = relativePath.split(path.sep) // Create Cartridge Tree View Root if (!Object.prototype.hasOwnProperty.call(cartridges, cartridge)) { @@ -394,7 +405,7 @@ class Cartridges { // Create Tree Structure from Relative File Path splitRelativePath.reduce((obj, name, index) => { - const relativeKey = `${base}/cartridges/${cartridge}/cartridge/${splitRelativePath.slice(0, index + 1).join('/')}` + const relativeKey = `${base}${path.sep}cartridges${path.sep}${cartridge}${path.sep}cartridge${path.sep}${splitRelativePath.slice(0, index + 1).join(path.sep)}` // Create Tree Item if Not Present if (!obj[name]) { @@ -431,7 +442,7 @@ class Cartridges { // We need some additional data for handing off to Overrides Panel treeItem.data = { cartridge: cartridge, - name: relativePath.substring(relativePath.lastIndexOf('/') + 1), + name: relativePath.substring(relativePath.lastIndexOf(path.sep) + 1), overrides: cartridgeFileData[relativePath], resourceUri: vscode.Uri.file(`${this.workspacePath}${relativeKey}`), type: util.getType(file), @@ -516,6 +527,7 @@ class Cartridges { /** * Refresh Cartridge Tree + * @param {Boolean} useCache Whether to Refresh Tree Using Cache */ refresh(useCache) { // Show Loading Indicator Until Loaded @@ -532,16 +544,18 @@ class Cartridges { } // Fetch Files from Workspace - this.getCartridges().then((cartridges) => { - // Update Tree View Data - this.treeCartridges = this.generateTree(cartridges) + this.getCartridges() + .then((cartridges) => { + // Update Tree View Data + this.treeCartridges = this.generateTree(cartridges) - // Let VS Code know we have updated data - vscode.commands.executeCommand('extension.sfccCartridges.cartridgeListUpdated', this.treeCartridges) + // Let VS Code know we have updated data + vscode.commands.executeCommand('extension.sfccCartridges.cartridgeListUpdated', this.treeCartridges) - // Stop Loading Indicator - resolve() - }) + // Stop Loading Indicator + resolve() + }) + .catch((err) => console.error(err)) }) ) } diff --git a/extension/CartridgesProvider.js b/extension/CartridgesProvider.js index 226b8fd..f6b8ae1 100644 --- a/extension/CartridgesProvider.js +++ b/extension/CartridgesProvider.js @@ -2,6 +2,8 @@ const vscode = require('vscode') +const { REGEXP_CARTRIDGE, SEP } = require('./constants') + /** * SFCC Cartridge Tree View Provider */ @@ -47,15 +49,14 @@ class CartridgesProvider { let level = 0 let found = [] - const regex = /^(.+)\/cartridges\/([^/]+)\/cartridge\/(.+)$/ - const parts = file.match(regex) + const parts = file.match(REGEXP_CARTRIDGE) // Sanity check that we have all the info we need if (parts.length === 4) { // Break out file parts into variables const cartridge = parts[2] const relativePath = parts[3] - const splitRelativePath = relativePath.split('/') + const splitRelativePath = relativePath.split(SEP) const tree = [cartridge].concat(splitRelativePath) // Get Root Element from Tree Item diff --git a/extension/constants.js b/extension/constants.js new file mode 100644 index 0000000..8175118 --- /dev/null +++ b/extension/constants.js @@ -0,0 +1,12 @@ +'use strict' + +const path = require('path') + +const REGEXP_CARTRIDGE = new RegExp(`^(.+)${path.sep}cartridges${path.sep}([^${path.sep}]+)${path.sep}cartridge${path.sep}(.+)$`) +const REGEXP_PATH = new RegExp(`[${path.sep}.]`, 'g') + +module.exports = { + REGEXP_CARTRIDGE, + REGEXP_PATH, + SEP: path.sep, +} diff --git a/extension/index.js b/extension/index.js index 3c723b0..32d9175 100644 --- a/extension/index.js +++ b/extension/index.js @@ -7,6 +7,7 @@ const CartridgeOverridesProvider = require('./CartridgeOverridesProvider') const Cartridges = require('./Cartridges') const CartridgesProvider = require('./CartridgesProvider') const util = require('./util') +const { SEP } = require('./constants') const WelcomePane = require('./welcome') @@ -123,7 +124,7 @@ function activate(context) { }) } else { // Show Information Message - vscode.window.showInformationMessage(localize('command.checkOverrides.noneFound', currentSelectedFileName.substring(currentSelectedFileName.lastIndexOf('/') + 1))) + vscode.window.showInformationMessage(localize('command.checkOverrides.noneFound', currentSelectedFileName.substring(currentSelectedFileName.lastIndexOf(SEP) + 1))) } } } diff --git a/extension/util.js b/extension/util.js index 594b34a..9e7616e 100644 --- a/extension/util.js +++ b/extension/util.js @@ -74,7 +74,7 @@ const getType = (file) => { * @param {*} context * @returns */ - const getWorkspace = (context) => { +const getWorkspace = (context) => { // Initialize Localization init(context.extensionPath) @@ -83,43 +83,43 @@ const getType = (file) => { // Check for missing VS Code Workspace, if present, otherwise use context path if (context && !vscode.workspace && !vscode.workspace.workspaceFolders) { - workspace = vscode.workspace.rootPath ? vscode.workspace.rootPath : path.dirname(context.fsPath) + workspace = vscode.workspace.rootPath ? vscode.workspace.rootPath : path.dirname(context.fsPath) } else { - // We have a Workspace, now let's figure out if it's single or multiroot - if (vscode.workspace && vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length === 1) { - // There was only one Workspace, so we can just use it - root = vscode.workspace.workspaceFolders[0] - workspace = root && root.uri ? root.uri.fsPath : null - } else if (vscode.workspace && vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 1) { - // There is more than one Workspace, so let's grab the active one - if (vscode.window.activeTextEditor) { - // Since there is a file active, let's find the workspace from that file - root = vscode.workspace.workspaceFolders.find((wsFolder) => { - const relative = path.relative(wsFolder.uri.fsPath, vscode.window.activeTextEditor.document.uri.path) - return relative && !relative.startsWith('..') && !path.isAbsolute(relative) - }) - workspace = root && root.uri ? root.uri.fsPath : null - } else { - // No file was open, so just grab the first available workspace - root = vscode.workspace.workspaceFolders[0] - workspace = root && root.uri ? root.uri.fsPath : null - } - } else if (context && vscode.workspace) { - // Something else is going on, let's see if we can still figure it out - try { - root = vscode.workspace.getWorkspaceFolder(context) - workspace = root && root.uri ? root.uri.fsPath : null - } catch (err) { - logger(err, 'error') - } + // We have a Workspace, now let's figure out if it's single or multiroot + if (vscode.workspace && vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length === 1) { + // There was only one Workspace, so we can just use it + root = vscode.workspace.workspaceFolders[0] + workspace = root && root.uri ? root.uri.fsPath : null + } else if (vscode.workspace && vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 1) { + // There is more than one Workspace, so let's grab the active one + if (vscode.window.activeTextEditor) { + // Since there is a file active, let's find the workspace from that file + root = vscode.workspace.workspaceFolders.find((wsFolder) => { + const relative = path.relative(wsFolder.uri.fsPath, vscode.window.activeTextEditor.document.uri.path) + return relative && !relative.startsWith('..') && !path.isAbsolute(relative) + }) + workspace = root && root.uri ? root.uri.fsPath : null + } else { + // No file was open, so just grab the first available workspace + root = vscode.workspace.workspaceFolders[0] + workspace = root && root.uri ? root.uri.fsPath : null } + } else if (context && vscode.workspace) { + // Something else is going on, let's see if we can still figure it out + try { + root = vscode.workspace.getWorkspaceFolder(context) + workspace = root && root.uri ? root.uri.fsPath : null + } catch (err) { + logger(err, 'error') + } + } } // If we did not get Workspace, let the user know if (!workspace) { - const message = localize('debug.logger.missingWorkspace') - logger(message, 'error') - vscode.window.showErrorMessage(`${localize('extension.title')}: ${message}`) + const message = localize('debug.logger.missingWorkspace') + logger(message, 'error') + vscode.window.showErrorMessage(`${localize('extension.title')}: ${message}`) } // Debug Cartridge Path diff --git a/package-lock.json b/package-lock.json index 058a9eb..318f025 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sfcc-cartridge-overrides", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 172be6d..2afed10 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sfcc-cartridge-overrides", "displayName": "SFCC Cartridge Overrides", - "version": "1.0.1", + "version": "1.0.2", "description": "VS Code Extension to Display SFCC Cartridge Overrides", "license": "MIT", "publisher": "PeterSchmalfeldt", From 38cdbea0f18df0b43dc1dcb686e939b113e84292 Mon Sep 17 00:00:00 2001 From: Peter Schmalfeldt Date: Mon, 25 Jul 2022 02:28:37 -0400 Subject: [PATCH 2/4] Updated to remove all hard coded path separators and ready to test on Windows. --- extension/Cache.js | 12 +- extension/CartridgeOverridesProvider.js | 236 +++++++++--------- extension/Cartridges.js | 146 ++++++----- extension/CartridgesProvider.js | 6 +- extension/index.js | 33 ++- package-lock.json | 317 ++++++++++++++---------- package.json | 11 +- package.nls.json | 1 + 8 files changed, 437 insertions(+), 325 deletions(-) diff --git a/extension/Cache.js b/extension/Cache.js index f6dcab3..174381e 100644 --- a/extension/Cache.js +++ b/extension/Cache.js @@ -1,6 +1,11 @@ 'use strict' -var pjson = require('../package.json') +const md5 = require('md5') + +const pjson = require('../package.json') +const util = require('./util') + +const { SEP } = require('./constants') /** * @class Cache @@ -18,10 +23,7 @@ const Cache = function (context, namespace) { this.context = context // Namespace of the context's globalState - this.namespace = namespace || 'cache' - - // Append Package Version to Cache Namespace - this.namespace = this.namespace.concat(`-${pjson.version}`) + this.namespace = md5(`${util.getWorkspace(context)}${SEP}${namespace}${SEP}${pjson.version}`) // Local cache object this.cache = this.context.globalState.get(this.namespace, {}) diff --git a/extension/CartridgeOverridesProvider.js b/extension/CartridgeOverridesProvider.js index 6104048..a875feb 100644 --- a/extension/CartridgeOverridesProvider.js +++ b/extension/CartridgeOverridesProvider.js @@ -346,64 +346,68 @@ class CartridgeOverridesProvider { } // Check all the property files line by line - checkControllers().then((overrideRoutes) => { - // Start creation of File Tree - data.overrides.forEach((override, index) => { - const isSelected = data.cartridge === override.cartridge ? 1 : 0 - const children = [] - const routeName = data.name.replace('.js', '') - - // Create Parent Tree Element - const treeItem = { - name: routeName, - tooltip: localize('ui.toggle.title'), - description: override.cartridge, - isSelected: isSelected, - sortOrder: index, - iconPath: index === data.overrides.length - 1 ? util.getIcon('controllers', isSelected) : util.getIcon('override', isSelected), - } - - // Add any properties that were found to be overwritten as children - Object.keys(overrideRoutes).forEach((prop) => { - if (Object.prototype.hasOwnProperty.call(overrideRoutes[prop], override.cartridge)) { - const propObj = overrideRoutes[prop][override.cartridge][0] - const range = propObj.lineNumber ? new vscode.Range(new vscode.Position(propObj.lineNumber - 1, 0), new vscode.Position(propObj.lineNumber - 1, 0)) : null - const args = propObj.lineNumber ? [propObj.resourceUri, { selection: new vscode.Selection(range.start, range.end) }] : [propObj.resourceUri] - - children.push({ - command: { - command: 'vscode.open', - arguments: args, - }, - name: propObj.name, - contextValue: 'file', - description: propObj.type, - tooltip: propObj.tooltip, - iconPath: util.getIcon('route'), - }) + checkControllers() + .then((overrideRoutes) => { + // Start creation of File Tree + data.overrides.forEach((override, index) => { + const isSelected = data.cartridge === override.cartridge ? 1 : 0 + const children = [] + const routeName = data.name.replace('.js', '') + + // Create Parent Tree Element + const treeItem = { + name: routeName, + tooltip: localize('ui.toggle.title'), + description: override.cartridge, + isSelected: isSelected, + sortOrder: index, + iconPath: index === data.overrides.length - 1 ? util.getIcon('controllers', isSelected) : util.getIcon('override', isSelected), } - }) - // Make the Parent Tree item collapsable if it contains children - if (children.length > 0) { - treeItem.children = children - treeItem.contextValue = 'folder' - } else { - treeItem.contextValue = 'file' - treeItem.command = { - command: 'vscode.open', - arguments: [override.resourceUri], - title: localize('ui.openFile.title', treeItem.name), + // Add any properties that were found to be overwritten as children + Object.keys(overrideRoutes).forEach((prop) => { + if (Object.prototype.hasOwnProperty.call(overrideRoutes[prop], override.cartridge)) { + const propObj = overrideRoutes[prop][override.cartridge][0] + const range = propObj.lineNumber ? new vscode.Range(new vscode.Position(propObj.lineNumber - 1, 0), new vscode.Position(propObj.lineNumber - 1, 0)) : null + const args = propObj.lineNumber ? [propObj.resourceUri, { selection: new vscode.Selection(range.start, range.end) }] : [propObj.resourceUri] + + children.push({ + command: { + command: 'vscode.open', + arguments: args, + }, + name: propObj.name, + contextValue: 'file', + description: propObj.type, + tooltip: propObj.tooltip, + iconPath: util.getIcon('route'), + }) + } + }) + + // Make the Parent Tree item collapsable if it contains children + if (children.length > 0) { + treeItem.children = children + treeItem.contextValue = 'folder' + } else { + treeItem.contextValue = 'file' + treeItem.command = { + command: 'vscode.open', + arguments: [override.resourceUri], + title: localize('ui.openFile.title', treeItem.name), + } } - } - // Push Tree Item to List - controllerTree.push(treeItem) - }) + // Push Tree Item to List + controllerTree.push(treeItem) + }) - this.treeData = controllerTree - this._onDidChangeTreeData.fire(undefined) - }) + this.treeData = controllerTree + this._onDidChangeTreeData.fire(undefined) + }) + .catch((err) => { + util.logger(localize('debug.logger.error', 'CartridgeOverridesProvider.generateControllerTree', err.toString()), 'error') + }) this.lastOpened = key @@ -479,71 +483,75 @@ class CartridgeOverridesProvider { } // Check all the property files line by line - checkProperties().then((overrideProperties) => { - // Check each property for overrides - Object.keys(overrideProperties).forEach((prop) => { - // If there are no overrides, let's do some cleanup - if (Object.keys(overrideProperties[prop]).length < 2) { - delete overrideProperties[prop] - } - }) - - // Start creation of File Tree - data.overrides.forEach((override, index) => { - const isSelected = data.cartridge === override.cartridge ? 1 : 0 - const children = [] - - // Create Parent Tree Element - const treeItem = { - name: data.name, - description: override.cartridge, - isSelected: isSelected, - sortOrder: index, - iconPath: index === data.overrides.length - 1 ? util.getIcon('templates', isSelected) : util.getIcon('override', isSelected), - } - - // Add any properties that were found to be overwritten as children + checkProperties() + .then((overrideProperties) => { + // Check each property for overrides Object.keys(overrideProperties).forEach((prop) => { - if (Object.prototype.hasOwnProperty.call(overrideProperties[prop], override.cartridge)) { - const propObj = overrideProperties[prop][override.cartridge][0] - const range = new vscode.Range(new vscode.Position(propObj.lineNumber - 1, 0), new vscode.Position(propObj.lineNumber - 1, 0)) - - children.push({ - command: { - command: 'vscode.open', - arguments: [ - propObj.resourceUri, - { - selection: new vscode.Selection(range.start, range.end), - }, - ], - }, - name: propObj.name, - contextValue: 'file', - iconPath: util.getIcon('property'), - }) + // If there are no overrides, let's do some cleanup + if (Object.keys(overrideProperties[prop]).length < 2) { + delete overrideProperties[prop] } }) - // Make the Parent Tree item collapsable if it contains children - if (children.length > 0) { - treeItem.children = children - treeItem.contextValue = 'folder' - } else { - treeItem.contextValue = 'file' - treeItem.command = { - command: 'vscode.open', - arguments: [override.resourceUri], + // Start creation of File Tree + data.overrides.forEach((override, index) => { + const isSelected = data.cartridge === override.cartridge ? 1 : 0 + const children = [] + + // Create Parent Tree Element + const treeItem = { + name: data.name, + description: override.cartridge, + isSelected: isSelected, + sortOrder: index, + iconPath: index === data.overrides.length - 1 ? util.getIcon('templates', isSelected) : util.getIcon('override', isSelected), } - } - // Push Tree Item to List - templateTree.push(treeItem) - }) + // Add any properties that were found to be overwritten as children + Object.keys(overrideProperties).forEach((prop) => { + if (Object.prototype.hasOwnProperty.call(overrideProperties[prop], override.cartridge)) { + const propObj = overrideProperties[prop][override.cartridge][0] + const range = new vscode.Range(new vscode.Position(propObj.lineNumber - 1, 0), new vscode.Position(propObj.lineNumber - 1, 0)) + + children.push({ + command: { + command: 'vscode.open', + arguments: [ + propObj.resourceUri, + { + selection: new vscode.Selection(range.start, range.end), + }, + ], + }, + name: propObj.name, + contextValue: 'file', + iconPath: util.getIcon('property'), + }) + } + }) - this.treeData = templateTree - this._onDidChangeTreeData.fire(undefined) - }) + // Make the Parent Tree item collapsable if it contains children + if (children.length > 0) { + treeItem.children = children + treeItem.contextValue = 'folder' + } else { + treeItem.contextValue = 'file' + treeItem.command = { + command: 'vscode.open', + arguments: [override.resourceUri], + } + } + + // Push Tree Item to List + templateTree.push(treeItem) + }) + + this.treeData = templateTree + this._onDidChangeTreeData.fire(undefined) + }) + .catch((err) => { + util.logger(localize('debug.logger.error', 'CartridgeOverridesProvider.generatePropertiesTree', err.toString()), 'error') + }) this.lastOpened = key @@ -619,10 +627,10 @@ class CartridgeOverridesProvider { // Add Custom Tree Item Data treeItem.command = item.command || null - treeItem.description = item.description || null + treeItem.description = item.description || '' treeItem.iconPath = item.iconPath || null treeItem.resourceUri = item.resourceUri || null - treeItem.tooltip = item.tooltip || null + treeItem.tooltip = item.tooltip || '' return treeItem } @@ -657,7 +665,7 @@ class CartridgeOverridesProvider { */ reset() { this.treeData = [] - this._onDidChangeTreeData.fire(undefined) + this._onDidChangeTreeData.fire() } } diff --git a/extension/Cartridges.js b/extension/Cartridges.js index 9be56d0..27b64e7 100644 --- a/extension/Cartridges.js +++ b/extension/Cartridges.js @@ -39,15 +39,19 @@ class Cartridges { this.refresh(true) // Get Cartridges and Start Loading Data - this.getCartridgesFromConfig().then((updateCartridgePath) => { - if (updateCartridgePath) { - // Refetch Cartridge since the settings changed - this.cartridgesPath = this.getCartridgesPath() - - // Do initial load of data using cache - this.refresh(true) - } - }) + this.getCartridgesFromConfig() + .then((updateCartridgePath) => { + if (updateCartridgePath) { + // Refetch Cartridge since the settings changed + this.cartridgesPath = this.getCartridgesPath() + + // Do initial load of data using cache + this.refresh(true) + } + }) + .catch((err) => { + util.logger(localize('debug.logger.error', 'Cartridges.constructor', err.toString()), 'error') + }) } /** @@ -158,53 +162,73 @@ class Cartridges { const cartridgePath = vscode.workspace.getConfiguration().get('extension.sfccCartridges.path') // Find dw.json file in root - vscode.workspace.findFiles(new vscode.RelativePattern(this.workspacePath, 'dw.{json,js}')).then((dwConfig) => { - // Make sure we found a file - if (dwConfig && typeof dwConfig[0] !== 'undefined' && typeof dwConfig[0].path !== 'undefined') { - // Read file and get its content - vscode.workspace.openTextDocument(dwConfig[0].path).then((config) => { - // Get Text - const configText = config.getText() - - // Try to parse the JSON - try { - const configJson = JSON.parse(configText) - - // Check if cartridgesPath was defined in the dw.json and if it is different than the one in VS Code Settings - if (configJson.cartridgesPath && cartridgePath !== configJson.cartridgesPath && configJson.cartridgesPath !== '') { - // Check which message to show - const message = cartridgePath && cartridgePath.length > 0 ? localize('config.properties.path.changed') : localize('config.properties.path.found') - - // Looks like the local dw.json is different than VS Code Settings, check if we should save the dw.json into VS Code - vscode.window.showInformationMessage(message, localize('ui.dialog.yes'), localize('ui.dialog.no')).then((answer) => { - if (answer === localize('ui.dialog.yes')) { - // Update VS Code Settings and reload - vscode.workspace - .getConfiguration() - .update('extension.sfccCartridges.path', configJson.cartridgesPath, vscode.ConfigurationTarget.Global) - .then(() => { - // Let the developer know their settings have been saved - vscode.window.showInformationMessage(localize('config.properties.path.updated')) - return resolve(true) + vscode.workspace + .findFiles(new vscode.RelativePattern(this.workspacePath, 'dw.{json,js}')) + .then((dwConfig) => { + // Make sure we found a file + if (dwConfig && typeof dwConfig[0] !== 'undefined' && typeof dwConfig[0].path !== 'undefined') { + // Read file and get its content + vscode.workspace + .openTextDocument(dwConfig[0].path) + .then((config) => { + // Get Text + const configText = config.getText() + + // Try to parse the JSON + try { + const configJson = JSON.parse(configText) + + // Check if cartridgesPath was defined in the dw.json and if it is different than the one in VS Code Settings + if (configJson.cartridgesPath && cartridgePath !== configJson.cartridgesPath && configJson.cartridgesPath !== '') { + // Check which message to show + const message = cartridgePath && cartridgePath.length > 0 ? localize('config.properties.path.changed') : localize('config.properties.path.found') + + // Looks like the local dw.json is different than VS Code Settings, check if we should save the dw.json into VS Code + vscode.window + .showInformationMessage(message, localize('ui.dialog.yes'), localize('ui.dialog.no')) + .then((answer) => { + if (answer === localize('ui.dialog.yes')) { + // Update VS Code Settings and reload + vscode.workspace + .getConfiguration() + .update('extension.sfccCartridges.path', configJson.cartridgesPath, vscode.ConfigurationTarget.Global) + .then(() => { + // Let the developer know their settings have been saved + vscode.window.showInformationMessage(localize('config.properties.path.updated')) + return resolve(true) + }) + .catch((err) => { + util.logger(localize('debug.logger.error', 'Cartridges.getCartridgesFromConfig:getConfiguration', err.toString()), 'error') + return resolve(false) + }) + } else { + return resolve(false) + } + }) + .catch((err) => { + util.logger(localize('debug.logger.error', 'Cartridges.getCartridgesFromConfig:showInformationMessage', err.toString()), 'error') + return resolve(false) }) } else { + // Config was present, but no cartridge path found return resolve(false) } - }) - } else { - // Config was present, but no cartridge path found - return resolve(false) - } - } catch (err) { - console.error(err) - return resolve(false) - } - }) - } else { - // No file to load - return resolve(false) - } - }) + } catch (err) { + util.logger(localize('debug.logger.error', 'Cartridges.getCartridgesFromConfig:JSON.parse', err.toString()), 'error') + return resolve(false) + } + }) + .catch((err) => { + util.logger(localize('debug.logger.error', 'Cartridges.getCartridgesFromConfig:openTextDocument', err.toString()), 'error') + }) + } else { + // No file to load + return resolve(false) + } + }) + .catch((err) => { + util.logger(localize('debug.logger.error', 'Cartridges.findFiles', err.toString()), 'error') + }) }) } @@ -468,8 +492,8 @@ class Cartridges { } // Create Tree Meta Data - let descriptionText = description.length > 0 ? description.join(' ') : null - let tooltipText = tooltip.length > 0 ? tooltip.join(' ') : null + let descriptionText = description && description.length > 0 ? description.join(' ') : null + let tooltipText = tooltip && tooltip.length > 0 ? tooltip.join(' ') : null // Update Tree Item Labels treeItem.description = descriptionText @@ -521,7 +545,12 @@ class Cartridges { return Promise.resolve(processFiles(this.cacheFiles.get('workspaceFiles'), true)) } else { // Use Native VS Code methods to locate Cartridges - return vscode.workspace.findFiles(includePattern, excludePattern).then((files) => processFiles(files)) + return vscode.workspace + .findFiles(includePattern, excludePattern) + .then((files) => processFiles(files)) + .catch((err) => { + util.logger(localize('debug.logger.error', 'Cartridges.getCartridges:processFiles', err.toString()), 'error') + }) } } @@ -536,7 +565,7 @@ class Cartridges { location: { viewId: 'sfccCartridgesView' }, }, () => - new Promise((resolve) => { + new Promise((resolve, reject) => { if (!useCache) { // Clear Cache this.cacheFiles.flush() @@ -555,7 +584,10 @@ class Cartridges { // Stop Loading Indicator resolve() }) - .catch((err) => console.error(err)) + .catch((err) => { + util.logger(localize('debug.logger.error', 'Cartridges.refresh:getCartridges', err.toString()), 'error') + reject(err) + }) }) ) } diff --git a/extension/CartridgesProvider.js b/extension/CartridgesProvider.js index f6b8ae1..2a783d4 100644 --- a/extension/CartridgesProvider.js +++ b/extension/CartridgesProvider.js @@ -103,10 +103,10 @@ class CartridgesProvider { // Add Custom Tree Item Data treeItem.command = item.command || null - treeItem.description = item.description || null + treeItem.description = item.description || '' treeItem.iconPath = item.iconPath || null treeItem.resourceUri = item.resourceUri || null - treeItem.tooltip = item.tooltip || null + treeItem.tooltip = item.tooltip || '' return treeItem } @@ -117,7 +117,7 @@ class CartridgesProvider { */ refresh(treeData) { this.treeData = treeData - this._onDidChangeTreeData.fire(undefined) + this._onDidChangeTreeData.fire() } } diff --git a/extension/index.js b/extension/index.js index 32d9175..9b4c950 100644 --- a/extension/index.js +++ b/extension/index.js @@ -92,7 +92,9 @@ function activate(context) { revealCartridgeFile(index + 1) } }) - .catch((err) => util.logger(err, 'error')) + .catch((err) => { + util.logger(localize('debug.logger.error', 'revealCartridgeFile', err.toString()), 'error') + }) } } @@ -111,17 +113,24 @@ function activate(context) { revealCartridgeFile(0) // Go ahead an update the Overrides Panel with Selected File - cartridgeOverridesProvider.load(found).then(() => { - // Once we have populated the Override Panel, let's select the active override - const selectedOverride = cartridgeOverridesProvider.getElement(found.cartridge) - - clearTimeout(revealTimeout) - revealTimeout = setTimeout(() => { - if (sfccCartridgeOverridesView) { - sfccCartridgeOverridesView.reveal(selectedOverride, { focus: true, select: true, expand: true }).catch((err) => util.logger(err, 'error')) - } - }, 500) - }) + cartridgeOverridesProvider + .load(found) + .then(() => { + // Once we have populated the Override Panel, let's select the active override + const selectedOverride = cartridgeOverridesProvider.getElement(found.cartridge) + + clearTimeout(revealTimeout) + revealTimeout = setTimeout(() => { + if (sfccCartridgeOverridesView) { + sfccCartridgeOverridesView.reveal(selectedOverride, { focus: true, select: true, expand: true }).catch((err) => { + util.logger(localize('debug.logger.error', 'activate.selectTreeViewFile:reveal', err.toString()), 'error') + }) + } + }, 500) + }) + .catch((err) => { + util.logger(localize('debug.logger.error', 'activate.selectTreeViewFile:cartridgeOverridesProvider', err.toString()), 'error') + }) } else { // Show Information Message vscode.window.showInformationMessage(localize('command.checkOverrides.noneFound', currentSelectedFileName.substring(currentSelectedFileName.lastIndexOf(SEP) + 1))) diff --git a/package-lock.json b/package-lock.json index 318f025..b0754d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -134,26 +134,26 @@ } }, "@eslint/eslintrc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.1.tgz", - "integrity": "sha512-bxvbYnBPN1Gibwyp6NrpnFzA3YtRL3BBAyEAFVIpNTm2Rn4Vy87GA5M4aSn3InRrlsbX5N0GW7XIx+U4SAEKdQ==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.0.tgz", + "integrity": "sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.3.1", - "globals": "^13.9.0", + "espree": "^9.3.2", + "globals": "^13.15.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "strip-json-comments": "^3.1.1" }, "dependencies": { "globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", + "version": "13.16.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.16.0.tgz", + "integrity": "sha512-A1lrQfpNF+McdPOnnFqY3kSN0AFTy485bTi1bkLk4mVPODIUEcSfhHgRqA+QdXPksrSTTztYXx37NFV+GpGk3Q==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -179,9 +179,9 @@ "dev": true }, "acorn": { - "version": "8.7.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", - "integrity": "sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==", + "version": "8.7.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz", + "integrity": "sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==", "dev": true }, "acorn-jsx": { @@ -312,6 +312,11 @@ "supports-color": "^5.3.0" } }, + "charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==" + }, "clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -353,21 +358,21 @@ "dev": true }, "colorette": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.16.tgz", - "integrity": "sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g==", + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz", + "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==", "dev": true }, "commander": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", - "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "version": "9.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.3.0.tgz", + "integrity": "sha512-hv95iU5uXPbK83mjrJKuZyFM/LBAoCV/XhVGkS5Je6tl7sxr6A0ITMw5WoRV46/UaJ46Nllm3Xt7IaJhXTIkzw==", "dev": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, "cross-spawn": { @@ -381,6 +386,11 @@ "which": "^2.0.1" } }, + "crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==" + }, "debug": { "version": "4.3.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", @@ -424,12 +434,12 @@ "dev": true }, "eslint": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.11.0.tgz", - "integrity": "sha512-/KRpd9mIRg2raGxHRGwW9ZywYNAClZrHjdueHcrVDuO3a6bj83eoTirCCk0M0yPwOjWYKHwRVRid+xK4F/GHgA==", + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.20.0.tgz", + "integrity": "sha512-d4ixhz5SKCa1D6SCPrivP7yYVi7nyD6A4vs6HIAul9ujBzcEmZVM3/0NN/yu5nKhmO1wjp5xQ46iRfmDGlOviA==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.2.1", + "@eslint/eslintrc": "^1.3.0", "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -440,14 +450,14 @@ "eslint-scope": "^7.1.1", "eslint-utils": "^3.0.0", "eslint-visitor-keys": "^3.3.0", - "espree": "^9.3.1", + "espree": "^9.3.2", "esquery": "^1.4.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", "functional-red-black-tree": "^1.0.1", "glob-parent": "^6.0.1", - "globals": "^13.6.0", + "globals": "^13.15.0", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", @@ -456,7 +466,7 @@ "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.1", "regexpp": "^3.2.0", @@ -513,9 +523,9 @@ "dev": true }, "globals": { - "version": "13.12.1", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.12.1.tgz", - "integrity": "sha512-317dFlgY2pdJZ9rspXDks7073GpDmXdfbM3vYYp0HAMKGDh1FfWPleI2ljVNLQX5M5lXcAslTcPTrOrMEFOjyw==", + "version": "13.16.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.16.0.tgz", + "integrity": "sha512-A1lrQfpNF+McdPOnnFqY3kSN0AFTy485bTi1bkLk4mVPODIUEcSfhHgRqA+QdXPksrSTTztYXx37NFV+GpGk3Q==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -545,9 +555,9 @@ "dev": true }, "eslint-plugin-prettier": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz", - "integrity": "sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz", + "integrity": "sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==", "dev": true, "requires": { "prettier-linter-helpers": "^1.0.0" @@ -587,13 +597,13 @@ "dev": true }, "espree": { - "version": "9.3.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.1.tgz", - "integrity": "sha512-bvdyLmJMfwkV3NCRl5ZhJf22zBFo1y8bYh3VYb+bfzqNB4Je68P2sSuXyuFquzWLebHpNd2/d5uv7yoP9ISnGQ==", + "version": "9.3.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.3.2.tgz", + "integrity": "sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA==", "dev": true, "requires": { - "acorn": "^8.7.0", - "acorn-jsx": "^5.3.1", + "acorn": "^8.7.1", + "acorn-jsx": "^5.3.2", "eslint-visitor-keys": "^3.3.0" }, "dependencies": { @@ -636,20 +646,20 @@ "dev": true }, "execa": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", - "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-6.1.0.tgz", + "integrity": "sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==", "dev": true, "requires": { "cross-spawn": "^7.0.3", - "get-stream": "^6.0.0", - "human-signals": "^2.1.0", - "is-stream": "^2.0.0", + "get-stream": "^6.0.1", + "human-signals": "^3.0.1", + "is-stream": "^3.0.0", "merge-stream": "^2.0.0", - "npm-run-path": "^4.0.1", - "onetime": "^5.1.2", - "signal-exit": "^3.0.3", - "strip-final-newline": "^2.0.0" + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^3.0.7", + "strip-final-newline": "^3.0.0" } }, "fast-deep-equal": { @@ -673,7 +683,7 @@ "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, "file-entry-cache": { @@ -705,15 +715,15 @@ } }, "flatted": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", - "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.6.tgz", + "integrity": "sha512-0sQoMh9s0BYsm+12Huy/rkKxVu4R1+r96YX5cG44rHV0pQ6iC3Q+mkoMFaGWObMFYQxCVT+ssG1ksneA2MI9KQ==", "dev": true }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "function-bind": { @@ -725,7 +735,7 @@ "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", "dev": true }, "get-stream": { @@ -735,15 +745,15 @@ "dev": true }, "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } @@ -779,9 +789,9 @@ "dev": true }, "human-signals": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", - "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-3.0.1.tgz", + "integrity": "sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==", "dev": true }, "ignore": { @@ -803,7 +813,7 @@ "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true }, "indent-string": { @@ -815,7 +825,7 @@ "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "requires": { "once": "^1.3.0", @@ -828,6 +838,11 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + }, "is-core-module": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", @@ -840,7 +855,7 @@ "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true }, "is-fullwidth-code-point": { @@ -865,15 +880,15 @@ "dev": true }, "is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", "dev": true }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "js-tokens": { @@ -906,7 +921,7 @@ "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true }, "levn": { @@ -920,37 +935,40 @@ } }, "lilconfig": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.0.4.tgz", - "integrity": "sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.0.5.tgz", + "integrity": "sha512-xaYmXZtTHPAw5m+xLN8ab9C+3a8YmV3asNSPOATITbtwrfbwaLJj8h66H1WMIpALCkqsIzK3h7oQ+PdX+LQ9Eg==", "dev": true }, "lint-staged": { - "version": "12.3.5", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.3.5.tgz", - "integrity": "sha512-oOH36RUs1It7b9U/C7Nl/a0sLfoIBcMB8ramiB3nuJ6brBqzsWiUAFSR5DQ3yyP/OR7XKMpijtgKl2DV1lQ3lA==", + "version": "13.0.3", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-13.0.3.tgz", + "integrity": "sha512-9hmrwSCFroTSYLjflGI8Uk+GWAwMB4OlpU4bMJEAT5d/llQwtYKoim4bLOyLCuWFAhWEupE0vkIFqtw/WIsPug==", "dev": true, "requires": { "cli-truncate": "^3.1.0", - "colorette": "^2.0.16", - "commander": "^8.3.0", - "debug": "^4.3.3", - "execa": "^5.1.1", - "lilconfig": "2.0.4", - "listr2": "^4.0.1", - "micromatch": "^4.0.4", + "colorette": "^2.0.17", + "commander": "^9.3.0", + "debug": "^4.3.4", + "execa": "^6.1.0", + "lilconfig": "2.0.5", + "listr2": "^4.0.5", + "micromatch": "^4.0.5", "normalize-path": "^3.0.0", - "object-inspect": "^1.12.0", + "object-inspect": "^1.12.2", + "pidtree": "^0.6.0", "string-argv": "^0.3.1", - "supports-color": "^9.2.1", - "yaml": "^1.10.2" + "yaml": "^2.1.1" }, "dependencies": { - "supports-color": { - "version": "9.2.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-9.2.1.tgz", - "integrity": "sha512-Obv7ycoCTG51N7y175StI9BlAXrmgZrFhZOb0/PyjHBher/NmsdBgbbQ1Inhq+gIhz6+7Gb+jWF2Vqi7Mf1xnQ==", - "dev": true + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } } } }, @@ -1130,9 +1148,19 @@ } }, "marked": { - "version": "4.0.12", - "resolved": "https://registry.npmjs.org/marked/-/marked-4.0.12.tgz", - "integrity": "sha512-hgibXWrEDNBWgGiK18j/4lkS6ihTe9sxtV4Q1OQppb/0zzyPSzoFANBa5MfsG/zgsWklmNnhm0XACZOH/0HBiQ==" + "version": "4.0.18", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.0.18.tgz", + "integrity": "sha512-wbLDJ7Zh0sqA0Vdg6aqlbT+yPxqLblpAZh1mK2+AO2twQkPywvvqQNfEPVwSSRjZ7dZcdeVBIAgiO7MMp3Dszw==" + }, + "md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "requires": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } }, "merge-stream": { "version": "2.0.0", @@ -1141,19 +1169,19 @@ "dev": true }, "micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", "dev": true, "requires": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" + "braces": "^3.0.2", + "picomatch": "^2.3.1" } }, "mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", "dev": true }, "minimatch": { @@ -1174,7 +1202,7 @@ "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, "normalize-path": { @@ -1184,36 +1212,44 @@ "dev": true }, "npm-run-path": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", + "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==", "dev": true, "requires": { - "path-key": "^3.0.0" + "path-key": "^4.0.0" + }, + "dependencies": { + "path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "dev": true + } } }, "object-inspect": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz", - "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", + "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==", "dev": true }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "requires": { "wrappy": "1" } }, "onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", "dev": true, "requires": { - "mimic-fn": "^2.1.0" + "mimic-fn": "^4.0.0" } }, "optionator": { @@ -1251,7 +1287,7 @@ "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, "path-key": { @@ -1272,6 +1308,12 @@ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true }, + "pidtree": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.6.0.tgz", + "integrity": "sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==", + "dev": true + }, "prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -1279,9 +1321,9 @@ "dev": true }, "prettier": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", - "integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", + "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", "dev": true }, "prettier-linter-helpers": { @@ -1330,6 +1372,23 @@ "requires": { "onetime": "^5.1.0", "signal-exit": "^3.0.2" + }, + "dependencies": { + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + } } }, "rfdc": { @@ -1445,9 +1504,9 @@ } }, "strip-final-newline": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", "dev": true }, "strip-json-comments": { @@ -1474,13 +1533,13 @@ "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, "to-fast-properties": { @@ -1499,9 +1558,9 @@ } }, "tslib": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", - "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", "dev": true }, "type-check": { @@ -1617,13 +1676,13 @@ "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, "yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.1.1.tgz", + "integrity": "sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==", "dev": true } } diff --git a/package.json b/package.json index 2afed10..506adb9 100644 --- a/package.json +++ b/package.json @@ -241,14 +241,15 @@ }, "devDependencies": { "babel-eslint": "^10.1.0", - "eslint": "^8.11.0", + "eslint": "^8.20.0", "eslint-config-prettier": "^8.5.0", - "eslint-plugin-prettier": "^4.0.0", - "lint-staged": "^12.3.5", - "prettier": "^2.5.1" + "eslint-plugin-prettier": "^4.2.1", + "lint-staged": "^13.0.3", + "prettier": "^2.7.1" }, "dependencies": { - "marked": "^4.0.12", + "marked": "^4.0.18", + "md5": "^2.3.0", "vscode-nls-i18n": "^0.2.4" } } diff --git a/package.nls.json b/package.nls.json index e5ab9b0..f56f88f 100644 --- a/package.nls.json +++ b/package.nls.json @@ -18,6 +18,7 @@ "config.properties.path.updated": "SFCC Cartridge Overrides Cartridge Path Updated", "debug.logger.cartridgesMissing": "Cartridge Missing from Workspace: {0}", "debug.logger.cartridgesSummary": "Found {0} files in {1} Cartridges in Workspace", + "debug.logger.error": "⚠ ERROR: [{0}] {1}", "debug.logger.fetchingCartridges": "Fetching SFCC Cartridges from Workspace ...", "debug.logger.missingWorkspace": "Workspace Folder Not Found. Open Folder or Workspace and try again.", "debug.logger.overridesDisabled": "Overrides Only: Disabled", From d5cb26db898c18652bce93162b10b51cea3bdc02 Mon Sep 17 00:00:00 2001 From: Peter Schmalfeldt Date: Mon, 25 Jul 2022 02:38:27 -0400 Subject: [PATCH 3/4] Updated to remove all hard coded path separators and ready to test on Windows. --- extension/CartridgeOverridesProvider.js | 6 +++--- extension/Cartridges.js | 6 +++--- extension/util.js | 10 ++++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/extension/CartridgeOverridesProvider.js b/extension/CartridgeOverridesProvider.js index a875feb..7d2d416 100644 --- a/extension/CartridgeOverridesProvider.js +++ b/extension/CartridgeOverridesProvider.js @@ -65,7 +65,7 @@ class CartridgeOverridesProvider { }) this.treeData = templateTree - this._onDidChangeTreeData.fire(undefined) + this._onDidChangeTreeData.fire() this.lastOpened = key @@ -403,7 +403,7 @@ class CartridgeOverridesProvider { }) this.treeData = controllerTree - this._onDidChangeTreeData.fire(undefined) + this._onDidChangeTreeData.fire() }) .catch((err) => { util.logger(localize('debug.logger.error', 'CartridgeOverridesProvider.generateControllerTree', err.toString()), 'error') @@ -547,7 +547,7 @@ class CartridgeOverridesProvider { }) this.treeData = templateTree - this._onDidChangeTreeData.fire(undefined) + this._onDidChangeTreeData.fire() }) .catch((err) => { util.logger(localize('debug.logger.error', 'CartridgeOverridesProvider.generatePropertiesTree', err.toString()), 'error') diff --git a/extension/Cartridges.js b/extension/Cartridges.js index 27b64e7..1749211 100644 --- a/extension/Cartridges.js +++ b/extension/Cartridges.js @@ -6,7 +6,7 @@ const { init, localize } = require('vscode-nls-i18n') const Cache = require('./Cache') const util = require('./util') -const { REGEXP_CARTRIDGE, REGEXP_PATH } = require('./constants') +const { REGEXP_CARTRIDGE, REGEXP_PATH, SEP } = require('./constants') /** * SFCC Cartridges @@ -385,7 +385,7 @@ class Cartridges { // Loop through Cartridge Path in the order they were listed this.cartridgesPath.forEach((cartridge) => { // Filter Detected files to just the files in the current cartridge - const cartridgeFiles = filesClone.filter((file) => file.indexOf(`cartridges${path.sep}${cartridge}${path.sep}cartridge`) > -1) + const cartridgeFiles = filesClone.filter((file) => file.indexOf(`cartridges${SEP}${cartridge}${SEP}cartridge`) > -1) // Check if Cartridge is missing if (cartridgeFiles && cartridgeFiles.length === 0 && !Object.prototype.hasOwnProperty.call(cartridges, cartridge) && !overridesOnly) { @@ -429,7 +429,7 @@ class Cartridges { // Create Tree Structure from Relative File Path splitRelativePath.reduce((obj, name, index) => { - const relativeKey = `${base}${path.sep}cartridges${path.sep}${cartridge}${path.sep}cartridge${path.sep}${splitRelativePath.slice(0, index + 1).join(path.sep)}` + const relativeKey = `${base}${SEP}cartridges${SEP}${cartridge}${SEP}cartridge${SEP}${splitRelativePath.slice(0, index + 1).join(path.sep)}` // Create Tree Item if Not Present if (!obj[name]) { diff --git a/extension/util.js b/extension/util.js index 9e7616e..8f62157 100644 --- a/extension/util.js +++ b/extension/util.js @@ -5,6 +5,8 @@ const vscode = require('vscode') const { init, localize } = require('vscode-nls-i18n') +const { SEP } = require('./constants') + // Create custom Output Channel to Log Helpful Messages const output = vscode.window.createOutputChannel('SFCC Cartridge Overrides') @@ -56,13 +58,13 @@ const getIcon = (type, overrideCount) => { * @returns {String} SFCC File Type */ const getType = (file) => { - if (file.includes(`${path.sep}controllers${path.sep}`)) { + if (file.includes(`${SEP}controllers${SEP}`)) { return 'controller' - } else if (file.includes(`${path.sep}models${path.sep}`)) { + } else if (file.includes(`${SEP}models${SEP}`)) { return 'model' - } else if (file.includes(`${path.sep}scripts${path.sep}`)) { + } else if (file.includes(`${SEP}scripts${SEP}`)) { return 'script' - } else if (file.includes(`${path.sep}templates${path.sep}`)) { + } else if (file.includes(`${SEP}templates${SEP}`)) { return 'template' } else { return 'unknown' From df4ae7180188a78a872811f2820dc538c01868df Mon Sep 17 00:00:00 2001 From: Peter Schmalfeldt Date: Mon, 25 Jul 2022 03:43:08 -0400 Subject: [PATCH 4/4] Fixed Windows Issues Works fine on Windows 10 & 11 :) --- DEVELOPERS.md | 12 ++++++++++++ TROUBLESHOOTING.md | 2 ++ extension/Cartridges.js | 3 +++ extension/constants.js | 7 +++++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 9e4b7fa..dd80900 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -4,6 +4,18 @@ Developer Setup Extension Development --- +### Downloading Extension + +> To get started developing this extension, you will first need to download the source code: + +```bash +git clone git@github.com:sfccdevops/sfcc-cartridge-overrides-vscode-extension.git +cd sfcc-cartridge-overrides-vscode-extension +npm install +``` + +### Testing Extension + > To develop this extension in VS Code: 1. Open File `extension.code-workspace` in VS Code diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md index 4b7f2c8..1612369 100644 --- a/TROUBLESHOOTING.md +++ b/TROUBLESHOOTING.md @@ -38,3 +38,5 @@ Need Help? > You can check for existing issues, or create a new one, by visiting our GitHub Issues page. [![Create Issue](https://img.shields.io/badge/Github-Issues-red.svg?style=for-the-badge&logo=github&logoColor=ffffff&logoWidth=16)](https://github.com/sfccdevops/sfcc-cartridge-overrides-vscode-extension/issues) + +**NOTE:** If you would like to report an issue, please copy the output from our `SFCC Cartridge Overrides` output panel. This will contain everything we need to know about what happened with this extension on your machine. You can access the output panel by accessing `View > Output` and then selecting the `SFCC Cartridge Overrides` from the select list of available output options. diff --git a/extension/Cartridges.js b/extension/Cartridges.js index 1749211..a5f3811 100644 --- a/extension/Cartridges.js +++ b/extension/Cartridges.js @@ -570,6 +570,9 @@ class Cartridges { // Clear Cache this.cacheFiles.flush() this.cacheOverrides.flush() + + // Update Cartridges Path + this.cartridgesPath = this.getCartridgesPath() } // Fetch Files from Workspace diff --git a/extension/constants.js b/extension/constants.js index 8175118..b4674c9 100644 --- a/extension/constants.js +++ b/extension/constants.js @@ -2,11 +2,14 @@ const path = require('path') -const REGEXP_CARTRIDGE = new RegExp(`^(.+)${path.sep}cartridges${path.sep}([^${path.sep}]+)${path.sep}cartridge${path.sep}(.+)$`) -const REGEXP_PATH = new RegExp(`[${path.sep}.]`, 'g') +const REGEXP_SEP = path.sep.replace('\\', '\\\\') + +const REGEXP_CARTRIDGE = new RegExp(`^(.+)${REGEXP_SEP}cartridges${REGEXP_SEP}([^${REGEXP_SEP}]+)${REGEXP_SEP}cartridge${REGEXP_SEP}(.+)$`) +const REGEXP_PATH = new RegExp(`[${REGEXP_SEP}.]`, 'g') module.exports = { REGEXP_CARTRIDGE, REGEXP_PATH, + REGEXP_SEP, SEP: path.sep, }