Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Automated Node list Output #162

Open
Xlinka opened this issue Sep 13, 2023 · 2 comments
Open

Automated Node list Output #162

Xlinka opened this issue Sep 13, 2023 · 2 comments
Labels
Enhancement New feature or request

Comments

@Xlinka
Copy link
Owner

Xlinka commented Sep 13, 2023

💡 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

@Xlinka Xlinka added the Enhancement New feature or request label Sep 13, 2023
@Nytra
Copy link
Contributor

Nytra commented Sep 13, 2023

@art0007i made this thing before that gets a list of all components and logix nodes, it could be useful here maybe https://github.com/art0007i/Neos-Component-List-Generator

@Xlinka
Copy link
Owner Author

Xlinka commented Sep 13, 2023

might be a start thanks for linking it

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants