diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 5ba61fca..e63fc581 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -27,6 +27,7 @@ jobs: - name: npm install, build, and test run: | npm install + npm run bootstrap npm run build --if-present npm run test env: diff --git a/DESIGN.md b/DESIGN.md new file mode 100644 index 00000000..dc29a7d6 --- /dev/null +++ b/DESIGN.md @@ -0,0 +1,94 @@ +# Design of the Serverless Toolkit + +The Serverless Toolkit is broken up into a variety of sub-projects that serve +different purposes. In order to guide contributors for any contributions to the +Serverless Toolkit, we wrote a set of guidelines that should be taken into +consideration. + +- [Design of the Serverless Toolkit](#design-of-the-serverless-toolkit) + - [1. Modularity](#1-modularity) + - [2. Designed for Twilio Functions development first](#2-designed-for-twilio-functions-development-first) + - [3. From Node.js Developers for Node.js Developers](#3-from-nodejs-developers-for-nodejs-developers) + - [4. The Toolkit should work standalone](#4-the-toolkit-should-work-standalone) + - [5. Convention over configuration](#5-convention-over-configuration) + - [6. Convenience over scriptability](#6-convenience-over-scriptability) + +## 1. Modularity + +While all modules together form the Serverless Toolkit, we offer with the +different modules a way for people to use different parts of the project. + +For example the [Serverless Framework Integration](https://github.com/twilio-labs/serverless-framework-integration) makes use of [`@twilio-labs/serverless-api`] but not of any of the CLI functionality. + +Right now the project breaks down into the following modules: + +| Project | Content | +| ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`twilio-run`] | Core CLI logic of the Serverless Toolkit | +| [`create-twilio-function`] | CLI logic for creating a new project. This can be called with `npm init twilio-function` and therefore should stay separate | +| [`@twilio-labs/plugin-serverless`] | A thin wrapper exposing the commands of [`twilio-run`] and [`create-twilio-function`] to the [Twilio CLI] | +| [`@twilio-labs/serverless-api`] | The core logic that interacts with the REST API. This should not include any CLI-related code. It should instead expose [EventEmitter](https://nodejs.org/api/events.html) or [Streams](https://nodejs.org/api/streams.html). | +| [`function-templates`] | The repository hosting all Twilio Function templates exposed by the CLI toolings | +| [`@twilio-labs/serverless-twilio-runtime`] | Twilio Runtime integration for the [Serverless Framework](https://serverless.com/) | +| [`@twilio-labs/serverless-runtime-types`] | TypeScript definitions for the Twilio Runtime environment | + +## 2. Designed for Twilio Functions development first + +The tooling has some inconsistencies with other tooling of the [Twilio CLI]. + +For example this tooling uses `ACCOUNT_SID` and `AUTH_TOKEN` in the `.env` file +but the [Twilio CLI] and other tools use `TWILIO_ACCOUNT_SID` and `TWILIO_AUTH_TOKEN`. + +This is by design because the Twilio Runtime will expose `ACCOUNT_SID` and +`AUTH_TOKEN` to the user instead. + +## 3. From Node.js Developers for Node.js Developers + +Whenever possible the tooling should not introduce unnecessary configuration but +make it intuitive for any Node.js developer to use it. Some examples: + +- `npm install ` should just install a dependency +- Adding an environment variable to the `.env` file should expose it to `process.env` + +## 4. The Toolkit should work standalone + +This goes inline with #3. A project should be able to be used by anyone who didn't use +Twilio before. As a result setup instructions of any Serverless project should be as +easy as: + +``` +git clone ... project +cd project +npm install +npm start +``` + +Therefore, you should be able to install the Toolkit as a developer dependency +using: + +``` +npm install --save-dev twilio-run +``` + +## 5. Convention over configuration + +Whenever we can avoid the developers having to learn and create configuration, we should. + +For example we should prefer the filesystem to infer information rather than +having an explicit configuration file. + +## 6. Convenience over scriptability + +While scriptability is important, the CLI part of the Toolkit should not be a thin-wrapper +of the REST API to allow Shell scripting. This is a good use case for the [Twilio CLI]. + +Instead it should focus on creating usable and convenient commands with as little configuration as possible. + +[`twilio-run`]: https://npm.im/twilio-run +[`create-twilio-function`]: https://npm.im/create-twilio-function +[`@twilio-labs/plugin-serverless`]: https://npm.im/@twilio-labs/plugin-serverless +[`@twilio-labs/serverless-api`]: https://npm.im/@twilio-labs/serverless-api +[`@twilio-labs/serverless-runtime-types`]: https://npm.im/@twilio-labs/serverless-runtime-types +[`@twilio-labs/serverless-twilio-runtime`]: https://npm.im/@twilio-labs/serverless-twilio-runtime +[`function-templates`]: https://github.com/twilio-labs/function-templates +[twilio cli]: https://twilio.com/docs/cli diff --git a/README.md b/README.md index eb22f7ef..9ae5bb80 100644 --- a/README.md +++ b/README.md @@ -1,347 +1,46 @@ -

twilio-run

-

CLI tool to locally develop and deploy to the Twilio Runtime. Part of the Serverless Toolkit

-

-npm (scoped) npm GitHub All Contributors Code of Conduct PRs Welcome -Travis (.com) -


+

Seagull with a French Fry*

+

Serverless Toolkit

+

Part of Twilio Labs Banner

