@mnemonica/tactica 0.1.0 → 0.1.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/README.md +340 -262
- package/lib/analyzer.d.ts +195 -7
- package/lib/analyzer.js +1584 -19
- package/lib/analyzer.js.map +1 -1
- package/lib/cli.d.ts +6 -0
- package/lib/cli.js +202 -6
- package/lib/cli.js.map +1 -1
- package/lib/generator.d.ts +41 -7
- package/lib/generator.js +243 -49
- package/lib/generator.js.map +1 -1
- package/lib/graph.d.ts +4 -0
- package/lib/graph.js +11 -0
- package/lib/graph.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +39 -9
- package/lib/index.js.map +1 -1
- package/lib/topologica-analyzer.d.ts +85 -0
- package/lib/topologica-analyzer.js +509 -0
- package/lib/topologica-analyzer.js.map +1 -0
- package/lib/types.d.ts +110 -0
- package/lib/writer.d.ts +25 -13
- package/lib/writer.js +94 -51
- package/lib/writer.js.map +1 -1
- package/package.json +22 -24
- package/lib/plugin.d.ts +0 -8
- package/lib/plugin.js +0 -128
- package/lib/plugin.js.map +0 -1
package/lib/writer.d.ts
CHANGED
|
@@ -1,40 +1,52 @@
|
|
|
1
|
-
import { GeneratedTypes } from './types';
|
|
1
|
+
import { GeneratedTypes, DefinitionInfo, UsageInfo, EDSInfo, FlowInfo } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Writes generated types to file system
|
|
4
4
|
*/
|
|
5
5
|
export declare class TypesWriter {
|
|
6
6
|
private outputDir;
|
|
7
7
|
constructor(outputDir?: string);
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Legacy write method - delegates to writeTypesFile
|
|
10
10
|
*/
|
|
11
11
|
write(generated: GeneratedTypes): string;
|
|
12
12
|
/**
|
|
13
|
-
* Write types.ts file
|
|
13
|
+
* Write types.ts file (exportable type aliases - default mode)
|
|
14
14
|
*/
|
|
15
15
|
writeTypesFile(generated: GeneratedTypes): string;
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
* Write global augmentation file (index.d.ts - module augmentation mode)
|
|
18
|
+
*/
|
|
19
19
|
writeGlobalAugmentation(generated: GeneratedTypes): string;
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
* Write to a custom filename
|
|
22
|
+
*/
|
|
23
23
|
writeTo(filename: string, content: string): string;
|
|
24
24
|
/**
|
|
25
25
|
* Ensure output directory exists
|
|
26
26
|
*/
|
|
27
27
|
private ensureDirectory;
|
|
28
|
-
/**
|
|
29
|
-
* Update .gitignore to exclude .tactica folder
|
|
30
|
-
*/
|
|
31
|
-
private updateGitignore;
|
|
32
28
|
/**
|
|
33
29
|
* Clean the output directory
|
|
34
30
|
*/
|
|
35
31
|
clean(): void;
|
|
36
32
|
/**
|
|
37
|
-
* Get
|
|
33
|
+
* Get output directory
|
|
38
34
|
*/
|
|
39
35
|
getOutputDir(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Write definitions.json file
|
|
38
|
+
*/
|
|
39
|
+
writeDefinitionsFile(definitions: Map<string, DefinitionInfo>): string;
|
|
40
|
+
/**
|
|
41
|
+
* Write usages.json file
|
|
42
|
+
*/
|
|
43
|
+
writeUsagesFile(usages: Map<string, UsageInfo[]>): string;
|
|
44
|
+
/**
|
|
45
|
+
* Write eds.json file
|
|
46
|
+
*/
|
|
47
|
+
writeEDSFile(eds: Map<string, EDSInfo[]>): string;
|
|
48
|
+
/**
|
|
49
|
+
* Write flow.json file
|
|
50
|
+
*/
|
|
51
|
+
writeFlowFile(flow: Map<string, FlowInfo[]>): string;
|
|
40
52
|
}
|
package/lib/writer.js
CHANGED
|
@@ -37,54 +37,44 @@ exports.TypesWriter = void 0;
|
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Writes generated types to file system
|
|
41
41
|
*/
|
|
42
42
|
class TypesWriter {
|
|
43
43
|
constructor(outputDir = '.tactica') {
|
|
44
44
|
this.outputDir = outputDir;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* Legacy write method - delegates to writeTypesFile
|
|
48
48
|
*/
|
|
49
49
|
write(generated) {
|
|
50
|
-
|
|
51
|
-
this.ensureDirectory();
|
|
52
|
-
const outputPath = path.join(this.outputDir, 'types.d.ts');
|
|
53
|
-
// Write the file
|
|
54
|
-
fs.writeFileSync(outputPath, generated.content, 'utf-8');
|
|
55
|
-
// Update .gitignore if needed
|
|
56
|
-
this.updateGitignore();
|
|
57
|
-
return outputPath;
|
|
50
|
+
return this.writeTypesFile(generated);
|
|
58
51
|
}
|
|
59
52
|
/**
|
|
60
|
-
* Write types.ts file
|
|
53
|
+
* Write types.ts file (exportable type aliases - default mode)
|
|
61
54
|
*/
|
|
62
55
|
writeTypesFile(generated) {
|
|
63
56
|
this.ensureDirectory();
|
|
64
|
-
const
|
|
65
|
-
fs.writeFileSync(
|
|
66
|
-
return
|
|
57
|
+
const filePath = path.join(this.outputDir, 'types.ts');
|
|
58
|
+
fs.writeFileSync(filePath, generated.content, 'utf-8');
|
|
59
|
+
return filePath;
|
|
67
60
|
}
|
|
68
61
|
/**
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
* Write global augmentation file (index.d.ts - module augmentation mode)
|
|
63
|
+
*/
|
|
71
64
|
writeGlobalAugmentation(generated) {
|
|
72
65
|
this.ensureDirectory();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// Update .gitignore if needed
|
|
77
|
-
this.updateGitignore();
|
|
78
|
-
return outputPath;
|
|
66
|
+
const filePath = path.join(this.outputDir, 'index.d.ts');
|
|
67
|
+
fs.writeFileSync(filePath, generated.content, 'utf-8');
|
|
68
|
+
return filePath;
|
|
79
69
|
}
|
|
80
70
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
* Write to a custom filename
|
|
72
|
+
*/
|
|
83
73
|
writeTo(filename, content) {
|
|
84
74
|
this.ensureDirectory();
|
|
85
|
-
const
|
|
86
|
-
fs.writeFileSync(
|
|
87
|
-
return
|
|
75
|
+
const filePath = path.join(this.outputDir, filename);
|
|
76
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
77
|
+
return filePath;
|
|
88
78
|
}
|
|
89
79
|
/**
|
|
90
80
|
* Ensure output directory exists
|
|
@@ -94,29 +84,6 @@ class TypesWriter {
|
|
|
94
84
|
fs.mkdirSync(this.outputDir, { recursive: true });
|
|
95
85
|
}
|
|
96
86
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Update .gitignore to exclude .tactica folder
|
|
99
|
-
*/
|
|
100
|
-
updateGitignore() {
|
|
101
|
-
const gitignorePath = path.join(process.cwd(), '.gitignore');
|
|
102
|
-
if (!fs.existsSync(gitignorePath)) {
|
|
103
|
-
// Create .gitignore
|
|
104
|
-
fs.writeFileSync(gitignorePath, `${this.outputDir}/\n`, 'utf-8');
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const content = fs.readFileSync(gitignorePath, 'utf-8');
|
|
108
|
-
const lines = content.split('\n');
|
|
109
|
-
// Check if already ignored
|
|
110
|
-
const isIgnored = lines.some(line => line.trim() === this.outputDir ||
|
|
111
|
-
line.trim() === `${this.outputDir}/`);
|
|
112
|
-
if (!isIgnored) {
|
|
113
|
-
// Add to .gitignore
|
|
114
|
-
const newContent = content.endsWith('\n')
|
|
115
|
-
? `${content}${this.outputDir}/\n`
|
|
116
|
-
: `${content}\n${this.outputDir}/\n`;
|
|
117
|
-
fs.writeFileSync(gitignorePath, newContent, 'utf-8');
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
87
|
/**
|
|
121
88
|
* Clean the output directory
|
|
122
89
|
*/
|
|
@@ -129,11 +96,87 @@ class TypesWriter {
|
|
|
129
96
|
}
|
|
130
97
|
}
|
|
131
98
|
/**
|
|
132
|
-
* Get
|
|
99
|
+
* Get output directory
|
|
133
100
|
*/
|
|
134
101
|
getOutputDir() {
|
|
135
102
|
return this.outputDir;
|
|
136
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Write definitions.json file
|
|
106
|
+
*/
|
|
107
|
+
writeDefinitionsFile(definitions) {
|
|
108
|
+
this.ensureDirectory();
|
|
109
|
+
const filePath = path.join(this.outputDir, 'definitions.json');
|
|
110
|
+
// Convert Map to plain object
|
|
111
|
+
const definitionsObj = {};
|
|
112
|
+
for (const [key, value] of definitions) {
|
|
113
|
+
definitionsObj[key] = value;
|
|
114
|
+
}
|
|
115
|
+
const json = {
|
|
116
|
+
version: '1.0',
|
|
117
|
+
generatedAt: new Date().toISOString(),
|
|
118
|
+
definitions: definitionsObj,
|
|
119
|
+
};
|
|
120
|
+
fs.writeFileSync(filePath, JSON.stringify(json, null, 2), 'utf-8');
|
|
121
|
+
return filePath;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Write usages.json file
|
|
125
|
+
*/
|
|
126
|
+
writeUsagesFile(usages) {
|
|
127
|
+
this.ensureDirectory();
|
|
128
|
+
const filePath = path.join(this.outputDir, 'usages.json');
|
|
129
|
+
// Convert Map to plain object
|
|
130
|
+
const usagesObj = {};
|
|
131
|
+
for (const [key, value] of usages) {
|
|
132
|
+
usagesObj[key] = value;
|
|
133
|
+
}
|
|
134
|
+
const json = {
|
|
135
|
+
version: '1.0',
|
|
136
|
+
generatedAt: new Date().toISOString(),
|
|
137
|
+
usages: usagesObj,
|
|
138
|
+
};
|
|
139
|
+
fs.writeFileSync(filePath, JSON.stringify(json, null, 2), 'utf-8');
|
|
140
|
+
return filePath;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Write eds.json file
|
|
144
|
+
*/
|
|
145
|
+
writeEDSFile(eds) {
|
|
146
|
+
this.ensureDirectory();
|
|
147
|
+
const filePath = path.join(this.outputDir, 'eds.json');
|
|
148
|
+
// Convert Map to plain object
|
|
149
|
+
const edsObj = {};
|
|
150
|
+
for (const [key, value] of eds) {
|
|
151
|
+
edsObj[key] = value;
|
|
152
|
+
}
|
|
153
|
+
const json = {
|
|
154
|
+
version: '1.0',
|
|
155
|
+
generatedAt: new Date().toISOString(),
|
|
156
|
+
eds: edsObj,
|
|
157
|
+
};
|
|
158
|
+
fs.writeFileSync(filePath, JSON.stringify(json, null, 2), 'utf-8');
|
|
159
|
+
return filePath;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Write flow.json file
|
|
163
|
+
*/
|
|
164
|
+
writeFlowFile(flow) {
|
|
165
|
+
this.ensureDirectory();
|
|
166
|
+
const filePath = path.join(this.outputDir, 'flow.json');
|
|
167
|
+
// Convert Map to plain object
|
|
168
|
+
const flowObj = {};
|
|
169
|
+
for (const [key, value] of flow) {
|
|
170
|
+
flowObj[key] = value;
|
|
171
|
+
}
|
|
172
|
+
const json = {
|
|
173
|
+
version: '1.0',
|
|
174
|
+
generatedAt: new Date().toISOString(),
|
|
175
|
+
flow: flowObj,
|
|
176
|
+
};
|
|
177
|
+
fs.writeFileSync(filePath, JSON.stringify(json, null, 2), 'utf-8');
|
|
178
|
+
return filePath;
|
|
179
|
+
}
|
|
137
180
|
}
|
|
138
181
|
exports.TypesWriter = TypesWriter;
|
|
139
182
|
//# sourceMappingURL=writer.js.map
|
package/lib/writer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,uCAAyB;AACzB,2CAA6B;AAG7B;;GAEG;AACH,MAAa,WAAW;IAGvB,
|
|
1
|
+
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEb,uCAAyB;AACzB,2CAA6B;AAG7B;;GAEG;AACH,MAAa,W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AAC,IAA6B;QAC1C,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAExD,8BAA8B;QAC9B,MAAM,OAAO,GAA+B,EAAE,CAAC;QAC/C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;QAED,MAAM,IAAI,GAAG;YACZ,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrC,IAAI,EAAE,OAAO;SACb,CAAC;QAEF,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QACnE,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD;AAnKD,kCAmKC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mnemonica/tactica",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Type definition generator for Mnemonica — statically analyzes define() calls and emits .tactica/ types, registry, and metadata",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"bin": {
|
|
@@ -19,45 +19,43 @@
|
|
|
19
19
|
"test": "TS_NODE_PROJECT=./tsconfig.test.json mocha test/**/*.test.ts",
|
|
20
20
|
"test:coverage": "npx nyc npm test",
|
|
21
21
|
"test:coverage:html": "npx nyc --reporter=html npm test",
|
|
22
|
-
"lint": "npx eslint --fix ./src"
|
|
22
|
+
"lint": "npx eslint --fix ./src",
|
|
23
|
+
"use:public": "rm -rf node_modules package-lock.json && npm install mnemonica@latest typeomatica@latest --save && npm install mnemonica@latest --save-dev && npm install mnemonica@latest --save-peer && echo 'Switched to PUBLIC npm dependencies (latest)'",
|
|
24
|
+
"use:local": "node -e \"const fs=require('fs'),p=JSON.parse(fs.readFileSync('package.json','utf8'));p.peerDependencies.mnemonica='file:../core';p.devDependencies.mnemonica='file:../core';p.devDependencies.typeomatica='file:../typeomatica';p.dependencies.mnemonica='file:../core';fs.writeFileSync('package.json',JSON.stringify(p,null,'\\t')+'\\n');console.log('Switched to LOCAL file: dependencies');\""
|
|
23
25
|
},
|
|
24
26
|
"keywords": [
|
|
25
27
|
"mnemonica",
|
|
26
28
|
"typescript",
|
|
27
|
-
"
|
|
28
|
-
"plugin",
|
|
29
|
+
"codegen",
|
|
29
30
|
"types",
|
|
30
|
-
"
|
|
31
|
+
"type-generator",
|
|
32
|
+
"ast"
|
|
31
33
|
],
|
|
32
34
|
"author": "went.out@gmail.com",
|
|
33
|
-
"contributors": [
|
|
34
|
-
"Roo AI <ai-assistant@example.com>"
|
|
35
|
-
],
|
|
36
35
|
"repository": {
|
|
37
36
|
"type": "git",
|
|
38
37
|
"url": "git+https://github.com/mythographica/tactica.git"
|
|
39
38
|
},
|
|
40
|
-
|
|
41
39
|
"license": "MIT",
|
|
42
40
|
"peerDependencies": {
|
|
43
|
-
"mnemonica": "^0.
|
|
44
|
-
"typescript": "^5.0.0"
|
|
41
|
+
"mnemonica": "^1.0.6",
|
|
42
|
+
"typescript": "^5.0.0 || ^6.0.0"
|
|
45
43
|
},
|
|
46
44
|
"devDependencies": {
|
|
47
|
-
"@istanbuljs/nyc-config-typescript": "^1.0.
|
|
48
|
-
"@types/chai": "^4.3.
|
|
49
|
-
"@types/mocha": "^10.0.
|
|
50
|
-
"@types/node": "^20.
|
|
51
|
-
"chai": "^4.
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"ts-node": "^10.9.0",
|
|
45
|
+
"@istanbuljs/nyc-config-typescript": "^1.0.0",
|
|
46
|
+
"@types/chai": "^4.3.20",
|
|
47
|
+
"@types/mocha": "^10.0.10",
|
|
48
|
+
"@types/node": "^20.19.43",
|
|
49
|
+
"chai": "^4.5.0",
|
|
50
|
+
"mocha": "^8.1.3",
|
|
51
|
+
"nyc": "^18.0.0",
|
|
52
|
+
"ts-node": "^10.9.2",
|
|
56
53
|
"typeomatica": "^0.3.57",
|
|
57
|
-
"typescript": "^5.3
|
|
54
|
+
"typescript": "^5.9.3"
|
|
58
55
|
},
|
|
59
56
|
"dependencies": {
|
|
60
|
-
"@types/chokidar": "^2.1.
|
|
61
|
-
"chokidar": "^3.
|
|
57
|
+
"@types/chokidar": "^2.1.7",
|
|
58
|
+
"chokidar": "^3.6.0",
|
|
59
|
+
"mnemonica": "^1.0.6"
|
|
62
60
|
}
|
|
63
61
|
}
|
package/lib/plugin.d.ts
DELETED
package/lib/plugin.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const analyzer_1 = require("./analyzer");
|
|
3
|
-
const graph_1 = require("./graph");
|
|
4
|
-
const generator_1 = require("./generator");
|
|
5
|
-
const writer_1 = require("./writer");
|
|
6
|
-
let pluginInfo;
|
|
7
|
-
let typeGraph = new graph_1.TypeGraphImpl();
|
|
8
|
-
/**
|
|
9
|
-
* Initialize the plugin
|
|
10
|
-
*/
|
|
11
|
-
function init(modules) {
|
|
12
|
-
const tsModule = modules.typescript;
|
|
13
|
-
function create(info) {
|
|
14
|
-
const config = info.config || {};
|
|
15
|
-
config.outputDir = config.outputDir || '.tactica';
|
|
16
|
-
// Store plugin info
|
|
17
|
-
pluginInfo = {
|
|
18
|
-
config,
|
|
19
|
-
project: info.project,
|
|
20
|
-
serverHost: info.serverHost,
|
|
21
|
-
moduleResolver: info.project,
|
|
22
|
-
};
|
|
23
|
-
// Set up file watching
|
|
24
|
-
setupFileWatcher(info, tsModule);
|
|
25
|
-
// Initial type generation
|
|
26
|
-
generateTypes(info, tsModule);
|
|
27
|
-
// Wrap the language service to intercept requests if needed
|
|
28
|
-
const proxy = Object.create(null);
|
|
29
|
-
const oldService = info.languageService;
|
|
30
|
-
for (const key of Object.keys(oldService)) {
|
|
31
|
-
const fn = oldService[key];
|
|
32
|
-
proxy[key] = (...args) => {
|
|
33
|
-
return fn.apply(oldService, args);
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return proxy;
|
|
37
|
-
}
|
|
38
|
-
function onConfigurationChanged(config) {
|
|
39
|
-
if (pluginInfo) {
|
|
40
|
-
pluginInfo.config = { ...pluginInfo.config, ...config };
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
create,
|
|
45
|
-
onConfigurationChanged,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Set up file watching for incremental updates
|
|
50
|
-
*/
|
|
51
|
-
function setupFileWatcher(info, _tsModule) {
|
|
52
|
-
const serverHost = info.serverHost;
|
|
53
|
-
// Hook into file change notifications
|
|
54
|
-
const originalFileChanged = serverHost.fileChanged;
|
|
55
|
-
if (originalFileChanged) {
|
|
56
|
-
serverHost.fileChanged = function (...args) {
|
|
57
|
-
const result = originalFileChanged.apply(this, args);
|
|
58
|
-
// Regenerate types when files change
|
|
59
|
-
generateTypes(info, _tsModule);
|
|
60
|
-
return result;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Generate types from the project
|
|
66
|
-
*/
|
|
67
|
-
function generateTypes(info, _tsModule) {
|
|
68
|
-
try {
|
|
69
|
-
const program = info.languageService.getProgram();
|
|
70
|
-
if (!program) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const config = pluginInfo?.config || { outputDir: '.tactica' };
|
|
74
|
-
const include = config.include || ['**/*.ts'];
|
|
75
|
-
const exclude = config.exclude || ['**/*.d.ts', 'node_modules/**'];
|
|
76
|
-
// Create analyzer
|
|
77
|
-
const analyzer = new analyzer_1.MnemonicaAnalyzer(program);
|
|
78
|
-
// Clear existing graph
|
|
79
|
-
typeGraph.clear();
|
|
80
|
-
// Analyze all source files
|
|
81
|
-
for (const sourceFile of program.getSourceFiles()) {
|
|
82
|
-
// Skip declaration files and files outside the project
|
|
83
|
-
if (sourceFile.isDeclarationFile) {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const fileName = sourceFile.fileName;
|
|
87
|
-
// Check exclude patterns
|
|
88
|
-
if (exclude.some(pattern => matchesGlob(fileName, pattern))) {
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
// Check include patterns (if specified)
|
|
92
|
-
if (include.length > 0 && !include.some(pattern => matchesGlob(fileName, pattern))) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
// Analyze the file
|
|
96
|
-
analyzer.analyzeFile(sourceFile);
|
|
97
|
-
}
|
|
98
|
-
// Get the graph and generate types
|
|
99
|
-
typeGraph = analyzer.getGraph();
|
|
100
|
-
const generator = new generator_1.TypesGenerator(typeGraph);
|
|
101
|
-
const generated = generator.generateTypesFile();
|
|
102
|
-
// Write types to file
|
|
103
|
-
const writer = new writer_1.TypesWriter(config.outputDir);
|
|
104
|
-
const outputPath = writer.writeTypesFile(generated);
|
|
105
|
-
// Log success
|
|
106
|
-
if (config.verbose) {
|
|
107
|
-
info.project.projectService.logger.info(`[Tactica] Generated types at ${outputPath} (${generated.types.length} types)`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
info.project.projectService.logger.info(`[Tactica] Error generating types: ${error}`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Simple glob matching function
|
|
116
|
-
*/
|
|
117
|
-
function matchesGlob(filePath, pattern) {
|
|
118
|
-
// Convert glob pattern to regex
|
|
119
|
-
const regexPattern = pattern
|
|
120
|
-
.replace(/\*\*/g, '<<<DOUBLESTAR>>>')
|
|
121
|
-
.replace(/\*/g, '[^/]*')
|
|
122
|
-
.replace(/<<<DOUBLESTAR>>>/g, '.*')
|
|
123
|
-
.replace(/\?/g, '.');
|
|
124
|
-
const regex = new RegExp(regexPattern);
|
|
125
|
-
return regex.test(filePath);
|
|
126
|
-
}
|
|
127
|
-
module.exports = init;
|
|
128
|
-
//# sourceMappingURL=plugin.js.map
|
package/lib/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAIb,yCAA+C;AAC/C,mCAAwC;AACxC,2CAA6C;AAC7C,qCAAuC;AAgBvC,IAAI,UAAkC,CAAC;AACvC,IAAI,SAAS,GAAG,IAAI,qBAAa,EAAE,CAAC;AAEpC;;GAEG;AACH,SAAS,IAAI,CAAC,OAAkC;IAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC;IAEpC,SAAS,MAAM,CAAC,IAAgC;QAC/C,MAAM,MAAM,GAAkB,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAChD,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;QAElD,oBAAoB;QACpB,UAAU,GAAG;YACZ,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,cAAc,EAAE,IAAI,CAAC,OAAO;SAC5B,CAAC;QAEF,uBAAuB;QACvB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAEjC,0BAA0B;QAC1B,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE9B,4DAA4D;QAC5D,MAAM,KAAK,GAAuB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC;QAExC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CA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