pgpm 1.2.2 → 1.4.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 +8 -5
- package/commands/cache.js +1 -4
- package/commands/init/module.js +34 -5
- package/commands/init/workspace.js +26 -9
- package/commands/test-packages.js +8 -10
- package/commands/upgrade-modules.js +68 -30
- package/esm/commands/cache.js +1 -4
- package/esm/commands/init/module.js +31 -5
- package/esm/commands/init/workspace.js +26 -9
- package/esm/commands/test-packages.js +8 -10
- package/esm/commands/upgrade-modules.js +68 -30
- package/esm/index.js +2 -4
- package/esm/utils/argv.js +0 -84
- package/esm/utils/display.js +15 -17
- package/index.js +2 -4
- package/package.json +5 -5
- package/utils/argv.d.ts +0 -38
- package/utils/argv.js +0 -88
- package/utils/display.d.ts +1 -3
- package/utils/display.js +15 -22
package/README.md
CHANGED
|
@@ -256,6 +256,9 @@ pgpm upgrade-modules --dry-run
|
|
|
256
256
|
|
|
257
257
|
# Upgrade specific modules
|
|
258
258
|
pgpm upgrade-modules --modules @pgpm/base32,@pgpm/faker
|
|
259
|
+
|
|
260
|
+
# Upgrade modules across all packages in the workspace
|
|
261
|
+
pgpm upgrade-modules --workspace --all
|
|
259
262
|
```
|
|
260
263
|
|
|
261
264
|
**Options:**
|
|
@@ -263,6 +266,7 @@ pgpm upgrade-modules --modules @pgpm/base32,@pgpm/faker
|
|
|
263
266
|
- `--all` - Upgrade all modules without prompting
|
|
264
267
|
- `--dry-run` - Show what would be upgraded without making changes
|
|
265
268
|
- `--modules <names>` - Comma-separated list of specific modules to upgrade
|
|
269
|
+
- `--workspace` - Upgrade modules across all packages in the workspace
|
|
266
270
|
- `--cwd <directory>` - Working directory (default: current directory)
|
|
267
271
|
|
|
268
272
|
#### `pgpm extension`
|
|
@@ -345,20 +349,20 @@ pgpm test-packages
|
|
|
345
349
|
# Run full deploy/verify/revert/deploy cycle
|
|
346
350
|
pgpm test-packages --full-cycle
|
|
347
351
|
|
|
348
|
-
#
|
|
349
|
-
pgpm test-packages --
|
|
352
|
+
# Continue testing all packages even after failures
|
|
353
|
+
pgpm test-packages --continue-on-fail
|
|
350
354
|
|
|
351
355
|
# Exclude specific modules
|
|
352
356
|
pgpm test-packages --exclude my-module,another-module
|
|
353
357
|
|
|
354
358
|
# Combine options
|
|
355
|
-
pgpm test-packages --full-cycle --
|
|
359
|
+
pgpm test-packages --full-cycle --continue-on-fail --exclude legacy-module
|
|
356
360
|
```
|
|
357
361
|
|
|
358
362
|
**Options:**
|
|
359
363
|
|
|
360
364
|
- `--full-cycle` - Run full deploy/verify/revert/deploy cycle (default: deploy only)
|
|
361
|
-
- `--
|
|
365
|
+
- `--continue-on-fail` - Continue testing all packages even after failures (default: stop on first failure)
|
|
362
366
|
- `--exclude <modules>` - Comma-separated module names to exclude
|
|
363
367
|
- `--cwd <directory>` - Working directory (default: current directory)
|
|
364
368
|
|
|
@@ -457,7 +461,6 @@ Common issues and solutions for pgpm, PostgreSQL, and testing.
|
|
|
457
461
|
* [@pgsql/enums](https://www.npmjs.com/package/@pgsql/enums): **🏷️ TypeScript enums** for PostgreSQL AST for safe and ergonomic parsing logic.
|
|
458
462
|
* [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
|
|
459
463
|
* [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
|
|
460
|
-
* [pg-ast](https://www.npmjs.com/package/pg-ast): **🔍 Low-level AST tools** and transformations for Postgres query structures.
|
|
461
464
|
|
|
462
465
|
### 🚀 API & Dev Tools
|
|
463
466
|
|
package/commands/cache.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const logger_1 = require("@pgpmjs/logger");
|
|
4
3
|
const create_gen_app_1 = require("create-gen-app");
|
|
5
4
|
const cli_error_1 = require("../utils/cli-error");
|
|
6
|
-
const log = new logger_1.Logger('cache');
|
|
7
5
|
const cacheUsageText = `
|
|
8
6
|
Cache Command:
|
|
9
7
|
|
|
@@ -26,7 +24,6 @@ exports.default = async (argv, _prompter, _options) => {
|
|
|
26
24
|
const toolName = argv.tool || 'pgpm';
|
|
27
25
|
const cacheManager = new create_gen_app_1.CacheManager({ toolName });
|
|
28
26
|
cacheManager.clearAll();
|
|
29
|
-
|
|
30
|
-
log.debug(`Cache location: ${cacheManager.getReposDir()}`);
|
|
27
|
+
process.stdout.write(`Cleared template cache for "${toolName}".\n`);
|
|
31
28
|
return argv;
|
|
32
29
|
};
|
package/commands/init/module.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.default = runModuleSetup;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
4
9
|
const core_1 = require("@pgpmjs/core");
|
|
5
|
-
const logger_1 = require("@pgpmjs/logger");
|
|
6
10
|
const types_1 = require("@pgpmjs/types");
|
|
7
|
-
const
|
|
11
|
+
const DEFAULT_MOTD = `
|
|
12
|
+
| _ _
|
|
13
|
+
=== |.===. '\\-//\`
|
|
14
|
+
(o o) {}o o{} (o o)
|
|
15
|
+
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-
|
|
16
|
+
`;
|
|
8
17
|
async function runModuleSetup(argv, prompter) {
|
|
9
18
|
const { cwd = process.cwd() } = argv;
|
|
10
19
|
const project = new core_1.PgpmPackage(cwd);
|
|
11
20
|
if (!project.workspacePath) {
|
|
12
|
-
|
|
21
|
+
process.stderr.write('Not inside a PGPM workspace.\n');
|
|
13
22
|
throw types_1.errors.NOT_IN_WORKSPACE({});
|
|
14
23
|
}
|
|
15
24
|
if (!project.isInsideAllowedDirs(cwd) && !project.isInWorkspace() && !project.isParentOfAllowedDirs(cwd)) {
|
|
16
|
-
|
|
25
|
+
process.stderr.write('You must be inside the workspace root or a parent directory of modules (like packages/).\n');
|
|
17
26
|
throw types_1.errors.NOT_IN_WORKSPACE_MODULE({});
|
|
18
27
|
}
|
|
19
28
|
const availExtensions = project.getAvailableModules();
|
|
@@ -60,6 +69,26 @@ async function runModuleSetup(argv, prompter) {
|
|
|
60
69
|
answers: templateAnswers,
|
|
61
70
|
noTty: Boolean(argv.noTty || argv['no-tty'] || process.env.CI === 'true')
|
|
62
71
|
});
|
|
63
|
-
|
|
72
|
+
const isRoot = path_1.default.resolve(project.getWorkspacePath()) === path_1.default.resolve(cwd);
|
|
73
|
+
const modulePath = isRoot
|
|
74
|
+
? path_1.default.join(cwd, 'packages', modName)
|
|
75
|
+
: path_1.default.join(cwd, modName);
|
|
76
|
+
const motdPath = path_1.default.join(modulePath, '.motd');
|
|
77
|
+
let motd = DEFAULT_MOTD;
|
|
78
|
+
if (fs_1.default.existsSync(motdPath)) {
|
|
79
|
+
try {
|
|
80
|
+
motd = fs_1.default.readFileSync(motdPath, 'utf8');
|
|
81
|
+
fs_1.default.unlinkSync(motdPath);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Ignore errors reading/deleting .motd
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
process.stdout.write(motd);
|
|
88
|
+
if (!motd.endsWith('\n')) {
|
|
89
|
+
process.stdout.write('\n');
|
|
90
|
+
}
|
|
91
|
+
const relPath = isRoot ? `packages/${modName}` : modName;
|
|
92
|
+
process.stdout.write(`\n✨ Enjoy!\n\ncd ./${relPath}\n`);
|
|
64
93
|
return { ...argv, ...answers };
|
|
65
94
|
}
|
|
@@ -4,11 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = runWorkspaceSetup;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
7
9
|
const core_1 = require("@pgpmjs/core");
|
|
8
|
-
const logger_1 = require("@pgpmjs/logger");
|
|
9
10
|
const inquirerer_1 = require("inquirerer");
|
|
10
|
-
const
|
|
11
|
-
|
|
11
|
+
const DEFAULT_MOTD = `
|
|
12
|
+
| _ _
|
|
13
|
+
=== |.===. '\\-//\`
|
|
14
|
+
(o o) {}o o{} (o o)
|
|
15
|
+
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-
|
|
16
|
+
`;
|
|
12
17
|
async function runWorkspaceSetup(argv, prompter) {
|
|
13
18
|
const workspaceQuestions = [
|
|
14
19
|
{
|
|
@@ -30,7 +35,7 @@ async function runWorkspaceSetup(argv, prompter) {
|
|
|
30
35
|
// This provides the intended workspace directory name before the folder is created
|
|
31
36
|
const dirName = path_1.default.basename(targetPath);
|
|
32
37
|
(0, inquirerer_1.registerDefaultResolver)('workspace.dirname', () => dirName);
|
|
33
|
-
|
|
38
|
+
await (0, core_1.scaffoldTemplate)({
|
|
34
39
|
type: 'workspace',
|
|
35
40
|
outputDir: targetPath,
|
|
36
41
|
templateRepo,
|
|
@@ -45,10 +50,22 @@ async function runWorkspaceSetup(argv, prompter) {
|
|
|
45
50
|
noTty: Boolean(argv.noTty || argv['no-tty'] || process.env.CI === 'true'),
|
|
46
51
|
cwd
|
|
47
52
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
// Check for .motd file and print it, or use default ASCII art
|
|
54
|
+
const motdPath = path_1.default.join(targetPath, '.motd');
|
|
55
|
+
let motd = DEFAULT_MOTD;
|
|
56
|
+
if (fs_1.default.existsSync(motdPath)) {
|
|
57
|
+
try {
|
|
58
|
+
motd = fs_1.default.readFileSync(motdPath, 'utf8');
|
|
59
|
+
fs_1.default.unlinkSync(motdPath);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Ignore errors reading/deleting .motd
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
process.stdout.write(motd);
|
|
66
|
+
if (!motd.endsWith('\n')) {
|
|
67
|
+
process.stdout.write('\n');
|
|
68
|
+
}
|
|
69
|
+
process.stdout.write(`\n✨ Enjoy!\n\ncd ./${dirName}\n`);
|
|
53
70
|
return { ...argv, ...answers, cwd: targetPath };
|
|
54
71
|
}
|
|
@@ -26,14 +26,14 @@ Test Packages Command:
|
|
|
26
26
|
Options:
|
|
27
27
|
--help, -h Show this help message
|
|
28
28
|
--exclude <pkgs> Comma-separated module names to exclude
|
|
29
|
-
--
|
|
29
|
+
--continue-on-fail Continue testing all packages even after failures
|
|
30
30
|
--full-cycle Run full deploy/verify/revert/deploy cycle (default: deploy only)
|
|
31
31
|
--cwd <directory> Working directory (default: current directory)
|
|
32
32
|
|
|
33
33
|
Examples:
|
|
34
|
-
pgpm test-packages Test all packages
|
|
34
|
+
pgpm test-packages Test all packages (stops on first failure)
|
|
35
35
|
pgpm test-packages --full-cycle Run full test cycle with verify/revert
|
|
36
|
-
pgpm test-packages --
|
|
36
|
+
pgpm test-packages --continue-on-fail Test all packages, collect all failures
|
|
37
37
|
pgpm test-packages --exclude my-module Exclude specific modules
|
|
38
38
|
`;
|
|
39
39
|
function dbSafeName(moduleName) {
|
|
@@ -205,8 +205,9 @@ exports.default = async (argv, _prompter, _options) => {
|
|
|
205
205
|
console.log(testPackagesUsageText);
|
|
206
206
|
process.exit(0);
|
|
207
207
|
}
|
|
208
|
-
// Parse options
|
|
209
|
-
const
|
|
208
|
+
// Parse options (stopOnFail defaults to true, use --continue-on-fail to disable)
|
|
209
|
+
const continueOnFail = argv['continue-on-fail'] === true || argv.continueOnFail === true;
|
|
210
|
+
const stopOnFail = !continueOnFail;
|
|
210
211
|
const fullCycle = argv['full-cycle'] === true || argv.fullCycle === true;
|
|
211
212
|
const cwd = argv.cwd || process.cwd();
|
|
212
213
|
// Parse excludes
|
|
@@ -216,10 +217,7 @@ exports.default = async (argv, _prompter, _options) => {
|
|
|
216
217
|
}
|
|
217
218
|
console.log('=== PGPM Package Integration Test ===');
|
|
218
219
|
console.log(`Testing all packages with ${fullCycle ? 'deploy/verify/revert/deploy cycle' : 'deploy only'}`);
|
|
219
|
-
if (stopOnFail) {
|
|
220
|
-
console.log('Mode: Stop on first failure');
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
220
|
+
if (!stopOnFail) {
|
|
223
221
|
console.log('Mode: Test all packages (collect all failures)');
|
|
224
222
|
}
|
|
225
223
|
console.log('');
|
|
@@ -273,7 +271,7 @@ exports.default = async (argv, _prompter, _options) => {
|
|
|
273
271
|
failedPackages.push(result);
|
|
274
272
|
if (stopOnFail) {
|
|
275
273
|
console.log('');
|
|
276
|
-
console.error(`${RED}STOPPING: Test failed for module ${result.moduleName}
|
|
274
|
+
console.error(`${RED}STOPPING: Test failed for module ${result.moduleName}${NC}`);
|
|
277
275
|
console.log('');
|
|
278
276
|
console.log('=== TEST SUMMARY (PARTIAL) ===');
|
|
279
277
|
if (successfulPackages.length > 0) {
|
|
@@ -17,12 +17,14 @@ Options:
|
|
|
17
17
|
--all Upgrade all modules without prompting
|
|
18
18
|
--dry-run Show what would be upgraded without making changes
|
|
19
19
|
--modules <names> Comma-separated list of specific modules to upgrade
|
|
20
|
+
--workspace Upgrade modules across all packages in the workspace
|
|
20
21
|
|
|
21
22
|
Examples:
|
|
22
23
|
pgpm upgrade-modules Interactive selection of modules to upgrade
|
|
23
24
|
pgpm upgrade-modules --all Upgrade all installed modules
|
|
24
25
|
pgpm upgrade-modules --dry-run Preview available upgrades
|
|
25
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
|
|
26
28
|
`;
|
|
27
29
|
async function fetchModuleVersions(installedVersions) {
|
|
28
30
|
const moduleNames = Object.keys(installedVersions);
|
|
@@ -39,41 +41,33 @@ async function fetchModuleVersions(installedVersions) {
|
|
|
39
41
|
}
|
|
40
42
|
return results;
|
|
41
43
|
}
|
|
42
|
-
|
|
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
|
-
}
|
|
44
|
+
async function upgradeModulesForProject(project, argv, prompter, dryRun, upgradeAll, specificModules, moduleName) {
|
|
57
45
|
const { installed, installedVersions } = project.getInstalledModules();
|
|
58
46
|
if (installed.length === 0) {
|
|
59
|
-
|
|
60
|
-
|
|
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;
|
|
61
54
|
}
|
|
62
|
-
|
|
55
|
+
const prefix = moduleName ? `[${moduleName}] ` : '';
|
|
56
|
+
log.info(`${prefix}Found ${installed.length} installed module(s). Checking for updates...`);
|
|
63
57
|
const moduleVersions = await fetchModuleVersions(installedVersions);
|
|
64
58
|
const modulesWithUpdates = moduleVersions.filter(m => m.hasUpdate);
|
|
65
59
|
if (modulesWithUpdates.length === 0) {
|
|
66
|
-
log.success(
|
|
67
|
-
return;
|
|
60
|
+
log.success(`${prefix}All modules are already up to date.`);
|
|
61
|
+
return false;
|
|
68
62
|
}
|
|
69
|
-
log.info(`\n${modulesWithUpdates.length} module(s) have updates available:\n`);
|
|
63
|
+
log.info(`\n${prefix}${modulesWithUpdates.length} module(s) have updates available:\n`);
|
|
70
64
|
for (const mod of modulesWithUpdates) {
|
|
71
65
|
log.info(` ${mod.name}: ${mod.currentVersion} -> ${mod.latestVersion}`);
|
|
72
66
|
}
|
|
73
67
|
console.log('');
|
|
74
68
|
if (dryRun) {
|
|
75
|
-
log.info(
|
|
76
|
-
return;
|
|
69
|
+
log.info(`${prefix}Dry run - no changes made.`);
|
|
70
|
+
return true;
|
|
77
71
|
}
|
|
78
72
|
let modulesToUpgrade;
|
|
79
73
|
if (upgradeAll) {
|
|
@@ -84,8 +78,8 @@ exports.default = async (argv, prompter, _options) => {
|
|
|
84
78
|
.filter(m => specificModules.includes(m.name))
|
|
85
79
|
.map(m => m.name);
|
|
86
80
|
if (modulesToUpgrade.length === 0) {
|
|
87
|
-
log.warn(
|
|
88
|
-
return;
|
|
81
|
+
log.warn(`${prefix}None of the specified modules have updates available.`);
|
|
82
|
+
return false;
|
|
89
83
|
}
|
|
90
84
|
}
|
|
91
85
|
else {
|
|
@@ -97,7 +91,7 @@ exports.default = async (argv, prompter, _options) => {
|
|
|
97
91
|
const questions = [
|
|
98
92
|
{
|
|
99
93
|
name: 'selectedModules',
|
|
100
|
-
message:
|
|
94
|
+
message: `${prefix}Select modules to upgrade:`,
|
|
101
95
|
type: 'checkbox',
|
|
102
96
|
options: options.map(o => o.message),
|
|
103
97
|
default: options.map(o => o.message)
|
|
@@ -111,11 +105,55 @@ exports.default = async (argv, prompter, _options) => {
|
|
|
111
105
|
.filter(mod => selectedOptions.includes(`${mod.name} (${mod.currentVersion} -> ${mod.latestVersion})`))
|
|
112
106
|
.map(m => m.name);
|
|
113
107
|
if (modulesToUpgrade.length === 0) {
|
|
114
|
-
log.info(
|
|
115
|
-
return;
|
|
108
|
+
log.info(`${prefix}No modules selected for upgrade.`);
|
|
109
|
+
return false;
|
|
116
110
|
}
|
|
117
111
|
}
|
|
118
|
-
log.info(`\
|
|
112
|
+
log.info(`\n${prefix}Upgrading ${modulesToUpgrade.length} module(s)...`);
|
|
119
113
|
await project.upgradeModules({ modules: modulesToUpgrade });
|
|
120
|
-
log.success(
|
|
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
|
+
}
|
|
121
159
|
};
|
package/esm/commands/cache.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Logger } from '@pgpmjs/logger';
|
|
2
1
|
import { CacheManager } from 'create-gen-app';
|
|
3
2
|
import { cliExitWithError } from '../utils/cli-error';
|
|
4
|
-
const log = new Logger('cache');
|
|
5
3
|
const cacheUsageText = `
|
|
6
4
|
Cache Command:
|
|
7
5
|
|
|
@@ -24,7 +22,6 @@ export default async (argv, _prompter, _options) => {
|
|
|
24
22
|
const toolName = argv.tool || 'pgpm';
|
|
25
23
|
const cacheManager = new CacheManager({ toolName });
|
|
26
24
|
cacheManager.clearAll();
|
|
27
|
-
|
|
28
|
-
log.debug(`Cache location: ${cacheManager.getReposDir()}`);
|
|
25
|
+
process.stdout.write(`Cleared template cache for "${toolName}".\n`);
|
|
29
26
|
return argv;
|
|
30
27
|
};
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
1
3
|
import { DEFAULT_TEMPLATE_REPO, DEFAULT_TEMPLATE_TOOL_NAME, PgpmPackage, sluggify } from '@pgpmjs/core';
|
|
2
|
-
import { Logger } from '@pgpmjs/logger';
|
|
3
4
|
import { errors } from '@pgpmjs/types';
|
|
4
|
-
const
|
|
5
|
+
const DEFAULT_MOTD = `
|
|
6
|
+
| _ _
|
|
7
|
+
=== |.===. '\\-//\`
|
|
8
|
+
(o o) {}o o{} (o o)
|
|
9
|
+
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-
|
|
10
|
+
`;
|
|
5
11
|
export default async function runModuleSetup(argv, prompter) {
|
|
6
12
|
const { cwd = process.cwd() } = argv;
|
|
7
13
|
const project = new PgpmPackage(cwd);
|
|
8
14
|
if (!project.workspacePath) {
|
|
9
|
-
|
|
15
|
+
process.stderr.write('Not inside a PGPM workspace.\n');
|
|
10
16
|
throw errors.NOT_IN_WORKSPACE({});
|
|
11
17
|
}
|
|
12
18
|
if (!project.isInsideAllowedDirs(cwd) && !project.isInWorkspace() && !project.isParentOfAllowedDirs(cwd)) {
|
|
13
|
-
|
|
19
|
+
process.stderr.write('You must be inside the workspace root or a parent directory of modules (like packages/).\n');
|
|
14
20
|
throw errors.NOT_IN_WORKSPACE_MODULE({});
|
|
15
21
|
}
|
|
16
22
|
const availExtensions = project.getAvailableModules();
|
|
@@ -57,6 +63,26 @@ export default async function runModuleSetup(argv, prompter) {
|
|
|
57
63
|
answers: templateAnswers,
|
|
58
64
|
noTty: Boolean(argv.noTty || argv['no-tty'] || process.env.CI === 'true')
|
|
59
65
|
});
|
|
60
|
-
|
|
66
|
+
const isRoot = path.resolve(project.getWorkspacePath()) === path.resolve(cwd);
|
|
67
|
+
const modulePath = isRoot
|
|
68
|
+
? path.join(cwd, 'packages', modName)
|
|
69
|
+
: path.join(cwd, modName);
|
|
70
|
+
const motdPath = path.join(modulePath, '.motd');
|
|
71
|
+
let motd = DEFAULT_MOTD;
|
|
72
|
+
if (fs.existsSync(motdPath)) {
|
|
73
|
+
try {
|
|
74
|
+
motd = fs.readFileSync(motdPath, 'utf8');
|
|
75
|
+
fs.unlinkSync(motdPath);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Ignore errors reading/deleting .motd
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
process.stdout.write(motd);
|
|
82
|
+
if (!motd.endsWith('\n')) {
|
|
83
|
+
process.stdout.write('\n');
|
|
84
|
+
}
|
|
85
|
+
const relPath = isRoot ? `packages/${modName}` : modName;
|
|
86
|
+
process.stdout.write(`\n✨ Enjoy!\n\ncd ./${relPath}\n`);
|
|
61
87
|
return { ...argv, ...answers };
|
|
62
88
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
1
3
|
import { DEFAULT_TEMPLATE_REPO, DEFAULT_TEMPLATE_TOOL_NAME, scaffoldTemplate, sluggify } from '@pgpmjs/core';
|
|
2
|
-
import { Logger } from '@pgpmjs/logger';
|
|
3
4
|
import { registerDefaultResolver } from 'inquirerer';
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
const DEFAULT_MOTD = `
|
|
6
|
+
| _ _
|
|
7
|
+
=== |.===. '\\-//\`
|
|
8
|
+
(o o) {}o o{} (o o)
|
|
9
|
+
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-
|
|
10
|
+
`;
|
|
6
11
|
export default async function runWorkspaceSetup(argv, prompter) {
|
|
7
12
|
const workspaceQuestions = [
|
|
8
13
|
{
|
|
@@ -24,7 +29,7 @@ export default async function runWorkspaceSetup(argv, prompter) {
|
|
|
24
29
|
// This provides the intended workspace directory name before the folder is created
|
|
25
30
|
const dirName = path.basename(targetPath);
|
|
26
31
|
registerDefaultResolver('workspace.dirname', () => dirName);
|
|
27
|
-
|
|
32
|
+
await scaffoldTemplate({
|
|
28
33
|
type: 'workspace',
|
|
29
34
|
outputDir: targetPath,
|
|
30
35
|
templateRepo,
|
|
@@ -39,10 +44,22 @@ export default async function runWorkspaceSetup(argv, prompter) {
|
|
|
39
44
|
noTty: Boolean(argv.noTty || argv['no-tty'] || process.env.CI === 'true'),
|
|
40
45
|
cwd
|
|
41
46
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
// Check for .motd file and print it, or use default ASCII art
|
|
48
|
+
const motdPath = path.join(targetPath, '.motd');
|
|
49
|
+
let motd = DEFAULT_MOTD;
|
|
50
|
+
if (fs.existsSync(motdPath)) {
|
|
51
|
+
try {
|
|
52
|
+
motd = fs.readFileSync(motdPath, 'utf8');
|
|
53
|
+
fs.unlinkSync(motdPath);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Ignore errors reading/deleting .motd
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
process.stdout.write(motd);
|
|
60
|
+
if (!motd.endsWith('\n')) {
|
|
61
|
+
process.stdout.write('\n');
|
|
62
|
+
}
|
|
63
|
+
process.stdout.write(`\n✨ Enjoy!\n\ncd ./${dirName}\n`);
|
|
47
64
|
return { ...argv, ...answers, cwd: targetPath };
|
|
48
65
|
}
|
|
@@ -21,14 +21,14 @@ Test Packages Command:
|
|
|
21
21
|
Options:
|
|
22
22
|
--help, -h Show this help message
|
|
23
23
|
--exclude <pkgs> Comma-separated module names to exclude
|
|
24
|
-
--
|
|
24
|
+
--continue-on-fail Continue testing all packages even after failures
|
|
25
25
|
--full-cycle Run full deploy/verify/revert/deploy cycle (default: deploy only)
|
|
26
26
|
--cwd <directory> Working directory (default: current directory)
|
|
27
27
|
|
|
28
28
|
Examples:
|
|
29
|
-
pgpm test-packages Test all packages
|
|
29
|
+
pgpm test-packages Test all packages (stops on first failure)
|
|
30
30
|
pgpm test-packages --full-cycle Run full test cycle with verify/revert
|
|
31
|
-
pgpm test-packages --
|
|
31
|
+
pgpm test-packages --continue-on-fail Test all packages, collect all failures
|
|
32
32
|
pgpm test-packages --exclude my-module Exclude specific modules
|
|
33
33
|
`;
|
|
34
34
|
function dbSafeName(moduleName) {
|
|
@@ -200,8 +200,9 @@ export default async (argv, _prompter, _options) => {
|
|
|
200
200
|
console.log(testPackagesUsageText);
|
|
201
201
|
process.exit(0);
|
|
202
202
|
}
|
|
203
|
-
// Parse options
|
|
204
|
-
const
|
|
203
|
+
// Parse options (stopOnFail defaults to true, use --continue-on-fail to disable)
|
|
204
|
+
const continueOnFail = argv['continue-on-fail'] === true || argv.continueOnFail === true;
|
|
205
|
+
const stopOnFail = !continueOnFail;
|
|
205
206
|
const fullCycle = argv['full-cycle'] === true || argv.fullCycle === true;
|
|
206
207
|
const cwd = argv.cwd || process.cwd();
|
|
207
208
|
// Parse excludes
|
|
@@ -211,10 +212,7 @@ export default async (argv, _prompter, _options) => {
|
|
|
211
212
|
}
|
|
212
213
|
console.log('=== PGPM Package Integration Test ===');
|
|
213
214
|
console.log(`Testing all packages with ${fullCycle ? 'deploy/verify/revert/deploy cycle' : 'deploy only'}`);
|
|
214
|
-
if (stopOnFail) {
|
|
215
|
-
console.log('Mode: Stop on first failure');
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
215
|
+
if (!stopOnFail) {
|
|
218
216
|
console.log('Mode: Test all packages (collect all failures)');
|
|
219
217
|
}
|
|
220
218
|
console.log('');
|
|
@@ -268,7 +266,7 @@ export default async (argv, _prompter, _options) => {
|
|
|
268
266
|
failedPackages.push(result);
|
|
269
267
|
if (stopOnFail) {
|
|
270
268
|
console.log('');
|
|
271
|
-
console.error(`${RED}STOPPING: Test failed for module ${result.moduleName}
|
|
269
|
+
console.error(`${RED}STOPPING: Test failed for module ${result.moduleName}${NC}`);
|
|
272
270
|
console.log('');
|
|
273
271
|
console.log('=== TEST SUMMARY (PARTIAL) ===');
|
|
274
272
|
if (successfulPackages.length > 0) {
|
|
@@ -15,12 +15,14 @@ Options:
|
|
|
15
15
|
--all Upgrade all modules without prompting
|
|
16
16
|
--dry-run Show what would be upgraded without making changes
|
|
17
17
|
--modules <names> Comma-separated list of specific modules to upgrade
|
|
18
|
+
--workspace Upgrade modules across all packages in the workspace
|
|
18
19
|
|
|
19
20
|
Examples:
|
|
20
21
|
pgpm upgrade-modules Interactive selection of modules to upgrade
|
|
21
22
|
pgpm upgrade-modules --all Upgrade all installed modules
|
|
22
23
|
pgpm upgrade-modules --dry-run Preview available upgrades
|
|
23
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
|
|
24
26
|
`;
|
|
25
27
|
async function fetchModuleVersions(installedVersions) {
|
|
26
28
|
const moduleNames = Object.keys(installedVersions);
|
|
@@ -37,41 +39,33 @@ async function fetchModuleVersions(installedVersions) {
|
|
|
37
39
|
}
|
|
38
40
|
return results;
|
|
39
41
|
}
|
|
40
|
-
|
|
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
|
-
}
|
|
42
|
+
async function upgradeModulesForProject(project, argv, prompter, dryRun, upgradeAll, specificModules, moduleName) {
|
|
55
43
|
const { installed, installedVersions } = project.getInstalledModules();
|
|
56
44
|
if (installed.length === 0) {
|
|
57
|
-
|
|
58
|
-
|
|
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;
|
|
59
52
|
}
|
|
60
|
-
|
|
53
|
+
const prefix = moduleName ? `[${moduleName}] ` : '';
|
|
54
|
+
log.info(`${prefix}Found ${installed.length} installed module(s). Checking for updates...`);
|
|
61
55
|
const moduleVersions = await fetchModuleVersions(installedVersions);
|
|
62
56
|
const modulesWithUpdates = moduleVersions.filter(m => m.hasUpdate);
|
|
63
57
|
if (modulesWithUpdates.length === 0) {
|
|
64
|
-
log.success(
|
|
65
|
-
return;
|
|
58
|
+
log.success(`${prefix}All modules are already up to date.`);
|
|
59
|
+
return false;
|
|
66
60
|
}
|
|
67
|
-
log.info(`\n${modulesWithUpdates.length} module(s) have updates available:\n`);
|
|
61
|
+
log.info(`\n${prefix}${modulesWithUpdates.length} module(s) have updates available:\n`);
|
|
68
62
|
for (const mod of modulesWithUpdates) {
|
|
69
63
|
log.info(` ${mod.name}: ${mod.currentVersion} -> ${mod.latestVersion}`);
|
|
70
64
|
}
|
|
71
65
|
console.log('');
|
|
72
66
|
if (dryRun) {
|
|
73
|
-
log.info(
|
|
74
|
-
return;
|
|
67
|
+
log.info(`${prefix}Dry run - no changes made.`);
|
|
68
|
+
return true;
|
|
75
69
|
}
|
|
76
70
|
let modulesToUpgrade;
|
|
77
71
|
if (upgradeAll) {
|
|
@@ -82,8 +76,8 @@ export default async (argv, prompter, _options) => {
|
|
|
82
76
|
.filter(m => specificModules.includes(m.name))
|
|
83
77
|
.map(m => m.name);
|
|
84
78
|
if (modulesToUpgrade.length === 0) {
|
|
85
|
-
log.warn(
|
|
86
|
-
return;
|
|
79
|
+
log.warn(`${prefix}None of the specified modules have updates available.`);
|
|
80
|
+
return false;
|
|
87
81
|
}
|
|
88
82
|
}
|
|
89
83
|
else {
|
|
@@ -95,7 +89,7 @@ export default async (argv, prompter, _options) => {
|
|
|
95
89
|
const questions = [
|
|
96
90
|
{
|
|
97
91
|
name: 'selectedModules',
|
|
98
|
-
message:
|
|
92
|
+
message: `${prefix}Select modules to upgrade:`,
|
|
99
93
|
type: 'checkbox',
|
|
100
94
|
options: options.map(o => o.message),
|
|
101
95
|
default: options.map(o => o.message)
|
|
@@ -109,11 +103,55 @@ export default async (argv, prompter, _options) => {
|
|
|
109
103
|
.filter(mod => selectedOptions.includes(`${mod.name} (${mod.currentVersion} -> ${mod.latestVersion})`))
|
|
110
104
|
.map(m => m.name);
|
|
111
105
|
if (modulesToUpgrade.length === 0) {
|
|
112
|
-
log.info(
|
|
113
|
-
return;
|
|
106
|
+
log.info(`${prefix}No modules selected for upgrade.`);
|
|
107
|
+
return false;
|
|
114
108
|
}
|
|
115
109
|
}
|
|
116
|
-
log.info(`\
|
|
110
|
+
log.info(`\n${prefix}Upgrading ${modulesToUpgrade.length} module(s)...`);
|
|
117
111
|
await project.upgradeModules({ modules: modulesToUpgrade });
|
|
118
|
-
log.success(
|
|
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
|
+
}
|
|
119
157
|
};
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
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
|
|
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
|
-
}
|
package/esm/utils/display.js
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
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
|
+
|
|
12
4
|
Core Database Operations:
|
|
13
5
|
add Add database changes to plans and create SQL files
|
|
14
6
|
deploy Deploy database changes and migrations
|
|
15
7
|
verify Verify database state and migrations
|
|
16
8
|
revert Revert database changes and migrations
|
|
17
|
-
|
|
9
|
+
|
|
18
10
|
Project Management:
|
|
19
11
|
init Initialize workspace or module
|
|
20
12
|
extension Manage module dependencies
|
|
@@ -23,7 +15,8 @@ export const usageText = `
|
|
|
23
15
|
export Export database migrations from existing databases
|
|
24
16
|
update Update pgpm to the latest version
|
|
25
17
|
cache Manage cached templates (clean)
|
|
26
|
-
|
|
18
|
+
upgrade-modules Upgrade installed pgpm modules to latest versions
|
|
19
|
+
|
|
27
20
|
Database Administration:
|
|
28
21
|
kill Terminate database connections and optionally drop databases
|
|
29
22
|
install Install database modules
|
|
@@ -33,7 +26,10 @@ export const usageText = `
|
|
|
33
26
|
analyze Analyze database structure
|
|
34
27
|
rename Rename database changes
|
|
35
28
|
admin-users Manage admin users
|
|
36
|
-
|
|
29
|
+
|
|
30
|
+
Testing:
|
|
31
|
+
test-packages Run integration tests on all workspace packages
|
|
32
|
+
|
|
37
33
|
Migration Tools:
|
|
38
34
|
migrate Migration management subcommands
|
|
39
35
|
init Initialize migration tracking
|
|
@@ -41,20 +37,22 @@ export const usageText = `
|
|
|
41
37
|
list List all changes
|
|
42
38
|
deps Show change dependencies
|
|
43
39
|
|
|
40
|
+
Development Tools:
|
|
41
|
+
docker Manage PostgreSQL Docker containers (start/stop)
|
|
42
|
+
env Manage PostgreSQL environment variables
|
|
43
|
+
test-packages Run integration tests on workspace packages
|
|
44
|
+
|
|
44
45
|
Global Options:
|
|
45
46
|
-h, --help Display this help information
|
|
46
47
|
-v, --version Display version information
|
|
47
48
|
--cwd <directory> Working directory (default: current directory)
|
|
48
|
-
|
|
49
|
+
|
|
49
50
|
Individual Command Help:
|
|
50
51
|
pgpm <command> --help Display detailed help for specific command
|
|
51
52
|
pgpm <command> -h Display detailed help for specific command
|
|
52
|
-
|
|
53
|
+
|
|
53
54
|
Examples:
|
|
54
55
|
pgpm deploy --help Show deploy command options
|
|
55
56
|
pgpm init workspace Initialize new workspace
|
|
56
57
|
pgpm install @pgpm/base32 Install a database module
|
|
57
58
|
`;
|
|
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
|
|
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
|
|
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.
|
|
3
|
+
"version": "1.4.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,14 +45,14 @@
|
|
|
45
45
|
"ts-node": "^10.9.2"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@pgpmjs/core": "^3.2.
|
|
48
|
+
"@pgpmjs/core": "^3.2.1",
|
|
49
49
|
"@pgpmjs/env": "^2.8.8",
|
|
50
50
|
"@pgpmjs/logger": "^1.3.5",
|
|
51
51
|
"@pgpmjs/types": "^2.12.6",
|
|
52
52
|
"appstash": "^0.2.6",
|
|
53
|
-
"create-gen-app": "^0.6.
|
|
53
|
+
"create-gen-app": "^0.6.2",
|
|
54
54
|
"find-and-require-package-json": "^0.8.2",
|
|
55
|
-
"inquirerer": "^2.
|
|
55
|
+
"inquirerer": "^2.3.0",
|
|
56
56
|
"js-yaml": "^4.1.0",
|
|
57
57
|
"minimist": "^1.2.8",
|
|
58
58
|
"pg-cache": "^1.6.9",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"pg",
|
|
74
74
|
"pgsql"
|
|
75
75
|
],
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "976cc9e0e09201c7df40518a1797f4178fc21c2c"
|
|
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
|
-
}
|
package/utils/display.d.ts
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
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;
|
|
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 upgrade-modules Upgrade installed pgpm modules to latest versions\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 Testing:\n test-packages Run integration tests on all workspace packages\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 Development Tools:\n docker Manage PostgreSQL Docker containers (start/stop)\n env Manage PostgreSQL environment variables\n test-packages Run integration tests on workspace packages\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 ";
|
package/utils/display.js
CHANGED
|
@@ -1,28 +1,15 @@
|
|
|
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
|
+
|
|
20
7
|
Core Database Operations:
|
|
21
8
|
add Add database changes to plans and create SQL files
|
|
22
9
|
deploy Deploy database changes and migrations
|
|
23
10
|
verify Verify database state and migrations
|
|
24
11
|
revert Revert database changes and migrations
|
|
25
|
-
|
|
12
|
+
|
|
26
13
|
Project Management:
|
|
27
14
|
init Initialize workspace or module
|
|
28
15
|
extension Manage module dependencies
|
|
@@ -31,7 +18,8 @@ exports.usageText = `
|
|
|
31
18
|
export Export database migrations from existing databases
|
|
32
19
|
update Update pgpm to the latest version
|
|
33
20
|
cache Manage cached templates (clean)
|
|
34
|
-
|
|
21
|
+
upgrade-modules Upgrade installed pgpm modules to latest versions
|
|
22
|
+
|
|
35
23
|
Database Administration:
|
|
36
24
|
kill Terminate database connections and optionally drop databases
|
|
37
25
|
install Install database modules
|
|
@@ -41,7 +29,10 @@ exports.usageText = `
|
|
|
41
29
|
analyze Analyze database structure
|
|
42
30
|
rename Rename database changes
|
|
43
31
|
admin-users Manage admin users
|
|
44
|
-
|
|
32
|
+
|
|
33
|
+
Testing:
|
|
34
|
+
test-packages Run integration tests on all workspace packages
|
|
35
|
+
|
|
45
36
|
Migration Tools:
|
|
46
37
|
migrate Migration management subcommands
|
|
47
38
|
init Initialize migration tracking
|
|
@@ -49,20 +40,22 @@ exports.usageText = `
|
|
|
49
40
|
list List all changes
|
|
50
41
|
deps Show change dependencies
|
|
51
42
|
|
|
43
|
+
Development Tools:
|
|
44
|
+
docker Manage PostgreSQL Docker containers (start/stop)
|
|
45
|
+
env Manage PostgreSQL environment variables
|
|
46
|
+
test-packages Run integration tests on workspace packages
|
|
47
|
+
|
|
52
48
|
Global Options:
|
|
53
49
|
-h, --help Display this help information
|
|
54
50
|
-v, --version Display version information
|
|
55
51
|
--cwd <directory> Working directory (default: current directory)
|
|
56
|
-
|
|
52
|
+
|
|
57
53
|
Individual Command Help:
|
|
58
54
|
pgpm <command> --help Display detailed help for specific command
|
|
59
55
|
pgpm <command> -h Display detailed help for specific command
|
|
60
|
-
|
|
56
|
+
|
|
61
57
|
Examples:
|
|
62
58
|
pgpm deploy --help Show deploy command options
|
|
63
59
|
pgpm init workspace Initialize new workspace
|
|
64
60
|
pgpm install @pgpm/base32 Install a database module
|
|
65
61
|
`;
|
|
66
|
-
function displayUsage() {
|
|
67
|
-
console.log(exports.usageText);
|
|
68
|
-
}
|