aws-architect 6.6.45 → 6.6.47
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/lib/BucketManager.js +10 -4
- package/lib/appRedirect.html +11 -11
- package/package.json +1 -1
package/lib/BucketManager.js
CHANGED
|
@@ -32,7 +32,7 @@ class BucketManager {
|
|
|
32
32
|
let contentTypeMapping = Object.assign({}, contentTypeMappingConst, contentTypeMappingOverride || {});
|
|
33
33
|
console.log('Deploying Website');
|
|
34
34
|
|
|
35
|
-
const uploadFile = async file => {
|
|
35
|
+
const uploadFile = async (file/*, directoryHasOtherFilesMap */) => {
|
|
36
36
|
let relativePath = path.relative(path.resolve(contentPath), path.resolve(file));
|
|
37
37
|
let relativePathUnixFormat = this.unixify(relativePath);
|
|
38
38
|
let matchingCacheMap = Array.isArray(cacheControlRegexMap) && cacheControlRegexMap.find(m =>
|
|
@@ -68,13 +68,14 @@ class BucketManager {
|
|
|
68
68
|
await this.putObjectIfDifferent(putObjectParams);
|
|
69
69
|
console.log(` => ${putObjectParams.Key} (Directory Handler)`);
|
|
70
70
|
|
|
71
|
-
// Then add a redirect from the base location to the "/"
|
|
71
|
+
// Then add a redirect from the base location to the "/" or if using enableIndexConversion just duplicate the file again
|
|
72
72
|
if (enableIndexConversion) {
|
|
73
73
|
putObjectParams.Body = fileData;
|
|
74
74
|
putObjectParams.Key = `${this.unixify(path.join(version, redirectFileUrl))}`;
|
|
75
75
|
} else {
|
|
76
76
|
const redirectFile = await fs.readFile(path.join(__dirname, './appRedirect.html'));
|
|
77
|
-
|
|
77
|
+
let lastPartOfPath = redirectFile.toString().split('/').slice(-1)[0];
|
|
78
|
+
const updatedRedirectFile = redirectFile.toString().replace('{{PATH}}', lastPartOfPath); // redirectFileUrl[0] === '/' ? redirectFileUrl : `/${redirectFileUrl}`);
|
|
78
79
|
putObjectParams.Body = Buffer.from(updatedRedirectFile);
|
|
79
80
|
putObjectParams.Key = this.unixify(path.join(version, redirectFileUrl));
|
|
80
81
|
putObjectParams.ContentMD5 = createHash('md5').update(updatedRedirectFile).digest('base64');
|
|
@@ -97,8 +98,13 @@ class BucketManager {
|
|
|
97
98
|
let sortedList = list.filter(file => !file.match('index.html'));
|
|
98
99
|
await Promise.all(sortedList.map(file => uploadFile(file)));
|
|
99
100
|
|
|
101
|
+
const fileCountsPerDirectoryMap = {};
|
|
102
|
+
for (const file of sortedList) {
|
|
103
|
+
const splitFile = file.split('/').slice(0, -1).join('/');
|
|
104
|
+
fileCountsPerDirectoryMap[splitFile] = true;
|
|
105
|
+
}
|
|
100
106
|
let indexList = list.filter(file => file.match('index.html')).sort((a, b) => b.split('/').length - a.split('/').length);
|
|
101
|
-
await Promise.all(indexList.map(file => uploadFile(file)));
|
|
107
|
+
await Promise.all(indexList.map(file => uploadFile(file, fileCountsPerDirectoryMap)));
|
|
102
108
|
|
|
103
109
|
return { Title: 'Upload Success.', Bucket: this.Bucket, Version: version };
|
|
104
110
|
}
|
package/lib/appRedirect.html
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
|
-
<html lang=en>
|
|
2
|
+
<html lang="en">
|
|
3
3
|
|
|
4
|
-
<head>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
</head>
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1">
|
|
7
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
8
|
+
<meta name="theme-color" content="#2d434d">
|
|
9
|
+
<title>Redirect</title>
|
|
10
|
+
<meta http-equiv="refresh" content="0; URL='./{{PATH}}/'" />
|
|
11
|
+
</head>
|
|
12
12
|
|
|
13
|
-
<body style="margin: 0; background-color: #e9eff2">
|
|
14
|
-
</body>
|
|
13
|
+
<body style="margin: 0; background-color: #e9eff2">
|
|
14
|
+
</body>
|
|
15
15
|
|
|
16
16
|
</html>
|