Skip to content

Commit

Permalink
Added template init and prompts for javy typescript.
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioespinoza committed Jul 10, 2024
1 parent 0735751 commit b82f232
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/commands/function/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions src/prompts/function/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ interface PromptDeployOutput {

enum EBlsFramework {
RUST = 'rust',
ASSEMBLY_SCRIPT = 'assemblyscript'
ASSEMBLY_SCRIPT = 'assemblyscript',
JAVY_TYPESCRIPT = 'typescript'
}

const templates = {
Expand All @@ -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<PromptDeployOutput | null> => {
Expand Down Expand Up @@ -55,7 +60,8 @@ const promptFnInit = async (options: PromptDeployOptions): Promise<PromptDeployO
message: 'Pick a framework',
choices: [
{ title: 'Assembly Script', value: EBlsFramework.ASSEMBLY_SCRIPT },
{ title: 'Rust', value: EBlsFramework.RUST }
{ title: 'Rust', value: EBlsFramework.RUST },
{ title: 'Typescript (Javy)', value: EBlsFramework.JAVY_TYPESCRIPT },
],
initial: 0
}
Expand Down

0 comments on commit b82f232

Please sign in to comment.