@cedarjs/pg 0.1.0-alpha.1 → 0.2.0-alpha.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.
Files changed (121) hide show
  1. package/README.md +276 -25
  2. package/dist/cli.cjs +60 -14
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.mjs +59 -13
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/{constants-CNZn5Xro.cjs → constants-Ct8myrEn.cjs} +2 -2
  7. package/dist/{constants-BY97wXjA.mjs.map → constants-Ct8myrEn.cjs.map} +1 -1
  8. package/dist/{constants-BY97wXjA.mjs → constants-NLR0U4NR.mjs} +2 -2
  9. package/dist/{constants-CNZn5Xro.cjs.map → constants-NLR0U4NR.mjs.map} +1 -1
  10. package/dist/dev-env.cjs +12 -0
  11. package/dist/dev-env.cjs.map +1 -0
  12. package/dist/dev-env.d.cts +1 -0
  13. package/dist/dev-env.d.mts +1 -0
  14. package/dist/dev-env.mjs +14 -0
  15. package/dist/dev-env.mjs.map +1 -0
  16. package/dist/index.cjs +50 -10
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.d.cts +168 -82
  19. package/dist/index.d.mts +168 -82
  20. package/dist/index.mjs +32 -2
  21. package/dist/index.mjs.map +1 -0
  22. package/dist/jest-teardown.cjs +18 -0
  23. package/dist/jest-teardown.cjs.map +1 -0
  24. package/dist/jest-teardown.d.cts +13 -0
  25. package/dist/jest-teardown.d.mts +14 -0
  26. package/dist/jest-teardown.mjs +18 -0
  27. package/dist/jest-teardown.mjs.map +1 -0
  28. package/dist/jest-template.cjs +41 -0
  29. package/dist/jest-template.cjs.map +1 -0
  30. package/dist/jest-template.d.cts +28 -0
  31. package/dist/jest-template.d.mts +28 -0
  32. package/dist/jest-template.mjs +35 -0
  33. package/dist/jest-template.mjs.map +1 -0
  34. package/dist/jest.cjs +12 -15
  35. package/dist/jest.cjs.map +1 -1
  36. package/dist/jest.d.cts +10 -7
  37. package/dist/jest.d.mts +10 -6
  38. package/dist/jest.mjs +12 -10
  39. package/dist/jest.mjs.map +1 -1
  40. package/dist/lease-B3TuX92y.d.mts +24 -0
  41. package/dist/lease-BSBBpaR4.mjs +201 -0
  42. package/dist/lease-BSBBpaR4.mjs.map +1 -0
  43. package/dist/lease-Bq9wKwQa.cjs +272 -0
  44. package/dist/lease-Bq9wKwQa.cjs.map +1 -0
  45. package/dist/lease-t4I9JahV.d.cts +24 -0
  46. package/dist/lifecycle-BOo6xBjD.mjs +684 -0
  47. package/dist/lifecycle-BOo6xBjD.mjs.map +1 -0
  48. package/dist/lifecycle-DEJ4GgWV.cjs +856 -0
  49. package/dist/lifecycle-DEJ4GgWV.cjs.map +1 -0
  50. package/dist/load-dev-env-7UjMHhw7.mjs +10 -0
  51. package/dist/load-dev-env-7UjMHhw7.mjs.map +1 -0
  52. package/dist/load-dev-env-cII6N4ZP.cjs +15 -0
  53. package/dist/load-dev-env-cII6N4ZP.cjs.map +1 -0
  54. package/dist/load-mode-env-B0qO9DZx.cjs +39 -0
  55. package/dist/load-mode-env-B0qO9DZx.cjs.map +1 -0
  56. package/dist/load-mode-env-C8gy4v9V.mjs +28 -0
  57. package/dist/load-mode-env-C8gy4v9V.mjs.map +1 -0
  58. package/dist/load-test-env-C34wpkIX.mjs +18 -0
  59. package/dist/load-test-env-C34wpkIX.mjs.map +1 -0
  60. package/dist/load-test-env-CkdUjTpV.cjs +23 -0
  61. package/dist/load-test-env-CkdUjTpV.cjs.map +1 -0
  62. package/dist/naming-C2nGVxPk.d.cts +39 -0
  63. package/dist/naming-C2nGVxPk.d.mts +39 -0
  64. package/dist/nx.cjs +26 -17
  65. package/dist/nx.cjs.map +1 -1
  66. package/dist/nx.d.cts +9 -20
  67. package/dist/nx.d.mts +9 -20
  68. package/dist/nx.mjs +20 -18
  69. package/dist/nx.mjs.map +1 -1
  70. package/dist/tasks-Caud9yHr.cjs +67 -0
  71. package/dist/tasks-Caud9yHr.cjs.map +1 -0
  72. package/dist/tasks-CjaZRi_G.d.mts +19 -0
  73. package/dist/tasks-DdQoP9We.d.cts +19 -0
  74. package/dist/tasks-KherHLac.mjs +38 -0
  75. package/dist/tasks-KherHLac.mjs.map +1 -0
  76. package/dist/template-CGw3C1Ob.mjs +88 -0
  77. package/dist/template-CGw3C1Ob.mjs.map +1 -0
  78. package/dist/template-D0gJ_MS2.cjs +105 -0
  79. package/dist/template-D0gJ_MS2.cjs.map +1 -0
  80. package/dist/template-mode-BkEs9LnY.cjs +91 -0
  81. package/dist/template-mode-BkEs9LnY.cjs.map +1 -0
  82. package/dist/template-mode-CcxV_Iju.d.cts +28 -0
  83. package/dist/template-mode-CcxV_Iju.d.mts +28 -0
  84. package/dist/template-mode-IjlFOG4O.mjs +80 -0
  85. package/dist/template-mode-IjlFOG4O.mjs.map +1 -0
  86. package/dist/test-env.cjs +16 -0
  87. package/dist/test-env.cjs.map +1 -0
  88. package/dist/test-env.d.cts +1 -0
  89. package/dist/test-env.d.mts +1 -0
  90. package/dist/test-env.mjs +18 -0
  91. package/dist/test-env.mjs.map +1 -0
  92. package/dist/vite-plus.cjs +8 -33
  93. package/dist/vite-plus.cjs.map +1 -1
  94. package/dist/vite-plus.d.cts +4 -48
  95. package/dist/vite-plus.d.mts +4 -48
  96. package/dist/vite-plus.mjs +5 -30
  97. package/dist/vite-plus.mjs.map +1 -1
  98. package/dist/vitest-template.cjs +48 -0
  99. package/dist/vitest-template.cjs.map +1 -0
  100. package/dist/vitest-template.d.cts +31 -0
  101. package/dist/vitest-template.d.mts +31 -0
  102. package/dist/vitest-template.mjs +42 -0
  103. package/dist/vitest-template.mjs.map +1 -0
  104. package/dist/vitest.cjs +10 -10
  105. package/dist/vitest.cjs.map +1 -1
  106. package/dist/vitest.d.cts +7 -3
  107. package/dist/vitest.d.mts +7 -2
  108. package/dist/vitest.mjs +10 -5
  109. package/dist/vitest.mjs.map +1 -1
  110. package/package.json +36 -12
  111. package/scripts/autopg-version +1 -0
  112. package/scripts/ci-install-autopg.sh +73 -0
  113. package/scripts/postinstall.js +35 -9
  114. package/dist/lifecycle-BGYtVXtx.cjs +0 -743
  115. package/dist/lifecycle-BGYtVXtx.cjs.map +0 -1
  116. package/dist/lifecycle-CT_8AWPv.mjs +0 -577
  117. package/dist/lifecycle-CT_8AWPv.mjs.map +0 -1
  118. package/dist/tasks-13P6tMth.mjs +0 -16
  119. package/dist/tasks-13P6tMth.mjs.map +0 -1
  120. package/dist/tasks-B8ryV9xo.cjs +0 -21
  121. package/dist/tasks-B8ryV9xo.cjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/pg",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.2.0-alpha.0",
