Selaa lähdekoodia

deps: replace `cuid` with `nanoid` (#3053)

Refs: https://github.com/transloadit/uppy/pull/3040#issuecomment-886468554
Antoine du Hamel 3 vuotta sitten
vanhempi
commit
defc7b40f8

+ 11 - 13
package-lock.json

@@ -47657,7 +47657,6 @@
       "version": "3.1.23",
       "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz",
       "integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==",
-      "dev": true,
       "bin": {
         "nanoid": "bin/nanoid.cjs"
       },
@@ -75496,7 +75495,7 @@
         "@uppy/companion-client": "file:../companion-client",
         "@uppy/utils": "file:../utils",
         "@uppy/xhr-upload": "file:../xhr-upload",
-        "cuid": "^2.1.1",
+        "nanoid": "^3.1.23",
         "qs-stringify": "^1.1.0"
       },
       "devDependencies": {
@@ -75844,10 +75843,10 @@
         "@transloadit/prettier-bytes": "0.0.7",
         "@uppy/store-default": "file:../store-default",
         "@uppy/utils": "file:../utils",
-        "cuid": "^2.1.1",
         "lodash.throttle": "^4.1.1",
         "mime-match": "^1.0.2",
         "namespace-emitter": "^2.0.1",
+        "nanoid": "^3.1.23",
         "preact": "^10.5.13"
       }
     },
@@ -75862,11 +75861,11 @@
         "@uppy/thumbnail-generator": "file:../thumbnail-generator",
         "@uppy/utils": "file:../utils",
         "classnames": "^2.2.6",
-        "cuid": "^2.1.1",
         "is-shallow-equal": "^1.0.1",
         "lodash.debounce": "^4.0.8",
         "lodash.throttle": "^4.1.1",
         "memoize-one": "^5.0.4",
+        "nanoid": "^3.1.23",
         "preact": "^10.5.13"
       },
       "devDependencies": {
@@ -76151,7 +76150,7 @@
       "version": "1.2.8",
       "license": "MIT",
       "dependencies": {
-        "cuid": "^2.1.1"
+        "nanoid": "^3.1.23"
       },
       "devDependencies": {
         "redux": "4.0.5"
@@ -76328,7 +76327,7 @@
       "dependencies": {
         "@uppy/companion-client": "file:../companion-client",
         "@uppy/utils": "file:../utils",
-        "cuid": "^2.1.1"
+        "nanoid": "^3.1.23"
       },
       "devDependencies": {
         "nock": "^13.1.0"
@@ -89424,7 +89423,7 @@
         "@uppy/companion-client": "file:../companion-client",
         "@uppy/utils": "file:../utils",
         "@uppy/xhr-upload": "file:../xhr-upload",
-        "cuid": "^2.1.1",
+        "nanoid": "^3.1.23",
         "qs-stringify": "^1.1.0",
         "whatwg-fetch": "3.6.2"
       }
@@ -89706,10 +89705,10 @@
         "@transloadit/prettier-bytes": "0.0.7",
         "@uppy/store-default": "file:../store-default",
         "@uppy/utils": "file:../utils",
-        "cuid": "^2.1.1",
         "lodash.throttle": "^4.1.1",
         "mime-match": "^1.0.2",
         "namespace-emitter": "^2.0.1",
+        "nanoid": "^3.1.23",
         "preact": "^10.5.13"
       }
     },
@@ -89724,11 +89723,11 @@
         "@uppy/thumbnail-generator": "file:../thumbnail-generator",
         "@uppy/utils": "file:../utils",
         "classnames": "^2.2.6",
-        "cuid": "^2.1.1",
         "is-shallow-equal": "^1.0.1",
         "lodash.debounce": "^4.0.8",
         "lodash.throttle": "^4.1.1",
         "memoize-one": "^5.0.4",
+        "nanoid": "^3.1.23",
         "preact": "^10.5.13",
         "resize-observer-polyfill": "^1.5.0"
       }
