vigthoria-cli 1.1.0 → 1.4.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.
- package/README.md +85 -2
- package/SECURITY_HARDENING.md +253 -0
- package/dist/commands/chat.d.ts +2 -2
- package/dist/commands/chat.js +4 -4
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/deploy.d.ts +80 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +514 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/generate.d.ts +3 -0
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +45 -4
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/hub.d.ts +40 -0
- package/dist/commands/hub.d.ts.map +1 -0
- package/dist/commands/hub.js +289 -0
- package/dist/commands/hub.js.map +1 -0
- package/dist/commands/repo.d.ts +80 -0
- package/dist/commands/repo.d.ts.map +1 -0
- package/dist/commands/repo.js +607 -0
- package/dist/commands/repo.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +267 -10
- package/dist/index.js.map +1 -1
- package/dist/utils/api.d.ts +15 -0
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +62 -33
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/config.js +1 -1
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/session.d.ts +1 -1
- package/dist/utils/session.js +1 -1
- package/dist/utils/tools.d.ts +18 -3
- package/dist/utils/tools.d.ts.map +1 -1
- package/dist/utils/tools.js +326 -20
- package/dist/utils/tools.js.map +1 -1
- package/install.sh +1 -1
- package/package.json +6 -3
- package/src/commands/chat.ts +4 -4
- package/src/commands/deploy.ts +609 -0
- package/src/commands/generate.ts +49 -4
- package/src/commands/hub.ts +382 -0
- package/src/commands/repo.ts +729 -0
- package/src/index.ts +297 -10
- package/src/utils/api.ts +78 -34
- package/src/utils/config.ts +1 -1
- package/src/utils/session.ts +1 -1
- package/src/utils/tools.ts +348 -21
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vigthoria CLI - Deploy Commands
|
|
3
|
+
*
|
|
4
|
+
* Deploy and host projects on Vigthoria infrastructure
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* vig deploy - Interactive deploy wizard
|
|
8
|
+
* vig deploy --subdomain <name> - Deploy to name.vigthoria.io
|
|
9
|
+
* vig deploy --domain <domain> - Deploy to custom domain
|
|
10
|
+
* vig deploy status - Show deployment status
|
|
11
|
+
* vig deploy list - List all deployments
|
|
12
|
+
* vig deploy remove <domain> - Remove a deployment
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import chalk from 'chalk';
|
|
16
|
+
import * as fs from 'fs';
|
|
17
|
+
import * as path from 'path';
|
|
18
|
+
import { Config } from '../utils/config.js';
|
|
19
|
+
import { Logger } from '../utils/logger.js';
|
|
20
|
+
import ora from 'ora';
|
|
21
|
+
import inquirer from 'inquirer';
|
|
22
|
+
|
|
23
|
+
interface HostingPlan {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
display_name: string;
|
|
27
|
+
price_monthly: number;
|
|
28
|
+
price_yearly: number;
|
|
29
|
+
max_projects: number;
|
|
30
|
+
storage_mb: number;
|
|
31
|
+
custom_domain_allowed: boolean;
|
|
32
|
+
subdomain_allowed: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface DeployedDomain {
|
|
36
|
+
id: number;
|
|
37
|
+
domain_type: 'preview' | 'subdomain' | 'custom';
|
|
38
|
+
subdomain: string | null;
|
|
39
|
+
custom_domain: string | null;
|
|
40
|
+
project_name: string;
|
|
41
|
+
hosting_tier: string;
|
|
42
|
+
ssl_status: string;
|
|
43
|
+
is_active: boolean;
|
|
44
|
+
url: string;
|
|
45
|
+
created_at: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface DeployOptions {
|
|
49
|
+
subdomain?: string;
|
|
50
|
+
domain?: string;
|
|
51
|
+
project?: string;
|
|
52
|
+
force?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export class DeployCommand {
|
|
56
|
+
private config: Config;
|
|
57
|
+
private logger: Logger;
|
|
58
|
+
private apiBase: string;
|
|
59
|
+
|
|
60
|
+
constructor(config: Config, logger: Logger) {
|
|
61
|
+
this.config = config;
|
|
62
|
+
this.logger = logger;
|
|
63
|
+
this.apiBase = this.config.get('apiUrl') || 'https://coder.vigthoria.io';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private getAuthHeaders(): Record<string, string> {
|
|
67
|
+
const token = this.config.get('authToken');
|
|
68
|
+
return {
|
|
69
|
+
'Authorization': `Bearer ${token}`,
|
|
70
|
+
'Content-Type': 'application/json'
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private isAuthenticated(): boolean {
|
|
75
|
+
return !!this.config.get('authToken');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private requireAuth(): void {
|
|
79
|
+
if (!this.isAuthenticated()) {
|
|
80
|
+
console.log(chalk.red('\n❌ Authentication required'));
|
|
81
|
+
console.log(chalk.gray(' Run `vig login` to authenticate first.\n'));
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Interactive deploy wizard
|
|
88
|
+
*/
|
|
89
|
+
async deploy(options: DeployOptions = {}): Promise<void> {
|
|
90
|
+
this.requireAuth();
|
|
91
|
+
|
|
92
|
+
console.log(chalk.cyan('\n🚀 Vigthoria Deploy - Host Your Project\n'));
|
|
93
|
+
|
|
94
|
+
// If subdomain or domain specified, deploy directly
|
|
95
|
+
if (options.subdomain) {
|
|
96
|
+
await this.deployToSubdomain(options.subdomain, options.project);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (options.domain) {
|
|
101
|
+
await this.deployToCustomDomain(options.domain, options.project);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Interactive wizard
|
|
106
|
+
const { deployType } = await inquirer.prompt([{
|
|
107
|
+
type: 'list',
|
|
108
|
+
name: 'deployType',
|
|
109
|
+
message: 'How would you like to deploy?',
|
|
110
|
+
choices: [
|
|
111
|
+
{ name: '🆓 Preview URL (Free) - coder.vigthoria.io/preview/...', value: 'preview' },
|
|
112
|
+
{ name: '🌐 Vigthoria Subdomain (€4.99/mo) - yourapp.vigthoria.io', value: 'subdomain' },
|
|
113
|
+
{ name: '🔗 Custom Domain (€9.99/mo) - yourdomain.com', value: 'custom' },
|
|
114
|
+
{ name: '📊 View Hosting Plans', value: 'plans' }
|
|
115
|
+
]
|
|
116
|
+
}]);
|
|
117
|
+
|
|
118
|
+
switch (deployType) {
|
|
119
|
+
case 'preview':
|
|
120
|
+
await this.deployToPreview(options.project);
|
|
121
|
+
break;
|
|
122
|
+
case 'subdomain':
|
|
123
|
+
await this.promptSubdomainDeploy(options.project);
|
|
124
|
+
break;
|
|
125
|
+
case 'custom':
|
|
126
|
+
await this.promptCustomDomainDeploy(options.project);
|
|
127
|
+
break;
|
|
128
|
+
case 'plans':
|
|
129
|
+
await this.showPlans();
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Deploy to preview URL (free)
|
|
136
|
+
*/
|
|
137
|
+
async deployToPreview(projectPath?: string): Promise<void> {
|
|
138
|
+
const spinner = ora('Deploying to preview...').start();
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
const projectDir = projectPath || process.cwd();
|
|
142
|
+
const projectInfo = this.detectProjectInfo(projectDir);
|
|
143
|
+
|
|
144
|
+
const response = await fetch(`${this.apiBase}/api/hosting/deploy/preview`, {
|
|
145
|
+
method: 'POST',
|
|
146
|
+
headers: this.getAuthHeaders(),
|
|
147
|
+
body: JSON.stringify({
|
|
148
|
+
projectName: projectInfo.name,
|
|
149
|
+
projectPath: projectDir
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
if (!response.ok) {
|
|
154
|
+
const error = await response.json() as { error?: string };
|
|
155
|
+
throw new Error(error.error || 'Failed to deploy');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const data = await response.json() as { success: boolean; url: string; message: string };
|
|
159
|
+
|
|
160
|
+
spinner.succeed(chalk.green('Deployed to preview!'));
|
|
161
|
+
|
|
162
|
+
console.log(chalk.cyan('\n🔗 Preview URL:'));
|
|
163
|
+
console.log(chalk.white(` ${data.url}`));
|
|
164
|
+
console.log(chalk.gray('\n Note: Preview URLs may expire after 7 days of inactivity.'));
|
|
165
|
+
console.log(chalk.gray(' Upgrade to a subdomain for permanent hosting.\n'));
|
|
166
|
+
|
|
167
|
+
} catch (error) {
|
|
168
|
+
spinner.fail('Deploy failed');
|
|
169
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
170
|
+
console.log(chalk.red(`\n❌ Error: ${errMsg}\n`));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Deploy to Vigthoria subdomain
|
|
176
|
+
*/
|
|
177
|
+
async deployToSubdomain(subdomain: string, projectPath?: string): Promise<void> {
|
|
178
|
+
const spinner = ora(`Deploying to ${subdomain}.vigthoria.io...`).start();
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
// Validate subdomain format
|
|
182
|
+
if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]$/.test(subdomain) || subdomain.length < 3) {
|
|
183
|
+
throw new Error('Subdomain must be 3+ chars, lowercase alphanumeric with hyphens');
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const projectDir = projectPath || process.cwd();
|
|
187
|
+
const projectInfo = this.detectProjectInfo(projectDir);
|
|
188
|
+
|
|
189
|
+
const response = await fetch(`${this.apiBase}/api/hosting/deploy/subdomain`, {
|
|
190
|
+
method: 'POST',
|
|
191
|
+
headers: this.getAuthHeaders(),
|
|
192
|
+
body: JSON.stringify({
|
|
193
|
+
subdomain,
|
|
194
|
+
projectName: projectInfo.name,
|
|
195
|
+
projectPath: projectDir
|
|
196
|
+
})
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const data = await response.json() as {
|
|
200
|
+
success: boolean;
|
|
201
|
+
url?: string;
|
|
202
|
+
error?: string;
|
|
203
|
+
requiresSubscription?: boolean;
|
|
204
|
+
checkoutUrl?: string;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
if (!response.ok || !data.success) {
|
|
208
|
+
if (data.requiresSubscription) {
|
|
209
|
+
spinner.stop();
|
|
210
|
+
console.log(chalk.yellow('\n⚠️ Subdomain hosting requires a subscription (€4.99/mo)'));
|
|
211
|
+
|
|
212
|
+
const { proceed } = await inquirer.prompt([{
|
|
213
|
+
type: 'confirm',
|
|
214
|
+
name: 'proceed',
|
|
215
|
+
message: 'Would you like to subscribe now?',
|
|
216
|
+
default: true
|
|
217
|
+
}]);
|
|
218
|
+
|
|
219
|
+
if (proceed && data.checkoutUrl) {
|
|
220
|
+
console.log(chalk.cyan(`\n🔗 Opening checkout: ${data.checkoutUrl}`));
|
|
221
|
+
console.log(chalk.gray('Please open this URL in your browser to subscribe.\n'));
|
|
222
|
+
}
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
throw new Error(data.error || 'Failed to deploy');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
spinner.succeed(chalk.green(`Deployed to ${subdomain}.vigthoria.io!`));
|
|
229
|
+
|
|
230
|
+
console.log(chalk.cyan('\n🌐 Your Site is Live:'));
|
|
231
|
+
console.log(chalk.bold.white(` https://${subdomain}.vigthoria.io`));
|
|
232
|
+
console.log(chalk.gray('\n ✓ SSL certificate auto-configured'));
|
|
233
|
+
console.log(chalk.gray(' ✓ Global CDN enabled'));
|
|
234
|
+
console.log(chalk.gray(' ✓ Unlimited traffic included\n'));
|
|
235
|
+
|
|
236
|
+
} catch (error) {
|
|
237
|
+
spinner.fail('Deploy failed');
|
|
238
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
239
|
+
console.log(chalk.red(`\n❌ Error: ${errMsg}\n`));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Deploy to custom domain
|
|
245
|
+
*/
|
|
246
|
+
async deployToCustomDomain(domain: string, projectPath?: string): Promise<void> {
|
|
247
|
+
const spinner = ora(`Setting up ${domain}...`).start();
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
const projectDir = projectPath || process.cwd();
|
|
251
|
+
const projectInfo = this.detectProjectInfo(projectDir);
|
|
252
|
+
|
|
253
|
+
const response = await fetch(`${this.apiBase}/api/hosting/deploy/custom`, {
|
|
254
|
+
method: 'POST',
|
|
255
|
+
headers: this.getAuthHeaders(),
|
|
256
|
+
body: JSON.stringify({
|
|
257
|
+
domain,
|
|
258
|
+
projectName: projectInfo.name,
|
|
259
|
+
projectPath: projectDir
|
|
260
|
+
})
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
const data = await response.json() as {
|
|
264
|
+
success: boolean;
|
|
265
|
+
url?: string;
|
|
266
|
+
error?: string;
|
|
267
|
+
requiresSubscription?: boolean;
|
|
268
|
+
checkoutUrl?: string;
|
|
269
|
+
dnsRecords?: { type: string; name: string; value: string }[];
|
|
270
|
+
verificationCode?: string;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
if (!response.ok || !data.success) {
|
|
274
|
+
if (data.requiresSubscription) {
|
|
275
|
+
spinner.stop();
|
|
276
|
+
console.log(chalk.yellow('\n⚠️ Custom domain hosting requires a subscription (€9.99/mo)'));
|
|
277
|
+
|
|
278
|
+
const { proceed } = await inquirer.prompt([{
|
|
279
|
+
type: 'confirm',
|
|
280
|
+
name: 'proceed',
|
|
281
|
+
message: 'Would you like to subscribe now?',
|
|
282
|
+
default: true
|
|
283
|
+
}]);
|
|
284
|
+
|
|
285
|
+
if (proceed && data.checkoutUrl) {
|
|
286
|
+
console.log(chalk.cyan(`\n🔗 Checkout URL: ${data.checkoutUrl}`));
|
|
287
|
+
console.log(chalk.gray('Please open this URL in your browser to subscribe.\n'));
|
|
288
|
+
}
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
throw new Error(data.error || 'Failed to deploy');
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
spinner.succeed(chalk.green('Domain registered!'));
|
|
295
|
+
|
|
296
|
+
if (data.dnsRecords) {
|
|
297
|
+
console.log(chalk.cyan('\n📝 Configure your DNS records:'));
|
|
298
|
+
console.log(chalk.gray('─'.repeat(60)));
|
|
299
|
+
|
|
300
|
+
for (const record of data.dnsRecords) {
|
|
301
|
+
console.log(chalk.white(` Type: ${record.type.padEnd(6)} Name: ${record.name.padEnd(20)} Value: ${record.value}`));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
console.log(chalk.gray('─'.repeat(60)));
|
|
305
|
+
console.log(chalk.yellow('\n⏳ After adding DNS records, run:'));
|
|
306
|
+
console.log(chalk.white(` vig deploy verify ${domain}\n`));
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
} catch (error) {
|
|
310
|
+
spinner.fail('Deploy failed');
|
|
311
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
312
|
+
console.log(chalk.red(`\n❌ Error: ${errMsg}\n`));
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Interactive subdomain prompt
|
|
318
|
+
*/
|
|
319
|
+
async promptSubdomainDeploy(projectPath?: string): Promise<void> {
|
|
320
|
+
const { subdomain } = await inquirer.prompt([{
|
|
321
|
+
type: 'input',
|
|
322
|
+
name: 'subdomain',
|
|
323
|
+
message: 'Enter your desired subdomain:',
|
|
324
|
+
suffix: chalk.gray('.vigthoria.io'),
|
|
325
|
+
validate: (input: string) => {
|
|
326
|
+
if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]$/.test(input) || input.length < 3) {
|
|
327
|
+
return 'Subdomain must be 3+ chars, lowercase alphanumeric with hyphens';
|
|
328
|
+
}
|
|
329
|
+
return true;
|
|
330
|
+
}
|
|
331
|
+
}]);
|
|
332
|
+
|
|
333
|
+
await this.deployToSubdomain(subdomain, projectPath);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Interactive custom domain prompt
|
|
338
|
+
*/
|
|
339
|
+
async promptCustomDomainDeploy(projectPath?: string): Promise<void> {
|
|
340
|
+
const { domain } = await inquirer.prompt([{
|
|
341
|
+
type: 'input',
|
|
342
|
+
name: 'domain',
|
|
343
|
+
message: 'Enter your domain:',
|
|
344
|
+
suffix: chalk.gray(' (e.g., myapp.com)'),
|
|
345
|
+
validate: (input: string) => {
|
|
346
|
+
if (!/^[a-z0-9][a-z0-9.-]+\.[a-z]{2,}$/i.test(input)) {
|
|
347
|
+
return 'Please enter a valid domain name';
|
|
348
|
+
}
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
}]);
|
|
352
|
+
|
|
353
|
+
await this.deployToCustomDomain(domain, projectPath);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Show hosting plans
|
|
358
|
+
*/
|
|
359
|
+
async showPlans(): Promise<void> {
|
|
360
|
+
const spinner = ora('Fetching hosting plans...').start();
|
|
361
|
+
|
|
362
|
+
try {
|
|
363
|
+
const response = await fetch(`${this.apiBase}/api/hosting/plans`, {
|
|
364
|
+
headers: this.getAuthHeaders()
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
if (!response.ok) {
|
|
368
|
+
throw new Error('Failed to fetch plans');
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const data = await response.json() as { success: boolean; plans: HostingPlan[] };
|
|
372
|
+
|
|
373
|
+
spinner.stop();
|
|
374
|
+
|
|
375
|
+
console.log(chalk.cyan('\n📊 Vigthoria Hosting Plans\n'));
|
|
376
|
+
console.log(chalk.gray('═'.repeat(70)));
|
|
377
|
+
|
|
378
|
+
for (const plan of data.plans) {
|
|
379
|
+
const price = plan.price_monthly === 0
|
|
380
|
+
? chalk.green('FREE')
|
|
381
|
+
: chalk.yellow(`€${plan.price_monthly.toFixed(2)}/mo`);
|
|
382
|
+
|
|
383
|
+
console.log(chalk.bold.white(`\n ${plan.display_name} - ${price}`));
|
|
384
|
+
console.log(chalk.gray(' ' + '─'.repeat(50)));
|
|
385
|
+
|
|
386
|
+
const features = [];
|
|
387
|
+
if (plan.subdomain_allowed) features.push('✓ Vigthoria subdomain');
|
|
388
|
+
if (plan.custom_domain_allowed) features.push('✓ Custom domain');
|
|
389
|
+
features.push(`✓ ${plan.max_projects === -1 ? 'Unlimited' : plan.max_projects} project(s)`);
|
|
390
|
+
features.push(`✓ ${plan.storage_mb >= 1024 ? (plan.storage_mb / 1024) + 'GB' : plan.storage_mb + 'MB'} storage`);
|
|
391
|
+
|
|
392
|
+
features.forEach(f => console.log(chalk.gray(` ${f}`)));
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
console.log(chalk.gray('\n' + '═'.repeat(70)));
|
|
396
|
+
console.log(chalk.cyan('\n Subscribe: vig deploy --subdomain myapp\n'));
|
|
397
|
+
|
|
398
|
+
} catch (error) {
|
|
399
|
+
spinner.fail('Failed to fetch plans');
|
|
400
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
401
|
+
console.log(chalk.red(`\n❌ Error: ${errMsg}\n`));
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* List all deployments
|
|
407
|
+
*/
|
|
408
|
+
async list(): Promise<void> {
|
|
409
|
+
this.requireAuth();
|
|
410
|
+
|
|
411
|
+
const spinner = ora('Fetching deployments...').start();
|
|
412
|
+
|
|
413
|
+
try {
|
|
414
|
+
const response = await fetch(`${this.apiBase}/api/hosting/domains`, {
|
|
415
|
+
headers: this.getAuthHeaders()
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
if (!response.ok) {
|
|
419
|
+
throw new Error('Failed to fetch deployments');
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const data = await response.json() as { success: boolean; domains: DeployedDomain[] };
|
|
423
|
+
|
|
424
|
+
spinner.stop();
|
|
425
|
+
|
|
426
|
+
if (data.domains.length === 0) {
|
|
427
|
+
console.log(chalk.yellow('\n📦 No deployments yet.\n'));
|
|
428
|
+
console.log(chalk.gray(' Run `vig deploy` to deploy your first project.\n'));
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
console.log(chalk.cyan(`\n🌐 Your Deployments (${data.domains.length})\n`));
|
|
433
|
+
|
|
434
|
+
for (const domain of data.domains) {
|
|
435
|
+
const statusIcon = domain.is_active ? '🟢' : '🔴';
|
|
436
|
+
const sslIcon = domain.ssl_status === 'active' ? '🔒' : '⚠️';
|
|
437
|
+
|
|
438
|
+
const url = domain.domain_type === 'subdomain'
|
|
439
|
+
? `${domain.subdomain}.vigthoria.io`
|
|
440
|
+
: domain.domain_type === 'custom'
|
|
441
|
+
? domain.custom_domain
|
|
442
|
+
: domain.url;
|
|
443
|
+
|
|
444
|
+
console.log(chalk.white(` ${statusIcon} ${url}`));
|
|
445
|
+
console.log(chalk.gray(` Project: ${domain.project_name} | SSL: ${sslIcon} ${domain.ssl_status} | Tier: ${domain.hosting_tier}`));
|
|
446
|
+
console.log();
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
} catch (error) {
|
|
450
|
+
spinner.fail('List failed');
|
|
451
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
452
|
+
console.log(chalk.red(`\n❌ Error: ${errMsg}\n`));
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Check deployment status
|
|
458
|
+
*/
|
|
459
|
+
async status(domain?: string): Promise<void> {
|
|
460
|
+
this.requireAuth();
|
|
461
|
+
|
|
462
|
+
const spinner = ora('Checking status...').start();
|
|
463
|
+
|
|
464
|
+
try {
|
|
465
|
+
const endpoint = domain
|
|
466
|
+
? `${this.apiBase}/api/hosting/domain/${encodeURIComponent(domain)}/status`
|
|
467
|
+
: `${this.apiBase}/api/hosting/status`;
|
|
468
|
+
|
|
469
|
+
const response = await fetch(endpoint, {
|
|
470
|
+
headers: this.getAuthHeaders()
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
if (!response.ok) {
|
|
474
|
+
throw new Error('Failed to fetch status');
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const data = await response.json();
|
|
478
|
+
|
|
479
|
+
spinner.stop();
|
|
480
|
+
|
|
481
|
+
console.log(chalk.cyan('\n📊 Deployment Status\n'));
|
|
482
|
+
console.log(JSON.stringify(data, null, 2));
|
|
483
|
+
|
|
484
|
+
} catch (error) {
|
|
485
|
+
spinner.fail('Status check failed');
|
|
486
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
487
|
+
console.log(chalk.red(`\n❌ Error: ${errMsg}\n`));
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Verify DNS for custom domain
|
|
493
|
+
*/
|
|
494
|
+
async verify(domain: string): Promise<void> {
|
|
495
|
+
this.requireAuth();
|
|
496
|
+
|
|
497
|
+
const spinner = ora(`Verifying DNS for ${domain}...`).start();
|
|
498
|
+
|
|
499
|
+
try {
|
|
500
|
+
const response = await fetch(`${this.apiBase}/api/hosting/domain/verify`, {
|
|
501
|
+
method: 'POST',
|
|
502
|
+
headers: this.getAuthHeaders(),
|
|
503
|
+
body: JSON.stringify({ domain })
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
const data = await response.json() as {
|
|
507
|
+
success: boolean;
|
|
508
|
+
verified: boolean;
|
|
509
|
+
error?: string;
|
|
510
|
+
sslStatus?: string;
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
if (!response.ok || !data.success) {
|
|
514
|
+
throw new Error(data.error || 'Verification failed');
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (data.verified) {
|
|
518
|
+
spinner.succeed(chalk.green('Domain verified!'));
|
|
519
|
+
console.log(chalk.cyan(`\n🎉 Your site is now live at: https://${domain}`));
|
|
520
|
+
console.log(chalk.gray(` SSL Status: ${data.sslStatus || 'Provisioning...'}\n`));
|
|
521
|
+
} else {
|
|
522
|
+
spinner.warn(chalk.yellow('DNS not propagated yet'));
|
|
523
|
+
console.log(chalk.gray('\n DNS changes can take up to 48 hours to propagate.'));
|
|
524
|
+
console.log(chalk.gray(' Try again later with: vig deploy verify ' + domain + '\n'));
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
} catch (error) {
|
|
528
|
+
spinner.fail('Verification failed');
|
|
529
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
530
|
+
console.log(chalk.red(`\n❌ Error: ${errMsg}\n`));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Remove a deployment
|
|
536
|
+
*/
|
|
537
|
+
async remove(domain: string): Promise<void> {
|
|
538
|
+
this.requireAuth();
|
|
539
|
+
|
|
540
|
+
const { confirm } = await inquirer.prompt([{
|
|
541
|
+
type: 'confirm',
|
|
542
|
+
name: 'confirm',
|
|
543
|
+
message: chalk.red(`Are you sure you want to remove ${domain}?`),
|
|
544
|
+
default: false
|
|
545
|
+
}]);
|
|
546
|
+
|
|
547
|
+
if (!confirm) {
|
|
548
|
+
console.log(chalk.yellow('\n⚠️ Removal cancelled.\n'));
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
const spinner = ora(`Removing ${domain}...`).start();
|
|
553
|
+
|
|
554
|
+
try {
|
|
555
|
+
const response = await fetch(`${this.apiBase}/api/hosting/domain/${encodeURIComponent(domain)}`, {
|
|
556
|
+
method: 'DELETE',
|
|
557
|
+
headers: this.getAuthHeaders()
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
if (!response.ok) {
|
|
561
|
+
const error = await response.json() as { error?: string };
|
|
562
|
+
throw new Error(error.error || 'Failed to remove');
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
spinner.succeed(chalk.green('Domain removed'));
|
|
566
|
+
console.log(chalk.gray('\n Your project files are still in your repository.\n'));
|
|
567
|
+
|
|
568
|
+
} catch (error) {
|
|
569
|
+
spinner.fail('Remove failed');
|
|
570
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
571
|
+
console.log(chalk.red(`\n❌ Error: ${errMsg}\n`));
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Detect project info from directory
|
|
577
|
+
*/
|
|
578
|
+
private detectProjectInfo(projectPath: string): { name: string; techStack: string[] } {
|
|
579
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
580
|
+
let name = path.basename(projectPath);
|
|
581
|
+
const techStack: string[] = [];
|
|
582
|
+
|
|
583
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
584
|
+
try {
|
|
585
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
586
|
+
name = pkg.name || name;
|
|
587
|
+
|
|
588
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
589
|
+
if (deps.react) techStack.push('React');
|
|
590
|
+
if (deps.vue) techStack.push('Vue');
|
|
591
|
+
if (deps.next) techStack.push('Next.js');
|
|
592
|
+
if (deps.express) techStack.push('Express');
|
|
593
|
+
if (deps.typescript) techStack.push('TypeScript');
|
|
594
|
+
} catch (e) {
|
|
595
|
+
// Ignore parse errors
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// Check for other frameworks
|
|
600
|
+
if (fs.existsSync(path.join(projectPath, 'requirements.txt'))) {
|
|
601
|
+
techStack.push('Python');
|
|
602
|
+
}
|
|
603
|
+
if (fs.existsSync(path.join(projectPath, 'index.html'))) {
|
|
604
|
+
techStack.push('Static HTML');
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
return { name, techStack };
|
|
608
|
+
}
|
|
609
|
+
}
|
package/src/commands/generate.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generate Command - Generate code from description
|
|
3
|
+
*
|
|
4
|
+
* Now with Senior Developer Mode (--pro) for impressive, production-ready output
|
|
3
5
|
*/
|
|
4
6
|
|
|
5
7
|
import chalk from 'chalk';
|
|
@@ -14,6 +16,7 @@ interface GenerateOptions {
|
|
|
14
16
|
language: string;
|
|
15
17
|
output?: string;
|
|
16
18
|
model: string;
|
|
19
|
+
pro?: boolean; // Senior Developer Mode
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
export class GenerateCommand {
|
|
@@ -36,20 +39,62 @@ export class GenerateCommand {
|
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
// Determine mode
|
|
43
|
+
const proMode = options.pro === true;
|
|
44
|
+
|
|
45
|
+
this.logger.section(proMode ? '🚀 Senior Developer Mode' : 'Code Generation');
|
|
40
46
|
console.log(chalk.gray(`Language: ${options.language}`));
|
|
41
47
|
console.log(chalk.gray(`Description: ${description}`));
|
|
48
|
+
if (proMode) {
|
|
49
|
+
console.log(chalk.cyan('Pro Mode: Planning → Generating → Quality Check'));
|
|
50
|
+
}
|
|
42
51
|
console.log();
|
|
43
52
|
|
|
44
53
|
const spinner = ora({
|
|
45
|
-
text: 'Generating code...',
|
|
54
|
+
text: proMode ? 'Phase 1: Planning project structure...' : 'Generating code...',
|
|
46
55
|
spinner: 'dots',
|
|
47
56
|
}).start();
|
|
48
57
|
|
|
49
58
|
try {
|
|
50
|
-
|
|
59
|
+
let code: string;
|
|
60
|
+
let quality: any = null;
|
|
51
61
|
|
|
52
|
-
|
|
62
|
+
if (proMode) {
|
|
63
|
+
// Senior Developer Mode - uses planning and quality checks
|
|
64
|
+
spinner.text = 'Phase 1: Planning project structure...';
|
|
65
|
+
const result = await this.api.generateProject(description, options.language, options.model);
|
|
66
|
+
|
|
67
|
+
spinner.text = 'Phase 2: Generating impressive code...';
|
|
68
|
+
code = result.code;
|
|
69
|
+
quality = result.quality;
|
|
70
|
+
|
|
71
|
+
spinner.stop();
|
|
72
|
+
|
|
73
|
+
// Show quality report
|
|
74
|
+
if (quality) {
|
|
75
|
+
console.log();
|
|
76
|
+
this.logger.section('Quality Report');
|
|
77
|
+
console.log(chalk.gray(`Lines of code: ${quality.lineCount}`));
|
|
78
|
+
console.log(chalk.gray(`Quality score: ${quality.score}/5`));
|
|
79
|
+
console.log();
|
|
80
|
+
console.log(chalk.gray('Visual Checks:'));
|
|
81
|
+
console.log(` ${quality.checks?.hasAnimations ? chalk.green('✓') : chalk.red('✗')} CSS Animations (@keyframes)`);
|
|
82
|
+
console.log(` ${quality.checks?.hasNeonEffects ? chalk.green('✓') : chalk.red('✗')} Neon/Glow Effects`);
|
|
83
|
+
console.log(` ${quality.checks?.hasResponsive ? chalk.green('✓') : chalk.red('✗')} Responsive Design (@media)`);
|
|
84
|
+
console.log(` ${quality.checks?.hasFontAwesome ? chalk.green('✓') : chalk.red('✗')} Font Awesome Icons`);
|
|
85
|
+
console.log(` ${quality.checks?.hasGoogleFonts ? chalk.green('✓') : chalk.red('✗')} Google Fonts`);
|
|
86
|
+
console.log();
|
|
87
|
+
console.log(chalk.gray('Structure Checks:'));
|
|
88
|
+
console.log(` ${quality.checks?.hasEmbeddedCSS ? chalk.green('✓') : chalk.red('✗')} Embedded CSS (<style> tag)`);
|
|
89
|
+
console.log(` ${quality.checks?.hasEmbeddedJS ? chalk.green('✓') : chalk.red('✗')} Embedded JavaScript (<script> tag)`);
|
|
90
|
+
console.log(` ${quality.checks?.singleFile ? chalk.green('✓') : chalk.red('✗')} Single-file (no external CSS/JS)`);
|
|
91
|
+
console.log();
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
// Standard mode
|
|
95
|
+
code = await this.api.generateCode(description, options.language, options.model);
|
|
96
|
+
spinner.stop();
|
|
97
|
+
}
|
|
53
98
|
|
|
54
99
|
// Display generated code
|
|
55
100
|
this.logger.section('Generated Code');
|