@brunwig/mup-aws-beanstalk 0.8.1
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/.babelrc +6 -0
- package/.eslintignore +2 -0
- package/.eslintrc.yml +10 -0
- package/.github/FUNDING.yml +12 -0
- package/changelog.md +56 -0
- package/docs/getting-started.md +83 -0
- package/docs/index.md +333 -0
- package/index.js +1 -0
- package/lib/assets/env.sh +30 -0
- package/lib/assets/env.yaml +19 -0
- package/lib/assets/graceful_shutdown.sh +14 -0
- package/lib/assets/graceful_shutdown.yaml +7 -0
- package/lib/assets/health-check.js +54 -0
- package/lib/assets/health-check.js.map +1 -0
- package/lib/assets/nginx-server.conf +59 -0
- package/lib/assets/nginx.conf +85 -0
- package/lib/assets/nginx.yaml +13 -0
- package/lib/assets/node.sh +25 -0
- package/lib/assets/node.yaml +8 -0
- package/lib/assets/npmrc +1 -0
- package/lib/assets/package.json +7 -0
- package/lib/assets/packages.yaml +5 -0
- package/lib/assets/start.sh +21 -0
- package/lib/aws.js +98 -0
- package/lib/aws.js.map +1 -0
- package/lib/certificates.js +64 -0
- package/lib/certificates.js.map +1 -0
- package/lib/command-handlers.js +774 -0
- package/lib/command-handlers.js.map +1 -0
- package/lib/commands.js +145 -0
- package/lib/commands.js.map +1 -0
- package/lib/download.js +27 -0
- package/lib/download.js.map +1 -0
- package/lib/eb-config.js +269 -0
- package/lib/eb-config.js.map +1 -0
- package/lib/env-ready.js +121 -0
- package/lib/env-ready.js.map +1 -0
- package/lib/env-settings.js +22 -0
- package/lib/env-settings.js.map +1 -0
- package/lib/index.js +111 -0
- package/lib/index.js.map +1 -0
- package/lib/policies.js +144 -0
- package/lib/policies.js.map +1 -0
- package/lib/prepare-bundle.js +245 -0
- package/lib/prepare-bundle.js.map +1 -0
- package/lib/recheck.js +27 -0
- package/lib/recheck.js.map +1 -0
- package/lib/upload.js +75 -0
- package/lib/upload.js.map +1 -0
- package/lib/utils.js +678 -0
- package/lib/utils.js.map +1 -0
- package/lib/validate.js +67 -0
- package/lib/validate.js.map +1 -0
- package/lib/versions.js +116 -0
- package/lib/versions.js.map +1 -0
- package/package.json +65 -0
- package/readme.md +18 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.injectFiles = injectFiles;
|
|
7
|
+
exports.archiveApp = archiveApp;
|
|
8
|
+
|
|
9
|
+
var _archiver = _interopRequireDefault(require("archiver"));
|
|
10
|
+
|
|
11
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
12
|
+
|
|
13
|
+
var _ejs = _interopRequireDefault(require("ejs"));
|
|
14
|
+
|
|
15
|
+
var _lodash = require("lodash");
|
|
16
|
+
|
|
17
|
+
var _path = _interopRequireDefault(require("path"));
|
|
18
|
+
|
|
19
|
+
var _utils = require("./utils");
|
|
20
|
+
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
|
|
23
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
+
|
|
25
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
26
|
+
|
|
27
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
28
|
+
|
|
29
|
+
function copyFolderSync(src, dest) {
|
|
30
|
+
if (!_fs.default.existsSync(src)) return;
|
|
31
|
+
if (!_fs.default.existsSync(dest)) _fs.default.mkdirSync(dest, {
|
|
32
|
+
recursive: true
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
_fs.default.readdirSync(src).forEach(dirent => {
|
|
36
|
+
const [srcPath, destPath] = [src, dest].map(dirPath => _path.default.join(dirPath, dirent));
|
|
37
|
+
|
|
38
|
+
const stat = _fs.default.lstatSync(srcPath);
|
|
39
|
+
|
|
40
|
+
switch (true) {
|
|
41
|
+
case stat.isFile():
|
|
42
|
+
console.log(` ... copying ${srcPath} ${destPath}`);
|
|
43
|
+
|
|
44
|
+
_fs.default.copyFileSync(srcPath, destPath);
|
|
45
|
+
|
|
46
|
+
break;
|
|
47
|
+
|
|
48
|
+
case stat.isDirectory():
|
|
49
|
+
copyFolderSync(srcPath, destPath);
|
|
50
|
+
break;
|
|
51
|
+
|
|
52
|
+
default:
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function copy(source, destination, vars = {}) {
|
|
59
|
+
let contents = _fs.default.readFileSync(source).toString();
|
|
60
|
+
|
|
61
|
+
contents = _ejs.default.render(contents, _objectSpread(_objectSpread({}, vars), {}, {
|
|
62
|
+
padScript(content, spaces) {
|
|
63
|
+
const padding = ''.padStart(spaces, ' ');
|
|
64
|
+
return content.split('\n').map(line => padding + line).join('\n');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}), {
|
|
68
|
+
filename: source
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
_fs.default.writeFileSync(destination, contents);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function injectFiles(api, name, version, appConfig) {
|
|
75
|
+
const {
|
|
76
|
+
yumPackages,
|
|
77
|
+
forceSSL,
|
|
78
|
+
gracefulShutdown,
|
|
79
|
+
buildOptions,
|
|
80
|
+
path: appPath
|
|
81
|
+
} = appConfig;
|
|
82
|
+
const bundlePath = buildOptions.buildLocation;
|
|
83
|
+
const {
|
|
84
|
+
bucket
|
|
85
|
+
} = (0, _utils.names)({
|
|
86
|
+
app: appConfig
|
|
87
|
+
});
|
|
88
|
+
let sourcePath = api.resolvePath(__dirname, './assets/package.json');
|
|
89
|
+
let destPath = api.resolvePath(bundlePath, 'bundle/package.json');
|
|
90
|
+
copy(sourcePath, destPath, {
|
|
91
|
+
name,
|
|
92
|
+
version
|
|
93
|
+
});
|
|
94
|
+
sourcePath = api.resolvePath(__dirname, './assets/npmrc');
|
|
95
|
+
destPath = api.resolvePath(bundlePath, 'bundle/.npmrc');
|
|
96
|
+
copy(sourcePath, destPath);
|
|
97
|
+
sourcePath = api.resolvePath(__dirname, './assets/start.sh');
|
|
98
|
+
destPath = api.resolvePath(bundlePath, 'bundle/start.sh');
|
|
99
|
+
copy(sourcePath, destPath);
|
|
100
|
+
['.ebextensions', '.platform', '.platform/hooks', '.platform/hooks/prebuild', '.platform/nginx', '.platform/nginx/conf.d', '.platform/nginx/conf.d/elasticbeanstalk'].forEach(folder => {
|
|
101
|
+
try {
|
|
102
|
+
_fs.default.mkdirSync(api.resolvePath(bundlePath, 'bundle', folder));
|
|
103
|
+
} catch (e) {
|
|
104
|
+
if (e.code !== 'EEXIST') {
|
|
105
|
+
throw e;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}); // For some resources we make two copies of scripts:
|
|
109
|
+
// 1) In .platform/hooks. These are used in AWS Linux 2
|
|
110
|
+
// 2) as part of a config file in .ebextensions for older platforms
|
|
111
|
+
|
|
112
|
+
const {
|
|
113
|
+
nodeVersion,
|
|
114
|
+
npmVersion
|
|
115
|
+
} = (0, _utils.getNodeVersion)(api, bundlePath);
|
|
116
|
+
sourcePath = api.resolvePath(__dirname, './assets/node.yaml');
|
|
117
|
+
destPath = api.resolvePath(bundlePath, 'bundle/.ebextensions/node.config');
|
|
118
|
+
copy(sourcePath, destPath, {
|
|
119
|
+
nodeVersion,
|
|
120
|
+
npmVersion
|
|
121
|
+
});
|
|
122
|
+
sourcePath = api.resolvePath(__dirname, './assets/node.sh');
|
|
123
|
+
destPath = api.resolvePath(bundlePath, 'bundle/.platform/hooks/prebuild/45node.sh');
|
|
124
|
+
copy(sourcePath, destPath, {
|
|
125
|
+
nodeVersion,
|
|
126
|
+
npmVersion
|
|
127
|
+
});
|
|
128
|
+
sourcePath = api.resolvePath(__dirname, './assets/nginx.yaml');
|
|
129
|
+
destPath = api.resolvePath(bundlePath, 'bundle/.ebextensions/nginx.config');
|
|
130
|
+
copy(sourcePath, destPath, {
|
|
131
|
+
forceSSL
|
|
132
|
+
});
|
|
133
|
+
sourcePath = api.resolvePath(__dirname, './assets/nginx-server.conf');
|
|
134
|
+
destPath = api.resolvePath(bundlePath, 'bundle/.platform/nginx/conf.d/elasticbeanstalk/00_application.conf');
|
|
135
|
+
copy(sourcePath, destPath, {
|
|
136
|
+
forceSSL
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (yumPackages) {
|
|
140
|
+
sourcePath = api.resolvePath(__dirname, './assets/packages.yaml');
|
|
141
|
+
destPath = api.resolvePath(bundlePath, 'bundle/.ebextensions/packages.config');
|
|
142
|
+
copy(sourcePath, destPath, {
|
|
143
|
+
packages: yumPackages
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (gracefulShutdown) {
|
|
148
|
+
sourcePath = api.resolvePath(__dirname, './assets/graceful_shutdown.yaml');
|
|
149
|
+
destPath = api.resolvePath(bundlePath, 'bundle/.ebextensions/graceful_shutdown.config');
|
|
150
|
+
copy(sourcePath, destPath);
|
|
151
|
+
sourcePath = api.resolvePath(__dirname, './assets/graceful_shutdown.sh');
|
|
152
|
+
destPath = api.resolvePath(bundlePath, 'bundle/.platform/hooks/prebuild/48graceful_shutdown.sh');
|
|
153
|
+
copy(sourcePath, destPath);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
sourcePath = api.resolvePath(__dirname, './assets/env.yaml');
|
|
157
|
+
destPath = api.resolvePath(bundlePath, 'bundle/.ebextensions/env.config');
|
|
158
|
+
copy(sourcePath, destPath, {
|
|
159
|
+
bucketName: bucket
|
|
160
|
+
});
|
|
161
|
+
sourcePath = api.resolvePath(__dirname, './assets/env.sh');
|
|
162
|
+
destPath = api.resolvePath(bundlePath, 'bundle/.platform/hooks/prebuild/47env.sh');
|
|
163
|
+
copy(sourcePath, destPath, {
|
|
164
|
+
bucketName: bucket
|
|
165
|
+
});
|
|
166
|
+
sourcePath = api.resolvePath(__dirname, './assets/health-check.js');
|
|
167
|
+
destPath = api.resolvePath(bundlePath, 'bundle/health-check.js');
|
|
168
|
+
copy(sourcePath, destPath);
|
|
169
|
+
let customConfigPath = api.resolvePath(api.getBasePath(), `${appPath}/.ebextensions`);
|
|
170
|
+
|
|
171
|
+
let customConfig = _fs.default.existsSync(customConfigPath);
|
|
172
|
+
|
|
173
|
+
if (customConfig) {
|
|
174
|
+
console.log(' Copying files from project .ebextensions folder');
|
|
175
|
+
|
|
176
|
+
_fs.default.readdirSync(customConfigPath).forEach(file => {
|
|
177
|
+
sourcePath = api.resolvePath(customConfigPath, file);
|
|
178
|
+
destPath = api.resolvePath(bundlePath, `bundle/.ebextensions/${file}`);
|
|
179
|
+
copy(sourcePath, destPath);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
customConfigPath = api.resolvePath(api.getBasePath(), `${appPath}/.platform`);
|
|
184
|
+
customConfig = _fs.default.existsSync(customConfigPath);
|
|
185
|
+
|
|
186
|
+
if (customConfig) {
|
|
187
|
+
console.log(' Copying files from project .platform folder');
|
|
188
|
+
copyFolderSync(customConfigPath, api.resolvePath(bundlePath, 'bundle/.platform'));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function archiveApp(buildLocation, api) {
|
|
193
|
+
const bundlePath = api.resolvePath(buildLocation, 'bundle.zip');
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
_fs.default.unlinkSync(bundlePath);
|
|
197
|
+
} catch (e) {// empty
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return new Promise((resolve, reject) => {
|
|
201
|
+
(0, _utils.logStep)('=> Archiving Bundle');
|
|
202
|
+
const sourceDir = api.resolvePath(buildLocation, 'bundle');
|
|
203
|
+
|
|
204
|
+
const output = _fs.default.createWriteStream(bundlePath);
|
|
205
|
+
|
|
206
|
+
const archive = (0, _archiver.default)('zip', {
|
|
207
|
+
gzip: true,
|
|
208
|
+
gzipOptions: {
|
|
209
|
+
level: 9
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
archive.pipe(output);
|
|
213
|
+
output.once('close', resolve);
|
|
214
|
+
archive.once('error', err => {
|
|
215
|
+
(0, _utils.logStep)('=> Archiving failed:', err.message);
|
|
216
|
+
reject(err);
|
|
217
|
+
});
|
|
218
|
+
let nextProgress = 0.1;
|
|
219
|
+
archive.on('progress', ({
|
|
220
|
+
entries
|
|
221
|
+
}) => {
|
|
222
|
+
try {
|
|
223
|
+
const progress = entries.processed / entries.total;
|
|
224
|
+
|
|
225
|
+
if (progress > nextProgress) {
|
|
226
|
+
console.log(` ${(0, _lodash.round)(Math.floor(nextProgress * 100), -1)}% Archived`);
|
|
227
|
+
nextProgress += 0.1;
|
|
228
|
+
}
|
|
229
|
+
} catch (e) {
|
|
230
|
+
console.log(e);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
archive.directory(sourceDir, false, entry => {
|
|
234
|
+
if (entry.name.startsWith('.platform/hooks/')) {
|
|
235
|
+
// Hooks must be executable for AWS Beanstalk to run them
|
|
236
|
+
// Windows doesn't have a way to make a file be executable, so we
|
|
237
|
+
// set it in the zip file
|
|
238
|
+
entry.mode = 0o777;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return entry;
|
|
242
|
+
}).finalize();
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=prepare-bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/prepare-bundle.js"],"names":["copyFolderSync","src","dest","fs","existsSync","mkdirSync","recursive","readdirSync","forEach","dirent","srcPath","destPath","map","dirPath","path","join","stat","lstatSync","isFile","console","log","copyFileSync","isDirectory","copy","source","destination","vars","contents","readFileSync","toString","ejs","render","padScript","content","spaces","padding","padStart","split","line","filename","writeFileSync","injectFiles","api","name","version","appConfig","yumPackages","forceSSL","gracefulShutdown","buildOptions","appPath","bundlePath","buildLocation","bucket","app","sourcePath","resolvePath","__dirname","folder","e","code","nodeVersion","npmVersion","packages","bucketName","customConfigPath","getBasePath","customConfig","file","archiveApp","unlinkSync","Promise","resolve","reject","sourceDir","output","createWriteStream","archive","gzip","gzipOptions","level","pipe","once","err","message","nextProgress","on","entries","progress","processed","total","Math","floor","directory","entry","startsWith","mode","finalize"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,SAASA,cAAT,CAAwBC,GAAxB,EAA6BC,IAA7B,EAAmC;AACjC,MAAI,CAACC,YAAGC,UAAH,CAAcH,GAAd,CAAL,EAAyB;AACzB,MAAI,CAACE,YAAGC,UAAH,CAAcF,IAAd,CAAL,EAA0BC,YAAGE,SAAH,CAAaH,IAAb,EAAmB;AAAEI,IAAAA,SAAS,EAAE;AAAb,GAAnB;;AAE1BH,cAAGI,WAAH,CAAeN,GAAf,EAAoBO,OAApB,CAA6BC,MAAD,IAAY;AACtC,UAAM,CAACC,OAAD,EAAUC,QAAV,IAAsB,CAACV,GAAD,EAAMC,IAAN,EAAYU,GAAZ,CAAgBC,OAAO,IAAIC,cAAKC,IAAL,CAAUF,OAAV,EAAmBJ,MAAnB,CAA3B,CAA5B;;AACA,UAAMO,IAAI,GAAGb,YAAGc,SAAH,CAAaP,OA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uE,IAAI,CAACC,KAAL,CAAWP,YAAY,GAAG,GAA1B,CAAN,EAAsC,CAAC,CAAvC,CAA0C,YAA3D;AACAA,UAAAA,YAAY,IAAI,GAAhB;AACD;AACF,OAPD,CAOE,OAAO1B,CAAP,EAAU;AACVxC,QAAAA,OAAO,CAACC,GAAR,CAAYuC,CAAZ;AACD;AACF,KAXD;AAaAkB,IAAAA,OAAO,CAACgB,SAAR,CAAkBnB,SAAlB,EAA6B,KAA7B,EAAqCoB,KAAD,IAAW;AAC7C,UAAIA,KAAK,CAACnD,IAAN,CAAWoD,UAAX,CAAsB,kBAAtB,CAAJ,EAA+C;AAC7C;AACA;AACA;AACAD,QAAAA,KAAK,CAACE,IAAN,GAAa,KAAb;AACD;;AACD,aAAOF,KAAP;AACD,KARD,EAQGG,QARH;AASD,GA3CM,CAAP;AA4CD","sourcesContent":["import archiver from 'archiver';\nimport fs from 'fs';\nimport ejs from 'ejs';\nimport { round } from 'lodash';\nimport path from 'path';\nimport { getNodeVersion, logStep, names } from './utils';\n\nfunction copyFolderSync(src, dest) {\n if (!fs.existsSync(src)) return;\n if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });\n\n fs.readdirSync(src).forEach((dirent) => {\n const [srcPath, destPath] = [src, dest].map(dirPath => path.join(dirPath, dirent));\n const stat = fs.lstatSync(srcPath);\n\n switch (true) {\n case stat.isFile():\n console.log(` ... copying ${srcPath} ${destPath}`);\n fs.copyFileSync(srcPath, destPath);\n break;\n case stat.isDirectory():\n copyFolderSync(srcPath, destPath);\n break;\n default:\n break;\n }\n });\n}\n\nfunction copy(source, destination, vars = {}) {\n let contents = fs.readFileSync(source).toString();\n\n contents = ejs.render(\n contents,\n {\n ...vars,\n padScript(content, spaces) {\n const padding = ''.padStart(spaces, ' ');\n return content.split('\\n').map(line => padding + line).join('\\n');\n }\n },\n {\n filename: source\n }\n );\n\n fs.writeFileSync(destination, contents);\n}\n\nexport function injectFiles(api, name, version, appConfig) {\n const {\n yumPackages,\n forceSSL,\n gracefulShutdown,\n buildOptions,\n path: appPath\n } = appConfig;\n const bundlePath = buildOptions.buildLocation;\n const {\n bucket\n } = names({ app: appConfig });\n\n let sourcePath = api.resolvePath(__dirname, './assets/package.json');\n let destPath = api.resolvePath(bundlePath, 'bundle/package.json');\n copy(sourcePath, destPath, {\n name,\n version\n });\n\n sourcePath = api.resolvePath(__dirname, './assets/npmrc');\n destPath = api.resolvePath(bundlePath, 'bundle/.npmrc');\n copy(sourcePath, destPath);\n\n sourcePath = api.resolvePath(__dirname, './assets/start.sh');\n destPath = api.resolvePath(bundlePath, 'bundle/start.sh');\n copy(sourcePath, destPath);\n\n [\n '.ebextensions',\n '.platform',\n '.platform/hooks',\n '.platform/hooks/prebuild',\n '.platform/nginx',\n '.platform/nginx/conf.d',\n '.platform/nginx/conf.d/elasticbeanstalk'\n ].forEach((folder) => {\n try {\n fs.mkdirSync(api.resolvePath(bundlePath, 'bundle', folder));\n } catch (e) {\n if (e.code !== 'EEXIST') {\n throw e;\n }\n }\n });\n\n\n // For some resources we make two copies of scripts:\n // 1) In .platform/hooks. These are used in AWS Linux 2\n // 2) as part of a config file in .ebextensions for older platforms\n const { nodeVersion, npmVersion } = getNodeVersion(api, bundlePath);\n sourcePath = api.resolvePath(__dirname, './assets/node.yaml');\n destPath = api.resolvePath(bundlePath, 'bundle/.ebextensions/node.config');\n copy(sourcePath, destPath, { nodeVersion, npmVersion });\n\n sourcePath = api.resolvePath(__dirname, './assets/node.sh');\n destPath = api.resolvePath(bundlePath, 'bundle/.platform/hooks/prebuild/45node.sh');\n copy(sourcePath, destPath, { nodeVersion, npmVersion });\n\n sourcePath = api.resolvePath(__dirname, './assets/nginx.yaml');\n destPath = api.resolvePath(bundlePath, 'bundle/.ebextensions/nginx.config');\n copy(sourcePath, destPath, { forceSSL });\n\n sourcePath = api.resolvePath(__dirname, './assets/nginx-server.conf');\n destPath = api.resolvePath(bundlePath, 'bundle/.platform/nginx/conf.d/elasticbeanstalk/00_application.conf');\n copy(sourcePath, destPath, { forceSSL });\n\n if (yumPackages) {\n sourcePath = api.resolvePath(__dirname, './assets/packages.yaml');\n destPath = api.resolvePath(bundlePath, 'bundle/.ebextensions/packages.config');\n copy(sourcePath, destPath, { packages: yumPackages });\n }\n\n if (gracefulShutdown) {\n sourcePath = api.resolvePath(__dirname, './assets/graceful_shutdown.yaml');\n destPath = api.resolvePath(bundlePath, 'bundle/.ebextensions/graceful_shutdown.config');\n copy(sourcePath, destPath);\n\n sourcePath = api.resolvePath(__dirname, './assets/graceful_shutdown.sh');\n destPath = api.resolvePath(bundlePath, 'bundle/.platform/hooks/prebuild/48graceful_shutdown.sh');\n copy(sourcePath, destPath);\n }\n\n sourcePath = api.resolvePath(__dirname, './assets/env.yaml');\n destPath = api.resolvePath(bundlePath, 'bundle/.ebextensions/env.config');\n copy(sourcePath, destPath, {\n bucketName: bucket\n });\n\n sourcePath = api.resolvePath(__dirname, './assets/env.sh');\n destPath = api.resolvePath(bundlePath, 'bundle/.platform/hooks/prebuild/47env.sh');\n copy(sourcePath, destPath, {\n bucketName: bucket\n });\n\n sourcePath = api.resolvePath(__dirname, './assets/health-check.js');\n destPath = api.resolvePath(bundlePath, 'bundle/health-check.js');\n copy(sourcePath, destPath);\n\n let customConfigPath = api.resolvePath(api.getBasePath(), `${appPath}/.ebextensions`);\n let customConfig = fs.existsSync(customConfigPath);\n if (customConfig) {\n console.log(' Copying files from project .ebextensions folder');\n fs.readdirSync(customConfigPath).forEach((file) => {\n sourcePath = api.resolvePath(customConfigPath, file);\n destPath = api.resolvePath(bundlePath, `bundle/.ebextensions/${file}`);\n copy(sourcePath, destPath);\n });\n }\n\n customConfigPath = api.resolvePath(api.getBasePath(), `${appPath}/.platform`);\n customConfig = fs.existsSync(customConfigPath);\n if (customConfig) {\n console.log(' Copying files from project .platform folder');\n copyFolderSync(customConfigPath, api.resolvePath(bundlePath, 'bundle/.platform'));\n }\n}\n\nexport function archiveApp(buildLocation, api) {\n const bundlePath = api.resolvePath(buildLocation, 'bundle.zip');\n\n try {\n fs.unlinkSync(bundlePath);\n } catch (e) {\n // empty\n }\n\n return new Promise((resolve, reject) => {\n logStep('=> Archiving Bundle');\n const sourceDir = api.resolvePath(buildLocation, 'bundle');\n\n const output = fs.createWriteStream(bundlePath);\n const archive = archiver('zip', {\n gzip: true,\n gzipOptions: {\n level: 9\n }\n });\n\n archive.pipe(output);\n output.once('close', resolve);\n\n archive.once('error', (err) => {\n logStep('=> Archiving failed:', err.message);\n reject(err);\n });\n\n let nextProgress = 0.1;\n archive.on('progress', ({ entries }) => {\n try {\n const progress = entries.processed / entries.total;\n\n if (progress > nextProgress) {\n console.log(` ${round(Math.floor(nextProgress * 100), -1)}% Archived`);\n nextProgress += 0.1;\n }\n } catch (e) {\n console.log(e);\n }\n });\n\n archive.directory(sourceDir, false, (entry) => {\n if (entry.name.startsWith('.platform/hooks/')) {\n // Hooks must be executable for AWS Beanstalk to run them\n // Windows doesn't have a way to make a file be executable, so we\n // set it in the zip file\n entry.mode = 0o777;\n }\n return entry;\n }).finalize();\n });\n}\n"],"file":"prepare-bundle.js"}
|
package/lib/recheck.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getRecheckInterval = getRecheckInterval;
|
|
7
|
+
exports.checkForThrottlingException = checkForThrottlingException;
|
|
8
|
+
exports.handleThrottlingException = handleThrottlingException;
|
|
9
|
+
let throttlingExceptionCounter = 0;
|
|
10
|
+
|
|
11
|
+
function getRecheckInterval() {
|
|
12
|
+
if (throttlingExceptionCounter === 10) {
|
|
13
|
+
throw new Error('Maximum throttling backoff exceeded');
|
|
14
|
+
} else {
|
|
15
|
+
return 2 ** throttlingExceptionCounter * 10000;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function checkForThrottlingException(exception) {
|
|
20
|
+
return exception && exception.code === 'Throttling' && exception.message === 'Rate exceeded';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function handleThrottlingException() {
|
|
24
|
+
throttlingExceptionCounter++;
|
|
25
|
+
console.log(`Setting new re-check interval to ${getRecheckInterval()}ms`);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=recheck.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/recheck.js"],"names":["throttlingExceptionCounter","getRecheckInterval","Error","checkForThrottlingException","exception","code","message","handleThrottlingException","console","log"],"mappings":";;;;;;;;AAAA,IAAIA,0BAA0B,GAAG,CAAjC;;AAEO,SAASC,kBAAT,GAA8B;AACnC,MAAID,0BAA0B,KAAK,EAAnC,EAAuC;AACrC,UAAM,IAAIE,KAAJ,CAAU,qCAAV,CAAN;AACD,GAFD,MAEO;AACL,WAAQ,KAAKF,0BAAL,GAAkC,KAA1C;AACD;AACF;;AAEM,SAASG,2BAAT,CAAqCC,SAArC,EAAgD;AACrD,SAAQA,SAAS,IAAKA,SAAS,CAACC,IAAV,KAAmB,YAAjC,IAAmDD,SAAS,CAACE,OAAV,KAAsB,eAAjF;AACD;;AAEM,SAASC,yBAAT,GAAqC;AAC1CP,EAAAA,0BAA0B;AAC1BQ,EAAAA,OAAO,CAACC,GAAR,CAAa,oCAAmCR,kBAAkB,EAAG,IAArE;AACD","sourcesContent":["let throttlingExceptionCounter = 0;\n\nexport function getRecheckInterval() {\n if (throttlingExceptionCounter === 10) {\n throw new Error('Maximum throttling backoff exceeded');\n } else {\n return (2 ** throttlingExceptionCounter * 10000);\n }\n}\n\nexport function checkForThrottlingException(exception) {\n return (exception && (exception.code === 'Throttling') && (exception.message === 'Rate exceeded'));\n}\n\nexport function handleThrottlingException() {\n throttlingExceptionCounter++;\n console.log(`Setting new re-check interval to ${getRecheckInterval()}ms`);\n}\n"],"file":"recheck.js"}
|
package/lib/upload.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = upload;
|
|
7
|
+
exports.uploadEnvFile = uploadEnvFile;
|
|
8
|
+
|
|
9
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
+
|
|
11
|
+
var _shellEscape = _interopRequireDefault(require("shell-escape"));
|
|
12
|
+
|
|
13
|
+
var _aws = require("./aws");
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
function upload(appConfig, bucket, key, bundlePath) {
|
|
18
|
+
const params = {
|
|
19
|
+
Bucket: bucket
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const fileStream = _fs.default.createReadStream(bundlePath);
|
|
23
|
+
|
|
24
|
+
fileStream.on('error', err => {
|
|
25
|
+
console.log(err);
|
|
26
|
+
});
|
|
27
|
+
params.Body = fileStream;
|
|
28
|
+
params.Key = key;
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
let lastPercentage = -1;
|
|
31
|
+
|
|
32
|
+
const uploader = _aws.s3.upload(params);
|
|
33
|
+
|
|
34
|
+
uploader.on('httpUploadProgress', progress => {
|
|
35
|
+
const percentage = Math.floor(progress.loaded / progress.total * 100);
|
|
36
|
+
|
|
37
|
+
if (percentage !== lastPercentage) {
|
|
38
|
+
console.log(` Uploaded ${percentage}%`);
|
|
39
|
+
|
|
40
|
+
if (percentage === 100) {
|
|
41
|
+
console.log(' Finishing upload. This could take a couple minutes');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
lastPercentage = percentage;
|
|
46
|
+
});
|
|
47
|
+
uploader.send((err, result) => {
|
|
48
|
+
if (err) {
|
|
49
|
+
reject(err);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
resolve(result);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function uploadEnvFile(bucket, version, content) {
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const uploader = _aws.s3.upload({
|
|
61
|
+
Bucket: bucket,
|
|
62
|
+
Body: content,
|
|
63
|
+
Key: `env/${version}.txt`
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
uploader.send((err, result) => {
|
|
67
|
+
if (err) {
|
|
68
|
+
return reject(err);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
resolve(result);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/upload.js"],"names":["upload","appConfig","bucket","key","bundlePath","params","Bucket","fileStream","fs","createReadStream","on","err","console","log","Body","Key","Promise","resolve","reject","lastPercentage","uploader","s3","progress","percentage","Math","floor","loaded","total","send","result","uploadEnvFile","version","content"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;;;AAEe,SAASA,MAAT,CAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,GAAnC,EAAwCC,UAAxC,EAAoD;AACjE,QAAMC,MAAM,GAAG;AAAEC,IAAAA,MAAM,EAAEJ;AAAV,GAAf;;AACA,QAAMK,UAAU,GAAGC,YAAGC,gBAAH,CAAoBL,UAApB,CAAnB;;AACAG,EAAAA,UAAU,CAACG,EAAX,CAAc,OAAd,EAAwBC,GAAD,IAAS;AAC9BC,IAAAA,OAAO,CAACC,GAAR,CAAYF,GAAZ;AACD,GAFD;AAIAN,EAAAA,MAAM,CAACS,IAAP,GAAcP,UAAd;AACAF,EAAAA,MAAM,CAACU,GAAP,GAAaZ,GAAb;AAEA,SAAO,IAAIa,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;AACtC,QAAIC,cAAc,GAAG,CAAC,CAAtB;;AAEA,UAAMC,QAAQ,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AAOD,GAbM,CAAP;AAcD","sourcesContent":["import fs from 'fs';\nimport shellEscape from 'shell-escape';\nimport { s3 } from './aws';\n\nexport default function upload(appConfig, bucket, key, bundlePath) {\n const params = { Bucket: bucket };\n const fileStream = fs.createReadStream(bundlePath);\n fileStream.on('error', (err) => {\n console.log(err);\n });\n\n params.Body = fileStream;\n params.Key = key;\n\n return new Promise((resolve, reject) => {\n let lastPercentage = -1;\n\n const uploader = s3.upload(params);\n\n uploader.on('httpUploadProgress', (progress) => {\n const percentage = Math.floor(progress.loaded / progress.total * 100);\n\n if (percentage !== lastPercentage) {\n console.log(` Uploaded ${percentage}%`);\n\n if (percentage === 100) {\n console.log(' Finishing upload. This could take a couple minutes');\n }\n }\n\n lastPercentage = percentage;\n });\n\n uploader.send((err, result) => {\n if (err) {\n reject(err);\n return;\n }\n\n resolve(result);\n });\n });\n}\n\nexport function uploadEnvFile(bucket, version, content) {\n return new Promise((resolve, reject) => {\n const uploader = s3.upload({\n Bucket: bucket,\n Body: content,\n Key: `env/${version}.txt`\n });\n uploader.send((err, result) => {\n if (err) {\n return reject(err);\n }\n\n resolve(result);\n });\n });\n}\n"],"file":"upload.js"}
|