Execute custom build script on ASK CLI(v2) deployment command

ASK CLI(v1) has a custom hook to deploy your skill. And ASK CLI(v2) has a similar one. Step by Step Create hoo […]

広告ここから
広告ここまで

目次

    ASK CLI(v1) has a custom hook to deploy your skill. And ASK CLI(v2) has a similar one.

    Step by Step

    Create hook directory

    At first, we need to create the hook script directory.

    $ mkdir hooks

    Get default script from GitHub

    Version 2’s hook script will overwrite the default script.

    So we have to provide a install and package command in your hook script.

    When you forgot to add it, we will failed to build.

    ==================== Deploy Skill Infrastructure ====================
      ✖ Deploy Alexa skill infrastructure for region "default"
    [Error]: ENOENT: no such file or directory, stat '/Users/development/sandbox/ForkedExample/.ask/lambda/build.zip'

    Most simplest way is get the default script from GitHub.

    $ cd hooks
    $ wget https://raw.githubusercontent.com/alexa/ask-cli/master/lib/b
    uiltins/build-flows/nodejs-npm/build.sh
    $ chmod +x ./build.sh

    Edit the script

    We can put any code into the hooks/build.sh file. This example is adding a npm run build command.

    install_dependencies() {
      [[ $DO_DEBUG == true ]] && display_debug "Installing NodeJS dependencies based on the package.json." 
      [[ $DO_DEBUG == false ]] && QQ=true # decide if quiet flag will be appended
    
      npm install --production ${QQ:+--quiet}
      // Add a new command!
      npm run build ${QQ:+--quiet}
      return $?
    }

    Conclusion

    We can still customize the deployment script in ASK CLI’s deploy command.

    So we’re able to use TypeScript easily.

    広告ここから
    広告ここまで

    Random posts

    Home
    Search
    Bookmark