This repository was archived by the owner on Nov 9, 2023. It is now read-only.
Description 馃挕 Feature Request
Describe the new feature or idea:
Make a script to run on build to write all the Logix nodes and components to a file and their categories for ease of use for GitHub updates.
Use Case
To save me time and make my life easier since writing down the nodes manually is just a bland task.
馃殌 Proposed Implementation
so far I got a js script but it doesn't do the job properly
const path = require('path');
const { EOL } = require('os'); // Platform-specific newline character
const folderPath = './NEOSPlus/Logix';
const outputFile = 'node_attributes.txt';
const nodeAttributes = [];
function findNodesInFile(filePath) {
try {
const content = fs.readFileSync(filePath, 'utf8');
const nodeNames = content.match(/\[NodeName\("([^"]+)"\)\]/g);
const categories = content.match(/\[Category\("([^"]+)"\)\]/g);
let nodeName = 'N/A'; // Default value for NodeName
if (nodeNames && nodeNames.length > 0) {
nodeName = nodeNames[0].match(/"([^"]+)"/)[1];
} else {
const classNameMatch = content.match(/public class ([^\s]+) : LogixNode/);
if (classNameMatch && classNameMatch[1]) {
nodeName = classNameMatch[1];
}
}
const category = categories ? categories[0].match(/"([^"]+)"/)[1] : 'N/A';
if (nodeName !== 'N/A' || category !== 'N/A') {
nodeAttributes.push({ NodeName: nodeName, Category: category });
}
} catch (err) {
console.error(`Error reading file ${filePath}: ${err.message}`);
}
}
function traverseDirectory(currentPath) {
fs.readdirSync(currentPath).forEach((file) => {
const filePath = path.join(currentPath, file);
if (fs.statSync(filePath).isDirectory()) {
traverseDirectory(filePath);
} else {
findNodesInFile(filePath);
}
});
}
traverseDirectory(folderPath);
// Write node attributes to the output file
const outputContent = nodeAttributes
.map(({ NodeName, Category }) => `NodeName: ${NodeName}, Category: ${Category}`)
.join(EOL);
fs.writeFileSync(outputFile, outputContent);
console.log(`Node attributes saved to ${outputFile}`);
馃挰 Additional Context
N/A
馃搮 Target Release (if applicable)
N/A
馃搵 Related Issues/PRs
N/A
馃搸 Attachments (if any)
N/A
Reactions are currently unavailable
馃挕 Feature Request
Describe the new feature or idea:
Make a script to run on build to write all the Logix nodes and components to a file and their categories for ease of use for GitHub updates.
Use Case
To save me time and make my life easier since writing down the nodes manually is just a bland task.
馃殌 Proposed Implementation
so far I got a js script but it doesn't do the job properly
馃挰 Additional Context
N/A
馃搮 Target Release (if applicable)
N/A
馃搵 Related Issues/PRs
N/A
馃搸 Attachments (if any)
N/A