Giter Club home page Giter Club logo

create-twilio-function's Issues

Add an "empty" option to create just the file structure

The default template has some example files in it. The blank template still has a couple of blank files. If you truly want to start a functions project from scratch there is no template available.

If we had an --empty option, we could skip templates and skip the default template and just create the file structure.

Tests are failing

When trying to create a new function using the --template flag with a missing template, the command succeeds.

Suspect this is a problem in twilio-run.

Display success message at the end of the process

There should be a message displayed at the end of the process with the next steps.

Those next steps are:

  • Change into the directory you just created
  • Start a local server running the functions: npm start
  • Visit the example function at http://localhost:3000/example
  • Create new functions in the functions directory and new assets in the assets directory

Use boxen for display, like twilio-run.

Make it possible to import Account SID and Auth Token from env variables

If a developer is already storing their Account SID and Auth Token in env variables then we should be able to use them.

Implementation:

If Account SID/Auth Token is detected in the environment, prompt to ask whether to use them.
If declined, move on to prompt for the credentials.

Include a flag, --import-credentials, which skips the prompt if the credentials are present (for automation).

Create function fails on windows with spaces in paths

OS: Windows 10 x64

Attempting to create the function in a directory that has a space throws an error.

C:\Users\Jordan Walsh\projects\launch-phone-redirect>npx create-twilio-function@next example
Error: EPERM: operation not permitted, mkdir 'C:\Users\Jordan'
TypeError: Cannot read property 'get' of undefined
    at errorMessage (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-message.js:38:39)
    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:201:13)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:225:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:263:24
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:83:7
    at Array.forEach (<anonymous>)
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:82:13
    at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
    at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:173:20)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97
  var doExit = npm.config.loaded ? npm.config.get('_exit') : true
                          ^

TypeError: Cannot read property 'loaded' of undefined
    at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97:27)
    at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
    at process.emit (events.js:198:13)
    at process._fatalException (internal/bootstrap/node.js:496:27)
Install for create-twilio-function@next failed with code 7

The same code executed in a directory with no spaces works fine:

c:\projects>create-twilio-function launch-phone-redirect
√ Creating project directory
Please enter your Twilio credentials which you can find in your Twilio console (​https://twil.io/your-console​).
? Twilio Account SID xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
? Twilio auth token [hidden]
√ Creating project directories and files
√ Downloading .gitignore file
√ Installing dependencies
╭──────────────────────────────────────────────────────────────────────────────╮
│                                                                              │
│   Success!                                                                   │
│                                                                              │
│   Created launch-phone-redirect at c:\projects                               │
│                                                                              │
│   Inside that directory, you can run the following command:                  │
│                                                                              │
│   npm start                                                                  │
│     Serves all functions in the ./functions subdirectory and assets in the   │
│     ./assets directory                                                       │
│                                                                              │
│   Get started by running:                                                    │
│                                                                              │
│   cd launch-phone-redirect                                                   │
│   npm start                                                                  │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

c:\projects>

Project is throwing an error when used in Twilio CLI Plugin

If you install the latest version (create-twilio-function@next) and try to use it in the plugin via twilio serverless:init it will create the directory and then throw an error that it exists.

Steps to repo:

  1. clone the plugin repo (https://github.com/twilio-labs/plugin-serverless)
  2. cd plugin-serverless && npm install && npm install create-twilio-function@next
  3. twilio plugin:link .
  4. in a different directory twilio serverless:init pineapple

If you instead locally clone create-twilio-function and change the step 2 to npm install ../create-twilio-function instead it will work.

Missing credentials offer sign-up/in pop-up

It would be neat to offer a way that if no credentials are passed to the CLI that people can choose to either enter their credentials or open the Twilio Console in the browser to sign in / retrieve their credentials.

We should make sure to:

  1. it should be descriptive and clear what's happening
  2. include UTM parameters to the URL to indicate the source

Add a "npm run deploy" command

It would be nice if we could have instructions for Serverless projects like:

git clone ...
cd project
npm install
cp .env.example .env
# Add credentials to .env
npm run deploy

Use fixed window size if it is not available

This package uses the window-size module to make sure the success message formats correctly based on the window size of the user's terminal.

Like in twilio-run/#82, it could break if the window-size module cannot return a width and height.

We should default to a fixed width of, say, 80 in the case where window-size doesn't return a value.

Steps to implement:

  • Create a new file in src/create-twilio-function called window-size.js
  • implement a get function that returns either the object that the window-size module would return or a default of { width: 80, height: 300 } (including tests)
  • replace the use of window-size in success-message.js with this new module

Allow for template flag to be passed

twilio-run can now create a new function from a template in twilio-labs/function-templates. create-twilio-function should be able to create a new project from either the default template within this project or by using twilio-run to grab a template.

API ideas:

Create a project called whats-up with the hello-world template.

npx create-twilio-function whats-up --template hello-world

List the available templates (also available in twilio-run). This might be a pain with the yargs default command.

npx create-twilio-function --list-templates

Update node version

The underlying platform continues to update the version of Node 10 that functions uses. We should try to keep up to date somehow.

Is it ok to change the version to "10"? Or should we keep up to date to ensure the absolute latest?

Failure to create a project prints "project already exists" no matter the error

I'm in a directory I don't have write access to and tried to make a new project:

$ ls -a
.		..
$ twilio serverless:init foo
A directory called 'foo' already exists. Please create your function in a new directory.

The error should be "no permission", or even "error creating directory" without the "directory already exists" would be better.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.