@aifabrix/builder 2.36.2 → 2.37.5
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/.cursor/rules/project-rules.mdc +19 -0
- package/README.md +68 -104
- package/integration/hubspot/test.js +1 -1
- package/lib/api/wizard.api.js +24 -1
- package/lib/app/deploy.js +43 -7
- package/lib/app/display.js +1 -1
- package/lib/app/list.js +3 -1
- package/lib/app/run-helpers.js +1 -1
- package/lib/build/index.js +3 -4
- package/lib/cli/index.js +45 -0
- package/lib/cli/setup-app.js +230 -0
- package/lib/cli/setup-auth.js +88 -0
- package/lib/cli/setup-dev.js +101 -0
- package/lib/cli/setup-environment.js +53 -0
- package/lib/cli/setup-external-system.js +87 -0
- package/lib/cli/setup-infra.js +219 -0
- package/lib/cli/setup-secrets.js +48 -0
- package/lib/cli/setup-utility.js +202 -0
- package/lib/cli.js +7 -961
- package/lib/commands/up-common.js +31 -1
- package/lib/commands/up-miso.js +6 -2
- package/lib/commands/wizard-core.js +32 -7
- package/lib/core/config.js +10 -0
- package/lib/core/ensure-encryption-key.js +56 -0
- package/lib/deployment/deployer-status.js +101 -0
- package/lib/deployment/deployer.js +62 -110
- package/lib/deployment/environment.js +133 -34
- package/lib/external-system/deploy.js +5 -1
- package/lib/external-system/test-auth.js +14 -7
- package/lib/generator/wizard.js +37 -41
- package/lib/infrastructure/helpers.js +1 -1
- package/lib/schema/environment-deploy-request.schema.json +64 -0
- package/lib/utils/help-builder.js +5 -2
- package/lib/utils/paths.js +22 -4
- package/lib/utils/secrets-generator.js +23 -8
- package/lib/utils/secrets-helpers.js +46 -21
- package/package.json +1 -1
- package/scripts/install-local.js +11 -2
- package/templates/applications/README.md.hbs +3 -3
- package/templates/applications/dataplane/variables.yaml +0 -2
- package/templates/applications/miso-controller/variables.yaml +0 -2
- package/templates/external-system/deploy.js.hbs +69 -0
- package/templates/infra/environment-dev.json +10 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI infrastructure command setup (up-infra, up-platform, up-miso, up-dataplane, down-infra, doctor, status, restart).
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Infrastructure command definitions for AI Fabrix Builder CLI
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const chalk = require('chalk');
|
|
10
|
+
const infra = require('../infrastructure');
|
|
11
|
+
const appLib = require('../app');
|
|
12
|
+
const validator = require('../validation/validator');
|
|
13
|
+
const config = require('../core/config');
|
|
14
|
+
const logger = require('../utils/logger');
|
|
15
|
+
const { handleCommandError } = require('../utils/cli-utils');
|
|
16
|
+
const { handleUpMiso } = require('../commands/up-miso');
|
|
17
|
+
const { handleUpDataplane } = require('../commands/up-dataplane');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Runs the up-infra command: resolves developer ID, traefik, and starts infra.
|
|
21
|
+
* @param {Object} options - Commander options (developer, traefik)
|
|
22
|
+
* @returns {Promise<void>}
|
|
23
|
+
*/
|
|
24
|
+
async function runUpInfraCommand(options) {
|
|
25
|
+
await config.ensureSecretsEncryptionKey();
|
|
26
|
+
let developerId = null;
|
|
27
|
+
if (options.developer) {
|
|
28
|
+
const id = parseInt(options.developer, 10);
|
|
29
|
+
if (isNaN(id) || id < 0) {
|
|
30
|
+
throw new Error('Developer ID must be a non-negative number (0 = default infra, > 0 = developer-specific)');
|
|
31
|
+
}
|
|
32
|
+
await config.setDeveloperId(id);
|
|
33
|
+
process.env.AIFABRIX_DEVELOPERID = id.toString();
|
|
34
|
+
developerId = id;
|
|
35
|
+
logger.log(chalk.green(`✓ Developer ID set to ${id}`));
|
|
36
|
+
}
|
|
37
|
+
const cfg = await config.getConfig();
|
|
38
|
+
if (options.traefik === true) {
|
|
39
|
+
cfg.traefik = true;
|
|
40
|
+
await config.saveConfig(cfg);
|
|
41
|
+
logger.log(chalk.green('✓ Traefik enabled and saved to config'));
|
|
42
|
+
} else if (options.traefik === false) {
|
|
43
|
+
cfg.traefik = false;
|
|
44
|
+
await config.saveConfig(cfg);
|
|
45
|
+
logger.log(chalk.green('✓ Traefik disabled and saved to config'));
|
|
46
|
+
}
|
|
47
|
+
const useTraefik = options.traefik === true ? true : (options.traefik === false ? false : !!(cfg.traefik));
|
|
48
|
+
await infra.startInfra(developerId, { traefik: useTraefik });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Sets up infrastructure commands
|
|
53
|
+
* @param {Command} program - Commander program instance
|
|
54
|
+
*/
|
|
55
|
+
function setupInfraCommands(program) {
|
|
56
|
+
program.command('up-infra')
|
|
57
|
+
.description('Start local infrastructure: Postgres, Redis, optional Traefik')
|
|
58
|
+
.option('-d, --developer <id>', 'Set developer ID and start infrastructure')
|
|
59
|
+
.option('--traefik', 'Include Traefik reverse proxy and save to config')
|
|
60
|
+
.option('--no-traefik', 'Exclude Traefik and save to config')
|
|
61
|
+
.action(async(options) => {
|
|
62
|
+
try {
|
|
63
|
+
await runUpInfraCommand(options);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
handleCommandError(error, 'up-infra');
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
program.command('up-platform')
|
|
71
|
+
.description('Start platform (Keycloak, Miso Controller, Dataplane) from community images; infra must be up')
|
|
72
|
+
.option('-r, --registry <url>', 'Override registry for all apps (e.g. myacr.azurecr.io)')
|
|
73
|
+
.option('--registry-mode <mode>', 'Override registry mode (acr|external)')
|
|
74
|
+
.option('-i, --image <key>=<value>', 'Override image (e.g. keycloak=myreg/k:v1, miso-controller=myreg/m:v1, dataplane=myreg/d:v1); can be repeated', (v, prev) => (prev || []).concat([v]))
|
|
75
|
+
.action(async(options) => {
|
|
76
|
+
try {
|
|
77
|
+
await handleUpMiso(options);
|
|
78
|
+
await handleUpDataplane(options);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
handleCommandError(error, 'up-platform');
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
program.command('up-miso')
|
|
86
|
+
.description('Install keycloak, miso-controller, and dataplane from images (no build). Infra must be up. Uses auto-generated secrets for testing.')
|
|
87
|
+
.option('-r, --registry <url>', 'Override registry for all apps (e.g. myacr.azurecr.io)')
|
|
88
|
+
.option('--registry-mode <mode>', 'Override registry mode (acr|external)')
|
|
89
|
+
.option('-i, --image <key>=<value>', 'Override image (e.g. keycloak=myreg/k:v1, miso-controller=myreg/m:v1, dataplane=myreg/d:v1); can be repeated', (v, prev) => (prev || []).concat([v]))
|
|
90
|
+
.action(async(options) => {
|
|
91
|
+
try {
|
|
92
|
+
await handleUpMiso(options);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
handleCommandError(error, 'up-miso');
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
program.command('up-dataplane')
|
|
100
|
+
.description('Register and deploy dataplane app in dev (requires login, environment must be dev)')
|
|
101
|
+
.option('-r, --registry <url>', 'Override registry for dataplane image')
|
|
102
|
+
.option('--registry-mode <mode>', 'Override registry mode (acr|external)')
|
|
103
|
+
.option('-i, --image <ref>', 'Override dataplane image reference (e.g. myreg/dataplane:latest)')
|
|
104
|
+
.action(async(options) => {
|
|
105
|
+
try {
|
|
106
|
+
await handleUpDataplane(options);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
handleCommandError(error, 'up-dataplane');
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
program.command('down-infra [app]')
|
|
114
|
+
.description('Stop and remove local infrastructure services or a specific application')
|
|
115
|
+
.option('-v, --volumes', 'Remove volumes (deletes all data)')
|
|
116
|
+
.action(async(appName, options) => {
|
|
117
|
+
try {
|
|
118
|
+
if (typeof appName === 'string' && appName.trim().length > 0) {
|
|
119
|
+
await appLib.downApp(appName, { volumes: !!options.volumes });
|
|
120
|
+
} else {
|
|
121
|
+
if (options.volumes) {
|
|
122
|
+
await infra.stopInfraWithVolumes();
|
|
123
|
+
} else {
|
|
124
|
+
await infra.stopInfra();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
} catch (error) {
|
|
128
|
+
handleCommandError(error, 'down-infra');
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
program.command('doctor')
|
|
134
|
+
.description('Check environment and configuration')
|
|
135
|
+
.action(async() => {
|
|
136
|
+
try {
|
|
137
|
+
const result = await validator.checkEnvironment();
|
|
138
|
+
logger.log('\n🔍 AI Fabrix Environment Check\n');
|
|
139
|
+
|
|
140
|
+
logger.log(`Docker: ${result.docker === 'ok' ? '✅ Running' : '❌ Not available'}`);
|
|
141
|
+
logger.log(`Ports: ${result.ports === 'ok' ? '✅ Available' : '⚠️ Some ports in use'}`);
|
|
142
|
+
logger.log(`Secrets: ${result.secrets === 'ok' ? '✅ Configured' : '❌ Missing'}`);
|
|
143
|
+
|
|
144
|
+
if (result.recommendations.length > 0) {
|
|
145
|
+
logger.log('\n📋 Recommendations:');
|
|
146
|
+
result.recommendations.forEach(rec => logger.log(` • ${rec}`));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (result.docker === 'ok') {
|
|
150
|
+
try {
|
|
151
|
+
const health = await infra.checkInfraHealth();
|
|
152
|
+
logger.log('\n🏥 Infrastructure Health:');
|
|
153
|
+
Object.entries(health).forEach(([service, status]) => {
|
|
154
|
+
const icon = status === 'healthy' ? '✅' : status === 'unknown' ? '❓' : '❌';
|
|
155
|
+
logger.log(` ${icon} ${service}: ${status}`);
|
|
156
|
+
});
|
|
157
|
+
} catch (error) {
|
|
158
|
+
logger.log('\n🏥 Infrastructure: Not running');
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
logger.log('');
|
|
163
|
+
} catch (error) {
|
|
164
|
+
handleCommandError(error, 'doctor');
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
program.command('status')
|
|
170
|
+
.description('Show detailed infrastructure service status and running applications')
|
|
171
|
+
.action(async() => {
|
|
172
|
+
try {
|
|
173
|
+
const status = await infra.getInfraStatus();
|
|
174
|
+
logger.log('\n📊 Infrastructure Status\n');
|
|
175
|
+
|
|
176
|
+
Object.entries(status).forEach(([service, info]) => {
|
|
177
|
+
const normalizedStatus = String(info.status).trim().toLowerCase();
|
|
178
|
+
const icon = normalizedStatus === 'running' ? '✅' : '❌';
|
|
179
|
+
logger.log(`${icon} ${service}:`);
|
|
180
|
+
logger.log(` Status: ${info.status}`);
|
|
181
|
+
logger.log(` Port: ${info.port}`);
|
|
182
|
+
logger.log(` URL: ${info.url}`);
|
|
183
|
+
logger.log('');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const apps = await infra.getAppStatus();
|
|
187
|
+
if (apps.length > 0) {
|
|
188
|
+
logger.log('📱 Running Applications\n');
|
|
189
|
+
apps.forEach((appInfo) => {
|
|
190
|
+
const normalizedStatus = String(appInfo.status).trim().toLowerCase();
|
|
191
|
+
const icon = normalizedStatus.includes('running') || normalizedStatus.includes('up') ? '✅' : '❌';
|
|
192
|
+
logger.log(`${icon} ${appInfo.name}:`);
|
|
193
|
+
logger.log(` Container: ${appInfo.container}`);
|
|
194
|
+
logger.log(` Port: ${appInfo.port}`);
|
|
195
|
+
logger.log(` Status: ${appInfo.status}`);
|
|
196
|
+
logger.log(` URL: ${appInfo.url}`);
|
|
197
|
+
logger.log('');
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
} catch (error) {
|
|
201
|
+
handleCommandError(error, 'status');
|
|
202
|
+
process.exit(1);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
program.command('restart <service>')
|
|
207
|
+
.description('Restart a specific infrastructure service')
|
|
208
|
+
.action(async(service) => {
|
|
209
|
+
try {
|
|
210
|
+
await infra.restartService(service);
|
|
211
|
+
logger.log(`✅ ${service} service restarted successfully`);
|
|
212
|
+
} catch (error) {
|
|
213
|
+
handleCommandError(error, 'restart');
|
|
214
|
+
process.exit(1);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
module.exports = { setupInfraCommands };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI secrets and security command setup (secrets set, secure).
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Secrets command definitions for AI Fabrix Builder CLI
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { handleCommandError } = require('../utils/cli-utils');
|
|
10
|
+
const { handleSecretsSet } = require('../commands/secrets-set');
|
|
11
|
+
const { handleSecure } = require('../commands/secure');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Sets up secrets and security commands
|
|
15
|
+
* @param {Command} program - Commander program instance
|
|
16
|
+
*/
|
|
17
|
+
function setupSecretsCommands(program) {
|
|
18
|
+
const secretsCmd = program
|
|
19
|
+
.command('secrets')
|
|
20
|
+
.description('Manage secrets in secrets files');
|
|
21
|
+
|
|
22
|
+
secretsCmd
|
|
23
|
+
.command('set <key> <value>')
|
|
24
|
+
.description('Set a secret value in secrets file')
|
|
25
|
+
.option('--shared', 'Save to general secrets file (from config.yaml aifabrix-secrets) instead of user secrets')
|
|
26
|
+
.action(async(key, value, options) => {
|
|
27
|
+
try {
|
|
28
|
+
await handleSecretsSet(key, value, options);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
handleCommandError(error, 'secrets set');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
program.command('secure')
|
|
36
|
+
.description('Encrypt secrets in secrets.local.yaml files for ISO 27001 compliance')
|
|
37
|
+
.option('--secrets-encryption <key>', 'Encryption key (32 bytes, hex or base64)')
|
|
38
|
+
.action(async(options) => {
|
|
39
|
+
try {
|
|
40
|
+
await handleSecure(options);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
handleCommandError(error, 'secure');
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = { setupSecretsCommands };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI utility command setup (resolve, json, split-json, genkey, show, validate, diff).
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Utility command definitions for AI Fabrix Builder CLI
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 2.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const chalk = require('chalk');
|
|
12
|
+
const secrets = require('../core/secrets');
|
|
13
|
+
const generator = require('../generator');
|
|
14
|
+
const logger = require('../utils/logger');
|
|
15
|
+
const { handleCommandError } = require('../utils/cli-utils');
|
|
16
|
+
const { detectAppType, getDeployJsonPath } = require('../utils/paths');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Handles split-json command logic
|
|
20
|
+
* @async
|
|
21
|
+
* @param {string} appName - Application name
|
|
22
|
+
* @param {Object} options - Command options
|
|
23
|
+
* @returns {Promise<Object>} Paths to generated files
|
|
24
|
+
*/
|
|
25
|
+
async function handleSplitJsonCommand(appName, options) {
|
|
26
|
+
const { appPath, appType } = await detectAppType(appName, options);
|
|
27
|
+
|
|
28
|
+
const outputDir = options.output || appPath;
|
|
29
|
+
if (appType === 'external') {
|
|
30
|
+
const schemaPath = path.join(appPath, 'application-schema.json');
|
|
31
|
+
if (!fs.existsSync(schemaPath)) {
|
|
32
|
+
throw new Error(`application-schema.json not found: ${schemaPath}`);
|
|
33
|
+
}
|
|
34
|
+
return generator.splitExternalApplicationSchema(schemaPath, outputDir);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const deployJsonPath = getDeployJsonPath(appName, appType, true);
|
|
38
|
+
if (!fs.existsSync(deployJsonPath)) {
|
|
39
|
+
throw new Error(`Deployment JSON file not found: ${deployJsonPath}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return generator.splitDeployJson(deployJsonPath, outputDir);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Logs split-json results
|
|
47
|
+
* @param {Object} result - Generated file paths
|
|
48
|
+
* @returns {void}
|
|
49
|
+
*/
|
|
50
|
+
function logSplitJsonResult(result) {
|
|
51
|
+
logger.log(chalk.green('\n✓ Successfully split deployment JSON into component files:'));
|
|
52
|
+
logger.log(` • env.template: ${result.envTemplate}`);
|
|
53
|
+
logger.log(` • variables.yaml: ${result.variables}`);
|
|
54
|
+
if (result.rbac) {
|
|
55
|
+
logger.log(` • rbac.yml: ${result.rbac}`);
|
|
56
|
+
}
|
|
57
|
+
logger.log(` • README.md: ${result.readme}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Sets up utility commands
|
|
62
|
+
* @param {Command} program - Commander program instance
|
|
63
|
+
*/
|
|
64
|
+
function setupUtilityCommands(program) {
|
|
65
|
+
program.command('resolve <app>')
|
|
66
|
+
.description('Generate .env file from template and validate application files')
|
|
67
|
+
.option('-f, --force', 'Generate missing secret keys in secrets file')
|
|
68
|
+
.option('--skip-validation', 'Skip file validation after generating .env')
|
|
69
|
+
.action(async(appName, options) => {
|
|
70
|
+
try {
|
|
71
|
+
const envPath = await secrets.generateEnvFile(appName, undefined, 'docker', options.force);
|
|
72
|
+
logger.log(`✓ Generated .env file: ${envPath}`);
|
|
73
|
+
|
|
74
|
+
if (!options.skipValidation) {
|
|
75
|
+
const validate = require('../validation/validate');
|
|
76
|
+
const result = await validate.validateAppOrFile(appName);
|
|
77
|
+
validate.displayValidationResults(result);
|
|
78
|
+
if (!result.valid) {
|
|
79
|
+
logger.log(chalk.yellow('\n⚠️ Validation found errors. Fix them before deploying.'));
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
handleCommandError(error, 'resolve');
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
program.command('json <app>')
|
|
90
|
+
.description('Generate deployment JSON to disk (<app>-deploy.json). Use before commit so version control has the correct file.')
|
|
91
|
+
.option('--type <type>', 'Application type (external) - if set, only checks integration folder')
|
|
92
|
+
.action(async(appName, options) => {
|
|
93
|
+
try {
|
|
94
|
+
const result = await generator.generateDeployJsonWithValidation(appName, options);
|
|
95
|
+
if (result.success) {
|
|
96
|
+
const fileName = result.path.includes('application-schema.json') ? 'application-schema.json' : 'deployment JSON';
|
|
97
|
+
logger.log(`✓ Generated ${fileName}: ${result.path}`);
|
|
98
|
+
|
|
99
|
+
if (result.validation.warnings && result.validation.warnings.length > 0) {
|
|
100
|
+
logger.log('\n⚠️ Warnings:');
|
|
101
|
+
result.validation.warnings.forEach(warning => logger.log(` • ${warning}`));
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
logger.log('❌ Validation failed:');
|
|
105
|
+
if (result.validation.errors && result.validation.errors.length > 0) {
|
|
106
|
+
result.validation.errors.forEach(error => logger.log(` • ${error}`));
|
|
107
|
+
}
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
handleCommandError(error, 'json');
|
|
112
|
+
process.exit(1);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
program.command('split-json <app>')
|
|
117
|
+
.description('Split deployment JSON into component files (env.template, variables.yaml, rbac.yml, README.md)')
|
|
118
|
+
.option('-o, --output <dir>', 'Output directory for component files (defaults to same directory as JSON)')
|
|
119
|
+
.option('--type <type>', 'Application type (external) - if set, only checks integration folder')
|
|
120
|
+
.action(async(appName, options) => {
|
|
121
|
+
try {
|
|
122
|
+
const result = await handleSplitJsonCommand(appName, options);
|
|
123
|
+
logSplitJsonResult(result);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
handleCommandError(error, 'split-json');
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
program.command('genkey <app>')
|
|
131
|
+
.description('Generate deployment key')
|
|
132
|
+
.action(async(appName) => {
|
|
133
|
+
try {
|
|
134
|
+
const jsonPath = await generator.generateDeployJson(appName);
|
|
135
|
+
|
|
136
|
+
const jsonContent = fs.readFileSync(jsonPath, 'utf8');
|
|
137
|
+
const deployment = JSON.parse(jsonContent);
|
|
138
|
+
|
|
139
|
+
const key = deployment.deploymentKey;
|
|
140
|
+
|
|
141
|
+
if (!key) {
|
|
142
|
+
throw new Error('deploymentKey not found in generated JSON');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
logger.log(`\nDeployment key for ${appName}:`);
|
|
146
|
+
logger.log(key);
|
|
147
|
+
logger.log(chalk.gray(`\nGenerated from: ${jsonPath}`));
|
|
148
|
+
} catch (error) {
|
|
149
|
+
handleCommandError(error, 'genkey');
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
program.command('show <appKey>')
|
|
155
|
+
.description('Show application info from local builder/ or integration/ (offline) or from controller (--online)')
|
|
156
|
+
.option('--online', 'Fetch application data from the controller')
|
|
157
|
+
.option('--json', 'Output as JSON')
|
|
158
|
+
.action(async(appKey, options) => {
|
|
159
|
+
try {
|
|
160
|
+
const { showApp } = require('../app/show');
|
|
161
|
+
await showApp(appKey, { online: options.online, json: options.json });
|
|
162
|
+
} catch (error) {
|
|
163
|
+
logger.error(chalk.red(`Error: ${error.message}`));
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
program.command('validate <appOrFile>')
|
|
169
|
+
.description('Validate application or external integration file')
|
|
170
|
+
.option('--type <type>', 'Application type (external) - if set, only checks integration folder')
|
|
171
|
+
.action(async(appOrFile, options) => {
|
|
172
|
+
try {
|
|
173
|
+
const validate = require('../validation/validate');
|
|
174
|
+
const result = await validate.validateAppOrFile(appOrFile, options);
|
|
175
|
+
validate.displayValidationResults(result);
|
|
176
|
+
if (!result.valid) {
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
handleCommandError(error, 'validate');
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
program.command('diff <file1> <file2>')
|
|
186
|
+
.description('Compare two configuration files (for deployment pipeline)')
|
|
187
|
+
.action(async(file1, file2) => {
|
|
188
|
+
try {
|
|
189
|
+
const diff = require('../core/diff');
|
|
190
|
+
const result = await diff.compareFiles(file1, file2);
|
|
191
|
+
diff.formatDiffOutput(result);
|
|
192
|
+
if (!result.identical) {
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
} catch (error) {
|
|
196
|
+
handleCommandError(error, 'diff');
|
|
197
|
+
process.exit(1);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
module.exports = { setupUtilityCommands };
|