pgpm 0.0.1 → 0.1.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/LICENSE +23 -0
- package/README.md +111 -116
- package/commands/add.js +7 -7
- package/commands/admin-users/add.js +8 -8
- package/commands/admin-users/bootstrap.js +7 -7
- package/commands/admin-users/remove.js +7 -7
- package/commands/admin-users.js +5 -5
- package/commands/analyze.js +1 -1
- package/commands/clear.js +3 -3
- package/commands/deploy.js +7 -7
- package/commands/export.js +4 -4
- package/commands/extension.js +3 -3
- package/commands/init/index.js +8 -8
- package/commands/install.js +6 -6
- package/commands/kill.js +6 -6
- package/commands/migrate/init.js +1 -1
- package/commands/migrate.js +1 -1
- package/commands/package.js +4 -4
- package/commands/plan.js +5 -5
- package/commands/remove.js +2 -2
- package/commands/rename.js +1 -1
- package/commands/revert.js +7 -7
- package/commands/tag.js +6 -6
- package/commands/verify.js +7 -7
- package/commands.d.ts +1 -0
- package/commands.js +7 -16
- package/esm/commands/add.js +7 -7
- package/esm/commands/admin-users/add.js +8 -8
- package/esm/commands/admin-users/bootstrap.js +7 -7
- package/esm/commands/admin-users/remove.js +7 -7
- package/esm/commands/admin-users.js +5 -5
- package/esm/commands/analyze.js +1 -1
- package/esm/commands/clear.js +3 -3
- package/esm/commands/deploy.js +7 -7
- package/esm/commands/export.js +4 -4
- package/esm/commands/extension.js +3 -3
- package/esm/commands/init/index.js +8 -8
- package/esm/commands/init/workspace.js +1 -1
- package/esm/commands/install.js +6 -6
- package/esm/commands/kill.js +6 -6
- package/esm/commands/migrate/init.js +1 -1
- package/esm/commands/migrate.js +1 -1
- package/esm/commands/package.js +4 -4
- package/esm/commands/plan.js +5 -5
- package/esm/commands/remove.js +2 -2
- package/esm/commands/rename.js +1 -1
- package/esm/commands/revert.js +7 -7
- package/esm/commands/tag.js +6 -6
- package/esm/commands/verify.js +7 -7
- package/esm/commands.js +5 -15
- package/esm/index.js +36 -10
- package/esm/utils/cli-error.js +1 -1
- package/esm/utils/display.js +13 -13
- package/esm/utils/index.js +3 -0
- package/index.d.ts +20 -0
- package/index.js +70 -10
- package/package.json +15 -18
- package/utils/cli-error.js +1 -1
- package/utils/display.d.ts +1 -1
- package/utils/display.js +13 -13
- package/utils/index.d.ts +3 -0
- package/utils/index.js +3 -0
- package/commands/explorer.d.ts +0 -3
- package/commands/explorer.js +0 -94
- package/commands/server.d.ts +0 -3
- package/commands/server.js +0 -187
- package/dist/README.md +0 -416
- package/dist/package.json +0 -77
- package/esm/commands/explorer.js +0 -92
- package/esm/commands/server.js +0 -185
|
@@ -8,11 +8,11 @@ const subcommandMap = {
|
|
|
8
8
|
remove
|
|
9
9
|
};
|
|
10
10
|
const adminUsersUsageText = `
|
|
11
|
-
|
|
11
|
+
Admin Users Commands:
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
pgpm admin-users bootstrap Initialize postgres roles and permissions (must be run first)
|
|
14
|
+
pgpm admin-users add Add database users with roles
|
|
15
|
+
pgpm admin-users remove Remove database users and revoke roles
|
|
16
16
|
|
|
17
17
|
Options:
|
|
18
18
|
--help, -h Show this help message
|
|
@@ -55,7 +55,7 @@ export default async (argv, prompter, options) => {
|
|
|
55
55
|
};
|
|
56
56
|
function getSubcommandDescription(cmd) {
|
|
57
57
|
const descriptions = {
|
|
58
|
-
bootstrap: 'Initialize
|
|
58
|
+
bootstrap: 'Initialize postgres roles and permissions (must be run first)',
|
|
59
59
|
add: 'Add database users with roles',
|
|
60
60
|
remove: 'Remove database users and revoke roles'
|
|
61
61
|
};
|
package/esm/commands/analyze.js
CHANGED
package/esm/commands/clear.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LaunchQLPackage } from '@launchql/core';
|
|
2
|
-
import { Logger } from '@launchql/logger';
|
|
3
|
-
import { getEnvOptions } from '@launchql/env';
|
|
4
|
-
import { getPgEnvOptions } from 'pg-env';
|
|
5
2
|
import { parsePlanFile } from '@launchql/core';
|
|
3
|
+
import { getEnvOptions } from '@launchql/env';
|
|
4
|
+
import { Logger } from '@launchql/logger';
|
|
6
5
|
import { errors } from '@launchql/types';
|
|
7
6
|
import path from 'path';
|
|
7
|
+
import { getPgEnvOptions } from 'pg-env';
|
|
8
8
|
import { getTargetDatabase } from '../utils';
|
|
9
9
|
const log = new Logger('clear');
|
|
10
10
|
export default async (argv, prompter, _options) => {
|
package/esm/commands/deploy.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { LaunchQLPackage } from '@launchql/core';
|
|
2
|
-
import { Logger } from '@launchql/logger';
|
|
3
2
|
import { getEnvOptions } from '@launchql/env';
|
|
3
|
+
import { Logger } from '@launchql/logger';
|
|
4
4
|
import { execSync } from 'child_process';
|
|
5
5
|
import { getPgEnvOptions, getSpawnEnvWithPg, } from 'pg-env';
|
|
6
6
|
import { getTargetDatabase } from '../utils';
|
|
7
7
|
import { selectPackage } from '../utils/module-utils';
|
|
8
8
|
const deployUsageText = `
|
|
9
|
-
|
|
9
|
+
Deploy Command:
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
pgpm deploy [OPTIONS]
|
|
12
12
|
|
|
13
13
|
Deploy database changes and migrations to target database.
|
|
14
14
|
|
|
@@ -26,10 +26,10 @@ Options:
|
|
|
26
26
|
--cwd <directory> Working directory (default: current directory)
|
|
27
27
|
|
|
28
28
|
Examples:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
pgpm deploy Deploy to selected database
|
|
30
|
+
pgpm deploy --createdb Deploy with database creation
|
|
31
|
+
pgpm deploy --package mypackage --to @v1.0.0 Deploy specific package to tag
|
|
32
|
+
pgpm deploy --fast --no-tx Fast deployment without transactions
|
|
33
33
|
`;
|
|
34
34
|
export default async (argv, prompter, _options) => {
|
|
35
35
|
// Show usage if explicitly requested
|
package/esm/commands/export.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { exportMigrations, LaunchQLPackage } from '@launchql/core';
|
|
2
|
-
import { getGitConfigInfo } from '@launchql/types';
|
|
3
2
|
import { getEnvOptions } from '@launchql/env';
|
|
3
|
+
import { getGitConfigInfo } from '@launchql/types';
|
|
4
4
|
import { resolve } from 'path';
|
|
5
5
|
import { getPgPool } from 'pg-cache';
|
|
6
6
|
const exportUsageText = `
|
|
7
|
-
|
|
7
|
+
Export Command:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
pgpm export [OPTIONS]
|
|
10
10
|
|
|
11
11
|
Export database migrations from existing databases.
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ Options:
|
|
|
18
18
|
--cwd <directory> Working directory (default: current directory)
|
|
19
19
|
|
|
20
20
|
Examples:
|
|
21
|
-
|
|
21
|
+
pgpm export Export migrations from selected database
|
|
22
22
|
`;
|
|
23
23
|
export default async (argv, prompter, _options) => {
|
|
24
24
|
// Show usage if explicitly requested
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LaunchQLPackage } from '@launchql/core';
|
|
2
2
|
const extensionUsageText = `
|
|
3
|
-
|
|
3
|
+
Extension Command:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
pgpm extension [OPTIONS]
|
|
6
6
|
|
|
7
7
|
Manage module dependencies.
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ Options:
|
|
|
11
11
|
--cwd <directory> Working directory (default: current directory)
|
|
12
12
|
|
|
13
13
|
Examples:
|
|
14
|
-
|
|
14
|
+
pgpm extension Manage dependencies for current module
|
|
15
15
|
`;
|
|
16
16
|
export default async (argv, prompter, _options) => {
|
|
17
17
|
// Show usage if explicitly requested
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import runModuleSetup from './module';
|
|
2
2
|
import runWorkspaceSetup from './workspace';
|
|
3
3
|
const initUsageText = `
|
|
4
|
-
|
|
4
|
+
Init Command:
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
pgpm init [OPTIONS]
|
|
7
7
|
|
|
8
|
-
Initialize
|
|
8
|
+
Initialize pgpm workspace or module.
|
|
9
9
|
|
|
10
10
|
Options:
|
|
11
11
|
--help, -h Show this help message
|
|
@@ -16,11 +16,11 @@ Options:
|
|
|
16
16
|
--from-branch <branch> Specify branch when using --repo (default: main)
|
|
17
17
|
|
|
18
18
|
Examples:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
pgpm init Initialize new module in existing workspace
|
|
20
|
+
pgpm init --workspace Initialize new workspace
|
|
21
|
+
pgpm init --repo owner/repo Use templates from GitHub repository
|
|
22
|
+
pgpm init --template-path ./custom-templates Use templates from local path
|
|
23
|
+
pgpm init --repo owner/repo --from-branch develop Use specific branch
|
|
24
24
|
`;
|
|
25
25
|
export default async (argv, prompter, _options) => {
|
|
26
26
|
// Show usage if explicitly requested
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sluggify } from '@launchql/core';
|
|
2
2
|
import { Logger } from '@launchql/logger';
|
|
3
3
|
// @ts-ignore - TypeScript module resolution issue with @launchql/templatizer
|
|
4
|
-
import { workspaceTemplate, writeRenderedTemplates
|
|
4
|
+
import { loadTemplates, workspaceTemplate, writeRenderedTemplates } from '@launchql/templatizer';
|
|
5
5
|
import { mkdirSync } from 'fs';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
const log = new Logger('workspace-init');
|
package/esm/commands/install.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { LaunchQLPackage } from '@launchql/core';
|
|
2
2
|
const installUsageText = `
|
|
3
|
-
|
|
3
|
+
Install Command:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
pgpm install <package>...
|
|
6
6
|
|
|
7
|
-
Install
|
|
7
|
+
Install pgpm modules into current module.
|
|
8
8
|
|
|
9
9
|
Arguments:
|
|
10
10
|
package One or more package names to install
|
|
@@ -14,8 +14,8 @@ Options:
|
|
|
14
14
|
--cwd <directory> Working directory (default: current directory)
|
|
15
15
|
|
|
16
16
|
Examples:
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
pgpm install @pgpm/base32 Install single package
|
|
18
|
+
pgpm install @pgpm/base32 @pgpm/utils Install multiple packages
|
|
19
19
|
`;
|
|
20
20
|
export default async (argv, prompter, _options) => {
|
|
21
21
|
// Show usage if explicitly requested
|
|
@@ -29,7 +29,7 @@ export default async (argv, prompter, _options) => {
|
|
|
29
29
|
throw new Error('You must run this command inside a LaunchQL module.');
|
|
30
30
|
}
|
|
31
31
|
if (argv._.length === 0) {
|
|
32
|
-
throw new Error('You must provide a package name to install, e.g. `@
|
|
32
|
+
throw new Error('You must provide a package name to install, e.g. `@pgpm/base32`');
|
|
33
33
|
}
|
|
34
34
|
await project.installModules(...argv._);
|
|
35
35
|
};
|
package/esm/commands/kill.js
CHANGED
|
@@ -2,9 +2,9 @@ import { Logger } from '@launchql/logger';
|
|
|
2
2
|
import { getPgPool } from 'pg-cache';
|
|
3
3
|
const log = new Logger('db-kill');
|
|
4
4
|
const killUsageText = `
|
|
5
|
-
|
|
5
|
+
Kill Command:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
pgpm kill [OPTIONS]
|
|
8
8
|
|
|
9
9
|
Terminate database connections and optionally drop databases.
|
|
10
10
|
|
|
@@ -16,10 +16,10 @@ Options:
|
|
|
16
16
|
--cwd <directory> Working directory (default: current directory)
|
|
17
17
|
|
|
18
18
|
Examples:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
pgpm kill Kill connections and drop selected databases (interactive)
|
|
20
|
+
pgpm kill --no-drop Only kill connections, preserve databases (interactive)
|
|
21
|
+
pgpm kill --pattern test_% Kill connections to databases matching 'test_%' pattern
|
|
22
|
+
pgpm kill --pattern %dev --no-drop Kill connections to databases ending with 'dev' but don't drop
|
|
23
23
|
`;
|
|
24
24
|
export default async (argv, prompter, _options) => {
|
|
25
25
|
// Show usage if explicitly requested
|
|
@@ -13,7 +13,7 @@ export default async (argv, prompter, _options) => {
|
|
|
13
13
|
{
|
|
14
14
|
name: 'yes',
|
|
15
15
|
type: 'confirm',
|
|
16
|
-
message: `Initialize
|
|
16
|
+
message: `Initialize pgpm migration schema in database "${database}"?`,
|
|
17
17
|
required: true
|
|
18
18
|
}
|
|
19
19
|
];
|
package/esm/commands/migrate.js
CHANGED
package/esm/commands/package.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LaunchQLPackage, writePackage } from '@launchql/core';
|
|
2
2
|
const packageUsageText = `
|
|
3
|
-
|
|
3
|
+
Package Command:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
pgpm package [OPTIONS]
|
|
6
6
|
|
|
7
7
|
Package module for distribution.
|
|
8
8
|
|
|
@@ -14,8 +14,8 @@ Options:
|
|
|
14
14
|
--cwd <directory> Working directory (default: current directory)
|
|
15
15
|
|
|
16
16
|
Examples:
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
pgpm package Package with defaults
|
|
18
|
+
pgpm package --no-plan Package without plan
|
|
19
19
|
`;
|
|
20
20
|
export default async (argv, prompter, _options) => {
|
|
21
21
|
// Show usage if explicitly requested
|
package/esm/commands/plan.js
CHANGED
|
@@ -2,9 +2,9 @@ import { LaunchQLPackage } from '@launchql/core';
|
|
|
2
2
|
import { Logger } from '@launchql/logger';
|
|
3
3
|
const log = new Logger('plan');
|
|
4
4
|
const planUsageText = `
|
|
5
|
-
|
|
5
|
+
Plan Command:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
pgpm plan [OPTIONS]
|
|
8
8
|
|
|
9
9
|
Generate module deployment plans.
|
|
10
10
|
|
|
@@ -15,9 +15,9 @@ Options:
|
|
|
15
15
|
--cwd <directory> Working directory (default: current directory)
|
|
16
16
|
|
|
17
17
|
Examples:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
pgpm plan Generate deployment plan for current module with defaults
|
|
19
|
+
pgpm plan --includePackages false Disable including external packages
|
|
20
|
+
pgpm plan --includeTags false Do not prefer tags for external packages
|
|
21
21
|
`;
|
|
22
22
|
export default async (argv, prompter, _options) => {
|
|
23
23
|
// Show usage if explicitly requested
|
package/esm/commands/remove.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { LaunchQLPackage } from '@launchql/core';
|
|
2
|
-
import { Logger } from '@launchql/logger';
|
|
3
2
|
import { getEnvOptions } from '@launchql/env';
|
|
3
|
+
import { Logger } from '@launchql/logger';
|
|
4
4
|
import { getPgEnvOptions } from 'pg-env';
|
|
5
5
|
import { getTargetDatabase } from '../utils';
|
|
6
6
|
import { cliExitWithError } from '../utils/cli-error';
|
|
7
7
|
const log = new Logger('remove');
|
|
8
8
|
export default async (argv, prompter, _options) => {
|
|
9
9
|
if (!argv.to) {
|
|
10
|
-
await cliExitWithError('No change specified. Usage:
|
|
10
|
+
await cliExitWithError('No change specified. Usage: pgpm remove --to <change>');
|
|
11
11
|
}
|
|
12
12
|
const database = await getTargetDatabase(argv, prompter, {
|
|
13
13
|
message: 'Select database'
|
package/esm/commands/rename.js
CHANGED
package/esm/commands/revert.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { LaunchQLPackage } from '@launchql/core';
|
|
2
|
-
import { Logger } from '@launchql/logger';
|
|
3
2
|
import { getEnvOptions } from '@launchql/env';
|
|
3
|
+
import { Logger } from '@launchql/logger';
|
|
4
4
|
import { getPgEnvOptions } from 'pg-env';
|
|
5
5
|
import { getTargetDatabase } from '../utils';
|
|
6
|
-
import { selectDeployedChange, selectDeployedPackage } from '../utils/deployed-changes';
|
|
7
6
|
import { cliExitWithError } from '../utils/cli-error';
|
|
7
|
+
import { selectDeployedChange, selectDeployedPackage } from '../utils/deployed-changes';
|
|
8
8
|
const log = new Logger('revert');
|
|
9
9
|
const revertUsageText = `
|
|
10
|
-
|
|
10
|
+
Revert Command:
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
pgpm revert [OPTIONS]
|
|
13
13
|
|
|
14
14
|
Revert database changes and migrations.
|
|
15
15
|
|
|
@@ -23,9 +23,9 @@ Options:
|
|
|
23
23
|
--cwd <directory> Working directory (default: current directory)
|
|
24
24
|
|
|
25
25
|
Examples:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
pgpm revert Revert latest changes
|
|
27
|
+
pgpm revert --to @v1.0.0 Revert to specific tag
|
|
28
|
+
pgpm revert --to Interactive selection from deployed changes
|
|
29
29
|
`;
|
|
30
30
|
export default async (argv, prompter, _options) => {
|
|
31
31
|
// Show usage if explicitly requested
|
package/esm/commands/tag.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { LaunchQLPackage } from '@launchql/core';
|
|
2
2
|
import { Logger } from '@launchql/logger';
|
|
3
3
|
import { errors } from '@launchql/types';
|
|
4
|
+
import * as path from 'path';
|
|
4
5
|
import { extractFirst } from '../utils/argv';
|
|
5
6
|
import { selectPackage } from '../utils/module-utils';
|
|
6
|
-
import * as path from 'path';
|
|
7
7
|
const log = new Logger('tag');
|
|
8
8
|
const tagUsageText = `
|
|
9
|
-
|
|
9
|
+
Tag Command:
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
pgpm tag [tag_name] [OPTIONS]
|
|
12
12
|
|
|
13
13
|
Add tags to changes for versioning.
|
|
14
14
|
|
|
@@ -23,9 +23,9 @@ Options:
|
|
|
23
23
|
--cwd <directory> Working directory (default: current directory)
|
|
24
24
|
|
|
25
25
|
Examples:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
pgpm tag v1.0.0 Add tag to latest change
|
|
27
|
+
pgpm tag v1.0.0 --comment "Initial release" Add tag with comment
|
|
28
|
+
pgpm tag v1.1.0 --package mypackage --changeName my-change Tag specific change in package
|
|
29
29
|
`;
|
|
30
30
|
export default async (argv, prompter, _options) => {
|
|
31
31
|
// Show usage if explicitly requested
|
package/esm/commands/verify.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { LaunchQLPackage } from '@launchql/core';
|
|
2
|
-
import { Logger } from '@launchql/logger';
|
|
3
2
|
import { getEnvOptions } from '@launchql/env';
|
|
3
|
+
import { Logger } from '@launchql/logger';
|
|
4
4
|
import { getPgEnvOptions } from 'pg-env';
|
|
5
5
|
import { getTargetDatabase } from '../utils';
|
|
6
|
-
import { selectDeployedChange, selectDeployedPackage } from '../utils/deployed-changes';
|
|
7
6
|
import { cliExitWithError } from '../utils/cli-error';
|
|
7
|
+
import { selectDeployedChange, selectDeployedPackage } from '../utils/deployed-changes';
|
|
8
8
|
const log = new Logger('verify');
|
|
9
9
|
const verifyUsageText = `
|
|
10
|
-
|
|
10
|
+
Verify Command:
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
pgpm verify [OPTIONS]
|
|
13
13
|
|
|
14
14
|
Verify database state matches expected migrations.
|
|
15
15
|
|
|
@@ -22,9 +22,9 @@ Options:
|
|
|
22
22
|
--cwd <directory> Working directory (default: current directory)
|
|
23
23
|
|
|
24
24
|
Examples:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
pgpm verify Verify current database state
|
|
26
|
+
pgpm verify --package mypackage Verify specific package
|
|
27
|
+
pgpm verify --to Interactive selection from deployed changes
|
|
28
28
|
`;
|
|
29
29
|
export default async (argv, prompter, _options) => {
|
|
30
30
|
// Show usage if explicitly requested
|
package/esm/commands.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { teardownPgPools } from 'pg-cache';
|
|
2
|
-
// Commands
|
|
3
2
|
import add from './commands/add';
|
|
4
3
|
import adminUsers from './commands/admin-users';
|
|
4
|
+
import analyze from './commands/analyze';
|
|
5
5
|
import clear from './commands/clear';
|
|
6
6
|
import deploy from './commands/deploy';
|
|
7
|
-
import explorer from './commands/explorer';
|
|
8
7
|
import _export from './commands/export';
|
|
9
8
|
import extension from './commands/extension';
|
|
10
9
|
import init from './commands/init';
|
|
@@ -14,12 +13,10 @@ import migrate from './commands/migrate';
|
|
|
14
13
|
import _package from './commands/package';
|
|
15
14
|
import plan from './commands/plan';
|
|
16
15
|
import remove from './commands/remove';
|
|
16
|
+
import renameCmd from './commands/rename';
|
|
17
17
|
import revert from './commands/revert';
|
|
18
|
-
import server from './commands/server';
|
|
19
18
|
import tag from './commands/tag';
|
|
20
19
|
import verify from './commands/verify';
|
|
21
|
-
import analyze from './commands/analyze';
|
|
22
|
-
import renameCmd from './commands/rename';
|
|
23
20
|
import { readAndParsePackageJson } from './package';
|
|
24
21
|
import { extractFirst, usageText } from './utils';
|
|
25
22
|
import { cliExitWithError } from './utils/cli-error';
|
|
@@ -33,7 +30,7 @@ const withPgTeardown = (fn, skipTeardown = false) => async (...args) => {
|
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
};
|
|
36
|
-
const
|
|
33
|
+
export const createPgpmCommandMap = (skipPgTeardown = false) => {
|
|
37
34
|
const pgt = (fn) => withPgTeardown(fn, skipPgTeardown);
|
|
38
35
|
return {
|
|
39
36
|
add,
|
|
@@ -53,10 +50,7 @@ const createCommandMap = (skipPgTeardown = false) => {
|
|
|
53
50
|
install: pgt(install),
|
|
54
51
|
migrate: pgt(migrate),
|
|
55
52
|
analyze: pgt(analyze),
|
|
56
|
-
rename: pgt(renameCmd)
|
|
57
|
-
// These manage their own connection lifecycles
|
|
58
|
-
server,
|
|
59
|
-
explorer
|
|
53
|
+
rename: pgt(renameCmd)
|
|
60
54
|
};
|
|
61
55
|
};
|
|
62
56
|
export const commands = async (argv, prompter, options) => {
|
|
@@ -66,18 +60,15 @@ export const commands = async (argv, prompter, options) => {
|
|
|
66
60
|
process.exit(0);
|
|
67
61
|
}
|
|
68
62
|
let { first: command, newArgv } = extractFirst(argv);
|
|
69
|
-
// Show usage if explicitly requested but no command specified
|
|
70
63
|
if ((argv.help || argv.h || command === 'help') && !command) {
|
|
71
64
|
console.log(usageText);
|
|
72
65
|
process.exit(0);
|
|
73
66
|
}
|
|
74
|
-
// Show usage for help command specifically
|
|
75
67
|
if (command === 'help') {
|
|
76
68
|
console.log(usageText);
|
|
77
69
|
process.exit(0);
|
|
78
70
|
}
|
|
79
|
-
const commandMap =
|
|
80
|
-
// Prompt if no command provided
|
|
71
|
+
const commandMap = createPgpmCommandMap(options?.skipPgTeardown);
|
|
81
72
|
if (!command) {
|
|
82
73
|
const answer = await prompter.prompt(argv, [
|
|
83
74
|
{
|
|
@@ -89,7 +80,6 @@ export const commands = async (argv, prompter, options) => {
|
|
|
89
80
|
]);
|
|
90
81
|
command = answer.command;
|
|
91
82
|
}
|
|
92
|
-
// Prompt for working directory
|
|
93
83
|
newArgv = await prompter.prompt(newArgv, [
|
|
94
84
|
{
|
|
95
85
|
type: 'text',
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
2
3
|
import { CLI } from 'inquirerer';
|
|
3
|
-
import {
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { commands, createPgpmCommandMap } from './commands';
|
|
6
|
+
export { createPgpmCommandMap };
|
|
7
|
+
export { default as add } from './commands/add';
|
|
8
|
+
export { default as adminUsers } from './commands/admin-users';
|
|
9
|
+
export { default as analyze } from './commands/analyze';
|
|
10
|
+
export { default as clear } from './commands/clear';
|
|
11
|
+
export { default as deploy } from './commands/deploy';
|
|
12
|
+
export { default as _export } from './commands/export';
|
|
13
|
+
export { default as extension } from './commands/extension';
|
|
14
|
+
export { default as install } from './commands/install';
|
|
15
|
+
export { default as kill } from './commands/kill';
|
|
16
|
+
export { default as migrate } from './commands/migrate';
|
|
17
|
+
export { default as _package } from './commands/package';
|
|
18
|
+
export { default as plan } from './commands/plan';
|
|
19
|
+
export { default as remove } from './commands/remove';
|
|
20
|
+
export { default as renameCmd } from './commands/rename';
|
|
21
|
+
export { default as revert } from './commands/revert';
|
|
22
|
+
export { default as tag } from './commands/tag';
|
|
23
|
+
export { default as verify } from './commands/verify';
|
|
24
|
+
export * from './utils';
|
|
4
25
|
export const options = {
|
|
5
26
|
minimistOpts: {
|
|
6
27
|
alias: {
|
|
@@ -9,12 +30,17 @@ export const options = {
|
|
|
9
30
|
}
|
|
10
31
|
}
|
|
11
32
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
if (require.main === module) {
|
|
34
|
+
if (process.argv.includes('--version') || process.argv.includes('-v')) {
|
|
35
|
+
const pkgPath = join(__dirname, 'package.json');
|
|
36
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
37
|
+
console.log(pkg.version);
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
const app = new CLI(commands, options);
|
|
41
|
+
app.run().then(() => {
|
|
42
|
+
}).catch(error => {
|
|
43
|
+
console.error('Unexpected error:', error);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
});
|
|
46
|
+
}
|
package/esm/utils/cli-error.js
CHANGED
package/esm/utils/display.js
CHANGED
|
@@ -7,8 +7,7 @@ export function displayVersion() {
|
|
|
7
7
|
console.log(chalk.blue(`Version: ${pkg.version}`));
|
|
8
8
|
}
|
|
9
9
|
export const usageText = `
|
|
10
|
-
Usage:
|
|
11
|
-
launchql <command> [options]
|
|
10
|
+
Usage: pgpm <command> [options]
|
|
12
11
|
|
|
13
12
|
Core Database Operations:
|
|
14
13
|
add Add database changes to plans and create SQL files
|
|
@@ -17,20 +16,21 @@ export const usageText = `
|
|
|
17
16
|
revert Revert database changes and migrations
|
|
18
17
|
|
|
19
18
|
Project Management:
|
|
20
|
-
init Initialize
|
|
19
|
+
init Initialize workspace or module
|
|
21
20
|
extension Manage module dependencies
|
|
22
21
|
plan Generate module deployment plans
|
|
23
22
|
package Package module for distribution
|
|
24
|
-
|
|
25
|
-
Development Tools:
|
|
26
|
-
server Start LaunchQL GraphQL server
|
|
27
|
-
explorer Launch GraphiQL explorer interface
|
|
28
23
|
export Export database migrations from existing databases
|
|
29
24
|
|
|
30
25
|
Database Administration:
|
|
31
26
|
kill Terminate database connections and optionally drop databases
|
|
32
|
-
install Install
|
|
27
|
+
install Install database modules
|
|
33
28
|
tag Add tags to changes for versioning
|
|
29
|
+
clear Clear database state
|
|
30
|
+
remove Remove database changes
|
|
31
|
+
analyze Analyze database structure
|
|
32
|
+
rename Rename database changes
|
|
33
|
+
admin-users Manage admin users
|
|
34
34
|
|
|
35
35
|
Migration Tools:
|
|
36
36
|
migrate Migration management subcommands
|
|
@@ -45,13 +45,13 @@ export const usageText = `
|
|
|
45
45
|
--cwd <directory> Working directory (default: current directory)
|
|
46
46
|
|
|
47
47
|
Individual Command Help:
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
pgpm <command> --help Display detailed help for specific command
|
|
49
|
+
pgpm <command> -h Display detailed help for specific command
|
|
50
50
|
|
|
51
51
|
Examples:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
pgpm deploy --help Show deploy command options
|
|
53
|
+
pgpm init --workspace Initialize new workspace
|
|
54
|
+
pgpm install @pgpm/base32 Install a database module
|
|
55
55
|
`;
|
|
56
56
|
export function displayUsage() {
|
|
57
57
|
console.log(usageText);
|
package/esm/utils/index.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { CLIOptions } from 'inquirerer';
|
|
3
|
+
import { createPgpmCommandMap } from './commands';
|
|
4
|
+
export { createPgpmCommandMap };
|
|
5
|
+
export { default as add } from './commands/add';
|
|
6
|
+
export { default as adminUsers } from './commands/admin-users';
|
|
7
|
+
export { default as analyze } from './commands/analyze';
|
|
8
|
+
export { default as clear } from './commands/clear';
|
|
9
|
+
export { default as deploy } from './commands/deploy';
|
|
10
|
+
export { default as _export } from './commands/export';
|
|
11
|
+
export { default as extension } from './commands/extension';
|
|
12
|
+
export { default as install } from './commands/install';
|
|
13
|
+
export { default as kill } from './commands/kill';
|
|
14
|
+
export { default as migrate } from './commands/migrate';
|
|
15
|
+
export { default as _package } from './commands/package';
|
|
16
|
+
export { default as plan } from './commands/plan';
|
|
17
|
+
export { default as remove } from './commands/remove';
|
|
18
|
+
export { default as renameCmd } from './commands/rename';
|
|
19
|
+
export { default as revert } from './commands/revert';
|
|
20
|
+
export { default as tag } from './commands/tag';
|
|
21
|
+
export { default as verify } from './commands/verify';
|
|
22
|
+
export * from './utils';
|
|
3
23
|
export declare const options: Partial<CLIOptions>;
|