pgpm 0.0.2 → 0.1.1

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.
Files changed (70) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +110 -115
  3. package/commands/add.js +7 -7
  4. package/commands/admin-users/add.js +8 -8
  5. package/commands/admin-users/bootstrap.js +7 -7
  6. package/commands/admin-users/remove.js +7 -7
  7. package/commands/admin-users.js +5 -5
  8. package/commands/analyze.js +1 -1
  9. package/commands/clear.js +3 -3
  10. package/commands/deploy.js +7 -7
  11. package/commands/export.js +4 -4
  12. package/commands/extension.js +3 -3
  13. package/commands/init/index.js +8 -8
  14. package/commands/install.js +6 -6
  15. package/commands/kill.js +6 -6
  16. package/commands/migrate/init.js +1 -1
  17. package/commands/migrate.js +1 -1
  18. package/commands/package.js +4 -4
  19. package/commands/plan.js +5 -5
  20. package/commands/remove.js +2 -2
  21. package/commands/rename.js +1 -1
  22. package/commands/revert.js +7 -7
  23. package/commands/tag.js +6 -6
  24. package/commands/verify.js +7 -7
  25. package/commands.d.ts +1 -0
  26. package/commands.js +7 -16
  27. package/esm/commands/add.js +7 -7
  28. package/esm/commands/admin-users/add.js +8 -8
  29. package/esm/commands/admin-users/bootstrap.js +7 -7
  30. package/esm/commands/admin-users/remove.js +7 -7
  31. package/esm/commands/admin-users.js +5 -5
  32. package/esm/commands/analyze.js +1 -1
  33. package/esm/commands/clear.js +3 -3
  34. package/esm/commands/deploy.js +7 -7
  35. package/esm/commands/export.js +4 -4
  36. package/esm/commands/extension.js +3 -3
  37. package/esm/commands/init/index.js +8 -8
  38. package/esm/commands/init/workspace.js +1 -1
  39. package/esm/commands/install.js +6 -6
  40. package/esm/commands/kill.js +6 -6
  41. package/esm/commands/migrate/init.js +1 -1
  42. package/esm/commands/migrate.js +1 -1
  43. package/esm/commands/package.js +4 -4
  44. package/esm/commands/plan.js +5 -5
  45. package/esm/commands/remove.js +2 -2
  46. package/esm/commands/rename.js +1 -1
  47. package/esm/commands/revert.js +7 -7
  48. package/esm/commands/tag.js +6 -6
  49. package/esm/commands/verify.js +7 -7
  50. package/esm/commands.js +5 -15
  51. package/esm/index.js +36 -10
  52. package/esm/utils/cli-error.js +1 -1
  53. package/esm/utils/display.js +13 -13
  54. package/esm/utils/index.js +3 -0
  55. package/index.d.ts +20 -0
  56. package/index.js +70 -10
  57. package/package.json +15 -18
  58. package/utils/cli-error.js +1 -1
  59. package/utils/display.d.ts +1 -1
  60. package/utils/display.js +13 -13
  61. package/utils/index.d.ts +3 -0
  62. package/utils/index.js +3 -0
  63. package/commands/explorer.d.ts +0 -3
  64. package/commands/explorer.js +0 -94
  65. package/commands/server.d.ts +0 -3
  66. package/commands/server.js +0 -187
  67. package/dist/README.md +0 -416
  68. package/dist/package.json +0 -77
  69. package/esm/commands/explorer.js +0 -92
  70. package/esm/commands/server.js +0 -185
package/index.js CHANGED
@@ -1,9 +1,64 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
3
20
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.options = void 0;
21
+ exports.options = exports.verify = exports.tag = exports.revert = exports.renameCmd = exports.remove = exports.plan = exports._package = exports.migrate = exports.kill = exports.install = exports.extension = exports._export = exports.deploy = exports.clear = exports.analyze = exports.adminUsers = exports.add = exports.createPgpmCommandMap = void 0;
22
+ const fs_1 = require("fs");
5
23
  const inquirerer_1 = require("inquirerer");
24
+ const path_1 = require("path");
6
25
  const commands_1 = require("./commands");
