aws-architect 6.7.159 → 6.7.163
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 -13
- package/package.json +1 -1
package/lib/BucketManager.js
CHANGED
|
@@ -34,7 +34,7 @@ class BucketManager {
|
|
|
34
34
|
let contentTypeMapping = Object.assign({}, contentTypeMappingConst, contentTypeMappingOverride || {});
|
|
35
35
|
console.log('Deploying Website');
|
|
36
36
|
|
|
37
|
-
const uploadFile = async
|
|
37
|
+
const uploadFile = async file => {
|
|
38
38
|
let relativePath = path.relative(path.resolve(contentPath), path.resolve(file));
|
|
39
39
|
let relativePathUnixFormat = this.unixify(relativePath);
|
|
40
40
|
let matchingCacheMap = Array.isArray(cacheControlRegexMap) && cacheControlRegexMap.find(m =>
|
|
@@ -60,19 +60,21 @@ class BucketManager {
|
|
|
60
60
|
console.log(`====> ${fileUrl}`);
|
|
61
61
|
// Also upload a redirect file pointing one place below and duplicate the file at /
|
|
62
62
|
const unixifiedIndexFilePath = this.unixify(relativePath);
|
|
63
|
-
if (unixifiedIndexFilePath.match(/\.html$/)
|
|
63
|
+
if (unixifiedIndexFilePath.match(/\.html$/)) {
|
|
64
64
|
// First duplicate the file at the "/" location
|
|
65
65
|
// Then add a redirect from the base location to the "/" by duplicating the file again, this way `/route`, `/route/`, and `/route/index.html` all point to `/route/index.html`
|
|
66
|
-
const redirectFileUrl = unixifiedIndexFilePath.replace(
|
|
66
|
+
const redirectFileUrl = unixifiedIndexFilePath.replace(/index.html$/, '').replace(/\.html$/, '').replace(/[/]$/, '');
|
|
67
67
|
putObjectParams.Body = fileData;
|
|
68
68
|
putObjectParams.Key = `${this.unixify(path.join(version, redirectFileUrl))}/`;
|
|
69
69
|
await this.putObjectIfDifferent(putObjectParams);
|
|
70
70
|
console.log(` => ${putObjectParams.Key} (Handler with: /)`);
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
if (redirectFileUrl.length) {
|
|
73
|
+
putObjectParams.Body = fileData;
|
|
74
|
+
putObjectParams.Key = `${this.unixify(path.join(version, redirectFileUrl))}`;
|
|
75
|
+
await this.putObjectIfDifferent(putObjectParams);
|
|
76
|
+
console.log(` => ${putObjectParams.Key} (Handler without: /)`);
|
|
77
|
+
}
|
|
76
78
|
}
|
|
77
79
|
} catch (failure) {
|
|
78
80
|
throw { File: file, Error: failure.stack || failure.toString(), Detail: failure };
|
|
@@ -84,13 +86,8 @@ class BucketManager {
|
|
|
84
86
|
let sortedList = list.filter(file => !file.match('index.html'));
|
|
85
87
|
await Promise.all(sortedList.map(file => uploadFile(file)));
|
|
86
88
|
|
|
87
|
-
const fileCountsPerDirectoryMap = {};
|
|
88
|
-
for (const file of sortedList) {
|
|
89
|
-
const splitFile = file.split('/').slice(0, -1).join('/');
|
|
90
|
-
fileCountsPerDirectoryMap[splitFile] = true;
|
|
91
|
-
}
|
|
92
89
|
let indexList = list.filter(file => file.match('index.html')).sort((a, b) => b.split('/').length - a.split('/').length);
|
|
93
|
-
await Promise.all(indexList.map(file => uploadFile(file
|
|
90
|
+
await Promise.all(indexList.map(file => uploadFile(file)));
|
|
94
91
|
|
|
95
92
|
return { Title: 'Upload Success.', Bucket: this.Bucket, Version: version };
|
|
96
93
|
}
|