@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,194 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const child_process_1 = require("child_process");
4
- const utils_1 = require("../utils");
5
- const dockerUsageText = `
6
- Docker Command:
7
-
8
- constructive docker <subcommand> [OPTIONS]
9
-
10
- Manage PostgreSQL Docker containers for local development.
11
-
12
- Subcommands:
13
- start Start PostgreSQL container
14
- stop Stop PostgreSQL container
15
-
16
- Options:
17
- --help, -h Show this help message
18
- --name <name> Container name (default: postgres)
19
- --image <image> Docker image (default: pyramation/pgvector:13.3-alpine)
20
- --port <port> Host port mapping (default: 5432)
21
- --user <user> PostgreSQL user (default: postgres)
22
- --password <pass> PostgreSQL password (default: password)
23
- --recreate Remove and recreate container on start
24
-
25
- Examples:
26
- constructive docker start Start default PostgreSQL container
27
- constructive docker start --port 5433 Start on custom port
28
- constructive docker start --recreate Remove and recreate container
29
- constructive docker stop Stop PostgreSQL container
30
- `;
31
- function run(command, args, options = {}) {
32
- return new Promise((resolve, reject) => {
33
- const stdio = options.stdio || 'pipe';
34
- const child = (0, child_process_1.spawn)(command, args, { stdio });
35
- let stdout = '';
36
- let stderr = '';
37
- if (stdio === 'pipe') {
38
- child.stdout?.on('data', (data) => {
39
- stdout += data.toString();
40
- });
41
- child.stderr?.on('data', (data) => {
42
- stderr += data.toString();
43
- });
44
- }
45
- child.on('error', (error) => {
46
- reject(error);
47
- });
48
- child.on('close', (code) => {
49
- resolve({
50
- code: code ?? 0,
51
- stdout: stdout.trim(),
52
- stderr: stderr.trim()
53
- });
54
- });
55
- });
56
- }
57
- async function checkDockerAvailable() {
58
- try {
59
- const result = await run('docker', ['--version']);
60
- return result.code === 0;
61
- }
62
- catch (error) {
63
- return false;
64
- }
65
- }
66
- async function isContainerRunning(name) {
67
- try {
68
- const result = await run('docker', ['inspect', '-f', '{{.State.Running}}', name]);
69
- if (result.code === 0) {
70
- return result.stdout.trim() === 'true';
71
- }
72
- return null;
73
- }
74
- catch (error) {
75
- return null;
76
- }
77
- }
78
- async function containerExists(name) {
79
- try {
80
- const result = await run('docker', ['inspect', name]);
81
- return result.code === 0;
82
- }
83
- catch (error) {
84
- return false;
85
- }
86
- }
87
- async function startContainer(options) {
88
- const { name, image, port, user, password, recreate } = options;
89
- const dockerAvailable = await checkDockerAvailable();
90
- if (!dockerAvailable) {
91
- await (0, utils_1.cliExitWithError)('Docker is not installed or not available in PATH. Please install Docker first.');
92
- return;
93
- }
94
- const exists = await containerExists(name);
95
- const running = await isContainerRunning(name);
96
- if (running === true) {
97
- console.log(`✅ Container "${name}" is already running`);
98
- return;
99
- }
100
- if (recreate && exists) {
101
- console.log(`🗑️ Removing existing container "${name}"...`);
102
- const removeResult = await run('docker', ['rm', '-f', name], { stdio: 'inherit' });
103
- if (removeResult.code !== 0) {
104
- await (0, utils_1.cliExitWithError)(`Failed to remove container "${name}"`);
105
- return;
106
- }
107
- }
108
- if (exists && running === false) {
109
- console.log(`🔄 Starting existing container "${name}"...`);
110
- const startResult = await run('docker', ['start', name], { stdio: 'inherit' });
111
- if (startResult.code === 0) {
112
- console.log(`✅ Container "${name}" started successfully`);
113
- }
114
- else {
115
- await (0, utils_1.cliExitWithError)(`Failed to start container "${name}"`);
116
- }
117
- return;
118
- }
119
- console.log(`🚀 Creating and starting new container "${name}"...`);
120
- const runArgs = [
121
- 'run',
122
- '-d',
123
- '--name', name,
124
- '-e', `POSTGRES_USER=${user}`,
125
- '-e', `POSTGRES_PASSWORD=${password}`,
126
- '-p', `${port}:5432`,
127
- image
128
- ];
129
- const runResult = await run('docker', runArgs, { stdio: 'inherit' });
130
- if (runResult.code === 0) {
131
- console.log(`✅ Container "${name}" created and started successfully`);
132
- console.log(`📌 PostgreSQL is available at localhost:${port}`);
133
- console.log(`👤 User: ${user}`);
134
- console.log(`🔑 Password: ${password}`);
135
- }
136
- else {
137
- await (0, utils_1.cliExitWithError)(`Failed to create container "${name}". Check if port ${port} is already in use.`);
138
- }
139
- }
140
- async function stopContainer(name) {
141
- const dockerAvailable = await checkDockerAvailable();
142
- if (!dockerAvailable) {
143
- await (0, utils_1.cliExitWithError)('Docker is not installed or not available in PATH. Please install Docker first.');
144
- return;
145
- }
146
- const exists = await containerExists(name);
147
- if (!exists) {
148
- console.log(`ℹ️ Container "${name}" not found`);
149
- return;
150
- }
151
- const running = await isContainerRunning(name);
152
- if (running === false) {
153
- console.log(`ℹ️ Container "${name}" is already stopped`);
154
- return;
155
- }
156
- console.log(`🛑 Stopping container "${name}"...`);
157
- const stopResult = await run('docker', ['stop', name], { stdio: 'inherit' });
158
- if (stopResult.code === 0) {
159
- console.log(`✅ Container "${name}" stopped successfully`);
160
- }
161
- else {
162
- await (0, utils_1.cliExitWithError)(`Failed to stop container "${name}"`);
163
- }
164
- }
165
- exports.default = async (argv, _prompter, _options) => {
166
- if (argv.help || argv.h) {
167
- console.log(dockerUsageText);
168
- process.exit(0);
169
- }
170
- const { first: subcommand, newArgv } = (0, utils_1.extractFirst)(argv);
171
- const args = newArgv;
172
- if (!subcommand) {
173
- console.log(dockerUsageText);
174
- await (0, utils_1.cliExitWithError)('No subcommand provided. Use "start" or "stop".');
175
- return;
176
- }
177
- const name = args.name || 'postgres';
178
- const image = args.image || 'pyramation/pgvector:13.3-alpine';
179
- const port = typeof args.port === 'number' ? args.port : 5432;
180
- const user = args.user || 'postgres';
181
- const password = args.password || 'password';
182
- const recreate = args.recreate === true;
183
- switch (subcommand) {
184
- case 'start':
185
- await startContainer({ name, image, port, user, password, recreate });
186
- break;
187
- case 'stop':
188
- await stopContainer(name);
189
- break;
190
- default:
191
- console.log(dockerUsageText);
192
- await (0, utils_1.cliExitWithError)(`Unknown subcommand: ${subcommand}. Use "start" or "stop".`);
193
- }
194
- };
package/commands/env.d.ts DELETED
@@ -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;
package/commands/env.js DELETED
@@ -1,124 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const child_process_1 = require("child_process");
4
- const pg_env_1 = require("pg-env");
5
- const envUsageText = `
6
- Environment Command:
7
-
8
- constructive env [OPTIONS] [COMMAND...]
9
-
10
- Manage PostgreSQL environment variables with profile support.
11
-
12
- Profiles:
13
- (default) Use local Postgres development profile
14
- --supabase Use Supabase local development profile
15
-
16
- Modes:
17
- No command Print export statements for shell evaluation
18
- With command Execute command with environment variables applied
19
-
20
- Options:
21
- --help, -h Show this help message
22
- --supabase Use Supabase profile instead of default Postgres
23
-
24
- Examples:
25
- constructive env Print default Postgres env exports
26
- constructive env --supabase Print Supabase env exports
27
- eval "$(constructive env)" Load default Postgres env into shell
28
- eval "$(constructive env --supabase)" Load Supabase env into shell
29
- constructive env lql deploy --database db1 Run command with default Postgres env
30
- constructive env createdb mydb Run command with default Postgres env
31
- constructive env --supabase lql deploy --database db1 Run command with Supabase env
32
- constructive env --supabase createdb mydb Run command with Supabase env
33
- `;
34
- const SUPABASE_PROFILE = {
35
- host: 'localhost',
36
- port: 54322,
37
- user: 'supabase_admin',
38
- password: 'postgres',
39
- database: 'postgres'
40
- };
41
- const DEFAULT_PROFILE = {
42
- ...pg_env_1.defaultPgConfig
43
- };
44
- function configToEnvVars(config) {
45
- return {
46
- PGHOST: config.host,
47
- PGPORT: String(config.port),
48
- PGUSER: config.user,
49
- PGPASSWORD: config.password,
50
- PGDATABASE: config.database
51
- };
52
- }
53
- function printExports(config) {
54
- const envVars = configToEnvVars(config);
55
- for (const [key, value] of Object.entries(envVars)) {
56
- const escapedValue = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
57
- console.log(`export ${key}="${escapedValue}"`);
58
- }
59
- }
60
- function executeCommand(config, command, args) {
61
- return new Promise((resolve, reject) => {
62
- const envVars = configToEnvVars(config);
63
- const env = {
64
- ...process.env,
65
- ...envVars
66
- };
67
- const child = (0, child_process_1.spawn)(command, args, {
68
- env,
69
- stdio: 'inherit',
70
- shell: false
71
- });
72
- child.on('error', (error) => {
73
- reject(error);
74
- });
75
- child.on('close', (code) => {
76
- resolve(code ?? 0);
77
- });
78
- });
79
- }
80
- exports.default = async (argv, _prompter) => {
81
- if (argv.help || argv.h) {
82
- console.log(envUsageText);
83
- process.exit(0);
84
- }
85
- const useSupabase = argv.supabase === true || typeof argv.supabase === 'string';
86
- const profile = useSupabase ? SUPABASE_PROFILE : DEFAULT_PROFILE;
87
- const rawArgs = process.argv.slice(2);
88
- let envIndex = rawArgs.findIndex(arg => arg === 'env');
89
- if (envIndex === -1) {
90
- envIndex = 0;
91
- }
92
- const argsAfterEnv = rawArgs.slice(envIndex + 1);
93
- const supabaseIndex = argsAfterEnv.findIndex(arg => arg === '--supabase');
94
- let commandArgs;
95
- if (supabaseIndex !== -1) {
96
- commandArgs = argsAfterEnv.slice(supabaseIndex + 1);
97
- }
98
- else {
99
- commandArgs = argsAfterEnv;
100
- }
101
- commandArgs = commandArgs.filter(arg => arg !== '--cwd' && !arg.startsWith('--cwd='));
102
- const cwdIndex = commandArgs.findIndex(arg => arg === '--cwd');
103
- if (cwdIndex !== -1 && cwdIndex + 1 < commandArgs.length) {
104
- commandArgs.splice(cwdIndex, 2);
105
- }
106
- if (commandArgs.length === 0) {
107
- printExports(profile);
108
- return;
109
- }
110
- const [command, ...args] = commandArgs;
111
- try {
112
- const exitCode = await executeCommand(profile, command, args);
113
- process.exit(exitCode);
114
- }
115
- catch (error) {
116
- if (error instanceof Error) {
117
- console.error(`Error executing command: ${error.message}`);
118
- }
119
- else {
120
- console.error(`Error executing command: ${String(error)}`);
121
- }
122
- process.exit(1);
123
- }
124
- };
@@ -1,129 +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 types_1 = require("@launchql/types");
6
- const path_1 = require("path");
7
- const pg_cache_1 = require("pg-cache");
8
- const exportUsageText = `
9
- Export Command:
10
-
11
- constructive 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
- constructive 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
- };
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@launchql/core");
4
- const extensionUsageText = `
5
- Extension Command:
6
-
7
- constructive 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
- constructive 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
- };
@@ -1,7 +0,0 @@
1
- import { CLIOptions, Inquirerer } from 'inquirerer';
2
- declare const _default: (argv: Partial<Record<string, any>>, prompter: Inquirerer, _options: CLIOptions) => Promise<{
3
- [x: string]: any;
4
- } | {
5
- cwd: string;
6
- }>;
7
- export default _default;
@@ -1,47 +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 module_1 = __importDefault(require("./module"));
7
- const workspace_1 = __importDefault(require("./workspace"));
8
- const initUsageText = `
9
- Init Command:
10
-
11
- constructive init [OPTIONS]
12
-
13
- Initialize constructive workspace or module.
14
-
15
- Options:
16
- --help, -h Show this help message
17
- --workspace Initialize workspace instead of module
18
- --cwd <directory> Working directory (default: current directory)
19
- --repo <repo> Use templates from GitHub repository (e.g., owner/repo)
20
- --template-path <path> Use templates from local path
21
- --from-branch <branch> Specify branch when using --repo (default: main)
22
-
23
- Examples:
24
- constructive init Initialize new module in existing workspace
25
- constructive init --workspace Initialize new workspace
26
- constructive init --repo owner/repo Use templates from GitHub repository
27
- constructive init --template-path ./custom-templates Use templates from local path
28
- constructive init --repo owner/repo --from-branch develop Use specific branch
29
- `;
30
- exports.default = async (argv, prompter, _options) => {
31
- // Show usage if explicitly requested
32
- if (argv.help || argv.h) {
33
- console.log(initUsageText);
34
- process.exit(0);
35
- }
36
- return handlePromptFlow(argv, prompter);
37
- };
38
- async function handlePromptFlow(argv, prompter) {
39
- const { workspace } = argv;
40
- switch (workspace) {
41
- case true:
42
- return (0, workspace_1.default)(argv, prompter);
43
- case false:
44
- default:
45
- return (0, module_1.default)(argv, prompter);
46
- }
47
- }
@@ -1,4 +0,0 @@
1
- import { Inquirerer } from 'inquirerer';
2
- export default function runModuleSetup(argv: Partial<Record<string, any>>, prompter: Inquirerer): Promise<{
3
- [x: string]: any;
4
- }>;
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = runModuleSetup;
4
- const core_1 = require("@launchql/core");
5
- const logger_1 = require("@launchql/logger");
6
- const types_1 = require("@launchql/types");
7
- const log = new logger_1.Logger('module-init');
8
- async function runModuleSetup(argv, prompter) {
9
- const { email, username } = (0, types_1.getGitConfigInfo)();
10
- const { cwd = process.cwd() } = argv;
11
- const project = new core_1.LaunchQLPackage(cwd);
12
- if (!project.workspacePath) {
13
- log.error('Not inside a LaunchQL workspace.');
14
- throw types_1.errors.NOT_IN_WORKSPACE({});
15
- }
16
- if (!project.isInsideAllowedDirs(cwd) && !project.isInWorkspace() && !project.isParentOfAllowedDirs(cwd)) {
17
- log.error('You must be inside the workspace root or a parent directory of modules (like packages/).');
18
- throw types_1.errors.NOT_IN_WORKSPACE_MODULE({});
19
- }
20
- const availExtensions = project.getAvailableModules();
21
- const moduleQuestions = [
22
- {
23
- name: 'MODULENAME',
24
- message: 'Enter the module name',
25
- required: true,
26
- type: 'text',
27
- },
28
- {
29
- name: 'extensions',
30
- message: 'Which extensions?',
31
- options: availExtensions,
32
- type: 'checkbox',
33
- allowCustomOptions: true,
34
- required: true,
35
- },
36
- ];
37
- const answers = await prompter.prompt(argv, moduleQuestions);
38
- const modName = (0, core_1.sluggify)(answers.MODULENAME);
39
- const extensions = answers.extensions
40
- .filter((opt) => opt.selected)
41
- .map((opt) => opt.name);
42
- // Determine template source
43
- let templateSource;
44
- if (argv.repo) {
45
- templateSource = {
46
- type: 'github',
47
- path: argv.repo,
48
- branch: argv.fromBranch
49
- };
50
- log.info(`Loading templates from GitHub repository: ${argv.repo}`);
51
- }
52
- else if (argv.templatePath) {
53
- templateSource = {
54
- type: 'local',
55
- path: argv.templatePath
56
- };
57
- log.info(`Loading templates from local path: ${argv.templatePath}`);
58
- }
59
- project.initModule({
60
- ...argv,
61
- ...answers,
62
- name: modName,
63
- // @ts-ignore
64
- USERFULLNAME: username,
65
- USEREMAIL: email,
66
- extensions,
67
- templateSource
68
- });
69
- log.success(`Initialized module: ${modName}`);
70
- return { ...argv, ...answers };
71
- }
@@ -1,4 +0,0 @@
1
- import { Inquirerer } from 'inquirerer';
2
- export default function runWorkspaceSetup(argv: Partial<Record<string, any>>, prompter: Inquirerer): Promise<{
3
- cwd: string;
4
- }>;