26
+ Object.defineProperty(exports, "createPgpmCommandMap", { enumerable: true, get: function () { return commands_1.createPgpmCommandMap; } });
27
+ var add_1 = require("./commands/add");
28
+ Object.defineProperty(exports, "add", { enumerable: true, get: function () { return __importDefault(add_1).default; } });
29
+ var admin_users_1 = require("./commands/admin-users");
30
+ Object.defineProperty(exports, "adminUsers", { enumerable: true, get: function () { return __importDefault(admin_users_1).default; } });
31
+ var analyze_1 = require("./commands/analyze");
32
+ Object.defineProperty(exports, "analyze", { enumerable: true, get: function () { return __importDefault(analyze_1).default; } });
33
+ var clear_1 = require("./commands/clear");
34
+ Object.defineProperty(exports, "clear", { enumerable: true, get: function () { return __importDefault(clear_1).default; } });
35
+ var deploy_1 = require("./commands/deploy");
36
+ Object.defineProperty(exports, "deploy", { enumerable: true, get: function () { return __importDefault(deploy_1).default; } });
37
+ var export_1 = require("./commands/export");
38
+ Object.defineProperty(exports, "_export", { enumerable: true, get: function () { return __importDefault(export_1).default; } });
39
+ var extension_1 = require("./commands/extension");
40
+ Object.defineProperty(exports, "extension", { enumerable: true, get: function () { return __importDefault(extension_1).default; } });
41
+ var install_1 = require("./commands/install");
42
+ Object.defineProperty(exports, "install", { enumerable: true, get: function () { return __importDefault(install_1).default; } });
43
+ var kill_1 = require("./commands/kill");
44
+ Object.defineProperty(exports, "kill", { enumerable: true, get: function () { return __importDefault(kill_1).default; } });
45
+ var migrate_1 = require("./commands/migrate");
46
+ Object.defineProperty(exports, "migrate", { enumerable: true, get: function () { return __importDefault(migrate_1).default; } });
47
+ var package_1 = require("./commands/package");
48
+ Object.defineProperty(exports, "_package", { enumerable: true, get: function () { return __importDefault(package_1).default; } });
49
+ var plan_1 = require("./commands/plan");
50
+ Object.defineProperty(exports, "plan", { enumerable: true, get: function () { return __importDefault(plan_1).default; } });
51
+ var remove_1 = require("./commands/remove");
52
+ Object.defineProperty(exports, "remove", { enumerable: true, get: function () { return __importDefault(remove_1).default; } });
53
+ var rename_1 = require("./commands/rename");
54
+ Object.defineProperty(exports, "renameCmd", { enumerable: true, get: function () { return __importDefault(rename_1).default; } });
55
+ var revert_1 = require("./commands/revert");
56
+ Object.defineProperty(exports, "revert", { enumerable: true, get: function () { return __importDefault(revert_1).default; } });
57
+ var tag_1 = require("./commands/tag");
58
+ Object.defineProperty(exports, "tag", { enumerable: true, get: function () { return __importDefault(tag_1).default; } });
59
+ var verify_1 = require("./commands/verify");
60
+ Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return __importDefault(verify_1).default; } });
61
+ __exportStar(require("./utils"), exports);
7
62
  exports.options = {
8
63
  minimistOpts: {
9
64
  alias: {
@@ -12,12 +67,17 @@ exports.options = {
12
67
  }
13
68
  }
14
69
  };
15
- const app = new inquirerer_1.CLI(commands_1.commands, exports.options);
16
- app.run().then(() => {
17
- // all done!
18
- }).catch(error => {
19
- // Should not reach here with the new CLI error handling pattern
20
- // But keep as fallback for unexpected errors
21
- console.error('Unexpected error:', error);
22
- process.exit(1);
23
- });
70
+ if (require.main === module) {
71
+ if (process.argv.includes('--version') || process.argv.includes('-v')) {
72
+ const pkgPath = (0, path_1.join)(__dirname, 'package.json');
73
+ const pkg = JSON.parse((0, fs_1.readFileSync)(pkgPath, 'utf8'));
74
+ console.log(pkg.version);
75
+ process.exit(0);
76
+ }
77
+ const app = new inquirerer_1.CLI(commands_1.commands, exports.options);
78
+ app.run().then(() => {
79
+ }).catch(error => {
80
+ console.error('Unexpected error:', error);
81
+ process.exit(1);
82
+ });
83
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "pgpm",
3
- "version": "0.0.2",
3
+ "version": "0.1.1",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
- "description": "PostgreSQL Package Manager",
5
+ "description": "PostgreSQL Package Manager - Database migration and package management CLI",
6
6
  "main": "index.js",
7
7
  "module": "esm/index.js",
8
8
  "types": "index.d.ts",
@@ -13,8 +13,7 @@
13
13
  "directory": "dist"
14
14
  },
15
15
  "bin": {
16
- "lql": "index.js",
17
- "launchql": "index.js"
16
+ "pgpm": "index.js"
18
17
  },
19
18
  "repository": {
20
19
  "type": "git",
@@ -46,19 +45,16 @@
46
45
  "ts-node": "^10.9.2"
47
46
  },
48
47
  "dependencies": {
49
- "@launchql/core": "^2.14.3",
50
- "@launchql/env": "^2.4.5",
51
- "@launchql/explorer": "^2.6.1",
48
+ "@launchql/core": "^2.14.4",
49
+ "@launchql/env": "^2.4.6",
52
50
  "@launchql/logger": "^1.1.3",
53
- "@launchql/server": "^2.6.1",
54
- "@launchql/server-utils": "^2.5.1",
55
- "@launchql/templatizer": "^2.4.5",
56
- "@launchql/types": "^2.7.0",
51
+ "@launchql/templatizer": "^2.4.6",
52
+ "@launchql/types": "^2.7.1",
57
53
  "chalk": "^4.1.0",
58
54
  "inquirerer": "^2.0.8",
59
55
  "js-yaml": "^4.1.0",
60
56
  "minimist": "^1.2.8",
61
- "pg-cache": "^1.3.8",
57
+ "pg-cache": "^1.3.9",
62
58
  "pg-env": "^1.1.1",
63
59
  "shelljs": "^0.9.2"
64
60
  },
@@ -66,12 +62,13 @@
66
62
  "cli",
67
63
  "command-line",
68
64
  "tool",
69
- "launchql",
70
- "utilities",
71
- "pg",
72
- "pgsql",
73
65
  "postgres",
74
- "graphile"
66
+ "postgresql",
67
+ "migration",
68
+ "package-manager",
69
+ "database",
70
+ "pg",
71
+ "pgsql"
75
72
  ],
