zappie 0.1.4 → 0.1.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # zappie
2
2
 
3
+ ## 0.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 49d3708: The npm package ships each registry item once, under its plain name, instead of also shipping an identical `<name>@<version>.json` copy. The hosted registry keeps both names. When `--registry` points at a local directory without the pinned file, `zappie` reads the plain file and checks that its version matches.
8
+ - 32ecccf: Add report-only storefront security headers, per-request nonces, prerendered-script hashes and V18 security-header verification. The starter now applies the policy to every document response.
9
+
3
10
  ## 0.1.4
4
11
 
5
12
  ### Patch Changes
package/dist/cli.js CHANGED
@@ -608,7 +608,7 @@ import path6 from "path";
608
608
  import { satisfies as satisfies2 } from "semver";
609
609
 
610
610
  // src/registry.ts
611
- import { readFile } from "fs/promises";
611
+ import { access, readFile } from "fs/promises";
612
612
  import path5 from "path";
613
613
  function object(value, label) {
614
614
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
@@ -691,9 +691,18 @@ var Registry = class {
691
691
  this.source = source2;
692
692
  this.cwd = cwd;
693
693
  }
694
+ remote() {
695
+ return /^https?:\/\//.test(this.source);
696
+ }
697
+ async exists(file) {
698
+ return access(path5.join(path5.resolve(this.cwd, this.source), file)).then(
699
+ () => true,
700
+ () => false
701
+ );
702
+ }
694
703
  async read(file) {
695
704
  try {
696
- if (/^https?:\/\//.test(this.source)) {
705
+ if (this.remote()) {
697
706
  const response = await fetch(
698
707
  `${this.source.replace(/\/+$/, "")}/${file}`
699
708
  );
@@ -713,8 +722,21 @@ var Registry = class {
713
722
  return index(await this.read("index.json"));
714
723
  }
715
724
  async item(name2, version2) {
716
- const suffix = version2 === void 0 ? name2 : `${name2}@${version2}`;
717
- return item(await this.read(`items/${suffix}.json`));
725
+ if (version2 === void 0) {
726
+ return item(await this.read(`items/${name2}.json`));
727
+ }
728
+ const pinned = `items/${name2}@${version2}.json`;
729
+ if (this.remote() || await this.exists(pinned)) {
730
+ return item(await this.read(pinned));
731
+ }
732
+ const current = item(await this.read(`items/${name2}.json`));
733
+ if (current.version !== version2) {
734
+ throw new CliError(
735
+ `We could not read registry ${pinned}: this registry has ${name2} ${current.version} only.`,
736
+ 3
737
+ );
738
+ }
739
+ return current;
718
740
  }
719
741
  };
720
742
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zappie",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Install Zappie kit components and check storefront projects.",
5
5
  "type": "module",
6
6
  "bin": {