From c4d4550268688f2c9916ce83da3c3d072cc406dc Mon Sep 17 00:00:00 2001 From: Daniel Morgenstern Date: Fri, 16 Nov 2018 12:01:27 +0100 Subject: [PATCH] fix #37 Avoid syntax highlighting for binary files or too large files --- package-lock.json | 398 ++++++++++++++++++++++++---------- package.json | 3 +- server/artifactory-service.ts | 11 +- server/fileLister.ts | 6 +- server/index.ts | 1 + src/services/BackendApi.ts | 12 +- src/services/DataStore.ts | 7 +- src/util/Util.ts | 30 +++ src/views/PackageDetail.vue | 130 +++++++---- types/TreeItem.ts | 2 + 10 files changed, 437 insertions(+), 163 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2a939da..15e1902 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "npmfrog", - "version": "1.0.0-rc.15", + "version": "1.0.0-rc.16", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -913,6 +913,12 @@ "uri-js": "^4.2.2" } }, + "ajv-errors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.0.tgz", + "integrity": "sha1-7PAh+hCP0X37Xms4Py3SM+Mf/Fk=", + "dev": true + }, "ajv-keywords": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.2.0.tgz", @@ -964,6 +970,12 @@ "string-width": "^2.0.0" } }, + "ansi-colors": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.1.tgz", + "integrity": "sha512-Xt+zb6nqgvV9SWAVp0EG3lRsHcbq5DDgqjPPz6pwgtj6RKz65zGXMNa82oJfOSBA/to6GmRP7Dr+6o+kbApTzQ==", + "dev": true + }, "ansi-escapes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", @@ -1071,16 +1083,6 @@ "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", "dev": true }, - "array-includes": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", - "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", - "dev": true, - "requires": { - "define-properties": "^1.1.2", - "es-abstract": "^1.7.0" - } - }, "array-map": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz", @@ -2064,18 +2066,11 @@ "dev": true }, "basic-auth": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz", - "integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", "requires": { - "safe-buffer": "5.1.1" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" - } + "safe-buffer": "5.1.2" } }, "batch": { @@ -4504,6 +4499,16 @@ "integrity": "sha512-95k0GDqvBjZavkuvzx/YqVLv/6YYa17fz6ILMSf7neqQITCPbnfEnQvEgMPNjH4kgobe7+WIL0yJEHku+H3qtQ==", "dev": true }, + "default-gateway": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/default-gateway/-/default-gateway-2.7.2.tgz", + "integrity": "sha512-lAc4i9QJR0YHSDFdzeBQKfZ1SRDG3hsJNEkrpcZa8QhBfidLAilT60BDEIVUUGqosFp425KOgB3uYqcnQrWafQ==", + "dev": true, + "requires": { + "execa": "^0.10.0", + "ip-regex": "^2.1.0" + } + }, "defaults": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", @@ -5243,15 +5248,6 @@ "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", "dev": true }, - "eventsource": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-0.1.6.tgz", - "integrity": "sha1-Cs7ehJ7X3RzMMsgRuxG5RNTykjI=", - "dev": true, - "requires": { - "original": ">=0.0.5" - } - }, "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", @@ -8301,16 +8297,6 @@ "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=", "dev": true }, - "import-local": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-1.0.0.tgz", - "integrity": "sha512-vAaZHieK9qjGo58agRBg+bhHX3hoTZU/Oa3GESWLz7t1U62fk63aHuDJJEteXoDeTCcPmUT+z38gkHPZkkmpmQ==", - "dev": true, - "requires": { - "pkg-dir": "^2.0.0", - "resolve-cwd": "^2.0.0" - } - }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -8385,15 +8371,6 @@ "through": "^2.3.6" } }, - "internal-ip": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/internal-ip/-/internal-ip-1.2.0.tgz", - "integrity": "sha1-rp+/k7mEh4eF1QqN4bNWlWBYz1w=", - "dev": true, - "requires": { - "meow": "^3.3.0" - } - }, "interpret": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", @@ -8429,6 +8406,12 @@ "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", "dev": true }, + "ip-regex": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/ip-regex/-/ip-regex-2.1.0.tgz", + "integrity": "sha1-+ni/XS5pE8kRzp+BnuUUa7bYROk=", + "dev": true + }, "ipaddr.js": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.6.0.tgz", @@ -9509,8 +9492,7 @@ "mime": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/mime/-/mime-2.3.1.tgz", - "integrity": "sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg==", - "dev": true + "integrity": "sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg==" }, "mime-db": { "version": "1.35.0", @@ -9697,13 +9679,13 @@ } }, "morgan": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz", - "integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz", + "integrity": "sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA==", "requires": { "basic-auth": "~2.0.0", "debug": "2.6.9", - "depd": "~1.1.1", + "depd": "~1.1.2", "on-finished": "~2.3.0", "on-headers": "~1.0.1" } @@ -14220,31 +14202,6 @@ "uuid": "^3.0.1" } }, - "sockjs-client": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.1.5.tgz", - "integrity": "sha1-G7fA9yIsQPQq3xT0RCy9Eml3GoM=", - "dev": true, - "requires": { - "debug": "^2.6.6", - "eventsource": "0.1.6", - "faye-websocket": "~0.11.0", - "inherits": "^2.0.1", - "json3": "^3.3.2", - "url-parse": "^1.1.8" - }, - "dependencies": { - "faye-websocket": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.1.tgz", - "integrity": "sha1-8O/hjE9W5PQK/H4Gxxn9XuYYjzg=", - "dev": true, - "requires": { - "websocket-driver": ">=0.5.1" - } - } - } - }, "sort-keys": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz", @@ -15682,12 +15639,6 @@ } } }, - "url-join": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/url-join/-/url-join-4.0.0.tgz", - "integrity": "sha1-TTNA6AfTdzvamZH4MFrNzCpmXSo=", - "dev": true - }, "url-loader": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/url-loader/-/url-loader-1.0.1.tgz", @@ -15751,7 +15702,7 @@ "util.promisify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz", - "integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==", + "integrity": "sha1-RA9xZaRZyaFtwUXrjnLzVocJcDA=", "dev": true, "requires": { "define-properties": "^1.1.2", @@ -16701,29 +16652,13 @@ "javascript-stringify": "^1.6.0" } }, - "webpack-dev-middleware": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-3.1.3.tgz", - "integrity": "sha512-I6Mmy/QjWU/kXwCSFGaiOoL5YEQIVmbb0o45xMoCyQAg/mClqZVTcsX327sPfekDyJWpCxb+04whNyLOIxpJdQ==", - "dev": true, - "requires": { - "loud-rejection": "^1.6.0", - "memory-fs": "~0.4.1", - "mime": "^2.1.0", - "path-is-absolute": "^1.0.0", - "range-parser": "^1.0.3", - "url-join": "^4.0.0", - "webpack-log": "^1.0.1" - } - }, "webpack-dev-server": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-3.1.5.tgz", - "integrity": "sha512-LVHg+EPwZLHIlfvokSTgtJqO/vI5CQi89fASb5JEDtVMDjY0yuIEqPPdMiKaBJIB/Ab7v/UN/sYZ7WsZvntQKw==", + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-3.1.10.tgz", + "integrity": "sha512-RqOAVjfqZJtQcB0LmrzJ5y4Jp78lv9CK0MZ1YJDTaTmedMZ9PU9FLMQNrMCfVu8hHzaVLVOJKBlGEHMN10z+ww==", "dev": true, "requires": { "ansi-html": "0.0.7", - "array-includes": "^3.0.3", "bonjour": "^3.5.0", "chokidar": "^2.0.0", "compression": "^1.5.2", @@ -16733,23 +16668,24 @@ "express": "^4.16.2", "html-entities": "^1.2.0", "http-proxy-middleware": "~0.18.0", - "import-local": "^1.0.0", - "internal-ip": "1.2.0", + "import-local": "^2.0.0", + "internal-ip": "^3.0.1", "ip": "^1.1.5", "killable": "^1.0.0", "loglevel": "^1.4.1", "opn": "^5.1.0", "portfinder": "^1.0.9", + "schema-utils": "^1.0.0", "selfsigned": "^1.9.1", "serve-index": "^1.7.2", "sockjs": "0.3.19", - "sockjs-client": "1.1.5", + "sockjs-client": "1.3.0", "spdy": "^3.4.1", "strip-ansi": "^3.0.0", "supports-color": "^5.1.0", - "webpack-dev-middleware": "3.1.3", - "webpack-log": "^1.1.2", - "yargs": "11.0.0" + "webpack-dev-middleware": "3.4.0", + "webpack-log": "^2.0.0", + "yargs": "12.0.2" }, "dependencies": { "ansi-regex": { @@ -16809,6 +16745,12 @@ } } }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", + "dev": true + }, "chokidar": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz", @@ -16831,12 +16773,38 @@ } }, "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, + "decamelize": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-2.0.0.tgz", + "integrity": "sha512-Ikpp5scV3MSYxY39ymh45ZLEecsTdv/Xj2CaQfI8RLMuwi7XvjX9H/fhraiSuU+C5w5NTDu4ZU72xNiZnurBPg==", + "dev": true, + "requires": { + "xregexp": "4.0.0" + } + }, + "eventsource": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-1.0.7.tgz", + "integrity": "sha512-4Ln17+vVT0k8aWq+t/bF5arcS3EpT9gYtW66EPacdj/mAFevznsnyoHLPy2BA8gbIQeIHoPsvwmfBftfcG//BQ==", + "dev": true, + "requires": { + "original": "^1.0.0" } }, "expand-brackets": { @@ -16976,6 +16944,15 @@ } } }, + "faye-websocket": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.1.tgz", + "integrity": "sha1-8O/hjE9W5PQK/H4Gxxn9XuYYjzg=", + "dev": true, + "requires": { + "websocket-driver": ">=0.5.1" + } + }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -16999,6 +16976,15 @@ } } }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "requires": { + "locate-path": "^3.0.0" + } + }, "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -17020,6 +17006,32 @@ } } }, + "import-local": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-2.0.0.tgz", + "integrity": "sha512-b6s04m3O+s3CGSbqDIyP4R6aAwAeYlVq9+WUWep6iHa8ETRf9yei1U48C5MmfJmV9AiLYYBKPMq/W+/WRpQmCQ==", + "dev": true, + "requires": { + "pkg-dir": "^3.0.0", + "resolve-cwd": "^2.0.0" + } + }, + "internal-ip": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/internal-ip/-/internal-ip-3.0.1.tgz", + "integrity": "sha512-NXXgESC2nNVtU+pqmC9e6R8B1GpKxzsAQhffvh5AL79qKnodd+L7tnEQmTiUAVngqLalPbSqRA7XGIEL5nCd0Q==", + "dev": true, + "requires": { + "default-gateway": "^2.6.0", + "ipaddr.js": "^1.5.2" + } + }, + "invert-kv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", + "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", + "dev": true + }, "is-accessor-descriptor": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", @@ -17096,6 +17108,36 @@ "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", "dev": true }, + "lcid": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", + "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", + "dev": true, + "requires": { + "invert-kv": "^2.0.0" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + } + }, + "mem": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.0.0.tgz", + "integrity": "sha512-WQxG/5xYc3tMbYLXoXPm81ET2WDULiU5FxbuIoNbJqLOOI8zehXFdZuiUEgfdrU2mVB1pxBZUGlYORSrpuJreA==", + "dev": true, + "requires": { + "map-age-cleaner": "^0.1.1", + "mimic-fn": "^1.0.0", + "p-is-promise": "^1.1.0" + } + }, "micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", @@ -17117,14 +17159,134 @@ "to-regex": "^3.0.2" } }, + "os-locale": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.0.1.tgz", + "integrity": "sha512-7g5e7dmXPtzcP4bgsZ8ixDVqA7oWYuEz4lOSujeWyliPai4gfVDiFIcwBg3aGCPnmSGfzOKTK3ccPn0CKv3DBw==", + "dev": true, + "requires": { + "execa": "^0.10.0", + "lcid": "^2.0.0", + "mem": "^4.0.0" + } + }, + "p-limit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz", + "integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "requires": { + "p-limit": "^2.0.0" + } + }, + "p-try": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", + "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", + "dev": true + }, + "pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "dev": true, + "requires": { + "find-up": "^3.0.0" + } + }, + "schema-utils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz", + "integrity": "sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g==", + "dev": true, + "requires": { + "ajv": "^6.1.0", + "ajv-errors": "^1.0.0", + "ajv-keywords": "^3.1.0" + } + }, + "sockjs-client": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/sockjs-client/-/sockjs-client-1.3.0.tgz", + "integrity": "sha512-R9jxEzhnnrdxLCNln0xg5uGHqMnkhPSTzUZH2eXcR03S/On9Yvoq2wyUZILRUhZCNVu2PmwWVoyuiPz8th8zbg==", + "dev": true, + "requires": { + "debug": "^3.2.5", + "eventsource": "^1.0.7", + "faye-websocket": "~0.11.1", + "inherits": "^2.0.3", + "json3": "^3.3.2", + "url-parse": "^1.4.3" + } + }, "strip-ansi": { "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { "ansi-regex": "^2.0.0" } + }, + "webpack-dev-middleware": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-3.4.0.tgz", + "integrity": "sha512-Q9Iyc0X9dP9bAsYskAVJ/hmIZZQwf/3Sy4xCAZgL5cUkjZmUZLt4l5HpbST/Pdgjn3u6pE7u5OdGd1apgzRujA==", + "dev": true, + "requires": { + "memory-fs": "~0.4.1", + "mime": "^2.3.1", + "range-parser": "^1.0.3", + "webpack-log": "^2.0.0" + } + }, + "webpack-log": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/webpack-log/-/webpack-log-2.0.0.tgz", + "integrity": "sha512-cX8G2vR/85UYG59FgkoMamwHUIkSSlV3bBMRsbxVXVUk2j6NleCKjQ/WE9eYg9WY4w25O9w8wKP4rzNZFmUcUg==", + "dev": true, + "requires": { + "ansi-colors": "^3.0.0", + "uuid": "^3.3.2" + } + }, + "yargs": { + "version": "12.0.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.2.tgz", + "integrity": "sha512-e7SkEx6N6SIZ5c5H22RTZae61qtn3PYUE8JYbBFlK9sYmh3DMQ6E5ygtaG/2BW0JZi4WGgTR2IV5ChqlqrDGVQ==", + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^2.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^1.0.1", + "os-locale": "^3.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1 || ^4.0.0", + "yargs-parser": "^10.1.0" + } + }, + "yargs-parser": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz", + "integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==", + "dev": true, + "requires": { + "camelcase": "^4.1.0" + } } } }, diff --git a/package.json b/package.json index d7ee119..dcbbad1 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "express": "^4.16.3", "express-serve-static-core": "^0.1.1", "fs-extra": "^7.0.0", - "morgan": "^1.9.0", + "mime": "^2.3.1", + "morgan": "^1.9.1", "node-emoji": "^1.8.1", "parse-authors": "^0.2.4", "pm2": "^3.0.3", diff --git a/server/artifactory-service.ts b/server/artifactory-service.ts index eb370ed..7aab1e5 100644 --- a/server/artifactory-service.ts +++ b/server/artifactory-service.ts @@ -203,8 +203,11 @@ function getDistTags({ scope, packageName }: PackageId): AxiosPromise { : axios.get(`/-/package/${name2url({ scope, packageName })}/dist-tags`); } -async function getFileContent(packageId: PackageId, filepath: string): Promise { - const versionResponse = await getDistTags(packageId); +async function getFileContent( + packageId: PackageId, + filepath: string, + format: string = 'string', +): Promise { const absPath = path.join( tmpDir, packageId.scope, @@ -213,7 +216,9 @@ async function getFileContent(packageId: PackageId, filepath: string): Promise { const res = resolve(dir, subdir); - return (await stat(res)).isDirectory() + const stats = await stat(res); + return stats.isDirectory() ? { id: generateId(), name: subdir, @@ -34,6 +36,8 @@ export default async function getFiles( id: generateId(), name: subdir, path: recursive ? sub.substring(sub.indexOf('/') + 1, sub.length) : '', + size: stats.size, + type: mime.getType(subdir), }; }), ); diff --git a/server/index.ts b/server/index.ts index 4639205..9a5e6d2 100644 --- a/server/index.ts +++ b/server/index.ts @@ -72,6 +72,7 @@ app.get('/packageDetail/:scope/:packageName/:version/files/:path', (req, res) => version: req.params.version, }, req.params.path, + req.query.format, ) .then(response => { res.send(response); diff --git a/src/services/BackendApi.ts b/src/services/BackendApi.ts index b519b35..fbdf78b 100644 --- a/src/services/BackendApi.ts +++ b/src/services/BackendApi.ts @@ -28,6 +28,10 @@ export default class BackendApi { return this.instance || (this.instance = new this()); } + public getBaseURL(): string { + return this.baseURL; + } + public getPackages(): AxiosPromise { return this.get('packages'); } @@ -44,11 +48,15 @@ export default class BackendApi { return this.get(`packageDetail/${scope}/${packageName}${version ? `/${version}` : ''}`); } - public getFileContent(packageId: PackageId, filepath: string): AxiosPromise { + public getFileContent( + packageId: PackageId, + filepath: string, + format: string = 'string', + ): AxiosPromise { return this.get( `packageDetail/${packageId.scope}/${packageId.packageName}${ packageId.version ? `/${packageId.version}` : '' - }/files/${filepath}`, + }/files/${filepath}?format=${format}`, ); } diff --git a/src/services/DataStore.ts b/src/services/DataStore.ts index 4089ca0..53dbfd2 100644 --- a/src/services/DataStore.ts +++ b/src/services/DataStore.ts @@ -175,7 +175,11 @@ export default class DataStore { }); } - public async getFileContent(packageId: PackageId, filepath: string): Promise { + public async getFileContent( + packageId: PackageId, + filepath: string, + format: string = 'string', + ): Promise { const key = `${packageId.scope}${packageId.packageName}${packageId.version}${filepath}`; return this.fileContentCache[key] ? new Promise(resolve => { @@ -185,6 +189,7 @@ export default class DataStore { (this.fileContentPromises[key] = BackendApi.Instance.getFileContent( packageId, filepath, + format, ).then(response => { this.fileContentCache[key] = response.data; return response.data; diff --git a/src/util/Util.ts b/src/util/Util.ts index e69de29..f9061ef 100644 --- a/src/util/Util.ts +++ b/src/util/Util.ts @@ -0,0 +1,30 @@ +export default { + fileSize(bytes: number): string { + const out = + bytes < 1000 + ? { + value: bytes, + prefix: '', + } + : bytes < 1000000 + ? { + value: bytes / 1000, + prefix: 'k', + } + : bytes < 1000000000 + ? { + value: bytes / 1000000, + prefix: 'M', + } + : bytes < 1000000000 + ? { + value: bytes / 1000, + prefix: 'G', + } + : { + value: bytes, + prefix: '', + }; + return `${Math.round(out.value)} ${out.prefix}B`; + }, +}; diff --git a/src/views/PackageDetail.vue b/src/views/PackageDetail.vue index 495c048..ee308dc 100644 --- a/src/views/PackageDetail.vue +++ b/src/views/PackageDetail.vue @@ -90,8 +90,36 @@ {{ getFileIcon(item.name) }} + + +

