Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a217376

Browse files
committedApr 29, 2019
merged master
2 parents c0c1a12 + c702a57 commit a217376

File tree

7 files changed

+2626
-1933
lines changed

7 files changed

+2626
-1933
lines changed
 

‎.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- '9'
3+
- '10'
44
- '8'
55
- '6'
66

‎LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2019 Graphcool, Inc.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

‎README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# serverless-plugin-typescript
2-
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com) [![npm version](https://badge.fury.io/js/serverless-plugin-typescript.svg)](https://badge.fury.io/js/serverless-plugin-typescript) [![Build Status](https://travis-ci.org/graphcool/serverless-plugin-typescript.svg?branch=master)](https://travis-ci.org/graphcool/serverless-plugin-typescript)
2+
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com) [![npm version](https://badge.fury.io/js/serverless-plugin-typescript.svg)](https://badge.fury.io/js/serverless-plugin-typescript) [![Build Status](https://travis-ci.org/prisma/serverless-plugin-typescript.svg?branch=master)](https://travis-ci.org/prisma/serverless-plugin-typescript)
33

44
Serverless plugin for zero-config Typescript support
55

@@ -163,8 +163,9 @@ module.exports = {
163163
}
164164
```
165165

166-
## Help & Community [![Slack Status](https://slack.graph.cool/badge.svg)](https://slack.graph.cool)
166+
## Help & Community
167167

168-
Join our [Slack community](http://slack.graph.cool/) if you run into issues or have questions. We love talking to you!
168+
Join our [Spectrum community](http://spectrum.chat/prisma) if you run into issues or have questions. We love talking to you!
169+
170+
<p align="center"><a href="https://oss.prisma.io"><img src="https://imgur.com/IMU2ERq.png" alt="Prisma" height="170px"></a></p>
169171

170-
![](http://i.imgur.com/5RHR6Ku.png)

‎example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
},
66
"devDependencies": {
77
"@types/lodash": "4.14.91",
8+
"@types/node": "^11.13.0",
89
"serverless-plugin-typescript": "1.1.5"
910
}
1011
}

‎package.json

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "serverless-plugin-typescript",
33
"version": "0.0.0-semantic-release",
4+
"license": "MIT",
45
"main": "dist/src/index.js",
56
"files": [
67
"dist",
@@ -10,14 +11,14 @@
1011
"scripts": {
1112
"prepublish": "npm run build",
1213
"precommit": "npm run test",
13-
"build": "rm -rf dist && tsc",
14+
"build": "rimraf dist && tsc",
1415
"pretest": "npm run lint",
1516
"test": "jest",
1617
"lint": "tslint -c tslint.json 'src/**/*.ts'"
1718
},
1819
"repository": {
1920
"type": "git",
20-
"url": "git+https://github.com/graphcool/serverless-plugin-typescript.git"
21+
"url": "git+https://github.com/prisma/serverless-plugin-typescript.git"
2122
},
2223
"keywords": [
2324
"serverless",
@@ -26,25 +27,27 @@
2627
"aws lambda"
2728
],
2829
"devDependencies": {
29-
"@types/fs-extra": "5.0.0",
30-
"@types/jest": "22.0.1",
31-
"@types/lodash": "4.14.91",
32-
"jest": "22.0.4",
33-
"mock-fs": "4.4.2",
34-
"ts-jest": "22.0.1",
35-
"tslint": "5.8.0"
30+
"@types/fs-extra": "5.0.5",
31+
"@types/jest": "24.0.11",
32+
"@types/lodash": "4.14.123",
33+
"jest": "24.5.0",
34+
"mock-fs": "4.8.0",
35+
"rimraf": "^2.6.3",
36+
"ts-jest": "24.0.1",
37+
"tslint": "5.14.0",
38+
"typescript": "^3.4.1"
3639
},
3740
"dependencies": {
38-
"fs-extra": "^5.0.0",
39-
"globby": "^7.0.0",
40-
"lodash": "^4.17.4",
41-
"typescript": "^2.2.2"
41+
"fs-extra": "^7.0.1",
42+
"globby": "^9.2.0",
43+
"lodash": "^4.17.11"
44+
},
45+
"peerDependencies": {
46+
"typescript": ">=2.2.2"
4247
},
4348
"jest": {
44-
"transform": {
45-
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
46-
},
47-
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
49+
"preset": "ts-jest",
50+
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.ts$",
4851
"moduleFileExtensions": [
4952
"ts",
5053
"tsx",

‎src/index.ts

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,21 @@ export class TypeScriptPlugin {
155155
}
156156

157157
async copyExtras() {
158-
// include node_modules into build
159-
if (!fs.existsSync(path.resolve(path.join(buildFolder, 'node_modules')))) {
160-
fs.symlinkSync(
158+
const outPkgPath = path.resolve(path.join(buildFolder, 'package.json'))
159+
const outModulesPath = path.resolve(path.join(buildFolder, 'node_modules'))
160+
161+
// Link or copy node_modules and package.json to .build so Serverless can
162+
// exlcude devDeps during packaging
163+
if (!fs.existsSync(outModulesPath)) {
164+
await this.linkOrCopy(
161165
path.resolve('node_modules'),
162-
path.resolve(path.join(buildFolder, 'node_modules'))
166+
outModulesPath,
167+
'junction'
163168
)
164169
}
165170

166-
// include package.json into build so Serverless can exlcude devDeps during packaging
167-
if (!fs.existsSync(path.resolve(path.join(buildFolder, 'package.json')))) {
168-
fs.symlinkSync(
169-
path.resolve('package.json'),
170-
path.resolve(path.join(buildFolder, 'package.json'))
171-
)
171+
if (!fs.existsSync(outPkgPath)) {
172+
await this.linkOrCopy(path.resolve('package.json'), outPkgPath, 'file')
172173
}
173174

174175
// include any "extras" from the "include" section
@@ -253,6 +254,23 @@ export class TypeScriptPlugin {
253254
// Remove temp build folder
254255
fs.removeSync(path.join(this.originalServicePath, buildFolder))
255256
}
257+
258+
/**
259+
* Attempt to symlink a given path or directory and copy if it fails with an
260+
* `EPERM` error.
261+
*/
262+
private async linkOrCopy(
263+
srcPath: string,
264+
dstPath: string,
265+
type?: 'dir' | 'junction' | 'file'
266+
): Promise<void> {
267+
return fs.symlink(srcPath, dstPath, type).catch(error => {
268+
if (error.code === 'EPERM' && error.errno === -4048) {
269+
return fs.copy(srcPath, dstPath)
270+
}
271+
throw error
272+
})
273+
}
256274
}
257275

258276
module.exports = TypeScriptPlugin

0 commit comments

Comments
 (0)