4
4
  "description": "Worktree-isolated local Postgres for Vite+, Nx, and CedarJS (via autopg)",
5
5
  "keywords": [
6
6
  "autopg",
@@ -29,6 +29,8 @@
29
29
  },
30
30
  "files": [
31
31
  "dist",
32
+ "scripts/autopg-version",
33
+ "scripts/ci-install-autopg.sh",
32
34
  "scripts/postinstall.js"
33
35
  ],
34
36
  "type": "module",
@@ -56,26 +58,42 @@
56
58
  "import": "./dist/vitest.mjs",
57
59
  "require": "./dist/vitest.cjs"
58
60
  },
61
+ "./vitest/template": {
62
+ "types": "./dist/vitest-template.d.mts",
63
+ "import": "./dist/vitest-template.mjs",
64
+ "require": "./dist/vitest-template.cjs"
65
+ },
59
66
  "./jest": {
60
67
  "types": "./dist/jest.d.mts",
61
68
  "import": "./dist/jest.mjs",
62
69
  "require": "./dist/jest.cjs"
63
70
  },
71
+ "./jest-teardown": {
72
+ "types": "./dist/jest-teardown.d.mts",
73
+ "import": "./dist/jest-teardown.mjs",
74
+ "require": "./dist/jest-teardown.cjs"
75
+ },
76
+ "./test-env": {
77
+ "types": "./dist/test-env.d.mts",
78
+ "import": "./dist/test-env.mjs",
79
+ "require": "./dist/test-env.cjs"
80
+ },
81
+ "./dev-env": {
82
+ "types": "./dist/dev-env.d.mts",
83
+ "import": "./dist/dev-env.mjs",
84
+ "require": "./dist/dev-env.cjs"
85
+ },
86
+ "./jest/template": {
87
+ "types": "./dist/jest-template.d.mts",
88
+ "import": "./dist/jest-template.mjs",
89
+ "require": "./dist/jest-template.cjs"
90
+ },
64
91
  "./package.json": "./package.json"
