@cloudcannon/asset-uploader
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -1,1 +0,1 @@ | ||
{"version":"0.1.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"}},"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"}},"args":[]}}} | ||
{"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":[]}}} |
{ | ||
"name": "@cloudcannon/asset-uploader", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"author": "Jonatah Benatti @jonatahb", | ||
@@ -14,2 +14,3 @@ "bin": { | ||
"ansi-colors": "^4.1.1", | ||
"aws-sdk": "^2.751.0", | ||
"cli-progress": "^3.8.2", | ||
@@ -16,0 +17,0 @@ "cloudinary": "^1.22.0", |
@@ -23,3 +23,3 @@ asset-uploader | ||
$ asset-uploader (-v|--version|version) | ||
@cloudcannon/asset-uploader/0.1.0 darwin-x64 node-v10.19.0 | ||
@cloudcannon/asset-uploader/0.2.0 darwin-x64 node-v10.19.0 | ||
$ asset-uploader --help [COMMAND] | ||
@@ -32,7 +32,19 @@ USAGE | ||
# API Keys | ||
In order to use this package you need to provide valid Cloudinary API Keys. | ||
You can generate and managed the keys from the [Cloudinary security settings page](https://cloudinary.com/console/settings/security) | ||
In order to use this package you need to provide valid API Keys. | ||
Before you run the commands, please export the keys to environment variables using the following commands: | ||
## S3 | ||
``` | ||
$ export AWS_KEY='ABCDEFGHIJKLMNOPQRST' | ||
$ export AWS_SECRET='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | ||
$ export BUCKET='my-bucket-name' | ||
``` | ||
## Cloudinary | ||
You can generate and managed the keys from the [Cloudinary security settings page](https://cloudinary.com/console/settings/security) | ||
``` | ||
$ export CLOUD_NAME='my-cloud-name' | ||
@@ -63,3 +75,3 @@ $ export API_KEY='123456789012345' | ||
_See code: [src/commands/analyse.js](https://github.com/CloudCannon/assets-uploader/blob/v0.1.0/src/commands/analyse.js)_ | ||
_See code: [src/commands/analyse.js](https://github.com/CloudCannon/assets-uploader/blob/v0.2.0/src/commands/analyse.js)_ | ||
@@ -75,8 +87,10 @@ ## `asset-uploader complete` | ||
OPTIONS | ||
-f, --folder=folder folder where to uploade the files | ||
-o, --output=output output changes | ||
-s, --source=source source of the website to be parsed | ||
-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 | ||
-s, --source=source source of the website to be parsed | ||
-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.1.0/src/commands/complete.js)_ | ||
_See code: [src/commands/complete.js](https://github.com/CloudCannon/assets-uploader/blob/v0.2.0/src/commands/complete.js)_ | ||
@@ -109,8 +123,10 @@ ## `asset-uploader help [COMMAND]` | ||
OPTIONS | ||
-f, --folder=folder folder where to upload the files on cloudinary | ||
-o, --output=output output changes | ||
-s, --source=source source of the website to be parsed | ||
-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 | ||
-s, --source=source source of the website to be parsed | ||
-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.1.0/src/commands/upload.js)_ | ||
_See code: [src/commands/upload.js](https://github.com/CloudCannon/assets-uploader/blob/v0.2.0/src/commands/upload.js)_ | ||
<!-- commandsstop --> |
@@ -9,3 +9,3 @@ const { Command, flags } = require('@oclif/command'); | ||
source: flags.source || '/', | ||
output: flags.output || '/output.json', | ||
output: flags.output || null, | ||
folder: flags.folder || '' | ||
@@ -12,0 +12,0 @@ }; |
@@ -9,4 +9,6 @@ const { Command, flags } = require('@oclif/command'); | ||
source: flags.source || '/', | ||
output: flags.output || '/output.json', | ||
folder: flags.folder || '' | ||
output: flags.output || null, | ||
folder: flags.folder || '', | ||
prefix: flags.prefix || '', | ||
uploader: flags.uploader || null | ||
}; | ||
@@ -23,5 +25,7 @@ await runner.complete(options); | ||
folder: flags.string({ char: 'f', description: 'folder where to uploade the files' }), | ||
output: flags.string({ char: 'o', description: 'output changes' }) | ||
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".' }) | ||
}; | ||
module.exports = CompleteCommand; |
@@ -9,4 +9,6 @@ const { Command, flags } = require('@oclif/command'); | ||
source: flags.source || '/', | ||
output: flags.output || '/output.json', | ||
folder: flags.folder || '' | ||
output: flags.output || null, | ||
folder: flags.folder || '', | ||
prefix: flags.prefix || '', | ||
uploader: flags.uploader || null | ||
}; | ||
@@ -23,5 +25,7 @@ await runner.upload(options); | ||
folder: flags.string({ char: 'f', description: 'folder where to upload the files on cloudinary' }), | ||
output: flags.string({ char: 'o', description: 'output changes' }) | ||
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".' }) | ||
}; | ||
module.exports = UploadCommand; |
const environment = process.env.environment || 'development'; | ||
const cloudinary = require('./cloudinary.js'); | ||
const AWS = require('./AWS.js'); | ||
module.exports = { | ||
environment: environment, | ||
cloudinary: cloudinary | ||
cloudinary: cloudinary, | ||
AWS: AWS | ||
}; |
@@ -70,2 +70,3 @@ // const c = require('ansi-colors'); | ||
this.images = {}; | ||
this.outputPath = options.output || '/output.json'; | ||
} | ||
@@ -115,5 +116,5 @@ | ||
images = images || this.images; | ||
console.log(`Output result to: ${this.options.output}`); | ||
console.log(`Output result to: ${this.outputPath}`); | ||
// console.log(this.images); | ||
const outputPath = path.join(this.options.source, this.options.output); | ||
const outputPath = path.join(this.options.source, this.outputPath); | ||
// await fs(outputPath); | ||
@@ -120,0 +121,0 @@ await fs.writeFile(outputPath, JSON.stringify(images), { encoding: 'utf8' }); |
@@ -5,2 +5,7 @@ const vfs = require('vinyl-fs'); | ||
module.exports = class Reader extends ParserInterface { | ||
constructor(options) { | ||
super(options); | ||
this.outputPath = options.output || '/ReaderOutput.json'; | ||
} | ||
async readFiles() { | ||
@@ -7,0 +12,0 @@ console.log(`Scanning dir: ${this.options.source}`); |
const path = require('path'); | ||
const PromisePool = require('es6-promise-pool'); | ||
const cliProgress = require('cli-progress'); | ||
const cloudinary = require('./cloudinaryHelper'); | ||
const CloudinaryLib = require('./uploaders/CloudinaryLib'); | ||
const S3Lib = require('./uploaders/S3Lib'); | ||
const CLOUDINARY_BATCH_SIZE = 100; | ||
const BATCH_SIZE = 200; | ||
module.exports = class Uploader { | ||
constructor(options, images, config) { | ||
this.options = options; | ||
if (!this.options.uploader) { | ||
throw new Error('Uploader type not selected.'); | ||
} | ||
this.images = images; | ||
this.config = config; | ||
this.types = { | ||
S3: new S3Lib(this.config), | ||
cloudinary: new CloudinaryLib(this.config) | ||
}; | ||
this.uploaderLib = this.types[this.options.uploader]; | ||
} | ||
@@ -17,3 +29,8 @@ | ||
// create a new progress bar instance and use shades_classic theme | ||
const bar1 = new cliProgress.SingleBar({ etaBuffer: CLOUDINARY_BATCH_SIZE }, cliProgress.Presets.shades_classic); | ||
const bar1 = new cliProgress.SingleBar( | ||
{ | ||
etaBuffer: BATCH_SIZE | ||
}, | ||
cliProgress.Presets.shades_classic | ||
); | ||
@@ -27,4 +44,5 @@ let complete = 0; | ||
const uploadFolder = path.join(this.options.folder, dirName); | ||
// console.log(`Uploading: ${fullPath}`); | ||
const upload = () => cloudinary.upload(fullPath, this.config, uploadFolder) | ||
const fileName = path.basename(filePath); | ||
const upload = () => this.uploaderLib.upload(fullPath, uploadFolder, fileName, this.options.prefix) | ||
.then((result) => { | ||
@@ -53,3 +71,3 @@ // console.log(`Image uploaded: ${filePath} -> ${result.url}`); | ||
console.log(`Found ${totalImages} to upload!`); | ||
console.log(`Found ${totalImages} files to upload!`); | ||
@@ -70,3 +88,3 @@ // start the progress bar with a total value of 200 and start value of 0 | ||
// The number of promises to process simultaneously. | ||
const concurrency = CLOUDINARY_BATCH_SIZE; | ||
const concurrency = BATCH_SIZE; | ||
@@ -88,3 +106,3 @@ // Create a pool. | ||
errors.forEach((error) => { | ||
console.log('Erross encountered uploading files:'); | ||
console.log('Errors encountered uploading files:'); | ||
console.log(error); | ||
@@ -91,0 +109,0 @@ }); |
@@ -8,2 +8,3 @@ const vfs = require('vinyl-fs'); | ||
this.images = images; | ||
this.outputPath = options.output || '/WriterOutput.json'; | ||
} | ||
@@ -10,0 +11,0 @@ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
25461
20
541
128
14
5
+ Addedaws-sdk@^2.751.0
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedaws-sdk@2.1639.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@4.9.2(transitive)
+ Addedevents@1.1.1(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedieee754@1.1.13(transitive)
+ Addedis-arguments@1.1.1(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-generator-function@1.0.10(transitive)
+ Addedis-typed-array@1.1.13(transitive)
+ Addedjmespath@0.16.0(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedpunycode@1.3.2(transitive)
+ Addedquerystring@0.2.0(transitive)
+ Addedsax@1.2.1(transitive)
+ Addedurl@0.10.3(transitive)
+ Addedutil@0.12.5(transitive)
+ Addeduuid@8.0.0(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)
+ Addedxml2js@0.6.2(transitive)
+ Addedxmlbuilder@11.0.1(transitive)
- Removedinherits@2.0.4(transitive)