pgpm 1.2.0 → 1.2.2
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 +26 -0
- package/commands/upgrade-modules.d.ts +4 -0
- package/commands/upgrade-modules.js +121 -0
- package/commands.js +2 -0
- package/esm/commands/upgrade-modules.js +119 -0
- package/esm/commands.js +2 -0
- package/package.json +4 -4
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,121 @@
|
|
|
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
|
+
|
|
21
|
+
Examples:
|
|
22
|
+
pgpm upgrade-modules Interactive selection of modules to upgrade
|
|
23
|
+
pgpm upgrade-modules --all Upgrade all installed modules
|
|
24
|
+
pgpm upgrade-modules --dry-run Preview available upgrades
|
|
25
|
+
pgpm upgrade-modules --modules @pgpm/base32,@pgpm/faker Upgrade specific modules
|
|
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 (0, npm_version_1.fetchLatestVersion)(name);
|
|
33
|
+
results.push({
|
|
34
|
+
name,
|
|
35
|
+
currentVersion,
|
|
36
|
+
latestVersion,
|
|
37
|
+
hasUpdate: latestVersion !== null && latestVersion !== currentVersion
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return results;
|
|
41
|
+
}
|
|
42
|
+
exports.default = async (argv, prompter, _options) => {
|
|
43
|
+
if (argv.help || argv.h) {
|
|
44
|
+
console.log(upgradeModulesUsageText);
|
|
45
|
+
process.exit(0);
|
|
46
|
+
}
|
|
47
|
+
const { cwd = process.cwd() } = argv;
|
|
48
|
+
const dryRun = Boolean(argv['dry-run']);
|
|
49
|
+
const upgradeAll = Boolean(argv.all);
|
|
50
|
+
const specificModules = argv.modules
|
|
51
|
+
? String(argv.modules).split(',').map(m => m.trim())
|
|
52
|
+
: undefined;
|
|
53
|
+
const project = new core_1.PgpmPackage(cwd);
|
|
54
|
+
if (!project.isInModule()) {
|
|
55
|
+
throw new Error('You must run this command inside a PGPM module.');
|
|
56
|
+
}
|
|
57
|
+
const { installed, installedVersions } = project.getInstalledModules();
|
|
58
|
+
if (installed.length === 0) {
|
|
59
|
+
log.info('No pgpm modules are installed in this module.');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
log.info(`Found ${installed.length} installed module(s). Checking for updates...`);
|
|
63
|
+
const moduleVersions = await fetchModuleVersions(installedVersions);
|
|
64
|
+
const modulesWithUpdates = moduleVersions.filter(m => m.hasUpdate);
|
|
65
|
+
if (modulesWithUpdates.length === 0) {
|
|
66
|
+
log.success('All modules are already up to date.');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
log.info(`\n${modulesWithUpdates.length} module(s) have updates available:\n`);
|
|
70
|
+
for (const mod of modulesWithUpdates) {
|
|
71
|
+
log.info(` ${mod.name}: ${mod.currentVersion} -> ${mod.latestVersion}`);
|
|
72
|
+
}
|
|
73
|
+
console.log('');
|
|
74
|
+
if (dryRun) {
|
|
75
|
+
log.info('Dry run - no changes made.');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let modulesToUpgrade;
|
|
79
|
+
if (upgradeAll) {
|
|
80
|
+
modulesToUpgrade = modulesWithUpdates.map(m => m.name);
|
|
81
|
+
}
|
|
82
|
+
else if (specificModules) {
|
|
83
|
+
modulesToUpgrade = modulesWithUpdates
|
|
84
|
+
.filter(m => specificModules.includes(m.name))
|
|
85
|
+
.map(m => m.name);
|
|
86
|
+
if (modulesToUpgrade.length === 0) {
|
|
87
|
+
log.warn('None of the specified modules have updates available.');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const options = modulesWithUpdates.map(mod => ({
|
|
93
|
+
name: mod.name,
|
|
94
|
+
value: mod.name,
|
|
95
|
+
message: `${mod.name} (${mod.currentVersion} -> ${mod.latestVersion})`
|
|
96
|
+
}));
|
|
97
|
+
const questions = [
|
|
98
|
+
{
|
|
99
|
+
name: 'selectedModules',
|
|
100
|
+
message: 'Select modules to upgrade:',
|
|
101
|
+
type: 'checkbox',
|
|
102
|
+
options: options.map(o => o.message),
|
|
103
|
+
default: options.map(o => o.message)
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
const answers = await prompter.prompt(argv, questions);
|
|
107
|
+
const selectedOptions = answers.selectedModules
|
|
108
|
+
.filter(opt => opt.selected)
|
|
109
|
+
.map(opt => opt.name);
|
|
110
|
+
modulesToUpgrade = modulesWithUpdates
|
|
111
|
+
.filter(mod => selectedOptions.includes(`${mod.name} (${mod.currentVersion} -> ${mod.latestVersion})`))
|
|
112
|
+
.map(m => m.name);
|
|
113
|
+
if (modulesToUpgrade.length === 0) {
|
|
114
|
+
log.info('No modules selected for upgrade.');
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
log.info(`\nUpgrading ${modulesToUpgrade.length} module(s)...`);
|
|
119
|
+
await project.upgradeModules({ modules: modulesToUpgrade });
|
|
120
|
+
log.success('\nUpgrade complete!');
|
|
121
|
+
};
|
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,119 @@
|
|
|
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
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
pgpm upgrade-modules Interactive selection of modules to upgrade
|
|
21
|
+
pgpm upgrade-modules --all Upgrade all installed modules
|
|
22
|
+
pgpm upgrade-modules --dry-run Preview available upgrades
|
|
23
|
+
pgpm upgrade-modules --modules @pgpm/base32,@pgpm/faker Upgrade specific modules
|
|
24
|
+
`;
|
|
25
|
+
async function fetchModuleVersions(installedVersions) {
|
|
26
|
+
const moduleNames = Object.keys(installedVersions);
|
|
27
|
+
const results = [];
|
|
28
|
+
for (const name of moduleNames) {
|
|
29
|
+
const currentVersion = installedVersions[name];
|
|
30
|
+
const latestVersion = await fetchLatestVersion(name);
|
|
31
|
+
results.push({
|
|
32
|
+
name,
|
|
33
|
+
currentVersion,
|
|
34
|
+
latestVersion,
|
|
35
|
+
hasUpdate: latestVersion !== null && latestVersion !== currentVersion
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return results;
|
|
39
|
+
}
|
|
40
|
+
export default async (argv, prompter, _options) => {
|
|
41
|
+
if (argv.help || argv.h) {
|
|
42
|
+
console.log(upgradeModulesUsageText);
|
|
43
|
+
process.exit(0);
|
|
44
|
+
}
|
|
45
|
+
const { cwd = process.cwd() } = argv;
|
|
46
|
+
const dryRun = Boolean(argv['dry-run']);
|
|
47
|
+
const upgradeAll = Boolean(argv.all);
|
|
48
|
+
const specificModules = argv.modules
|
|
49
|
+
? String(argv.modules).split(',').map(m => m.trim())
|
|
50
|
+
: undefined;
|
|
51
|
+
const project = new PgpmPackage(cwd);
|
|
52
|
+
if (!project.isInModule()) {
|
|
53
|
+
throw new Error('You must run this command inside a PGPM module.');
|
|
54
|
+
}
|
|
55
|
+
const { installed, installedVersions } = project.getInstalledModules();
|
|
56
|
+
if (installed.length === 0) {
|
|
57
|
+
log.info('No pgpm modules are installed in this module.');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
log.info(`Found ${installed.length} installed module(s). Checking for updates...`);
|
|
61
|
+
const moduleVersions = await fetchModuleVersions(installedVersions);
|
|
62
|
+
const modulesWithUpdates = moduleVersions.filter(m => m.hasUpdate);
|
|
63
|
+
if (modulesWithUpdates.length === 0) {
|
|
64
|
+
log.success('All modules are already up to date.');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
log.info(`\n${modulesWithUpdates.length} module(s) have updates available:\n`);
|
|
68
|
+
for (const mod of modulesWithUpdates) {
|
|
69
|
+
log.info(` ${mod.name}: ${mod.currentVersion} -> ${mod.latestVersion}`);
|
|
70
|
+
}
|
|
71
|
+
console.log('');
|
|
72
|
+
if (dryRun) {
|
|
73
|
+
log.info('Dry run - no changes made.');
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
let modulesToUpgrade;
|
|
77
|
+
if (upgradeAll) {
|
|
78
|
+
modulesToUpgrade = modulesWithUpdates.map(m => m.name);
|
|
79
|
+
}
|
|
80
|
+
else if (specificModules) {
|
|
81
|
+
modulesToUpgrade = modulesWithUpdates
|
|
82
|
+
.filter(m => specificModules.includes(m.name))
|
|
83
|
+
.map(m => m.name);
|
|
84
|
+
if (modulesToUpgrade.length === 0) {
|
|
85
|
+
log.warn('None of the specified modules have updates available.');
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const options = modulesWithUpdates.map(mod => ({
|
|
91
|
+
name: mod.name,
|
|
92
|
+
value: mod.name,
|
|
93
|
+
message: `${mod.name} (${mod.currentVersion} -> ${mod.latestVersion})`
|
|
94
|
+
}));
|
|
95
|
+
const questions = [
|
|
96
|
+
{
|
|
97
|
+
name: 'selectedModules',
|
|
98
|
+
message: 'Select modules to upgrade:',
|
|
99
|
+
type: 'checkbox',
|
|
100
|
+
options: options.map(o => o.message),
|
|
101
|
+
default: options.map(o => o.message)
|
|
102
|
+
}
|
|
103
|
+
];
|
|
104
|
+
const answers = await prompter.prompt(argv, questions);
|
|
105
|
+
const selectedOptions = answers.selectedModules
|
|
106
|
+
.filter(opt => opt.selected)
|
|
107
|
+
.map(opt => opt.name);
|
|
108
|
+
modulesToUpgrade = modulesWithUpdates
|
|
109
|
+
.filter(mod => selectedOptions.includes(`${mod.name} (${mod.currentVersion} -> ${mod.latestVersion})`))
|
|
110
|
+
.map(m => m.name);
|
|
111
|
+
if (modulesToUpgrade.length === 0) {
|
|
112
|
+
log.info('No modules selected for upgrade.');
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
log.info(`\nUpgrading ${modulesToUpgrade.length} module(s)...`);
|
|
117
|
+
await project.upgradeModules({ modules: modulesToUpgrade });
|
|
118
|
+
log.success('\nUpgrade complete!');
|
|
119
|
+
};
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pgpm",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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.
|
|
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",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"inquirerer": "^2.2.0",
|
|
56
56
|
"js-yaml": "^4.1.0",
|
|
57
57
|
"minimist": "^1.2.8",
|
|
58
|
-
"pg-cache": "^1.6.
|
|
58
|
+
"pg-cache": "^1.6.9",
|
|
59
59
|
"pg-env": "^1.2.4",
|
|
60
60
|
"semver": "^7.6.2",
|
|
61
61
|
"shelljs": "^0.10.0",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"pg",
|
|
74
74
|
"pgsql"
|
|
75
75
|
],
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "8eaef530cad9cfa4f905ad085d5f0475563cf856"
|
|
77
77
|
}
|