@tsonic/backend 0.0.1 → 0.0.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/dist/.tsbuildinfo +1 -0
- package/dist/build-orchestrator.d.ts +9 -0
- package/dist/build-orchestrator.d.ts.map +1 -0
- package/dist/build-orchestrator.js +170 -0
- package/dist/build-orchestrator.js.map +1 -0
- package/dist/dotnet.d.ts +17 -0
- package/dist/dotnet.d.ts.map +1 -0
- package/dist/dotnet.js +85 -0
- package/dist/dotnet.js.map +1 -0
- package/dist/dotnet.test.d.ts +5 -0
- package/dist/dotnet.test.d.ts.map +1 -0
- package/dist/dotnet.test.js +46 -0
- package/dist/dotnet.test.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/index.ts → dist/index.js} +1 -19
- package/dist/index.js.map +1 -0
- package/dist/program-generator.d.ts +9 -0
- package/dist/program-generator.d.ts.map +1 -0
- package/dist/program-generator.js +27 -0
- package/dist/program-generator.js.map +1 -0
- package/dist/program-generator.test.d.ts +5 -0
- package/dist/program-generator.test.d.ts.map +1 -0
- package/dist/program-generator.test.js +53 -0
- package/dist/program-generator.test.js.map +1 -0
- package/dist/project-generator.d.ts +18 -0
- package/dist/project-generator.d.ts.map +1 -0
- package/dist/project-generator.js +182 -0
- package/dist/project-generator.js.map +1 -0
- package/dist/project-generator.test.d.ts +5 -0
- package/dist/project-generator.test.d.ts.map +1 -0
- package/dist/project-generator.test.js +103 -0
- package/dist/project-generator.test.js.map +1 -0
- package/dist/types.d.ts +133 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +6 -3
- package/src/build-orchestrator.ts +0 -215
- package/src/dotnet.test.ts +0 -50
- package/src/dotnet.ts +0 -101
- package/src/program-generator.test.ts +0 -63
- package/src/program-generator.ts +0 -33
- package/src/project-generator.test.ts +0 -130
- package/src/project-generator.ts +0 -245
- package/src/types.ts +0 -150
- package/tsconfig.json +0 -14
package/src/project-generator.ts
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .csproj file generation for multiple output types
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
BuildConfig,
|
|
7
|
-
NuGetPackage,
|
|
8
|
-
OutputConfig,
|
|
9
|
-
ExecutableConfig,
|
|
10
|
-
LibraryConfig,
|
|
11
|
-
ConsoleAppConfig,
|
|
12
|
-
PackageMetadata,
|
|
13
|
-
AssemblyReference,
|
|
14
|
-
} from "./types.js";
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generate package references XML
|
|
18
|
-
*/
|
|
19
|
-
const formatPackageReferences = (packages: readonly NuGetPackage[]): string => {
|
|
20
|
-
if (packages.length === 0) {
|
|
21
|
-
return "";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const refs = packages
|
|
25
|
-
.map(
|
|
26
|
-
(pkg) =>
|
|
27
|
-
` <PackageReference Include="${pkg.name}" Version="${pkg.version}" />`
|
|
28
|
-
)
|
|
29
|
-
.join("\n");
|
|
30
|
-
|
|
31
|
-
return `
|
|
32
|
-
<ItemGroup>
|
|
33
|
-
${refs}
|
|
34
|
-
</ItemGroup>`;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Generate assembly references XML (for DLL files)
|
|
39
|
-
*/
|
|
40
|
-
const formatAssemblyReferences = (
|
|
41
|
-
refs: readonly AssemblyReference[]
|
|
42
|
-
): string => {
|
|
43
|
-
if (refs.length === 0) {
|
|
44
|
-
return "";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const refElements = refs
|
|
48
|
-
.map(
|
|
49
|
-
(ref) =>
|
|
50
|
-
` <Reference Include="${ref.name}">
|
|
51
|
-
<HintPath>${ref.hintPath}</HintPath>
|
|
52
|
-
</Reference>`
|
|
53
|
-
)
|
|
54
|
-
.join("\n");
|
|
55
|
-
|
|
56
|
-
return `
|
|
57
|
-
<ItemGroup>
|
|
58
|
-
${refElements}
|
|
59
|
-
</ItemGroup>`;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Capitalize first letter
|
|
64
|
-
*/
|
|
65
|
-
const capitalizeFirst = (str: string): string => {
|
|
66
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Generate NuGet package metadata properties
|
|
71
|
-
*/
|
|
72
|
-
const generatePackageMetadata = (metadata: PackageMetadata): string => {
|
|
73
|
-
const authors = metadata.authors.join(";");
|
|
74
|
-
const tags = metadata.tags?.join(";") || "";
|
|
75
|
-
|
|
76
|
-
return `
|
|
77
|
-
<PackageId>${metadata.id}</PackageId>
|
|
78
|
-
<Version>${metadata.version}</Version>
|
|
79
|
-
<Authors>${authors}</Authors>
|
|
80
|
-
<Description>${metadata.description}</Description>${metadata.projectUrl ? `\n <PackageProjectUrl>${metadata.projectUrl}</PackageProjectUrl>` : ""}${metadata.license ? `\n <PackageLicenseExpression>${metadata.license}</PackageLicenseExpression>` : ""}${tags ? `\n <PackageTags>${tags}</PackageTags>` : ""}`;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Generate property group for executable output
|
|
85
|
-
*/
|
|
86
|
-
const generateExecutableProperties = (
|
|
87
|
-
config: BuildConfig,
|
|
88
|
-
execConfig: ExecutableConfig
|
|
89
|
-
): string => {
|
|
90
|
-
const nativeAotSettings = execConfig.nativeAot
|
|
91
|
-
? `
|
|
92
|
-
<!-- NativeAOT settings -->
|
|
93
|
-
<PublishAot>true</PublishAot>
|
|
94
|
-
<PublishSingleFile>${execConfig.singleFile}</PublishSingleFile>
|
|
95
|
-
<PublishTrimmed>${execConfig.trimmed}</PublishTrimmed>
|
|
96
|
-
<InvariantGlobalization>${execConfig.invariantGlobalization}</InvariantGlobalization>
|
|
97
|
-
<StripSymbols>${execConfig.stripSymbols}</StripSymbols>
|
|
98
|
-
|
|
99
|
-
<!-- Optimization -->
|
|
100
|
-
<OptimizationPreference>${capitalizeFirst(execConfig.optimization)}</OptimizationPreference>
|
|
101
|
-
<IlcOptimizationPreference>${capitalizeFirst(execConfig.optimization)}</IlcOptimizationPreference>`
|
|
102
|
-
: `
|
|
103
|
-
<PublishSingleFile>${execConfig.singleFile}</PublishSingleFile>
|
|
104
|
-
<SelfContained>${execConfig.selfContained}</SelfContained>`;
|
|
105
|
-
|
|
106
|
-
return ` <PropertyGroup>
|
|
107
|
-
<OutputType>Exe</OutputType>
|
|
108
|
-
<TargetFramework>${config.dotnetVersion}</TargetFramework>
|
|
109
|
-
<RootNamespace>${config.rootNamespace}</RootNamespace>
|
|
110
|
-
<AssemblyName>${config.outputName}</AssemblyName>
|
|
111
|
-
<Nullable>enable</Nullable>
|
|
112
|
-
<ImplicitUsings>false</ImplicitUsings>${nativeAotSettings}
|
|
113
|
-
</PropertyGroup>`;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Generate property group for library output
|
|
118
|
-
*/
|
|
119
|
-
const generateLibraryProperties = (
|
|
120
|
-
config: BuildConfig,
|
|
121
|
-
libConfig: LibraryConfig
|
|
122
|
-
): string => {
|
|
123
|
-
const targetFrameworks = libConfig.targetFrameworks.join(";");
|
|
124
|
-
const isMultiTarget = libConfig.targetFrameworks.length > 1;
|
|
125
|
-
const targetProp = isMultiTarget
|
|
126
|
-
? `<TargetFrameworks>${targetFrameworks}</TargetFrameworks>`
|
|
127
|
-
: `<TargetFramework>${libConfig.targetFrameworks[0]}</TargetFramework>`;
|
|
128
|
-
|
|
129
|
-
const docSettings = libConfig.generateDocumentation
|
|
130
|
-
? `
|
|
131
|
-
<GenerateDocumentationFile>true</GenerateDocumentationFile>`
|
|
132
|
-
: "";
|
|
133
|
-
|
|
134
|
-
const symbolSettings = libConfig.includeSymbols
|
|
135
|
-
? `
|
|
136
|
-
<DebugType>embedded</DebugType>
|
|
137
|
-
<DebugSymbols>true</DebugSymbols>`
|
|
138
|
-
: `
|
|
139
|
-
<DebugType>none</DebugType>`;
|
|
140
|
-
|
|
141
|
-
const packageSettings =
|
|
142
|
-
libConfig.packable && libConfig.packageMetadata
|
|
143
|
-
? generatePackageMetadata(libConfig.packageMetadata)
|
|
144
|
-
: "";
|
|
145
|
-
|
|
146
|
-
return ` <PropertyGroup>
|
|
147
|
-
<OutputType>Library</OutputType>
|
|
148
|
-
${targetProp}
|
|
149
|
-
<RootNamespace>${config.rootNamespace}</RootNamespace>
|
|
150
|
-
<AssemblyName>${config.outputName}</AssemblyName>
|
|
151
|
-
<Nullable>enable</Nullable>
|
|
152
|
-
<ImplicitUsings>false</ImplicitUsings>${docSettings}${symbolSettings}
|
|
153
|
-
<IsPackable>${libConfig.packable}</IsPackable>${packageSettings}
|
|
154
|
-
</PropertyGroup>`;
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Generate property group for console app output
|
|
159
|
-
*/
|
|
160
|
-
const generateConsoleAppProperties = (
|
|
161
|
-
config: BuildConfig,
|
|
162
|
-
consoleConfig: ConsoleAppConfig
|
|
163
|
-
): string => {
|
|
164
|
-
return ` <PropertyGroup>
|
|
165
|
-
<OutputType>Exe</OutputType>
|
|
166
|
-
<TargetFramework>${consoleConfig.targetFramework}</TargetFramework>
|
|
167
|
-
<RootNamespace>${config.rootNamespace}</RootNamespace>
|
|
168
|
-
<AssemblyName>${config.outputName}</AssemblyName>
|
|
169
|
-
<Nullable>enable</Nullable>
|
|
170
|
-
<ImplicitUsings>false</ImplicitUsings>
|
|
171
|
-
<PublishSingleFile>${consoleConfig.singleFile}</PublishSingleFile>
|
|
172
|
-
<SelfContained>${consoleConfig.selfContained}</SelfContained>
|
|
173
|
-
</PropertyGroup>`;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Generate property group based on output type
|
|
178
|
-
*/
|
|
179
|
-
const generatePropertyGroup = (
|
|
180
|
-
config: BuildConfig,
|
|
181
|
-
outputConfig: OutputConfig
|
|
182
|
-
): string => {
|
|
183
|
-
switch (outputConfig.type) {
|
|
184
|
-
case "executable":
|
|
185
|
-
return generateExecutableProperties(config, outputConfig);
|
|
186
|
-
case "library":
|
|
187
|
-
return generateLibraryProperties(config, outputConfig);
|
|
188
|
-
case "console-app":
|
|
189
|
-
return generateConsoleAppProperties(config, outputConfig);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Generate complete .csproj file content
|
|
195
|
-
*/
|
|
196
|
-
export const generateCsproj = (config: BuildConfig): string => {
|
|
197
|
-
const packageRefs = formatPackageReferences(config.packages);
|
|
198
|
-
const assemblyRefs = formatAssemblyReferences(
|
|
199
|
-
config.assemblyReferences ?? []
|
|
200
|
-
);
|
|
201
|
-
const runtimeRef = config.runtimePath
|
|
202
|
-
? `
|
|
203
|
-
<ItemGroup>
|
|
204
|
-
<ProjectReference Include="${config.runtimePath}" />
|
|
205
|
-
</ItemGroup>`
|
|
206
|
-
: "";
|
|
207
|
-
|
|
208
|
-
const propertyGroup = generatePropertyGroup(config, config.outputConfig);
|
|
209
|
-
|
|
210
|
-
return `<Project Sdk="Microsoft.NET.Sdk">
|
|
211
|
-
${propertyGroup}${packageRefs}${assemblyRefs}${runtimeRef}
|
|
212
|
-
</Project>
|
|
213
|
-
`;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Legacy function for backward compatibility
|
|
218
|
-
* @deprecated Use generateCsproj with outputConfig instead
|
|
219
|
-
*/
|
|
220
|
-
export const generateCsprojLegacy = (
|
|
221
|
-
config: BuildConfig & {
|
|
222
|
-
invariantGlobalization?: boolean;
|
|
223
|
-
stripSymbols?: boolean;
|
|
224
|
-
optimizationPreference?: "Size" | "Speed";
|
|
225
|
-
}
|
|
226
|
-
): string => {
|
|
227
|
-
// Convert legacy config to new format
|
|
228
|
-
const execConfig: ExecutableConfig = {
|
|
229
|
-
type: "executable",
|
|
230
|
-
nativeAot: true,
|
|
231
|
-
singleFile: true,
|
|
232
|
-
trimmed: true,
|
|
233
|
-
stripSymbols: config.stripSymbols ?? true,
|
|
234
|
-
optimization: config.optimizationPreference ?? "Speed",
|
|
235
|
-
invariantGlobalization: config.invariantGlobalization ?? true,
|
|
236
|
-
selfContained: true,
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
const newConfig: BuildConfig = {
|
|
240
|
-
...config,
|
|
241
|
-
outputConfig: execConfig,
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
return generateCsproj(newConfig);
|
|
245
|
-
};
|
package/src/types.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for backend build process
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* NuGet package reference
|
|
7
|
-
*/
|
|
8
|
-
export type NuGetPackage = {
|
|
9
|
-
readonly name: string;
|
|
10
|
-
readonly version: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Output type taxonomy
|
|
15
|
-
*/
|
|
16
|
-
export type OutputType = "executable" | "library" | "console-app";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* NuGet package metadata for libraries
|
|
20
|
-
*/
|
|
21
|
-
export type PackageMetadata = {
|
|
22
|
-
readonly id: string;
|
|
23
|
-
readonly version: string;
|
|
24
|
-
readonly authors: readonly string[];
|
|
25
|
-
readonly description: string;
|
|
26
|
-
readonly projectUrl?: string;
|
|
27
|
-
readonly license?: string;
|
|
28
|
-
readonly tags?: readonly string[];
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Executable-specific configuration
|
|
33
|
-
*/
|
|
34
|
-
export type ExecutableConfig = {
|
|
35
|
-
readonly type: "executable";
|
|
36
|
-
readonly nativeAot: boolean;
|
|
37
|
-
readonly singleFile: boolean;
|
|
38
|
-
readonly trimmed: boolean;
|
|
39
|
-
readonly stripSymbols: boolean;
|
|
40
|
-
readonly optimization: "Size" | "Speed";
|
|
41
|
-
readonly invariantGlobalization: boolean;
|
|
42
|
-
readonly selfContained: boolean;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Library-specific configuration
|
|
47
|
-
*/
|
|
48
|
-
export type LibraryConfig = {
|
|
49
|
-
readonly type: "library";
|
|
50
|
-
readonly targetFrameworks: readonly string[];
|
|
51
|
-
readonly generateDocumentation: boolean;
|
|
52
|
-
readonly includeSymbols: boolean;
|
|
53
|
-
readonly packable: boolean;
|
|
54
|
-
readonly packageMetadata?: PackageMetadata;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Console app configuration (non-NativeAOT)
|
|
59
|
-
*/
|
|
60
|
-
export type ConsoleAppConfig = {
|
|
61
|
-
readonly type: "console-app";
|
|
62
|
-
readonly selfContained: boolean;
|
|
63
|
-
readonly singleFile: boolean;
|
|
64
|
-
readonly targetFramework: string;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Output configuration union type
|
|
69
|
-
*/
|
|
70
|
-
export type OutputConfig = ExecutableConfig | LibraryConfig | ConsoleAppConfig;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Assembly reference (for DLL files)
|
|
74
|
-
*/
|
|
75
|
-
export type AssemblyReference = {
|
|
76
|
-
readonly name: string;
|
|
77
|
-
readonly hintPath: string;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Build configuration options
|
|
82
|
-
*/
|
|
83
|
-
export type BuildConfig = {
|
|
84
|
-
readonly rootNamespace: string;
|
|
85
|
-
readonly outputName: string;
|
|
86
|
-
readonly dotnetVersion: string;
|
|
87
|
-
readonly runtimePath?: string;
|
|
88
|
-
readonly assemblyReferences?: readonly AssemblyReference[];
|
|
89
|
-
readonly packages: readonly NuGetPackage[];
|
|
90
|
-
readonly outputConfig: OutputConfig;
|
|
91
|
-
// Legacy fields for backward compatibility
|
|
92
|
-
readonly invariantGlobalization?: boolean;
|
|
93
|
-
readonly stripSymbols?: boolean;
|
|
94
|
-
readonly optimizationPreference?: "Size" | "Speed";
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Entry point information
|
|
99
|
-
*/
|
|
100
|
-
export type EntryInfo = {
|
|
101
|
-
readonly namespace: string;
|
|
102
|
-
readonly className: string;
|
|
103
|
-
readonly methodName: string;
|
|
104
|
-
readonly isAsync: boolean;
|
|
105
|
-
readonly needsProgram: boolean;
|
|
106
|
-
readonly runtime?: "js" | "dotnet";
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Build options passed to buildNativeAot
|
|
111
|
-
*/
|
|
112
|
-
export type BuildOptions = {
|
|
113
|
-
readonly namespace: string;
|
|
114
|
-
readonly outputName?: string;
|
|
115
|
-
readonly dotnetVersion?: string;
|
|
116
|
-
readonly rid?: string;
|
|
117
|
-
readonly keepTemp?: boolean;
|
|
118
|
-
readonly stripSymbols?: boolean;
|
|
119
|
-
readonly optimizationPreference?: "Size" | "Speed";
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Result of the build process
|
|
124
|
-
*/
|
|
125
|
-
export type BuildResult =
|
|
126
|
-
| {
|
|
127
|
-
readonly ok: true;
|
|
128
|
-
readonly outputPath: string;
|
|
129
|
-
readonly buildDir: string;
|
|
130
|
-
}
|
|
131
|
-
| {
|
|
132
|
-
readonly ok: false;
|
|
133
|
-
readonly error: string;
|
|
134
|
-
readonly buildDir?: string;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Dotnet execution result
|
|
139
|
-
*/
|
|
140
|
-
export type DotnetResult =
|
|
141
|
-
| {
|
|
142
|
-
readonly ok: true;
|
|
143
|
-
readonly stdout: string;
|
|
144
|
-
}
|
|
145
|
-
| {
|
|
146
|
-
readonly ok: false;
|
|
147
|
-
readonly error: string;
|
|
148
|
-
readonly stdout?: string;
|
|
149
|
-
readonly stderr?: string;
|
|
150
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "./dist",
|
|
5
|
-
"rootDir": "./src",
|
|
6
|
-
"composite": true,
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"declarationMap": true,
|
|
9
|
-
"tsBuildInfoFile": "./dist/.tsbuildinfo"
|
|
10
|
-
},
|
|
11
|
-
"include": ["src/**/*.ts"],
|
|
12
|
-
"exclude": ["node_modules", "dist"],
|
|
13
|
-
"references": [{ "path": "../frontend" }, { "path": "../emitter" }]
|
|
14
|
-
}
|