Fix PR feedback

This commit is contained in:
Jim Laurie 2018-02-23 14:57:58 +01:00
parent d512d503b1
commit 543f21cdb1
57 changed files with 71 additions and 69 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -43,7 +43,7 @@
}
],
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 3.0.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -51,7 +51,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -42,7 +42,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -37,7 +37,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -39,7 +39,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -39,7 +39,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -39,7 +39,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -40,7 +40,6 @@ module.exports = scope => {
'dependencies': {
'lodash': '4.x.x',
'strapi': getDependencyVersion(cliPkg, 'strapi'),
'strapi-upload-local': getDependencyVersion(cliPkg, 'strapi'),
[scope.client.connector]: getDependencyVersion(cliPkg, 'strapi'),
[scope.client.module]: scope.client.version
},

View File

@ -44,7 +44,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -40,7 +40,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -39,7 +39,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -39,7 +39,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -39,7 +39,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -3,7 +3,7 @@
"version": "3.0.0-alpha.10.2",
"description": "Helper for Strapi plugins development",
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"author": {

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -42,7 +42,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.0.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -42,7 +42,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -44,7 +44,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -43,7 +43,7 @@
"url": "git://github.com/strapi/strapi.git"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 3.0.0"
},
"license": "MIT"

View File

@ -47,7 +47,7 @@
"url": "git://github.com/strapi/strapi.git"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 3.0.0"
},
"license": "MIT"

View File

@ -44,7 +44,7 @@
"url": "git://github.com/strapi/strapi.git"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 3.0.0"
},
"license": "MIT"

View File