76
- "gitHead": "2e8a123c53d33ee10377b0f034392b0dff1e8a88"
73
+ "gitHead": "efef74a45c940502c4f4cdeb889dfeaf5c9a65a6"
77
74
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cliExitWithError = void 0;
4
- const types_1 = require("@launchql/types");
5
4
  const logger_1 = require("@launchql/logger");
5
+ const types_1 = require("@launchql/types");
6
6
  const pg_cache_1 = require("pg-cache");
7
7
  const log = new logger_1.Logger('cli');
8
8
  /**
@@ -1,3 +1,3 @@
1
1
  export declare function displayVersion(): void;
2
- export declare const usageText = "\n Usage: lql <command> [options]\n launchql <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 LaunchQL workspace or module\n extension Manage module dependencies\n plan Generate module deployment plans\n package Package module for distribution\n \n Development Tools:\n server Start LaunchQL GraphQL server\n explorer Launch GraphiQL explorer interface\n export Export database migrations from existing databases\n \n Database Administration:\n kill Terminate database connections and optionally drop databases\n install Install LaunchQL modules\n tag Add tags to changes for versioning\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 lql <command> --help Display detailed help for specific command\n lql <command> -h Display detailed help for specific command\n \n Examples:\n lql deploy --help Show deploy command options\n lql server --port 8080 Start server on port 8080\n lql init --workspace Initialize new workspace\n ";
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 \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
3
  export declare function displayUsage(): void;
package/utils/display.js CHANGED
@@ -15,8 +15,7 @@ function displayVersion() {
15
15
  console.log(chalk_1.default.blue(`Version: ${pkg.version}`));
16
16
  }
17
17
  exports.usageText = `
18
- Usage: lql <command> [options]
19
- launchql <command> [options]
18
+ Usage: pgpm <command> [options]
20
19
 
21
20
  Core Database Operations:
22
21
  add Add database changes to plans and create SQL files
@@ -25,20 +24,21 @@ exports.usageText = `
25
24
  revert Revert database changes and migrations
26
25
 
27
26
  Project Management:
28
- init Initialize LaunchQL workspace or module
27
+ init Initialize workspace or module
29
28
  extension Manage module dependencies
30
29
  plan Generate module deployment plans
31
30
  package Package module for distribution
32
-
33
- Development Tools:
34
- server Start LaunchQL GraphQL server
35
- explorer Launch GraphiQL explorer interface
36
31
  export Export database migrations from existing databases
37
32
 
38
33
  Database Administration:
39
34
  kill Terminate database connections and optionally drop databases
40
- install Install LaunchQL modules
35
+ install Install database modules
41
36
  tag Add tags to changes for versioning
37
+ clear Clear database state
38
+ remove Remove database changes
39
+ analyze Analyze database structure
40
+ rename Rename database changes
41
+ admin-users Manage admin users
42
42
 
43
43
  Migration Tools:
44
44
  migrate Migration management subcommands
@@ -53,13 +53,13 @@ exports.usageText = `
53
53
  --cwd <directory> Working directory (default: current directory)
54
54
 
55
55
  Individual Command Help:
56
- lql <command> --help Display detailed help for specific command
57
- lql <command> -h Display detailed help for specific command
56
+ pgpm <command> --help Display detailed help for specific command
57
+ pgpm <command> -h Display detailed help for specific command
58
58
 
59
59
  Examples:
60
- lql deploy --help Show deploy command options
61
- lql server --port 8080 Start server on port 8080
62
- lql init --workspace Initialize new workspace
60
+ pgpm deploy --help Show deploy command options
61
+ pgpm init --workspace Initialize new workspace
62
+ pgpm install @pgpm/base32 Install a database module
63
63
  `;
64
64
  function displayUsage() {
65
65
  console.log(exports.usageText);
package/utils/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  export * from './argv';
2
2
  export * from './database';
3
3
  export * from './display';
4
+ export * from './cli-error';
5
+ export * from './deployed-changes';
6
+ export * from './module-utils';
package/utils/index.js CHANGED
@@ -17,3 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./argv"), exports);
18
18
  __exportStar(require("./database"), exports);
19
19
  __exportStar(require("./display"), exports);
20
+ __exportStar(require("./cli-error"), exports);
21
+ __exportStar(require("./deployed-changes"), exports);
22
+ __exportStar(require("./module-utils"), exports);
@@ -1,3 +0,0 @@
1
- import { CLIOptions, Inquirerer } from 'inquirerer';
2
- declare const _default: (argv: Partial<Record<string, any>>, prompter: Inquirerer, _options: CLIOptions) => Promise<void>;
3
- export default _default;
@@ -1,94 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const explorer_1 = require("@launchql/explorer");
4
- const logger_1 = require("@launchql/logger");
5
- const env_1 = require("@launchql/env");
6
- const log = new logger_1.Logger('explorer');
7
- const explorerUsageText = `
8
- LaunchQL Explorer Command:
9
-
10
- lql explorer [OPTIONS]
11
-
12
- Launch GraphiQL explorer interface.
13
-
14
- Options:
15
- --help, -h Show this help message
16
- --port <number> Server port (default: 5555)
17
- --origin <url> CORS origin URL (default: http://localhost:3000)
18
- --simpleInflection Use simple inflection (default: true)
19
- --oppositeBaseNames Use opposite base names (default: false)
20
- --postgis Enable PostGIS extension (default: true)
21
- --cwd <directory> Working directory (default: current directory)
22
-
23
- Examples:
24
- lql explorer Launch explorer with defaults
25
- lql explorer --origin http://localhost:4000 Launch explorer with custom origin
26
- `;
27
- const questions = [
28
- {
29
- name: 'simpleInflection',
30
- message: 'Use simple inflection?',
31
- type: 'confirm',
32
- required: false,
33
- default: true,
34
- useDefault: true
35
- },
36
- {
37
- name: 'oppositeBaseNames',
38
- message: 'Use opposite base names?',
39
- type: 'confirm',
40
- required: false,
41
- default: false,
42
- useDefault: true
43
- },
44
- {
45
- name: 'postgis',
46
- message: 'Enable PostGIS extension?',
47
- type: 'confirm',
48
- required: false,
49
- default: true,
50
- useDefault: true
51
- },
52
- {
53
- name: 'port',
54
- message: 'Development server port',
55
- type: 'number',
56
- required: false,
57
- default: 5555,
58
- useDefault: true
59
- },
60
- {
61
- name: 'origin',
62
- message: 'CORS origin URL',
63
- type: 'text',
64
- required: false,
65
- default: 'http://localhost:3000',
66
- useDefault: true
67
- }
68
- ];
69
- exports.default = async (argv, prompter, _options) => {
70
- // Show usage if explicitly requested
71
- if (argv.help || argv.h) {
72
- console.log(explorerUsageText);
73
- process.exit(0);
74
- }
75
- log.info('🔧 LaunchQL Explorer Configuration:\n');
76
- const { oppositeBaseNames, origin, port, postgis, simpleInflection } = await prompter.prompt(argv, questions);
77
- const options = (0, env_1.getEnvOptions)({
78
- features: {
79
- oppositeBaseNames,
80
- simpleInflection,
81
- postgis
82
- },
83
- server: {
84
- origin,
85
- port
86
- }
87
- });
88
- log.success('✅ Selected Configuration:');
89
- for (const [key, value] of Object.entries(options)) {
90
- log.debug(`${key}: ${JSON.stringify(value)}`);
91
- }
92
- log.success('🚀 Launching Explorer...\n');
93
- (0, explorer_1.LaunchQLExplorer)(options);
94
- };
@@ -1,3 +0,0 @@
1
- import { CLIOptions, Inquirerer } from 'inquirerer';
2
- declare const _default: (argv: Partial<Record<string, any>>, prompter: Inquirerer, _options: CLIOptions) => Promise<void>;
3
- export default _default;
@@ -1,187 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const logger_1 = require("@launchql/logger");
4
- const server_1 = require("@launchql/server");
5
- const env_1 = require("@launchql/env");
6
- const pg_cache_1 = require("pg-cache");
7
- const log = new logger_1.Logger('server');
8
- const serverUsageText = `
9
- LaunchQL Server Command:
10
-
11
- lql server [OPTIONS]
12
-
13
- Start LaunchQL GraphQL development server.
14
-
15
- Options:
16
- --help, -h Show this help message
17
- --port <number> Server port (default: 5555)
18
- --simpleInflection Use simple inflection (default: true)
19
- --oppositeBaseNames Use opposite base names (default: false)
20
- --postgis Enable PostGIS extension (default: true)
21
- --metaApi Enable Meta API (default: true)
22
- --cwd <directory> Working directory (default: current directory)
23
-
24
- Examples:
25
- lql server Start server with defaults
26
- lql server --port 8080 Start server on custom port
27
- lql server --no-postgis Start server without PostGIS
28
- `;
29
- const questions = [
30
- {
31
- name: 'simpleInflection',
32
- message: 'Use simple inflection?',
33
- type: 'confirm',
34
- required: false,
35
- default: true,
36
- useDefault: true
37
- },
38
- {
39
- name: 'oppositeBaseNames',
40
- message: 'Use opposite base names?',
41
- type: 'confirm',
42
- required: false,
43
- default: false,
44
- useDefault: true
45
- },
46
- {
47
- name: 'postgis',
48
- message: 'Enable PostGIS extension?',
49
- type: 'confirm',
50
- required: false,
51
- default: true,
52
- useDefault: true
53
- },
54
- {
55
- name: 'metaApi',
56
- message: 'Enable Meta API?',
57
- type: 'confirm',
58
- required: false,
59
- default: true,
60
- useDefault: true
61
- },
62
- {
63
- name: 'origin',
64
- message: 'CORS origin (exact URL or *)',
65
- type: 'text',
66
- required: false,
67
- // no default to avoid accidentally opening up CORS; pass explicitly or via env
68
- },
69
- {
70
- name: 'port',
71
- message: 'Development server port',
72
- type: 'number',
73
- required: false,
74
- default: 5555,
75
- useDefault: true
76
- }
77
- ];
78
- exports.default = async (argv, prompter, _options) => {
79
- // Show usage if explicitly requested
80
- if (argv.help || argv.h) {
81
- console.log(serverUsageText);
82
- process.exit(0);
83
- }
84
- log.info('🔧 LaunchQL Server Configuration:\n');
85
- let selectedDb = process.env.PGDATABASE;
86
- if (!selectedDb) {
87
- const db = await (0, pg_cache_1.getPgPool)({ database: 'postgres' });
88
- const result = await db.query(`
89
- SELECT datname FROM pg_database
90
- WHERE datistemplate = false AND datname NOT IN ('postgres')
91
- AND datname !~ '^pg_'
92
- ORDER BY datname;
93
- `);
94
- const dbChoices = result.rows.map(row => row.datname);
95
- const { database } = await prompter.prompt(argv, [
96
- {
97
- type: 'autocomplete',
98
- name: 'database',
99
- message: 'Select the database to use',
100
- options: dbChoices,
101
- required: true
102
- }
103
- ]);
104
- selectedDb = database;
105
- log.info(`📌 Using database: "${selectedDb}"`);
106
- }
107
- const { oppositeBaseNames, port, postgis, simpleInflection, metaApi, origin } = await prompter.prompt(argv, questions);
108
- // Warn when passing CORS override via CLI, especially in production
109
- if (origin && origin.trim().length) {
110
- const env = (process.env.NODE_ENV || 'development').toLowerCase();
111
- if (env === 'production') {
112
- if (origin.trim() === '*') {
113
- log.warn('CORS wildcard ("*") provided via --origin in production: this effectively disables CORS and is not recommended. Prefer per-API CORS via meta schema.');
114
- }
115
- else {
116
- log.warn(`CORS override (origin=${origin.trim()}) provided via --origin in production. Prefer per-API CORS via meta schema.`);
117
- }
118
- }
119
- }
120
- let selectedSchemas = [];
121
- let authRole;
122
- let roleName;
123
- if (!metaApi) {
124
- const db = await (0, pg_cache_1.getPgPool)({ database: selectedDb });
125
- const result = await db.query(`
126
- SELECT nspname
127
- FROM pg_namespace
128
- WHERE nspname NOT IN ('pg_catalog', 'information_schema')
129
- ORDER BY nspname;
130
- `);
131
- const schemaChoices = result.rows.map(row => ({
132
- name: row.nspname,
133
- value: row.nspname,
134
- selected: true
135
- }));
136
- const { schemas } = await prompter.prompt(argv, [
137
- {
138
- type: 'checkbox',
139
- name: 'schemas',
140
- message: 'Select schemas to expose',
141
- options: schemaChoices,
142
- required: true
143
- }
144
- ]);
145
- selectedSchemas = schemas.filter(s => s.selected).map(s => s.value);
146
- const { authRole: selectedAuthRole, roleName: selectedRoleName } = await prompter.prompt(argv, [
147
- {
148
- type: 'autocomplete',
149
- name: 'authRole',
150
- message: 'Select the authentication role',
151
- options: ['postgres', 'authenticated', 'anonymous'],
152
- required: true
153
- },
154
- {
155
- type: 'autocomplete',
156
- name: 'roleName',
157
- message: 'Enter the default role name:',
158
- options: ['postgres', 'authenticated', 'anonymous'],
159
- required: true
160
- }
161
- ]);
162
- authRole = selectedAuthRole;
163
- roleName = selectedRoleName;
164
- }
165
- const options = (0, env_1.getEnvOptions)({
166
- pg: { database: selectedDb },
167
- features: {
168
- oppositeBaseNames,
169
- simpleInflection,
170
- postgis
171
- },
172
- api: {
173
- enableMetaApi: metaApi,
174
- ...(metaApi === false && { exposedSchemas: selectedSchemas, authRole, roleName })
175
- },
176
- server: {
177
- port,
178
- ...(origin ? { origin } : {})
179
- }
180
- });
181
- log.success('✅ Selected Configuration:');
182
- for (const [key, value] of Object.entries(options)) {
183
- log.debug(`${key}: ${JSON.stringify(value)}`);
184
- }
185
- log.success('🚀 Launching Server...\n');
186
- (0, server_1.LaunchQLServer)(options);
187
- };