65
92
  },
66
93
  "publishConfig": {
67
94
  "access": "public",
68
95
  "tag": "alpha"
69
96
  },
70
- "scripts": {
71
- "build": "vp pack",
72
- "dev": "vp pack --watch",
73
- "test": "vp test",
74
- "check": "vp check",
75
- "prepublishOnly": "vp pack",
76
- "postinstall": "node scripts/postinstall.js",
77
- "prepare": "vp config || true"
78
- },
79
97
  "dependencies": {
80
98
  "pg": "^8.16.3"
81
99
  },
@@ -92,5 +110,11 @@
92
110
  "engines": {
93
111
  "node": ">=24"
94
112
  },
95
- "packageManager": "pnpm@11.18.0"
96
- }
113
+ "scripts": {
114
+ "build": "vp pack",
115
+ "dev": "vp pack --watch",
116
+ "test": "vp test",
117
+ "check": "vp check",
118
+ "postinstall": "node scripts/postinstall.js"
119
+ }
120
+ }
@@ -0,0 +1 @@
1
+ v3.0.7
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env bash
2
+ # Binary-only autopg install for CI (and postinstall when CEDAR_PG_INSTALL_AUTOPG=1).
3
+ # Fetches pinned release, verifies attestation, installs binary — no pm2.
4
+ # Version pin: scripts/autopg-version (override with AUTOPG_VERSION).
5
+ set -euo pipefail
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ if [ -z "${AUTOPG_VERSION:-}" ]; then
9
+ AUTOPG_VERSION="$(tr -d '[:space:]' <"${SCRIPT_DIR}/autopg-version")"
10
+ fi
11
+ VERSION="${AUTOPG_VERSION}"
12
+ REPO="${AUTOPG_REPO:-automagik-dev/autopg}"
13
+ LEGACY_REPO="${AUTOPG_LEGACY_REPO:-namastexlabs/pgserve}"
14
+
15
+ detect_libc() {
16
+ if [ -e /lib/ld-musl-x86_64.so.1 ] || (ldd --version 2>&1 | grep -qi musl); then
17
+ echo musl
18
+ else
19
+ echo glibc
20
+ fi
21
+ }
22
+
23
+ case "$(uname -s)-$(uname -m)" in
24
+ Linux-x86_64) PLATFORM="linux-x64-$(detect_libc)" ;;
25
+ Linux-aarch64) PLATFORM="linux-arm64" ;;
26
+ Darwin-arm64) PLATFORM="darwin-arm64" ;;
27
+ Darwin-x86_64) PLATFORM="darwin-x64" ;;
28
+ *)
29
+ echo "[ci-install-autopg] unsupported platform: $(uname -s)-$(uname -m)" >&2
30
+ exit 1
31
+ ;;
32
+ esac
33
+
34
+ if [ -x "${HOME}/.local/bin/autopg" ]; then
35
+ echo "[ci-install-autopg] already present: ${HOME}/.local/bin/autopg"
36
+ exit 0
37
+ fi
38
+
39
+ TARBALL="autopg-${VERSION#v}-${PLATFORM}.tar.gz"
40
+ URL="https://github.com/${REPO}/releases/download/${VERSION}/${TARBALL}"
41
+ TMP="$(mktemp -d)"
42
+ trap 'rm -rf "$TMP"' EXIT
43
+
44
+ echo "[ci-install-autopg] fetching ${URL}"
45
+ curl -fsSL --output "${TMP}/${TARBALL}" "${URL}"
46
+
47
+ if ! command -v gh >/dev/null 2>&1; then
48
+ echo "[ci-install-autopg] gh CLI required for attestation verify" >&2
49
+ exit 1
50
+ fi
51
+
52
+ echo "[ci-install-autopg] verifying attestation"
53
+ if ! gh attestation verify "${TMP}/${TARBALL}" --repo "${REPO}" \
54
+ && ! gh attestation verify "${TMP}/${TARBALL}" --repo "${LEGACY_REPO}"; then
55
+ echo "[ci-install-autopg] attestation verify failed" >&2
56
+ exit 1
57
+ fi
58
+
59
+ echo "[ci-install-autopg] extracting binary tree"
60
+ tar -xzf "${TMP}/${TARBALL}" -C "${TMP}"
61
+ SRC="${TMP}/autopg"
62
+ if [ ! -x "${SRC}/autopg" ]; then
63
+ echo "[ci-install-autopg] unexpected tarball layout: ${SRC}/autopg missing" >&2
64
+ exit 1
65
+ fi
66
+
67
+ INSTALL_DIR="${HOME}/.local/share/autopg/${VERSION}"
68
+ mkdir -p "${INSTALL_DIR}" "${HOME}/.local/bin"
69
+ cp -a "${SRC}/." "${INSTALL_DIR}/"
70
+ ln -sfn "${INSTALL_DIR}/autopg" "${HOME}/.local/bin/autopg"
71
+
72
+ echo "[ci-install-autopg] ok — $(command -v autopg || echo "${HOME}/.local/bin/autopg")"
73
+ "${HOME}/.local/bin/autopg" --help >/dev/null
@@ -4,19 +4,23 @@
4
4
  * Idempotent across npm / yarn / pnpm. Never fails the parent install hard
