Skip to content

Commit d85c2f5

Browse files
authored
feat: add install from source to README (#352)
1 parent f8d7706 commit d85c2f5

File tree

1 file changed

+100
-28
lines changed

1 file changed

+100
-28
lines changed

README.md

Lines changed: 100 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,82 @@
11
# AWS SDK for JavaScript V3 Developer Preview
2+
23
[![Build Status](https://travis-ci.org/aws/aws-sdk-js-v3.svg?branch=master)](https://travis-ci.org/aws/aws-sdk-js-v3)
34
[![codecov](https://codecov.io/gh/aws/aws-sdk-js-v3/branch/master/graph/badge.svg)](https://codecov.io/gh/aws/aws-sdk-js-v3)
45
[![Greenkeeper badge](https://badges.greenkeeper.io/aws/aws-sdk-js-v3.svg)](https://greenkeeper.io/)
56
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
67

7-
The __AWS SDK for JavaScript V3 Developer Preview__ is a rewrite of V2 with some great new features. As with version 2, it enables you to easily work with [Amazon Web Services](https://aws.amazon.com/), but has been written in TypeScript and adds several frequently requested features, like modularized packages.
8+
The **AWS SDK for JavaScript V3 Developer Preview** is a rewrite of V2 with some great new features. As with version 2, it enables you to easily work with [Amazon Web Services](https://aws.amazon.com/), but has been written in TypeScript and adds several frequently requested features, like modularized packages.
89

910
Many aspects of the SDK have been refactored and cleaned up, in addition to generating service client packages instead of hydrating services at SDK runtime. The Developer Preview is your chance to influence the direction of the new AWS SDK for JavaScript. Tell us what you like, tell us what you don’t like. Your feedback matters to us.
1011

1112
## Production Readiness
13+
1214
This project is still in its early stages. We want feedback from you, and may make breaking changes in future releases while the SDK is still in developer preview.
1315

1416
The new AWS SDK for JavaScript will also be able to run alongside the version 2.x SDK in the same package to allow partial migration to the new product. As we get close to general availability for version 3, we’ll share a more detailed plan on how we’ll support the 2.x line.
1517

16-
1718
## Getting started
19+
1820
Let’s walk through setting up a project that depends on DynamoDB from the SDK and makes a simple service call. The following steps use npm as an example. These steps assume you have node.js and npm already installed.
19-
1. Create a new node.js project.
20-
2. Inside of the project, run: `npm install --save @aws-sdk/client-dynamodb-v2-node@preview`
21-
3. Create a new file called index.js, create a DynamoDB service client and send a request.
21+
22+
1. Create a new node.js project.
23+
2. Inside of the project, run: `npm install --save @aws-sdk/client-dynamodb-v2-node@preview`
24+
3. Create a new file called index.js, create a DynamoDB service client and send a request.
25+
2226
```javascript
23-
const {DynamoDBClient} = require('@aws-sdk/client-dynamodb-node/DynamoDBClient');
24-
const {ListTablesCommand} = require('@aws-sdk/client-dynamodb-node/commands/ListTablesCommand');
27+
const {
28+
DynamoDBClient
29+
} = require("@aws-sdk/client-dynamodb-node/DynamoDBClient");
30+
const {
31+
ListTablesCommand
32+
} = require("@aws-sdk/client-dynamodb-node/commands/ListTablesCommand");
2533
async function example() {
26-
const client = new DynamoDBClient({region: 'us-west-2'});
34+
const client = new DynamoDBClient({ region: "us-west-2" });
2735
const command = new ListTablesCommand({});
2836
try {
2937
const results = await client.send(command);
30-
console.log(results.TableNames.join('\n'));
38+
console.log(results.TableNames.join("\n"));
3139
} catch (err) {
3240
console.error(err);
3341
}
3442
}
3543
example();
3644
```
45+
3746
For users want to use V2-like interfaces, you can import client with only the service name(e.g DynamoDB), and call the operation name directly from the client:
47+
3848
```javascript
39-
const {DynamoDB} = require('@aws-sdk/client-dynamodb-node');
49+
const { DynamoDB } = require("@aws-sdk/client-dynamodb-node");
4050
async function example() {
41-
const client = new DynamoDB({region: 'us-west-2'});
51+
const client = new DynamoDB({ region: "us-west-2" });
4252
try {
4353
const results = await client.listTables({});
44-
console.log(results.TableNames.join('\n'));
54+
console.log(results.TableNames.join("\n"));
4555
} catch (err) {
4656
console.error(err);
4757
}
4858
}
4959
example();
5060
```
61+
5162
Note that this client is subject to change. It might be removed with SDK V3 comes closer to production-ready.
5263

5364
## New features
65+
5466
### Modularized packages
67+
5568
The SDK is now split up across multiple packages. The 2.x version of the SDK contained support for every service. This made it very easy to use multiple services in a project. Due to the limitations around reducing the size of the SDK when only using a handful of services or operations, many customers requested having separate packages for each service client. We have also split up the core parts of the SDK so that service clients only pull in what they need. For example, a service sends responses in JSON will no longer need to also have an XML parser as a dependency.
5669

5770
For those that were already importing services as sub-modules from the version 2.x SDK, the import statement doesn’t look too different. Here’s an example of importing the AWS Lambda service in version 2.0 of the SDK, and the Developer Preview:
71+
5872
```javascript
5973
// import the Lambda client constructor in version 2.0 of the SDK
60-
const Lambda = require('aws-sdk/clients/lambda');
74+
const Lambda = require("aws-sdk/clients/lambda");
6175

6276
// import the Lambda client constructor in the node.js version of the Developer Preview
63-
const {Lambda} = require('@aws-sdk/client-lambda-node');
77+
const { Lambda } = require("@aws-sdk/client-lambda-node");
6478
```
79+
6580
It is also possible to import both versions of the Lambda client by changing the variable name the Lambda constructor is stored in.
6681
Separate packages for browser and node.js
6782

@@ -70,53 +85,110 @@ In addition to publishing separate packages for each service client, each packag
7085
By publishing separate packages for node.js and browser environments, we’ve removed the guesswork around which version your builds will use. This also allows us to use environment-specific typings. For example, streams are implemented with different interfaces in node.js and browsers. Depending on which package you are using, the typings will reflect the streams for the environment you’ve chosen.
7186

7287
### API changes
88+
7389
We’ve made several public API changes to improve consistency, make the SDK easier to use, and remove deprecated or confusing APIs. The following are some of the bigger changes included in the new AWS SDK for JavaScript Developer Preview.
90+
7491
#### Configuration
75-
In version 2.x of the SDK, service configuration could be passed to individual client constructors.
76-
However, these configurations would first be merged automatically into a copy of the global SDK configuration: `AWS.config`.
77-
Also, calling `AWS.config.update({/* params *})` only updated configuration for service clients instantiated after the update call was made, not any existing clients.
92+
93+
In version 2.x of the SDK, service configuration could be passed to individual client constructors.
94+
However, these configurations would first be merged automatically into a copy of the global SDK configuration: `AWS.config`.
95+
Also, calling `AWS.config.update({/* params *})` only updated configuration for service clients instantiated after the update call was made, not any existing clients.
7896

7997
This behavior was a frequent source of confusion, and made it difficult to add configuration to the global object that only affects a subset of service clients in a forward-compatible way.
80-
In the Developer Preview, there is no longer a global configuration managed by the SDK.
81-
Configuration must be passed to each service client that is instantiated.
98+
In the Developer Preview, there is no longer a global configuration managed by the SDK.
99+
Configuration must be passed to each service client that is instantiated.
82100
It is still possible to share the same configuration across multiple clients but that configuration will not be automatically merged with a global state.
101+
83102
#### Middleware
103+
84104
Version 2.x of the SDK allows modifying a request throughout multiple stages of a request’s lifecycle by attaching event listeners to a request.
85105
Some feedback we received frequently was that it can be difficult to debug what went wrong during a request’s lifecycle.
86106
We’ve switched to using a middleware stack to control the lifecycle of an operation call now.
87107
This gives us a few benefits. Each middleware in the stack calls the next middleware after making any changes to the request object.
88108
This also makes debugging issues in the stack much easier since you can see exactly which middleware have been called leading up to an error.
89109
Here’s an example of adding a custom header using middleware:
110+
90111
```javascript
91112
lambda.middlewareStack.add(
92-
(next, context) => (args) => {
93-
args.request.headers['Custom-Header'] = 'value';
113+
(next, context) => args => {
114+
args.request.headers["Custom-Header"] = "value";
94115
return next(args);
95116
},
96117
{
97-
step: 'build'
118+
step: "build"
98119
}
99120
);
100121

101122
lambda.putObject(params);
102123
```
103-
In the above example, we’re adding a middleware to our S3 client’s middleware stack.
104-
The first argument is a function that accepts next, the next middleware in the stack to call, and context, an object that contains some information about the operation being called.
124+
125+
In the above example, we’re adding a middleware to our S3 client’s middleware stack.
126+
The first argument is a function that accepts next, the next middleware in the stack to call, and context, an object that contains some information about the operation being called.
105127
It returns a function that accepts args, an object that contains the parameters passed to the operation and the request, and returns the result from calling the next middleware with args.
128+
129+
### Install from Source
130+
131+
Select clients have been published to NPM and can be installed as described above. For clients that have not yet been published to NPM, follow these instructions to install from source:
132+
133+
1. Clone this repository to local by:
134+
135+
```
136+
git clone https://github.com/aws/aws-sdk-js-v3.git
137+
```
138+
139+
1. Under the repository root directory, run following command to link and build the whole library, the process may take several minutes:
140+
141+
```
142+
yarn & yarn test-all
143+
```
144+
145+
For more information, please refer to [contributing guide](https://github.com/aws/aws-sdk-js-v3/blob/master/CONTRIBUTING.md#setup-and-testing).
146+
147+
1. After the repository is successfully built, change directory to the client that you want to install, for example:
148+
149+
```
150+
cd clients/browser/client-lambda-browser
151+
```
152+
153+
1. Pack the client:
154+
155+
```
156+
yarn pack .
157+
```
158+
159+
`yarn pack` will create an archive file in the client package folder, e.g. `aws-sdk-client-lambda-browser-v0.1.0-preview.1.tgz`.
160+
161+
1. Change directory to the project you are working on and move the archive to the location to store the vendor packages:
162+
163+
```
164+
mv path/to/aws-sdk-js-v3/clients/browser/client-lambda-browser/aws-sdk-client-lambda-browser-v0.1.0-preview.1.tgz ./path/to/vendors/folder
165+
```
166+
167+
1. Install the package to your project:
168+
169+
```
170+
npm install ./path/to/vendors/folder/aws-sdk-client-lambda-browser-v0.1.0-preview.1.tgz
171+
```
172+
106173
### Giving feedback and contributing
174+
107175
You can provide feedback to us in several ways. Both positive and negative feedback is appreciated.
108-
While the SDK is in preview, you may encounter bugs while using it.
176+
While the SDK is in preview, you may encounter bugs while using it.
109177
If you do, please feel free to open an issue on our GitHub repository.
110178
Our GitHub issues page also includes work we know still needs to be done before exiting a preview state.
179+
111180
#### Feedback
112-
__GitHub issues__. Customers who are comfortable giving public feedback can open a GitHub issue in the new repository.
181+
182+
**GitHub issues**. Customers who are comfortable giving public feedback can open a GitHub issue in the new repository.
113183
This is the preferred mechanism to give feedback so that other customers can engage in the conversation, +1 issues, etc.
114184
Issues you open will be evaluated, and included in our roadmap for the GA launch.
115185

116-
__Gitter channel__. For informal discussion or general feedback, you may join the [Gitter chat](https://gitter.im/aws/aws-sdk-js-v3).
186+
**Gitter channel**. For informal discussion or general feedback, you may join the [Gitter chat](https://gitter.im/aws/aws-sdk-js-v3).
117187
The Gitter channel is also a great place to get help with the Developer Preview from other developers. JS SDK team doesn't
118188
track the discussion daily, so feel free to open an issue if your question cannot be answered there.
189+
119190
#### Contributing
191+
120192
You can open pull requests for fixes or additions to the new AWS SDK for JavaScript Developer Preview.
121-
All pull requests must be submitted under the Apache 2.0 license and will be reviewed by an SDK team member prior to merging.
193+
All pull requests must be submitted under the Apache 2.0 license and will be reviewed by an SDK team member prior to merging.
122194
Accompanying unit tests are appreciated. See [Contributing](CONTRIBUTING.md) for more information.

0 commit comments

Comments
 (0)