openkbs 0.0.60 → 0.0.62
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 +25 -7
- package/src/index.js +3 -3
- package/version.json +3 -3
package/package.json
CHANGED
package/src/actions.js
CHANGED
|
@@ -931,7 +931,7 @@ async function fnAction(subCommand, args = []) {
|
|
|
931
931
|
switch (subCommand) {
|
|
932
932
|
case 'list':
|
|
933
933
|
return await fnListAction(kbToken);
|
|
934
|
-
case '
|
|
934
|
+
case 'push':
|
|
935
935
|
return await fnDeployAction(kbToken, args[0], args.slice(1));
|
|
936
936
|
case 'delete':
|
|
937
937
|
return await fnDeleteAction(kbToken, args[0]);
|
|
@@ -946,13 +946,13 @@ async function fnAction(subCommand, args = []) {
|
|
|
946
946
|
console.log('');
|
|
947
947
|
console.log('Commands:');
|
|
948
948
|
console.log(' list List all elastic functions');
|
|
949
|
-
console.log('
|
|
949
|
+
console.log(' push <name> Push a function from ./functions/<name>/');
|
|
950
950
|
console.log(' delete <name> Delete a function');
|
|
951
951
|
console.log(' logs <name> View function logs');
|
|
952
952
|
console.log(' env <name> [KEY=value] View or set environment variables');
|
|
953
953
|
console.log(' invoke <name> [payload] Invoke a function');
|
|
954
954
|
console.log('');
|
|
955
|
-
console.log('Options for
|
|
955
|
+
console.log('Options for push:');
|
|
956
956
|
console.log(' --region <region> Region (us-east-1, eu-central-1, ap-southeast-1)');
|
|
957
957
|
console.log(' --memory <mb> Memory size (128-3008 MB)');
|
|
958
958
|
console.log(' --timeout <seconds> Timeout (1-900 seconds)');
|
|
@@ -1005,6 +1005,8 @@ async function fnDeployAction(kbToken, functionName, args) {
|
|
|
1005
1005
|
let region = findRegion();
|
|
1006
1006
|
let memorySize = 256;
|
|
1007
1007
|
let timeout = 30;
|
|
1008
|
+
let runtime = null; // null = use default (nodejs24.x)
|
|
1009
|
+
let handler = null; // null = use default (index.handler)
|
|
1008
1010
|
|
|
1009
1011
|
for (let i = 0; i < args.length; i++) {
|
|
1010
1012
|
if (args[i] === '--region' && args[i + 1]) {
|
|
@@ -1013,6 +1015,10 @@ async function fnDeployAction(kbToken, functionName, args) {
|
|
|
1013
1015
|
memorySize = parseInt(args[++i]);
|
|
1014
1016
|
} else if (args[i] === '--timeout' && args[i + 1]) {
|
|
1015
1017
|
timeout = parseInt(args[++i]);
|
|
1018
|
+
} else if (args[i] === '--runtime' && args[i + 1]) {
|
|
1019
|
+
runtime = args[++i];
|
|
1020
|
+
} else if (args[i] === '--handler' && args[i + 1]) {
|
|
1021
|
+
handler = args[++i];
|
|
1016
1022
|
}
|
|
1017
1023
|
}
|
|
1018
1024
|
|
|
@@ -1082,7 +1088,7 @@ async function fnDeployAction(kbToken, functionName, args) {
|
|
|
1082
1088
|
} else {
|
|
1083
1089
|
// Create new function
|
|
1084
1090
|
console.log('Creating new function...');
|
|
1085
|
-
|
|
1091
|
+
const createParams = {
|
|
1086
1092
|
token: kbToken,
|
|
1087
1093
|
action: 'createElasticFunction',
|
|
1088
1094
|
functionName,
|
|
@@ -1090,7 +1096,10 @@ async function fnDeployAction(kbToken, functionName, args) {
|
|
|
1090
1096
|
region,
|
|
1091
1097
|
memorySize,
|
|
1092
1098
|
timeout
|
|
1093
|
-
}
|
|
1099
|
+
};
|
|
1100
|
+
if (runtime) createParams.runtime = runtime;
|
|
1101
|
+
if (handler) createParams.handler = handler;
|
|
1102
|
+
response = await makePostRequest(KB_API_URL, createParams);
|
|
1094
1103
|
}
|
|
1095
1104
|
|
|
1096
1105
|
if (response.error) {
|
|
@@ -1837,11 +1846,20 @@ async function siteAction(subCommand, args = []) {
|
|
|
1837
1846
|
const { kbToken } = await fetchKBJWT(kbId);
|
|
1838
1847
|
|
|
1839
1848
|
switch (subCommand) {
|
|
1840
|
-
case '
|
|
1849
|
+
case 'push':
|
|
1850
|
+
// If a folder path is provided, use it
|
|
1851
|
+
if (args.length > 0 && args[0] && !args[0].startsWith('-')) {
|
|
1852
|
+
const customDir = path.resolve(process.cwd(), args[0]);
|
|
1853
|
+
if (fs.existsSync(customDir) && fs.statSync(customDir).isDirectory()) {
|
|
1854
|
+
siteDir = customDir;
|
|
1855
|
+
} else {
|
|
1856
|
+
return console.red(`Directory not found: ${args[0]}`);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1841
1859
|
return await siteDeployAction(kbToken, kbId, siteDir, args);
|
|
1842
1860
|
default:
|
|
1843
1861
|
console.log('Site management commands:\n');
|
|
1844
|
-
console.log(' openkbs site
|
|
1862
|
+
console.log(' openkbs site push [folder] Upload files to S3 (defaults to current dir or site/)');
|
|
1845
1863
|
console.log('\nRun from a folder containing settings.json with kbId, or from parent with site/ subdirectory');
|
|
1846
1864
|
}
|
|
1847
1865
|
}
|
package/src/index.js
CHANGED
|
@@ -210,7 +210,7 @@ program
|
|
|
210
210
|
.addHelpText('after', `
|
|
211
211
|
Examples:
|
|
212
212
|
$ openkbs fn list List all functions
|
|
213
|
-
$ openkbs fn
|
|
213
|
+
$ openkbs fn push hello --region us-east-1 Push function from ./functions/hello/
|
|
214
214
|
$ openkbs fn delete hello Delete a function
|
|
215
215
|
$ openkbs fn logs hello View function logs
|
|
216
216
|
$ openkbs fn env hello View environment variables
|
|
@@ -224,10 +224,10 @@ program
|
|
|
224
224
|
.action((subCommand, args) => siteAction(subCommand, args))
|
|
225
225
|
.addHelpText('after', `
|
|
226
226
|
Examples:
|
|
227
|
-
$ openkbs site
|
|
227
|
+
$ openkbs site push Push site/ folder (or current dir) to S3
|
|
228
|
+
$ openkbs site push ./dist Push specific folder to S3
|
|
228
229
|
|
|
229
230
|
Run from a directory containing settings.json with kbId.
|
|
230
|
-
Files are uploaded to the whitelabel domain's files bucket.
|
|
231
231
|
`);
|
|
232
232
|
|
|
233
233
|
program
|
package/version.json
CHANGED