Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add typescript support to bottender dev
- Loading branch information
Showing
10 changed files
with
91 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.test.{ts,js} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/create-bottender-app/src/utils/generateAppEntry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import prettier from 'prettier'; | ||
|
||
import { Platform } from '../types'; | ||
|
||
const generateAppEntry = ( | ||
isTypescript: boolean, | ||
platforms: Platform[] | ||
): string => { | ||
if (!isTypescript) { | ||
return prettier.format( | ||
` | ||
module.exports = async function App(context) { | ||
await context.sendText('Welcome to Bottender'); | ||
}; | ||
`, | ||
{ | ||
trailingComma: 'es5', | ||
singleQuote: true, | ||
parser: 'babel', | ||
} | ||
); | ||
} | ||
|
||
const contexts = platforms.map( | ||
platform => `${platform.charAt(0).toUpperCase()}${platform.slice(1)}Context` | ||
); | ||
|
||
return prettier.format( | ||
` | ||
import { ${contexts.join(', ')} } from 'bottender'; | ||
export default async function App(context: ${contexts.join( | ||
' | ' | ||
)}): Promise<void> { | ||
await context.sendText('Welcome to Bottender'); | ||
}; | ||
`, | ||
{ | ||
trailingComma: 'es5', | ||
singleQuote: true, | ||
parser: 'typescript', | ||
} | ||
); | ||
}; | ||
|
||
export default generateAppEntry; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
packages/create-bottender-app/template-typescript/src/index.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters