@siyavuyachagi/typesharp 0.1.1 → 0.1.3
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/LICENSE +1 -1
- package/README.md +118 -43
- package/dist/cli/index.js +6 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/core/create-sample-config.d.ts +5 -0
- package/dist/core/create-sample-config.d.ts.map +1 -0
- package/dist/core/create-sample-config.js +110 -0
- package/dist/core/create-sample-config.js.map +1 -0
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +36 -66
- package/dist/core/index.js.map +1 -1
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +5 -4
- package/dist/generator/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/parser/index.js +12 -190
- package/dist/parser/index.js.map +1 -1
- package/dist/parser/parse-properties.d.ts +6 -0
- package/dist/parser/parse-properties.d.ts.map +1 -0
- package/dist/parser/parse-properties.js +250 -0
- package/dist/parser/parse-properties.js.map +1 -0
- package/dist/parser/resolve-project-files-from-source.d.ts +29 -0
- package/dist/parser/resolve-project-files-from-source.d.ts.map +1 -0
- package/dist/parser/resolve-project-files-from-source.js +98 -0
- package/dist/parser/resolve-project-files-from-source.js.map +1 -0
- package/dist/types/index.d.ts +7 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/naming-convention-config.d.ts +9 -0
- package/dist/types/naming-convention-config.d.ts.map +1 -0
- package/dist/types/naming-convention-config.js +3 -0
- package/dist/types/naming-convention-config.js.map +1 -0
- package/dist/types/naming-convention.d.ts +5 -0
- package/dist/types/naming-convention.d.ts.map +1 -0
- package/dist/types/naming-convention.js +3 -0
- package/dist/types/naming-convention.js.map +1 -0
- package/dist/types/typesharp-config.d.ts +18 -25
- package/dist/types/typesharp-config.d.ts.map +1 -1
- package/package.json +13 -6
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseProperties = parseProperties;
|
|
4
|
+
/**
|
|
5
|
+
* Parse properties from class body
|
|
6
|
+
*/
|
|
7
|
+
function parseProperties(classBody) {
|
|
8
|
+
const properties = [];
|
|
9
|
+
let match;
|
|
10
|
+
// Match property declarations with get/set
|
|
11
|
+
const propertyRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*\{\s*get;\s*set;\s*\}/g;
|
|
12
|
+
while ((match = propertyRegex.exec(classBody)) !== null) {
|
|
13
|
+
const type = match[1];
|
|
14
|
+
const name = match[2];
|
|
15
|
+
const tsAttrs = extractTypeSharpAttributeInfo(classBody, match.index);
|
|
16
|
+
if (tsAttrs.ignore)
|
|
17
|
+
continue;
|
|
18
|
+
const resolvedName = tsAttrs.overrideName ?? name;
|
|
19
|
+
const resolvedType = tsAttrs.overrideType ?? type;
|
|
20
|
+
const obs = extractObsoleteInfo(classBody, match.index);
|
|
21
|
+
properties.push({ ...parsePropertyType(resolvedName, resolvedType), ...obs });
|
|
22
|
+
}
|
|
23
|
+
// Also match computed/expression-bodied properties (with =>)
|
|
24
|
+
const computedPropertyRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*=>/g;
|
|
25
|
+
while ((match = computedPropertyRegex.exec(classBody)) !== null) {
|
|
26
|
+
const type = match[1];
|
|
27
|
+
const name = match[2];
|
|
28
|
+
const tsAttrs = extractTypeSharpAttributeInfo(classBody, match.index);
|
|
29
|
+
if (tsAttrs.ignore)
|
|
30
|
+
continue;
|
|
31
|
+
const resolvedName = tsAttrs.overrideName ?? name;
|
|
32
|
+
const resolvedType = tsAttrs.overrideType ?? type;
|
|
33
|
+
const obs = extractObsoleteInfo(classBody, match.index);
|
|
34
|
+
properties.push({ ...parsePropertyType(resolvedName, resolvedType), ...obs });
|
|
35
|
+
}
|
|
36
|
+
// { get { return ...; } }
|
|
37
|
+
const getBlockRegex = /public\s+([\w<>[\]?]+)\s+(\w+)\s*\{\s*get\s*\{[^}]*\}\s*\}/g;
|
|
38
|
+
while ((match = getBlockRegex.exec(classBody)) !== null) {
|
|
39
|
+
const type = match[1];
|
|
40
|
+
const name = match[2];
|
|
41
|
+
const tsAttrs = extractTypeSharpAttributeInfo(classBody, match.index);
|
|
42
|
+
if (tsAttrs.ignore)
|
|
43
|
+
continue;
|
|
44
|
+
const resolvedName = tsAttrs.overrideName ?? name;
|
|
45
|
+
const resolvedType = tsAttrs.overrideType ?? type;
|
|
46
|
+
const obs = extractObsoleteInfo(classBody, match.index);
|
|
47
|
+
properties.push({ ...parsePropertyType(resolvedName, resolvedType), ...obs });
|
|
48
|
+
}
|
|
49
|
+
return properties;
|
|
50
|
+
}
|
|
51
|
+
function extractObsoleteInfo(classBody, matchIndex) {
|
|
52
|
+
const before = classBody.substring(0, matchIndex);
|
|
53
|
+
const lines = before.split('\n');
|
|
54
|
+
// Walk backwards, only through attribute lines and whitespace
|
|
55
|
+
// Stop as soon as we hit a line that isn't an attribute or blank
|
|
56
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
57
|
+
const line = lines[i].trim();
|
|
58
|
+
if (line === '')
|
|
59
|
+
continue;
|
|
60
|
+
// If it's an attribute line, check for Obsolete
|
|
61
|
+
if (line.startsWith('[')) {
|
|
62
|
+
const obsoleteMatch = line.match(/\[Obsolete(?:Attribute)?\s*(?:\(\s*"([^"]*)"\s*(?:,\s*(?:true|false))?\s*\))?\]/i);
|
|
63
|
+
if (obsoleteMatch) {
|
|
64
|
+
return {
|
|
65
|
+
isDeprecated: true,
|
|
66
|
+
deprecationMessage: obsoleteMatch[1] ?? undefined
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// It's a different attribute — keep walking back (stacked attributes)
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
// Hit a non-attribute, non-blank line — stop looking
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return { isDeprecated: false };
|
|
76
|
+
}
|
|
77
|
+
function extractTypeSharpAttributeInfo(classBody, matchIndex) {
|
|
78
|
+
const before = classBody.substring(0, matchIndex);
|
|
79
|
+
const lines = before.split('\n');
|
|
80
|
+
let ignore = false;
|
|
81
|
+
let overrideName;
|
|
82
|
+
let overrideType;
|
|
83
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
84
|
+
const line = lines[i].trim();
|
|
85
|
+
if (line === '')
|
|
86
|
+
continue;
|
|
87
|
+
if (!line.startsWith('['))
|
|
88
|
+
break;
|
|
89
|
+
if (/\[TypeIgnore\]/.test(line))
|
|
90
|
+
ignore = true;
|
|
91
|
+
const nameMatch = line.match(/\[TypeName\s*\(\s*"([^"]+)"\s*\)\]/);
|
|
92
|
+
if (nameMatch)
|
|
93
|
+
overrideName = nameMatch[1];
|
|
94
|
+
const asMatch = line.match(/\[TypeAs\s*\(\s*"([^"]+)"\s*\)\]/);
|
|
95
|
+
if (asMatch)
|
|
96
|
+
overrideType = asMatch[1];
|
|
97
|
+
}
|
|
98
|
+
return { ignore, overrideName, overrideType };
|
|
99
|
+
}
|
|
100
|
+
function parsePropertyType(name, csType) {
|
|
101
|
+
let raw = csType.trim();
|
|
102
|
+
let isNullable = false;
|
|
103
|
+
// Extract nullable marker (T?)
|
|
104
|
+
if (raw.endsWith('?')) {
|
|
105
|
+
isNullable = true;
|
|
106
|
+
raw = raw.slice(0, -1).trim();
|
|
107
|
+
}
|
|
108
|
+
// Recursive resolver: returns { tsType, isArray }
|
|
109
|
+
function resolveType(typeText) {
|
|
110
|
+
const t = typeText.trim();
|
|
111
|
+
// 1) Array syntax: T[]
|
|
112
|
+
if (t.endsWith('[]')) {
|
|
113
|
+
const inner = t.slice(0, -2).trim();
|
|
114
|
+
const resolved = resolveType(inner);
|
|
115
|
+
// If inner is already an array, keep it as array-of-array semantics;
|
|
116
|
+
// mark as array so generator will append [] (or use resolved.tsType which may include [] already)
|
|
117
|
+
return { tsType: resolved.tsType, isArray: true };
|
|
118
|
+
}
|
|
119
|
+
// 2) Dictionary-like types (handle Dictionary, IDictionary, IReadOnlyDictionary)
|
|
120
|
+
if (/^(?:[\w\.]+\.)?(?:Dictionary|IDictionary|IReadOnlyDictionary)\s*</.test(t)) {
|
|
121
|
+
// locate first '<' and its matching '>'
|
|
122
|
+
const firstAngle = t.indexOf('<');
|
|
123
|
+
const lastAngle = findMatchingAngleBracket(t, firstAngle);
|
|
124
|
+
if (firstAngle !== -1 && lastAngle !== -1) {
|
|
125
|
+
const inner = t.slice(firstAngle + 1, lastAngle).trim();
|
|
126
|
+
const args = splitTopLevelGenericArgs(inner);
|
|
127
|
+
if (args.length === 2) {
|
|
128
|
+
const keyCs = args[0];
|
|
129
|
+
const valueCs = args[1];
|
|
130
|
+
// Guard against undefined/null/empty parts before resolving
|
|
131
|
+
if (typeof keyCs !== 'string' || typeof valueCs !== 'string' || keyCs.trim() === '' || valueCs.trim() === '') {
|
|
132
|
+
// Fallback: avoid throwing — emit a generic record
|
|
133
|
+
return { tsType: 'Record<string, any>', isArray: false };
|
|
134
|
+
}
|
|
135
|
+
const resolvedKey = resolveType(keyCs);
|
|
136
|
+
const resolvedValue = resolveType(valueCs);
|
|
137
|
+
// Normalize key to a safe TS key type: Record<K extends keyof any, V>
|
|
138
|
+
// If key is not primitive 'string' or 'number' or 'symbol', coerce to 'string'
|
|
139
|
+
const keyTsRaw = resolvedKey.tsType;
|
|
140
|
+
const safeKey = keyTsRaw === 'string' || keyTsRaw === 'number' || keyTsRaw === 'symbol'
|
|
141
|
+
? keyTsRaw
|
|
142
|
+
: 'string';
|
|
143
|
+
// Build value type (respect nested arrays)
|
|
144
|
+
const valueType = resolvedValue.isArray ? `${resolvedValue.tsType}[]` : resolvedValue.tsType;
|
|
145
|
+
return { tsType: `Record<${safeKey}, ${valueType}>`, isArray: false };
|
|
146
|
+
}
|
|
147
|
+
// else: fallthrough to other checks (malformed or >2 args) — do not falsely match
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// 3) Collections: List<T>, IEnumerable<T>, ICollection<T>, IList<T>
|
|
151
|
+
const collectionMatch = t.match(/^(?:List|IEnumerable|ICollection|IList)\s*<\s*(.+)\s*>$/);
|
|
152
|
+
if (collectionMatch) {
|
|
153
|
+
const inner = collectionMatch[1].trim();
|
|
154
|
+
const resolvedInner = resolveType(inner);
|
|
155
|
+
// Collections become inner[] in TS; mark isArray true and tsType = resolvedInner.tsType
|
|
156
|
+
// The generator will append [].
|
|
157
|
+
return { tsType: resolvedInner.tsType, isArray: true };
|
|
158
|
+
}
|
|
159
|
+
// 4) Fallback: map primitive / known types, else return as-is (class name)
|
|
160
|
+
return { tsType: mapCSharpTypeToTypeScript(t), isArray: false };
|
|
161
|
+
}
|
|
162
|
+
const resolved = resolveType(raw);
|
|
163
|
+
return {
|
|
164
|
+
name,
|
|
165
|
+
type: resolved.tsType,
|
|
166
|
+
isNullable,
|
|
167
|
+
isArray: resolved.isArray,
|
|
168
|
+
isGeneric: false,
|
|
169
|
+
genericType: undefined,
|
|
170
|
+
isDeprecated: false,
|
|
171
|
+
deprecationMessage: undefined,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Find the index of the matching '>' for the first '<' at startIdx.
|
|
176
|
+
* Returns -1 if not found.
|
|
177
|
+
*/
|
|
178
|
+
function findMatchingAngleBracket(s, startIdx) {
|
|
179
|
+
let depth = 0;
|
|
180
|
+
for (let i = startIdx; i < s.length; i++) {
|
|
181
|
+
if (s[i] === '<')
|
|
182
|
+
depth++;
|
|
183
|
+
else if (s[i] === '>') {
|
|
184
|
+
depth--;
|
|
185
|
+
if (depth === 0)
|
|
186
|
+
return i;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return -1;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Split a comma-separated generic-argument string into top-level args,
|
|
193
|
+
* i.e. respects nested <...> and does NOT split commas inside nested generics.
|
|
194
|
+
* Example: "string, List<Dictionary<string, Foo>>, int" -> ["string", "List<Dictionary<string, Foo>>", "int"]
|
|
195
|
+
*/
|
|
196
|
+
function splitTopLevelGenericArgs(s) {
|
|
197
|
+
const parts = [];
|
|
198
|
+
let depth = 0;
|
|
199
|
+
let buf = '';
|
|
200
|
+
for (let i = 0; i < s.length; i++) {
|
|
201
|
+
const ch = s[i];
|
|
202
|
+
if (ch === '<') {
|
|
203
|
+
depth++;
|
|
204
|
+
buf += ch;
|
|
205
|
+
}
|
|
206
|
+
else if (ch === '>') {
|
|
207
|
+
depth--;
|
|
208
|
+
buf += ch;
|
|
209
|
+
}
|
|
210
|
+
else if (ch === ',' && depth === 0) {
|
|
211
|
+
parts.push(buf.trim());
|
|
212
|
+
buf = '';
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
buf += ch;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (buf.trim().length > 0)
|
|
219
|
+
parts.push(buf.trim());
|
|
220
|
+
return parts;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Map C# primitive types to TypeScript types
|
|
224
|
+
*/
|
|
225
|
+
function mapCSharpTypeToTypeScript(csType) {
|
|
226
|
+
const typeMap = {
|
|
227
|
+
'bool': 'boolean',
|
|
228
|
+
'byte': 'number',
|
|
229
|
+
'byte[]': 'Blob',
|
|
230
|
+
'decimal': 'number',
|
|
231
|
+
'double': 'number',
|
|
232
|
+
'DateOnly': 'string',
|
|
233
|
+
'DateTime': 'string',
|
|
234
|
+
'float': 'number',
|
|
235
|
+
'FileStream': 'Blob',
|
|
236
|
+
'FormFile': 'File',
|
|
237
|
+
'Guid': 'string',
|
|
238
|
+
'int': 'number',
|
|
239
|
+
'IFormFile': 'File',
|
|
240
|
+
'IFormFileCollection': 'File[]',
|
|
241
|
+
'long': 'number',
|
|
242
|
+
'MemoryStream': 'Blob',
|
|
243
|
+
'object': 'any',
|
|
244
|
+
'string': 'string',
|
|
245
|
+
'Stream': 'Blob',
|
|
246
|
+
'TimeOnly': 'string',
|
|
247
|
+
};
|
|
248
|
+
return typeMap[csType] || csType;
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=parse-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-properties.js","sourceRoot":"","sources":["../../src/parser/parse-properties.ts"],"names":[],"mappings":";;AAMA,0CAsDC;AAzDD;;GAEG;AACH,SAAgB,eAAe,CAAC,SAAiB;IAC7C,MAAM,UAAU,GAAqB,EAAE,CAAC;IAExC,IAAI,KAAK,CAAC;IAEV,2CAA2C;IAC3C,MAAM,aAAa,GAAG,yDAAyD,CAAC;IAChF,OAAO,CAAC,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACvB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QAEvB,MAAM,OAAO,GAAG,6BAA6B,CAAC,SAAS,EAAE,KAAK,CAAC,KAAM,CAAC,CAAC;QACvE,IAAI,OAAO,CAAC,MAAM;YAAE,SAAS;QAE7B,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC;QAClD,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC;QAElD,MAAM,GAAG,GAAG,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,KAAM,CAAC,CAAC;QACzD,UAAU,CAAC,IAAI,CAAC,EAAE,GAAG,iBAAiB,CAAC,YAAY,EAAE,YAAY,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC;IAClF,CAAC;IAED,6DAA6D;IAC7D,MAAM,qBAAqB,GAAG,sCAAsC,CAAC;IACrE,OAAO,CAAC,KAAK,GAAG,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,K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AI,EAAE,KAAK,GAAG,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACnC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YACvB,GAAG,GAAG,EAAE,CAAC;QACb,CAAC;aAAM,CAAC;YACJ,GAAG,IAAI,EAAE,CAAC;QACd,CAAC;IACL,CAAC;IACD,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAClD,OAAO,KAAK,CAAC;AACjB,CAAC;AAID;;GAEG;AACH,SAAS,yBAAyB,CAAC,MAAc;IAC7C,MAAM,OAAO,GAA2B;QACpC,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,MAAM;QAChB,SAAS,EAAE,QAAQ;QACnB,QAAQ,EAAE,QAAQ;QAClB,UAAU,EAAE,QAAQ;QACpB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE,QAAQ;QACjB,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,MAAM;QAClB,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,MAAM;QACnB,qBAAqB,EAAE,QAAQ;QAC/B,MAAM,EAAE,QAAQ;QAChB,cAAc,EAAE,MAAM;QACtB,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EAAE,MAAM;QAChB,UAAU,EAAE,QAAQ;KACvB,CAAC;IAEF,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a list of `.csproj` file paths from one or more source entries.
|
|
3
|
+
*
|
|
4
|
+
* Supported source types:
|
|
5
|
+
* - `.csproj` — used directly
|
|
6
|
+
* - `.sln` — parsed using regex to extract referenced `.csproj` paths
|
|
7
|
+
* - `.slnx` — parsed as XML to extract `<Project Path="..." />` entries
|
|
8
|
+
*
|
|
9
|
+
* @param source - A single path or array of paths to `.csproj`, `.sln`, or `.slnx` files
|
|
10
|
+
* @returns A flat array of resolved absolute `.csproj` file paths
|
|
11
|
+
* @throws If a source file type is not `.csproj`, `.sln`, or `.slnx`
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Single solution file
|
|
15
|
+
* resolveProjectFilesFromSource('C:/MyApp/MyApp.sln');
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // XML solution file
|
|
19
|
+
* resolveProjectFilesFromSource('C:/MyApp/MyApp.slnx');
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Mixed sources
|
|
23
|
+
* resolveProjectFilesFromSource([
|
|
24
|
+
* 'C:/MyApp/MyApp.slnx',
|
|
25
|
+
* 'C:/Other/Other.csproj'
|
|
26
|
+
* ]);
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveProjectFilesFromSource(source: string | string[]): string[];
|
|
29
|
+
//# sourceMappingURL=resolve-project-files-from-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-project-files-from-source.d.ts","sourceRoot":"","sources":["../../src/parser/resolve-project-files-from-source.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,CA8BjF"}
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.resolveProjectFilesFromSource = resolveProjectFilesFromSource;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* Resolves a list of `.csproj` file paths from one or more source entries.
|
|
41
|
+
*
|
|
42
|
+
* Supported source types:
|
|
43
|
+
* - `.csproj` — used directly
|
|
44
|
+
* - `.sln` — parsed using regex to extract referenced `.csproj` paths
|
|
45
|
+
* - `.slnx` — parsed as XML to extract `<Project Path="..." />` entries
|
|
46
|
+
*
|
|
47
|
+
* @param source - A single path or array of paths to `.csproj`, `.sln`, or `.slnx` files
|
|
48
|
+
* @returns A flat array of resolved absolute `.csproj` file paths
|
|
49
|
+
* @throws If a source file type is not `.csproj`, `.sln`, or `.slnx`
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // Single solution file
|
|
53
|
+
* resolveProjectFilesFromSource('C:/MyApp/MyApp.sln');
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // XML solution file
|
|
57
|
+
* resolveProjectFilesFromSource('C:/MyApp/MyApp.slnx');
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Mixed sources
|
|
61
|
+
* resolveProjectFilesFromSource([
|
|
62
|
+
* 'C:/MyApp/MyApp.slnx',
|
|
63
|
+
* 'C:/Other/Other.csproj'
|
|
64
|
+
* ]);
|
|
65
|
+
*/
|
|
66
|
+
function resolveProjectFilesFromSource(source) {
|
|
67
|
+
const sources = Array.isArray(source) ? source : [source];
|
|
68
|
+
const csprojFiles = [];
|
|
69
|
+
for (const s of sources) {
|
|
70
|
+
if (s.endsWith('.sln')) {
|
|
71
|
+
const content = fs.readFileSync(s, 'utf-8');
|
|
72
|
+
const slnDir = path.dirname(s);
|
|
73
|
+
const matches = [...content.matchAll(/"([^"]+\.csproj)"/g)];
|
|
74
|
+
for (const match of matches) {
|
|
75
|
+
const relPath = match[1].replace(/\\/g, path.sep);
|
|
76
|
+
csprojFiles.push(path.resolve(slnDir, relPath));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (s.endsWith('.slnx')) {
|
|
80
|
+
const content = fs.readFileSync(s, 'utf-8');
|
|
81
|
+
const slnDir = path.dirname(s);
|
|
82
|
+
const matches = [...content.matchAll(/<Project\s+Path="([^"]+\.csproj)"\s*\/>/g)];
|
|
83
|
+
for (const match of matches) {
|
|
84
|
+
const relPath = match[1].replace(/\\/g, path.sep);
|
|
85
|
+
csprojFiles.push(path.resolve(slnDir, relPath));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (s.endsWith('.csproj')) {
|
|
89
|
+
csprojFiles.push(s);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw new Error(`Unsupported source file type: "${path.basename(s)}". Expected .csproj, .sln, or .slnx`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
console.log('csproj files', csprojFiles);
|
|
96
|
+
return csprojFiles;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=resolve-project-files-from-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-project-files-from-source.js","sourceRoot":"","sources":["../../src/parser/resolve-project-files-from-source.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,sEA8BC;AA5DD,uCAAyB;AACzB,2CAA6B;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,6BAA6B,CAAC,MAAyB;IACnE,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACrB,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,OAAO,GAAG,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAC5D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;gBACnD,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;YACpD,CAAC;QACL,CAAC;aAAM,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;YAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,OAAO,GAAG,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,0CAA0C,CAAC,CAAC,CAAC;YAClF,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;gBACnD,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;YACpD,CAAC;QACL,CAAC;aAAM,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC;aAAM,CAAC;YACJ,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,qCAAqC,CAAC,CAAC;QAC7G,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;IACxC,OAAO,WAAW,CAAC;AACvB,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { NamingConvention
|
|
1
|
+
import { NamingConvention } from "./naming-convention";
|
|
2
|
+
import { NamingConventionConfig } from "./naming-convention-config";
|
|
2
3
|
import { TypeSharpConfig } from "./typesharp-config";
|
|
3
4
|
/**
|
|
4
5
|
* Parsed C# property
|
|
@@ -9,6 +10,10 @@ export interface CSharpProperty {
|
|
|
9
10
|
isNullable: boolean;
|
|
10
11
|
isArray: boolean;
|
|
11
12
|
isGeneric: boolean;
|
|
13
|
+
/** Whether the property is marked as obsolete/deprecated */
|
|
14
|
+
isDeprecated: boolean;
|
|
15
|
+
/** Optional message from [Obsolete("...")] */
|
|
16
|
+
deprecationMessage?: string;
|
|
12
17
|
genericType?: string;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
@@ -39,6 +44,6 @@ export interface GenerationOptions {
|
|
|
39
44
|
classes: CSharpClass[];
|
|
40
45
|
}
|
|
41
46
|
export type { TypeSharpConfig };
|
|
42
|
-
export type { NamingConvention };
|
|
43
47
|
export type { NamingConventionConfig };
|
|
48
|
+
export type { NamingConvention };
|
|
44
49
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,4DAA4D;IAC5D,YAAY,EAAE,OAAO,CAAC;IACtB,8CAA8C;IAC9C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAGD,YAAY,EAAE,eAAe,EAAE,CAAA;AAC/B,YAAY,EAAE,sBAAsB,EAAE,CAAA;AACtC,YAAY,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NamingConvention } from "./naming-convention";
|
|
2
|
+
/**
|
|
3
|
+
* More specific naming convension configuration
|
|
4
|
+
*/
|
|
5
|
+
export type NamingConventionConfig = {
|
|
6
|
+
file: NamingConvention;
|
|
7
|
+
dir: NamingConvention;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=naming-convention-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming-convention-config.d.ts","sourceRoot":"","sources":["../../src/types/naming-convention-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,GAAG,EAAE,gBAAgB,CAAC;CACzB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming-convention-config.js","sourceRoot":"","sources":["../../src/types/naming-convention-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming-convention.d.ts","sourceRoot":"","sources":["../../src/types/naming-convention.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming-convention.js","sourceRoot":"","sources":["../../src/types/naming-convention.ts"],"names":[],"mappings":""}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
+
import { NamingConvention } from "./naming-convention";
|
|
2
|
+
import { NamingConventionConfig } from "./naming-convention-config";
|
|
1
3
|
/**
|
|
2
|
-
* TypeSharp configuration
|
|
4
|
+
* TypeSharp configuration file
|
|
3
5
|
* @see https://github.com/siyavuyachagi/typesharp
|
|
4
6
|
*/
|
|
5
7
|
export interface TypeSharpConfig {
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Path(s) to C# source(s): `.csproj` file(s) or a `.sln` solution file.
|
|
10
|
+
* When a `.sln` is provided, TypeSharp automatically discovers all projects within it.
|
|
11
|
+
*
|
|
12
|
+
* Replaces the deprecated `projectFiles` option.
|
|
13
|
+
* @example
|
|
14
|
+
* source: "C:/MyApp/MyApp.sln"
|
|
12
15
|
* // or
|
|
13
|
-
* [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
16
|
+
* source: ["C:/MyApp/Api/Api.csproj", "C:/MyApp/Domain/Domain.csproj"]
|
|
17
|
+
*/
|
|
18
|
+
source: string | string[];
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `source` instead. Will be removed in a future version.
|
|
21
|
+
* @see source
|
|
18
22
|
*/
|
|
19
|
-
projectFiles
|
|
23
|
+
projectFiles?: string | string[];
|
|
20
24
|
/**
|
|
21
25
|
* Path where TypeScript files will be generated
|
|
22
26
|
*/
|
|
@@ -26,7 +30,7 @@ export interface TypeSharpConfig {
|
|
|
26
30
|
*/
|
|
27
31
|
targetAnnotation?: string;
|
|
28
32
|
/**
|
|
29
|
-
* Controls whether generated types are written to one file or multiple files.
|
|
33
|
+
* Controls whether generated types are written to one file or multiple files. (default: `false`)
|
|
30
34
|
*
|
|
31
35
|
* - true → All generated types go into a single file: "index.ts"
|
|
32
36
|
* - false → Each file is written separately, using the naming convention.
|
|
@@ -34,7 +38,7 @@ export interface TypeSharpConfig {
|
|
|
34
38
|
*/
|
|
35
39
|
singleOutputFile?: boolean;
|
|
36
40
|
/**
|
|
37
|
-
* Naming convention for property names in generated types
|
|
41
|
+
* Naming convention for property names in generated types (default: `camel`)
|
|
38
42
|
* @example
|
|
39
43
|
* "namingConvention": "camel",
|
|
40
44
|
* // or
|
|
@@ -57,15 +61,4 @@ export interface TypeSharpConfig {
|
|
|
57
61
|
*/
|
|
58
62
|
fileSuffix?: string;
|
|
59
63
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Naming convention options for path, file and property names
|
|
62
|
-
*/
|
|
63
|
-
export type NamingConvention = 'kebab' | 'snake' | 'camel' | 'pascal';
|
|
64
|
-
/**
|
|
65
|
-
* More specific naming convension configuration
|
|
66
|
-
*/
|
|
67
|
-
export type NamingConventionConfig = {
|
|
68
|
-
file: NamingConvention;
|
|
69
|
-
dir: NamingConvention;
|
|
70
|
-
};
|
|
71
64
|
//# sourceMappingURL=typesharp-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesharp-config.d.ts","sourceRoot":"","sources":["../../src/types/typesharp-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAE5B
|
|
1
|
+
{"version":3,"file":"typesharp-config.d.ts","sourceRoot":"","sources":["../../src/types/typesharp-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE;;;GAGG;AACH,MAAM,WAAW,eAAe;IAE5B;;;;;;;;;OASG;IACH,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE1B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEjC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAO3B;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,sBAAsB,CAAC;IAE7D;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siyavuyachagi/typesharp",
|
|
3
3
|
"description": "Generate TypeScript types from C# models with TypeSharp attribute",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Siyavuya Chagi <syavuya08@gmail.com>",
|
|
7
7
|
"repository": {
|
|
@@ -22,20 +22,27 @@
|
|
|
22
22
|
"LICENSE"
|
|
23
23
|
],
|
|
24
24
|
"keywords": [
|
|
25
|
-
"
|
|
26
|
-
"csharp",
|
|
25
|
+
"cli",
|
|
27
26
|
"code-generation",
|
|
28
|
-
"
|
|
27
|
+
"csharp",
|
|
28
|
+
"type-sharp",
|
|
29
|
+
"types",
|
|
30
|
+
"typescript"
|
|
29
31
|
],
|
|
30
32
|
"scripts": {
|
|
31
33
|
"build": "tsc",
|
|
32
34
|
"dev": "tsc --watch",
|
|
33
35
|
"prepublishOnly": "npm run build",
|
|
34
|
-
"test": "
|
|
36
|
+
"test": "vitest",
|
|
37
|
+
"test:run": "vitest run",
|
|
38
|
+
"test:ui": "npx vitest --ui"
|
|
35
39
|
},
|
|
36
40
|
"devDependencies": {
|
|
37
41
|
"@types/node": "^25.0.0",
|
|
38
|
-
"
|
|
42
|
+
"@vitest/ui": "^4.0.18",
|
|
43
|
+
"tsx": "^4.21.0",
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
|
+
"vitest": "^4.0.18"
|
|
39
46
|
},
|
|
40
47
|
"dependencies": {
|
|
41
48
|
"chalk": "^5.6.2",
|