@dropthis/cli 0.1.5
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.
- package/README.md +171 -0
- package/dist/cli.cjs +1489 -0
- package/dist/cli.cjs.map +1 -0
- package/node_modules/@dropthis/node/README.md +90 -0
- package/node_modules/@dropthis/node/dist/index.cjs +1010 -0
- package/node_modules/@dropthis/node/dist/index.cjs.map +1 -0
- package/node_modules/@dropthis/node/dist/index.d.cts +408 -0
- package/node_modules/@dropthis/node/dist/index.d.ts +408 -0
- package/node_modules/@dropthis/node/dist/index.mjs +969 -0
- package/node_modules/@dropthis/node/dist/index.mjs.map +1 -0
- package/node_modules/@dropthis/node/package.json +55 -0
- package/node_modules/@nodelib/fs.scandir/LICENSE +21 -0
- package/node_modules/@nodelib/fs.scandir/README.md +171 -0
- package/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
- package/node_modules/@nodelib/fs.scandir/out/adapters/fs.js +19 -0
- package/node_modules/@nodelib/fs.scandir/out/constants.d.ts +4 -0
- package/node_modules/@nodelib/fs.scandir/out/constants.js +17 -0
- package/node_modules/@nodelib/fs.scandir/out/index.d.ts +12 -0
- package/node_modules/@nodelib/fs.scandir/out/index.js +26 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/async.js +104 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts +1 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/common.js +13 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts +5 -0
- package/node_modules/@nodelib/fs.scandir/out/providers/sync.js +54 -0
- package/node_modules/@nodelib/fs.scandir/out/settings.d.ts +20 -0
- package/node_modules/@nodelib/fs.scandir/out/settings.js +24 -0
- package/node_modules/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
- package/node_modules/@nodelib/fs.scandir/out/types/index.js +2 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts +2 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/fs.js +19 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts +2 -0
- package/node_modules/@nodelib/fs.scandir/out/utils/index.js +5 -0
- package/node_modules/@nodelib/fs.scandir/package.json +44 -0
- package/node_modules/@nodelib/fs.stat/LICENSE +21 -0
- package/node_modules/@nodelib/fs.stat/README.md +126 -0
- package/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
- package/node_modules/@nodelib/fs.stat/out/adapters/fs.js +17 -0
- package/node_modules/@nodelib/fs.stat/out/index.d.ts +12 -0
- package/node_modules/@nodelib/fs.stat/out/index.js +26 -0
- package/node_modules/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
- package/node_modules/@nodelib/fs.stat/out/providers/async.js +36 -0
- package/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts +3 -0
- package/node_modules/@nodelib/fs.stat/out/providers/sync.js +23 -0
- package/node_modules/@nodelib/fs.stat/out/settings.d.ts +16 -0
- package/node_modules/@nodelib/fs.stat/out/settings.js +16 -0
- package/node_modules/@nodelib/fs.stat/out/types/index.d.ts +4 -0
- package/node_modules/@nodelib/fs.stat/out/types/index.js +2 -0
- package/node_modules/@nodelib/fs.stat/package.json +37 -0
- package/node_modules/@nodelib/fs.walk/LICENSE +21 -0
- package/node_modules/@nodelib/fs.walk/README.md +215 -0
- package/node_modules/@nodelib/fs.walk/out/index.d.ts +14 -0
- package/node_modules/@nodelib/fs.walk/out/index.js +34 -0
- package/node_modules/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
- package/node_modules/@nodelib/fs.walk/out/providers/async.js +30 -0
- package/node_modules/@nodelib/fs.walk/out/providers/index.d.ts +4 -0
- package/node_modules/@nodelib/fs.walk/out/providers/index.js +9 -0
- package/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts +12 -0
- package/node_modules/@nodelib/fs.walk/out/providers/stream.js +34 -0
- package/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts +10 -0
- package/node_modules/@nodelib/fs.walk/out/providers/sync.js +14 -0
- package/node_modules/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
- package/node_modules/@nodelib/fs.walk/out/readers/async.js +97 -0
- package/node_modules/@nodelib/fs.walk/out/readers/common.d.ts +7 -0
- package/node_modules/@nodelib/fs.walk/out/readers/common.js +31 -0
- package/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
- package/node_modules/@nodelib/fs.walk/out/readers/reader.js +11 -0
- package/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts +15 -0
- package/node_modules/@nodelib/fs.walk/out/readers/sync.js +59 -0
- package/node_modules/@nodelib/fs.walk/out/settings.d.ts +30 -0
- package/node_modules/@nodelib/fs.walk/out/settings.js +26 -0
- package/node_modules/@nodelib/fs.walk/out/types/index.d.ts +8 -0
- package/node_modules/@nodelib/fs.walk/out/types/index.js +2 -0
- package/node_modules/@nodelib/fs.walk/package.json +44 -0
- package/node_modules/braces/LICENSE +21 -0
- package/node_modules/braces/README.md +586 -0
- package/node_modules/braces/index.js +170 -0
- package/node_modules/braces/lib/compile.js +60 -0
- package/node_modules/braces/lib/constants.js +57 -0
- package/node_modules/braces/lib/expand.js +113 -0
- package/node_modules/braces/lib/parse.js +331 -0
- package/node_modules/braces/lib/stringify.js +32 -0
- package/node_modules/braces/lib/utils.js +122 -0
- package/node_modules/braces/package.json +77 -0
- package/node_modules/fast-glob/LICENSE +21 -0
- package/node_modules/fast-glob/README.md +830 -0
- package/node_modules/fast-glob/out/index.d.ts +40 -0
- package/node_modules/fast-glob/out/index.js +102 -0
- package/node_modules/fast-glob/out/managers/tasks.d.ts +22 -0
- package/node_modules/fast-glob/out/managers/tasks.js +110 -0
- package/node_modules/fast-glob/out/providers/async.d.ts +9 -0
- package/node_modules/fast-glob/out/providers/async.js +23 -0
- package/node_modules/fast-glob/out/providers/filters/deep.d.ts +16 -0
- package/node_modules/fast-glob/out/providers/filters/deep.js +62 -0
- package/node_modules/fast-glob/out/providers/filters/entry.d.ts +17 -0
- package/node_modules/fast-glob/out/providers/filters/entry.js +85 -0
- package/node_modules/fast-glob/out/providers/filters/error.d.ts +8 -0
- package/node_modules/fast-glob/out/providers/filters/error.js +15 -0
- package/node_modules/fast-glob/out/providers/matchers/matcher.d.ts +33 -0
- package/node_modules/fast-glob/out/providers/matchers/matcher.js +45 -0
- package/node_modules/fast-glob/out/providers/matchers/partial.d.ts +4 -0
- package/node_modules/fast-glob/out/providers/matchers/partial.js +38 -0
- package/node_modules/fast-glob/out/providers/provider.d.ts +19 -0
- package/node_modules/fast-glob/out/providers/provider.js +48 -0
- package/node_modules/fast-glob/out/providers/stream.d.ts +11 -0
- package/node_modules/fast-glob/out/providers/stream.js +31 -0
- package/node_modules/fast-glob/out/providers/sync.d.ts +9 -0
- package/node_modules/fast-glob/out/providers/sync.js +23 -0
- package/node_modules/fast-glob/out/providers/transformers/entry.d.ts +8 -0
- package/node_modules/fast-glob/out/providers/transformers/entry.js +26 -0
- package/node_modules/fast-glob/out/readers/async.d.ts +10 -0
- package/node_modules/fast-glob/out/readers/async.js +35 -0
- package/node_modules/fast-glob/out/readers/reader.d.ts +15 -0
- package/node_modules/fast-glob/out/readers/reader.js +33 -0
- package/node_modules/fast-glob/out/readers/stream.d.ts +14 -0
- package/node_modules/fast-glob/out/readers/stream.js +55 -0
- package/node_modules/fast-glob/out/readers/sync.d.ts +12 -0
- package/node_modules/fast-glob/out/readers/sync.js +43 -0
- package/node_modules/fast-glob/out/settings.d.ts +164 -0
- package/node_modules/fast-glob/out/settings.js +59 -0
- package/node_modules/fast-glob/out/types/index.d.ts +31 -0
- package/node_modules/fast-glob/out/types/index.js +2 -0
- package/node_modules/fast-glob/out/utils/array.d.ts +2 -0
- package/node_modules/fast-glob/out/utils/array.js +22 -0
- package/node_modules/fast-glob/out/utils/errno.d.ts +2 -0
- package/node_modules/fast-glob/out/utils/errno.js +7 -0
- package/node_modules/fast-glob/out/utils/fs.d.ts +4 -0
- package/node_modules/fast-glob/out/utils/fs.js +19 -0
- package/node_modules/fast-glob/out/utils/index.d.ts +8 -0
- package/node_modules/fast-glob/out/utils/index.js +17 -0
- package/node_modules/fast-glob/out/utils/path.d.ts +13 -0
- package/node_modules/fast-glob/out/utils/path.js +68 -0
- package/node_modules/fast-glob/out/utils/pattern.d.ts +49 -0
- package/node_modules/fast-glob/out/utils/pattern.js +206 -0
- package/node_modules/fast-glob/out/utils/stream.d.ts +4 -0
- package/node_modules/fast-glob/out/utils/stream.js +17 -0
- package/node_modules/fast-glob/out/utils/string.d.ts +2 -0
- package/node_modules/fast-glob/out/utils/string.js +11 -0
- package/node_modules/fast-glob/package.json +81 -0
- package/node_modules/fastq/LICENSE +13 -0
- package/node_modules/fastq/README.md +310 -0
- package/node_modules/fastq/SECURITY.md +15 -0
- package/node_modules/fastq/bench.js +66 -0
- package/node_modules/fastq/eslint.config.js +11 -0
- package/node_modules/fastq/example.js +14 -0
- package/node_modules/fastq/example.mjs +9 -0
- package/node_modules/fastq/index.d.ts +59 -0
- package/node_modules/fastq/package.json +49 -0
- package/node_modules/fastq/queue.js +346 -0
- package/node_modules/fastq/test/example.ts +83 -0
- package/node_modules/fastq/test/promise.js +325 -0
- package/node_modules/fastq/test/test.js +733 -0
- package/node_modules/fastq/test/tsconfig.json +11 -0
- package/node_modules/fill-range/LICENSE +21 -0
- package/node_modules/fill-range/README.md +237 -0
- package/node_modules/fill-range/index.js +248 -0
- package/node_modules/fill-range/package.json +74 -0
- package/node_modules/glob-parent/LICENSE +15 -0
- package/node_modules/glob-parent/README.md +137 -0
- package/node_modules/glob-parent/index.js +42 -0
- package/node_modules/glob-parent/package.json +48 -0
- package/node_modules/ignore/LICENSE-MIT +21 -0
- package/node_modules/ignore/README.md +452 -0
- package/node_modules/ignore/index.d.ts +81 -0
- package/node_modules/ignore/index.js +784 -0
- package/node_modules/ignore/legacy.js +681 -0
- package/node_modules/ignore/package.json +87 -0
- package/node_modules/is-extglob/LICENSE +21 -0
- package/node_modules/is-extglob/README.md +107 -0
- package/node_modules/is-extglob/index.js +20 -0
- package/node_modules/is-extglob/package.json +69 -0
- package/node_modules/is-glob/LICENSE +21 -0
- package/node_modules/is-glob/README.md +206 -0
- package/node_modules/is-glob/index.js +150 -0
- package/node_modules/is-glob/package.json +81 -0
- package/node_modules/is-number/LICENSE +21 -0
- package/node_modules/is-number/README.md +187 -0
- package/node_modules/is-number/index.js +18 -0
- package/node_modules/is-number/package.json +82 -0
- package/node_modules/merge2/LICENSE +21 -0
- package/node_modules/merge2/README.md +144 -0
- package/node_modules/merge2/index.js +144 -0
- package/node_modules/merge2/package.json +43 -0
- package/node_modules/micromatch/LICENSE +21 -0
- package/node_modules/micromatch/README.md +1024 -0
- package/node_modules/micromatch/index.js +474 -0
- package/node_modules/micromatch/package.json +119 -0
- package/node_modules/mime-db/HISTORY.md +541 -0
- package/node_modules/mime-db/LICENSE +23 -0
- package/node_modules/mime-db/README.md +109 -0
- package/node_modules/mime-db/db.json +9342 -0
- package/node_modules/mime-db/index.js +12 -0
- package/node_modules/mime-db/package.json +56 -0
- package/node_modules/mime-types/HISTORY.md +421 -0
- package/node_modules/mime-types/LICENSE +23 -0
- package/node_modules/mime-types/README.md +126 -0
- package/node_modules/mime-types/index.js +211 -0
- package/node_modules/mime-types/mimeScore.js +52 -0
- package/node_modules/mime-types/package.json +45 -0
- package/node_modules/picomatch/LICENSE +21 -0
- package/node_modules/picomatch/README.md +716 -0
- package/node_modules/picomatch/index.js +3 -0
- package/node_modules/picomatch/lib/constants.js +184 -0
- package/node_modules/picomatch/lib/parse.js +1392 -0
- package/node_modules/picomatch/lib/picomatch.js +342 -0
- package/node_modules/picomatch/lib/scan.js +391 -0
- package/node_modules/picomatch/lib/utils.js +64 -0
- package/node_modules/picomatch/package.json +81 -0
- package/node_modules/queue-microtask/LICENSE +20 -0
- package/node_modules/queue-microtask/README.md +90 -0
- package/node_modules/queue-microtask/index.d.ts +2 -0
- package/node_modules/queue-microtask/index.js +9 -0
- package/node_modules/queue-microtask/package.json +55 -0
- package/node_modules/reusify/.github/dependabot.yml +7 -0
- package/node_modules/reusify/.github/workflows/ci.yml +96 -0
- package/node_modules/reusify/LICENSE +22 -0
- package/node_modules/reusify/README.md +139 -0
- package/node_modules/reusify/SECURITY.md +15 -0
- package/node_modules/reusify/benchmarks/createNoCodeFunction.js +30 -0
- package/node_modules/reusify/benchmarks/fib.js +13 -0
- package/node_modules/reusify/benchmarks/reuseNoCodeFunction.js +38 -0
- package/node_modules/reusify/eslint.config.js +14 -0
- package/node_modules/reusify/package.json +50 -0
- package/node_modules/reusify/reusify.d.ts +14 -0
- package/node_modules/reusify/reusify.js +33 -0
- package/node_modules/reusify/test.js +66 -0
- package/node_modules/reusify/tsconfig.json +11 -0
- package/node_modules/run-parallel/LICENSE +20 -0
- package/node_modules/run-parallel/README.md +85 -0
- package/node_modules/run-parallel/index.js +51 -0
- package/node_modules/run-parallel/package.json +58 -0
- package/node_modules/to-regex-range/LICENSE +21 -0
- package/node_modules/to-regex-range/README.md +305 -0
- package/node_modules/to-regex-range/index.js +288 -0
- package/node_modules/to-regex-range/package.json +88 -0
- package/package.json +53 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* mime-types
|
|
3
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
4
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Module dependencies.
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
var db = require('mime-db')
|
|
16
|
+
var extname = require('path').extname
|
|
17
|
+
var mimeScore = require('./mimeScore')
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Module variables.
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/
|
|
25
|
+
var TEXT_TYPE_REGEXP = /^text\//i
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Module exports.
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
exports.charset = charset
|
|
33
|
+
exports.charsets = { lookup: charset }
|
|
34
|
+
exports.contentType = contentType
|
|
35
|
+
exports.extension = extension
|
|
36
|
+
exports.extensions = Object.create(null)
|
|
37
|
+
exports.lookup = lookup
|
|
38
|
+
exports.types = Object.create(null)
|
|
39
|
+
exports._extensionConflicts = []
|
|
40
|
+
|
|
41
|
+
// Populate the extensions/types maps
|
|
42
|
+
populateMaps(exports.extensions, exports.types)
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get the default charset for a MIME type.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} type
|
|
48
|
+
* @return {boolean|string}
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
function charset (type) {
|
|
52
|
+
if (!type || typeof type !== 'string') {
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// TODO: use media-typer
|
|
57
|
+
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
|
58
|
+
var mime = match && db[match[1].toLowerCase()]
|
|
59
|
+
|
|
60
|
+
if (mime && mime.charset) {
|
|
61
|
+
return mime.charset
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// default text/* to utf-8
|
|
65
|
+
if (match && TEXT_TYPE_REGEXP.test(match[1])) {
|
|
66
|
+
return 'UTF-8'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return false
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Create a full Content-Type header given a MIME type or extension.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} str
|
|
76
|
+
* @return {boolean|string}
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
function contentType (str) {
|
|
80
|
+
// TODO: should this even be in this module?
|
|
81
|
+
if (!str || typeof str !== 'string') {
|
|
82
|
+
return false
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
var mime = str.indexOf('/') === -1 ? exports.lookup(str) : str
|
|
86
|
+
|
|
87
|
+
if (!mime) {
|
|
88
|
+
return false
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// TODO: use content-type or other module
|
|
92
|
+
if (mime.indexOf('charset') === -1) {
|
|
93
|
+
var charset = exports.charset(mime)
|
|
94
|
+
if (charset) mime += '; charset=' + charset.toLowerCase()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return mime
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get the default extension for a MIME type.
|
|
102
|
+
*
|
|
103
|
+
* @param {string} type
|
|
104
|
+
* @return {boolean|string}
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
function extension (type) {
|
|
108
|
+
if (!type || typeof type !== 'string') {
|
|
109
|
+
return false
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// TODO: use media-typer
|
|
113
|
+
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
|
114
|
+
|
|
115
|
+
// get extensions
|
|
116
|
+
var exts = match && exports.extensions[match[1].toLowerCase()]
|
|
117
|
+
|
|
118
|
+
if (!exts || !exts.length) {
|
|
119
|
+
return false
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return exts[0]
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Lookup the MIME type for a file path/extension.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} path
|
|
129
|
+
* @return {boolean|string}
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
function lookup (path) {
|
|
133
|
+
if (!path || typeof path !== 'string') {
|
|
134
|
+
return false
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// get the extension ("ext" or ".ext" or full path)
|
|
138
|
+
var extension = extname('x.' + path)
|
|
139
|
+
.toLowerCase()
|
|
140
|
+
.slice(1)
|
|
141
|
+
|
|
142
|
+
if (!extension) {
|
|
143
|
+
return false
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return exports.types[extension] || false
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Populate the extensions and types maps.
|
|
151
|
+
* @private
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
function populateMaps (extensions, types) {
|
|
155
|
+
Object.keys(db).forEach(function forEachMimeType (type) {
|
|
156
|
+
var mime = db[type]
|
|
157
|
+
var exts = mime.extensions
|
|
158
|
+
|
|
159
|
+
if (!exts || !exts.length) {
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// mime -> extensions
|
|
164
|
+
extensions[type] = exts
|
|
165
|
+
|
|
166
|
+
// extension -> mime
|
|
167
|
+
for (var i = 0; i < exts.length; i++) {
|
|
168
|
+
var extension = exts[i]
|
|
169
|
+
types[extension] = _preferredType(extension, types[extension], type)
|
|
170
|
+
|
|
171
|
+
// DELETE (eventually): Capture extension->type maps that change as a
|
|
172
|
+
// result of switching to mime-score. This is just to help make reviewing
|
|
173
|
+
// PR #119 easier, and can be removed once that PR is approved.
|
|
174
|
+
const legacyType = _preferredTypeLegacy(
|
|
175
|
+
extension,
|
|
176
|
+
types[extension],
|
|
177
|
+
type
|
|
178
|
+
)
|
|
179
|
+
if (legacyType !== types[extension]) {
|
|
180
|
+
exports._extensionConflicts.push([extension, legacyType, types[extension]])
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Resolve type conflict using mime-score
|
|
187
|
+
function _preferredType (ext, type0, type1) {
|
|
188
|
+
var score0 = type0 ? mimeScore(type0, db[type0].source) : 0
|
|
189
|
+
var score1 = type1 ? mimeScore(type1, db[type1].source) : 0
|
|
190
|
+
|
|
191
|
+
return score0 > score1 ? type0 : type1
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Resolve type conflict using pre-mime-score logic
|
|
195
|
+
function _preferredTypeLegacy (ext, type0, type1) {
|
|
196
|
+
var SOURCE_RANK = ['nginx', 'apache', undefined, 'iana']
|
|
197
|
+
|
|
198
|
+
var score0 = type0 ? SOURCE_RANK.indexOf(db[type0].source) : 0
|
|
199
|
+
var score1 = type1 ? SOURCE_RANK.indexOf(db[type1].source) : 0
|
|
200
|
+
|
|
201
|
+
if (
|
|
202
|
+
exports.types[extension] !== 'application/octet-stream' &&
|
|
203
|
+
(score0 > score1 ||
|
|
204
|
+
(score0 === score1 &&
|
|
205
|
+
exports.types[extension]?.slice(0, 12) === 'application/'))
|
|
206
|
+
) {
|
|
207
|
+
return type0
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return score0 > score1 ? type0 : type1
|
|
211
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// 'mime-score' back-ported to CommonJS
|
|
2
|
+
|
|
3
|
+
// Score RFC facets (see https://tools.ietf.org/html/rfc6838#section-3)
|
|
4
|
+
var FACET_SCORES = {
|
|
5
|
+
'prs.': 100,
|
|
6
|
+
'x-': 200,
|
|
7
|
+
'x.': 300,
|
|
8
|
+
'vnd.': 400,
|
|
9
|
+
default: 900
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Score mime source (Logic originally from `jshttp/mime-types` module)
|
|
13
|
+
var SOURCE_SCORES = {
|
|
14
|
+
nginx: 10,
|
|
15
|
+
apache: 20,
|
|
16
|
+
iana: 40,
|
|
17
|
+
default: 30 // definitions added by `jshttp/mime-db` project?
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var TYPE_SCORES = {
|
|
21
|
+
// prefer application/xml over text/xml
|
|
22
|
+
// prefer application/rtf over text/rtf
|
|
23
|
+
application: 1,
|
|
24
|
+
|
|
25
|
+
// prefer font/woff over application/font-woff
|
|
26
|
+
font: 2,
|
|
27
|
+
|
|
28
|
+
default: 0
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get each component of the score for a mime type. The sum of these is the
|
|
33
|
+
* total score. The higher the score, the more "official" the type.
|
|
34
|
+
*/
|
|
35
|
+
module.exports = function mimeScore (mimeType, source = 'default') {
|
|
36
|
+
if (mimeType === 'application/octet-stream') {
|
|
37
|
+
return 0
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const [type, subtype] = mimeType.split('/')
|
|
41
|
+
|
|
42
|
+
const facet = subtype.replace(/(\.|x-).*/, '$1')
|
|
43
|
+
|
|
44
|
+
const facetScore = FACET_SCORES[facet] || FACET_SCORES.default
|
|
45
|
+
const sourceScore = SOURCE_SCORES[source] || SOURCE_SCORES.default
|
|
46
|
+
const typeScore = TYPE_SCORES[type] || TYPE_SCORES.default
|
|
47
|
+
|
|
48
|
+
// All else being equal prefer shorter types
|
|
49
|
+
const lengthScore = 1 - mimeType.length / 100
|
|
50
|
+
|
|
51
|
+
return facetScore + sourceScore + typeScore + lengthScore
|
|
52
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mime-types",
|
|
3
|
+
"description": "The ultimate javascript content-type utility.",
|
|
4
|
+
"version": "3.0.1",
|
|
5
|
+
"contributors": [
|
|
6
|
+
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
|
7
|
+
"Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)",
|
|
8
|
+
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"mime",
|
|
13
|
+
"types"
|
|
14
|
+
],
|
|
15
|
+
"repository": "jshttp/mime-types",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"mime-db": "^1.54.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"eslint": "8.33.0",
|
|
21
|
+
"eslint-config-standard": "14.1.1",
|
|
22
|
+
"eslint-plugin-import": "2.27.5",
|
|
23
|
+
"eslint-plugin-markdown": "3.0.0",
|
|
24
|
+
"eslint-plugin-node": "11.1.0",
|
|
25
|
+
"eslint-plugin-promise": "6.1.1",
|
|
26
|
+
"eslint-plugin-standard": "4.1.0",
|
|
27
|
+
"mocha": "10.2.0",
|
|
28
|
+
"nyc": "15.1.0"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"HISTORY.md",
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"index.js",
|
|
34
|
+
"mimeScore.js"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">= 0.6"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"lint": "eslint .",
|
|
41
|
+
"test": "mocha --reporter spec test/test.js",
|
|
42
|
+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
|
43
|
+
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present, Jon Schlinkert.
|
|
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.
|