From bb4704a7f59abafab0289bd5c2b77d7f58abe69b Mon Sep 17 00:00:00 2001 From: Joseph Schmitt Date: Fri, 26 May 2017 19:50:33 -0400 Subject: [PATCH] Fix broken build. Finally got back around to this project and fixed the broken build. This shoud fix #26 #25. --- .babelrc | 12 +++++++++-- .gitignore | 7 ++++--- README.md | 20 ++++++++++-------- default.env | 18 +++++++--------- event.json | 3 +++ package.json | 26 +++++++++++++----------- src/lib/handlers.js | 6 ++++-- test_events/couch_potato_add_movie.json | 3 +++ test_events/couch_potato_find_movie.json | 4 ++++ 9 files changed, 60 insertions(+), 39 deletions(-) diff --git a/.babelrc b/.babelrc index 3ca1979..cf0818c 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,12 @@ { - "presets": ["es2015"], - "plugins": ["transform-runtime"] + "presets": [ + [ + "env", + { + "targets": { + "node": "6.10" + } + } + ] + ] } diff --git a/.gitignore b/.gitignore index 9607674..24384d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -deploy.env -lambda.zip -node_modules/ +.DS_Store .env +deploy.env +alexa-couchpotato.zip dist/ +node_modules/ diff --git a/README.md b/README.md index c4502eb..2a434e9 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,17 @@ Function](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/d ## Configuring The Skill -To configure the skill, copy `default.env` to `.env` and fill in the correct values for `CP_URL`, which -should point to your Couch Potato server, and `CP_API_KEY` which should have your server's API key. +To configure the skill, copy `default.env` to `.env` and fill in the correct values for `CP_URL`, +which should point to your Couch Potato server, and `CP_API_KEY` which should have your server's +API key. ## Testing The Skill Locally You can use [node-lambda](https://github.com/motdotla/node-lambda) to test this skill locally. In the `test_events` directory are several event files you can use for testing, and they should map -pretty well to each Intent. To test an intent, simply copy the contents of one of the json files in -that directory and overwrite the contents of `event.json`. Make sure you run `npm install` from the -command line to get the the latest npm packages, and then run `npm run test-lambda`. +pretty well to each Intent. To test an intent, simply update the `EVENT_FILE` value in your `.env` +config file to point to the event to test against. Make sure you run `npm install` from the command +line to get the the latest npm packages, and then run `npm run test-lambda`. ## Setting up the Skill @@ -46,11 +47,12 @@ you've created your Lambda function, look at the top right of the page to get yo number and put that in the Alexa Skill Information Endpoint field. To deploy to Lambda, first makes sure you do an `npm install` at the root of the project. -Once all the dependencies are installed, run `npm run bundle`, which will create a lambda.zip file. -You can then upload that zip file to Lambda for use in your function and skill. +Once all the dependencies are installed, run `npm run package`, which will create a an +`alexa-couchpotato.zip` file in your project directory. You can then upload that zip file to Lambda +for use in your function and skill. You can also use [node-lambda](https://github.com/motdotla/node-lambda) to deploy to your Lambda function directly from the command line. Simply add a deploy.env file with your environment -configuration (and double check the supplied .env file in this repository) and then run -`node-lambda deploy`. Please visit the [node-lambda](https://github.com/motdotla/node-lambda) +configuration (and double check the supplied `.env file` in this repository) and then run +`npm run deploy`. Please visit the [node-lambda](https://github.com/motdotla/node-lambda) project page for more information on deploying from the command line. diff --git a/default.env b/default.env index b41551a..33730f8 100644 --- a/default.env +++ b/default.env @@ -1,12 +1,8 @@ -AWS_ENVIRONMENT= -AWS_SESSION_TOKEN= -AWS_REGION=us-east-1 -AWS_FUNCTION_NAME=couchpotato -AWS_HANDLER=index.handler -AWS_MODE=event -AWS_MEMORY_SIZE=128 -AWS_TIMEOUT=10 -AWS_DESCRIPTION= -AWS_RUNTIME=nodejs4.3 -CP_URL=http://url-to-couch-potato-server +AWS_HANDLER=dist/index.handler +AWS_RUNTIME=nodejs6.10 +EVENT_FILE=test_events/couch_potato_find_movie.json +PREBUILT_DIRECTORY=dist +SRC_DIRECTORY=src + +CP_URL=http://url-to-couch-potato-server:PORT CP_API_KEY=APIKEY diff --git a/event.json b/event.json index 836a206..b7ae2bb 100644 --- a/event.json +++ b/event.json @@ -19,6 +19,9 @@ "movieName": { "name": "movieName", "value": "the godfather" + }, + "releaseDate": { + "name": "releaseDate" } } } diff --git a/package.json b/package.json index 9dbed58..7fff007 100644 --- a/package.json +++ b/package.json @@ -1,27 +1,29 @@ { "name": "alexa-couchpotato", - "version": "1.1.1", + "version": "1.2.0", "description": "A skill to ask Alexa about your Couch Potato queue.", - "main": "src/index.js", + "main": "dist/index.js", "scripts": { "build": "babel src -d dist", - "zip": "cp -r {.env,deploy.env,package.json} dist/; cd dist; npm install --production; bestzip ../lambda.zip * .env;", - "bundle": "npm run build; npm run zip;", - "test-lambda": "npm run build; node-lambda run --handler dist/index.handler" + "deploy": "npm run build; node-lambda deploy", + "package": "npm run build; node-lambda package --packageDirectory=./", + "postinstall": "npm run build", + "test-lambda": "npm run build; node-lambda run" }, "author": "Joe Schmitt", "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/josephschmitt/alexa-couchpotato.git" + }, "dependencies": { - "alexa-app": "^2.3.2", + "alexa-app": "^4.0.1", "dotenv": "^2.0.0", "node-couchpotato": "^0.1.4" }, "devDependencies": { - "babel-cli": "^6.7.5", - "babel-core": "^6.7.6", - "babel-plugin-transform-runtime": "^6.7.5", - "babel-preset-es2015": "^6.6.0", - "bestzip": "^1.1.3", - "node-lambda": "^0.8.11" + "babel-cli": "^6.24.1", + "babel-preset-env": "^1.5.1", + "node-lambda": "^0.8.15" } } diff --git a/src/lib/handlers.js b/src/lib/handlers.js index 89e484c..b91cb14 100644 --- a/src/lib/handlers.js +++ b/src/lib/handlers.js @@ -61,8 +61,10 @@ export function handleFindMovieIntent(req, resp) { export function handleAddMovieIntent(req, resp) { cp.movie.search(buildMovieQuery(req), NUM_RESULTS).then(function (movies) { - movies = formatSearchResults(movies); - sendSearchResponse(movies, movieName, resp); + const formattedResults = formatSearchResults(movies); + const movieName = req.slot('movieName'); + + sendSearchResponse(formattedResults, movieName, resp); }); //Async response diff --git a/test_events/couch_potato_add_movie.json b/test_events/couch_potato_add_movie.json index dc12913..4f01351 100644 --- a/test_events/couch_potato_add_movie.json +++ b/test_events/couch_potato_add_movie.json @@ -19,6 +19,9 @@ "movieName": { "name": "movieName", "value": "the godfather" + }, + "releaseDate": { + "name": "releaseDate" } } } diff --git a/test_events/couch_potato_find_movie.json b/test_events/couch_potato_find_movie.json index 836a206..3588cd1 100644 --- a/test_events/couch_potato_find_movie.json +++ b/test_events/couch_potato_find_movie.json @@ -19,6 +19,10 @@ "movieName": { "name": "movieName", "value": "the godfather" + }, + "releaseDate": { + "name": "releaseDate", + "value": "1972" } } }