Parcourir la source

Move `Core` class to `@uppy/core` package.

Didn't move `Plugin` yet.

Steps taken:

```bash
cp -R package-template packages/@uppy/core
git mv src/core/Core.js packages/@uppy/core/src/index.js
git mv src/core/Core.test.js packages/@uppy/core/src/index.test.js
fgrep './core' -r src # find Core uses
vim src/react/propTypes.js src/... # update core requires to `@uppy/core`
fgrep require packages/@uppy/core/src/* # find npm dependencies of @uppy/core
vim packages/@uppy/core/{package.json,README.md} # Update, and add dependencies
```
Renée Kooi il y a 6 ans
Parent
commit
20e8949754

+ 21 - 0
packages/@uppy/core/LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2018 Transloadit
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 43 - 0
packages/@uppy/core/README.md

@@ -0,0 +1,43 @@
+# @uppy/core
+
+<img src="https://uppy.io/images/logos/uppy-dog-head-arrow.svg" width="120" alt="Uppy logo: a superman puppy in a pink suit" align="right">
+
+<a href="https://www.npmjs.com/package/@uppy/core"><img src="https://img.shields.io/npm/v/@uppy/core.svg?style=flat-square"></a>
+<a href="https://travis-ci.org/transloadit/uppy"><img src="https://img.shields.io/travis/transloadit/uppy/master.svg?style=flat-square" alt="Build Status"></a>
+
+Uppy is a sleek, modular JavaScript file uploader that integrates seamlessly with any application. It’s fast, easy to use and lets you worry about more important problems than building a file uploader.
+
+- **Fetch** files from local disk, remote urls, Google Drive, Dropbox, Instagram, or snap and record selfies with a camera;
+- **Preview** and edit metadata with a nice interface;
+- **Upload** to the final destination, optionally process/encode
+
+**[Read the docs](https://uppy.io/docs)** | **[Try Uppy](https://uppy.io/examples/dashboard/)**
+
+Uppy is being developed by the folks at [Transloadit](https://transloadit.com), a versatile file encoding service.
+
+## Example
+
+```js
+const Uppy = require('@uppy/core')
+
+const uppy = Uppy({ autoProceed: false })
+uppy.use(SomePlugin)
+```
+
+## Installation
+
+```bash
+$ npm install @uppy/core --save
+```
+
+We recommend installing from npm and then using a module bundler such as [Webpack](http://webpack.github.io/), [Browserify](http://browserify.org/) or [Rollup.js](http://rollupjs.org/).
+
+Alternatively, you can also use this plugin in a pre-built bundle from Transloadit's CDN: Edgly. In that case `Uppy` will attach itself to the global `window.Uppy` object. See the [main Uppy documentation](https://uppy.io/docs/#Installation) for instructions.
+
+## Documentation
+
+Documentation for this plugin can be found on the [Uppy website](https://uppy.io/docs/DOC_PAGE_HERE).
+
+## License
+
+[The MIT License](./LICENSE).

+ 32 - 0
packages/@uppy/core/package.json

@@ -0,0 +1,32 @@
+{
+  "name": "@uppy/core",
+  "description": "Core module for the extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding, remote providers like Instagram, Dropbox, Google Drive, S3 and more :dog:",
+  "version": "0.25.5",
+  "license": "MIT",
+  "main": "lib/index.js",
+  "jsnext:main": "src/index.js",
+  "types": "types/index.d.ts",
+  "keywords": [
+    "file uploader",
+    "plugin name and other keywords",
+    "uppy",
+    "uppy-plugin"
+  ],
+  "homepage": "https://uppy.io",
+  "bugs": {
+    "url": "https://github.com/transloadit/uppy/issues"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/transloadit/uppy.git"
+  },
+  "dependencies": {
+    "@uppy/utils": "^0.25.5",
+    "@uppy/store-default": "^0.25.5",
+    "cuid": "^2.1.1",
+    "lodash.throttle": "^4.1.1",
+    "mime-match": "^1.0.2",
+    "namespace-emitter": "^2.0.1",
+    "prettier-bytes": "^1.0.4"
+  }
+}

+ 0 - 0
src/core/__snapshots__/Core.test.js.snap → packages/@uppy/core/src/__snapshots__/index.test.js.snap


+ 0 - 0
src/core/Core.js → packages/@uppy/core/src/index.js


+ 8 - 8
src/core/Core.test.js → packages/@uppy/core/src/index.test.js

@@ -1,12 +1,12 @@
 const fs = require('fs')
 const path = require('path')
-const Core = require('./Core')
-const Plugin = require('./Plugin')
-const AcquirerPlugin1 = require('../../test/mocks/acquirerPlugin1')
-const AcquirerPlugin2 = require('../../test/mocks/acquirerPlugin2')
-const InvalidPlugin = require('../../test/mocks/invalidPlugin')
-const InvalidPluginWithoutId = require('../../test/mocks/invalidPluginWithoutId')
-const InvalidPluginWithoutType = require('../../test/mocks/invalidPluginWithoutType')
+const Core = require('./index')
+const Plugin = require('../../../../src/core/Plugin')
+const AcquirerPlugin1 = require('../../../../test/mocks/acquirerPlugin1')
+const AcquirerPlugin2 = require('../../../../test/mocks/acquirerPlugin2')
+const InvalidPlugin = require('../../../../test/mocks/invalidPlugin')
+const InvalidPluginWithoutId = require('../../../../test/mocks/invalidPluginWithoutId')
+const InvalidPluginWithoutType = require('../../../../test/mocks/invalidPluginWithoutType')
 
 jest.mock('cuid', () => {
   return () => 'cjd09qwxb000dlql4tp4doz8h'
@@ -15,7 +15,7 @@ jest.mock('@uppy/utils/lib/findDOMElement', () => {
   return () => null
 })
 
-const sampleImage = fs.readFileSync(path.join(__dirname, '../../test/resources/image.jpg'))
+const sampleImage = fs.readFileSync(path.join(__dirname, '../../../../test/resources/image.jpg'))
 
 describe('src/Core', () => {
   const RealCreateObjectUrl = global.URL.createObjectURL

+ 0 - 0
packages/@uppy/core/types/index.d.ts


+ 1 - 2
src/core/index.js

@@ -1,2 +1 @@
-const Core = require('./Core')
-module.exports = Core
+module.exports = require('@uppy/core')

+ 1 - 1
src/index.js

@@ -1,4 +1,4 @@
-const Core = require('./core')
+const Core = require('@uppy/core')
 
 // Communication with Uppy Server
 const server = require('./server')

+ 1 - 1
src/plugins/Dashboard/index.test.js

@@ -1,4 +1,4 @@
-const Core = require('../../core')
+const Core = require('@uppy/core')
 const DashboardPlugin = require('./index')
 const StatusBarPlugin = require('../StatusBar')
 

+ 1 - 1
src/plugins/Transloadit/index.test.js

@@ -1,4 +1,4 @@
-const Core = require('../../core')
+const Core = require('@uppy/core')
 const Transloadit = require('./')
 
 describe('Transloadit', () => {

+ 1 - 1
src/plugins/XHRUpload.test.js

@@ -1,5 +1,5 @@
 const nock = require('nock')
-const Core = require('../core')
+const Core = require('@uppy/core')
 const XHRUpload = require('./XHRUpload')
 
 describe('XHRUpload', () => {

+ 1 - 1
src/react/Dashboard.test.js

@@ -1,7 +1,7 @@
 const h = require('react').createElement
 const { mount, configure } = require('enzyme')
 const ReactAdapter = require('enzyme-adapter-react-16')
-const Uppy = require('../core')
+const Uppy = require('@uppy/core')
 
 beforeAll(() => {
   configure({ adapter: new ReactAdapter() })

+ 1 - 1
src/react/DashboardModal.test.js

@@ -1,7 +1,7 @@
 const h = require('react').createElement
 const { mount, configure } = require('enzyme')
 const ReactAdapter = require('enzyme-adapter-react-16')
-const Uppy = require('../core')
+const Uppy = require('@uppy/core')
 
 jest.mock('../plugins/Dashboard', () => require('./__mocks__/DashboardPlugin'))
 

+ 1 - 1
src/react/DragDrop.test.js

@@ -1,7 +1,7 @@
 const h = require('react').createElement
 const { mount, configure } = require('enzyme')
 const ReactAdapter = require('enzyme-adapter-react-16')
-const Uppy = require('../core')
+const Uppy = require('@uppy/core')
 
 beforeAll(() => {
   configure({ adapter: new ReactAdapter() })

+ 1 - 1
src/react/ProgressBar.test.js

@@ -1,7 +1,7 @@
 const h = require('react').createElement
 const { mount, configure } = require('enzyme')
 const ReactAdapter = require('enzyme-adapter-react-16')
-const Uppy = require('../core')
+const Uppy = require('@uppy/core')
 
 beforeAll(() => {
   configure({ adapter: new ReactAdapter() })

+ 1 - 1
src/react/StatusBar.test.js

@@ -1,7 +1,7 @@
 const h = require('react').createElement
 const { mount, configure } = require('enzyme')
 const ReactAdapter = require('enzyme-adapter-react-16')
-const Uppy = require('../core')
+const Uppy = require('@uppy/core')
 
 beforeAll(() => {
   configure({ adapter: new ReactAdapter() })

+ 1 - 1
src/react/propTypes.js

@@ -1,5 +1,5 @@
 const PropTypes = require('prop-types')
-const UppyCore = require('../core').Uppy
+const UppyCore = require('@uppy/core').Uppy
 
 // The `uppy` prop receives the Uppy core instance.
 const uppy = PropTypes.instanceOf(UppyCore).isRequired