@@ -89916,7 +89915,7 @@
     "@uppy/store-redux": {
       "version": "file:packages/@uppy/store-redux",
       "requires": {
-        "cuid": "^2.1.1",
+        "nanoid": "^3.1.23",
         "redux": "4.0.5"
       },
       "dependencies": {
@@ -90044,7 +90043,7 @@
       "requires": {
         "@uppy/companion-client": "file:../companion-client",
         "@uppy/utils": "file:../utils",
-        "cuid": "^2.1.1",
+        "nanoid": "^3.1.23",
         "nock": "^13.1.0"
       }
     },
@@ -116301,8 +116300,7 @@
     "nanoid": {
       "version": "3.1.23",
       "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz",
-      "integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==",
-      "dev": true
+      "integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw=="
     },
     "nanomatch": {
       "version": "1.2.13",

+ 1 - 1
packages/@uppy/aws-s3/package.json

@@ -25,7 +25,7 @@
     "@uppy/companion-client": "file:../companion-client",
     "@uppy/utils": "file:../utils",
     "@uppy/xhr-upload": "file:../xhr-upload",
-    "cuid": "^2.1.1",
+    "nanoid": "^3.1.23",
     "qs-stringify": "^1.1.0"
   },
   "devDependencies": {

+ 2 - 2
packages/@uppy/aws-s3/src/MiniXHRUpload.js

@@ -1,4 +1,4 @@
-const cuid = require('cuid')
+const { nanoid } = require('nanoid')
 const { Provider, RequestClient, Socket } = require('@uppy/companion-client')
 const emitSocketProgress = require('@uppy/utils/lib/emitSocketProgress')
 const getSocketHost = require('@uppy/utils/lib/getSocketHost')
@@ -161,7 +161,7 @@ module.exports = class MiniXHRUpload {
         reject(error)
       })
 
-      const id = cuid()
+      const id = nanoid()
 
       xhr.upload.addEventListener('loadstart', (ev) => {
         this.uppy.log(`[AwsS3/XHRUpload] ${id} started`)

+ 1 - 1
packages/@uppy/core/package.json

@@ -23,10 +23,10 @@
     "@transloadit/prettier-bytes": "0.0.7",
     "@uppy/store-default": "file:../store-default",
     "@uppy/utils": "file:../utils",
-    "cuid": "^2.1.1",
     "lodash.throttle": "^4.1.1",
     "mime-match": "^1.0.2",
     "namespace-emitter": "^2.0.1",
+    "nanoid": "^3.1.23",
     "preact": "^10.5.13"
   }
 }

+ 2 - 2
packages/@uppy/core/src/index.js

@@ -1,7 +1,7 @@
 /* global AggregateError */
 const Translator = require('@uppy/utils/lib/Translator')
 const ee = require('namespace-emitter')
-const cuid = require('cuid')
+const { nanoid } = require('nanoid')
 const throttle = require('lodash.throttle')
 const prettierBytes = require('@transloadit/prettier-bytes')
 const match = require('mime-match')
@@ -1464,7 +1464,7 @@ class Uppy {
       throw new Error('Cannot create a new upload: already uploading.')
     }
 
-    const uploadID = cuid()
+    const uploadID = nanoid()
 
     this.emit('upload', {
       id: uploadID,

+ 2 - 2
packages/@uppy/core/src/index.test.js

@@ -11,8 +11,8 @@ const InvalidPluginWithoutId = require('../../../../test/mocks/invalidPluginWith
 const InvalidPluginWithoutType = require('../../../../test/mocks/invalidPluginWithoutType')
 const DeepFrozenStore = require('../../../../test/resources/DeepFrozenStore.js')
 
-jest.mock('cuid', () => {
-  return () => 'cjd09qwxb000dlql4tp4doz8h'
+jest.mock('nanoid', () => {
+  return { nanoid: () => 'cjd09qwxb000dlql4tp4doz8h' }
 })
 jest.mock('@uppy/utils/lib/findDOMElement', () => {
   return () => null

+ 1 - 1
packages/@uppy/dashboard/package.json

@@ -29,11 +29,11 @@
     "@uppy/thumbnail-generator": "file:../thumbnail-generator",
     "@uppy/utils": "file:../utils",
     "classnames": "^2.2.6",
-    "cuid": "^2.1.1",
     "is-shallow-equal": "^1.0.1",
     "lodash.debounce": "^4.0.8",
     "lodash.throttle": "^4.1.1",
     "memoize-one": "^5.0.4",
+    "nanoid": "^3.1.23",
     "preact": "^10.5.13"
   },
   "devDependencies": {

+ 2 - 2
packages/@uppy/dashboard/src/index.js

@@ -8,7 +8,7 @@ const findAllDOMElements = require('@uppy/utils/lib/findAllDOMElements')
 const toArray = require('@uppy/utils/lib/toArray')
 const getDroppedFiles = require('@uppy/utils/lib/getDroppedFiles')
 const getTextDirection = require('@uppy/utils/lib/getTextDirection')
-const cuid = require('cuid')
+const { nanoid } = require('nanoid')
 const trapFocus = require('./utils/trapFocus')
 const createSuperFocus = require('./utils/createSuperFocus')
 const memoize = require('memoize-one').default || require('memoize-one')
@@ -46,7 +46,7 @@ module.exports = class Dashboard extends UIPlugin {
     this.id = this.opts.id || 'Dashboard'
     this.title = 'Dashboard'
     this.type = 'orchestrator'
-    this.modalName = `uppy-Dashboard-${cuid()}`
+    this.modalName = `uppy-Dashboard-${nanoid()}`
 
     this.defaultLocale = {
       strings: {

+ 1 - 1
packages/@uppy/store-redux/package.json

@@ -20,7 +20,7 @@
     "url": "git+https://github.com/transloadit/uppy.git"
   },
   "dependencies": {
-    "cuid": "^2.1.1"
+    "nanoid": "^3.1.23"
   },
   "devDependencies": {
     "redux": "4.0.5"

+ 2 - 2
packages/@uppy/store-redux/src/index.js

@@ -1,4 +1,4 @@
-const cuid = require('cuid')
+const { nanoid } = require('nanoid')
 
 // Redux action name.
 const STATE_UPDATE = 'uppy/STATE_UPDATE'
@@ -20,7 +20,7 @@ class ReduxStore {
 
   constructor (opts) {
     this._store = opts.store
-    this._id = opts.id || cuid()
+    this._id = opts.id || nanoid()
     this._selector = opts.selector || defaultSelector(this._id)
 
     // Calling `setState` to dispatch an action to the Redux store.

+ 1 - 1
packages/@uppy/xhr-upload/package.json

@@ -26,7 +26,7 @@
   "dependencies": {
     "@uppy/companion-client": "file:../companion-client",
     "@uppy/utils": "file:../utils",
-    "cuid": "^2.1.1"
+    "nanoid": "^3.1.23"
   },
   "devDependencies": {
     "nock": "^13.1.0"

+ 2 - 2
packages/@uppy/xhr-upload/src/index.js

@@ -1,5 +1,5 @@
 const { BasePlugin } = require('@uppy/core')
-const cuid = require('cuid')
+const { nanoid } = require('nanoid')
 const Translator = require('@uppy/utils/lib/Translator')
 const { Provider, RequestClient, Socket } = require('@uppy/companion-client')
 const emitSocketProgress = require('@uppy/utils/lib/emitSocketProgress')
@@ -250,7 +250,7 @@ module.exports = class XHRUpload extends BasePlugin {
         reject(error)
       })
 
-      const id = cuid()
+      const id = nanoid()
 
       xhr.upload.addEventListener('loadstart', () => {
         this.uppy.log(`[XHRUpload] ${id} started`)