Skip to content

Commit

Permalink
Lz async await (ali-sdk#500)
Browse files Browse the repository at this point in the history
* refactor: add eslint for es6

* feat: add rule eslint

* feat: code review check

* refactor: node async await finish without cluster.js

* refactor: browser async await format by eslint

* feat: bucket lifecycle cors and so on need sync time more than 500ms

* feat: browser structure with es7

* feat: browser structure with es7

* refactor: browser object async await and test case

* feat: remove unused file

* feat: rename file name and ignore config

* add browser multipart upload parallel

* fix: 1.upload part doneParts copy 2.if cancel multipart reset multipart upload options

* refactor: add eslint for es6

* feat: add rule eslint

* refactor: node async await finish without cluster.js

* refactor: browser async await format by eslint

* feat: browser structure with es7

* feat: code review check

* chore: resolve confict

* feat: remove unused file

* feat: rename file name and ignore config

* add browser multipart upload parallel

* fix: 1.upload part doneParts copy 2.if cancel multipart reset multipart upload options

* feat: add readme for async await operation

* fix: multipart upload job cancel or err

* fix: multipart upload job cancel or err

* rm file

* chore: resolve confict

* test: ci

* test: ci

* test: ci

* chore:delete package-lock.json

* chore: modify browser test case

* refactor:remove the region parameter of bucket operations

* chore: mount debug to oss proto

* refactor: add eslint for es6

* feat: add rule eslint

* refactor: node async await finish without cluster.js

* refactor: browser async await format by eslint

* feat: bucket lifecycle cors and so on need sync time more than 500ms

* feat: code review check

* refactor: add eslint for es6

* feat: add rule eslint

* refactor: node async await finish without cluster.js

* refactor: browser async await format by eslint

* feat: browser structure with es7

* feat: browser structure with es7

* feat: browser structure with es7

* feat: code review check

* chore: resolve confict

* refactor: browser object async await and test case

* feat: remove unused file

* feat: remove unused file

* feat: rename file name and ignore config

* feat: rename file name and ignore config

* add browser multipart upload parallel

* add browser multipart upload parallel

* fix: 1.upload part doneParts copy 2.if cancel multipart reset multipart upload options

* fix: 1.upload part doneParts copy 2.if cancel multipart reset multipart upload options

* feat: add readme for async await operation

* fix: multipart upload job cancel or err

* fix: multipart upload job cancel or err

* rm file

* chore: resolve confict

* test: ci

* test: ci

* test: ci

* chore:delete package-lock.json

* chore: modify browser test case

* refactor:remove the region parameter of bucket operations

* chore: mount debug to oss proto

* docs: add UPGRADING.md

* refactor: remove temp variable and update publish shell

* docs: update UPGRADING.md

* refactor: cluster async/await

* chore: remove unuse browser.js

* chore: set log level for debug

* chore(release): 6.0.0
  • Loading branch information
luozhang002 authored and binghaiwang committed Jul 10, 2018
1 parent 63df586 commit 0f3b21b
Show file tree
Hide file tree
Showing 52 changed files with 3,513 additions and 11,789 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ test/browser/.tmp
test/browser/build
test/benchmark/
test/fixtures/
task/
task/
browser-build.js
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
// override default options
'no-underscore-dangle': [0],
'no-plusplus': [0],
'no-return-await':[0],
'no-param-reassign': [0],
'max-len': ['warn', 120, 2, {
ignoreUrls: true,
Expand Down
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="6.0.0"></a>
# [6.0.0](https://github.com/aliyun/oss-nodejs-sdk/compare/v5.3.1...v6.0.0) (2018-07-10)

### Features

* refactor async/await instead of generator and test case
* remove region param about bucket operations
* support cancel on node sdk
* mount debug info on client proto
* remove unuse browser.js in /

### docs

* README.md example

<a name="5.3.1"></a>
## [5.3.1](https://github.com/aliyun/oss-nodejs-sdk/compare/v5.1.0...v5.3.1) (2018-06-27)
# [5.3.1](https://github.com/aliyun/oss-nodejs-sdk/compare/v5.1.0...v5.3.1) (2018-06-27)

### Bug Fixes

Expand Down
873 changes: 419 additions & 454 deletions README.md

Large diffs are not rendered by default.

125 changes: 125 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# @!title Upgrading Notes (5.x to 6.x)

# Upgrading Notes (5.x to 6.x)

No matter how it changes, our api name will never change. In order to give developers a better experience, we just change the way that the client use.the This document captures breaking changes from 5.x versions to the first
stable 6.x (non-RC) release of the Aliyun SDK for JavaScript.

## 1. Remove Region Param fo All Bucket Operations

For all the bucket operation ,including putBucket、deleteBucket、getBucketInfo、 getBucketLoaction、
putBucketACL、gitBucketACL、 putBucketLogging、 getBucketLogging、 deleteBucketLogging、 putBucketWebsite、
getBucketWebsite、deleteBucketWebsite putBucketReferer getBucketReferer etc.

Upgrading example

The following 1.x code, eg deleteBucket

```
const OSS = require('ali-oss');
const Client = new OSS(...);
Client.deleteBucket(bucket,region);
```
Should be changed to the following:

```
const OSS = require('ali-oss');
const Client = new OSS(...);
Client.deleteBucket(bucket);
```

## 2. `Async Await` instead of `generator` Operation In Internal Code

We use `Async Await` to refactor all api 、test case etc to instead of `co generator`
it can optimize our code to maintain and provide with a better development experience for developers

## 3. Dropped `OSS.Wrapper` When Init Client

Before in async opearion we use `OSS.Wrapper` ,but now we just use `new OSS()` ,it will return Promise like `OSS.Wrapper`,please remmove `Wrapper`.

Upgrading example

The following 5.x code:

```
const OSS = require('ali-oss');
const client = new OSS.Wrapper({
accessKeyId: xxx,
accessKeySecret: xxx,
region: xxx
bucket: bucketName
})
client.operation(...).then(...).catch(...);
```

Should be changed to the following:

```
const OSS = require('ali-oss');
const client = new OSS({
accessKeyId: xxx,
accessKeySecret: xxx,
region: xxx
bucket: bucketName
})
client.operation(...).then(...).catch(...);
```

## 4.Support Cancel Operion For Node SDK When Upload File

Should be used like:

```
cosnt OSS = require('ali-oss');
const client = new OSS({
accessKeyId: xxx,
accessKeySecret: xxx,
region: 'xxx',
bucket: bucketName
});
// use bucket
client.useBucket(bucketName);
// progress
const progress = async function progress(p, checkpoint) {
console.log(p);
};
const filePath = './resource/X.zip';
const options = {
progress,
partSize: 100 * 1024,
meta: {
year: 2017,
people: 'test',
},
};
//upload local file
async function upload() {
try {
const result = await client.multipartUpload('bilibili/hahhh', filePath, options);
} catch (e) {
if (client.isCancel()) {
console.log('canceled!');
// do
} else {
// do
}
}
}
upload();
// after 3s cancel
setTimeout(() => {
client.cancel();
}, 3000);
```
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"package.json"
],
"main": "dist/aliyun-oss-sdk.js",
"version": "5.3.1"
"version": "6.0.0"
}
7 changes: 4 additions & 3 deletions browser-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ function build(options, callback) {
var brOpts = {
basedir: path.resolve(__dirname, '.'),
fullPaths: false,
standalone: 'OSS'
standalone: 'OSS',
debug: true
};
browserify(brOpts).add('./lib/browser.js')
.transform(babelify, {
"global": true,
"presets": ["es2015"],
"plugins": ["transform-runtime"],
"only": ['lib/*', 'node_modules/co-gather/*', 'shims/*', 'shims/crypto/*'],
"plugins": ["transform-runtime", "babel-plugin-transform-regenerator", "babel-plugin-transform-es2015-modules-commonjs"],
"only": ['lib/*', 'shims/*', 'shims/crypto/*'],
}).transform(aliasify, {
global: true,
aliases: {
Expand Down
10 changes: 0 additions & 10 deletions browser.js

This file was deleted.

Loading

0 comments on commit 0f3b21b

Please sign in to comment.