Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add specifications support to CLI #1025

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions templates/cli/lib/commands/init.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
1 change: 1 addition & 0 deletions templates/cli/lib/commands/push.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion templates/cli/lib/config.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
Expand Down
21 changes: 20 additions & 1 deletion templates/cli/lib/questions.js.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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
abnegate marked this conversation as resolved.
Show resolved Hide resolved
}
})
return choices;
},
}
];

Expand Down
Loading