+ + This file is too big to show it's content (> {{maxSizeToShowContent / 1000}} kB). + + This filetype ({{data.activeTreeItem.type}}) is not supported. +

+ But you can download it here: +
@@ -326,6 +355,8 @@ import Searchable from '../../types/Searchable'; import { icons } from '../plugins/vuetify'; import { close } from 'fs'; import TreeItem from '../../types/TreeItem'; +import Util from '../util/Util'; +import BackendApi from '../services/BackendApi'; @Component({ components: { @@ -395,6 +426,10 @@ export default class PackageDetail extends Vue { this.init(); } + private get baseUrl(): string { + return BackendApi.Instance.getBaseURL(); + } + private resetModel(): void { this.activeTab = 0; this.resetCurrentPackage(); @@ -425,6 +460,10 @@ export default class PackageDetail extends Vue { }); } + private get maxSizeToShowContent(): number { + return 50000; + } + private selectCode(event: Event): void { const target = event.target as HTMLElement; const label = target.classList.contains('v-icon') @@ -442,44 +481,58 @@ export default class PackageDetail extends Vue { if (this.data.packageDetail && this.data.packageDetail.fileList) { const currentFile = this.findFile(this.data.packageDetail.fileList, id); if (currentFile && !currentFile.children && currentFile.name === clickedLabel) { - this.toggleLoading(true); - const timeout = global.setTimeout(() => { - if (!this.data.activeCode) { - this.toggleLoading(false); - EventBus.$emit(Errors.TIMEOUT_ERROR, new Error('Timeout Error. No code found.')); - } - }, 30000); - const code = DataStore.Instance.getFileContent( - { - scope: this.data.currentPackage ? this.data.currentPackage.scope : undefined, - packageName: Router.currentRoute.params.packageName, - version: this.data.currentPackage ? this.data.currentPackage.version : undefined, - }, - encodeURIComponent(`${currentFile.path}/${currentFile.name}`), - ) - .then(content => { - if (typeof content === 'string') { - this.data.activeCode = content; - } else { - try { - this.data.activeCode = JSON.stringify(content, null, 2); - } catch (error) { - this.data.activeCode = 'Error: Could not display file content.'; - } + if (currentFile.size !== undefined && currentFile.size > this.maxSizeToShowContent) { + this.data.activeTreeItem = currentFile; + this.data.activeCode = undefined; + } else { + this.toggleLoading(true); + const timeout = global.setTimeout(() => { + if (!this.data.activeCode) { + this.toggleLoading(false); + EventBus.$emit(Errors.TIMEOUT_ERROR, new Error('Timeout Error. No code found.')); } - this.data.activeTreeItem = currentFile; - this.toggleLoading(false); - global.clearTimeout(timeout); - }) - .catch(error => { - this.toggleLoading(false); - EventBus.$emit(Errors.SERVER_ERROR, error); - global.clearTimeout(timeout); - }); + }, 30000); + const code = DataStore.Instance.getFileContent( + { + scope: this.data.currentPackage ? this.data.currentPackage.scope : undefined, + packageName: Router.currentRoute.params.packageName, + version: this.data.currentPackage ? this.data.currentPackage.version : undefined, + }, + encodeURIComponent(`${currentFile.path}/${currentFile.name}`), + ) + .then(content => { + if (typeof content === 'string') { + this.data.activeCode = content; + } else { + try { + this.data.activeCode = JSON.stringify(content, null, 2); + } catch (error) { + this.data.activeCode = 'Error: Could not display file content.'; + } + } + this.data.activeTreeItem = currentFile; + this.toggleLoading(false); + global.clearTimeout(timeout); + }) + .catch(error => { + this.toggleLoading(false); + EventBus.$emit(Errors.SERVER_ERROR, error); + global.clearTimeout(timeout); + }); + } } } } + private isHighlightableType(item: TreeItem): boolean { + return item.type !== undefined && + ( + item.type.endsWith('json') || + item.type.endsWith('application/javascript') || + item.type.startsWith('text') + ); + } + private resetActiveCode(): void { this.data.activeTreeItem = { id: '', @@ -641,7 +694,11 @@ export default class PackageDetail extends Vue { return languages[extension]; } } - return 'javascript'; + return 'plaintext'; + } + + private fileSize(bytes: number): string { + return Util.fileSize(bytes); } private isOld(): boolean | undefined { @@ -708,9 +765,8 @@ export default class PackageDetail extends Vue { padding: 0 !important; } -.file-content, -.loading-spinner { - margin-top: 2rem; +.v-treeview { + margin-bottom: 2rem; } pre code.hljs { diff --git a/types/TreeItem.ts b/types/TreeItem.ts index 42ee718..d57b704 100644 --- a/types/TreeItem.ts +++ b/types/TreeItem.ts @@ -3,4 +3,6 @@ export default interface TreeItem { readonly name: string; readonly path: string; readonly children?: TreeItem[]; + readonly size?: number; + readonly type?: string; }