aws-sdk 2.0.1 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +20 -0
- package/.gitignore +10 -0
- package/.travis.yml +20 -0
- package/.yardopts +20 -0
- package/.yardopts_guide +21 -0
- package/Gemfile +16 -0
- package/Gemfile.lock +34 -0
- package/README.md +5 -6
- package/Rakefile +14 -0
- package/UPGRADING.md +9 -4
- package/configuration.sample +5 -0
- package/dist/BUNDLE_LICENSE.txt +96 -0
- package/dist/aws-sdk.js +9594 -0
- package/dist/aws-sdk.min.js +21 -0
- package/dist-tools/.eslintrc +10 -0
- package/dist-tools/browser-builder.js +142 -0
- package/dist-tools/strategies/cache.js +68 -0
- package/dist-tools/strategies/default.js +165 -0
- package/dist-tools/test/browser-builder.mocha.spec.coffee +182 -0
- package/dist-tools/test/helpers.coffee +16 -0
- package/doc-src/guide/browser-building.md +93 -0
- package/doc-src/guide/browser-configuring-wif.md +287 -0
- package/doc-src/guide/browser-configuring.md +218 -0
- package/doc-src/guide/browser-examples.md +220 -0
- package/doc-src/guide/browser-intro.md +46 -0
- package/doc-src/guide/browser-making-requests.md +279 -0
- package/doc-src/guide/browser-services.md +75 -0
- package/doc-src/guide/index.md +41 -0
- package/doc-src/guide/node-configuring.md +272 -0
- package/doc-src/guide/node-examples.md +341 -0
- package/doc-src/guide/node-intro.md +32 -0
- package/doc-src/guide/node-making-requests.md +309 -0
- package/doc-src/guide/node-services.md +159 -0
- package/doc-src/templates/api-versions/model_documentor.rb +366 -0
- package/doc-src/templates/api-versions/plugin.rb +230 -0
- package/doc-src/templates/api-versions/templates/default/class/html/setup.rb +9 -0
- package/doc-src/templates/api-versions/templates/default/class/html/waiter_details_list.erb +7 -0
- package/doc-src/templates/api-versions/templates/default/class/html/waiter_summary.erb +7 -0
- package/doc-src/templates/api-versions/templates/default/docstring/html/experimental.erb +4 -0
- package/doc-src/templates/api-versions/templates/default/docstring/setup.rb +9 -0
- package/doc-src/templates/api-versions/templates/default/fulldoc/html/css/common.css +6 -0
- package/doc-src/templates/api-versions/templates/default/fulldoc/html/setup.rb +62 -0
- package/doc-src/templates/api-versions/templates/default/layout/html/services.erb +10 -0
- package/doc-src/templates/api-versions/templates/default/layout/html/setup.rb +28 -0
- package/doc-src/templates/api-versions/templates/default/module/html/box_info.erb +45 -0
- package/doc-src/templates/api-versions/templates/default/module/html/children.erb +8 -0
- package/doc-src/templates/api-versions/templates/default/tags/setup.rb +3 -0
- package/doc-src/templates/api-versions/templates/default/waiter_details/html/method_signature.erb +3 -0
- package/doc-src/templates/api-versions/templates/default/waiter_details/html/setup.rb +5 -0
- package/doc-src/templates/default/layout/html/footer.erb +31 -0
- package/doc-src/templates/default/layout/html/layout.erb +23 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/css/highlight.github.css +127 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/css/style.css +1192 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/img/logo.png +0 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/app.js +33 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/highlight.pack.js +27 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/AUTHORS +55 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/LICENSE +25 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/doctools.js +247 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/file.png +0 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/sphinx/searchtools.js +568 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/js/underscore.js +23 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/search.erb +29 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/search_index.erb +1 -0
- package/doc-src/templates/flasky_sphinx_guide/fulldoc/html/setup.rb +75 -0
- package/doc-src/templates/flasky_sphinx_guide/layout/html/layout.erb +93 -0
- package/doc-src/templates/flasky_sphinx_guide/layout/html/setup.rb +9 -0
- package/doc-src/templates/flasky_sphinx_guide/layout/html/sidebar.erb +45 -0
- package/doc-src/templates/flasky_sphinx_guide/onefile/html/layout.erb +51 -0
- package/doc-src/templates/flasky_sphinx_guide/onefile/html/setup.rb +1 -0
- package/eslint-rules/no-require-in-service.js +10 -0
- package/features/autoscaling/autoscaling.feature +21 -0
- package/features/autoscaling/step_definitions/autoscaling.js +49 -0
- package/features/cloudformation/cloudformation.feature +22 -0
- package/features/cloudformation/step_definitions/cloudformation.js +26 -0
- package/features/cloudfront/cloudfront.feature +28 -0
- package/features/cloudfront/step_definitions/cloudfront-latest.js +54 -0
- package/features/cloudfront/step_definitions/cloudfront.js +21 -0
- package/features/cloudsearch/cloudsearch.feature +34 -0
- package/features/cloudsearch/step_definitions/cloudsearch.js +42 -0
- package/features/cloudtrail/cloudtrail.feature +17 -0
- package/features/cloudtrail/step_definitions/cloudtrail.js +14 -0
- package/features/cloudwatch/cloudwatch.feature +15 -0
- package/features/cloudwatch/step_definitions/cloudwatch.js +48 -0
- package/features/datapipeline/datapipeline.feature +23 -0
- package/features/datapipeline/step_definitions/datapipeline.js +79 -0
- package/features/directconnect/directconnect.feature +20 -0
- package/features/directconnect/step_definitions/directconnect.js +44 -0
- package/features/dynamodb/crc32.feature +18 -0
- package/features/dynamodb/step_definitions/dynamodb.js +154 -0
- package/features/dynamodb/tables.feature +50 -0
- package/features/ec2/ec2.feature +28 -0
- package/features/ec2/step_definitions/ec2.js +65 -0
- package/features/elasticache/elasticache.feature +20 -0
- package/features/elasticache/step_definitions/elasticache.js +34 -0
- package/features/elasticbeanstalk/elasticbeanstalk.feature +22 -0
- package/features/elasticbeanstalk/step_definitions/elasticbeanstalk.js +38 -0
- package/features/elastictranscoder/elastictranscoder.feature +24 -0
- package/features/elastictranscoder/step_definitions/elastictranscoder.js +56 -0
- package/features/elb/elb.feature +19 -0
- package/features/elb/step_definitions/elb.js +37 -0
- package/features/emr/emr.feature +16 -0
- package/features/emr/step_definitions/emr.js +45 -0
- package/features/extra/assertions.js +29 -0
- package/features/extra/dummy.feature +0 -0
- package/features/extra/fixtures/testfile.txt +1 -0
- package/features/extra/helpers.js +113 -0
- package/features/extra/hooks.js +107 -0
- package/features/extra/world.js +12 -0
- package/features/glacier/glacier.feature +47 -0
- package/features/glacier/step_definitions/glacier.js +112 -0
- package/features/iam/iam.feature +24 -0
- package/features/iam/step_definitions/iam.js +66 -0
- package/features/importexport/importexport.feature +53 -0
- package/features/importexport/step_definitions/importexport.js +42 -0
- package/features/kinesis/kinesis.feature +9 -0
- package/features/kinesis/step_definitions/kinesis.js +10 -0
- package/features/opsworks/opsworks.feature +26 -0
- package/features/opsworks/step_definitions/opsworks.js +42 -0
- package/features/rds/rds.feature +32 -0
- package/features/rds/step_definitions/rds.js +72 -0
- package/features/redshift/redshift.feature +20 -0
- package/features/redshift/step_definitions/redshift.js +33 -0
- package/features/route53/route53.feature +41 -0
- package/features/route53/step_definitions/route53.js +97 -0
- package/features/s3/buckets.feature +40 -0
- package/features/s3/objects.feature +122 -0
- package/features/s3/step_definitions/buckets.js +136 -0
- package/features/s3/step_definitions/hooks.js +39 -0
- package/features/s3/step_definitions/objects.js +204 -0
- package/features/s3/step_definitions/proxy.js +44 -0
- package/features/ses/ses.feature +20 -0
- package/features/ses/step_definitions/ses.js +22 -0
- package/features/simpledb/simpledb.feature +29 -0
- package/features/simpledb/step_definitions/simpledb.js +46 -0
- package/features/sns/sns.feature +15 -0
- package/features/sns/step_definitions/sns.js +33 -0
- package/features/sqs/messages.feature +21 -0
- package/features/sqs/queues.feature +18 -0
- package/features/sqs/step_definitions/messages.js +46 -0
- package/features/sqs/step_definitions/queues.js +33 -0
- package/features/sqs/step_definitions/sqs.js +7 -0
- package/features/storagegateway/step_definitions/storagegateway.js +16 -0
- package/features/storagegateway/storagegateway.feature +13 -0
- package/features/sts/step_definitions/sts.js +35 -0
- package/features/sts/sts.feature +29 -0
- package/features/support/step_definitions/support.js +35 -0
- package/features/support/support.feature +18 -0
- package/features/swf/step_definitions/swf.js +38 -0
- package/features/swf/swf.feature +15 -0
- package/index.js +2 -0
- package/lib/core.js +2 -2
- package/lib/credentials/shared_ini_file_credentials.js +0 -1
- package/lib/event_listeners.js +13 -1
- package/lib/http/node.js +19 -30
- package/lib/model/resource_waiter.js +0 -4
- package/lib/model/shape.js +2 -1
- package/lib/protocol/rest_xml.js +1 -1
- package/lib/region_config.js +31 -0
- package/lib/region_config.json +56 -0
- package/lib/request.js +37 -45
- package/lib/sequential_executor.js +17 -34
- package/lib/service.js +17 -44
- package/lib/services/cloudsearchdomain.js +69 -0
- package/lib/services/route53.js +0 -12
- package/lib/services/s3.js +3 -19
- package/lib/signers/v4.js +2 -1
- package/lib/util.js +28 -3
- package/package.json +3 -3
- package/scripts/console +11 -3
- package/scripts/coverage +126 -0
- package/tasks/apis.rake +122 -0
- package/tasks/browser.rake +89 -0
- package/tasks/docs.rake +36 -0
- package/tasks/lib/cucumber_generator.rb +40 -0
- package/tasks/util.rake +33 -0
- package/test/browser/js/jasmine-1.3.1.js +2600 -0
- package/test/browser/js/jasmine-html.js +681 -0
- package/test/browser/runner.html +109 -0
- package/test/browser/runner.js +92 -0
- package/test/browser/sample/appinfo.sample.js +15 -0
- package/test/browser/sample/console.html +429 -0
- package/test/browser/sample/css/smoothness/images/animated-overlay.gif +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- package/test/browser/sample/css/smoothness/jquery-ui-1.10.1.custom.css +1175 -0
- package/test/browser/sample/css/smoothness/jquery-ui-1.10.1.custom.min.css +5 -0
- package/test/browser/sample/img/loading.gif +0 -0
- package/test/browser/sample/js/jquery-1.9.1.js +9597 -0
- package/test/browser/sample/js/jquery-ui-1.10.1.custom.js +14903 -0
- package/test/browser/sample/js/jquery-ui-1.10.1.custom.min.js +6 -0
- package/test/browser/sample/s3upload.html +111 -0
- package/test/browser.spec.coffee +207 -0
- package/test/config.spec.coffee +202 -0
- package/test/credential_provider_chain.spec.coffee +90 -0
- package/test/credentials.spec.coffee +452 -0
- package/test/endpoint.spec.coffee +80 -0
- package/test/event_listeners.spec.coffee +493 -0
- package/test/helpers.coffee +150 -0
- package/test/http_request.spec.coffee +55 -0
- package/test/json/builder.spec.coffee +129 -0
- package/test/json/parser.spec.coffee +108 -0
- package/test/metadata_service.spec.coffee +54 -0
- package/test/model/api.spec.coffee +67 -0
- package/test/model/shape.spec.coffee +23 -0
- package/test/node_http_client.spec.coffee +40 -0
- package/test/param_validator.spec.coffee +456 -0
- package/test/protocol/json.spec.coffee +167 -0
- package/test/protocol/query.spec.coffee +191 -0
- package/test/protocol/rest.spec.coffee +237 -0
- package/test/protocol/rest_json.spec.coffee +255 -0
- package/test/protocol/rest_xml.spec.coffee +329 -0
- package/test/query/query_param_serializer.spec.coffee +327 -0
- package/test/region_config.spec.coffee +50 -0
- package/test/request.spec.coffee +316 -0
- package/test/resource_waiter.spec.coffee +89 -0
- package/test/response.spec.coffee +81 -0
- package/test/sequential_executor.spec.coffee +118 -0
- package/test/service.spec.coffee +230 -0
- package/test/services/cloudfront.spec.coffee +44 -0
- package/test/services/cloudsearchdomain.spec.coffee +23 -0
- package/test/services/dynamodb.spec.coffee +32 -0
- package/test/services/ec2.spec.coffee +78 -0
- package/test/services/elastictranscoder.spec.coffee +43 -0
- package/test/services/glacier.spec.coffee +61 -0
- package/test/services/rds.spec.coffee +38 -0
- package/test/services/route53.spec.coffee +77 -0
- package/test/services/s3.spec.coffee +538 -0
- package/test/services/simpledb.spec.coffee +12 -0
- package/test/services/sqs.spec.coffee +130 -0
- package/test/services/sts.spec.coffee +72 -0
- package/test/services/swf.spec.coffee +6 -0
- package/test/signers/presign.spec.coffee +36 -0
- package/test/signers/s3.spec.coffee +297 -0
- package/test/signers/v2.spec.coffee +68 -0
- package/test/signers/v4.spec.coffee +135 -0
- package/test/util.spec.coffee +510 -0
- package/test/xml/builder.spec.coffee +529 -0
- package/test/xml/parser.spec.coffee +587 -0
- package/lib/services/simpledb.js +0 -15
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
|
|
6
|
+
var CacheStrategy = require('./strategies/cache');
|
|
7
|
+
var DefaultStrategy = require('./strategies/default');
|
|
8
|
+
|
|
9
|
+
var defaultServices = 'cloudwatch,dynamodb,kinesis,s3,sqs,sns,sts';
|
|
10
|
+
var sanitizeRegex = /[^a-zA-Z0-9,-]/;
|
|
11
|
+
|
|
12
|
+
function Builder(options) {
|
|
13
|
+
this.setDefaultOptions(options);
|
|
14
|
+
this.serviceCode = [];
|
|
15
|
+
this.builtServices = {};
|
|
16
|
+
this.buildStrategy = this.options.cache ?
|
|
17
|
+
new CacheStrategy(this) : new DefaultStrategy(this);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Builder.prototype.setDefaultOptions = function(options) {
|
|
21
|
+
this.options = options || {};
|
|
22
|
+
this.options.libPath = this.options.libPath || this.getRootPath();
|
|
23
|
+
this.options.cacheRoot = this.options.cacheRoot ||
|
|
24
|
+
path.join(this.options.libPath, 'dist-tools', 'cache');
|
|
25
|
+
this.options.cache = this.options.cache || false;
|
|
26
|
+
this.options.writeCache = this.options.writeCache || false;
|
|
27
|
+
this.options.minify = this.options.minify || false;
|
|
28
|
+
this.options.minifyOptions = this.options.minifyOptions || {compress: false};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
Builder.prototype.getRootPath = function() {
|
|
32
|
+
return path.join(__dirname, '..');
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
Builder.prototype.cachePath = function(path) {
|
|
36
|
+
var fullPath = this.options.cacheRoot;
|
|
37
|
+
if (path) {
|
|
38
|
+
fullPath += '/' + path + (this.options.minify ? '.min' : '') + '.js';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return fullPath;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
Builder.prototype.cacheExists = function(path) {
|
|
45
|
+
return fs.existsSync(this.cachePath(path));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
Builder.prototype.buildService = function(name, usingDefaultServices) {
|
|
49
|
+
var match = name.match(/^(.+?)(?:-(.+?))?$/);
|
|
50
|
+
var service = match[1], version = match[2] || 'latest';
|
|
51
|
+
var contents = [];
|
|
52
|
+
var lines, err;
|
|
53
|
+
|
|
54
|
+
if (!this.builtServices[service]) {
|
|
55
|
+
this.builtServices[service] = {};
|
|
56
|
+
|
|
57
|
+
lines = this.buildStrategy.getServiceHeader(service);
|
|
58
|
+
if (lines === null) {
|
|
59
|
+
if (!usingDefaultServices) {
|
|
60
|
+
err = new Error('Invalid module: ' + service);
|
|
61
|
+
err.name = 'InvalidModuleError';
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
contents.push(lines);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!this.builtServices[service][version]) {
|
|
70
|
+
this.builtServices[service][version] = true;
|
|
71
|
+
|
|
72
|
+
lines = this.buildStrategy.getService(service, version);
|
|
73
|
+
if (lines === null) {
|
|
74
|
+
if (!usingDefaultServices) {
|
|
75
|
+
err = new Error('Invalid module: ' + service + '-' + version);
|
|
76
|
+
err.name = 'InvalidModuleError';
|
|
77
|
+
throw err;
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
contents.push(lines);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return contents.join('\n');
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
Builder.prototype.addServices = function(services) {
|
|
88
|
+
var usingDefaultServices = false;
|
|
89
|
+
if (!services) {
|
|
90
|
+
usingDefaultServices = true;
|
|
91
|
+
services = defaultServices;
|
|
92
|
+
}
|
|
93
|
+
if (services.match(sanitizeRegex)) {
|
|
94
|
+
throw new Error('Incorrectly formatted service names');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
var invalidModules = [];
|
|
98
|
+
var stsIncluded = false;
|
|
99
|
+
services.split(',').sort().forEach(function(name) {
|
|
100
|
+
if (name.match(/^sts\b/) || name === 'all') stsIncluded = true;
|
|
101
|
+
try {
|
|
102
|
+
this.serviceCode.push(this.buildService(name, usingDefaultServices));
|
|
103
|
+
} catch (e) {
|
|
104
|
+
if (e.name === 'InvalidModuleError') invalidModules.push(name);
|
|
105
|
+
else throw e;
|
|
106
|
+
}
|
|
107
|
+
}.bind(this));
|
|
108
|
+
|
|
109
|
+
if (!stsIncluded) {
|
|
110
|
+
this.serviceCode.push(this.buildService('sts'));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (invalidModules.length > 0) {
|
|
114
|
+
throw new Error('Missing modules: ' + invalidModules.join(', '));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return this;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
Builder.prototype.build = function(callback) {
|
|
121
|
+
this.buildStrategy.getCore(function(err, core) {
|
|
122
|
+
callback(err, err ? null : (core + ';' + this.serviceCode.join('\n')));
|
|
123
|
+
}.bind(this));
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// run if we called this tool directly
|
|
127
|
+
if (require.main === module) {
|
|
128
|
+
var options = {
|
|
129
|
+
minify: process.env.MINIFY ? true : false,
|
|
130
|
+
cache: process.env.CACHE ? true : false,
|
|
131
|
+
writeCache: process.env.WRITE_CACHE ? true : false,
|
|
132
|
+
cacheRoot: process.env.CACHE_ROOT,
|
|
133
|
+
libPath: process.env.LIB_PATH
|
|
134
|
+
};
|
|
135
|
+
var services = process.argv[2] || process.env.SERVICES;
|
|
136
|
+
new Builder(options).addServices(services).build(function (err, code) {
|
|
137
|
+
if (err) console.error(err.message);
|
|
138
|
+
else console.log(code);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports = Builder;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var fs = require('fs');
|
|
2
|
+
|
|
3
|
+
function CacheStrategy(builder) {
|
|
4
|
+
this.builder = builder;
|
|
5
|
+
this.cacheRoot = this.builder.options.cacheRoot;
|
|
6
|
+
this.minify = this.builder.options.minify;
|
|
7
|
+
|
|
8
|
+
this.loadServices();
|
|
9
|
+
if (!this.builder.cacheExists()) {
|
|
10
|
+
fs.mkdirSync(this.builder.cachePath());
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
CacheStrategy.prototype.loadServices = function() {
|
|
15
|
+
this.services = {};
|
|
16
|
+
fs.readdirSync(this.cacheRoot).forEach(function(file) {
|
|
17
|
+
var match = file.match(/^([^_-]+)-(latest|\d+-\d+-\d+)\.(?:min\.)?js$/);
|
|
18
|
+
if (match) {
|
|
19
|
+
var service = match[1], version = match[2];
|
|
20
|
+
if (!this.services[service]) this.services[service] = {};
|
|
21
|
+
this.services[service][version] = service + '-' + version;
|
|
22
|
+
}
|
|
23
|
+
}.bind(this));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
CacheStrategy.prototype.getServiceHeader = function(service) {
|
|
27
|
+
if (service === 'all') {
|
|
28
|
+
return Object.keys(this.services).map(function (name) {
|
|
29
|
+
return this.getServiceHeader(name);
|
|
30
|
+
}.bind(this)).join('\n');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (this.services[service] && this.builder.cacheExists(service)) {
|
|
34
|
+
return this.read(service);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
CacheStrategy.prototype.getService = function(service, version) {
|
|
40
|
+
if (service === 'all') {
|
|
41
|
+
return Object.keys(this.services).map(function (name) {
|
|
42
|
+
return this.getService(name);
|
|
43
|
+
}.bind(this)).join('\n');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var versions = this.services[service];
|
|
47
|
+
if (versions) {
|
|
48
|
+
var file = versions[version || 'latest'];
|
|
49
|
+
if (file && this.builder.cacheExists(file)) {
|
|
50
|
+
return this.read(file);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
CacheStrategy.prototype.getCore = function(callback) {
|
|
57
|
+
if (this.builder.cacheExists('_core')) {
|
|
58
|
+
callback(null, this.read('_core'));
|
|
59
|
+
} else {
|
|
60
|
+
callback(new Error('Core not found.'));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
CacheStrategy.prototype.read = function(path) {
|
|
65
|
+
return fs.readFileSync(this.builder.cachePath(path)).toString();
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
module.exports = CacheStrategy;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var fs = require('fs');
|
|
2
|
+
var util = require('util');
|
|
3
|
+
var path = require('path');
|
|
4
|
+
|
|
5
|
+
function DefaultStrategy(builder) {
|
|
6
|
+
this.builder = builder;
|
|
7
|
+
this.libPath = this.builder.options.libPath;
|
|
8
|
+
this.isCached = this.builder.options.writeCache;
|
|
9
|
+
this.isMinified = this.builder.options.minify;
|
|
10
|
+
this.minifyOptions = this.builder.options.minifyOptions || {};
|
|
11
|
+
this.minifyOptions.fromString = true;
|
|
12
|
+
this.AWS = require(this.libPath + '/lib/aws');
|
|
13
|
+
this.apis = require('aws-sdk-apis');
|
|
14
|
+
this.license = [
|
|
15
|
+
'// AWS SDK for JavaScript v' + this.AWS.VERSION,
|
|
16
|
+
'// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.',
|
|
17
|
+
'// License at https://sdk.amazonaws.com/js/BUNDLE_LICENSE.txt'
|
|
18
|
+
].join('\n') + '\n';
|
|
19
|
+
this.setServiceClasses();
|
|
20
|
+
|
|
21
|
+
if (this.isCached && !this.builder.cacheExists()) {
|
|
22
|
+
fs.mkdirSync(this.builder.cachePath());
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
DefaultStrategy.prototype.setServiceClasses = function() {
|
|
27
|
+
this.serviceClasses = {};
|
|
28
|
+
this.AWS.util.each.call(this, this.AWS, function(name, serviceClass) {
|
|
29
|
+
if (serviceClass.serviceIdentifier) {
|
|
30
|
+
this.serviceClasses[serviceClass.serviceIdentifier] = serviceClass;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
DefaultStrategy.prototype.minify = function(code) {
|
|
36
|
+
var uglify = require('uglify-js');
|
|
37
|
+
var minified = uglify.minify(code, this.minifyOptions);
|
|
38
|
+
return minified.code;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
DefaultStrategy.prototype.stripComments = function(code) {
|
|
42
|
+
var lines = code.split(/\r?\n/);
|
|
43
|
+
var multiLine = false;
|
|
44
|
+
lines = lines.map(function (line) {
|
|
45
|
+
var rLine = line;
|
|
46
|
+
if (line.match(/^\s*\/\//)) {
|
|
47
|
+
rLine = null;
|
|
48
|
+
} else if (line.match(/^\s*\/\*/)) {
|
|
49
|
+
multiLine = true;
|
|
50
|
+
rLine = null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (multiLine) {
|
|
54
|
+
var multiLineEnd = line.match(/\*\/(.*)/);
|
|
55
|
+
if (multiLineEnd) {
|
|
56
|
+
multiLine = false;
|
|
57
|
+
rLine = multiLineEnd[1];
|
|
58
|
+
} else {
|
|
59
|
+
rLine = null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return rLine;
|
|
64
|
+
}).filter(function(l) { return l !== null; });
|
|
65
|
+
|
|
66
|
+
var newCode = lines.join('\n');
|
|
67
|
+
newCode = newCode.replace(/\/\*\*[\s\S]+?Copyright\s+.+?Amazon[\s\S]+?\*\//g, '');
|
|
68
|
+
return newCode;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
DefaultStrategy.prototype.getServiceHeader = function(service) {
|
|
72
|
+
if (service === 'all') {
|
|
73
|
+
return Object.keys(this.serviceClasses).map(function(service) {
|
|
74
|
+
return this.getServiceHeader(service);
|
|
75
|
+
}.bind(this)).join('\n');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var file = util.format(
|
|
79
|
+
'AWS.%s = AWS.Service.defineService(\'%s\');\n',
|
|
80
|
+
this.apis.serviceName(service), service);
|
|
81
|
+
var svcPath = this.libPath + '/lib/services/' + service + '.js';
|
|
82
|
+
if (fs.existsSync(svcPath)) {
|
|
83
|
+
var lines = fs.readFileSync(svcPath).toString().split(/\r?\n/);
|
|
84
|
+
file += lines.map(function (line) {
|
|
85
|
+
line = line.replace(/^var\s*.*\s*=\s*require\s*\(.+\).*/, '');
|
|
86
|
+
line = line.replace(/^module.exports\s*=.*/, '');
|
|
87
|
+
return line;
|
|
88
|
+
}).join('\n');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (this.isMinified) file = this.minify(file);
|
|
92
|
+
else file = this.stripComments(file);
|
|
93
|
+
|
|
94
|
+
if (this.isCached) {
|
|
95
|
+
fs.writeFileSync(this.builder.cachePath(service), file);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return file;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
DefaultStrategy.prototype.getService = function(service, version) {
|
|
102
|
+
if (service === 'all') {
|
|
103
|
+
return Object.keys(this.serviceClasses).map(function(service) {
|
|
104
|
+
var out = this.serviceClasses[service].apiVersions.map(function(version) {
|
|
105
|
+
if (version.indexOf('*') >= 0) return null;
|
|
106
|
+
return this.getService(service, version);
|
|
107
|
+
}.bind(this)).filter(function(c) { return c !== null; }).join('\n');
|
|
108
|
+
|
|
109
|
+
if (this.isCached) {
|
|
110
|
+
// build 'latest', but don't add it to code (for caching)
|
|
111
|
+
this.getService(service, 'latest');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return out;
|
|
115
|
+
}.bind(this)).join('\n');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
var svc, api;
|
|
119
|
+
if (!this.serviceClasses[service]) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
var ClassName = this.serviceClasses[service];
|
|
125
|
+
svc = new ClassName({apiVersion: version, endpoint: 'localhost'});
|
|
126
|
+
api = this.apis.load(service, svc.api.apiVersion);
|
|
127
|
+
} catch (e) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
var line = util.format(
|
|
132
|
+
'AWS.Service.defineServiceApi(AWS.%s, "%s", %s);',
|
|
133
|
+
this.apis.serviceName(service), svc.api.apiVersion, JSON.stringify(api));
|
|
134
|
+
|
|
135
|
+
if (this.isCached) {
|
|
136
|
+
fs.writeFileSync(this.builder.cachePath(service + '-' + version), line);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return line;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
DefaultStrategy.prototype.getCore = function(callback) {
|
|
143
|
+
var img = require('browserify/node_modules/insert-module-globals');
|
|
144
|
+
img.vars.process = function() { return '{browser:true}'; };
|
|
145
|
+
|
|
146
|
+
var browserify = require('browserify');
|
|
147
|
+
var opts = { basedir: this.libPath };
|
|
148
|
+
browserify(opts).add('./lib/browser').
|
|
149
|
+
ignore('domain').bundle(function (err, data) {
|
|
150
|
+
if (err) return callback(err);
|
|
151
|
+
|
|
152
|
+
var code = (data || '').toString();
|
|
153
|
+
if (this.isMinified) code = this.minify(code);
|
|
154
|
+
else code = this.stripComments(code);
|
|
155
|
+
|
|
156
|
+
code = this.license + code;
|
|
157
|
+
if (this.isCached) {
|
|
158
|
+
fs.writeFileSync(this.builder.cachePath('_core'), code);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
callback(null, code);
|
|
162
|
+
}.bind(this));
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
module.exports = DefaultStrategy;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
helpers = require('./helpers')
|
|
2
|
+
Builder = helpers.Builder
|
|
3
|
+
exec = require('child_process').exec
|
|
4
|
+
fs = require('fs')
|
|
5
|
+
expect = helpers.chai.expect
|
|
6
|
+
|
|
7
|
+
describe 'Builder', ->
|
|
8
|
+
describe 'addServices', ->
|
|
9
|
+
builder = null
|
|
10
|
+
code = null
|
|
11
|
+
beforeEach -> builder = new helpers.Builder
|
|
12
|
+
|
|
13
|
+
add = (services) ->
|
|
14
|
+
builder.addServices(services)
|
|
15
|
+
code = builder.serviceCode.join('\n')
|
|
16
|
+
|
|
17
|
+
assertServiceAdded = (klass, version) ->
|
|
18
|
+
version = version || new helpers.AWS[klass](endpoint: 'localhost').api.apiVersion;
|
|
19
|
+
expect(code).to.match(new RegExp('AWS\\.' + klass +
|
|
20
|
+
' = AWS\\.Service\\.defineService\\(\'' +
|
|
21
|
+
helpers.AWS[klass].serviceIdentifier + '\''))
|
|
22
|
+
expect(code).to.match(new RegExp(
|
|
23
|
+
'AWS\\.Service\\.defineServiceApi\\(AWS\\.' +
|
|
24
|
+
klass + ', "' + version + '",'))
|
|
25
|
+
|
|
26
|
+
assertBundleFailed = (services, errMsg) ->
|
|
27
|
+
expect(-> builder.addServices(services)).to.throw(errMsg)
|
|
28
|
+
|
|
29
|
+
it 'accepts comma delimited services by name', ->
|
|
30
|
+
add 's3,cloudwatch'
|
|
31
|
+
assertServiceAdded 'S3'
|
|
32
|
+
assertServiceAdded 'CloudWatch'
|
|
33
|
+
assertServiceAdded 'STS' # STS always added
|
|
34
|
+
|
|
35
|
+
it 'uses latest service version if version suffix is not supplied', ->
|
|
36
|
+
add 'rds'
|
|
37
|
+
assertServiceAdded 'RDS'
|
|
38
|
+
|
|
39
|
+
it 'accepts fully qualified service-version pair', ->
|
|
40
|
+
add 'rds-2013-09-09'
|
|
41
|
+
assertServiceAdded 'RDS', '2013-09-09'
|
|
42
|
+
|
|
43
|
+
it 'accepts "all" for all services', ->
|
|
44
|
+
add 'all'
|
|
45
|
+
Object.keys(builder.buildStrategy.serviceClasses).forEach (s) ->
|
|
46
|
+
name = builder.buildStrategy.apis.serviceName(s)
|
|
47
|
+
assertServiceAdded(name)
|
|
48
|
+
|
|
49
|
+
it 'throws an error if the service does not exist', ->
|
|
50
|
+
assertBundleFailed 'invalidmodule', 'Missing modules: invalidmodule'
|
|
51
|
+
|
|
52
|
+
it 'throws an error if the service version does not exist', ->
|
|
53
|
+
services = 's3-1999-01-01'
|
|
54
|
+
msg = 'Missing modules: s3-1999-01-01'
|
|
55
|
+
assertBundleFailed(services, msg)
|
|
56
|
+
|
|
57
|
+
it 'groups multiple errors into one error object', ->
|
|
58
|
+
services = 's3-1999-01-01,invalidmodule,dynamodb-01-01-01'
|
|
59
|
+
msg = 'Missing modules: dynamodb-01-01-01, invalidmodule, s3-1999-01-01'
|
|
60
|
+
assertBundleFailed(services, msg)
|
|
61
|
+
|
|
62
|
+
it 'throws an opaque error if special characters are found (/, ., *)', ->
|
|
63
|
+
msg = 'Incorrectly formatted service names'
|
|
64
|
+
assertBundleFailed('path/to/service', msg)
|
|
65
|
+
assertBundleFailed('to/../../../root', msg)
|
|
66
|
+
assertBundleFailed('*.js', msg)
|
|
67
|
+
assertBundleFailed('a.b', msg)
|
|
68
|
+
assertBundleFailed('a=b', msg)
|
|
69
|
+
assertBundleFailed('!d', msg)
|
|
70
|
+
assertBundleFailed('valid1,valid2,invalid.module', msg)
|
|
71
|
+
|
|
72
|
+
describe 'build', ->
|
|
73
|
+
bundleCache = {}
|
|
74
|
+
data = null
|
|
75
|
+
|
|
76
|
+
beforeEach -> data = ''
|
|
77
|
+
|
|
78
|
+
buildBundle = (services, opts, code, cb) ->
|
|
79
|
+
cacheKey = JSON.stringify(services: services, options: opts)
|
|
80
|
+
if bundleCache[cacheKey]
|
|
81
|
+
result = null
|
|
82
|
+
if code
|
|
83
|
+
result = helpers.evalCode(code, bundleCache[cacheKey])
|
|
84
|
+
return cb(null, result)
|
|
85
|
+
|
|
86
|
+
opts = opts || {}
|
|
87
|
+
new Builder(opts).addServices(services).build (err, d) ->
|
|
88
|
+
data = d
|
|
89
|
+
bundleCache[cacheKey] = data
|
|
90
|
+
result = null
|
|
91
|
+
if !err && code
|
|
92
|
+
result = helpers.evalCode(code, data)
|
|
93
|
+
cb(err, result)
|
|
94
|
+
|
|
95
|
+
it 'defaults to no minification', ->
|
|
96
|
+
buildBundle null, null, 'window.AWS', (err, AWS) ->
|
|
97
|
+
expect(data).to.match(/Copyright Amazon\.com/i)
|
|
98
|
+
|
|
99
|
+
it 'can be minified (slow)', ->
|
|
100
|
+
buildBundle null, minify: true, null, ->
|
|
101
|
+
expect(data).to.match(/Copyright Amazon\.com/i) # has license
|
|
102
|
+
expect(data).to.match(/function \w\(\w,\w,\w\)\{function \w\(\w,\w\)\{/)
|
|
103
|
+
|
|
104
|
+
it 'can build default services into bundle', ->
|
|
105
|
+
buildBundle null, null, 'window.AWS', (err, AWS) ->
|
|
106
|
+
expect(new AWS.S3().api.apiVersion).to.equal(new helpers.AWS.S3().api.apiVersion)
|
|
107
|
+
expect(new AWS.DynamoDB().api.apiVersion).to.equal(new helpers.AWS.DynamoDB().api.apiVersion)
|
|
108
|
+
expect(new AWS.STS().api.apiVersion).to.equal(new helpers.AWS.STS().api.apiVersion)
|
|
109
|
+
|
|
110
|
+
it 'can build all services into bundle', ->
|
|
111
|
+
buildBundle 'all', null, 'window.AWS', (err, AWS) ->
|
|
112
|
+
Object.keys(helpers.AWS).forEach (k) ->
|
|
113
|
+
if k.serviceIdentifier
|
|
114
|
+
expect(typeof AWS[k]).to.equal('object')
|
|
115
|
+
|
|
116
|
+
describe 'cached writer', ->
|
|
117
|
+
it 'writes core and services to disk', (done) ->
|
|
118
|
+
root = __dirname + '/tmpcache/'
|
|
119
|
+
builder = new Builder(writeCache: true, cacheRoot: root)
|
|
120
|
+
builder.addServices('s3').build ->
|
|
121
|
+
try
|
|
122
|
+
['s3.js', 's3-latest.js', '_core.js'].forEach (item) ->
|
|
123
|
+
expect(fs.existsSync(root + item)).to.equal(true, item + ' exists?')
|
|
124
|
+
finally
|
|
125
|
+
exec('rm -rf ' + root, done)
|
|
126
|
+
|
|
127
|
+
it 'writes minified core and services to disk', (done) ->
|
|
128
|
+
root = __dirname + '/tmpcache/'
|
|
129
|
+
builder = new Builder(writeCache: true, cacheRoot: root, minify: true)
|
|
130
|
+
builder.addServices('s3').build ->
|
|
131
|
+
try
|
|
132
|
+
['s3.min.js', 's3-latest.min.js', '_core.min.js'].forEach (item) ->
|
|
133
|
+
expect(fs.existsSync(root + item)).to.equal(true, item + ' exists?')
|
|
134
|
+
finally
|
|
135
|
+
exec('rm -rf ' + root, done)
|
|
136
|
+
|
|
137
|
+
describe 'cached loading', ->
|
|
138
|
+
root = __dirname + '/tmpcache/'
|
|
139
|
+
|
|
140
|
+
it 'sets up cache', (done) ->
|
|
141
|
+
builder = new Builder(writeCache: true, cacheRoot: root)
|
|
142
|
+
builder.addServices('s3').build(done)
|
|
143
|
+
|
|
144
|
+
it 'loads from cache', ->
|
|
145
|
+
builder = new Builder(cache: true, cacheRoot: root)
|
|
146
|
+
builder.addServices('all').build (err, code) ->
|
|
147
|
+
expect(code).to.contain('AWS.S3 = ')
|
|
148
|
+
|
|
149
|
+
it 'fails if cache item is missing', ->
|
|
150
|
+
builder = new Builder(cache: true, cacheRoot: root)
|
|
151
|
+
expect(-> builder.addServices('kinesis')).to.throw('Missing modules: kinesis')
|
|
152
|
+
|
|
153
|
+
it 'fails to load from core if core is missing', (done) ->
|
|
154
|
+
exec 'rm ' + root + '_core.js', ->
|
|
155
|
+
builder = new Builder(cache: true, cacheRoot: root)
|
|
156
|
+
builder.addServices('s3').build (err, data) ->
|
|
157
|
+
expect(err.message).to.equal('Core not found.')
|
|
158
|
+
expect(data).to.equal(null)
|
|
159
|
+
done()
|
|
160
|
+
|
|
161
|
+
it 'removes cache', (done) ->
|
|
162
|
+
exec('rm -rf ' + root, done)
|
|
163
|
+
|
|
164
|
+
describe 'as executable', ->
|
|
165
|
+
cwd = __dirname + '/../'
|
|
166
|
+
script = './browser-builder.js '
|
|
167
|
+
|
|
168
|
+
it 'uses first argument to get services list', (done) ->
|
|
169
|
+
exec script + 'iam-2010-05-08', cwd: cwd, maxBuffer: 999999999, (e, out) ->
|
|
170
|
+
expect(out).to.match(/Copyright Amazon\.com/i)
|
|
171
|
+
expect(out).to.contain('"2010-05-08"')
|
|
172
|
+
expect(out).not.to.contain('"2006-03-01"')
|
|
173
|
+
done()
|
|
174
|
+
|
|
175
|
+
it 'uses MINIFY environment variable to set minification mode', (done) ->
|
|
176
|
+
env = JSON.parse(JSON.stringify(process.env))
|
|
177
|
+
env.MINIFY = '1'
|
|
178
|
+
exec script, cwd: cwd, maxBuffer: 999999999, (e, out) ->
|
|
179
|
+
expect(out).to.match(/Copyright Amazon\.com/i)
|
|
180
|
+
expect(out).to.match(/function \w\(\w,\w,\w\)\{function \w\(\w,\w\)\{/)
|
|
181
|
+
expect(out).to.contain('"2006-03-01"')
|
|
182
|
+
done()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
fs = require('fs')
|
|
2
|
+
|
|
3
|
+
evalCode = (code, preamble) ->
|
|
4
|
+
eval """
|
|
5
|
+
(function() {
|
|
6
|
+
var window = GLOBAL;
|
|
7
|
+
#{preamble};
|
|
8
|
+
return #{code};
|
|
9
|
+
})();
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
module.exports =
|
|
13
|
+
AWS: require('../../lib/aws')
|
|
14
|
+
Builder: require('../browser-builder')
|
|
15
|
+
chai: require('chai')
|
|
16
|
+
evalCode: evalCode
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @title Building the SDK for the Browser
|
|
2
|
+
|
|
3
|
+
# Building the SDK for Use in the Browser
|
|
4
|
+
|
|
5
|
+
This section explains how you can create your own build of the AWS SDK for
|
|
6
|
+
JavaScript. If you are working with the SDK outside of an environment that
|
|
7
|
+
enforces CORS in your browser and want access to the full gamut of services
|
|
8
|
+
provided by the **AWS SDK for JavaScript**, it is possible to build a custom
|
|
9
|
+
copy of the SDK locally by cloning the repository and running the same build
|
|
10
|
+
tools used to generate the default hosted version of the SDK. This chapter
|
|
11
|
+
outlines the steps to build the SDK on your own with extra services and API
|
|
12
|
+
versions.
|
|
13
|
+
|
|
14
|
+
## Setting Up
|
|
15
|
+
|
|
16
|
+
In order to build the SDK, you first need to clone the Git repository containing
|
|
17
|
+
the SDK source. These instructions assume you have [Git](http://git-scm.org) and
|
|
18
|
+
a version of [Node.js](http://nodejs.org) installed on your machine.
|
|
19
|
+
|
|
20
|
+
First, clone the repository from GitHub and cd into the directory:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
git clone git://github.com/aws/aws-sdk-js
|
|
24
|
+
cd aws-sdk-js
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
After you have cloned the repository, you need to download the dependency modules
|
|
28
|
+
for both the SDK and build tool:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
You should now be able to build a packaged version of the SDK.
|
|
35
|
+
|
|
36
|
+
## Building
|
|
37
|
+
|
|
38
|
+
The builder tool is found in `dist-tools/browser-builder.js`. You can run
|
|
39
|
+
this script by typing:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
node dist-tools/browser-builder.js > aws-sdk.js
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This will build to the file `aws-sdk.js`. By default this package includes
|
|
46
|
+
only the services documented in the {file:browser-services.md Working With Services}
|
|
47
|
+
chapter. Building custom services is discussed later in this chapter. Note
|
|
48
|
+
also that by default, this file is uncompressed.
|
|
49
|
+
|
|
50
|
+
### Minifying Output
|
|
51
|
+
|
|
52
|
+
The builder tool can also compress output. To do this, set the `MINIFY`
|
|
53
|
+
environment variable like so:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
MINIFY=1 node dist-tools/browser-builder.js > aws-sdk.js
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Building Specific Services and API Versions
|
|
60
|
+
|
|
61
|
+
#### Selecting Services to Build
|
|
62
|
+
|
|
63
|
+
When building via the builder tool, you can select which services you want to
|
|
64
|
+
build into the SDK. To select services, specify the names of the services
|
|
65
|
+
delimited by commas as arguments to the tool on the command-line. For example,
|
|
66
|
+
to build only Amazon S3 and Amazon EC2, use the following command:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
node dist-tools/browser-builder.js s3,ec2 > aws-sdk-s3-ec2.js
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Selecting API Versions
|
|
73
|
+
|
|
74
|
+
You can also select specific API versions of services when building
|
|
75
|
+
by suffixing the version name after the service identifier. For example, to
|
|
76
|
+
build both API versions of Amazon DynamoDB, you could use the following
|
|
77
|
+
command:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
node dist-tools/browser-builder.js dynamodb-2011-12-05,dynamodb-2012-08-10
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Available service identifiers and API versions can be found by looking at the
|
|
84
|
+
file list in https://github.com/aws/aws-sdk-js/tree/master/lib/services/api
|
|
85
|
+
|
|
86
|
+
#### Building All Services
|
|
87
|
+
|
|
88
|
+
Finally, you can build **all services** (and API versions) by passing "all"
|
|
89
|
+
as a command-line argument:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
node dist-tools/browser-builder.js all > aws-sdk-full.js
|
|
93
|
+
```
|