fileflows 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -0
- package/cli.js +80 -0
- package/config/localVars.js +48 -0
- package/config/localVars.test.js +37 -0
- package/index.js +8 -0
- package/lib/SUMMARY.md +53 -0
- package/lib/dataFlowGrouper.js +150 -0
- package/lib/dataFlowGrouper.test.js +17 -0
- package/lib/dependencyExtractor.js +70 -0
- package/lib/dependencyExtractor.test.js +9 -0
- package/lib/fileClassifier.js +38 -0
- package/lib/fileClassifier.test.js +9 -0
- package/lib/fileFlowsGenerator.js +141 -0
- package/lib/fileFlowsGenerator.test.js +17 -0
- package/lib/fileIO.js +55 -0
- package/lib/fileIO.test.js +13 -0
- package/lib/graphUtils.js +139 -0
- package/lib/graphUtils.test.js +25 -0
- package/lib/index.js +37 -0
- package/lib/index.test.js +53 -0
- package/lib/jsParser.js +127 -0
- package/lib/jsParser.test.js +13 -0
- package/lib/otherFileParser.js +103 -0
- package/lib/otherFileParser.test.js +9 -0
- package/package.json +74 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Non-JavaScript file parsing functionality
|
|
3
|
+
* Handles JSON, Markdown, YAML, ENV, GraphQL, Shell, HTML files
|
|
4
|
+
* @param {string} content - File content to parse
|
|
5
|
+
* @param {string} relPath - Relative path of the file
|
|
6
|
+
* @param {string} ext - File extension
|
|
7
|
+
* @returns {Object} Parsed metadata specific to file type
|
|
8
|
+
*/
|
|
9
|
+
function parseOtherFile(content, relPath, ext) {
|
|
10
|
+
const localVars = require(`../config/localVars`);
|
|
11
|
+
const lines = content.split(`\n`);
|
|
12
|
+
|
|
13
|
+
switch (ext) {
|
|
14
|
+
case `json`:
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(content);
|
|
17
|
+
const keys = Object.keys(parsed);
|
|
18
|
+
const summary = [parsed.name || parsed.title || 'JSON Configuration'].filter(Boolean);
|
|
19
|
+
return {
|
|
20
|
+
Keys: keys.slice(0, localVars.MAX_JSON_KEYS),
|
|
21
|
+
Summary: summary
|
|
22
|
+
};
|
|
23
|
+
} catch {
|
|
24
|
+
return { Keys: [], Summary: 'Malformed JSON' };
|
|
25
|
+
}
|
|
26
|
+
case `md`:
|
|
27
|
+
const headings = lines
|
|
28
|
+
.filter((l) => l.startsWith(`#`))
|
|
29
|
+
.map((l) => l.replace(/^#+ /, ``))
|
|
30
|
+
.slice(0, 5);
|
|
31
|
+
const firstHeading = headings[0];
|
|
32
|
+
return {
|
|
33
|
+
Headings: headings,
|
|
34
|
+
Summary: firstHeading ? [firstHeading] : []
|
|
35
|
+
};
|
|
36
|
+
case `yml`:
|
|
37
|
+
case `yaml`:
|
|
38
|
+
const yamlKeys = lines
|
|
39
|
+
.filter((l) => /^[a-zA-Z0-9_]+:/.test(l))
|
|
40
|
+
.slice(0, localVars.MAX_YAML_KEYS)
|
|
41
|
+
.map((l) => l.split(`:`)[0]);
|
|
42
|
+
const yamlName = lines.find(l => l.includes('name:'))?.split(':')[1]?.trim() || 'YAML Configuration';
|
|
43
|
+
return {
|
|
44
|
+
Keys: yamlKeys,
|
|
45
|
+
Summary: [yamlName]
|
|
46
|
+
};
|
|
47
|
+
case `env`:
|
|
48
|
+
return {
|
|
49
|
+
Vars: lines
|
|
50
|
+
.filter((l) => l.includes(`=`))
|
|
51
|
+
.map((l) => l.split(`=`)[0])
|
|
52
|
+
};
|
|
53
|
+
case `graphql`:
|
|
54
|
+
const types = lines
|
|
55
|
+
.filter((l) => /^(query|mutation|type)\s+/.test(l))
|
|
56
|
+
.map((l) => l.trim().split(/\s+/)[1])
|
|
57
|
+
.filter(Boolean);
|
|
58
|
+
return {
|
|
59
|
+
Types: types,
|
|
60
|
+
Summary: 'GraphQL Schema'
|
|
61
|
+
};
|
|
62
|
+
case `sh`:
|
|
63
|
+
const commands = lines
|
|
64
|
+
.filter(l => l.trim() && !l.startsWith('#'))
|
|
65
|
+
.slice(0, localVars.MAX_SHELL_COMMANDS)
|
|
66
|
+
.map(l => l.trim().split(/\s+/)[0])
|
|
67
|
+
.filter(cmd => cmd && !cmd.includes('='));
|
|
68
|
+
const scriptPurpose = content.includes('deploy') ? 'deployment' : 'shell script';
|
|
69
|
+
return {
|
|
70
|
+
Commands: [...new Set(commands)],
|
|
71
|
+
Summary: [scriptPurpose]
|
|
72
|
+
};
|
|
73
|
+
case `html`:
|
|
74
|
+
// Simple and reliable HTML tag extraction
|
|
75
|
+
const tagLines = lines.filter(line => line.includes('<') && !line.includes('</'));
|
|
76
|
+
const tags = [];
|
|
77
|
+
|
|
78
|
+
for (const line of tagLines) {
|
|
79
|
+
const matches = line.match(/<([a-zA-Z][a-zA-Z0-9]*)/g);
|
|
80
|
+
if (matches) {
|
|
81
|
+
matches.forEach(match => {
|
|
82
|
+
const tagName = match.substring(1).toLowerCase();
|
|
83
|
+
if (tagName && !tags.includes(tagName)) {
|
|
84
|
+
tags.push(tagName);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Extract title from HTML
|
|
91
|
+
const titleMatch = content.match(/<title[^>]*>(.*?)<\/title>/is);
|
|
92
|
+
const title = titleMatch ? titleMatch[1].trim() : 'HTML Document';
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
Tags: tags.slice(0, localVars.MAX_HTML_TAGS),
|
|
96
|
+
Summary: title
|
|
97
|
+
};
|
|
98
|
+
default:
|
|
99
|
+
return { Summary: 'Unknown file type' };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
module.exports = parseOtherFile;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Auto-generated unit test for otherFileParser.js - optimized for speed
|
|
2
|
+
const mod = require('./otherFileParser.js');
|
|
3
|
+
|
|
4
|
+
describe('otherFileParser.js', () => {
|
|
5
|
+
test('parseOtherFile works', async () => {
|
|
6
|
+
// Fast assertion - TODO: implement specific test logic
|
|
7
|
+
expect(typeof mod.parseOtherFile).toBeDefined();
|
|
8
|
+
});
|
|
9
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fileflows",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI tool for deploying data workflow analysis documentation",
|
|
5
|
+
"main": "cli.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"fileflows": "./cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"generate": "node cli.js",
|
|
11
|
+
"help": "node cli.js --help",
|
|
12
|
+
"test": "node qtests-runner.js",
|
|
13
|
+
"start": "node bin/cli.js"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"file-analysis",
|
|
17
|
+
"documentation",
|
|
18
|
+
"data-flow",
|
|
19
|
+
"cli",
|
|
20
|
+
"code-analysis",
|
|
21
|
+
"project-structure",
|
|
22
|
+
"ast-parsing",
|
|
23
|
+
"dependency-graph",
|
|
24
|
+
"file-flows",
|
|
25
|
+
"ai",
|
|
26
|
+
"agent",
|
|
27
|
+
"context",
|
|
28
|
+
"automation"
|
|
29
|
+
],
|
|
30
|
+
"author": "Q",
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": ""
|
|
35
|
+
},
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "#readme",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=16.0.0"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"bin/",
|
|
45
|
+
"lib/",
|
|
46
|
+
"config/",
|
|
47
|
+
"contexts/",
|
|
48
|
+
"features/",
|
|
49
|
+
"scripts/",
|
|
50
|
+
"index.js",
|
|
51
|
+
"README.md"
|
|
52
|
+
],
|
|
53
|
+
"preferGlobal": true,
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@babel/parser": "^7.28.3",
|
|
56
|
+
"@babel/traverse": "^7.28.3",
|
|
57
|
+
"commoncontext": "^1.0.0",
|
|
58
|
+
"globby": "^14.1.0",
|
|
59
|
+
"npmcontext": "^1.0.0",
|
|
60
|
+
"qerrors": "^1.2.6",
|
|
61
|
+
"winston": "^3.17.0",
|
|
62
|
+
"winston-daily-rotate-file": "^5.0.0"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"agentsqripts": "^1.0.8",
|
|
66
|
+
"arqitect": "^1.0.7",
|
|
67
|
+
"loqatevars": "^1.0.6",
|
|
68
|
+
"madge": "^8.0.0",
|
|
69
|
+
"qtests": "^1.1.4",
|
|
70
|
+
"quantumagent": "^1.0.4",
|
|
71
|
+
"repomix": "^1.2.0",
|
|
72
|
+
"unqommented": "^1.1.0"
|
|
73
|
+
}
|
|
74
|
+
}
|