This repository has been archived by the owner on Feb 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
prune.sh
executable file
·177 lines (169 loc) · 4.61 KB
/
prune.sh
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/env sh
# Fork of https://github.com/tuananh/node-prune
# ... which is a port of https://github.com/tj/node-prune to bash
#
# See also:
# - https://github.com/tuananh/node-prune
# - https://github.com/timoxley/cruft
# - https://yarnpkg.com/en/docs/cli/autoclean
# - https://github.com/ModClean/modclean
#
# Prunes common files that are unnecessarily published in npm packages
# when people don't configure `.npmignore` or package.json's `files`
fileCount (){
find . -type d -prune -exec find {} -type f \
-not -path "*architect/shared*" \
-not -path "*architect/views*" \
-not -path "*@begin*" \
-not -path "*@smallwins*" \; | wc -l
}
beforeSize=$(du -hsk . | cut -d$'\t' -f 1)
beforeFiles=$(fileCount)
# Common unneeded files
find . -type d -name node_modules -prune -exec find {} -type f \( \
-name _config.yml -o \
-name .appveyor.yml -o \
-name .babelrc -o \
-name .coveralls.yml -o \
-name .dir-locals.el -o \
-name .dntrc -o \
-name .documentup.json -o \
-iname .ds_store -o \
-name .editorconfig -o \
-name .editorconfig -o \
-name .eslintignore -o \
-name .eslintrc -o \
-name .eslintrc.js -o \
-name .eslintrc.json -o \
-name .eslintrc.yaml -o \
-name .eslintrc.yml -o \
-name .flowconfig -o \
-name .gitattributes -o \
-name .gitignore -o \
-name .gitkeep -o \
-name .gitlab-ci.yml -o \
-name .gitmodules -o \
-name .gradle -o \
-name .htmllintrc -o \
-name .idea -o \
-name .istanbul.yml -o \
-name .jamignore -o \
-name .jsbeautifyrc -o \
-name .jscsrc -o \
-name .jshintignore -o \
-name .jshintrc -o \
-name .lint -o \
-name .lintignore -o \
-name .npmignore -o \
-name .npmrc -o \
-name .stylelintrc -o \
-name .stylelintrc.js -o \
-name .stylelintrc.json -o \
-name .stylelintrc.yaml -o \
-name .stylelintrc.yml -o \
-name .tern-port -o \
-name .tern-project -o \
-name .travis.yml -o \
-name .yarn-integrity -o \
-name .yarn-metadata.json -o \
-name .yarnclean -o \
-name .yo-rc -o \
-name .yo-rc.json -o \
-name .zuul.yml -o \
-name appveyor.yml -o \
-iname AUTHORS -o \
-name benchmark -o \
-name bower.json -o \
-name builderror.log -o \
-name cakefile -o \
-iname CHANGELOG -o \
-iname CHANGELOG.md -o \
-iname changes -o \
-name circle.yml -o \
-iname CONTRIBUTORS -o \
-name desktop.ini -o \
-name dockerfile -o \
-name eslint -o \
-iname Gruntfile.js -o \
-iname Gulpfile.js -o \
-name htmllint.js -o \
-name jest.config.js -o \
-name jsl.conf -o \
-name jsstyle -o \
-name karma.conf.js -o \
-iname LICENCE -o \
-iname LICENSE -o \
-iname LICENSE-BSD -o \
-iname LICENSE-jsbn -o \
-iname LICENSE-MIT -o \
-iname LICENSE-MIT.txt -o \
-iname LICENSE.BSD -o \
-iname LICENSE.md -o \
-iname LICENSE.txt -o \
-iname Makefile -o \
-name mocha.opts -o \
-name npm-debug.log -o \
-iname README -o \
-iname README.md -o \
-iname README.txt -o \
-name robot.html -o \
-name stylelint.config.js -o \
-iname thumbs.db -o \
-name tsconfig.json -o \
-name wercker.yml -o \
-name "*.coffee" -o \
-name "*.gypi" -o \
-name "*.jst" -o \
-name "*.markdown" -o \
-name "*.md" -o \
-name "*.mkd" -o \
-name "*.obj" -o \
-name "*.sln" -o \
-name "*.swp" -o \
-name "*.vcxproj.filters" -o \
-name "*.vcxproj" -o \
\( -name '*.ts' -and \! -name '*.d.ts' \) \
\) \
-not -path "*@architect/shared*" \
-not -path "*@architect/views*" \
-not -path "*@begin*" \
-not -path "*@smallwins*" \
-print0 \; | xargs -0 rm -rf
# Common unneeded directories
find . -type d -name node_modules -prune -exec find {} -type d \( \
-name __mocks__ -o \
-name __tests__ -o \
-name __test__ -o \
-name .circleci -o \
-name .github -o \
-name .idea -o \
-name .nyc_output -o \
-name .vscode -o \
-name assets -o \
-name coverage -o \
-name doc -o \
-name docs -o \
-name example -o \
-name examples -o \
-name images -o \
-name powered-test -o \
-name samples -o \
-name test -o \
-name tests -o \
-name website \
\) \
-not -path "*@architect/shared*" \
-not -path "*@architect/views*" \
-not -path "*@begin*" \
-not -path "*@smallwins*" \
-print0 \; | xargs -0 rm -rf
# TODO look into issues I was seeing before removing these
# -name node-gyp -o \
# -name node-pre-gyp -o \
# -name gyp -o \
afterSize=$(du -hsk . | cut -d$'\t' -f 1)
afterFiles=$(fileCount)
echo ${beforeSize}
echo ${afterSize}
echo ${beforeFiles}
echo ${afterFiles}