-- [About](#about) -- [Installation](#installation) -- [Usage](#usage) - - [Create a new project](#create-a-new-project) - - [Project conventions](#project-conventions) - - [Function templates](#function-templates) - - [Deploy a project](#deploy-a-project) -- [Commands](#commands) - - [`twilio-run start [dir]`](#twilio-run-start-dir) - - [Examples](#examples) - - [`twilio-run deploy`](#twilio-run-deploy) - - [Examples](#examples-1) - - [`twilio-run list-templates`](#twilio-run-list-templates) - - [Examples](#examples-2) - - [`twilio-run new [namespace]`](#twilio-run-new-namespace) - - [Examples](#examples-3) - - [`twilio-run list [types]`](#twilio-run-list-types) - - [Examples](#examples-4) - - [`twilio-run activate`](#twilio-run-activate) - - [Examples](#examples-5) - - [`twilio-run logs`](#twilio-run-logs) - - [Examples](#examples-6) -- [API](#api) - - [`runDevServer(port: number, baseDir: string): Promise`](#rundevserverport-number-basedir-string-promiseexpressapplication) - - [`handleToExpressRoute(handler: TwilioHandlerFunction): Express.RequestHandler`](#handletoexpressroutehandler-twiliohandlerfunction-expressrequesthandler) -- [Error Handling in Dev Server](#error-handling-in-dev-server) -- [Contributing](#contributing) - - [Code of Conduct](#code-of-conduct) -- [Contributors](#contributors) -- [License](#license) +## What is the Serverless Toolkit? -## About +The [Serverless Toolkit](https://www.twilio.com/docs/labs/serverless-toolkit) is CLI tooling to help you develop locally and deploy to the [Twilio Runtime](https://www.twilio.com/runtime). -This project is part of the [Serverless Toolkit](https://github.com/twilio-labs/serverless-toolkit). For a more extended documentation, check out the [Twilio Docs](https://www.twilio.com/docs/labs/serverless-toolkit). +There are two ways you can use the toolkit. If you are already using the [Twilio CLI](https://www.twilio.com/docs/twilio-cli), you can install it via a plugin. Alternatively, you can use the toolkit as a standalone using [twilio-run](https://npm.im/twilio-run) via npm or another Node.js package manager. -## Installation +Throughout the [docs](https://www.twilio.com/docs/labs/serverless-toolkit), you can switch in the code snippets between Twilio-CLI and Bash Session to get the commands for both versions. -You can install the CLI tool via `npm` or another package manager. Ideally install it as a dev dependency instead of global: +## Let's work together -```bash -# Install it as a dev dependency -npm install twilio-run --save-dev - -# Afterwards you can use by using: -node_modules/.bin/twilio-run - -npx twilio-run - -# Or inside your package.json scripts section as "twilio-run" -``` - -## Usage - -Check out the [commands](#commands) for in depth usage, but here are some things you will want to know: - -### Create a new project - -To create a new project with the Twilio Serverless Toolkit you can use [`create-twilio-function`](https://github.com/twilio-labs/create-twilio-function/) which will scaffold a new project that is ready to be used with `twilio-run`. - -```bash -# Create a valid project, for example: -npm init twilio-function my-project - -# Navigate into project -cd my-project -``` - -You can then use `twilio-run` to run a local development server to serve your functions and assets. - -```bash -npx twilio-run start -``` - -### Project conventions - -By default JavaScript Functions should be placed in the `functions` directory and assets, which can be JavaScript, images, CSS, or any static asset, should be placed in the `assets` directory. You can choose other directories by providing a `--functions-folder` or `--assets-folder` option to `twilio-run` commands. - -Twilio Functions and Assets can be public, protected or private. The differences are: - -* **Public**: Any one with the URL can visit the Function or Asset -* **Protected**: Twilio signs webhook requests, making a Twilio Function protected means that the Function will validate the webhook signature and reject any incoming requests that don't match -* **Private**: The Function or Asset doesn't a URL, it can only be required within another Function or Asset - -Within `twilio-run` you can make your Functions or Assets public, protected or private by adding to the function filename. Functions and Assets are public by default. To make a Function or Asset protected or private, add `.protected` or `.private` to the filename before the extension. For example: `functions/secret.protected.js` or `assets/hidden.private.jpg`. - -### Function templates - -There are a number of pre-written Function templates that you can add to your project. The [templates are available on GitHub](https://github.com/twilio-labs/function-templates) and you can also propose your own via pull request. - -To list the available templates you can run: - -```bash -npx twilio-run list-templates -``` - -To add a new function into your project from a template you can run: - -```bash -npx twilio-run new namespace -``` - -The command will walk you through choosing the template. - -### Deploy a project - -To deploy a project to the Twilio infrastructure you can run the command: - -```bash -npx twilio-run deploy -``` - -This will deploy your project to the "dev" environment by default. You can then promote the project from "dev" to other environments with the command: - -```bash -npx twilio-run promote --from=dev --to=stage -``` - -## Commands - -The CLI exposes a variety of commands. The best way to find out about the flags and commands available is to run `twilio-run --help` or `twilio-run [command] --help` - -### `twilio-run start [dir]` -- Aliases: `twilio-run dev`, `twilio-run` - -Starts a local development server for testing and debugging of your environment. By default only variables in the `.env` file will be available via `process.env` or through the `context` argument inside Twilio Functions. - -#### Examples - -```bash -# Serves all functions in current functions sub directory -twilio-run - -# Serves all functions in demo/functions -twilio-run demo - -# Serves functions on port 9000 -PORT=9000 twilio-run - -# Serves functions on port 4200 -twilio-run --port=4200 - -# Starts up the inspector mode for the node process -twilio-run --inspect - -# Exposes the Twilio functions via ngrok to share them -twilio-run --ngrok -``` - -### `twilio-run deploy` - -Deploys your project to Twilio. It will read dependencies automatically from your `package.json`'s `dependencies` field and install them. It will also upload and set the variables that are specified in your `.env` file. You can point it against a different `.env` file via command-line flags. - -#### Examples - -```bash -# Deploys all functions and assets in the current working directory -twilio-run deploy - -# Creates an environment with the domain suffix "prod" -twilio-run deploy --environment=prod -``` - -### `twilio-run list-templates` +Everything in this toolkit is released under [Twilio Labs](https://www.twilio.com/docs/labs) and fully open-source. If you find any problems with this, [please file an issue](https://github.com/twilio-labs/twilio-run/issues) or even create a pull request to work together with us on the toolkit. We would love to hear your ideas and feedback! -Lists the [available templates](https://github.com/twilio-labs/function-templates) that you can use to generate new functions and/or assets inside your current project with the [`twilio-run new` command](#twilio-run-new-namespace) below. +## Project Structure & Contributing -#### Examples +This project is a monorepo, meaning it contains multiple packages in one repository. It consists out of the following packages: -```bash -# List available templates -twilio-run list-templates -``` - -### `twilio-run new [namespace]` - -Creates a new set of functions and/or assets inside your current project based on a [template](https://github.com/twilio-labs/function-templates). - -#### Examples - -```bash -# Create a new function using the blank template -# in a subfolder (namespace) demo -twilio-run new demo --template=blank -``` - -### `twilio-run list [types]` - -Lists a set of available resources for different types related to your Account. Available resources that can be listed: -- Services -- Environments or Builds (requires to pass a Service) -- Functions, Assets or Variables (requires to pass a Service and Environment) - - -#### Examples - -```bash -# Lists all existing services/projects associated with your Twilio Account -twilio-run list services -# Lists all existing functions & assets associated with the `dev` environment of this service/project -twilio-run ls functions,assets --environment=dev --service-name=demo -# Outputs all environments for a specific service with extended output for better parsing -twilio-run ls environments --service-sid=ZSxxxxx --extended-output -# Only lists the SIDs and dates of last update for assets, variables and functions -twilio-run ls assets,variables,functions --properties=sid,date_updated -``` - -### `twilio-run activate` -- Aliases: `twilio-run promote` +- [`twilio-run`](packages/twilio-run) - The underlying CLI tool +- [`plugin-serverless`](https://github.com/twilio-labs/plugin-serverless) - Exposes the `twilio-run` CLI into the [Twilio CLI](https://www.twilio.com/docs/twilio-cli) +- [`create-twilio-function`](https://github.com/twilio-labs/create-twilio-function) - Handles templating and bootstrapping of new projects and Functions +- [`serverless-api`](https://github.com/twilio-labs/serverless-api) - The module used to interact with the actual [Serverless API](https://github.com/twilio-labs/serverless-api) +- [`function-templates`](https://github.com/twilio-labs/function-templates) - The templates used by the toolkit to create new Functions -Promotes an existing deployment to a new environment. It can also create a new environment if it doesn't exist. +To understand more about the structure and the design of the Toolkit check out the [design documentation](DESIGN.md). -#### Examples +## Setup & Development -```bash -# Promotes the same build that is on the "dev" environment to the "prod" environment -twilio-run activate --environment=prod --source-environment=dev -# Duplicates an existing build to a new environment called `demo` -twilio-run activate --environment=demo --create-environment --build-sid=ZB1234xxxxxxxxxx -``` - -### `twilio-run logs` - -Print logs from your Twilio Serverless project - -#### Examples +This project uses [`lerna`](https://npm.im/lerna) as a tool to manage the monorepo. If you are unfamiliar with the tool, start by checking out the the [lerna docs](https://lerna.js.org/). ```bash -# Gets the latest logs for the current project in the dev environment -twilio-run logs -# Continuously streams the latest logs for the current project in the dev environment -twilio-run logs --tail -# Gets the latest logs for the function sid in the production environment -twilio-run logs --function-sid ZFXXX --environment production -``` - -## API - -The module also exposes two functions that you can use outside of the CLI tool to spin up local development. - -If you want to interact with the Runtime API instead, [check out the `@twilio-labs/serverless-api` package](https://github.com/twilio-labs/serverless-api). - -### `runDevServer(port: number, baseDir: string): Promise` - -This allows you to trigger running an express server that will expose all functions and assets. Example: - -```js -const { runDevServer } = require('twilio-run'); - -runDevServer(9000) - .then(app => { - console.log(`Server is running on port ${app.get('port')})`); - }) - .catch(err => { - console.error('Something failed'); - }); +git clone git@github.com:twilio-labs/twilio-run.git serverless-toolkit +cd serverless-toolkit +npm install +npm run bootstrap ``` -### `handleToExpressRoute(handler: TwilioHandlerFunction): Express.RequestHandler` - -You can take the `handler` function of a Twilio Function file and expose it in an existing Express server. Example: - -```js -const express = require('express'); -const bodyParser = require('body-parser'); -const { handlerToExpressRoute } = require('twilio-run'); - -const { handler } = require('./path/to/function.js'); - -const app = express(); -app.use(bodyParser.urlencoded({ extended: false })); - -app.all(handlerToExpressRoute(handler)); - -app.listen(3000, () => console.log('Server running on port 3000')); -``` - -## Error Handling in Dev Server - -If your local Twilio Function throws an unhandled error or returns an `Error` instance via the `callback` method, we will return an HTTP status code of `500` and return the error object as JSON. - -By default we will clean up the stack trace for you to remove internal code of the dev server and add it as `at [Twilio Dev Server internals]` into the stack trace. - -An example would look like this: - -``` -Error: What? - at format (/Users/dkundel/dev/twilio-run/examples/basic/functions/hello.js:5:9) - at exports.handler (/Users/dkundel/dev/twilio-run/examples/basic/functions/hello.js:13:3) - at [Twilio Dev Server internals] -``` - -If you want to have the full un-modified stack trace instead, set the following environment variable, either in your Twilio Function or via `.env`: - -``` -TWILIO_SERVERLESS_FULL_ERRORS=true -``` - -This will result into a stack trace like this: - -``` -Error: What? - at format (/Users/dkundel/dev/twilio-run/examples/basic/functions/hello.js:5:9) - at exports.handler (/Users/dkundel/dev/twilio-run/examples/basic/functions/hello.js:13:3) - at twilioFunctionHandler (/Users/dkundel/dev/twilio-run/dist/runtime/route.js:125:13) - at app.all (/Users/dkundel/dev/twilio-run/dist/runtime/server.js:122:82) - at Layer.handle [as handle_request] (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/layer.js:95:5) - at next (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/route.js:137:13) - at next (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/route.js:131:14) - at next (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/route.js:131:14) - at next (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/route.js:131:14) - at next (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/route.js:131:14) -``` - -In general you'll want to use the cleaned-up stack trace since the internals might change throughout time. - - - -## Contributing - -This project welcomes contributions from the community. Please see the [`CONTRIBUTING.md`](CONTRIBUTING.md) file for more details. - -### Code of Conduct - -Please be aware that this project has a [Code of Conduct](CODE_OF_CONDUCT.md). The tldr; is to just be excellent to each other ❤️ - -## Contributors - -Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): - - - -| [Dominik Kundel
Dominik Kundel](https://dkundel.com)
[💻](https://github.com/dkundel/twilio-run/commits?author=dkundel "Code") | [dbbidclips
dbbidclips](https://github.com/dbbidclips)
[💻](https://github.com/dkundel/twilio-run/commits?author=dbbidclips "Code") [🐛](https://github.com/dkundel/twilio-run/issues?q=author%3Adbbidclips "Bug reports") | [Shelby Hagman
Shelby Hagman](https://shagman.codes)
[🐛](https://github.com/dkundel/twilio-run/issues?q=author%3AShelbyZ "Bug reports") [💻](https://github.com/dkundel/twilio-run/commits?author=ShelbyZ "Code") | [JavaScript Joe
JavaScript Joe](https://joeprevite.com/)
[🐛](https://github.com/dkundel/twilio-run/issues?q=author%3Ajsjoeio "Bug reports") | [Stefan Judis
Stefan Judis](https://www.stefanjudis.com/)
[🐛](https://github.com/dkundel/twilio-run/issues?q=author%3Astefanjudis "Bug reports") [💻](https://github.com/dkundel/twilio-run/commits?author=stefanjudis "Code") | [Phil Nash
Phil Nash](https://philna.sh)
[🐛](https://github.com/dkundel/twilio-run/issues?q=author%3Aphilnash "Bug reports") [💻](https://github.com/dkundel/twilio-run/commits?author=philnash "Code") [👀](#review-philnash "Reviewed Pull Requests") | -| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | - +## License -This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! +MIT -## License +## Disclaimer -[MIT](LICENSE) +Unofficial logo. Not a Twilio logo. diff --git a/images/squared-serverless-logo-small.png b/images/squared-serverless-logo-small.png new file mode 100644 index 00000000..2c240287 Binary files /dev/null and b/images/squared-serverless-logo-small.png differ diff --git a/jest.config.base.js b/jest.config.base.js new file mode 100644 index 00000000..f627da31 --- /dev/null +++ b/jest.config.base.js @@ -0,0 +1,182 @@ +// For a detailed explanation regarding each configuration property, visit: +// https://jestjs.io/docs/en/configuration.html + +module.exports = { + preset: "ts-jest", + + // Automatically clear mock calls and instances between every test + clearMocks: true, + + // The directory where Jest should output its coverage files + coverageDirectory: "coverage", + + // A set of global variables that need to be available in all test environments + globals: { + "ts-jest": { + tsConfig: "tsconfig.test.json" + } + }, + // The test environment that will be used for testing + testEnvironment: "node" + + // All imported modules in your tests should be mocked automatically + // automock: false, + + // Stop running tests after the first failure + // bail: false, + + // Respect "browser" field in package.json when resolving modules + // browser: false, + + // The directory where Jest should store its cached dependency information + // cacheDirectory: "/var/folders/hm/3p38c0353l3gvb3q_m69n1qh2hfrd1/T/jest_1e8c69", + + // Indicates whether the coverage information should be collected while executing the test + // collectCoverage: false, + + // An array of glob patterns indicating a set of files for which coverage information should be collected + // collectCoverageFrom: null, + + // An array of regexp pattern strings used to skip coverage collection + // coveragePathIgnorePatterns: [ + // "/node_modules/" + // ], + + // A list of reporter names that Jest uses when writing coverage reports + // coverageReporters: [ + // "json", + // "text", + // "lcov", + // "clover" + // ], + + // An object that configures minimum threshold enforcement for coverage results + // coverageThreshold: null, + + // Make calling deprecated APIs throw helpful error messages + // errorOnDeprecated: false, + + // Force coverage collection from ignored files usin a array of glob patterns + // forceCoverageMatch: [], + + // A path to a module which exports an async function that is triggered once before all test suites + // globalSetup: null, + + // A path to a module which exports an async function that is triggered once after all test suites + // globalTeardown: null, + + // An array of directory names to be searched recursively up from the requiring module's location + // moduleDirectories: [ + // "node_modules" + // ], + + // An array of file extensions your modules use + // moduleFileExtensions: [ + // "js", + // "json", + // "jsx", + // "node" + // ], + + // A map from regular expressions to module names that allow to stub out resources with a single module + // moduleNameMapper: {}, + + // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader + // modulePathIgnorePatterns: [], + + // Activates notifications for test results + // notify: false, + + // An enum that specifies notification mode. Requires { notify: true } + // notifyMode: "always", + + // Run tests from one or more projects + // projects: null, + + // Use this configuration option to add custom reporters to Jest + // reporters: undefined, + + // Automatically reset mock state between every test + // resetMocks: false, + + // Reset the module registry before running each individual test + // resetModules: false, + + // A path to a custom resolver + // resolver: null, + + // Automatically restore mock state between every test + // restoreMocks: false, + + // The root directory that Jest should scan for tests and modules within + // rootDir: null, + + // A list of paths to directories that Jest should use to search for files in + // roots: [ + // "" + // ], + + // Allows you to use a custom runner instead of Jest's default test runner + // runner: "jest-runner", + + // The paths to modules that run some code to configure or set up the testing environment before each test + // setupFiles: [], + + // The path to a module that runs some code to configure or set up the testing framework before each test + // setupTestFrameworkScriptFile: null, + + // A list of paths to snapshot serializer modules Jest should use for snapshot testing + // snapshotSerializers: [], + + // Options that will be passed to the testEnvironment + // testEnvironmentOptions: {}, + + // Adds a location field to test results + // testLocationInResults: false, + + // The glob patterns Jest uses to detect test files + // testMatch: [ + // "**/__tests__/**/*.js?(x)", + // "**/?(*.)+(spec|test).js?(x)" + // ], + + // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped + // testPathIgnorePatterns: [ + // "/node_modules/" + // ], + + // The regexp pattern Jest uses to detect test files + // testRegex: "", + + // This option allows the use of a custom results processor + // testResultsProcessor: null, + + // This option allows use of a custom test runner + // testRunner: "jasmine2", + + // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href + // testURL: "about:blank", + + // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" + // timers: "real", + + // A map from regular expressions to paths to transformers + // transform: null, + + // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation + // transformIgnorePatterns: [ + // "/node_modules/" + // ], + + // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them + // unmockedModulePathPatterns: undefined, + + // Indicates whether each individual test should be reported during the run + // verbose: null, + + // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode + // watchPathIgnorePatterns: [], + + // Whether to use watchman for file crawling + // watchman: true, +}; diff --git a/jest.config.js b/jest.config.js index d316667c..34176bc5 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,182 +1,7 @@ -// For a detailed explanation regarding each configuration property, visit: -// https://jestjs.io/docs/en/configuration.html +const base = require("./jest.config.base.js"); module.exports = { - preset: 'ts-jest', - - // Automatically clear mock calls and instances between every test - clearMocks: true, - - // The directory where Jest should output its coverage files - coverageDirectory: 'coverage', - - // A set of global variables that need to be available in all test environments - globals: { - 'ts-jest': { - tsConfig: 'tsconfig.test.json', - }, - }, - // The test environment that will be used for testing - testEnvironment: 'node', - - // All imported modules in your tests should be mocked automatically - // automock: false, - - // Stop running tests after the first failure - // bail: false, - - // Respect "browser" field in package.json when resolving modules - // browser: false, - - // The directory where Jest should store its cached dependency information - // cacheDirectory: "/var/folders/hm/3p38c0353l3gvb3q_m69n1qh2hfrd1/T/jest_1e8c69", - - // Indicates whether the coverage information should be collected while executing the test - // collectCoverage: false, - - // An array of glob patterns indicating a set of files for which coverage information should be collected - // collectCoverageFrom: null, - - // An array of regexp pattern strings used to skip coverage collection - // coveragePathIgnorePatterns: [ - // "/node_modules/" - // ], - - // A list of reporter names that Jest uses when writing coverage reports - // coverageReporters: [ - // "json", - // "text", - // "lcov", - // "clover" - // ], - - // An object that configures minimum threshold enforcement for coverage results - // coverageThreshold: null, - - // Make calling deprecated APIs throw helpful error messages - // errorOnDeprecated: false, - - // Force coverage collection from ignored files usin a array of glob patterns - // forceCoverageMatch: [], - - // A path to a module which exports an async function that is triggered once before all test suites - // globalSetup: null, - - // A path to a module which exports an async function that is triggered once after all test suites - // globalTeardown: null, - - // An array of directory names to be searched recursively up from the requiring module's location - // moduleDirectories: [ - // "node_modules" - // ], - - // An array of file extensions your modules use - // moduleFileExtensions: [ - // "js", - // "json", - // "jsx", - // "node" - // ], - - // A map from regular expressions to module names that allow to stub out resources with a single module - // moduleNameMapper: {}, - - // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader - // modulePathIgnorePatterns: [], - - // Activates notifications for test results - // notify: false, - - // An enum that specifies notification mode. Requires { notify: true } - // notifyMode: "always", - - // Run tests from one or more projects - // projects: null, - - // Use this configuration option to add custom reporters to Jest - // reporters: undefined, - - // Automatically reset mock state between every test - // resetMocks: false, - - // Reset the module registry before running each individual test - // resetModules: false, - - // A path to a custom resolver - // resolver: null, - - // Automatically restore mock state between every test - // restoreMocks: false, - - // The root directory that Jest should scan for tests and modules within - // rootDir: null, - - // A list of paths to directories that Jest should use to search for files in - // roots: [ - // "" - // ], - - // Allows you to use a custom runner instead of Jest's default test runner - // runner: "jest-runner", - - // The paths to modules that run some code to configure or set up the testing environment before each test - // setupFiles: [], - - // The path to a module that runs some code to configure or set up the testing framework before each test - // setupTestFrameworkScriptFile: null, - - // A list of paths to snapshot serializer modules Jest should use for snapshot testing - // snapshotSerializers: [], - - // Options that will be passed to the testEnvironment - // testEnvironmentOptions: {}, - - // Adds a location field to test results - // testLocationInResults: false, - - // The glob patterns Jest uses to detect test files - // testMatch: [ - // "**/__tests__/**/*.js?(x)", - // "**/?(*.)+(spec|test).js?(x)" - // ], - - // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped - // testPathIgnorePatterns: [ - // "/node_modules/" - // ], - - // The regexp pattern Jest uses to detect test files - // testRegex: "", - - // This option allows the use of a custom results processor - // testResultsProcessor: null, - - // This option allows use of a custom test runner - // testRunner: "jasmine2", - - // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href - // testURL: "about:blank", - - // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" - // timers: "real", - - // A map from regular expressions to paths to transformers - // transform: null, - - // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation - // transformIgnorePatterns: [ - // "/node_modules/" - // ], - - // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them - // unmockedModulePathPatterns: undefined, - - // Indicates whether each individual test should be reported during the run - // verbose: null, - - // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode - // watchPathIgnorePatterns: [], - - // Whether to use watchman for file crawling - // watchman: true, + ...base, + projects: ["/packages/*/jest.config.js"], + coverageDirectory: "/coverage/" }; diff --git a/lerna.json b/lerna.json new file mode 100644 index 00000000..001cebc7 --- /dev/null +++ b/lerna.json @@ -0,0 +1,16 @@ +{ + "npmClient": "npm", + "command": { + "publish": { + "message": "chore(release): publish %s" + }, + "bootstrap": { + "npmClientArgs": ["--no-package-lock"] + }, + "version": { + "allowBranch": ["master", "feature/*"] + } + }, + "packages": ["packages/*"], + "version": "independent" +} diff --git a/package.json b/package.json index 0e9e2dee..767e675a 100644 --- a/package.json +++ b/package.json @@ -1,131 +1,36 @@ { - "name": "twilio-run", - "version": "2.8.0-beta.1", - "bin": { - "twilio-functions": "./bin/twilio-run.js", - "twilio-run": "./bin/twilio-run.js" - }, - "description": "CLI tool to run Twilio Functions locally for development", - "main": "dist/index.js", - "types": "dist/index.d.ts", + "name": "@twilio-labs/serverless-toolkit", + "private": true, "scripts": { - "clean": "rimraf dist", - "build": "tsc", - "build:noemit": "tsc --noEmit", + "bootstrap": "lerna bootstrap --no-ci", + "release": "lerna version --conventional-commits", + "cm": "git-cz", "jest": "jest", + "build:noemit": "lerna run build:noemit", + "clean": "lerna run clean", "test": "run-s build:noemit jest", "contrib:add": "all-contributors add", "contrib:generate": "all-contributors generate", - "lint-staged": "lint-staged", - "prepack": "run-s clean build", - "cm": "git-cz", - "release": "HUSKY_SKIP_HOOKS=1 standard-version", - "reset-dependencies": "bash ./hooks/update-dependencies.sh" - }, - "keywords": [ - "twilio", - "twilio-functions", - "serverless" - ], - "repository": { - "type": "git", - "url": "https://github.com/twilio-labs/twilio-run.git" - }, - "bugs": { - "url": "https://github.com/twilio-labs/twilio-run/issues", - "email": "dkundel@twilio.com" - }, - "author": "Dominik Kundel ", - "license": "MIT", - "dependencies": { - "@twilio-labs/serverless-api": "^4.0.1", - "@twilio-labs/serverless-runtime-types": "^1.1.7", - "@types/express": "^4.17.0", - "@types/inquirer": "^6.0.3", - "@types/is-ci": "^2.0.0", - "@types/wrap-ansi": "^3.0.0", - "body-parser": "^1.18.3", - "boxen": "^1.3.0", - "chalk": "^2.4.2", - "chokidar": "^3.2.3", - "columnify": "^1.5.4", - "common-tags": "^1.8.0", - "conf": "^5.0.0", - "debug": "^3.1.0", - "dotenv": "^6.2.0", - "express": "^4.16.3", - "express-useragent": "^1.0.13", - "fast-redact": "^1.5.0", - "got": "^9.6.0", - "inquirer": "^6.5.0", - "is-ci": "^2.0.0", - "listr": "^0.14.3", - "lodash.camelcase": "^4.3.0", - "lodash.debounce": "^4.0.8", - "lodash.flatten": "^4.4.0", - "lodash.kebabcase": "^4.1.1", - "lodash.startcase": "^4.4.0", - "log-symbols": "^2.2.0", - "ngrok": "^3.0.1", - "nocache": "^2.1.0", - "normalize.css": "^8.0.1", - "ora": "^3.3.1", - "pkg-install": "^1.0.0", - "serialize-error": "^7.0.1", - "terminal-link": "^1.3.0", - "title": "^3.4.1", - "twilio": "^3.43.1", - "type-fest": "^0.15.1", - "window-size": "^1.1.1", - "wrap-ansi": "^5.1.0", - "yargs": "^13.2.2" + "lint-staged": "lint-staged" }, "devDependencies": { "@commitlint/cli": "^8.1.0", "@commitlint/config-conventional": "^8.0.0", - "@types/cheerio": "^0.22.12", - "@types/common-tags": "^1.8.0", - "@types/debug": "^4.1.4", - "@types/dotenv": "^6.1.1", - "@types/express-useragent": "^0.2.21", - "@types/got": "^9.6.0", "@types/jest": "^24.0.15", - "@types/listr": "^0.14.0", - "@types/lodash.debounce": "^4.0.6", - "@types/lodash.flatten": "^4.4.6", - "@types/lodash.kebabcase": "^4.1.6", - "@types/lodash.startcase": "^4.4.6", - "@types/mock-fs": "^4.10.0", - "@types/node": "^14.0.19", - "@types/prompts": "^2.0.1", - "@types/supertest": "^2.0.8", - "@types/title": "^1.0.5", - "@types/window-size": "^0.2.4", "all-contributors-cli": "^5.3.0", - "cheerio": "^1.0.0-rc.2", "commitizen": "^3.1.1", "cz-conventional-changelog": "^2.1.0", "husky": "^3.0.0", "jest": "^26.2.2", "jest-express": "^1.10.1", + "lerna": "^3.22.1", "lint-staged": "^8.2.1", - "listr-silent-renderer": "^1.1.1", - "mock-fs": "^4.12.0", - "nock": "^12.0.2", "npm-run-all": "^4.1.5", "prettier": "^1.18.2", "rimraf": "^2.6.3", - "standard-version": "^8.0.1", - "supertest": "^3.1.0", "ts-jest": "^26.0.0", - "typescript": "^3.9.2" + "typescript": "^3.9.7" }, - "files": [ - "bin/", - "dist/", - "LICENSE", - "README.md" - ], "husky": { "hooks": { "pre-commit": "run-s lint-staged test", diff --git a/.npmrc b/packages/twilio-run/.npmrc similarity index 100% rename from .npmrc rename to packages/twilio-run/.npmrc diff --git a/.prettierrc b/packages/twilio-run/.prettierrc similarity index 100% rename from .prettierrc rename to packages/twilio-run/.prettierrc diff --git a/CHANGELOG.md b/packages/twilio-run/CHANGELOG.md similarity index 98% rename from CHANGELOG.md rename to packages/twilio-run/CHANGELOG.md index 6d3c5f57..1de2068e 100644 --- a/CHANGELOG.md +++ b/packages/twilio-run/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [2.8.0](https://github.com/twilio-labs/twilio-run/compare/v2.8.0-beta.0...v2.8.0) (2020-08-07) + + +### Bug Fixes + +* **env:** catch dotenv parsing error ([c8e327b](https://github.com/twilio-labs/twilio-run/commit/c8e327b9b6bed6573726e19e18e7ee8091b98cb5)) +* upgrade type-fest from 0.6.0 to 0.15.1 ([d682b2d](https://github.com/twilio-labs/twilio-run/commit/d682b2dbd00d725578251f1efef66109fcd208f5)) + ## [2.8.0-beta.1](https://github.com/twilio-labs/twilio-run/compare/v2.7.0...v2.8.0-beta.1) (2020-07-08) diff --git a/CONTRIBUTING.md b/packages/twilio-run/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to packages/twilio-run/CONTRIBUTING.md diff --git a/packages/twilio-run/README.md b/packages/twilio-run/README.md new file mode 100644 index 00000000..eb22f7ef --- /dev/null +++ b/packages/twilio-run/README.md @@ -0,0 +1,347 @@ +

twilio-run

+

CLI tool to locally develop and deploy to the Twilio Runtime. Part of the Serverless Toolkit

+

+npm (scoped) npm GitHub All Contributors Code of Conduct PRs Welcome +Travis (.com) +


+ +- [About](#about) +- [Installation](#installation) +- [Usage](#usage) + - [Create a new project](#create-a-new-project) + - [Project conventions](#project-conventions) + - [Function templates](#function-templates) + - [Deploy a project](#deploy-a-project) +- [Commands](#commands) + - [`twilio-run start [dir]`](#twilio-run-start-dir) + - [Examples](#examples) + - [`twilio-run deploy`](#twilio-run-deploy) + - [Examples](#examples-1) + - [`twilio-run list-templates`](#twilio-run-list-templates) + - [Examples](#examples-2) + - [`twilio-run new [namespace]`](#twilio-run-new-namespace) + - [Examples](#examples-3) + - [`twilio-run list [types]`](#twilio-run-list-types) + - [Examples](#examples-4) + - [`twilio-run activate`](#twilio-run-activate) + - [Examples](#examples-5) + - [`twilio-run logs`](#twilio-run-logs) + - [Examples](#examples-6) +- [API](#api) + - [`runDevServer(port: number, baseDir: string): Promise`](#rundevserverport-number-basedir-string-promiseexpressapplication) + - [`handleToExpressRoute(handler: TwilioHandlerFunction): Express.RequestHandler`](#handletoexpressroutehandler-twiliohandlerfunction-expressrequesthandler) +- [Error Handling in Dev Server](#error-handling-in-dev-server) +- [Contributing](#contributing) + - [Code of Conduct](#code-of-conduct) +- [Contributors](#contributors) +- [License](#license) + +## About + +This project is part of the [Serverless Toolkit](https://github.com/twilio-labs/serverless-toolkit). For a more extended documentation, check out the [Twilio Docs](https://www.twilio.com/docs/labs/serverless-toolkit). + +## Installation + +You can install the CLI tool via `npm` or another package manager. Ideally install it as a dev dependency instead of global: + +```bash +# Install it as a dev dependency +npm install twilio-run --save-dev + +# Afterwards you can use by using: +node_modules/.bin/twilio-run + +npx twilio-run + +# Or inside your package.json scripts section as "twilio-run" +``` + +## Usage + +Check out the [commands](#commands) for in depth usage, but here are some things you will want to know: + +### Create a new project + +To create a new project with the Twilio Serverless Toolkit you can use [`create-twilio-function`](https://github.com/twilio-labs/create-twilio-function/) which will scaffold a new project that is ready to be used with `twilio-run`. + +```bash +# Create a valid project, for example: +npm init twilio-function my-project + +# Navigate into project +cd my-project +``` + +You can then use `twilio-run` to run a local development server to serve your functions and assets. + +```bash +npx twilio-run start +``` + +### Project conventions + +By default JavaScript Functions should be placed in the `functions` directory and assets, which can be JavaScript, images, CSS, or any static asset, should be placed in the `assets` directory. You can choose other directories by providing a `--functions-folder` or `--assets-folder` option to `twilio-run` commands. + +Twilio Functions and Assets can be public, protected or private. The differences are: + +* **Public**: Any one with the URL can visit the Function or Asset +* **Protected**: Twilio signs webhook requests, making a Twilio Function protected means that the Function will validate the webhook signature and reject any incoming requests that don't match +* **Private**: The Function or Asset doesn't a URL, it can only be required within another Function or Asset + +Within `twilio-run` you can make your Functions or Assets public, protected or private by adding to the function filename. Functions and Assets are public by default. To make a Function or Asset protected or private, add `.protected` or `.private` to the filename before the extension. For example: `functions/secret.protected.js` or `assets/hidden.private.jpg`. + +### Function templates + +There are a number of pre-written Function templates that you can add to your project. The [templates are available on GitHub](https://github.com/twilio-labs/function-templates) and you can also propose your own via pull request. + +To list the available templates you can run: + +```bash +npx twilio-run list-templates +``` + +To add a new function into your project from a template you can run: + +```bash +npx twilio-run new namespace +``` + +The command will walk you through choosing the template. + +### Deploy a project + +To deploy a project to the Twilio infrastructure you can run the command: + +```bash +npx twilio-run deploy +``` + +This will deploy your project to the "dev" environment by default. You can then promote the project from "dev" to other environments with the command: + +```bash +npx twilio-run promote --from=dev --to=stage +``` + +## Commands + +The CLI exposes a variety of commands. The best way to find out about the flags and commands available is to run `twilio-run --help` or `twilio-run [command] --help` + +### `twilio-run start [dir]` +- Aliases: `twilio-run dev`, `twilio-run` + +Starts a local development server for testing and debugging of your environment. By default only variables in the `.env` file will be available via `process.env` or through the `context` argument inside Twilio Functions. + +#### Examples + +```bash +# Serves all functions in current functions sub directory +twilio-run + +# Serves all functions in demo/functions +twilio-run demo + +# Serves functions on port 9000 +PORT=9000 twilio-run + +# Serves functions on port 4200 +twilio-run --port=4200 + +# Starts up the inspector mode for the node process +twilio-run --inspect + +# Exposes the Twilio functions via ngrok to share them +twilio-run --ngrok +``` + +### `twilio-run deploy` + +Deploys your project to Twilio. It will read dependencies automatically from your `package.json`'s `dependencies` field and install them. It will also upload and set the variables that are specified in your `.env` file. You can point it against a different `.env` file via command-line flags. + +#### Examples + +```bash +# Deploys all functions and assets in the current working directory +twilio-run deploy + +# Creates an environment with the domain suffix "prod" +twilio-run deploy --environment=prod +``` + +### `twilio-run list-templates` + +Lists the [available templates](https://github.com/twilio-labs/function-templates) that you can use to generate new functions and/or assets inside your current project with the [`twilio-run new` command](#twilio-run-new-namespace) below. + +#### Examples + +```bash +# List available templates +twilio-run list-templates +``` + +### `twilio-run new [namespace]` + +Creates a new set of functions and/or assets inside your current project based on a [template](https://github.com/twilio-labs/function-templates). + +#### Examples + +```bash +# Create a new function using the blank template +# in a subfolder (namespace) demo +twilio-run new demo --template=blank +``` + +### `twilio-run list [types]` + +Lists a set of available resources for different types related to your Account. Available resources that can be listed: +- Services +- Environments or Builds (requires to pass a Service) +- Functions, Assets or Variables (requires to pass a Service and Environment) + + +#### Examples + +```bash +# Lists all existing services/projects associated with your Twilio Account +twilio-run list services +# Lists all existing functions & assets associated with the `dev` environment of this service/project +twilio-run ls functions,assets --environment=dev --service-name=demo +# Outputs all environments for a specific service with extended output for better parsing +twilio-run ls environments --service-sid=ZSxxxxx --extended-output +# Only lists the SIDs and dates of last update for assets, variables and functions +twilio-run ls assets,variables,functions --properties=sid,date_updated +``` + +### `twilio-run activate` +- Aliases: `twilio-run promote` + +Promotes an existing deployment to a new environment. It can also create a new environment if it doesn't exist. + +#### Examples + +```bash +# Promotes the same build that is on the "dev" environment to the "prod" environment +twilio-run activate --environment=prod --source-environment=dev +# Duplicates an existing build to a new environment called `demo` +twilio-run activate --environment=demo --create-environment --build-sid=ZB1234xxxxxxxxxx +``` + +### `twilio-run logs` + +Print logs from your Twilio Serverless project + +#### Examples + +```bash +# Gets the latest logs for the current project in the dev environment +twilio-run logs +# Continuously streams the latest logs for the current project in the dev environment +twilio-run logs --tail +# Gets the latest logs for the function sid in the production environment +twilio-run logs --function-sid ZFXXX --environment production +``` + +## API + +The module also exposes two functions that you can use outside of the CLI tool to spin up local development. + +If you want to interact with the Runtime API instead, [check out the `@twilio-labs/serverless-api` package](https://github.com/twilio-labs/serverless-api). + +### `runDevServer(port: number, baseDir: string): Promise` + +This allows you to trigger running an express server that will expose all functions and assets. Example: + +```js +const { runDevServer } = require('twilio-run'); + +runDevServer(9000) + .then(app => { + console.log(`Server is running on port ${app.get('port')})`); + }) + .catch(err => { + console.error('Something failed'); + }); +``` + +### `handleToExpressRoute(handler: TwilioHandlerFunction): Express.RequestHandler` + +You can take the `handler` function of a Twilio Function file and expose it in an existing Express server. Example: + +```js +const express = require('express'); +const bodyParser = require('body-parser'); +const { handlerToExpressRoute } = require('twilio-run'); + +const { handler } = require('./path/to/function.js'); + +const app = express(); +app.use(bodyParser.urlencoded({ extended: false })); + +app.all(handlerToExpressRoute(handler)); + +app.listen(3000, () => console.log('Server running on port 3000')); +``` + +## Error Handling in Dev Server + +If your local Twilio Function throws an unhandled error or returns an `Error` instance via the `callback` method, we will return an HTTP status code of `500` and return the error object as JSON. + +By default we will clean up the stack trace for you to remove internal code of the dev server and add it as `at [Twilio Dev Server internals]` into the stack trace. + +An example would look like this: + +``` +Error: What? + at format (/Users/dkundel/dev/twilio-run/examples/basic/functions/hello.js:5:9) + at exports.handler (/Users/dkundel/dev/twilio-run/examples/basic/functions/hello.js:13:3) + at [Twilio Dev Server internals] +``` + +If you want to have the full un-modified stack trace instead, set the following environment variable, either in your Twilio Function or via `.env`: + +``` +TWILIO_SERVERLESS_FULL_ERRORS=true +``` + +This will result into a stack trace like this: + +``` +Error: What? + at format (/Users/dkundel/dev/twilio-run/examples/basic/functions/hello.js:5:9) + at exports.handler (/Users/dkundel/dev/twilio-run/examples/basic/functions/hello.js:13:3) + at twilioFunctionHandler (/Users/dkundel/dev/twilio-run/dist/runtime/route.js:125:13) + at app.all (/Users/dkundel/dev/twilio-run/dist/runtime/server.js:122:82) + at Layer.handle [as handle_request] (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/layer.js:95:5) + at next (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/route.js:137:13) + at next (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/route.js:131:14) + at next (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/route.js:131:14) + at next (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/route.js:131:14) + at next (/Users/dkundel/dev/twilio-run/node_modules/express/lib/router/route.js:131:14) +``` + +In general you'll want to use the cleaned-up stack trace since the internals might change throughout time. + + + +## Contributing + +This project welcomes contributions from the community. Please see the [`CONTRIBUTING.md`](CONTRIBUTING.md) file for more details. + +### Code of Conduct + +Please be aware that this project has a [Code of Conduct](CODE_OF_CONDUCT.md). The tldr; is to just be excellent to each other ❤️ + +## Contributors + +Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): + + + +| [Dominik Kundel
Dominik Kundel](https://dkundel.com)
[💻](https://github.com/dkundel/twilio-run/commits?author=dkundel "Code") | [dbbidclips
dbbidclips](https://github.com/dbbidclips)
[💻](https://github.com/dkundel/twilio-run/commits?author=dbbidclips "Code") [🐛](https://github.com/dkundel/twilio-run/issues?q=author%3Adbbidclips "Bug reports") | [Shelby Hagman
Shelby Hagman](https://shagman.codes)
[🐛](https://github.com/dkundel/twilio-run/issues?q=author%3AShelbyZ "Bug reports") [💻](https://github.com/dkundel/twilio-run/commits?author=ShelbyZ "Code") | [JavaScript Joe
JavaScript Joe](https://joeprevite.com/)
[🐛](https://github.com/dkundel/twilio-run/issues?q=author%3Ajsjoeio "Bug reports") | [Stefan Judis
Stefan Judis](https://www.stefanjudis.com/)
[🐛](https://github.com/dkundel/twilio-run/issues?q=author%3Astefanjudis "Bug reports") [💻](https://github.com/dkundel/twilio-run/commits?author=stefanjudis "Code") | [Phil Nash
Phil Nash](https://philna.sh)
[🐛](https://github.com/dkundel/twilio-run/issues?q=author%3Aphilnash "Bug reports") [💻](https://github.com/dkundel/twilio-run/commits?author=philnash "Code") [👀](#review-philnash "Reviewed Pull Requests") | +| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | + + +This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! + +## License + +[MIT](LICENSE) diff --git a/__mocks__/twilio.ts b/packages/twilio-run/__mocks__/twilio.ts similarity index 100% rename from __mocks__/twilio.ts rename to packages/twilio-run/__mocks__/twilio.ts diff --git a/__mocks__/window-size.ts b/packages/twilio-run/__mocks__/window-size.ts similarity index 100% rename from __mocks__/window-size.ts rename to packages/twilio-run/__mocks__/window-size.ts diff --git a/__tests__/config/list.test.ts b/packages/twilio-run/__tests__/config/list.test.ts similarity index 100% rename from __tests__/config/list.test.ts rename to packages/twilio-run/__tests__/config/list.test.ts diff --git a/__tests__/config/start.test.ts b/packages/twilio-run/__tests__/config/start.test.ts similarity index 100% rename from __tests__/config/start.test.ts rename to packages/twilio-run/__tests__/config/start.test.ts diff --git a/__tests__/config/utils.test.ts b/packages/twilio-run/__tests__/config/utils.test.ts similarity index 100% rename from __tests__/config/utils.test.ts rename to packages/twilio-run/__tests__/config/utils.test.ts diff --git a/__tests__/config/utils/credentials.test.ts b/packages/twilio-run/__tests__/config/utils/credentials.test.ts similarity index 100% rename from __tests__/config/utils/credentials.test.ts rename to packages/twilio-run/__tests__/config/utils/credentials.test.ts diff --git a/__tests__/config/utils/env.test.ts b/packages/twilio-run/__tests__/config/utils/env.test.ts similarity index 100% rename from __tests__/config/utils/env.test.ts rename to packages/twilio-run/__tests__/config/utils/env.test.ts diff --git a/__tests__/config/utils/mergeFlagsAndConfig.test.ts b/packages/twilio-run/__tests__/config/utils/mergeFlagsAndConfig.test.ts similarity index 100% rename from __tests__/config/utils/mergeFlagsAndConfig.test.ts rename to packages/twilio-run/__tests__/config/utils/mergeFlagsAndConfig.test.ts diff --git a/__tests__/config/utils/service-name.test.ts b/packages/twilio-run/__tests__/config/utils/service-name.test.ts similarity index 100% rename from __tests__/config/utils/service-name.test.ts rename to packages/twilio-run/__tests__/config/utils/service-name.test.ts diff --git a/__tests__/runtime/__snapshots__/integration.test.ts.snap b/packages/twilio-run/__tests__/runtime/__snapshots__/integration.test.ts.snap similarity index 100% rename from __tests__/runtime/__snapshots__/integration.test.ts.snap rename to packages/twilio-run/__tests__/runtime/__snapshots__/integration.test.ts.snap diff --git a/__tests__/runtime/integration.test.ts b/packages/twilio-run/__tests__/runtime/integration.test.ts similarity index 100% rename from __tests__/runtime/integration.test.ts rename to packages/twilio-run/__tests__/runtime/integration.test.ts diff --git a/__tests__/runtime/internal/response.test.ts b/packages/twilio-run/__tests__/runtime/internal/response.test.ts similarity index 100% rename from __tests__/runtime/internal/response.test.ts rename to packages/twilio-run/__tests__/runtime/internal/response.test.ts diff --git a/__tests__/runtime/internal/runtime-paths.test.ts b/packages/twilio-run/__tests__/runtime/internal/runtime-paths.test.ts similarity index 100% rename from __tests__/runtime/internal/runtime-paths.test.ts rename to packages/twilio-run/__tests__/runtime/internal/runtime-paths.test.ts diff --git a/__tests__/runtime/route.test.ts b/packages/twilio-run/__tests__/runtime/route.test.ts similarity index 100% rename from __tests__/runtime/route.test.ts rename to packages/twilio-run/__tests__/runtime/route.test.ts diff --git a/__tests__/templating/data.test.ts b/packages/twilio-run/__tests__/templating/data.test.ts similarity index 100% rename from __tests__/templating/data.test.ts rename to packages/twilio-run/__tests__/templating/data.test.ts diff --git a/__tests__/templating/filesystem.test.ts b/packages/twilio-run/__tests__/templating/filesystem.test.ts similarity index 100% rename from __tests__/templating/filesystem.test.ts rename to packages/twilio-run/__tests__/templating/filesystem.test.ts diff --git a/__tests__/utils/debug.test.ts b/packages/twilio-run/__tests__/utils/debug.test.ts similarity index 100% rename from __tests__/utils/debug.test.ts rename to packages/twilio-run/__tests__/utils/debug.test.ts diff --git a/__tests__/utils/stack-trace/clean-up.test.ts b/packages/twilio-run/__tests__/utils/stack-trace/clean-up.test.ts similarity index 100% rename from __tests__/utils/stack-trace/clean-up.test.ts rename to packages/twilio-run/__tests__/utils/stack-trace/clean-up.test.ts diff --git a/__tests__/utils/stack-trace/helpers.test.ts b/packages/twilio-run/__tests__/utils/stack-trace/helpers.test.ts similarity index 100% rename from __tests__/utils/stack-trace/helpers.test.ts rename to packages/twilio-run/__tests__/utils/stack-trace/helpers.test.ts diff --git a/bin/twilio-run.js b/packages/twilio-run/bin/twilio-run.js similarity index 100% rename from bin/twilio-run.js rename to packages/twilio-run/bin/twilio-run.js diff --git a/examples/basic/assets/something.txt b/packages/twilio-run/examples/basic/assets/something.txt similarity index 100% rename from examples/basic/assets/something.txt rename to packages/twilio-run/examples/basic/assets/something.txt diff --git a/examples/basic/functions/error.js b/packages/twilio-run/examples/basic/functions/error.js similarity index 100% rename from examples/basic/functions/error.js rename to packages/twilio-run/examples/basic/functions/error.js diff --git a/examples/basic/functions/hello.js b/packages/twilio-run/examples/basic/functions/hello.js similarity index 100% rename from examples/basic/functions/hello.js rename to packages/twilio-run/examples/basic/functions/hello.js diff --git a/examples/only-assets/assets/something.txt b/packages/twilio-run/examples/only-assets/assets/something.txt similarity index 100% rename from examples/only-assets/assets/something.txt rename to packages/twilio-run/examples/only-assets/assets/something.txt diff --git a/examples/only-functions/functions/hello.js b/packages/twilio-run/examples/only-functions/functions/hello.js similarity index 100% rename from examples/only-functions/functions/hello.js rename to packages/twilio-run/examples/only-functions/functions/hello.js diff --git a/fixtures/assets/hello.js b/packages/twilio-run/fixtures/assets/hello.js similarity index 100% rename from fixtures/assets/hello.js rename to packages/twilio-run/fixtures/assets/hello.js diff --git a/fixtures/functions/basic-error.js b/packages/twilio-run/fixtures/functions/basic-error.js similarity index 100% rename from fixtures/functions/basic-error.js rename to packages/twilio-run/fixtures/functions/basic-error.js diff --git a/fixtures/functions/basic-twiml.js b/packages/twilio-run/fixtures/functions/basic-twiml.js similarity index 100% rename from fixtures/functions/basic-twiml.js rename to packages/twilio-run/fixtures/functions/basic-twiml.js diff --git a/hooks/update-dependencies.sh b/packages/twilio-run/hooks/update-dependencies.sh similarity index 100% rename from hooks/update-dependencies.sh rename to packages/twilio-run/hooks/update-dependencies.sh diff --git a/packages/twilio-run/jest.config.js b/packages/twilio-run/jest.config.js new file mode 100644 index 00000000..7daeab26 --- /dev/null +++ b/packages/twilio-run/jest.config.js @@ -0,0 +1,12 @@ +const base = require('../../jest.config.base.js'); + +module.exports = { + ...base, + globals: { + 'ts-jest': { + tsConfig: './tsconfig.test.json', + }, + }, + name: 'twilio-run', + displayName: 'twilio-run', +}; diff --git a/packages/twilio-run/package.json b/packages/twilio-run/package.json new file mode 100644 index 00000000..483bc319 --- /dev/null +++ b/packages/twilio-run/package.json @@ -0,0 +1,107 @@ +{ + "name": "twilio-run", + "version": "2.8.0", + "bin": { + "twilio-functions": "./bin/twilio-run.js", + "twilio-run": "./bin/twilio-run.js" + }, + "description": "CLI tool to run Twilio Functions locally for development", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "scripts": { + "clean": "rimraf dist", + "build": "tsc", + "build:noemit": "tsc --noEmit", + "prepack": "run-s clean build" + }, + "keywords": [ + "twilio", + "twilio-functions", + "serverless" + ], + "repository": { + "type": "git", + "url": "https://github.com/twilio-labs/twilio-run.git" + }, + "bugs": { + "url": "https://github.com/twilio-labs/twilio-run/issues", + "email": "dkundel@twilio.com" + }, + "author": "Dominik Kundel ", + "license": "MIT", + "dependencies": { + "@twilio-labs/serverless-api": "^4.0.1", + "@twilio-labs/serverless-runtime-types": "^1.1.7", + "@types/express": "^4.17.0", + "@types/inquirer": "^6.0.3", + "@types/is-ci": "^2.0.0", + "@types/wrap-ansi": "^3.0.0", + "body-parser": "^1.18.3", + "boxen": "^1.3.0", + "chalk": "^2.4.2", + "chokidar": "^3.2.3", + "columnify": "^1.5.4", + "common-tags": "^1.8.0", + "conf": "^5.0.0", + "debug": "^3.1.0", + "dotenv": "^6.2.0", + "express": "^4.16.3", + "express-useragent": "^1.0.13", + "fast-redact": "^1.5.0", + "got": "^9.6.0", + "inquirer": "^6.5.0", + "is-ci": "^2.0.0", + "listr": "^0.14.3", + "lodash.camelcase": "^4.3.0", + "lodash.debounce": "^4.0.8", + "lodash.flatten": "^4.4.0", + "lodash.kebabcase": "^4.1.1", + "lodash.startcase": "^4.4.0", + "log-symbols": "^2.2.0", + "ngrok": "^3.0.1", + "nocache": "^2.1.0", + "normalize.css": "^8.0.1", + "ora": "^3.3.1", + "pkg-install": "^1.0.0", + "serialize-error": "^7.0.1", + "terminal-link": "^1.3.0", + "title": "^3.4.1", + "twilio": "^3.43.1", + "type-fest": "^0.15.1", + "window-size": "^1.1.1", + "wrap-ansi": "^5.1.0", + "yargs": "^13.2.2" + }, + "devDependencies": { + "@types/cheerio": "^0.22.12", + "@types/common-tags": "^1.8.0", + "@types/debug": "^4.1.4", + "@types/dotenv": "^6.1.1", + "@types/express-useragent": "^0.2.21", + "@types/got": "^9.6.0", + "@types/jest": "^24.0.15", + "@types/listr": "^0.14.0", + "@types/lodash.debounce": "^4.0.6", + "@types/lodash.flatten": "^4.4.6", + "@types/lodash.kebabcase": "^4.1.6", + "@types/lodash.startcase": "^4.4.6", + "@types/mock-fs": "^4.10.0", + "@types/node": "^14.0.19", + "@types/prompts": "^2.0.1", + "@types/supertest": "^2.0.8", + "@types/title": "^1.0.5", + "@types/window-size": "^0.2.4", + "cheerio": "^1.0.0-rc.2", + "listr-silent-renderer": "^1.1.1", + "mock-fs": "^4.12.0", + "nock": "^12.0.2", + "supertest": "^3.1.0", + "typescript": "^3.9.2" + }, + "files": [ + "bin/", + "dist/", + "LICENSE", + "README.md" + ] +} diff --git a/src/checks/check-account-sid.ts b/packages/twilio-run/src/checks/check-account-sid.ts similarity index 100% rename from src/checks/check-account-sid.ts rename to packages/twilio-run/src/checks/check-account-sid.ts diff --git a/src/checks/check-credentials.ts b/packages/twilio-run/src/checks/check-credentials.ts similarity index 100% rename from src/checks/check-credentials.ts rename to packages/twilio-run/src/checks/check-credentials.ts diff --git a/src/checks/check-service-sid.ts b/packages/twilio-run/src/checks/check-service-sid.ts similarity index 100% rename from src/checks/check-service-sid.ts rename to packages/twilio-run/src/checks/check-service-sid.ts diff --git a/src/checks/nodejs-version.ts b/packages/twilio-run/src/checks/nodejs-version.ts similarity index 100% rename from src/checks/nodejs-version.ts rename to packages/twilio-run/src/checks/nodejs-version.ts diff --git a/src/checks/project-structure.ts b/packages/twilio-run/src/checks/project-structure.ts similarity index 100% rename from src/checks/project-structure.ts rename to packages/twilio-run/src/checks/project-structure.ts diff --git a/src/cli.ts b/packages/twilio-run/src/cli.ts similarity index 100% rename from src/cli.ts rename to packages/twilio-run/src/cli.ts diff --git a/src/commands/activate.ts b/packages/twilio-run/src/commands/activate.ts similarity index 100% rename from src/commands/activate.ts rename to packages/twilio-run/src/commands/activate.ts diff --git a/src/commands/deploy.ts b/packages/twilio-run/src/commands/deploy.ts similarity index 100% rename from src/commands/deploy.ts rename to packages/twilio-run/src/commands/deploy.ts diff --git a/src/commands/list-templates.ts b/packages/twilio-run/src/commands/list-templates.ts similarity index 100% rename from src/commands/list-templates.ts rename to packages/twilio-run/src/commands/list-templates.ts diff --git a/src/commands/list.ts b/packages/twilio-run/src/commands/list.ts similarity index 100% rename from src/commands/list.ts rename to packages/twilio-run/src/commands/list.ts diff --git a/src/commands/logs.ts b/packages/twilio-run/src/commands/logs.ts similarity index 100% rename from src/commands/logs.ts rename to packages/twilio-run/src/commands/logs.ts diff --git a/src/commands/new.ts b/packages/twilio-run/src/commands/new.ts similarity index 100% rename from src/commands/new.ts rename to packages/twilio-run/src/commands/new.ts diff --git a/src/commands/shared.ts b/packages/twilio-run/src/commands/shared.ts similarity index 100% rename from src/commands/shared.ts rename to packages/twilio-run/src/commands/shared.ts diff --git a/src/commands/start.ts b/packages/twilio-run/src/commands/start.ts similarity index 100% rename from src/commands/start.ts rename to packages/twilio-run/src/commands/start.ts diff --git a/src/commands/types.ts b/packages/twilio-run/src/commands/types.ts similarity index 100% rename from src/commands/types.ts rename to packages/twilio-run/src/commands/types.ts diff --git a/src/commands/utils.ts b/packages/twilio-run/src/commands/utils.ts similarity index 100% rename from src/commands/utils.ts rename to packages/twilio-run/src/commands/utils.ts diff --git a/src/config/__mocks__/global.ts b/packages/twilio-run/src/config/__mocks__/global.ts similarity index 100% rename from src/config/__mocks__/global.ts rename to packages/twilio-run/src/config/__mocks__/global.ts diff --git a/src/config/__mocks__/utils.ts b/packages/twilio-run/src/config/__mocks__/utils.ts similarity index 100% rename from src/config/__mocks__/utils.ts rename to packages/twilio-run/src/config/__mocks__/utils.ts diff --git a/src/config/activate.ts b/packages/twilio-run/src/config/activate.ts similarity index 100% rename from src/config/activate.ts rename to packages/twilio-run/src/config/activate.ts diff --git a/src/config/deploy.ts b/packages/twilio-run/src/config/deploy.ts similarity index 100% rename from src/config/deploy.ts rename to packages/twilio-run/src/config/deploy.ts diff --git a/src/config/global.ts b/packages/twilio-run/src/config/global.ts similarity index 100% rename from src/config/global.ts rename to packages/twilio-run/src/config/global.ts diff --git a/src/config/list.ts b/packages/twilio-run/src/config/list.ts similarity index 100% rename from src/config/list.ts rename to packages/twilio-run/src/config/list.ts diff --git a/src/config/logs.ts b/packages/twilio-run/src/config/logs.ts similarity index 100% rename from src/config/logs.ts rename to packages/twilio-run/src/config/logs.ts diff --git a/src/config/start.ts b/packages/twilio-run/src/config/start.ts similarity index 100% rename from src/config/start.ts rename to packages/twilio-run/src/config/start.ts diff --git a/src/config/utils.ts b/packages/twilio-run/src/config/utils.ts similarity index 100% rename from src/config/utils.ts rename to packages/twilio-run/src/config/utils.ts diff --git a/src/config/utils/__mocks__/env.ts b/packages/twilio-run/src/config/utils/__mocks__/env.ts similarity index 100% rename from src/config/utils/__mocks__/env.ts rename to packages/twilio-run/src/config/utils/__mocks__/env.ts diff --git a/src/config/utils/__mocks__/mergeFlagsAndConfig.ts b/packages/twilio-run/src/config/utils/__mocks__/mergeFlagsAndConfig.ts similarity index 100% rename from src/config/utils/__mocks__/mergeFlagsAndConfig.ts rename to packages/twilio-run/src/config/utils/__mocks__/mergeFlagsAndConfig.ts diff --git a/src/config/utils/__mocks__/package-json.ts b/packages/twilio-run/src/config/utils/__mocks__/package-json.ts similarity index 100% rename from src/config/utils/__mocks__/package-json.ts rename to packages/twilio-run/src/config/utils/__mocks__/package-json.ts diff --git a/src/config/utils/credentials.ts b/packages/twilio-run/src/config/utils/credentials.ts similarity index 100% rename from src/config/utils/credentials.ts rename to packages/twilio-run/src/config/utils/credentials.ts diff --git a/src/config/utils/env.ts b/packages/twilio-run/src/config/utils/env.ts similarity index 100% rename from src/config/utils/env.ts rename to packages/twilio-run/src/config/utils/env.ts diff --git a/src/config/utils/mergeFlagsAndConfig.ts b/packages/twilio-run/src/config/utils/mergeFlagsAndConfig.ts similarity index 100% rename from src/config/utils/mergeFlagsAndConfig.ts rename to packages/twilio-run/src/config/utils/mergeFlagsAndConfig.ts diff --git a/src/config/utils/package-json.ts b/packages/twilio-run/src/config/utils/package-json.ts similarity index 100% rename from src/config/utils/package-json.ts rename to packages/twilio-run/src/config/utils/package-json.ts diff --git a/src/config/utils/service-name.ts b/packages/twilio-run/src/config/utils/service-name.ts similarity index 100% rename from src/config/utils/service-name.ts rename to packages/twilio-run/src/config/utils/service-name.ts diff --git a/src/index.ts b/packages/twilio-run/src/index.ts similarity index 100% rename from src/index.ts rename to packages/twilio-run/src/index.ts diff --git a/src/printers/activate.ts b/packages/twilio-run/src/printers/activate.ts similarity index 100% rename from src/printers/activate.ts rename to packages/twilio-run/src/printers/activate.ts diff --git a/src/printers/deploy.ts b/packages/twilio-run/src/printers/deploy.ts similarity index 100% rename from src/printers/deploy.ts rename to packages/twilio-run/src/printers/deploy.ts diff --git a/src/printers/list.ts b/packages/twilio-run/src/printers/list.ts similarity index 100% rename from src/printers/list.ts rename to packages/twilio-run/src/printers/list.ts diff --git a/src/printers/logs.ts b/packages/twilio-run/src/printers/logs.ts similarity index 100% rename from src/printers/logs.ts rename to packages/twilio-run/src/printers/logs.ts diff --git a/src/printers/new.ts b/packages/twilio-run/src/printers/new.ts similarity index 100% rename from src/printers/new.ts rename to packages/twilio-run/src/printers/new.ts diff --git a/src/printers/start.ts b/packages/twilio-run/src/printers/start.ts similarity index 100% rename from src/printers/start.ts rename to packages/twilio-run/src/printers/start.ts diff --git a/src/printers/utils.ts b/packages/twilio-run/src/printers/utils.ts similarity index 100% rename from src/printers/utils.ts rename to packages/twilio-run/src/printers/utils.ts diff --git a/src/runtime/internal/functionRunner.ts b/packages/twilio-run/src/runtime/internal/functionRunner.ts similarity index 100% rename from src/runtime/internal/functionRunner.ts rename to packages/twilio-run/src/runtime/internal/functionRunner.ts diff --git a/src/runtime/internal/request-logger.ts b/packages/twilio-run/src/runtime/internal/request-logger.ts similarity index 100% rename from src/runtime/internal/request-logger.ts rename to packages/twilio-run/src/runtime/internal/request-logger.ts diff --git a/src/runtime/internal/response.ts b/packages/twilio-run/src/runtime/internal/response.ts similarity index 100% rename from src/runtime/internal/response.ts rename to packages/twilio-run/src/runtime/internal/response.ts diff --git a/src/runtime/internal/route-cache.ts b/packages/twilio-run/src/runtime/internal/route-cache.ts similarity index 100% rename from src/runtime/internal/route-cache.ts rename to packages/twilio-run/src/runtime/internal/route-cache.ts diff --git a/src/runtime/internal/runtime-paths.ts b/packages/twilio-run/src/runtime/internal/runtime-paths.ts similarity index 100% rename from src/runtime/internal/runtime-paths.ts rename to packages/twilio-run/src/runtime/internal/runtime-paths.ts diff --git a/src/runtime/internal/runtime.ts b/packages/twilio-run/src/runtime/internal/runtime.ts similarity index 100% rename from src/runtime/internal/runtime.ts rename to packages/twilio-run/src/runtime/internal/runtime.ts diff --git a/src/runtime/route.ts b/packages/twilio-run/src/runtime/route.ts similarity index 100% rename from src/runtime/route.ts rename to packages/twilio-run/src/runtime/route.ts diff --git a/src/runtime/server.ts b/packages/twilio-run/src/runtime/server.ts similarity index 100% rename from src/runtime/server.ts rename to packages/twilio-run/src/runtime/server.ts diff --git a/src/runtime/utils/inspector.ts b/packages/twilio-run/src/runtime/utils/inspector.ts similarity index 100% rename from src/runtime/utils/inspector.ts rename to packages/twilio-run/src/runtime/utils/inspector.ts diff --git a/src/serverless-api/utils.ts b/packages/twilio-run/src/serverless-api/utils.ts similarity index 100% rename from src/serverless-api/utils.ts rename to packages/twilio-run/src/serverless-api/utils.ts diff --git a/src/templating/actions.ts b/packages/twilio-run/src/templating/actions.ts similarity index 100% rename from src/templating/actions.ts rename to packages/twilio-run/src/templating/actions.ts diff --git a/src/templating/data.ts b/packages/twilio-run/src/templating/data.ts similarity index 100% rename from src/templating/data.ts rename to packages/twilio-run/src/templating/data.ts diff --git a/src/templating/filesystem.ts b/packages/twilio-run/src/templating/filesystem.ts similarity index 100% rename from src/templating/filesystem.ts rename to packages/twilio-run/src/templating/filesystem.ts diff --git a/src/types.d.ts b/packages/twilio-run/src/types.d.ts similarity index 100% rename from src/types.d.ts rename to packages/twilio-run/src/types.d.ts diff --git a/src/types/generic.ts b/packages/twilio-run/src/types/generic.ts similarity index 100% rename from src/types/generic.ts rename to packages/twilio-run/src/types/generic.ts diff --git a/src/utils/debug.ts b/packages/twilio-run/src/utils/debug.ts similarity index 100% rename from src/utils/debug.ts rename to packages/twilio-run/src/utils/debug.ts diff --git a/src/utils/error-html.ts b/packages/twilio-run/src/utils/error-html.ts similarity index 100% rename from src/utils/error-html.ts rename to packages/twilio-run/src/utils/error-html.ts diff --git a/src/utils/fs.ts b/packages/twilio-run/src/utils/fs.ts similarity index 100% rename from src/utils/fs.ts rename to packages/twilio-run/src/utils/fs.ts diff --git a/src/utils/logger.ts b/packages/twilio-run/src/utils/logger.ts similarity index 100% rename from src/utils/logger.ts rename to packages/twilio-run/src/utils/logger.ts diff --git a/src/utils/output.ts b/packages/twilio-run/src/utils/output.ts similarity index 100% rename from src/utils/output.ts rename to packages/twilio-run/src/utils/output.ts diff --git a/src/utils/stack-trace/clean-up.ts b/packages/twilio-run/src/utils/stack-trace/clean-up.ts similarity index 100% rename from src/utils/stack-trace/clean-up.ts rename to packages/twilio-run/src/utils/stack-trace/clean-up.ts diff --git a/src/utils/stack-trace/helpers.ts b/packages/twilio-run/src/utils/stack-trace/helpers.ts similarity index 100% rename from src/utils/stack-trace/helpers.ts rename to packages/twilio-run/src/utils/stack-trace/helpers.ts diff --git a/tsconfig.json b/packages/twilio-run/tsconfig.json similarity index 83% rename from tsconfig.json rename to packages/twilio-run/tsconfig.json index 5b2ecd36..aaa06045 100644 --- a/tsconfig.json +++ b/packages/twilio-run/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig.base.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { "declaration": true, "outDir": "./dist" /* Redirect output structure to the directory. */, diff --git a/packages/twilio-run/tsconfig.test.json b/packages/twilio-run/tsconfig.test.json new file mode 100644 index 00000000..8dabc9e8 --- /dev/null +++ b/packages/twilio-run/tsconfig.test.json @@ -0,0 +1,6 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "incremental": true + } +}