@hynaweb/stage 1.0.1 ā 1.0.2
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/bin/cli.js +50 -16
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -4,8 +4,8 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const readline = require('readline');
|
|
6
6
|
|
|
7
|
-
// Points to your new Edge Function
|
|
8
7
|
const API_URL = 'https://mczesspakhkomlnmfstw.supabase.co/functions/v1/deploy-stage';
|
|
8
|
+
const DESTROY_URL = 'https://mczesspakhkomlnmfstw.supabase.co/functions/v1/destroy-stage';
|
|
9
9
|
const SUPABASE_KEY = 'sb_publishable_sG0q8k6txKHOihBduyr67w_UKfolcvj';
|
|
10
10
|
|
|
11
11
|
const configPath = path.join(require('os').homedir(), '.hyna-stage');
|
|
@@ -25,27 +25,61 @@ async function getApiKey() {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
async function main() {
|
|
28
|
-
|
|
28
|
+
const command = process.argv[2];
|
|
29
29
|
const apiKey = await getApiKey();
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
if (command === 'up') {
|
|
32
|
+
console.log('š Initializing HYNA-Stage...');
|
|
32
33
|
console.log('š¦ Spinning up cloud environment...');
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
try {
|
|
36
|
+
const res = await axios.post(API_URL, {}, {
|
|
37
|
+
headers: {
|
|
38
|
+
'Authorization': 'Bearer ' + apiKey,
|
|
39
|
+
'apikey': SUPABASE_KEY,
|
|
40
|
+
'Content-Type': 'application/json'
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
console.log('\nā
Environment is LIVE!');
|
|
45
|
+
console.log('š URL: \x1b[36m' + res.data.url + '\x1b[0m');
|
|
46
|
+
console.log('š Sandbox ID: ' + res.data.sandbox_id);
|
|
47
|
+
console.log('ā±ļø Auto-destruct in: 1 hour\n');
|
|
48
|
+
|
|
49
|
+
} catch (err) {
|
|
50
|
+
console.error('ā Error:', err.response?.data?.error || err.message);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if (command === 'down') {
|
|
54
|
+
const sandboxId = process.argv[3];
|
|
55
|
+
|
|
56
|
+
if (!sandboxId) {
|
|
57
|
+
console.error('ā Please provide a sandbox ID: hyna-stage down <sandbox_id>');
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
41
60
|
|
|
42
|
-
console.log('
|
|
43
|
-
console.log('š URL: \x1b[36m' + res.data.url + '\x1b[0m');
|
|
44
|
-
console.log('š Sandbox ID: ' + res.data.sandbox_id);
|
|
45
|
-
console.log('ā±ļø Auto-destruct in: 1 hour\n');
|
|
61
|
+
console.log('šļø Destroying sandbox ' + sandboxId + '...');
|
|
46
62
|
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
try {
|
|
64
|
+
await axios.post(DESTROY_URL, { sandbox_id: sandboxId }, {
|
|
65
|
+
headers: {
|
|
66
|
+
'Authorization': 'Bearer ' + apiKey,
|
|
67
|
+
'apikey': SUPABASE_KEY,
|
|
68
|
+
'Content-Type': 'application/json'
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
console.log('\nā
Environment destroyed successfully.\n');
|
|
73
|
+
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error('ā Error:', err.response?.data?.error || err.message);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
console.log('Usage:');
|
|
80
|
+
console.log(' hyna-stage up Spin up a new environment');
|
|
81
|
+
console.log(' hyna-stage down <id> Destroy a specific environment');
|
|
49
82
|
}
|
|
50
83
|
}
|
|
84
|
+
|
|
51
85
|
main();
|