🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

pg-env

Package Overview
Dependencies
Maintainers
3
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-env - npm Package Compare versions

Comparing version
1.28.0
to
1.29.0
+30
esm/pg-client.d.ts
/**
* Resolving *which* PostgreSQL client binary to run (pg_dump, createdb, psql).
*
* The client's major version must be >= the server's, so when the local
* client is older, absent, or the server only reachable inside a container,
* callers need to point pgpm at a version-matched binary. That is a
* tool-location concern, distinct from connection settings (which stay in the
* PG* config): the resolved command still receives the connection via
* {@link getSpawnEnvWithPg} and explicit args.
*
* Two knobs, resolved here so nothing reads `process.env` ad hoc:
* - `PGPM_PG_CLIENT_PREFIX` — prepended to every tool, e.g.
* `docker exec -e PGUSER=postgres <container>` runs the container's client.
* - a per-tool alias (`PGPM_PG_DUMP` / `PGPM_CREATEDB` / `PGPM_PSQL`) — the
* full command for that one tool; when set it replaces the tool name (and
* the prefix, since an explicit alias is already complete).
*/
/** PostgreSQL client binaries pgpm may shell out to. */
export type PgClientTool = 'pg_dump' | 'createdb' | 'psql';
/**
* The argv for a PostgreSQL client tool, honoring a per-tool alias (highest
* precedence) then a shared prefix, else the bare tool name.
*
* @example
* // PGPM_PG_CLIENT_PREFIX="docker exec -e PGUSER=postgres pg"
* getPgClientCommand('pg_dump'); // ['docker','exec','-e','PGUSER=postgres','pg','pg_dump']
* // PGPM_PSQL="/usr/local/bin/psql18"
* getPgClientCommand('psql'); // ['/usr/local/bin/psql18']
*/
export declare const getPgClientCommand: (tool: PgClientTool, env?: NodeJS.ProcessEnv) => string[];
/**
* Resolving *which* PostgreSQL client binary to run (pg_dump, createdb, psql).
*
* The client's major version must be >= the server's, so when the local
* client is older, absent, or the server only reachable inside a container,
* callers need to point pgpm at a version-matched binary. That is a
* tool-location concern, distinct from connection settings (which stay in the
* PG* config): the resolved command still receives the connection via
* {@link getSpawnEnvWithPg} and explicit args.
*
* Two knobs, resolved here so nothing reads `process.env` ad hoc:
* - `PGPM_PG_CLIENT_PREFIX` — prepended to every tool, e.g.
* `docker exec -e PGUSER=postgres <container>` runs the container's client.
* - a per-tool alias (`PGPM_PG_DUMP` / `PGPM_CREATEDB` / `PGPM_PSQL`) — the
* full command for that one tool; when set it replaces the tool name (and
* the prefix, since an explicit alias is already complete).
*/
/** Env var holding the per-tool alias for each client binary. */
const TOOL_ALIAS_ENV = {
pg_dump: 'PGPM_PG_DUMP',
createdb: 'PGPM_CREATEDB',
psql: 'PGPM_PSQL'
};
/** Env var holding the prefix prepended to every client binary. */
const CLIENT_PREFIX_ENV = 'PGPM_PG_CLIENT_PREFIX';
const tokenize = (value) => value.trim().split(/\s+/).filter(Boolean);
/**
* The argv for a PostgreSQL client tool, honoring a per-tool alias (highest
* precedence) then a shared prefix, else the bare tool name.
*
* @example
* // PGPM_PG_CLIENT_PREFIX="docker exec -e PGUSER=postgres pg"
* getPgClientCommand('pg_dump'); // ['docker','exec','-e','PGUSER=postgres','pg','pg_dump']
* // PGPM_PSQL="/usr/local/bin/psql18"
* getPgClientCommand('psql'); // ['/usr/local/bin/psql18']
*/
export const getPgClientCommand = (tool, env = process.env) => {
const alias = (env[TOOL_ALIAS_ENV[tool]] ?? '').trim();
if (alias)
return tokenize(alias);
const prefix = (env[CLIENT_PREFIX_ENV] ?? '').trim();
return prefix ? [...tokenize(prefix), tool] : [tool];
};
/**
* Resolving *which* PostgreSQL client binary to run (pg_dump, createdb, psql).
*
* The client's major version must be >= the server's, so when the local
* client is older, absent, or the server only reachable inside a container,
* callers need to point pgpm at a version-matched binary. That is a
* tool-location concern, distinct from connection settings (which stay in the
* PG* config): the resolved command still receives the connection via
* {@link getSpawnEnvWithPg} and explicit args.
*
* Two knobs, resolved here so nothing reads `process.env` ad hoc:
* - `PGPM_PG_CLIENT_PREFIX` — prepended to every tool, e.g.
* `docker exec -e PGUSER=postgres <container>` runs the container's client.
* - a per-tool alias (`PGPM_PG_DUMP` / `PGPM_CREATEDB` / `PGPM_PSQL`) — the
* full command for that one tool; when set it replaces the tool name (and
* the prefix, since an explicit alias is already complete).
*/
/** PostgreSQL client binaries pgpm may shell out to. */
export type PgClientTool = 'pg_dump' | 'createdb' | 'psql';
/**
* The argv for a PostgreSQL client tool, honoring a per-tool alias (highest
* precedence) then a shared prefix, else the bare tool name.
*
* @example
* // PGPM_PG_CLIENT_PREFIX="docker exec -e PGUSER=postgres pg"
* getPgClientCommand('pg_dump'); // ['docker','exec','-e','PGUSER=postgres','pg','pg_dump']
* // PGPM_PSQL="/usr/local/bin/psql18"
* getPgClientCommand('psql'); // ['/usr/local/bin/psql18']
*/
export declare const getPgClientCommand: (tool: PgClientTool, env?: NodeJS.ProcessEnv) => string[];
"use strict";
/**
* Resolving *which* PostgreSQL client binary to run (pg_dump, createdb, psql).
*
* The client's major version must be >= the server's, so when the local
* client is older, absent, or the server only reachable inside a container,
* callers need to point pgpm at a version-matched binary. That is a
* tool-location concern, distinct from connection settings (which stay in the
* PG* config): the resolved command still receives the connection via
* {@link getSpawnEnvWithPg} and explicit args.
*
* Two knobs, resolved here so nothing reads `process.env` ad hoc:
* - `PGPM_PG_CLIENT_PREFIX` — prepended to every tool, e.g.
* `docker exec -e PGUSER=postgres <container>` runs the container's client.
* - a per-tool alias (`PGPM_PG_DUMP` / `PGPM_CREATEDB` / `PGPM_PSQL`) — the
* full command for that one tool; when set it replaces the tool name (and
* the prefix, since an explicit alias is already complete).
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPgClientCommand = void 0;
/** Env var holding the per-tool alias for each client binary. */
const TOOL_ALIAS_ENV = {
pg_dump: 'PGPM_PG_DUMP',
createdb: 'PGPM_CREATEDB',
psql: 'PGPM_PSQL'
};
/** Env var holding the prefix prepended to every client binary. */
const CLIENT_PREFIX_ENV = 'PGPM_PG_CLIENT_PREFIX';
const tokenize = (value) => value.trim().split(/\s+/).filter(Boolean);
/**
* The argv for a PostgreSQL client tool, honoring a per-tool alias (highest
* precedence) then a shared prefix, else the bare tool name.
*
* @example
* // PGPM_PG_CLIENT_PREFIX="docker exec -e PGUSER=postgres pg"
* getPgClientCommand('pg_dump'); // ['docker','exec','-e','PGUSER=postgres','pg','pg_dump']
* // PGPM_PSQL="/usr/local/bin/psql18"
* getPgClientCommand('psql'); // ['/usr/local/bin/psql18']
*/
const getPgClientCommand = (tool, env = process.env) => {
const alias = (env[TOOL_ALIAS_ENV[tool]] ?? '').trim();
if (alias)
return tokenize(alias);
const prefix = (env[CLIENT_PREFIX_ENV] ?? '').trim();
return prefix ? [...tokenize(prefix), tool] : [tool];
};
exports.getPgClientCommand = getPgClientCommand;
+1
-0
export { getPgEnvOptions, getPgEnvVars, getSpawnEnvWithPg, toPgEnvVars } from './env';
export { getPgClientCommand, PgClientTool } from './pg-client';
export { defaultPgConfig, PgConfig, PgPoolConfig } from './pg-config';
export { getPgEnvOptions, getPgEnvVars, getSpawnEnvWithPg, toPgEnvVars } from './env';
export { getPgClientCommand } from './pg-client';
export { defaultPgConfig } from './pg-config';
export { getPgEnvOptions, getPgEnvVars, getSpawnEnvWithPg, toPgEnvVars } from './env';
export { getPgClientCommand, PgClientTool } from './pg-client';
export { defaultPgConfig, PgConfig, PgPoolConfig } from './pg-config';
+3
-1
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultPgConfig = exports.toPgEnvVars = exports.getSpawnEnvWithPg = exports.getPgEnvVars = exports.getPgEnvOptions = void 0;
exports.defaultPgConfig = exports.getPgClientCommand = exports.toPgEnvVars = exports.getSpawnEnvWithPg = exports.getPgEnvVars = exports.getPgEnvOptions = void 0;
var env_1 = require("./env");

@@ -9,3 +9,5 @@ Object.defineProperty(exports, "getPgEnvOptions", { enumerable: true, get: function () { return env_1.getPgEnvOptions; } });

Object.defineProperty(exports, "toPgEnvVars", { enumerable: true, get: function () { return env_1.toPgEnvVars; } });
var pg_client_1 = require("./pg-client");
Object.defineProperty(exports, "getPgClientCommand", { enumerable: true, get: function () { return pg_client_1.getPgClientCommand; } });
var pg_config_1 = require("./pg-config");
Object.defineProperty(exports, "defaultPgConfig", { enumerable: true, get: function () { return pg_config_1.defaultPgConfig; } });
{
"name": "pg-env",
"version": "1.28.0",
"version": "1.29.0",
"author": "Constructive <developers@constructive.io>",

@@ -44,3 +44,3 @@ "description": "PostgreSQL environment configuration utilities",

},
"gitHead": "d508453a32a2f1d70ff6916871046615226e6f33"
"gitHead": "6da0705f8aa49d62dc2defb8b135b71674611483"
}