@tsplc/compiler 0.2.17 → 0.2.18
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 +2 -2
- package/dist/cli.js +920 -943
- package/dist/cli.js.map +13 -10
- package/dist/codesys.js +3893 -3352
- package/dist/codesys.js.map +29 -20
- package/dist/elaborate-capture.js +33 -17
- package/dist/elaborate-capture.js.map +3 -3
- package/dist/index.js +8787 -6855
- package/dist/index.js.map +40 -20
- package/dist/ir.js +1575 -1072
- package/dist/ir.js.map +21 -17
- package/dist/math.js.map +2 -2
- package/dist/project.js +154 -60
- package/dist/project.js.map +5 -5
- package/dist/telemetry.js +27 -9
- package/dist/telemetry.js.map +5 -5
- package/package.json +112 -112
- package/src/codesys/config.ts +50 -0
- package/src/codesys/debug.ts +670 -0
- package/src/codesys/emit.ts +142 -0
- package/src/codesys/engineering.ts +109 -0
- package/src/codesys/expressions.ts +92 -0
- package/src/codesys/global-lists.ts +250 -0
- package/src/codesys/global-names.ts +68 -0
- package/src/codesys/http.ts +890 -0
- package/src/codesys/index.ts +30 -0
- package/src/codesys/instrumentation.ts +430 -0
- package/src/codesys/io-paths.ts +140 -0
- package/src/codesys/manifest.ts +643 -0
- package/src/codesys/names.ts +81 -0
- package/src/codesys/numeric.ts +409 -0
- package/src/codesys/operands.ts +62 -0
- package/src/codesys/plan.ts +605 -0
- package/src/codesys/programs.ts +53 -0
- package/src/codesys/publication.ts +171 -0
- package/src/codesys/routines.ts +603 -0
- package/src/codesys/sources.ts +71 -0
- package/src/codesys/st-files.ts +115 -0
- package/src/codesys/storage.ts +97 -0
- package/src/codesys/symbols.ts +220 -0
- package/src/codesys/task-access.ts +320 -0
- package/src/codesys/telemetry.ts +732 -0
- package/src/codesys/types.ts +250 -0
- package/src/codesys/vendor.ts +150 -0
- package/src/frontend/analyzer.ts +794 -0
- package/src/frontend/async.ts +317 -1137
- package/src/frontend/blocks.ts +537 -403
- package/src/frontend/configuration.ts +176 -144
- package/src/frontend/const-functions.ts +183 -148
- package/src/frontend/cooperative.ts +73 -43
- package/src/frontend/coroutines.ts +1032 -0
- package/src/frontend/elaborate/calls.ts +535 -0
- package/src/frontend/elaborate/capture.ts +157 -101
- package/src/frontend/elaborate/dialect.ts +257 -0
- package/src/frontend/elaborate/expressions.ts +992 -0
- package/src/frontend/elaborate/frame.ts +53 -0
- package/src/frontend/elaborate/graph.ts +116 -71
- package/src/frontend/elaborate/imports.ts +70 -0
- package/src/frontend/elaborate/index.ts +435 -331
- package/src/frontend/elaborate/initializers.ts +198 -0
- package/src/frontend/elaborate/layouts.ts +591 -384
- package/src/frontend/elaborate/model.ts +264 -169
- package/src/frontend/elaborate/specialize.ts +343 -2586
- package/src/frontend/elaborate/statements.ts +606 -0
- package/src/frontend/elaborate/storage.ts +546 -0
- package/src/frontend/elaborate/values.ts +58 -0
- package/src/frontend/elaborate/writes.ts +100 -0
- package/src/frontend/exposure.ts +172 -140
- package/src/frontend/expressions.ts +1383 -0
- package/src/frontend/intrinsics.ts +337 -0
- package/src/frontend/module-graph.ts +89 -59
- package/src/frontend/positions.ts +271 -200
- package/src/frontend/promise-chains.ts +897 -0
- package/src/frontend/promises.ts +390 -747
- package/src/frontend/routines.ts +181 -0
- package/src/frontend/sdk.ts +82 -0
- package/src/frontend/services.ts +506 -372
- package/src/frontend/statements.ts +855 -0
- package/src/frontend/tasks.ts +471 -0
- package/src/frontend/telemetry.ts +174 -0
- package/src/frontend/types.ts +845 -551
- package/src/frontend/typescript.ts +323 -2543
- package/src/index.ts +5 -5
- package/src/ir/aggregates.ts +275 -0
- package/src/ir/allocation.ts +84 -0
- package/src/ir/core-model.ts +146 -0
- package/src/ir/declarations.ts +295 -0
- package/src/ir/diagnostics.ts +61 -0
- package/src/ir/domains.ts +152 -0
- package/src/ir/fold.ts +342 -0
- package/src/ir/index.ts +90 -0
- package/{ir/errors.ts → src/ir/job-errors.ts} +12 -10
- package/src/ir/layouts.ts +181 -0
- package/src/ir/link.ts +354 -0
- package/src/ir/model.ts +386 -0
- package/{ir → src/ir}/normalization-error.ts +4 -4
- package/src/ir/normalize.ts +70 -0
- package/src/ir/numeric.ts +171 -0
- package/src/ir/ranges.ts +256 -0
- package/src/ir/routine.ts +1163 -0
- package/src/ir/scalars.ts +321 -0
- package/src/ir/types.ts +127 -0
- package/src/project/artifacts.ts +342 -0
- package/src/project/cli.ts +177 -0
- package/src/project/debugger.ts +82 -0
- package/src/project/index.ts +6 -0
- package/src/project/plant.ts +467 -0
- package/src/project/project-commands.ts +372 -0
- package/src/project/project.ts +457 -0
- package/src/project/release.ts +153 -0
- package/src/project/server.ts +150 -0
- package/src/project/terminal.ts +32 -0
- package/stdlib/math.ts +14 -10
- package/stdlib/telemetry.ts +71 -47
- package/types/async.d.ts +46 -40
- package/types/data-types.d.ts +26 -26
- package/types/globals.d.ts +41 -38
- package/types/index.d.ts +96 -51
- package/types/plc.d.ts +3 -4
- package/types/telemetry.d.ts +14 -14
- package/backends/codesys/config.ts +0 -54
- package/backends/codesys/debug.ts +0 -509
- package/backends/codesys/emit.ts +0 -1738
- package/backends/codesys/engineering.ts +0 -88
- package/backends/codesys/global-names.ts +0 -49
- package/backends/codesys/http.ts +0 -675
- package/backends/codesys/index.ts +0 -13
- package/backends/codesys/io-paths.ts +0 -105
- package/backends/codesys/manifest.ts +0 -312
- package/backends/codesys/names.ts +0 -76
- package/backends/codesys/numeric.ts +0 -356
- package/backends/codesys/plan.ts +0 -457
- package/backends/codesys/publication.ts +0 -59
- package/backends/codesys/storage.ts +0 -70
- package/backends/codesys/task-access.ts +0 -293
- package/backends/codesys/telemetry.ts +0 -593
- package/backends/codesys/types.ts +0 -179
- package/backends/codesys/vendor.ts +0 -108
- package/ir/aggregates.ts +0 -333
- package/ir/allocation.ts +0 -74
- package/ir/core-model.ts +0 -129
- package/ir/core.ts +0 -64
- package/ir/declarations.ts +0 -208
- package/ir/diagnostics.ts +0 -43
- package/ir/domains.ts +0 -96
- package/ir/index.ts +0 -8
- package/ir/link.ts +0 -185
- package/ir/model.ts +0 -346
- package/ir/routine.ts +0 -859
- package/ir/scalars.ts +0 -675
- package/ir/types.ts +0 -76
- package/project/artifacts.ts +0 -277
- package/project/cli.ts +0 -395
- package/project/index.ts +0 -1
- package/project/plant.ts +0 -509
- package/project/project.ts +0 -358
- package/project/server.ts +0 -113
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import {
|
|
3
|
+
buildTargetFor,
|
|
4
|
+
controllerFor,
|
|
5
|
+
type Environment,
|
|
6
|
+
loadTsplcConfig,
|
|
7
|
+
rawBuildConfig,
|
|
8
|
+
} from "@tsplc/config";
|
|
9
|
+
import {
|
|
10
|
+
buildProject as buildSt,
|
|
11
|
+
configureDocker,
|
|
12
|
+
configureRuntime,
|
|
13
|
+
inspectController,
|
|
14
|
+
installLibraries,
|
|
15
|
+
loadSources,
|
|
16
|
+
rawEngineeringSettings,
|
|
17
|
+
resolveConfig,
|
|
18
|
+
runProject,
|
|
19
|
+
updateController,
|
|
20
|
+
} from "@tsplc/build";
|
|
21
|
+
import { checkHostConfig } from "@tsplc/compiler";
|
|
22
|
+
import { type Diagnostic, hasErrors } from "@tsplc/compiler/ir";
|
|
23
|
+
import { generateProject } from "@tsplc/typegen";
|
|
24
|
+
import { loadHardware, resolveIo } from "@tsplc/typegen/hardware";
|
|
25
|
+
import {
|
|
26
|
+
buildConfigs,
|
|
27
|
+
buildProject,
|
|
28
|
+
checkProject,
|
|
29
|
+
cleanProject,
|
|
30
|
+
projectTargets,
|
|
31
|
+
} from "./project.ts";
|
|
32
|
+
import { buildServer } from "./server.ts";
|
|
33
|
+
|
|
34
|
+
const projectCommands = [
|
|
35
|
+
"install",
|
|
36
|
+
"typegen",
|
|
37
|
+
"check",
|
|
38
|
+
"build",
|
|
39
|
+
"run",
|
|
40
|
+
"download",
|
|
41
|
+
"online-change",
|
|
42
|
+
"inspect",
|
|
43
|
+
"clean",
|
|
44
|
+
"configure",
|
|
45
|
+
] as const;
|
|
46
|
+
|
|
47
|
+
export type ProjectCommand = (typeof projectCommands)[number];
|
|
48
|
+
|
|
49
|
+
export const projectCommand = (name: string) =>
|
|
50
|
+
projectCommands.find((command) => command === name);
|
|
51
|
+
|
|
52
|
+
export interface ProjectFlags {
|
|
53
|
+
"emit-only"?: boolean;
|
|
54
|
+
format?: string;
|
|
55
|
+
read?: string[];
|
|
56
|
+
"initialize-user"?: boolean;
|
|
57
|
+
"frozen-lockfile"?: boolean;
|
|
58
|
+
check?: boolean;
|
|
59
|
+
plc?: boolean;
|
|
60
|
+
server?: boolean;
|
|
61
|
+
simulate?: boolean;
|
|
62
|
+
runtime?: boolean;
|
|
63
|
+
target?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Every command result; one whose diagnostics have errors fails the command. */
|
|
67
|
+
export type CommandResult = object & { diagnostics?: readonly Diagnostic[] };
|
|
68
|
+
|
|
69
|
+
/** A result whose diagnostics fail the command; the CLI reports the whole result. */
|
|
70
|
+
export class DiagnosticFailure extends Error {
|
|
71
|
+
constructor(readonly result: CommandResult) {
|
|
72
|
+
super("PLC validation failed.");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type LoadedConfig = Awaited<ReturnType<typeof loadTsplcConfig>>;
|
|
77
|
+
|
|
78
|
+
/** Rejects the flags that don't apply to `command`. */
|
|
79
|
+
export const checkProjectFlags = (
|
|
80
|
+
command: ProjectCommand,
|
|
81
|
+
flags: ProjectFlags,
|
|
82
|
+
) => {
|
|
83
|
+
if (flags.format && !["json", "text"].includes(flags.format)) {
|
|
84
|
+
throw new Error("--format must be json or text.");
|
|
85
|
+
}
|
|
86
|
+
if (flags["emit-only"] && command !== "build") {
|
|
87
|
+
throw new Error("--emit-only is supported by build only.");
|
|
88
|
+
}
|
|
89
|
+
if (flags.target && (command === "configure" || command === "clean")) {
|
|
90
|
+
throw new Error("--target applies only to commands that read the config.");
|
|
91
|
+
}
|
|
92
|
+
if (flags.runtime && command !== "configure") {
|
|
93
|
+
throw new Error("--runtime applies only to configure.");
|
|
94
|
+
}
|
|
95
|
+
if ((flags.plc || flags.server) && command !== "build") {
|
|
96
|
+
throw new Error("--plc and --server apply only to build.");
|
|
97
|
+
}
|
|
98
|
+
// deploy takes --simulate too, but runs as a plant command.
|
|
99
|
+
if (
|
|
100
|
+
flags.simulate &&
|
|
101
|
+
!["run", "download", "online-change"].includes(command)
|
|
102
|
+
) {
|
|
103
|
+
throw new Error(
|
|
104
|
+
"--simulate applies only to run, download, online-change and deploy.",
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
if (flags.plc && flags.server) {
|
|
108
|
+
throw new Error("Choose --plc or --server, or omit both for a full build.");
|
|
109
|
+
}
|
|
110
|
+
if (flags.server && flags["emit-only"]) {
|
|
111
|
+
throw new Error("--emit-only applies to PLC emission only.");
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const runProjectCommand = async (
|
|
116
|
+
command: ProjectCommand,
|
|
117
|
+
file: string,
|
|
118
|
+
flags: ProjectFlags,
|
|
119
|
+
env: Environment,
|
|
120
|
+
): Promise<CommandResult> => {
|
|
121
|
+
const load = () =>
|
|
122
|
+
loadTsplcConfig(file, { env, target: flags.target, forAgent: false });
|
|
123
|
+
switch (command) {
|
|
124
|
+
case "configure":
|
|
125
|
+
return configure(flags);
|
|
126
|
+
case "clean":
|
|
127
|
+
return cleanProject(file);
|
|
128
|
+
case "install":
|
|
129
|
+
return install(await load(), flags);
|
|
130
|
+
case "typegen":
|
|
131
|
+
return typegen(file, await load(), flags);
|
|
132
|
+
case "check":
|
|
133
|
+
return check(file, await loadCheckedConfig(file, load));
|
|
134
|
+
case "build":
|
|
135
|
+
return build(file, await loadCheckedConfig(file, load), flags);
|
|
136
|
+
case "run":
|
|
137
|
+
return run(file, await loadCheckedConfig(file, load), flags);
|
|
138
|
+
case "inspect":
|
|
139
|
+
return inspect(await load(), flags);
|
|
140
|
+
case "download":
|
|
141
|
+
case "online-change":
|
|
142
|
+
return updateProgram(
|
|
143
|
+
command,
|
|
144
|
+
file,
|
|
145
|
+
await loadCheckedConfig(file, load),
|
|
146
|
+
flags,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/** A config loaded after its host config check, whose diagnostics the compiler reports. */
|
|
152
|
+
interface CheckedConfig {
|
|
153
|
+
loaded: LoadedConfig;
|
|
154
|
+
hostConfigDiagnostics: readonly Diagnostic[];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Loads the config after type-checking it, so a type error fails before the config runs. */
|
|
158
|
+
const loadCheckedConfig = async (
|
|
159
|
+
file: string,
|
|
160
|
+
load: () => Promise<LoadedConfig>,
|
|
161
|
+
): Promise<CheckedConfig> => {
|
|
162
|
+
const hostConfigDiagnostics = checkHostConfig(resolve(file));
|
|
163
|
+
if (hasErrors(hostConfigDiagnostics)) {
|
|
164
|
+
throw new DiagnosticFailure({ diagnostics: hostConfigDiagnostics });
|
|
165
|
+
}
|
|
166
|
+
return { loaded: await load(), hostConfigDiagnostics };
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/** Builds the Docker image every build uses, or with `--runtime` the local PLC runtime's. */
|
|
170
|
+
const configure = async (flags: Pick<ProjectFlags, "runtime">) => {
|
|
171
|
+
await (flags.runtime ? configureRuntime() : configureDocker());
|
|
172
|
+
return { ok: true };
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const install = async (
|
|
176
|
+
{ config, root }: LoadedConfig,
|
|
177
|
+
flags: Pick<ProjectFlags, "frozen-lockfile">,
|
|
178
|
+
) => ({
|
|
179
|
+
libraries: await installLibraries(config.dependencies, root, {
|
|
180
|
+
frozen: flags["frozen-lockfile"],
|
|
181
|
+
}),
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const typegen = async (
|
|
185
|
+
file: string,
|
|
186
|
+
loaded: LoadedConfig,
|
|
187
|
+
flags: Pick<ProjectFlags, "check">,
|
|
188
|
+
) => {
|
|
189
|
+
const targets = await projectTargets(file, { loaded });
|
|
190
|
+
if (loaded.config.compiler && !flags.check) {
|
|
191
|
+
await generateProject(file, { hardwareOnly: true, loaded, targets });
|
|
192
|
+
const emitted = await buildProject(file, { emitOnly: true, loaded });
|
|
193
|
+
if (hasErrors(emitted.diagnostics)) {
|
|
194
|
+
throw new DiagnosticFailure(emitted);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return generateProject(file, { check: flags.check, loaded, targets });
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const check = async (
|
|
201
|
+
file: string,
|
|
202
|
+
{ loaded, hostConfigDiagnostics }: CheckedConfig,
|
|
203
|
+
) => {
|
|
204
|
+
const { config, configFile, root } = loaded;
|
|
205
|
+
if (config.compiler) {
|
|
206
|
+
return checkProject(file, { loaded, hostConfigDiagnostics });
|
|
207
|
+
}
|
|
208
|
+
const sources = await loadSources(
|
|
209
|
+
resolveConfig(
|
|
210
|
+
{
|
|
211
|
+
...rawBuildConfig(config),
|
|
212
|
+
io: resolveIo(config, await loadHardware(config, root)),
|
|
213
|
+
},
|
|
214
|
+
configFile,
|
|
215
|
+
),
|
|
216
|
+
);
|
|
217
|
+
return { objects: sources.objects.length };
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* The PLC program `build` and `run` compile: TypeScript through the compiler, or raw
|
|
222
|
+
* Structured Text straight to the vendor build. Either refreshes the generated types.
|
|
223
|
+
*/
|
|
224
|
+
const buildPlc = async (
|
|
225
|
+
command: "build" | "run",
|
|
226
|
+
file: string,
|
|
227
|
+
{ loaded, hostConfigDiagnostics }: CheckedConfig,
|
|
228
|
+
flags: Pick<ProjectFlags, "emit-only" | "frozen-lockfile" | "simulate">,
|
|
229
|
+
) => {
|
|
230
|
+
const { config } = loaded;
|
|
231
|
+
if (config.compiler) {
|
|
232
|
+
const built = await buildProject(file, {
|
|
233
|
+
emitOnly: flags["emit-only"],
|
|
234
|
+
frozenLockfile: flags["frozen-lockfile"],
|
|
235
|
+
...buildConfigs(loaded, flags),
|
|
236
|
+
hostConfigDiagnostics,
|
|
237
|
+
controller: controllerFor(config, command),
|
|
238
|
+
buildTarget: buildTargetFor(command),
|
|
239
|
+
});
|
|
240
|
+
if (hasErrors(built.diagnostics)) {
|
|
241
|
+
throw new DiagnosticFailure(built);
|
|
242
|
+
}
|
|
243
|
+
await generateProject(file, {
|
|
244
|
+
loaded,
|
|
245
|
+
targets: await projectTargets(file, { loaded }),
|
|
246
|
+
});
|
|
247
|
+
return built;
|
|
248
|
+
}
|
|
249
|
+
if (flags["emit-only"]) {
|
|
250
|
+
throw new Error("Raw Structured Text is already emitted.");
|
|
251
|
+
}
|
|
252
|
+
const built = await buildSt(
|
|
253
|
+
await rawEngineeringSettings(loaded, {
|
|
254
|
+
command,
|
|
255
|
+
frozenLockfile: flags["frozen-lockfile"],
|
|
256
|
+
simulate: flags.simulate,
|
|
257
|
+
}),
|
|
258
|
+
);
|
|
259
|
+
await generateProject(file, { hardwareOnly: !config.typegen, loaded });
|
|
260
|
+
return built;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
/** The PLC program and, unless `--plc` or `--emit-only` restricts it, the configured server. */
|
|
264
|
+
const build = async (
|
|
265
|
+
file: string,
|
|
266
|
+
checked: CheckedConfig,
|
|
267
|
+
flags: Pick<
|
|
268
|
+
ProjectFlags,
|
|
269
|
+
"emit-only" | "frozen-lockfile" | "plc" | "server" | "simulate"
|
|
270
|
+
>,
|
|
271
|
+
) => {
|
|
272
|
+
const { config, root } = checked.loaded;
|
|
273
|
+
if (flags.server) {
|
|
274
|
+
return buildServer(config, root);
|
|
275
|
+
}
|
|
276
|
+
const plc = await buildPlc("build", file, checked, flags);
|
|
277
|
+
if (flags.plc || flags["emit-only"] || !config.server?.runtime) {
|
|
278
|
+
return plc;
|
|
279
|
+
}
|
|
280
|
+
return { ...plc, ...(await buildServer(config, root)) };
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const run = async (
|
|
284
|
+
file: string,
|
|
285
|
+
checked: CheckedConfig,
|
|
286
|
+
flags: Pick<ProjectFlags, "frozen-lockfile" | "simulate">,
|
|
287
|
+
) => {
|
|
288
|
+
const { config, configFile } = checked.loaded;
|
|
289
|
+
const built = await buildPlc("run", file, checked, flags);
|
|
290
|
+
if (!config.build) {
|
|
291
|
+
throw new Error("Configure build to run this project.");
|
|
292
|
+
}
|
|
293
|
+
await runProject(
|
|
294
|
+
resolveConfig(
|
|
295
|
+
config.compiler ? config.build : rawBuildConfig(config),
|
|
296
|
+
configFile,
|
|
297
|
+
),
|
|
298
|
+
config.name,
|
|
299
|
+
);
|
|
300
|
+
return built;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
const inspect = async (
|
|
304
|
+
{ config, configFile }: LoadedConfig,
|
|
305
|
+
flags: Pick<ProjectFlags, "read">,
|
|
306
|
+
) => {
|
|
307
|
+
if (!config.build) {
|
|
308
|
+
throw new Error("Configure build settings and controller connection.");
|
|
309
|
+
}
|
|
310
|
+
// Inspection needs only the connection/baseline. It must remain usable
|
|
311
|
+
// when local sources, descriptors or dependency caches are unavailable.
|
|
312
|
+
return inspectController(
|
|
313
|
+
resolveConfig(
|
|
314
|
+
{ ...config.build, controller: controllerFor(config, "inspect") },
|
|
315
|
+
configFile,
|
|
316
|
+
),
|
|
317
|
+
flags.read,
|
|
318
|
+
);
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
/** Downloads or online-changes the program on the configured controller. */
|
|
322
|
+
const updateProgram = async (
|
|
323
|
+
operation: "download" | "online-change",
|
|
324
|
+
file: string,
|
|
325
|
+
checked: CheckedConfig,
|
|
326
|
+
flags: Pick<
|
|
327
|
+
ProjectFlags,
|
|
328
|
+
"frozen-lockfile" | "simulate" | "initialize-user" | "read"
|
|
329
|
+
>,
|
|
330
|
+
) => {
|
|
331
|
+
const { config } = checked.loaded;
|
|
332
|
+
if (!config.build) {
|
|
333
|
+
throw new Error("Configure build settings and controller connection.");
|
|
334
|
+
}
|
|
335
|
+
const settings = config.compiler
|
|
336
|
+
? await emittedControllerSettings(operation, file, checked, flags)
|
|
337
|
+
: await rawEngineeringSettings(checked.loaded, {
|
|
338
|
+
command: operation,
|
|
339
|
+
frozenLockfile: flags["frozen-lockfile"],
|
|
340
|
+
simulate: flags.simulate,
|
|
341
|
+
});
|
|
342
|
+
return updateController(settings, operation, {
|
|
343
|
+
initializeUser: flags["initialize-user"],
|
|
344
|
+
read: flags.read,
|
|
345
|
+
});
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const emittedControllerSettings = async (
|
|
349
|
+
operation: "download" | "online-change",
|
|
350
|
+
file: string,
|
|
351
|
+
{ loaded, hostConfigDiagnostics }: CheckedConfig,
|
|
352
|
+
flags: Pick<ProjectFlags, "frozen-lockfile" | "simulate">,
|
|
353
|
+
) => {
|
|
354
|
+
const emitted = await buildProject(file, {
|
|
355
|
+
emitOnly: true,
|
|
356
|
+
forController: true,
|
|
357
|
+
frozenLockfile: flags["frozen-lockfile"],
|
|
358
|
+
...buildConfigs(loaded, flags),
|
|
359
|
+
hostConfigDiagnostics,
|
|
360
|
+
controller: controllerFor(loaded.config, operation),
|
|
361
|
+
buildTarget: buildTargetFor(operation),
|
|
362
|
+
});
|
|
363
|
+
if (hasErrors(emitted.diagnostics)) {
|
|
364
|
+
throw new DiagnosticFailure(emitted);
|
|
365
|
+
}
|
|
366
|
+
if (!emitted.controllerConfig) {
|
|
367
|
+
throw new Error("Configure build settings for deployment.");
|
|
368
|
+
}
|
|
369
|
+
// Emission already resolves the generated entry/task paths. Passing
|
|
370
|
+
// this through the input schema again would reject its configFile.
|
|
371
|
+
return { ...emitted.controllerConfig, io: {} };
|
|
372
|
+
};
|