@constructive-io/cli 0.0.2 → 5.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.
Files changed (130) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +320 -189
  3. package/commands/{analyze.d.ts → codegen.d.ts} +2 -2
  4. package/commands/codegen.js +131 -0
  5. package/commands/explorer.js +94 -0
  6. package/commands/get-graphql-schema.js +73 -0
  7. package/commands/server.js +187 -0
  8. package/commands.d.ts +0 -1
  9. package/commands.js +42 -61
  10. package/esm/commands/codegen.js +126 -0
  11. package/esm/commands/explorer.js +92 -0
  12. package/esm/commands/get-graphql-schema.js +71 -0
  13. package/esm/commands/server.js +185 -0
  14. package/esm/commands.js +41 -59
  15. package/esm/index.js +16 -36
  16. package/esm/utils/display.js +26 -23
  17. package/esm/utils/index.js +3 -6
  18. package/index.d.ts +0 -22
  19. package/index.js +16 -72
  20. package/package.json +44 -29
  21. package/utils/display.d.ts +1 -1
  22. package/utils/display.js +26 -23
  23. package/utils/index.d.ts +3 -6
  24. package/utils/index.js +7 -20
  25. package/commands/add.d.ts +0 -7
  26. package/commands/add.js +0 -86
  27. package/commands/admin-users/add.d.ts +0 -4
  28. package/commands/admin-users/add.js +0 -89
  29. package/commands/admin-users/bootstrap.d.ts +0 -4
  30. package/commands/admin-users/bootstrap.js +0 -50
  31. package/commands/admin-users/remove.d.ts +0 -4
  32. package/commands/admin-users/remove.js +0 -82
  33. package/commands/admin-users.d.ts +0 -4
  34. package/commands/admin-users.js +0 -68
  35. package/commands/analyze.js +0 -21
  36. package/commands/clear.d.ts +0 -3
  37. package/commands/clear.js +0 -59
  38. package/commands/deploy.d.ts +0 -4
  39. package/commands/deploy.js +0 -146
  40. package/commands/docker.d.ts +0 -3
  41. package/commands/docker.js +0 -194
  42. package/commands/env.d.ts +0 -4
  43. package/commands/env.js +0 -124
  44. package/commands/export.js +0 -129
  45. package/commands/extension.js +0 -48
  46. package/commands/init/index.d.ts +0 -7
  47. package/commands/init/index.js +0 -47
  48. package/commands/init/module.d.ts +0 -4
  49. package/commands/init/module.js +0 -71
  50. package/commands/init/workspace.d.ts +0 -4
  51. package/commands/init/workspace.js +0 -52
  52. package/commands/install.d.ts +0 -4
  53. package/commands/install.js +0 -37
  54. package/commands/kill.js +0 -107
  55. package/commands/migrate/deps.d.ts +0 -4
  56. package/commands/migrate/deps.js +0 -186
  57. package/commands/migrate/init.d.ts +0 -4
  58. package/commands/migrate/init.js +0 -65
  59. package/commands/migrate/list.d.ts +0 -4
  60. package/commands/migrate/list.js +0 -85
  61. package/commands/migrate/status.d.ts +0 -4
  62. package/commands/migrate/status.js +0 -94
  63. package/commands/migrate.d.ts +0 -4
  64. package/commands/migrate.js +0 -69
  65. package/commands/package.d.ts +0 -3
  66. package/commands/package.js +0 -65
  67. package/commands/plan.d.ts +0 -3
  68. package/commands/plan.js +0 -62
  69. package/commands/remove.d.ts +0 -3
  70. package/commands/remove.js +0 -42
  71. package/commands/rename.d.ts +0 -4
  72. package/commands/rename.js +0 -35
  73. package/commands/revert.d.ts +0 -3
  74. package/commands/revert.js +0 -107
  75. package/commands/tag.d.ts +0 -6
  76. package/commands/tag.js +0 -168
  77. package/commands/verify.d.ts +0 -3
  78. package/commands/verify.js +0 -85
  79. package/dist/README.md +0 -412
  80. package/dist/package.json +0 -64
  81. package/esm/commands/add.js +0 -51
  82. package/esm/commands/admin-users/add.js +0 -87
  83. package/esm/commands/admin-users/bootstrap.js +0 -48
  84. package/esm/commands/admin-users/remove.js +0 -80
  85. package/esm/commands/admin-users.js +0 -63
  86. package/esm/commands/analyze.js +0 -16
  87. package/esm/commands/clear.js +0 -54
  88. package/esm/commands/deploy.js +0 -144
  89. package/esm/commands/docker.js +0 -192
  90. package/esm/commands/env.js +0 -122
  91. package/esm/commands/export.js +0 -127
  92. package/esm/commands/extension.js +0 -46
  93. package/esm/commands/init/index.js +0 -42
  94. package/esm/commands/init/module.js +0 -68
  95. package/esm/commands/init/workspace.js +0 -46
  96. package/esm/commands/install.js +0 -35
  97. package/esm/commands/kill.js +0 -105
  98. package/esm/commands/migrate/deps.js +0 -184
  99. package/esm/commands/migrate/init.js +0 -63
  100. package/esm/commands/migrate/list.js +0 -83
  101. package/esm/commands/migrate/status.js +0 -92
  102. package/esm/commands/migrate.js +0 -64
  103. package/esm/commands/package.js +0 -63
  104. package/esm/commands/plan.js +0 -60
  105. package/esm/commands/remove.js +0 -40
  106. package/esm/commands/rename.js +0 -30
  107. package/esm/commands/revert.js +0 -105
  108. package/esm/commands/tag.js +0 -133
  109. package/esm/commands/verify.js +0 -83
  110. package/esm/package.js +0 -26
  111. package/esm/utils/argv.js +0 -92
  112. package/esm/utils/cli-error.js +0 -48
  113. package/esm/utils/database.js +0 -78
  114. package/esm/utils/deployed-changes.js +0 -68
  115. package/esm/utils/module-utils.js +0 -51
  116. package/package.d.ts +0 -1
  117. package/package.js +0 -29
  118. package/utils/argv.d.ts +0 -46
  119. package/utils/argv.js +0 -100
  120. package/utils/cli-error.d.ts +0 -8
  121. package/utils/cli-error.js +0 -52
  122. package/utils/database.d.ts +0 -21
  123. package/utils/database.js +0 -83
  124. package/utils/deployed-changes.d.ts +0 -4
  125. package/utils/deployed-changes.js +0 -72
  126. package/utils/module-utils.d.ts +0 -8
  127. package/utils/module-utils.js +0 -54
  128. /package/commands/{export.d.ts → explorer.d.ts} +0 -0
  129. /package/commands/{extension.d.ts → get-graphql-schema.d.ts} +0 -0
  130. /package/commands/{kill.d.ts → server.d.ts} +0 -0
