tsonic 0.0.1 → 0.0.10
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/src/cli/parser.test.ts
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for CLI argument parser
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, it } from "mocha";
|
|
6
|
-
import { expect } from "chai";
|
|
7
|
-
import { parseArgs } from "./parser.js";
|
|
8
|
-
|
|
9
|
-
describe("CLI Parser", () => {
|
|
10
|
-
describe("parseArgs", () => {
|
|
11
|
-
describe("Commands", () => {
|
|
12
|
-
it("should parse build command", () => {
|
|
13
|
-
const result = parseArgs(["build"]);
|
|
14
|
-
expect(result.command).to.equal("build");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should parse run command", () => {
|
|
18
|
-
const result = parseArgs(["run"]);
|
|
19
|
-
expect(result.command).to.equal("run");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("should parse emit command", () => {
|
|
23
|
-
const result = parseArgs(["emit"]);
|
|
24
|
-
expect(result.command).to.equal("emit");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("should parse project:init as two-word command", () => {
|
|
28
|
-
const result = parseArgs(["project", "init"]);
|
|
29
|
-
expect(result.command).to.equal("project:init");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("should parse help command from --help", () => {
|
|
33
|
-
const result = parseArgs(["--help"]);
|
|
34
|
-
expect(result.command).to.equal("help");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should parse help command from -h", () => {
|
|
38
|
-
const result = parseArgs(["-h"]);
|
|
39
|
-
expect(result.command).to.equal("help");
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("should parse version command from --version", () => {
|
|
43
|
-
const result = parseArgs(["--version"]);
|
|
44
|
-
expect(result.command).to.equal("version");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("should parse version command from -v", () => {
|
|
48
|
-
const result = parseArgs(["-v"]);
|
|
49
|
-
expect(result.command).to.equal("version");
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe("Entry File", () => {
|
|
54
|
-
it("should parse entry file after command", () => {
|
|
55
|
-
const result = parseArgs(["run", "index.ts"]);
|
|
56
|
-
expect(result.command).to.equal("run");
|
|
57
|
-
expect(result.entryFile).to.equal("index.ts");
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it("should parse entry file with path", () => {
|
|
61
|
-
const result = parseArgs(["build", "src/main.ts"]);
|
|
62
|
-
expect(result.command).to.equal("build");
|
|
63
|
-
expect(result.entryFile).to.equal("src/main.ts");
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("should handle no entry file", () => {
|
|
67
|
-
const result = parseArgs(["build"]);
|
|
68
|
-
expect(result.entryFile).to.equal(undefined);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe("Options", () => {
|
|
73
|
-
it("should parse --verbose option", () => {
|
|
74
|
-
const result = parseArgs(["build", "--verbose"]);
|
|
75
|
-
expect(result.options.verbose).to.equal(true);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("should parse -V short option for verbose", () => {
|
|
79
|
-
const result = parseArgs(["build", "-V"]);
|
|
80
|
-
expect(result.options.verbose).to.equal(true);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("should parse --quiet option", () => {
|
|
84
|
-
const result = parseArgs(["build", "--quiet"]);
|
|
85
|
-
expect(result.options.quiet).to.equal(true);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("should parse -q short option for quiet", () => {
|
|
89
|
-
const result = parseArgs(["build", "-q"]);
|
|
90
|
-
expect(result.options.quiet).to.equal(true);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("should parse --config option with value", () => {
|
|
94
|
-
const result = parseArgs(["build", "--config", "tsonic.json"]);
|
|
95
|
-
expect(result.options.config).to.equal("tsonic.json");
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("should parse -c short option for config", () => {
|
|
99
|
-
const result = parseArgs(["build", "-c", "custom.json"]);
|
|
100
|
-
expect(result.options.config).to.equal("custom.json");
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("should parse --src option with value", () => {
|
|
104
|
-
const result = parseArgs(["build", "--src", "source"]);
|
|
105
|
-
expect(result.options.src).to.equal("source");
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("should parse -s short option for src", () => {
|
|
109
|
-
const result = parseArgs(["build", "-s", "app"]);
|
|
110
|
-
expect(result.options.src).to.equal("app");
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("should parse --out option with value", () => {
|
|
114
|
-
const result = parseArgs(["build", "--out", "output"]);
|
|
115
|
-
expect(result.options.out).to.equal("output");
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it("should parse -o short option for out", () => {
|
|
119
|
-
const result = parseArgs(["build", "-o", "dist"]);
|
|
120
|
-
expect(result.options.out).to.equal("dist");
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("should parse --namespace option with value", () => {
|
|
124
|
-
const result = parseArgs(["build", "--namespace", "MyApp"]);
|
|
125
|
-
expect(result.options.namespace).to.equal("MyApp");
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("should parse -n short option for namespace", () => {
|
|
129
|
-
const result = parseArgs(["build", "-n", "App"]);
|
|
130
|
-
expect(result.options.namespace).to.equal("App");
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("should parse --rid option with value", () => {
|
|
134
|
-
const result = parseArgs(["build", "--rid", "linux-x64"]);
|
|
135
|
-
expect(result.options.rid).to.equal("linux-x64");
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("should parse -r short option for rid", () => {
|
|
139
|
-
const result = parseArgs(["build", "-r", "win-x64"]);
|
|
140
|
-
expect(result.options.rid).to.equal("win-x64");
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it("should parse --optimize option with speed", () => {
|
|
144
|
-
const result = parseArgs(["build", "--optimize", "speed"]);
|
|
145
|
-
expect(result.options.optimize).to.equal("speed");
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("should parse --optimize option with size", () => {
|
|
149
|
-
const result = parseArgs(["build", "--optimize", "size"]);
|
|
150
|
-
expect(result.options.optimize).to.equal("size");
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("should parse -O short option for optimize", () => {
|
|
154
|
-
const result = parseArgs(["build", "-O", "speed"]);
|
|
155
|
-
expect(result.options.optimize).to.equal("speed");
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it("should parse --keep-temp option", () => {
|
|
159
|
-
const result = parseArgs(["build", "--keep-temp"]);
|
|
160
|
-
expect(result.options.keepTemp).to.equal(true);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("should parse -k short option for keep-temp", () => {
|
|
164
|
-
const result = parseArgs(["build", "-k"]);
|
|
165
|
-
expect(result.options.keepTemp).to.equal(true);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("should parse --no-strip option", () => {
|
|
169
|
-
const result = parseArgs(["build", "--no-strip"]);
|
|
170
|
-
expect(result.options.noStrip).to.equal(true);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
describe("Program Arguments", () => {
|
|
175
|
-
it("should parse program arguments after --", () => {
|
|
176
|
-
const result = parseArgs(["run", "index.ts", "--", "arg1", "arg2"]);
|
|
177
|
-
expect(result.programArgs).to.deep.equal(["arg1", "arg2"]);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it("should handle options in program arguments", () => {
|
|
181
|
-
const result = parseArgs([
|
|
182
|
-
"run",
|
|
183
|
-
"index.ts",
|
|
184
|
-
"--",
|
|
185
|
-
"--verbose",
|
|
186
|
-
"-o",
|
|
187
|
-
"out",
|
|
188
|
-
]);
|
|
189
|
-
expect(result.programArgs).to.deep.equal(["--verbose", "-o", "out"]);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it("should handle empty program arguments", () => {
|
|
193
|
-
const result = parseArgs(["run", "index.ts"]);
|
|
194
|
-
expect(result.programArgs).to.deep.equal([]);
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
describe("Complex Scenarios", () => {
|
|
199
|
-
it("should parse command with entry file and multiple options", () => {
|
|
200
|
-
const result = parseArgs([
|
|
201
|
-
"build",
|
|
202
|
-
"src/main.ts",
|
|
203
|
-
"--namespace",
|
|
204
|
-
"MyApp",
|
|
205
|
-
"--out",
|
|
206
|
-
"dist",
|
|
207
|
-
"--verbose",
|
|
208
|
-
]);
|
|
209
|
-
expect(result.command).to.equal("build");
|
|
210
|
-
expect(result.entryFile).to.equal("src/main.ts");
|
|
211
|
-
expect(result.options.namespace).to.equal("MyApp");
|
|
212
|
-
expect(result.options.out).to.equal("dist");
|
|
213
|
-
expect(result.options.verbose).to.equal(true);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it("should parse run command with entry, options, and program args", () => {
|
|
217
|
-
const result = parseArgs([
|
|
218
|
-
"run",
|
|
219
|
-
"index.ts",
|
|
220
|
-
"--verbose",
|
|
221
|
-
"--",
|
|
222
|
-
"programArg1",
|
|
223
|
-
"programArg2",
|
|
224
|
-
]);
|
|
225
|
-
expect(result.command).to.equal("run");
|
|
226
|
-
expect(result.entryFile).to.equal("index.ts");
|
|
227
|
-
expect(result.options.verbose).to.equal(true);
|
|
228
|
-
expect(result.programArgs).to.deep.equal([
|
|
229
|
-
"programArg1",
|
|
230
|
-
"programArg2",
|
|
231
|
-
]);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it("should handle empty args array", () => {
|
|
235
|
-
const result = parseArgs([]);
|
|
236
|
-
expect(result.command).to.equal("");
|
|
237
|
-
expect(result.entryFile).to.equal(undefined);
|
|
238
|
-
expect(result.options).to.deep.equal({});
|
|
239
|
-
expect(result.programArgs).to.deep.equal([]);
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
it("should handle mixed short and long options", () => {
|
|
243
|
-
const result = parseArgs([
|
|
244
|
-
"build",
|
|
245
|
-
"-n",
|
|
246
|
-
"App",
|
|
247
|
-
"--out",
|
|
248
|
-
"dist",
|
|
249
|
-
"-V",
|
|
250
|
-
"--keep-temp",
|
|
251
|
-
]);
|
|
252
|
-
expect(result.options.namespace).to.equal("App");
|
|
253
|
-
expect(result.options.out).to.equal("dist");
|
|
254
|
-
expect(result.options.verbose).to.equal(true);
|
|
255
|
-
expect(result.options.keepTemp).to.equal(true);
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
});
|
package/src/cli/parser.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI argument parser
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { CliOptions } from "../types.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Parse CLI arguments
|
|
9
|
-
*/
|
|
10
|
-
export const parseArgs = (
|
|
11
|
-
args: string[]
|
|
12
|
-
): {
|
|
13
|
-
command: string;
|
|
14
|
-
entryFile?: string;
|
|
15
|
-
options: CliOptions;
|
|
16
|
-
programArgs?: string[];
|
|
17
|
-
} => {
|
|
18
|
-
const options: CliOptions = {};
|
|
19
|
-
let command = "";
|
|
20
|
-
let entryFile: string | undefined;
|
|
21
|
-
const programArgs: string[] = [];
|
|
22
|
-
let captureProgramArgs = false;
|
|
23
|
-
|
|
24
|
-
for (let i = 0; i < args.length; i++) {
|
|
25
|
-
const arg = args[i];
|
|
26
|
-
if (!arg) continue; // Skip if undefined
|
|
27
|
-
|
|
28
|
-
// Separator for program arguments
|
|
29
|
-
if (arg === "--") {
|
|
30
|
-
captureProgramArgs = true;
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (captureProgramArgs) {
|
|
35
|
-
programArgs.push(arg);
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Commands
|
|
40
|
-
if (!command && !arg.startsWith("-")) {
|
|
41
|
-
command = arg;
|
|
42
|
-
// Handle "project init" as two-word command
|
|
43
|
-
const nextArg = args[i + 1];
|
|
44
|
-
if (command === "project" && nextArg === "init") {
|
|
45
|
-
command = "project:init";
|
|
46
|
-
i++;
|
|
47
|
-
}
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Entry file (first non-option after command)
|
|
52
|
-
if (command && !entryFile && !arg.startsWith("-")) {
|
|
53
|
-
entryFile = arg;
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Options
|
|
58
|
-
switch (arg) {
|
|
59
|
-
case "-h":
|
|
60
|
-
case "--help":
|
|
61
|
-
options.verbose = true; // reuse for help flag
|
|
62
|
-
return { command: "help", options: {} };
|
|
63
|
-
case "-v":
|
|
64
|
-
case "--version":
|
|
65
|
-
return { command: "version", options: {} };
|
|
66
|
-
case "-V":
|
|
67
|
-
case "--verbose":
|
|
68
|
-
options.verbose = true;
|
|
69
|
-
break;
|
|
70
|
-
case "-q":
|
|
71
|
-
case "--quiet":
|
|
72
|
-
options.quiet = true;
|
|
73
|
-
break;
|
|
74
|
-
case "-c":
|
|
75
|
-
case "--config":
|
|
76
|
-
options.config = args[++i] ?? "";
|
|
77
|
-
break;
|
|
78
|
-
case "-s":
|
|
79
|
-
case "--src":
|
|
80
|
-
options.src = args[++i] ?? "";
|
|
81
|
-
break;
|
|
82
|
-
case "-o":
|
|
83
|
-
case "--out":
|
|
84
|
-
options.out = args[++i] ?? "";
|
|
85
|
-
break;
|
|
86
|
-
case "-n":
|
|
87
|
-
case "--namespace":
|
|
88
|
-
options.namespace = args[++i] ?? "";
|
|
89
|
-
break;
|
|
90
|
-
case "-r":
|
|
91
|
-
case "--rid":
|
|
92
|
-
options.rid = args[++i] ?? "";
|
|
93
|
-
break;
|
|
94
|
-
case "-O":
|
|
95
|
-
case "--optimize":
|
|
96
|
-
options.optimize = (args[++i] ?? "speed") as "size" | "speed";
|
|
97
|
-
break;
|
|
98
|
-
case "-k":
|
|
99
|
-
case "--keep-temp":
|
|
100
|
-
options.keepTemp = true;
|
|
101
|
-
break;
|
|
102
|
-
case "--no-strip":
|
|
103
|
-
options.noStrip = true;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return { command, entryFile, options, programArgs };
|
|
109
|
-
};
|
package/src/cli.ts
DELETED
package/src/commands/build.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* tsonic build command - Build executable
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { spawnSync } from "node:child_process";
|
|
6
|
-
import { join, relative } from "node:path";
|
|
7
|
-
import { copyFileSync, chmodSync, existsSync } from "node:fs";
|
|
8
|
-
import type { ResolvedConfig, Result } from "../types.js";
|
|
9
|
-
import { emitCommand } from "./emit.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Build native executable
|
|
13
|
-
*/
|
|
14
|
-
export const buildCommand = (
|
|
15
|
-
config: ResolvedConfig
|
|
16
|
-
): Result<{ outputPath: string }, string> => {
|
|
17
|
-
const { outputDirectory, outputName, rid, quiet, verbose } = config;
|
|
18
|
-
|
|
19
|
-
// Step 1: Emit C# code
|
|
20
|
-
if (!quiet) {
|
|
21
|
-
console.log("Step 1/3: Generating C# code...");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const emitResult = emitCommand(config);
|
|
25
|
-
if (!emitResult.ok) {
|
|
26
|
-
return emitResult;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const generatedDir = emitResult.value.outputDir;
|
|
30
|
-
const csprojPath = join(generatedDir, "tsonic.csproj");
|
|
31
|
-
|
|
32
|
-
if (!existsSync(csprojPath)) {
|
|
33
|
-
return {
|
|
34
|
-
ok: false,
|
|
35
|
-
error: `No tsonic.csproj found in ${outputDirectory}/. This should have been created by emit.`,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Step 2: Run dotnet publish
|
|
40
|
-
if (!quiet) {
|
|
41
|
-
console.log("Step 2/3: Compiling with dotnet publish...");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const publishArgs = [
|
|
45
|
-
"publish",
|
|
46
|
-
"tsonic.csproj",
|
|
47
|
-
"-c",
|
|
48
|
-
"Release",
|
|
49
|
-
"-r",
|
|
50
|
-
rid,
|
|
51
|
-
"--nologo",
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
if (quiet) {
|
|
55
|
-
publishArgs.push("--verbosity", "quiet");
|
|
56
|
-
} else if (verbose) {
|
|
57
|
-
publishArgs.push("--verbosity", "detailed");
|
|
58
|
-
} else {
|
|
59
|
-
publishArgs.push("--verbosity", "minimal");
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const publishResult = spawnSync("dotnet", publishArgs, {
|
|
63
|
-
cwd: generatedDir,
|
|
64
|
-
stdio: verbose ? "inherit" : "pipe",
|
|
65
|
-
encoding: "utf-8",
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
if (publishResult.status !== 0) {
|
|
69
|
-
const errorMsg =
|
|
70
|
-
publishResult.stderr || publishResult.stdout || "Unknown error";
|
|
71
|
-
return {
|
|
72
|
-
ok: false,
|
|
73
|
-
error: `dotnet publish failed:\n${errorMsg}`,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Step 3: Copy output binary
|
|
78
|
-
if (!quiet) {
|
|
79
|
-
console.log("Step 3/3: Copying output binary...");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const binaryName =
|
|
83
|
-
process.platform === "win32" ? `${outputName}.exe` : outputName;
|
|
84
|
-
const publishDir = join(
|
|
85
|
-
generatedDir,
|
|
86
|
-
"bin",
|
|
87
|
-
"Release",
|
|
88
|
-
config.dotnetVersion,
|
|
89
|
-
rid,
|
|
90
|
-
"publish"
|
|
91
|
-
);
|
|
92
|
-
const sourceBinary = join(publishDir, binaryName);
|
|
93
|
-
const targetBinary = join(process.cwd(), binaryName);
|
|
94
|
-
|
|
95
|
-
if (!existsSync(sourceBinary)) {
|
|
96
|
-
return {
|
|
97
|
-
ok: false,
|
|
98
|
-
error: `Built binary not found at ${sourceBinary}`,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
copyFileSync(sourceBinary, targetBinary);
|
|
104
|
-
|
|
105
|
-
// Make executable on Unix
|
|
106
|
-
if (process.platform !== "win32") {
|
|
107
|
-
chmodSync(targetBinary, 0o755);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (!quiet) {
|
|
111
|
-
const relativePath = relative(process.cwd(), targetBinary);
|
|
112
|
-
console.log(`\n✓ Build complete: ${relativePath}`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
ok: true,
|
|
117
|
-
value: { outputPath: targetBinary },
|
|
118
|
-
};
|
|
119
|
-
} catch (error) {
|
|
120
|
-
return {
|
|
121
|
-
ok: false,
|
|
122
|
-
error: `Failed to copy binary: ${error instanceof Error ? error.message : String(error)}`,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
};
|