ceulen 0.29.2 → 0.31.0

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,90 @@
1
+ #!/bin/sh
2
+ # Smoke-test the npm-installable tarball: install into a throwaway directory and
3
+ # assert the payload, with a non-zero exit for EVERY kind of wrong answer.
4
+ #
5
+ # Exists because AGENTS.md tells you to "install it from a clean directory and
6
+ # assert the payload" before calling a release shipped, and hand-rolling that
7
+ # check has repeatedly produced exit codes that meant nothing — capturing $?
8
+ # after a pipeline, or a node -e that only printed results without calling
9
+ # process.exit. Every assertion here is fatal.
10
+ #
11
+ # Checks, each independently fatal:
12
+ # - npm install's own exit status (captured without a pipe)
13
+ # - installed package.json version == the requested version
14
+ # - every --require path exists in the installed package
15
+ # - every --forbid path is ABSENT (deleted files must stay deleted)
16
+ #
17
+ # Usage: scripts/smoke-install.sh <version> [package]
18
+ # [--require <path-in-package>]...
19
+ # [--forbid <path-in-package>]...
20
+ # Exit: 0 = installed and every assertion held; 1 = a check failed; 2 = bad usage.
21
+ set -eu
22
+
23
+ VERSION=""
24
+ PACKAGE="ceulen"
25
+ REQUIRE=""
26
+ FORBID=""
27
+ # Version the installed package.json must report. Defaults to the version we
28
+ # install; --expect-version exists so the mismatch guard is testable through the
29
+ # real CLI instead of by poking at internals.
30
+ EXPECT_VERSION=""
31
+ while [ $# -gt 0 ]; do
32
+ case "$1" in
33
+ --require) REQUIRE="$REQUIRE $2"; shift 2 ;;
34
+ --forbid) FORBID="$FORBID $2"; shift 2 ;;
35
+ --package) PACKAGE="$2"; shift 2 ;;
36
+ --expect-version) EXPECT_VERSION="$2"; shift 2 ;;
37
+ -*) echo "unknown option: $1" >&2; exit 2 ;;
38
+ *) [ -z "$VERSION" ] && VERSION="$1" || { echo "unexpected argument: $1" >&2; exit 2; }; shift ;;
39
+ esac
40
+ done
41
+ [ -n "$VERSION" ] || { echo "usage: smoke-install.sh <version> [package] [--require p]... [--forbid p]... [--expect-version v]" >&2; exit 2; }
42
+ [ -n "$EXPECT_VERSION" ] || EXPECT_VERSION="$VERSION"
43
+
44
+ WORK=$(mktemp -d)
45
+ trap 'rm -rf "$WORK"' EXIT INT TERM
46
+ cd "$WORK"
47
+
48
+ # npm's OWN exit status — no pipeline, so nothing can mask it.
49
+ if ! npm install "$PACKAGE@$VERSION" --no-save --loglevel=error > install.log 2>&1; then
50
+ echo "FAIL: npm install $PACKAGE@$VERSION exited non-zero" >&2
51
+ tail -20 install.log >&2
52
+ exit 1
53
+ fi
54
+ echo "ok npm install $PACKAGE@$VERSION — exit 0"
55
+
56
+ BASE="node_modules/$PACKAGE"
57
+ SMOKE_BASE="$BASE" SMOKE_VERSION="$EXPECT_VERSION" SMOKE_REQUIRE="$REQUIRE" SMOKE_FORBID="$FORBID" node -e '
58
+ const fs = require("fs");
59
+ const path = require("path");
60
+ const base = process.env.SMOKE_BASE;
61
+ const want = process.env.SMOKE_VERSION;
62
+ const split = (s) => (s || "").trim().split(/\s+/).filter(Boolean);
63
+ const require_ = split(process.env.SMOKE_REQUIRE);
64
+ const forbid = split(process.env.SMOKE_FORBID);
65
+
66
+ let bad = 0;
67
+ const fail = (m) => { console.error("FAIL: " + m); bad = 1; };
68
+
69
+ let pkg;
70
+ try {
71
+ pkg = JSON.parse(fs.readFileSync(path.join(base, "package.json"), "utf8"));
72
+ } catch (e) {
73
+ console.error("FAIL: cannot read the installed package.json — extraction failed");
74
+ process.exit(1);
75
+ }
76
+
77
+ if (pkg.version !== want) fail("installed version " + pkg.version + " != requested " + want);
78
+ else console.log("ok version " + pkg.version);
79
+
80
+ for (const f of require_) {
81
+ if (fs.existsSync(path.join(base, f))) console.log("ok present " + f);
82
+ else fail("missing " + f);
83
+ }
84
+ for (const f of forbid) {
85
+ if (fs.existsSync(path.join(base, f))) fail("unexpected " + f + " (should not ship)");
86
+ else console.log("ok absent " + f);
87
+ }
88
+
89
+ process.exit(bad ? 1 : 0);
90
+ '