@@ -1,69 +0,0 @@
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 deps_1 = __importDefault(require("./migrate/deps"));
8
- // Migrate subcommands
9
- const init_1 = __importDefault(require("./migrate/init"));
10
- const list_1 = __importDefault(require("./migrate/list"));
11
- const status_1 = __importDefault(require("./migrate/status"));
12
- const subcommandMap = {
13
- init: init_1.default,
14
- status: status_1.default,
15
- list: list_1.default,
16
- deps: deps_1.default
17
- };
18
- const migrateUsageText = `
19
- Migrate Commands:
20
-
21
- launchql migrate init Initialize migration tracking in database
22
- launchql migrate status Show current migration status
23
- launchql migrate list List all changes (deployed and pending)
24
- launchql migrate deps Show change dependencies
25
-
26
- Options:
27
- --help, -h Show this help message
28
- --cwd Working directory (default: current directory)
29
- `;
30
- exports.default = async (argv, prompter, options) => {
31
- let { first: subcommand, newArgv } = (0, utils_1.extractFirst)(argv);
32
- // Show usage if explicitly requested
33
- if (argv.help || argv.h || subcommand === 'help') {
34
- console.log(migrateUsageText);
35
- process.exit(0);
36
- }
37
- // Prompt if no subcommand provided
38
- if (!subcommand) {
39
- const answer = await prompter.prompt(argv, [
40
- {
41
- type: 'autocomplete',
42
- name: 'subcommand',
43
- message: 'What migrate operation do you want to perform?',
44
- options: Object.keys(subcommandMap).map(cmd => ({
45
- name: cmd,
46
- value: cmd,
47
- description: getSubcommandDescription(cmd)
48
- }))
49
- }
50
- ]);
51
- subcommand = answer.subcommand;
52
- }
53
- const subcommandFn = subcommandMap[subcommand];
54
- if (!subcommandFn) {
55
- console.error(`Unknown migrate subcommand: ${subcommand}`);
56
- console.log(migrateUsageText);
57
- process.exit(1);
58
- }
59
- await subcommandFn(newArgv, prompter, options);
60
- };
61
- function getSubcommandDescription(cmd) {
62
- const descriptions = {
63
- init: 'Initialize migration tracking in database',
64
- status: 'Show current migration status',
65
- list: 'List all changes (deployed and pending)',
66
- deps: 'Show change dependencies'
67
- };
68
- return descriptions[cmd] || '';
69
- }
@@ -1,3 +0,0 @@
1
- import { CLIOptions, Inquirerer } from 'inquirerer';
2
- declare const _default: (argv: Partial<Record<string, any>>, prompter: Inquirerer, _options: CLIOptions) => Promise<Partial<Record<string, any>>>;
3
- export default _default;
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@launchql/core");
4
- const packageUsageText = `
5
- Package Command:
6
-
7
- constructive package [OPTIONS]
8
-
9
- Package module for distribution.
10
-
11
- Options:
12
- --help, -h Show this help message
13
- --plan Include deployment plan (default: true)
14
- --pretty Pretty-print output (default: true)
15
- --functionDelimiter <delimiter> Function delimiter (default: $EOFCODE$)
16
- --cwd <directory> Working directory (default: current directory)
17
-
18
- Examples:
19
- constructive package Package with defaults
20
- constructive package --no-plan Package without plan
21
- `;
22
- exports.default = async (argv, prompter, _options) => {
23
- // Show usage if explicitly requested
24
- if (argv.help || argv.h) {
25
- console.log(packageUsageText);
26
- process.exit(0);
27
- }
28
- const questions = [
29
- {
30
- type: 'confirm',
31
- name: 'plan',
32
- default: true,
33
- useDefault: true,
34
- required: true
35
- },
36
- {
37
- type: 'confirm',
38
- name: 'pretty',
39
- default: true,
40
- useDefault: true,
41
- required: true
42
- },
43
- {
44
- type: 'text',
45
- name: 'functionDelimiter',
46
- default: '$EOFCODE$',
47
- useDefault: true,
48
- required: false
49
- }
50
- ];
51
- let { cwd, plan, pretty, functionDelimiter } = await prompter.prompt(argv, questions);
52
- const project = new core_1.LaunchQLPackage(cwd);
53
- project.ensureModule();
54
- const info = project.getModuleInfo();
55
- info.version;
56
- await (0, core_1.writePackage)({
57
- version: info.version,
58
- extension: true,
59
- usePlan: plan,
60
- packageDir: project.modulePath,
61
- pretty,
62
- functionDelimiter
63
- });
64
- return argv;
65
- };
@@ -1,3 +0,0 @@
1
- import { CLIOptions, Inquirerer } from 'inquirerer';
2
- declare const _default: (argv: Partial<Record<string, any>>, prompter: Inquirerer, _options: CLIOptions) => Promise<Partial<Record<string, any>>>;
3
- export default _default;
package/commands/plan.js DELETED
@@ -1,62 +0,0 @@
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 log = new logger_1.Logger('plan');
6
- const planUsageText = `
7
- Plan Command:
8
-
9
- constructive plan [OPTIONS]
10
-
11
- Generate module deployment plans.
12
-
13
- Options:
14
- --help, -h Show this help message
15
- --includePackages Include packages in plan (default: true)
16
- --includeTags Prefer @tag references for external packages when available (default: true)
17
- --cwd <directory> Working directory (default: current directory)
18
-
19
- Examples:
20
- constructive plan Generate deployment plan for current module with defaults
21
- constructive plan --includePackages false Disable including external packages
22
- constructive plan --includeTags false Do not prefer tags for external packages
23
- `;
24
- exports.default = async (argv, prompter, _options) => {
25
- // Show usage if explicitly requested
26
- if (argv.help || argv.h) {
27
- console.log(planUsageText);
28
- process.exit(0);
29
- }
30
- const questions = [
31
- {
32
- type: 'confirm',
33
- name: 'includePackages',
34
- message: 'Include packages in plan?',
35
- useDefault: true,
36
- default: true
37
- },
38
- {
39
- type: 'confirm',
40
- name: 'includeTags',
41
- message: 'Prefer @tag references for external packages when available?',
42
- useDefault: true,
43
- default: true
44
- }
45
- ];
46
- let { cwd, includePackages, includeTags } = await prompter.prompt(argv, questions);
47
- if (!cwd) {
48
- cwd = process.cwd();
49
- log.info(`Using current directory: ${cwd}`);
50
- }
51
- const pkg = new core_1.LaunchQLPackage(cwd);
52
- if (!pkg.isInModule()) {
53
- throw new Error('This command must be run inside a LaunchQL module.');
54
- }
55
- const includePackagesFlag = typeof includePackages === 'boolean' ? includePackages : true;
56
- const includeTagsFlag = typeof includeTags === 'boolean' ? includeTags : true;
57
- pkg.writeModulePlan({
58
- includePackages: includePackagesFlag,
59
- includeTags: includeTagsFlag
60
- });
61
- return argv;
62
- };
@@ -1,3 +0,0 @@
1
- import { CLIOptions, Inquirerer } from 'inquirerer';
2
- declare const _default: (argv: Partial<Record<string, any>>, prompter: Inquirerer, _options: CLIOptions) => Promise<Partial<Record<string, any>>>;
3
- export default _default;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@launchql/core");
4
- const env_1 = require("@launchql/env");
5
- const logger_1 = require("@launchql/logger");
6
- const pg_env_1 = require("pg-env");
7
- const utils_1 = require("../utils");
8
- const cli_error_1 = require("../utils/cli-error");
9
- const log = new logger_1.Logger('remove');
10
- exports.default = async (argv, prompter, _options) => {
11
- if (!argv.to) {
12
- await (0, cli_error_1.cliExitWithError)('No change specified. Usage: constructive remove --to <change>');
13
- }
14
- const database = await (0, utils_1.getTargetDatabase)(argv, prompter, {
15
- message: 'Select database'
16
- });
17
- const questions = [
18
- {
19
- name: 'yes',
20
- type: 'confirm',
21
- message: 'Are you sure you want to proceed with removing changes?',
22
- required: true
23
- }
24
- ];
25
- let { yes, cwd } = await prompter.prompt(argv, questions);
26
- if (!yes) {
27
- log.info('Operation cancelled.');
28
- return;
29
- }
30
- log.debug(`Using current directory: ${cwd}`);
31
- const pkg = new core_1.LaunchQLPackage(cwd);
32
- if (!pkg.isInModule()) {
33
- throw new Error('Not in a LaunchQL module directory. Please run this command from within a module.');
34
- }
35
- const opts = (0, env_1.getEnvOptions)({
36
- pg: (0, pg_env_1.getPgEnvOptions)({ database })
37
- });
38
- const toChange = argv.to;
39
- await pkg.removeFromPlan(toChange);
40
- log.success(`✅ Successfully removed changes from '${toChange}' to end of plan.`);
41
- return argv;
42
- };
@@ -1,4 +0,0 @@
1
- import { Inquirerer } from 'inquirerer';
2
- import { ParsedArgs } from 'minimist';
3
- declare const _default: (argv: Partial<ParsedArgs>, _prompter: Inquirerer) => Promise<void>;
4
- export default _default;
@@ -1,35 +0,0 @@
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 path_1 = __importDefault(require("path"));
8
- const cli_error_1 = require("../utils/cli-error");
9
- exports.default = async (argv, _prompter) => {
10
- const cwd = argv.cwd || process.cwd();
11
- const to = argv.to || (argv._ && argv._[0]);
12
- if (!to) {
13
- await (0, cli_error_1.cliExitWithError)('Missing new name. Use --to <name> or provide as positional argument.');
14
- }
15
- const dryRun = !!argv['dry-run'] || !!argv.dryRun;
16
- const syncPkg = !!argv['sync-pkg-name'] || !!argv.syncPkgName;
17
- const proj = new core_1.LaunchQLPackage(path_1.default.resolve(cwd));
18
- const res = proj.renameModule(to, { dryRun, syncPackageJsonName: syncPkg });
19
- if (dryRun) {
20
- console.log('Dry run');
21
- }
22
- if (res.changed.length > 0) {
23
- console.log('Changed:');
24
- for (const f of res.changed)
25
- console.log(`- ${f}`);
26
- }
27
- else {
28
- console.log('No changes');
29
- }
30
- if (res.warnings.length > 0) {
31
- console.log('Warnings:');
32
- for (const w of res.warnings)
33
- console.log(`- ${w}`);
34
- }
35
- };
@@ -1,3 +0,0 @@
1
- import { CLIOptions, Inquirerer } from 'inquirerer';
2
- declare const _default: (argv: Partial<Record<string, any>>, prompter: Inquirerer, _options: CLIOptions) => Promise<Partial<Record<string, any>>>;
3
- export default _default;
@@ -1,107 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@launchql/core");
4
- const env_1 = require("@launchql/env");
5
- const logger_1 = require("@launchql/logger");
6
- const pg_env_1 = require("pg-env");
7
- const utils_1 = require("../utils");
8
- const cli_error_1 = require("../utils/cli-error");
9
- const deployed_changes_1 = require("../utils/deployed-changes");
10
- const log = new logger_1.Logger('revert');
11
- const revertUsageText = `
12
- Revert Command:
13
-
14
- constructive revert [OPTIONS]
15
-
16
- Revert database changes and migrations.
17
-
18
- Options:
19
- --help, -h Show this help message
20
- --recursive Revert recursively through dependencies
21
- --package <name> Revert specific package
22
- --to <target> Revert to specific change or tag
23
- --to Interactive selection of deployed changes
24
- --tx Use transactions (default: true)
25
- --cwd <directory> Working directory (default: current directory)
26
-
27
- Examples:
28
- constructive revert Revert latest changes
29
- constructive revert --to @v1.0.0 Revert to specific tag
30
- constructive revert --to Interactive selection from deployed changes
31
- `;
32
- exports.default = async (argv, prompter, _options) => {
33
- // Show usage if explicitly requested
34
- if (argv.help || argv.h) {
35
- console.log(revertUsageText);
36
- process.exit(0);
37
- }
38
- const database = await (0, utils_1.getTargetDatabase)(argv, prompter, {
39
- message: 'Select database'
40
- });
41
- const questions = [
42
- {
43
- name: 'yes',
44
- type: 'confirm',
45
- message: 'Are you sure you want to proceed?',
46
- required: true
47
- },
48
- {
49
- name: 'recursive',
50
- type: 'confirm',
51
- message: 'Deploy recursively through dependencies?',
52
- useDefault: true,
53
- default: true,
54
- required: false
55
- },
56
- {
57
- name: 'tx',
58
- type: 'confirm',
59
- message: 'Use Transaction?',
60
- useDefault: true,
61
- default: true,
62
- required: false
63
- }
64
- ];
65
- let { yes, recursive, cwd, tx } = await prompter.prompt(argv, questions);
66
- if (!yes) {
67
- log.info('Operation cancelled.');
68
- return;
69
- }
70
- log.debug(`Using current directory: ${cwd}`);
71
- let packageName;
72
- if (recursive && argv.to !== true) {
73
- packageName = await (0, deployed_changes_1.selectDeployedPackage)(database, argv, prompter, log, 'revert');
74
- if (!packageName) {
75
- await (0, cli_error_1.cliExitWithError)('No package found to revert');
76
- }
77
- }
78
- const pkg = new core_1.LaunchQLPackage(cwd);
79
- const opts = (0, env_1.getEnvOptions)({
80
- pg: (0, pg_env_1.getPgEnvOptions)({ database }),
81
- deployment: {
82
- useTx: tx
83
- }
84
- });
85
- let target;
86
- if (argv.to === true) {
87
- target = await (0, deployed_changes_1.selectDeployedChange)(database, argv, prompter, log, 'revert');
88
- if (!target) {
89
- await (0, cli_error_1.cliExitWithError)('No target selected, operation cancelled');
90
- }
91
- }
92
- else if (packageName && argv.to) {
93
- target = `${packageName}:${argv.to}`;
94
- }
95
- else if (packageName) {
96
- target = packageName;
97
- }
98
- else if (argv.package && argv.to) {
99
- target = `${argv.package}:${argv.to}`;
100
- }
101
- else if (argv.package) {
102
- target = argv.package;
103
- }
104
- await pkg.revert(opts, target, recursive);
105
- log.success('Revert complete.');
106
- return argv;
107
- };
package/commands/tag.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { CLIOptions, Inquirerer } from 'inquirerer';
2
- declare const _default: (argv: Partial<Record<string, any>>, prompter: Inquirerer, _options: CLIOptions) => Promise<{
3
- _: string[];
4
- "--"?: string[] | undefined;
5
- }>;
6
- export default _default;
package/commands/tag.js DELETED
@@ -1,168 +0,0 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- const core_1 = require("@launchql/core");
37
- const logger_1 = require("@launchql/logger");
38
- const types_1 = require("@launchql/types");
39
- const path = __importStar(require("path"));
40
- const argv_1 = require("../utils/argv");
41
- const module_utils_1 = require("../utils/module-utils");
42
- const log = new logger_1.Logger('tag');
43
- const tagUsageText = `
44
- Tag Command:
45
-
46
- constructive tag [tag_name] [OPTIONS]
47
-
48
- Add tags to changes for versioning.
49
-
50
- Arguments:
51
- tag_name Name of the tag to create
52
-
53
- Options:
54
- --help, -h Show this help message
55
- --package <name> Target specific package
56
- --changeName <name> Target specific change (default: latest)
57
- --comment <text> Optional tag comment
58
- --cwd <directory> Working directory (default: current directory)
59
-
60
- Examples:
61
- constructive tag v1.0.0 Add tag to latest change
62
- constructive tag v1.0.0 --comment "Initial release" Add tag with comment
63
- constructive tag v1.1.0 --package mypackage --changeName my-change Tag specific change in package
64
- `;
65
- exports.default = async (argv, prompter, _options) => {
66
- // Show usage if explicitly requested
67
- if (argv.help || argv.h) {
68
- console.log(tagUsageText);
69
- process.exit(0);
70
- }
71
- const { first: tagName, newArgv } = (0, argv_1.extractFirst)(argv);
72
- const cwdResult = await prompter.prompt(newArgv, [
73
- {
74
- type: 'text',
75
- name: 'cwd',
76
- message: 'Working directory',
77
- required: false,
78
- default: process.cwd(),
79
- useDefault: true
80
- }
81
- ]);
82
- const cwd = cwdResult.cwd || process.cwd();
83
- const pkg = new core_1.LaunchQLPackage(cwd);
84
- let packageName;
85
- if (argv.package) {
86
- packageName = argv.package;
87
- log.info(`Using specified package: ${packageName}`);
88
- }
89
- else if (pkg.isInModule()) {
90
- packageName = pkg.getModuleName();
91
- log.info(`Using current module: ${packageName}`);
92
- }
93
- else if (pkg.isInWorkspace()) {
94
- packageName = await (0, module_utils_1.selectPackage)(newArgv, prompter, cwd, 'add tag to', log);
95
- if (!packageName) {
96
- throw new Error('No package selected. Cannot add tag without specifying a target package.');
97
- }
98
- }
99
- else {
100
- throw new Error('This command must be run inside a LaunchQL workspace or module.');
101
- }
102
- const questions = [];
103
- if (!tagName) {
104
- questions.push({
105
- type: 'text',
106
- name: 'tagName',
107
- message: 'Tag name',
108
- required: true,
109
- validate: (value) => {
110
- if (!value || value.trim().length === 0) {
111
- return false;
112
- }
113
- if (value.includes('/')) {
114
- return false;
115
- }
116
- if (value.includes('@')) {
117
- return false;
118
- }
119
- return true;
120
- }
121
- });
122
- }
123
- questions.push({
124
- type: 'text',
125
- name: 'changeName',
126
- message: 'Target change name (leave empty for latest change)',
127
- required: false
128
- }, {
129
- type: 'text',
130
- name: 'comment',
131
- message: 'Tag comment (optional)',
132
- required: false
133
- });
134
- const answers = await prompter.prompt(newArgv, questions);
135
- const finalTagName = tagName || answers.tagName;
136
- const changeName = answers.changeName;
137
- const comment = answers.comment;
138
- try {
139
- if (argv.package || !pkg.isInModule()) {
140
- const moduleMap = pkg.getModuleMap();
141
- const module = moduleMap[packageName];
142
- if (!module) {
143
- throw types_1.errors.MODULE_NOT_FOUND({ name: packageName });
144
- }
145
- const workspacePath = pkg.getWorkspacePath();
146
- const absoluteModulePath = path.resolve(workspacePath, module.path);
147
- const originalCwd = process.cwd();
148
- process.chdir(absoluteModulePath);
149
- try {
150
- const modulePkg = new core_1.LaunchQLPackage(absoluteModulePath);
151
- modulePkg.addTag(finalTagName.trim(), changeName?.trim() || undefined, comment?.trim() || undefined);
152
- log.info(`Successfully added tag '${finalTagName}' to ${changeName || 'latest change'} in package '${packageName}'`);
153
- }
154
- finally {
155
- process.chdir(originalCwd);
156
- }
157
- }
158
- else {
159
- pkg.addTag(finalTagName.trim(), changeName?.trim() || undefined, comment?.trim() || undefined);
160
- log.info(`Successfully added tag '${finalTagName}' to ${changeName || 'latest change'}`);
161
- }
162
- }
163
- catch (error) {
164
- log.error(`Failed to add tag: ${error instanceof Error ? error.message : String(error)}`);
165
- throw error;
166
- }
167
- return newArgv;
168
- };
@@ -1,3 +0,0 @@
1
- import { CLIOptions, Inquirerer } from 'inquirerer';
2
- declare const _default: (argv: Partial<Record<string, any>>, prompter: Inquirerer, _options: CLIOptions) => Promise<Partial<Record<string, any>>>;
3
- export default _default;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@launchql/core");
4
- const env_1 = require("@launchql/env");
5
- const logger_1 = require("@launchql/logger");
6
- const pg_env_1 = require("pg-env");
7
- const utils_1 = require("../utils");
8
- const cli_error_1 = require("../utils/cli-error");
9
- const deployed_changes_1 = require("../utils/deployed-changes");
10
- const log = new logger_1.Logger('verify');
11
- const verifyUsageText = `
12
- Verify Command:
13
-
14
- constructive verify [OPTIONS]
15
-
16
- Verify database state matches expected migrations.
17
-
18
- Options:
19
- --help, -h Show this help message
20
- --recursive Verify recursively through dependencies
21
- --package <name> Verify specific package
22
- --to <target> Verify up to specific change or tag
23
- --to Interactive selection of deployed changes
24
- --cwd <directory> Working directory (default: current directory)
25
-
26
- Examples:
27
- constructive verify Verify current database state
28
- constructive verify --package mypackage Verify specific package
29
- constructive verify --to Interactive selection from deployed changes
30
- `;
31
- exports.default = async (argv, prompter, _options) => {
32
- // Show usage if explicitly requested
33
- if (argv.help || argv.h) {
34
- console.log(verifyUsageText);
35
- process.exit(0);
36
- }
37
- const database = await (0, utils_1.getTargetDatabase)(argv, prompter, {
38
- message: 'Select database'
39
- });
40
- const questions = [
41
- {
42
- name: 'recursive',
43
- type: 'confirm',
44
- message: 'Deploy recursively through dependencies?',
45
- useDefault: true,
46
- default: true,
47
- required: false
48
- },
49
- ];
50
- let { recursive, cwd } = await prompter.prompt(argv, questions);
51
- log.debug(`Using current directory: ${cwd}`);
52
- let packageName;
53
- if (recursive && argv.to !== true) {
54
- packageName = await (0, deployed_changes_1.selectDeployedPackage)(database, argv, prompter, log, 'verify');
55
- if (!packageName) {
56
- await (0, cli_error_1.cliExitWithError)('No package found to verify');
57
- }
58
- }
59
- const project = new core_1.LaunchQLPackage(cwd);
60
- const opts = (0, env_1.getEnvOptions)({
61
- pg: (0, pg_env_1.getPgEnvOptions)({ database })
62
- });
63
- let target;
64
- if (argv.to === true) {
65
- target = await (0, deployed_changes_1.selectDeployedChange)(database, argv, prompter, log, 'verify');
66
- if (!target) {
67
- await (0, cli_error_1.cliExitWithError)('No target selected, operation cancelled');
68
- }
69
- }
70
- else if (packageName && argv.to) {
71
- target = `${packageName}:${argv.to}`;
72
- }
73
- else if (packageName) {
74
- target = packageName;
75
- }
76
- else if (argv.package && argv.to) {
77
- target = `${argv.package}:${argv.to}`;
78
- }
79
- else if (argv.package) {
80
- target = argv.package;
81
- }
82
- await project.verify(opts, target, recursive);
83
- log.success('Verify complete.');
84
- return argv;
85
- };