Skip to content

Commit 42dbe35

Browse files
Add specifications support to CLI
1 parent 7773439 commit 42dbe35

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

lib/commands/init.js

+1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ const initFunction = async () => {
299299
$id: functionId,
300300
name: answers.name,
301301
runtime: answers.runtime.id,
302+
specification: answers.specification,
302303
execute: ["any"],
303304
events: [],
304305
scopes: ["users.read"],

lib/commands/push.js

+1
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
11261126
functionId: func.$id,
11271127
name: func.name,
11281128
runtime: func.runtime,
1129+
specification: func.specification,
11291130
execute: func.execute,
11301131
events: func.events,
11311132
schedule: func.schedule,

lib/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const process = require("process");
55
const JSONbig = require("json-bigint")({ storeAsString: false });
66

77
const KeysVars = new Set(["key", "value"]);
8-
const KeysFunction = new Set(["path", "$id", "execute", "name", "enabled", "logging", "runtime", "scopes", "events", "schedule", "timeout", "entrypoint", "commands", "vars"]);
8+
const KeysFunction = new Set(["path", "$id", "execute", "name", "enabled", "logging", "runtime", "specification", "scopes", "events", "schedule", "timeout", "entrypoint", "commands", "vars"]);
99
const KeysDatabase = new Set(["$id", "name", "enabled"]);
1010
const KeysCollection = new Set(["$id", "$permissions", "databaseId", "name", "enabled", "documentSecurity", "attributes", "indexes"]);
1111
const KeysStorage = new Set(["$id", "$permissions", "fileSecurity", "name", "enabled", "maximumFileSize", "allowedFileExtensions", "compression", "encryption", "antivirus"]);

lib/questions.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const Client = require("./client");
33
const { localConfig, globalConfig } = require('./config');
44
const { projectsList } = require('./commands/projects');
55
const { teamsList } = require('./commands/teams');
6-
const { functionsListRuntimes, functionsList } = require('./commands/functions');
6+
const { functionsListRuntimes, functionsListSpecifications, functionsList } = require('./commands/functions');
77
const { accountListMfaFactors } = require("./commands/account");
88
const { sdkForConsole } = require("./sdks");
99
const { validateRequired } = require("./validations");
@@ -301,6 +301,25 @@ const questionsCreateFunction = [
301301
})
302302
return choices;
303303
},
304+
},
305+
{
306+
type: "list",
307+
name: "specification",
308+
message: "What specification would you like to use?",
309+
choices: async () => {
310+
let response = await functionsListSpecifications({
311+
parseOutput: false
312+
})
313+
let specifications = response["specifications"]
314+
let choices = specifications.map((spec, idx) => {
315+
return {
316+
name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
317+
value: spec.slug,
318+
disabled: spec.enabled === false ? 'Upgrade to use' : false
319+
}
320+
})
321+
return choices;
322+
},
304323
}
305324
];
306325

0 commit comments

Comments
 (0)