openkbs 0.0.64 → 0.0.65
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 +2 -0
- package/elastic/README.md +1150 -0
- package/elastic/functions.md +328 -0
- package/elastic/postgres.md +287 -0
- package/elastic/pulse.md +386 -0
- package/elastic/storage.md +291 -0
- package/package.json +1 -1
- package/src/actions.js +35 -7
- package/src/index.js +15 -1
- package/src/utils.js +8 -4
- package/version.json +3 -3
package/src/actions.js
CHANGED
|
@@ -1935,7 +1935,7 @@ async function siteDeployAction(kbToken, kbId, siteDir, args) {
|
|
|
1935
1935
|
}
|
|
1936
1936
|
|
|
1937
1937
|
console.green(`\nUpload complete! ${uploaded}/${files.length} files uploaded.`);
|
|
1938
|
-
console.log(`Files accessible at: https://files.openkbs.com/${kbId}/`);
|
|
1938
|
+
// console.log(`Files accessible at: https://files.openkbs.com/${kbId}/`);
|
|
1939
1939
|
|
|
1940
1940
|
} catch (error) {
|
|
1941
1941
|
console.red('Upload failed:', error.message);
|
|
@@ -2184,9 +2184,12 @@ async function elasticDeployAction() {
|
|
|
2184
2184
|
if (elasticRes.error) {
|
|
2185
2185
|
console.red('Elastic deploy error:', elasticRes.error);
|
|
2186
2186
|
} else {
|
|
2187
|
-
if (elasticRes.pulse?.enabled) console.green(' ✓ Pulse enabled');
|
|
2188
|
-
if (elasticRes.
|
|
2189
|
-
if (elasticRes.
|
|
2187
|
+
if (elasticRes.pulse?.enabled || elasticRes.pulse?.alreadyEnabled) console.green(' ✓ Pulse enabled');
|
|
2188
|
+
if (elasticRes.pulse?.error) console.yellow(' ⚠ Pulse:', elasticRes.pulse.error);
|
|
2189
|
+
if (elasticRes.postgres?.enabled || elasticRes.postgres?.alreadyEnabled || elasticRes.postgres?.host) console.green(' ✓ Postgres enabled');
|
|
2190
|
+
if (elasticRes.postgres?.error) console.yellow(' ⚠ Postgres:', elasticRes.postgres.error);
|
|
2191
|
+
if (elasticRes.storage?.enabled || elasticRes.storage?.alreadyEnabled || elasticRes.storage?.bucket) console.green(' ✓ Storage enabled');
|
|
2192
|
+
if (elasticRes.storage?.error) console.yellow(' ⚠ Storage:', elasticRes.storage.error);
|
|
2190
2193
|
if (elasticRes.storage?.cloudfront) console.green(' ✓ CloudFront configured');
|
|
2191
2194
|
}
|
|
2192
2195
|
}
|
|
@@ -2277,13 +2280,37 @@ async function elasticDestroyAction() {
|
|
|
2277
2280
|
console.log('\nDisabling Elastic services...');
|
|
2278
2281
|
|
|
2279
2282
|
if (config.elastic.storage) {
|
|
2283
|
+
// First remove CloudFront behavior/origin if configured
|
|
2284
|
+
const cloudfrontPath = typeof config.elastic.storage === 'object'
|
|
2285
|
+
? config.elastic.storage.cloudfront
|
|
2286
|
+
: null;
|
|
2287
|
+
|
|
2288
|
+
if (cloudfrontPath) {
|
|
2289
|
+
try {
|
|
2290
|
+
await makePostRequest(KB_API_URL, {
|
|
2291
|
+
token: kbToken,
|
|
2292
|
+
action: 'setStorageCloudFront',
|
|
2293
|
+
pathPrefix: cloudfrontPath,
|
|
2294
|
+
enable: false
|
|
2295
|
+
});
|
|
2296
|
+
console.green(` ✓ CloudFront behavior removed (/${cloudfrontPath}/*)`);
|
|
2297
|
+
} catch (e) {
|
|
2298
|
+
console.yellow(` ⚠ CloudFront: ${e.message}`);
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
// Then delete storage bucket
|
|
2280
2303
|
try {
|
|
2281
|
-
await makePostRequest(KB_API_URL, {
|
|
2304
|
+
const storageRes = await makePostRequest(KB_API_URL, {
|
|
2282
2305
|
token: kbToken,
|
|
2283
2306
|
action: 'deleteElasticStorage',
|
|
2284
2307
|
force: true
|
|
2285
2308
|
});
|
|
2286
|
-
|
|
2309
|
+
if (storageRes.error) {
|
|
2310
|
+
console.yellow(` ⚠ Storage: ${storageRes.error}`);
|
|
2311
|
+
} else {
|
|
2312
|
+
console.green(' ✓ Storage disabled');
|
|
2313
|
+
}
|
|
2287
2314
|
} catch (e) {
|
|
2288
2315
|
console.yellow(` ⚠ Storage: ${e.message}`);
|
|
2289
2316
|
}
|
|
@@ -2473,5 +2500,6 @@ module.exports = {
|
|
|
2473
2500
|
postgresAction,
|
|
2474
2501
|
pulseAction,
|
|
2475
2502
|
stackAction,
|
|
2476
|
-
elasticDeployAction
|
|
2503
|
+
elasticDeployAction,
|
|
2504
|
+
elasticDestroyAction
|
|
2477
2505
|
};
|
package/src/index.js
CHANGED
|
@@ -20,7 +20,8 @@ const {
|
|
|
20
20
|
postgresAction,
|
|
21
21
|
pulseAction,
|
|
22
22
|
stackAction,
|
|
23
|
-
elasticDeployAction
|
|
23
|
+
elasticDeployAction,
|
|
24
|
+
elasticDestroyAction
|
|
24
25
|
} = require('./actions');
|
|
25
26
|
|
|
26
27
|
|
|
@@ -128,6 +129,19 @@ Reads openkbs.json and deploys:
|
|
|
128
129
|
- Site
|
|
129
130
|
`);
|
|
130
131
|
|
|
132
|
+
program
|
|
133
|
+
.command('destroy')
|
|
134
|
+
.description('Destroy all resources from openkbs.json (DANGEROUS)')
|
|
135
|
+
.action(elasticDestroyAction)
|
|
136
|
+
.addHelpText('after', `
|
|
137
|
+
Examples:
|
|
138
|
+
$ openkbs destroy
|
|
139
|
+
|
|
140
|
+
Reads openkbs.json and deletes:
|
|
141
|
+
- Functions
|
|
142
|
+
- Elastic services (storage, postgres, pulse)
|
|
143
|
+
`);
|
|
144
|
+
|
|
131
145
|
program
|
|
132
146
|
.command('stack <subcommand>')
|
|
133
147
|
.description('Manage stack resources (deploy, destroy, status)')
|
package/src/utils.js
CHANGED
|
@@ -166,14 +166,18 @@ function makePostRequest(url, data) {
|
|
|
166
166
|
try {
|
|
167
167
|
const parsed = JSON.parse(body);
|
|
168
168
|
if (parsed.error) {
|
|
169
|
-
console.red(parsed.error);
|
|
169
|
+
console.red(`Error: ${parsed.error}`);
|
|
170
170
|
} else if (parsed.message) {
|
|
171
|
-
console.red(parsed.message);
|
|
171
|
+
console.red(`Error: ${parsed.message}`);
|
|
172
172
|
} else {
|
|
173
|
-
|
|
173
|
+
// Show the full response body if no error/message field
|
|
174
|
+
console.red(`Request failed (HTTP ${res.statusCode}):`);
|
|
175
|
+
console.red(JSON.stringify(parsed, null, 2));
|
|
174
176
|
}
|
|
175
177
|
} catch (e) {
|
|
176
|
-
|
|
178
|
+
// Could not parse JSON, show raw body
|
|
179
|
+
console.red(`Request failed (HTTP ${res.statusCode}):`);
|
|
180
|
+
console.red(body || 'No response body');
|
|
177
181
|
}
|
|
178
182
|
|
|
179
183
|
process.exit(1);
|
package/version.json
CHANGED