diff --git a/minify.sh b/minify.sh new file mode 100755 index 0000000..64f59f6 --- /dev/null +++ b/minify.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# array of files to minify +FILES=(inline main polyfills scripts styles vendor) +OPTIONS="-c toplevel,dead_code=true,unused=true" + +for i in "${FILES[@]}" +do + echo "minify ${i} ..." + $(npm bin)/uglifyjs public/${i}.bundle.js ${OPTIONS} -o public/${i}.bundle.js +done diff --git a/package-lock.json b/package-lock.json index 1c62e67..f85a287 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2,12 +2,17 @@ "name": "opt-cc", "version": "1.1.2", "lockfileVersion": 1, + "requires": true, "dependencies": { "ajv": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", - "dev": true + "dev": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } }, "ansi-regex": { "version": "0.2.1", @@ -56,13 +61,19 @@ "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", "dev": true, - "optional": true + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } }, "boom": { "version": "2.10.1", "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", "dev": true, + "requires": { + "hoek": "2.16.3" + }, "dependencies": { "hoek": { "version": "2.16.3", @@ -83,6 +94,13 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", "dev": true, + "requires": { + "ansi-styles": "1.1.0", + "escape-string-regexp": "1.0.5", + "has-ansi": "0.1.0", + "strip-ansi": "0.3.0", + "supports-color": "0.2.0" + }, "dependencies": { "supports-color": { "version": "0.2.0", @@ -102,19 +120,31 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", - "dev": true + "dev": true, + "requires": { + "delayed-stream": "1.0.0" + } }, "commander": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz", - "integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=", - "dev": true + "integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=" }, "concurrently": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-3.5.0.tgz", "integrity": "sha1-jPG3cHppFqeKT/W3e7BN7FSzebI=", - "dev": true + "dev": true, + "requires": { + "chalk": "0.5.1", + "commander": "2.6.0", + "date-fns": "1.28.5", + "lodash": "4.17.4", + "rx": "2.3.24", + "spawn-command": "0.0.2-1", + "supports-color": "3.2.3", + "tree-kill": "1.1.0" + } }, "core-js": { "version": "2.4.1", @@ -126,13 +156,19 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", - "dev": true + "dev": true, + "requires": { + "boom": "2.10.1" + } }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "dev": true, + "requires": { + "assert-plus": "1.0.0" + }, "dependencies": { "assert-plus": { "version": "1.0.0", @@ -159,7 +195,10 @@ "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", "dev": true, - "optional": true + "optional": true, + "requires": { + "jsbn": "0.1.1" + } }, "escape-string-regexp": { "version": "1.0.5", @@ -189,13 +228,21 @@ "version": "2.1.4", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", - "dev": true + "dev": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.15" + } }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "dev": true, + "requires": { + "assert-plus": "1.0.0" + }, "dependencies": { "assert-plus": { "version": "1.0.0", @@ -215,13 +262,20 @@ "version": "4.2.1", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", - "dev": true + "dev": true, + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } }, "has-ansi": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=", - "dev": true + "dev": true, + "requires": { + "ansi-regex": "0.2.1" + } }, "has-flag": { "version": "1.0.0", @@ -234,6 +288,12 @@ "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", "dev": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + }, "dependencies": { "hoek": { "version": "2.16.3", @@ -253,7 +313,12 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", - "dev": true + "dev": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.0", + "sshpk": "1.13.1" + } }, "is-typedarray": { "version": "1.0.0", @@ -283,7 +348,14 @@ "version": "9.2.0", "resolved": "https://registry.npmjs.org/joi/-/joi-9.2.0.tgz", "integrity": "sha1-M4WseQGSEwy+Iw6ALsAskhW7/to=", - "dev": true + "dev": true, + "requires": { + "hoek": "4.1.1", + "isemail": "2.2.1", + "items": "2.1.1", + "moment": "2.18.1", + "topo": "2.0.2" + } }, "jsbn": { "version": "0.1.1", @@ -302,7 +374,10 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true + "dev": true, + "requires": { + "jsonify": "0.0.0" + } }, "json-stringify-safe": { "version": "5.0.1", @@ -321,6 +396,12 @@ "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", "integrity": "sha1-o7h+QCmNjDgFUtjMdiigu5WiKRg=", "dev": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.0.2", + "json-schema": "0.2.3", + "verror": "1.3.6" + }, "dependencies": { "assert-plus": { "version": "1.0.0", @@ -346,7 +427,10 @@ "version": "2.1.15", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", "integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=", - "dev": true + "dev": true, + "requires": { + "mime-db": "1.27.0" + } }, "minimist": { "version": "1.2.0", @@ -388,7 +472,31 @@ "version": "2.81.0", "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", - "dev": true + "dev": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.15", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.1.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.2", + "tunnel-agent": "0.6.0", + "uuid": "3.1.0" + } }, "rx": { "version": "2.3.24", @@ -399,7 +507,7 @@ "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", "dev": true }, "sntp": { @@ -407,6 +515,9 @@ "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", "dev": true, + "requires": { + "hoek": "2.16.3" + }, "dependencies": { "hoek": { "version": "2.16.3", @@ -416,6 +527,11 @@ } } }, + "source-map": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=" + }, "spawn-command": { "version": "0.0.2-1", "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz", @@ -427,6 +543,16 @@ "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", "dev": true, + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, "dependencies": { "assert-plus": { "version": "1.0.0", @@ -446,25 +572,37 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", - "dev": true + "dev": true, + "requires": { + "ansi-regex": "0.2.1" + } }, "supports-color": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", - "dev": true + "dev": true, + "requires": { + "has-flag": "1.0.0" + } }, "topo": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/topo/-/topo-2.0.2.tgz", "integrity": "sha1-zVYVdSU5BXwNwEkaYhw7xvvh0YI=", - "dev": true + "dev": true, + "requires": { + "hoek": "4.1.1" + } }, "tough-cookie": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", - "dev": true + "dev": true, + "requires": { + "punycode": "1.4.1" + } }, "tree-kill": { "version": "1.1.0", @@ -476,7 +614,10 @@ "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } }, "tweetnacl": { "version": "0.14.5", @@ -485,23 +626,42 @@ "dev": true, "optional": true }, + "uglify-js": { + "version": "3.0.26", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.0.26.tgz", + "integrity": "sha512-+D/BjzuvT1oRMSkH0fuF3M/BCvDxDywmZasd1UTPPHsdsHZqJEAZSvrojgFlS7lrM3ZZWq5h7Bb5i96X1TbOJw==", + "requires": { + "commander": "2.6.0", + "source-map": "0.5.6" + } + }, "uuid": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", + "integrity": "sha1-PdPT55Crwk17DToDT/q6vijrvAQ=", "dev": true }, "verror": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=", - "dev": true + "dev": true, + "requires": { + "extsprintf": "1.0.2" + } }, "wait-on": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/wait-on/-/wait-on-2.0.2.tgz", "integrity": "sha1-CoT9BwJMb8Joyw6r5YW+IXqvK6o=", "dev": true, + "requires": { + "core-js": "2.4.1", + "joi": "9.2.0", + "minimist": "1.2.0", + "request": "2.81.0", + "rx": "4.1.0" + }, "dependencies": { "rx": { "version": "4.1.0", diff --git a/package.json b/package.json index ec4f66a..337f54c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "start": "npm run deploy-static-prod && npm start --prefix ./api", "dev": "npm run deploy-static && npm run dev --prefix ./api", "deploy-static": "cd ./static && $(npm bin)/ng build && ln -s ../api/resource/ ../public/resource", - "deploy-static-prod": "cd ./static && $(npm bin)/ng build --env=prod && ln -s ../api/resource/ ../public/resource", + "deploy-static-prod": "cd ./static && $(npm bin)/ng build --env=prod && ln -s ../api/resource/ ../public/resource && cd .. && npm run deploy-minify", + "deploy-minify": "./minify.sh", "postinstall": "npm install --prefix ./static && npm install --prefix ./api", "mongodb": "mkdir -p mongodb-data && mongod --dbpath ./mongodb-data", "test": "npm test --prefix ./api", @@ -18,5 +19,8 @@ "devDependencies": { "concurrently": "^3.4.0", "wait-on": "^2.0.2" + }, + "dependencies": { + "uglify-js": "^3.0.26" } } diff --git a/static/src/app/models/model-interfaces.ts b/static/src/app/models/model-interfaces.ts index 5b0a706..a3d5dd2 100644 --- a/static/src/app/models/model-interfaces.ts +++ b/static/src/app/models/model-interfaces.ts @@ -11,7 +11,7 @@ export interface User { _id?: string; boardUserId?: number; username?: string; - squad?: Squad; + squad?: any; //Squad or string rank?: Rank; awards?: Award[]; } @@ -54,7 +54,7 @@ export interface Rank { export interface Award { _id?: string, userId: string, - decorationId?: Decoration; + decorationId?: any; //Decoration or string reason?: string; proposer?: AppUser; date?: number; // since Date.now() returns a number diff --git a/static/src/app/request/award/req-award.component.ts b/static/src/app/request/award/req-award.component.ts index 3d213fe..6935187 100644 --- a/static/src/app/request/award/req-award.component.ts +++ b/static/src/app/request/award/req-award.component.ts @@ -79,7 +79,7 @@ export class RequestAwardComponent { addAwarding(previewImage, descriptionField) { if (this.decoration._id && this.reason.length > 0) { - const award = { + const award : Award = { "userId": this.user._id, "decorationId": this.decoration._id, "reason": this.reason, diff --git a/static/src/app/users/edit-user/edit-user.component.html b/static/src/app/users/edit-user/edit-user.component.html index 5e18fee..07c609b 100644 --- a/static/src/app/users/edit-user/edit-user.component.html +++ b/static/src/app/users/edit-user/edit-user.component.html @@ -4,7 +4,7 @@