pgpm 0.4.2 → 0.5.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.
- package/commands/add.js +2 -2
- package/commands/admin-users/add.js +3 -3
- package/commands/admin-users/bootstrap.js +3 -3
- package/commands/admin-users/remove.js +3 -3
- package/commands/analyze.js +2 -2
- package/commands/cache.js +1 -1
- package/commands/clear.js +7 -7
- package/commands/deploy.js +4 -4
- package/commands/export.js +4 -4
- package/commands/extension.js +3 -3
- package/commands/init/module.js +5 -5
- package/commands/init/workspace.js +2 -2
- package/commands/install.js +3 -3
- package/commands/kill.js +1 -1
- package/commands/migrate/deps.js +4 -4
- package/commands/migrate/init.js +3 -3
- package/commands/migrate/list.js +4 -4
- package/commands/migrate/status.js +5 -5
- package/commands/package.js +2 -2
- package/commands/plan.js +4 -4
- package/commands/remove.js +5 -5
- package/commands/rename.js +2 -2
- package/commands/revert.js +4 -4
- package/commands/tag.js +6 -6
- package/commands/update.js +3 -3
- package/commands/verify.js +4 -4
- package/commands.js +3 -3
- package/esm/commands/add.js +2 -2
- package/esm/commands/admin-users/add.js +3 -3
- package/esm/commands/admin-users/bootstrap.js +3 -3
- package/esm/commands/admin-users/remove.js +3 -3
- package/esm/commands/analyze.js +2 -2
- package/esm/commands/cache.js +1 -1
- package/esm/commands/clear.js +7 -7
- package/esm/commands/deploy.js +4 -4
- package/esm/commands/export.js +4 -4
- package/esm/commands/extension.js +3 -3
- package/esm/commands/init/module.js +5 -5
- package/esm/commands/init/workspace.js +2 -2
- package/esm/commands/install.js +3 -3
- package/esm/commands/kill.js +1 -1
- package/esm/commands/migrate/deps.js +4 -4
- package/esm/commands/migrate/init.js +3 -3
- package/esm/commands/migrate/list.js +4 -4
- package/esm/commands/migrate/status.js +5 -5
- package/esm/commands/package.js +2 -2
- package/esm/commands/plan.js +4 -4
- package/esm/commands/remove.js +5 -5
- package/esm/commands/rename.js +2 -2
- package/esm/commands/revert.js +4 -4
- package/esm/commands/tag.js +6 -6
- package/esm/commands/update.js +3 -3
- package/esm/commands/verify.js +4 -4
- package/esm/commands.js +3 -3
- package/esm/utils/argv.js +1 -1
- package/esm/utils/cli-error.js +4 -4
- package/esm/utils/deployed-changes.js +3 -3
- package/esm/utils/display.js +2 -2
- package/esm/utils/module-utils.js +3 -3
- package/esm/utils/update-check.js +4 -4
- package/esm/utils/update-config.js +1 -1
- package/package.json +12 -11
- package/utils/argv.js +1 -1
- package/utils/cli-error.d.ts +2 -2
- package/utils/cli-error.js +4 -4
- package/utils/deployed-changes.d.ts +1 -1
- package/utils/deployed-changes.js +3 -3
- package/utils/display.js +2 -2
- package/utils/module-utils.d.ts +1 -1
- package/utils/module-utils.js +3 -3
- package/utils/update-check.d.ts +1 -1
- package/utils/update-check.js +4 -4
- package/utils/update-config.d.ts +1 -1
- package/utils/update-config.js +1 -1
- package/esm/package.js +0 -26
- package/package.d.ts +0 -1
- package/package.js +0 -29
package/utils/cli-error.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cliExitWithError = void 0;
|
|
4
|
-
const logger_1 = require("@
|
|
5
|
-
const types_1 = require("@
|
|
4
|
+
const logger_1 = require("@pgpmjs/logger");
|
|
5
|
+
const types_1 = require("@pgpmjs/types");
|
|
6
6
|
const pg_cache_1 = require("pg-cache");
|
|
7
7
|
const log = new logger_1.Logger('cli');
|
|
8
8
|
/**
|
|
@@ -12,8 +12,8 @@ const log = new logger_1.Logger('cli');
|
|
|
12
12
|
* IMPORTANT: This function properly cleans up PostgreSQL connections before exiting.
|
|
13
13
|
*/
|
|
14
14
|
const cliExitWithError = async (error, context) => {
|
|
15
|
-
if (error instanceof types_1.
|
|
16
|
-
// For
|
|
15
|
+
if (error instanceof types_1.PgpmError) {
|
|
16
|
+
// For PgpmError instances, use structured logging
|
|
17
17
|
log.error(`Error: ${error.message}`);
|
|
18
18
|
// Log additional context if available
|
|
19
19
|
if (error.context && Object.keys(error.context).length > 0) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Logger } from '@
|
|
1
|
+
import { Logger } from '@pgpmjs/logger';
|
|
2
2
|
import { Inquirerer } from 'inquirerer';
|
|
3
3
|
export declare function selectDeployedChange(database: string, argv: Partial<Record<string, any>>, prompter: Inquirerer, log: Logger, action?: 'revert' | 'verify'): Promise<string | undefined>;
|
|
4
4
|
export declare function selectDeployedPackage(database: string, argv: Partial<Record<string, any>>, prompter: Inquirerer, log: Logger, action?: 'revert' | 'verify'): Promise<string | undefined>;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.selectDeployedChange = selectDeployedChange;
|
|
4
4
|
exports.selectDeployedPackage = selectDeployedPackage;
|
|
5
|
-
const core_1 = require("@
|
|
5
|
+
const core_1 = require("@pgpmjs/core");
|
|
6
6
|
const pg_env_1 = require("pg-env");
|
|
7
7
|
async function selectDeployedChange(database, argv, prompter, log, action = 'revert') {
|
|
8
8
|
const pgEnv = (0, pg_env_1.getPgEnvOptions)({ database });
|
|
9
|
-
const client = new core_1.
|
|
9
|
+
const client = new core_1.PgpmMigrate(pgEnv);
|
|
10
10
|
let selectedPackage;
|
|
11
11
|
if (argv.package) {
|
|
12
12
|
selectedPackage = argv.package;
|
|
@@ -52,7 +52,7 @@ async function selectDeployedPackage(database, argv, prompter, log, action = 're
|
|
|
52
52
|
return argv.package;
|
|
53
53
|
}
|
|
54
54
|
const pgEnv = (0, pg_env_1.getPgEnvOptions)({ database });
|
|
55
|
-
const client = new core_1.
|
|
55
|
+
const client = new core_1.PgpmMigrate(pgEnv);
|
|
56
56
|
const packageStatuses = await client.status();
|
|
57
57
|
if (packageStatuses.length === 0) {
|
|
58
58
|
log.warn('No deployed packages found in database');
|
package/utils/display.js
CHANGED
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.usageText = void 0;
|
|
7
7
|
exports.displayVersion = displayVersion;
|
|
8
8
|
exports.displayUsage = displayUsage;
|
|
9
|
+
const find_and_require_package_json_1 = require("find-and-require-package-json");
|
|
9
10
|
const yanse_1 = __importDefault(require("yanse"));
|
|
10
|
-
const package_1 = require("../package");
|
|
11
11
|
// Function to display the version information
|
|
12
12
|
function displayVersion() {
|
|
13
|
-
const pkg = (0,
|
|
13
|
+
const pkg = (0, find_and_require_package_json_1.findAndRequirePackageJson)(__dirname);
|
|
14
14
|
console.log(yanse_1.default.green(`Name: ${pkg.name}`));
|
|
15
15
|
console.log(yanse_1.default.blue(`Version: ${pkg.version}`));
|
|
16
16
|
}
|
package/utils/module-utils.d.ts
CHANGED
package/utils/module-utils.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.selectPackage = selectPackage;
|
|
4
|
-
const core_1 = require("@
|
|
5
|
-
const types_1 = require("@
|
|
4
|
+
const core_1 = require("@pgpmjs/core");
|
|
5
|
+
const types_1 = require("@pgpmjs/types");
|
|
6
6
|
/**
|
|
7
7
|
* Handle package selection for operations that need a specific package
|
|
8
8
|
* Returns the selected package name, or undefined if validation fails or no packages exist
|
|
9
9
|
*/
|
|
10
10
|
async function selectPackage(argv, prompter, cwd, operationName, log) {
|
|
11
|
-
const pkg = new core_1.
|
|
11
|
+
const pkg = new core_1.PgpmPackage(cwd);
|
|
12
12
|
const modules = await pkg.getModules();
|
|
13
13
|
const moduleNames = modules.map(mod => mod.getModuleName());
|
|
14
14
|
// Check if any modules exist
|
package/utils/update-check.d.ts
CHANGED
package/utils/update-check.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkForUpdates = checkForUpdates;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const find_and_require_package_json_1 = require("find-and-require-package-json");
|
|
5
|
+
const logger_1 = require("@pgpmjs/logger");
|
|
6
|
+
const types_1 = require("@pgpmjs/types");
|
|
7
7
|
const npm_version_1 = require("./npm-version");
|
|
8
8
|
const update_config_1 = require("./update-config");
|
|
9
9
|
const log = new logger_1.Logger('update-check');
|
|
@@ -17,7 +17,7 @@ const shouldSkip = (command) => {
|
|
|
17
17
|
return false;
|
|
18
18
|
};
|
|
19
19
|
async function checkForUpdates(options = {}) {
|
|
20
|
-
const { pkgName = types_1.UPDATE_PACKAGE_NAME, pkgVersion = (0,
|
|
20
|
+
const { pkgName = types_1.UPDATE_PACKAGE_NAME, pkgVersion = (0, find_and_require_package_json_1.findAndRequirePackageJson)(__dirname).version, command, now = Date.now(), key = types_1.UPDATE_CHECK_APPSTASH_KEY, toolName, baseDir } = options;
|
|
21
21
|
if (shouldSkip(command)) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
package/utils/update-config.d.ts
CHANGED
package/utils/update-config.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.writeUpdateConfig = writeUpdateConfig;
|
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
11
|
const appstash_1 = require("appstash");
|
|
12
|
-
const types_1 = require("@
|
|
12
|
+
const types_1 = require("@pgpmjs/types");
|
|
13
13
|
const defaultToolName = 'pgpm';
|
|
14
14
|
const getConfigPath = (options = {}) => {
|
|
15
15
|
const toolName = options.toolName ?? defaultToolName;
|
package/esm/package.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'fs';
|
|
2
|
-
import { dirname, join } from 'path';
|
|
3
|
-
// need to search due to the dist/ folder and src/, etc.
|
|
4
|
-
function findPackageJson(currentDir) {
|
|
5
|
-
const filePath = join(currentDir, 'package.json');
|
|
6
|
-
// Check if package.json exists in the current directory
|
|
7
|
-
if (existsSync(filePath)) {
|
|
8
|
-
return filePath;
|
|
9
|
-
}
|
|
10
|
-
// Get the parent directory
|
|
11
|
-
const parentDir = dirname(currentDir);
|
|
12
|
-
// If reached the root directory, package.json is not found
|
|
13
|
-
if (parentDir === currentDir) {
|
|
14
|
-
throw new Error('package.json not found in any parent directory');
|
|
15
|
-
}
|
|
16
|
-
// Recursively look in the parent directory
|
|
17
|
-
return findPackageJson(parentDir);
|
|
18
|
-
}
|
|
19
|
-
export function readAndParsePackageJson() {
|
|
20
|
-
// Start searching from the current directory
|
|
21
|
-
const pkgPath = findPackageJson(__dirname);
|
|
22
|
-
// Read and parse the package.json
|
|
23
|
-
const str = readFileSync(pkgPath, 'utf8');
|
|
24
|
-
const pkg = JSON.parse(str);
|
|
25
|
-
return pkg;
|
|
26
|
-
}
|
package/package.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function readAndParsePackageJson(): any;
|
package/package.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readAndParsePackageJson = readAndParsePackageJson;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
// need to search due to the dist/ folder and src/, etc.
|
|
7
|
-
function findPackageJson(currentDir) {
|
|
8
|
-
const filePath = (0, path_1.join)(currentDir, 'package.json');
|
|
9
|
-
// Check if package.json exists in the current directory
|
|
10
|
-
if ((0, fs_1.existsSync)(filePath)) {
|
|
11
|
-
return filePath;
|
|
12
|
-
}
|
|
13
|
-
// Get the parent directory
|
|
14
|
-
const parentDir = (0, path_1.dirname)(currentDir);
|
|
15
|
-
// If reached the root directory, package.json is not found
|
|
16
|
-
if (parentDir === currentDir) {
|
|
17
|
-
throw new Error('package.json not found in any parent directory');
|
|
18
|
-
}
|
|
19
|
-
// Recursively look in the parent directory
|
|
20
|
-
return findPackageJson(parentDir);
|
|
21
|
-
}
|
|
22
|
-
function readAndParsePackageJson() {
|
|
23
|
-
// Start searching from the current directory
|
|
24
|
-
const pkgPath = findPackageJson(__dirname);
|
|
25
|
-
// Read and parse the package.json
|
|
26
|
-
const str = (0, fs_1.readFileSync)(pkgPath, 'utf8');
|
|
27
|
-
const pkg = JSON.parse(str);
|
|
28
|
-
return pkg;
|
|
29
|
-
}
|