@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
package/dist/cli.js.map
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../project/
|
|
3
|
+
"sources": ["../src/project/cli.ts", "../src/project/debugger.ts", "../src/project/plant.ts", "../src/project/release.ts", "../src/project/project.ts", "../src/project/artifacts.ts", "../src/project/server.ts", "../src/project/terminal.ts", "../src/project/plant.ts", "../src/project/project-commands.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"
|
|
6
|
-
"#!/usr/bin/env bun\nimport { buildServer } from \"./server.ts\";\nimport { existsSync } from \"node:fs\";\nimport { parseArgs } from \"node:util\";\nimport { relative, resolve } from \"node:path\";\nimport {\n buildTargetFor,\n controllerFor,\n loadTsplcConfig,\n rawBuildConfig,\n simulationConfig,\n} from \"@tsplc/config\";\nimport {\n buildProject as buildSt,\n configureDocker,\n configureRuntime,\n inspectController,\n installLibraries,\n loadSources,\n resolveConfig,\n runProject,\n updateController,\n} from \"@tsplc/build\";\nimport { checkHostConfig } from \"@tsplc/compiler\";\nimport {\n createDebugger,\n createLoginAdapter,\n createOpcUaAdapter,\n loadManifest,\n opcUaConnection,\n serveDebugger,\n} from \"@tsplc/debug\";\nimport { type Diagnostic, formatDiagnostic, hasErrors } from \"@tsplc/compiler/ir\";\nimport { deviceTree } from \"@tsplc/typegen\";\nimport { loadHardware, resolveIo } from \"@tsplc/typegen/hardware\";\nimport { generateProject } from \"@tsplc/typegen\";\nimport {\n connect,\n plantCommands,\n readThroughAgent,\n runPlantCommand,\n serverTokenEnv,\n} from \"./plant.ts\";\nimport { buildProject, checkProject, cleanProject, projectTargets } from \"./project.ts\";\n\nasync function main() {\n const { values, positionals } = parseArgs({\n allowPositionals: true,\n options: {\n config: { type: \"string\" },\n help: { type: \"boolean\", short: \"h\" },\n \"emit-only\": { type: \"boolean\" },\n format: { type: \"string\" },\n read: { type: \"string\", multiple: true },\n \"initialize-user\": { type: \"boolean\" },\n \"frozen-lockfile\": { type: \"boolean\" },\n check: { type: \"boolean\" },\n plc: { type: \"boolean\" },\n server: { type: \"boolean\" },\n simulate: { type: \"boolean\" },\n runtime: { type: \"boolean\" },\n download: { type: \"boolean\" },\n restore: { type: \"boolean\" },\n select: { type: \"boolean\" },\n yes: { type: \"boolean\", short: \"y\" },\n port: { type: \"string\" },\n \"server-url\": { type: \"string\" },\n opcua: { type: \"boolean\" },\n },\n });\n const command = positionals[0],\n file = values.config ?? \"tsplc.config.ts\";\n if (!command || values.help) {\n console.log(\n `tsplc install|typegen|check|build|run|download|online-change|inspect|clean|configure [--config tsplc.config.ts] [--plc|--server] [--simulate] [--runtime] [--emit-only] [--format json] [--read symbol]\n\nPlant agent (TSPLC_AGENT_URL, TSPLC_AGENT_TOKEN):\n tsplc deploy [--download] [--select] [--initialize-user] [--simulate]\n tsplc target | status | login | logout\n tsplc vars [path] | read <expression>... | write <expression> <value>\n tsplc force <expression> <value> | unforce [expression]... [--restore]\n tsplc start | stop | reset warm|cold (-y skips confirmations)\n\nDebugger, on http://127.0.0.1, for the built .tsplc/artifacts/st/debug.json; it reads through\nthe plant agent's login (TSPLC_AGENT_URL, TSPLC_AGENT_TOKEN), or --opcua at config monitor:\n tsplc debug [--port 4870] [--server-url url] [--opcua]`,\n );\n return 0;\n }\n if (command === \"debug\") {\n if (positionals.length > 1)\n throw new Error(\"Usage: tsplc debug [--port 4870] [--server-url url] [--opcua]\");\n await serveProjectDebugger(await loadTsplcConfig(file), values);\n return 0;\n }\n if (plantCommands.has(command)) {\n const failed = await runPlantCommand(command, positionals.slice(1), values, {\n file,\n load: () => loadTsplcConfig(file),\n });\n return failed ? report(failed, values.format) : 0;\n }\n if (positionals.length > 1) throw new Error(\"Specify one command.\");\n if (\n ![\n \"install\",\n \"typegen\",\n \"check\",\n \"build\",\n \"run\",\n \"download\",\n \"online-change\",\n \"inspect\",\n \"clean\",\n \"configure\",\n ].includes(command)\n )\n throw new Error(`Unknown command ${command}.`);\n if (values.format && ![\"json\", \"text\"].includes(values.format))\n throw new Error(\"--format must be json or text.\");\n if (values[\"emit-only\"] && command !== \"build\")\n throw new Error(\"--emit-only is supported by build only.\");\n if (values.runtime && command !== \"configure\")\n throw new Error(\"--runtime applies only to configure.\");\n if ((values.plc || values.server) && command !== \"build\")\n throw new Error(\"--plc and --server apply only to build.\");\n if (values.simulate && ![\"run\", \"download\", \"online-change\", \"deploy\"].includes(command))\n throw new Error(\"--simulate applies only to run, download, online-change and deploy.\");\n if (values.plc && values.server)\n throw new Error(\"Choose --plc or --server, or omit both for a full build.\");\n if (values.server && values[\"emit-only\"])\n throw new Error(\"--emit-only applies to PLC emission only.\");\n const log = console.log,\n previousLogTarget = process.env[\"TSPLC_LOG_STDERR\"];\n if (values.format === \"json\") {\n console.log = console.error;\n process.env[\"TSPLC_LOG_STDERR\"] = \"1\";\n }\n let result: unknown;\n try {\n if (command === \"configure\") {\n await (values.runtime ? configureRuntime() : configureDocker());\n result = { ok: true };\n } else if (command === \"clean\") {\n result = await cleanProject(file);\n } else {\n if ([\"check\", \"build\", \"run\", \"download\", \"online-change\"].includes(command)) {\n const diagnostics = checkHostConfig(resolve(file));\n if (hasErrors(diagnostics)) throw new DiagnosticFailure({ diagnostics });\n }\n const loaded = await loadTsplcConfig(file);\n const { config, configFile, root } = loaded;\n // Generated types keep describing the hardware project; only the download omits fieldbus I/O.\n const target = values.simulate ? { ...loaded, config: simulationConfig(config) } : loaded;\n if (command === \"install\")\n result = {\n libraries: await installLibraries(config.dependencies, root, {\n frozen: values[\"frozen-lockfile\"],\n }),\n };\n else if (command === \"typegen\") {\n const targets = await projectTargets(file, { loaded });\n if (config.compiler && !values.check) {\n await generateProject(file, { hardwareOnly: true, loaded, targets });\n const emitted = await buildProject(file, { emitOnly: true, loaded });\n if (hasErrors(emitted.diagnostics)) throw new DiagnosticFailure(emitted);\n }\n result = await generateProject(file, { check: values.check, loaded, targets });\n } else if (command === \"check\") {\n result = config.compiler\n ? await checkProject(file, { loaded })\n : {\n objects: (\n await loadSources(\n resolveConfig(\n {\n ...rawBuildConfig(config),\n io: resolveIo(config, await loadHardware(config, root)),\n },\n configFile,\n ),\n )\n ).objects.length,\n };\n } else if (command === \"build\" && values.server) {\n result = await buildServer(config, root);\n } else if (command === \"build\" || command === \"run\") {\n if (config.compiler) {\n const built = await buildProject(file, {\n emitOnly: values[\"emit-only\"],\n frozenLockfile: values[\"frozen-lockfile\"],\n loaded: target,\n ...(values.simulate && { configured: config }),\n controller: controllerFor(config, command),\n buildTarget: buildTargetFor(command),\n });\n if (hasErrors(built.diagnostics)) throw new DiagnosticFailure(built);\n await generateProject(file, {\n loaded,\n targets: await projectTargets(file, { loaded }),\n });\n result = built;\n } else {\n if (values[\"emit-only\"]) throw new Error(\"Raw Structured Text is already emitted.\");\n if (!config.build) throw new Error(\"Configure build settings.\");\n const build = rawBuildConfig(config);\n const libraries = await installLibraries(config.dependencies, root, {\n frozen: values[\"frozen-lockfile\"],\n });\n const hardware = await loadHardware(target.config, root);\n result = await buildSt(\n resolveConfig(\n {\n ...build,\n libraries,\n io: resolveIo(target.config, hardware),\n deviceTree: await deviceTree(target.config, hardware),\n controller: controllerFor(config, command),\n },\n configFile,\n ),\n );\n await generateProject(file, { hardwareOnly: !config.typegen, loaded });\n }\n if (command === \"build\" && !values.plc && !values[\"emit-only\"] && config.server?.runtime) {\n const backend = await buildServer(config, root);\n result = { ...(typeof result === \"object\" && result !== null ? result : {}), ...backend };\n }\n if (command === \"run\") {\n if (!config.build) throw new Error(\"Configure build to run this project.\");\n await runProject(\n resolveConfig(config.compiler ? config.build : rawBuildConfig(config), configFile),\n config.name,\n );\n }\n } else if (command === \"inspect\") {\n if (!config.build) throw new Error(\"Configure build settings and controller connection.\");\n // Inspection needs only the connection/baseline. It must remain usable\n // when local sources, descriptors or dependency caches are unavailable.\n result = await inspectController(\n resolveConfig(\n { ...config.build, controller: controllerFor(config, command) },\n configFile,\n ),\n values.read,\n );\n } else if ([\"download\", \"online-change\"].includes(command)) {\n if (!config.build) throw new Error(\"Configure build settings and controller connection.\");\n let settings: ReturnType<typeof resolveConfig>;\n if (config.compiler) {\n const emitted = await buildProject(file, {\n emitOnly: true,\n forController: true,\n frozenLockfile: values[\"frozen-lockfile\"],\n loaded: target,\n ...(values.simulate && { configured: config }),\n buildTarget: buildTargetFor(command),\n });\n if (hasErrors(emitted.diagnostics)) throw new DiagnosticFailure(emitted);\n if (!emitted.controllerConfig)\n throw new Error(\"Configure build settings for deployment.\");\n // Emission already resolves the generated entry/task paths. Passing\n // this through the input schema again would reject its configFile.\n settings = { ...emitted.controllerConfig, io: {} };\n } else\n settings = {\n ...resolveConfig(\n {\n ...rawBuildConfig(config),\n io: resolveIo(target.config, await loadHardware(target.config, root)),\n },\n configFile,\n ),\n libraries: await installLibraries(config.dependencies, root, {\n frozen: values[\"frozen-lockfile\"],\n }),\n };\n result = await updateController(\n { ...settings, controller: controllerFor(config, command) },\n command as \"download\" | \"online-change\",\n {\n initializeUser: values[\"initialize-user\"],\n read: values.read,\n },\n );\n } else throw new Error(`Unknown command ${command}.`);\n }\n } finally {\n console.log = log;\n if (previousLogTarget === undefined) delete process.env[\"TSPLC_LOG_STDERR\"];\n else process.env[\"TSPLC_LOG_STDERR\"] = previousLogTarget;\n }\n return report(result, values.format);\n}\n/**\n * Serves the debugger for the project's last build until interrupted. It reads the controller\n * through the plant agent's login, or with `--opcua` at the config's `monitor` endpoint, and\n * follows the server's telemetry and requests when the server's base URL (`--server-url`, or\n * `server.baseUrlEnv`) and the PLC's bearer token are in the environment.\n */\nasync function serveProjectDebugger(\n { config, root }: Awaited<ReturnType<typeof loadTsplcConfig>>,\n flags: { port?: string; \"server-url\"?: string; opcua?: boolean },\n) {\n if (flags.opcua && !config.monitor)\n throw new Error(\"Configure monitor with the controller's OPC UA endpoint to use --opcua.\");\n const agentUrl = process.env[\"TSPLC_AGENT_URL\"];\n if (!flags.opcua && !(agentUrl && process.env[\"TSPLC_AGENT_TOKEN\"]))\n throw new Error(\n \"Set TSPLC_AGENT_URL and TSPLC_AGENT_TOKEN to read through the plant agent's login, or pass --opcua for a local virtual PLC.\",\n );\n const file = resolve(root, \".tsplc/artifacts/st/debug.json\");\n if (!existsSync(file))\n throw new Error(\n `No debug manifest at ${relative(process.cwd(), file)}: build with debug configured.`,\n );\n const port = Number(flags.port ?? 4870);\n if (!Number.isInteger(port) || port < 1 || port > 65535)\n throw new Error(\"--port must be a TCP port.\");\n const manifest = await loadManifest(file);\n const serverUrl =\n flags[\"server-url\"] ?? (config.server?.baseUrlEnv && process.env[config.server.baseUrlEnv]);\n const tokenEnv = serverTokenEnv(config);\n const token = tokenEnv && process.env[tokenEnv];\n const log = (message: string) => console.log(`${new Date().toISOString()} ${message}`);\n const debug = await createDebugger({\n manifest,\n adapter:\n flags.opcua && config.monitor\n ? createOpcUaAdapter(opcUaConnection(config.monitor, { root, env: process.env }))\n : createLoginAdapter({\n read: readThroughAgent(connect()),\n probe: manifest.build.target,\n endpoint: `the plant agent at ${agentUrl}`,\n }),\n stateDirectory: resolve(root, \".tsplc/debug\"),\n watch: config.debug?.watch ?? {},\n ...(serverUrl && token && { server: { url: serverUrl, token } }),\n projectRoot: root,\n log,\n });\n const server = serveDebugger(debug, { port, log });\n console.log(`tsPLC debugger at ${server.url}`);\n if (!serverUrl || !token)\n console.log(\n \"Not following the server's telemetry and requests: set server.baseUrlEnv or --server-url, and the server's bearer token variable.\",\n );\n await new Promise((stopped) => {\n process.once(\"SIGINT\", stopped);\n process.once(\"SIGTERM\", stopped);\n });\n await server.stop(true);\n await debug.close();\n}\nclass DiagnosticFailure extends Error {\n constructor(readonly result: unknown) {\n super(\"PLC validation failed.\");\n }\n}\nfunction report(result: unknown, format?: string) {\n const diagnostics =\n result && typeof result === \"object\" && \"diagnostics\" in result\n ? (result.diagnostics as Diagnostic[])\n : [];\n const ok = !hasErrors(diagnostics);\n if (format === \"json\")\n console.log(\n JSON.stringify({ ok, ...(result && typeof result === \"object\" ? result : { result }) }),\n );\n else {\n for (const diagnostic of diagnostics) console.error(formatDiagnostic(diagnostic));\n if (ok) console.log(\"tsPLC completed.\");\n }\n return ok ? 0 : 1;\n}\ntry {\n process.exitCode = await main();\n} catch (cause) {\n // main() may fail before its options parse, so detect JSON output from raw argv.\n const json = process.argv.includes(\"json\") || process.argv.includes(\"--format=json\");\n if (cause instanceof DiagnosticFailure) {\n process.exitCode = report(cause.result, json ? \"json\" : undefined);\n } else {\n const message = cause instanceof Error ? cause.message : String(cause);\n if (json)\n console.log(\n JSON.stringify({\n ok: false,\n diagnostics: [{ origin: \"config\", code: \"PLC5003\", severity: \"error\", message }],\n }),\n );\n else console.error(message);\n process.exitCode = 1;\n }\n}\n",
|
|
7
|
-
"import { existsSync } from \"node:fs\";\nimport { basename, relative, resolve, sep } from \"node:path\";\nimport { createInterface } from \"node:readline/promises\";\nimport { pathToFileURL } from \"node:url\";\nimport {\n AgentOperationError,\n type AgentClient,\n createAgentClient,\n type ReleaseFile,\n} from \"@tsplc/agent/client\";\nimport type { Credentials, ReleaseManifest, Target, Variable } from \"@tsplc/agent\";\nimport type { LoginCommand, LoginResult } from \"@tsplc/build\";\nimport { controllerFor, simulationConfig, type loadTsplcConfig } from \"@tsplc/config\";\nimport { LoginUnavailable, noLogin } from \"@tsplc/debug\";\nimport { hasErrors } from \"@tsplc/compiler/ir\";\nimport { generateProject } from \"@tsplc/typegen\";\nimport { z } from \"zod\";\nimport { buildProject, projectTargets } from \"./project.ts\";\nimport { bundleServer } from \"./server.ts\";\n\nexport const plantCommands = new Set([\n \"deploy\",\n \"target\",\n \"status\",\n \"login\",\n \"logout\",\n \"vars\",\n \"read\",\n \"write\",\n \"force\",\n \"unforce\",\n \"start\",\n \"stop\",\n \"reset\",\n]);\n\nexport interface PlantFlags {\n download?: boolean;\n \"initialize-user\"?: boolean;\n restore?: boolean;\n select?: boolean;\n simulate?: boolean;\n yes?: boolean;\n \"frozen-lockfile\"?: boolean;\n}\n\ntype LoadedConfig = Awaited<ReturnType<typeof loadTsplcConfig>>;\n\nconst ask = async (question: string) => {\n const lines = createInterface({ input: process.stdin, output: process.stdout });\n try {\n return (await lines.question(question)).trim();\n } finally {\n lines.close();\n }\n};\n\n/** Reads a line without echoing it. */\nconst askSecret = (question: string) =>\n new Promise<string>((accept, reject) => {\n if (!process.stdin.isTTY) {\n reject(new Error(\"The controller password needs an interactive terminal.\"));\n return;\n }\n // Echo goes off before the prompt appears, so nothing typed at it can show.\n process.stdin.setRawMode(true);\n process.stdin.setEncoding(\"utf8\");\n process.stdin.resume();\n process.stdout.write(question);\n let secret = \"\";\n const finish = () => {\n process.stdin.off(\"data\", read);\n process.stdin.setRawMode(false);\n process.stdin.pause();\n process.stdout.write(\"\\n\");\n };\n const read = (text: string) => {\n for (const character of text) {\n if (character === \"\\r\" || character === \"\\n\") {\n finish();\n accept(secret);\n return;\n }\n if (character === \"\\u0003\") {\n finish();\n reject(new Error(\"Cancelled.\"));\n return;\n }\n secret = character === \"\\u007f\" ? secret.slice(0, -1) : secret + character;\n }\n };\n process.stdin.on(\"data\", read);\n });\n\nconst choose = async <T>(question: string, items: readonly T[], label: (item: T) => string) => {\n items.forEach((item, index) => console.log(` ${index + 1}. ${label(item)}`));\n while (true) {\n const item = items[Number(await ask(`${question} [1-${items.length}]: `)) - 1];\n if (item !== undefined) return item;\n }\n};\n\nconst confirm = async (question: string, flags: PlantFlags) =>\n flags.yes || /^y(es)?$/i.test(await ask(`${question} [y/N]: `));\n\nconst askCredentials = async (): Promise<Credentials> => ({\n username: await ask(\"Controller username: \"),\n password: await askSecret(\"Controller password: \"),\n});\n\nconst progress = (message: string) => console.log(` ${message}`);\n\n/** Prints progress with the minutes and seconds since it was made, so the slow steps show. */\nconst timedProgress = () => {\n const start = Date.now();\n return (message: string) => {\n const seconds = Math.round((Date.now() - start) / 1000);\n progress(`${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, \"0\")} ${message}`);\n };\n};\n\n/** The plant agent named by TSPLC_AGENT_URL and TSPLC_AGENT_TOKEN. */\nexport const connect = () => {\n const environment = z\n .object({\n TSPLC_AGENT_URL: z.url({\n error: \"Set TSPLC_AGENT_URL to the plant agent, such as http://line-pc:4850\",\n }),\n TSPLC_AGENT_TOKEN: z.string({ error: \"Set TSPLC_AGENT_TOKEN to the plant agent's token\" }),\n })\n .parse(process.env);\n return createAgentClient({\n url: environment.TSPLC_AGENT_URL,\n token: environment.TSPLC_AGENT_TOKEN,\n });\n};\n\n/**\n * Reads through the agent's open login, as `tsplc read` does, without opening one: the\n * debugger has no controller credentials.\n */\nexport const readThroughAgent =\n (agent: AgentClient) =>\n async ([first, ...rest]: string[]) => {\n if (!first) return {};\n try {\n const result = await agent.command({ command: \"read\", expressions: [first, ...rest] });\n if (!(\"values\" in result)) throw new Error(\"The agent answered a read without values\");\n return result.values;\n } catch (error) {\n const { login } = await agent.status();\n if (!login) throw new LoginUnavailable(noLogin, { cause: error });\n if (\"error\" in login) throw new Error(login.error, { cause: error });\n throw error;\n }\n };\n\nconst selectTarget = async (agent: AgentClient): Promise<Target> => {\n const interfaces = await agent.interfaces();\n if (!interfaces.length) throw new Error(\"The plant PC has no IPv4 network.\");\n const network =\n interfaces.length === 1 && interfaces[0]\n ? interfaces[0]\n : await choose(\n \"Which network is the controller on?\",\n interfaces,\n (item) => `${item.name} ${item.address}/${item.prefixLength}`,\n );\n console.log(`Scanning ${network.address}/${network.prefixLength} for CODESYS controllers…`);\n const found = await agent.discover(network.name);\n const manual = { address: \"\", port: 11740, hostname: null };\n const choice = await choose(\"Which controller?\", [...found, manual], (item) =>\n item === manual\n ? \"Enter an address\"\n : `${item.address}${item.hostname ? ` (${item.hostname})` : \"\"}`,\n );\n const host = choice === manual ? await ask(\"Controller address: \") : choice.address;\n return agent.setTarget({ host, port: choice.port });\n};\n\n/** Every published leaf the generated contract describes, as CODESYS expressions name it. */\nconst contractVariables = async (config: LoadedConfig[\"config\"], root: string) => {\n if (!config.typegen) return [];\n const contract = z\n .object({\n symbols: z.array(z.object({ name: z.string(), gvl: z.string(), type: z.string() })),\n typeFields: z.record(z.string(), z.array(z.object({ field: z.string(), type: z.string() }))),\n })\n .parse(await import(pathToFileURL(resolve(root, config.typegen.dir, \"plc.ts\")).href));\n return contract.symbols.flatMap(({ name, gvl, type }): Variable[] => {\n const path = `${gvl}.${name}`;\n const fields = contract.typeFields[type];\n if (!fields) return [{ path, type }];\n return fields.map((field) => ({\n path:\n field.field === \"\"\n ? path\n : `${path}${field.field.startsWith(\"[\") ? \"\" : \".\"}${field.field}`,\n type: field.type,\n }));\n });\n};\n\n/**\n * The variable holding the bearer token the PLC sends the project's own server: the HTTP\n * credential for the server's base URL.\n */\nexport const serverTokenEnv = (config: LoadedConfig[\"config\"]) =>\n config.codesys?.http?.credentials.find(({ originEnv }) => originEnv === config.server?.baseUrlEnv)\n ?.bearerTokenEnv;\n\n/**\n * Compiles the program and bundles its server into the files `tsplc deploy` uploads: the\n * production program, or with `--simulate` the development one without fieldbus I/O, for a\n * virtual PLC whose inputs a plant simulation writes, as `tsplc run --simulate` builds it.\n */\nconst prepareRelease = async (file: string, loaded: LoadedConfig, flags: PlantFlags) => {\n const { config, root } = loaded;\n if (!config.compiler) throw new Error(\"tsplc deploy deploys tsPLC programs; configure compiler.\");\n const command = flags.simulate ? \"run\" : \"deploy\";\n const emitted = await buildProject(file, {\n emitOnly: true,\n forController: true,\n frozenLockfile: flags[\"frozen-lockfile\"],\n ...(flags.simulate\n ? { loaded: { ...loaded, config: simulationConfig(config) }, configured: config }\n : { loaded }),\n buildTarget: flags.simulate ? \"development\" : \"production\",\n controller: controllerFor(config, command),\n });\n if (hasErrors(emitted.diagnostics)) return { diagnostics: emitted.diagnostics };\n const settings = emitted.controllerConfig;\n if (!settings) throw new Error(\"Configure build settings for deployment.\");\n await generateProject(file, { loaded, targets: await projectTargets(file, { loaded }) });\n\n const portable = (path: string) => path.split(sep).join(\"/\");\n const libraries = (settings.libraries ?? []).map((library) => ({\n ...library,\n release: `libraries/${library.sha256}-${basename(library.path)}`,\n }));\n const files: ReleaseFile[] = [\n { path: \"template.project\", content: Bun.file(settings.template) },\n ...libraries.map((library) => ({ path: library.release, content: Bun.file(library.path) })),\n ];\n // The agent compiles only the ST. Plain TypeScript programs emit their generated modules under `.tsplc/`.\n for await (const source of new Bun.Glob(\"**/*.st\").scan({ cwd: settings.sourceDir, dot: true }))\n files.push({\n path: `st/${portable(source)}`,\n content: Bun.file(resolve(settings.sourceDir, source)),\n });\n // The agent's debugger reads the program through its debug manifest.\n const debugManifest = resolve(settings.sourceDir, \"debug.json\");\n if (existsSync(debugManifest))\n files.push({ path: \"debug.json\", content: Bun.file(debugManifest) });\n let server: string | undefined;\n if (config.server?.runtime) {\n const script = await bundleServer(config, root);\n server = `server/${basename(script)}`;\n files.push({ path: server, content: Bun.file(script) });\n }\n const manifest: ReleaseManifest = {\n // Paths are relative to the release; the agent supplies the output and controller settings.\n config: {\n io: {},\n deviceTree: settings.deviceTree,\n controller: settings.controller,\n libraryReferences: settings.libraryReferences,\n libraries: libraries.map(({ release, ...library }) => ({ ...library, path: release })),\n task: settings.task,\n tasks: settings.tasks,\n removeObjects: settings.removeObjects,\n symbols: settings.symbols,\n timeouts: settings.timeouts,\n template: \"template.project\",\n sourceDir: \"st\",\n entry: `st/${portable(relative(settings.sourceDir, settings.entry))}`,\n },\n variables: await contractVariables(config, root),\n server,\n debug: config.debug,\n serverTokenEnv: serverTokenEnv(config),\n };\n return { release: { manifest, files } };\n};\n\nconst deploy = async (\n agent: AgentClient,\n file: string,\n loaded: LoadedConfig,\n flags: PlantFlags,\n) => {\n const status = await agent.status();\n if (status.login) throw new Error(\"A login is open; log out before deploying: tsplc logout\");\n const target = !status.target || flags.select ? await selectTarget(agent) : status.target;\n console.log(`Building the release for ${target.host}…`);\n const building = timedProgress();\n const { release, diagnostics } = await prepareRelease(file, loaded, flags);\n if (!release) return { diagnostics };\n building(\"Built\");\n if (\n flags.download &&\n !(await confirm(\n \"A full download stops the running application while it loads. Continue?\",\n flags,\n ))\n )\n throw new Error(\"Cancelled.\");\n const credentials = await askCredentials();\n const settings = {\n credentials,\n download: flags.download ?? false,\n initializeUser: flags[\"initialize-user\"] ?? false,\n };\n console.log(\n release.manifest.server ? \"Deploying the server and the program…\" : \"Deploying the program…\",\n );\n const deploying = timedProgress();\n deploying(\"Uploading\");\n try {\n return await agent.deploy(release, settings, deploying);\n } catch (error) {\n if (\n !(error instanceof AgentOperationError && error.downloadRequired) ||\n !(await confirm(\n `${error.message}. A full download stops the running application while it loads. Download now?`,\n flags,\n ))\n )\n throw error;\n return agent.deploy(release, { ...settings, download: true }, timedProgress());\n }\n};\n\n/** Opens a login when none is working; it stays open across commands until `tsplc logout`. */\nconst ensureLogin = async (agent: AgentClient) => {\n const { login } = await agent.status();\n if (login && \"state\" in login) return;\n if (login) {\n console.log(`The open login failed (${login.error}); replacing it.`);\n await agent.logout();\n }\n const credentials = await askCredentials();\n console.log(\n \"Logging in. CODESYS takes a few minutes to start; the login stays open until tsplc logout.\",\n );\n await agent.login(credentials, progress);\n};\n\n/** The children of `prefix` in the variable tree, with array indexes folded into one range. */\nexport const variableChildren = (variables: readonly Variable[], prefix: string) => {\n const children = new Map<string, { type?: string; leaves: number }>();\n const start = prefix.toLowerCase();\n for (const { path, type } of variables) {\n const lower = path.toLowerCase();\n if (\n prefix &&\n !(lower === start || lower.startsWith(`${start}.`) || lower.startsWith(`${start}[`))\n )\n continue;\n const rest = path.slice(prefix.length).replace(/^\\./, \"\");\n if (rest === \"\") return [{ name: path, type, leaves: 1 }];\n const name = /^(\\[[^\\]]*\\]|[^.[]+)/.exec(rest)?.[0] ?? rest;\n const child = children.get(name) ?? { leaves: 0 };\n children.set(name, { type: rest === name ? type : undefined, leaves: child.leaves + 1 });\n }\n const indexes = [...children.keys()]\n .filter((name) => /^\\[\\d+\\]$/.test(name))\n .map((name) => Number(name.slice(1, -1)));\n const listed = [...children].filter(([name]) => !/^\\[\\d+\\]$/.test(name));\n if (indexes.length) {\n const first = children.get(`[${Math.min(...indexes)}]`);\n listed.unshift([`[${Math.min(...indexes)}..${Math.max(...indexes)}]`, first ?? { leaves: 0 }]);\n }\n return listed.map(([name, child]) => ({ name, ...child }));\n};\n\nconst printLogin = (result: LoginResult) => {\n if (\"values\" in result) {\n for (const [expression, value] of Object.entries(result.values))\n console.log(`${expression} = ${value}`);\n return;\n }\n console.log(`Application ${result.state}`);\n if (result.forced.length) console.log(`Forced: ${result.forced.join(\", \")}`);\n};\n\n/**\n * Runs a command against the plant agent named by TSPLC_AGENT_URL and TSPLC_AGENT_TOKEN.\n * Returns a deployment's compiler diagnostics when the program doesn't compile.\n */\nexport const runPlantCommand = async (\n command: string,\n args: string[],\n flags: PlantFlags,\n project: { file: string; load: () => Promise<LoadedConfig> },\n) => {\n const agent = connect();\n const expect = (count: number, usage: string) => {\n if (args.length !== count) throw new Error(`Usage: tsplc ${command} ${usage}`);\n };\n const send = async (loginCommand: LoginCommand) => {\n await ensureLogin(agent);\n printLogin(await agent.command(loginCommand));\n };\n switch (command) {\n case \"deploy\": {\n expect(0, \"[--download] [--select] [--initialize-user] [--simulate]\");\n const deployed = await deploy(agent, project.file, await project.load(), flags);\n if (\"diagnostics\" in deployed) return deployed;\n console.log(`Deployed release ${deployed.id} (${deployed.operation}).`);\n return;\n }\n case \"target\": {\n expect(0, \"\");\n const target = await selectTarget(agent);\n console.log(`Deployments now go to ${target.host}:${target.port}.`);\n return;\n }\n case \"status\": {\n expect(0, \"\");\n const status = await agent.status();\n console.log(\n `Controller ${status.target ? `${status.target.host}:${status.target.port}` : \"not selected (tsplc target)\"}`,\n );\n console.log(\n `Release ${status.release ? `${status.release.id}, ${status.release.operation} at ${status.release.deployedAt}` : \"none\"}`,\n );\n console.log(\n `Server ${status.server ? `${status.server.running ? \"running\" : \"restarting\"} (${status.server.executable})` : \"none\"}`,\n );\n const { login } = status;\n if (!login) console.log(\"Login closed\");\n else if (\"error\" in login) console.log(`Login failed: ${login.error} (tsplc logout)`);\n else\n console.log(\n `Login open; application ${login.state}${login.forced.length ? `; forced: ${login.forced.join(\", \")}` : \"\"}`,\n );\n return;\n }\n case \"login\":\n expect(0, \"\");\n await ensureLogin(agent);\n printLogin(await agent.command({ command: \"state\" }));\n return;\n case \"logout\": {\n expect(0, \"\");\n const { login } = await agent.status();\n const forced = login && \"forced\" in login ? login.forced : [];\n if (\n forced.length &&\n !(await confirm(\n `Forced: ${forced.join(\", \")}. Forces stay on the controller after logout. Log out anyway?`,\n flags,\n ))\n )\n throw new Error(\"Cancelled.\");\n const { failure } = await agent.logout();\n console.log(\n failure\n ? `The login couldn't log out (${failure}); its container was removed.`\n : \"Logged out.\",\n );\n return;\n }\n case \"vars\": {\n if (args.length > 1) throw new Error(\"Usage: tsplc vars [path]\");\n const variables = await agent.variables();\n const children = variableChildren(variables, args[0] ?? \"\");\n if (!children.length) throw new Error(`No published variable ${args[0]}.`);\n for (const child of children)\n console.log(`${child.name.padEnd(32)} ${child.type ?? `${child.leaves} variables`}`);\n return;\n }\n case \"read\": {\n const [first, ...rest] = args;\n if (!first) throw new Error(\"Usage: tsplc read <expression>...\");\n return send({ command: \"read\", expressions: [first, ...rest] });\n }\n case \"write\":\n case \"force\": {\n const [expression, value, ...extra] = args;\n if (!expression || !value || extra.length)\n throw new Error(`Usage: tsplc ${command} <expression> <value>`);\n return send({ command, values: { [expression]: value } });\n }\n case \"unforce\":\n return send({ command: \"unforce\", expressions: args, restore: flags.restore ?? false });\n case \"start\":\n expect(0, \"\");\n return send({ command: \"start\" });\n case \"stop\":\n expect(0, \"\");\n if (!(await confirm(\"Stop the application on the controller?\", flags)))\n throw new Error(\"Cancelled.\");\n return send({ command: \"stop\" });\n case \"reset\": {\n expect(1, \"warm|cold\");\n const kind = z.enum([\"warm\", \"cold\"]).parse(args[0]);\n if (\n !(await confirm(\n `Reset the application (${kind})? It stops and reinitializes its variables.`,\n flags,\n ))\n )\n throw new Error(\"Cancelled.\");\n return send({ command: \"reset\", kind: kind === \"warm\" ? \"Warm\" : \"Cold\" });\n }\n }\n};\n",
|
|
8
|
-
"import { copyFile, mkdir, mkdtemp, realpath, rm, writeFile } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport {\n buildCodesys,\n codesysBuildConfig,\n type CodesysPlan,\n type CodesysProject,\n type SourceMapping,\n diagnoseCodesys,\n emitCodesys,\n ioTargets,\n publicationSelectors,\n planCodesys,\n} from \"@tsplc/compiler/codesys\";\nimport { analyze, checkHostConfig } from \"@tsplc/compiler\";\nimport {\n type Controller,\n type BuildTarget,\n type NormalizedConfig,\n type ResolvedTsplcConfig,\n compilerConfig,\n loadTsplcConfig,\n} from \"@tsplc/config\";\nimport { deviceTree, type ProjectTargets, loadHardware, resolveIo } from \"@tsplc/typegen\";\nimport { installLibraries } from \"@tsplc/build\";\nimport { type Diagnostic, hasErrors, normalizeModule } from \"@tsplc/compiler/ir\";\nimport { cleanArtifacts, engineeringDirectory, owned, publishArtifacts } from \"./artifacts.ts\";\n\nconst failure = (origin: Diagnostic[\"origin\"], code: string, cause: unknown): Diagnostic => ({\n origin,\n code,\n severity: \"error\",\n message: cause instanceof Error ? cause.message : String(cause),\n});\n\ntype LoadedConfig = Awaited<ReturnType<typeof loadTsplcConfig>>;\n\nasync function loadProject(\n file: string,\n loaded?: LoadedConfig,\n buildTarget?: BuildTarget,\n configured?: ResolvedTsplcConfig,\n): Promise<{\n config?: NormalizedConfig;\n configFile: string;\n shared?: ResolvedTsplcConfig;\n project?: CodesysProject;\n diagnostics: readonly Diagnostic[];\n}> {\n let configFile = resolve(file);\n try {\n configFile = await realpath(configFile);\n const diagnostics = checkHostConfig(configFile);\n if (hasErrors(diagnostics)) return { configFile, diagnostics };\n const shared = (loaded ?? (await loadTsplcConfig(configFile))).config;\n const root = dirname(configFile);\n const catalog = await loadHardware(shared, root);\n\n const config = compilerConfig(shared, resolveIo(shared, catalog), buildTarget);\n return {\n configFile,\n shared,\n config: { ...config, ...sourceInput(config, root) },\n project: {\n root,\n ...(shared.debug && { debug: shared.debug }),\n ...(shared.telemetry && { telemetry: shared.telemetry }),\n ...(shared.server && { server: shared.server }),\n // A simulation build drops fieldbus IO, but the debugger still shows the hardware it stands in for.\n hardware: {\n catalog: configured ? await loadHardware(configured, root) : catalog,\n config: configured ?? shared,\n tree: shared.codesys?.deviceTree !== undefined,\n },\n },\n diagnostics,\n };\n } catch (cause) {\n return { configFile, diagnostics: [failure(\"config\", \"PLC5003\", cause)] };\n }\n}\n\n/** The analyzer's entry points, resolved against the config file's directory. */\nfunction sourceInput(\n compiler: { tsconfig: string; programs: Record<string, { module: string; export: string }> },\n root: string,\n) {\n return {\n tsconfig: resolve(root, compiler.tsconfig),\n programs: Object.fromEntries(\n Object.entries(compiler.programs).map(([name, entry]) => [\n name,\n { ...entry, module: resolve(root, entry.module) },\n ]),\n ),\n };\n}\n\n/**\n * I/O keys and publication selectors from analyzed PLC source. It ignores the\n * config's own type errors, so a typo cannot switch off the types that flag it;\n * it is undefined only while the source itself fails analysis.\n */\nexport async function projectTargets(\n file = \"tsplc.config.ts\",\n options: { loaded?: LoadedConfig } = {},\n): Promise<ProjectTargets | undefined> {\n const configFile = await realpath(resolve(file));\n const { config } = options.loaded ?? (await loadTsplcConfig(configFile));\n if (!config.compiler) return undefined;\n const source = analyze({\n ...sourceInput(config.compiler, dirname(configFile)),\n services: config.server,\n });\n const core = source.module && normalizeModule(source.module).core;\n return core ? { io: ioTargets(core), publication: publicationSelectors(core) } : undefined;\n}\n\nexport async function checkProject(\n file = \"tsplc.config.ts\",\n options: {\n loaded?: LoadedConfig;\n buildTarget?: BuildTarget;\n /** The configuration `loaded` simulates, whose hardware the debug manifest describes. */\n configured?: ResolvedTsplcConfig;\n } = {},\n): Promise<{\n configFile: string;\n config?: NormalizedConfig;\n shared?: ResolvedTsplcConfig;\n plan?: CodesysPlan;\n diagnostics: readonly Diagnostic[];\n}> {\n const loaded = await loadProject(file, options.loaded, options.buildTarget, options.configured);\n if (!loaded.config || !loaded.project) {\n return loaded;\n }\n\n const config = loaded.config;\n if (config.target.kind !== \"codesys\") {\n return {\n ...loaded,\n diagnostics: [failure(\"backend\", \"PLC7001\", `Unsupported target: ${config.target.kind}`)],\n };\n }\n\n const source = analyze({\n tsconfig: config.tsconfig,\n programs: config.programs,\n services: loaded.shared?.server,\n });\n if (!source.module) {\n return { ...loaded, diagnostics: source.diagnostics };\n }\n const normalized = normalizeModule(source.module);\n if (!normalized.core) {\n return { ...loaded, diagnostics: normalized.diagnostics };\n }\n\n const tasks = config.tasks.map((task) => ({\n name: task.name,\n intervalNanoseconds: task.schedule.interval.nanoseconds,\n priority: task.priority,\n programs: task.programs,\n }));\n const planned = planCodesys(normalized.core, { tasks }, config.target.options, loaded.project);\n return {\n ...loaded,\n ...planned,\n diagnostics: [\n ...loaded.diagnostics,\n ...source.diagnostics,\n ...normalized.diagnostics,\n ...planned.diagnostics,\n ],\n };\n}\n\n/** The installed libraries and fieldbus device tree a CODESYS project of this program needs. */\nasync function engineeringInputs(\n shared: ResolvedTsplcConfig,\n configFile: string,\n bundle: Pick<ReturnType<typeof emitCodesys>, \"ioMappings\">,\n frozen?: boolean,\n) {\n const root = dirname(configFile);\n const tree = await deviceTree(shared, await loadHardware(shared, root));\n return {\n libraries: await installLibraries(shared.dependencies, root, { frozen }),\n // The emitted names locate mapped IO; the tree maps their channels.\n deviceTree: tree && {\n ...tree,\n mappings: bundle.ioMappings.map(({ address, variable }) => ({ address, variable })),\n },\n };\n}\n\nexport async function buildProject(\n file = \"tsplc.config.ts\",\n options: {\n emitOnly?: boolean;\n frozenLockfile?: boolean;\n loaded?: LoadedConfig;\n controller?: Controller;\n buildTarget?: BuildTarget;\n configured?: ResolvedTsplcConfig;\n /** Resolve libraries and the device tree into `controllerConfig` even when only emitting. */\n forController?: boolean;\n } = {},\n): Promise<{\n directory?: string;\n status?: \"emitted\" | \"vendor-compiled\";\n controllerConfig?: ReturnType<typeof codesysBuildConfig>;\n diagnostics: readonly Diagnostic[];\n}> {\n let staging: string | undefined;\n try {\n const configFile = await realpath(resolve(file));\n // Withdraw the previous success receipt before checking the new source.\n // Old artifacts remain owned and intact until publication succeeds.\n const previous = await owned(configFile, true);\n if (previous.unknown.length) {\n throw new Error(`Output contains unrelated files: ${previous.unknown.join(\", \")}`);\n }\n\n const checked = await checkProject(configFile, {\n loaded: options.loaded,\n buildTarget: options.buildTarget,\n configured: options.configured,\n });\n if (!checked.plan || !checked.config) {\n return { diagnostics: checked.diagnostics };\n }\n const bundle = emitCodesys(checked.plan);\n if (hasErrors(bundle.diagnostics)) {\n return { diagnostics: bundle.diagnostics };\n }\n const shared = checked.shared;\n const engineering =\n shared && (!options.emitOnly || options.forController)\n ? await engineeringInputs(shared, configFile, bundle, options.frozenLockfile)\n : undefined;\n const controllerConfig = shared?.build\n ? codesysBuildConfig(checked.plan, bundle, {\n configFile,\n sourceDir: join(previous.output, \"st\"),\n outDir: resolve(dirname(configFile), shared.build.outDir),\n controller: options.controller,\n ...engineering,\n })\n : undefined;\n\n await mkdir(previous.root, { recursive: true });\n staging = await mkdtemp(join(previous.root, \"stage-\"));\n const artifacts = [\n ...bundle.artifacts,\n { path: \"mappings.json\", content: `${JSON.stringify(compactMappings(bundle.mappings))}\\n` },\n { path: \"io-symbols.json\", content: `${JSON.stringify(bundle.ioSymbols, null, 2)}\\n` },\n { path: \"publication.json\", content: `${JSON.stringify(bundle.publication, null, 2)}\\n` },\n { path: \"config.json\", content: `${JSON.stringify(checked.config, null, 2)}\\n` },\n ...(bundle.debug\n ? [{ path: \"debug.json\", content: `${JSON.stringify(bundle.debug)}\\n` }]\n : []),\n ];\n for (const artifact of artifacts) {\n const path = join(staging, \"st\", artifact.path);\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, artifact.content);\n }\n\n let vendor: Awaited<ReturnType<typeof buildCodesys>> | undefined;\n if (!options.emitOnly) {\n // The engineering cache has its own ownership marker and survives clean.\n const outDir = shared?.build\n ? resolve(dirname(configFile), shared.build.outDir ?? \"build\")\n : join(previous.root, \"engineering\");\n await engineeringDirectory(outDir, configFile);\n try {\n vendor = await buildCodesys(checked.plan, bundle, {\n configFile,\n sourceDir: join(staging, \"st\"),\n outDir,\n controller: options.controller,\n ...engineering,\n });\n } catch (cause) {\n return { diagnostics: diagnoseCodesys(cause, bundle) };\n }\n\n const vendorArtifacts = [\n [\"Application.project\", vendor.project],\n [\"Application.app\", vendor.output],\n [\"Application.crc\", vendor.checksum],\n ] as const;\n for (const [name, path] of vendorArtifacts) {\n if (!path) continue;\n const destination = join(staging, \"vendor\", name);\n await mkdir(dirname(destination), { recursive: true });\n await copyFile(path, destination);\n }\n }\n\n const status = vendor ? \"vendor-compiled\" : \"emitted\";\n await publishArtifacts(staging, previous, {\n configFile,\n status,\n ...(vendor && { vendor: { application: vendor.application, tasks: vendor.tasks } }),\n });\n // Publication moved this directory into place; it is no longer staging.\n staging = undefined;\n return {\n directory: previous.output,\n status,\n ...(controllerConfig && { controllerConfig }),\n diagnostics: [...checked.diagnostics, ...bundle.diagnostics],\n };\n } catch (cause) {\n return { diagnostics: [failure(\"config\", \"PLC5004\", cause)] };\n } finally {\n if (staging) {\n await rm(staging, { recursive: true, force: true });\n }\n }\n}\n\n/**\n * Source mappings with each ST path and source file written once: `mappings` rows are\n * `[object, line, file, start, end, sourceLine, sourceColumn]`, indexing `objects` and `files`.\n */\nfunction compactMappings(mappings: readonly SourceMapping[]) {\n const objects = new Map<string, number>(),\n files = new Map<string, number>();\n const index = (table: Map<string, number>, value: string) => {\n if (!table.has(value)) table.set(value, table.size);\n return table.get(value)!;\n };\n const rows = mappings.map(({ path, line, span }) => [\n index(objects, path),\n line,\n index(files, span.file),\n span.start,\n span.end,\n span.line,\n span.column,\n ]);\n return { objects: [...objects.keys()], files: [...files.keys()], mappings: rows };\n}\n\nexport async function cleanProject(file = \"tsplc.config.ts\"): Promise<{\n diagnostics: readonly Diagnostic[];\n}> {\n try {\n await cleanArtifacts(await realpath(resolve(file)));\n return { diagnostics: [] };\n } catch (cause) {\n return { diagnostics: [failure(\"config\", \"PLC5004\", cause)] };\n }\n}\n",
|
|
9
|
-
"import { createHash } from \"node:crypto\";\nimport { lstat, mkdir, readdir, readFile, rename, rm, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport type { buildCodesys } from \"@tsplc/compiler/codesys\";\n\nconst missing = (cause: unknown): boolean =>\n cause instanceof Error && \"code\" in cause && cause.code === \"ENOENT\";\nconst digest = (value: string | Uint8Array): string =>\n createHash(\"sha256\").update(value).digest(\"hex\");\n\n// Ownership is an explicit boundary: generated files must match their manifest,\n// and engineering trees must belong to this configuration before vendor writes.\ninterface Manifest {\n kind: \"tsplc-artifacts\";\n version: 1;\n configFile: string;\n files: { path: string; sha256: string }[];\n}\n\nfunction manifest(value: unknown, configFile: string): Manifest {\n if (\n typeof value !== \"object\" ||\n value === null ||\n !(\"kind\" in value) ||\n value.kind !== \"tsplc-artifacts\" ||\n !(\"version\" in value) ||\n value.version !== 1 ||\n !(\"configFile\" in value) ||\n value.configFile !== configFile ||\n !(\"files\" in value) ||\n !Array.isArray(value.files)\n ) {\n throw new Error(\"Output directory has no matching tsPLC ownership manifest.\");\n }\n\n const files = value.files.map((item: unknown) => {\n if (\n typeof item !== \"object\" ||\n item === null ||\n !(\"path\" in item) ||\n typeof item.path !== \"string\" ||\n !/^[A-Za-z0-9_ .-]+(?:\\/[A-Za-z0-9_ .-]+)*$/.test(item.path) ||\n item.path.split(\"/\").some((part) => part === \".\" || part === \"..\") ||\n [\"manifest.json\", \"receipt.json\"].includes(item.path) ||\n !(\"sha256\" in item) ||\n typeof item.sha256 !== \"string\" ||\n !/^[0-9a-f]{64}$/.test(item.sha256)\n ) {\n throw new Error(\"Invalid generated file ownership entry.\");\n }\n return { path: item.path, sha256: item.sha256 };\n });\n if (new Set(files.map((item) => item.path)).size !== files.length) {\n throw new Error(\"Duplicate generated file ownership entry.\");\n }\n return { kind: \"tsplc-artifacts\", version: 1, configFile, files };\n}\n\nasync function directory(path: string): Promise<boolean> {\n try {\n const entry = await lstat(path);\n if (!entry.isDirectory() || entry.isSymbolicLink()) {\n throw new Error(`Generated directory must be a real directory: ${path}`);\n }\n return true;\n } catch (cause) {\n if (missing(cause)) {\n return false;\n }\n throw cause;\n }\n}\n\nasync function filesIn(path: string, prefix = \"\"): Promise<string[]> {\n const result: string[] = [];\n for (const entry of await readdir(path, { withFileTypes: true })) {\n const name = prefix + entry.name;\n if (entry.isDirectory() && !entry.isSymbolicLink()) {\n result.push(...(await filesIn(join(path, entry.name), `${name}/`)));\n } else {\n result.push(name);\n }\n }\n return result;\n}\n\nexport async function engineeringDirectory(path: string, configFile: string): Promise<void> {\n const marker = join(path, \"ownership.json\");\n const exists = await directory(path);\n if (!exists || !(await readdir(path)).length) {\n await mkdir(path, { recursive: true });\n await writeFile(\n marker,\n `${JSON.stringify({ kind: \"tsplc-engineering\", version: 1, configFile }, null, 2)}\\n`,\n { flag: \"wx\" },\n );\n } else {\n const entry = await lstat(marker).catch((cause: unknown) => {\n if (missing(cause)) {\n throw new Error(`Engineering cache has no matching tsPLC ownership marker: ${path}`);\n }\n throw cause;\n });\n if (!entry.isFile() || entry.isSymbolicLink()) {\n throw new Error(\"Engineering ownership marker must be a real file.\");\n }\n const value = JSON.parse(await readFile(marker, \"utf8\"));\n if (\n value?.kind !== \"tsplc-engineering\" ||\n value.version !== 1 ||\n value.configFile !== configFile\n ) {\n throw new Error(`Engineering cache has no matching tsPLC ownership marker: ${path}`);\n }\n }\n\n const inspect = async (directory: string): Promise<void> => {\n for (const entry of await readdir(directory, { withFileTypes: true })) {\n const child = join(directory, entry.name);\n if (entry.isSymbolicLink()) {\n throw new Error(`Engineering cache must not contain symlinks: ${child}`);\n }\n if (entry.isDirectory()) {\n await inspect(child);\n }\n }\n };\n await inspect(path);\n}\n\nexport async function owned(\n configFile: string,\n withdrawReceipt = false,\n): Promise<{ root: string; output: string; ownership?: Manifest; unknown: string[] }> {\n const root = join(dirname(configFile), \".tsplc\");\n const output = join(root, \"artifacts\");\n if (!(await directory(root)) || !(await directory(output))) {\n return { root, output, unknown: [] };\n }\n\n const manifestPath = join(output, \"manifest.json\");\n const manifestEntry = await lstat(manifestPath);\n if (!manifestEntry.isFile() || manifestEntry.isSymbolicLink()) {\n throw new Error(\"Ownership manifest must be a real file.\");\n }\n const ownership = manifest(JSON.parse(await readFile(manifestPath, \"utf8\")), configFile);\n const receipt = join(output, \"receipt.json\");\n try {\n const entry = await lstat(receipt);\n if (!entry.isFile() || entry.isSymbolicLink()) {\n throw new Error(\"Build receipt must be a real file.\");\n }\n const value = JSON.parse(await readFile(receipt, \"utf8\"));\n if (\n value?.kind !== \"tsplc-build\" ||\n value.version !== 1 ||\n value.configFile !== configFile ||\n ![\"emitted\", \"vendor-compiled\"].includes(value.status)\n ) {\n throw new Error(\"Build receipt is not owned by this configuration.\");\n }\n if (withdrawReceipt) {\n await rm(receipt);\n }\n } catch (cause) {\n if (!missing(cause)) {\n throw cause;\n }\n }\n\n const names = new Set([\n ...ownership.files.map((file) => file.path),\n \"manifest.json\",\n \"receipt.json\",\n ]);\n for (const file of ownership.files) {\n let parent = output;\n for (const part of file.path.split(\"/\").slice(0, -1)) {\n parent = join(parent, part);\n if (!(await directory(parent))) {\n throw new Error(`Missing generated directory: ${parent}`);\n }\n }\n const path = join(output, file.path);\n const entry = await lstat(path);\n if (!entry.isFile() || entry.isSymbolicLink() || digest(await readFile(path)) !== file.sha256) {\n throw new Error(\n `Generated file was replaced or edited; preserve it before rebuilding/cleaning: ${path}`,\n );\n }\n }\n return {\n root,\n output,\n ownership,\n unknown: (await filesIn(output)).filter((name) => !names.has(name)),\n };\n}\n\ninterface Receipt {\n configFile: string;\n status: \"emitted\" | \"vendor-compiled\";\n vendor?: Pick<Awaited<ReturnType<typeof buildCodesys>>, \"application\" | \"tasks\">;\n}\n\n// Compile in a separate staging tree. Recheck ownership immediately before the\n// swap, because the vendor build may have given the user time to edit old files.\nexport async function publishArtifacts(\n staging: string,\n previous: Awaited<ReturnType<typeof owned>>,\n receipt: Receipt,\n): Promise<void> {\n const configFile = receipt.configFile;\n const generated = (await filesIn(staging)).sort();\n const ownership: Manifest = { kind: \"tsplc-artifacts\", version: 1, configFile, files: [] };\n for (const path of generated) {\n ownership.files.push({ path, sha256: digest(await readFile(join(staging, path))) });\n }\n await writeFile(join(staging, \"manifest.json\"), `${JSON.stringify(ownership, null, 2)}\\n`);\n await writeFile(\n join(staging, \"receipt.json\"),\n `${JSON.stringify(\n { kind: \"tsplc-build\", version: 1, generatedAt: new Date().toISOString(), ...receipt },\n null,\n 2,\n )}\\n`,\n );\n\n const current = await owned(configFile);\n if (JSON.stringify(current.ownership) !== JSON.stringify(previous.ownership)) {\n throw new Error(\"Output ownership changed during the build; preserve it before rebuilding.\");\n }\n if (current.unknown.length) {\n throw new Error(`Output contains unrelated files: ${current.unknown.join(\", \")}`);\n }\n\n const backup = `${staging}-previous`;\n if (previous.ownership) {\n await rename(previous.output, backup);\n }\n try {\n await rename(staging, previous.output);\n } catch (cause) {\n if (previous.ownership) {\n await rename(backup, previous.output);\n }\n throw cause;\n }\n if (previous.ownership) {\n await rm(backup, { recursive: true });\n }\n}\n\nexport async function cleanArtifacts(configFile: string): Promise<void> {\n const generated = await owned(configFile);\n if (!generated.ownership) {\n return;\n }\n for (const entry of generated.ownership.files) {\n await rm(join(generated.output, entry.path));\n }\n await rm(join(generated.output, \"receipt.json\"), { force: true });\n await rm(join(generated.output, \"manifest.json\"));\n\n // Remove empty generated directories while preserving unrelated files.\n const removeEmpty = async (path: string): Promise<void> => {\n for (const entry of await readdir(path, { withFileTypes: true })) {\n if (entry.isDirectory() && !entry.isSymbolicLink()) {\n await removeEmpty(join(path, entry.name));\n }\n }\n if (!(await readdir(path)).length) {\n await rm(path, { recursive: true });\n }\n };\n await removeEmpty(generated.output);\n}\n",
|
|
10
|
-
"import { existsSync } from \"node:fs\";\nimport { mkdtemp, mkdir, rm, rename } from \"node:fs/promises\";\nimport { dirname, resolve, join } from \"node:path\";\nimport { createRequire } from \"node:module\";\nimport ts from \"typescript\";\nimport type { ResolvedTsplcConfig } from \"@tsplc/config\";\nimport { typeCheckOnly } from \"@tsplc/compiler\";\n\nexport const resolveServerModule = (root: string, name: string) =>\n name.startsWith(\".\") || name.startsWith(\"/\") || existsSync(resolve(root, name))\n ? resolve(root, name)\n : createRequire(join(root, \"package.json\")).resolve(name);\n\nconst kebabCase = (name: string) =>\n name\n .replace(/([a-z0-9])([A-Z])|([A-Z])([A-Z][a-z])/g, \"$1$3-$2$4\")\n .replace(/[^A-Za-z0-9]+/g, \"-\")\n .replace(/^-|-$/g, \"\")\n .toLowerCase();\n\n/** The host entry, type-checked as it will be built. */\nconst checkedServerEntry = (config: ResolvedTsplcConfig, root: string) => {\n const runtime = config.server?.runtime;\n if (!runtime) throw new Error(\"Configure server.runtime to build the server.\");\n const entry = resolveServerModule(root, runtime.entry);\n const tsconfig = ts.findConfigFile(dirname(entry), ts.sys.fileExists);\n if (!tsconfig) throw new Error(\"Server entry requires a tsconfig.json.\");\n const read = ts.readConfigFile(tsconfig, ts.sys.readFile);\n if (read.error) throw new Error(ts.flattenDiagnosticMessageText(read.error.messageText, \"\\n\"));\n const parsed = ts.parseJsonConfigFileContent(read.config, ts.sys, dirname(tsconfig));\n const program = ts.createProgram({\n rootNames: [entry, ...parsed.fileNames.filter((file) => /\\.d\\.[cm]?ts$/.test(file))],\n options: { ...parsed.options, ...typeCheckOnly },\n projectReferences: parsed.projectReferences,\n });\n const diagnostics = [...parsed.errors, ...ts.getPreEmitDiagnostics(program)];\n if (diagnostics.length)\n throw new Error(\n ts.formatDiagnosticsWithColorAndContext(diagnostics, {\n getCanonicalFileName: (path) => path,\n getCurrentDirectory: () => root,\n getNewLine: () => \"\\n\",\n }),\n );\n return { entry, runtime };\n};\n\n/**\n * Bundles the host entry, which starts its own listener, into one minified script,\n * `build/server/<name>-services.js`, which the plant agent runs on its own Bun. It is a few MB\n * where an executable, which embeds Bun, is over 100, and deployments upload it.\n */\nexport const bundleServer = async (config: ResolvedTsplcConfig, root: string) => {\n const { entry } = checkedServerEntry(config, root);\n const outFile = resolve(root, \"build/server\", `${kebabCase(config.name)}-services.js`);\n const result = await Bun.build({\n entrypoints: [entry],\n target: \"bun\",\n minify: true,\n env: \"disable\",\n });\n if (!result.success) throw new AggregateError(result.logs, \"Server bundle build failed.\");\n const [script, ...assets] = result.outputs;\n if (!script || assets.length)\n throw new Error(\n `The server bundle needs files beside its script (${assets.map(({ path }) => path).join(\", \")}), which deployments don't carry.`,\n );\n await mkdir(dirname(outFile), { recursive: true });\n await Bun.write(outFile, script);\n return outFile;\n};\n\n/** Compiles the host entry, which starts its own listener, into `build/server/<name>-services`. */\nexport const buildServer = async (config: ResolvedTsplcConfig, root: string) => {\n const { entry, runtime } = checkedServerEntry(config, root);\n const windows = runtime.target\n ? runtime.target.includes(\"windows\")\n : process.platform === \"win32\";\n const outFile = resolve(\n root,\n \"build/server\",\n `${kebabCase(config.name)}-services${windows ? \".exe\" : \"\"}`,\n );\n await mkdir(dirname(outFile), { recursive: true });\n // Compile beside the output so dependency resolution starts from the owning project.\n const staging = await mkdtemp(join(dirname(outFile), \".tsplc-server-\"));\n try {\n const binary = join(staging, \"server\");\n const result = await Bun.build({\n entrypoints: [entry],\n env: \"disable\",\n compile: {\n outfile: binary,\n ...(runtime.target ? { target: runtime.target } : {}),\n autoloadDotenv: false,\n autoloadBunfig: false,\n autoloadTsconfig: false,\n autoloadPackageJson: false,\n },\n });\n if (!result.success) throw new AggregateError(result.logs, \"Server executable build failed.\");\n // Bun names a Windows executable itself.\n await rename(windows ? `${binary}.exe` : binary, outFile);\n return {\n server: {\n executable: outFile,\n target: runtime.target ?? `bun-${process.platform}-${process.arch}`,\n },\n };\n } finally {\n await rm(staging, { recursive: true, force: true });\n }\n};\n",
|
|
11
|
-
"import { copyFile, mkdir, mkdtemp, realpath, rm, writeFile } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport {\n buildCodesys,\n codesysBuildConfig,\n type CodesysPlan,\n type CodesysProject,\n type SourceMapping,\n diagnoseCodesys,\n emitCodesys,\n ioTargets,\n publicationSelectors,\n planCodesys,\n} from \"@tsplc/compiler/codesys\";\nimport { analyze, checkHostConfig } from \"@tsplc/compiler\";\nimport {\n type Controller,\n type BuildTarget,\n type NormalizedConfig,\n type ResolvedTsplcConfig,\n compilerConfig,\n loadTsplcConfig,\n} from \"@tsplc/config\";\nimport { deviceTree, type ProjectTargets, loadHardware, resolveIo } from \"@tsplc/typegen\";\nimport { installLibraries } from \"@tsplc/build\";\nimport { type Diagnostic, hasErrors, normalizeModule } from \"@tsplc/compiler/ir\";\nimport { cleanArtifacts, engineeringDirectory, owned, publishArtifacts } from \"./artifacts.ts\";\n\nconst failure = (origin: Diagnostic[\"origin\"], code: string, cause: unknown): Diagnostic => ({\n origin,\n code,\n severity: \"error\",\n message: cause instanceof Error ? cause.message : String(cause),\n});\n\ntype LoadedConfig = Awaited<ReturnType<typeof loadTsplcConfig>>;\n\nasync function loadProject(\n file: string,\n loaded?: LoadedConfig,\n buildTarget?: BuildTarget,\n configured?: ResolvedTsplcConfig,\n): Promise<{\n config?: NormalizedConfig;\n configFile: string;\n shared?: ResolvedTsplcConfig;\n project?: CodesysProject;\n diagnostics: readonly Diagnostic[];\n}> {\n let configFile = resolve(file);\n try {\n configFile = await realpath(configFile);\n const diagnostics = checkHostConfig(configFile);\n if (hasErrors(diagnostics)) return { configFile, diagnostics };\n const shared = (loaded ?? (await loadTsplcConfig(configFile))).config;\n const root = dirname(configFile);\n const catalog = await loadHardware(shared, root);\n\n const config = compilerConfig(shared, resolveIo(shared, catalog), buildTarget);\n return {\n configFile,\n shared,\n config: { ...config, ...sourceInput(config, root) },\n project: {\n root,\n ...(shared.debug && { debug: shared.debug }),\n ...(shared.telemetry && { telemetry: shared.telemetry }),\n ...(shared.server && { server: shared.server }),\n // A simulation build drops fieldbus IO, but the debugger still shows the hardware it stands in for.\n hardware: {\n catalog: configured ? await loadHardware(configured, root) : catalog,\n config: configured ?? shared,\n tree: shared.codesys?.deviceTree !== undefined,\n },\n },\n diagnostics,\n };\n } catch (cause) {\n return { configFile, diagnostics: [failure(\"config\", \"PLC5003\", cause)] };\n }\n}\n\n/** The analyzer's entry points, resolved against the config file's directory. */\nfunction sourceInput(\n compiler: { tsconfig: string; programs: Record<string, { module: string; export: string }> },\n root: string,\n) {\n return {\n tsconfig: resolve(root, compiler.tsconfig),\n programs: Object.fromEntries(\n Object.entries(compiler.programs).map(([name, entry]) => [\n name,\n { ...entry, module: resolve(root, entry.module) },\n ]),\n ),\n };\n}\n\n/**\n * I/O keys and publication selectors from analyzed PLC source. It ignores the\n * config's own type errors, so a typo cannot switch off the types that flag it;\n * it is undefined only while the source itself fails analysis.\n */\nexport async function projectTargets(\n file = \"tsplc.config.ts\",\n options: { loaded?: LoadedConfig } = {},\n): Promise<ProjectTargets | undefined> {\n const configFile = await realpath(resolve(file));\n const { config } = options.loaded ?? (await loadTsplcConfig(configFile));\n if (!config.compiler) return undefined;\n const source = analyze({\n ...sourceInput(config.compiler, dirname(configFile)),\n services: config.server,\n });\n const core = source.module && normalizeModule(source.module).core;\n return core ? { io: ioTargets(core), publication: publicationSelectors(core) } : undefined;\n}\n\nexport async function checkProject(\n file = \"tsplc.config.ts\",\n options: {\n loaded?: LoadedConfig;\n buildTarget?: BuildTarget;\n /** The configuration `loaded` simulates, whose hardware the debug manifest describes. */\n configured?: ResolvedTsplcConfig;\n } = {},\n): Promise<{\n configFile: string;\n config?: NormalizedConfig;\n shared?: ResolvedTsplcConfig;\n plan?: CodesysPlan;\n diagnostics: readonly Diagnostic[];\n}> {\n const loaded = await loadProject(file, options.loaded, options.buildTarget, options.configured);\n if (!loaded.config || !loaded.project) {\n return loaded;\n }\n\n const config = loaded.config;\n if (config.target.kind !== \"codesys\") {\n return {\n ...loaded,\n diagnostics: [failure(\"backend\", \"PLC7001\", `Unsupported target: ${config.target.kind}`)],\n };\n }\n\n const source = analyze({\n tsconfig: config.tsconfig,\n programs: config.programs,\n services: loaded.shared?.server,\n });\n if (!source.module) {\n return { ...loaded, diagnostics: source.diagnostics };\n }\n const normalized = normalizeModule(source.module);\n if (!normalized.core) {\n return { ...loaded, diagnostics: normalized.diagnostics };\n }\n\n const tasks = config.tasks.map((task) => ({\n name: task.name,\n intervalNanoseconds: task.schedule.interval.nanoseconds,\n priority: task.priority,\n programs: task.programs,\n }));\n const planned = planCodesys(normalized.core, { tasks }, config.target.options, loaded.project);\n return {\n ...loaded,\n ...planned,\n diagnostics: [\n ...loaded.diagnostics,\n ...source.diagnostics,\n ...normalized.diagnostics,\n ...planned.diagnostics,\n ],\n };\n}\n\n/** The installed libraries and fieldbus device tree a CODESYS project of this program needs. */\nasync function engineeringInputs(\n shared: ResolvedTsplcConfig,\n configFile: string,\n bundle: Pick<ReturnType<typeof emitCodesys>, \"ioMappings\">,\n frozen?: boolean,\n) {\n const root = dirname(configFile);\n const tree = await deviceTree(shared, await loadHardware(shared, root));\n return {\n libraries: await installLibraries(shared.dependencies, root, { frozen }),\n // The emitted names locate mapped IO; the tree maps their channels.\n deviceTree: tree && {\n ...tree,\n mappings: bundle.ioMappings.map(({ address, variable }) => ({ address, variable })),\n },\n };\n}\n\nexport async function buildProject(\n file = \"tsplc.config.ts\",\n options: {\n emitOnly?: boolean;\n frozenLockfile?: boolean;\n loaded?: LoadedConfig;\n controller?: Controller;\n buildTarget?: BuildTarget;\n configured?: ResolvedTsplcConfig;\n /** Resolve libraries and the device tree into `controllerConfig` even when only emitting. */\n forController?: boolean;\n } = {},\n): Promise<{\n directory?: string;\n status?: \"emitted\" | \"vendor-compiled\";\n controllerConfig?: ReturnType<typeof codesysBuildConfig>;\n diagnostics: readonly Diagnostic[];\n}> {\n let staging: string | undefined;\n try {\n const configFile = await realpath(resolve(file));\n // Withdraw the previous success receipt before checking the new source.\n // Old artifacts remain owned and intact until publication succeeds.\n const previous = await owned(configFile, true);\n if (previous.unknown.length) {\n throw new Error(`Output contains unrelated files: ${previous.unknown.join(\", \")}`);\n }\n\n const checked = await checkProject(configFile, {\n loaded: options.loaded,\n buildTarget: options.buildTarget,\n configured: options.configured,\n });\n if (!checked.plan || !checked.config) {\n return { diagnostics: checked.diagnostics };\n }\n const bundle = emitCodesys(checked.plan);\n if (hasErrors(bundle.diagnostics)) {\n return { diagnostics: bundle.diagnostics };\n }\n const shared = checked.shared;\n const engineering =\n shared && (!options.emitOnly || options.forController)\n ? await engineeringInputs(shared, configFile, bundle, options.frozenLockfile)\n : undefined;\n const controllerConfig = shared?.build\n ? codesysBuildConfig(checked.plan, bundle, {\n configFile,\n sourceDir: join(previous.output, \"st\"),\n outDir: resolve(dirname(configFile), shared.build.outDir),\n controller: options.controller,\n ...engineering,\n })\n : undefined;\n\n await mkdir(previous.root, { recursive: true });\n staging = await mkdtemp(join(previous.root, \"stage-\"));\n const artifacts = [\n ...bundle.artifacts,\n { path: \"mappings.json\", content: `${JSON.stringify(compactMappings(bundle.mappings))}\\n` },\n { path: \"io-symbols.json\", content: `${JSON.stringify(bundle.ioSymbols, null, 2)}\\n` },\n { path: \"publication.json\", content: `${JSON.stringify(bundle.publication, null, 2)}\\n` },\n { path: \"config.json\", content: `${JSON.stringify(checked.config, null, 2)}\\n` },\n ...(bundle.debug\n ? [{ path: \"debug.json\", content: `${JSON.stringify(bundle.debug)}\\n` }]\n : []),\n ];\n for (const artifact of artifacts) {\n const path = join(staging, \"st\", artifact.path);\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, artifact.content);\n }\n\n let vendor: Awaited<ReturnType<typeof buildCodesys>> | undefined;\n if (!options.emitOnly) {\n // The engineering cache has its own ownership marker and survives clean.\n const outDir = shared?.build\n ? resolve(dirname(configFile), shared.build.outDir ?? \"build\")\n : join(previous.root, \"engineering\");\n await engineeringDirectory(outDir, configFile);\n try {\n vendor = await buildCodesys(checked.plan, bundle, {\n configFile,\n sourceDir: join(staging, \"st\"),\n outDir,\n controller: options.controller,\n ...engineering,\n });\n } catch (cause) {\n return { diagnostics: diagnoseCodesys(cause, bundle) };\n }\n\n const vendorArtifacts = [\n [\"Application.project\", vendor.project],\n [\"Application.app\", vendor.output],\n [\"Application.crc\", vendor.checksum],\n ] as const;\n for (const [name, path] of vendorArtifacts) {\n if (!path) continue;\n const destination = join(staging, \"vendor\", name);\n await mkdir(dirname(destination), { recursive: true });\n await copyFile(path, destination);\n }\n }\n\n const status = vendor ? \"vendor-compiled\" : \"emitted\";\n await publishArtifacts(staging, previous, {\n configFile,\n status,\n ...(vendor && { vendor: { application: vendor.application, tasks: vendor.tasks } }),\n });\n // Publication moved this directory into place; it is no longer staging.\n staging = undefined;\n return {\n directory: previous.output,\n status,\n ...(controllerConfig && { controllerConfig }),\n diagnostics: [...checked.diagnostics, ...bundle.diagnostics],\n };\n } catch (cause) {\n return { diagnostics: [failure(\"config\", \"PLC5004\", cause)] };\n } finally {\n if (staging) {\n await rm(staging, { recursive: true, force: true });\n }\n }\n}\n\n/**\n * Source mappings with each ST path and source file written once: `mappings` rows are\n * `[object, line, file, start, end, sourceLine, sourceColumn]`, indexing `objects` and `files`.\n */\nfunction compactMappings(mappings: readonly SourceMapping[]) {\n const objects = new Map<string, number>(),\n files = new Map<string, number>();\n const index = (table: Map<string, number>, value: string) => {\n if (!table.has(value)) table.set(value, table.size);\n return table.get(value)!;\n };\n const rows = mappings.map(({ path, line, span }) => [\n index(objects, path),\n line,\n index(files, span.file),\n span.start,\n span.end,\n span.line,\n span.column,\n ]);\n return { objects: [...objects.keys()], files: [...files.keys()], mappings: rows };\n}\n\nexport async function cleanProject(file = \"tsplc.config.ts\"): Promise<{\n diagnostics: readonly Diagnostic[];\n}> {\n try {\n await cleanArtifacts(await realpath(resolve(file)));\n return { diagnostics: [] };\n } catch (cause) {\n return { diagnostics: [failure(\"config\", \"PLC5004\", cause)] };\n }\n}\n"
|
|
5
|
+
"#!/usr/bin/env bun\nimport { parseArgs } from \"node:util\";\nimport { loadTsplcConfig } from \"@tsplc/config\";\nimport { formatDiagnostic, hasErrors } from \"@tsplc/compiler/ir\";\nimport { serveProjectDebugger } from \"./debugger.ts\";\nimport { connect, plantCommand, runPlantCommand } from \"./plant.ts\";\nimport {\n\ttype CommandResult,\n\tDiagnosticFailure,\n\tcheckProjectFlags,\n\tprojectCommand,\n\trunProjectCommand,\n} from \"./project-commands.ts\";\n\nconst usage = `tsplc install|typegen|check|build|run|download|online-change|inspect|clean|configure [--config tsplc.config.ts] [--target name] [--plc|--server] [--simulate] [--runtime] [--emit-only] [--format json] [--read symbol]\n\nPlant agent (TSPLC_AGENT_URL, TSPLC_AGENT_TOKEN):\n tsplc deploy [--target name] [--download] [--select] [--initialize-user] [--simulate]\n tsplc target | status | login | logout\n tsplc vars [path] | read <expression>... | write <expression> <value>\n tsplc force <expression> <value> | unforce [expression]... [--restore]\n tsplc start | stop | reset warm|cold (-y skips confirmations)\n\nDebugger, on http://127.0.0.1, for the built .tsplc/artifacts/st/debug.json; it reads through\nthe plant agent's login (TSPLC_AGENT_URL, TSPLC_AGENT_TOKEN), or --opcua at config monitor:\n tsplc debug [--target name] [--port 4870] [--server-url url] [--opcua]`;\n\nasync function main() {\n\tconst { values, positionals } = parseArgs({\n\t\tallowPositionals: true,\n\t\toptions: {\n\t\t\tconfig: { type: \"string\" },\n\t\t\ttarget: { type: \"string\" },\n\t\t\thelp: { type: \"boolean\", short: \"h\" },\n\t\t\t\"emit-only\": { type: \"boolean\" },\n\t\t\tformat: { type: \"string\" },\n\t\t\tread: { type: \"string\", multiple: true },\n\t\t\t\"initialize-user\": { type: \"boolean\" },\n\t\t\t\"frozen-lockfile\": { type: \"boolean\" },\n\t\t\tcheck: { type: \"boolean\" },\n\t\t\tplc: { type: \"boolean\" },\n\t\t\tserver: { type: \"boolean\" },\n\t\t\tsimulate: { type: \"boolean\" },\n\t\t\truntime: { type: \"boolean\" },\n\t\t\tdownload: { type: \"boolean\" },\n\t\t\trestore: { type: \"boolean\" },\n\t\t\tselect: { type: \"boolean\" },\n\t\t\tyes: { type: \"boolean\", short: \"y\" },\n\t\t\tport: { type: \"string\" },\n\t\t\t\"server-url\": { type: \"string\" },\n\t\t\topcua: { type: \"boolean\" },\n\t\t},\n\t});\n\tconst [name, ...args] = positionals;\n\tconst file = values.config ?? \"tsplc.config.ts\";\n\tif (!name || values.help) {\n\t\tconsole.log(usage);\n\t\treturn 0;\n\t}\n\tif (name === \"debug\") {\n\t\tif (args.length) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Usage: tsplc debug [--target name] [--port 4870] [--server-url url] [--opcua]\",\n\t\t\t);\n\t\t}\n\t\tawait serveProjectDebugger(\n\t\t\tawait loadTsplcConfig(file, {\n\t\t\t\tenv: process.env,\n\t\t\t\ttarget: values.target,\n\t\t\t\tforAgent: false,\n\t\t\t}),\n\t\t\tvalues,\n\t\t);\n\t\treturn 0;\n\t}\n\tconst plant = plantCommand(name);\n\tif (plant) {\n\t\tconst failed = await runPlantCommand(\n\t\t\tconnect(process.env),\n\t\t\tplant,\n\t\t\targs,\n\t\t\tvalues,\n\t\t\t{\n\t\t\t\tfile,\n\t\t\t\tload: () =>\n\t\t\t\t\tloadTsplcConfig(file, {\n\t\t\t\t\t\tenv: process.env,\n\t\t\t\t\t\ttarget: values.target,\n\t\t\t\t\t\tforAgent: true,\n\t\t\t\t\t}),\n\t\t\t},\n\t\t\tprocess.env,\n\t\t);\n\t\treturn failed ? report(failed, values.format) : 0;\n\t}\n\tif (args.length) {\n\t\tthrow new Error(\"Specify one command.\");\n\t}\n\tconst command = projectCommand(name);\n\tif (!command) {\n\t\tthrow new Error(`Unknown command ${name}.`);\n\t}\n\tcheckProjectFlags(command, values);\n\tconst result = await withProgressOnStderr(values.format === \"json\", () =>\n\t\trunProjectCommand(command, file, values, process.env),\n\t);\n\treturn report(result, values.format);\n}\n\n/**\n * Sends progress to stderr while `run` runs, so stdout holds only the JSON result. Docker\n * commands that `@tsplc/build` runs follow `TSPLC_LOG_STDERR`.\n */\nasync function withProgressOnStderr<T>(\n\tenabled: boolean,\n\trun: () => Promise<T>,\n) {\n\tif (!enabled) {\n\t\treturn run();\n\t}\n\tconst log = console.log;\n\tconst previousLogTarget = process.env[\"TSPLC_LOG_STDERR\"];\n\tconsole.log = console.error;\n\tprocess.env[\"TSPLC_LOG_STDERR\"] = \"1\";\n\ttry {\n\t\treturn await run();\n\t} finally {\n\t\tconsole.log = log;\n\t\tif (previousLogTarget === undefined) {\n\t\t\tdelete process.env[\"TSPLC_LOG_STDERR\"];\n\t\t} else {\n\t\t\tprocess.env[\"TSPLC_LOG_STDERR\"] = previousLogTarget;\n\t\t}\n\t}\n}\n\nfunction report(result: CommandResult, format: string | undefined) {\n\tconst diagnostics = result.diagnostics ?? [];\n\tconst ok = !hasErrors(diagnostics);\n\tif (format === \"json\") {\n\t\tconsole.log(JSON.stringify({ ok, ...result }));\n\t} else {\n\t\tfor (const diagnostic of diagnostics) {\n\t\t\tconsole.error(formatDiagnostic(diagnostic));\n\t\t}\n\t\tif (ok) {\n\t\t\tconsole.log(\"tsPLC completed.\");\n\t\t}\n\t}\n\treturn ok ? 0 : 1;\n}\n\ntry {\n\tprocess.exitCode = await main();\n} catch (cause) {\n\t// main() may fail before its options parse, so detect JSON output from raw argv.\n\tconst json =\n\t\tprocess.argv.includes(\"json\") || process.argv.includes(\"--format=json\");\n\tif (cause instanceof DiagnosticFailure) {\n\t\tprocess.exitCode = report(cause.result, json ? \"json\" : undefined);\n\t} else {\n\t\tconst message = cause instanceof Error ? cause.message : String(cause);\n\t\tif (json) {\n\t\t\tconsole.log(\n\t\t\t\tJSON.stringify({\n\t\t\t\t\tok: false,\n\t\t\t\t\tdiagnostics: [\n\t\t\t\t\t\t{ origin: \"config\", code: \"PLC5003\", severity: \"error\", message },\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\tconsole.error(message);\n\t\t}\n\t\tprocess.exitCode = 1;\n\t}\n}\n",
|
|
6
|
+
"import { existsSync } from \"node:fs\";\nimport { relative, resolve } from \"node:path\";\nimport { serverTokenEnv, type loadTsplcConfig } from \"@tsplc/config\";\nimport {\n\tcreateDebugger,\n\tcreateLoginAdapter,\n\tcreateOpcUaAdapter,\n\tloadManifest,\n\topcUaConnection,\n\tserveDebugger,\n} from \"@tsplc/debug\";\nimport { connect, readThroughAgent } from \"./plant.ts\";\n\n/**\n * Serves the debugger for the project's last build until interrupted. It reads the controller\n * through the plant agent's login, or with `--opcua` at the config's `monitor` endpoint, and\n * follows the server's telemetry and requests when the server's base URL (`--server-url`, or\n * `server.baseUrlEnv`) and the PLC's bearer token are in the config's environment.\n */\nexport async function serveProjectDebugger(\n\t{ config, root, env }: Awaited<ReturnType<typeof loadTsplcConfig>>,\n\tflags: { port?: string; \"server-url\"?: string; opcua?: boolean },\n) {\n\tif (flags.opcua && !config.monitor) {\n\t\tthrow new Error(\n\t\t\t\"Configure monitor with the controller's OPC UA endpoint to use --opcua.\",\n\t\t);\n\t}\n\tconst agentUrl = env[\"TSPLC_AGENT_URL\"];\n\tif (!flags.opcua && !(agentUrl && env[\"TSPLC_AGENT_TOKEN\"])) {\n\t\tthrow new Error(\n\t\t\t\"Set TSPLC_AGENT_URL and TSPLC_AGENT_TOKEN to read through the plant agent's login, or pass --opcua for a local virtual PLC.\",\n\t\t);\n\t}\n\tconst file = resolve(root, \".tsplc/artifacts/st/debug.json\");\n\tif (!existsSync(file)) {\n\t\tthrow new Error(\n\t\t\t`No debug manifest at ${relative(process.cwd(), file)}: build with debug configured.`,\n\t\t);\n\t}\n\tconst port = Number(flags.port ?? 4870);\n\tif (!Number.isInteger(port) || port < 1 || port > 65535) {\n\t\tthrow new Error(\"--port must be a TCP port.\");\n\t}\n\tconst manifest = await loadManifest(file);\n\tconst serverUrl =\n\t\tflags[\"server-url\"] ??\n\t\t(config.server?.baseUrlEnv && env[config.server.baseUrlEnv]);\n\tconst tokenEnv = serverTokenEnv(config);\n\tconst token = tokenEnv && env[tokenEnv];\n\tconst log = (message: string) =>\n\t\tconsole.log(`${new Date().toISOString()} ${message}`);\n\tconst debug = await createDebugger({\n\t\tmanifest,\n\t\tadapter:\n\t\t\tflags.opcua && config.monitor\n\t\t\t\t? createOpcUaAdapter(opcUaConnection(config.monitor, { root, env }))\n\t\t\t\t: createLoginAdapter({\n\t\t\t\t\t\tread: readThroughAgent(connect(env)),\n\t\t\t\t\t\tprobe: manifest.build.target,\n\t\t\t\t\t\tendpoint: `the plant agent at ${agentUrl}`,\n\t\t\t\t\t}),\n\t\tstateDirectory: resolve(root, \".tsplc/debug\"),\n\t\twatch: config.debug?.watch ?? {},\n\t\t...(serverUrl && token && { server: { url: serverUrl, token } }),\n\t\tprojectRoot: root,\n\t\tlog,\n\t});\n\tconst server = serveDebugger(debug, { port, log });\n\tconsole.log(`tsPLC debugger at ${server.url}`);\n\tif (!serverUrl || !token) {\n\t\tconsole.log(\n\t\t\t\"Not following the server's telemetry and requests: set server.baseUrlEnv or --server-url, and the server's bearer token variable.\",\n\t\t);\n\t}\n\tawait new Promise((stopped) => {\n\t\tprocess.once(\"SIGINT\", stopped);\n\t\tprocess.once(\"SIGTERM\", stopped);\n\t});\n\tawait server.stop(true);\n\tawait debug.close();\n}\n",
|
|
7
|
+
"import {\n\tAgentOperationError,\n\ttype AgentClient,\n\tcreateAgentClient,\n} from \"@tsplc/agent/client\";\nimport {\n\task,\n\taskCredentials,\n\ttype Credentials,\n\ttype Target,\n\ttype Variable,\n} from \"@tsplc/agent\";\nimport type { LoginCommand, LoginResult } from \"@tsplc/build\";\nimport type { Environment, loadTsplcConfig } from \"@tsplc/config\";\nimport { LoginUnavailable, noLogin } from \"@tsplc/debug\";\nimport { z } from \"zod\";\nimport { prepareRelease } from \"./release.ts\";\nimport { choose, confirm, progress, timedProgress } from \"./terminal.ts\";\n\nconst plantCommands = [\n\t\"deploy\",\n\t\"target\",\n\t\"status\",\n\t\"login\",\n\t\"logout\",\n\t\"vars\",\n\t\"read\",\n\t\"write\",\n\t\"force\",\n\t\"unforce\",\n\t\"start\",\n\t\"stop\",\n\t\"reset\",\n] as const;\n\nexport type PlantCommand = (typeof plantCommands)[number];\n\nexport const plantCommand = (name: string) =>\n\tplantCommands.find((command) => command === name);\n\nexport interface PlantFlags {\n\tdownload?: boolean;\n\t\"initialize-user\"?: boolean;\n\trestore?: boolean;\n\tselect?: boolean;\n\tsimulate?: boolean;\n\tyes?: boolean;\n\t\"frozen-lockfile\"?: boolean;\n}\n\ntype LoadedConfig = Awaited<ReturnType<typeof loadTsplcConfig>>;\n\n/** The plant agent named by TSPLC_AGENT_URL and TSPLC_AGENT_TOKEN in `env`. */\nexport const connect = (env: Record<string, string | undefined>) => {\n\tconst environment = z\n\t\t.object({\n\t\t\tTSPLC_AGENT_URL: z.url({\n\t\t\t\terror:\n\t\t\t\t\t\"Set TSPLC_AGENT_URL to the plant agent, such as http://line-pc:4850\",\n\t\t\t}),\n\t\t\tTSPLC_AGENT_TOKEN: z.string({\n\t\t\t\terror: \"Set TSPLC_AGENT_TOKEN to the plant agent's token\",\n\t\t\t}),\n\t\t})\n\t\t.parse(env);\n\treturn createAgentClient({\n\t\turl: environment.TSPLC_AGENT_URL,\n\t\ttoken: environment.TSPLC_AGENT_TOKEN,\n\t});\n};\n\n/**\n * Reads through the agent's open login, as `tsplc read` does, without opening one: the\n * debugger has no controller credentials.\n */\nexport const readThroughAgent =\n\t(agent: AgentClient) =>\n\tasync ([first, ...rest]: string[]) => {\n\t\tif (!first) {\n\t\t\treturn {};\n\t\t}\n\t\ttry {\n\t\t\tconst result = await agent.command({\n\t\t\t\tcommand: \"read\",\n\t\t\t\texpressions: [first, ...rest],\n\t\t\t});\n\t\t\tif (!(\"values\" in result)) {\n\t\t\t\tthrow new Error(\"The agent answered a read without values\");\n\t\t\t}\n\t\t\treturn result.values;\n\t\t} catch (error) {\n\t\t\tconst { login } = await agent.status();\n\t\t\tif (!login) {\n\t\t\t\tthrow new LoginUnavailable(noLogin, { cause: error });\n\t\t\t}\n\t\t\tif (\"error\" in login) {\n\t\t\t\tthrow new Error(login.error, { cause: error });\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t};\n\nconst selectTarget = async (agent: AgentClient): Promise<Target> => {\n\tconst interfaces = await agent.interfaces();\n\tif (!interfaces.length) {\n\t\tthrow new Error(\"The plant PC has no IPv4 network.\");\n\t}\n\tconst network =\n\t\tinterfaces.length === 1 && interfaces[0]\n\t\t\t? interfaces[0]\n\t\t\t: await choose(\n\t\t\t\t\t\"Which network is the controller on?\",\n\t\t\t\t\tinterfaces,\n\t\t\t\t\t(item) => `${item.name} ${item.address}/${item.prefixLength}`,\n\t\t\t\t);\n\tconsole.log(\n\t\t`Scanning ${network.address}/${network.prefixLength} for CODESYS controllers…`,\n\t);\n\tconst found = await agent.discover(network.name);\n\tconst manual = { address: \"\", port: 11740, hostname: null };\n\tconst choice = await choose(\n\t\t\"Which controller?\",\n\t\t[...found, manual],\n\t\t(item) =>\n\t\t\titem === manual\n\t\t\t\t? \"Enter an address\"\n\t\t\t\t: `${item.address}${item.hostname ? ` (${item.hostname})` : \"\"}`,\n\t);\n\tconst host =\n\t\tchoice === manual ? await ask(\"Controller address: \") : choice.address;\n\treturn agent.setTarget({ host, port: choice.port });\n};\n\n/**\n * The controller user to send: TSPLC_CONTROLLER_USERNAME and TSPLC_CONTROLLER_PASSWORD from\n * `env`, else null for the user stored on the agent, else what `prompt` asks for. Initializing\n * the controller's user creates the one sent, so it never leaves it to the stored one.\n */\nexport const controllerCredentials = async (\n\tenv: Environment,\n\tagent: { stored: boolean; initializeUser: boolean },\n\tprompt: () => Promise<Credentials>,\n): Promise<Credentials | null> => {\n\tconst username = env[\"TSPLC_CONTROLLER_USERNAME\"];\n\tconst password = env[\"TSPLC_CONTROLLER_PASSWORD\"];\n\tif (username && password) {\n\t\treturn { username, password };\n\t}\n\tif (username || password) {\n\t\tthrow new Error(\n\t\t\t\"Set both TSPLC_CONTROLLER_USERNAME and TSPLC_CONTROLLER_PASSWORD, or neither.\",\n\t\t);\n\t}\n\treturn agent.stored && !agent.initializeUser ? null : prompt();\n};\n\nconst deploy = async (\n\tagent: AgentClient,\n\tfile: string,\n\tloaded: LoadedConfig,\n\tflags: PlantFlags,\n\tenv: Environment,\n) => {\n\tconst status = await agent.status();\n\tif (status.login) {\n\t\tthrow new Error(\"A login is open; log out before deploying: tsplc logout\");\n\t}\n\tconst target =\n\t\t!status.target || flags.select ? await selectTarget(agent) : status.target;\n\tconsole.log(`Building the release for ${target.host}…`);\n\tconst building = timedProgress();\n\tconst { release, diagnostics } = await prepareRelease(file, loaded, flags);\n\tif (!release) {\n\t\treturn { diagnostics };\n\t}\n\tbuilding(\"Built\");\n\tif (\n\t\tflags.download &&\n\t\t!(await confirm(\n\t\t\t\"A full download stops the running application while it loads. Continue?\",\n\t\t\tflags,\n\t\t))\n\t) {\n\t\tthrow new Error(\"Cancelled.\");\n\t}\n\tconst credentials = await controllerCredentials(\n\t\tenv,\n\t\t{\n\t\t\tstored: status.credentialsStored,\n\t\t\tinitializeUser: flags[\"initialize-user\"] ?? false,\n\t\t},\n\t\taskCredentials,\n\t);\n\tconst settings = {\n\t\tcredentials,\n\t\tdownload: flags.download ?? false,\n\t\tinitializeUser: flags[\"initialize-user\"] ?? false,\n\t};\n\tconsole.log(\n\t\trelease.manifest.server\n\t\t\t? \"Deploying the server and the program…\"\n\t\t\t: \"Deploying the program…\",\n\t);\n\tconst deploying = timedProgress();\n\tdeploying(\"Uploading\");\n\ttry {\n\t\treturn await agent.deploy(release, settings, deploying);\n\t} catch (error) {\n\t\tif (\n\t\t\t!(error instanceof AgentOperationError && error.downloadRequired) ||\n\t\t\t!(await confirm(\n\t\t\t\t`${error.message}. A full download stops the running application while it loads. Download now?`,\n\t\t\t\tflags,\n\t\t\t))\n\t\t) {\n\t\t\tthrow error;\n\t\t}\n\t\treturn agent.deploy(\n\t\t\trelease,\n\t\t\t{ ...settings, download: true },\n\t\t\ttimedProgress(),\n\t\t);\n\t}\n};\n\n/** Opens a login when none is working; it stays open across commands until `tsplc logout`. */\nconst ensureLogin = async (agent: AgentClient, env: Environment) => {\n\tconst { login, credentialsStored } = await agent.status();\n\tif (login && \"state\" in login) {\n\t\treturn;\n\t}\n\tif (login) {\n\t\tconsole.log(`The open login failed (${login.error}); replacing it.`);\n\t\tawait agent.logout();\n\t}\n\tconst credentials = await controllerCredentials(\n\t\tenv,\n\t\t{ stored: credentialsStored, initializeUser: false },\n\t\taskCredentials,\n\t);\n\tconsole.log(\n\t\t\"Logging in. CODESYS takes a few minutes to start; the login stays open until tsplc logout.\",\n\t);\n\tawait agent.login(credentials, progress);\n};\n\n/** The children of `prefix` in the variable tree, with array indexes folded into one range. */\nexport const variableChildren = (\n\tvariables: readonly Variable[],\n\tprefix: string,\n) => {\n\tconst children = new Map<string, { type?: string; leaves: number }>();\n\tconst start = prefix.toLowerCase();\n\tfor (const { path, type } of variables) {\n\t\tconst lower = path.toLowerCase();\n\t\tif (\n\t\t\tprefix &&\n\t\t\t!(\n\t\t\t\tlower === start ||\n\t\t\t\tlower.startsWith(`${start}.`) ||\n\t\t\t\tlower.startsWith(`${start}[`)\n\t\t\t)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst rest = path.slice(prefix.length).replace(/^\\./, \"\");\n\t\tif (rest === \"\") {\n\t\t\treturn [{ name: path, type, leaves: 1 }];\n\t\t}\n\t\tconst name = /^(\\[[^\\]]*\\]|[^.[]+)/.exec(rest)?.[0] ?? rest;\n\t\tconst child = children.get(name) ?? { leaves: 0 };\n\t\tchildren.set(name, {\n\t\t\ttype: rest === name ? type : undefined,\n\t\t\tleaves: child.leaves + 1,\n\t\t});\n\t}\n\tconst indexes = [...children.keys()]\n\t\t.filter((name) => /^\\[\\d+\\]$/.test(name))\n\t\t.map((name) => Number(name.slice(1, -1)));\n\tconst listed = [...children].filter(([name]) => !/^\\[\\d+\\]$/.test(name));\n\tif (indexes.length) {\n\t\tconst first = children.get(`[${Math.min(...indexes)}]`);\n\t\tlisted.unshift([\n\t\t\t`[${Math.min(...indexes)}..${Math.max(...indexes)}]`,\n\t\t\tfirst ?? { leaves: 0 },\n\t\t]);\n\t}\n\treturn listed.map(([name, child]) => ({ name, ...child }));\n};\n\nconst printStatus = async (agent: AgentClient) => {\n\tconst status = await agent.status();\n\tconsole.log(\n\t\t`Controller ${status.target ? `${status.target.host}:${status.target.port}` : \"not selected (tsplc target)\"}`,\n\t);\n\tconsole.log(\n\t\t`Release ${status.release ? `${status.release.id}, ${status.release.operation} at ${status.release.deployedAt}` : \"none\"}`,\n\t);\n\tconsole.log(\n\t\t`Server ${status.server ? `${status.server.running ? \"running\" : \"restarting\"} (${status.server.executable})` : \"none\"}`,\n\t);\n\tconst { login } = status;\n\tif (!login) {\n\t\tconsole.log(\"Login closed\");\n\t} else if (\"error\" in login) {\n\t\tconsole.log(`Login failed: ${login.error} (tsplc logout)`);\n\t} else {\n\t\tconsole.log(\n\t\t\t`Login open; application ${login.state}${login.forced.length ? `; forced: ${login.forced.join(\", \")}` : \"\"}`,\n\t\t);\n\t}\n};\n\n/** Lists the deployed release's published variables under `path`, or its roots. */\nconst printVariables = async (agent: AgentClient, path: string | undefined) => {\n\tconst children = variableChildren(await agent.variables(), path ?? \"\");\n\tif (!children.length) {\n\t\tthrow new Error(`No published variable ${path}.`);\n\t}\n\tfor (const child of children) {\n\t\tconsole.log(\n\t\t\t`${child.name.padEnd(32)} ${child.type ?? `${child.leaves} variables`}`,\n\t\t);\n\t}\n};\n\nconst printLogin = (result: LoginResult) => {\n\tif (\"values\" in result) {\n\t\tfor (const [expression, value] of Object.entries(result.values)) {\n\t\t\tconsole.log(`${expression} = ${value}`);\n\t\t}\n\t\treturn;\n\t}\n\tconsole.log(`Application ${result.state}`);\n\tif (result.forced.length) {\n\t\tconsole.log(`Forced: ${result.forced.join(\", \")}`);\n\t}\n};\n\n/**\n * Runs a command against the plant agent. Returns a deployment's compiler diagnostics when the\n * program doesn't compile.\n */\nexport const runPlantCommand = async (\n\tagent: AgentClient,\n\tcommand: PlantCommand,\n\targs: string[],\n\tflags: PlantFlags,\n\tproject: { file: string; load: () => Promise<LoadedConfig> },\n\tenv: Environment,\n) => {\n\tconst expect = (count: number, usage: string) => {\n\t\tif (args.length !== count) {\n\t\t\tthrow new Error(`Usage: tsplc ${command} ${usage}`);\n\t\t}\n\t};\n\tconst send = async (loginCommand: LoginCommand) => {\n\t\tawait ensureLogin(agent, env);\n\t\tprintLogin(await agent.command(loginCommand));\n\t};\n\tswitch (command) {\n\t\tcase \"deploy\": {\n\t\t\texpect(\n\t\t\t\t0,\n\t\t\t\t\"[--target name] [--download] [--select] [--initialize-user] [--simulate]\",\n\t\t\t);\n\t\t\tconst deployed = await deploy(\n\t\t\t\tagent,\n\t\t\t\tproject.file,\n\t\t\t\tawait project.load(),\n\t\t\t\tflags,\n\t\t\t\tenv,\n\t\t\t);\n\t\t\tif (\"diagnostics\" in deployed) {\n\t\t\t\treturn deployed;\n\t\t\t}\n\t\t\tconsole.log(`Deployed release ${deployed.id} (${deployed.operation}).`);\n\t\t\treturn;\n\t\t}\n\t\tcase \"target\": {\n\t\t\texpect(0, \"\");\n\t\t\tconst target = await selectTarget(agent);\n\t\t\tconsole.log(`Deployments now go to ${target.host}:${target.port}.`);\n\t\t\treturn;\n\t\t}\n\t\tcase \"status\":\n\t\t\texpect(0, \"\");\n\t\t\treturn printStatus(agent);\n\t\tcase \"login\":\n\t\t\texpect(0, \"\");\n\t\t\tawait ensureLogin(agent, env);\n\t\t\tprintLogin(await agent.command({ command: \"state\" }));\n\t\t\treturn;\n\t\tcase \"logout\": {\n\t\t\texpect(0, \"\");\n\t\t\tconst { login } = await agent.status();\n\t\t\tconst forced = login && \"forced\" in login ? login.forced : [];\n\t\t\tif (\n\t\t\t\tforced.length &&\n\t\t\t\t!(await confirm(\n\t\t\t\t\t`Forced: ${forced.join(\", \")}. Forces stay on the controller after logout. Log out anyway?`,\n\t\t\t\t\tflags,\n\t\t\t\t))\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Cancelled.\");\n\t\t\t}\n\t\t\tconst { failure } = await agent.logout();\n\t\t\tconsole.log(\n\t\t\t\tfailure\n\t\t\t\t\t? `The login couldn't log out (${failure}); its container was removed.`\n\t\t\t\t\t: \"Logged out.\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tcase \"vars\":\n\t\t\tif (args.length > 1) {\n\t\t\t\tthrow new Error(\"Usage: tsplc vars [path]\");\n\t\t\t}\n\t\t\treturn printVariables(agent, args[0]);\n\t\tcase \"read\": {\n\t\t\tconst [first, ...rest] = args;\n\t\t\tif (!first) {\n\t\t\t\tthrow new Error(\"Usage: tsplc read <expression>...\");\n\t\t\t}\n\t\t\treturn send({ command: \"read\", expressions: [first, ...rest] });\n\t\t}\n\t\tcase \"write\":\n\t\tcase \"force\": {\n\t\t\tconst [expression, value, ...extra] = args;\n\t\t\tif (!expression || !value || extra.length) {\n\t\t\t\tthrow new Error(`Usage: tsplc ${command} <expression> <value>`);\n\t\t\t}\n\t\t\treturn send({ command, values: { [expression]: value } });\n\t\t}\n\t\tcase \"unforce\":\n\t\t\treturn send({\n\t\t\t\tcommand: \"unforce\",\n\t\t\t\texpressions: args,\n\t\t\t\trestore: flags.restore ?? false,\n\t\t\t});\n\t\tcase \"start\":\n\t\t\texpect(0, \"\");\n\t\t\treturn send({ command: \"start\" });\n\t\tcase \"stop\":\n\t\t\texpect(0, \"\");\n\t\t\tif (!(await confirm(\"Stop the application on the controller?\", flags))) {\n\t\t\t\tthrow new Error(\"Cancelled.\");\n\t\t\t}\n\t\t\treturn send({ command: \"stop\" });\n\t\tcase \"reset\": {\n\t\t\texpect(1, \"warm|cold\");\n\t\t\tconst kind = z.enum([\"warm\", \"cold\"]).parse(args[0]);\n\t\t\tif (\n\t\t\t\t!(await confirm(\n\t\t\t\t\t`Reset the application (${kind})? It stops and reinitializes its variables.`,\n\t\t\t\t\tflags,\n\t\t\t\t))\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Cancelled.\");\n\t\t\t}\n\t\t\treturn send({\n\t\t\t\tcommand: \"reset\",\n\t\t\t\tkind: kind === \"warm\" ? \"Warm\" : \"Cold\",\n\t\t\t});\n\t\t}\n\t}\n};\n",
|
|
8
|
+
"import { existsSync } from \"node:fs\";\nimport { basename, relative, resolve, sep } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ReleaseFile } from \"@tsplc/agent/client\";\nimport type { ReleaseManifest } from \"@tsplc/agent\";\nimport {\n\tbuildTargetFor,\n\tcontrollerFor,\n\tserverTokenEnv,\n\ttype loadTsplcConfig,\n} from \"@tsplc/config\";\nimport { hasErrors } from \"@tsplc/compiler/ir\";\nimport { contractVariables } from \"@tsplc/opcua/contract\";\nimport { generateProject } from \"@tsplc/typegen\";\nimport { z } from \"zod\";\nimport { buildConfigs, buildProject, projectTargets } from \"./project.ts\";\nimport { bundleServer } from \"./server.ts\";\n\ntype LoadedConfig = Awaited<ReturnType<typeof loadTsplcConfig>>;\n\n/** Every published leaf the generated contract describes, as CODESYS expressions name it. */\nconst releaseVariables = async (\n\tconfig: LoadedConfig[\"config\"],\n\troot: string,\n) => {\n\tif (!config.typegen) {\n\t\treturn [];\n\t}\n\tconst contract = z\n\t\t.object({\n\t\t\tsymbols: z.array(\n\t\t\t\tz.object({ name: z.string(), gvl: z.string(), type: z.string() }),\n\t\t\t),\n\t\t\ttypeFields: z.record(\n\t\t\t\tz.string(),\n\t\t\t\tz.array(\n\t\t\t\t\tz.object({\n\t\t\t\t\t\tfield: z.string(),\n\t\t\t\t\t\ttype: z.string(),\n\t\t\t\t\t\tdescription: z.string(),\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t\t})\n\t\t.parse(\n\t\t\tawait import(\n\t\t\t\tpathToFileURL(resolve(root, config.typegen.dir, \"plc.ts\")).href\n\t\t\t),\n\t\t);\n\treturn contractVariables(contract).map(({ path, type }) => ({ path, type }));\n};\n\n/**\n * Compiles the program and bundles its server into the files `tsplc deploy` uploads: the\n * production program, or with `--simulate` the development one without fieldbus I/O, for a\n * virtual PLC whose inputs a plant simulation writes, as `tsplc run --simulate` builds it.\n */\nexport const prepareRelease = async (\n\tfile: string,\n\tloaded: LoadedConfig,\n\tflags: { simulate?: boolean; \"frozen-lockfile\"?: boolean },\n) => {\n\tconst { config, root } = loaded;\n\tif (!config.compiler) {\n\t\tthrow new Error(\"tsplc deploy deploys tsPLC programs; configure compiler.\");\n\t}\n\tconst command = flags.simulate ? \"run\" : \"deploy\";\n\tconst emitted = await buildProject(file, {\n\t\temitOnly: true,\n\t\tforController: true,\n\t\tfrozenLockfile: flags[\"frozen-lockfile\"],\n\t\t...buildConfigs(loaded, flags),\n\t\tbuildTarget: buildTargetFor(command),\n\t\tcontroller: controllerFor(config, command),\n\t});\n\tif (hasErrors(emitted.diagnostics)) {\n\t\treturn { diagnostics: emitted.diagnostics };\n\t}\n\tconst settings = emitted.controllerConfig;\n\tif (!settings) {\n\t\tthrow new Error(\"Configure build settings for deployment.\");\n\t}\n\tawait generateProject(file, {\n\t\tloaded,\n\t\ttargets: await projectTargets(file, { loaded }),\n\t});\n\n\tconst portable = (path: string) => path.split(sep).join(\"/\");\n\tconst libraries = (settings.libraries ?? []).map((library) => ({\n\t\t...library,\n\t\trelease: `libraries/${library.sha256}-${basename(library.path)}`,\n\t}));\n\tconst files: ReleaseFile[] = [\n\t\t{ path: \"template.project\", content: Bun.file(settings.template) },\n\t\t...libraries.map((library) => ({\n\t\t\tpath: library.release,\n\t\t\tcontent: Bun.file(library.path),\n\t\t})),\n\t];\n\t// The agent compiles only the ST. Plain TypeScript programs emit their generated modules under `.tsplc/`.\n\tfor await (const source of new Bun.Glob(\"**/*.st\").scan({\n\t\tcwd: settings.sourceDir,\n\t\tdot: true,\n\t})) {\n\t\tfiles.push({\n\t\t\tpath: `st/${portable(source)}`,\n\t\t\tcontent: Bun.file(resolve(settings.sourceDir, source)),\n\t\t});\n\t}\n\t// The agent's debugger reads the program through its debug manifest.\n\tconst debugManifest = resolve(settings.sourceDir, \"debug.json\");\n\tif (existsSync(debugManifest)) {\n\t\tfiles.push({ path: \"debug.json\", content: Bun.file(debugManifest) });\n\t}\n\tconst serverScript =\n\t\tconfig.server?.runtime && (await bundleServer(config, root));\n\tconst server = serverScript\n\t\t? {\n\t\t\t\tpath: `server/${basename(serverScript)}`,\n\t\t\t\tcontent: Bun.file(serverScript),\n\t\t\t}\n\t\t: undefined;\n\tif (server) {\n\t\tfiles.push(server);\n\t}\n\tconst manifest: ReleaseManifest = {\n\t\t// Paths are relative to the release; the agent supplies the output and controller settings.\n\t\tconfig: {\n\t\t\tio: {},\n\t\t\tdeviceTree: settings.deviceTree,\n\t\t\tcontroller: settings.controller,\n\t\t\tlibraryReferences: settings.libraryReferences,\n\t\t\tlibraries: libraries.map(({ release, ...library }) => ({\n\t\t\t\t...library,\n\t\t\t\tpath: release,\n\t\t\t})),\n\t\t\ttask: settings.task,\n\t\t\ttasks: settings.tasks,\n\t\t\tremoveObjects: settings.removeObjects,\n\t\t\tsymbols: settings.symbols,\n\t\t\ttimeouts: settings.timeouts,\n\t\t\ttemplate: \"template.project\",\n\t\t\tsourceDir: \"st\",\n\t\t\tentry: `st/${portable(relative(settings.sourceDir, settings.entry))}`,\n\t\t},\n\t\tvariables: await releaseVariables(config, root),\n\t\tserver: server?.path,\n\t\tdebug: config.debug,\n\t\tserverTokenEnv: serverTokenEnv(config),\n\t\tsecrets: config.secrets,\n\t};\n\treturn { release: { manifest, files } };\n};\n",
|
|
9
|
+
"import {\n\tcopyFile,\n\tmkdir,\n\tmkdtemp,\n\trealpath,\n\trm,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport {\n\tbuildCodesys,\n\tcodesysBuildConfig,\n\ttype CodesysPlan,\n\ttype CodesysProject,\n\ttype SourceMapping,\n\tdiagnoseCodesys,\n\temitCodesys,\n\tioTargets,\n\tpublicationSelectors,\n\tplanCodesys,\n} from \"@tsplc/compiler/codesys\";\nimport { analyze, checkHostConfig } from \"@tsplc/compiler\";\nimport {\n\ttype Controller,\n\ttype BuildTarget,\n\ttype NormalizedConfig,\n\ttype ResolvedTsplcConfig,\n\tcompilerConfig,\n\tloadTsplcConfig,\n\tsimulationConfig,\n} from \"@tsplc/config\";\nimport {\n\tdeviceTree,\n\ttype ProjectTargets,\n\tloadHardware,\n\tresolveIo,\n} from \"@tsplc/typegen\";\nimport { installLibraries } from \"@tsplc/build\";\nimport {\n\ttype Diagnostic,\n\thasErrors,\n\tnormalizeModule,\n} from \"@tsplc/compiler/ir\";\nimport {\n\tcleanArtifacts,\n\tengineeringDirectory,\n\towned,\n\tpublishArtifacts,\n} from \"./artifacts.ts\";\n\nconst failure = (\n\torigin: Diagnostic[\"origin\"],\n\tcode: string,\n\tcause: unknown,\n): Diagnostic => ({\n\torigin,\n\tcode,\n\tseverity: \"error\",\n\tmessage: cause instanceof Error ? cause.message : String(cause),\n});\n\ntype LoadedConfig = Awaited<ReturnType<typeof loadTsplcConfig>>;\n\n/**\n * `buildProject`'s `loaded` and `configured` options. With `simulate` the build omits fieldbus\n * I/O so a plant simulator can write the inputs; generated types and the debug manifest keep\n * describing the hardware project.\n */\nexport const buildConfigs = (\n\tloaded: LoadedConfig,\n\toptions: { simulate?: boolean },\n) =>\n\toptions.simulate\n\t\t? {\n\t\t\t\tloaded: { ...loaded, config: simulationConfig(loaded.config) },\n\t\t\t\tconfigured: loaded.config,\n\t\t\t}\n\t\t: { loaded };\n\ninterface ProjectOptions {\n\tloaded?: LoadedConfig;\n\tbuildTarget?: BuildTarget;\n\t/** The configuration `loaded` simulates, whose hardware the debug manifest describes. */\n\tconfigured?: ResolvedTsplcConfig;\n\t/**\n\t * The host config check's diagnostics, when the caller ran it before loading the config. The\n\t * check type-checks the config and takes seconds.\n\t */\n\thostConfigDiagnostics?: readonly Diagnostic[];\n}\n\nasync function loadProject(\n\tfile: string,\n\t{ loaded, buildTarget, configured, hostConfigDiagnostics }: ProjectOptions,\n): Promise<{\n\tconfig?: NormalizedConfig;\n\tconfigFile: string;\n\tshared?: ResolvedTsplcConfig;\n\tproject?: CodesysProject;\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\tlet configFile = resolve(file);\n\ttry {\n\t\tconfigFile = await realpath(configFile);\n\t\tconst diagnostics = hostConfigDiagnostics ?? checkHostConfig(configFile);\n\t\tif (hasErrors(diagnostics)) {\n\t\t\treturn { configFile, diagnostics };\n\t\t}\n\t\tconst { config: shared, env } =\n\t\t\tloaded ?? (await loadTsplcConfig(configFile));\n\t\tconst root = dirname(configFile);\n\t\tconst catalog = await loadHardware(shared, root);\n\n\t\tconst config = compilerConfig(\n\t\t\tshared,\n\t\t\tresolveIo(shared, catalog),\n\t\t\tbuildTarget,\n\t\t);\n\t\treturn {\n\t\t\tconfigFile,\n\t\t\tshared,\n\t\t\tconfig: { ...config, ...sourceInput(config, root) },\n\t\t\tproject: {\n\t\t\t\troot,\n\t\t\t\tenv,\n\t\t\t\t...(shared.debug && { debug: shared.debug }),\n\t\t\t\t...(shared.telemetry && { telemetry: shared.telemetry }),\n\t\t\t\t...(shared.server && { server: shared.server }),\n\t\t\t\t// A simulation build drops fieldbus IO, but the debugger still shows the hardware it stands in for.\n\t\t\t\thardware: {\n\t\t\t\t\tcatalog: configured ? await loadHardware(configured, root) : catalog,\n\t\t\t\t\tconfig: configured ?? shared,\n\t\t\t\t\ttree: shared.codesys?.deviceTree !== undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t\tdiagnostics,\n\t\t};\n\t} catch (cause) {\n\t\treturn { configFile, diagnostics: [failure(\"config\", \"PLC5003\", cause)] };\n\t}\n}\n\n/** The analyzer's entry points, resolved against the config file's directory. */\nfunction sourceInput(\n\tcompiler: {\n\t\ttsconfig: string;\n\t\tprograms: Record<string, { module: string; export: string }>;\n\t},\n\troot: string,\n) {\n\treturn {\n\t\ttsconfig: resolve(root, compiler.tsconfig),\n\t\tprograms: Object.fromEntries(\n\t\t\tObject.entries(compiler.programs).map(([name, entry]) => [\n\t\t\t\tname,\n\t\t\t\t{ ...entry, module: resolve(root, entry.module) },\n\t\t\t]),\n\t\t),\n\t};\n}\n\n/**\n * I/O keys and publication selectors from analyzed PLC source. It ignores the\n * config's own type errors, so a typo cannot switch off the types that flag it;\n * it is undefined only while the source itself fails analysis.\n */\nexport async function projectTargets(\n\tfile = \"tsplc.config.ts\",\n\toptions: { loaded?: LoadedConfig } = {},\n): Promise<ProjectTargets | undefined> {\n\tconst configFile = await realpath(resolve(file));\n\tconst { config, env } = options.loaded ?? (await loadTsplcConfig(configFile));\n\tif (!config.compiler) {\n\t\treturn undefined;\n\t}\n\tconst source = analyze({\n\t\t...sourceInput(config.compiler, dirname(configFile)),\n\t\tservices: config.server,\n\t\tenv,\n\t});\n\tconst core = source.module && normalizeModule(source.module).core;\n\treturn core\n\t\t? { io: ioTargets(core), publication: publicationSelectors(core) }\n\t\t: undefined;\n}\n\nexport async function checkProject(\n\tfile = \"tsplc.config.ts\",\n\toptions: ProjectOptions = {},\n): Promise<{\n\tconfigFile: string;\n\tconfig?: NormalizedConfig;\n\tshared?: ResolvedTsplcConfig;\n\tplan?: CodesysPlan;\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\tconst loaded = await loadProject(file, options);\n\tif (!loaded.config || !loaded.project) {\n\t\treturn loaded;\n\t}\n\n\tconst config = loaded.config;\n\tif (config.target.kind !== \"codesys\") {\n\t\treturn {\n\t\t\t...loaded,\n\t\t\tdiagnostics: [\n\t\t\t\tfailure(\n\t\t\t\t\t\"backend\",\n\t\t\t\t\t\"PLC7001\",\n\t\t\t\t\t`Unsupported target: ${config.target.kind}`,\n\t\t\t\t),\n\t\t\t],\n\t\t};\n\t}\n\n\tconst source = analyze({\n\t\ttsconfig: config.tsconfig,\n\t\tprograms: config.programs,\n\t\tservices: loaded.shared?.server,\n\t\tenv: loaded.project.env,\n\t});\n\tif (!source.module) {\n\t\treturn { ...loaded, diagnostics: source.diagnostics };\n\t}\n\tconst normalized = normalizeModule(source.module);\n\tif (!normalized.core) {\n\t\treturn { ...loaded, diagnostics: normalized.diagnostics };\n\t}\n\n\tconst tasks = config.tasks.map((task) => ({\n\t\tname: task.name,\n\t\tintervalNanoseconds: task.schedule.interval.nanoseconds,\n\t\tpriority: task.priority,\n\t\tprograms: task.programs,\n\t}));\n\tconst planned = planCodesys(\n\t\tnormalized.core,\n\t\t{ tasks },\n\t\tconfig.target.options,\n\t\tloaded.project,\n\t);\n\treturn {\n\t\t...loaded,\n\t\t...planned,\n\t\tdiagnostics: [\n\t\t\t...loaded.diagnostics,\n\t\t\t...source.diagnostics,\n\t\t\t...normalized.diagnostics,\n\t\t\t...planned.diagnostics,\n\t\t],\n\t};\n}\n\n/** The installed libraries and fieldbus device tree a CODESYS project of this program needs. */\nasync function engineeringInputs(\n\tshared: ResolvedTsplcConfig,\n\tconfigFile: string,\n\tbundle: Pick<ReturnType<typeof emitCodesys>, \"ioMappings\">,\n\toptions: { frozen?: boolean },\n) {\n\tconst root = dirname(configFile);\n\tconst tree = await deviceTree(shared, await loadHardware(shared, root));\n\treturn {\n\t\tlibraries: await installLibraries(shared.dependencies, root, options),\n\t\t// The emitted names locate mapped IO; the tree maps their channels.\n\t\tdeviceTree: tree && {\n\t\t\t...tree,\n\t\t\tmappings: bundle.ioMappings.map(({ address, variable }) => ({\n\t\t\t\taddress,\n\t\t\t\tvariable,\n\t\t\t})),\n\t\t},\n\t};\n}\n\nexport async function buildProject(\n\tfile = \"tsplc.config.ts\",\n\toptions: ProjectOptions & {\n\t\temitOnly?: boolean;\n\t\tfrozenLockfile?: boolean;\n\t\tcontroller?: Controller;\n\t\t/** Resolve libraries and the device tree into `controllerConfig` even when only emitting. */\n\t\tforController?: boolean;\n\t} = {},\n): Promise<{\n\tdirectory?: string;\n\tstatus?: \"emitted\" | \"vendor-compiled\";\n\tcontrollerConfig?: ReturnType<typeof codesysBuildConfig>;\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\tlet staging: string | undefined;\n\ttry {\n\t\tconst configFile = await realpath(resolve(file));\n\t\t// Withdraw the previous success receipt before checking the new source.\n\t\t// Old artifacts remain owned and intact until publication succeeds.\n\t\tconst previous = await owned(configFile, true);\n\t\tif (previous.unknown.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Output contains unrelated files: ${previous.unknown.join(\", \")}`,\n\t\t\t);\n\t\t}\n\n\t\tconst checked = await checkProject(configFile, options);\n\t\tif (!checked.plan || !checked.config) {\n\t\t\treturn { diagnostics: checked.diagnostics };\n\t\t}\n\t\tconst bundle = emitCodesys(checked.plan);\n\t\tif (hasErrors(bundle.diagnostics)) {\n\t\t\treturn { diagnostics: bundle.diagnostics };\n\t\t}\n\t\tconst shared = checked.shared;\n\t\tconst engineering =\n\t\t\tshared && (!options.emitOnly || options.forController)\n\t\t\t\t? await engineeringInputs(shared, configFile, bundle, {\n\t\t\t\t\t\tfrozen: options.frozenLockfile,\n\t\t\t\t\t})\n\t\t\t\t: undefined;\n\t\tconst outDir =\n\t\t\tshared?.build && resolve(dirname(configFile), shared.build.outDir);\n\t\tconst controllerConfig = outDir\n\t\t\t? codesysBuildConfig(checked.plan, bundle, {\n\t\t\t\t\tconfigFile,\n\t\t\t\t\tsourceDir: join(previous.output, \"st\"),\n\t\t\t\t\toutDir,\n\t\t\t\t\tcontroller: options.controller,\n\t\t\t\t\t...engineering,\n\t\t\t\t})\n\t\t\t: undefined;\n\n\t\tawait mkdir(previous.root, { recursive: true });\n\t\tstaging = await mkdtemp(join(previous.root, \"stage-\"));\n\t\tconst artifacts = [\n\t\t\t...bundle.artifacts,\n\t\t\t{\n\t\t\t\tpath: \"mappings.json\",\n\t\t\t\tcontent: `${JSON.stringify(compactMappings(bundle.mappings))}\\n`,\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"io-symbols.json\",\n\t\t\t\tcontent: `${JSON.stringify(bundle.ioSymbols, null, 2)}\\n`,\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"publication.json\",\n\t\t\t\tcontent: `${JSON.stringify(bundle.publication, null, 2)}\\n`,\n\t\t\t},\n\t\t\t{\n\t\t\t\tpath: \"config.json\",\n\t\t\t\tcontent: `${JSON.stringify(checked.config, null, 2)}\\n`,\n\t\t\t},\n\t\t\t...(bundle.debug\n\t\t\t\t? [{ path: \"debug.json\", content: `${JSON.stringify(bundle.debug)}\\n` }]\n\t\t\t\t: []),\n\t\t];\n\t\tfor (const artifact of artifacts) {\n\t\t\tconst path = join(staging, \"st\", artifact.path);\n\t\t\tawait mkdir(dirname(path), { recursive: true });\n\t\t\tawait writeFile(path, artifact.content);\n\t\t}\n\n\t\tlet vendor: Awaited<ReturnType<typeof buildCodesys>> | undefined;\n\t\tif (!options.emitOnly) {\n\t\t\t// The engineering cache has its own ownership marker and survives clean.\n\t\t\tconst engineeringDir = outDir ?? join(previous.root, \"engineering\");\n\t\t\tawait engineeringDirectory(engineeringDir, configFile);\n\t\t\ttry {\n\t\t\t\tvendor = await buildCodesys(checked.plan, bundle, {\n\t\t\t\t\tconfigFile,\n\t\t\t\t\tsourceDir: join(staging, \"st\"),\n\t\t\t\t\toutDir: engineeringDir,\n\t\t\t\t\tcontroller: options.controller,\n\t\t\t\t\t...engineering,\n\t\t\t\t});\n\t\t\t} catch (cause) {\n\t\t\t\treturn { diagnostics: diagnoseCodesys(cause, bundle) };\n\t\t\t}\n\n\t\t\tconst vendorArtifacts = [\n\t\t\t\t[\"Application.project\", vendor.project],\n\t\t\t\t[\"Application.app\", vendor.output],\n\t\t\t\t[\"Application.crc\", vendor.checksum],\n\t\t\t] as const;\n\t\t\tfor (const [name, path] of vendorArtifacts) {\n\t\t\t\tif (!path) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst destination = join(staging, \"vendor\", name);\n\t\t\t\tawait mkdir(dirname(destination), { recursive: true });\n\t\t\t\tawait copyFile(path, destination);\n\t\t\t}\n\t\t}\n\n\t\tconst status = vendor ? \"vendor-compiled\" : \"emitted\";\n\t\tawait publishArtifacts(staging, previous, {\n\t\t\tconfigFile,\n\t\t\tstatus,\n\t\t\t...(vendor && {\n\t\t\t\tvendor: { application: vendor.application, tasks: vendor.tasks },\n\t\t\t}),\n\t\t});\n\t\t// Publication moved this directory into place; it is no longer staging.\n\t\tstaging = undefined;\n\t\treturn {\n\t\t\tdirectory: previous.output,\n\t\t\tstatus,\n\t\t\t...(controllerConfig && { controllerConfig }),\n\t\t\tdiagnostics: [...checked.diagnostics, ...bundle.diagnostics],\n\t\t};\n\t} catch (cause) {\n\t\treturn { diagnostics: [failure(\"config\", \"PLC5004\", cause)] };\n\t} finally {\n\t\tif (staging) {\n\t\t\tawait rm(staging, { recursive: true, force: true });\n\t\t}\n\t}\n}\n\n/**\n * Source mappings with each ST path and source file written once: `mappings` rows are\n * `[object, line, file, start, end, sourceLine, sourceColumn]`, indexing `objects` and `files`.\n */\nfunction compactMappings(mappings: readonly SourceMapping[]) {\n\tconst objects = new Map<string, number>();\n\tconst files = new Map<string, number>();\n\tconst index = (table: Map<string, number>, value: string) => {\n\t\tconst known = table.get(value);\n\t\tif (known !== undefined) {\n\t\t\treturn known;\n\t\t}\n\t\ttable.set(value, table.size);\n\t\treturn table.size - 1;\n\t};\n\tconst rows = mappings.map(({ path, line, span }) => [\n\t\tindex(objects, path),\n\t\tline,\n\t\tindex(files, span.file),\n\t\tspan.start,\n\t\tspan.end,\n\t\tspan.line,\n\t\tspan.column,\n\t]);\n\treturn {\n\t\tobjects: [...objects.keys()],\n\t\tfiles: [...files.keys()],\n\t\tmappings: rows,\n\t};\n}\n\nexport async function cleanProject(file = \"tsplc.config.ts\"): Promise<{\n\tdiagnostics: readonly Diagnostic[];\n}> {\n\ttry {\n\t\tawait cleanArtifacts(await realpath(resolve(file)));\n\t\treturn { diagnostics: [] };\n\t} catch (cause) {\n\t\treturn { diagnostics: [failure(\"config\", \"PLC5004\", cause)] };\n\t}\n}\n",
|
|
10
|
+
"import { createHash } from \"node:crypto\";\nimport {\n\tlstat,\n\tmkdir,\n\treaddir,\n\treadFile,\n\trename,\n\trm,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\nimport type { buildCodesys } from \"@tsplc/compiler/codesys\";\nimport { sha256Digest } from \"@tsplc/config/build\";\nimport { z } from \"zod\";\n\nconst missing = (cause: unknown): boolean =>\n\tcause instanceof Error && \"code\" in cause && cause.code === \"ENOENT\";\nconst digest = (value: string | Uint8Array): string =>\n\tcreateHash(\"sha256\").update(value).digest(\"hex\");\n\n// Ownership is an explicit boundary: generated files must match their manifest,\n// and engineering trees must belong to this configuration before vendor writes.\nconst generatedFileSchema = z.object({\n\tpath: z\n\t\t.string()\n\t\t.regex(/^[A-Za-z0-9_ .-]+(?:\\/[A-Za-z0-9_ .-]+)*$/)\n\t\t.refine(\n\t\t\t(path) =>\n\t\t\t\t!path.split(\"/\").some((part) => part === \".\" || part === \"..\") &&\n\t\t\t\t![\"manifest.json\", \"receipt.json\"].includes(path),\n\t\t),\n\tsha256: sha256Digest,\n});\n\n/** The manifest's envelope; its entries are checked one by one to name the failure. */\nconst manifestSchema = z.object({\n\tkind: z.literal(\"tsplc-artifacts\"),\n\tversion: z.literal(1),\n\tconfigFile: z.string(),\n\tfiles: z.array(z.unknown()),\n});\n\ntype Manifest = Omit<z.infer<typeof manifestSchema>, \"files\"> & {\n\tfiles: z.infer<typeof generatedFileSchema>[];\n};\n\nconst buildStatusSchema = z.enum([\"emitted\", \"vendor-compiled\"]);\n\nconst receiptSchema = z.object({\n\tkind: z.literal(\"tsplc-build\"),\n\tversion: z.literal(1),\n\tconfigFile: z.string(),\n\tstatus: buildStatusSchema,\n});\n\nconst engineeringMarkerSchema = z.object({\n\tkind: z.literal(\"tsplc-engineering\"),\n\tversion: z.literal(1),\n\tconfigFile: z.string(),\n});\n\nfunction manifest(value: unknown, configFile: string): Manifest {\n\tconst parsed = manifestSchema.safeParse(value);\n\tif (!parsed.success || parsed.data.configFile !== configFile) {\n\t\tthrow new Error(\n\t\t\t\"Output directory has no matching tsPLC ownership manifest.\",\n\t\t);\n\t}\n\n\tconst files = parsed.data.files.map((item) => {\n\t\tconst file = generatedFileSchema.safeParse(item);\n\t\tif (!file.success) {\n\t\t\tthrow new Error(\"Invalid generated file ownership entry.\");\n\t\t}\n\t\treturn file.data;\n\t});\n\tif (new Set(files.map((item) => item.path)).size !== files.length) {\n\t\tthrow new Error(\"Duplicate generated file ownership entry.\");\n\t}\n\treturn { ...parsed.data, files };\n}\n\nasync function directory(path: string): Promise<boolean> {\n\ttry {\n\t\tconst entry = await lstat(path);\n\t\tif (!entry.isDirectory() || entry.isSymbolicLink()) {\n\t\t\tthrow new Error(`Generated directory must be a real directory: ${path}`);\n\t\t}\n\t\treturn true;\n\t} catch (cause) {\n\t\tif (missing(cause)) {\n\t\t\treturn false;\n\t\t}\n\t\tthrow cause;\n\t}\n}\n\nasync function filesIn(path: string, prefix = \"\"): Promise<string[]> {\n\tconst result: string[] = [];\n\tfor (const entry of await readdir(path, { withFileTypes: true })) {\n\t\tconst name = prefix + entry.name;\n\t\tif (entry.isDirectory() && !entry.isSymbolicLink()) {\n\t\t\tresult.push(...(await filesIn(join(path, entry.name), `${name}/`)));\n\t\t} else {\n\t\t\tresult.push(name);\n\t\t}\n\t}\n\treturn result;\n}\n\nexport async function engineeringDirectory(\n\tpath: string,\n\tconfigFile: string,\n): Promise<void> {\n\tconst marker = join(path, \"ownership.json\");\n\tconst exists = await directory(path);\n\tif (!exists || !(await readdir(path)).length) {\n\t\tawait mkdir(path, { recursive: true });\n\t\tawait writeFile(\n\t\t\tmarker,\n\t\t\t`${JSON.stringify({ kind: \"tsplc-engineering\", version: 1, configFile }, null, 2)}\\n`,\n\t\t\t{ flag: \"wx\" },\n\t\t);\n\t} else {\n\t\tconst entry = await lstat(marker).catch((cause: unknown) => {\n\t\t\tif (missing(cause)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Engineering cache has no matching tsPLC ownership marker: ${path}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow cause;\n\t\t});\n\t\tif (!entry.isFile() || entry.isSymbolicLink()) {\n\t\t\tthrow new Error(\"Engineering ownership marker must be a real file.\");\n\t\t}\n\t\tconst value = engineeringMarkerSchema.safeParse(\n\t\t\tJSON.parse(await readFile(marker, \"utf8\")),\n\t\t);\n\t\tif (!value.success || value.data.configFile !== configFile) {\n\t\t\tthrow new Error(\n\t\t\t\t`Engineering cache has no matching tsPLC ownership marker: ${path}`,\n\t\t\t);\n\t\t}\n\t}\n\n\tconst inspect = async (directory: string): Promise<void> => {\n\t\tfor (const entry of await readdir(directory, { withFileTypes: true })) {\n\t\t\tconst child = join(directory, entry.name);\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Engineering cache must not contain symlinks: ${child}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait inspect(child);\n\t\t\t}\n\t\t}\n\t};\n\tawait inspect(path);\n}\n\nexport async function owned(\n\tconfigFile: string,\n\twithdrawReceipt = false,\n): Promise<{\n\troot: string;\n\toutput: string;\n\townership?: Manifest;\n\tunknown: string[];\n}> {\n\tconst root = join(dirname(configFile), \".tsplc\");\n\tconst output = join(root, \"artifacts\");\n\tif (!(await directory(root)) || !(await directory(output))) {\n\t\treturn { root, output, unknown: [] };\n\t}\n\n\tconst manifestPath = join(output, \"manifest.json\");\n\tconst manifestEntry = await lstat(manifestPath);\n\tif (!manifestEntry.isFile() || manifestEntry.isSymbolicLink()) {\n\t\tthrow new Error(\"Ownership manifest must be a real file.\");\n\t}\n\tconst ownership = manifest(\n\t\tJSON.parse(await readFile(manifestPath, \"utf8\")),\n\t\tconfigFile,\n\t);\n\tconst receipt = join(output, \"receipt.json\");\n\ttry {\n\t\tconst entry = await lstat(receipt);\n\t\tif (!entry.isFile() || entry.isSymbolicLink()) {\n\t\t\tthrow new Error(\"Build receipt must be a real file.\");\n\t\t}\n\t\tconst value = receiptSchema.safeParse(\n\t\t\tJSON.parse(await readFile(receipt, \"utf8\")),\n\t\t);\n\t\tif (!value.success || value.data.configFile !== configFile) {\n\t\t\tthrow new Error(\"Build receipt is not owned by this configuration.\");\n\t\t}\n\t\tif (withdrawReceipt) {\n\t\t\tawait rm(receipt);\n\t\t}\n\t} catch (cause) {\n\t\tif (!missing(cause)) {\n\t\t\tthrow cause;\n\t\t}\n\t}\n\n\tconst names = new Set([\n\t\t...ownership.files.map((file) => file.path),\n\t\t\"manifest.json\",\n\t\t\"receipt.json\",\n\t]);\n\tfor (const file of ownership.files) {\n\t\tlet parent = output;\n\t\tfor (const part of file.path.split(\"/\").slice(0, -1)) {\n\t\t\tparent = join(parent, part);\n\t\t\tif (!(await directory(parent))) {\n\t\t\t\tthrow new Error(`Missing generated directory: ${parent}`);\n\t\t\t}\n\t\t}\n\t\tconst path = join(output, file.path);\n\t\tconst entry = await lstat(path);\n\t\tif (\n\t\t\t!entry.isFile() ||\n\t\t\tentry.isSymbolicLink() ||\n\t\t\tdigest(await readFile(path)) !== file.sha256\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Generated file was replaced or edited; preserve it before rebuilding/cleaning: ${path}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\troot,\n\t\toutput,\n\t\townership,\n\t\tunknown: (await filesIn(output)).filter((name) => !names.has(name)),\n\t};\n}\n\ninterface Receipt {\n\tconfigFile: string;\n\tstatus: z.infer<typeof buildStatusSchema>;\n\tvendor?: Pick<\n\t\tAwaited<ReturnType<typeof buildCodesys>>,\n\t\t\"application\" | \"tasks\"\n\t>;\n}\n\n// Compile in a separate staging tree. Recheck ownership immediately before the\n// swap, because the vendor build may have given the user time to edit old files.\nexport async function publishArtifacts(\n\tstaging: string,\n\tprevious: Awaited<ReturnType<typeof owned>>,\n\treceipt: Receipt,\n): Promise<void> {\n\tconst configFile = receipt.configFile;\n\tconst generated = (await filesIn(staging)).sort();\n\tconst ownership: Manifest = {\n\t\tkind: \"tsplc-artifacts\",\n\t\tversion: 1,\n\t\tconfigFile,\n\t\tfiles: [],\n\t};\n\tfor (const path of generated) {\n\t\townership.files.push({\n\t\t\tpath,\n\t\t\tsha256: digest(await readFile(join(staging, path))),\n\t\t});\n\t}\n\tawait writeFile(\n\t\tjoin(staging, \"manifest.json\"),\n\t\t`${JSON.stringify(ownership, null, 2)}\\n`,\n\t);\n\tawait writeFile(\n\t\tjoin(staging, \"receipt.json\"),\n\t\t`${JSON.stringify(\n\t\t\t{\n\t\t\t\tkind: \"tsplc-build\",\n\t\t\t\tversion: 1,\n\t\t\t\tgeneratedAt: new Date().toISOString(),\n\t\t\t\t...receipt,\n\t\t\t},\n\t\t\tnull,\n\t\t\t2,\n\t\t)}\\n`,\n\t);\n\n\tconst current = await owned(configFile);\n\tif (\n\t\tJSON.stringify(current.ownership) !== JSON.stringify(previous.ownership)\n\t) {\n\t\tthrow new Error(\n\t\t\t\"Output ownership changed during the build; preserve it before rebuilding.\",\n\t\t);\n\t}\n\tif (current.unknown.length) {\n\t\tthrow new Error(\n\t\t\t`Output contains unrelated files: ${current.unknown.join(\", \")}`,\n\t\t);\n\t}\n\n\tconst backup = `${staging}-previous`;\n\tif (previous.ownership) {\n\t\tawait rename(previous.output, backup);\n\t}\n\ttry {\n\t\tawait rename(staging, previous.output);\n\t} catch (cause) {\n\t\tif (previous.ownership) {\n\t\t\tawait rename(backup, previous.output);\n\t\t}\n\t\tthrow cause;\n\t}\n\tif (previous.ownership) {\n\t\tawait rm(backup, { recursive: true });\n\t}\n}\n\nexport async function cleanArtifacts(configFile: string): Promise<void> {\n\tconst generated = await owned(configFile);\n\tif (!generated.ownership) {\n\t\treturn;\n\t}\n\tfor (const entry of generated.ownership.files) {\n\t\tawait rm(join(generated.output, entry.path));\n\t}\n\tawait rm(join(generated.output, \"receipt.json\"), { force: true });\n\tawait rm(join(generated.output, \"manifest.json\"));\n\n\t// Remove empty generated directories while preserving unrelated files.\n\tconst removeEmpty = async (path: string): Promise<void> => {\n\t\tfor (const entry of await readdir(path, { withFileTypes: true })) {\n\t\t\tif (entry.isDirectory() && !entry.isSymbolicLink()) {\n\t\t\t\tawait removeEmpty(join(path, entry.name));\n\t\t\t}\n\t\t}\n\t\tif (!(await readdir(path)).length) {\n\t\t\tawait rm(path, { recursive: true });\n\t\t}\n\t};\n\tawait removeEmpty(generated.output);\n}\n",
|
|
11
|
+
"import { existsSync } from \"node:fs\";\nimport { mkdtemp, mkdir, rm, rename } from \"node:fs/promises\";\nimport { dirname, resolve, join } from \"node:path\";\nimport { createRequire } from \"node:module\";\nimport ts from \"typescript\";\nimport type { ResolvedTsplcConfig } from \"@tsplc/config\";\nimport { typeCheckOnly } from \"@tsplc/compiler\";\n\nconst resolveServerModule = (root: string, name: string) =>\n\tname.startsWith(\".\") ||\n\tname.startsWith(\"/\") ||\n\texistsSync(resolve(root, name))\n\t\t? resolve(root, name)\n\t\t: createRequire(join(root, \"package.json\")).resolve(name);\n\nconst kebabCase = (name: string) =>\n\tname\n\t\t.replace(/([a-z0-9])([A-Z])|([A-Z])([A-Z][a-z])/g, \"$1$3-$2$4\")\n\t\t.replace(/[^A-Za-z0-9]+/g, \"-\")\n\t\t.replace(/^-|-$/g, \"\")\n\t\t.toLowerCase();\n\n/** `build/server/<name>-services<extension>`, where the server's script or executable goes. */\nconst serverOutput = (\n\tconfig: ResolvedTsplcConfig,\n\troot: string,\n\textension: string,\n) =>\n\tresolve(\n\t\troot,\n\t\t\"build/server\",\n\t\t`${kebabCase(config.name)}-services${extension}`,\n\t);\n\n/** The host entry, type-checked as it will be built. */\nconst checkedServerEntry = (config: ResolvedTsplcConfig, root: string) => {\n\tconst runtime = config.server?.runtime;\n\tif (!runtime) {\n\t\tthrow new Error(\"Configure server.runtime to build the server.\");\n\t}\n\tconst entry = resolveServerModule(root, runtime.entry);\n\tconst tsconfig = ts.findConfigFile(dirname(entry), ts.sys.fileExists);\n\tif (!tsconfig) {\n\t\tthrow new Error(\"Server entry requires a tsconfig.json.\");\n\t}\n\tconst read = ts.readConfigFile(tsconfig, ts.sys.readFile);\n\tif (read.error) {\n\t\tthrow new Error(\n\t\t\tts.flattenDiagnosticMessageText(read.error.messageText, \"\\n\"),\n\t\t);\n\t}\n\tconst parsed = ts.parseJsonConfigFileContent(\n\t\tread.config,\n\t\tts.sys,\n\t\tdirname(tsconfig),\n\t);\n\tconst program = ts.createProgram({\n\t\trootNames: [\n\t\t\tentry,\n\t\t\t...parsed.fileNames.filter((file) => /\\.d\\.[cm]?ts$/.test(file)),\n\t\t],\n\t\toptions: { ...parsed.options, ...typeCheckOnly },\n\t\tprojectReferences: parsed.projectReferences,\n\t});\n\tconst diagnostics = [...parsed.errors, ...ts.getPreEmitDiagnostics(program)];\n\tif (diagnostics.length) {\n\t\tthrow new Error(\n\t\t\tts.formatDiagnosticsWithColorAndContext(diagnostics, {\n\t\t\t\tgetCanonicalFileName: (path) => path,\n\t\t\t\tgetCurrentDirectory: () => root,\n\t\t\t\tgetNewLine: () => \"\\n\",\n\t\t\t}),\n\t\t);\n\t}\n\treturn { entry, runtime };\n};\n\n/**\n * Bundles the host entry, which starts its own listener, into one minified script,\n * `build/server/<name>-services.js`, which the plant agent runs on its own Bun. It is a few MB\n * where an executable, which embeds Bun, is over 100, and deployments upload it.\n */\nexport const bundleServer = async (\n\tconfig: ResolvedTsplcConfig,\n\troot: string,\n) => {\n\tconst { entry } = checkedServerEntry(config, root);\n\tconst outFile = serverOutput(config, root, \".js\");\n\tconst result = await Bun.build({\n\t\tentrypoints: [entry],\n\t\ttarget: \"bun\",\n\t\tminify: true,\n\t\tenv: \"disable\",\n\t});\n\tif (!result.success) {\n\t\tthrow new AggregateError(result.logs, \"Server bundle build failed.\");\n\t}\n\tconst [script, ...assets] = result.outputs;\n\tif (!script || assets.length) {\n\t\tthrow new Error(\n\t\t\t`The server bundle needs files beside its script (${assets.map(({ path }) => path).join(\", \")}), which deployments don't carry.`,\n\t\t);\n\t}\n\tawait mkdir(dirname(outFile), { recursive: true });\n\tawait Bun.write(outFile, script);\n\treturn outFile;\n};\n\n/** Compiles the host entry, which starts its own listener, into `build/server/<name>-services`. */\nexport const buildServer = async (\n\tconfig: ResolvedTsplcConfig,\n\troot: string,\n) => {\n\tconst { entry, runtime } = checkedServerEntry(config, root);\n\tconst windows = runtime.target\n\t\t? runtime.target.includes(\"windows\")\n\t\t: process.platform === \"win32\";\n\tconst outFile = serverOutput(config, root, windows ? \".exe\" : \"\");\n\tawait mkdir(dirname(outFile), { recursive: true });\n\t// Compile beside the output so dependency resolution starts from the owning project.\n\tconst staging = await mkdtemp(join(dirname(outFile), \".tsplc-server-\"));\n\ttry {\n\t\tconst binary = join(staging, \"server\");\n\t\tconst result = await Bun.build({\n\t\t\tentrypoints: [entry],\n\t\t\tenv: \"disable\",\n\t\t\tcompile: {\n\t\t\t\toutfile: binary,\n\t\t\t\t...(runtime.target ? { target: runtime.target } : {}),\n\t\t\t\tautoloadDotenv: false,\n\t\t\t\tautoloadBunfig: false,\n\t\t\t\tautoloadTsconfig: false,\n\t\t\t\tautoloadPackageJson: false,\n\t\t\t},\n\t\t});\n\t\tif (!result.success) {\n\t\t\tthrow new AggregateError(result.logs, \"Server executable build failed.\");\n\t\t}\n\t\t// Bun names a Windows executable itself.\n\t\tawait rename(windows ? `${binary}.exe` : binary, outFile);\n\t\treturn {\n\t\t\tserver: {\n\t\t\t\texecutable: outFile,\n\t\t\t\ttarget: runtime.target ?? `bun-${process.platform}-${process.arch}`,\n\t\t\t},\n\t\t};\n\t} finally {\n\t\tawait rm(staging, { recursive: true, force: true });\n\t}\n};\n",
|
|
12
|
+
"import { ask } from \"@tsplc/agent\";\n\nexport const choose = async <T>(\n\tquestion: string,\n\titems: readonly T[],\n\tlabel: (item: T) => string,\n) => {\n\titems.forEach((item, index) => console.log(` ${index + 1}. ${label(item)}`));\n\twhile (true) {\n\t\tconst item =\n\t\t\titems[Number(await ask(`${question} [1-${items.length}]: `)) - 1];\n\t\tif (item !== undefined) {\n\t\t\treturn item;\n\t\t}\n\t}\n};\n\nexport const confirm = async (question: string, flags: { yes?: boolean }) =>\n\tflags.yes || /^y(es)?$/i.test(await ask(`${question} [y/N]: `));\n\nexport const progress = (message: string) => console.log(` ${message}`);\n\n/** Prints progress with the minutes and seconds since it was made, so the slow steps show. */\nexport const timedProgress = () => {\n\tconst start = Date.now();\n\treturn (message: string) => {\n\t\tconst seconds = Math.round((Date.now() - start) / 1000);\n\t\tprogress(\n\t\t\t`${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, \"0\")} ${message}`,\n\t\t);\n\t};\n};\n",
|
|
13
|
+
"import {\n\tAgentOperationError,\n\ttype AgentClient,\n\tcreateAgentClient,\n} from \"@tsplc/agent/client\";\nimport {\n\task,\n\taskCredentials,\n\ttype Credentials,\n\ttype Target,\n\ttype Variable,\n} from \"@tsplc/agent\";\nimport type { LoginCommand, LoginResult } from \"@tsplc/build\";\nimport type { Environment, loadTsplcConfig } from \"@tsplc/config\";\nimport { LoginUnavailable, noLogin } from \"@tsplc/debug\";\nimport { z } from \"zod\";\nimport { prepareRelease } from \"./release.ts\";\nimport { choose, confirm, progress, timedProgress } from \"./terminal.ts\";\n\nconst plantCommands = [\n\t\"deploy\",\n\t\"target\",\n\t\"status\",\n\t\"login\",\n\t\"logout\",\n\t\"vars\",\n\t\"read\",\n\t\"write\",\n\t\"force\",\n\t\"unforce\",\n\t\"start\",\n\t\"stop\",\n\t\"reset\",\n] as const;\n\nexport type PlantCommand = (typeof plantCommands)[number];\n\nexport const plantCommand = (name: string) =>\n\tplantCommands.find((command) => command === name);\n\nexport interface PlantFlags {\n\tdownload?: boolean;\n\t\"initialize-user\"?: boolean;\n\trestore?: boolean;\n\tselect?: boolean;\n\tsimulate?: boolean;\n\tyes?: boolean;\n\t\"frozen-lockfile\"?: boolean;\n}\n\ntype LoadedConfig = Awaited<ReturnType<typeof loadTsplcConfig>>;\n\n/** The plant agent named by TSPLC_AGENT_URL and TSPLC_AGENT_TOKEN in `env`. */\nexport const connect = (env: Record<string, string | undefined>) => {\n\tconst environment = z\n\t\t.object({\n\t\t\tTSPLC_AGENT_URL: z.url({\n\t\t\t\terror:\n\t\t\t\t\t\"Set TSPLC_AGENT_URL to the plant agent, such as http://line-pc:4850\",\n\t\t\t}),\n\t\t\tTSPLC_AGENT_TOKEN: z.string({\n\t\t\t\terror: \"Set TSPLC_AGENT_TOKEN to the plant agent's token\",\n\t\t\t}),\n\t\t})\n\t\t.parse(env);\n\treturn createAgentClient({\n\t\turl: environment.TSPLC_AGENT_URL,\n\t\ttoken: environment.TSPLC_AGENT_TOKEN,\n\t});\n};\n\n/**\n * Reads through the agent's open login, as `tsplc read` does, without opening one: the\n * debugger has no controller credentials.\n */\nexport const readThroughAgent =\n\t(agent: AgentClient) =>\n\tasync ([first, ...rest]: string[]) => {\n\t\tif (!first) {\n\t\t\treturn {};\n\t\t}\n\t\ttry {\n\t\t\tconst result = await agent.command({\n\t\t\t\tcommand: \"read\",\n\t\t\t\texpressions: [first, ...rest],\n\t\t\t});\n\t\t\tif (!(\"values\" in result)) {\n\t\t\t\tthrow new Error(\"The agent answered a read without values\");\n\t\t\t}\n\t\t\treturn result.values;\n\t\t} catch (error) {\n\t\t\tconst { login } = await agent.status();\n\t\t\tif (!login) {\n\t\t\t\tthrow new LoginUnavailable(noLogin, { cause: error });\n\t\t\t}\n\t\t\tif (\"error\" in login) {\n\t\t\t\tthrow new Error(login.error, { cause: error });\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t};\n\nconst selectTarget = async (agent: AgentClient): Promise<Target> => {\n\tconst interfaces = await agent.interfaces();\n\tif (!interfaces.length) {\n\t\tthrow new Error(\"The plant PC has no IPv4 network.\");\n\t}\n\tconst network =\n\t\tinterfaces.length === 1 && interfaces[0]\n\t\t\t? interfaces[0]\n\t\t\t: await choose(\n\t\t\t\t\t\"Which network is the controller on?\",\n\t\t\t\t\tinterfaces,\n\t\t\t\t\t(item) => `${item.name} ${item.address}/${item.prefixLength}`,\n\t\t\t\t);\n\tconsole.log(\n\t\t`Scanning ${network.address}/${network.prefixLength} for CODESYS controllers…`,\n\t);\n\tconst found = await agent.discover(network.name);\n\tconst manual = { address: \"\", port: 11740, hostname: null };\n\tconst choice = await choose(\n\t\t\"Which controller?\",\n\t\t[...found, manual],\n\t\t(item) =>\n\t\t\titem === manual\n\t\t\t\t? \"Enter an address\"\n\t\t\t\t: `${item.address}${item.hostname ? ` (${item.hostname})` : \"\"}`,\n\t);\n\tconst host =\n\t\tchoice === manual ? await ask(\"Controller address: \") : choice.address;\n\treturn agent.setTarget({ host, port: choice.port });\n};\n\n/**\n * The controller user to send: TSPLC_CONTROLLER_USERNAME and TSPLC_CONTROLLER_PASSWORD from\n * `env`, else null for the user stored on the agent, else what `prompt` asks for. Initializing\n * the controller's user creates the one sent, so it never leaves it to the stored one.\n */\nexport const controllerCredentials = async (\n\tenv: Environment,\n\tagent: { stored: boolean; initializeUser: boolean },\n\tprompt: () => Promise<Credentials>,\n): Promise<Credentials | null> => {\n\tconst username = env[\"TSPLC_CONTROLLER_USERNAME\"];\n\tconst password = env[\"TSPLC_CONTROLLER_PASSWORD\"];\n\tif (username && password) {\n\t\treturn { username, password };\n\t}\n\tif (username || password) {\n\t\tthrow new Error(\n\t\t\t\"Set both TSPLC_CONTROLLER_USERNAME and TSPLC_CONTROLLER_PASSWORD, or neither.\",\n\t\t);\n\t}\n\treturn agent.stored && !agent.initializeUser ? null : prompt();\n};\n\nconst deploy = async (\n\tagent: AgentClient,\n\tfile: string,\n\tloaded: LoadedConfig,\n\tflags: PlantFlags,\n\tenv: Environment,\n) => {\n\tconst status = await agent.status();\n\tif (status.login) {\n\t\tthrow new Error(\"A login is open; log out before deploying: tsplc logout\");\n\t}\n\tconst target =\n\t\t!status.target || flags.select ? await selectTarget(agent) : status.target;\n\tconsole.log(`Building the release for ${target.host}…`);\n\tconst building = timedProgress();\n\tconst { release, diagnostics } = await prepareRelease(file, loaded, flags);\n\tif (!release) {\n\t\treturn { diagnostics };\n\t}\n\tbuilding(\"Built\");\n\tif (\n\t\tflags.download &&\n\t\t!(await confirm(\n\t\t\t\"A full download stops the running application while it loads. Continue?\",\n\t\t\tflags,\n\t\t))\n\t) {\n\t\tthrow new Error(\"Cancelled.\");\n\t}\n\tconst credentials = await controllerCredentials(\n\t\tenv,\n\t\t{\n\t\t\tstored: status.credentialsStored,\n\t\t\tinitializeUser: flags[\"initialize-user\"] ?? false,\n\t\t},\n\t\taskCredentials,\n\t);\n\tconst settings = {\n\t\tcredentials,\n\t\tdownload: flags.download ?? false,\n\t\tinitializeUser: flags[\"initialize-user\"] ?? false,\n\t};\n\tconsole.log(\n\t\trelease.manifest.server\n\t\t\t? \"Deploying the server and the program…\"\n\t\t\t: \"Deploying the program…\",\n\t);\n\tconst deploying = timedProgress();\n\tdeploying(\"Uploading\");\n\ttry {\n\t\treturn await agent.deploy(release, settings, deploying);\n\t} catch (error) {\n\t\tif (\n\t\t\t!(error instanceof AgentOperationError && error.downloadRequired) ||\n\t\t\t!(await confirm(\n\t\t\t\t`${error.message}. A full download stops the running application while it loads. Download now?`,\n\t\t\t\tflags,\n\t\t\t))\n\t\t) {\n\t\t\tthrow error;\n\t\t}\n\t\treturn agent.deploy(\n\t\t\trelease,\n\t\t\t{ ...settings, download: true },\n\t\t\ttimedProgress(),\n\t\t);\n\t}\n};\n\n/** Opens a login when none is working; it stays open across commands until `tsplc logout`. */\nconst ensureLogin = async (agent: AgentClient, env: Environment) => {\n\tconst { login, credentialsStored } = await agent.status();\n\tif (login && \"state\" in login) {\n\t\treturn;\n\t}\n\tif (login) {\n\t\tconsole.log(`The open login failed (${login.error}); replacing it.`);\n\t\tawait agent.logout();\n\t}\n\tconst credentials = await controllerCredentials(\n\t\tenv,\n\t\t{ stored: credentialsStored, initializeUser: false },\n\t\taskCredentials,\n\t);\n\tconsole.log(\n\t\t\"Logging in. CODESYS takes a few minutes to start; the login stays open until tsplc logout.\",\n\t);\n\tawait agent.login(credentials, progress);\n};\n\n/** The children of `prefix` in the variable tree, with array indexes folded into one range. */\nexport const variableChildren = (\n\tvariables: readonly Variable[],\n\tprefix: string,\n) => {\n\tconst children = new Map<string, { type?: string; leaves: number }>();\n\tconst start = prefix.toLowerCase();\n\tfor (const { path, type } of variables) {\n\t\tconst lower = path.toLowerCase();\n\t\tif (\n\t\t\tprefix &&\n\t\t\t!(\n\t\t\t\tlower === start ||\n\t\t\t\tlower.startsWith(`${start}.`) ||\n\t\t\t\tlower.startsWith(`${start}[`)\n\t\t\t)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst rest = path.slice(prefix.length).replace(/^\\./, \"\");\n\t\tif (rest === \"\") {\n\t\t\treturn [{ name: path, type, leaves: 1 }];\n\t\t}\n\t\tconst name = /^(\\[[^\\]]*\\]|[^.[]+)/.exec(rest)?.[0] ?? rest;\n\t\tconst child = children.get(name) ?? { leaves: 0 };\n\t\tchildren.set(name, {\n\t\t\ttype: rest === name ? type : undefined,\n\t\t\tleaves: child.leaves + 1,\n\t\t});\n\t}\n\tconst indexes = [...children.keys()]\n\t\t.filter((name) => /^\\[\\d+\\]$/.test(name))\n\t\t.map((name) => Number(name.slice(1, -1)));\n\tconst listed = [...children].filter(([name]) => !/^\\[\\d+\\]$/.test(name));\n\tif (indexes.length) {\n\t\tconst first = children.get(`[${Math.min(...indexes)}]`);\n\t\tlisted.unshift([\n\t\t\t`[${Math.min(...indexes)}..${Math.max(...indexes)}]`,\n\t\t\tfirst ?? { leaves: 0 },\n\t\t]);\n\t}\n\treturn listed.map(([name, child]) => ({ name, ...child }));\n};\n\nconst printStatus = async (agent: AgentClient) => {\n\tconst status = await agent.status();\n\tconsole.log(\n\t\t`Controller ${status.target ? `${status.target.host}:${status.target.port}` : \"not selected (tsplc target)\"}`,\n\t);\n\tconsole.log(\n\t\t`Release ${status.release ? `${status.release.id}, ${status.release.operation} at ${status.release.deployedAt}` : \"none\"}`,\n\t);\n\tconsole.log(\n\t\t`Server ${status.server ? `${status.server.running ? \"running\" : \"restarting\"} (${status.server.executable})` : \"none\"}`,\n\t);\n\tconst { login } = status;\n\tif (!login) {\n\t\tconsole.log(\"Login closed\");\n\t} else if (\"error\" in login) {\n\t\tconsole.log(`Login failed: ${login.error} (tsplc logout)`);\n\t} else {\n\t\tconsole.log(\n\t\t\t`Login open; application ${login.state}${login.forced.length ? `; forced: ${login.forced.join(\", \")}` : \"\"}`,\n\t\t);\n\t}\n};\n\n/** Lists the deployed release's published variables under `path`, or its roots. */\nconst printVariables = async (agent: AgentClient, path: string | undefined) => {\n\tconst children = variableChildren(await agent.variables(), path ?? \"\");\n\tif (!children.length) {\n\t\tthrow new Error(`No published variable ${path}.`);\n\t}\n\tfor (const child of children) {\n\t\tconsole.log(\n\t\t\t`${child.name.padEnd(32)} ${child.type ?? `${child.leaves} variables`}`,\n\t\t);\n\t}\n};\n\nconst printLogin = (result: LoginResult) => {\n\tif (\"values\" in result) {\n\t\tfor (const [expression, value] of Object.entries(result.values)) {\n\t\t\tconsole.log(`${expression} = ${value}`);\n\t\t}\n\t\treturn;\n\t}\n\tconsole.log(`Application ${result.state}`);\n\tif (result.forced.length) {\n\t\tconsole.log(`Forced: ${result.forced.join(\", \")}`);\n\t}\n};\n\n/**\n * Runs a command against the plant agent. Returns a deployment's compiler diagnostics when the\n * program doesn't compile.\n */\nexport const runPlantCommand = async (\n\tagent: AgentClient,\n\tcommand: PlantCommand,\n\targs: string[],\n\tflags: PlantFlags,\n\tproject: { file: string; load: () => Promise<LoadedConfig> },\n\tenv: Environment,\n) => {\n\tconst expect = (count: number, usage: string) => {\n\t\tif (args.length !== count) {\n\t\t\tthrow new Error(`Usage: tsplc ${command} ${usage}`);\n\t\t}\n\t};\n\tconst send = async (loginCommand: LoginCommand) => {\n\t\tawait ensureLogin(agent, env);\n\t\tprintLogin(await agent.command(loginCommand));\n\t};\n\tswitch (command) {\n\t\tcase \"deploy\": {\n\t\t\texpect(\n\t\t\t\t0,\n\t\t\t\t\"[--target name] [--download] [--select] [--initialize-user] [--simulate]\",\n\t\t\t);\n\t\t\tconst deployed = await deploy(\n\t\t\t\tagent,\n\t\t\t\tproject.file,\n\t\t\t\tawait project.load(),\n\t\t\t\tflags,\n\t\t\t\tenv,\n\t\t\t);\n\t\t\tif (\"diagnostics\" in deployed) {\n\t\t\t\treturn deployed;\n\t\t\t}\n\t\t\tconsole.log(`Deployed release ${deployed.id} (${deployed.operation}).`);\n\t\t\treturn;\n\t\t}\n\t\tcase \"target\": {\n\t\t\texpect(0, \"\");\n\t\t\tconst target = await selectTarget(agent);\n\t\t\tconsole.log(`Deployments now go to ${target.host}:${target.port}.`);\n\t\t\treturn;\n\t\t}\n\t\tcase \"status\":\n\t\t\texpect(0, \"\");\n\t\t\treturn printStatus(agent);\n\t\tcase \"login\":\n\t\t\texpect(0, \"\");\n\t\t\tawait ensureLogin(agent, env);\n\t\t\tprintLogin(await agent.command({ command: \"state\" }));\n\t\t\treturn;\n\t\tcase \"logout\": {\n\t\t\texpect(0, \"\");\n\t\t\tconst { login } = await agent.status();\n\t\t\tconst forced = login && \"forced\" in login ? login.forced : [];\n\t\t\tif (\n\t\t\t\tforced.length &&\n\t\t\t\t!(await confirm(\n\t\t\t\t\t`Forced: ${forced.join(\", \")}. Forces stay on the controller after logout. Log out anyway?`,\n\t\t\t\t\tflags,\n\t\t\t\t))\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Cancelled.\");\n\t\t\t}\n\t\t\tconst { failure } = await agent.logout();\n\t\t\tconsole.log(\n\t\t\t\tfailure\n\t\t\t\t\t? `The login couldn't log out (${failure}); its container was removed.`\n\t\t\t\t\t: \"Logged out.\",\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tcase \"vars\":\n\t\t\tif (args.length > 1) {\n\t\t\t\tthrow new Error(\"Usage: tsplc vars [path]\");\n\t\t\t}\n\t\t\treturn printVariables(agent, args[0]);\n\t\tcase \"read\": {\n\t\t\tconst [first, ...rest] = args;\n\t\t\tif (!first) {\n\t\t\t\tthrow new Error(\"Usage: tsplc read <expression>...\");\n\t\t\t}\n\t\t\treturn send({ command: \"read\", expressions: [first, ...rest] });\n\t\t}\n\t\tcase \"write\":\n\t\tcase \"force\": {\n\t\t\tconst [expression, value, ...extra] = args;\n\t\t\tif (!expression || !value || extra.length) {\n\t\t\t\tthrow new Error(`Usage: tsplc ${command} <expression> <value>`);\n\t\t\t}\n\t\t\treturn send({ command, values: { [expression]: value } });\n\t\t}\n\t\tcase \"unforce\":\n\t\t\treturn send({\n\t\t\t\tcommand: \"unforce\",\n\t\t\t\texpressions: args,\n\t\t\t\trestore: flags.restore ?? false,\n\t\t\t});\n\t\tcase \"start\":\n\t\t\texpect(0, \"\");\n\t\t\treturn send({ command: \"start\" });\n\t\tcase \"stop\":\n\t\t\texpect(0, \"\");\n\t\t\tif (!(await confirm(\"Stop the application on the controller?\", flags))) {\n\t\t\t\tthrow new Error(\"Cancelled.\");\n\t\t\t}\n\t\t\treturn send({ command: \"stop\" });\n\t\tcase \"reset\": {\n\t\t\texpect(1, \"warm|cold\");\n\t\t\tconst kind = z.enum([\"warm\", \"cold\"]).parse(args[0]);\n\t\t\tif (\n\t\t\t\t!(await confirm(\n\t\t\t\t\t`Reset the application (${kind})? It stops and reinitializes its variables.`,\n\t\t\t\t\tflags,\n\t\t\t\t))\n\t\t\t) {\n\t\t\t\tthrow new Error(\"Cancelled.\");\n\t\t\t}\n\t\t\treturn send({\n\t\t\t\tcommand: \"reset\",\n\t\t\t\tkind: kind === \"warm\" ? \"Warm\" : \"Cold\",\n\t\t\t});\n\t\t}\n\t}\n};\n",
|
|
14
|
+
"import { resolve } from \"node:path\";\nimport {\n\tbuildTargetFor,\n\tcontrollerFor,\n\ttype Environment,\n\tloadTsplcConfig,\n\trawBuildConfig,\n} from \"@tsplc/config\";\nimport {\n\tbuildProject as buildSt,\n\tconfigureDocker,\n\tconfigureRuntime,\n\tinspectController,\n\tinstallLibraries,\n\tloadSources,\n\trawEngineeringSettings,\n\tresolveConfig,\n\trunProject,\n\tupdateController,\n} from \"@tsplc/build\";\nimport { checkHostConfig } from \"@tsplc/compiler\";\nimport { type Diagnostic, hasErrors } from \"@tsplc/compiler/ir\";\nimport { generateProject } from \"@tsplc/typegen\";\nimport { loadHardware, resolveIo } from \"@tsplc/typegen/hardware\";\nimport {\n\tbuildConfigs,\n\tbuildProject,\n\tcheckProject,\n\tcleanProject,\n\tprojectTargets,\n} from \"./project.ts\";\nimport { buildServer } from \"./server.ts\";\n\nconst projectCommands = [\n\t\"install\",\n\t\"typegen\",\n\t\"check\",\n\t\"build\",\n\t\"run\",\n\t\"download\",\n\t\"online-change\",\n\t\"inspect\",\n\t\"clean\",\n\t\"configure\",\n] as const;\n\nexport type ProjectCommand = (typeof projectCommands)[number];\n\nexport const projectCommand = (name: string) =>\n\tprojectCommands.find((command) => command === name);\n\nexport interface ProjectFlags {\n\t\"emit-only\"?: boolean;\n\tformat?: string;\n\tread?: string[];\n\t\"initialize-user\"?: boolean;\n\t\"frozen-lockfile\"?: boolean;\n\tcheck?: boolean;\n\tplc?: boolean;\n\tserver?: boolean;\n\tsimulate?: boolean;\n\truntime?: boolean;\n\ttarget?: string;\n}\n\n/** Every command result; one whose diagnostics have errors fails the command. */\nexport type CommandResult = object & { diagnostics?: readonly Diagnostic[] };\n\n/** A result whose diagnostics fail the command; the CLI reports the whole result. */\nexport class DiagnosticFailure extends Error {\n\tconstructor(readonly result: CommandResult) {\n\t\tsuper(\"PLC validation failed.\");\n\t}\n}\n\ntype LoadedConfig = Awaited<ReturnType<typeof loadTsplcConfig>>;\n\n/** Rejects the flags that don't apply to `command`. */\nexport const checkProjectFlags = (\n\tcommand: ProjectCommand,\n\tflags: ProjectFlags,\n) => {\n\tif (flags.format && ![\"json\", \"text\"].includes(flags.format)) {\n\t\tthrow new Error(\"--format must be json or text.\");\n\t}\n\tif (flags[\"emit-only\"] && command !== \"build\") {\n\t\tthrow new Error(\"--emit-only is supported by build only.\");\n\t}\n\tif (flags.target && (command === \"configure\" || command === \"clean\")) {\n\t\tthrow new Error(\"--target applies only to commands that read the config.\");\n\t}\n\tif (flags.runtime && command !== \"configure\") {\n\t\tthrow new Error(\"--runtime applies only to configure.\");\n\t}\n\tif ((flags.plc || flags.server) && command !== \"build\") {\n\t\tthrow new Error(\"--plc and --server apply only to build.\");\n\t}\n\t// deploy takes --simulate too, but runs as a plant command.\n\tif (\n\t\tflags.simulate &&\n\t\t![\"run\", \"download\", \"online-change\"].includes(command)\n\t) {\n\t\tthrow new Error(\n\t\t\t\"--simulate applies only to run, download, online-change and deploy.\",\n\t\t);\n\t}\n\tif (flags.plc && flags.server) {\n\t\tthrow new Error(\"Choose --plc or --server, or omit both for a full build.\");\n\t}\n\tif (flags.server && flags[\"emit-only\"]) {\n\t\tthrow new Error(\"--emit-only applies to PLC emission only.\");\n\t}\n};\n\nexport const runProjectCommand = async (\n\tcommand: ProjectCommand,\n\tfile: string,\n\tflags: ProjectFlags,\n\tenv: Environment,\n): Promise<CommandResult> => {\n\tconst load = () =>\n\t\tloadTsplcConfig(file, { env, target: flags.target, forAgent: false });\n\tswitch (command) {\n\t\tcase \"configure\":\n\t\t\treturn configure(flags);\n\t\tcase \"clean\":\n\t\t\treturn cleanProject(file);\n\t\tcase \"install\":\n\t\t\treturn install(await load(), flags);\n\t\tcase \"typegen\":\n\t\t\treturn typegen(file, await load(), flags);\n\t\tcase \"check\":\n\t\t\treturn check(file, await loadCheckedConfig(file, load));\n\t\tcase \"build\":\n\t\t\treturn build(file, await loadCheckedConfig(file, load), flags);\n\t\tcase \"run\":\n\t\t\treturn run(file, await loadCheckedConfig(file, load), flags);\n\t\tcase \"inspect\":\n\t\t\treturn inspect(await load(), flags);\n\t\tcase \"download\":\n\t\tcase \"online-change\":\n\t\t\treturn updateProgram(\n\t\t\t\tcommand,\n\t\t\t\tfile,\n\t\t\t\tawait loadCheckedConfig(file, load),\n\t\t\t\tflags,\n\t\t\t);\n\t}\n};\n\n/** A config loaded after its host config check, whose diagnostics the compiler reports. */\ninterface CheckedConfig {\n\tloaded: LoadedConfig;\n\thostConfigDiagnostics: readonly Diagnostic[];\n}\n\n/** Loads the config after type-checking it, so a type error fails before the config runs. */\nconst loadCheckedConfig = async (\n\tfile: string,\n\tload: () => Promise<LoadedConfig>,\n): Promise<CheckedConfig> => {\n\tconst hostConfigDiagnostics = checkHostConfig(resolve(file));\n\tif (hasErrors(hostConfigDiagnostics)) {\n\t\tthrow new DiagnosticFailure({ diagnostics: hostConfigDiagnostics });\n\t}\n\treturn { loaded: await load(), hostConfigDiagnostics };\n};\n\n/** Builds the Docker image every build uses, or with `--runtime` the local PLC runtime's. */\nconst configure = async (flags: Pick<ProjectFlags, \"runtime\">) => {\n\tawait (flags.runtime ? configureRuntime() : configureDocker());\n\treturn { ok: true };\n};\n\nconst install = async (\n\t{ config, root }: LoadedConfig,\n\tflags: Pick<ProjectFlags, \"frozen-lockfile\">,\n) => ({\n\tlibraries: await installLibraries(config.dependencies, root, {\n\t\tfrozen: flags[\"frozen-lockfile\"],\n\t}),\n});\n\nconst typegen = async (\n\tfile: string,\n\tloaded: LoadedConfig,\n\tflags: Pick<ProjectFlags, \"check\">,\n) => {\n\tconst targets = await projectTargets(file, { loaded });\n\tif (loaded.config.compiler && !flags.check) {\n\t\tawait generateProject(file, { hardwareOnly: true, loaded, targets });\n\t\tconst emitted = await buildProject(file, { emitOnly: true, loaded });\n\t\tif (hasErrors(emitted.diagnostics)) {\n\t\t\tthrow new DiagnosticFailure(emitted);\n\t\t}\n\t}\n\treturn generateProject(file, { check: flags.check, loaded, targets });\n};\n\nconst check = async (\n\tfile: string,\n\t{ loaded, hostConfigDiagnostics }: CheckedConfig,\n) => {\n\tconst { config, configFile, root } = loaded;\n\tif (config.compiler) {\n\t\treturn checkProject(file, { loaded, hostConfigDiagnostics });\n\t}\n\tconst sources = await loadSources(\n\t\tresolveConfig(\n\t\t\t{\n\t\t\t\t...rawBuildConfig(config),\n\t\t\t\tio: resolveIo(config, await loadHardware(config, root)),\n\t\t\t},\n\t\t\tconfigFile,\n\t\t),\n\t);\n\treturn { objects: sources.objects.length };\n};\n\n/**\n * The PLC program `build` and `run` compile: TypeScript through the compiler, or raw\n * Structured Text straight to the vendor build. Either refreshes the generated types.\n */\nconst buildPlc = async (\n\tcommand: \"build\" | \"run\",\n\tfile: string,\n\t{ loaded, hostConfigDiagnostics }: CheckedConfig,\n\tflags: Pick<ProjectFlags, \"emit-only\" | \"frozen-lockfile\" | \"simulate\">,\n) => {\n\tconst { config } = loaded;\n\tif (config.compiler) {\n\t\tconst built = await buildProject(file, {\n\t\t\temitOnly: flags[\"emit-only\"],\n\t\t\tfrozenLockfile: flags[\"frozen-lockfile\"],\n\t\t\t...buildConfigs(loaded, flags),\n\t\t\thostConfigDiagnostics,\n\t\t\tcontroller: controllerFor(config, command),\n\t\t\tbuildTarget: buildTargetFor(command),\n\t\t});\n\t\tif (hasErrors(built.diagnostics)) {\n\t\t\tthrow new DiagnosticFailure(built);\n\t\t}\n\t\tawait generateProject(file, {\n\t\t\tloaded,\n\t\t\ttargets: await projectTargets(file, { loaded }),\n\t\t});\n\t\treturn built;\n\t}\n\tif (flags[\"emit-only\"]) {\n\t\tthrow new Error(\"Raw Structured Text is already emitted.\");\n\t}\n\tconst built = await buildSt(\n\t\tawait rawEngineeringSettings(loaded, {\n\t\t\tcommand,\n\t\t\tfrozenLockfile: flags[\"frozen-lockfile\"],\n\t\t\tsimulate: flags.simulate,\n\t\t}),\n\t);\n\tawait generateProject(file, { hardwareOnly: !config.typegen, loaded });\n\treturn built;\n};\n\n/** The PLC program and, unless `--plc` or `--emit-only` restricts it, the configured server. */\nconst build = async (\n\tfile: string,\n\tchecked: CheckedConfig,\n\tflags: Pick<\n\t\tProjectFlags,\n\t\t\"emit-only\" | \"frozen-lockfile\" | \"plc\" | \"server\" | \"simulate\"\n\t>,\n) => {\n\tconst { config, root } = checked.loaded;\n\tif (flags.server) {\n\t\treturn buildServer(config, root);\n\t}\n\tconst plc = await buildPlc(\"build\", file, checked, flags);\n\tif (flags.plc || flags[\"emit-only\"] || !config.server?.runtime) {\n\t\treturn plc;\n\t}\n\treturn { ...plc, ...(await buildServer(config, root)) };\n};\n\nconst run = async (\n\tfile: string,\n\tchecked: CheckedConfig,\n\tflags: Pick<ProjectFlags, \"frozen-lockfile\" | \"simulate\">,\n) => {\n\tconst { config, configFile } = checked.loaded;\n\tconst built = await buildPlc(\"run\", file, checked, flags);\n\tif (!config.build) {\n\t\tthrow new Error(\"Configure build to run this project.\");\n\t}\n\tawait runProject(\n\t\tresolveConfig(\n\t\t\tconfig.compiler ? config.build : rawBuildConfig(config),\n\t\t\tconfigFile,\n\t\t),\n\t\tconfig.name,\n\t);\n\treturn built;\n};\n\nconst inspect = async (\n\t{ config, configFile }: LoadedConfig,\n\tflags: Pick<ProjectFlags, \"read\">,\n) => {\n\tif (!config.build) {\n\t\tthrow new Error(\"Configure build settings and controller connection.\");\n\t}\n\t// Inspection needs only the connection/baseline. It must remain usable\n\t// when local sources, descriptors or dependency caches are unavailable.\n\treturn inspectController(\n\t\tresolveConfig(\n\t\t\t{ ...config.build, controller: controllerFor(config, \"inspect\") },\n\t\t\tconfigFile,\n\t\t),\n\t\tflags.read,\n\t);\n};\n\n/** Downloads or online-changes the program on the configured controller. */\nconst updateProgram = async (\n\toperation: \"download\" | \"online-change\",\n\tfile: string,\n\tchecked: CheckedConfig,\n\tflags: Pick<\n\t\tProjectFlags,\n\t\t\"frozen-lockfile\" | \"simulate\" | \"initialize-user\" | \"read\"\n\t>,\n) => {\n\tconst { config } = checked.loaded;\n\tif (!config.build) {\n\t\tthrow new Error(\"Configure build settings and controller connection.\");\n\t}\n\tconst settings = config.compiler\n\t\t? await emittedControllerSettings(operation, file, checked, flags)\n\t\t: await rawEngineeringSettings(checked.loaded, {\n\t\t\t\tcommand: operation,\n\t\t\t\tfrozenLockfile: flags[\"frozen-lockfile\"],\n\t\t\t\tsimulate: flags.simulate,\n\t\t\t});\n\treturn updateController(settings, operation, {\n\t\tinitializeUser: flags[\"initialize-user\"],\n\t\tread: flags.read,\n\t});\n};\n\nconst emittedControllerSettings = async (\n\toperation: \"download\" | \"online-change\",\n\tfile: string,\n\t{ loaded, hostConfigDiagnostics }: CheckedConfig,\n\tflags: Pick<ProjectFlags, \"frozen-lockfile\" | \"simulate\">,\n) => {\n\tconst emitted = await buildProject(file, {\n\t\temitOnly: true,\n\t\tforController: true,\n\t\tfrozenLockfile: flags[\"frozen-lockfile\"],\n\t\t...buildConfigs(loaded, flags),\n\t\thostConfigDiagnostics,\n\t\tcontroller: controllerFor(loaded.config, operation),\n\t\tbuildTarget: buildTargetFor(operation),\n\t});\n\tif (hasErrors(emitted.diagnostics)) {\n\t\tthrow new DiagnosticFailure(emitted);\n\t}\n\tif (!emitted.controllerConfig) {\n\t\tthrow new Error(\"Configure build settings for deployment.\");\n\t}\n\t// Emission already resolves the generated entry/task paths. Passing\n\t// this through the input schema again would reject its configFile.\n\treturn { ...emitted.controllerConfig, io: {} };\n};\n"
|
|
12
15
|
],
|
|
13
|
-
"mappings": ";;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AAEO,IAAM,sBAAsB,CAAC,MAAc,SAChD,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG,KAAK,WAAW,QAAQ,MAAM,IAAI,CAAC,IAC1E,QAAQ,MAAM,IAAI,IAClB,cAAc,KAAK,MAAM,cAAc,CAAC,EAAE,QAAQ,IAAI;AAE5D,IAAM,YAAY,CAAC,SACjB,KACG,QAAQ,0CAA0C,WAAW,EAC7D,QAAQ,kBAAkB,GAAG,EAC7B,QAAQ,UAAU,EAAE,EACpB,YAAY;AAGjB,IAAM,qBAAqB,CAAC,QAA6B,SAAiB;AAAA,EACxE,MAAM,UAAU,OAAO,QAAQ;AAA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