diff --git a/package.json b/package.json index 4aa73fdacc..b5e84f6536 100644 --- a/package.json +++ b/package.json @@ -171,6 +171,7 @@ "@types/proper-lockfile": "^4.1.1", "@types/react-beautiful-dnd": "^13.0.0", "@types/tar": "^4.0.3", + "@types/triple-beam": "^1.3.2", "array-move": "^3.0.0", "chalk": "^4.1.0", "conf": "^7.0.1", @@ -204,9 +205,11 @@ "semver": "^7.3.2", "serializr": "^2.0.3", "shell-env": "^3.0.0", + "string.ify": "^1.0.64", "tar": "^6.0.2", "tcp-port-used": "^1.0.1", "tempy": "^0.5.0", + "triple-beam": "^1.3.0", "universal-analytics": "^0.4.20", "uuid": "^8.1.0", "win-ca": "^3.2.0", diff --git a/src/common/cluster-store_test.ts b/src/common/cluster-store_test.ts index 2810883690..2fb9ff8b34 100644 --- a/src/common/cluster-store_test.ts +++ b/src/common/cluster-store_test.ts @@ -366,4 +366,9 @@ describe("pre 3.6.0-beta.1 config with an existing cluster", () => { const { icon } = clusterStore.clustersList[0].preferences; expect(icon.startsWith("data:;base64,")).toBe(true); }) + + it("migration of icon does not have whitespace", async () => { + const { icon } = clusterStore.clustersList[0].preferences; + expect(/\s/g.exec(icon)).toBe(null); + }) }) diff --git a/src/main/logger.ts b/src/main/logger.ts index 4068aaacd2..a027e6d1c7 100644 --- a/src/main/logger.ts +++ b/src/main/logger.ts @@ -1,6 +1,27 @@ import { app, remote } from "electron"; import winston from "winston" import { isDebugging } from "../common/vars"; +import { format } from "logform"; +import stringify from "string.ify"; +import { MESSAGE } from "triple-beam"; + +const debugSimple = format(info => { + const rest = Object.assign({}, info); + delete rest.level; + delete rest.message; + delete rest.splat; + + const stringifiedRest = stringify.configure({ maxStringLength: 300 })(rest); + + const padding = info.padding?.[info.level] || ''; + if (stringifiedRest !== '{}') { + info[MESSAGE as any] = `${info.level}:${padding} ${info.message} ${stringifiedRest}`; + } else { + info[MESSAGE as any] = `${info.level}:${padding} ${info.message}`; + } + + return info; +}); const consoleOptions: winston.transports.ConsoleTransportOptions = { handleExceptions: false, @@ -20,7 +41,7 @@ const fileOptions: winston.transports.FileTransportOptions = { const logger = winston.createLogger({ format: winston.format.combine( winston.format.colorize(), - winston.format.simple(), + isDebugging ? debugSimple() : winston.format.simple(), ), transports: [ new winston.transports.Console(consoleOptions), diff --git a/src/migrations/cluster-store/3.6.0-beta.1.ts b/src/migrations/cluster-store/3.6.0-beta.1.ts index 412c77ab96..f0023d8674 100644 --- a/src/migrations/cluster-store/3.6.0-beta.1.ts +++ b/src/migrations/cluster-store/3.6.0-beta.1.ts @@ -12,6 +12,7 @@ export default migration({ version: "3.6.0-beta.1", run(store, printLog) { const userDataPath = (app || remote.app).getPath("userData") + const iconsFolder = path.join(userDataPath, "icons") const kubeConfigBase = ClusterStore.getCustomKubeConfigPath(""); const storedClusters: ClusterModel[] = store.get("clusters") || []; @@ -61,5 +62,7 @@ export default migration({ if (migratedClusters.length > 0) { store.set("clusters", migratedClusters) } + + fse.removeSync(iconsFolder) } }) diff --git a/types/mocks.d.ts b/types/mocks.d.ts index 7ddd25267b..b1324be942 100644 --- a/types/mocks.d.ts +++ b/types/mocks.d.ts @@ -3,6 +3,7 @@ declare module "mac-ca" declare module "win-ca" declare module "@hapi/call" declare module "@hapi/subtext" +declare module "string.ify" // Global path to static assets declare const __static: string; diff --git a/yarn.lock b/yarn.lock index c7d43c4472..e9565b555f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2199,6 +2199,11 @@ resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.0.tgz#fef1904e4668b6e5ecee60c52cc6a078ffa6697d" integrity sha512-I99sngh224D0M7XgW1s120zxCt3VYQ3IQsuw3P3jbq5GG4yc79+ZjyKznyOGIQrflfylLgcfekeZW/vk0yng6A== +"@types/triple-beam@^1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@types/triple-beam/-/triple-beam-1.3.2.tgz#38ecb64f01aa0d02b7c8f4222d7c38af6316fef8" + integrity sha512-txGIh+0eDFzKGC25zORnswy+br1Ha7hj5cMVwKIU7+s0U2AxxJru/jZSMU6OC9MJWP6+pc/hc6ZjyZShpsyY2g== + "@types/trusted-types@*": version "1.0.4" resolved "https://registry.yarnpkg.com/@types/trusted-types/-/trusted-types-1.0.4.tgz#922d092c84a776a59acb0bd6785fd82b59b9bad5" @@ -9333,6 +9338,11 @@ pretty-format@^26.0.1: ansi-styles "^4.0.0" react-is "^16.12.0" +printable-characters@^1.0.26, printable-characters@^1.0.42: + version "1.0.42" + resolved "https://registry.yarnpkg.com/printable-characters/-/printable-characters-1.0.42.tgz#3f18e977a9bd8eb37fcc4ff5659d7be90868b3d8" + integrity sha1-Pxjpd6m9jrN/zE/1ZZ176Qhos9g= + private@^0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -10782,6 +10792,21 @@ string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" +string.bullet@^1.0.12: + version "1.0.12" + resolved "https://registry.yarnpkg.com/string.bullet/-/string.bullet-1.0.12.tgz#b41fc417850a57e4042bf3cf347b6eee257ee253" + integrity sha1-tB/EF4UKV+QEK/PPNHtu7iV+4lM= + dependencies: + printable-characters "^1.0.26" + +string.ify@^1.0.64: + version "1.0.64" + resolved "https://registry.yarnpkg.com/string.ify/-/string.ify-1.0.64.tgz#58de9fcc411a26bb61f83bf61a1a756da0966c3b" + integrity sha512-4Aa5yndnuOhE1GV2W3ht4rQ08XHq46JLXmSOv0jeUWEzqliBvm8lAXvt+66np+J9DkoCZikFzTzjXVLRR0F/Xw== + dependencies: + printable-characters "^1.0.42" + string.bullet "^1.0.12" + string.prototype.trimend@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913"