@constructive-io/cli 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +23 -0
- package/README.md +412 -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/docker.d.ts +3 -0
- package/commands/docker.js +194 -0
- package/commands/env.d.ts +4 -0
- package/commands/env.js +124 -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/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 +6 -0
- package/commands.js +113 -0
- package/dist/README.md +412 -0
- package/dist/package.json +64 -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/docker.js +192 -0
- package/esm/commands/env.js +122 -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/tag.js +133 -0
- package/esm/commands/verify.js +83 -0
- package/esm/commands.js +105 -0
- package/esm/index.js +48 -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 +6 -0
- package/esm/utils/module-utils.js +51 -0
- package/index.d.ts +25 -0
- package/index.js +87 -0
- package/package.d.ts +1 -0
- package/package.js +29 -0
- package/package.json +64 -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 +6 -0
- package/utils/index.js +22 -0
- package/utils/module-utils.d.ts +8 -0
- package/utils/module-utils.js +54 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectDeployedChange = selectDeployedChange;
|
|
4
|
+
exports.selectDeployedPackage = selectDeployedPackage;
|
|
5
|
+
const core_1 = require("@launchql/core");
|
|
6
|
+
const pg_env_1 = require("pg-env");
|
|
7
|
+
async function selectDeployedChange(database, argv, prompter, log, action = 'revert') {
|
|
8
|
+
const pgEnv = (0, pg_env_1.getPgEnvOptions)({ database });
|
|
9
|
+
const client = new core_1.LaunchQLMigrate(pgEnv);
|
|
10
|
+
let selectedPackage;
|
|
11
|
+
if (argv.package) {
|
|
12
|
+
selectedPackage = argv.package;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const packageStatuses = await client.status();
|
|
16
|
+
if (packageStatuses.length === 0) {
|
|
17
|
+
log.warn('No deployed packages found in database');
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
const packageAnswer = await prompter.prompt(argv, [{
|
|
21
|
+
type: 'autocomplete',
|
|
22
|
+
name: 'package',
|
|
23
|
+
message: `Select package to ${action} from:`,
|
|
24
|
+
options: packageStatuses.map(status => ({
|
|
25
|
+
name: status.package,
|
|
26
|
+
value: status.package,
|
|
27
|
+
description: `${status.totalDeployed} changes, last: ${status.lastChange}`
|
|
28
|
+
}))
|
|
29
|
+
}]);
|
|
30
|
+
selectedPackage = packageAnswer.package;
|
|
31
|
+
}
|
|
32
|
+
const deployedChanges = await client.getDeployedChanges(database, selectedPackage);
|
|
33
|
+
if (deployedChanges.length === 0) {
|
|
34
|
+
log.warn(`No deployed changes found for package ${selectedPackage}`);
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
const changeAnswer = await prompter.prompt(argv, [{
|
|
38
|
+
type: 'autocomplete',
|
|
39
|
+
name: 'change',
|
|
40
|
+
message: `Select change to ${action} to in ${selectedPackage}:`,
|
|
41
|
+
options: deployedChanges.map(change => ({
|
|
42
|
+
name: change.change_name,
|
|
43
|
+
value: change.change_name,
|
|
44
|
+
description: `Deployed: ${new Date(change.deployed_at).toLocaleString()}`
|
|
45
|
+
}))
|
|
46
|
+
}]);
|
|
47
|
+
const selectedChange = changeAnswer.change;
|
|
48
|
+
return `${selectedPackage}:${selectedChange}`;
|
|
49
|
+
}
|
|
50
|
+
async function selectDeployedPackage(database, argv, prompter, log, action = 'revert') {
|
|
51
|
+
if (argv.package) {
|
|
52
|
+
return argv.package;
|
|
53
|
+
}
|
|
54
|
+
const pgEnv = (0, pg_env_1.getPgEnvOptions)({ database });
|
|
55
|
+
const client = new core_1.LaunchQLMigrate(pgEnv);
|
|
56
|
+
const packageStatuses = await client.status();
|
|
57
|
+
if (packageStatuses.length === 0) {
|
|
58
|
+
log.warn('No deployed packages found in database');
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const packageAnswer = await prompter.prompt(argv, [{
|
|
62
|
+
type: 'autocomplete',
|
|
63
|
+
name: 'package',
|
|
64
|
+
message: `Select package to ${action}:`,
|
|
65
|
+
options: packageStatuses.map(status => ({
|
|
66
|
+
name: status.package,
|
|
67
|
+
value: status.package,
|
|
68
|
+
description: `${status.totalDeployed} changes, last: ${status.lastChange}`
|
|
69
|
+
}))
|
|
70
|
+
}]);
|
|
71
|
+
return packageAnswer.package;
|
|
72
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function displayVersion(): void;
|
|
2
|
+
export declare const usageText = "\n Usage: constructive <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 constructive <command> --help Display detailed help for specific command\n constructive <command> -h Display detailed help for specific command\n\n Examples:\n constructive deploy --help Show deploy command options\n constructive init --workspace Initialize new workspace\n constructive install @pgpm/base32 Install a database module\n ";
|
|
3
|
+
export declare function displayUsage(): void;
|
package/utils/display.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
exports.usageText = void 0;
|
|
7
|
+
exports.displayVersion = displayVersion;
|
|
8
|
+
exports.displayUsage = displayUsage;
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const package_1 = require("../package");
|
|
11
|
+
// Function to display the version information
|
|
12
|
+
function displayVersion() {
|
|
13
|
+
const pkg = (0, package_1.readAndParsePackageJson)();
|
|
14
|
+
console.log(chalk_1.default.green(`Name: ${pkg.name}`));
|
|
15
|
+
console.log(chalk_1.default.blue(`Version: ${pkg.version}`));
|
|
16
|
+
}
|
|
17
|
+
exports.usageText = `
|
|
18
|
+
Usage: constructive <command> [options]
|
|
19
|
+
|
|
20
|
+
Core Database Operations:
|
|
21
|
+
add Add database changes to plans and create SQL files
|
|
22
|
+
deploy Deploy database changes and migrations
|
|
23
|
+
verify Verify database state and migrations
|
|
24
|
+
revert Revert database changes and migrations
|
|
25
|
+
|
|
26
|
+
Project Management:
|
|
27
|
+
init Initialize workspace or module
|
|
28
|
+
extension Manage module dependencies
|
|
29
|
+
plan Generate module deployment plans
|
|
30
|
+
package Package module for distribution
|
|
31
|
+
export Export database migrations from existing databases
|
|
32
|
+
|
|
33
|
+
Database Administration:
|
|
34
|
+
kill Terminate database connections and optionally drop databases
|
|
35
|
+
install Install database modules
|
|
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
|
+
|
|
43
|
+
Migration Tools:
|
|
44
|
+
migrate Migration management subcommands
|
|
45
|
+
init Initialize migration tracking
|
|
46
|
+
status Show migration status
|
|
47
|
+
list List all changes
|
|
48
|
+
deps Show change dependencies
|
|
49
|
+
|
|
50
|
+
Global Options:
|
|
51
|
+
-h, --help Display this help information
|
|
52
|
+
-v, --version Display version information
|
|
53
|
+
--cwd <directory> Working directory (default: current directory)
|
|
54
|
+
|
|
55
|
+
Individual Command Help:
|
|
56
|
+
constructive <command> --help Display detailed help for specific command
|
|
57
|
+
constructive <command> -h Display detailed help for specific command
|
|
58
|
+
|
|
59
|
+
Examples:
|
|
60
|
+
constructive deploy --help Show deploy command options
|
|
61
|
+
constructive init --workspace Initialize new workspace
|
|
62
|
+
constructive install @pgpm/base32 Install a database module
|
|
63
|
+
`;
|
|
64
|
+
function displayUsage() {
|
|
65
|
+
console.log(exports.usageText);
|
|
66
|
+
}
|
package/utils/index.d.ts
ADDED
package/utils/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./argv"), exports);
|
|
18
|
+
__exportStar(require("./database"), exports);
|
|
19
|
+
__exportStar(require("./display"), exports);
|
|
20
|
+
__exportStar(require("./cli-error"), exports);
|
|
21
|
+
__exportStar(require("./deployed-changes"), exports);
|
|
22
|
+
__exportStar(require("./module-utils"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Logger } from '@launchql/logger';
|
|
2
|
+
import { Inquirerer } from 'inquirerer';
|
|
3
|
+
import { ParsedArgs } from 'minimist';
|
|
4
|
+
/**
|
|
5
|
+
* Handle package selection for operations that need a specific package
|
|
6
|
+
* Returns the selected package name, or undefined if validation fails or no packages exist
|
|
7
|
+
*/
|
|
8
|
+
export declare function selectPackage(argv: Partial<ParsedArgs>, prompter: Inquirerer, cwd: string, operationName: string, log?: Logger): Promise<string | undefined>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectPackage = selectPackage;
|
|
4
|
+
const core_1 = require("@launchql/core");
|
|
5
|
+
const types_1 = require("@launchql/types");
|
|
6
|
+
/**
|
|
7
|
+
* Handle package selection for operations that need a specific package
|
|
8
|
+
* Returns the selected package name, or undefined if validation fails or no packages exist
|
|
9
|
+
*/
|
|
10
|
+
async function selectPackage(argv, prompter, cwd, operationName, log) {
|
|
11
|
+
const pkg = new core_1.LaunchQLPackage(cwd);
|
|
12
|
+
const modules = await pkg.getModules();
|
|
13
|
+
const moduleNames = modules.map(mod => mod.getModuleName());
|
|
14
|
+
// Check if any modules exist
|
|
15
|
+
if (!moduleNames.length) {
|
|
16
|
+
const errorMsg = 'No modules found in the specified directory.';
|
|
17
|
+
if (log) {
|
|
18
|
+
log.error(errorMsg);
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
prompter.close();
|
|
23
|
+
throw types_1.errors.NOT_FOUND({}, errorMsg);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// If a specific package was provided, validate it
|
|
27
|
+
if (argv.package) {
|
|
28
|
+
const packageName = argv.package;
|
|
29
|
+
if (log)
|
|
30
|
+
log.info(`Using specified package: ${packageName}`);
|
|
31
|
+
if (!moduleNames.includes(packageName)) {
|
|
32
|
+
const errorMsg = `Package '${packageName}' not found. Available packages: ${moduleNames.join(', ')}`;
|
|
33
|
+
if (log) {
|
|
34
|
+
log.error(errorMsg);
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
throw types_1.errors.NOT_FOUND({}, errorMsg);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return packageName;
|
|
42
|
+
}
|
|
43
|
+
// Interactive selection
|
|
44
|
+
const { package: selectedPackage } = await prompter.prompt(argv, [{
|
|
45
|
+
type: 'autocomplete',
|
|
46
|
+
name: 'package',
|
|
47
|
+
message: `Choose a package to ${operationName}`,
|
|
48
|
+
options: moduleNames,
|
|
49
|
+
required: true
|
|
50
|
+
}]);
|
|
51
|
+
if (log)
|
|
52
|
+
log.info(`Selected package: ${selectedPackage}`);
|
|
53
|
+
return selectedPackage;
|
|
54
|
+
}
|