@tsplc/build 0.5.8 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/images.js CHANGED
@@ -64,7 +64,7 @@ var digestFiles = async (files, texts) => {
64
64
  }
65
65
  for (const file of [...files].sort((a, b) => a.name.localeCompare(b.name))) {
66
66
  hash.update(`${file.name}\x00`);
67
- hash.update(await readFile(file.path));
67
+ hash.update(await file.read());
68
68
  hash.update("\x00");
69
69
  }
70
70
  return hash.digest("hex");
@@ -100,8 +100,21 @@ var containerManifest = async () => {
100
100
  var recipeFile = (path) => path === "docker" || path === "docker/Dockerfile" || path === "docker/entrypoint.sh" || (path === "docker/install" || path.startsWith("docker/install/")) && includeSource(basename(path)) && basename(path) !== ".npmignore" && !path.split("/").includes("tests") && path !== "docker/install/wine-signal/check.sh";
101
101
  var builderRecipe = async () => digestFiles((await recipeFiles()).map((name) => ({
102
102
  name,
103
- path: resolve2(packageDirectory, name)
103
+ read: () => readFile(resolve2(packageDirectory, name))
104
104
  })), { manifest: JSON.stringify(await containerManifest()) });
105
+ var toolingLine = /\bbun\b/i;
106
+ var engineeringRecipe = async () => digestFiles((await recipeFiles()).map((name) => ({
107
+ name,
108
+ read: async () => {
109
+ const content = await readFile(resolve2(packageDirectory, name));
110
+ if (name !== "docker/Dockerfile") {
111
+ return content;
112
+ }
113
+ return content.toString("utf8").split(`
114
+ `).filter((line) => !toolingLine.test(line)).join(`
115
+ `);
116
+ }
117
+ })), {});
105
118
  var recipeFiles = () => listFiles(packageDirectory, resolve2(packageDirectory, "docker"), recipeFile);
106
119
  async function prepareDockerContext() {
107
120
  const context = await mkdtemp(resolve2(tmpdir(), "tsplc-docker-"));
@@ -171,6 +184,8 @@ async function buildBuilderImage(options) {
171
184
  `SETUP_PLATFORM=${options.setupPlatform}`,
172
185
  "--build-arg",
173
186
  `INSTALLER_SOURCE=${options.installer ? "installer-local" : "installer-download"}`,
187
+ "--build-arg",
188
+ `TSPLC_ENGINEERING=${await engineeringRecipe()}`,
174
189
  "--label",
175
190
  `${recipeLabel}=${await builderRecipe()}`,
176
191
  "--progress",
@@ -223,5 +238,5 @@ export {
223
238
  setupPlatformFor
224
239
  };
225
240
 
226
- //# debugId=5C665E6889C8F40A64756E2164756E21
241
+ //# debugId=997E8AF37653A91D64756E2164756E21
227
242
  //# sourceMappingURL=images.js.map
@@ -2,11 +2,11 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/images.ts", "../src/docker-context.ts", "../src/package-path.ts"],
4
4
  "sourcesContent": [
5
- "import { copyFile, cp, mkdir, mkdtemp, rm } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { resolve } from \"node:path\";\nimport { dockerImage } from \"@tsplc/config/build\";\nimport { builderRecipe, prepareDockerContext } from \"./docker-context\";\nimport { packageDirectory } from \"./package-path\";\n\nexport const builderImage = dockerImage;\n\nexport const gatewayImage = \"tsplc-edge-gateway:4.22.0.0\";\n\n/** The local CODESYS Control for Linux SL runtime; it is always built here, never published. */\nexport const runtimeImage = \"tsplc-control-linux-sl:4.22.0.0\";\n\nconst registry = \"ghcr.io/livingforjesus\";\n\n/**\n * The published copy of a local image whose tag already names what is in it, as the gateway's names its CODESYS version:\n * every tsPLC that uses that version shares the one copy.\n */\nexport const publishedImage = (image: string) => `${registry}/${image}`;\n\n/**\n * The published copy of the builder image for this installation's recipe. Containers run the installed tsPLC's code, so\n * the image changes only with its recipe, and every tsPLC with the same recipe shares the one copy rather than a release\n * rebuilding the vendor installation.\n */\nexport const publishedBuilderImage = async () =>\n\t`${registry}/${builderImage.split(\":\")[0]}:recipe-${await builderRecipe()}`;\n\n/** The platform the vendor installer runs on; the compiler image itself is always AMD64. */\nexport type SetupPlatform = \"linux/amd64\" | \"linux/arm64\";\n\n/** The setup platform for a Docker server's `{{.OSType}}/{{.Architecture}}`, or null when it has none. */\nexport const setupPlatformFor = (server: string): SetupPlatform | null => {\n\tif (server === \"linux/aarch64\" || server === \"linux/arm64\") {\n\t\treturn \"linux/arm64\";\n\t}\n\tif (server === \"linux/x86_64\" || server === \"linux/amd64\") {\n\t\treturn \"linux/amd64\";\n\t}\n\treturn null;\n};\n\n/** The label an image built by `buildBuilderImage` carries its `builderRecipe` in. */\nexport const recipeLabel = \"tsplc.recipe\";\n\n/**\n * Builds the builder image from the full recipe, labelled with it. `installer` is a local CODESYS installer,\n * or null to download the official one; `winetricksCache` seeds the prerequisite downloads.\n * `docker` runs one Docker client command, so each caller keeps its own terminal handling.\n */\nexport async function buildBuilderImage(options: {\n\ttag: string;\n\tsetupPlatform: SetupPlatform;\n\tinstaller: string | null;\n\twinetricksCache: string | null;\n\tdocker: (args: string[]) => Promise<void>;\n}) {\n\tconst installerContext = await mkdtemp(\n\t\tresolve(tmpdir(), \"codesys-installer-\"),\n\t);\n\tlet context: string | undefined;\n\ttry {\n\t\tcontext = await prepareDockerContext();\n\t\tconst cache = resolve(installerContext, \"winetricks\");\n\t\tawait mkdir(cache);\n\t\tif (options.winetricksCache) {\n\t\t\tawait cp(options.winetricksCache, cache, { recursive: true });\n\t\t}\n\t\tif (options.installer) {\n\t\t\tawait copyFile(\n\t\t\t\toptions.installer,\n\t\t\t\tresolve(installerContext, \"codesys.exe\"),\n\t\t\t);\n\t\t}\n\t\tconst arm = options.setupPlatform === \"linux/arm64\";\n\t\t// FEX handles ARM setup's 32-bit prerequisites; the compiler runtime stays AMD64.\n\t\tawait options.docker([\n\t\t\t\"build\",\n\t\t\t\"--platform\",\n\t\t\t\"linux/amd64\",\n\t\t\t\"--build-arg\",\n\t\t\t`SETUP_BASE=${arm ? \"arm-setup\" : \"base\"}`,\n\t\t\t\"--build-arg\",\n\t\t\t`SETUP_PLATFORM=${options.setupPlatform}`,\n\t\t\t\"--build-arg\",\n\t\t\t`INSTALLER_SOURCE=${options.installer ? \"installer-local\" : \"installer-download\"}`,\n\t\t\t\"--label\",\n\t\t\t`${recipeLabel}=${await builderRecipe()}`,\n\t\t\t\"--progress\",\n\t\t\t\"plain\",\n\t\t\t\"--build-context\",\n\t\t\t`installer=${installerContext}`,\n\t\t\t\"-f\",\n\t\t\tresolve(context, \"docker/Dockerfile\"),\n\t\t\t\"-t\",\n\t\t\toptions.tag,\n\t\t\tcontext,\n\t\t]);\n\t} finally {\n\t\tawait Promise.all([\n\t\t\trm(installerContext, { recursive: true, force: true }),\n\t\t\t...(context ? [rm(context, { recursive: true, force: true })] : []),\n\t\t]);\n\t}\n}\n\n/** Builds the local CODESYS Control for Linux SL runtime, the device a production build targets. */\nexport const buildRuntimeImage = (options: {\n\ttag: string;\n\tdocker: (args: string[]) => Promise<void>;\n}) =>\n\toptions.docker([\n\t\t\"build\",\n\t\t\"--platform\",\n\t\t\"linux/amd64\",\n\t\t\"--progress\",\n\t\t\"plain\",\n\t\t\"-t\",\n\t\toptions.tag,\n\t\tresolve(packageDirectory, \"docker/control-linux-sl\"),\n\t]);\n\nexport const buildGatewayImage = (options: {\n\ttag: string;\n\tdocker: (args: string[]) => Promise<void>;\n}) =>\n\toptions.docker([\n\t\t\"build\",\n\t\t\"--platform\",\n\t\t\"linux/amd64\",\n\t\t\"--progress\",\n\t\t\"plain\",\n\t\t\"-t\",\n\t\toptions.tag,\n\t\tresolve(packageDirectory, \"docker/edge-gateway\"),\n\t]);\n",
6
- "import { createHash } from \"node:crypto\";\nimport {\n\tcp,\n\tmkdir,\n\tmkdtemp,\n\treaddir,\n\treadFile,\n\trm,\n\tstat,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, posix, relative, resolve, sep } from \"node:path\";\nimport { z } from \"zod\";\nimport { packageDirectory } from \"./package-path\";\n\nconst includeSource = (source: string) => {\n\tconst name = basename(source);\n\treturn (\n\t\tname !== \"__pycache__\" &&\n\t\tname !== \".DS_Store\" &&\n\t\t!name.endsWith(\".pyc\") &&\n\t\t!name.endsWith(\".test.ts\") &&\n\t\t!name.endsWith(\".fixtures.ts\") &&\n\t\t!(name.startsWith(\"test_\") && name.endsWith(\".py\"))\n\t);\n};\n\n/**\n * The workspace packages container code imports, each copied with the files Bun runs it from,\n * to `directory` in the context and `image` in the image.\n */\nconst containerPackages = [\n\t{\n\t\tentry: \"@tsplc/config/build\",\n\t\tdirectory: \"shared-config\",\n\t\timage: \"/opt/tsplc-config\",\n\t\tfiles: [\"src\", \"templates\", \"package.json\"],\n\t},\n\t{\n\t\tentry: \"@tsplc/iec\",\n\t\tdirectory: \"shared-iec\",\n\t\timage: \"/opt/tsplc-iec\",\n\t\tfiles: [\"src\", \"package.json\"],\n\t},\n];\n\n/** Where the image keeps this package. */\nconst imagePackage = \"/opt/codesys-build\";\n/**\n * This package's files that the image runs and a container may take from the installed package\n * instead: everything the runner imports and the CODESYS scripts. The entrypoint stays the image's.\n */\nconst packageCode = [\"src\", \"python\", \"docker/runner.ts\", \"docker/config.ts\"];\n\nconst packageRoot = (entry: string) =>\n\tresolve(dirname(createRequire(import.meta.url).resolve(entry)), \"..\");\n\n/** A host file or directory and the path in the image it replaces. */\nexport interface ContainerMount {\n\tsource: string;\n\ttarget: string;\n}\n\n/**\n * The code a builder container runs, as this installation has it, and where the image keeps its\n * own copy. Mounted over the image's, it makes a container run this installation's tsPLC whatever\n * tsPLC built the image, so only a change of the image's recipe needs a new image.\n */\nexport const containerCode = (): ContainerMount[] => [\n\t...packageCode.map((path) => ({\n\t\tsource: resolve(packageDirectory, path),\n\t\ttarget: posix.join(imagePackage, path),\n\t})),\n\t...containerPackages.flatMap(({ entry, image, files }) =>\n\t\tfiles.map((file) => ({\n\t\t\tsource: resolve(packageRoot(entry), file),\n\t\t\ttarget: posix.join(image, file),\n\t\t})),\n\t),\n];\n\n/** Every file under `path`, or `path` itself, that `include` keeps, by its path relative to `root`. */\nconst listFiles = async (\n\troot: string,\n\tpath: string,\n\tinclude: (relativePath: string) => boolean,\n): Promise<string[]> => {\n\tconst name = relative(root, path).split(sep).join(\"/\");\n\tif (!include(name)) {\n\t\treturn [];\n\t}\n\tif (!(await stat(path)).isDirectory()) {\n\t\treturn [name];\n\t}\n\tconst entries = await readdir(path);\n\treturn (\n\t\tawait Promise.all(\n\t\t\tentries.map((entry) => listFiles(root, resolve(path, entry), include)),\n\t\t)\n\t).flat();\n};\n\n/** A digest of named texts and files, which changes when a name or a file's content does. */\nconst digestFiles = async (\n\tfiles: { name: string; path: string }[],\n\ttexts: Record<string, string>,\n) => {\n\tconst hash = createHash(\"sha256\");\n\tfor (const [name, text] of Object.entries(texts)) {\n\t\thash.update(`${name}\\0${text}\\0`);\n\t}\n\tfor (const file of [...files].sort((a, b) => a.name.localeCompare(b.name))) {\n\t\thash.update(`${file.name}\\0`);\n\t\thash.update(await readFile(file.path));\n\t\thash.update(\"\\0\");\n\t}\n\treturn hash.digest(\"hex\");\n};\n\n/**\n * A digest of the code `containerCode` mounts, which a long-running container is labelled with so\n * that one running other code is replaced.\n */\nexport const containerCodeDigest = async () =>\n\tdigestFiles(\n\t\t(\n\t\t\tawait Promise.all(\n\t\t\t\tcontainerCode().map(async ({ source, target }) =>\n\t\t\t\t\t(\n\t\t\t\t\t\tawait listFiles(dirname(source), source, (path) =>\n\t\t\t\t\t\t\tincludeSource(basename(path)),\n\t\t\t\t\t\t)\n\t\t\t\t\t).map((name) => ({\n\t\t\t\t\t\tname: posix.join(posix.dirname(target), name),\n\t\t\t\t\t\tpath: resolve(dirname(source), name),\n\t\t\t\t\t})),\n\t\t\t\t),\n\t\t\t)\n\t\t).flat(),\n\t\t{},\n\t);\n\nconst manifestDependencies = z.object({\n\tname: z.string(),\n\tdependencies: z.record(z.string(), z.string()).default({}),\n});\n\n/**\n * The third-party packages the image installs: what this package and each package the\n * context carries depend on, at the versions their manifests pin.\n */\nexport function containerDependencies(\n\tmanifests: z.infer<typeof manifestDependencies>[],\n) {\n\tconst selected = new Map<string, { version: string; owner: string }>();\n\tfor (const manifest of manifests) {\n\t\tfor (const [name, version] of Object.entries(manifest.dependencies)) {\n\t\t\tif (name.startsWith(\"@tsplc/\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst existing = selected.get(name);\n\t\t\tif (existing && existing.version !== version) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The builder image cannot install ${name}: ${existing.owner} pins ${existing.version} and ${manifest.name} pins ${version}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tselected.set(name, { version, owner: manifest.name });\n\t\t}\n\t}\n\treturn Object.fromEntries(\n\t\t[...selected].map(([name, { version }]) => [name, version]),\n\t);\n}\n\nconst readManifest = async (directory: string) =>\n\tmanifestDependencies.parse(\n\t\tJSON.parse(await readFile(resolve(directory, \"package.json\"), \"utf8\")),\n\t);\n\n/** The manifest of the third-party packages the image installs, as its recipe writes it. */\nexport const containerManifest = async () => {\n\tconst manifests = [await readManifest(packageDirectory)];\n\tfor (const { entry } of containerPackages) {\n\t\tmanifests.push(await readManifest(packageRoot(entry)));\n\t}\n\treturn { type: \"module\", dependencies: containerDependencies(manifests) };\n};\n\n/**\n * The files of the image's recipe that its containers can't take from the installed package: the\n * Dockerfile, the entrypoint and the installation's scripts and data. Tests and checks of the\n * installation's own tools stay out, as the published package leaves them out, and so does\n * `.npmignore`, which npm never packs: an image built from a checkout carries the recipe an\n * installed tsPLC computes, so it finds the image published under that recipe current.\n */\nconst recipeFile = (path: string) =>\n\tpath === \"docker\" ||\n\tpath === \"docker/Dockerfile\" ||\n\tpath === \"docker/entrypoint.sh\" ||\n\t((path === \"docker/install\" || path.startsWith(\"docker/install/\")) &&\n\t\tincludeSource(basename(path)) &&\n\t\tbasename(path) !== \".npmignore\" &&\n\t\t!path.split(\"/\").includes(\"tests\") &&\n\t\tpath !== \"docker/install/wine-signal/check.sh\");\n\n/**\n * The builder image's recipe: what it installs and how. An image built from another recipe has\n * another vendor installation or other third-party packages, so its containers can't run this\n * installation's code, while one built from this recipe runs any tsPLC with this recipe.\n */\nexport const builderRecipe = async () =>\n\tdigestFiles(\n\t\t(await recipeFiles()).map((name) => ({\n\t\t\tname,\n\t\t\tpath: resolve(packageDirectory, name),\n\t\t})),\n\t\t{ manifest: JSON.stringify(await containerManifest()) },\n\t);\n\n/** The package's files `builderRecipe` covers, beside the third-party manifest. */\nexport const recipeFiles = () =>\n\tlistFiles(packageDirectory, resolve(packageDirectory, \"docker\"), recipeFile);\n\nexport async function prepareDockerContext() {\n\tconst context = await mkdtemp(resolve(tmpdir(), \"tsplc-docker-\"));\n\ttry {\n\t\tfor (const directory of [\"src\", \"python\", \"docker\", \"runtime\"]) {\n\t\t\tawait cp(\n\t\t\t\tresolve(packageDirectory, directory),\n\t\t\t\tresolve(context, directory),\n\t\t\t\t{\n\t\t\t\t\trecursive: true,\n\t\t\t\t\tfilter: includeSource,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tfor (const { entry, directory, files } of containerPackages) {\n\t\t\tconst root = packageRoot(entry);\n\t\t\tawait mkdir(resolve(context, directory));\n\t\t\tfor (const file of files) {\n\t\t\t\tawait cp(resolve(root, file), resolve(context, directory, file), {\n\t\t\t\t\trecursive: true,\n\t\t\t\t\tfilter: includeSource,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tawait writeFile(\n\t\t\tresolve(context, \"package.json\"),\n\t\t\tJSON.stringify(await containerManifest()),\n\t\t);\n\t\treturn context;\n\t} catch (cause) {\n\t\tawait rm(context, { recursive: true, force: true });\n\t\tthrow cause;\n\t}\n}\n",
5
+ "import { copyFile, cp, mkdir, mkdtemp, rm } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { resolve } from \"node:path\";\nimport { dockerImage } from \"@tsplc/config/build\";\nimport {\n\tbuilderRecipe,\n\tengineeringRecipe,\n\tprepareDockerContext,\n} from \"./docker-context\";\nimport { packageDirectory } from \"./package-path\";\n\nexport const builderImage = dockerImage;\n\nexport const gatewayImage = \"tsplc-edge-gateway:4.22.0.0\";\n\n/** The local CODESYS Control for Linux SL runtime; it is always built here, never published. */\nexport const runtimeImage = \"tsplc-control-linux-sl:4.22.0.0\";\n\nconst registry = \"ghcr.io/livingforjesus\";\n\n/**\n * The published copy of a local image whose tag already names what is in it, as the gateway's names its CODESYS version:\n * every tsPLC that uses that version shares the one copy.\n */\nexport const publishedImage = (image: string) => `${registry}/${image}`;\n\n/**\n * The published copy of the builder image for this installation's recipe. Containers run the installed tsPLC's code, so\n * the image changes only with its recipe, and every tsPLC with the same recipe shares the one copy rather than a release\n * rebuilding the vendor installation.\n */\nexport const publishedBuilderImage = async () =>\n\t`${registry}/${builderImage.split(\":\")[0]}:recipe-${await builderRecipe()}`;\n\n/** The platform the vendor installer runs on; the compiler image itself is always AMD64. */\nexport type SetupPlatform = \"linux/amd64\" | \"linux/arm64\";\n\n/** The setup platform for a Docker server's `{{.OSType}}/{{.Architecture}}`, or null when it has none. */\nexport const setupPlatformFor = (server: string): SetupPlatform | null => {\n\tif (server === \"linux/aarch64\" || server === \"linux/arm64\") {\n\t\treturn \"linux/arm64\";\n\t}\n\tif (server === \"linux/x86_64\" || server === \"linux/amd64\") {\n\t\treturn \"linux/amd64\";\n\t}\n\treturn null;\n};\n\n/** The label an image built by `buildBuilderImage` carries its `builderRecipe` in. */\nexport const recipeLabel = \"tsplc.recipe\";\n\n/**\n * Builds the builder image from the full recipe, labelled with it. `installer` is a local CODESYS installer,\n * or null to download the official one; `winetricksCache` seeds the prerequisite downloads.\n * `docker` runs one Docker client command, so each caller keeps its own terminal handling.\n */\nexport async function buildBuilderImage(options: {\n\ttag: string;\n\tsetupPlatform: SetupPlatform;\n\tinstaller: string | null;\n\twinetricksCache: string | null;\n\tdocker: (args: string[]) => Promise<void>;\n}) {\n\tconst installerContext = await mkdtemp(\n\t\tresolve(tmpdir(), \"codesys-installer-\"),\n\t);\n\tlet context: string | undefined;\n\ttry {\n\t\tcontext = await prepareDockerContext();\n\t\tconst cache = resolve(installerContext, \"winetricks\");\n\t\tawait mkdir(cache);\n\t\tif (options.winetricksCache) {\n\t\t\tawait cp(options.winetricksCache, cache, { recursive: true });\n\t\t}\n\t\tif (options.installer) {\n\t\t\tawait copyFile(\n\t\t\t\toptions.installer,\n\t\t\t\tresolve(installerContext, \"codesys.exe\"),\n\t\t\t);\n\t\t}\n\t\tconst arm = options.setupPlatform === \"linux/arm64\";\n\t\t// FEX handles ARM setup's 32-bit prerequisites; the compiler runtime stays AMD64.\n\t\tawait options.docker([\n\t\t\t\"build\",\n\t\t\t\"--platform\",\n\t\t\t\"linux/amd64\",\n\t\t\t\"--build-arg\",\n\t\t\t`SETUP_BASE=${arm ? \"arm-setup\" : \"base\"}`,\n\t\t\t\"--build-arg\",\n\t\t\t`SETUP_PLATFORM=${options.setupPlatform}`,\n\t\t\t\"--build-arg\",\n\t\t\t`INSTALLER_SOURCE=${options.installer ? \"installer-local\" : \"installer-download\"}`,\n\t\t\t\"--build-arg\",\n\t\t\t`TSPLC_ENGINEERING=${await engineeringRecipe()}`,\n\t\t\t\"--label\",\n\t\t\t`${recipeLabel}=${await builderRecipe()}`,\n\t\t\t\"--progress\",\n\t\t\t\"plain\",\n\t\t\t\"--build-context\",\n\t\t\t`installer=${installerContext}`,\n\t\t\t\"-f\",\n\t\t\tresolve(context, \"docker/Dockerfile\"),\n\t\t\t\"-t\",\n\t\t\toptions.tag,\n\t\t\tcontext,\n\t\t]);\n\t} finally {\n\t\tawait Promise.all([\n\t\t\trm(installerContext, { recursive: true, force: true }),\n\t\t\t...(context ? [rm(context, { recursive: true, force: true })] : []),\n\t\t]);\n\t}\n}\n\n/** Builds the local CODESYS Control for Linux SL runtime, the device a production build targets. */\nexport const buildRuntimeImage = (options: {\n\ttag: string;\n\tdocker: (args: string[]) => Promise<void>;\n}) =>\n\toptions.docker([\n\t\t\"build\",\n\t\t\"--platform\",\n\t\t\"linux/amd64\",\n\t\t\"--progress\",\n\t\t\"plain\",\n\t\t\"-t\",\n\t\toptions.tag,\n\t\tresolve(packageDirectory, \"docker/control-linux-sl\"),\n\t]);\n\nexport const buildGatewayImage = (options: {\n\ttag: string;\n\tdocker: (args: string[]) => Promise<void>;\n}) =>\n\toptions.docker([\n\t\t\"build\",\n\t\t\"--platform\",\n\t\t\"linux/amd64\",\n\t\t\"--progress\",\n\t\t\"plain\",\n\t\t\"-t\",\n\t\toptions.tag,\n\t\tresolve(packageDirectory, \"docker/edge-gateway\"),\n\t]);\n",
6
+ "import { createHash } from \"node:crypto\";\nimport {\n\tcp,\n\tmkdir,\n\tmkdtemp,\n\treaddir,\n\treadFile,\n\trm,\n\tstat,\n\twriteFile,\n} from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { tmpdir } from \"node:os\";\nimport { basename, dirname, posix, relative, resolve, sep } from \"node:path\";\nimport { z } from \"zod\";\nimport { packageDirectory } from \"./package-path\";\n\nconst includeSource = (source: string) => {\n\tconst name = basename(source);\n\treturn (\n\t\tname !== \"__pycache__\" &&\n\t\tname !== \".DS_Store\" &&\n\t\t!name.endsWith(\".pyc\") &&\n\t\t!name.endsWith(\".test.ts\") &&\n\t\t!name.endsWith(\".fixtures.ts\") &&\n\t\t!(name.startsWith(\"test_\") && name.endsWith(\".py\"))\n\t);\n};\n\n/**\n * The workspace packages container code imports, each copied with the files Bun runs it from,\n * to `directory` in the context and `image` in the image.\n */\nconst containerPackages = [\n\t{\n\t\tentry: \"@tsplc/config/build\",\n\t\tdirectory: \"shared-config\",\n\t\timage: \"/opt/tsplc-config\",\n\t\tfiles: [\"src\", \"templates\", \"package.json\"],\n\t},\n\t{\n\t\tentry: \"@tsplc/iec\",\n\t\tdirectory: \"shared-iec\",\n\t\timage: \"/opt/tsplc-iec\",\n\t\tfiles: [\"src\", \"package.json\"],\n\t},\n];\n\n/** Where the image keeps this package. */\nconst imagePackage = \"/opt/codesys-build\";\n/**\n * This package's files that the image runs and a container may take from the installed package\n * instead: everything the runner imports and the CODESYS scripts. The entrypoint stays the image's.\n */\nconst packageCode = [\"src\", \"python\", \"docker/runner.ts\", \"docker/config.ts\"];\n\nconst packageRoot = (entry: string) =>\n\tresolve(dirname(createRequire(import.meta.url).resolve(entry)), \"..\");\n\n/** A host file or directory and the path in the image it replaces. */\nexport interface ContainerMount {\n\tsource: string;\n\ttarget: string;\n}\n\n/**\n * The code a builder container runs, as this installation has it, and where the image keeps its\n * own copy. Mounted over the image's, it makes a container run this installation's tsPLC whatever\n * tsPLC built the image, so only a change of the image's recipe needs a new image.\n */\nexport const containerCode = (): ContainerMount[] => [\n\t...packageCode.map((path) => ({\n\t\tsource: resolve(packageDirectory, path),\n\t\ttarget: posix.join(imagePackage, path),\n\t})),\n\t...containerPackages.flatMap(({ entry, image, files }) =>\n\t\tfiles.map((file) => ({\n\t\t\tsource: resolve(packageRoot(entry), file),\n\t\t\ttarget: posix.join(image, file),\n\t\t})),\n\t),\n];\n\n/** Every file under `path`, or `path` itself, that `include` keeps, by its path relative to `root`. */\nconst listFiles = async (\n\troot: string,\n\tpath: string,\n\tinclude: (relativePath: string) => boolean,\n): Promise<string[]> => {\n\tconst name = relative(root, path).split(sep).join(\"/\");\n\tif (!include(name)) {\n\t\treturn [];\n\t}\n\tif (!(await stat(path)).isDirectory()) {\n\t\treturn [name];\n\t}\n\tconst entries = await readdir(path);\n\treturn (\n\t\tawait Promise.all(\n\t\t\tentries.map((entry) => listFiles(root, resolve(path, entry), include)),\n\t\t)\n\t).flat();\n};\n\n/** A digest of named texts and files, which changes when a name or a file's content does. */\nconst digestFiles = async (\n\tfiles: { name: string; read: () => Promise<Uint8Array | string> }[],\n\ttexts: Record<string, string>,\n) => {\n\tconst hash = createHash(\"sha256\");\n\tfor (const [name, text] of Object.entries(texts)) {\n\t\thash.update(`${name}\\0${text}\\0`);\n\t}\n\tfor (const file of [...files].sort((a, b) => a.name.localeCompare(b.name))) {\n\t\thash.update(`${file.name}\\0`);\n\t\thash.update(await file.read());\n\t\thash.update(\"\\0\");\n\t}\n\treturn hash.digest(\"hex\");\n};\n\n/**\n * A digest of the code `containerCode` mounts, which a long-running container is labelled with so\n * that one running other code is replaced.\n */\nexport const containerCodeDigest = async () =>\n\tdigestFiles(\n\t\t(\n\t\t\tawait Promise.all(\n\t\t\t\tcontainerCode().map(async ({ source, target }) =>\n\t\t\t\t\t(\n\t\t\t\t\t\tawait listFiles(dirname(source), source, (path) =>\n\t\t\t\t\t\t\tincludeSource(basename(path)),\n\t\t\t\t\t\t)\n\t\t\t\t\t).map((name) => ({\n\t\t\t\t\t\tname: posix.join(posix.dirname(target), name),\n\t\t\t\t\t\tread: () => readFile(resolve(dirname(source), name)),\n\t\t\t\t\t})),\n\t\t\t\t),\n\t\t\t)\n\t\t).flat(),\n\t\t{},\n\t);\n\nconst manifestDependencies = z.object({\n\tname: z.string(),\n\tdependencies: z.record(z.string(), z.string()).default({}),\n});\n\n/**\n * The third-party packages the image installs: what this package and each package the\n * context carries depend on, at the versions their manifests pin.\n */\nexport function containerDependencies(\n\tmanifests: z.infer<typeof manifestDependencies>[],\n) {\n\tconst selected = new Map<string, { version: string; owner: string }>();\n\tfor (const manifest of manifests) {\n\t\tfor (const [name, version] of Object.entries(manifest.dependencies)) {\n\t\t\tif (name.startsWith(\"@tsplc/\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst existing = selected.get(name);\n\t\t\tif (existing && existing.version !== version) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`The builder image cannot install ${name}: ${existing.owner} pins ${existing.version} and ${manifest.name} pins ${version}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tselected.set(name, { version, owner: manifest.name });\n\t\t}\n\t}\n\treturn Object.fromEntries(\n\t\t[...selected].map(([name, { version }]) => [name, version]),\n\t);\n}\n\nconst readManifest = async (directory: string) =>\n\tmanifestDependencies.parse(\n\t\tJSON.parse(await readFile(resolve(directory, \"package.json\"), \"utf8\")),\n\t);\n\n/** The manifest of the third-party packages the image installs, as its recipe writes it. */\nexport const containerManifest = async () => {\n\tconst manifests = [await readManifest(packageDirectory)];\n\tfor (const { entry } of containerPackages) {\n\t\tmanifests.push(await readManifest(packageRoot(entry)));\n\t}\n\treturn { type: \"module\", dependencies: containerDependencies(manifests) };\n};\n\n/**\n * The files of the image's recipe that its containers can't take from the installed package: the\n * Dockerfile, the entrypoint and the installation's scripts and data. Tests and checks of the\n * installation's own tools stay out, as the published package leaves them out, and so does\n * `.npmignore`, which npm never packs: an image built from a checkout carries the recipe an\n * installed tsPLC computes, so it finds the image published under that recipe current.\n */\nconst recipeFile = (path: string) =>\n\tpath === \"docker\" ||\n\tpath === \"docker/Dockerfile\" ||\n\tpath === \"docker/entrypoint.sh\" ||\n\t((path === \"docker/install\" || path.startsWith(\"docker/install/\")) &&\n\t\tincludeSource(basename(path)) &&\n\t\tbasename(path) !== \".npmignore\" &&\n\t\t!path.split(\"/\").includes(\"tests\") &&\n\t\tpath !== \"docker/install/wine-signal/check.sh\");\n\n/**\n * The builder image's recipe: what it installs and how. An image built from another recipe has\n * another vendor installation or other third-party packages, so its containers can't run this\n * installation's code, while one built from this recipe runs any tsPLC with this recipe.\n */\nexport const builderRecipe = async () =>\n\tdigestFiles(\n\t\t(await recipeFiles()).map((name) => ({\n\t\t\tname,\n\t\t\tread: () => readFile(resolve(packageDirectory, name)),\n\t\t})),\n\t\t{ manifest: JSON.stringify(await containerManifest()) },\n\t);\n\n/** The Dockerfile's lines that install Bun, which runs tsPLC's own code and compiles nothing. */\nconst toolingLine = /\\bbun\\b/i;\n\n/**\n * The CODESYS engineering the builder image installs: its recipe without Bun and the third-party\n * packages tsPLC's code runs on. Images with the same engineering compile a project alike, so an\n * online change can follow a download made with another of them.\n */\nexport const engineeringRecipe = async () =>\n\tdigestFiles(\n\t\t(await recipeFiles()).map((name) => ({\n\t\t\tname,\n\t\t\tread: async () => {\n\t\t\t\tconst content = await readFile(resolve(packageDirectory, name));\n\t\t\t\tif (name !== \"docker/Dockerfile\") {\n\t\t\t\t\treturn content;\n\t\t\t\t}\n\t\t\t\treturn content\n\t\t\t\t\t.toString(\"utf8\")\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.filter((line) => !toolingLine.test(line))\n\t\t\t\t\t.join(\"\\n\");\n\t\t\t},\n\t\t})),\n\t\t{},\n\t);\n\n/** The package's files `builderRecipe` covers, beside the third-party manifest. */\nexport const recipeFiles = () =>\n\tlistFiles(packageDirectory, resolve(packageDirectory, \"docker\"), recipeFile);\n\nexport async function prepareDockerContext() {\n\tconst context = await mkdtemp(resolve(tmpdir(), \"tsplc-docker-\"));\n\ttry {\n\t\tfor (const directory of [\"src\", \"python\", \"docker\", \"runtime\"]) {\n\t\t\tawait cp(\n\t\t\t\tresolve(packageDirectory, directory),\n\t\t\t\tresolve(context, directory),\n\t\t\t\t{\n\t\t\t\t\trecursive: true,\n\t\t\t\t\tfilter: includeSource,\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tfor (const { entry, directory, files } of containerPackages) {\n\t\t\tconst root = packageRoot(entry);\n\t\t\tawait mkdir(resolve(context, directory));\n\t\t\tfor (const file of files) {\n\t\t\t\tawait cp(resolve(root, file), resolve(context, directory, file), {\n\t\t\t\t\trecursive: true,\n\t\t\t\t\tfilter: includeSource,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tawait writeFile(\n\t\t\tresolve(context, \"package.json\"),\n\t\t\tJSON.stringify(await containerManifest()),\n\t\t);\n\t\treturn context;\n\t} catch (cause) {\n\t\tawait rm(context, { recursive: true, force: true });\n\t\tthrow cause;\n\t}\n}\n",
7
7
  "import { resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n// Both source modules and published bundles live one directory below the package root.\nexport const packageDirectory = resolve(\n\tfileURLToPath(new URL(\"..\", import.meta.url)),\n);\n"
8
8
  ],
9
- "mappings": ";AAAA,yBAAmB,cAAI,mBAAO,gBAAS;AACvC,mBAAS;AACT,oBAAS;AACT;;;ACHA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AACA;AACA,wDAA6C;AAC7C;;;ACdA;AACA;AAGO,IAAM,mBAAmB,QAC/B,cAAc,IAAI,IA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E,WAAW,MAAM,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC;AAAA,IAClE,CAAC;AAAA;AAAA;AAKI,IAAM,oBAAoB,CAAC,YAIjC,QAAQ,OAAO;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,SAAQ,kBAAkB,yBAAyB;AACpD,CAAC;AAEK,IAAM,oBAAoB,CAAC,YAIjC,QAAQ,OAAO;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,SAAQ,kBAAkB,qBAAqB;AAChD,CAAC;",
10
+ "debugId": "997E8AF37653A91D64756E2164756E21",
11
11
  "names": []
12
12
  }
package/dist/index.js CHANGED
@@ -155,14 +155,14 @@ var digestFiles = async (files, texts) => {
155
155
  }
156
156
  for (const file of [...files].sort((a, b) => a.name.localeCompare(b.name))) {
157
157
  hash.update(`${file.name}\x00`);
158
- hash.update(await readFile2(file.path));
158
+ hash.update(await file.read());
159
159
  hash.update("\x00");
160
160
  }
161
161
  return hash.digest("hex");
162
162
  };
163
163
  var containerCodeDigest = async () => digestFiles((await Promise.all(containerCode().map(async ({ source, target }) => (await listFiles(dirname(source), source, (path) => includeSource(basename(path)))).map((name) => ({
164
164
  name: posix.join(posix.dirname(target), name),
165
- path: resolve3(dirname(source), name)
165
+ read: () => readFile2(resolve3(dirname(source), name))
166
166
  }))))).flat(), {});
167
167
  var manifestDependencies = z2.object({
168
168
  name: z2.string(),
@@ -195,8 +195,21 @@ var containerManifest = async () => {
195
195
  var recipeFile = (path) => path === "docker" || path === "docker/Dockerfile" || path === "docker/entrypoint.sh" || (path === "docker/install" || path.startsWith("docker/install/")) && includeSource(basename(path)) && basename(path) !== ".npmignore" && !path.split("/").includes("tests") && path !== "docker/install/wine-signal/check.sh";
196
196
  var builderRecipe = async () => digestFiles((await recipeFiles()).map((name) => ({
197
197
  name,
198
- path: resolve3(packageDirectory, name)
198
+ read: () => readFile2(resolve3(packageDirectory, name))
199
199
  })), { manifest: JSON.stringify(await containerManifest()) });
200
+ var toolingLine = /\bbun\b/i;
201
+ var engineeringRecipe = async () => digestFiles((await recipeFiles()).map((name) => ({
202
+ name,
203
+ read: async () => {
204
+ const content = await readFile2(resolve3(packageDirectory, name));
205
+ if (name !== "docker/Dockerfile") {
206
+ return content;
207
+ }
208
+ return content.toString("utf8").split(`
209
+ `).filter((line) => !toolingLine.test(line)).join(`
210
+ `);
211
+ }
212
+ })), {});
200
213
  var recipeFiles = () => listFiles(packageDirectory, resolve3(packageDirectory, "docker"), recipeFile);
201
214
  async function prepareDockerContext() {
202
215
  const context = await mkdtemp(resolve3(tmpdir(), "tsplc-docker-"));
@@ -392,6 +405,8 @@ async function buildBuilderImage(options) {
392
405
  `SETUP_PLATFORM=${options.setupPlatform}`,
393
406
  "--build-arg",
394
407
  `INSTALLER_SOURCE=${options.installer ? "installer-local" : "installer-download"}`,
408
+ "--build-arg",
409
+ `TSPLC_ENGINEERING=${await engineeringRecipe()}`,
395
410
  "--label",
396
411
  `${recipeLabel}=${await builderRecipe()}`,
397
412
  "--progress",
@@ -675,6 +690,7 @@ var controllerResultSchema = z5.strictObject({
675
690
  operationId: z5.uuid(),
676
691
  operation: z5.enum(["download", "online-change", "inspect"]),
677
692
  imageId: imageIdSchema,
693
+ engineering: sha256Digest.optional(),
678
694
  templateHash: sha256Digest,
679
695
  target: z5.strictObject({
680
696
  network: z5.string().nonempty(),
@@ -726,7 +742,8 @@ var controllerTarget = (config, online) => ({
726
742
  deviceTree: deviceTreeStructure(config.deviceTree)
727
743
  }
728
744
  });
729
- var sameBaseline = (state, expected) => state.imageId === expected.imageId && state.templateHash === expected.templateHash && JSON.stringify(state.target) === JSON.stringify(expected.target);
745
+ var sameBuilder = (state, expected) => state.engineering && expected.engineering ? state.engineering === expected.engineering : state.imageId === expected.imageId;
746
+ var sameBaseline = (state, expected) => sameBuilder(state, expected) && state.templateHash === expected.templateHash && JSON.stringify(state.target) === JSON.stringify(expected.target);
730
747
  var explicitDownload = "use an explicit download";
731
748
 
732
749
  class DownloadRequiredError extends Error {
@@ -1083,7 +1100,7 @@ import { basename as basename3 } from "node:path";
1083
1100
  import {
1084
1101
  globalSections,
1085
1102
  identifierPattern as identifierPattern2,
1086
- qualifiers as qualifiers2,
1103
+ qualifiers as qualifiers3,
1087
1104
  variableSections as variableSections3
1088
1105
  } from "@tsplc/iec/st";
1089
1106
 
@@ -1091,8 +1108,56 @@ import {
1091
1108
  import {
1092
1109
  conditionalDirective,
1093
1110
  modifiers,
1111
+ qualifiers as qualifiers2,
1094
1112
  variableSections as variableSections2
1095
1113
  } from "@tsplc/iec/st";
1114
+
1115
+ // packages/build/src/st/reader.ts
1116
+ var createTokenReader = (source, filename) => {
1117
+ const tokens = tokenize(source, filename);
1118
+ let index = 0;
1119
+ const peek = (ahead = 0) => tokens[index + ahead];
1120
+ const fail = (message, token = peek()) => {
1121
+ throw new StSyntaxError(source, token?.start ?? source.length, filename, message);
1122
+ };
1123
+ const take = () => {
1124
+ const token = peek();
1125
+ if (!token) {
1126
+ return fail("Unexpected end of declaration");
1127
+ }
1128
+ index++;
1129
+ return token;
1130
+ };
1131
+ const expect = (value) => {
1132
+ if (peek()?.value !== value) {
1133
+ fail(`Expected ${value}`);
1134
+ }
1135
+ return take();
1136
+ };
1137
+ const consume = (value) => {
1138
+ if (peek()?.value === value) {
1139
+ return take();
1140
+ }
1141
+ };
1142
+ return {
1143
+ source,
1144
+ filename,
1145
+ tokens,
1146
+ peek,
1147
+ take,
1148
+ expect,
1149
+ consume,
1150
+ fail,
1151
+ get index() {
1152
+ return index;
1153
+ },
1154
+ get end() {
1155
+ return tokens[index - 1]?.end ?? 0;
1156
+ }
1157
+ };
1158
+ };
1159
+
1160
+ // packages/build/src/st/declarations.ts
1096
1161
  var objectKinds = {
1097
1162
  PROGRAM: "program",
1098
1163
  FUNCTION_BLOCK: "function_block",
@@ -1263,51 +1328,15 @@ var readDeclarationSections = (reader) => {
1263
1328
  }
1264
1329
  }
1265
1330
  };
1266
-
1267
- // packages/build/src/st/reader.ts
1268
- var createTokenReader = (source, filename) => {
1269
- const tokens = tokenize(source, filename);
1270
- let index = 0;
1271
- const peek = (ahead = 0) => tokens[index + ahead];
1272
- const fail = (message, token = peek()) => {
1273
- throw new StSyntaxError(source, token?.start ?? source.length, filename, message);
1274
- };
1275
- const take = () => {
1276
- const token = peek();
1277
- if (!token) {
1278
- return fail("Unexpected end of declaration");
1279
- }
1280
- index++;
1281
- return token;
1282
- };
1283
- const expect = (value) => {
1284
- if (peek()?.value !== value) {
1285
- fail(`Expected ${value}`);
1286
- }
1287
- return take();
1288
- };
1289
- const consume = (value) => {
1290
- if (peek()?.value === value) {
1291
- return take();
1292
- }
1293
- };
1294
- return {
1295
- source,
1296
- filename,
1297
- tokens,
1298
- peek,
1299
- take,
1300
- expect,
1301
- consume,
1302
- fail,
1303
- get index() {
1304
- return index;
1305
- },
1306
- get end() {
1307
- return tokens[index - 1]?.end ?? 0;
1308
- }
1309
- };
1310
- };
1331
+ var keptSections = new Set([
1332
+ "VAR",
1333
+ "VAR_INPUT",
1334
+ "VAR_OUTPUT",
1335
+ "VAR_IN_OUT",
1336
+ "VAR_STAT",
1337
+ "VAR_INST",
1338
+ "VAR_GLOBAL"
1339
+ ]);
1311
1340
 
1312
1341
  // packages/build/src/st/parse.ts
1313
1342
  var dutTypes = {
@@ -1352,7 +1381,7 @@ var parseGlobals = (reader, options) => {
1352
1381
  const start = reader.index;
1353
1382
  readVariableSection(reader);
1354
1383
  for (const token of reader.tokens.slice(start + 1, reader.index)) {
1355
- if (token.kind !== "word" || !qualifiers2.has(token.value)) {
1384
+ if (token.kind !== "word" || !qualifiers3.has(token.value)) {
1356
1385
  break;
1357
1386
  }
1358
1387
  persistent ||= token.value === "PERSISTENT";
@@ -1667,24 +1696,38 @@ import { tmpdir as tmpdir4 } from "node:os";
1667
1696
  import { posix as posix3, resolve as resolve10 } from "node:path";
1668
1697
  import { setTimeout as delay2 } from "node:timers/promises";
1669
1698
  import { controllerBudgets as controllerBudgets2 } from "@tsplc/config/build";
1670
- import { z as z9 } from "zod";
1699
+ import { z as z10 } from "zod";
1671
1700
 
1672
1701
  // packages/build/src/controller-session.ts
1673
1702
  import { cp as cp5, mkdir as mkdir6, readdir as readdir3, readFile as readFile7, rm as rm6, writeFile as writeFile5 } from "node:fs/promises";
1674
1703
  import { resolve as resolve9 } from "node:path";
1675
1704
  import {
1676
1705
  controllerBudgets,
1706
+ cyclicTasksSchema as cyclicTasksSchema2,
1677
1707
  sha256Digest as sha256Digest2
1678
1708
  } from "@tsplc/config/build";
1709
+ import { z as z9 } from "zod";
1710
+
1711
+ // packages/build/src/online-change-check.ts
1712
+ import { elementaryType } from "@tsplc/iec";
1679
1713
  import { z as z8 } from "zod";
1680
- var guid = z8.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i);
1681
- var pointerSchema = z8.strictObject({
1682
- schemaVersion: z8.literal(1),
1683
- generation: z8.uuid()
1714
+ var committedObjectSchema = z8.lazy(() => z8.looseObject({
1715
+ kind: z8.string(),
1716
+ name: z8.string(),
1717
+ declaration: z8.string(),
1718
+ children: z8.array(committedObjectSchema).optional()
1719
+ }));
1720
+
1721
+ // packages/build/src/controller-session.ts
1722
+ var guid = z9.string().regex(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i);
1723
+ var pointerSchema = z9.strictObject({
1724
+ schemaVersion: z9.literal(1),
1725
+ generation: z9.uuid()
1684
1726
  });
1685
1727
  var baselineSchema = controllerResultSchema.extend({
1686
- objects: z8.array(z8.record(z8.string(), z8.unknown())),
1687
- files: z8.record(z8.string(), sha256Digest2),
1728
+ objects: z9.array(committedObjectSchema),
1729
+ tasks: cyclicTasksSchema2.optional(),
1730
+ files: z9.record(z9.string(), sha256Digest2),
1688
1731
  deviceSettings: sha256Digest2.optional()
1689
1732
  });
1690
1733
  var controllerDirectory = (outDir) => resolve9(outDir, ".codesys/controller");
@@ -1705,10 +1748,10 @@ var controllerBaseline = async (outDir) => {
1705
1748
  return "malformed";
1706
1749
  }
1707
1750
  };
1708
- var restoreResultSchema = z8.object({
1709
- restored: z8.boolean(),
1710
- controllerIds: z8.strictObject({ codeId: guid, dataId: guid }),
1711
- state: z8.string()
1751
+ var restoreResultSchema = z9.object({
1752
+ restored: z9.boolean(),
1753
+ controllerIds: z9.strictObject({ codeId: guid, dataId: guid }),
1754
+ state: z9.string()
1712
1755
  });
1713
1756
 
1714
1757
  // packages/build/src/controller-online.ts
@@ -1739,7 +1782,7 @@ var controllerConnection = async (config) => {
1739
1782
  };
1740
1783
  };
1741
1784
  var checkReceipt = (result, expected, diagnostics) => {
1742
- if (result.operationId !== expected.operationId || result.operation !== expected.operation || !sameBaseline(result, expected)) {
1785
+ if (result.operationId !== expected.operationId || result.operation !== expected.operation || result.imageId !== expected.imageId || !sameBaseline(result, expected)) {
1743
1786
  throw new Error(`Controller receipt does not match this operation's image, template or target. Inspect ${diagnostics} for diagnostics`);
1744
1787
  }
1745
1788
  return result;
@@ -1791,12 +1834,12 @@ var controllerOperation = async (config, operation, options) => {
1791
1834
  };
1792
1835
  var updateController = (config, operation, options = {}) => controllerOperation(config, operation, options);
1793
1836
  var inspectController = (config, read, options = {}) => controllerOperation(config, "inspect", { ...options, read });
1794
- var loginReplySchema = z9.discriminatedUnion("ok", [
1795
- z9.strictObject({ ok: z9.literal(true), result: z9.unknown() }),
1796
- z9.strictObject({
1797
- ok: z9.literal(false),
1798
- error: z9.string(),
1799
- downloadRequired: z9.literal(true).optional(),
1837
+ var loginReplySchema = z10.discriminatedUnion("ok", [
1838
+ z10.strictObject({ ok: z10.literal(true), result: z10.unknown() }),
1839
+ z10.strictObject({
1840
+ ok: z10.literal(false),
1841
+ error: z10.string(),
1842
+ downloadRequired: z10.literal(true).optional(),
1800
1843
  rollback: rollbackSchema.optional()
1801
1844
  })
1802
1845
  ]);
@@ -1840,7 +1883,7 @@ var callContainer = async (name, port, method, body) => {
1840
1883
  return reply.result;
1841
1884
  };
1842
1885
  var answers = (name, port) => callContainer(name, port, "GET").then(() => true, () => false);
1843
- var warmStateSchema = z9.object({ finishing: z9.boolean() });
1886
+ var warmStateSchema = z10.object({ finishing: z10.boolean() });
1844
1887
  var finishing = (name) => callContainer(name, warmPort, "GET").then((state) => warmStateSchema.safeParse(state).data?.finishing === true, () => false);
1845
1888
  var settleWarmController = async (config, name) => {
1846
1889
  const deadline = Date.now() + 2 * controllerBudgets2(config.timeouts).prepare;
@@ -2056,21 +2099,21 @@ import { mkdir as mkdir8, readFile as readFile9, rename as rename3, writeFile as
2056
2099
  import { basename as basename5, relative as relative3, resolve as resolve11 } from "node:path";
2057
2100
  import { sha256Digest as sha256Digest3 } from "@tsplc/config/build";
2058
2101
  import { generatedDirectory } from "@tsplc/config/project-files";
2059
- import { z as z10 } from "zod";
2102
+ import { z as z11 } from "zod";
2060
2103
  var libraryRegistry = "https://store-archive.codesys.com/CODESYSLibs";
2061
2104
  var libraryFile = /\.(?:compiled-library(?:-v\d+)?|library)$/i;
2062
- var installedLibrarySchema = z10.object({
2063
- title: z10.string(),
2064
- company: z10.string().optional(),
2065
- version: z10.string().optional(),
2066
- namespace: z10.string().optional(),
2067
- path: z10.string(),
2105
+ var installedLibrarySchema = z11.object({
2106
+ title: z11.string(),
2107
+ company: z11.string().optional(),
2108
+ version: z11.string().optional(),
2109
+ namespace: z11.string().optional(),
2110
+ path: z11.string(),
2068
2111
  sha256: sha256Digest3,
2069
- url: z10.string().optional()
2112
+ url: z11.string().optional()
2070
2113
  });
2071
- var libraryLockSchema = z10.object({
2072
- version: z10.literal(1),
2073
- dependencies: z10.record(z10.string(), installedLibrarySchema)
2114
+ var libraryLockSchema = z11.object({
2115
+ version: z11.literal(1),
2116
+ dependencies: z11.record(z11.string(), installedLibrarySchema)
2074
2117
  });
2075
2118
  var readLock = async (file) => {
2076
2119
  const text = await readFile9(file, "utf8").catch((cause) => {
@@ -2254,7 +2297,7 @@ import { mkdtemp as mkdtemp5, readFile as readFile10, rm as rm8, writeFile as wr
2254
2297
  import { tmpdir as tmpdir5 } from "node:os";
2255
2298
  import { basename as basename6, dirname as dirname2, join } from "node:path";
2256
2299
  import { setTimeout as delay3 } from "node:timers/promises";
2257
- import { z as z11 } from "zod";
2300
+ import { z as z12 } from "zod";
2258
2301
 
2259
2302
  // packages/build/src/runtime-status.ts
2260
2303
  var getApplicationStatus = (log, application, startedAt) => {
@@ -2272,9 +2315,9 @@ var getApplicationStatus = (log, application, startedAt) => {
2272
2315
  };
2273
2316
 
2274
2317
  // packages/build/src/run.ts
2275
- var stateSchema = z11.object({
2276
- Running: z11.boolean(),
2277
- StartedAt: z11.iso.datetime({ offset: true })
2318
+ var stateSchema = z12.object({
2319
+ Running: z12.boolean(),
2320
+ StartedAt: z12.iso.datetime({ offset: true })
2278
2321
  });
2279
2322
  var service = "plc";
2280
2323
  var runtimeProject = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9_-]+/g, "-");
@@ -2387,5 +2430,5 @@ export {
2387
2430
  workerScriptsDigest
2388
2431
  };
2389
2432
 
2390
- //# debugId=429690DB6F268B1964756E2164756E21
2433
+ //# debugId=EB6D02505BF86AFD64756E2164756E21
2391
2434
  //# sourceMappingURL=index.js.map