pgpm 1.2.1 → 1.3.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/README.md CHANGED
@@ -82,6 +82,7 @@ Here are some useful commands for reference:
82
82
  ### Module Management
83
83
 
84
84
  - `pgpm install` - Install database modules as dependencies
85
+ - `pgpm upgrade-modules` - Upgrade installed modules to latest versions
85
86
  - `pgpm extension` - Interactively manage module dependencies
86
87
  - `pgpm tag` - Version your changes with tags
87
88
 
@@ -239,6 +240,31 @@ pgpm install @pgpm/base32
239
240
  pgpm install @pgpm/base32 @pgpm/faker
240
241
  ```
241
242
 
243
+ #### `pgpm upgrade-modules`
244
+
245
+ Upgrade installed pgpm modules to their latest versions from npm.
246
+
247
+ ```bash
248
+ # Interactive selection of modules to upgrade
249
+ pgpm upgrade-modules
250
+
251
+ # Upgrade all installed modules without prompting
252
+ pgpm upgrade-modules --all
253
+
254
+ # Preview available upgrades without making changes
255
+ pgpm upgrade-modules --dry-run
256
+
257
+ # Upgrade specific modules
258
+ pgpm upgrade-modules --modules @pgpm/base32,@pgpm/faker
259
+ ```
260
+
261
+ **Options:**
262
+
263
+ - `--all` - Upgrade all modules without prompting
264
+ - `--dry-run` - Show what would be upgraded without making changes
265
+ - `--modules <names>` - Comma-separated list of specific modules to upgrade
266
+ - `--cwd <directory>` - Working directory (default: current directory)
267
+
242
268
  #### `pgpm extension`
243
269
 
244
270
  Interactively manage module dependencies.
@@ -0,0 +1,4 @@
1
+ import { CLIOptions, Inquirerer } from 'inquirerer';
2
+ import { ParsedArgs } from 'minimist';
3
+ declare const _default: (argv: Partial<ParsedArgs>, prompter: Inquirerer, _options: CLIOptions) => Promise<void>;
4
+ export default _default;
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@pgpmjs/core");
4
+ const logger_1 = require("@pgpmjs/logger");
5
+ const npm_version_1 = require("../utils/npm-version");
6
+ const log = new logger_1.Logger('upgrade-modules');
7
+ const upgradeModulesUsageText = `
8
+ Upgrade Modules Command:
9
+
10
+ pgpm upgrade-modules [OPTIONS]
11
+
12
+ Upgrade installed pgpm modules to their latest versions from npm.
13
+
14
+ Options:
15
+ --help, -h Show this help message
16
+ --cwd <directory> Working directory (default: current directory)
17
+ --all Upgrade all modules without prompting
18
+ --dry-run Show what would be upgraded without making changes
19
+ --modules <names> Comma-separated list of specific modules to upgrade
20
+ --workspace Upgrade modules across all packages in the workspace
21
+
22
+ Examples:
23
+ pgpm upgrade-modules Interactive selection of modules to upgrade
24
+ pgpm upgrade-modules --all Upgrade all installed modules
25
+ pgpm upgrade-modules --dry-run Preview available upgrades
26
+ pgpm upgrade-modules --modules @pgpm/base32,@pgpm/faker Upgrade specific modules
27
+ pgpm upgrade-modules --workspace --all Upgrade all modules across the entire workspace
28
+ `;
29
+ async function fetchModuleVersions(installedVersions) {
30
+ const moduleNames = Object.keys(installedVersions);
31
+ const results = [];
32
+ for (const name of moduleNames) {
33
+ const currentVersion = installedVersions[name];
34
+ const latestVersion = await (0, npm_version_1.fetchLatestVersion)(name);
35
+ results.push({
36
+ name,
37
+ currentVersion,
38
+ latestVersion,
39
+ hasUpdate: latestVersion !== null && latestVersion !== currentVersion
40
+ });
41
+ }
42
+ return results;
43
+ }
44
+ async function upgradeModulesForProject(project, argv, prompter, dryRun, upgradeAll, specificModules, moduleName) {
45
+ const { installed, installedVersions } = project.getInstalledModules();
46
+ if (installed.length === 0) {
47
+ if (moduleName) {
48
+ log.info(`[${moduleName}] No pgpm modules are installed.`);
49
+ }
50
+ else {
51
+ log.info('No pgpm modules are installed in this module.');
52
+ }
53
+ return false;
54
+ }
55
+ const prefix = moduleName ? `[${moduleName}] ` : '';
56
+ log.info(`${prefix}Found ${installed.length} installed module(s). Checking for updates...`);
57
+ const moduleVersions = await fetchModuleVersions(installedVersions);
58
+ const modulesWithUpdates = moduleVersions.filter(m => m.hasUpdate);
59
+ if (modulesWithUpdates.length === 0) {
60
+ log.success(`${prefix}All modules are already up to date.`);
61
+ return false;
62
+ }
63
+ log.info(`\n${prefix}${modulesWithUpdates.length} module(s) have updates available:\n`);
64
+ for (const mod of modulesWithUpdates) {
65
+ log.info(` ${mod.name}: ${mod.currentVersion} -> ${mod.latestVersion}`);
66
+ }
67
+ console.log('');
68
+ if (dryRun) {
69
+ log.info(`${prefix}Dry run - no changes made.`);
70
+ return true;
71
+ }
72
+ let modulesToUpgrade;
73
+ if (upgradeAll) {
74
+ modulesToUpgrade = modulesWithUpdates.map(m => m.name);
75
+ }
76
+ else if (specificModules) {
77
+ modulesToUpgrade = modulesWithUpdates
78
+ .filter(m => specificModules.includes(m.name))
79
+ .map(m => m.name);
80
+ if (modulesToUpgrade.length === 0) {
81
+ log.warn(`${prefix}None of the specified modules have updates available.`);
82
+ return false;
83
+ }
84
+ }
85
+ else {
86
+ const options = modulesWithUpdates.map(mod => ({
87
+ name: mod.name,
88
+ value: mod.name,
89
+ message: `${mod.name} (${mod.currentVersion} -> ${mod.latestVersion})`
90
+ }));
91
+ const questions = [
92
+ {
93
+ name: 'selectedModules',
94
+ message: `${prefix}Select modules to upgrade:`,
95
+ type: 'checkbox',
96
+ options: options.map(o => o.message),
97
+ default: options.map(o => o.message)
98
+ }
99
+ ];
100
+ const answers = await prompter.prompt(argv, questions);
101
+ const selectedOptions = answers.selectedModules
102
+ .filter(opt => opt.selected)
103
+ .map(opt => opt.name);
104
+ modulesToUpgrade = modulesWithUpdates
105
+ .filter(mod => selectedOptions.includes(`${mod.name} (${mod.currentVersion} -> ${mod.latestVersion})`))
106
+ .map(m => m.name);
107
+ if (modulesToUpgrade.length === 0) {
108
+ log.info(`${prefix}No modules selected for upgrade.`);
109
+ return false;
110
+ }
111
+ }
112
+ log.info(`\n${prefix}Upgrading ${modulesToUpgrade.length} module(s)...`);
113
+ await project.upgradeModules({ modules: modulesToUpgrade });
114
+ log.success(`${prefix}Upgrade complete!`);
115
+ return true;
116
+ }
117
+ exports.default = async (argv, prompter, _options) => {
118
+ if (argv.help || argv.h) {
119
+ console.log(upgradeModulesUsageText);
120
+ process.exit(0);
121
+ }
122
+ const { cwd = process.cwd() } = argv;
123
+ const dryRun = Boolean(argv['dry-run']);
124
+ const upgradeAll = Boolean(argv.all);
125
+ const workspaceMode = Boolean(argv.workspace);
126
+ const specificModules = argv.modules
127
+ ? String(argv.modules).split(',').map(m => m.trim())
128
+ : undefined;
129
+ const project = new core_1.PgpmPackage(cwd);
130
+ if (workspaceMode) {
131
+ if (!project.getWorkspacePath()) {
132
+ throw new Error('You must run this command inside a PGPM workspace when using --workspace.');
133
+ }
134
+ const modules = await project.getModules();
135
+ if (modules.length === 0) {
136
+ log.info('No modules found in the workspace.');
137
+ return;
138
+ }
139
+ log.info(`Found ${modules.length} module(s) in the workspace.\n`);
140
+ let anyUpgraded = false;
141
+ for (const moduleProject of modules) {
142
+ const moduleName = moduleProject.getModuleName();
143
+ const upgraded = await upgradeModulesForProject(moduleProject, argv, prompter, dryRun, upgradeAll, specificModules, moduleName);
144
+ if (upgraded) {
145
+ anyUpgraded = true;
146
+ }
147
+ console.log('');
148
+ }
149
+ if (!anyUpgraded && !dryRun) {
150
+ log.success('All modules across the workspace are already up to date.');
151
+ }
152
+ }
153
+ else {
154
+ if (!project.isInModule()) {
155
+ throw new Error('You must run this command inside a PGPM module. Use --workspace to upgrade all modules in the workspace.');
156
+ }
157
+ await upgradeModulesForProject(project, argv, prompter, dryRun, upgradeAll, specificModules);
158
+ }
159
+ };
package/commands.js CHANGED
@@ -23,6 +23,7 @@ const migrate_1 = __importDefault(require("./commands/migrate"));
23
23
  const package_1 = __importDefault(require("./commands/package"));
24
24
  const plan_1 = __importDefault(require("./commands/plan"));
25
25
  const update_1 = __importDefault(require("./commands/update"));
26
+ const upgrade_modules_1 = __importDefault(require("./commands/upgrade-modules"));
26
27
  const remove_1 = __importDefault(require("./commands/remove"));
27
28
  const rename_1 = __importDefault(require("./commands/rename"));
28
29
  const revert_1 = __importDefault(require("./commands/revert"));
@@ -66,6 +67,7 @@ const createPgpmCommandMap = (skipPgTeardown = false) => {
66
67
  analyze: pgt(analyze_1.default),
67
68
  rename: pgt(rename_1.default),
68
69
  'test-packages': pgt(test_packages_1.default),
70
+ 'upgrade-modules': pgt(upgrade_modules_1.default),
69
71
  cache: cache_1.default,
70
72
  update: update_1.default
71
73
  };
@@ -0,0 +1,157 @@
1
+ import { PgpmPackage } from '@pgpmjs/core';
2
+ import { Logger } from '@pgpmjs/logger';
3
+ import { fetchLatestVersion } from '../utils/npm-version';
4
+ const log = new Logger('upgrade-modules');
5
+ const upgradeModulesUsageText = `
6
+ Upgrade Modules Command:
7
+
8
+ pgpm upgrade-modules [OPTIONS]
9
+
10
+ Upgrade installed pgpm modules to their latest versions from npm.
11
+
12
+ Options:
13
+ --help, -h Show this help message
14
+ --cwd <directory> Working directory (default: current directory)
15
+ --all Upgrade all modules without prompting
16
+ --dry-run Show what would be upgraded without making changes
17
+ --modules <names> Comma-separated list of specific modules to upgrade
18
+ --workspace Upgrade modules across all packages in the workspace
19
+
20
+ Examples:
21
+ pgpm upgrade-modules Interactive selection of modules to upgrade
22
+ pgpm upgrade-modules --all Upgrade all installed modules
23
+ pgpm upgrade-modules --dry-run Preview available upgrades
24
+ pgpm upgrade-modules --modules @pgpm/base32,@pgpm/faker Upgrade specific modules
25
+ pgpm upgrade-modules --workspace --all Upgrade all modules across the entire workspace
26
+ `;
27
+ async function fetchModuleVersions(installedVersions) {
28
+ const moduleNames = Object.keys(installedVersions);
29
+ const results = [];
30
+ for (const name of moduleNames) {
31
+ const currentVersion = installedVersions[name];
32
+ const latestVersion = await fetchLatestVersion(name);
33
+ results.push({
34
+ name,
35
+ currentVersion,
36
+ latestVersion,
37
+ hasUpdate: latestVersion !== null && latestVersion !== currentVersion
38
+ });
39
+ }
40
+ return results;
41
+ }
42
+ async function upgradeModulesForProject(project, argv, prompter, dryRun, upgradeAll, specificModules, moduleName) {
43
+ const { installed, installedVersions } = project.getInstalledModules();
44
+ if (installed.length === 0) {
45
+ if (moduleName) {
46
+ log.info(`[${moduleName}] No pgpm modules are installed.`);
47
+ }
48
+ else {
49
+ log.info('No pgpm modules are installed in this module.');
50
+ }
51
+ return false;
52
+ }
53
+ const prefix = moduleName ? `[${moduleName}] ` : '';
54
+ log.info(`${prefix}Found ${installed.length} installed module(s). Checking for updates...`);
55
+ const moduleVersions = await fetchModuleVersions(installedVersions);
56
+ const modulesWithUpdates = moduleVersions.filter(m => m.hasUpdate);
57
+ if (modulesWithUpdates.length === 0) {
58
+ log.success(`${prefix}All modules are already up to date.`);
59
+ return false;
60
+ }
61
+ log.info(`\n${prefix}${modulesWithUpdates.length} module(s) have updates available:\n`);
62
+ for (const mod of modulesWithUpdates) {
63
+ log.info(` ${mod.name}: ${mod.currentVersion} -> ${mod.latestVersion}`);
64
+ }
65
+ console.log('');
66
+ if (dryRun) {
67
+ log.info(`${prefix}Dry run - no changes made.`);
68
+ return true;
69
+ }
70
+ let modulesToUpgrade;
71
+ if (upgradeAll) {
72
+ modulesToUpgrade = modulesWithUpdates.map(m => m.name);
73
+ }
74
+ else if (specificModules) {
75
+ modulesToUpgrade = modulesWithUpdates
76
+ .filter(m => specificModules.includes(m.name))
77
+ .map(m => m.name);
78
+ if (modulesToUpgrade.length === 0) {
79
+ log.warn(`${prefix}None of the specified modules have updates available.`);
80
+ return false;
81
+ }
82
+ }
83
+ else {
84
+ const options = modulesWithUpdates.map(mod => ({
85
+ name: mod.name,
86
+ value: mod.name,
87
+ message: `${mod.name} (${mod.currentVersion} -> ${mod.latestVersion})`
88
+ }));
89
+ const questions = [
90
+ {
91
+ name: 'selectedModules',
92
+ message: `${prefix}Select modules to upgrade:`,
93
+ type: 'checkbox',
94
+ options: options.map(o => o.message),
95
+ default: options.map(o => o.message)
96
+ }
97
+ ];
98
+ const answers = await prompter.prompt(argv, questions);
99
+ const selectedOptions = answers.selectedModules
100
+ .filter(opt => opt.selected)
101
+ .map(opt => opt.name);
102
+ modulesToUpgrade = modulesWithUpdates
103
+ .filter(mod => selectedOptions.includes(`${mod.name} (${mod.currentVersion} -> ${mod.latestVersion})`))
104
+ .map(m => m.name);
105
+ if (modulesToUpgrade.length === 0) {
106
+ log.info(`${prefix}No modules selected for upgrade.`);
107
+ return false;
108
+ }
109
+ }
110
+ log.info(`\n${prefix}Upgrading ${modulesToUpgrade.length} module(s)...`);
111
+ await project.upgradeModules({ modules: modulesToUpgrade });
112
+ log.success(`${prefix}Upgrade complete!`);
113
+ return true;
114
+ }
115
+ export default async (argv, prompter, _options) => {
116
+ if (argv.help || argv.h) {
117
+ console.log(upgradeModulesUsageText);
118
+ process.exit(0);
119
+ }
120
+ const { cwd = process.cwd() } = argv;
121
+ const dryRun = Boolean(argv['dry-run']);
122
+ const upgradeAll = Boolean(argv.all);
123
+ const workspaceMode = Boolean(argv.workspace);
124
+ const specificModules = argv.modules
125
+ ? String(argv.modules).split(',').map(m => m.trim())
126
+ : undefined;
127
+ const project = new PgpmPackage(cwd);
128
+ if (workspaceMode) {
129
+ if (!project.getWorkspacePath()) {
130
+ throw new Error('You must run this command inside a PGPM workspace when using --workspace.');
131
+ }
132
+ const modules = await project.getModules();
133
+ if (modules.length === 0) {
134
+ log.info('No modules found in the workspace.');
135
+ return;
136
+ }
137
+ log.info(`Found ${modules.length} module(s) in the workspace.\n`);
138
+ let anyUpgraded = false;
139
+ for (const moduleProject of modules) {
140
+ const moduleName = moduleProject.getModuleName();
141
+ const upgraded = await upgradeModulesForProject(moduleProject, argv, prompter, dryRun, upgradeAll, specificModules, moduleName);
142
+ if (upgraded) {
143
+ anyUpgraded = true;
144
+ }
145
+ console.log('');
146
+ }
147
+ if (!anyUpgraded && !dryRun) {
148
+ log.success('All modules across the workspace are already up to date.');
149
+ }
150
+ }
151
+ else {
152
+ if (!project.isInModule()) {
153
+ throw new Error('You must run this command inside a PGPM module. Use --workspace to upgrade all modules in the workspace.');
154
+ }
155
+ await upgradeModulesForProject(project, argv, prompter, dryRun, upgradeAll, specificModules);
156
+ }
157
+ };
package/esm/commands.js CHANGED
@@ -17,6 +17,7 @@ import migrate from './commands/migrate';
17
17
  import _package from './commands/package';
18
18
  import plan from './commands/plan';
19
19
  import updateCmd from './commands/update';
20
+ import upgradeModules from './commands/upgrade-modules';
20
21
  import remove from './commands/remove';
21
22
  import renameCmd from './commands/rename';
22
23
  import revert from './commands/revert';
@@ -60,6 +61,7 @@ export const createPgpmCommandMap = (skipPgTeardown = false) => {
60
61
  analyze: pgt(analyze),
61
62
  rename: pgt(renameCmd),
62
63
  'test-packages': pgt(testPackages),
64
+ 'upgrade-modules': pgt(upgradeModules),
63
65
  cache,
64
66
  update: updateCmd
65
67
  };
package/esm/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { readFileSync } from 'fs';
2
+ import { findAndRequirePackageJson } from 'find-and-require-package-json';
3
3
  import { CLI } from 'inquirerer';
4
- import { join } from 'path';
5
4
  import { commands, createPgpmCommandMap } from './commands';
6
5
  export { createInitUsageText } from './commands/init';
7
6
  export { createPgpmCommandMap };
@@ -38,8 +37,7 @@ export const options = {
38
37
  };
39
38
  if (require.main === module) {
40
39
  if (process.argv.includes('--version') || process.argv.includes('-v')) {
41
- const pkgPath = join(__dirname, 'package.json');
42
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
40
+ const pkg = findAndRequirePackageJson(__dirname);
43
41
  console.log(pkg.version);
44
42
  process.exit(0);
45
43
  }
package/esm/utils/argv.js CHANGED
@@ -1,5 +1,3 @@
1
- import { Logger } from '@pgpmjs/logger';
2
- const log = new Logger('argv-utils');
3
1
  export const extractFirst = (argv) => {
4
2
  const first = argv._?.[0];
5
3
  const newArgv = {
@@ -8,85 +6,3 @@ export const extractFirst = (argv) => {
8
6
  };
9
7
  return { first, newArgv };
10
8
  };
11
- /**
12
- * Validates and normalizes common CLI arguments
13
- */
14
- export function validateCommonArgs(argv) {
15
- const validated = {
16
- ...argv,
17
- cwd: argv.cwd || process.cwd(),
18
- _: argv._ || []
19
- };
20
- const booleanFlags = ['recursive', 'yes', 'tx', 'fast', 'logOnly', 'createdb', 'usePlan', 'cache', 'drop', 'all', 'summary', 'help', 'h'];
21
- for (const flag of booleanFlags) {
22
- if (argv[flag] !== undefined && typeof argv[flag] !== 'boolean') {
23
- log.warn(`--${flag} flag should be boolean, converting to true`);
24
- validated[flag] = true;
25
- }
26
- }
27
- const stringFlags = ['package', 'to', 'database'];
28
- for (const flag of stringFlags) {
29
- if (argv[flag] !== undefined && typeof argv[flag] !== 'string') {
30
- log.warn(`--${flag} should be a string, converting`);
31
- validated[flag] = String(argv[flag]);
32
- }
33
- }
34
- return validated;
35
- }
36
- /**
37
- * Checks if required flags are provided when certain conditions are met
38
- */
39
- export function validateFlagDependencies(argv) {
40
- if (argv.to && !argv.package && !argv.recursive) {
41
- log.warn('--to flag provided without --package or --recursive. Target may not work as expected.');
42
- }
43
- if (argv.package && argv.recursive) {
44
- if (argv.package.includes(':')) {
45
- log.warn('--package should not contain ":" when using --recursive. Use --to for target specification.');
46
- }
47
- }
48
- }
49
- /**
50
- * Logs the effective CLI arguments for debugging
51
- */
52
- export function logEffectiveArgs(argv, commandName) {
53
- const relevantArgs = {
54
- cwd: argv.cwd,
55
- database: argv.database,
56
- package: argv.package,
57
- to: argv.to,
58
- recursive: argv.recursive,
59
- yes: argv.yes,
60
- tx: argv.tx,
61
- fast: argv.fast,
62
- logOnly: argv.logOnly,
63
- createdb: argv.createdb,
64
- usePlan: argv.usePlan,
65
- cache: argv.cache,
66
- drop: argv.drop,
67
- all: argv.all,
68
- summary: argv.summary
69
- };
70
- const definedArgs = Object.fromEntries(Object.entries(relevantArgs).filter(([_, value]) => value !== undefined));
71
- if (Object.keys(definedArgs).length > 1) { // More than just cwd
72
- log.debug(`${commandName} effective arguments:`, definedArgs);
73
- }
74
- }
75
- /**
76
- * Constructs a deployment target string from package and to arguments
77
- */
78
- export function constructTarget(argv, packageName) {
79
- if (packageName && argv.to) {
80
- return `${packageName}:${argv.to}`;
81
- }
82
- else if (packageName) {
83
- return packageName;
84
- }
85
- else if (argv.package && argv.to) {
86
- return `${argv.package}:${argv.to}`;
87
- }
88
- else if (argv.package) {
89
- return argv.package;
90
- }
91
- return undefined;
92
- }
@@ -1,11 +1,3 @@
1
- import { findAndRequirePackageJson } from 'find-and-require-package-json';
2
- import yanse from 'yanse';
3
- // Function to display the version information
4
- export function displayVersion() {
5
- const pkg = findAndRequirePackageJson(__dirname);
6
- console.log(yanse.green(`Name: ${pkg.name}`));
7
- console.log(yanse.blue(`Version: ${pkg.version}`));
8
- }
9
1
  export const usageText = `
