cloudmason2 1.4.0 → 1.5.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.
@@ -0,0 +1,36 @@
1
+ const path = require('path');
2
+
3
+ const TYPES = {
4
+ '.html': 'text/html',
5
+ '.css': 'text/css',
6
+ '.js': 'application/javascript',
7
+ '.mjs': 'application/javascript',
8
+ '.json': 'application/json',
9
+ '.txt': 'text/plain',
10
+ '.md': 'text/markdown',
11
+ '.csv': 'text/csv',
12
+ '.xml': 'application/xml',
13
+ '.yaml': 'text/yaml',
14
+ '.yml': 'text/yaml',
15
+ '.png': 'image/png',
16
+ '.jpg': 'image/jpeg',
17
+ '.jpeg': 'image/jpeg',
18
+ '.gif': 'image/gif',
19
+ '.svg': 'image/svg+xml',
20
+ '.webp': 'image/webp',
21
+ '.ico': 'image/x-icon',
22
+ '.woff': 'font/woff',
23
+ '.woff2': 'font/woff2',
24
+ '.ttf': 'font/ttf',
25
+ '.otf': 'font/otf',
26
+ '.mp4': 'video/mp4',
27
+ '.webm': 'video/webm',
28
+ '.pdf': 'application/pdf',
29
+ '.zip': 'application/zip',
30
+ '.gz': 'application/gzip'
31
+ };
32
+
33
+ // Content type from a file path or s3 key
34
+ exports.contentType = function(p){
35
+ return TYPES[path.extname(p).toLowerCase()] || 'application/octet-stream';
36
+ }
@@ -227,6 +227,7 @@ class MasonApp extends ELMNT
227
227
  background: #ffffff;
228
228
  }
229
229
  .head:hover { background: #e8e8e8; }
230
+ .name { text-transform: uppercase; letter-spacing: 0.5px; }
230
231
  .count { margin-left: auto; font-size: 12px; font-weight: 400; color: #525252; }
231
232
  .chev { transition: transform 0.15s; color: #525252; }
232
233
  .open .chev { transform: rotate(180deg); }
@@ -3,6 +3,7 @@ const { S3Client, PutObjectCommand, GetObjectCommand } = require("@aws-sdk/clien
3
3
  const { SSMClient, GetParameterCommand } = require("@aws-sdk/client-ssm");
4
4
  const OrgConfig = require('./helpers/org_config');
5
5
  const Apps = require('./helpers/apps');
6
+ const Mime = require('./helpers/mime');
6
7
 
7
8
  // The Marketplace Catalog API is only available in us-east-1
8
9
  const CATALOG_REGION = 'us-east-1';
@@ -53,7 +54,7 @@ exports.main = async function(args){
53
54
  const amiAlias = `resolve:ssm:/aws/service/marketplace/${manifest.productId}/${fullVersion}`;
54
55
  const upgradeText = buildUpgradeTemplate(stackText, amiAlias);
55
56
  const upgradeKey = `${appPrefix}/versions/${vFolder}/upgrade.yaml`;
56
- await s3.send(new PutObjectCommand({ Bucket: bucket, Key: upgradeKey, Body: upgradeText }));
57
+ await s3.send(new PutObjectCommand({ Bucket: bucket, Key: upgradeKey, Body: upgradeText, ContentType: Mime.contentType(upgradeKey) }));
57
58
  console.log(`Uploaded upgrade template s3://${bucket}/${upgradeKey}`);
58
59
 
59
60
  // --- III START CHANGE SET ---
@@ -5,6 +5,7 @@ const { S3Client, PutObjectCommand, GetObjectCommand } = require("@aws-sdk/clien
5
5
  const { EC2Client, DescribeRegionsCommand, DescribeImagesCommand, DeregisterImageCommand, DeleteSnapshotCommand } = require("@aws-sdk/client-ec2");
6
6
  const OrgConfig = require('./helpers/org_config');
7
7
  const Apps = require('./helpers/apps');
8
+ const Mime = require('./helpers/mime');
8
9
  const { buildAMI } = require('./ssh_build');
9
10
 
10
11
  exports.main = async function(args){
@@ -93,7 +94,7 @@ exports.main = async function(args){
93
94
  console.log('No AmiId parameter found in stack. Template unchanged');
94
95
  }
95
96
  }
96
- await s3.send(new PutObjectCommand({ Bucket: bucket, Key: stackKey, Body: finalStack }));
97
+ await s3.send(new PutObjectCommand({ Bucket: bucket, Key: stackKey, Body: finalStack, ContentType: Mime.contentType(stackKey) }));
97
98
  console.log(`Uploaded s3://${bucket}/${stackKey}`);
98
99
 
99
100
  // --- V UPDATE MANIFEST ---
@@ -162,7 +163,8 @@ async function uploadFile(s3, bucket, key, localPath){
162
163
  await s3.send(new PutObjectCommand({
163
164
  Bucket: bucket,
164
165
  Key: key,
165
- Body: fs.createReadStream(localPath)
166
+ Body: fs.createReadStream(localPath),
167
+ ContentType: Mime.contentType(key)
166
168
  }));
167
169
  }
168
170
 
@@ -3,14 +3,7 @@ const path = require('path');
3
3
  const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3");
4
4
  const OrgConfig = require('./helpers/org_config');
5
5
  const Apps = require('./helpers/apps');
6
-
7
- const CONTENT_TYPES = {
8
- '.html': 'text/html', '.css': 'text/css', '.js': 'application/javascript',
9
- '.json': 'application/json', '.txt': 'text/plain', '.md': 'text/markdown',
10
- '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.gif': 'image/gif',
11
- '.svg': 'image/svg+xml', '.ico': 'image/x-icon', '.csv': 'text/csv',
12
- '.yaml': 'text/yaml', '.yml': 'text/yaml', '.zip': 'application/zip', '.pdf': 'application/pdf'
13
- };
6
+ const Mime = require('./helpers/mime');
14
7
 
15
8
  // update-assets: upload a file or folder to the app's cdn folder
16
9
  exports.main = async function(args){
@@ -45,7 +38,7 @@ exports.main = async function(args){
45
38
  Bucket: bucket,
46
39
  Key: key,
47
40
  Body: fs.createReadStream(f),
48
- ContentType: CONTENT_TYPES[path.extname(f).toLowerCase()] || 'application/octet-stream'
41
+ ContentType: Mime.contentType(f)
49
42
  }));
50
43
  console.log(`Uploaded s3://${bucket}/${key}`);
51
44
  uploaded += 1;
@@ -3,6 +3,7 @@ const path = require('path');
3
3
  const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3");
4
4
  const OrgConfig = require('./helpers/org_config');
5
5
  const Apps = require('./helpers/apps');
6
+ const Mime = require('./helpers/mime');
6
7
 
7
8
  // Marketplace listing text files stored as top-level manifest attributes.
8
9
  // Names match the keys the AWS Marketplace Catalog API expects
@@ -107,7 +108,7 @@ async function applyAssets(s3, bucket, appPrefix, region, assetsPath, manifest){
107
108
  Bucket: bucket,
108
109
  Key: key,
109
110
  Body: fs.createReadStream(imgPath),
110
- ContentType: 'image/png'
111
+ ContentType: Mime.contentType(img.file)
111
112
  }));
112
113
  manifest[img.attr] = `https://${bucket}.s3.${region}.amazonaws.com/${key}`;
113
114
  console.log(`Uploaded ${img.file}: ${manifest[img.attr]}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudmason2",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "",
5
5
  "main": "main.js",
6
6
  "files": [