Use twilioserverlessrc in TypeScript projects to point at output
dkundel opened this issue · comments
As called out in #465 for TypeScript projects we need to point the Serverless Toolkit against the output folders in dist/functions
and dist/assets
as opposed to leaving it to the default of functions
and assets
. Right now this is done in the package.json
for the deploy
script by using the --functions-folder
and --assets-folder
in the script. These flags don't get picked up if you run twilio serverless:deploy
though. Instead we should modify the .twilioserverlessrc
file that gets created to set the values accordingly instead.
Changes required
- Add a
isTypeScriptProject
argument to thetemplateDefaultConfigFile
function in/packages/twilio-run/src/templating/defaultConfig.ts
- Adjust the logic of
templateDefaultConfigFile
ifisTypeScriptProject
istrue
to set"functionsFolder": "dist/functions"
and"assetsFolder": "dist/assets"
accordingly. - Add same
isTypeScriptProject
as optional argument towriteDefaultConfigFile
method and pass totemplateDefaultConfigFile
- Change
createServerlessConfigFile
function inpackages/create-twilio-function/src/create-twilio-function/create-files.js
to accept anisTypeScriptProject
flag and pass it towriteDefaultConfigFile
- Change call of
createServerlessConfigFile
inpackages/create-twilio-function/src/create-twilio-function.js
to passisTypeScriptProject
by checking forprojectType === 'typescript'
- Remove the now redundant additions to the
start
anddeploy
scripts (lines 54-57) from thecreatePackageJSON
method increate-files.js
Acceptance criteria
After the changes were made the following order of commands should work:
twilio serverless:init ts-example --typescript
cd ts-example
npm run build
twilio serverless:deploy
twilio serverless:start
should also work out of the box after running npm run build
.