10
2
  Usage: pgpm <command> [options]
11
3
 
@@ -55,6 +47,3 @@ export const usageText = `
55
47
  pgpm init workspace Initialize new workspace
56
48
  pgpm install @pgpm/base32 Install a database module
57
49
  `;
58
- export function displayUsage() {
59
- console.log(usageText);
60
- }
package/index.js CHANGED
@@ -19,9 +19,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.options = exports.verify = exports.testPackages = exports.tag = exports.revert = exports.renameCmd = exports.remove = exports.plan = exports._package = exports.migrate = exports.kill = exports.install = exports.extension = exports._export = exports.env = exports.docker = exports.deploy = exports.clear = exports.analyze = exports.adminUsers = exports.add = exports.createPgpmCommandMap = exports.createInitUsageText = void 0;
22
- const fs_1 = require("fs");
22
+ const find_and_require_package_json_1 = require("find-and-require-package-json");
23
23
  const inquirerer_1 = require("inquirerer");
24
- const path_1 = require("path");
25
24
  const commands_1 = require("./commands");
26
25
  Object.defineProperty(exports, "createPgpmCommandMap", { enumerable: true, get: function () { return commands_1.createPgpmCommandMap; } });
27
26
  var init_1 = require("./commands/init");
@@ -79,8 +78,7 @@ exports.options = {
79
78
  };
