Skip to content

Commit 9e30b77

Browse files
feat: show Rust as option in functions:create (#6316)
* feat: show Rust as option in functions:create * style: lint --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent ab901d8 commit 9e30b77

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/commands/functions/functions-create.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ const require = createRequire(import.meta.url)
3131

3232
const templatesDir = path.resolve(dirname(fileURLToPath(import.meta.url)), '../../functions-templates')
3333

34-
const showRustTemplates = process.env.NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE === 'true'
35-
3634
/**
3735
* Ensure that there's a sub-directory in `src/functions-templates` named after
3836
* each `value` property in this list.
@@ -41,7 +39,7 @@ const languages = [
4139
{ name: 'JavaScript', value: 'javascript' },
4240
{ name: 'TypeScript', value: 'typescript' },
4341
{ name: 'Go', value: 'go' },
44-
showRustTemplates && { name: 'Rust', value: 'rust' },
42+
{ name: 'Rust', value: 'rust' },
4543
]
4644

4745
/**
@@ -181,12 +179,10 @@ const pickTemplate = async function ({ language: languageFromFlag }, funcType) {
181179
if (language === undefined) {
182180
const langs =
183181
funcType === 'edge'
184-
? // @ts-expect-error TS(2339) FIXME: Property 'value' does not exist on type 'false | {... Remove this comment to see the full error message
185-
languages.filter((lang) => lang.value === 'javascript' || lang.value === 'typescript')
182+
? languages.filter((lang) => lang.value === 'javascript' || lang.value === 'typescript')
186183
: languages.filter(Boolean)
187184

188185
const { language: languageFromPrompt } = await inquirer.prompt({
189-
// @ts-expect-error
190186
choices: langs,
191187
message: 'Select the language of your function',
192188
name: 'language',
@@ -239,7 +235,7 @@ const DEFAULT_PRIORITY = 999
239235
const selectTypeOfFunc = async () => {
240236
const functionTypes = [
241237
{ name: 'Edge function (Deno)', value: 'edge' },
242-
{ name: 'Serverless function (Node/Go)', value: 'serverless' },
238+
{ name: 'Serverless function (Node/Go/Rust)', value: 'serverless' },
243239
]
244240

245241
const { functionType } = await inquirer.prompt([
@@ -561,6 +557,17 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun
561557

562558
await installAddons(command, addons, path.resolve(functionPath))
563559
await handleOnComplete({ command, onComplete })
560+
561+
log()
562+
log(chalk.greenBright(`Function created!`))
563+
564+
if (lang == 'rust') {
565+
log(
566+
chalk.green(
567+
`Please note that Rust functions require setting the NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE environment variable to 'true' on your site.`,
568+
),
569+
)
570+
}
564571
}
565572
}
566573

0 commit comments

Comments
 (0)