@ostro-cloud/cli 0.0.0-stage → 1.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ const { getStoredConfig, resolveServiceUrl, request } = require('../client');
2
+ const fs = require('fs');
3
+
4
+ async function applyManifest(manifestPath, options = {}) {
5
+ const config = getStoredConfig();
6
+ const k8sUrl = resolveServiceUrl('kubernetes', options.k8sUrl);
7
+ const namespace = options.namespace || 'default';
8
+
9
+ console.log(`\x1b[36m☸️ Applying Kubernetes Manifest [${manifestPath}] in namespace [${namespace}]...\x1b[0m`);
10
+
11
+ if (!fs.existsSync(manifestPath)) {
12
+ console.error(`\x1b[31m✖ Manifest file not found:\x1b[0m ${manifestPath}`);
13
+ return;
14
+ }
15
+
16
+ const yamlContent = fs.readFileSync(manifestPath, 'utf-8');
17
+
18
+ try {
19
+ const result = await request(`${k8sUrl}/api/v1/applications/deploy`, {
20
+ method: 'POST',
21
+ body: JSON.stringify({
22
+ yaml: yamlContent,
23
+ namespace
24
+ })
25
+ });
26
+
27
+ const regionStr = config.region ? ` (${config.region})` : '';
28
+ console.log(`\x1b[32m✔ Manifest successfully applied to Ostro K8s Cluster${regionStr}!\x1b[0m`);
29
+ if (result && result.vip) {
30
+ console.log(` Workload Static VIP: \x1b[33mhttp://${result.vip}\x1b[0m`);
31
+ }
32
+ const app = result?.appliedResources?.find(r => r.kind === 'Deployment');
33
+ if (app) {
34
+ console.log(` Live Ingress Domain: \x1b[34mhttp://${app.name}.ostro-cloud.com\x1b[0m`);
35
+ }
36
+ console.log(` Target Namespace: \x1b[35m${result?.namespace || namespace}\x1b[0m\n`);
37
+ } catch (err) {
38
+ console.error(`\x1b[31m✖ kubectl apply failed:\x1b[0m`, err.message);
39
+ }
40
+ }
41
+
42
+ module.exports = {
43
+ applyManifest
44
+ };
@@ -0,0 +1,154 @@
1
+ const { saveConfig, request, getStoredConfig } = require('../client');
2
+ const readline = require('readline');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const os = require('os');
6
+
7
+ const CREDENTIALS_FILE = path.join(os.homedir(), '.ostro', 'credentials');
8
+
9
+ function ask(query, isPassword = false) {
10
+ const rl = readline.createInterface({
11
+ input: process.stdin,
12
+ output: process.stdout,
13
+ });
14
+
15
+ return new Promise((resolve) => {
16
+ if (isPassword) {
17
+ const stdin = process.stdin;
18
+ process.stdout.write(query);
19
+ stdin.resume();
20
+ stdin.setRawMode && stdin.setRawMode(true);
21
+ stdin.setEncoding('utf8');
22
+
23
+ let password = '';
24
+ const onData = (ch) => {
25
+ ch = ch.toString('utf8');
26
+ switch (ch) {
27
+ case '\n':
28
+ case '\r':
29
+ case '\u0004':
30
+ stdin.setRawMode && stdin.setRawMode(false);
31
+ stdin.pause();
32
+ stdin.removeListener('data', onData);
33
+ process.stdout.write('\n');
34
+ rl.close();
35
+ resolve(password);
36
+ break;
37
+ case '\u0003':
38
+ process.exit();
39
+ break;
40
+ case '\u007f':
41
+ case '\b':
42
+ if (password.length > 0) {
43
+ password = password.slice(0, -1);
44
+ process.stdout.write('\b \b');
45
+ }
46
+ break;
47
+ default:
48
+ password += ch;
49
+ process.stdout.write('*');
50
+ break;
51
+ }
52
+ };
53
+ stdin.on('data', onData);
54
+ } else {
55
+ rl.question(query, (ans) => {
56
+ rl.close();
57
+ resolve(ans.trim());
58
+ });
59
+ }
60
+ });
61
+ }
62
+
63
+ function writeAwsStyleCredentials(profile, accessKeyId, secretAccessKey, sessionToken, roleArn) {
64
+ const dir = path.dirname(CREDENTIALS_FILE);
65
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
66
+
67
+ const content = `[${profile}]
68
+ ostro_access_key_id = ${accessKeyId || ''}
69
+ ostro_secret_access_key = ${secretAccessKey || ''}
70
+ ostro_session_token = ${sessionToken || ''}
71
+ ostro_role_arn = ${roleArn || ''}
72
+ `;
73
+ fs.writeFileSync(CREDENTIALS_FILE, content, { mode: 0o600 });
74
+ }
75
+
76
+ async function login(options) {
77
+ const config = getStoredConfig();
78
+ // Derive IAM login URL from domain — no endpoint flag needed
79
+ const domain = config.domain || process.env.OSTRO_DOMAIN || 'ostro-cloud.com';
80
+ const region = config.region || process.env.OSTRO_REGION || 'in-bihar-1';
81
+ const consoleHost = `https://console.${domain}`;
82
+ const iamBase = config.iamUrl || process.env.OSTRO_IAM_URL || `${consoleHost}/iam`;
83
+ // --endpoint kept for backwards-compat; it overrides the domain-derived URL
84
+ const endpoint = options.endpoint || iamBase;
85
+ const profile = options.profile || config.environment || 'default';
86
+
87
+ let username = options.username;
88
+ let password = options.password;
89
+
90
+ console.log(`\x1b[36m🔑 Ostro Cloud Login\x1b[0m`);
91
+ console.log(` IAM: \x1b[34m${iamBase}\x1b[0m`);
92
+ console.log(` Region: \x1b[33m${region}\x1b[0m`);
93
+ console.log(` Profile: \x1b[35m${profile}\x1b[0m\n`);
94
+
95
+ if (!username) {
96
+ username = await ask('Username or Email: ');
97
+ }
98
+ if (!password) {
99
+ password = await ask('Password: ', true);
100
+ }
101
+
102
+ if (!username || !password) {
103
+ console.error('\x1b[31m✖ Username and password are required.\x1b[0m');
104
+ return;
105
+ }
106
+
107
+ try {
108
+ const loginUrl = `${endpoint}/api/auth/login`;
109
+ const res = await request(loginUrl, {
110
+ method: 'POST',
111
+ body: JSON.stringify({
112
+ username,
113
+ password
114
+ })
115
+ });
116
+
117
+ if (res && res.sessionToken) {
118
+ // 1. Update ~/.ostro/config.json
119
+ saveConfig({
120
+ endpoint,
121
+ sessionToken: res.sessionToken,
122
+ token: res.sessionToken,
123
+ accessKeyId: res.accessKeyId || null,
124
+ secretAccessKey: res.secretAccessKey || null,
125
+ roleArn: res.role || null
126
+ });
127
+
128
+ // 2. Update ~/.ostro/credentials in AWS format
129
+ writeAwsStyleCredentials(
130
+ profile,
131
+ res.accessKeyId,
132
+ res.secretAccessKey,
133
+ res.sessionToken,
134
+ res.role
135
+ );
136
+
137
+ console.log(`\x1b[32m✔ Successfully authenticated to Ostro Cloud!\x1b[0m`);
138
+ console.log(` User: \x1b[33m${res.user?.username || username}\x1b[0m (${res.user?.email || 'N/A'})`);
139
+ console.log(` Account ID: \x1b[35m${res.accountId || res.user?.accountId}\x1b[0m`);
140
+ console.log(` Role: \x1b[36m${res.roleName || res.role || 'User'}\x1b[0m`);
141
+ console.log(` Key ID: \x1b[90m${res.accessKeyId || 'N/A'}\x1b[0m`);
142
+ console.log(` Credentials Saved: \x1b[32m~/.ostro/credentials\x1b[0m`);
143
+ console.log(` Expires: \x1b[90m${res.expiresAt || '24h'}\x1b[0m\n`);
144
+ } else {
145
+ console.error('\x1b[31m✖ Authentication failed: No session token received.\x1b[0m');
146
+ }
147
+ } catch (err) {
148
+ console.error(`\x1b[31m✖ Login failed:\x1b[0m`, err.message);
149
+ }
150
+ }
151
+
152
+ module.exports = {
153
+ login
154
+ };
@@ -0,0 +1,88 @@
1
+ const { getStoredConfig, resolveServiceUrl, request } = require('../client');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ async function listBuckets(options = {}) {
6
+ const config = getStoredConfig();
7
+ const s3Url = resolveServiceUrl('storage', options.s3Url);
8
+ const region = options.region || config.region || null;
9
+
10
+ const headerInfo = [];
11
+ if (region) headerInfo.push(`REGION: ${region}`);
12
+ const headerStr = headerInfo.length > 0 ? ` [${headerInfo.join(', ')}]` : '';
13
+
14
+ console.log(`\x1b[36m💽 Ostro S3 Buckets${headerStr}\x1b[0m\n`);
15
+
16
+ try {
17
+ const queryParams = new URLSearchParams();
18
+ if (region) queryParams.set('region', region);
19
+ const queryStr = queryParams.toString() ? `?${queryParams.toString()}` : '';
20
+
21
+ const list = await request(`${s3Url}/api/s3/buckets${queryStr}`);
22
+ if (!Array.isArray(list) || list.length === 0) {
23
+ console.log(` \x1b[33m(No buckets created)\x1b[0m`);
24
+ return;
25
+ }
26
+
27
+ console.log(` ${'CREATION DATE'.padEnd(24)} ${'BUCKET NAME'.padEnd(35)} ${'OBJECTS'}`);
28
+ console.log(` ${'-'.repeat(70)}`);
29
+ list.forEach(b => {
30
+ console.log(` ${(b.creationDate || b.created_at || '—').padEnd(24)} \x1b[32m${b.name.padEnd(35)}\x1b[0m ${b.objectCount || 0} objects`);
31
+ });
32
+ } catch (err) {
33
+ console.error(`\x1b[31m✖ Error listing buckets:\x1b[0m`, err.message);
34
+ }
35
+ }
36
+
37
+ async function syncDirectory(localDir, bucketUri, options = {}) {
38
+ const config = getStoredConfig();
39
+ const s3Url = resolveServiceUrl('storage', options.s3Url);
40
+ const bucketName = bucketUri.replace('s3://', '').replace('/', '');
41
+
42
+ console.log(`\x1b[36m📂 Syncing directory [${localDir}] to s3://${bucketName}...\x1b[0m`);
43
+
44
+ if (!fs.existsSync(localDir)) {
45
+ console.error(`\x1b[31m✖ Directory not found:\x1b[0m ${localDir}`);
46
+ return;
47
+ }
48
+
49
+ function getAllFiles(dirPath, arrayOfFiles = []) {
50
+ const files = fs.readdirSync(dirPath);
51
+ files.forEach(file => {
52
+ const fullPath = path.join(dirPath, file);
53
+ if (fs.statSync(fullPath).isDirectory()) {
54
+ getAllFiles(fullPath, arrayOfFiles);
55
+ } else {
56
+ arrayOfFiles.push(fullPath);
57
+ }
58
+ });
59
+ return arrayOfFiles;
60
+ }
61
+
62
+ const files = getAllFiles(localDir);
63
+ console.log(` Found ${files.length} files to upload...`);
64
+
65
+ for (const file of files) {
66
+ const relativeKey = path.relative(localDir, file);
67
+ const content = fs.readFileSync(file, 'utf-8');
68
+ try {
69
+ await request(`${s3Url}/api/s3/buckets/${bucketName}/objects`, {
70
+ method: 'POST',
71
+ body: JSON.stringify({
72
+ key: relativeKey,
73
+ content
74
+ })
75
+ });
76
+ console.log(` \x1b[32m✔ Uploaded:\x1b[0m ${relativeKey}`);
77
+ } catch (err) {
78
+ console.error(` \x1b[31m✖ Failed:\x1b[0m ${relativeKey} (${err.message})`);
79
+ }
80
+ }
81
+
82
+ console.log(`\x1b[32m\n✔ S3 sync complete! Static web hosting available at: ${s3Url}/site/${bucketName}/index.html\x1b[0m\n`);
83
+ }
84
+
85
+ module.exports = {
86
+ listBuckets,
87
+ syncDirectory
88
+ };
@@ -0,0 +1,104 @@
1
+ const { getStoredConfig, resolveServiceUrl, request } = require('../client');
2
+ const fs = require('fs');
3
+
4
+ async function listFunctions(options = {}) {
5
+ const config = getStoredConfig();
6
+ const serverlessUrl = resolveServiceUrl('serverless', options.serverlessUrl);
7
+ const region = options.region || config.region || null;
8
+
9
+ const headerInfo = [];
10
+ if (region) headerInfo.push(`REGION: ${region}`);
11
+ const headerStr = headerInfo.length > 0 ? ` [${headerInfo.join(', ')}]` : '';
12
+
13
+ console.log(`\x1b[36m⚡ Ostro Serverless — Functions${headerStr}\x1b[0m\n`);
14
+
15
+ try {
16
+ const queryParams = new URLSearchParams();
17
+ if (region) queryParams.set('region', region);
18
+ const queryStr = queryParams.toString() ? `?${queryParams.toString()}` : '';
19
+
20
+ const list = await request(`${serverlessUrl}/api/functions${queryStr}`);
21
+ if (!Array.isArray(list) || list.length === 0) {
22
+ console.log(` \x1b[33m(No functions deployed)\x1b[0m`);
23
+ return;
24
+ }
25
+
26
+ console.log(` ${'FUNCTION NAME'.padEnd(30)} ${'RUNTIME'.padEnd(16)} ${'MEMORY'.padEnd(10)} ${'TIMEOUT'.padEnd(10)} ${'UPDATED'}`);
27
+ console.log(` ${'-'.repeat(80)}`);
28
+ list.forEach(fn => {
29
+ console.log(` \x1b[32m${fn.name.padEnd(30)}\x1b[0m ${fn.runtime.padEnd(16)} ${(fn.memory + ' MB').padEnd(10)} ${(fn.timeout + 's').padEnd(10)} ${fn.updatedAt || 'N/A'}`);
30
+ });
31
+ console.log(`\n Total: ${list.length} function(s) active`);
32
+ } catch (err) {
33
+ console.error(`\x1b[31m✖ Error fetching functions:\x1b[0m`, err.message);
34
+ }
35
+ }
36
+
37
+ async function deployFunction(name, options = {}) {
38
+ const config = getStoredConfig();
39
+ const serverlessUrl = resolveServiceUrl('serverless', options.serverlessUrl);
40
+ const region = options.region || config.region || null;
41
+ const runtime = options.runtime || 'nodejs20.x';
42
+ const handler = options.handler || 'index.handler';
43
+ const filePath = options.file || 'index.js';
44
+
45
+ if (!fs.existsSync(filePath)) {
46
+ throw new Error(`Source file not found: ${filePath}`);
47
+ }
48
+ const code = fs.readFileSync(filePath, 'utf-8');
49
+
50
+ const regionLabel = region ? ` in ${region}` : '';
51
+ console.log(`\x1b[36m🚀 Deploying Serverless Function [${name}]${regionLabel}...\x1b[0m`);
52
+
53
+ try {
54
+ const result = await request(`${serverlessUrl}/api/functions`, {
55
+ method: 'POST',
56
+ body: JSON.stringify({
57
+ name,
58
+ runtime,
59
+ handler,
60
+ code,
61
+ ...(region ? { region } : {})
62
+ })
63
+ });
64
+
65
+ console.log(`\x1b[32m✔ Function [${name}] deployed successfully!\x1b[0m`);
66
+ const arnRegion = region || 'global';
67
+ console.log(` ARN: \x1b[33marn:ostro:serverless:${arnRegion}:function:${name}\x1b[0m`);
68
+ console.log(` Gateway Endpoint: \x1b[34m${serverlessUrl}/gateway/${name}\x1b[0m\n`);
69
+ } catch (err) {
70
+ console.error(`\x1b[31m✖ Deployment failed:\x1b[0m`, err.message);
71
+ }
72
+ }
73
+
74
+ async function invokeFunction(name, options = {}) {
75
+ const config = getStoredConfig();
76
+ const serverlessUrl = resolveServiceUrl('serverless', options.serverlessUrl);
77
+ let payload = {};
78
+
79
+ if (options.data) {
80
+ try { payload = JSON.parse(options.data); } catch { payload = { text: options.data }; }
81
+ }
82
+
83
+ console.log(`\x1b[36m⚡ Invoking Function [${name}]...\x1b[0m`);
84
+
85
+ try {
86
+ const startTime = Date.now();
87
+ const result = await request(`${serverlessUrl}/api/functions/${name}/invoke`, {
88
+ method: 'POST',
89
+ body: JSON.stringify({ payload })
90
+ });
91
+ const duration = Date.now() - startTime;
92
+
93
+ console.log(`\x1b[32m✔ Execution Complete (${duration}ms)\x1b[0m\n`);
94
+ console.log(JSON.stringify(result, null, 2));
95
+ } catch (err) {
96
+ console.error(`\x1b[31m✖ Invocation failed:\x1b[0m`, err.message);
97
+ }
98
+ }
99
+
100
+ module.exports = {
101
+ listFunctions,
102
+ deployFunction,
103
+ invokeFunction
104
+ };
@@ -0,0 +1,41 @@
1
+ const { request, getStoredConfig } = require('../client');
2
+
3
+ async function checkStatus() {
4
+ const config = getStoredConfig();
5
+ const base = config.endpoint;
6
+ if (!base) {
7
+ throw new Error('Endpoint is not configured. Set OSTRO_ENDPOINT or run "ostro-cloud configure --endpoint <url>".');
8
+ }
9
+ console.log(`\x1b[36m===================================================\x1b[0m`);
10
+ console.log(`\x1b[36m☁️ Ostro Cloud Cluster Health & Diagnostic Engine\x1b[0m`);
11
+ console.log(`\x1b[36m===================================================\x1b[0m`);
12
+ console.log(` Endpoint: \x1b[34m${base}\x1b[0m`);
13
+ console.log(` Region: \x1b[33m🇮🇳 ${config.region}\x1b[0m`);
14
+ console.log(` Environment: \x1b[32m${config.environment.toUpperCase()}\x1b[0m\n`);
15
+
16
+ const services = [
17
+ { name: 'Unified Console', url: `${base}/api/health` },
18
+ { name: 'Kubernetes Engine (EKS)', url: `${base}/kubernetes/api/health` },
19
+ { name: 'Ostro Serverless (Lambda)', url: `${base}/serverless/api/health` },
20
+ { name: 'Ostro Bucket (S3)', url: `${base}/storage/api/health` },
21
+ { name: 'Ostro Formation (IaC)', url: `${base}/formation/api/health` },
22
+ { name: 'Ostro Ingress Tunnel', url: `${base}/tunnel/api/health` },
23
+ { name: 'Ostro DNS (Route 53)', url: `${base}/dns/api/health` },
24
+ { name: 'Ostro EventBus IPC', url: `${base}/eventbus/health` }
25
+ ];
26
+
27
+ for (const svc of services) {
28
+ const start = Date.now();
29
+ try {
30
+ await request(svc.url);
31
+ const latency = Date.now() - start;
32
+ console.log(` \x1b[32m✔\x1b[0m ${svc.name.padEnd(30)} \x1b[32mONLINE (${latency}ms)\x1b[0m — \x1b[90m${svc.url}\x1b[0m`);
33
+ } catch (err) {
34
+ console.log(` \x1b[31m✖\x1b[0m ${svc.name.padEnd(30)} \x1b[31mOFFLINE (${err.message})\x1b[0m — \x1b[90m${svc.url}\x1b[0m`);
35
+ }
36
+ }
37
+
38
+ console.log(`\n All microservices configured for automated GitLab CI/CD & Local Terminals.\n`);
39
+ }
40
+
41
+ module.exports = { checkStatus };
@@ -0,0 +1,129 @@
1
+ const { getStoredConfig, resolveServiceUrl, request } = require('../client');
2
+
3
+ async function listTunnels(options = {}) {
4
+ const config = getStoredConfig();
5
+ const tunnelUrl = resolveServiceUrl('tunnel', options.tunnelUrl);
6
+ const region = options.region || config.region || null;
7
+
8
+ const headerInfo = [];
9
+ if (region) headerInfo.push(`REGION: ${region}`);
10
+ const headerStr = headerInfo.length > 0 ? ` [${headerInfo.join(', ')}]` : '';
11
+
12
+ console.log(`\x1b[36m⚡ Ostro Ingress Tunnels & DNS${headerStr}\x1b[0m\n`);
13
+
14
+ try {
15
+ const queryParams = new URLSearchParams();
16
+ if (region) queryParams.set('region', region);
17
+ const queryStr = queryParams.toString() ? `?${queryParams.toString()}` : '';
18
+
19
+ const list = await request(`${tunnelUrl}/api/tunnels${queryStr}`);
20
+ if (!Array.isArray(list) || list.length === 0) {
21
+ console.log(` \x1b[33m(No active tunnels mapped)\x1b[0m`);
22
+ return;
23
+ }
24
+
25
+ console.log(` ${'TUNNEL ID'.padEnd(24)} ${'NAME'.padEnd(25)} ${'STATUS'.padEnd(10)} ${'HOSTNAME'.padEnd(30)} ${'TARGET HOST:PORT'}`);
26
+ console.log(` ${'-'.repeat(105)}`);
27
+ list.forEach(t => {
28
+ const id = (t.id || '').padEnd(24);
29
+ const name = (t.name || '').padEnd(25);
30
+ const statusColor = t.status === 'ACTIVE' ? '\x1b[32m' : '\x1b[33m';
31
+ const status = `${statusColor}${(t.status || 'ACTIVE').padEnd(10)}\x1b[0m`;
32
+ const hostname = (t.hostname || t.publicUrl || '').padEnd(30);
33
+ const target = t.target_host ? `${t.target_host}:${t.target_port}` : (t.targetUrl || '—');
34
+ console.log(` ${id} \x1b[32m${name}\x1b[0m ${status} \x1b[36m${hostname}\x1b[0m ${target}`);
35
+ });
36
+ console.log(`\n Total: ${list.length} ingress tunnel(s) active`);
37
+ } catch (err) {
38
+ console.error(`\x1b[31m✖ Error listing tunnels:\x1b[0m`, err.message);
39
+ }
40
+ }
41
+
42
+ async function createTunnel(name, options = {}) {
43
+ const config = getStoredConfig();
44
+ const tunnelUrl = resolveServiceUrl('tunnel', options.tunnelUrl);
45
+
46
+ const rawTarget = options.target;
47
+ if (!rawTarget) {
48
+ throw new Error('Target origin is required. Pass --target <host:port>.');
49
+ }
50
+
51
+ const hostname = options.hostname || options.publicUrl;
52
+ if (!hostname) {
53
+ throw new Error('Public hostname is required. Pass --hostname <domain>.');
54
+ }
55
+
56
+ const provider = options.provider ? String(options.provider).toUpperCase() : 'CLOUDFLARE';
57
+ const region = options.region || config.region || null;
58
+
59
+ let targetHost = rawTarget;
60
+ let targetPort = 80;
61
+ const targetClean = rawTarget.replace(/^https?:\/\//, '');
62
+ if (targetClean.includes(':')) {
63
+ const parts = targetClean.split(':');
64
+ targetHost = parts[0];
65
+ targetPort = parseInt(parts[1], 10);
66
+ if (isNaN(targetPort)) {
67
+ throw new Error(`Invalid port in target: ${rawTarget}`);
68
+ }
69
+ } else {
70
+ targetHost = targetClean;
71
+ }
72
+
73
+ console.log(`\x1b[36m🚀 Creating [${provider}] Ingress Tunnel [${name}] -> ${hostname} -> [${targetHost}:${targetPort}]...\x1b[0m`);
74
+
75
+ try {
76
+ const queryParams = new URLSearchParams();
77
+ if (region) queryParams.set('region', region);
78
+ const queryStr = queryParams.toString() ? `?${queryParams.toString()}` : '';
79
+
80
+ const result = await request(`${tunnelUrl}/api/tunnels${queryStr}`, {
81
+ method: 'POST',
82
+ body: JSON.stringify({
83
+ name,
84
+ provider,
85
+ hostname,
86
+ target_host: targetHost,
87
+ target_port: targetPort,
88
+ ...(region ? { region } : {})
89
+ })
90
+ });
91
+
92
+ const tunnel = result.data || result;
93
+ console.log(`\x1b[32m✔ Ingress Tunnel created successfully!\x1b[0m`);
94
+ console.log(` ID: \x1b[36m${tunnel.id}\x1b[0m`);
95
+ console.log(` Name: \x1b[32m${tunnel.name}\x1b[0m`);
96
+ console.log(` Public Hostname: \x1b[36m${tunnel.hostname}\x1b[0m`);
97
+ console.log(` Target Origin: \x1b[32m${tunnel.target_host}:${tunnel.target_port}\x1b[0m`);
98
+ console.log(` Status: \x1b[32m${tunnel.status}\x1b[0m\n`);
99
+ } catch (err) {
100
+ console.error(`\x1b[31m✖ Failed to create tunnel:\x1b[0m`, err.message);
101
+ }
102
+ }
103
+
104
+ async function deleteTunnel(nameOrId, options = {}) {
105
+ const config = getStoredConfig();
106
+ const tunnelUrl = resolveServiceUrl('tunnel', options.tunnelUrl);
107
+ const region = options.region || config.region || null;
108
+
109
+ console.log(`\x1b[33m⚡ Deleting Ingress Tunnel [${nameOrId}]...\x1b[0m`);
110
+
111
+ try {
112
+ const queryParams = new URLSearchParams();
113
+ if (region) queryParams.set('region', region);
114
+ const queryStr = queryParams.toString() ? `?${queryParams.toString()}` : '';
115
+
116
+ const result = await request(`${tunnelUrl}/api/tunnels/${encodeURIComponent(nameOrId)}${queryStr}`, {
117
+ method: 'DELETE'
118
+ });
119
+ console.log(`\x1b[32m✔ ${result.message || `Tunnel ${nameOrId} deleted successfully`}\x1b[0m`);
120
+ } catch (err) {
121
+ console.error(`\x1b[31m✖ Failed to delete tunnel:\x1b[0m`, err.message);
122
+ }
123
+ }
124
+
125
+ module.exports = {
126
+ listTunnels,
127
+ createTunnel,
128
+ deleteTunnel
129
+ };
package/package.json CHANGED
@@ -1,6 +1,39 @@
1
1
  {
2
- "name": "@ostro-cloud/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@ostro-cloud/cli",
3
+ "version": "1.0.0-alpha.5",
4
+ "description": "Enterprise Command Line Interface (CLI) for Ostro Cloud Serverless, S3 Buckets, Kubernetes, and CloudFormation Orchestration",
5
+ "main": "lib/index.js",
6
+ "bin": {
7
+ "ostro": "bin/ostro.js",
8
+ "ocs": "bin/ostro.js",
9
+ "ostro-cloud": "bin/ostro.js",
10
+ "ostro-cfn": "bin/ostro.js"
11
+ },
12
+ "keywords": [
13
+ "ostro",
14
+ "cloud",
15
+ "serverless",
16
+ "aws",
17
+ "lambda",
18
+ "s3",
19
+ "cloudformation",
20
+ "kubernetes",
21
+ "cicd",
22
+ "gitlab-ci",
23
+ "cli"
24
+ ],
25
+ "author": "Ostro Cloud Systems",
26
+ "license": "MIT",
27
+ "dependencies": {
28
+ "@ostro/foundation": "^2.0.0-alpha.6",
29
+ "commander": "^12.1.0"
30
+ },
31
+ "engines": {
32
+ "node": ">=22.0.0"
33
+ },
34
+ "scripts": {
35
+ "lint:check": "eslint .",
36
+ "lint:fix": "eslint . --fix",
37
+ "test": "HEADLESS=true jest --runInBand"
38
+ }
39
+ }