80
79
  if (require.main === module) {
81
80
  if (process.argv.includes('--version') || process.argv.includes('-v')) {
82
- const pkgPath = (0, path_1.join)(__dirname, 'package.json');
83
- const pkg = JSON.parse((0, fs_1.readFileSync)(pkgPath, 'utf8'));
81
+ const pkg = (0, find_and_require_package_json_1.findAndRequirePackageJson)(__dirname);
84
82
  console.log(pkg.version);
85
83
  process.exit(0);
86
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgpm",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "PostgreSQL Package Manager - Database migration and package management CLI",
6
6
  "main": "index.js",
@@ -45,7 +45,7 @@
45
45
  "ts-node": "^10.9.2"
46
46
  },
47
47
  "dependencies": {
48
- "@pgpmjs/core": "^3.1.4",
48
+ "@pgpmjs/core": "^3.2.0",
49
49
  "@pgpmjs/env": "^2.8.8",
50
50
  "@pgpmjs/logger": "^1.3.5",
51
51
  "@pgpmjs/types": "^2.12.6",
@@ -73,5 +73,5 @@
73
73
  "pg",
74
74
  "pgsql"
75
75
  ],
76
- "gitHead": "fc182ff9e4c4745a3e86eda6d58e3b0061f36564"
76
+ "gitHead": "f041cbb1c54277b1b408af5b44d5a8cae933bae7"
77
77
  }
package/utils/argv.d.ts CHANGED
@@ -6,41 +6,3 @@ export declare const extractFirst: (argv: Partial<ParsedArgs>) => {
6
6
  "--"?: string[] | undefined;
7
7
  };
8
8
  };
9
- /**
10
- * Common CLI argument validation and processing utilities
11
- */
12
- export interface ValidatedArgv extends ParsedArgs {
13
- cwd: string;
14
- database?: string;
15
- package?: string;
16
- to?: string;
17
- recursive?: boolean;
18
- yes?: boolean;
19
- tx?: boolean;
20
- fast?: boolean;
21
- logOnly?: boolean;
22
- createdb?: boolean;
23
- usePlan?: boolean;
24
- cache?: boolean;
25
- drop?: boolean;
26
- all?: boolean;
27
- summary?: boolean;
28
- help?: boolean;
29
- h?: boolean;
30
- }
31
- /**
32
- * Validates and normalizes common CLI arguments
33
- */
34
- export declare function validateCommonArgs(argv: Partial<ParsedArgs>): ValidatedArgv;
35
- /**
36
- * Checks if required flags are provided when certain conditions are met
37
- */
38
- export declare function validateFlagDependencies(argv: ValidatedArgv): void;
39
- /**
40
- * Logs the effective CLI arguments for debugging
41
- */
42
- export declare function logEffectiveArgs(argv: ValidatedArgv, commandName: string): void;
43
- /**
44
- * Constructs a deployment target string from package and to arguments
45
- */
46
- export declare function constructTarget(argv: ValidatedArgv, packageName?: string): string | undefined;
package/utils/argv.js CHANGED
@@ -1,12 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractFirst = void 0;
4
- exports.validateCommonArgs = validateCommonArgs;
5
- exports.validateFlagDependencies = validateFlagDependencies;
6
- exports.logEffectiveArgs = logEffectiveArgs;
7
- exports.constructTarget = constructTarget;
8
- const logger_1 = require("@pgpmjs/logger");
9
- const log = new logger_1.Logger('argv-utils');
10
4
  const extractFirst = (argv) => {
11
5
  const first = argv._?.[0];
12
6
  const newArgv = {
@@ -16,85 +10,3 @@ const extractFirst = (argv) => {
16
10
  return { first, newArgv };
17
11
  };
18
12
  exports.extractFirst = extractFirst;
19
- /**
20
- * Validates and normalizes common CLI arguments
21
- */
22
- function validateCommonArgs(argv) {
23
- const validated = {
24
- ...argv,
25
- cwd: argv.cwd || process.cwd(),
26
- _: argv._ || []
27
- };
28
- const booleanFlags = ['recursive', 'yes', 'tx', 'fast', 'logOnly', 'createdb', 'usePlan', 'cache', 'drop', 'all', 'summary', 'help', 'h'];
29
- for (const flag of booleanFlags) {
30
- if (argv[flag] !== undefined && typeof argv[flag] !== 'boolean') {
31
- log.warn(`--${flag} flag should be boolean, converting to true`);
32
- validated[flag] = true;
33
- }
34
- }
35
- const stringFlags = ['package', 'to', 'database'];
36
- for (const flag of stringFlags) {
37
- if (argv[flag] !== undefined && typeof argv[flag] !== 'string') {
38
- log.warn(`--${flag} should be a string, converting`);
39
- validated[flag] = String(argv[flag]);
40
- }
41
- }
42
- return validated;
43
- }
44
- /**
45
- * Checks if required flags are provided when certain conditions are met
46
- */
47
- function validateFlagDependencies(argv) {
48
- if (argv.to && !argv.package && !argv.recursive) {
49
- log.warn('--to flag provided without --package or --recursive. Target may not work as expected.');
50
- }
51
- if (argv.package && argv.recursive) {
52
- if (argv.package.includes(':')) {
53
- log.warn('--package should not contain ":" when using --recursive. Use --to for target specification.');
54
- }
55
- }
56
- }
57
- /**
58
- * Logs the effective CLI arguments for debugging
59
- */
60
- function logEffectiveArgs(argv, commandName) {
61
- const relevantArgs = {
62
- cwd: argv.cwd,
63
- database: argv.database,
64
- package: argv.package,
65
- to: argv.to,
66
- recursive: argv.recursive,
67
- yes: argv.yes,
68
- tx: argv.tx,
69
- fast: argv.fast,
70
- logOnly: argv.logOnly,
71
- createdb: argv.createdb,
72
- usePlan: argv.usePlan,
73
- cache: argv.cache,
74
- drop: argv.drop,
75
- all: argv.all,
76
- summary: argv.summary
77
- };
78
- const definedArgs = Object.fromEntries(Object.entries(relevantArgs).filter(([_, value]) => value !== undefined));
79
- if (Object.keys(definedArgs).length > 1) { // More than just cwd
80
- log.debug(`${commandName} effective arguments:`, definedArgs);
81
- }
82
- }
83
- /**
84
- * Constructs a deployment target string from package and to arguments
85
- */
86
- function constructTarget(argv, packageName) {
87
- if (packageName && argv.to) {
88
- return `${packageName}:${argv.to}`;
89
- }
90
- else if (packageName) {
91
- return packageName;
92
- }
93
- else if (argv.package && argv.to) {
94
- return `${argv.package}:${argv.to}`;
95
- }
96
- else if (argv.package) {
97
- return argv.package;
98
- }
99
- return undefined;
100
- }
@@ -1,3 +1 @@
1
- export declare function displayVersion(): void;
2
1
  export declare const usageText = "\n Usage: pgpm <command> [options]\n \n Core Database Operations:\n add Add database changes to plans and create SQL files\n deploy Deploy database changes and migrations\n verify Verify database state and migrations\n revert Revert database changes and migrations\n \n Project Management:\n init Initialize workspace or module\n extension Manage module dependencies\n plan Generate module deployment plans\n package Package module for distribution\n export Export database migrations from existing databases\n update Update pgpm to the latest version\n cache Manage cached templates (clean)\n \n Database Administration:\n kill Terminate database connections and optionally drop databases\n install Install database modules\n tag Add tags to changes for versioning\n clear Clear database state\n remove Remove database changes\n analyze Analyze database structure\n rename Rename database changes\n admin-users Manage admin users\n \n Migration Tools:\n migrate Migration management subcommands\n init Initialize migration tracking\n status Show migration status\n list List all changes\n deps Show change dependencies\n \n Global Options:\n -h, --help Display this help information\n -v, --version Display version information\n --cwd <directory> Working directory (default: current directory)\n \n Individual Command Help:\n pgpm <command> --help Display detailed help for specific command\n pgpm <command> -h Display detailed help for specific command\n \n Examples:\n pgpm deploy --help Show deploy command options\n pgpm init workspace Initialize new workspace\n pgpm install @pgpm/base32 Install a database module\n ";
3
- export declare function displayUsage(): void;
package/utils/display.js CHANGED
@@ -1,19 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.usageText = void 0;
7
- exports.displayVersion = displayVersion;
8
- exports.displayUsage = displayUsage;
9
- const find_and_require_package_json_1 = require("find-and-require-package-json");
10
- const yanse_1 = __importDefault(require("yanse"));
11
- // Function to display the version information
12
- function displayVersion() {
13
- const pkg = (0, find_and_require_package_json_1.findAndRequirePackageJson)(__dirname);
14
- console.log(yanse_1.default.green(`Name: ${pkg.name}`));
15
- console.log(yanse_1.default.blue(`Version: ${pkg.version}`));
16
- }
17
4
  exports.usageText = `
18
5
  Usage: pgpm <command> [options]
19
6
 
@@ -63,6 +50,3 @@ exports.usageText = `
63
50
  pgpm init workspace Initialize new workspace
64
51
  pgpm install @pgpm/base32 Install a database module
65
52
  `;
66
- function displayUsage() {
67
- console.log(exports.usageText);
68
- }