From 0869b37c0de381ce9d0ffa29291c2b14bd1aa1ae Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Fri, 13 May 2022 10:22:31 +0200 Subject: [PATCH 1/2] feat: Escape '/' with '$' in filenames --- server/services/main.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/services/main.js b/server/services/main.js index 79f6018..d353484 100644 --- a/server/services/main.js +++ b/server/services/main.js @@ -24,8 +24,9 @@ module.exports = () => ({ const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => `${configType}.${configName}`.startsWith(option))); if (shouldExclude) return; - // Replace ':' with '#' in filenames for Windows support. + // Replace reserved characters in filenames. configName = configName.replace(/:/g, "#"); + configName = configName.replace(/\//g, "$"); // Check if the JSON content should be minified. const json = !strapi.config.get('plugin.config-sync').minify @@ -59,8 +60,9 @@ module.exports = () => ({ const shouldExclude = !isEmpty(strapi.config.get('plugin.config-sync.excludedConfig').filter((option) => configName.startsWith(option))); if (shouldExclude) return; - // Replace ':' with '#' in filenames for Windows support. + // Replace reserved characters in filenames. configName = configName.replace(/:/g, "#"); + configName = configName.replace(/\//g, "$"); fs.unlinkSync(`${strapi.config.get('plugin.config-sync.syncDir')}${configName}.json`); }, @@ -73,8 +75,9 @@ module.exports = () => ({ * @returns {object} The JSON content of the config file. */ readConfigFile: async (configType, configName) => { - // Replace ':' with '#' in filenames for Windows support. + // Replace reserved characters in filenames. configName = configName.replace(/:/g, "#"); + configName = configName.replace(/\//g, "$"); const readFile = util.promisify(fs.readFile); return readFile(`${strapi.config.get('plugin.config-sync.syncDir')}${configType}.${configName}.json`) @@ -107,8 +110,9 @@ module.exports = () => ({ const type = file.split('.')[0]; // Grab the first part of the filename. const name = file.split(/\.(.+)/)[1].split('.').slice(0, -1).join('.'); // Grab the rest of the filename minus the file extension. - // Replace ':' with '#' in filenames for Windows support. - const formattedName = name.replace(/#/g, ":"); + // Put back reserved characters from filenames. + let formattedName = name.replace(/#/g, ":"); + formattedName = name.replace(/\$/g, "/"); if ( configType && configType !== type From 6cd9a55a527903aadeaf9ced98233f34acc20abe Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Fri, 13 May 2022 10:31:48 +0200 Subject: [PATCH 2/2] chore: Drop node 12 support --- .github/workflows/tests.yml | 4 ++-- playground/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cdafaa5..abb48fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [12, 14, 16] + node: [14, 16] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [12, 14, 16] + node: [14, 16] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 diff --git a/playground/package.json b/playground/package.json index 90e35ce..6af6628 100644 --- a/playground/package.json +++ b/playground/package.json @@ -28,7 +28,7 @@ "uuid": "2e84e366-1e09-43c2-a99f-a0d0acbc2ca5" }, "engines": { - "node": ">=12.x.x <=16.x.x", + "node": ">=14.x.x <=16.x.x", "npm": ">=6.0.0" }, "license": "MIT"