@everystack/pg-tools 0.4.0 → 0.4.1
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/package.json +1 -1
- package/src/index.ts +17 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everystack/pg-tools",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Prebuilt PostgreSQL client tools (pg_dump/pg_restore) as an AWS Lambda layer for everystack db:backup",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"author": "Scalable Technology, Inc. <licensing@scalable.technology>",
|
package/src/index.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { readFileSync } from 'node:fs';
|
|
20
|
-
import { join } from 'node:path';
|
|
20
|
+
import { join, dirname } from 'node:path';
|
|
21
21
|
|
|
22
22
|
/** Shape of the committed `manifest.json` — the artifact's self-description. */
|
|
23
23
|
export interface PgToolsManifest {
|
|
@@ -35,14 +35,24 @@ export interface PgToolsManifest {
|
|
|
35
35
|
lock: { sha256: string; rpms: number };
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// The package
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
38
|
+
// The package's REAL on-disk root — resolved via node module resolution of its OWN exported
|
|
39
|
+
// manifest, never `__dirname`. SST 4.14+ bundles the dynamically-imported sst.config graph (and
|
|
40
|
+
// this package with it), so `__dirname` resolves to the `.sst` bundle dir, not node_modules —
|
|
41
|
+
// `join(__dirname, '..')` then reads a manifest that isn't there (ENOENT at config eval, the whole
|
|
42
|
+
// deploy fails). `require.resolve` of the package specifier walks node_modules from wherever the
|
|
43
|
+
// bundle lives and finds the real file. `require` is ambient: native under CommonJS (the tests, a
|
|
44
|
+
// built dist) and provided by SST's ESM banner (`const require = createRequire(import.meta.url)`)
|
|
45
|
+
// in the bundled config. Indirected through a variable so a bundler leaves it a runtime resolve
|
|
46
|
+
// instead of trying to inline the target. (everystack: same __dirname-in-a-bundle class as the ops
|
|
47
|
+
// handler; here it's the framework's own asset resolution.)
|
|
48
|
+
const resolvePath = require.resolve;
|
|
49
|
+
const pkgManifestPath = resolvePath('@everystack/pg-tools/manifest.json');
|
|
50
|
+
const pkgRoot = dirname(pkgManifestPath);
|
|
42
51
|
|
|
43
|
-
/** The artifact's manifest (major, arch, sha256, provenance). Read once at load
|
|
52
|
+
/** The artifact's manifest (major, arch, sha256, provenance). Read once at load, from the resolved
|
|
53
|
+
* real path. */
|
|
44
54
|
export const manifest: PgToolsManifest = JSON.parse(
|
|
45
|
-
readFileSync(
|
|
55
|
+
readFileSync(pkgManifestPath, 'utf-8'),
|
|
46
56
|
) as PgToolsManifest;
|
|
47
57
|
|
|
48
58
|
/** Absolute path to the vendored layer zip (arm64, PG `manifest.major`). */
|