tsonic 0.0.1 → 0.0.12
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 +21 -0
- package/bin.js +17 -0
- package/package.json +16 -29
- package/dist/cli/constants.d.ts +0 -5
- package/dist/cli/constants.d.ts.map +0 -1
- package/dist/cli/constants.js +0 -5
- package/dist/cli/constants.js.map +0 -1
- package/dist/cli/dispatcher.d.ts +0 -8
- package/dist/cli/dispatcher.d.ts.map +0 -1
- package/dist/cli/dispatcher.js +0 -98
- package/dist/cli/dispatcher.js.map +0 -1
- package/dist/cli/help.d.ts +0 -8
- package/dist/cli/help.d.ts.map +0 -1
- package/dist/cli/help.js +0 -48
- package/dist/cli/help.js.map +0 -1
- package/dist/cli/index.d.ts +0 -8
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -8
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/parser.d.ts +0 -14
- package/dist/cli/parser.d.ts.map +0 -1
- package/dist/cli/parser.js +0 -94
- package/dist/cli/parser.js.map +0 -1
- package/dist/cli/parser.test.d.ts +0 -5
- package/dist/cli/parser.test.d.ts.map +0 -1
- package/dist/cli/parser.test.js +0 -221
- package/dist/cli/parser.test.js.map +0 -1
- package/dist/cli.d.ts +0 -6
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -6
- package/dist/cli.js.map +0 -1
- package/dist/commands/build.d.ts +0 -11
- package/dist/commands/build.d.ts.map +0 -1
- package/dist/commands/build.js +0 -99
- package/dist/commands/build.js.map +0 -1
- package/dist/commands/emit.d.ts +0 -12
- package/dist/commands/emit.d.ts.map +0 -1
- package/dist/commands/emit.js +0 -170
- package/dist/commands/emit.js.map +0 -1
- package/dist/commands/init.d.ts +0 -14
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -217
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/run.d.ts +0 -11
- package/dist/commands/run.d.ts.map +0 -1
- package/dist/commands/run.js +0 -40
- package/dist/commands/run.js.map +0 -1
- package/dist/config.d.ts +0 -17
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -84
- package/dist/config.js.map +0 -1
- package/dist/config.test.d.ts +0 -5
- package/dist/config.test.d.ts.map +0 -1
- package/dist/config.test.js +0 -274
- package/dist/config.test.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -20
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts +0 -74
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
- package/src/cli/constants.ts +0 -5
- package/src/cli/dispatcher.ts +0 -115
- package/src/cli/help.ts +0 -49
- package/src/cli/index.ts +0 -8
- package/src/cli/parser.test.ts +0 -259
- package/src/cli/parser.ts +0 -109
- package/src/cli.ts +0 -6
- package/src/commands/build.ts +0 -125
- package/src/commands/emit.ts +0 -222
- package/src/commands/init.ts +0 -272
- package/src/commands/run.ts +0 -51
- package/src/config.test.ts +0 -328
- package/src/config.ts +0 -105
- package/src/index.ts +0 -23
- package/src/types.ts +0 -74
- package/tsconfig.json +0 -18
package/dist/commands/init.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tsonic project init command
|
|
3
|
-
*/
|
|
4
|
-
import { writeFileSync, existsSync, readFileSync, mkdirSync } from "node:fs";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import { spawnSync } from "node:child_process";
|
|
7
|
-
const DEFAULT_GITIGNORE = `# .NET build artifacts
|
|
8
|
-
generated/bin/
|
|
9
|
-
generated/obj/
|
|
10
|
-
|
|
11
|
-
# Optional: Uncomment to ignore generated C# files
|
|
12
|
-
# generated/**/*.cs
|
|
13
|
-
|
|
14
|
-
# Output executables
|
|
15
|
-
*.exe
|
|
16
|
-
app
|
|
17
|
-
|
|
18
|
-
# Dependencies
|
|
19
|
-
node_modules/
|
|
20
|
-
`;
|
|
21
|
-
const SAMPLE_MAIN_TS = `import { Console } from "System";
|
|
22
|
-
import { File } from "System.IO";
|
|
23
|
-
|
|
24
|
-
export function main(): void {
|
|
25
|
-
Console.WriteLine("Reading README.md...");
|
|
26
|
-
const content = File.ReadAllText("./README.md");
|
|
27
|
-
Console.WriteLine(content);
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
30
|
-
const SAMPLE_README = `# My Tsonic Project
|
|
31
|
-
|
|
32
|
-
This is a sample Tsonic project that demonstrates .NET interop.
|
|
33
|
-
|
|
34
|
-
## Getting Started
|
|
35
|
-
|
|
36
|
-
Build and run the project:
|
|
37
|
-
|
|
38
|
-
\`\`\`bash
|
|
39
|
-
npm run build
|
|
40
|
-
./app
|
|
41
|
-
\`\`\`
|
|
42
|
-
|
|
43
|
-
Or run directly:
|
|
44
|
-
|
|
45
|
-
\`\`\`bash
|
|
46
|
-
npm run dev
|
|
47
|
-
\`\`\`
|
|
48
|
-
|
|
49
|
-
## Project Structure
|
|
50
|
-
|
|
51
|
-
- \`src/main.ts\` - Entry point
|
|
52
|
-
- \`tsonic.json\` - Project configuration
|
|
53
|
-
- \`generated/\` - Generated C# code (gitignored)
|
|
54
|
-
`;
|
|
55
|
-
/**
|
|
56
|
-
* Generate tsonic.json config
|
|
57
|
-
*/
|
|
58
|
-
const generateConfig = (includeTypeRoots) => {
|
|
59
|
-
const config = {
|
|
60
|
-
$schema: "https://tsonic.dev/schema/v1.json",
|
|
61
|
-
rootNamespace: "MyApp",
|
|
62
|
-
entryPoint: "src/main.ts",
|
|
63
|
-
sourceRoot: "src",
|
|
64
|
-
outputDirectory: "generated",
|
|
65
|
-
outputName: "app",
|
|
66
|
-
optimize: "speed",
|
|
67
|
-
packages: [],
|
|
68
|
-
buildOptions: {
|
|
69
|
-
stripSymbols: true,
|
|
70
|
-
invariantGlobalization: true,
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
if (includeTypeRoots) {
|
|
74
|
-
config.dotnet = {
|
|
75
|
-
typeRoots: ["node_modules/@tsonic/dotnet-types/types"],
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return JSON.stringify(config, null, 2) + "\n";
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Create or update package.json with scripts and metadata
|
|
82
|
-
*/
|
|
83
|
-
const createOrUpdatePackageJson = (packageJsonPath) => {
|
|
84
|
-
let packageJson;
|
|
85
|
-
if (existsSync(packageJsonPath)) {
|
|
86
|
-
// Merge with existing package.json
|
|
87
|
-
const existing = readFileSync(packageJsonPath, "utf-8");
|
|
88
|
-
packageJson = JSON.parse(existing);
|
|
89
|
-
// Ensure required fields exist
|
|
90
|
-
if (!packageJson.name) {
|
|
91
|
-
packageJson.name = "my-tsonic-app";
|
|
92
|
-
}
|
|
93
|
-
if (!packageJson.version) {
|
|
94
|
-
packageJson.version = "1.0.0";
|
|
95
|
-
}
|
|
96
|
-
if (!packageJson.type) {
|
|
97
|
-
packageJson.type = "module";
|
|
98
|
-
}
|
|
99
|
-
// Merge scripts
|
|
100
|
-
const existingScripts = packageJson.scripts || {};
|
|
101
|
-
packageJson.scripts = {
|
|
102
|
-
...existingScripts,
|
|
103
|
-
build: "tsonic build src/main.ts",
|
|
104
|
-
dev: "tsonic run src/main.ts",
|
|
105
|
-
};
|
|
106
|
-
// Ensure devDependencies exists
|
|
107
|
-
if (!packageJson.devDependencies) {
|
|
108
|
-
packageJson.devDependencies = {};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
// Create new package.json
|
|
113
|
-
packageJson = {
|
|
114
|
-
name: "my-tsonic-app",
|
|
115
|
-
version: "1.0.0",
|
|
116
|
-
type: "module",
|
|
117
|
-
scripts: {
|
|
118
|
-
build: "tsonic build src/main.ts",
|
|
119
|
-
dev: "tsonic run src/main.ts",
|
|
120
|
-
},
|
|
121
|
-
devDependencies: {},
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf-8");
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* Install npm package
|
|
128
|
-
*/
|
|
129
|
-
const installPackage = (packageName, version) => {
|
|
130
|
-
const result = spawnSync("npm", ["install", "--save-dev", `${packageName}@${version}`], {
|
|
131
|
-
stdio: "inherit",
|
|
132
|
-
encoding: "utf-8",
|
|
133
|
-
});
|
|
134
|
-
if (result.status !== 0) {
|
|
135
|
-
return {
|
|
136
|
-
ok: false,
|
|
137
|
-
error: `Failed to install ${packageName}@${version}`,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
return { ok: true, value: undefined };
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* Initialize a new Tsonic project
|
|
144
|
-
*/
|
|
145
|
-
export const initProject = (cwd, options = {}) => {
|
|
146
|
-
const tsonicJsonPath = join(cwd, "tsonic.json");
|
|
147
|
-
const gitignorePath = join(cwd, ".gitignore");
|
|
148
|
-
const srcDir = join(cwd, "src");
|
|
149
|
-
const mainTsPath = join(srcDir, "main.ts");
|
|
150
|
-
const readmePath = join(cwd, "README.md");
|
|
151
|
-
const packageJsonPath = join(cwd, "package.json");
|
|
152
|
-
// Check if tsonic.json already exists
|
|
153
|
-
if (existsSync(tsonicJsonPath)) {
|
|
154
|
-
return {
|
|
155
|
-
ok: false,
|
|
156
|
-
error: "tsonic.json already exists. Project is already initialized.",
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
try {
|
|
160
|
-
// Create or update package.json FIRST (before npm install)
|
|
161
|
-
const packageJsonExists = existsSync(packageJsonPath);
|
|
162
|
-
createOrUpdatePackageJson(packageJsonPath);
|
|
163
|
-
console.log(packageJsonExists ? "✓ Updated package.json" : "✓ Created package.json");
|
|
164
|
-
// Install .NET type declarations
|
|
165
|
-
const shouldInstallTypes = !options.skipTypes;
|
|
166
|
-
const typesVersion = options.typesVersion ?? "10.0.0";
|
|
167
|
-
if (shouldInstallTypes) {
|
|
168
|
-
console.log(`Installing .NET type declarations (@tsonic/dotnet-types@${typesVersion})...`);
|
|
169
|
-
const installResult = installPackage("@tsonic/dotnet-types", typesVersion);
|
|
170
|
-
if (!installResult.ok) {
|
|
171
|
-
return installResult;
|
|
172
|
-
}
|
|
173
|
-
console.log("✓ Installed @tsonic/dotnet-types");
|
|
174
|
-
}
|
|
175
|
-
// Create tsonic.json
|
|
176
|
-
const config = generateConfig(shouldInstallTypes);
|
|
177
|
-
writeFileSync(tsonicJsonPath, config, "utf-8");
|
|
178
|
-
console.log("✓ Created tsonic.json");
|
|
179
|
-
// Create or append to .gitignore
|
|
180
|
-
if (existsSync(gitignorePath)) {
|
|
181
|
-
const existing = readFileSync(gitignorePath, "utf-8");
|
|
182
|
-
if (!existing.includes("generated/")) {
|
|
183
|
-
writeFileSync(gitignorePath, existing + "\n" + DEFAULT_GITIGNORE, "utf-8");
|
|
184
|
-
console.log("✓ Updated .gitignore");
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
writeFileSync(gitignorePath, DEFAULT_GITIGNORE, "utf-8");
|
|
189
|
-
console.log("✓ Created .gitignore");
|
|
190
|
-
}
|
|
191
|
-
// Create src directory and main.ts
|
|
192
|
-
if (!existsSync(srcDir)) {
|
|
193
|
-
mkdirSync(srcDir, { recursive: true });
|
|
194
|
-
}
|
|
195
|
-
if (!existsSync(mainTsPath)) {
|
|
196
|
-
writeFileSync(mainTsPath, SAMPLE_MAIN_TS, "utf-8");
|
|
197
|
-
console.log("✓ Created src/main.ts");
|
|
198
|
-
}
|
|
199
|
-
// Create README.md
|
|
200
|
-
if (!existsSync(readmePath)) {
|
|
201
|
-
writeFileSync(readmePath, SAMPLE_README, "utf-8");
|
|
202
|
-
console.log("✓ Created README.md");
|
|
203
|
-
}
|
|
204
|
-
console.log("\n✓ Project initialized successfully!");
|
|
205
|
-
console.log("\nNext steps:");
|
|
206
|
-
console.log(" npm run build # Build executable");
|
|
207
|
-
console.log(" npm run dev # Run directly");
|
|
208
|
-
return { ok: true, value: undefined };
|
|
209
|
-
}
|
|
210
|
-
catch (error) {
|
|
211
|
-
return {
|
|
212
|
-
ok: false,
|
|
213
|
-
error: `Failed to initialize project: ${error instanceof Error ? error.message : String(error)}`,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
//# sourceMappingURL=init.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAQ/C,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;CAazB,CAAC;AAEF,MAAM,cAAc,GAAG;;;;;;;;CAQtB,CAAC;AAEF,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBrB,CAAC;AAEF;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,gBAAyB,EAAU,EAAE;IAC3D,MAAM,MAAM,GAA4B;QACtC,OAAO,EAAE,mCAAmC;QAC5C,aAAa,EAAE,OAAO;QACtB,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,KAAK;QACjB,eAAe,EAAE,WAAW;QAC5B,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,OAAO;QACjB,QAAQ,EAAE,EAAE;QACZ,YAAY,EAAE;YACZ,YAAY,EAAE,IAAI;YAClB,sBAAsB,EAAE,IAAI;SAC7B;KACF,CAAC;IAEF,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,CAAC,MAAM,GAAG;YACd,SAAS,EAAE,CAAC,yCAAyC,CAAC;SACvD,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,MAA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DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tsonic run command - Build and execute
|
|
3
|
-
*/
|
|
4
|
-
import type { ResolvedConfig, Result } from "../types.js";
|
|
5
|
-
/**
|
|
6
|
-
* Build and run the executable
|
|
7
|
-
*/
|
|
8
|
-
export declare const runCommand: (config: ResolvedConfig, programArgs?: string[]) => Result<{
|
|
9
|
-
exitCode: number;
|
|
10
|
-
}, string>;
|
|
11
|
-
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1D;;GAEG;AACH,eAAO,MAAM,UAAU,GACrB,QAAQ,cAAc,EACtB,cAAa,MAAM,EAAO,KACzB,MAAM,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,CAoCrC,CAAC"}
|
package/dist/commands/run.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tsonic run command - Build and execute
|
|
3
|
-
*/
|
|
4
|
-
import { spawnSync } from "node:child_process";
|
|
5
|
-
import { buildCommand } from "./build.js";
|
|
6
|
-
/**
|
|
7
|
-
* Build and run the executable
|
|
8
|
-
*/
|
|
9
|
-
export const runCommand = (config, programArgs = []) => {
|
|
10
|
-
// Build the executable
|
|
11
|
-
const buildResult = buildCommand(config);
|
|
12
|
-
if (!buildResult.ok) {
|
|
13
|
-
return buildResult;
|
|
14
|
-
}
|
|
15
|
-
const { outputPath } = buildResult.value;
|
|
16
|
-
if (!config.quiet) {
|
|
17
|
-
console.log(`\nRunning ${outputPath}...`);
|
|
18
|
-
console.log("─".repeat(50));
|
|
19
|
-
}
|
|
20
|
-
// Execute the binary
|
|
21
|
-
const runResult = spawnSync(outputPath, programArgs, {
|
|
22
|
-
stdio: "inherit",
|
|
23
|
-
encoding: "utf-8",
|
|
24
|
-
});
|
|
25
|
-
if (runResult.error) {
|
|
26
|
-
return {
|
|
27
|
-
ok: false,
|
|
28
|
-
error: `Failed to run executable: ${runResult.error.message}`,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if (!config.quiet) {
|
|
32
|
-
console.log("─".repeat(50));
|
|
33
|
-
console.log(`\nProcess exited with code ${runResult.status ?? 0}`);
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
ok: true,
|
|
37
|
-
value: { exitCode: runResult.status ?? 0 },
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=run.js.map
|
package/dist/commands/run.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,MAAsB,EACtB,cAAwB,EAAE,EACY,EAAE;IACxC,uBAAuB;IACvB,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC;QACpB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC;IAEzC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,aAAa,UAAU,KAAK,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,qBAAqB;IACrB,MAAM,SAAS,GAAG,SAAS,CAAC,UAAU,EAAE,WAAW,EAAE;QACnD,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;IAEH,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,6BAA6B,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE;SAC9D,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,8BAA8B,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE;KAC3C,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/config.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration loading and validation
|
|
3
|
-
*/
|
|
4
|
-
import type { TsonicConfig, CliOptions, ResolvedConfig, Result } from "./types.js";
|
|
5
|
-
/**
|
|
6
|
-
* Load tsonic.json from a directory
|
|
7
|
-
*/
|
|
8
|
-
export declare const loadConfig: (configPath: string) => Result<TsonicConfig, string>;
|
|
9
|
-
/**
|
|
10
|
-
* Find tsonic.json by walking up the directory tree
|
|
11
|
-
*/
|
|
12
|
-
export declare const findConfig: (startDir: string) => string | null;
|
|
13
|
-
/**
|
|
14
|
-
* Resolve final configuration from file + CLI args
|
|
15
|
-
*/
|
|
16
|
-
export declare const resolveConfig: (config: TsonicConfig, cliOptions: CliOptions, entryFile?: string) => ResolvedConfig;
|
|
17
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,MAAM,EACP,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,eAAO,MAAM,UAAU,GACrB,YAAY,MAAM,KACjB,MAAM,CAAC,YAAY,EAAE,MAAM,CA2B7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,KAAG,MAAM,GAAG,IAiBtD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GACxB,QAAQ,YAAY,EACpB,YAAY,UAAU,EACtB,YAAY,MAAM,KACjB,cA2BF,CAAC"}
|
package/dist/config.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configuration loading and validation
|
|
3
|
-
*/
|
|
4
|
-
import { readFileSync, existsSync } from "node:fs";
|
|
5
|
-
import { join, resolve, dirname } from "node:path";
|
|
6
|
-
import { detectRid } from "@tsonic/backend";
|
|
7
|
-
/**
|
|
8
|
-
* Load tsonic.json from a directory
|
|
9
|
-
*/
|
|
10
|
-
export const loadConfig = (configPath) => {
|
|
11
|
-
if (!existsSync(configPath)) {
|
|
12
|
-
return {
|
|
13
|
-
ok: false,
|
|
14
|
-
error: `Config file not found: ${configPath}`,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
const content = readFileSync(configPath, "utf-8");
|
|
19
|
-
const config = JSON.parse(content);
|
|
20
|
-
// Validate required fields
|
|
21
|
-
if (!config.rootNamespace) {
|
|
22
|
-
return {
|
|
23
|
-
ok: false,
|
|
24
|
-
error: "tsonic.json: 'rootNamespace' is required",
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
return { ok: true, value: config };
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
return {
|
|
31
|
-
ok: false,
|
|
32
|
-
error: `Failed to parse tsonic.json: ${error instanceof Error ? error.message : String(error)}`,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Find tsonic.json by walking up the directory tree
|
|
38
|
-
*/
|
|
39
|
-
export const findConfig = (startDir) => {
|
|
40
|
-
let currentDir = resolve(startDir);
|
|
41
|
-
// Walk up until we find tsonic.json or hit root
|
|
42
|
-
while (true) {
|
|
43
|
-
const configPath = join(currentDir, "tsonic.json");
|
|
44
|
-
if (existsSync(configPath)) {
|
|
45
|
-
return configPath;
|
|
46
|
-
}
|
|
47
|
-
const parentDir = dirname(currentDir);
|
|
48
|
-
if (parentDir === currentDir) {
|
|
49
|
-
// Hit root
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
currentDir = parentDir;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Resolve final configuration from file + CLI args
|
|
57
|
-
*/
|
|
58
|
-
export const resolveConfig = (config, cliOptions, entryFile) => {
|
|
59
|
-
const entryPoint = entryFile ?? config.entryPoint ?? "src/main.ts";
|
|
60
|
-
const sourceRoot = cliOptions.src ?? config.sourceRoot ?? dirname(entryPoint);
|
|
61
|
-
// Default type roots: node_modules/@tsonic/dotnet-types/types
|
|
62
|
-
const defaultTypeRoots = ["node_modules/@tsonic/dotnet-types/types"];
|
|
63
|
-
const typeRoots = config.dotnet?.typeRoots ?? defaultTypeRoots;
|
|
64
|
-
return {
|
|
65
|
-
rootNamespace: cliOptions.namespace ?? config.rootNamespace,
|
|
66
|
-
entryPoint,
|
|
67
|
-
sourceRoot,
|
|
68
|
-
outputDirectory: config.outputDirectory ?? "generated",
|
|
69
|
-
outputName: cliOptions.out ?? config.outputName ?? "app",
|
|
70
|
-
rid: cliOptions.rid ?? config.rid ?? detectRid(),
|
|
71
|
-
dotnetVersion: config.dotnetVersion ?? "net10.0",
|
|
72
|
-
optimize: cliOptions.optimize ?? config.optimize ?? "speed",
|
|
73
|
-
packages: config.dotnet?.packages ?? config.packages ?? [],
|
|
74
|
-
stripSymbols: cliOptions.noStrip
|
|
75
|
-
? false
|
|
76
|
-
: (config.buildOptions?.stripSymbols ?? true),
|
|
77
|
-
invariantGlobalization: config.buildOptions?.invariantGlobalization ?? true,
|
|
78
|
-
keepTemp: cliOptions.keepTemp ?? false,
|
|
79
|
-
verbose: cliOptions.verbose ?? false,
|
|
80
|
-
quiet: cliOptions.quiet ?? false,
|
|
81
|
-
typeRoots,
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,UAAkB,EACY,EAAE;IAChC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,OAAO;YACL,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,0BAA0B,UAAU,EAAE;SAC9C,CAAC;IACJ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAiB,CAAC;QAEnD,2BAA2B;QAC3B,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAC1B,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,0CAA0C;aAClD,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,EAAE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