Skip to content

Commit c702a57

Browse files
authored
Merge pull request #1 from prisma/master
rebase
2 parents 55aa82b + d6496ab commit c702a57

File tree

7 files changed

+2624
-1929
lines changed

7 files changed

+2624
-1929
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: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,17 @@ export class TypeScriptPlugin {
136136
}
137137

138138
async copyExtras() {
139-
// include node_modules into build
140-
if (!fs.existsSync(path.resolve(path.join(buildFolder, 'node_modules')))) {
141-
fs.symlinkSync(path.resolve('node_modules'), path.resolve(path.join(buildFolder, 'node_modules')))
139+
const outPkgPath = path.resolve(path.join(buildFolder, 'package.json'))
140+
const outModulesPath = path.resolve(path.join(buildFolder, 'node_modules'))
141+
142+
// Link or copy node_modules and package.json to .build so Serverless can
143+
// exlcude devDeps during packaging
144+
if (!fs.existsSync(outModulesPath)) {
145+
await this.linkOrCopy(path.resolve('node_modules'), outModulesPath, 'junction')
142146
}
143147

144-
// include package.json into build so Serverless can exlcude devDeps during packaging
145-
if (!fs.existsSync(path.resolve(path.join(buildFolder, 'package.json')))) {
146-
fs.symlinkSync(path.resolve('package.json'), path.resolve(path.join(buildFolder, 'package.json')))
148+
if (!fs.existsSync(outPkgPath)) {
149+
await this.linkOrCopy(path.resolve('package.json'), outPkgPath, 'file')
147150
}
148151

149152
// include any "extras" from the "include" section
@@ -209,6 +212,23 @@ export class TypeScriptPlugin {
209212
fs.removeSync(path.join(this.originalServicePath, buildFolder))
210213
}
211214

215+
/**
216+
* Attempt to symlink a given path or directory and copy if it fails with an
217+
* `EPERM` error.
218+
*/
219+
private async linkOrCopy(
220+
srcPath: string,
221+
dstPath: string,
222+
type?: 'dir' | 'junction' | 'file'
223+
): Promise<void> {
224+
return fs.symlink(srcPath, dstPath, type)
225+
.catch(error => {
226+
if (error.code === 'EPERM' && error.errno === -4048) {
227+
return fs.copy(srcPath, dstPath)
228+
}
229+
throw error
230+
})
231+
}
212232
}
213233

214234
module.exports = TypeScriptPlugin

0 commit comments

Comments
 (0)