Skip to content

Use twilioserverlessrc in TypeScript projects to point at output #467

@dkundel

Description

@dkundel

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

  1. Add a isTypeScriptProject argument to the templateDefaultConfigFile function in /packages/twilio-run/src/templating/defaultConfig.ts
  2. Adjust the logic of templateDefaultConfigFile if isTypeScriptProject is true to set "functionsFolder": "dist/functions" and "assetsFolder": "dist/assets" accordingly.
  3. Add same isTypeScriptProject as optional argument to writeDefaultConfigFile method and pass to templateDefaultConfigFile
  4. 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
  5. Change call of createServerlessConfigFile in packages/create-twilio-function/src/create-twilio-function.js to pass isTypeScriptProject by checking for projectType === 'typescript'
  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions