fileflows 1.0.1 → 1.0.2

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 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;
@@ -35,6 +35,42 @@ 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
+ // Testing dependencies (from qtests.config.js)
59
+ qtests: require(`qtests`)
60
+ };
61
+ }
62
+
63
+ // === ENVIRONMENT VARIABLES ===
64
+ // Centralized environment variable access using qerrors utilities
65
+ const { getEnv } = require(`qerrors`);
66
+
67
+ function getEnvironmentConfig() {
68
+ return {
69
+ NODE_ENV: getEnv(`NODE_ENV`, `development`),
70
+ DEBUG_TESTS: getEnv(`DEBUG_TESTS`, `false`) === `true`
71
+ };
72
+ }
73
+
38
74
  module.exports = {
39
75
  CODE_EXTENSIONS,
40
76
  ALL_EXTENSIONS,
@@ -44,5 +80,7 @@ module.exports = {
44
80
  MAX_JSON_KEYS,
45
81
  MAX_YAML_KEYS,
46
82
  MAX_SHELL_COMMANDS,
47
- MAX_HTML_TAGS
83
+ MAX_HTML_TAGS,
84
+ getDependencies,
85
+ getEnvironmentConfig
48
86
  };
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
- const { generateFileFlows } = require(`./lib/index`);
7
+ function getMainExport() {
8
+ const localVars = require(`./config/localVars`);
9
+ const { generateFileFlows } = localVars.getDependencies();
10
+ return generateFileFlows;
11
+ }
7
12
 
8
- module.exports = generateFileFlows;
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
- console.error(`⚠️ File flow generation failed:`, error.message);
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
- console.log(`⚠️ No files found in directory: ${ROOT}`);
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
- console.log(`✅ FILE_FLOWS.md written with ${result.filesAnalyzed} files.`);
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
- throw new Error(`Path traversal attempt detected: ${filePath}`);
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
- const generateFileFlows = require(`./fileFlowsGenerator`);
7
- const groupByDataFlow = require(`./dataFlowGrouper`);
8
- const classifyFile = require(`./fileClassifier`);
9
- const parseJSFile = require(`./jsParser`);
10
- const parseOtherFile = require(`./otherFileParser`);
11
- const extractDependencies = require(`./dependencyExtractor`);
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
- // 🚩AI: MAIN_LIBRARY_EXPORTS_REGISTRY
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
- // Suppress parse errors for cleaner console output
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.1",
3
+ "version": "1.0.2",
4
4
  "description": "CLI tool for deploying data workflow analysis documentation",
5
5
  "main": "cli.js",
6
6
  "bin": {
@@ -54,9 +54,7 @@
54
54
  "dependencies": {
55
55
  "@babel/parser": "^7.28.3",
56
56
  "@babel/traverse": "^7.28.3",
57
- "commoncontext": "^1.0.0",
58
57
  "globby": "^14.1.0",
59
- "npmcontext": "^1.0.0",
60
58
  "qerrors": "^1.2.6",
61
59
  "winston": "^3.17.0",
62
60
  "winston-daily-rotate-file": "^5.0.0"
@@ -64,9 +62,11 @@
64
62
  "devDependencies": {
65
63
  "agentsqripts": "^1.0.8",
66
64
  "arqitect": "^1.0.7",
65
+ "commoncontext": "^1.0.1",
67
66
  "loqatevars": "^1.0.6",
68
67
  "madge": "^8.0.0",
69
- "qtests": "^1.1.8",
68
+ "npmcontext": "^1.0.1",
69
+ "qtests": "^1.1.9",
70
70
  "quantumagent": "^1.0.5",
71
71
  "repomix": "^1.2.0",
72
72
  "unqommented": "^1.1.0"