openkbs 0.0.75 → 0.0.76
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/package.json +1 -1
- package/src/actions.js +53 -2
- package/templates/.claude/CLAUDE.md +4 -2
- package/version.json +3 -3
package/package.json
CHANGED
package/src/actions.js
CHANGED
|
@@ -1960,9 +1960,13 @@ async function siteAction(subCommand, args = []) {
|
|
|
1960
1960
|
}
|
|
1961
1961
|
}
|
|
1962
1962
|
return await siteDeployAction(kbToken, kbId, siteDir, args);
|
|
1963
|
+
case 'spa':
|
|
1964
|
+
return await siteSpaAction(kbToken, args);
|
|
1963
1965
|
default:
|
|
1964
1966
|
console.log('Site management commands:\n');
|
|
1965
1967
|
console.log(' openkbs site push [folder] Upload files to S3 (defaults to current dir or site/)');
|
|
1968
|
+
console.log(' openkbs site spa <path> Enable SPA fallback (e.g., /app/index.html)');
|
|
1969
|
+
console.log(' openkbs site spa --disable Disable SPA fallback');
|
|
1966
1970
|
console.log('\nRun from a folder containing settings.json with kbId, or from parent with site/ subdirectory');
|
|
1967
1971
|
}
|
|
1968
1972
|
}
|
|
@@ -2045,6 +2049,50 @@ async function siteDeployAction(kbToken, kbId, siteDir, args) {
|
|
|
2045
2049
|
}
|
|
2046
2050
|
}
|
|
2047
2051
|
|
|
2052
|
+
/**
|
|
2053
|
+
* Configure SPA fallback for whitelabel domain
|
|
2054
|
+
*/
|
|
2055
|
+
async function siteSpaAction(kbToken, args) {
|
|
2056
|
+
const disable = args.includes('--disable');
|
|
2057
|
+
const spaPath = args.find(a => !a.startsWith('-'));
|
|
2058
|
+
|
|
2059
|
+
if (!disable && !spaPath) {
|
|
2060
|
+
console.log('Usage:');
|
|
2061
|
+
console.log(' openkbs site spa /app/index.html Enable SPA fallback');
|
|
2062
|
+
console.log(' openkbs site spa --disable Disable SPA fallback');
|
|
2063
|
+
return;
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
try {
|
|
2067
|
+
console.log(disable ? 'Disabling SPA fallback...' : `Enabling SPA fallback: ${spaPath}`);
|
|
2068
|
+
|
|
2069
|
+
const response = await makePostRequest(KB_API_URL, {
|
|
2070
|
+
token: kbToken,
|
|
2071
|
+
action: 'deployElastic',
|
|
2072
|
+
elastic: {},
|
|
2073
|
+
spa: disable ? null : spaPath
|
|
2074
|
+
});
|
|
2075
|
+
|
|
2076
|
+
if (response.error) {
|
|
2077
|
+
return console.red('Error:', response.error);
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2080
|
+
if (response.spa?.error) {
|
|
2081
|
+
return console.red('SPA Error:', response.spa.error);
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
if (response.spa?.enabled) {
|
|
2085
|
+
console.green(`✓ SPA fallback enabled: ${response.spa.spaFallback}`);
|
|
2086
|
+
console.log(` Domain: ${response.spa.domain}`);
|
|
2087
|
+
console.log(' Changes may take 2-5 minutes to propagate.');
|
|
2088
|
+
} else if (disable) {
|
|
2089
|
+
console.green('✓ SPA fallback disabled');
|
|
2090
|
+
}
|
|
2091
|
+
} catch (error) {
|
|
2092
|
+
console.red('Failed:', error.message);
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
|
|
2048
2096
|
// ===== Elastic Pulse Commands =====
|
|
2049
2097
|
|
|
2050
2098
|
async function pulseAction(subCommand, args = []) {
|
|
@@ -2276,12 +2324,13 @@ async function elasticDeployAction() {
|
|
|
2276
2324
|
const kbToken = res.kbToken;
|
|
2277
2325
|
|
|
2278
2326
|
// Deploy elastic services if configured
|
|
2279
|
-
if (config.elastic) {
|
|
2327
|
+
if (config.elastic || config.spa) {
|
|
2280
2328
|
console.log('\nEnabling Elastic services...');
|
|
2281
2329
|
const elasticRes = await makePostRequest(KB_API_URL, {
|
|
2282
2330
|
token: kbToken,
|
|
2283
2331
|
action: 'deployElastic',
|
|
2284
|
-
elastic: config.elastic
|
|
2332
|
+
elastic: config.elastic || {},
|
|
2333
|
+
spa: config.spa
|
|
2285
2334
|
});
|
|
2286
2335
|
|
|
2287
2336
|
if (elasticRes.error) {
|
|
@@ -2294,6 +2343,8 @@ async function elasticDeployAction() {
|
|
|
2294
2343
|
if (elasticRes.storage?.enabled || elasticRes.storage?.alreadyEnabled || elasticRes.storage?.bucket) console.green(' ✓ Storage enabled');
|
|
2295
2344
|
if (elasticRes.storage?.error) console.yellow(' ⚠ Storage:', elasticRes.storage.error);
|
|
2296
2345
|
if (elasticRes.storage?.cloudfront) console.green(' ✓ CloudFront configured');
|
|
2346
|
+
if (elasticRes.spa?.enabled) console.green(` ✓ SPA fallback: ${elasticRes.spa.spaFallback}`);
|
|
2347
|
+
if (elasticRes.spa?.error) console.yellow(' ⚠ SPA:', elasticRes.spa.error);
|
|
2297
2348
|
}
|
|
2298
2349
|
}
|
|
2299
2350
|
|
package/version.json
CHANGED