@madgex/fert 1.6.1 → 1.7.0
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.
|
@@ -33,6 +33,7 @@ module.exports = class AssetStoreUploader {
|
|
|
33
33
|
|
|
34
34
|
const form = new FormData();
|
|
35
35
|
form.append('data', fs.createReadStream(file));
|
|
36
|
+
form.append('invalidateCache', 'false'); // opt out as will invalidate whole path (*) at end
|
|
36
37
|
form.append('modifiedById', ASSET_STORE_USER_GUID);
|
|
37
38
|
|
|
38
39
|
const spinner = ora(`${chalk.yellow('Uploading')}: ${label}`).start();
|
|
@@ -77,6 +78,34 @@ module.exports = class AssetStoreUploader {
|
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Invalidate files on all CloudFront edge locations
|
|
83
|
+
* @param {array} paths Paths to invalidate
|
|
84
|
+
*/
|
|
85
|
+
async invalidatePaths(paths) {
|
|
86
|
+
const invalidateUrl = new URL('api/assets/invalidate', this.apiUrl);
|
|
87
|
+
|
|
88
|
+
log.debug('invalidating', { paths });
|
|
89
|
+
|
|
90
|
+
const payload = {
|
|
91
|
+
modifiedById: ASSET_STORE_USER_GUID,
|
|
92
|
+
paths,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
await axios.post(invalidateUrl.href, payload, {
|
|
96
|
+
headers: {
|
|
97
|
+
apikey: this.apiKey,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
log.info(
|
|
102
|
+
`CloudFront cache invalidation sent for the following paths:\n${JSON.stringify(
|
|
103
|
+
paths
|
|
104
|
+
)}\n\nNote this may take upto ${chalk.yellow(
|
|
105
|
+
'30 seconds'
|
|
106
|
+
)} to complete.\n`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
80
109
|
// Returns array of all files in provided directory (recursive)
|
|
81
110
|
_getFilesFromDir = (dir, files = []) => {
|
|
82
111
|
fs.readdirSync(dir).forEach((entry) => {
|
package/bin/commands/publish.js
CHANGED
|
@@ -10,6 +10,7 @@ const {
|
|
|
10
10
|
AWS_PARAM_NAME,
|
|
11
11
|
REMOTE_UPLOAD_BASE,
|
|
12
12
|
UPLOAD_DIR,
|
|
13
|
+
INVALIDATION_PATH,
|
|
13
14
|
} = require('../../constants');
|
|
14
15
|
|
|
15
16
|
module.exports = async (root, options) => {
|
|
@@ -32,6 +33,7 @@ module.exports = async (root, options) => {
|
|
|
32
33
|
const apiUrl = Hoek.reachTemplate(templateCtx, ASSET_STORE_API);
|
|
33
34
|
const remoteBasePath = Hoek.reachTemplate(templateCtx, REMOTE_UPLOAD_BASE);
|
|
34
35
|
const apiKeyParamPath = Hoek.reachTemplate(templateCtx, AWS_PARAM_NAME);
|
|
36
|
+
const invalidationPath = Hoek.reachTemplate(templateCtx, INVALIDATION_PATH);
|
|
35
37
|
|
|
36
38
|
const apiKey = await getAwsParam(apiKeyParamPath);
|
|
37
39
|
|
|
@@ -49,4 +51,6 @@ module.exports = async (root, options) => {
|
|
|
49
51
|
const result = await assetStore.uploadDir(localDir);
|
|
50
52
|
|
|
51
53
|
log.success(`Publish complete in ${(result.duration / 1000).toFixed(0)}s\n`);
|
|
54
|
+
|
|
55
|
+
await assetStore.invalidatePaths([invalidationPath]);
|
|
52
56
|
};
|
package/constants.js
CHANGED
|
@@ -23,6 +23,7 @@ module.exports = {
|
|
|
23
23
|
'/api/assets/jobseekers-frontend/{fertConfig.clientPropertyId}',
|
|
24
24
|
AWS_PARAM_NAME:
|
|
25
25
|
'/{Environement_Name}/jobboard/kong/internal/consumer-key/jobseekers-frontend_{fertConfig.client.rootClientPropertyId}',
|
|
26
|
+
INVALIDATION_PATH: `/jobseekers-frontend/{fertConfig.clientPropertyId}/*`,
|
|
26
27
|
ASSET_STORE_USER_GUID: 'a386d4b6-f2df-4b80-ad1f-0349e23f530b',
|
|
27
28
|
TEMPLATES: [
|
|
28
29
|
{
|