@formepdf/core 0.10.0 → 0.10.2

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.
@@ -0,0 +1,62 @@
1
+ #!/bin/bash
2
+ # Assert the @formepdf/core tarball ships every file the package's own
3
+ # entry points import. Catches the failure mode that shipped in 0.10.0
4
+ # — wasm-pack writes a `.gitignore` containing `*` inside each output
5
+ # dir, and `npm publish` silently drops the directory contents. The
6
+ # `build:wasm` script removes those gitignores, but if a future change
7
+ # adds a new pkg-* dir and forgets to add the matching `rm`, this
8
+ # script fails loudly during `npm publish` (it's wired up via
9
+ # `prepublishOnly`).
10
+ #
11
+ # Also runs as part of CI so we catch the regression at PR time, not
12
+ # release time.
13
+ set -euo pipefail
14
+
15
+ cd "$(dirname "$0")/.."
16
+
17
+ # Ask npm what it *would* publish. --ignore-scripts is critical: we're
18
+ # called from prepublishOnly, and npm pack itself fires prepublishOnly,
19
+ # which would recurse forever (or silently fail with an empty tarball
20
+ # name and a confusing `tar: Failed to open ''` error). --dry-run skips
21
+ # writing a real .tgz to disk. --json gives us structured output we
22
+ # don't need to parse out of human-readable notices.
23
+ FILES=$(npm pack --dry-run --json --ignore-scripts \
24
+ | sed -n 's/^[[:space:]]*"path": "\([^"]*\)".*/package\/\1/p')
25
+
26
+ REQUIRED=(
27
+ package/dist/index.js
28
+ package/dist/browser.js
29
+ package/dist/worker.js
30
+ package/pkg/forme.js
31
+ package/pkg/forme_bg.js
32
+ package/pkg/forme_bg.wasm
33
+ package/pkg-web/forme.js
34
+ package/pkg-web/forme_bg.wasm
35
+ package/pkg-node/forme.js
36
+ package/pkg-node/forme_bg.wasm
37
+ package/package.json
38
+ )
39
+
40
+ missing=0
41
+ for f in "${REQUIRED[@]}"; do
42
+ if ! printf '%s\n' "$FILES" | grep -qx "$f"; then
43
+ echo "MISSING from tarball: $f"
44
+ missing=1
45
+ fi
46
+ done
47
+
48
+ # Stray .gitignore inside any published pkg dir means wasm-pack's output
49
+ # slipped through — exactly the 0.10.0 regression.
50
+ if printf '%s\n' "$FILES" | grep -E '/pkg(-web|-node)?/\.gitignore$' >/dev/null; then
51
+ echo "Stray .gitignore inside a published pkg* dir — npm publish will drop directory contents. Add it to the build:wasm cleanup step."
52
+ printf '%s\n' "$FILES" | grep -E '/pkg(-web|-node)?/\.gitignore$' >&2
53
+ missing=1
54
+ fi
55
+
56
+ if [ "$missing" -ne 0 ]; then
57
+ echo
58
+ echo "Tarball is missing files. Refusing to publish."
59
+ exit 1
60
+ fi
61
+
62
+ echo "OK: tarball has all required files and no stray .gitignore files."