@aletheia-ios/tools 0.2.2 → 0.2.3

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.
Files changed (2) hide show
  1. package/dist/cli.js +20 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -748,23 +748,37 @@ async function create(repo, slug, name) {
748
748
  }
749
749
  //#endregion
750
750
  //#region src/lib/zip.ts
751
+ /** The calendar fields stamped on every entry, as a zip records them. */
752
+ const EPOCH = {
753
+ year: 2e3,
754
+ month: 0,
755
+ day: 1
756
+ };
751
757
  /**
752
758
  * The modification time stamped on every entry.
753
759
  *
754
- * A fixed mtime is what makes two builds of the same content byte-identical, which the app
755
- * relies on to treat one package published by two lists as one package.
760
+ * Built from the local-time constructor rather than a UTC instant, because a zip stores a DOS
761
+ * timestamp of the *local* calendar fields. A UTC instant renders as 00:00 on a runner in UTC
762
+ * and 11:00 on a machine in Sydney, which produced byte-different archives of identical files
763
+ * and broke the one guarantee this function exists to make. These arguments read back as
764
+ * 2000-01-01 00:00 from every timezone.
765
+ *
766
+ * Constructed per call so that construction and encoding always see the same timezone.
756
767
  */
757
- const EPOCH = /* @__PURE__ */ new Date("2000-01-01T00:00:00Z");
768
+ function epoch() {
769
+ return new Date(EPOCH.year, EPOCH.month, EPOCH.day);
770
+ }
758
771
  /**
759
772
  * Zips files into bytes that depend only on their names and contents.
760
773
  *
761
- * Entries are written in sorted name order with the fixed mtime and maximum deflate, so
762
- * the same input always produces the same archive and the same sha256.
774
+ * Entries are written in sorted name order with a fixed mtime and maximum deflate, so the same
775
+ * input produces the same archive and the same sha256 on any machine, in any timezone.
763
776
  */
764
777
  function deterministicZip(files) {
778
+ const mtime = epoch();
765
779
  const entries = {};
766
780
  for (const name of Object.keys(files).sort()) entries[name] = [files[name], {
767
- mtime: EPOCH,
781
+ mtime,
768
782
  level: 9
769
783
  }];
770
784
  return zipSync(entries);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aletheia-ios/tools",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "The aletheia CLI: build, check, pack, index and serve source packages",
5
5
  "license": "MIT",
6
6
  "repository": {