customizr 2.0.0 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
+
4
+ name: "Run Automated Tests"
5
+
6
+ on:
7
+ push:
8
+ branches: [main]
9
+ pull_request:
10
+ branches: [main]
11
+
12
+ jobs:
13
+ test:
14
+ runs-on: ubuntu-latest
15
+ timeout-minutes: 30
16
+ strategy:
17
+ matrix:
18
+ node-version: [12.x, 14.x, 16.x]
19
+ steps:
20
+ - name: Checkout code 🛎️
21
+ uses: actions/checkout@v2
22
+ - name: Setup Node.js ${{ matrix.node-version }}
23
+ uses: actions/setup-node@v2
24
+ with:
25
+ node-version: ${{ matrix.node-version }}
26
+ - name: Install dependencies and run tests
27
+ run: |
28
+ npm ci
29
+ npm test
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 The Modernizr team
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 all
13
- 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 THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 The Modernizr team
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 all
13
+ 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 THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,259 +1,258 @@
1
- # customizr
2
-
3
- [![Build Status](https://api.travis-ci.org/Modernizr/customizr.png?branch=master,develop)](https://travis-ci.org/Modernizr/customizr)
4
-
5
- [![NPM](https://nodei.co/npm/customizr.png?compact=true)](https://nodei.co/npm/customizr/)
6
-
7
- ##### *tl;dr:* This tool crawls through your project files, gathers up your references to Modernizr tests and outputs a lean, mean Modernizr machine.
8
-
9
- `customizr` is a Modernizr builder for your project. It is based on the Modernizr team's [Modulizr](https://github.com/Modernizr/modernizr.com/blob/gh-pages/i/js/modulizr.js) tool.
10
-
11
- This configurable task allows you to configure and export a custom Modernizr build. Use Modernizr's [annotated source](http://modernizr.com/downloads/modernizr-latest.js) for development, and let this tool worry about optimization.
12
-
13
- When you're ready to build, `customizr` will crawl your project for Modernizr test references and save out a minified, uglified, customized version using only the tests you've used in your JavaScript or (S)CSS.
14
-
15
- ## Example
16
-
17
- ### CSS / SCSS / LESS
18
-
19
- When going through css files, the crawler will not look for `display: flex` but rather if the code contains a css selector that is named like the Modernizr properties
20
-
21
- ```
22
- .flexbox {
23
- ...
24
- }
25
- ```
26
-
27
- or
28
-
29
- ```
30
- .no-flexbox {
31
- ...
32
- }
33
- ```
34
-
35
- ### Javascript
36
-
37
- When going through javascript files, the crawler will look for Modernizr calls like this one:
38
-
39
- ```
40
- if (!Modernizr.flexbox) {
41
- ...
42
- }
43
- ```
44
-
45
- ## Use with Grunt
46
-
47
- A Grunt wrapper is available at: [https://github.com/Modernizr/grunt-modernizr](https://github.com/Modernizr/grunt-modernizr)
48
-
49
- ## Use with Gulp
50
-
51
- A Gulp wrapper is available at: [https://github.com/rejas/gulp-modernizr](https://github.com/rejas/gulp-modernizr)
52
-
53
- ## Getting Started
54
-
55
- Install with npm: `npm install --save customizr`
56
-
57
- ## Documentation
58
-
59
- ### Command Line
60
-
61
- ```
62
- ./node-modules/.bin/customizr -c path/to/config
63
- ```
64
-
65
- ### Command Line Options
66
-
67
- ```
68
- -h, --help # Print options and usage
69
- -v, --version # Print the version number
70
- -c, --config # Path to your Modernizr config JSON file
71
- -f, --force # Ignore cached versions and force build Modernizr
72
- ```
73
-
74
- #### Config File
75
-
76
- A sample config file is below. Default values shown:
77
-
78
- ```javascript
79
- {
80
- // Avoid unnecessary builds (see Caching section below)
81
- "cache" : true,
82
-
83
- // Path to the build you're using for development.
84
- "devFile" : false,
85
-
86
- // Path to save out the built file
87
- "dest" : false,
88
-
89
- // Based on default settings on http://modernizr.com/download/
90
- "options" : [
91
- "addTest",
92
- "html5printshiv",
93
- "testProp"
94
- ],
95
-
96
- // By default, the build process is verbose
97
- "quiet" : false,
98
-
99
- // By default, source is uglified before saving
100
- "uglify" : true,
101
-
102
- // Define any tests you want to explicitly include
103
- "tests" : [],
104
-
105
- // Useful for excluding any tests that this tool will match
106
- // e.g. you use .notification class for notification elements,
107
- // but don’t want the test for Notification API
108
- "excludeTests": [],
109
-
110
- // By default, will crawl your project for references to Modernizr tests
111
- // Set to false to disable
112
- "crawl" : true,
113
-
114
- // Set to true to pass in buffers via the "files" parameter below
115
- "useBuffers" : false,
116
-
117
- // By default, this task will crawl all *.js, *.css, *.scss files.
118
- "files" : {
119
- "src": [
120
- "*[^(g|G)runt(file)?].{js,css,scss}",
121
- "**[^node_modules]/**/*.{js,css,scss}",
122
- "!lib/**/*"
123
- ]
124
- },
125
-
126
- // Have custom Modernizr tests? Add them here.
127
- "customTests" : [],
128
-
129
- // Add custom prefix to Modernizr CSS classes
130
- "classPrefix" : ''
131
- }
132
- ```
133
-
134
- ###### **`cache`** (Boolean, optional)
135
- When true, `customizr` will avoid the expensive build process if a certain criteria is met (see [Caching](#caching) section below)
136
-
137
- ###### **`devFile`** (String, optional)
138
- Path to the local build file you're using for development. This parameter is needed so `customizr` can skip your dev file when traversing your project to avoid triggering false positives. If you're using a remote file for development, set this option to `remote`.
139
-
140
- This is an optional parameter. If you do not have a local devFile, set this option to `false`. Note that if this parameter is false and you have a local development file, it will find all Modernizr references from this file and will defeat the purpose of this tool.
141
-
142
- ###### **`dest`** (String, optional)
143
- Path to save the customized Modernizr build. It defaults to `lib/modernizr-custom.js`.
144
-
145
- This is an optional parameter. If undefined or falsy, `customizr` will return the result as a string and will not write to disk.
146
-
147
- ###### **`options`** (Array, optional)
148
- An array of extra configuration options. Check the extra section on [modernizr.com/download](http://modernizr.com/download/) for complete options. Defaults are as they appear on the official site.
149
-
150
- This is an optional parameter.
151
-
152
- ###### **`quiet`** (Boolean, optional)
153
- By default, the build process is verbose. Set to true to build silently.
154
-
155
- This is an optional parameter.
156
-
157
- ###### **`uglify`** (Boolean, optional)
158
- By default, the source is uglified before save. Set to false to disable.
159
-
160
- This is an optional parameter.
161
-
162
- ###### **`tests`** (Array, optional)
163
- Define any tests you want to explicitly include. Check out the full set of test options [here](#ADD_LINK_LATER).
164
-
165
- This is an optional parameter.
166
-
167
- ###### **`excludeTests`** (Array, optional)
168
- Useful for excluding any tests that this tool will match. (e.g. you use .notification class for notification elements, but don’t want the test for Notification API).
169
-
170
- This is an optional parameter.
171
-
172
- ###### **`crawl`** (Boolean, optional)
173
- By default, this task will crawl your project for references to Modernizr tests. Set to false to disable.
174
-
175
- This is an optional parameter.
176
-
177
- ###### **`useBuffers`** (Boolean, optional)
178
- When `true`, the `files` parameter will accept an array of buffers in lieu of lookup strings.
179
-
180
- ###### **`files.src`** (Array, optional)
181
- When `crawl` = `true`, this task will crawl all `*.js`, `*.css`, `*.scss` files. You can override this by defining a custom `files.src` array. The object supports either:
182
-
183
- - An array of all [minimatch](https://github.com/isaacs/minimatch) options
184
- - An array of [Vinyl-style](https://github.com/wearefractal/vinyl) File buffers. `useBuffers` must be `true` to enable this functionality.
185
-
186
- This is an optional parameter.
187
-
188
- ###### **`customTests`** (Array, optional)
189
- Have custom Modernizr tests? Add paths to their location here. The object supports all [minimatch](https://github.com/isaacs/minimatch) options.
190
-
191
- This is an optional parameter.
192
-
193
- ###### **`classPrefix`** (String, optional)
194
- Add custom prefix to Modernizr classes to avoid clashes with your preexisting class names.
195
-
196
- This is an optional parameter.
197
-
198
- ## Caching
199
-
200
- For large projects, building a custom Modernizr file can be an expensive task. `customizr` does its best to avoid unnecessary builds by following a set criteria. When all of the following are met, it assumes that no changes are necessary:
201
-
202
- - If `customizr` has been previously run *AND*
203
- - If [`settings.cache`](#cache-boolean-optional) is true *AND*
204
- - If [`settings.dest`](#dest-string-optional) exists and is identical to the previous build *AND*
205
- - If the `customizr` version is identical to the previous build *AND*
206
- - If the `modernizr` dependency is identical to the previous build *AND*
207
- - If the current [`customizr` settings](#config-file) are identical to the previous build *THEN*
208
-
209
- `customizr` returns the cached data found in [`settings.dest`](#dest-string-optional)
210
-
211
- - If any of the preceding rules are falsy, the cache is invalidated.
212
- - If [`settings.cache`](#cache-boolean-optional) is falsy, the cache is invalidated.
213
- - If [`settings.dest`](#dest-string-optional) is not defined, the cache is invalidated.
214
-
215
- ## Programmatic API
216
-
217
- ### require("customizr")(settings, callback)
218
-
219
- - `settings` — A settings object as described above in "Config File".
220
- - `callback` — A callback to execute when the task is finished
221
-
222
- You can use `customizr` directly in your app if you prefer to not rely on the binary.
223
-
224
- ```js
225
- var modernizr = require("customizr");
226
-
227
- var settings = {
228
- "cache" : true,
229
- "devFile" : false,
230
- "dest" : false,
231
- "options" : [
232
- "setClasses",
233
- "addTest",
234
- "html5printshiv",
235
- "testProp"
236
- ],
237
- "uglify" : true,
238
- "tests" : [],
239
- "excludeTests": [],
240
- "crawl" : true,
241
- "useBuffers": false,
242
- "files" : {
243
- "src": [
244
- "*[^(g|G)runt(file)?].{js,css,scss}",
245
- "**[^node_modules]/**/*.{js,css,scss}",
246
- "!lib/**/*"
247
- ]
248
- },
249
- "customTests" : []
250
- };
251
-
252
- modernizr(settings, function () {
253
- // all done!
254
- });
255
- ```
256
-
257
- ## License
258
- Copyright (c) 2020 The Modernizr team
259
- Licensed under the MIT license.
1
+ # customizr
2
+
3
+ [![Build Status](https://github.com/Modernizr/customizr/actions/workflows/testing.yml/badge.svg)](https://github.com/Modernizr/customizr/actions/workflows/testing.yml)
4
+ [![NPM](https://nodei.co/npm/customizr.png?compact=true)](https://nodei.co/npm/customizr/)
5
+
6
+ ##### *tl;dr:* This tool crawls through your project files, gathers up your references to Modernizr tests and outputs a lean, mean Modernizr machine.
7
+
8
+ `customizr` is a Modernizr builder for your project. It is based on the Modernizr team's [Modulizr](https://github.com/Modernizr/modernizr.com/blob/gh-pages/i/js/modulizr.js) tool.
9
+
10
+ This configurable task allows you to configure and export a custom Modernizr build. Use Modernizr's [annotated source](http://modernizr.com/downloads/modernizr-latest.js) for development, and let this tool worry about optimization.
11
+
12
+ When you're ready to build, `customizr` will crawl your project for Modernizr test references and save out a minified, uglified, customized version using only the tests you've used in your JavaScript or (S)CSS.
13
+
14
+ ## Example
15
+
16
+ ### CSS / SCSS / LESS
17
+
18
+ When going through css files, the crawler will not look for `display: flex` but rather if the code contains a css selector that is named like the Modernizr properties
19
+
20
+ ```
21
+ .flexbox {
22
+ ...
23
+ }
24
+ ```
25
+
26
+ or
27
+
28
+ ```
29
+ .no-flexbox {
30
+ ...
31
+ }
32
+ ```
33
+
34
+ ### Javascript
35
+
36
+ When going through javascript files, the crawler will look for Modernizr calls like this one:
37
+
38
+ ```
39
+ if (!Modernizr.flexbox) {
40
+ ...
41
+ }
42
+ ```
43
+
44
+ ## Use with Grunt
45
+
46
+ A Grunt wrapper is available at: [https://github.com/Modernizr/grunt-modernizr](https://github.com/Modernizr/grunt-modernizr)
47
+
48
+ ## Use with Gulp
49
+
50
+ A Gulp wrapper is available at: [https://github.com/rejas/gulp-modernizr](https://github.com/rejas/gulp-modernizr)
51
+
52
+ ## Getting Started
53
+
54
+ Install with npm: `npm install --save customizr`
55
+
56
+ ## Documentation
57
+
58
+ ### Command Line
59
+
60
+ ```
61
+ ./node-modules/.bin/customizr -c path/to/config
62
+ ```
63
+
64
+ ### Command Line Options
65
+
66
+ ```
67
+ -h, --help # Print options and usage
68
+ -v, --version # Print the version number
69
+ -c, --config # Path to your Modernizr config JSON file
70
+ -f, --force # Ignore cached versions and force build Modernizr
71
+ ```
72
+
73
+ #### Config File
74
+
75
+ A sample config file is below. Default values shown:
76
+
77
+ ```javascript
78
+ {
79
+ // Avoid unnecessary builds (see Caching section below)
80
+ "cache" : true,
81
+
82
+ // Path to the build you're using for development.
83
+ "devFile" : false,
84
+
85
+ // Path to save out the built file
86
+ "dest" : false,
87
+
88
+ // Based on default settings on http://modernizr.com/download/
89
+ "options" : [
90
+ "addTest",
91
+ "html5printshiv",
92
+ "testProp"
93
+ ],
94
+
95
+ // By default, the build process is verbose
96
+ "quiet" : false,
97
+
98
+ // By default, source is uglified before saving
99
+ "uglify" : true,
100
+
101
+ // Define any tests you want to explicitly include
102
+ "tests" : [],
103
+
104
+ // Useful for excluding any tests that this tool will match
105
+ // e.g. you use .notification class for notification elements,
106
+ // but don’t want the test for Notification API
107
+ "excludeTests": [],
108
+
109
+ // By default, will crawl your project for references to Modernizr tests
110
+ // Set to false to disable
111
+ "crawl" : true,
112
+
113
+ // Set to true to pass in buffers via the "files" parameter below
114
+ "useBuffers" : false,
115
+
116
+ // By default, this task will crawl all *.js, *.css, *.scss files.
117
+ "files" : {
118
+ "src": [
119
+ "*[^(g|G)runt(file)?].{js,css,scss}",
120
+ "**[^node_modules]/**/*.{js,css,scss}",
121
+ "!lib/**/*"
122
+ ]
123
+ },
124
+
125
+ // Have custom Modernizr tests? Add them here.
126
+ "customTests" : [],
127
+
128
+ // Add custom prefix to Modernizr CSS classes
129
+ "classPrefix" : ''
130
+ }
131
+ ```
132
+
133
+ ###### **`cache`** (Boolean, optional)
134
+ When true, `customizr` will avoid the expensive build process if a certain criteria is met (see [Caching](#caching) section below)
135
+
136
+ ###### **`devFile`** (String, optional)
137
+ Path to the local build file you're using for development. This parameter is needed so `customizr` can skip your dev file when traversing your project to avoid triggering false positives. If you're using a remote file for development, set this option to `remote`.
138
+
139
+ This is an optional parameter. If you do not have a local devFile, set this option to `false`. Note that if this parameter is false and you have a local development file, it will find all Modernizr references from this file and will defeat the purpose of this tool.
140
+
141
+ ###### **`dest`** (String, optional)
142
+ Path to save the customized Modernizr build. It defaults to `lib/modernizr-custom.js`.
143
+
144
+ This is an optional parameter. If undefined or falsy, `customizr` will return the result as a string and will not write to disk.
145
+
146
+ ###### **`options`** (Array, optional)
147
+ An array of extra configuration options. Check the extra section on [modernizr.com/download](http://modernizr.com/download/) for complete options. Defaults are as they appear on the official site.
148
+
149
+ This is an optional parameter.
150
+
151
+ ###### **`quiet`** (Boolean, optional)
152
+ By default, the build process is verbose. Set to true to build silently.
153
+
154
+ This is an optional parameter.
155
+
156
+ ###### **`uglify`** (Boolean, optional)
157
+ By default, the source is uglified before save. Set to false to disable.
158
+
159
+ This is an optional parameter.
160
+
161
+ ###### **`tests`** (Array, optional)
162
+ Define any tests you want to explicitly include. Check out the full set of test options [here](#ADD_LINK_LATER).
163
+
164
+ This is an optional parameter.
165
+
166
+ ###### **`excludeTests`** (Array, optional)
167
+ Useful for excluding any tests that this tool will match. (e.g. you use .notification class for notification elements, but don’t want the test for Notification API).
168
+
169
+ This is an optional parameter.
170
+
171
+ ###### **`crawl`** (Boolean, optional)
172
+ By default, this task will crawl your project for references to Modernizr tests. Set to false to disable.
173
+
174
+ This is an optional parameter.
175
+
176
+ ###### **`useBuffers`** (Boolean, optional)
177
+ When `true`, the `files` parameter will accept an array of buffers in lieu of lookup strings.
178
+
179
+ ###### **`files.src`** (Array, optional)
180
+ When `crawl` = `true`, this task will crawl all `*.js`, `*.css`, `*.scss` files. You can override this by defining a custom `files.src` array. The object supports either:
181
+
182
+ - An array of all [minimatch](https://github.com/isaacs/minimatch) options
183
+ - An array of [Vinyl-style](https://github.com/wearefractal/vinyl) File buffers. `useBuffers` must be `true` to enable this functionality.
184
+
185
+ This is an optional parameter.
186
+
187
+ ###### **`customTests`** (Array, optional)
188
+ Have custom Modernizr tests? Add paths to their location here. The object supports all [minimatch](https://github.com/isaacs/minimatch) options.
189
+
190
+ This is an optional parameter.
191
+
192
+ ###### **`classPrefix`** (String, optional)
193
+ Add custom prefix to Modernizr classes to avoid clashes with your preexisting class names.
194
+
195
+ This is an optional parameter.
196
+
197
+ ## Caching
198
+
199
+ For large projects, building a custom Modernizr file can be an expensive task. `customizr` does its best to avoid unnecessary builds by following a set criteria. When all of the following are met, it assumes that no changes are necessary:
200
+
201
+ - If `customizr` has been previously run *AND*
202
+ - If [`settings.cache`](#cache-boolean-optional) is true *AND*
203
+ - If [`settings.dest`](#dest-string-optional) exists and is identical to the previous build *AND*
204
+ - If the `customizr` version is identical to the previous build *AND*
205
+ - If the `modernizr` dependency is identical to the previous build *AND*
206
+ - If the current [`customizr` settings](#config-file) are identical to the previous build *THEN*
207
+
208
+ `customizr` returns the cached data found in [`settings.dest`](#dest-string-optional)
209
+
210
+ - If any of the preceding rules are falsy, the cache is invalidated.
211
+ - If [`settings.cache`](#cache-boolean-optional) is falsy, the cache is invalidated.
212
+ - If [`settings.dest`](#dest-string-optional) is not defined, the cache is invalidated.
213
+
214
+ ## Programmatic API
215
+
216
+ ### require("customizr")(settings, callback)
217
+
218
+ - `settings` — A settings object as described above in "Config File".
219
+ - `callback` — A callback to execute when the task is finished
220
+
221
+ You can use `customizr` directly in your app if you prefer to not rely on the binary.
222
+
223
+ ```js
224
+ var modernizr = require("customizr");
225
+
226
+ var settings = {
227
+ "cache" : true,
228
+ "devFile" : false,
229
+ "dest" : false,
230
+ "options" : [
231
+ "setClasses",
232
+ "addTest",
233
+ "html5printshiv",
234
+ "testProp"
235
+ ],
236
+ "uglify" : true,
237
+ "tests" : [],
238
+ "excludeTests": [],
239
+ "crawl" : true,
240
+ "useBuffers": false,
241
+ "files" : {
242
+ "src": [
243
+ "*[^(g|G)runt(file)?].{js,css,scss}",
244
+ "**[^node_modules]/**/*.{js,css,scss}",
245
+ "!lib/**/*"
246
+ ]
247
+ },
248
+ "customTests" : []
249
+ };
250
+
251
+ modernizr(settings, function () {
252
+ // all done!
253
+ });
254
+ ```
255
+
256
+ ## License
257
+ Copyright (c) 2021 The Modernizr team
258
+ Licensed under the MIT license.