x-fidelity 1.4.1 → 1.5.1

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +135 -121
  3. package/dist/archetypes/index.js +2 -3
  4. package/dist/core/cli.js +26 -20
  5. package/dist/core/engine.js +129 -18
  6. package/dist/core/engine.test.js +21 -46
  7. package/dist/facts/openaiAnalysisFacts.js +2 -3
  8. package/dist/facts/openaiAnalysisFacts.test.js +2 -2
  9. package/dist/facts/repoDependencyFacts.js +5 -1
  10. package/dist/index.js +32 -17
  11. package/dist/operators/fileContains.test.js +37 -2
  12. package/dist/operators/openaiAnalysisHighSeverity.js +11 -7
  13. package/dist/operators/openaiAnalysisHighSeverity.test.js +41 -0
  14. package/dist/rules/index.js +35 -6
  15. package/dist/rules/index.test.js +11 -2
  16. package/dist/rules/{noDatabases-rule.json → noDatabases-iterative-rule.json} +2 -2
  17. package/dist/rules/{nonStandardDirectoryStructure-rule.json → nonStandardDirectoryStructure-global-rule.json} +3 -3
  18. package/{src/rules/openaiAnalysisA11y-rule.json → dist/rules/openaiAnalysisA11y-global-rule.json} +1 -1
  19. package/{src/rules/openaiAnalysisTop5-rule.json → dist/rules/openaiAnalysisTop5-global-rule.json} +1 -1
  20. package/dist/rules/{outdatedFramework-rule.json → outdatedFramework-global-rule.json} +4 -3
  21. package/dist/rules/{sensitiveLogging-rule.json → sensitiveLogging-iterative-rule.json} +4 -2
  22. package/dist/server/configServer.js +26 -15
  23. package/dist/server/expressLogger.js +36 -0
  24. package/dist/utils/config.js +71 -5
  25. package/dist/utils/logger.js +26 -4
  26. package/dist/utils/telemetry.js +48 -0
  27. package/dist/xfidelity +32 -17
  28. package/package.json +7 -4
  29. package/src/archetypes/index.ts +3 -4
  30. package/src/core/cli.ts +30 -25
  31. package/src/core/engine.test.ts +21 -53
  32. package/src/core/engine.ts +152 -26
  33. package/src/facts/openaiAnalysisFacts.test.ts +2 -2
  34. package/src/facts/openaiAnalysisFacts.ts +2 -3
  35. package/src/facts/repoDependencyFacts.ts +9 -2
  36. package/src/facts/repoFilesystemFacts.test.ts +1 -1
  37. package/src/facts/repoFilesystemFacts.ts +1 -1
  38. package/src/index.ts +30 -16
  39. package/src/operators/fileContains.test.ts +43 -2
  40. package/src/operators/fileContains.ts +1 -1
  41. package/src/operators/index.ts +1 -1
  42. package/src/operators/nonStandardDirectoryStructure.ts +2 -1
  43. package/src/operators/openaiAnalysisHighSeverity.test.ts +46 -0
  44. package/src/operators/openaiAnalysisHighSeverity.ts +14 -8
  45. package/src/operators/outdatedFramework.ts +1 -1
  46. package/src/rules/index.test.ts +12 -2
  47. package/src/rules/index.ts +34 -7
  48. package/src/rules/{noDatabases-rule.json → noDatabases-iterative-rule.json} +2 -2
  49. package/src/rules/{nonStandardDirectoryStructure-rule.json → nonStandardDirectoryStructure-global-rule.json} +3 -3
  50. package/{dist/rules/openaiAnalysisA11y-rule.json → src/rules/openaiAnalysisA11y-global-rule.json} +1 -1
  51. package/{dist/rules/openaiAnalysisTop5-rule.json → src/rules/openaiAnalysisTop5-global-rule.json} +1 -1
  52. package/src/rules/{outdatedFramework-rule.json → outdatedFramework-global-rule.json} +4 -3
  53. package/src/rules/{sensitiveLogging-rule.json → sensitiveLogging-iterative-rule.json} +4 -2
  54. package/src/server/configServer.ts +27 -17
  55. package/src/server/expressLogger.ts +37 -0
  56. package/src/utils/config.ts +52 -7
  57. package/src/utils/logger.ts +30 -4
  58. package/src/utils/telemetry.ts +41 -0
  59. /package/dist/{typeDefs.js → types/typeDefs.js} +0 -0
  60. /package/src/{typeDefs.ts → types/typeDefs.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## [1.5.1](https://github.com/zotoio/x-fidelity/compare/v1.5.0...v1.5.1) (2024-07-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **scope:** logging correlation ([ea1c497](https://github.com/zotoio/x-fidelity/commit/ea1c4977cac418c49cd9f6778e7f72458c2c2a61))
7
+
8
+ # [1.5.0](https://github.com/zotoio/x-fidelity/compare/v1.4.1...v1.5.0) (2024-07-24)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **logger:** console transport ([69c62b1](https://github.com/zotoio/x-fidelity/commit/69c62b1b9859bc71801c576b969e9698ecc53a61))
14
+ * **log:** remove console and add process exit codes ([3ec801f](https://github.com/zotoio/x-fidelity/commit/3ec801fe3f913452d1f6ef14723fd0f8cb3a8439))
15
+
16
+
17
+ ### Features
18
+
19
+ * **telemetry:** basic start ([47faf3b](https://github.com/zotoio/x-fidelity/commit/47faf3b5f7a88afc07be1b256a611ce46ef64872))
20
+ * **telemetry:** basics including tracing ([f07f6b4](https://github.com/zotoio/x-fidelity/commit/f07f6b4d7ad886008cd20d3ccfa80e0e980bfd34))
21
+ * **telemetry:** request ids ([e19489e](https://github.com/zotoio/x-fidelity/commit/e19489eadd08b06119244a8e1798c2f22bac898b))
22
+
1
23
  ## [1.4.1](https://github.com/zotoio/x-fidelity/compare/v1.4.0...v1.4.1) (2024-07-14)
2
24
 
3
25
 
package/README.md CHANGED
@@ -1,6 +1,24 @@
1
1
  # x-fidelity
2
2
 
3
- CLI for opinionated framework adherence checks
3
+ x-fidelity is an advanced CLI tool designed to enforce opinionated framework adherence checks within a codebase. It provides a flexible and extensible way to ensure your projects follow specific standards and best practices.
4
+
5
+ ## Quick Start
6
+
7
+ 1. Install x-fidelity:
8
+ ```
9
+ yarn global add x-fidelity
10
+ export PATH="$PATH:$(yarn global bin)"
11
+ ```
12
+
13
+ 2. Run in your project directory:
14
+ ```
15
+ xfidelity
16
+ ```
17
+
18
+ 3. For more options:
19
+ ```
20
+ xfidelity --help
21
+ ```
4
22
 
5
23
  ```
6
24
  =====================================
@@ -16,107 +34,131 @@ CLI for opinionated framework adherence checks
16
34
  -------------------------------------
17
35
  ```
18
36
 
19
- ## What is x-fidelity?
37
+ ## Table of Contents
38
+
39
+ 1. [Intent and Purpose](#intent-and-purpose)
40
+ 2. [Key Features](#key-features)
41
+ 3. [Installation](#installation)
42
+ 4. [Usage](#usage)
43
+ 5. [Configuration](#configuration)
44
+ 6. [Extending x-fidelity](#extending-x-fidelity)
45
+ 7. [OpenAI Integration](#openai-integration)
46
+ 8. [Hosting Config Servers](#hosting-config-servers)
47
+ 9. [Best Practices](#best-practices)
48
+ 10. [Contributing](#contributing)
49
+ 11. [License](#license)
20
50
 
21
- x-fidelity is a CLI tool designed to enforce adherence to a set of opinionated framework rules within a codebase. It checks for various conditions such as directory structure, dependency versions, and the presence of certain strings in files.
51
+ ## Intent and Purpose
22
52
 
23
- ## Features
53
+ x-fidelity aims to streamline the process of maintaining code quality and consistency across projects. By providing a flexible, rule-based system, it allows teams to:
24
54
 
25
- - Ensures the directory structure matches a predefined standard.
26
- - Verifies that dependencies are up-to-date according to a specified minimum version.
27
- - Checks for the presence or absence of specific strings in files.
28
- - Configurable via a remote JSON configuration file.
29
- - Integrates with OpenAI for advanced code analysis.
55
+ - Enforce coding standards and best practices
56
+ - Ensure consistent project structures
57
+ - Maintain up-to-date dependencies
58
+ - Catch potential issues early in the development process
59
+ - Integrate advanced code analysis using AI (via OpenAI)
60
+
61
+ The tool is designed to be highly customizable, allowing teams to define their own archetypes, rules, and checks tailored to their specific needs and tech stacks.
62
+
63
+ ## Key Features
64
+
65
+ - **Flexible Archetype System**: Define custom project archetypes with specific rules and configurations.
66
+ - **Customizable Rules**: Create and apply rules for various aspects of your codebase.
67
+ - **Directory Structure Validation**: Ensure your project follows a predefined directory structure.
68
+ - **Dependency Version Checking**: Verify that your project uses up-to-date dependencies.
69
+ - **Content Analysis**: Search for specific patterns or strings within your codebase.
70
+ - **Remote Configuration**: Fetch configurations from a remote server for centralized management.
71
+ - **OpenAI Integration**: Leverage AI for advanced code analysis and suggestions.
72
+ - **Extensible Architecture**: Easily add new operators, facts, and rules to suit your needs.
30
73
 
31
74
  ## Installation
32
75
 
33
- Install x-fidelity with Node.js 18+ and Yarn:
76
+ Install x-fidelity using Node.js 18+ and Yarn:
34
77
 
35
78
  ```sh
36
79
  yarn global add x-fidelity
37
80
  export PATH="$PATH:$(yarn global bin)"
38
81
  ```
39
82
 
40
- You may want to add the path line to your `~/.bashrc` or `~/.zshrc` file for persistence of the binary in your path.
83
+ For persistent access, add the PATH line to your `~/.bashrc` or `~/.zshrc` file.
41
84
 
42
85
  ## Usage
43
86
 
44
- ### CLI
87
+ ### Basic Usage
45
88
 
46
- To run x-fidelity, use the following command:
89
+ Run x-fidelity in your project directory:
47
90
 
48
91
  ```sh
49
92
  xfidelity
50
-
51
- # you can use the following options for more advanced setups such as the remote config server
52
- xfidelity [-d --dir <directory>] [-c --configUrl <url>] [-a --archtype <archetype>]
53
93
  ```
54
94
 
55
- - `-d --dir <directory>`: (Optional) The root directory of the local repo dir to analyze. Default is current dir.
56
- - `-c --configUrl <url>`: (Optional) The URL to fetch the configuration from.
57
- - `-a --archetype <archetype>`: (Optional) The archetype to use for analysis. 'node-fullstack' is the default, or 'java-microservice' and these are extensible)
95
+ ### Advanced Usage
58
96
 
59
- **Example for node-fullstack archetype in current dir with remove config server:**
97
+ Use command-line options for more control:
60
98
 
61
99
  ```sh
62
- xfidelity --configUrl https://localhost:8888
100
+ xfidelity [-d --dir <directory>] [-c --configServer <url>] [-a --archetype <archetype>] [-m --mode <mode>] [-p --port <port>]
63
101
  ```
64
102
 
65
- **Example for java-microservice archetype in parent dir with remote config server (in this example running locally on port 8888):**
103
+ - `-d --dir <directory>`: Specify the root directory to analyze (default: current directory)
104
+ - `-c --configServer <url>`: URL to fetch the configuration from
105
+ - `-a --archetype <archetype>`: Archetype to use for analysis (default: 'node-fullstack')
106
+ - `-m --mode <mode>`: Run mode: 'cli' or 'server' (default: 'cli')
107
+ - `-p --port <port>`: Port number for server mode (default: 8888)
108
+
109
+ Examples:
66
110
 
67
111
  ```sh
68
- xfidelity -d .. -a java-microservice --c https://localhost:8888
69
- ```
112
+ # Use remote config server
113
+ xfidelity --configServer https://localhost:8888
70
114
 
71
- ### Configuration Server
115
+ # Analyze parent directory with java-microservice archetype
116
+ xfidelity -d .. -a java-microservice -c https://localhost:8888
72
117
 
73
- x-fidelity includes an optional configuration server that can be used to serve configuration per archetype. This includes config for fact provders and custom operators, and also the rule json to use per archetype.
118
+ # Run in server mode with custom port
119
+ xfidelity --mode server --port 9999
74
120
 
75
- This is of most use when you need to be able to globally rollout config updates for minor/patch releases without relying cli users run to upgrade x-fidelity.
121
+ ```
76
122
 
77
- **To start the server:**
123
+ ### Configuration Server
78
124
 
79
- 1. Navigate to the x-fidelity directory.
80
- 2. Run the following command:
125
+ Start the built-in configuration server:
81
126
 
82
127
  ```sh
83
- yarn start-config-server
128
+ yarn start-server
84
129
  ```
85
130
 
86
- > **By default, the server will start on port 8888**. You can override this using the `XFI_SERVER_PORT` environment variable You can then use the server URL as the `--configUrl` parameter when running the CLI.
131
+ Or use the CLI:
132
+
87
133
  ```sh
88
- export XFI_SERVER_PORT=8888
134
+ xfidelity --mode server
89
135
  ```
90
136
 
91
- ## OpenAI Integration
92
-
93
- To enable OpenAI features for experimental LLM-based codebase analysis:
94
-
95
- 1. Sign up for a developer account at [OpenAI](https://platform.openai.com).
96
- 2. Navigate to the API section and generate a new API key.
97
- 3. Set the `OPENAI_API_KEY` environment variable:
137
+ Set a custom port:
98
138
 
99
139
  ```sh
100
- export OPENAI_API_KEY=your_openai_api_key
140
+ xfidelity --mode server --port 9999
101
141
  ```
102
- 4. Optionally set the OPENAI_MODEL environment var (default is gpt-4o):
142
+
143
+ You can also set the port using an environment variable:
144
+
103
145
  ```sh
104
- export OPENAI_MODEL=gpt-4
146
+ export XFI_SERVER_PORT=8888
147
+ xfidelity --mode server
105
148
  ```
106
- Note that not all models consistently return parseable JSON results, so some experimentation is required.
107
-
108
- > [!IMPORTANT]
109
- > Using OpenAI's API may incur costs. Please refer to OpenAI's pricing page for more details.
110
- >
111
- >The 'collectOpenaiAnalysisFacts' function will concatenate all files that are not blacklisted but are included in the whitelist and send this to OpenAI. Ensure you consider any sensitive data that may be sent, and the cost based on the token count this will be per rule check that is executed.
112
149
 
113
150
  ## Configuration
114
151
 
115
- The configuration for x-fidelity is based on archetypes, which define the rules, operators, facts, and other settings for a specific type of project. You can find example configuration files in the `src/archetypes` directory of the repository.
152
+ x-fidelity uses archetypes to define project-specific configurations. Archetypes specify:
116
153
 
117
- ### Archetype Schema
154
+ - Rules to apply
155
+ - Operators to use
156
+ - Facts to gather
157
+ - Dependency version requirements
158
+ - Standard directory structure
159
+ - File patterns to include or exclude
118
160
 
119
- An archetype is defined with the following structure:
161
+ Example archetype structure:
120
162
 
121
163
  ```typescript
122
164
  interface ArchetypeConfig {
@@ -132,54 +174,19 @@ interface ArchetypeConfig {
132
174
  }
133
175
  ```
134
176
 
135
- - `rules`: An array of rule names to be applied for this archetype.
136
- - `operators`: An array of operator names used in the rules.
137
- - `facts`: An array of fact provider names used to gather information about the codebase.
138
- - `config`: Additional configuration specific to the archetype:
139
- - `minimumDependencyVersions`: Minimum required versions for dependencies.
140
- - `standardStructure`: Expected directory structure for the project.
141
- - `blacklistPatterns`: Patterns for files/directories to be ignored.
142
- - `whitelistPatterns`: Patterns for files/directories to be included.
143
-
144
- ### Rule Structure
145
-
146
- Each rule is defined in a JSON file with the following structure:
147
-
148
- ```json
149
- {
150
- "name": "ruleName",
151
- "conditions": {
152
- "all": [
153
- {
154
- "fact": "factName",
155
- "operator": "operatorName",
156
- "value": "expectedValue"
157
- }
158
- ]
159
- },
160
- "event": {
161
- "type": "violation",
162
- "params": {
163
- "message": "Error message when the rule fails"
164
- }
165
- }
166
- }
167
- ```
177
+ ## Extending x-fidelity
168
178
 
169
- ## Creating New Archetypes
170
-
171
- To create a new archetype:
179
+ x-fidelity is designed to be highly extensible:
172
180
 
173
- 1. Create a new file in the `src/archetypes` directory, e.g., `myNewArchetype.ts`.
174
- 2. Define the archetype configuration following the `ArchetypeConfig` interface.
175
- 3. Add any necessary rules in the `src/rules` directory.
176
- 4. If needed, create custom operators in the `src/operators` directory.
177
- 5. If needed, create custom fact providers in the `src/facts` directory.
178
- 6. Update the `src/archetypes/index.ts` file to include your new archetype.
181
+ 1. **Custom Rules**: Add new JSON rule files in `src/rules`.
182
+ 2. **Custom Operators**: Implement new operators in `src/operators` and add them to `src/operators/index.ts`.
183
+ 3. **Custom Facts**: Create new fact providers in `src/facts` and add them to `src/facts/index.ts`.
184
+ 4. **New Archetypes**: Define new archetypes in `src/archetypes` and include them in `src/archetypes/index.ts`.
179
185
 
180
- Example of a new archetype:
186
+ Example of creating a new archetype:
181
187
 
182
188
  ```typescript
189
+ // src/archetypes/myNewArchetype.ts
183
190
  export const myNewArchetype: ArchetypeConfig = {
184
191
  rules: ['myCustomRule', 'standardRule1', 'standardRule2'],
185
192
  operators: ['myCustomOperator', 'standardOperator1'],
@@ -201,41 +208,43 @@ export const myNewArchetype: ArchetypeConfig = {
201
208
  };
202
209
  ```
203
210
 
204
- ## Extensibility
211
+ ## OpenAI Integration
205
212
 
206
- x-fidelity is designed to be highly extensible:
213
+ To enable AI-powered code analysis:
214
+
215
+ 1. Sign up for an [OpenAI API key](https://platform.openai.com).
216
+ 2. Set environment variables:
217
+
218
+ ```sh
219
+ export OPENAI_API_KEY=your_openai_api_key
220
+ export OPENAI_MODEL=gpt-4 # Optional, default is gpt-4o
221
+ ```
207
222
 
208
- 1. **Custom Rules**: Create new rules by adding JSON files in the `src/rules` directory.
209
- 2. **Custom Operators**: Implement new operators in the `src/operators` directory and add them to `src/operators/index.ts`.
210
- 3. **Custom Facts**: Create new fact providers in the `src/facts` directory and add them to `src/facts/index.ts`.
211
- 4. **New Archetypes**: As described above, create new archetypes to support different project types or frameworks.
223
+ > [!IMPORTANT]
224
+ > Be aware of potential costs and data privacy concerns when using OpenAI's API.
212
225
 
213
226
  ## Hosting Config Servers
214
227
 
215
228
  To host a config server for x-fidelity:
216
229
 
217
- 1. Set up a Node.js server environment (e.g., using Express.js).
218
- 2. Implement endpoints that serve the archetype configurations and rules.
219
- 3. Ensure the server is secure and can handle the expected load.
220
- 4. Use HTTPS for secure communication.
221
- 5. Implement caching mechanisms to improve performance.
222
- 6. Consider using a CDN for global distribution and lower latency.
230
+ 1. Set up a Node.js server (e.g., Express.js)
231
+ 2. Implement endpoints for archetype configurations and rules
232
+ 3. Ensure security, scalability, and performance
233
+ 4. Use HTTPS and implement proper authentication
234
+ 5. Consider using a CDN for global distribution
223
235
 
224
- Example server setup (simplified):
236
+ Example server setup:
225
237
 
226
238
  ```javascript
227
239
  const express = require('express');
228
240
  const app = express();
229
241
 
230
242
  app.get('/archetypes/:archetype', (req, res) => {
231
- const archetype = req.params.archetype;
232
- // Fetch and return the archetype configuration
243
+ // Fetch and return archetype configuration
233
244
  });
234
245
 
235
246
  app.get('/archetypes/:archetype/rules/:rule', (req, res) => {
236
- const archetype = req.params.archetype;
237
- const rule = req.params.rule;
238
- // Fetch and return the specific rule for the archetype
247
+ // Fetch and return specific rule
239
248
  });
240
249
 
241
250
  app.listen(8888, () => {
@@ -243,15 +252,20 @@ app.listen(8888, () => {
243
252
  });
244
253
  ```
245
254
 
246
- Best practices for hosting:
255
+ ## Best Practices
256
+
257
+ 1. **Version Control**: Keep your x-fidelity configurations in version control.
258
+ 2. **Continuous Integration**: Integrate x-fidelity checks into your CI/CD pipeline.
259
+ 3. **Regular Updates**: Keep your archetypes, rules, and dependencies up to date.
260
+ 4. **Documentation**: Document custom rules, operators, and archetypes for your team.
261
+ 5. **Gradual Implementation**: When introducing x-fidelity to an existing project, start with basic checks and gradually increase strictness.
262
+ 6. **Team Alignment**: Ensure your team understands and agrees on the rules being enforced.
263
+ 7. **Performance**: Be mindful of the performance impact, especially for large codebases.
264
+
265
+ ## Contributing
247
266
 
248
- - Use environment variables for sensitive information.
249
- - Implement proper error handling and logging.
250
- - Set up monitoring and alerting for the server.
251
- - Regularly update and maintain the server and its dependencies.
252
- - Implement rate limiting to prevent abuse.
253
- - Consider using containerization (e.g., Docker) for easy deployment and scaling.
267
+ Contributions to x-fidelity are welcome! Please refer to the `CONTRIBUTING.md` file for guidelines on how to contribute to this project.
254
268
 
255
269
  ## License
256
270
 
257
- This project is licensed under the MIT License.
271
+ This project is licensed under the MIT License. See the `LICENSE` file for details.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.archetypes = void 0;
4
4
  exports.archetypes = {
5
5
  'node-fullstack': {
6
- rules: ['sensitiveLogging', 'outdatedFramework', 'noDatabases', 'nonStandardDirectoryStructure', 'openaiAnalysisTop5', 'openaiAnalysisA11y'],
6
+ rules: ['sensitiveLogging-iterative', 'outdatedFramework-global', 'noDatabases-iterative', 'nonStandardDirectoryStructure-global', 'openaiAnalysisTop5-global', 'openaiAnalysisA11y-global', 'yarnLockfileCheck-global'],
7
7
  operators: ['fileContains', 'outdatedFramework', 'nonStandardDirectoryStructure', 'openaiAnalysisHighSeverity'],
8
8
  facts: ['repoFilesystemFacts', 'repoDependencyFacts', 'openaiAnalysisFacts'],
9
9
  config: {
@@ -14,7 +14,6 @@ exports.archetypes = {
14
14
  standardStructure: {
15
15
  app: {
16
16
  frontend: null,
17
- common: null,
18
17
  server: null
19
18
  }
20
19
  },
@@ -29,7 +28,7 @@ exports.archetypes = {
29
28
  }
30
29
  },
31
30
  'java-microservice': {
32
- rules: ['sensitiveLogging', 'outdatedFramework', 'noDatabases', 'nonStandardDirectoryStructure'],
31
+ rules: ['sensitiveLogging-iterative', 'outdatedFramework-global', 'noDatabases-iterative', 'nonStandardDirectoryStructure-global'],
33
32
  operators: ['fileContains', 'outdatedFramework', 'nonStandardDirectoryStructure'],
34
33
  facts: ['repoFilesystemFacts', 'repoDependencyFacts'],
35
34
  config: {
package/dist/core/cli.js CHANGED
@@ -3,6 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.options = void 0;
4
4
  const logger_1 = require("../utils/logger");
5
5
  const commander_1 = require("commander");
6
+ // Ensure logger is initialized
7
+ if (!logger_1.logger || typeof logger_1.logger.info !== 'function') {
8
+ console.error('Logger is not properly initialized');
9
+ process.exit(1);
10
+ }
11
+ commander_1.program
12
+ .option("-d, --dir <directory>", "The checkout directory to analyze (default: current directory)", ".")
13
+ .option("-a, --archetype <archetype>", "The archetype to use for analysis (default: node-fullstack)", "node-fullstack")
14
+ .option("-c, --configServer <configServer>", "The config server URL for fetching remote archetype configurations and rules")
15
+ .option("-m, --mode <mode>", "Run mode: 'cli' or 'server' (default: cli)", "cli")
16
+ .option("-p, --port <port>", "Port number for server mode (default: 8888)", "8888")
17
+ .option("-l, --local-config <path>", "Path to local archetype config and rules");
18
+ commander_1.program.parse();
19
+ const options = commander_1.program.opts();
20
+ exports.options = options;
6
21
  const banner = (`
7
22
  =====================================
8
23
  __ __ ________ ______
@@ -14,26 +29,17 @@ const banner = (`
14
29
  | ## | ## | ## | ## \\
15
30
  \\## \\## \\## \\######
16
31
 
17
- -------------------------------------
18
- ${new Date().toString()}`);
19
- console.log(banner);
20
- logger_1.logger.info([banner]);
21
- commander_1.program
22
- .option("-d, --dir <directory>", "The checkout directory to analyse", ".")
23
- .option("-a, --archetype <archetype>", "The archetype to use for analysis", "node-fullstack")
24
- .option("-c, --configServer <configServer>", "The config server URL for fetching remote archetype configurations and rules");
25
- commander_1.program.parse();
26
- const options = commander_1.program.opts();
27
- exports.options = options;
32
+ --------------------
33
+ ${new Date().toString().slice(0, 24)}
34
+ archetype: ${options.archetype}
35
+ directory: ${process.env.PWD}/${options.dir}
36
+ configServer: ${options.configServer ? options.configServer : 'none'}
37
+ mode: ${options.mode}
38
+ port: ${options.mode === 'server' ? options.port : 'N/A'}
39
+ local-config: ${options.localConfig ? options.localConfig : 'none'}
40
+ for available options run: xfidelity --help
41
+ =====================================`);
42
+ logger_1.logger.info(banner);
28
43
  // print help if no arguments are passed
29
44
  if (commander_1.program.options.length === 0)
30
45
  commander_1.program.help();
31
- if (!options.dir) {
32
- console.error("Checkout directory not provided. Defaulting to current directory.");
33
- }
34
- let msg = `Archetype ${options.archetype}: analysis of: ${process.env.PWD}/${options.dir}`;
35
- logger_1.logger.info(msg) && console.log(msg);
36
- msg = `configServer: ${options.configServer ? options.configServer : 'local'}`;
37
- logger_1.logger.info(msg) && console.log(msg);
38
- msg = '=====================================';
39
- logger_1.logger.info(msg) && console.log(msg);