Skip to content
This repository was archived by the owner on Sep 8, 2021. It is now read-only.

Commit 50c1301

Browse files
author
test
committed
false
1 parent 83dd8d1 commit 50c1301

File tree

16 files changed

+8922
-1799
lines changed

16 files changed

+8922
-1799
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ Sets up [netlify-lambda](https://github.com/netlify/netlify-lambda) for vue-cli
1010
vue add netlify-lambda
1111
```
1212

13-
_Note, until [this PR](https://github.com/vuejs/vue-cli/pull/1038/files) gets merged into vue-cli, this will also modify binaries in the project in a way that breaks their encoding, so only commit the relevant files_
14-
1513
## Usage
1614

1715
This ads a `netlify.toml` and a `src/lambda` folder with an example `hello.js` lambda function.
@@ -21,4 +19,3 @@ Any js file added in `src/lambda` will be built as a lambda. It will be compiled
2119
When deployed to Netlify, the AWS lambda's are reachable under `/.netlify/functions/:name` - ie, the `hello.js` Lambda will be available under `/.netlify/functions/hello`.
2220

2321
The plugin also sets up a proxy and runs the Lambdas locally, to simplify local development.
24-

__tests__/lambdaTest.spec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
jest.setTimeout(90000);
2+
3+
const create = require("@vue/cli-test-utils/createTestProject");
4+
const path = require("path");
5+
const cwd = path.resolve(__dirname, "../testProject");
6+
const rimraf = require("rimraf");
7+
8+
beforeAll(async () => {
9+
rimraf(path.resolve(cwd, "example-netlify-lambda-project"), () => {});
10+
});
11+
12+
test("should create vuex modules", async () => {
13+
const project = await create(
14+
"example-netlify-lambda-project",
15+
{
16+
plugins: {
17+
"@vue/cli-plugin-babel": {}
18+
}
19+
},
20+
cwd
21+
);
22+
await project.run(
23+
`${require.resolve(
24+
"@vue/cli/bin/vue"
25+
)} add vue-cli-plugin-netlify-lambda@file:../../`
26+
);
27+
await project.run(
28+
`${require.resolve(
29+
"@vue/cli/bin/vue"
30+
)} invoke vue-cli-plugin-netlify-lambda`
31+
);
32+
expect(await project.has("src/lambda/hello.js")).toBe(true);
33+
});

package.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,27 @@
44
"description": "Vue Cli plugin for adding Netlify Lambda",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "jest"
8+
},
9+
"jest": {
10+
"testEnvironment": "node",
11+
"setupFiles": [
12+
"<rootDir>/scripts/testSetup.js"
13+
],
14+
"testPathIgnorePatterns": [
15+
"./generator/template/",
16+
"./generator/generator.js"
17+
]
818
},
919
"author": "Netlify",
1020
"license": "MIT",
1121
"dependencies": {
12-
"netlify-lambda": "1.0.0-babel-7-beta"
22+
"@vue/cli": "^3.0.1",
23+
"@vue/cli-plugin-babel": "^3.0.1",
24+
"@vue/cli-service": "^3.0.1",
25+
"@vue/cli-test-utils": "^3.0.1",
26+
"jest": "^23.5.0",
27+
"netlify-lambda": "1.0.0-babel-7-beta",
28+
"rimraf": "^2.6.2"
1329
}
1430
}

scripts/testSetup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
process.env.VUE_CLI_TEST = true;

testProject/.gitkeep

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
# local env files
6+
.env.local
7+
.env.*.local
8+
9+
# Log files
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
14+
# Editor directories and files
15+
.idea
16+
.vscode
17+
*.suo
18+
*.ntvs*
19+
*.njsproj
20+
*.sln
21+
*.sw*
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# example-netlify-lambda-project
2+
3+
## Project setup
4+
```
5+
yarn install
6+
```
7+
8+
### Compiles and hot-reloads for development
9+
```
10+
yarn run serve
11+
```
12+
13+
### Compiles and minifies for production
14+
```
15+
yarn run build
16+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
presets: [
3+
'@vue/app'
4+
]
5+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "example-netlify-lambda-project",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"serve": "vue-cli-service serve",
7+
"build": "vue-cli-service build"
8+
},
9+
"dependencies": {
10+
"vue": "^2.5.17"
11+
},
12+
"devDependencies": {
13+
"@vue/cli-plugin-babel": "^3.0.1",
14+
"@vue/cli-service": "^3.0.1",
15+
"vue-template-compiler": "^2.5.17"
16+
},
17+
"postcss": {
18+
"plugins": {
19+
"autoprefixer": {}
20+
}
21+
},
22+
"browserslist": [
23+
"> 1%",
24+
"last 2 versions",
25+
"not ie <= 8"
26+
]
27+
}
1.12 KB
Binary file not shown.

0 commit comments

Comments
 (0)