@agents-at-scale/ark 0.1.35 → 0.1.36
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/dist/arkServices.d.ts +42 -0
- package/dist/arkServices.js +138 -0
- package/dist/arkServices.spec.d.ts +1 -0
- package/dist/arkServices.spec.js +24 -0
- package/dist/commands/agents/index.d.ts +3 -0
- package/dist/commands/agents/index.js +65 -0
- package/dist/commands/agents/index.spec.d.ts +1 -0
- package/dist/commands/agents/index.spec.js +67 -0
- package/dist/commands/chat/index.d.ts +3 -0
- package/dist/commands/chat/index.js +29 -0
- package/dist/commands/cluster/get.d.ts +2 -0
- package/dist/commands/cluster/get.js +39 -0
- package/dist/commands/cluster/get.spec.d.ts +1 -0
- package/dist/commands/cluster/get.spec.js +92 -0
- package/dist/commands/cluster/index.d.ts +2 -1
- package/dist/commands/cluster/index.js +3 -5
- package/dist/commands/cluster/index.spec.d.ts +1 -0
- package/dist/commands/cluster/index.spec.js +24 -0
- package/dist/commands/completion/index.d.ts +3 -0
- package/dist/commands/completion/index.js +230 -0
- package/dist/commands/completion/index.spec.d.ts +1 -0
- package/dist/commands/completion/index.spec.js +34 -0
- package/dist/commands/config/index.d.ts +3 -0
- package/dist/commands/config/index.js +42 -0
- package/dist/commands/config/index.spec.d.ts +1 -0
- package/dist/commands/config/index.spec.js +78 -0
- package/dist/commands/dashboard/index.d.ts +4 -0
- package/dist/commands/dashboard/index.js +39 -0
- package/dist/commands/docs/index.d.ts +4 -0
- package/dist/commands/docs/index.js +18 -0
- package/dist/commands/generate/config.js +5 -24
- package/dist/commands/generate/generators/mcpserver.d.ts +2 -1
- package/dist/commands/generate/generators/mcpserver.js +26 -5
- package/dist/commands/generate/generators/project.js +22 -41
- package/dist/commands/generate/index.d.ts +2 -1
- package/dist/commands/generate/index.js +1 -1
- package/dist/commands/install/index.d.ts +8 -0
- package/dist/commands/install/index.js +295 -0
- package/dist/commands/install/index.spec.d.ts +1 -0
- package/dist/commands/install/index.spec.js +143 -0
- package/dist/commands/models/create.d.ts +1 -0
- package/dist/commands/models/create.js +213 -0
- package/dist/commands/models/create.spec.d.ts +1 -0
- package/dist/commands/models/create.spec.js +125 -0
- package/dist/commands/models/index.d.ts +3 -0
- package/dist/commands/models/index.js +75 -0
- package/dist/commands/models/index.spec.d.ts +1 -0
- package/dist/commands/models/index.spec.js +96 -0
- package/dist/commands/query/index.d.ts +3 -0
- package/dist/commands/query/index.js +24 -0
- package/dist/commands/query/index.spec.d.ts +1 -0
- package/dist/commands/query/index.spec.js +53 -0
- package/dist/commands/routes/index.d.ts +3 -0
- package/dist/commands/routes/index.js +93 -0
- package/dist/commands/status/index.d.ts +3 -0
- package/dist/commands/status/index.js +281 -0
- package/dist/commands/targets/index.d.ts +3 -0
- package/dist/commands/targets/index.js +72 -0
- package/dist/commands/targets/index.spec.d.ts +1 -0
- package/dist/commands/targets/index.spec.js +154 -0
- package/dist/commands/teams/index.d.ts +3 -0
- package/dist/commands/teams/index.js +64 -0
- package/dist/commands/teams/index.spec.d.ts +1 -0
- package/dist/commands/teams/index.spec.js +70 -0
- package/dist/commands/tools/index.d.ts +3 -0
- package/dist/commands/tools/index.js +49 -0
- package/dist/commands/tools/index.spec.d.ts +1 -0
- package/dist/commands/tools/index.spec.js +70 -0
- package/dist/commands/uninstall/index.d.ts +3 -0
- package/dist/commands/uninstall/index.js +101 -0
- package/dist/commands/uninstall/index.spec.d.ts +1 -0
- package/dist/commands/uninstall/index.spec.js +125 -0
- package/dist/components/ChatUI.d.ts +16 -0
- package/dist/components/ChatUI.js +801 -0
- package/dist/components/statusChecker.d.ts +14 -24
- package/dist/components/statusChecker.js +295 -129
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -42
- package/dist/lib/arkApiClient.d.ts +53 -0
- package/dist/lib/arkApiClient.js +102 -0
- package/dist/lib/arkApiProxy.d.ts +9 -0
- package/dist/lib/arkApiProxy.js +22 -0
- package/dist/lib/arkServiceProxy.d.ts +14 -0
- package/dist/lib/arkServiceProxy.js +95 -0
- package/dist/lib/arkStatus.d.ts +10 -0
- package/dist/lib/arkStatus.js +79 -0
- package/dist/lib/arkStatus.spec.d.ts +1 -0
- package/dist/lib/arkStatus.spec.js +49 -0
- package/dist/lib/chatClient.d.ts +33 -0
- package/dist/lib/chatClient.js +93 -0
- package/dist/lib/cluster.d.ts +2 -1
- package/dist/lib/cluster.js +37 -16
- package/dist/lib/cluster.spec.d.ts +1 -0
- package/dist/lib/cluster.spec.js +338 -0
- package/dist/lib/commands.d.ts +16 -0
- package/dist/lib/commands.js +29 -0
- package/dist/lib/commands.spec.d.ts +1 -0
- package/dist/lib/commands.spec.js +146 -0
- package/dist/lib/config.d.ts +26 -80
- package/dist/lib/config.js +70 -205
- package/dist/lib/config.spec.d.ts +1 -0
- package/dist/lib/config.spec.js +99 -0
- package/dist/lib/errors.js +1 -1
- package/dist/lib/errors.spec.d.ts +1 -0
- package/dist/lib/errors.spec.js +221 -0
- package/dist/lib/executeQuery.d.ts +20 -0
- package/dist/lib/executeQuery.js +135 -0
- package/dist/lib/executeQuery.spec.d.ts +1 -0
- package/dist/lib/executeQuery.spec.js +170 -0
- package/dist/lib/nextSteps.d.ts +4 -0
- package/dist/lib/nextSteps.js +20 -0
- package/dist/lib/nextSteps.spec.d.ts +1 -0
- package/dist/lib/nextSteps.spec.js +59 -0
- package/dist/lib/output.d.ts +36 -0
- package/dist/lib/output.js +89 -0
- package/dist/lib/output.spec.d.ts +1 -0
- package/dist/lib/output.spec.js +123 -0
- package/dist/lib/startup.d.ts +9 -0
- package/dist/lib/startup.js +87 -0
- package/dist/lib/startup.spec.d.ts +1 -0
- package/dist/lib/startup.spec.js +152 -0
- package/dist/lib/types.d.ts +87 -3
- package/dist/lib/versions.d.ts +23 -0
- package/dist/lib/versions.js +51 -0
- package/dist/types/types.d.ts +40 -0
- package/dist/types/types.js +1 -0
- package/dist/ui/AgentSelector.d.ts +8 -0
- package/dist/ui/AgentSelector.js +53 -0
- package/dist/ui/MainMenu.d.ts +5 -1
- package/dist/ui/MainMenu.js +226 -91
- package/dist/ui/ModelSelector.d.ts +8 -0
- package/dist/ui/ModelSelector.js +53 -0
- package/dist/ui/TeamSelector.d.ts +8 -0
- package/dist/ui/TeamSelector.js +55 -0
- package/dist/ui/ToolSelector.d.ts +8 -0
- package/dist/ui/ToolSelector.js +53 -0
- package/dist/ui/statusFormatter.d.ts +22 -7
- package/dist/ui/statusFormatter.js +39 -39
- package/dist/ui/statusFormatter.spec.d.ts +1 -0
- package/dist/ui/statusFormatter.spec.js +58 -0
- package/package.json +16 -5
- package/dist/commands/cluster/get-ip.d.ts +0 -2
- package/dist/commands/cluster/get-ip.js +0 -32
- package/dist/commands/cluster/get-type.d.ts +0 -2
- package/dist/commands/cluster/get-type.js +0 -26
- package/dist/commands/completion.d.ts +0 -2
- package/dist/commands/completion.js +0 -108
- package/dist/commands/config.d.ts +0 -5
- package/dist/commands/config.js +0 -327
- package/dist/components/DashboardCLI.d.ts +0 -3
- package/dist/components/DashboardCLI.js +0 -149
- package/dist/config.d.ts +0 -42
- package/dist/config.js +0 -243
- package/dist/lib/arkClient.d.ts +0 -32
- package/dist/lib/arkClient.js +0 -43
- package/dist/lib/consts.d.ts +0 -10
- package/dist/lib/consts.js +0 -15
- package/dist/lib/exec.d.ts +0 -5
- package/dist/lib/exec.js +0 -20
- package/dist/lib/gatewayManager.d.ts +0 -24
- package/dist/lib/gatewayManager.js +0 -85
- package/dist/lib/kubernetes.d.ts +0 -28
- package/dist/lib/kubernetes.js +0 -122
- package/dist/lib/progress.d.ts +0 -128
- package/dist/lib/progress.js +0 -273
- package/dist/lib/wrappers/git.d.ts +0 -2
- package/dist/lib/wrappers/git.js +0 -43
|
@@ -8,7 +8,7 @@ import { TemplateDiscovery } from '../templateDiscovery.js';
|
|
|
8
8
|
import { toKebabCase, validateNameStrict, isValidKubernetesName, } from '../utils/nameUtils.js';
|
|
9
9
|
import { getInquirerProjectTypeChoices, GENERATOR_DEFAULTS, CLI_CONFIG, } from '../config.js';
|
|
10
10
|
import { SecurityUtils } from '../../../lib/security.js';
|
|
11
|
-
import
|
|
11
|
+
import ora from 'ora';
|
|
12
12
|
export function createProjectGenerator() {
|
|
13
13
|
return {
|
|
14
14
|
name: 'project',
|
|
@@ -38,61 +38,40 @@ class ProjectGenerator {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async generate(name, destination, options) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
progress.addStep('prerequisites', 'Checking prerequisites');
|
|
44
|
-
progress.addStep('configuration', 'Gathering project configuration');
|
|
45
|
-
if (!options.skipModels) {
|
|
46
|
-
progress.addStep('models', 'Configuring model providers');
|
|
47
|
-
}
|
|
48
|
-
if (!options.skipGit) {
|
|
49
|
-
progress.addStep('git', 'Setting up git repository');
|
|
50
|
-
}
|
|
51
|
-
progress.addStep('generation', 'Generating project files');
|
|
52
|
-
progress.addStep('completion', 'Finalizing project setup');
|
|
41
|
+
console.log(chalk.blue(`\n🚀 ARK Agent Project Generator\n`));
|
|
42
|
+
const spinner = ora('Checking prerequisites').start();
|
|
53
43
|
try {
|
|
54
44
|
// Check prerequisites
|
|
55
|
-
progress.startStep('prerequisites');
|
|
56
45
|
await this.checkPrerequisites();
|
|
57
|
-
|
|
46
|
+
spinner.succeed('Prerequisites validated');
|
|
58
47
|
// Get project configuration
|
|
59
|
-
|
|
48
|
+
spinner.start('Gathering project configuration');
|
|
60
49
|
const config = await this.getProjectConfig(name, destination, options);
|
|
61
|
-
|
|
50
|
+
spinner.succeed(`Project "${config.name}" configured`);
|
|
62
51
|
// Discover and configure models (only if not skipped)
|
|
63
52
|
if (config.configureModels) {
|
|
64
|
-
|
|
53
|
+
spinner.start('Configuring model providers');
|
|
65
54
|
await this.configureModels(config);
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
progress.skipStep('models', 'Model configuration skipped');
|
|
55
|
+
spinner.succeed(`Model provider: ${config.selectedModels || 'none'}`);
|
|
70
56
|
}
|
|
71
57
|
// Configure git if requested (only if not skipped)
|
|
72
58
|
if (config.initGit) {
|
|
73
|
-
|
|
59
|
+
spinner.start('Setting up git repository');
|
|
74
60
|
await this.configureGit(config);
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
progress.skipStep('git', 'Git setup skipped');
|
|
61
|
+
spinner.succeed('Git repository configured');
|
|
79
62
|
}
|
|
80
63
|
// Generate the project
|
|
81
|
-
|
|
64
|
+
spinner.start('Generating project files');
|
|
82
65
|
await this.generateProject(config);
|
|
83
|
-
|
|
66
|
+
spinner.succeed('Project files created');
|
|
84
67
|
// Finalize
|
|
85
|
-
|
|
68
|
+
spinner.start('Finalizing project setup');
|
|
86
69
|
this.showNextSteps(config);
|
|
87
|
-
|
|
88
|
-
|
|
70
|
+
spinner.succeed('Project ready');
|
|
71
|
+
console.log(chalk.green(`\n✅ Project generation completed\n`));
|
|
89
72
|
}
|
|
90
73
|
catch (error) {
|
|
91
|
-
|
|
92
|
-
const currentStep = progress['steps'].find((s) => s.status === 'running');
|
|
93
|
-
if (currentStep) {
|
|
94
|
-
progress.failStep(currentStep.name, `Failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
95
|
-
}
|
|
74
|
+
spinner.fail(`Failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
96
75
|
throw error;
|
|
97
76
|
}
|
|
98
77
|
}
|
|
@@ -105,7 +84,7 @@ class ProjectGenerator {
|
|
|
105
84
|
}
|
|
106
85
|
catch {
|
|
107
86
|
requirements.push({ tool: 'git', available: false, required: false });
|
|
108
|
-
|
|
87
|
+
console.log(chalk.yellow('⚠️ Warning: Git not found - git features will be disabled'));
|
|
109
88
|
}
|
|
110
89
|
// Check for deployment tools (optional for project generation)
|
|
111
90
|
const deploymentTools = ['kubectl', 'helm'];
|
|
@@ -121,12 +100,14 @@ class ProjectGenerator {
|
|
|
121
100
|
}
|
|
122
101
|
}
|
|
123
102
|
if (missingDeploymentTools.length > 0) {
|
|
124
|
-
|
|
125
|
-
|
|
103
|
+
console.log(chalk.blue(`ℹ️ Optional tools not found: ${missingDeploymentTools.join(', ')}`));
|
|
104
|
+
console.log(chalk.cyan('💡 Tip: Install kubectl and helm later to deploy your project to a cluster'));
|
|
126
105
|
}
|
|
127
106
|
}
|
|
128
107
|
async getProjectConfig(name, destination, options) {
|
|
129
|
-
|
|
108
|
+
console.log(chalk.gray(`\n${'─'.repeat(50)}`));
|
|
109
|
+
console.log(chalk.cyan('Project Configuration'));
|
|
110
|
+
console.log(chalk.gray(`${'─'.repeat(50)}\n`));
|
|
130
111
|
// Use command line options if provided, otherwise prompt
|
|
131
112
|
let projectType = options.projectType;
|
|
132
113
|
let parentDir = destination;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import type { ArkConfig } from '../../lib/config.js';
|
|
2
3
|
export interface GeneratorOptions {
|
|
3
4
|
name?: string;
|
|
4
5
|
destination?: string;
|
|
@@ -21,4 +22,4 @@ export interface Generator {
|
|
|
21
22
|
templatePath: string;
|
|
22
23
|
generate(name: string, destination: string, options: GeneratorOptions): Promise<void>;
|
|
23
24
|
}
|
|
24
|
-
export declare function createGenerateCommand(): Command;
|
|
25
|
+
export declare function createGenerateCommand(_: ArkConfig): Command;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { ArkConfig } from '../../lib/config.js';
|
|
3
|
+
export declare function installArk(config: ArkConfig, serviceName?: string, options?: {
|
|
4
|
+
yes?: boolean;
|
|
5
|
+
waitForReady?: string;
|
|
6
|
+
verbose?: boolean;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
export declare function createInstallCommand(config: ArkConfig): Command;
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { execute } from '../../lib/commands.js';
|
|
4
|
+
import inquirer from 'inquirer';
|
|
5
|
+
import { showNoClusterError } from '../../lib/startup.js';
|
|
6
|
+
import output from '../../lib/output.js';
|
|
7
|
+
import { getInstallableServices, arkDependencies, } from '../../arkServices.js';
|
|
8
|
+
import { isArkReady } from '../../lib/arkStatus.js';
|
|
9
|
+
import { printNextSteps } from '../../lib/nextSteps.js';
|
|
10
|
+
import ora from 'ora';
|
|
11
|
+
async function installService(service, verbose = false) {
|
|
12
|
+
const helmArgs = [
|
|
13
|
+
'upgrade',
|
|
14
|
+
'--install',
|
|
15
|
+
service.helmReleaseName,
|
|
16
|
+
service.chartPath,
|
|
17
|
+
];
|
|
18
|
+
// Only add namespace flag if service has explicit namespace
|
|
19
|
+
if (service.namespace) {
|
|
20
|
+
helmArgs.push('--namespace', service.namespace);
|
|
21
|
+
}
|
|
22
|
+
// Add any additional install args
|
|
23
|
+
helmArgs.push(...(service.installArgs || []));
|
|
24
|
+
await execute('helm', helmArgs, { stdio: 'inherit' }, { verbose });
|
|
25
|
+
}
|
|
26
|
+
export async function installArk(config, serviceName, options = {}) {
|
|
27
|
+
// Validate that --wait-for-ready requires -y
|
|
28
|
+
if (options.waitForReady && !options.yes) {
|
|
29
|
+
output.error('--wait-for-ready requires -y flag for non-interactive mode');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
// Check cluster connectivity from config
|
|
33
|
+
if (!config.clusterInfo) {
|
|
34
|
+
showNoClusterError();
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
const clusterInfo = config.clusterInfo;
|
|
38
|
+
// Show cluster info
|
|
39
|
+
output.success(`connected to cluster: ${chalk.bold(clusterInfo.context)}`);
|
|
40
|
+
console.log(); // Add blank line after cluster info
|
|
41
|
+
// If a specific service is requested, install only that service
|
|
42
|
+
if (serviceName) {
|
|
43
|
+
const services = getInstallableServices();
|
|
44
|
+
const service = Object.values(services).find((s) => s.name === serviceName);
|
|
45
|
+
if (!service) {
|
|
46
|
+
output.error(`service '${serviceName}' not found`);
|
|
47
|
+
output.info('available services:');
|
|
48
|
+
for (const s of Object.values(services)) {
|
|
49
|
+
output.info(` ${s.name}`);
|
|
50
|
+
}
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
output.info(`installing ${service.name}...`);
|
|
54
|
+
try {
|
|
55
|
+
await installService(service, options.verbose);
|
|
56
|
+
output.success(`${service.name} installed successfully`);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
output.error(`failed to install ${service.name}`);
|
|
60
|
+
console.error(error);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// If not using -y flag, show checklist interface
|
|
66
|
+
if (!options.yes) {
|
|
67
|
+
console.log(chalk.cyan.bold('\nSelect components to install:'));
|
|
68
|
+
console.log(chalk.gray('Use arrow keys to navigate, space to toggle, enter to confirm\n'));
|
|
69
|
+
// Build choices for the checkbox prompt
|
|
70
|
+
const allChoices = [
|
|
71
|
+
new inquirer.Separator(chalk.bold('──── Dependencies ────')),
|
|
72
|
+
{
|
|
73
|
+
name: `cert-manager ${chalk.gray('- Certificate management')}`,
|
|
74
|
+
value: 'cert-manager',
|
|
75
|
+
checked: true,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: `gateway-api ${chalk.gray('- Gateway API CRDs')}`,
|
|
79
|
+
value: 'gateway-api',
|
|
80
|
+
checked: true,
|
|
81
|
+
},
|
|
82
|
+
new inquirer.Separator(chalk.bold('──── Ark Core ────')),
|
|
83
|
+
{
|
|
84
|
+
name: `ark-controller ${chalk.gray('- Core Ark controller')}`,
|
|
85
|
+
value: 'ark-controller',
|
|
86
|
+
checked: true,
|
|
87
|
+
},
|
|
88
|
+
new inquirer.Separator(chalk.bold('──── Ark Services ────')),
|
|
89
|
+
{
|
|
90
|
+
name: `ark-api ${chalk.gray('- API service')}`,
|
|
91
|
+
value: 'ark-api',
|
|
92
|
+
checked: true,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: `ark-dashboard ${chalk.gray('- Web dashboard')}`,
|
|
96
|
+
value: 'ark-dashboard',
|
|
97
|
+
checked: true,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: `ark-mcp ${chalk.gray('- MCP services')}`,
|
|
101
|
+
value: 'ark-mcp',
|
|
102
|
+
checked: true,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: `localhost-gateway ${chalk.gray('- Gateway for local access')}`,
|
|
106
|
+
value: 'localhost-gateway',
|
|
107
|
+
checked: true,
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
let selectedComponents = [];
|
|
111
|
+
try {
|
|
112
|
+
const answers = await inquirer.prompt([
|
|
113
|
+
{
|
|
114
|
+
type: 'checkbox',
|
|
115
|
+
name: 'components',
|
|
116
|
+
message: 'Components to install:',
|
|
117
|
+
choices: allChoices,
|
|
118
|
+
pageSize: 15,
|
|
119
|
+
},
|
|
120
|
+
]);
|
|
121
|
+
selectedComponents = answers.components;
|
|
122
|
+
if (selectedComponents.length === 0) {
|
|
123
|
+
output.warning('No components selected. Exiting.');
|
|
124
|
+
process.exit(0);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
// Handle Ctrl-C gracefully
|
|
129
|
+
if (error && error.name === 'ExitPromptError') {
|
|
130
|
+
console.log('\nInstallation cancelled');
|
|
131
|
+
process.exit(130);
|
|
132
|
+
}
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
// Install dependencies if selected
|
|
136
|
+
const shouldInstallDeps = selectedComponents.includes('cert-manager') ||
|
|
137
|
+
selectedComponents.includes('gateway-api');
|
|
138
|
+
// Install selected dependencies
|
|
139
|
+
if (shouldInstallDeps) {
|
|
140
|
+
// Always install cert-manager repo and update if installing any dependency
|
|
141
|
+
if (selectedComponents.includes('cert-manager') ||
|
|
142
|
+
selectedComponents.includes('gateway-api')) {
|
|
143
|
+
for (const depKey of ['cert-manager-repo', 'helm-repo-update']) {
|
|
144
|
+
const dep = arkDependencies[depKey];
|
|
145
|
+
output.info(`installing ${dep.description || dep.name}...`);
|
|
146
|
+
try {
|
|
147
|
+
await execute(dep.command, dep.args, {
|
|
148
|
+
stdio: 'inherit',
|
|
149
|
+
}, { verbose: options.verbose });
|
|
150
|
+
output.success(`${dep.name} completed`);
|
|
151
|
+
console.log();
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
console.log();
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Install cert-manager if selected
|
|
160
|
+
if (selectedComponents.includes('cert-manager')) {
|
|
161
|
+
const dep = arkDependencies['cert-manager'];
|
|
162
|
+
output.info(`installing ${dep.description || dep.name}...`);
|
|
163
|
+
try {
|
|
164
|
+
await execute(dep.command, dep.args, {
|
|
165
|
+
stdio: 'inherit',
|
|
166
|
+
}, { verbose: options.verbose });
|
|
167
|
+
output.success(`${dep.name} completed`);
|
|
168
|
+
console.log();
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
console.log();
|
|
172
|
+
process.exit(1);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// Install gateway-api if selected
|
|
176
|
+
if (selectedComponents.includes('gateway-api')) {
|
|
177
|
+
const dep = arkDependencies['gateway-api-crds'];
|
|
178
|
+
output.info(`installing ${dep.description || dep.name}...`);
|
|
179
|
+
try {
|
|
180
|
+
await execute(dep.command, dep.args, {
|
|
181
|
+
stdio: 'inherit',
|
|
182
|
+
}, { verbose: options.verbose });
|
|
183
|
+
output.success(`${dep.name} completed`);
|
|
184
|
+
console.log();
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
console.log();
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Install selected services
|
|
193
|
+
const services = getInstallableServices();
|
|
194
|
+
for (const service of Object.values(services)) {
|
|
195
|
+
// Check if this service was selected
|
|
196
|
+
const serviceKey = service.helmReleaseName;
|
|
197
|
+
if (!selectedComponents.includes(serviceKey)) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
output.info(`installing ${service.name}...`);
|
|
201
|
+
try {
|
|
202
|
+
await installService(service, options.verbose);
|
|
203
|
+
console.log(); // Add blank line after command output
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
// Continue with remaining services on error
|
|
207
|
+
console.log(); // Add blank line after error output
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
// -y flag was used, install everything
|
|
213
|
+
// Install all dependencies
|
|
214
|
+
for (const dep of Object.values(arkDependencies)) {
|
|
215
|
+
output.info(`installing ${dep.description || dep.name}...`);
|
|
216
|
+
try {
|
|
217
|
+
await execute(dep.command, dep.args, {
|
|
218
|
+
stdio: 'inherit',
|
|
219
|
+
}, { verbose: options.verbose });
|
|
220
|
+
output.success(`${dep.name} completed`);
|
|
221
|
+
console.log(); // Add blank line after dependency
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
console.log(); // Add blank line after error
|
|
225
|
+
process.exit(1);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// Install all services
|
|
229
|
+
const services = getInstallableServices();
|
|
230
|
+
for (const service of Object.values(services)) {
|
|
231
|
+
output.info(`installing ${service.name}...`);
|
|
232
|
+
try {
|
|
233
|
+
await installService(service, options.verbose);
|
|
234
|
+
console.log(); // Add blank line after command output
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// Continue with remaining services on error
|
|
238
|
+
console.log(); // Add blank line after error output
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// Show next steps after successful installation
|
|
243
|
+
if (!serviceName || serviceName === 'all') {
|
|
244
|
+
printNextSteps();
|
|
245
|
+
}
|
|
246
|
+
// Wait for Ark to be ready if requested
|
|
247
|
+
if (options.waitForReady) {
|
|
248
|
+
// Parse timeout value (e.g., '30s', '2m', '60')
|
|
249
|
+
const parseTimeout = (value) => {
|
|
250
|
+
const match = value.match(/^(\d+)([sm])?$/);
|
|
251
|
+
if (!match) {
|
|
252
|
+
throw new Error('Invalid timeout format. Use format like 30s or 2m');
|
|
253
|
+
}
|
|
254
|
+
const num = parseInt(match[1], 10);
|
|
255
|
+
const unit = match[2] || 's';
|
|
256
|
+
return unit === 'm' ? num * 60 : num;
|
|
257
|
+
};
|
|
258
|
+
try {
|
|
259
|
+
const timeoutSeconds = parseTimeout(options.waitForReady);
|
|
260
|
+
const startTime = Date.now();
|
|
261
|
+
const endTime = startTime + timeoutSeconds * 1000;
|
|
262
|
+
const spinner = ora(`Waiting for Ark to be ready (timeout: ${timeoutSeconds}s)...`).start();
|
|
263
|
+
while (Date.now() < endTime) {
|
|
264
|
+
if (await isArkReady()) {
|
|
265
|
+
spinner.succeed('Ark is ready!');
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const elapsed = Math.floor((Date.now() - startTime) / 1000);
|
|
269
|
+
spinner.text = `Waiting for Ark to be ready (${elapsed}/${timeoutSeconds}s)...`;
|
|
270
|
+
// Wait 2 seconds before checking again
|
|
271
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
272
|
+
}
|
|
273
|
+
// Timeout reached
|
|
274
|
+
spinner.fail(`Ark did not become ready within ${timeoutSeconds} seconds`);
|
|
275
|
+
process.exit(1);
|
|
276
|
+
}
|
|
277
|
+
catch (error) {
|
|
278
|
+
output.error(`Failed to wait for ready: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
279
|
+
process.exit(1);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
export function createInstallCommand(config) {
|
|
284
|
+
const command = new Command('install');
|
|
285
|
+
command
|
|
286
|
+
.description('Install ARK components using Helm')
|
|
287
|
+
.argument('[service]', 'specific service to install, or all if omitted')
|
|
288
|
+
.option('-y, --yes', 'automatically confirm all installations')
|
|
289
|
+
.option('--wait-for-ready <timeout>', 'wait for Ark to be ready after installation (e.g., 30s, 2m)')
|
|
290
|
+
.option('-v, --verbose', 'show commands being executed')
|
|
291
|
+
.action(async (service, options) => {
|
|
292
|
+
await installArk(config, service, options);
|
|
293
|
+
});
|
|
294
|
+
return command;
|
|
295
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
const mockExeca = jest.fn(() => Promise.resolve());
|
|
4
|
+
jest.unstable_mockModule('execa', () => ({
|
|
5
|
+
execa: mockExeca,
|
|
6
|
+
}));
|
|
7
|
+
const mockGetClusterInfo = jest.fn();
|
|
8
|
+
jest.unstable_mockModule('../../lib/cluster.js', () => ({
|
|
9
|
+
getClusterInfo: mockGetClusterInfo,
|
|
10
|
+
}));
|
|
11
|
+
const mockGetInstallableServices = jest.fn();
|
|
12
|
+
const mockArkServices = {};
|
|
13
|
+
const mockArkDependencies = {};
|
|
14
|
+
jest.unstable_mockModule('../../arkServices.js', () => ({
|
|
15
|
+
getInstallableServices: mockGetInstallableServices,
|
|
16
|
+
arkServices: mockArkServices,
|
|
17
|
+
arkDependencies: mockArkDependencies,
|
|
18
|
+
}));
|
|
19
|
+
const mockOutput = {
|
|
20
|
+
error: jest.fn(),
|
|
21
|
+
info: jest.fn(),
|
|
22
|
+
success: jest.fn(),
|
|
23
|
+
warning: jest.fn(),
|
|
24
|
+
};
|
|
25
|
+
jest.unstable_mockModule('../../lib/output.js', () => ({
|
|
26
|
+
default: mockOutput,
|
|
27
|
+
}));
|
|
28
|
+
const mockExit = jest.spyOn(process, 'exit').mockImplementation((() => {
|
|
29
|
+
throw new Error('process.exit called');
|
|
30
|
+
}));
|
|
31
|
+
jest.spyOn(console, 'log').mockImplementation(() => { });
|
|
32
|
+
jest.spyOn(console, 'error').mockImplementation(() => { });
|
|
33
|
+
const { createInstallCommand } = await import('./index.js');
|
|
34
|
+
describe('install command', () => {
|
|
35
|
+
const mockConfig = {
|
|
36
|
+
clusterInfo: {
|
|
37
|
+
context: 'test-cluster',
|
|
38
|
+
type: 'minikube',
|
|
39
|
+
namespace: 'default',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
jest.clearAllMocks();
|
|
44
|
+
mockGetClusterInfo.mockResolvedValue({
|
|
45
|
+
context: 'test-cluster',
|
|
46
|
+
type: 'minikube',
|
|
47
|
+
namespace: 'default',
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
it('creates command with correct structure', () => {
|
|
51
|
+
const command = createInstallCommand(mockConfig);
|
|
52
|
+
expect(command).toBeInstanceOf(Command);
|
|
53
|
+
expect(command.name()).toBe('install');
|
|
54
|
+
});
|
|
55
|
+
it('installs single service with correct helm parameters', async () => {
|
|
56
|
+
const mockService = {
|
|
57
|
+
name: 'ark-api',
|
|
58
|
+
helmReleaseName: 'ark-api',
|
|
59
|
+
chartPath: './charts/ark-api',
|
|
60
|
+
namespace: 'ark-system',
|
|
61
|
+
installArgs: ['--set', 'image.tag=latest'],
|
|
62
|
+
};
|
|
63
|
+
mockGetInstallableServices.mockReturnValue({
|
|
64
|
+
'ark-api': mockService,
|
|
65
|
+
});
|
|
66
|
+
const command = createInstallCommand(mockConfig);
|
|
67
|
+
await command.parseAsync(['node', 'test', 'ark-api']);
|
|
68
|
+
expect(mockExeca).toHaveBeenCalledWith('helm', [
|
|
69
|
+
'upgrade',
|
|
70
|
+
'--install',
|
|
71
|
+
'ark-api',
|
|
72
|
+
'./charts/ark-api',
|
|
73
|
+
'--namespace',
|
|
74
|
+
'ark-system',
|
|
75
|
+
'--set',
|
|
76
|
+
'image.tag=latest',
|
|
77
|
+
], { stdio: 'inherit' });
|
|
78
|
+
expect(mockOutput.success).toHaveBeenCalledWith('ark-api installed successfully');
|
|
79
|
+
});
|
|
80
|
+
it('shows error when service not found', async () => {
|
|
81
|
+
mockGetInstallableServices.mockReturnValue({
|
|
82
|
+
'ark-api': { name: 'ark-api' },
|
|
83
|
+
'ark-controller': { name: 'ark-controller' },
|
|
84
|
+
});
|
|
85
|
+
const command = createInstallCommand(mockConfig);
|
|
86
|
+
await expect(command.parseAsync(['node', 'test', 'invalid-service'])).rejects.toThrow('process.exit called');
|
|
87
|
+
expect(mockOutput.error).toHaveBeenCalledWith("service 'invalid-service' not found");
|
|
88
|
+
expect(mockOutput.info).toHaveBeenCalledWith('available services:');
|
|
89
|
+
expect(mockOutput.info).toHaveBeenCalledWith(' ark-api');
|
|
90
|
+
expect(mockOutput.info).toHaveBeenCalledWith(' ark-controller');
|
|
91
|
+
expect(mockExit).toHaveBeenCalledWith(1);
|
|
92
|
+
});
|
|
93
|
+
it('handles service without namespace (uses current context)', async () => {
|
|
94
|
+
const mockService = {
|
|
95
|
+
name: 'ark-dashboard',
|
|
96
|
+
helmReleaseName: 'ark-dashboard',
|
|
97
|
+
chartPath: './charts/ark-dashboard',
|
|
98
|
+
// namespace is undefined - should use current context
|
|
99
|
+
installArgs: ['--set', 'replicas=2'],
|
|
100
|
+
};
|
|
101
|
+
mockGetInstallableServices.mockReturnValue({
|
|
102
|
+
'ark-dashboard': mockService,
|
|
103
|
+
});
|
|
104
|
+
const command = createInstallCommand(mockConfig);
|
|
105
|
+
await command.parseAsync(['node', 'test', 'ark-dashboard']);
|
|
106
|
+
// Should NOT include --namespace flag
|
|
107
|
+
expect(mockExeca).toHaveBeenCalledWith('helm', [
|
|
108
|
+
'upgrade',
|
|
109
|
+
'--install',
|
|
110
|
+
'ark-dashboard',
|
|
111
|
+
'./charts/ark-dashboard',
|
|
112
|
+
'--set',
|
|
113
|
+
'replicas=2',
|
|
114
|
+
], { stdio: 'inherit' });
|
|
115
|
+
});
|
|
116
|
+
it('handles service without installArgs', async () => {
|
|
117
|
+
const mockService = {
|
|
118
|
+
name: 'simple-service',
|
|
119
|
+
helmReleaseName: 'simple-service',
|
|
120
|
+
chartPath: './charts/simple',
|
|
121
|
+
namespace: 'default',
|
|
122
|
+
};
|
|
123
|
+
mockGetInstallableServices.mockReturnValue({
|
|
124
|
+
'simple-service': mockService,
|
|
125
|
+
});
|
|
126
|
+
const command = createInstallCommand(mockConfig);
|
|
127
|
+
await command.parseAsync(['node', 'test', 'simple-service']);
|
|
128
|
+
expect(mockExeca).toHaveBeenCalledWith('helm', [
|
|
129
|
+
'upgrade',
|
|
130
|
+
'--install',
|
|
131
|
+
'simple-service',
|
|
132
|
+
'./charts/simple',
|
|
133
|
+
'--namespace',
|
|
134
|
+
'default',
|
|
135
|
+
], { stdio: 'inherit' });
|
|
136
|
+
});
|
|
137
|
+
it('exits when cluster not connected', async () => {
|
|
138
|
+
mockGetClusterInfo.mockResolvedValue({ error: true });
|
|
139
|
+
const command = createInstallCommand({});
|
|
140
|
+
await expect(command.parseAsync(['node', 'test', 'ark-api'])).rejects.toThrow('process.exit called');
|
|
141
|
+
expect(mockExit).toHaveBeenCalledWith(1);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createModel(modelName?: string): Promise<boolean>;
|