@djodjonx/neosyringe-cli 0.0.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.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @djodjonx/neosyringe-cli
2
+
3
+ CLI validator for NeoSyringe dependency graphs.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ npx neosyringe-check
9
+ ```
10
+
11
+ See [Documentation](https://djodjonx.github.io/neosyringe/guide/cli).
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.mjs ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ import * as ts from "typescript";
3
+ import { Analyzer } from "@djodjonx/neosyringe-core/analyzer";
4
+ import { GraphValidator } from "@djodjonx/neosyringe-core/generator";
5
+
6
+ //#region src/index.ts
7
+ /**
8
+ * NeoSyringe CLI
9
+ *
10
+ * Validates the dependency graph for a TypeScript project.
11
+ * Detects circular dependencies, missing bindings, and duplicate registrations.
12
+ *
13
+ * @example
14
+ * ```bash
15
+ * npx neo-syringe-check
16
+ * ```
17
+ */
18
+ /**
19
+ * CLI entry point.
20
+ * Reads tsconfig.json, analyzes the project, and validates the dependency graph.
21
+ */
22
+ function main() {
23
+ const cwd = process.cwd();
24
+ const configPath = ts.findConfigFile(cwd, ts.sys.fileExists, "tsconfig.json");
25
+ if (!configPath) {
26
+ console.error("❌ Could not find tsconfig.json");
27
+ process.exit(1);
28
+ }
29
+ console.log(`Analyzing project: ${configPath}`);
30
+ const { config } = ts.readConfigFile(configPath, ts.sys.readFile);
31
+ const { options, fileNames, errors } = ts.parseJsonConfigFileContent(config, ts.sys, cwd);
32
+ if (errors.length > 0) {
33
+ console.error("❌ TypeScript config errors:");
34
+ errors.forEach((e) => console.error(e.messageText));
35
+ process.exit(1);
36
+ }
37
+ const analyzer = new Analyzer(ts.createProgram(fileNames, options));
38
+ try {
39
+ console.log("🔍 Extracting dependency graph...");
40
+ const graph = analyzer.extract();
41
+ console.log(` Found ${graph.nodes.size} services.`);
42
+ console.log("🛡️ Validating graph...");
43
+ new GraphValidator().validate(graph);
44
+ console.log("✅ Validation passed! No circular dependencies or missing bindings found.");
45
+ process.exit(0);
46
+ } catch (e) {
47
+ console.error(`
48
+ ❌ Validation Failed:`);
49
+ console.error(` ${e.message}`);
50
+ process.exit(1);
51
+ }
52
+ }
53
+ main();
54
+
55
+ //#endregion
56
+ export { };
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@djodjonx/neosyringe-cli",
3
+ "version": "0.0.1",
4
+ "description": "CLI validator for NeoSyringe",
5
+ "type": "module",
6
+ "bin": {
7
+ "neosyringe-check": "dist/index.mjs"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "dependencies": {
16
+ "@djodjonx/neosyringe-core": "0.1.0"
17
+ },
18
+ "peerDependencies": {
19
+ "typescript": ">=5.0.0"
20
+ },
21
+ "devDependencies": {
22
+ "tsdown": "0.20.0-beta.3",
23
+ "typescript": "^5.9.3",
24
+ "vitest": "^4.0.17"
25
+ },
26
+ "scripts": {
27
+ "build": "tsdown",
28
+ "test": "vitest run"
29
+ }
30
+ }