Skip to content

Commit

Permalink
Fix broken build.
Browse files Browse the repository at this point in the history
Finally got back around to this project and fixed the broken build. This shoud fix #26 #25.
  • Loading branch information
josephschmitt committed May 27, 2017
1 parent 8eeb0ae commit bb4704a
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 39 deletions.
12 changes: 10 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"presets": ["es2015"],
"plugins": ["transform-runtime"]
"presets": [
[
"env",
{
"targets": {
"node": "6.10"
}
}
]
]
}
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
deploy.env
lambda.zip
node_modules/
.DS_Store
.env
deploy.env
alexa-couchpotato.zip
dist/
node_modules/
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
18 changes: 7 additions & 11 deletions default.env
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions event.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"movieName": {
"name": "movieName",
"value": "the godfather"
},
"releaseDate": {
"name": "releaseDate"
}
}
}
Expand Down
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
6 changes: 4 additions & 2 deletions src/lib/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test_events/couch_potato_add_movie.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"movieName": {
"name": "movieName",
"value": "the godfather"
},
"releaseDate": {
"name": "releaseDate"
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions test_events/couch_potato_find_movie.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"movieName": {
"name": "movieName",
"value": "the godfather"
},
"releaseDate": {
"name": "releaseDate",
"value": "1972"
}
}
}
Expand Down

0 comments on commit bb4704a

Please sign in to comment.