fileflows 1.0.1 → 1.0.3
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/cli.js +4 -3
- package/config/localVars.js +62 -1
- package/index.js +7 -2
- package/lib/fileFlowsGenerator.js +16 -3
- package/lib/fileIO.js +6 -1
- package/lib/index.js +23 -31
- package/lib/jsParser.js +6 -1
- package/package.json +5 -6
package/cli.js
CHANGED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
* CLI tool for generating FILE_FLOWS.md
|
|
4
4
|
* Analyzes project files and creates documentation showing data flow relationships
|
|
5
5
|
* Following NPM architecture guidelines with modular structure
|
|
6
|
+
* Refactored: Global const declarations moved to config/localVars.js
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
const generateFileFlows = require(`./lib/fileFlowsGenerator`);
|
|
9
|
-
const localVars = require(`./config/localVars`);
|
|
10
|
-
|
|
11
9
|
/**
|
|
12
10
|
* CLI usage display functionality
|
|
13
11
|
* Shows help information for the CLI tool
|
|
@@ -31,6 +29,9 @@ function showUsage() {
|
|
|
31
29
|
* Parses arguments and executes file flows generation
|
|
32
30
|
*/
|
|
33
31
|
async function main() {
|
|
32
|
+
const localVars = require(`./config/localVars`);
|
|
33
|
+
const { generateFileFlows } = localVars.getDependencies();
|
|
34
|
+
|
|
34
35
|
const args = process.argv.slice(2);
|
|
35
36
|
let rootDir = localVars.DEFAULT_ROOT_DIR;
|
|
36
37
|
let outputFile = null;
|
package/config/localVars.js
CHANGED
|
@@ -35,6 +35,64 @@ const MAX_YAML_KEYS = 5;
|
|
|
35
35
|
const MAX_SHELL_COMMANDS = 5;
|
|
36
36
|
const MAX_HTML_TAGS = 5;
|
|
37
37
|
|
|
38
|
+
// === CENTRALIZED DEPENDENCIES ===
|
|
39
|
+
// All require statements moved from global scope to centralized configuration
|
|
40
|
+
function getDependencies() {
|
|
41
|
+
return {
|
|
42
|
+
// Core library modules (from lib/index.js)
|
|
43
|
+
generateFileFlows: require(`../lib/fileFlowsGenerator`),
|
|
44
|
+
groupByDataFlow: require(`../lib/dataFlowGrouper`),
|
|
45
|
+
classifyFile: require(`../lib/fileClassifier`),
|
|
46
|
+
parseJSFile: require(`../lib/jsParser`),
|
|
47
|
+
parseOtherFile: require(`../lib/otherFileParser`),
|
|
48
|
+
extractDependencies: require(`../lib/dependencyExtractor`),
|
|
49
|
+
fileIO: require(`../lib/fileIO`),
|
|
50
|
+
graphUtils: require(`../lib/graphUtils`),
|
|
51
|
+
|
|
52
|
+
// System dependencies (from qtests-runner.js)
|
|
53
|
+
fs: require(`fs`),
|
|
54
|
+
path: require(`path`),
|
|
55
|
+
childProcess: require(`child_process`),
|
|
56
|
+
os: require(`os`)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// === DEVELOPMENT DEPENDENCIES ===
|
|
61
|
+
// Async loading for ES module dependencies (qtests is an ES module)
|
|
62
|
+
async function getDevDependencies() {
|
|
63
|
+
// Check if this is a development environment and qtests is available
|
|
64
|
+
if (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') {
|
|
65
|
+
try {
|
|
66
|
+
// Use dynamic import for ES modules
|
|
67
|
+
const qtests = await import('qtests');
|
|
68
|
+
return {
|
|
69
|
+
qtests: qtests
|
|
70
|
+
};
|
|
71
|
+
} catch (error) {
|
|
72
|
+
// qtests not available
|
|
73
|
+
return {
|
|
74
|
+
qtests: null
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Production environment - don't load qtests at all
|
|
80
|
+
return {
|
|
81
|
+
qtests: null
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// === ENVIRONMENT VARIABLES ===
|
|
86
|
+
// Centralized environment variable access using qerrors utilities
|
|
87
|
+
const { getEnv } = require(`qerrors`);
|
|
88
|
+
|
|
89
|
+
function getEnvironmentConfig() {
|
|
90
|
+
return {
|
|
91
|
+
NODE_ENV: getEnv(`NODE_ENV`, `development`),
|
|
92
|
+
DEBUG_TESTS: getEnv(`DEBUG_TESTS`, `false`) === `true`
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
38
96
|
module.exports = {
|
|
39
97
|
CODE_EXTENSIONS,
|
|
40
98
|
ALL_EXTENSIONS,
|
|
@@ -44,5 +102,8 @@ module.exports = {
|
|
|
44
102
|
MAX_JSON_KEYS,
|
|
45
103
|
MAX_YAML_KEYS,
|
|
46
104
|
MAX_SHELL_COMMANDS,
|
|
47
|
-
MAX_HTML_TAGS
|
|
105
|
+
MAX_HTML_TAGS,
|
|
106
|
+
getDependencies,
|
|
107
|
+
getDevDependencies,
|
|
108
|
+
getEnvironmentConfig
|
|
48
109
|
};
|
package/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main entry point for the file-flows-cli NPM module
|
|
3
3
|
* Exports public functionality following NPM architecture guidelines
|
|
4
|
+
* Refactored: Global const declarations moved to config/localVars.js
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
function getMainExport() {
|
|
8
|
+
const localVars = require(`./config/localVars`);
|
|
9
|
+
const { generateFileFlows } = localVars.getDependencies();
|
|
10
|
+
return generateFileFlows;
|
|
11
|
+
}
|
|
7
12
|
|
|
8
|
-
module.exports =
|
|
13
|
+
module.exports = getMainExport();
|
|
@@ -71,13 +71,21 @@ async function generateFileFlows(rootDir = `.`, outputFile = null) {
|
|
|
71
71
|
|
|
72
72
|
files = findFiles('.');
|
|
73
73
|
} catch (error) {
|
|
74
|
-
|
|
74
|
+
require('qerrors').logError(error, 'File flow generation failed during file discovery', {
|
|
75
|
+
context: 'FILE_DISCOVERY_ERROR',
|
|
76
|
+
rootDir: ROOT,
|
|
77
|
+
outputFile: FILE_OUTPUT
|
|
78
|
+
});
|
|
75
79
|
return { filesAnalyzed: 0, flowGroups: 0, outputFile: null };
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
// Check if any files were found
|
|
79
83
|
if (files.length === 0) {
|
|
80
|
-
|
|
84
|
+
require('qerrors').logWarn(`No files found in directory: ${ROOT}`, 'generateFileFlows', {
|
|
85
|
+
context: 'NO_FILES_FOUND',
|
|
86
|
+
rootDir: ROOT,
|
|
87
|
+
searchExtensions: localVars.ALL_EXTENSIONS
|
|
88
|
+
});
|
|
81
89
|
return { filesAnalyzed: 0, flowGroups: 0, outputFile: null };
|
|
82
90
|
}
|
|
83
91
|
|
|
@@ -136,7 +144,12 @@ async function generateFileFlows(rootDir = `.`, outputFile = null) {
|
|
|
136
144
|
outputFile: FILE_OUTPUT
|
|
137
145
|
};
|
|
138
146
|
|
|
139
|
-
|
|
147
|
+
require('qerrors').logInfo(`FILE_FLOWS.md generation completed`, 'generateFileFlows', {
|
|
148
|
+
context: 'GENERATION_SUCCESS',
|
|
149
|
+
filesAnalyzed: result.filesAnalyzed,
|
|
150
|
+
flowGroups: result.flowGroups,
|
|
151
|
+
outputFile: result.outputFile
|
|
152
|
+
});
|
|
140
153
|
return result;
|
|
141
154
|
}
|
|
142
155
|
|
package/lib/fileIO.js
CHANGED
|
@@ -39,7 +39,12 @@ function safeResolvePath(rootDir, filePath) {
|
|
|
39
39
|
|
|
40
40
|
// Prevent directory traversal attacks
|
|
41
41
|
if (relative.startsWith(`..`)) {
|
|
42
|
-
|
|
42
|
+
const { createTypedError, ErrorTypes } = require('qerrors');
|
|
43
|
+
throw createTypedError(
|
|
44
|
+
`Path traversal attempt detected: ${filePath}`,
|
|
45
|
+
ErrorTypes.VALIDATION,
|
|
46
|
+
'PATH_TRAVERSAL_DETECTED'
|
|
47
|
+
);
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
return { success: true, resolvedPath: resolved };
|
package/lib/index.js
CHANGED
|
@@ -1,37 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Library aggregation module
|
|
3
3
|
* Exports all library functionality following NPM architecture guidelines
|
|
4
|
+
* Refactored: Global const declarations moved to config/localVars.js
|
|
4
5
|
*/
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
// 🚩AI: MAIN_LIBRARY_EXPORTS_REGISTRY - Dependencies centralized in config/localVars.js
|
|
8
|
+
function getLibraryModules() {
|
|
9
|
+
const localVars = require(`../config/localVars`);
|
|
10
|
+
const deps = localVars.getDependencies();
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
generateFileFlows: deps.generateFileFlows,
|
|
14
|
+
groupByDataFlow: deps.groupByDataFlow,
|
|
15
|
+
classifyFile: deps.classifyFile,
|
|
16
|
+
parseJSFile: deps.parseJSFile,
|
|
17
|
+
parseOtherFile: deps.parseOtherFile,
|
|
18
|
+
extractDependencies: deps.extractDependencies,
|
|
19
|
+
safeReadFileSync: deps.fileIO.safeReadFileSync,
|
|
20
|
+
safeResolvePath: deps.fileIO.safeResolvePath,
|
|
21
|
+
buildDependencyGraph: deps.graphUtils.buildDependencyGraph,
|
|
22
|
+
findConnectedComponents: deps.graphUtils.findConnectedComponents,
|
|
23
|
+
depthFirstSearch: deps.graphUtils.depthFirstSearch,
|
|
24
|
+
groupBySimilarity: deps.graphUtils.groupBySimilarity,
|
|
25
|
+
calculateRoleScore: deps.graphUtils.calculateRoleScore
|
|
26
|
+
};
|
|
27
|
+
}
|
|
12
28
|
|
|
13
|
-
|
|
14
|
-
const { safeReadFileSync, safeResolvePath } = require(`./fileIO`);
|
|
15
|
-
const {
|
|
16
|
-
buildDependencyGraph,
|
|
17
|
-
findConnectedComponents,
|
|
18
|
-
depthFirstSearch,
|
|
19
|
-
groupBySimilarity,
|
|
20
|
-
calculateRoleScore
|
|
21
|
-
} = require(`./graphUtils`);
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
generateFileFlows,
|
|
25
|
-
groupByDataFlow,
|
|
26
|
-
classifyFile,
|
|
27
|
-
parseJSFile,
|
|
28
|
-
parseOtherFile,
|
|
29
|
-
extractDependencies,
|
|
30
|
-
safeReadFileSync,
|
|
31
|
-
safeResolvePath,
|
|
32
|
-
buildDependencyGraph,
|
|
33
|
-
findConnectedComponents,
|
|
34
|
-
depthFirstSearch,
|
|
35
|
-
groupBySimilarity,
|
|
36
|
-
calculateRoleScore
|
|
37
|
-
};
|
|
29
|
+
module.exports = getLibraryModules();
|
package/lib/jsParser.js
CHANGED
|
@@ -110,7 +110,12 @@ function parseJSFile(content, filePath) {
|
|
|
110
110
|
|
|
111
111
|
visitNode(ast);
|
|
112
112
|
} catch (err) {
|
|
113
|
-
//
|
|
113
|
+
// Log parse errors for debugging but don't crash
|
|
114
|
+
require('qerrors').logWarn(`JavaScript parsing failed for ${filePath}`, 'parseJSFile', {
|
|
115
|
+
context: 'JS_PARSE_ERROR',
|
|
116
|
+
filePath: filePath,
|
|
117
|
+
errorMessage: err.message
|
|
118
|
+
});
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fileflows",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "CLI tool for deploying data workflow analysis documentation",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -54,9 +54,6 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/parser": "^7.28.3",
|
|
56
56
|
"@babel/traverse": "^7.28.3",
|
|
57
|
-
"commoncontext": "^1.0.0",
|
|
58
|
-
"globby": "^14.1.0",
|
|
59
|
-
"npmcontext": "^1.0.0",
|
|
60
57
|
"qerrors": "^1.2.6",
|
|
61
58
|
"winston": "^3.17.0",
|
|
62
59
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -64,11 +61,13 @@
|
|
|
64
61
|
"devDependencies": {
|
|
65
62
|
"agentsqripts": "^1.0.8",
|
|
66
63
|
"arqitect": "^1.0.7",
|
|
64
|
+
"commoncontext": "^1.0.1",
|
|
67
65
|
"loqatevars": "^1.0.6",
|
|
68
66
|
"madge": "^8.0.0",
|
|
69
|
-
"
|
|
67
|
+
"npmcontext": "^1.0.1",
|
|
68
|
+
"qtests": "^1.1.9",
|
|
70
69
|
"quantumagent": "^1.0.5",
|
|
71
70
|
"repomix": "^1.2.0",
|
|
72
71
|
"unqommented": "^1.1.0"
|
|
73
72
|
}
|
|
74
|
-
}
|
|
73
|
+
}
|