5
5
  * when network is unavailable; prints a clear warning instead.
6
6
  *
7
- * Supply-chain: both the install script ref and the binary release are pinned.
8
- * Bump AUTOPG_VERSION (and the matching tag in INSTALL_URL) deliberately when
9
- * upgrading; do not track main/latest.
7
+ * Version pin: scripts/autopg-version (single source of truth).
8
+ *
9
+ * - Local / non-CI: pinned upstream install.sh (may start pm2).
10
+ * - CI + CEDAR_PG_INSTALL_AUTOPG=1: binary-only scripts/ci-install-autopg.sh
11
+ * (attestation via gh; no pm2 — cedar-pg ephemeral host owns startup).
10
12
  */
11
13
 
12
14
  import { spawnSync } from "node:child_process";
13
- import { existsSync } from "node:fs";
15
+ import { existsSync, readFileSync } from "node:fs";
14
16
  import { homedir } from "node:os";
15
- import { join } from "node:path";
17
+ import { dirname, join } from "node:path";
18
+ import { fileURLToPath } from "node:url";
16
19
 
17
- /** Pinned autopg release tag. Bump intentionally for upgrades. */
18
- const AUTOPG_VERSION = "v3.0.7";
20
+ const HERE = dirname(fileURLToPath(import.meta.url));
21
+ const AUTOPG_VERSION = readFileSync(join(HERE, "autopg-version"), "utf8").trim();
19
22
  const INSTALL_URL = `https://raw.githubusercontent.com/automagik-dev/autopg/${AUTOPG_VERSION}/install.sh`;
23
+ const CI_INSTALL = join(HERE, "ci-install-autopg.sh");
20
24
 
21
25
  function hasAutopg() {
22
26
  if (process.env.AUTOPG_BIN && existsSync(process.env.AUTOPG_BIN)) return true;
@@ -34,12 +38,34 @@ function main() {
34
38
  return;
35
39
  }
36
40
 
41
+ const inCi = process.env.CI === "true";
42
+ const forceCiInstall = process.env.CEDAR_PG_INSTALL_AUTOPG === "1";
43
+
37
44
  // Skip in CI unless explicitly requested; CI images often bake autopg
38
- if (process.env.CI === "true" && process.env.CEDAR_PG_INSTALL_AUTOPG !== "1") {
45
+ // or run scripts/ci-install-autopg.sh from the workflow.
46
+ if (inCi && !forceCiInstall) {
39
47
  console.warn(
40
48
  "[cedarpg] autopg not found; CI detected, skip auto-install. " +
41
- "Set CEDAR_PG_INSTALL_AUTOPG=1 or install autopg in the image.",
49
+ "Set CEDAR_PG_INSTALL_AUTOPG=1 or run scripts/ci-install-autopg.sh.",
50
+ );
51
+ return;
52
+ }
53
+
54
+ if (inCi && forceCiInstall) {
55
+ console.log(
56
+ `[cedarpg] autopg not found; CI binary install ${AUTOPG_VERSION} via ci-install-autopg.sh...`,
42
57
  );
58
+ const result = spawnSync("bash", [CI_INSTALL], {
59
+ stdio: "inherit",
60
+ env: { ...process.env, AUTOPG_VERSION },
61
+ });
62
+ if (result.status !== 0) {
63
+ console.warn(
64
+ "[cedarpg] CI binary install failed.\n" +
65
+ " Run: bash scripts/ci-install-autopg.sh\n" +
66
+ " (requires gh CLI + GH_TOKEN for attestation verify)",
67
+ );
68
+ }
43
69
  return;
44
70
  }
45
71