├── .editorconfig
├── .gitattributes
├── .github
├── dependabot.yml
└── workflows
│ ├── main.yml
│ └── pull_request.yml
├── .gitignore
├── .npmrc
├── CHANGELOG.md
├── LICENSE
├── README.md
├── bin
├── help.txt
└── index.js
├── demo.png
├── package.json
└── src
├── default
└── blacklist.js
├── getProductionDeps.js
├── index.js
└── load-config.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 |
3 | root = true
4 |
5 | [*]
6 | indent_style = space
7 | indent_size = 2
8 | end_of_line = lf
9 | charset = utf-8
10 | trim_trailing_whitespace = true
11 | insert_final_newline = true
12 | max_line_length = 80
13 | indent_brace_style = 1TBS
14 | spaces_around_operators = true
15 | quote_type = auto
16 |
17 | [package.json]
18 | indent_style = space
19 | indent_size = 2
20 |
21 | [*.md]
22 | trim_trailing_whitespace = false
23 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: npm
4 | directory: '/'
5 | schedule:
6 | interval: daily
7 | - package-ecosystem: 'github-actions'
8 | directory: '/'
9 | schedule:
10 | # Check for updates to GitHub Actions every weekday
11 | interval: 'daily'
12 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: main
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 | jobs:
9 | contributors:
10 | if: "${{ github.event.head_commit.message != 'build: contributors' }}"
11 | runs-on: ubuntu-latest
12 | steps:
13 | - name: Checkout
14 | uses: actions/checkout@v4
15 | with:
16 | fetch-depth: 0
17 | token: ${{ secrets.GITHUB_TOKEN }}
18 | - name: Setup Node.js
19 | uses: actions/setup-node@v4
20 | with:
21 | node-version: lts/*
22 | - name: Contributors
23 | run: |
24 | git config --global user.email ${{ secrets.GIT_EMAIL }}
25 | git config --global user.name ${{ secrets.GIT_USERNAME }}
26 | npm run contributors
27 | - name: Push changes
28 | run: |
29 | git push origin ${{ github.head_ref }}
30 |
31 | release:
32 | if: |
33 | !startsWith(github.event.head_commit.message, 'chore(release):') &&
34 | !startsWith(github.event.head_commit.message, 'docs:') &&
35 | !startsWith(github.event.head_commit.message, 'ci:')
36 | needs: [contributors]
37 | runs-on: ubuntu-latest
38 | steps:
39 | - name: Checkout
40 | uses: actions/checkout@v4
41 | with:
42 | token: ${{ secrets.GITHUB_TOKEN }}
43 | - name: Setup Node.js
44 | uses: actions/setup-node@v4
45 | with:
46 | node-version: lts/*
47 | - name: Setup PNPM
48 | uses: pnpm/action-setup@v4
49 | with:
50 | version: latest
51 | run_install: true
52 | - name: Test
53 | run: npm test
54 | # - name: Report
55 | # run: npx c8 report --reporter=text-lcov > coverage/lcov.info
56 | # - name: Coverage
57 | # uses: coverallsapp/github-action@main
58 | # with:
59 | # github-token: ${{ secrets.GITHUB_TOKEN }}
60 | - name: Release
61 | env:
62 | GH_TOKEN: ${{ secrets.GH_TOKEN }}
63 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
64 | run: |
65 | git config --global user.email ${{ secrets.GIT_EMAIL }}
66 | git config --global user.name ${{ secrets.GIT_USERNAME }}
67 | git pull origin master
68 | npm run release
69 |
--------------------------------------------------------------------------------
/.github/workflows/pull_request.yml:
--------------------------------------------------------------------------------
1 | name: pull_request
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | branches:
9 | - master
10 |
11 | jobs:
12 | test:
13 | if: github.ref != 'refs/heads/master'
14 | runs-on: ubuntu-latest
15 | steps:
16 | - name: Checkout
17 | uses: actions/checkout@v4
18 | with:
19 | token: ${{ secrets.GITHUB_TOKEN }}
20 | - name: Setup Node.js
21 | uses: actions/setup-node@v4
22 | with:
23 | node-version: lts/*
24 | - name: Setup PNPM
25 | uses: pnpm/action-setup@v4
26 | with:
27 | version: latest
28 | run_install: true
29 | - name: Test
30 | run: npm test
31 | # - name: Report
32 | # run: npx c8 report --reporter=text-lcov > coverage/lcov.info
33 | # - name: Coverage
34 | # uses: coverallsapp/github-action@main
35 | # with:
36 | # github-token: ${{ secrets.GITHUB_TOKEN }}
37 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ############################
2 | # npm
3 | ############################
4 | node_modules
5 | npm-debug.log
6 | .node_history
7 | yarn.lock
8 | package-lock.json
9 |
10 | ############################
11 | # tmp, editor & OS files
12 | ############################
13 | .tmp
14 | *.swo
15 | *.swp
16 | *.swn
17 | *.swm
18 | .DS_Store
19 | *#
20 | *~
21 | .idea
22 | *sublime*
23 | nbproject
24 |
25 | ############################
26 | # Tests
27 | ############################
28 | testApp
29 | coverage
30 | .nyc_output
31 |
32 | ############################
33 | # Other
34 | ############################
35 | .envrc
36 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | unsafe-perm=true
2 | save-prefix=~
3 | save=false
4 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4 |
5 | ### 1.5.9 (2025-04-28)
6 |
7 | ### 1.5.8 (2025-01-04)
8 |
9 |
10 | ### Bug Fixes
11 |
12 | * default arguments ([6132401](https://github.com/Kikobeats/untracked/commit/61324017374345008fd05e2d03cb3934e51eac76))
13 |
14 | ### 1.5.7 (2025-01-04)
15 |
16 | ### 1.5.6 (2024-05-08)
17 |
18 | ### 1.5.5 (2024-02-09)
19 |
20 | ### 1.5.4 (2024-01-16)
21 |
22 | ### 1.5.3 (2023-12-16)
23 |
24 | ### 1.5.2 (2023-10-24)
25 |
26 | ### 1.5.1 (2023-10-19)
27 |
28 | ## 1.5.0 (2023-10-08)
29 |
30 |
31 | ### Features
32 |
33 | * sort output ([f0f8b2d](https://github.com/Kikobeats/untracked/commit/f0f8b2dc81532c76628595d49842260895b2f78e))
34 |
35 | ### 1.4.20 (2023-09-05)
36 |
37 | ### 1.4.19 (2023-09-05)
38 |
39 | ### 1.4.18 (2023-07-24)
40 |
41 | ### 1.4.17 (2023-04-21)
42 |
43 |
44 | ### Bug Fixes
45 |
46 | * setup buffer enough big ([2125a99](https://github.com/Kikobeats/untracked/commit/2125a99cfecbf2b82bd8ff76ee5cf608ac7d6220))
47 |
48 | ### 1.4.16 (2023-04-06)
49 |
50 |
51 | ### Bug Fixes
52 |
53 | * remove duplicates ([26b90f5](https://github.com/Kikobeats/untracked/commit/26b90f567fa2a4cb0ad24c5390073ca48eeac1f7))
54 |
55 | ### 1.4.15 (2022-05-17)
56 |
57 | ### 1.4.14 (2022-04-12)
58 |
59 | ### 1.4.13 (2022-04-04)
60 |
61 | ### 1.4.12 (2022-03-02)
62 |
63 | ### 1.4.11 (2022-02-25)
64 |
65 | ### 1.4.10 (2022-01-21)
66 |
67 |
68 | ### Bug Fixes
69 |
70 | * fallback empty object ([b025bcf](https://github.com/Kikobeats/untracked/commit/b025bcf57658ea5208c589fe492281b30ab4de0e))
71 |
72 | ### 1.4.9 (2021-12-08)
73 |
74 |
75 | ### Bug Fixes
76 |
77 | * read configuration prop path ([b208e6d](https://github.com/Kikobeats/untracked/commit/b208e6d2cb4a1cece184df56d116f4e73fec5aad))
78 |
79 | ### 1.4.8 (2021-12-01)
80 |
81 |
82 | ### Bug Fixes
83 |
84 | * pass cwd to joycon ([4099931](https://github.com/Kikobeats/untracked/commit/4099931ae00a71781981eccace017bc1faaf20af))
85 |
86 | ### 1.4.7 (2021-12-01)
87 |
88 | ### 1.4.6 (2021-11-22)
89 |
90 | ### [1.4.5](https://github.com/Kikobeats/untracked/compare/v1.4.4...v1.4.5) (2021-11-22)
91 |
92 | ### [1.4.4](https://github.com/Kikobeats/untracked/compare/v1.4.3...v1.4.4) (2020-12-25)
93 |
94 | ### [1.4.3](https://github.com/Kikobeats/untracked/compare/v1.4.2...v1.4.3) (2020-11-30)
95 |
96 | ### [1.4.2](https://github.com/Kikobeats/untracked/compare/v1.4.1...v1.4.2) (2020-11-30)
97 |
98 | ### [1.4.1](https://github.com/Kikobeats/untracked/compare/v1.4.0...v1.4.1) (2020-10-30)
99 |
100 | ## 1.4.0 (2020-05-07)
101 |
102 |
103 | ### Features
104 |
105 | * improve filtering ([9373577](https://github.com/Kikobeats/untracked/commit/93735771cacb613e068c34a6459320e48c42d60f))
106 |
107 |
108 | ### Bug Fixes
109 |
110 | * **package:** update cosmiconfig to version 4.0.0 ([5905265](https://github.com/Kikobeats/untracked/commit/59052654ce433b5f594948bc4266cc5fab378222))
111 | * **package:** update cosmiconfig to version 5.0.0 ([5f5d471](https://github.com/Kikobeats/untracked/commit/5f5d471cc8b723c94385763f6d5adc6c4732126a))
112 | * **package:** update cosmiconfig to version 5.1.0 ([fe701ca](https://github.com/Kikobeats/untracked/commit/fe701cae4e20bc5f290373eddd23eaa385e8155f))
113 | * **package:** update cosmiconfig to version 5.2.0 ([d84a41c](https://github.com/Kikobeats/untracked/commit/d84a41cbe67ba2538ef960e6f0ab35cc7f497d11))
114 | * **package:** update update-notifier to version 2.4.0 ([1d5b950](https://github.com/Kikobeats/untracked/commit/1d5b9502b7818947b09613a91b7c8bdd5a865e63))
115 | * **package:** update update-notifier to version 2.5.0 ([80fe27c](https://github.com/Kikobeats/untracked/commit/80fe27cf603edcfe7afb5d0a1e61db8d735e73e6))
116 | * **package:** update update-notifier to version 2.6.0 ([0516c26](https://github.com/Kikobeats/untracked/commit/0516c26cdc5ac967327af107482c6b12c385ac1c))
117 | * add more cases ([c53aea1](https://github.com/Kikobeats/untracked/commit/c53aea15edaf9ec82384588d460dfd00ca49663d))
118 | * **package:** update meow to version 5.0.0 ([3a60363](https://github.com/Kikobeats/untracked/commit/3a603631599921cf62a4e1ed3061a31ca5950603))
119 |
120 | ## 1.3.0 (2020-01-20)
121 |
122 | * build: update dependencies ([afa5bff](https://github.com/Kikobeats/untracked/commit/afa5bff))
123 | * docs: add lambda-prune ([60005d8](https://github.com/Kikobeats/untracked/commit/60005d8))
124 |
125 |
126 |
127 |
128 | ## 1.2.3 (2019-06-21)
129 |
130 | * build: exclude txt extension ([03162ba](https://github.com/Kikobeats/untracked/commit/03162ba))
131 |
132 |
133 |
134 |
135 | ## 1.2.2 (2019-06-20)
136 |
137 | * build: migrate hooks ([3d8abd9](https://github.com/Kikobeats/untracked/commit/3d8abd9))
138 |
139 |
140 |
141 |
142 | ## 1.2.1 (2019-06-20)
143 |
144 | * build: tweaks ([9cf1860](https://github.com/Kikobeats/untracked/commit/9cf1860))
145 | * build: update dependencies ([676d3a1](https://github.com/Kikobeats/untracked/commit/676d3a1))
146 | * build: update dependencies ([b1d0ed8](https://github.com/Kikobeats/untracked/commit/b1d0ed8))
147 | * build: use lodash as dependency ([9707fbc](https://github.com/Kikobeats/untracked/commit/9707fbc))
148 | * docs: add docker ([23b19d4](https://github.com/Kikobeats/untracked/commit/23b19d4))
149 | * docs: add Heroku section ([080632f](https://github.com/Kikobeats/untracked/commit/080632f))
150 | * docs: add yarn command ([9f88758](https://github.com/Kikobeats/untracked/commit/9f88758))
151 | * docs: revamped ([ef6ca02](https://github.com/Kikobeats/untracked/commit/ef6ca02))
152 | * [ImgBot] Optimize images ([12c3c0d](https://github.com/Kikobeats/untracked/commit/12c3c0d))
153 | * Fix incorrect file name on `Up` documentation ([0d76d9b](https://github.com/Kikobeats/untracked/commit/0d76d9b))
154 | * Update README.md ([85c3617](https://github.com/Kikobeats/untracked/commit/85c3617))
155 | * Update README.md ([edda309](https://github.com/Kikobeats/untracked/commit/edda309))
156 | * Update README.md ([ebf6c68](https://github.com/Kikobeats/untracked/commit/ebf6c68))
157 | * fix(package): update cosmiconfig to version 5.2.0 ([d84a41c](https://github.com/Kikobeats/untracked/commit/d84a41c))
158 | * fix(package): update update-notifier to version 2.6.0 ([0516c26](https://github.com/Kikobeats/untracked/commit/0516c26))
159 |
160 |
161 |
162 |
163 | # 1.2.0 (2019-03-17)
164 |
165 | * build: add markup format ([252817f](https://github.com/Kikobeats/untracked/commit/252817f))
166 | * fix(package): update cosmiconfig to version 5.1.0 ([fe701ca](https://github.com/Kikobeats/untracked/commit/fe701ca))
167 | * Update README.md ([5dfe905](https://github.com/Kikobeats/untracked/commit/5dfe905))
168 | * Update README.md ([fdf65de](https://github.com/Kikobeats/untracked/commit/fdf65de))
169 |
170 |
171 |
172 |
173 | ## 1.1.1 (2018-12-03)
174 |
175 | * fix: add more cases ([c53aea1](https://github.com/Kikobeats/untracked/commit/c53aea1))
176 |
177 |
178 |
179 |
180 | # 1.1.0 (2018-12-03)
181 |
182 | * feat: improve filtering ([9373577](https://github.com/Kikobeats/untracked/commit/9373577))
183 | * Update package.json ([3f3d726](https://github.com/Kikobeats/untracked/commit/3f3d726))
184 |
185 |
186 |
187 |
188 | ## 1.0.8 (2018-05-10)
189 |
190 | * Migrate to last cosmiconfig version ([da960d9](https://github.com/Kikobeats/untracked/commit/da960d9))
191 | * fix(package): update cosmiconfig to version 5.0.0 ([5f5d471](https://github.com/Kikobeats/untracked/commit/5f5d471))
192 | * fix(package): update meow to version 5.0.0 ([3a60363](https://github.com/Kikobeats/untracked/commit/3a60363))
193 | * fix(package): update update-notifier to version 2.4.0 ([1d5b950](https://github.com/Kikobeats/untracked/commit/1d5b950))
194 | * fix(package): update update-notifier to version 2.5.0 ([80fe27c](https://github.com/Kikobeats/untracked/commit/80fe27c))
195 |
196 |
197 |
198 |
199 | ## 1.0.7 (2018-03-06)
200 |
201 | * Update ([8529fae](https://github.com/Kikobeats/untracked/commit/8529fae))
202 |
203 |
204 |
205 |
206 | ## 1.0.6 (2018-02-09)
207 |
208 | * Fix files field ([25af8a5](https://github.com/Kikobeats/untracked/commit/25af8a5))
209 |
210 |
211 |
212 |
213 | ## 1.0.5 (2018-02-09)
214 |
215 | * Add files field ([128f499](https://github.com/Kikobeats/untracked/commit/128f499))
216 | * Add more files to ignore ([3168d74](https://github.com/Kikobeats/untracked/commit/3168d74))
217 |
218 |
219 |
220 |
221 | ## 1.0.4 (2018-01-23)
222 |
223 | * Add more files to ignore ([afa1036](https://github.com/Kikobeats/untracked/commit/afa1036))
224 |
225 |
226 |
227 |
228 | ## 1.0.3 (2018-01-19)
229 |
230 | * Add license variation ([84a14ed](https://github.com/Kikobeats/untracked/commit/84a14ed))
231 | * Update README.md ([25c69c4](https://github.com/Kikobeats/untracked/commit/25c69c4))
232 | * fix(package): update cosmiconfig to version 4.0.0 ([5905265](https://github.com/Kikobeats/untracked/commit/5905265))
233 |
234 |
235 |
236 |
237 | ## 1.0.2 (2017-12-25)
238 |
239 | * Add more rules ([12b1e25](https://github.com/Kikobeats/untracked/commit/12b1e25))
240 |
241 |
242 |
243 |
244 | ## 1.0.1 (2017-12-24)
245 |
246 | * Resolve all production deps ([419048a](https://github.com/Kikobeats/untracked/commit/419048a))
247 |
248 |
249 |
250 |
251 | # 1.0.0 (2017-12-24)
252 |
253 | * Add keywords ([808686d](https://github.com/Kikobeats/untracked/commit/808686d))
254 | * First commit ([99fe61e](https://github.com/Kikobeats/untracked/commit/99fe61e))
255 | * Update README.md ([e2daef5](https://github.com/Kikobeats/untracked/commit/e2daef5))
256 | * Update README.md ([35c7803](https://github.com/Kikobeats/untracked/commit/35c7803))
257 | * Update README.md ([f68bd82](https://github.com/Kikobeats/untracked/commit/f68bd82))
258 | * docs(readme): add Greenkeeper badge ([3f8696a](https://github.com/Kikobeats/untracked/commit/3f8696a))
259 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright © 2017 Kiko Beats (kikobeats.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # untracked
2 |
3 | 
4 | [](https://www.npmjs.org/package/untracked)
5 |
6 |
7 |
8 |
9 |

10 |
11 |
12 |
13 |
14 |
15 | **untracked** is a universal way for ingnoring unnecessary common files (such as `README.md`, `LICENSE.md`, `Makefile`, `Gruntfile`, `Gulpfile`, `karma.conf.js`, etc) to fit your bundle and create **smallest production ready bunddle** possible.
16 |
17 | ## Usage
18 |
19 | Just run the command
20 |
21 | ```
22 | npx untracked
23 | ```
24 |
25 | The files to ignore will be detected automagically ✨.
26 |
27 | ### Using with Heroku
28 |
29 | You need to write the output as [`.slugignore`](https://devcenter.heroku.com/articles/slug-compiler#ignoring-files-with-slugignore).
30 |
31 | For doing that you can run the command directly
32 |
33 | ```
34 | npx untracked > .slugignore
35 | ```
36 |
37 | Also, you can declare it as [`heroku-prebuild`](https://devcenter.heroku.com/articles/nodejs-support#heroku-specific-build-steps) at `scripts` in your `package.json`:
38 |
39 | ```json
40 | {
41 | "scripts": {
42 | "heroku-prebuild": "npx untracked > .slugignore"
43 | }
44 | }
45 | ```
46 |
47 | ### Using with Vercel
48 |
49 | Just you need to write the output at [`.vercelignore`](https://vercel.com/docs/concepts/deployments/vercel-ignore) file.
50 |
51 | ```
52 | npx untracked > .vercelignore
53 | ```
54 |
55 | ### Using with Yarn
56 |
57 | [Yarn](https://yarnpkg.com) supports remove unnecessary files via [`.yarnclean`](https://yarnpkg.com/en/docs/cli/autoclean).
58 |
59 | ```bash
60 | yarn install --production
61 | npx untracked > .yarnclean
62 | yarn autoclean --force
63 | ```
64 |
65 | ### Using with Docker
66 |
67 | Just you need to write the output at [`.dockerignore`](https://docs.docker.com/engine/reference/builder/#dockerignore-file) file.
68 |
69 | ```
70 | npx untracked > .dockerignore
71 | ```
72 |
73 |
74 | ## Additional Files
75 |
76 | Sometimes you need to declare an extra file to include/ignore in the bundle.
77 |
78 | That's could be achieve just declaring a `untracked` field into your `package.json`:
79 |
80 | ```json
81 | {
82 | "untracked": {
83 | "whitelist": [
84 | "bin"
85 | ],
86 | "blacklist": [
87 | "bench",
88 | "node_modules/@ffprobe-installer/darwin-x64",
89 | "node_modules/@ffprobe-installer/linux-ia32",
90 | "node_modules/@ffprobe-installer/win32-ia32",
91 | "node_modules/@ffprobe-installer/win32-x64",
92 | "node_modules/puppeteer/.local-chromium",
93 | "scripts"
94 | ]
95 | }
96 | }
97 | ```
98 |
99 |
100 | If you need to declare this files programatically, you can use any of the [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) supported ways for loading the configuration.
101 |
102 | ## How It Works™
103 |
104 | **untracked** create a list of common files to ignore using [gitignore pattern format](https://git-scm.com/docs/gitignore#_pattern_format).
105 |
106 | This makes it compatible with any builder process that supports ignore files based on this pattern declaration.
107 |
108 | Under the hood, **untracked** supports file name variations for files such as
109 |
110 | - Documentation (`docs`, `LICENSE`, `README`, etc).
111 | - Toolings configuration (`Makefile`, `Gruntfile`, `Gulpfile`, `karma.conf.js`,etc).
112 | - Assets (`*.map`, `*.d.ts`, `*.flow`, etc).
113 |
114 | It creates the properly gitpattern for ignoring any of these files.
115 |
116 | ## Related
117 |
118 | - [lambda-prune](https://github.com/Kikobeats/lambda-prune) – Cleanup old AWS Lambda functions.
119 | - [node-prune](https://github.com/tj/node-prune) – Remove unnecessary files from node_modules (.md, .ts, ...).
120 | - [lambdapack](https://github.com/toriihq/lambdapack) – Package your AWS Lambda efficiently.
121 |
122 |
123 | ## License
124 |
125 | **untracked** © [Kiko Beats](https://kikobeats.com), released under the [MIT](https://github.com/Kikobeats/untracked/blob/master/LICENSE.md) License.
126 | Authored and maintained by Kiko Beats with help from [contributors](https://github.com/Kikobeats/untracked/contributors).
127 |
128 | > [kikobeats.com](https://kikobeats.com) · GitHub [@Kiko Beats](https://github.com/Kikobeats) · X [@Kikobeats](https://x.com/Kikobeats)
129 |
--------------------------------------------------------------------------------
/bin/help.txt:
--------------------------------------------------------------------------------
1 | Usage
2 | $ untracked
3 |
4 | Just declare a `untracked` field in your `package.json` with:
5 |
6 | - whitelist: Files you want to include.
7 | - blacklist: Files you want to ignore.
8 |
9 | For example:
10 |
11 | {
12 | "untracked": {
13 | "whitelist": [
14 | "build",
15 | "bin",
16 | ".metascraperrc"
17 | ],
18 | "blacklist": [
19 | "node_modules/puppeteer/.local-chromium"
20 | ]
21 | },
22 | }
23 |
24 | Files declared need to follow gitignore pattern format:
25 | https://git-scm.com/docs/gitignore#_pattern_format
26 |
27 | Your `dependencies` are included by default.
28 |
--------------------------------------------------------------------------------
/bin/index.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | 'use strict'
4 |
5 | const path = require('path')
6 | const mri = require('mri')
7 |
8 | const pkg = require('../package.json')
9 | const untracked = require('..')
10 |
11 | require('update-notifier')({ pkg }).notify()
12 |
13 | const argv = mri(process.argv.slice(2), {
14 | alias: {
15 | help: 'h'
16 | }
17 | })
18 |
19 | if (argv.help) {
20 | console.log(
21 | require('fs').readFileSync(path.join(__dirname, 'help.txt'), 'utf8')
22 | )
23 | process.exit()
24 | }
25 |
26 | untracked(argv)
27 | .then(output => console.log(output))
28 | .catch(error => console.error(error) || process.exit(1))
29 |
--------------------------------------------------------------------------------
/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kikobeats/untracked/0742ae758b97c817fa492b6a9ea7a69f145dd8a6/demo.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "untracked",
3 | "description": "Universal way for ignoring unnecessary common files to fit your bundle",
4 | "homepage": "https://github.com/Kikobeats/untracked",
5 | "version": "1.5.9",
6 | "main": "src/index.js",
7 | "bin": {
8 | "untracked": "bin/index.js"
9 | },
10 | "author": {
11 | "email": "josefrancisco.verdu@gmail.com",
12 | "name": "Kiko Beats",
13 | "url": "https://kikobeats.com"
14 | },
15 | "contributors": [
16 | {
17 | "name": "Lucas Bento",
18 | "email": "lucas.bsilva@outlook.com"
19 | }
20 | ],
21 | "repository": {
22 | "type": "git",
23 | "url": "git+https://github.com/Kikobeats/untracked.git"
24 | },
25 | "bugs": {
26 | "url": "https://github.com/Kikobeats/untracked/issues"
27 | },
28 | "keywords": [
29 | "apex",
30 | "aws",
31 | "gitignore",
32 | "lambda",
33 | "up",
34 | "upignore",
35 | "webpack"
36 | ],
37 | "dependencies": {
38 | "joycon": "~3.1.1",
39 | "lodash": "~4.17.21",
40 | "mri": "~1.2.0",
41 | "update-notifier": "~5.1.0"
42 | },
43 | "devDependencies": {
44 | "@commitlint/cli": "latest",
45 | "@commitlint/config-conventional": "latest",
46 | "@ksmithut/prettier-standard": "latest",
47 | "ci-publish": "latest",
48 | "finepack": "latest",
49 | "git-authors-cli": "latest",
50 | "github-generate-release": "latest",
51 | "nano-staged": "latest",
52 | "simple-git-hooks": "latest",
53 | "standard": "latest",
54 | "standard-markdown": "latest",
55 | "standard-version": "latest"
56 | },
57 | "engines": {
58 | "node": ">= 6"
59 | },
60 | "files": [
61 | "bin",
62 | "src"
63 | ],
64 | "scripts": {
65 | "clean": "rm -rf node_modules",
66 | "contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
67 | "lint": "standard-markdown README.md && standard",
68 | "postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
69 | "pretest": "npm run lint",
70 | "pretty": "prettier-standard index.js {core,test,bin}/**/*.js --single-quote",
71 | "release": "standard-version -a",
72 | "release:github": "github-generate-release",
73 | "release:tags": "git push --follow-tags origin HEAD:master",
74 | "test": "exit 0"
75 | },
76 | "preferGlobal": true,
77 | "license": "MIT",
78 | "commitlint": {
79 | "extends": [
80 | "@commitlint/config-conventional"
81 | ],
82 | "rules": {
83 | "body-max-line-length": [
84 | 0
85 | ]
86 | }
87 | },
88 | "nano-staged": {
89 | "*.js": [
90 | "prettier-standard",
91 | "standard --fix"
92 | ],
93 | "*.md": [
94 | "standard-markdown"
95 | ],
96 | "package.json": [
97 | "finepack"
98 | ]
99 | },
100 | "simple-git-hooks": {
101 | "commit-msg": "npx commitlint --edit",
102 | "pre-commit": "npx nano-staged"
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/src/default/blacklist.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1)
4 |
5 | const MARKUP_FORMAT = [
6 | 'adoc',
7 | 'asc',
8 | 'asciidoc',
9 | 'creole',
10 | 'markdown',
11 | 'md',
12 | 'mdown',
13 | 'mediawiki',
14 | 'mkdn',
15 | 'org',
16 | 'pod',
17 | 'rdoc',
18 | 'rst',
19 | 'textile',
20 | 'txt',
21 | 'wiki'
22 | ]
23 |
24 | const cases = word => [
25 | ...MARKUP_FORMAT.map(format => `${word.toUpperCase()}.${format}`),
26 | `${word.toUpperCase()}`,
27 | ...MARKUP_FORMAT.map(format => `${word}.${format}`),
28 | `${word}`,
29 | ...MARKUP_FORMAT.map(format => `${capitalize(word)}.${format}`),
30 | `${capitalize(word)}`
31 | ]
32 |
33 | module.exports = [
34 | '__*__',
35 | '_config.yml',
36 | '.*',
37 | 'eslint',
38 | '*.d.ts',
39 | '*.flow',
40 | '*.map.json',
41 | '*.map',
42 | '*.opts',
43 | 'appveyor.yml',
44 | 'circle.yml',
45 | 'coverage/',
46 | 'demo/',
47 | 'doc/*',
48 | 'docs/*',
49 | 'eslint',
50 | 'example.*',
51 | 'example/*',
52 | 'examples',
53 | 'Gruntfile.js',
54 | 'Gulpfile.js',
55 | 'gulpfile.js',
56 | 'htmllint.js',
57 | 'jest.config.js',
58 | 'karma.conf.js',
59 | 'Makefile',
60 | 'node_modules/*',
61 | 'npm-*.log',
62 | 'package-lock.json',
63 | 'stylelint*',
64 | 'test*',
65 | 'tsconfig.json',
66 | 'yarn-*.log',
67 | 'yarn.lock'
68 | ]
69 | .concat(cases('author'))
70 | .concat(cases('authors'))
71 | .concat(cases('changelog'))
72 | .concat(cases('changes'))
73 | .concat(cases('contributing'))
74 | .concat(cases('contribution'))
75 | .concat(cases('contributors'))
76 | .concat(cases('code_of_conduct'))
77 | .concat(cases('governance'))
78 | .concat(cases('licence'))
79 | .concat(cases('license-*'))
80 | .concat(cases('license'))
81 | .concat(cases('history'))
82 | .concat(cases('readme'))
83 | .concat(cases('security'))
84 | .concat(cases('pull_request_template'))
85 | .concat(cases('issue_template'))
86 |
--------------------------------------------------------------------------------
/src/getProductionDeps.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const { isObject, forEach, get } = require('lodash')
4 | const { execSync } = require('child_process')
5 |
6 | const flattenDeps = (pkg, acc) => {
7 | const dependencies = get(pkg, 'dependencies')
8 | if (!isObject(dependencies)) return
9 |
10 | forEach(dependencies, (dependencyPkg, dependencyName) => {
11 | acc[dependencyName] = true
12 | flattenDeps(dependencyPkg, acc)
13 | })
14 | }
15 |
16 | const readProductionDeps = () => {
17 | let output
18 | try {
19 | output = execSync('npm ls --prod --all --json 2> /dev/null', {
20 | maxBuffer: 1024 * 1024 * 500
21 | })
22 | } catch (err) {
23 | output = err.stdout
24 | }
25 | return JSON.parse(output.toString())
26 | }
27 |
28 | module.exports = () => {
29 | const deps = {}
30 | const pkg = readProductionDeps()
31 | flattenDeps(pkg, deps)
32 | return Object.keys(deps)
33 | }
34 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const getProductionDeps = require('./getProductionDeps')
4 | const loadConfig = require('./load-config')
5 |
6 | const doNotIgnore = dep => `!${dep}`
7 |
8 | const cleanup = array => [...new Set(array)].sort((a, b) => a.localeCompare(b))
9 |
10 | const START = '### start auto generated using `untracked`'
11 | const FINISH = '### finished auto generated using `untracked`'
12 |
13 | module.exports = async opts => {
14 | const { blacklist, whitelist } = await loadConfig(opts)
15 | const removeBlacklistedDeps = dep => !blacklist.includes(dep)
16 | const includeNamespaces = dep =>
17 | dep.indexOf('/') >= 0 ? dep.split('/')[0] : dep
18 |
19 | const productionDeps = getProductionDeps()
20 | .filter(removeBlacklistedDeps)
21 | .map(includeNamespaces)
22 |
23 | const output = []
24 | .concat(
25 | cleanup(blacklist),
26 | cleanup(productionDeps.concat(whitelist).map(doNotIgnore))
27 | )
28 | .join('\n')
29 |
30 | return `${START}\n${output}\n${FINISH}`
31 | }
32 |
--------------------------------------------------------------------------------
/src/load-config.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const { get } = require('lodash')
4 | const JoyCon = require('joycon')
5 |
6 | const DEFAULT = {
7 | blacklist: require('./default/blacklist')
8 | }
9 |
10 | const loadConfig = async cwd => {
11 | const joycon = new JoyCon({
12 | cwd,
13 | packageKey: 'untracked',
14 | files: [
15 | 'package.json',
16 | '.untrackedrc',
17 | '.untrackedrc.json',
18 | '.untrackedrc.js',
19 | 'untracked.config.js'
20 | ]
21 | })
22 | const { data: configFile = {} } = (await joycon.load()) || {}
23 |
24 | return configFile
25 | }
26 |
27 | const createCollection = (configFile, propName) => {
28 | const collection = new Set(get(configFile, propName, []))
29 | DEFAULT[propName] && DEFAULT[propName].forEach(item => collection.add(item))
30 | return Array.from(collection)
31 | }
32 |
33 | module.exports = async ({ cwd = process.cwd() } = {}) => {
34 | const configFile = await loadConfig(cwd)
35 |
36 | return {
37 | whitelist: createCollection(configFile, 'whitelist'),
38 | blacklist: createCollection(configFile, 'blacklist')
39 | }
40 | }
41 |
--------------------------------------------------------------------------------