diff --git a/templates/cli/lib/commands/init.js.twig b/templates/cli/lib/commands/init.js.twig index eb583d37d..d1861d70f 100644 --- a/templates/cli/lib/commands/init.js.twig +++ b/templates/cli/lib/commands/init.js.twig @@ -299,6 +299,7 @@ const initFunction = async () => { $id: functionId, name: answers.name, runtime: answers.runtime.id, + specification: answers.specification, execute: ["any"], events: [], scopes: ["users.read"], diff --git a/templates/cli/lib/commands/push.js.twig b/templates/cli/lib/commands/push.js.twig index 88122d15b..fb454cb02 100644 --- a/templates/cli/lib/commands/push.js.twig +++ b/templates/cli/lib/commands/push.js.twig @@ -1126,6 +1126,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur functionId: func.$id, name: func.name, runtime: func.runtime, + specification: func.specification, execute: func.execute, events: func.events, schedule: func.schedule, diff --git a/templates/cli/lib/config.js.twig b/templates/cli/lib/config.js.twig index 408c56ee6..d843a0abd 100644 --- a/templates/cli/lib/config.js.twig +++ b/templates/cli/lib/config.js.twig @@ -5,7 +5,7 @@ const process = require("process"); const JSONbig = require("json-bigint")({ storeAsString: false }); const KeysVars = new Set(["key", "value"]); -const KeysFunction = new Set(["path", "$id", "execute", "name", "enabled", "logging", "runtime", "scopes", "events", "schedule", "timeout", "entrypoint", "commands", "vars"]); +const KeysFunction = new Set(["path", "$id", "execute", "name", "enabled", "logging", "runtime", "specification", "scopes", "events", "schedule", "timeout", "entrypoint", "commands", "vars"]); const KeysDatabase = new Set(["$id", "name", "enabled"]); const KeysCollection = new Set(["$id", "$permissions", "databaseId", "name", "enabled", "documentSecurity", "attributes", "indexes"]); const KeysStorage = new Set(["$id", "$permissions", "fileSecurity", "name", "enabled", "maximumFileSize", "allowedFileExtensions", "compression", "encryption", "antivirus"]); diff --git a/templates/cli/lib/questions.js.twig b/templates/cli/lib/questions.js.twig index 942142671..cf2aca30b 100644 --- a/templates/cli/lib/questions.js.twig +++ b/templates/cli/lib/questions.js.twig @@ -3,7 +3,7 @@ const Client = require("./client"); const { localConfig, globalConfig } = require('./config'); const { projectsList } = require('./commands/projects'); const { teamsList } = require('./commands/teams'); -const { functionsListRuntimes, functionsList } = require('./commands/functions'); +const { functionsListRuntimes, functionsListSpecifications, functionsList } = require('./commands/functions'); const { accountListMfaFactors } = require("./commands/account"); const { sdkForConsole } = require("./sdks"); const { validateRequired } = require("./validations"); @@ -301,6 +301,25 @@ const questionsCreateFunction = [ }) return choices; }, + }, + { + type: "list", + name: "specification", + message: "What specification would you like to use?", + choices: async () => { + let response = await functionsListSpecifications({ + parseOutput: false + }) + let specifications = response["specifications"] + let choices = specifications.map((spec, idx) => { + return { + name: `${spec.cpus} CPU, ${spec.memory}MB RAM`, + value: spec.slug, + disabled: spec.enabled === false ? 'Upgrade to use' : false + } + }) + return choices; + }, } ];