@ -20,10 +20,10 @@ module.exports = async cb => {
name: 'upload'
});
fs.readdir(path.join(strapi.config.appPath, 'node_modules'), async (err, node_modules) => {
fs.readdir(path.join(strapi.config.appPath, 'plugins', 'upload', 'node_modules'), async (err, node_modules) => {
// get all upload provider
const uploads = _.filter(node_modules, (node_module) => {
return _.startsWith(node_module, ('strapi-upload-'));
return _.startsWith(node_module, ('strapi-upload'));
});
strapi.plugins.upload.config.providers = [];
@ -31,16 +31,16 @@ module.exports = async cb => {
// mount all providers to get configs
_.forEach(uploads, (node_module) => {
strapi.plugins.upload.config.providers.push(
require(path.join(`${strapi.config.appPath}/node_modules/${node_module}`))
require(path.join(`${strapi.config.appPath}/plugins/upload/node_modules/${node_module}`))
);
});
try {
// if profiver config not exit set one by default
// if provider config not exit set one by default
const config = await pluginStore.get({key: 'provider'});
if (!config) {
const provider = strapi.plugins.upload.config.providers[0];
const provider = _.find(strapi.plugins.upload.config.providers, {provider: 'local'});
const value = _.assign({}, provider, {
enabled: true,
@ -51,8 +51,8 @@ module.exports = async cb => {
await pluginStore.set({key: 'provider', value});
}
} catch (err) {
strapi.log.error(`Can't laod ${config.provider} upload provider`);
strapi.log.warn(`Please install strapi-upload-${config.provider} --save`);
strapi.log.error(`Can't load ${config.provider} upload provider.`);
strapi.log.warn(`Please install strapi-upload-${config.provider} --save in ${path.join(strapi.config.appPath, 'plugins', 'upload')} folder.`);
strapi.stop();
}

View File

@ -17,7 +17,6 @@ module.exports = {
*/
index: async (ctx) => {
console.log(ctx.request.body.files);
const config = await strapi.store({
environment: strapi.config.environment,
type: 'plugin',
@ -35,7 +34,7 @@ module.exports = {
for (var i = 0; i < files.length; i++) {
if (files[i].size > config.sizeLimit) {
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Upload.status.sizeLimit' }] }] : 'One of file is bigger than limit size!');
return ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: 'Upload.status.sizeLimit', values: {file: files[i].name} }] }] : `${files[i].name} file is bigger than limit size!`);
}
}

View File

@ -17,8 +17,7 @@
},
"ext": {
"type": "string",
"configurable": false,
"required": true
"configurable": false
},
"mime": {
"type": "string",

View File

@ -27,6 +27,7 @@
"uuid": "^3.2.1"
},
"devDependencies": {
"strapi-upload-local": "3.0.0-alpha.10.2",
"strapi-helper-plugin": "3.0.0-alpha.10.2"
},
"author": {

View File

@ -32,7 +32,7 @@ module.exports = {
return {
name: stream.name,
hash: uuid().replace(/-/g, ''),
ext: _.last(stream.name.split('.')),
ext: stream.name.split('.').length > 1 ? `.${_.last(stream.name.split('.'))}` : '',
buffer: Buffer.concat(buffers),
mime: stream.type,
size: (stream.size / 1000).toFixed(2)

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -43,7 +43,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -9,7 +9,7 @@ const _ = require('lodash');
const AWS = require('aws-sdk');
module.exports = {
provider: 's3',
provider: 'aws-s3',
name: 'Amazon Web Service S3',
auth: {
public: {
@ -69,12 +69,11 @@ module.exports = {
return new Promise((resolve, reject) => {
// upload file on S3 bucket
S3.upload({
Key: `${file.hash}.${file.ext}`,
Key: `${file.hash}${file.ext}`,
Body: new Buffer(file.buffer, 'binary'),
ACL: 'public-read'
}, (err, data) => {
if (err) {
console.log(err);
return reject(err);
}
@ -91,12 +90,11 @@ module.exports = {
S3.deleteObjects({
Delete: {
Objects: [{
Key: `${file.hash}.${file.ext}`
Key: `${file.hash}${file.ext}`
}]
}
}, (err, data) => {
if (err) {
console.log(err);
return reject(err);
}

View File

@ -1,5 +1,5 @@
{
"name": "strapi-upload-s3",
"name": "strapi-upload-aws-s3",
"version": "3.0.0-alpha.10.2",
"description": "AWS S3 provider for strapi upload",
"homepage": "http://strapi.io",
@ -17,7 +17,7 @@
"aws-sdk": "^2.199.0"
},
"strapi": {
"isHook": false
"isProvider": true
},
"author": {
"email": "hi@strapi.io",
@ -39,7 +39,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -16,12 +16,12 @@ module.exports = {
upload: (file) => {
return new Promise((resolve, reject) => {
// write file in public/assets folder
fs.writeFile(path.join(strapi.config.appPath, 'public', `uploads/${file.hash}.${file.ext}`), file.buffer, (err) => {
fs.writeFile(path.join(strapi.config.appPath, 'public', `uploads/${file.hash}${file.ext}`), file.buffer, (err) => {
if (err) {
return reject(err);
}
file.url = `/uploads/${file.hash}.${file.ext}`;
file.url = `/uploads/${file.hash}${file.ext}`;
resolve();
});
@ -29,8 +29,14 @@ module.exports = {
},
delete: (file) => {
return new Promise((resolve, reject) => {
const filePath = path.join(strapi.config.appPath, 'public', `uploads/${file.hash}${file.ext}`);
if (!fs.existsSync(filePath)) {
return resolve('File doesn\'t exist');
}
// remove file from public/assets folder
fs.unlink(path.join(strapi.config.appPath, 'public', file.url), (err) => {
fs.unlink(filePath, (err) => {
if (err) {
return reject(err);
}

View File

@ -13,7 +13,7 @@
"main": "./lib",
"dependencies": {},
"strapi": {
"isHook": false
"isProvider": true
},
"author": {
"email": "hi@strapi.io",
@ -35,7 +35,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
Copyright (c) 2017, Vandium Software Inc.
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:

View File

@ -41,7 +41,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"

View File

@ -1,4 +1,4 @@
Copyright (c) 2015-2017 Strapi Solutions.
Copyright (c) 2015-2018 Strapi Solutions.
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:

View File

@ -84,7 +84,7 @@
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 8.0.0",
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"preferGlobal": true,

View File

@ -107,7 +107,7 @@ watcher('🏗 Building...', 'npm run build');
shell.cd('../strapi-upload-local');
watcher('📦 Linking strapi-plugin-upload...', 'npm link --no-optional', false);
shell.cd('../strapi-upload-s3');
shell.cd('../strapi-upload-aws-s3');
watcher('📦 Linking strapi-plugin-upload...', 'npm link --no-optional', false);
shell.cd('../strapi-plugin-content-type-builder');