@cloudcannon/asset-uploader
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -1,1 +0,1 @@ | ||
{"version":"0.2.0","commands":{"analyse":{"id":"analyse","description":"Provide an output with the list of assets found to be uploaded.","pluginName":"@cloudcannon/asset-uploader","pluginType":"core","aliases":[],"flags":{"source":{"name":"source","type":"option","char":"s","description":"source of the website to be parsed"},"output":{"name":"output","type":"option","char":"o","description":"output changes"}},"args":[]},"complete":{"id":"complete","description":"Scan source directory, upload and rewrite source files with the new assets location.","pluginName":"@cloudcannon/asset-uploader","pluginType":"core","aliases":[],"flags":{"source":{"name":"source","type":"option","char":"s","description":"source of the website to be parsed"},"folder":{"name":"folder","type":"option","char":"f","description":"folder where to uploade the files"},"output":{"name":"output","type":"option","char":"o","description":"output changes"},"prefix":{"name":"prefix","type":"option","char":"p","description":"prefix to be appended in front of instead of the returned URL from provider"},"uploader":{"name":"uploader","type":"option","char":"u","description":"uploader to be used. Choose between: \"S3\"|\"cloudinary\"."}},"args":[]},"upload":{"id":"upload","description":"Scan source directory and upload assets to cloudinary.","pluginName":"@cloudcannon/asset-uploader","pluginType":"core","aliases":[],"flags":{"source":{"name":"source","type":"option","char":"s","description":"source of the website to be parsed"},"folder":{"name":"folder","type":"option","char":"f","description":"folder where to upload the files on cloudinary"},"output":{"name":"output","type":"option","char":"o","description":"output changes"},"prefix":{"name":"prefix","type":"option","char":"p","description":"prefix to be appended in front of instead of the returned URL from provider"},"uploader":{"name":"uploader","type":"option","char":"u","description":"uploader to be used. Choose between: \"S3\"|\"cloudinary\"."}},"args":[]}}} | ||
{"version":"0.2.1","commands":{"analyse":{"id":"analyse","description":"Provide an output with the list of assets found to be uploaded. Does not upload any files.","pluginName":"@cloudcannon/asset-uploader","pluginType":"core","aliases":[],"flags":{"source":{"name":"source","type":"option","char":"s","description":"source of the website to be parsed"},"output":{"name":"output","type":"option","char":"o","description":"filename for output changes summary"}},"args":[]},"complete":{"id":"complete","description":"Scan source directory, upload assets and rewrite source files with the new asset location.","pluginName":"@cloudcannon/asset-uploader","pluginType":"core","aliases":[],"flags":{"source":{"name":"source","type":"option","char":"s","description":"source of the website to be parsed"},"folder":{"name":"folder","type":"option","char":"f","description":"folder where to upload the files"},"output":{"name":"output","type":"option","char":"o","description":"filename for output changes summary"},"prefix":{"name":"prefix","type":"option","char":"p","description":"prefix for the URL of the uploaded asset - only applicable to S3 uploader"},"uploader":{"name":"uploader","type":"option","char":"u","description":"uploader to be used. Choose between: \"S3\"|\"cloudinary\""}},"args":[]},"upload":{"id":"upload","description":"Scan source directory and upload assets to selected provider. Does not update the original source files.","pluginName":"@cloudcannon/asset-uploader","pluginType":"core","aliases":[],"flags":{"source":{"name":"source","type":"option","char":"s","description":"source of the website to be parsed"},"folder":{"name":"folder","type":"option","char":"f","description":"folder where to upload the files"},"output":{"name":"output","type":"option","char":"o","description":"filename for output changes summary"},"prefix":{"name":"prefix","type":"option","char":"p","description":"prefix for the URL of the uploaded asset - only applicable to S3 uploader"},"uploader":{"name":"uploader","type":"option","char":"u","description":"uploader to be used. Choose between: \"S3\"|\"cloudinary\""}},"args":[]}}} |
{ | ||
"name": "@cloudcannon/asset-uploader", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Jonatah Benatti @jonatahb", | ||
@@ -5,0 +5,0 @@ "bin": { |
@@ -23,3 +23,3 @@ asset-uploader | ||
$ asset-uploader (-v|--version|version) | ||
@cloudcannon/asset-uploader/0.2.0 darwin-x64 node-v10.19.0 | ||
@cloudcannon/asset-uploader/0.2.1 darwin-x64 node-v10.19.0 | ||
$ asset-uploader --help [COMMAND] | ||
@@ -31,2 +31,10 @@ USAGE | ||
<!-- usagestop --> | ||
This package is designed to read all `.html` and `.md` files from a source repository (`-s`) and parse the front-matter object looking for image keys (keys that contain `_path`, `image` or `thumbnail`) that have a value pointing to a local file. | ||
Each image will be uploaded into the configured folder (`-f`) to S3 or Cloudinary based on the uploader selected (`-u`). | ||
For every sucessfull image uploaded the process will rewrite the path on the source `.html` or `.md` files. | ||
Images uploaded to S3 can use a prefix (`-p`) appended to URL to be updated on the source files. | ||
No changes are commit to the repo. This package only modifies the local files from the source directory. | ||
# API Keys | ||
@@ -64,3 +72,3 @@ In order to use this package you need to provide valid API Keys. | ||
Provide an output with the list of assets found to be uploaded. | ||
Provide an output with the list of assets found to be uploaded. Does not upload any files. | ||
@@ -72,11 +80,11 @@ ``` | ||
OPTIONS | ||
-o, --output=output output changes | ||
-o, --output=output filename for output changes summary | ||
-s, --source=source source of the website to be parsed | ||
``` | ||
_See code: [src/commands/analyse.js](https://github.com/CloudCannon/assets-uploader/blob/v0.2.0/src/commands/analyse.js)_ | ||
_See code: [src/commands/analyse.js](https://github.com/CloudCannon/assets-uploader/blob/v0.2.1/src/commands/analyse.js)_ | ||
## `asset-uploader complete` | ||
Scan source directory, upload and rewrite source files with the new assets location. | ||
Scan source directory, upload assets and rewrite source files with the new asset location. | ||
@@ -88,10 +96,10 @@ ``` | ||
OPTIONS | ||
-f, --folder=folder folder where to uploade the files | ||
-o, --output=output output changes | ||
-p, --prefix=prefix prefix to be appended in front of instead of the returned URL from provider | ||
-f, --folder=folder folder where to upload the files | ||
-o, --output=output filename for output changes summary | ||
-p, --prefix=prefix prefix for the URL of the uploaded asset - only applicable to S3 uploader | ||
-s, --source=source source of the website to be parsed | ||
-u, --uploader=uploader uploader to be used. Choose between: "S3"|"cloudinary". | ||
-u, --uploader=uploader uploader to be used. Choose between: "S3"|"cloudinary" | ||
``` | ||
_See code: [src/commands/complete.js](https://github.com/CloudCannon/assets-uploader/blob/v0.2.0/src/commands/complete.js)_ | ||
_See code: [src/commands/complete.js](https://github.com/CloudCannon/assets-uploader/blob/v0.2.1/src/commands/complete.js)_ | ||
@@ -117,3 +125,3 @@ ## `asset-uploader help [COMMAND]` | ||
Scan source directory and upload assets to cloudinary. | ||
Scan source directory and upload assets to selected provider. Does not update the original source files. | ||
@@ -125,10 +133,10 @@ ``` | ||
OPTIONS | ||
-f, --folder=folder folder where to upload the files on cloudinary | ||
-o, --output=output output changes | ||
-p, --prefix=prefix prefix to be appended in front of instead of the returned URL from provider | ||
-f, --folder=folder folder where to upload the files | ||
-o, --output=output filename for output changes summary | ||
-p, --prefix=prefix prefix for the URL of the uploaded asset - only applicable to S3 uploader | ||
-s, --source=source source of the website to be parsed | ||
-u, --uploader=uploader uploader to be used. Choose between: "S3"|"cloudinary". | ||
-u, --uploader=uploader uploader to be used. Choose between: "S3"|"cloudinary" | ||
``` | ||
_See code: [src/commands/upload.js](https://github.com/CloudCannon/assets-uploader/blob/v0.2.0/src/commands/upload.js)_ | ||
_See code: [src/commands/upload.js](https://github.com/CloudCannon/assets-uploader/blob/v0.2.1/src/commands/upload.js)_ | ||
<!-- commandsstop --> |
@@ -17,9 +17,9 @@ const { Command, flags } = require('@oclif/command'); | ||
AnalyseCommand.description = 'Provide an output with the list of assets found to be uploaded.'; | ||
AnalyseCommand.description = 'Provide an output with the list of assets found to be uploaded. Does not upload any files.'; | ||
AnalyseCommand.flags = { | ||
source: flags.string({ char: 's', description: 'source of the website to be parsed' }), | ||
output: flags.string({ char: 'o', description: 'output changes' }) | ||
output: flags.string({ char: 'o', description: 'filename for output changes summary' }) | ||
}; | ||
module.exports = AnalyseCommand; |
@@ -19,12 +19,12 @@ const { Command, flags } = require('@oclif/command'); | ||
CompleteCommand.description = 'Scan source directory, upload and rewrite source files with the new assets location.'; | ||
CompleteCommand.description = 'Scan source directory, upload assets and rewrite source files with the new asset location.'; | ||
CompleteCommand.flags = { | ||
source: flags.string({ char: 's', description: 'source of the website to be parsed' }), | ||
folder: flags.string({ char: 'f', description: 'folder where to uploade the files' }), | ||
output: flags.string({ char: 'o', description: 'output changes' }), | ||
prefix: flags.string({ char: 'p', description: 'prefix to be appended in front of instead of the returned URL from provider' }), | ||
uploader: flags.string({ char: 'u', description: 'uploader to be used. Choose between: "S3"|"cloudinary".' }) | ||
folder: flags.string({ char: 'f', description: 'folder where to upload the files' }), | ||
output: flags.string({ char: 'o', description: 'filename for output changes summary' }), | ||
prefix: flags.string({ char: 'p', description: 'prefix for the URL of the uploaded asset - only applicable to S3 uploader' }), | ||
uploader: flags.string({ char: 'u', description: 'uploader to be used. Choose between: "S3"|"cloudinary"' }) | ||
}; | ||
module.exports = CompleteCommand; |
@@ -19,12 +19,12 @@ const { Command, flags } = require('@oclif/command'); | ||
UploadCommand.description = 'Scan source directory and upload assets to cloudinary.'; | ||
UploadCommand.description = 'Scan source directory and upload assets to selected provider. Does not update the original source files.'; | ||
UploadCommand.flags = { | ||
source: flags.string({ char: 's', description: 'source of the website to be parsed' }), | ||
folder: flags.string({ char: 'f', description: 'folder where to upload the files on cloudinary' }), | ||
output: flags.string({ char: 'o', description: 'output changes' }), | ||
prefix: flags.string({ char: 'p', description: 'prefix to be appended in front of instead of the returned URL from provider' }), | ||
uploader: flags.string({ char: 'u', description: 'uploader to be used. Choose between: "S3"|"cloudinary".' }) | ||
folder: flags.string({ char: 'f', description: 'folder where to upload the files' }), | ||
output: flags.string({ char: 'o', description: 'filename for output changes summary' }), | ||
prefix: flags.string({ char: 'p', description: 'prefix for the URL of the uploaded asset - only applicable to S3 uploader' }), | ||
uploader: flags.string({ char: 'u', description: 'uploader to be used. Choose between: "S3"|"cloudinary"' }) | ||
}; | ||
module.exports = UploadCommand; |
@@ -9,5 +9,2 @@ const cloudinary = require('cloudinary').v2; | ||
upload(filePath, folder) { | ||
if (!this.config.cloudinary.cloud_name || !this.config.cloudinary.api_key || !this.config.cloudinary.api_secret) { | ||
throw new Error('Invalid configuration for Cloudinary API Keys!'); | ||
} | ||
this.setCloudinaryConfig(); | ||
@@ -26,4 +23,7 @@ const upload = cloudinary.uploader.upload(filePath, | ||
setCloudinaryConfig() { | ||
if (!this.config.cloudinary.cloud_name || !this.config.cloudinary.api_key || !this.config.cloudinary.api_secret) { | ||
throw new Error('Invalid configuration for Cloudinary API Keys!'); | ||
} | ||
cloudinary.config(this.config.cloudinary); | ||
} | ||
}; |
@@ -12,3 +12,3 @@ const AWS = require('aws-sdk'); | ||
upload(filePath, folder, fileName, prefix) { | ||
AWS.config.update(this.config.AWS); | ||
this.setCloudinaryConfig(); | ||
return new Promise(((resolve, reject) => { | ||
@@ -49,2 +49,10 @@ const s3 = new AWS.S3({ | ||
} | ||
// eslint-disable-next-line class-methods-use-this | ||
setCloudinaryConfig() { | ||
if (!this.config.AWS.bucket || !this.config.AWS.accessKeyId || !this.config.AWS.secretAccessKey) { | ||
throw new Error('Invalid configuration for AWS!'); | ||
} | ||
AWS.config.update(this.config.AWS); | ||
} | ||
}; |
26787
548
136