vigthoria-cli 1.1.0 ā 1.3.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 +83 -0
- 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/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 +585 -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 +254 -7
- package/dist/index.js.map +1 -1
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +6 -24
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/tools.d.ts +6 -0
- package/dist/utils/tools.d.ts.map +1 -1
- package/dist/utils/tools.js +269 -15
- package/dist/utils/tools.js.map +1 -1
- package/package.json +5 -2
- package/src/commands/deploy.ts +609 -0
- package/src/commands/hub.ts +382 -0
- package/src/commands/repo.ts +701 -0
- package/src/index.ts +285 -7
- package/src/utils/api.ts +6 -25
- package/src/utils/tools.ts +283 -16
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ Similar to Claude Code, but integrated with Vigthoria's AI models and subscripti
|
|
|
22
22
|
- š **Code Review** - Quality analysis and suggestions
|
|
23
23
|
- š **Secure Auth** - Integration with Vigthoria accounts
|
|
24
24
|
- š¦ **Project Context** - Understands your codebase
|
|
25
|
+
- šļø **Vigthoria Repo** - Push/Pull projects to your personal cloud repository
|
|
25
26
|
|
|
26
27
|
## Installation
|
|
27
28
|
|
|
@@ -211,6 +212,88 @@ vigthoria init
|
|
|
211
212
|
|
|
212
213
|
Creates a `.vigthoria.json` file with project-specific settings.
|
|
213
214
|
|
|
215
|
+
### Vigthoria Repository (Cloud Storage)
|
|
216
|
+
|
|
217
|
+
Push and pull your projects to/from your personal Vigthoria Repository - your cloud workspace for projects.
|
|
218
|
+
|
|
219
|
+
#### Push a Project
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# Push current directory to Vigthoria Repo
|
|
223
|
+
vigthoria repo push
|
|
224
|
+
|
|
225
|
+
# Push specific path
|
|
226
|
+
vigthoria repo push /path/to/project
|
|
227
|
+
|
|
228
|
+
# Push with visibility setting
|
|
229
|
+
vigthoria repo push --visibility private
|
|
230
|
+
vigthoria repo push --visibility public
|
|
231
|
+
vigthoria repo push --visibility restricted
|
|
232
|
+
|
|
233
|
+
# Force overwrite existing project
|
|
234
|
+
vigthoria repo push --force
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
#### Pull a Project
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Pull a project from your repo
|
|
241
|
+
vigthoria repo pull my-project
|
|
242
|
+
|
|
243
|
+
# Pull to specific output directory
|
|
244
|
+
vigthoria repo pull my-project --output /path/to/destination
|
|
245
|
+
|
|
246
|
+
# Overwrite existing directory
|
|
247
|
+
vigthoria repo pull my-project --force
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### List Projects
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# List all your projects
|
|
254
|
+
vigthoria repo list
|
|
255
|
+
# or
|
|
256
|
+
vigthoria repo ls
|
|
257
|
+
|
|
258
|
+
# Filter by visibility
|
|
259
|
+
vigthoria repo list --visibility private
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### Check Sync Status
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# Check if current project is synced
|
|
266
|
+
vigthoria repo status
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
#### Share a Project
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Generate shareable link (default 7 days)
|
|
273
|
+
vigthoria repo share my-project
|
|
274
|
+
|
|
275
|
+
# Custom expiration
|
|
276
|
+
vigthoria repo share my-project --expires 24h
|
|
277
|
+
vigthoria repo share my-project --expires 30d
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
#### Delete a Project
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
# Remove from Vigthoria Repo (local files unaffected)
|
|
284
|
+
vigthoria repo delete my-project
|
|
285
|
+
# or
|
|
286
|
+
vigthoria repo rm my-project
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
#### Clone a Public Project
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
# Clone from preview URL or project ID
|
|
293
|
+
vigthoria repo clone https://coder.vigthoria.io/preview/123
|
|
294
|
+
vigthoria repo clone 123
|
|
295
|
+
```
|
|
296
|
+
|
|
214
297
|
## Available Models
|
|
215
298
|
|
|
216
299
|
### Vigthoria Native Models
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
import { Config } from '../utils/config.js';
|
|
15
|
+
import { Logger } from '../utils/logger.js';
|
|
16
|
+
interface DeployOptions {
|
|
17
|
+
subdomain?: string;
|
|
18
|
+
domain?: string;
|
|
19
|
+
project?: string;
|
|
20
|
+
force?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare class DeployCommand {
|
|
23
|
+
private config;
|
|
24
|
+
private logger;
|
|
25
|
+
private apiBase;
|
|
26
|
+
constructor(config: Config, logger: Logger);
|
|
27
|
+
private getAuthHeaders;
|
|
28
|
+
private isAuthenticated;
|
|
29
|
+
private requireAuth;
|
|
30
|
+
/**
|
|
31
|
+
* Interactive deploy wizard
|
|
32
|
+
*/
|
|
33
|
+
deploy(options?: DeployOptions): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Deploy to preview URL (free)
|
|
36
|
+
*/
|
|
37
|
+
deployToPreview(projectPath?: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Deploy to Vigthoria subdomain
|
|
40
|
+
*/
|
|
41
|
+
deployToSubdomain(subdomain: string, projectPath?: string): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Deploy to custom domain
|
|
44
|
+
*/
|
|
45
|
+
deployToCustomDomain(domain: string, projectPath?: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Interactive subdomain prompt
|
|
48
|
+
*/
|
|
49
|
+
promptSubdomainDeploy(projectPath?: string): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Interactive custom domain prompt
|
|
52
|
+
*/
|
|
53
|
+
promptCustomDomainDeploy(projectPath?: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Show hosting plans
|
|
56
|
+
*/
|
|
57
|
+
showPlans(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* List all deployments
|
|
60
|
+
*/
|
|
61
|
+
list(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Check deployment status
|
|
64
|
+
*/
|
|
65
|
+
status(domain?: string): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Verify DNS for custom domain
|
|
68
|
+
*/
|
|
69
|
+
verify(domain: string): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Remove a deployment
|
|
72
|
+
*/
|
|
73
|
+
remove(domain: string): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Detect project info from directory
|
|
76
|
+
*/
|
|
77
|
+
private detectProjectInfo;
|
|
78
|
+
}
|
|
79
|
+
export {};
|
|
80
|
+
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AA6B5C,UAAU,aAAa;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,aAAa;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAM1C,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,WAAW;IAQnB;;OAEG;IACG,MAAM,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CxD;;OAEG;IACG,eAAe,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC1D;;OAEG;IACG,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkE/E;;OAEG;IACG,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsE/E;;OAEG;IACG,qBAAqB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBhE;;OAEG;IACG,wBAAwB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBnE;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IA8ChC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgD3B;;OAEG;IACG,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC5C;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwC3C;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsC3C;;OAEG;IACH,OAAO,CAAC,iBAAiB;CA+B5B"}
|
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vigthoria CLI - Deploy Commands
|
|
4
|
+
*
|
|
5
|
+
* Deploy and host projects on Vigthoria infrastructure
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* vig deploy - Interactive deploy wizard
|
|
9
|
+
* vig deploy --subdomain <name> - Deploy to name.vigthoria.io
|
|
10
|
+
* vig deploy --domain <domain> - Deploy to custom domain
|
|
11
|
+
* vig deploy status - Show deployment status
|
|
12
|
+
* vig deploy list - List all deployments
|
|
13
|
+
* vig deploy remove <domain> - Remove a deployment
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
49
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
50
|
+
};
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.DeployCommand = void 0;
|
|
53
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
54
|
+
const fs = __importStar(require("fs"));
|
|
55
|
+
const path = __importStar(require("path"));
|
|
56
|
+
const ora_1 = __importDefault(require("ora"));
|
|
57
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
58
|
+
class DeployCommand {
|
|
59
|
+
config;
|
|
60
|
+
logger;
|
|
61
|
+
apiBase;
|
|
62
|
+
constructor(config, logger) {
|
|
63
|
+
this.config = config;
|
|
64
|
+
this.logger = logger;
|
|
65
|
+
this.apiBase = this.config.get('apiUrl') || 'https://coder.vigthoria.io';
|
|
66
|
+
}
|
|
67
|
+
getAuthHeaders() {
|
|
68
|
+
const token = this.config.get('authToken');
|
|
69
|
+
return {
|
|
70
|
+
'Authorization': `Bearer ${token}`,
|
|
71
|
+
'Content-Type': 'application/json'
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
isAuthenticated() {
|
|
75
|
+
return !!this.config.get('authToken');
|
|
76
|
+
}
|
|
77
|
+
requireAuth() {
|
|
78
|
+
if (!this.isAuthenticated()) {
|
|
79
|
+
console.log(chalk_1.default.red('\nā Authentication required'));
|
|
80
|
+
console.log(chalk_1.default.gray(' Run `vig login` to authenticate first.\n'));
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Interactive deploy wizard
|
|
86
|
+
*/
|
|
87
|
+
async deploy(options = {}) {
|
|
88
|
+
this.requireAuth();
|
|
89
|
+
console.log(chalk_1.default.cyan('\nš Vigthoria Deploy - Host Your Project\n'));
|
|
90
|
+
// If subdomain or domain specified, deploy directly
|
|
91
|
+
if (options.subdomain) {
|
|
92
|
+
await this.deployToSubdomain(options.subdomain, options.project);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (options.domain) {
|
|
96
|
+
await this.deployToCustomDomain(options.domain, options.project);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
// Interactive wizard
|
|
100
|
+
const { deployType } = await inquirer_1.default.prompt([{
|
|
101
|
+
type: 'list',
|
|
102
|
+
name: 'deployType',
|
|
103
|
+
message: 'How would you like to deploy?',
|
|
104
|
+
choices: [
|
|
105
|
+
{ name: 'š Preview URL (Free) - coder.vigthoria.io/preview/...', value: 'preview' },
|
|
106
|
+
{ name: 'š Vigthoria Subdomain (ā¬4.99/mo) - yourapp.vigthoria.io', value: 'subdomain' },
|
|
107
|
+
{ name: 'š Custom Domain (ā¬9.99/mo) - yourdomain.com', value: 'custom' },
|
|
108
|
+
{ name: 'š View Hosting Plans', value: 'plans' }
|
|
109
|
+
]
|
|
110
|
+
}]);
|
|
111
|
+
switch (deployType) {
|
|
112
|
+
case 'preview':
|
|
113
|
+
await this.deployToPreview(options.project);
|
|
114
|
+
break;
|
|
115
|
+
case 'subdomain':
|
|
116
|
+
await this.promptSubdomainDeploy(options.project);
|
|
117
|
+
break;
|
|
118
|
+
case 'custom':
|
|
119
|
+
await this.promptCustomDomainDeploy(options.project);
|
|
120
|
+
break;
|
|
121
|
+
case 'plans':
|
|
122
|
+
await this.showPlans();
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Deploy to preview URL (free)
|
|
128
|
+
*/
|
|
129
|
+
async deployToPreview(projectPath) {
|
|
130
|
+
const spinner = (0, ora_1.default)('Deploying to preview...').start();
|
|
131
|
+
try {
|
|
132
|
+
const projectDir = projectPath || process.cwd();
|
|
133
|
+
const projectInfo = this.detectProjectInfo(projectDir);
|
|
134
|
+
const response = await fetch(`${this.apiBase}/api/hosting/deploy/preview`, {
|
|
135
|
+
method: 'POST',
|
|
136
|
+
headers: this.getAuthHeaders(),
|
|
137
|
+
body: JSON.stringify({
|
|
138
|
+
projectName: projectInfo.name,
|
|
139
|
+
projectPath: projectDir
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
if (!response.ok) {
|
|
143
|
+
const error = await response.json();
|
|
144
|
+
throw new Error(error.error || 'Failed to deploy');
|
|
145
|
+
}
|
|
146
|
+
const data = await response.json();
|
|
147
|
+
spinner.succeed(chalk_1.default.green('Deployed to preview!'));
|
|
148
|
+
console.log(chalk_1.default.cyan('\nš Preview URL:'));
|
|
149
|
+
console.log(chalk_1.default.white(` ${data.url}`));
|
|
150
|
+
console.log(chalk_1.default.gray('\n Note: Preview URLs may expire after 7 days of inactivity.'));
|
|
151
|
+
console.log(chalk_1.default.gray(' Upgrade to a subdomain for permanent hosting.\n'));
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
spinner.fail('Deploy failed');
|
|
155
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
156
|
+
console.log(chalk_1.default.red(`\nā Error: ${errMsg}\n`));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Deploy to Vigthoria subdomain
|
|
161
|
+
*/
|
|
162
|
+
async deployToSubdomain(subdomain, projectPath) {
|
|
163
|
+
const spinner = (0, ora_1.default)(`Deploying to ${subdomain}.vigthoria.io...`).start();
|
|
164
|
+
try {
|
|
165
|
+
// Validate subdomain format
|
|
166
|
+
if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]$/.test(subdomain) || subdomain.length < 3) {
|
|
167
|
+
throw new Error('Subdomain must be 3+ chars, lowercase alphanumeric with hyphens');
|
|
168
|
+
}
|
|
169
|
+
const projectDir = projectPath || process.cwd();
|
|
170
|
+
const projectInfo = this.detectProjectInfo(projectDir);
|
|
171
|
+
const response = await fetch(`${this.apiBase}/api/hosting/deploy/subdomain`, {
|
|
172
|
+
method: 'POST',
|
|
173
|
+
headers: this.getAuthHeaders(),
|
|
174
|
+
body: JSON.stringify({
|
|
175
|
+
subdomain,
|
|
176
|
+
projectName: projectInfo.name,
|
|
177
|
+
projectPath: projectDir
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
const data = await response.json();
|
|
181
|
+
if (!response.ok || !data.success) {
|
|
182
|
+
if (data.requiresSubscription) {
|
|
183
|
+
spinner.stop();
|
|
184
|
+
console.log(chalk_1.default.yellow('\nā ļø Subdomain hosting requires a subscription (ā¬4.99/mo)'));
|
|
185
|
+
const { proceed } = await inquirer_1.default.prompt([{
|
|
186
|
+
type: 'confirm',
|
|
187
|
+
name: 'proceed',
|
|
188
|
+
message: 'Would you like to subscribe now?',
|
|
189
|
+
default: true
|
|
190
|
+
}]);
|
|
191
|
+
if (proceed && data.checkoutUrl) {
|
|
192
|
+
console.log(chalk_1.default.cyan(`\nš Opening checkout: ${data.checkoutUrl}`));
|
|
193
|
+
console.log(chalk_1.default.gray('Please open this URL in your browser to subscribe.\n'));
|
|
194
|
+
}
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
throw new Error(data.error || 'Failed to deploy');
|
|
198
|
+
}
|
|
199
|
+
spinner.succeed(chalk_1.default.green(`Deployed to ${subdomain}.vigthoria.io!`));
|
|
200
|
+
console.log(chalk_1.default.cyan('\nš Your Site is Live:'));
|
|
201
|
+
console.log(chalk_1.default.bold.white(` https://${subdomain}.vigthoria.io`));
|
|
202
|
+
console.log(chalk_1.default.gray('\n ā SSL certificate auto-configured'));
|
|
203
|
+
console.log(chalk_1.default.gray(' ā Global CDN enabled'));
|
|
204
|
+
console.log(chalk_1.default.gray(' ā Unlimited traffic included\n'));
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
spinner.fail('Deploy failed');
|
|
208
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
209
|
+
console.log(chalk_1.default.red(`\nā Error: ${errMsg}\n`));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Deploy to custom domain
|
|
214
|
+
*/
|
|
215
|
+
async deployToCustomDomain(domain, projectPath) {
|
|
216
|
+
const spinner = (0, ora_1.default)(`Setting up ${domain}...`).start();
|
|
217
|
+
try {
|
|
218
|
+
const projectDir = projectPath || process.cwd();
|
|
219
|
+
const projectInfo = this.detectProjectInfo(projectDir);
|
|
220
|
+
const response = await fetch(`${this.apiBase}/api/hosting/deploy/custom`, {
|
|
221
|
+
method: 'POST',
|
|
222
|
+
headers: this.getAuthHeaders(),
|
|
223
|
+
body: JSON.stringify({
|
|
224
|
+
domain,
|
|
225
|
+
projectName: projectInfo.name,
|
|
226
|
+
projectPath: projectDir
|
|
227
|
+
})
|
|
228
|
+
});
|
|
229
|
+
const data = await response.json();
|
|
230
|
+
if (!response.ok || !data.success) {
|
|
231
|
+
if (data.requiresSubscription) {
|
|
232
|
+
spinner.stop();
|
|
233
|
+
console.log(chalk_1.default.yellow('\nā ļø Custom domain hosting requires a subscription (ā¬9.99/mo)'));
|
|
234
|
+
const { proceed } = await inquirer_1.default.prompt([{
|
|
235
|
+
type: 'confirm',
|
|
236
|
+
name: 'proceed',
|
|
237
|
+
message: 'Would you like to subscribe now?',
|
|
238
|
+
default: true
|
|
239
|
+
}]);
|
|
240
|
+
if (proceed && data.checkoutUrl) {
|
|
241
|
+
console.log(chalk_1.default.cyan(`\nš Checkout URL: ${data.checkoutUrl}`));
|
|
242
|
+
console.log(chalk_1.default.gray('Please open this URL in your browser to subscribe.\n'));
|
|
243
|
+
}
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
throw new Error(data.error || 'Failed to deploy');
|
|
247
|
+
}
|
|
248
|
+
spinner.succeed(chalk_1.default.green('Domain registered!'));
|
|
249
|
+
if (data.dnsRecords) {
|
|
250
|
+
console.log(chalk_1.default.cyan('\nš Configure your DNS records:'));
|
|
251
|
+
console.log(chalk_1.default.gray('ā'.repeat(60)));
|
|
252
|
+
for (const record of data.dnsRecords) {
|
|
253
|
+
console.log(chalk_1.default.white(` Type: ${record.type.padEnd(6)} Name: ${record.name.padEnd(20)} Value: ${record.value}`));
|
|
254
|
+
}
|
|
255
|
+
console.log(chalk_1.default.gray('ā'.repeat(60)));
|
|
256
|
+
console.log(chalk_1.default.yellow('\nā³ After adding DNS records, run:'));
|
|
257
|
+
console.log(chalk_1.default.white(` vig deploy verify ${domain}\n`));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
spinner.fail('Deploy failed');
|
|
262
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
263
|
+
console.log(chalk_1.default.red(`\nā Error: ${errMsg}\n`));
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Interactive subdomain prompt
|
|
268
|
+
*/
|
|
269
|
+
async promptSubdomainDeploy(projectPath) {
|
|
270
|
+
const { subdomain } = await inquirer_1.default.prompt([{
|
|
271
|
+
type: 'input',
|
|
272
|
+
name: 'subdomain',
|
|
273
|
+
message: 'Enter your desired subdomain:',
|
|
274
|
+
suffix: chalk_1.default.gray('.vigthoria.io'),
|
|
275
|
+
validate: (input) => {
|
|
276
|
+
if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]$/.test(input) || input.length < 3) {
|
|
277
|
+
return 'Subdomain must be 3+ chars, lowercase alphanumeric with hyphens';
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
}]);
|
|
282
|
+
await this.deployToSubdomain(subdomain, projectPath);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Interactive custom domain prompt
|
|
286
|
+
*/
|
|
287
|
+
async promptCustomDomainDeploy(projectPath) {
|
|
288
|
+
const { domain } = await inquirer_1.default.prompt([{
|
|
289
|
+
type: 'input',
|
|
290
|
+
name: 'domain',
|
|
291
|
+
message: 'Enter your domain:',
|
|
292
|
+
suffix: chalk_1.default.gray(' (e.g., myapp.com)'),
|
|
293
|
+
validate: (input) => {
|
|
294
|
+
if (!/^[a-z0-9][a-z0-9.-]+\.[a-z]{2,}$/i.test(input)) {
|
|
295
|
+
return 'Please enter a valid domain name';
|
|
296
|
+
}
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
}]);
|
|
300
|
+
await this.deployToCustomDomain(domain, projectPath);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Show hosting plans
|
|
304
|
+
*/
|
|
305
|
+
async showPlans() {
|
|
306
|
+
const spinner = (0, ora_1.default)('Fetching hosting plans...').start();
|
|
307
|
+
try {
|
|
308
|
+
const response = await fetch(`${this.apiBase}/api/hosting/plans`, {
|
|
309
|
+
headers: this.getAuthHeaders()
|
|
310
|
+
});
|
|
311
|
+
if (!response.ok) {
|
|
312
|
+
throw new Error('Failed to fetch plans');
|
|
313
|
+
}
|
|
314
|
+
const data = await response.json();
|
|
315
|
+
spinner.stop();
|
|
316
|
+
console.log(chalk_1.default.cyan('\nš Vigthoria Hosting Plans\n'));
|
|
317
|
+
console.log(chalk_1.default.gray('ā'.repeat(70)));
|
|
318
|
+
for (const plan of data.plans) {
|
|
319
|
+
const price = plan.price_monthly === 0
|
|
320
|
+
? chalk_1.default.green('FREE')
|
|
321
|
+
: chalk_1.default.yellow(`ā¬${plan.price_monthly.toFixed(2)}/mo`);
|
|
322
|
+
console.log(chalk_1.default.bold.white(`\n ${plan.display_name} - ${price}`));
|
|
323
|
+
console.log(chalk_1.default.gray(' ' + 'ā'.repeat(50)));
|
|
324
|
+
const features = [];
|
|
325
|
+
if (plan.subdomain_allowed)
|
|
326
|
+
features.push('ā Vigthoria subdomain');
|
|
327
|
+
if (plan.custom_domain_allowed)
|
|
328
|
+
features.push('ā Custom domain');
|
|
329
|
+
features.push(`ā ${plan.max_projects === -1 ? 'Unlimited' : plan.max_projects} project(s)`);
|
|
330
|
+
features.push(`ā ${plan.storage_mb >= 1024 ? (plan.storage_mb / 1024) + 'GB' : plan.storage_mb + 'MB'} storage`);
|
|
331
|
+
features.forEach(f => console.log(chalk_1.default.gray(` ${f}`)));
|
|
332
|
+
}
|
|
333
|
+
console.log(chalk_1.default.gray('\n' + 'ā'.repeat(70)));
|
|
334
|
+
console.log(chalk_1.default.cyan('\n Subscribe: vig deploy --subdomain myapp\n'));
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
spinner.fail('Failed to fetch plans');
|
|
338
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
339
|
+
console.log(chalk_1.default.red(`\nā Error: ${errMsg}\n`));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* List all deployments
|
|
344
|
+
*/
|
|
345
|
+
async list() {
|
|
346
|
+
this.requireAuth();
|
|
347
|
+
const spinner = (0, ora_1.default)('Fetching deployments...').start();
|
|
348
|
+
try {
|
|
349
|
+
const response = await fetch(`${this.apiBase}/api/hosting/domains`, {
|
|
350
|
+
headers: this.getAuthHeaders()
|
|
351
|
+
});
|
|
352
|
+
if (!response.ok) {
|
|
353
|
+
throw new Error('Failed to fetch deployments');
|
|
354
|
+
}
|
|
355
|
+
const data = await response.json();
|
|
356
|
+
spinner.stop();
|
|
357
|
+
if (data.domains.length === 0) {
|
|
358
|
+
console.log(chalk_1.default.yellow('\nš¦ No deployments yet.\n'));
|
|
359
|
+
console.log(chalk_1.default.gray(' Run `vig deploy` to deploy your first project.\n'));
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
console.log(chalk_1.default.cyan(`\nš Your Deployments (${data.domains.length})\n`));
|
|
363
|
+
for (const domain of data.domains) {
|
|
364
|
+
const statusIcon = domain.is_active ? 'š¢' : 'š“';
|
|
365
|
+
const sslIcon = domain.ssl_status === 'active' ? 'š' : 'ā ļø';
|
|
366
|
+
const url = domain.domain_type === 'subdomain'
|
|
367
|
+
? `${domain.subdomain}.vigthoria.io`
|
|
368
|
+
: domain.domain_type === 'custom'
|
|
369
|
+
? domain.custom_domain
|
|
370
|
+
: domain.url;
|
|
371
|
+
console.log(chalk_1.default.white(` ${statusIcon} ${url}`));
|
|
372
|
+
console.log(chalk_1.default.gray(` Project: ${domain.project_name} | SSL: ${sslIcon} ${domain.ssl_status} | Tier: ${domain.hosting_tier}`));
|
|
373
|
+
console.log();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
spinner.fail('List failed');
|
|
378
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
379
|
+
console.log(chalk_1.default.red(`\nā Error: ${errMsg}\n`));
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Check deployment status
|
|
384
|
+
*/
|
|
385
|
+
async status(domain) {
|
|
386
|
+
this.requireAuth();
|
|
387
|
+
const spinner = (0, ora_1.default)('Checking status...').start();
|
|
388
|
+
try {
|
|
389
|
+
const endpoint = domain
|
|
390
|
+
? `${this.apiBase}/api/hosting/domain/${encodeURIComponent(domain)}/status`
|
|
391
|
+
: `${this.apiBase}/api/hosting/status`;
|
|
392
|
+
const response = await fetch(endpoint, {
|
|
393
|
+
headers: this.getAuthHeaders()
|
|
394
|
+
});
|
|
395
|
+
if (!response.ok) {
|
|
396
|
+
throw new Error('Failed to fetch status');
|
|
397
|
+
}
|
|
398
|
+
const data = await response.json();
|
|
399
|
+
spinner.stop();
|
|
400
|
+
console.log(chalk_1.default.cyan('\nš Deployment Status\n'));
|
|
401
|
+
console.log(JSON.stringify(data, null, 2));
|
|
402
|
+
}
|
|
403
|
+
catch (error) {
|
|
404
|
+
spinner.fail('Status check failed');
|
|
405
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
406
|
+
console.log(chalk_1.default.red(`\nā Error: ${errMsg}\n`));
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Verify DNS for custom domain
|
|
411
|
+
*/
|
|
412
|
+
async verify(domain) {
|
|
413
|
+
this.requireAuth();
|
|
414
|
+
const spinner = (0, ora_1.default)(`Verifying DNS for ${domain}...`).start();
|
|
415
|
+
try {
|
|
416
|
+
const response = await fetch(`${this.apiBase}/api/hosting/domain/verify`, {
|
|
417
|
+
method: 'POST',
|
|
418
|
+
headers: this.getAuthHeaders(),
|
|
419
|
+
body: JSON.stringify({ domain })
|
|
420
|
+
});
|
|
421
|
+
const data = await response.json();
|
|
422
|
+
if (!response.ok || !data.success) {
|
|
423
|
+
throw new Error(data.error || 'Verification failed');
|
|
424
|
+
}
|
|
425
|
+
if (data.verified) {
|
|
426
|
+
spinner.succeed(chalk_1.default.green('Domain verified!'));
|
|
427
|
+
console.log(chalk_1.default.cyan(`\nš Your site is now live at: https://${domain}`));
|
|
428
|
+
console.log(chalk_1.default.gray(` SSL Status: ${data.sslStatus || 'Provisioning...'}\n`));
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
spinner.warn(chalk_1.default.yellow('DNS not propagated yet'));
|
|
432
|
+
console.log(chalk_1.default.gray('\n DNS changes can take up to 48 hours to propagate.'));
|
|
433
|
+
console.log(chalk_1.default.gray(' Try again later with: vig deploy verify ' + domain + '\n'));
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
spinner.fail('Verification failed');
|
|
438
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
439
|
+
console.log(chalk_1.default.red(`\nā Error: ${errMsg}\n`));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Remove a deployment
|
|
444
|
+
*/
|
|
445
|
+
async remove(domain) {
|
|
446
|
+
this.requireAuth();
|
|
447
|
+
const { confirm } = await inquirer_1.default.prompt([{
|
|
448
|
+
type: 'confirm',
|
|
449
|
+
name: 'confirm',
|
|
450
|
+
message: chalk_1.default.red(`Are you sure you want to remove ${domain}?`),
|
|
451
|
+
default: false
|
|
452
|
+
}]);
|
|
453
|
+
if (!confirm) {
|
|
454
|
+
console.log(chalk_1.default.yellow('\nā ļø Removal cancelled.\n'));
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const spinner = (0, ora_1.default)(`Removing ${domain}...`).start();
|
|
458
|
+
try {
|
|
459
|
+
const response = await fetch(`${this.apiBase}/api/hosting/domain/${encodeURIComponent(domain)}`, {
|
|
460
|
+
method: 'DELETE',
|
|
461
|
+
headers: this.getAuthHeaders()
|
|
462
|
+
});
|
|
463
|
+
if (!response.ok) {
|
|
464
|
+
const error = await response.json();
|
|
465
|
+
throw new Error(error.error || 'Failed to remove');
|
|
466
|
+
}
|
|
467
|
+
spinner.succeed(chalk_1.default.green('Domain removed'));
|
|
468
|
+
console.log(chalk_1.default.gray('\n Your project files are still in your repository.\n'));
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
spinner.fail('Remove failed');
|
|
472
|
+
const errMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
473
|
+
console.log(chalk_1.default.red(`\nā Error: ${errMsg}\n`));
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Detect project info from directory
|
|
478
|
+
*/
|
|
479
|
+
detectProjectInfo(projectPath) {
|
|
480
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
481
|
+
let name = path.basename(projectPath);
|
|
482
|
+
const techStack = [];
|
|
483
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
484
|
+
try {
|
|
485
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
486
|
+
name = pkg.name || name;
|
|
487
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
488
|
+
if (deps.react)
|
|
489
|
+
techStack.push('React');
|
|
490
|
+
if (deps.vue)
|
|
491
|
+
techStack.push('Vue');
|
|
492
|
+
if (deps.next)
|
|
493
|
+
techStack.push('Next.js');
|
|
494
|
+
if (deps.express)
|
|
495
|
+
techStack.push('Express');
|
|
496
|
+
if (deps.typescript)
|
|
497
|
+
techStack.push('TypeScript');
|
|
498
|
+
}
|
|
499
|
+
catch (e) {
|
|
500
|
+
// Ignore parse errors
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
// Check for other frameworks
|
|
504
|
+
if (fs.existsSync(path.join(projectPath, 'requirements.txt'))) {
|
|
505
|
+
techStack.push('Python');
|
|
506
|
+
}
|
|
507
|
+
if (fs.existsSync(path.join(projectPath, 'index.html'))) {
|
|
508
|
+
techStack.push('Static HTML');
|
|
509
|
+
}
|
|
510
|
+
return { name, techStack };
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
exports.DeployCommand = DeployCommand;
|
|
514
|
+
//# sourceMappingURL=deploy.js.map
|