@tsplc/build 0.5.7 → 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/cli.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // packages/build/src/cli.ts
5
5
  import { parseArgs } from "util";
6
6
  import { loadTsplcConfig } from "@tsplc/config";
7
- import { z as z14 } from "zod";
7
+ import { z as z15 } from "zod";
8
8
 
9
9
  // packages/build/src/artifacts.ts
10
10
  import {
@@ -156,7 +156,7 @@ var digestFiles = async (files, texts) => {
156
156
  }
157
157
  for (const file of [...files].sort((a, b) => a.name.localeCompare(b.name))) {
158
158
  hash.update(`${file.name}\x00`);
159
- hash.update(await readFile2(file.path));
159
+ hash.update(await file.read());
160
160
  hash.update("\x00");
161
161
  }
162
162
  return hash.digest("hex");
@@ -192,8 +192,21 @@ var containerManifest = async () => {
192
192
  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";
193
193
  var builderRecipe = async () => digestFiles((await recipeFiles()).map((name) => ({
194
194
  name,
195
- path: resolve3(packageDirectory, name)
195
+ read: () => readFile2(resolve3(packageDirectory, name))
196
196
  })), { manifest: JSON.stringify(await containerManifest()) });
197
+ var toolingLine = /\bbun\b/i;
198
+ var engineeringRecipe = async () => digestFiles((await recipeFiles()).map((name) => ({
199
+ name,
200
+ read: async () => {
201
+ const content = await readFile2(resolve3(packageDirectory, name));
202
+ if (name !== "docker/Dockerfile") {
203
+ return content;
204
+ }
205
+ return content.toString("utf8").split(`
206
+ `).filter((line) => !toolingLine.test(line)).join(`
207
+ `);
208
+ }
209
+ })), {});
197
210
  var recipeFiles = () => listFiles(packageDirectory, resolve3(packageDirectory, "docker"), recipeFile);
198
211
  async function prepareDockerContext() {
199
212
  const context = await mkdtemp(resolve3(tmpdir(), "tsplc-docker-"));
@@ -365,6 +378,8 @@ async function buildBuilderImage(options) {
365
378
  `SETUP_PLATFORM=${options.setupPlatform}`,
366
379
  "--build-arg",
367
380
  `INSTALLER_SOURCE=${options.installer ? "installer-local" : "installer-download"}`,
381
+ "--build-arg",
382
+ `TSPLC_ENGINEERING=${await engineeringRecipe()}`,
368
383
  "--label",
369
384
  `${recipeLabel}=${await builderRecipe()}`,
370
385
  "--progress",
@@ -561,6 +576,7 @@ var controllerResultSchema = z5.strictObject({
561
576
  operationId: z5.uuid(),
562
577
  operation: z5.enum(["download", "online-change", "inspect"]),
563
578
  imageId: imageIdSchema,
579
+ engineering: sha256Digest.optional(),
564
580
  templateHash: sha256Digest,
565
581
  target: z5.strictObject({
566
582
  network: z5.string().nonempty(),
@@ -611,7 +627,8 @@ var controllerTarget = (config, online) => ({
611
627
  deviceTree: deviceTreeStructure(config.deviceTree)
612
628
  }
613
629
  });
614
- var sameBaseline = (state, expected) => state.imageId === expected.imageId && state.templateHash === expected.templateHash && JSON.stringify(state.target) === JSON.stringify(expected.target);
630
+ var sameBuilder = (state, expected) => state.engineering && expected.engineering ? state.engineering === expected.engineering : state.imageId === expected.imageId;
631
+ var sameBaseline = (state, expected) => sameBuilder(state, expected) && state.templateHash === expected.templateHash && JSON.stringify(state.target) === JSON.stringify(expected.target);
615
632
  var rollbackSchema = z5.enum([
616
633
  "intact",
617
634
  "restored",
@@ -940,7 +957,7 @@ import { basename as basename3 } from "node:path";
940
957
  import {
941
958
  globalSections,
942
959
  identifierPattern as identifierPattern2,
943
- qualifiers as qualifiers2,
960
+ qualifiers as qualifiers3,
944
961
  variableSections as variableSections3
945
962
  } from "@tsplc/iec/st";
946
963
 
@@ -948,8 +965,56 @@ import {
948
965
  import {
949
966
  conditionalDirective,
950
967
  modifiers,
968
+ qualifiers as qualifiers2,
951
969
  variableSections as variableSections2
952
970
  } from "@tsplc/iec/st";
971
+
972
+ // packages/build/src/st/reader.ts
973
+ var createTokenReader = (source, filename) => {
974
+ const tokens = tokenize(source, filename);
975
+ let index = 0;
976
+ const peek = (ahead = 0) => tokens[index + ahead];
977
+ const fail = (message, token = peek()) => {
978
+ throw new StSyntaxError(source, token?.start ?? source.length, filename, message);
979
+ };
980
+ const take = () => {
981
+ const token = peek();
982
+ if (!token) {
983
+ return fail("Unexpected end of declaration");
984
+ }
985
+ index++;
986
+ return token;
987
+ };
988
+ const expect = (value) => {
989
+ if (peek()?.value !== value) {
990
+ fail(`Expected ${value}`);
991
+ }
992
+ return take();
993
+ };
994
+ const consume = (value) => {
995
+ if (peek()?.value === value) {
996
+ return take();
997
+ }
998
+ };
999
+ return {
1000
+ source,
1001
+ filename,
1002
+ tokens,
1003
+ peek,
1004
+ take,
1005
+ expect,
1006
+ consume,
1007
+ fail,
1008
+ get index() {
1009
+ return index;
1010
+ },
1011
+ get end() {
1012
+ return tokens[index - 1]?.end ?? 0;
1013
+ }
1014
+ };
1015
+ };
1016
+
1017
+ // packages/build/src/st/declarations.ts
953
1018
  var objectKinds = {
954
1019
  PROGRAM: "program",
955
1020
  FUNCTION_BLOCK: "function_block",
@@ -1120,51 +1185,15 @@ var readDeclarationSections = (reader) => {
1120
1185
  }
1121
1186
  }
1122
1187
  };
1123
-
1124
- // packages/build/src/st/reader.ts
1125
- var createTokenReader = (source, filename) => {
1126
- const tokens = tokenize(source, filename);
1127
- let index = 0;
1128
- const peek = (ahead = 0) => tokens[index + ahead];
1129
- const fail = (message, token = peek()) => {
1130
- throw new StSyntaxError(source, token?.start ?? source.length, filename, message);
1131
- };
1132
- const take = () => {
1133
- const token = peek();
1134
- if (!token) {
1135
- return fail("Unexpected end of declaration");
1136
- }
1137
- index++;
1138
- return token;
1139
- };
1140
- const expect = (value) => {
1141
- if (peek()?.value !== value) {
1142
- fail(`Expected ${value}`);
1143
- }
1144
- return take();
1145
- };
1146
- const consume = (value) => {
1147
- if (peek()?.value === value) {
1148
- return take();
1149
- }
1150
- };
1151
- return {
1152
- source,
1153
- filename,
1154
- tokens,
1155
- peek,
1156
- take,
1157
- expect,
1158
- consume,
1159
- fail,
1160
- get index() {
1161
- return index;
1162
- },
1163
- get end() {
1164
- return tokens[index - 1]?.end ?? 0;
1165
- }
1166
- };
1167
- };
1188
+ var keptSections = new Set([
1189
+ "VAR",
1190
+ "VAR_INPUT",
1191
+ "VAR_OUTPUT",
1192
+ "VAR_IN_OUT",
1193
+ "VAR_STAT",
1194
+ "VAR_INST",
1195
+ "VAR_GLOBAL"
1196
+ ]);
1168
1197
 
1169
1198
  // packages/build/src/st/parse.ts
1170
1199
  var dutTypes = {
@@ -1209,7 +1238,7 @@ var parseGlobals = (reader, options) => {
1209
1238
  const start = reader.index;
1210
1239
  readVariableSection(reader);
1211
1240
  for (const token of reader.tokens.slice(start + 1, reader.index)) {
1212
- if (token.kind !== "word" || !qualifiers2.has(token.value)) {
1241
+ if (token.kind !== "word" || !qualifiers3.has(token.value)) {
1213
1242
  break;
1214
1243
  }
1215
1244
  persistent ||= token.value === "PERSISTENT";
@@ -1524,30 +1553,44 @@ import { mkdir as mkdir6, mkdtemp as mkdtemp4, readFile as readFile7, rm as rm6
1524
1553
  import { tmpdir as tmpdir4 } from "node:os";
1525
1554
  import { posix as posix3, resolve as resolve10 } from "node:path";
1526
1555
  import { controllerBudgets as controllerBudgets2 } from "@tsplc/config/build";
1527
- import { z as z9 } from "zod";
1556
+ import { z as z10 } from "zod";
1528
1557
 
1529
1558
  // packages/build/src/controller-session.ts
1530
1559
  import { resolve as resolve9 } from "node:path";
1531
1560
  import {
1532
1561
  controllerBudgets,
1562
+ cyclicTasksSchema as cyclicTasksSchema2,
1533
1563
  sha256Digest as sha256Digest2
1534
1564
  } from "@tsplc/config/build";
1565
+ import { z as z9 } from "zod";
1566
+
1567
+ // packages/build/src/online-change-check.ts
1568
+ import { elementaryType } from "@tsplc/iec";
1535
1569
  import { z as z8 } from "zod";
1536
- 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);
1537
- var pointerSchema = z8.strictObject({
1538
- schemaVersion: z8.literal(1),
1539
- generation: z8.uuid()
1570
+ var committedObjectSchema = z8.lazy(() => z8.looseObject({
1571
+ kind: z8.string(),
1572
+ name: z8.string(),
1573
+ declaration: z8.string(),
1574
+ children: z8.array(committedObjectSchema).optional()
1575
+ }));
1576
+
1577
+ // packages/build/src/controller-session.ts
1578
+ 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);
1579
+ var pointerSchema = z9.strictObject({
1580
+ schemaVersion: z9.literal(1),
1581
+ generation: z9.uuid()
1540
1582
  });
1541
1583
  var baselineSchema = controllerResultSchema.extend({
1542
- objects: z8.array(z8.record(z8.string(), z8.unknown())),
1543
- files: z8.record(z8.string(), sha256Digest2),
1584
+ objects: z9.array(committedObjectSchema),
1585
+ tasks: cyclicTasksSchema2.optional(),
1586
+ files: z9.record(z9.string(), sha256Digest2),
1544
1587
  deviceSettings: sha256Digest2.optional()
1545
1588
  });
1546
1589
  var controllerDirectory = (outDir) => resolve9(outDir, ".codesys/controller");
1547
- var restoreResultSchema = z8.object({
1548
- restored: z8.boolean(),
1549
- controllerIds: z8.strictObject({ codeId: guid, dataId: guid }),
1550
- state: z8.string()
1590
+ var restoreResultSchema = z9.object({
1591
+ restored: z9.boolean(),
1592
+ controllerIds: z9.strictObject({ codeId: guid, dataId: guid }),
1593
+ state: z9.string()
1551
1594
  });
1552
1595
 
1553
1596
  // packages/build/src/controller-online.ts
@@ -1578,7 +1621,7 @@ var controllerConnection = async (config) => {
1578
1621
  };
1579
1622
  };
1580
1623
  var checkReceipt = (result, expected, diagnostics) => {
1581
- if (result.operationId !== expected.operationId || result.operation !== expected.operation || !sameBaseline(result, expected)) {
1624
+ if (result.operationId !== expected.operationId || result.operation !== expected.operation || result.imageId !== expected.imageId || !sameBaseline(result, expected)) {
1582
1625
  throw new Error(`Controller receipt does not match this operation's image, template or target. Inspect ${diagnostics} for diagnostics`);
1583
1626
  }
1584
1627
  return result;
@@ -1629,16 +1672,16 @@ var controllerOperation = async (config, operation, options) => {
1629
1672
  }
1630
1673
  };
1631
1674
  var updateController = (config, operation, options = {}) => controllerOperation(config, operation, options);
1632
- var loginReplySchema = z9.discriminatedUnion("ok", [
1633
- z9.strictObject({ ok: z9.literal(true), result: z9.unknown() }),
1634
- z9.strictObject({
1635
- ok: z9.literal(false),
1636
- error: z9.string(),
1637
- downloadRequired: z9.literal(true).optional(),
1675
+ var loginReplySchema = z10.discriminatedUnion("ok", [
1676
+ z10.strictObject({ ok: z10.literal(true), result: z10.unknown() }),
1677
+ z10.strictObject({
1678
+ ok: z10.literal(false),
1679
+ error: z10.string(),
1680
+ downloadRequired: z10.literal(true).optional(),
1638
1681
  rollback: rollbackSchema.optional()
1639
1682
  })
1640
1683
  ]);
1641
- var warmStateSchema = z9.object({ finishing: z9.boolean() });
1684
+ var warmStateSchema = z10.object({ finishing: z10.boolean() });
1642
1685
 
1643
1686
  // packages/build/src/docker-build.ts
1644
1687
  var pullPublished = async ({ image, published }, progress) => {
@@ -1717,21 +1760,21 @@ import { mkdir as mkdir7, readFile as readFile8, rename as rename3, writeFile as
1717
1760
  import { basename as basename5, relative as relative3, resolve as resolve11 } from "node:path";
1718
1761
  import { sha256Digest as sha256Digest3 } from "@tsplc/config/build";
1719
1762
  import { generatedDirectory } from "@tsplc/config/project-files";
1720
- import { z as z10 } from "zod";
1763
+ import { z as z11 } from "zod";
1721
1764
  var libraryRegistry = "https://store-archive.codesys.com/CODESYSLibs";
1722
1765
  var libraryFile = /\.(?:compiled-library(?:-v\d+)?|library)$/i;
1723
- var installedLibrarySchema = z10.object({
1724
- title: z10.string(),
1725
- company: z10.string().optional(),
1726
- version: z10.string().optional(),
1727
- namespace: z10.string().optional(),
1728
- path: z10.string(),
1766
+ var installedLibrarySchema = z11.object({
1767
+ title: z11.string(),
1768
+ company: z11.string().optional(),
1769
+ version: z11.string().optional(),
1770
+ namespace: z11.string().optional(),
1771
+ path: z11.string(),
1729
1772
  sha256: sha256Digest3,
1730
- url: z10.string().optional()
1773
+ url: z11.string().optional()
1731
1774
  });
1732
- var libraryLockSchema = z10.object({
1733
- version: z10.literal(1),
1734
- dependencies: z10.record(z10.string(), installedLibrarySchema)
1775
+ var libraryLockSchema = z11.object({
1776
+ version: z11.literal(1),
1777
+ dependencies: z11.record(z11.string(), installedLibrarySchema)
1735
1778
  });
1736
1779
  var readLock = async (file) => {
1737
1780
  const text = await readFile8(file, "utf8").catch((cause) => {
@@ -1896,21 +1939,21 @@ import { mkdir as mkdir8, readFile as readFile9, rename as rename4, writeFile as
1896
1939
  import { basename as basename6, relative as relative4, resolve as resolve12 } from "node:path";
1897
1940
  import { sha256Digest as sha256Digest4 } from "@tsplc/config/build";
1898
1941
  import { generatedDirectory as generatedDirectory2 } from "@tsplc/config/project-files";
1899
- import { z as z11 } from "zod";
1942
+ import { z as z12 } from "zod";
1900
1943
  var libraryRegistry2 = "https://store-archive.codesys.com/CODESYSLibs";
1901
1944
  var libraryFile2 = /\.(?:compiled-library(?:-v\d+)?|library)$/i;
1902
- var installedLibrarySchema2 = z11.object({
1903
- title: z11.string(),
1904
- company: z11.string().optional(),
1905
- version: z11.string().optional(),
1906
- namespace: z11.string().optional(),
1907
- path: z11.string(),
1945
+ var installedLibrarySchema2 = z12.object({
1946
+ title: z12.string(),
1947
+ company: z12.string().optional(),
1948
+ version: z12.string().optional(),
1949
+ namespace: z12.string().optional(),
1950
+ path: z12.string(),
1908
1951
  sha256: sha256Digest4,
1909
- url: z11.string().optional()
1952
+ url: z12.string().optional()
1910
1953
  });
1911
- var libraryLockSchema2 = z11.object({
1912
- version: z11.literal(1),
1913
- dependencies: z11.record(z11.string(), installedLibrarySchema2)
1954
+ var libraryLockSchema2 = z12.object({
1955
+ version: z12.literal(1),
1956
+ dependencies: z12.record(z12.string(), installedLibrarySchema2)
1914
1957
  });
1915
1958
  var readLock2 = async (file) => {
1916
1959
  const text = await readFile9(file, "utf8").catch((cause) => {
@@ -2067,7 +2110,7 @@ import { mkdir as mkdir9, mkdtemp as mkdtemp5, readFile as readFile10, rm as rm7
2067
2110
  import { tmpdir as tmpdir5 } from "node:os";
2068
2111
  import { posix as posix4, resolve as resolve13 } from "node:path";
2069
2112
  import { controllerBudgets as controllerBudgets3 } from "@tsplc/config/build";
2070
- import { z as z12 } from "zod";
2113
+ import { z as z13 } from "zod";
2071
2114
  var credentialEnvironment2 = (config, { environment = process.env }) => {
2072
2115
  const names = config.online?.credentials ? [
2073
2116
  config.online.credentials.usernameEnv,
@@ -2095,7 +2138,7 @@ var controllerConnection2 = async (config) => {
2095
2138
  };
2096
2139
  };
2097
2140
  var checkReceipt2 = (result, expected, diagnostics) => {
2098
- if (result.operationId !== expected.operationId || result.operation !== expected.operation || !sameBaseline(result, expected)) {
2141
+ if (result.operationId !== expected.operationId || result.operation !== expected.operation || result.imageId !== expected.imageId || !sameBaseline(result, expected)) {
2099
2142
  throw new Error(`Controller receipt does not match this operation's image, template or target. Inspect ${diagnostics} for diagnostics`);
2100
2143
  }
2101
2144
  return result;
@@ -2146,16 +2189,16 @@ var controllerOperation2 = async (config, operation, options) => {
2146
2189
  }
2147
2190
  };
2148
2191
  var inspectController = (config, read, options = {}) => controllerOperation2(config, "inspect", { ...options, read });
2149
- var loginReplySchema2 = z12.discriminatedUnion("ok", [
2150
- z12.strictObject({ ok: z12.literal(true), result: z12.unknown() }),
2151
- z12.strictObject({
2152
- ok: z12.literal(false),
2153
- error: z12.string(),
2154
- downloadRequired: z12.literal(true).optional(),
2192
+ var loginReplySchema2 = z13.discriminatedUnion("ok", [
2193
+ z13.strictObject({ ok: z13.literal(true), result: z13.unknown() }),
2194
+ z13.strictObject({
2195
+ ok: z13.literal(false),
2196
+ error: z13.string(),
2197
+ downloadRequired: z13.literal(true).optional(),
2155
2198
  rollback: rollbackSchema.optional()
2156
2199
  })
2157
2200
  ]);
2158
- var warmStateSchema2 = z12.object({ finishing: z12.boolean() });
2201
+ var warmStateSchema2 = z13.object({ finishing: z13.boolean() });
2159
2202
 
2160
2203
  // packages/build/src/project-operations.ts
2161
2204
  var checkRawSources = async ({
@@ -2178,7 +2221,7 @@ import { mkdtemp as mkdtemp6, readFile as readFile11, rm as rm8, writeFile as wr
2178
2221
  import { tmpdir as tmpdir6 } from "node:os";
2179
2222
  import { basename as basename7, dirname as dirname2, join } from "node:path";
2180
2223
  import { setTimeout as delay2 } from "node:timers/promises";
2181
- import { z as z13 } from "zod";
2224
+ import { z as z14 } from "zod";
2182
2225
 
2183
2226
  // packages/build/src/runtime-status.ts
2184
2227
  var getApplicationStatus = (log, application, startedAt) => {
@@ -2196,9 +2239,9 @@ var getApplicationStatus = (log, application, startedAt) => {
2196
2239
  };
2197
2240
 
2198
2241
  // packages/build/src/run.ts
2199
- var stateSchema = z13.object({
2200
- Running: z13.boolean(),
2201
- StartedAt: z13.iso.datetime({ offset: true })
2242
+ var stateSchema = z14.object({
2243
+ Running: z14.boolean(),
2244
+ StartedAt: z14.iso.datetime({ offset: true })
2202
2245
  });
2203
2246
  var service = "plc";
2204
2247
  var runtimeProject = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9_-]+/g, "-");
@@ -2268,7 +2311,7 @@ ${log.split(`
2268
2311
  });
2269
2312
 
2270
2313
  // packages/build/src/cli.ts
2271
- var commandSchema = z14.enum([
2314
+ var commandSchema = z15.enum([
2272
2315
  "configure",
2273
2316
  "install",
2274
2317
  "check",
@@ -2359,5 +2402,5 @@ try {
2359
2402
  process.exitCode = 1;
2360
2403
  }
2361
2404
 
2362
- //# debugId=08C86387477FF4AB64756E2164756E21
2405
+ //# debugId=8A39677BBD3E872964756E2164756E21
2363
2406
  //# sourceMappingURL=cli.js.map