-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathcommon-excludes.js
115 lines (107 loc) · 3.35 KB
/
common-excludes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
'use strict';
const semver = require('semver');
module.exports = class CommonExcludes {
constructor(serverless, options) {
if (!semver.satisfies(serverless.version, '>= 2.32')) {
throw new Error('serverless-plugin-common-excludes requires serverless 2.32 or higher!');
}
this.serverless = serverless;
this.options = options;
this.hooks = {
'after:deploy:function:initialize': this.addExcludes.bind(this),
'after:package:initialize': this.addExcludes.bind(this)
};
}
addExcludes() {
const { service } = this.serverless;
service.package = service.package || {};
service.package.patterns = service.package.patterns || [];
const set = new Set(service.package.patterns);
[
// common project files
'!.gitignore',
'!.gitconfig',
'!.editorconfig',
'!.eslintignore',
'!.eslintrc',
'!.npmrc',
'!.nycrc',
'!.npmignore',
'!*coveralls.yml',
'!.circleci/**',
'!*circle.yml',
'!*travis.yml',
'!.gitlab-ci.yml',
'!*.md',
'!*.apib',
'!.vscode/**',
'!package-lock.json',
'!.npm-upgrade.json',
'!sonar-project.properties',
'!sonar-coverage.info',
'!rollup.config.*',
'!yarn.lock',
// common project directories
'!coverage/**',
'!.nyc_output/**',
'!docs/**',
'!test/**',
'!tests/**',
'!CODEOWNERS',
// common things that node_modules fail to .npmignore
'!node_modules/**/*.md',
'!node_modules/**/*.flow',
'!node_modules/**/*.patch',
'!node_modules/**/*.conf',
'!node_modules/**/*.markdown',
'!node_modules/**/*.coffee',
'!node_modules/**/jsdoc_conf.json',
'!node_modules/**/*Makefile',
'!node_modules/**/Dockerfile',
'!node_modules/**/*.txt',
'!node_modules/**/*.yml',
'!node_modules/**/*.xml',
'!node_modules/**/*.html',
'!node_modules/**/test/**',
'!node_modules/**/tests/**',
'!node_modules/**/examples/**',
'!node_modules/**/coverage/**',
'!node_modules/**/.nyc_output/**',
'!node_modules/**/bin/**',
'!node_modules/**/bower.json',
'!node_modules/**/karma.conf.js',
'!node_modules/**/Gruntfile.js',
'!node_modules/**/rollup.config.*',
'!node_modules/**/yarn.lock',
'!node_modules/**/sonar-project.properties',
'!node_modules/**/package-lock.json',
'!node_modules/**/*.d.ts',
'!node_modules/**/*.map',
'!node_modules/**/tsconfig.json',
'!node_modules/**/AUTHORS',
'!node_modules/**/CODEOWNERS',
'!node_modules/**/OWNERS',
'!node_modules/**/*.iml',
'!node_module/**/*.bash_completion.in',
// yes, these are real
'!node_modules/**/*.gif',
'!node_modules/**/*.png',
'!node_modules/**/*.jpg',
'!node_modules/**/*.jpeg',
// module-specific odd things
'!node_modules/**/winston/scratch/**',
'!node_modules/**/sshpk/man/**',
'!node_modules/**/bluebird/js/browser/**',
'!node_modules/**/date-fns/docs.json',
'!node_modules/**/aws-xray-sdk-core/doc-src/**',
// AWS SDK unused dist files
'!node_modules/**/aws-sdk/dist/**',
'!node_modules/**/aws-sdk/dist-tools/**',
].forEach(pattern => {
if (set.has(pattern)) {
return;
}
service.package.patterns.push(pattern);
});
}
};