Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: add prettier, lint-staged, husky and eslint rules #1120

Merged
merged 29 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f8ddba4
add config and format code
trim21 Apr 9, 2023
188b9bd
fix ci
trim21 Apr 9, 2023
1c11f81
single quote
trim21 Apr 9, 2023
870a475
keep config only, format code latter
trim21 Apr 9, 2023
8cdbdf7
revert unexpected change
trim21 Apr 9, 2023
a893308
revert unexpected change
trim21 Apr 9, 2023
29d17f3
Update package.json
trim21 Apr 9, 2023
557dc1c
update rule
trim21 Apr 9, 2023
1ba9d0c
fix lint-staged
trim21 Apr 9, 2023
f85c21f
format code
trim21 Apr 9, 2023
c060a44
wrong ignore file
trim21 Apr 9, 2023
5b91c39
add curly
trim21 Apr 10, 2023
690423d
Merge remote-tracking branch 'upstream/master' into style
trim21 Apr 12, 2023
887fd8f
exclude ci files from prettier
trim21 Apr 12, 2023
94e19e0
ci: split lint/build ci
trim21 Apr 12, 2023
6490d6c
ci step name
trim21 Apr 12, 2023
69763bf
set ci in windows in parallel 3
trim21 Apr 12, 2023
4ca489c
add 'no-template-curly-in-string'
trim21 Apr 12, 2023
152da40
format examples
trim21 Apr 13, 2023
e1c7e3f
add trailingComma: all
trim21 Apr 14, 2023
82f45ff
Merge branch 'master' into style
trim21 Apr 19, 2023
4413d5c
Merge branch 'master' into style
trim21 Apr 26, 2023
c1829e3
Merge branch 'style' of https://github.com/trim21/minio-js into style
trim21 Apr 26, 2023
79da518
ignore yarn v2 config
trim21 Apr 26, 2023
f5da542
remove unexpected rollup plugin
trim21 Apr 26, 2023
ea89a27
Merge branch 'master' into style
trim21 Apr 26, 2023
e1fab52
Merge remote-tracking branch 'origin/master' into style
trim21 Apr 30, 2023
5b2d0cd
use latest npm
trim21 Apr 30, 2023
8c3b7fb
chmod
trim21 Apr 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ node_modules

/dist/
yarn.lock
.yarn/
.yarnrc.yml
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion examples/compose-object-test-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const os = require('os')
const splitFile = require('split-file')
const fs = require('fs')

var Minio = require('minio')
var Minio = require('../dist/main/minio')
var Helpers = require('../dist/main/helpers')

var s3Client = new Minio.Client({
Expand Down
2 changes: 1 addition & 1 deletion examples/compose-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname and my-objectname
// are dummy values, please replace them with original values.

var Minio = require('minio')
var Minio = require('../dist/main/minio')
var Helpers = require('../dist/main/helpers')

var s3Client = new Minio.Client({
Expand Down
2 changes: 1 addition & 1 deletion examples/select-object-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY, my-bucketname
// and my-objectname are dummy values, please replace them with original values.

var Minio = require('minio')
var Minio = require('../dist/main/minio')

var s3Client = new Minio.Client({
endPoint: 's3.amazonaws.com',
Expand Down
782 changes: 74 additions & 708 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
"devDependencies": {
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.10",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-typescript": "^11.1.0",
"@types/lodash": "^4.14.192",
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "^5.57.1",
Expand Down
2 changes: 2 additions & 0 deletions src/main/AssumeRoleProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class AssumeRoleProvider extends CredentialProvider {
token,
webIdentityToken,
action = 'AssumeRole',
transportAgent = undefined,
}) {
super({})

Expand Down Expand Up @@ -112,6 +113,7 @@ class AssumeRoleProvider extends CredentialProvider {
'x-amz-date': makeDateLong(date),
'x-amz-content-sha256': contentSha256,
},
agent: this.transportAgent,
}

const authorization = signV4ByServiceName(requestOptions, this.accessKey, this.secretKey, this.region, date, 'sts')
Expand Down
33 changes: 24 additions & 9 deletions src/main/minio.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ export class Client {
// if custom transport agent is set, use it.
if (params.transportAgent) {
if (!isObject(params.transportAgent)) {
throw new errors.InvalidArgumentError(`Invalid transportAgent type: ${params.transportAgent}, expected to be type "object"`)
throw new errors.InvalidArgumentError(
`Invalid transportAgent type: ${params.transportAgent}, expected to be type "object"`,
)
}

transportAgent = params.transportAgent
Expand Down Expand Up @@ -1157,13 +1159,17 @@ export class Client {
(cb) => fs.stat(filePath, cb),
(stats, cb) => {
size = stats.size
var stream
var cbTriggered = false
var origCb = cb
cb = function () {
if (cbTriggered) {
return
}
cbTriggered = true
if (stream) {
stream.destroy()
}
return origCb.apply(this, arguments)
}
if (size > this.maxObjectSize) {
Expand All @@ -1185,7 +1191,7 @@ export class Client {
.on('data', (data) => {
var md5sum = data.md5sum
var sha256sum = data.sha256sum
var stream = fs.createReadStream(filePath, options)
stream = fs.createReadStream(filePath, options)
uploader(stream, size, sha256sum, md5sum, (err, objInfo) => {
callback(err, objInfo)
cb(true)
Expand Down Expand Up @@ -1224,13 +1230,17 @@ export class Client {
cb(null, uploadedSize < size)
},
(cb) => {
var stream
var cbTriggered = false
var origCb = cb
cb = function () {
if (cbTriggered) {
return
}
cbTriggered = true
if (stream) {
stream.destroy()
}
return origCb.apply(this, arguments)
}
var part = parts[partNumber]
Expand All @@ -1255,7 +1265,7 @@ export class Client {
return cb()
}
// part is not uploaded yet, or md5 mismatch
var stream = fs.createReadStream(filePath, options)
stream = fs.createReadStream(filePath, options)
uploader(uploadId, partNumber, stream, length, data.sha256sum, data.md5sum, (e, objInfo) => {
if (e) {
return cb(e)
Expand Down Expand Up @@ -1930,7 +1940,7 @@ export class Client {

async.eachSeries(
result.listOfList,
(list) => {
(list, batchCb) => {
var objects = []
list.forEach(function (value) {
if (isObject(value)) {
Expand All @@ -1947,22 +1957,27 @@ export class Client {

headers['Content-MD5'] = toMd5(payload)

let removeObjectsResult
this.makeRequest({ method, bucketName, query, headers }, payload, [200], '', true, (e, response) => {
if (e) {
return cb(e)
return batchCb(e)
}
let removeObjectsResult
pipesetup(response, transformers.removeObjectsTransformer())
.on('data', (data) => {
removeObjectsResult = data
})
.on('error', cb)
.on('error', (e) => {
return batchCb(e, null)
})
.on('end', () => {
cb(null, removeObjectsResult)
batchResults.push(removeObjectsResult)
return batchCb(null, removeObjectsResult)
})
})
},
cb,
() => {
cb(null, _.flatten(batchResults))
},
)
}

Expand Down
1 change: 1 addition & 0 deletions src/main/s3-endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ let awsS3Endpoint = {
'ap-northeast-1': 's3-ap-northeast-1.amazonaws.com',
'cn-north-1': 's3.cn-north-1.amazonaws.com.cn',
'ap-east-1': 's3.ap-east-1.amazonaws.com',
'eu-north-1': 's3.eu-north-1.amazonaws.com',
// Add new endpoints here.
}

Expand Down