diff --git a/src/commands/function/init.ts b/src/commands/function/init.ts index b62287c..67d8415 100644 --- a/src/commands/function/init.ts +++ b/src/commands/function/init.ts @@ -56,13 +56,20 @@ export const run = async (options: any) => { await handleNpmInstallation() return } - break; case 'rust': // Check whether Cargo/Rust is installed if (!getCargoInstallationStatus()) isValidated = await handleCargoInstallation() break + + case 'typescript': + // Check whether NPM is installed + if (!getNpmInstallationStatus()) { + await handleNpmInstallation() + return + } + break } if (!isValidated) { @@ -110,6 +117,12 @@ export const run = async (options: any) => { } catch (error: any) { logger.error('Failed to configure Rust function.', error.message) } + + case 'typescript': + execSync(`cd ${installationPath}; npm pkg set name=${sanitizedName}`) + execSync(`cd ${installationPath}; npm pkg set bls.functionId=${functionId}`) + execSync(`cd ${installationPath}; npm install`, { stdio: 'ignore' }) + break } } catch (error: any) { logger.error('Failed to finalize function setup, please try again.', error.message) diff --git a/src/prompts/function/init.ts b/src/prompts/function/init.ts index 352183a..fe77234 100644 --- a/src/prompts/function/init.ts +++ b/src/prompts/function/init.ts @@ -14,7 +14,8 @@ interface PromptDeployOutput { enum EBlsFramework { RUST = 'rust', - ASSEMBLY_SCRIPT = 'assemblyscript' + ASSEMBLY_SCRIPT = 'assemblyscript', + JAVY_TYPESCRIPT = 'typescript' } const templates = { @@ -24,7 +25,11 @@ const templates = { ], [EBlsFramework.RUST]: [ { title: 'Hello World', value: 'https://github.com/blocklessnetwork/template-rust-hello-world' } + ], + [EBlsFramework.JAVY_TYPESCRIPT]: [ + { title: 'Hello World', value: 'https://github.com/blocklessnetwork/template-javy-typescript-hello-world' } ] + } const promptFnInit = async (options: PromptDeployOptions): Promise => { @@ -55,7 +60,8 @@ const promptFnInit = async (options: PromptDeployOptions): Promise