pgpm 0.0.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.
- package/README.md +416 -0
- package/commands/add.d.ts +7 -0
- package/commands/add.js +86 -0
- package/commands/admin-users/add.d.ts +4 -0
- package/commands/admin-users/add.js +89 -0
- package/commands/admin-users/bootstrap.d.ts +4 -0
- package/commands/admin-users/bootstrap.js +50 -0
- package/commands/admin-users/remove.d.ts +4 -0
- package/commands/admin-users/remove.js +82 -0
- package/commands/admin-users.d.ts +4 -0
- package/commands/admin-users.js +68 -0
- package/commands/analyze.d.ts +4 -0
- package/commands/analyze.js +21 -0
- package/commands/clear.d.ts +3 -0
- package/commands/clear.js +59 -0
- package/commands/deploy.d.ts +4 -0
- package/commands/deploy.js +146 -0
- package/commands/explorer.d.ts +3 -0
- package/commands/explorer.js +94 -0
- package/commands/export.d.ts +3 -0
- package/commands/export.js +129 -0
- package/commands/extension.d.ts +4 -0
- package/commands/extension.js +48 -0
- package/commands/init/index.d.ts +7 -0
- package/commands/init/index.js +47 -0
- package/commands/init/module.d.ts +4 -0
- package/commands/init/module.js +71 -0
- package/commands/init/workspace.d.ts +4 -0
- package/commands/init/workspace.js +52 -0
- package/commands/install.d.ts +4 -0
- package/commands/install.js +37 -0
- package/commands/kill.d.ts +3 -0
- package/commands/kill.js +107 -0
- package/commands/migrate/deps.d.ts +4 -0
- package/commands/migrate/deps.js +186 -0
- package/commands/migrate/init.d.ts +4 -0
- package/commands/migrate/init.js +65 -0
- package/commands/migrate/list.d.ts +4 -0
- package/commands/migrate/list.js +85 -0
- package/commands/migrate/status.d.ts +4 -0
- package/commands/migrate/status.js +94 -0
- package/commands/migrate.d.ts +4 -0
- package/commands/migrate.js +69 -0
- package/commands/package.d.ts +3 -0
- package/commands/package.js +65 -0
- package/commands/plan.d.ts +3 -0
- package/commands/plan.js +62 -0
- package/commands/remove.d.ts +3 -0
- package/commands/remove.js +42 -0
- package/commands/rename.d.ts +4 -0
- package/commands/rename.js +35 -0
- package/commands/revert.d.ts +3 -0
- package/commands/revert.js +107 -0
- package/commands/server.d.ts +3 -0
- package/commands/server.js +187 -0
- package/commands/tag.d.ts +6 -0
- package/commands/tag.js +168 -0
- package/commands/verify.d.ts +3 -0
- package/commands/verify.js +85 -0
- package/commands.d.ts +5 -0
- package/commands.js +118 -0
- package/dist/README.md +416 -0
- package/dist/package.json +77 -0
- package/esm/commands/add.js +51 -0
- package/esm/commands/admin-users/add.js +87 -0
- package/esm/commands/admin-users/bootstrap.js +48 -0
- package/esm/commands/admin-users/remove.js +80 -0
- package/esm/commands/admin-users.js +63 -0
- package/esm/commands/analyze.js +16 -0
- package/esm/commands/clear.js +54 -0
- package/esm/commands/deploy.js +144 -0
- package/esm/commands/explorer.js +92 -0
- package/esm/commands/export.js +127 -0
- package/esm/commands/extension.js +46 -0
- package/esm/commands/init/index.js +42 -0
- package/esm/commands/init/module.js +68 -0
- package/esm/commands/init/workspace.js +46 -0
- package/esm/commands/install.js +35 -0
- package/esm/commands/kill.js +105 -0
- package/esm/commands/migrate/deps.js +184 -0
- package/esm/commands/migrate/init.js +63 -0
- package/esm/commands/migrate/list.js +83 -0
- package/esm/commands/migrate/status.js +92 -0
- package/esm/commands/migrate.js +64 -0
- package/esm/commands/package.js +63 -0
- package/esm/commands/plan.js +60 -0
- package/esm/commands/remove.js +40 -0
- package/esm/commands/rename.js +30 -0
- package/esm/commands/revert.js +105 -0
- package/esm/commands/server.js +185 -0
- package/esm/commands/tag.js +133 -0
- package/esm/commands/verify.js +83 -0
- package/esm/commands.js +111 -0
- package/esm/index.js +20 -0
- package/esm/package.js +26 -0
- package/esm/utils/argv.js +92 -0
- package/esm/utils/cli-error.js +48 -0
- package/esm/utils/database.js +78 -0
- package/esm/utils/deployed-changes.js +68 -0
- package/esm/utils/display.js +58 -0
- package/esm/utils/index.js +3 -0
- package/esm/utils/module-utils.js +51 -0
- package/index.d.ts +3 -0
- package/index.js +23 -0
- package/package.d.ts +1 -0
- package/package.js +29 -0
- package/package.json +77 -0
- package/utils/argv.d.ts +46 -0
- package/utils/argv.js +100 -0
- package/utils/cli-error.d.ts +8 -0
- package/utils/cli-error.js +52 -0
- package/utils/database.d.ts +21 -0
- package/utils/database.js +83 -0
- package/utils/deployed-changes.d.ts +4 -0
- package/utils/deployed-changes.js +72 -0
- package/utils/display.d.ts +3 -0
- package/utils/display.js +66 -0
- package/utils/index.d.ts +3 -0
- package/utils/index.js +19 -0
- package/utils/module-utils.d.ts +8 -0
- package/utils/module-utils.js +54 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@launchql/core");
|
|
4
|
+
const logger_1 = require("@launchql/logger");
|
|
5
|
+
const pg_env_1 = require("pg-env");
|
|
6
|
+
const log = new logger_1.Logger('admin-users-remove');
|
|
7
|
+
const removeUsageText = `
|
|
8
|
+
LaunchQL Admin Users Remove Command:
|
|
9
|
+
|
|
10
|
+
lql admin-users remove [OPTIONS]
|
|
11
|
+
|
|
12
|
+
Remove database users and revoke their LaunchQL roles.
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--help, -h Show this help message
|
|
16
|
+
--username <username> Username for the database user to remove
|
|
17
|
+
--test Remove test users (app_user, app_admin)
|
|
18
|
+
--cwd <directory> Working directory (default: current directory)
|
|
19
|
+
|
|
20
|
+
Examples:
|
|
21
|
+
lql admin-users remove --username myuser
|
|
22
|
+
lql admin-users remove --test # Remove test users
|
|
23
|
+
lql admin-users remove # Will prompt for username
|
|
24
|
+
`;
|
|
25
|
+
exports.default = async (argv, prompter, _options) => {
|
|
26
|
+
// Show usage if explicitly requested
|
|
27
|
+
if (argv.help || argv.h) {
|
|
28
|
+
console.log(removeUsageText);
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
const pgEnv = (0, pg_env_1.getPgEnvOptions)();
|
|
32
|
+
const isTest = argv.test;
|
|
33
|
+
const init = new core_1.LaunchQLInit(pgEnv);
|
|
34
|
+
try {
|
|
35
|
+
if (isTest) {
|
|
36
|
+
const { yes: confirmTest } = await prompter.prompt(argv, [
|
|
37
|
+
{
|
|
38
|
+
type: 'confirm',
|
|
39
|
+
name: 'yes',
|
|
40
|
+
message: 'Are you sure you want to remove LaunchQL test users (app_user, app_admin)?',
|
|
41
|
+
default: false
|
|
42
|
+
}
|
|
43
|
+
]);
|
|
44
|
+
if (!confirmTest) {
|
|
45
|
+
log.info('Operation cancelled.');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
await init.removeDbRoles('app_user');
|
|
49
|
+
await init.removeDbRoles('app_admin');
|
|
50
|
+
log.success('Test users removed successfully.');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const prompts = [
|
|
54
|
+
{
|
|
55
|
+
type: 'text',
|
|
56
|
+
name: 'username',
|
|
57
|
+
message: 'Enter username for database user to remove:',
|
|
58
|
+
validate: (input) => input && input.trim().length > 0
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
const { username } = await prompter.prompt(argv, prompts);
|
|
62
|
+
const { yes } = await prompter.prompt(argv, [
|
|
63
|
+
{
|
|
64
|
+
type: 'confirm',
|
|
65
|
+
name: 'yes',
|
|
66
|
+
message: `Are you sure you want to remove database user "${username}"?`,
|
|
67
|
+
default: false
|
|
68
|
+
}
|
|
69
|
+
]);
|
|
70
|
+
if (!yes) {
|
|
71
|
+
log.info('Operation cancelled.');
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
await init.removeDbRoles(username);
|
|
75
|
+
log.success(`Database user "${username}" removed successfully.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
await init.close();
|
|
80
|
+
}
|
|
81
|
+
return argv;
|
|
82
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const add_1 = __importDefault(require("./admin-users/add"));
|
|
8
|
+
const bootstrap_1 = __importDefault(require("./admin-users/bootstrap"));
|
|
9
|
+
const remove_1 = __importDefault(require("./admin-users/remove"));
|
|
10
|
+
const subcommandMap = {
|
|
11
|
+
add: add_1.default,
|
|
12
|
+
bootstrap: bootstrap_1.default,
|
|
13
|
+
remove: remove_1.default
|
|
14
|
+
};
|
|
15
|
+
const adminUsersUsageText = `
|
|
16
|
+
LaunchQL Admin Users Commands:
|
|
17
|
+
|
|
18
|
+
lql admin-users bootstrap Initialize LaunchQL roles and permissions (must be run first)
|
|
19
|
+
lql admin-users add Add database users with roles
|
|
20
|
+
lql admin-users remove Remove database users and revoke roles
|
|
21
|
+
|
|
22
|
+
Options:
|
|
23
|
+
--help, -h Show this help message
|
|
24
|
+
--cwd Working directory (default: current directory)
|
|
25
|
+
`;
|
|
26
|
+
exports.default = async (argv, prompter, options) => {
|
|
27
|
+
let { first: subcommand, newArgv } = (0, utils_1.extractFirst)(argv);
|
|
28
|
+
// Prompt if no subcommand provided
|
|
29
|
+
if (!subcommand) {
|
|
30
|
+
// Show usage if explicitly requested and no subcommand provided
|
|
31
|
+
if (argv.help || argv.h) {
|
|
32
|
+
console.log(adminUsersUsageText);
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
const answer = await prompter.prompt(argv, [
|
|
36
|
+
{
|
|
37
|
+
type: 'autocomplete',
|
|
38
|
+
name: 'subcommand',
|
|
39
|
+
message: 'What admin users operation do you want to perform?',
|
|
40
|
+
options: Object.keys(subcommandMap).map(cmd => ({
|
|
41
|
+
name: cmd,
|
|
42
|
+
value: cmd,
|
|
43
|
+
description: getSubcommandDescription(cmd)
|
|
44
|
+
}))
|
|
45
|
+
}
|
|
46
|
+
]);
|
|
47
|
+
subcommand = answer.subcommand;
|
|
48
|
+
}
|
|
49
|
+
if (subcommand === 'help') {
|
|
50
|
+
console.log(adminUsersUsageText);
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
const subcommandFn = subcommandMap[subcommand];
|
|
54
|
+
if (!subcommandFn) {
|
|
55
|
+
console.error(`Unknown admin-users subcommand: ${subcommand}`);
|
|
56
|
+
console.log(adminUsersUsageText);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
await subcommandFn(newArgv, prompter, options);
|
|
60
|
+
};
|
|
61
|
+
function getSubcommandDescription(cmd) {
|
|
62
|
+
const descriptions = {
|
|
63
|
+
bootstrap: 'Initialize LaunchQL roles and permissions (must be run first)',
|
|
64
|
+
add: 'Add database users with roles',
|
|
65
|
+
remove: 'Remove database users and revoke roles'
|
|
66
|
+
};
|
|
67
|
+
return descriptions[cmd] || '';
|
|
68
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const core_1 = require("@launchql/core");
|
|
8
|
+
exports.default = async (argv, _prompter) => {
|
|
9
|
+
const cwd = argv.cwd || process.cwd();
|
|
10
|
+
const proj = new core_1.LaunchQLPackage(path_1.default.resolve(cwd));
|
|
11
|
+
const result = proj.analyzeModule();
|
|
12
|
+
if (result.ok) {
|
|
13
|
+
console.log(`OK ${result.name}`);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
console.log(`NOT OK ${result.name}`);
|
|
17
|
+
for (const issue of result.issues) {
|
|
18
|
+
const loc = issue.file ? ` (${issue.file})` : '';
|
|
19
|
+
console.log(`- [${issue.code}] ${issue.message}${loc}`);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const core_1 = require("@launchql/core");
|
|
7
|
+
const logger_1 = require("@launchql/logger");
|
|
8
|
+
const env_1 = require("@launchql/env");
|
|
9
|
+
const pg_env_1 = require("pg-env");
|
|
10
|
+
const core_2 = require("@launchql/core");
|
|
11
|
+
const types_1 = require("@launchql/types");
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const utils_1 = require("../utils");
|
|
14
|
+
const log = new logger_1.Logger('clear');
|
|
15
|
+
exports.default = async (argv, prompter, _options) => {
|
|
16
|
+
const database = await (0, utils_1.getTargetDatabase)(argv, prompter, {
|
|
17
|
+
message: 'Select database'
|
|
18
|
+
});
|
|
19
|
+
const questions = [
|
|
20
|
+
{
|
|
21
|
+
name: 'yes',
|
|
22
|
+
type: 'confirm',
|
|
23
|
+
message: 'Are you sure you want to clear ALL changes from the plan? This will remove all changes and their associated files.',
|
|
24
|
+
required: true
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
let { yes, cwd } = await prompter.prompt(argv, questions);
|
|
28
|
+
if (!yes) {
|
|
29
|
+
log.info('Operation cancelled.');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
log.debug(`Using current directory: ${cwd}`);
|
|
33
|
+
const pkg = new core_1.LaunchQLPackage(cwd);
|
|
34
|
+
if (!pkg.isInModule()) {
|
|
35
|
+
throw new Error('Not in a LaunchQL module directory. Please run this command from within a module.');
|
|
36
|
+
}
|
|
37
|
+
const modulePath = pkg.getModulePath();
|
|
38
|
+
if (!modulePath) {
|
|
39
|
+
throw new Error('Could not resolve module path');
|
|
40
|
+
}
|
|
41
|
+
const planPath = path_1.default.join(modulePath, 'launchql.plan');
|
|
42
|
+
const result = (0, core_2.parsePlanFile)(planPath);
|
|
43
|
+
if (result.errors.length > 0) {
|
|
44
|
+
throw types_1.errors.PLAN_PARSE_ERROR({ planPath, errors: result.errors.map(e => e.message).join(', ') });
|
|
45
|
+
}
|
|
46
|
+
const plan = result.data;
|
|
47
|
+
if (plan.changes.length === 0) {
|
|
48
|
+
log.info('Plan is already empty - nothing to clear.');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const firstChange = plan.changes[0].name;
|
|
52
|
+
log.info(`Found ${plan.changes.length} changes in plan. Clearing from first change: ${firstChange}`);
|
|
53
|
+
const opts = (0, env_1.getEnvOptions)({
|
|
54
|
+
pg: (0, pg_env_1.getPgEnvOptions)({ database })
|
|
55
|
+
});
|
|
56
|
+
await pkg.removeFromPlan(firstChange);
|
|
57
|
+
log.success(`✅ Successfully cleared all changes from the plan.`);
|
|
58
|
+
return argv;
|
|
59
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@launchql/core");
|
|
4
|
+
const logger_1 = require("@launchql/logger");
|
|
5
|
+
const env_1 = require("@launchql/env");
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
const pg_env_1 = require("pg-env");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
const module_utils_1 = require("../utils/module-utils");
|
|
10
|
+
const deployUsageText = `
|
|
11
|
+
LaunchQL Deploy Command:
|
|
12
|
+
|
|
13
|
+
lql deploy [OPTIONS]
|
|
14
|
+
|
|
15
|
+
Deploy database changes and migrations to target database.
|
|
16
|
+
|
|
17
|
+
Options:
|
|
18
|
+
--help, -h Show this help message
|
|
19
|
+
--createdb Create database if it doesn't exist
|
|
20
|
+
--recursive Deploy recursively through dependencies
|
|
21
|
+
--package <name> Target specific package
|
|
22
|
+
--to <target> Deploy to specific change or tag
|
|
23
|
+
--tx Use transactions (default: true)
|
|
24
|
+
--fast Use fast deployment strategy
|
|
25
|
+
--logOnly Log-only mode, skip script execution
|
|
26
|
+
--usePlan Use deployment plan
|
|
27
|
+
--cache Enable caching
|
|
28
|
+
--cwd <directory> Working directory (default: current directory)
|
|
29
|
+
|
|
30
|
+
Examples:
|
|
31
|
+
lql deploy Deploy to selected database
|
|
32
|
+
lql deploy --createdb Deploy with database creation
|
|
33
|
+
lql deploy --package mypackage --to @v1.0.0 Deploy specific package to tag
|
|
34
|
+
lql deploy --fast --no-tx Fast deployment without transactions
|
|
35
|
+
`;
|
|
36
|
+
exports.default = async (argv, prompter, _options) => {
|
|
37
|
+
// Show usage if explicitly requested
|
|
38
|
+
if (argv.help || argv.h) {
|
|
39
|
+
console.log(deployUsageText);
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
const pgEnv = (0, pg_env_1.getPgEnvOptions)();
|
|
43
|
+
const log = new logger_1.Logger('cli');
|
|
44
|
+
// Get target database
|
|
45
|
+
let database;
|
|
46
|
+
if (argv.createdb) {
|
|
47
|
+
// Prompt for selection
|
|
48
|
+
({ database } = await prompter.prompt(argv, [
|
|
49
|
+
{
|
|
50
|
+
type: 'text',
|
|
51
|
+
name: 'database',
|
|
52
|
+
message: 'Database name',
|
|
53
|
+
required: true
|
|
54
|
+
}
|
|
55
|
+
]));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
database = await (0, utils_1.getTargetDatabase)(argv, prompter, {
|
|
59
|
+
message: 'Select database'
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const questions = [
|
|
63
|
+
{
|
|
64
|
+
name: 'yes',
|
|
65
|
+
type: 'confirm',
|
|
66
|
+
message: 'Are you sure you want to proceed?',
|
|
67
|
+
required: true
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'recursive',
|
|
71
|
+
type: 'confirm',
|
|
72
|
+
message: 'Deploy recursively through dependencies?',
|
|
73
|
+
useDefault: true,
|
|
74
|
+
default: true,
|
|
75
|
+
required: false
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'tx',
|
|
79
|
+
type: 'confirm',
|
|
80
|
+
message: 'Use Transaction?',
|
|
81
|
+
useDefault: true,
|
|
82
|
+
default: true,
|
|
83
|
+
required: false
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: 'fast',
|
|
87
|
+
type: 'confirm',
|
|
88
|
+
message: 'Use Fast Deployment?',
|
|
89
|
+
useDefault: true,
|
|
90
|
+
default: false,
|
|
91
|
+
required: false
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'logOnly',
|
|
95
|
+
type: 'confirm',
|
|
96
|
+
message: 'Log-only mode (skip script execution)?',
|
|
97
|
+
useDefault: true,
|
|
98
|
+
default: false,
|
|
99
|
+
required: false
|
|
100
|
+
}
|
|
101
|
+
];
|
|
102
|
+
let { yes, recursive, createdb, cwd, tx, fast, logOnly } = await prompter.prompt(argv, questions);
|
|
103
|
+
if (!yes) {
|
|
104
|
+
log.info('Operation cancelled.');
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
log.debug(`Using current directory: ${cwd}`);
|
|
108
|
+
if (createdb) {
|
|
109
|
+
log.info(`Creating database ${database}...`);
|
|
110
|
+
(0, child_process_1.execSync)(`createdb ${database}`, {
|
|
111
|
+
env: (0, pg_env_1.getSpawnEnvWithPg)(pgEnv)
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
let packageName;
|
|
115
|
+
if (recursive) {
|
|
116
|
+
packageName = await (0, module_utils_1.selectPackage)(argv, prompter, cwd, 'deploy', log);
|
|
117
|
+
}
|
|
118
|
+
const cliOverrides = {
|
|
119
|
+
pg: (0, pg_env_1.getPgEnvOptions)({ database }),
|
|
120
|
+
deployment: {
|
|
121
|
+
useTx: tx !== false,
|
|
122
|
+
fast: fast !== false,
|
|
123
|
+
usePlan: argv.usePlan !== false,
|
|
124
|
+
cache: argv.cache !== false,
|
|
125
|
+
logOnly: argv.logOnly !== false,
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const opts = (0, env_1.getEnvOptions)(cliOverrides);
|
|
129
|
+
const project = new core_1.LaunchQLPackage(cwd);
|
|
130
|
+
let target;
|
|
131
|
+
if (packageName && argv.to) {
|
|
132
|
+
target = `${packageName}:${argv.to}`;
|
|
133
|
+
}
|
|
134
|
+
else if (packageName) {
|
|
135
|
+
target = packageName;
|
|
136
|
+
}
|
|
137
|
+
else if (argv.package && argv.to) {
|
|
138
|
+
target = `${argv.package}:${argv.to}`;
|
|
139
|
+
}
|
|
140
|
+
else if (argv.package) {
|
|
141
|
+
target = argv.package;
|
|
142
|
+
}
|
|
143
|
+
await project.deploy(opts, target, recursive);
|
|
144
|
+
log.success('Deployment complete.');
|
|
145
|
+
return argv;
|
|
146
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@launchql/core");
|
|
4
|
+
const types_1 = require("@launchql/types");
|
|
5
|
+
const env_1 = require("@launchql/env");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const pg_cache_1 = require("pg-cache");
|
|
8
|
+
const exportUsageText = `
|
|
9
|
+
LaunchQL Export Command:
|
|
10
|
+
|
|
11
|
+
lql export [OPTIONS]
|
|
12
|
+
|
|
13
|
+
Export database migrations from existing databases.
|
|
14
|
+
|
|
15
|
+
Options:
|
|
16
|
+
--help, -h Show this help message
|
|
17
|
+
--author <name> Project author (default: from git config)
|
|
18
|
+
--extensionName <name> Extension name
|
|
19
|
+
--metaExtensionName <name> Meta extension name (default: svc)
|
|
20
|
+
--cwd <directory> Working directory (default: current directory)
|
|
21
|
+
|
|
22
|
+
Examples:
|
|
23
|
+
lql export Export migrations from selected database
|
|
24
|
+
`;
|
|
25
|
+
exports.default = async (argv, prompter, _options) => {
|
|
26
|
+
// Show usage if explicitly requested
|
|
27
|
+
if (argv.help || argv.h) {
|
|
28
|
+
console.log(exportUsageText);
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
const { email, username } = (0, types_1.getGitConfigInfo)();
|
|
32
|
+
const cwd = argv.cwd ?? process.cwd();
|
|
33
|
+
const project = new core_1.LaunchQLPackage(cwd);
|
|
34
|
+
project.ensureWorkspace();
|
|
35
|
+
project.resetCwd(project.workspacePath);
|
|
36
|
+
const options = (0, env_1.getEnvOptions)();
|
|
37
|
+
const db = await (0, pg_cache_1.getPgPool)({
|
|
38
|
+
database: 'postgres'
|
|
39
|
+
});
|
|
40
|
+
const databasesResult = await db.query(`
|
|
41
|
+
SELECT datname FROM pg_catalog.pg_database
|
|
42
|
+
WHERE datistemplate = FALSE AND datname NOT IN ('postgres')
|
|
43
|
+
AND datname !~ '^pg_';
|
|
44
|
+
`);
|
|
45
|
+
let databases;
|
|
46
|
+
({ databases } = await prompter.prompt(argv, [
|
|
47
|
+
{
|
|
48
|
+
type: 'checkbox',
|
|
49
|
+
name: 'databases',
|
|
50
|
+
message: 'Select a database',
|
|
51
|
+
options: databasesResult.rows.map(row => row.datname),
|
|
52
|
+
required: true
|
|
53
|
+
}
|
|
54
|
+
]));
|
|
55
|
+
const dbname = databases.filter(d => d.selected).map(d => d.value)[0];
|
|
56
|
+
const selectedDb = await (0, pg_cache_1.getPgPool)({
|
|
57
|
+
database: dbname
|
|
58
|
+
});
|
|
59
|
+
const dbsResult = await selectedDb.query(`
|
|
60
|
+
SELECT id, name FROM collections_public.database;
|
|
61
|
+
`);
|
|
62
|
+
let database_ids;
|
|
63
|
+
({ database_ids } = await prompter.prompt({}, [
|
|
64
|
+
{
|
|
65
|
+
type: 'checkbox',
|
|
66
|
+
name: 'database_ids',
|
|
67
|
+
message: 'Select database_id(s)',
|
|
68
|
+
options: dbsResult.rows.map(db => db.name),
|
|
69
|
+
required: true
|
|
70
|
+
}
|
|
71
|
+
]));
|
|
72
|
+
const dbInfo = {
|
|
73
|
+
dbname,
|
|
74
|
+
database_ids: database_ids.map(did => dbsResult.rows.find(db => db.name === did.name).id)
|
|
75
|
+
};
|
|
76
|
+
const { author, extensionName, metaExtensionName } = await prompter.prompt(argv, [
|
|
77
|
+
{
|
|
78
|
+
type: 'text',
|
|
79
|
+
name: 'author',
|
|
80
|
+
message: 'Project author',
|
|
81
|
+
default: `${username} <${email}>`,
|
|
82
|
+
required: true
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: 'text',
|
|
86
|
+
name: 'extensionName',
|
|
87
|
+
message: 'Extension name',
|
|
88
|
+
default: dbInfo.database_ids[0],
|
|
89
|
+
required: true
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'text',
|
|
93
|
+
name: 'metaExtensionName',
|
|
94
|
+
message: 'Meta extension name',
|
|
95
|
+
default: 'svc',
|
|
96
|
+
required: true
|
|
97
|
+
}
|
|
98
|
+
]);
|
|
99
|
+
const schemasResult = await selectedDb.query(`SELECT * FROM collections_public.schema WHERE database_id = $1`, [dbInfo.database_ids[0]]);
|
|
100
|
+
const { schema_names } = await prompter.prompt({}, [
|
|
101
|
+
{
|
|
102
|
+
type: 'checkbox',
|
|
103
|
+
name: 'schema_names',
|
|
104
|
+
message: 'Select schema_name(s)',
|
|
105
|
+
options: schemasResult.rows.map(s => s.schema_name),
|
|
106
|
+
default: schemasResult.rows.map(s => s.schema_name),
|
|
107
|
+
required: true
|
|
108
|
+
}
|
|
109
|
+
]);
|
|
110
|
+
const outdir = (0, path_1.resolve)(project.workspacePath, 'packages/');
|
|
111
|
+
await (0, core_1.exportMigrations)({
|
|
112
|
+
project,
|
|
113
|
+
options,
|
|
114
|
+
dbInfo,
|
|
115
|
+
author,
|
|
116
|
+
schema_names,
|
|
117
|
+
outdir,
|
|
118
|
+
extensionName,
|
|
119
|
+
metaExtensionName
|
|
120
|
+
});
|
|
121
|
+
console.log(`
|
|
122
|
+
|
|
123
|
+
|||
|
|
124
|
+
(o o)
|
|
125
|
+
ooO--(_)--Ooo-
|
|
126
|
+
|
|
127
|
+
✨ finished!
|
|
128
|
+
`);
|
|
129
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@launchql/core");
|
|
4
|
+
const extensionUsageText = `
|
|
5
|
+
LaunchQL Extension Command:
|
|
6
|
+
|
|
7
|
+
lql extension [OPTIONS]
|
|
8
|
+
|
|
9
|
+
Manage module dependencies.
|
|
10
|
+
|
|
11
|
+
Options:
|
|
12
|
+
--help, -h Show this help message
|
|
13
|
+
--cwd <directory> Working directory (default: current directory)
|
|
14
|
+
|
|
15
|
+
Examples:
|
|
16
|
+
lql extension Manage dependencies for current module
|
|
17
|
+
`;
|
|
18
|
+
exports.default = async (argv, prompter, _options) => {
|
|
19
|
+
// Show usage if explicitly requested
|
|
20
|
+
if (argv.help || argv.h) {
|
|
21
|
+
console.log(extensionUsageText);
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
const { cwd = process.cwd() } = argv;
|
|
25
|
+
const project = new core_1.LaunchQLPackage(cwd);
|
|
26
|
+
if (!project.isInModule()) {
|
|
27
|
+
throw new Error('You must run this command inside a LaunchQL module.');
|
|
28
|
+
}
|
|
29
|
+
const info = project.getModuleInfo();
|
|
30
|
+
const installed = project.getRequiredModules();
|
|
31
|
+
const available = project.getAvailableModules();
|
|
32
|
+
const filtered = available.filter(name => name !== info.extname);
|
|
33
|
+
const questions = [
|
|
34
|
+
{
|
|
35
|
+
name: 'extensions',
|
|
36
|
+
message: 'Which modules does this one depend on?',
|
|
37
|
+
type: 'checkbox',
|
|
38
|
+
allowCustomOptions: true,
|
|
39
|
+
options: filtered,
|
|
40
|
+
default: installed
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
const answers = await prompter.prompt(argv, questions);
|
|
44
|
+
const selected = answers.extensions
|
|
45
|
+
.filter(opt => opt.selected)
|
|
46
|
+
.map(opt => opt.name);
|
|
47
|
+
project.setModuleDependencies(selected);
|
|
48
|
+
};
|