-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add item name to script to update single destination (#1837)
- Loading branch information
Showing
2 changed files
with
107 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* eslint-disable no-console */ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const destinationsDir = path.join(__dirname, '../src/configurations/destinations'); | ||
|
||
function findJsonMapperDestinations() { | ||
try { | ||
if (!fs.existsSync(destinationsDir)) { | ||
throw new Error(`Destinations directory not found: ${destinationsDir}`); | ||
} | ||
return fs | ||
.readdirSync(destinationsDir) | ||
.map((destination) => { | ||
try { | ||
const destinationsFilePath = path.join(destinationsDir, destination, 'db-config.json'); | ||
if (!fs.existsSync(destinationsFilePath)) { | ||
console.warn(`Skipping ${destination}: Missing configuration file`); | ||
return null; | ||
} | ||
const destinationsContent = fs.readFileSync(destinationsFilePath, 'utf8'); | ||
const destinationDefinition = JSON.parse(destinationsContent); | ||
if (!destinationDefinition.name) { | ||
console.warn(`Skipping ${destination}: Missing name`); | ||
return null; | ||
} | ||
return { | ||
name: destinationDefinition.name, | ||
config: destinationDefinition.config, | ||
}; | ||
} catch (err) { | ||
console.error(`Error processing ${destination}:`, err.message); | ||
return null; | ||
} | ||
}) | ||
.filter(Boolean) | ||
.filter( | ||
(destination) => | ||
!destination.config?.disableJsonMapper && !destination.config?.supportsVisualMapper, | ||
) | ||
.map((destination) => destination.name); | ||
} catch (err) { | ||
console.error('Failed to process destinations:', err.message); | ||
return []; | ||
} | ||
} | ||
|
||
console.log(findJsonMapperDestinations().join('\n')); |