composed-di 0.2.6 → 0.2.8
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 +1 -1
- package/dist/plugin/index.d.ts +66 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +397 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/serviceModule.d.ts +1 -1
- package/dist/serviceModule.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/ServiceModule.ts +2 -2
package/README.md
CHANGED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
import { ServiceModule } from '../ServiceModule';
|
|
3
|
+
import { DotGraphOptions } from '../utils';
|
|
4
|
+
export interface GraphGeneratorOptions {
|
|
5
|
+
/** Output directory for generated graph files (default: './graphs') */
|
|
6
|
+
outputDir?: string;
|
|
7
|
+
/** Options to pass to createDotGraph */
|
|
8
|
+
graphOptions?: DotGraphOptions;
|
|
9
|
+
/** File extension for output files (default: '.dot') */
|
|
10
|
+
fileExtension?: string;
|
|
11
|
+
/** Whether to require compiled JS files instead of TS (default: false) */
|
|
12
|
+
useCompiledFiles?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface ServiceModuleInfo {
|
|
15
|
+
name: string;
|
|
16
|
+
filePath: string;
|
|
17
|
+
line: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Finds all ServiceModule constant declarations in a TypeScript project.
|
|
21
|
+
*
|
|
22
|
+
* @param projectPath - Path to the tsconfig.json or project directory
|
|
23
|
+
* @returns Array of information about found ServiceModule declarations
|
|
24
|
+
*/
|
|
25
|
+
export declare function findServiceModuleDeclarations(projectPath: string): ServiceModuleInfo[];
|
|
26
|
+
/**
|
|
27
|
+
* Evaluates a TypeScript/JavaScript file and extracts ServiceModule instances.
|
|
28
|
+
*
|
|
29
|
+
* @param filePath - Path to the file to evaluate
|
|
30
|
+
* @param moduleNames - Names of the ServiceModule variables to extract
|
|
31
|
+
* @returns Map of variable names to ServiceModule instances
|
|
32
|
+
*/
|
|
33
|
+
export declare function evaluateServiceModules(filePath: string, moduleNames: string[]): Promise<Map<string, ServiceModule>>;
|
|
34
|
+
/**
|
|
35
|
+
* Generates DOT graph files for all ServiceModule declarations found in a project.
|
|
36
|
+
*
|
|
37
|
+
* @param projectPath - Path to the tsconfig.json or project directory
|
|
38
|
+
* @param options - Options for graph generation
|
|
39
|
+
*/
|
|
40
|
+
export declare function generateGraphFiles(projectPath: string, options?: GraphGeneratorOptions): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a ts-node plugin that automatically finds ServiceModule declarations
|
|
43
|
+
* and generates DOT graph files.
|
|
44
|
+
*
|
|
45
|
+
* Usage in tsconfig.json:
|
|
46
|
+
* {
|
|
47
|
+
* "compilerOptions": {
|
|
48
|
+
* "plugins": [
|
|
49
|
+
* {
|
|
50
|
+
* "name": "composed-di/plugin",
|
|
51
|
+
* "outputDir": "./graphs"
|
|
52
|
+
* }
|
|
53
|
+
* ]
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
*/
|
|
57
|
+
export declare function createPlugin(options?: GraphGeneratorOptions): {
|
|
58
|
+
create(info: ts.server.PluginCreateInfo): ts.LanguageService;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* CLI entry point for generating graph files.
|
|
62
|
+
* Can be run directly: npx ts-node src/plugin/index.ts [projectPath] [outputDir]
|
|
63
|
+
*/
|
|
64
|
+
export declare function main(args?: string[]): Promise<void>;
|
|
65
|
+
export default createPlugin;
|
|
66
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAkB,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3D,MAAM,WAAW,qBAAqB;IACpC,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,UAAU,iBAAiB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAgDtF;AAoID;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAyErC;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,IAAI,CAAC,CAwDf;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,qBAA0B;iBAE/C,EAAE,CAAC,MAAM,CAAC,gBAAgB;EAkB1C;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAShF;AAGD,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.findServiceModuleDeclarations = findServiceModuleDeclarations;
|
|
46
|
+
exports.evaluateServiceModules = evaluateServiceModules;
|
|
47
|
+
exports.generateGraphFiles = generateGraphFiles;
|
|
48
|
+
exports.createPlugin = createPlugin;
|
|
49
|
+
exports.main = main;
|
|
50
|
+
const ts = __importStar(require("typescript"));
|
|
51
|
+
const fs = __importStar(require("fs"));
|
|
52
|
+
const path = __importStar(require("path"));
|
|
53
|
+
const ServiceModule_1 = require("../ServiceModule");
|
|
54
|
+
const ServiceFactory_1 = require("../ServiceFactory");
|
|
55
|
+
const ServiceKey_1 = require("../ServiceKey");
|
|
56
|
+
const utils_1 = require("../utils");
|
|
57
|
+
/**
|
|
58
|
+
* Finds all ServiceModule constant declarations in a TypeScript project.
|
|
59
|
+
*
|
|
60
|
+
* @param projectPath - Path to the tsconfig.json or project directory
|
|
61
|
+
* @returns Array of information about found ServiceModule declarations
|
|
62
|
+
*/
|
|
63
|
+
function findServiceModuleDeclarations(projectPath) {
|
|
64
|
+
const configPath = projectPath.endsWith('.json')
|
|
65
|
+
? projectPath
|
|
66
|
+
: ts.findConfigFile(projectPath, ts.sys.fileExists, 'tsconfig.json');
|
|
67
|
+
if (!configPath) {
|
|
68
|
+
throw new Error(`Could not find tsconfig.json in ${projectPath}`);
|
|
69
|
+
}
|
|
70
|
+
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
71
|
+
if (configFile.error) {
|
|
72
|
+
throw new Error(`Error reading tsconfig.json: ${ts.flattenDiagnosticMessageText(configFile.error.messageText, '\n')}`);
|
|
73
|
+
}
|
|
74
|
+
const parsedConfig = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(configPath));
|
|
75
|
+
const program = ts.createProgram(parsedConfig.fileNames, parsedConfig.options);
|
|
76
|
+
const checker = program.getTypeChecker();
|
|
77
|
+
const serviceModules = [];
|
|
78
|
+
for (const sourceFile of program.getSourceFiles()) {
|
|
79
|
+
if (sourceFile.isDeclarationFile)
|
|
80
|
+
continue;
|
|
81
|
+
ts.forEachChild(sourceFile, function visit(node) {
|
|
82
|
+
if (ts.isVariableStatement(node)) {
|
|
83
|
+
for (const declaration of node.declarationList.declarations) {
|
|
84
|
+
if (ts.isIdentifier(declaration.name) && declaration.initializer) {
|
|
85
|
+
// Check if the initializer is a call to ServiceModule.from()
|
|
86
|
+
if (isServiceModuleFromCall(declaration.initializer, checker)) {
|
|
87
|
+
const { line } = sourceFile.getLineAndCharacterOfPosition(declaration.getStart());
|
|
88
|
+
serviceModules.push({
|
|
89
|
+
name: declaration.name.text,
|
|
90
|
+
filePath: sourceFile.fileName,
|
|
91
|
+
line: line + 1
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
ts.forEachChild(node, visit);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return serviceModules;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Checks if a node is a call to ServiceModule.from()
|
|
104
|
+
*/
|
|
105
|
+
function isServiceModuleFromCall(node, checker) {
|
|
106
|
+
if (!ts.isCallExpression(node))
|
|
107
|
+
return false;
|
|
108
|
+
const expression = node.expression;
|
|
109
|
+
// Check for ServiceModule.from() pattern
|
|
110
|
+
if (ts.isPropertyAccessExpression(expression)) {
|
|
111
|
+
const propertyName = expression.name.text;
|
|
112
|
+
const objectExpression = expression.expression;
|
|
113
|
+
if (propertyName === 'from' && ts.isIdentifier(objectExpression)) {
|
|
114
|
+
const symbol = checker.getSymbolAtLocation(objectExpression);
|
|
115
|
+
if (symbol) {
|
|
116
|
+
const name = symbol.getName();
|
|
117
|
+
if (name === 'ServiceModule') {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Fallback: check by identifier name
|
|
122
|
+
if (objectExpression.text === 'ServiceModule') {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Compiles TypeScript source code to JavaScript.
|
|
131
|
+
*
|
|
132
|
+
* @param sourceCode - TypeScript source code
|
|
133
|
+
* @param fileName - Name of the file (for error reporting)
|
|
134
|
+
* @returns Compiled JavaScript code
|
|
135
|
+
*/
|
|
136
|
+
function compileTypeScript(sourceCode, fileName) {
|
|
137
|
+
const result = ts.transpileModule(sourceCode, {
|
|
138
|
+
compilerOptions: {
|
|
139
|
+
module: ts.ModuleKind.CommonJS,
|
|
140
|
+
target: ts.ScriptTarget.ES2020,
|
|
141
|
+
esModuleInterop: true,
|
|
142
|
+
strict: false,
|
|
143
|
+
},
|
|
144
|
+
fileName,
|
|
145
|
+
});
|
|
146
|
+
return result.outputText;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Creates a custom require function for the sandbox environment.
|
|
150
|
+
*
|
|
151
|
+
* @param basePath - Base path for resolving relative imports
|
|
152
|
+
* @returns Custom require function
|
|
153
|
+
*/
|
|
154
|
+
function createSandboxRequire(basePath) {
|
|
155
|
+
const customRequire = ((modulePath) => {
|
|
156
|
+
// Handle relative imports
|
|
157
|
+
if (modulePath.startsWith('./') || modulePath.startsWith('../')) {
|
|
158
|
+
const resolvedPath = path.resolve(basePath, modulePath);
|
|
159
|
+
// Try to find the module (could be .ts, .js, or directory with index)
|
|
160
|
+
const possiblePaths = [
|
|
161
|
+
resolvedPath,
|
|
162
|
+
resolvedPath + '.ts',
|
|
163
|
+
resolvedPath + '.js',
|
|
164
|
+
path.join(resolvedPath, 'index.ts'),
|
|
165
|
+
path.join(resolvedPath, 'index.js'),
|
|
166
|
+
];
|
|
167
|
+
for (const p of possiblePaths) {
|
|
168
|
+
if (fs.existsSync(p) && fs.statSync(p).isFile()) {
|
|
169
|
+
const source = fs.readFileSync(p, 'utf-8');
|
|
170
|
+
if (p.endsWith('.ts')) {
|
|
171
|
+
const compiled = compileTypeScript(source, p);
|
|
172
|
+
const moduleExports = {};
|
|
173
|
+
const moduleObj = { exports: moduleExports };
|
|
174
|
+
const wrappedCode = `(function(exports, require, module, __filename, __dirname) { ${compiled} })`;
|
|
175
|
+
const fn = eval(wrappedCode);
|
|
176
|
+
fn(moduleExports, createSandboxRequire(path.dirname(p)), moduleObj, p, path.dirname(p));
|
|
177
|
+
return moduleObj.exports;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
return require(p);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// Handle package imports (including our own package)
|
|
186
|
+
if (modulePath === 'composed-di' || modulePath.startsWith('composed-di/')) {
|
|
187
|
+
// Return our own exports
|
|
188
|
+
return {
|
|
189
|
+
ServiceModule: ServiceModule_1.ServiceModule,
|
|
190
|
+
ServiceFactory: ServiceFactory_1.ServiceFactory,
|
|
191
|
+
ServiceKey: ServiceKey_1.ServiceKey,
|
|
192
|
+
createDotGraph: utils_1.createDotGraph,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
// Fall back to Node's require for other modules
|
|
196
|
+
return require(modulePath);
|
|
197
|
+
});
|
|
198
|
+
// Add required properties to make it a valid NodeRequire
|
|
199
|
+
customRequire.resolve = require.resolve;
|
|
200
|
+
customRequire.cache = require.cache;
|
|
201
|
+
customRequire.extensions = require.extensions;
|
|
202
|
+
customRequire.main = require.main;
|
|
203
|
+
return customRequire;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Checks if a value is a ServiceModule instance using duck typing.
|
|
207
|
+
* This is necessary because the ServiceModule class might be loaded from different
|
|
208
|
+
* module instances, causing instanceof checks to fail.
|
|
209
|
+
*/
|
|
210
|
+
function isServiceModule(value) {
|
|
211
|
+
if (!value || typeof value !== 'object')
|
|
212
|
+
return false;
|
|
213
|
+
// Duck typing: check for ServiceModule's characteristic properties and methods
|
|
214
|
+
return (Array.isArray(value.factories) &&
|
|
215
|
+
typeof value.get === 'function' &&
|
|
216
|
+
typeof value.dispose === 'function');
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Evaluates a TypeScript/JavaScript file and extracts ServiceModule instances.
|
|
220
|
+
*
|
|
221
|
+
* @param filePath - Path to the file to evaluate
|
|
222
|
+
* @param moduleNames - Names of the ServiceModule variables to extract
|
|
223
|
+
* @returns Map of variable names to ServiceModule instances
|
|
224
|
+
*/
|
|
225
|
+
function evaluateServiceModules(filePath, moduleNames) {
|
|
226
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
227
|
+
const results = new Map();
|
|
228
|
+
try {
|
|
229
|
+
// Resolve the absolute path
|
|
230
|
+
const absolutePath = path.resolve(filePath);
|
|
231
|
+
const basePath = path.dirname(absolutePath);
|
|
232
|
+
// Read and compile the TypeScript file
|
|
233
|
+
const sourceCode = fs.readFileSync(absolutePath, 'utf-8');
|
|
234
|
+
const compiledCode = compileTypeScript(sourceCode, absolutePath);
|
|
235
|
+
// Create a sandbox context with necessary globals
|
|
236
|
+
const moduleExports = {};
|
|
237
|
+
const moduleObj = { exports: moduleExports };
|
|
238
|
+
// Create custom require for the sandbox
|
|
239
|
+
const sandboxRequire = createSandboxRequire(basePath);
|
|
240
|
+
// Execute the compiled code
|
|
241
|
+
const wrappedCode = `(function(exports, require, module, __filename, __dirname) {
|
|
242
|
+
${compiledCode}
|
|
243
|
+
})`;
|
|
244
|
+
const fn = eval(wrappedCode);
|
|
245
|
+
fn(moduleExports, sandboxRequire, moduleObj, absolutePath, basePath);
|
|
246
|
+
// Check for ServiceModule instances in exports using duck typing
|
|
247
|
+
for (const name of moduleNames) {
|
|
248
|
+
// Check direct exports (exports.name = ...)
|
|
249
|
+
if (isServiceModule(moduleExports[name])) {
|
|
250
|
+
results.set(name, moduleExports[name]);
|
|
251
|
+
}
|
|
252
|
+
// Check module.exports (module.exports.name = ...)
|
|
253
|
+
else if (isServiceModule(moduleObj.exports[name])) {
|
|
254
|
+
results.set(name, moduleObj.exports[name]);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// Debug: log what we found in exports
|
|
258
|
+
if (process.env.DEBUG_PLUGIN) {
|
|
259
|
+
console.log(` Debug: exports keys = [${Object.keys(moduleExports).join(', ')}]`);
|
|
260
|
+
console.log(` Debug: results size = ${results.size}`);
|
|
261
|
+
}
|
|
262
|
+
// If no exports found, the variables might be local (not exported)
|
|
263
|
+
// In this case, we need to modify the code to capture them
|
|
264
|
+
if (results.size === 0 && moduleNames.length > 0) {
|
|
265
|
+
// Try to capture local variables by returning them
|
|
266
|
+
const captureCode = `(function(exports, require, module, __filename, __dirname) {
|
|
267
|
+
${compiledCode}
|
|
268
|
+
return { ${moduleNames.map(n => `"${n}": typeof ${n} !== 'undefined' ? ${n} : undefined`).join(', ')} };
|
|
269
|
+
})`;
|
|
270
|
+
try {
|
|
271
|
+
const captureFn = eval(captureCode);
|
|
272
|
+
const localVars = captureFn(moduleExports, sandboxRequire, moduleObj, absolutePath, basePath);
|
|
273
|
+
for (const name of moduleNames) {
|
|
274
|
+
const value = localVars[name];
|
|
275
|
+
if (isServiceModule(value)) {
|
|
276
|
+
results.set(name, value);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
catch (captureError) {
|
|
281
|
+
// Silently ignore capture errors - variables might be in nested scopes
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
console.warn(`Warning: Could not evaluate ${filePath}:`, error);
|
|
287
|
+
}
|
|
288
|
+
return results;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Generates DOT graph files for all ServiceModule declarations found in a project.
|
|
293
|
+
*
|
|
294
|
+
* @param projectPath - Path to the tsconfig.json or project directory
|
|
295
|
+
* @param options - Options for graph generation
|
|
296
|
+
*/
|
|
297
|
+
function generateGraphFiles(projectPath_1) {
|
|
298
|
+
return __awaiter(this, arguments, void 0, function* (projectPath, options = {}) {
|
|
299
|
+
const { outputDir = './graphs', graphOptions = {
|
|
300
|
+
direction: 'TB',
|
|
301
|
+
highlightLeaves: true,
|
|
302
|
+
highlightRoots: true,
|
|
303
|
+
}, fileExtension = '.dot' } = options;
|
|
304
|
+
// Find all ServiceModule declarations
|
|
305
|
+
const declarations = findServiceModuleDeclarations(projectPath);
|
|
306
|
+
if (declarations.length === 0) {
|
|
307
|
+
console.log('No ServiceModule declarations found.');
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
console.log(`Found ${declarations.length} ServiceModule declaration(s):`);
|
|
311
|
+
declarations.forEach(d => {
|
|
312
|
+
console.log(` - ${d.name} in ${d.filePath}:${d.line}`);
|
|
313
|
+
});
|
|
314
|
+
// Create output directory if it doesn't exist
|
|
315
|
+
const absoluteOutputDir = path.resolve(outputDir);
|
|
316
|
+
if (!fs.existsSync(absoluteOutputDir)) {
|
|
317
|
+
fs.mkdirSync(absoluteOutputDir, { recursive: true });
|
|
318
|
+
}
|
|
319
|
+
// Group declarations by file
|
|
320
|
+
const byFile = new Map();
|
|
321
|
+
for (const decl of declarations) {
|
|
322
|
+
const existing = byFile.get(decl.filePath) || [];
|
|
323
|
+
existing.push(decl);
|
|
324
|
+
byFile.set(decl.filePath, existing);
|
|
325
|
+
}
|
|
326
|
+
// Process each file
|
|
327
|
+
for (const [filePath, decls] of byFile) {
|
|
328
|
+
const moduleNames = decls.map(d => d.name);
|
|
329
|
+
const modules = yield evaluateServiceModules(filePath, moduleNames);
|
|
330
|
+
for (const [name, module] of modules) {
|
|
331
|
+
const graphContent = (0, utils_1.createDotGraph)(module, Object.assign(Object.assign({}, graphOptions), { title: graphOptions.title || `${name} Dependency Graph` }));
|
|
332
|
+
const outputFileName = `${name}${fileExtension}`;
|
|
333
|
+
const outputPath = path.join(absoluteOutputDir, outputFileName);
|
|
334
|
+
fs.writeFileSync(outputPath, graphContent, 'utf-8');
|
|
335
|
+
console.log(`Generated: ${outputPath}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Creates a ts-node plugin that automatically finds ServiceModule declarations
|
|
342
|
+
* and generates DOT graph files.
|
|
343
|
+
*
|
|
344
|
+
* Usage in tsconfig.json:
|
|
345
|
+
* {
|
|
346
|
+
* "compilerOptions": {
|
|
347
|
+
* "plugins": [
|
|
348
|
+
* {
|
|
349
|
+
* "name": "composed-di/plugin",
|
|
350
|
+
* "outputDir": "./graphs"
|
|
351
|
+
* }
|
|
352
|
+
* ]
|
|
353
|
+
* }
|
|
354
|
+
* }
|
|
355
|
+
*/
|
|
356
|
+
function createPlugin(options = {}) {
|
|
357
|
+
return {
|
|
358
|
+
create(info) {
|
|
359
|
+
const proxy = Object.create(null);
|
|
360
|
+
for (const k of Object.keys(info.languageService)) {
|
|
361
|
+
const x = info.languageService[k];
|
|
362
|
+
// @ts-ignore
|
|
363
|
+
proxy[k] = (...args) => x.apply(info.languageService, args);
|
|
364
|
+
}
|
|
365
|
+
// Generate graphs when the plugin is initialized
|
|
366
|
+
const projectPath = info.project.getCurrentDirectory();
|
|
367
|
+
generateGraphFiles(projectPath, options).catch(err => {
|
|
368
|
+
console.error('Error generating graph files:', err);
|
|
369
|
+
});
|
|
370
|
+
return proxy;
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* CLI entry point for generating graph files.
|
|
376
|
+
* Can be run directly: npx ts-node src/plugin/index.ts [projectPath] [outputDir]
|
|
377
|
+
*/
|
|
378
|
+
function main() {
|
|
379
|
+
return __awaiter(this, arguments, void 0, function* (args = process.argv.slice(2)) {
|
|
380
|
+
const projectPath = args[0] || '.';
|
|
381
|
+
const outputDir = args[1] || './graphs';
|
|
382
|
+
console.log(`Scanning project at: ${path.resolve(projectPath)}`);
|
|
383
|
+
console.log(`Output directory: ${path.resolve(outputDir)}`);
|
|
384
|
+
console.log('');
|
|
385
|
+
yield generateGraphFiles(projectPath, { outputDir });
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
// Export default for ts-node plugin compatibility
|
|
389
|
+
exports.default = createPlugin;
|
|
390
|
+
// Run main if executed directly
|
|
391
|
+
if (require.main === module) {
|
|
392
|
+
main().catch(err => {
|
|
393
|
+
console.error('Error:', err);
|
|
394
|
+
process.exit(1);
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,sEAgDC;AA2ID,wDA4EC;AAQD,gDA2DC;AAkBD,oCAoBC;AAMD,oBASC;AA/ZD,+CAAiC;AACjC,uCAAyB;AACzB,2CAA6B;AAE7B,oDAAiD;AACjD,sDAAmD;AACnD,8CAA2C;AAC3C,oCAA2D;AAmB3D;;;;;GAKG;AACH,SAAgB,6BAA6B,CAAC,WAAmB;IAC/D,MAAM,UAAU,GAAG,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC9C,CAAC,CAAC,WAAW;QACb,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,WAAW,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAEvE,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,mCAAmC,WAAW,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,UAAU,GAAG,EAAE,CAAC,cAAc,CAAC,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAClE,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,gCA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CAAC;AAE5B,gCAAgC;AAChC,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;QACjB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/serviceModule.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServiceKey } from './ServiceKey';
|
|
2
2
|
import { ServiceFactory } from './ServiceFactory';
|
|
3
3
|
import { ServiceScope } from './ServiceScope';
|
|
4
|
-
type GenericFactory = ServiceFactory<unknown, readonly ServiceKey<
|
|
4
|
+
type GenericFactory = ServiceFactory<unknown, readonly ServiceKey<any>[]>;
|
|
5
5
|
export declare class ServiceModule {
|
|
6
6
|
readonly factories: GenericFactory[];
|
|
7
7
|
private constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceModule.d.ts","sourceRoot":"","sources":["../src/ServiceModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,KAAK,cAAc,GAAG,cAAc,CAAC,OAAO,EAAE,SAAS,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"ServiceModule.d.ts","sourceRoot":"","sources":["../src/ServiceModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,KAAK,cAAc,GAAG,cAAc,CAAC,OAAO,EAAE,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAG1E,qBAAa,aAAa;IACJ,QAAQ,CAAC,SAAS,EAAE,cAAc,EAAE;IAAxD,OAAO;IAOM,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAqBnD;;;;;;;;;OASG;IACI,OAAO,CAAC,KAAK,CAAC,EAAE,YAAY;IAQnC;;;;;;;;;OASG;IACH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,aAAa,GAAG,cAAc,CAAC,EAAE,GAAG,aAAa;CAcxE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "composed-di",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.8",
|
|
5
5
|
"author": "Juan Herrera juanhr454@gmail.com",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"require": "./dist/index.js"
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
16
|
"files": [
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
"license": "MIT",
|
|
25
26
|
"repository": {
|
|
26
27
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/imherrera/composed-di"
|
|
28
|
+
"url": "git+https://github.com/imherrera/composed-di.git"
|
|
28
29
|
},
|
|
29
30
|
"scripts": {
|
|
30
31
|
"build": "tsc --build",
|
package/src/ServiceModule.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { ServiceKey } from './ServiceKey';
|
|
|
2
2
|
import { ServiceFactory } from './ServiceFactory';
|
|
3
3
|
import { ServiceScope } from './ServiceScope';
|
|
4
4
|
|
|
5
|
-
type GenericFactory = ServiceFactory<unknown, readonly ServiceKey<
|
|
6
|
-
type GenericKey = ServiceKey<
|
|
5
|
+
type GenericFactory = ServiceFactory<unknown, readonly ServiceKey<any>[]>;
|
|
6
|
+
type GenericKey = ServiceKey<any>;
|
|
7
7
|
|
|
8
8
|
export class ServiceModule {
|
|
9
9
|
private constructor(readonly factories: GenericFactory[]) {
|