create-docusaurus 0.0.0-4395 → 0.0.0-4414
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/package.json +3 -3
- package/templates/classic/package.json +3 -3
- package/templates/classic-typescript/package.json +4 -4
- package/templates/facebook/package.json +3 -3
- package/templates/facebook/node_modules/hosted-git-info/CHANGELOG.md +0 -185
- package/templates/facebook/node_modules/hosted-git-info/LICENSE +0 -13
- package/templates/facebook/node_modules/hosted-git-info/README.md +0 -133
- package/templates/facebook/node_modules/hosted-git-info/git-host-info.js +0 -154
- package/templates/facebook/node_modules/hosted-git-info/git-host.js +0 -110
- package/templates/facebook/node_modules/hosted-git-info/index.js +0 -237
- package/templates/facebook/node_modules/hosted-git-info/package.json +0 -52
- package/templates/facebook/node_modules/lru-cache/LICENSE +0 -15
- package/templates/facebook/node_modules/lru-cache/README.md +0 -166
- package/templates/facebook/node_modules/lru-cache/index.js +0 -334
- package/templates/facebook/node_modules/lru-cache/package.json +0 -34
- package/templates/facebook/node_modules/normalize-package-data/AUTHORS +0 -4
- package/templates/facebook/node_modules/normalize-package-data/LICENSE +0 -15
- package/templates/facebook/node_modules/normalize-package-data/README.md +0 -108
- package/templates/facebook/node_modules/normalize-package-data/lib/extract_description.js +0 -22
- package/templates/facebook/node_modules/normalize-package-data/lib/fixer.js +0 -474
- package/templates/facebook/node_modules/normalize-package-data/lib/make_warning.js +0 -22
- package/templates/facebook/node_modules/normalize-package-data/lib/normalize.js +0 -48
- package/templates/facebook/node_modules/normalize-package-data/lib/safe_format.js +0 -11
- package/templates/facebook/node_modules/normalize-package-data/lib/typos.json +0 -25
- package/templates/facebook/node_modules/normalize-package-data/lib/warning_messages.json +0 -30
- package/templates/facebook/node_modules/normalize-package-data/package.json +0 -41
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
// A linked list to keep track of recently-used-ness
|
|
4
|
-
const Yallist = require('yallist')
|
|
5
|
-
|
|
6
|
-
const MAX = Symbol('max')
|
|
7
|
-
const LENGTH = Symbol('length')
|
|
8
|
-
const LENGTH_CALCULATOR = Symbol('lengthCalculator')
|
|
9
|
-
const ALLOW_STALE = Symbol('allowStale')
|
|
10
|
-
const MAX_AGE = Symbol('maxAge')
|
|
11
|
-
const DISPOSE = Symbol('dispose')
|
|
12
|
-
const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet')
|
|
13
|
-
const LRU_LIST = Symbol('lruList')
|
|
14
|
-
const CACHE = Symbol('cache')
|
|
15
|
-
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet')
|
|
16
|
-
|
|
17
|
-
const naiveLength = () => 1
|
|
18
|
-
|
|
19
|
-
// lruList is a yallist where the head is the youngest
|
|
20
|
-
// item, and the tail is the oldest. the list contains the Hit
|
|
21
|
-
// objects as the entries.
|
|
22
|
-
// Each Hit object has a reference to its Yallist.Node. This
|
|
23
|
-
// never changes.
|
|
24
|
-
//
|
|
25
|
-
// cache is a Map (or PseudoMap) that matches the keys to
|
|
26
|
-
// the Yallist.Node object.
|
|
27
|
-
class LRUCache {
|
|
28
|
-
constructor (options) {
|
|
29
|
-
if (typeof options === 'number')
|
|
30
|
-
options = { max: options }
|
|
31
|
-
|
|
32
|
-
if (!options)
|
|
33
|
-
options = {}
|
|
34
|
-
|
|
35
|
-
if (options.max && (typeof options.max !== 'number' || options.max < 0))
|
|
36
|
-
throw new TypeError('max must be a non-negative number')
|
|
37
|
-
// Kind of weird to have a default max of Infinity, but oh well.
|
|
38
|
-
const max = this[MAX] = options.max || Infinity
|
|
39
|
-
|
|
40
|
-
const lc = options.length || naiveLength
|
|
41
|
-
this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc
|
|
42
|
-
this[ALLOW_STALE] = options.stale || false
|
|
43
|
-
if (options.maxAge && typeof options.maxAge !== 'number')
|
|
44
|
-
throw new TypeError('maxAge must be a number')
|
|
45
|
-
this[MAX_AGE] = options.maxAge || 0
|
|
46
|
-
this[DISPOSE] = options.dispose
|
|
47
|
-
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false
|
|
48
|
-
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false
|
|
49
|
-
this.reset()
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// resize the cache when the max changes.
|
|
53
|
-
set max (mL) {
|
|
54
|
-
if (typeof mL !== 'number' || mL < 0)
|
|
55
|
-
throw new TypeError('max must be a non-negative number')
|
|
56
|
-
|
|
57
|
-
this[MAX] = mL || Infinity
|
|
58
|
-
trim(this)
|
|
59
|
-
}
|
|
60
|
-
get max () {
|
|
61
|
-
return this[MAX]
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
set allowStale (allowStale) {
|
|
65
|
-
this[ALLOW_STALE] = !!allowStale
|
|
66
|
-
}
|
|
67
|
-
get allowStale () {
|
|
68
|
-
return this[ALLOW_STALE]
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
set maxAge (mA) {
|
|
72
|
-
if (typeof mA !== 'number')
|
|
73
|
-
throw new TypeError('maxAge must be a non-negative number')
|
|
74
|
-
|
|
75
|
-
this[MAX_AGE] = mA
|
|
76
|
-
trim(this)
|
|
77
|
-
}
|
|
78
|
-
get maxAge () {
|
|
79
|
-
return this[MAX_AGE]
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// resize the cache when the lengthCalculator changes.
|
|
83
|
-
set lengthCalculator (lC) {
|
|
84
|
-
if (typeof lC !== 'function')
|
|
85
|
-
lC = naiveLength
|
|
86
|
-
|
|
87
|
-
if (lC !== this[LENGTH_CALCULATOR]) {
|
|
88
|
-
this[LENGTH_CALCULATOR] = lC
|
|
89
|
-
this[LENGTH] = 0
|
|
90
|
-
this[LRU_LIST].forEach(hit => {
|
|
91
|
-
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key)
|
|
92
|
-
this[LENGTH] += hit.length
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
trim(this)
|
|
96
|
-
}
|
|
97
|
-
get lengthCalculator () { return this[LENGTH_CALCULATOR] }
|
|
98
|
-
|
|
99
|
-
get length () { return this[LENGTH] }
|
|
100
|
-
get itemCount () { return this[LRU_LIST].length }
|
|
101
|
-
|
|
102
|
-
rforEach (fn, thisp) {
|
|
103
|
-
thisp = thisp || this
|
|
104
|
-
for (let walker = this[LRU_LIST].tail; walker !== null;) {
|
|
105
|
-
const prev = walker.prev
|
|
106
|
-
forEachStep(this, fn, walker, thisp)
|
|
107
|
-
walker = prev
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
forEach (fn, thisp) {
|
|
112
|
-
thisp = thisp || this
|
|
113
|
-
for (let walker = this[LRU_LIST].head; walker !== null;) {
|
|
114
|
-
const next = walker.next
|
|
115
|
-
forEachStep(this, fn, walker, thisp)
|
|
116
|
-
walker = next
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
keys () {
|
|
121
|
-
return this[LRU_LIST].toArray().map(k => k.key)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
values () {
|
|
125
|
-
return this[LRU_LIST].toArray().map(k => k.value)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
reset () {
|
|
129
|
-
if (this[DISPOSE] &&
|
|
130
|
-
this[LRU_LIST] &&
|
|
131
|
-
this[LRU_LIST].length) {
|
|
132
|
-
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value))
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
this[CACHE] = new Map() // hash of items by key
|
|
136
|
-
this[LRU_LIST] = new Yallist() // list of items in order of use recency
|
|
137
|
-
this[LENGTH] = 0 // length of items in the list
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
dump () {
|
|
141
|
-
return this[LRU_LIST].map(hit =>
|
|
142
|
-
isStale(this, hit) ? false : {
|
|
143
|
-
k: hit.key,
|
|
144
|
-
v: hit.value,
|
|
145
|
-
e: hit.now + (hit.maxAge || 0)
|
|
146
|
-
}).toArray().filter(h => h)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
dumpLru () {
|
|
150
|
-
return this[LRU_LIST]
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
set (key, value, maxAge) {
|
|
154
|
-
maxAge = maxAge || this[MAX_AGE]
|
|
155
|
-
|
|
156
|
-
if (maxAge && typeof maxAge !== 'number')
|
|
157
|
-
throw new TypeError('maxAge must be a number')
|
|
158
|
-
|
|
159
|
-
const now = maxAge ? Date.now() : 0
|
|
160
|
-
const len = this[LENGTH_CALCULATOR](value, key)
|
|
161
|
-
|
|
162
|
-
if (this[CACHE].has(key)) {
|
|
163
|
-
if (len > this[MAX]) {
|
|
164
|
-
del(this, this[CACHE].get(key))
|
|
165
|
-
return false
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const node = this[CACHE].get(key)
|
|
169
|
-
const item = node.value
|
|
170
|
-
|
|
171
|
-
// dispose of the old one before overwriting
|
|
172
|
-
// split out into 2 ifs for better coverage tracking
|
|
173
|
-
if (this[DISPOSE]) {
|
|
174
|
-
if (!this[NO_DISPOSE_ON_SET])
|
|
175
|
-
this[DISPOSE](key, item.value)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
item.now = now
|
|
179
|
-
item.maxAge = maxAge
|
|
180
|
-
item.value = value
|
|
181
|
-
this[LENGTH] += len - item.length
|
|
182
|
-
item.length = len
|
|
183
|
-
this.get(key)
|
|
184
|
-
trim(this)
|
|
185
|
-
return true
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const hit = new Entry(key, value, len, now, maxAge)
|
|
189
|
-
|
|
190
|
-
// oversized objects fall out of cache automatically.
|
|
191
|
-
if (hit.length > this[MAX]) {
|
|
192
|
-
if (this[DISPOSE])
|
|
193
|
-
this[DISPOSE](key, value)
|
|
194
|
-
|
|
195
|
-
return false
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
this[LENGTH] += hit.length
|
|
199
|
-
this[LRU_LIST].unshift(hit)
|
|
200
|
-
this[CACHE].set(key, this[LRU_LIST].head)
|
|
201
|
-
trim(this)
|
|
202
|
-
return true
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
has (key) {
|
|
206
|
-
if (!this[CACHE].has(key)) return false
|
|
207
|
-
const hit = this[CACHE].get(key).value
|
|
208
|
-
return !isStale(this, hit)
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
get (key) {
|
|
212
|
-
return get(this, key, true)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
peek (key) {
|
|
216
|
-
return get(this, key, false)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
pop () {
|
|
220
|
-
const node = this[LRU_LIST].tail
|
|
221
|
-
if (!node)
|
|
222
|
-
return null
|
|
223
|
-
|
|
224
|
-
del(this, node)
|
|
225
|
-
return node.value
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
del (key) {
|
|
229
|
-
del(this, this[CACHE].get(key))
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
load (arr) {
|
|
233
|
-
// reset the cache
|
|
234
|
-
this.reset()
|
|
235
|
-
|
|
236
|
-
const now = Date.now()
|
|
237
|
-
// A previous serialized cache has the most recent items first
|
|
238
|
-
for (let l = arr.length - 1; l >= 0; l--) {
|
|
239
|
-
const hit = arr[l]
|
|
240
|
-
const expiresAt = hit.e || 0
|
|
241
|
-
if (expiresAt === 0)
|
|
242
|
-
// the item was created without expiration in a non aged cache
|
|
243
|
-
this.set(hit.k, hit.v)
|
|
244
|
-
else {
|
|
245
|
-
const maxAge = expiresAt - now
|
|
246
|
-
// dont add already expired items
|
|
247
|
-
if (maxAge > 0) {
|
|
248
|
-
this.set(hit.k, hit.v, maxAge)
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
prune () {
|
|
255
|
-
this[CACHE].forEach((value, key) => get(this, key, false))
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const get = (self, key, doUse) => {
|
|
260
|
-
const node = self[CACHE].get(key)
|
|
261
|
-
if (node) {
|
|
262
|
-
const hit = node.value
|
|
263
|
-
if (isStale(self, hit)) {
|
|
264
|
-
del(self, node)
|
|
265
|
-
if (!self[ALLOW_STALE])
|
|
266
|
-
return undefined
|
|
267
|
-
} else {
|
|
268
|
-
if (doUse) {
|
|
269
|
-
if (self[UPDATE_AGE_ON_GET])
|
|
270
|
-
node.value.now = Date.now()
|
|
271
|
-
self[LRU_LIST].unshiftNode(node)
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return hit.value
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
const isStale = (self, hit) => {
|
|
279
|
-
if (!hit || (!hit.maxAge && !self[MAX_AGE]))
|
|
280
|
-
return false
|
|
281
|
-
|
|
282
|
-
const diff = Date.now() - hit.now
|
|
283
|
-
return hit.maxAge ? diff > hit.maxAge
|
|
284
|
-
: self[MAX_AGE] && (diff > self[MAX_AGE])
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
const trim = self => {
|
|
288
|
-
if (self[LENGTH] > self[MAX]) {
|
|
289
|
-
for (let walker = self[LRU_LIST].tail;
|
|
290
|
-
self[LENGTH] > self[MAX] && walker !== null;) {
|
|
291
|
-
// We know that we're about to delete this one, and also
|
|
292
|
-
// what the next least recently used key will be, so just
|
|
293
|
-
// go ahead and set it now.
|
|
294
|
-
const prev = walker.prev
|
|
295
|
-
del(self, walker)
|
|
296
|
-
walker = prev
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
const del = (self, node) => {
|
|
302
|
-
if (node) {
|
|
303
|
-
const hit = node.value
|
|
304
|
-
if (self[DISPOSE])
|
|
305
|
-
self[DISPOSE](hit.key, hit.value)
|
|
306
|
-
|
|
307
|
-
self[LENGTH] -= hit.length
|
|
308
|
-
self[CACHE].delete(hit.key)
|
|
309
|
-
self[LRU_LIST].removeNode(node)
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
class Entry {
|
|
314
|
-
constructor (key, value, length, now, maxAge) {
|
|
315
|
-
this.key = key
|
|
316
|
-
this.value = value
|
|
317
|
-
this.length = length
|
|
318
|
-
this.now = now
|
|
319
|
-
this.maxAge = maxAge || 0
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const forEachStep = (self, fn, node, thisp) => {
|
|
324
|
-
let hit = node.value
|
|
325
|
-
if (isStale(self, hit)) {
|
|
326
|
-
del(self, node)
|
|
327
|
-
if (!self[ALLOW_STALE])
|
|
328
|
-
hit = undefined
|
|
329
|
-
}
|
|
330
|
-
if (hit)
|
|
331
|
-
fn.call(thisp, hit.value, hit.key, self)
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
module.exports = LRUCache
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "lru-cache",
|
|
3
|
-
"description": "A cache object that deletes the least-recently-used items.",
|
|
4
|
-
"version": "6.0.0",
|
|
5
|
-
"author": "Isaac Z. Schlueter <i@izs.me>",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"mru",
|
|
8
|
-
"lru",
|
|
9
|
-
"cache"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"test": "tap",
|
|
13
|
-
"snap": "tap",
|
|
14
|
-
"preversion": "npm test",
|
|
15
|
-
"postversion": "npm publish",
|
|
16
|
-
"prepublishOnly": "git push origin --follow-tags"
|
|
17
|
-
},
|
|
18
|
-
"main": "index.js",
|
|
19
|
-
"repository": "git://github.com/isaacs/node-lru-cache.git",
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"benchmark": "^2.1.4",
|
|
22
|
-
"tap": "^14.10.7"
|
|
23
|
-
},
|
|
24
|
-
"license": "ISC",
|
|
25
|
-
"dependencies": {
|
|
26
|
-
"yallist": "^4.0.0"
|
|
27
|
-
},
|
|
28
|
-
"files": [
|
|
29
|
-
"index.js"
|
|
30
|
-
],
|
|
31
|
-
"engines": {
|
|
32
|
-
"node": ">=10"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
This package contains code originally written by Isaac Z. Schlueter.
|
|
2
|
-
Used with permission.
|
|
3
|
-
|
|
4
|
-
Copyright (c) Meryn Stol ("Author")
|
|
5
|
-
All rights reserved.
|
|
6
|
-
|
|
7
|
-
The BSD License
|
|
8
|
-
|
|
9
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
10
|
-
|
|
11
|
-
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
12
|
-
|
|
13
|
-
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
14
|
-
|
|
15
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
# normalize-package-data
|
|
2
|
-
|
|
3
|
-
[](https://travis-ci.org/npm/normalize-package-data)
|
|
4
|
-
|
|
5
|
-
normalize-package-data exports a function that normalizes package metadata. This data is typically found in a package.json file, but in principle could come from any source - for example the npm registry.
|
|
6
|
-
|
|
7
|
-
normalize-package-data is used by [read-package-json](https://npmjs.org/package/read-package-json) to normalize the data it reads from a package.json file. In turn, read-package-json is used by [npm](https://npmjs.org/package/npm) and various npm-related tools.
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
npm install normalize-package-data
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
Basic usage is really simple. You call the function that normalize-package-data exports. Let's call it `normalizeData`.
|
|
18
|
-
|
|
19
|
-
```javascript
|
|
20
|
-
normalizeData = require('normalize-package-data')
|
|
21
|
-
packageData = require("./package.json")
|
|
22
|
-
normalizeData(packageData)
|
|
23
|
-
// packageData is now normalized
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
#### Strict mode
|
|
27
|
-
|
|
28
|
-
You may activate strict validation by passing true as the second argument.
|
|
29
|
-
|
|
30
|
-
```javascript
|
|
31
|
-
normalizeData = require('normalize-package-data')
|
|
32
|
-
packageData = require("./package.json")
|
|
33
|
-
normalizeData(packageData, true)
|
|
34
|
-
// packageData is now normalized
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
If strict mode is activated, only Semver 2.0 version strings are accepted. Otherwise, Semver 1.0 strings are accepted as well. Packages must have a name, and the name field must not have contain leading or trailing whitespace.
|
|
38
|
-
|
|
39
|
-
#### Warnings
|
|
40
|
-
|
|
41
|
-
Optionally, you may pass a "warning" function. It gets called whenever the `normalizeData` function encounters something that doesn't look right. It indicates less than perfect input data.
|
|
42
|
-
|
|
43
|
-
```javascript
|
|
44
|
-
normalizeData = require('normalize-package-data')
|
|
45
|
-
packageData = require("./package.json")
|
|
46
|
-
warnFn = function(msg) { console.error(msg) }
|
|
47
|
-
normalizeData(packageData, warnFn)
|
|
48
|
-
// packageData is now normalized. Any number of warnings may have been logged.
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
You may combine strict validation with warnings by passing `true` as the second argument, and `warnFn` as third.
|
|
52
|
-
|
|
53
|
-
When `private` field is set to `true`, warnings will be suppressed.
|
|
54
|
-
|
|
55
|
-
### Potential exceptions
|
|
56
|
-
|
|
57
|
-
If the supplied data has an invalid name or version vield, `normalizeData` will throw an error. Depending on where you call `normalizeData`, you may want to catch these errors so can pass them to a callback.
|
|
58
|
-
|
|
59
|
-
## What normalization (currently) entails
|
|
60
|
-
|
|
61
|
-
* The value of `name` field gets trimmed (unless in strict mode).
|
|
62
|
-
* The value of the `version` field gets cleaned by `semver.clean`. See [documentation for the semver module](https://github.com/isaacs/node-semver).
|
|
63
|
-
* If `name` and/or `version` fields are missing, they are set to empty strings.
|
|
64
|
-
* If `files` field is not an array, it will be removed.
|
|
65
|
-
* If `bin` field is a string, then `bin` field will become an object with `name` set to the value of the `name` field, and `bin` set to the original string value.
|
|
66
|
-
* If `man` field is a string, it will become an array with the original string as its sole member.
|
|
67
|
-
* If `keywords` field is string, it is considered to be a list of keywords separated by one or more white-space characters. It gets converted to an array by splitting on `\s+`.
|
|
68
|
-
* All people fields (`author`, `maintainers`, `contributors`) get converted into objects with name, email and url properties.
|
|
69
|
-
* If `bundledDependencies` field (a typo) exists and `bundleDependencies` field does not, `bundledDependencies` will get renamed to `bundleDependencies`.
|
|
70
|
-
* If the value of any of the dependencies fields (`dependencies`, `devDependencies`, `optionalDependencies`) is a string, it gets converted into an object with familiar `name=>value` pairs.
|
|
71
|
-
* The values in `optionalDependencies` get added to `dependencies`. The `optionalDependencies` array is left untouched.
|
|
72
|
-
* As of v2: Dependencies that point at known hosted git providers (currently: github, bitbucket, gitlab) will have their URLs canonicalized, but protocols will be preserved.
|
|
73
|
-
* As of v2: Dependencies that use shortcuts for hosted git providers (`org/proj`, `github:org/proj`, `bitbucket:org/proj`, `gitlab:org/proj`, `gist:docid`) will have the shortcut left in place. (In the case of github, the `org/proj` form will be expanded to `github:org/proj`.) THIS MARKS A BREAKING CHANGE FROM V1, where the shorcut was previously expanded to a URL.
|
|
74
|
-
* If `description` field does not exist, but `readme` field does, then (more or less) the first paragraph of text that's found in the readme is taken as value for `description`.
|
|
75
|
-
* If `repository` field is a string, it will become an object with `url` set to the original string value, and `type` set to `"git"`.
|
|
76
|
-
* If `repository.url` is not a valid url, but in the style of "[owner-name]/[repo-name]", `repository.url` will be set to git+https://github.com/[owner-name]/[repo-name].git
|
|
77
|
-
* If `bugs` field is a string, the value of `bugs` field is changed into an object with `url` set to the original string value.
|
|
78
|
-
* If `bugs` field does not exist, but `repository` field points to a repository hosted on GitHub, the value of the `bugs` field gets set to an url in the form of https://github.com/[owner-name]/[repo-name]/issues . If the repository field points to a GitHub Gist repo url, the associated http url is chosen.
|
|
79
|
-
* If `bugs` field is an object, the resulting value only has email and url properties. If email and url properties are not strings, they are ignored. If no valid values for either email or url is found, bugs field will be removed.
|
|
80
|
-
* If `homepage` field is not a string, it will be removed.
|
|
81
|
-
* If the url in the `homepage` field does not specify a protocol, then http is assumed. For example, `myproject.org` will be changed to `http://myproject.org`.
|
|
82
|
-
* If `homepage` field does not exist, but `repository` field points to a repository hosted on GitHub, the value of the `homepage` field gets set to an url in the form of https://github.com/[owner-name]/[repo-name]#readme . If the repository field points to a GitHub Gist repo url, the associated http url is chosen.
|
|
83
|
-
|
|
84
|
-
### Rules for name field
|
|
85
|
-
|
|
86
|
-
If `name` field is given, the value of the name field must be a string. The string may not:
|
|
87
|
-
|
|
88
|
-
* start with a period.
|
|
89
|
-
* contain the following characters: `/@\s+%`
|
|
90
|
-
* contain any characters that would need to be encoded for use in urls.
|
|
91
|
-
* resemble the word `node_modules` or `favicon.ico` (case doesn't matter).
|
|
92
|
-
|
|
93
|
-
### Rules for version field
|
|
94
|
-
|
|
95
|
-
If `version` field is given, the value of the version field must be a valid *semver* string, as determined by the `semver.valid` method. See [documentation for the semver module](https://github.com/isaacs/node-semver).
|
|
96
|
-
|
|
97
|
-
### Rules for license field
|
|
98
|
-
|
|
99
|
-
The `license`/`licence` field should be a valid *SPDX license expression* or one of the special values allowed by [validate-npm-package-license](https://npmjs.com/package/validate-npm-package-license). See [documentation for the license field in package.json](https://docs.npmjs.com/files/package.json#license).
|
|
100
|
-
|
|
101
|
-
## Credits
|
|
102
|
-
|
|
103
|
-
This package contains code based on read-package-json written by Isaac Z. Schlueter. Used with permisson.
|
|
104
|
-
|
|
105
|
-
## License
|
|
106
|
-
|
|
107
|
-
normalize-package-data is released under the [BSD 2-Clause License](https://opensource.org/licenses/BSD-2-Clause).
|
|
108
|
-
Copyright (c) 2013 Meryn Stol
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module.exports = extractDescription
|
|
2
|
-
|
|
3
|
-
// Extracts description from contents of a readme file in markdown format
|
|
4
|
-
function extractDescription (d) {
|
|
5
|
-
if (!d) {
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
if (d === 'ERROR: No README data found!') {
|
|
9
|
-
return
|
|
10
|
-
}
|
|
11
|
-
// the first block of text before the first heading
|
|
12
|
-
// that isn't the first line heading
|
|
13
|
-
d = d.trim().split('\n')
|
|
14
|
-
for (var s = 0; d[s] && d[s].trim().match(/^(#|$)/); s++) {
|
|
15
|
-
;
|
|
16
|
-
}
|
|
17
|
-
var l = d.length
|
|
18
|
-
for (var e = s + 1; e < l && d[e].trim(); e++) {
|
|
19
|
-
;
|
|
20
|
-
}
|
|
21
|
-
return d.slice(s, e).join(' ').trim()
|
|
22
|
-
}
|