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 the templateDefaultConfigFile function in /packages/twilio-run/src/templating/defaultConfig.ts
- Adjust the logic of
templateDefaultConfigFile if isTypeScriptProject is true to set "functionsFolder": "dist/functions" and "assetsFolder": "dist/assets" accordingly.
- Add same
isTypeScriptProject as optional argument to writeDefaultConfigFile method and pass to templateDefaultConfigFile
- Change
createServerlessConfigFile function in packages/create-twilio-function/src/create-twilio-function/create-files.js to accept an isTypeScriptProject flag and pass it to writeDefaultConfigFile
- Change call of
createServerlessConfigFile in packages/create-twilio-function/src/create-twilio-function.js to pass isTypeScriptProject by checking for projectType === 'typescript'
- Remove the now redundant additions to the
start and deploy scripts (lines 54-57) from the createPackageJSON method in create-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.
As called out in #465 for TypeScript projects we need to point the Serverless Toolkit against the output folders in
dist/functionsanddist/assetsas opposed to leaving it to the default offunctionsandassets. Right now this is done in thepackage.jsonfor thedeployscript by using the--functions-folderand--assets-folderin the script. These flags don't get picked up if you runtwilio serverless:deploythough. Instead we should modify the.twilioserverlessrcfile that gets created to set the values accordingly instead.Changes required
isTypeScriptProjectargument to thetemplateDefaultConfigFilefunction in/packages/twilio-run/src/templating/defaultConfig.tstemplateDefaultConfigFileifisTypeScriptProjectistrueto set"functionsFolder": "dist/functions"and"assetsFolder": "dist/assets"accordingly.isTypeScriptProjectas optional argument towriteDefaultConfigFilemethod and pass totemplateDefaultConfigFilecreateServerlessConfigFilefunction inpackages/create-twilio-function/src/create-twilio-function/create-files.jsto accept anisTypeScriptProjectflag and pass it towriteDefaultConfigFilecreateServerlessConfigFileinpackages/create-twilio-function/src/create-twilio-function.jsto passisTypeScriptProjectby checking forprojectType === 'typescript'startanddeployscripts (lines 54-57) from thecreatePackageJSONmethod increate-files.jsAcceptance 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:deploytwilio serverless:startshould also work out of the box after runningnpm run build.