mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Use common/logger everywhere, remove main/logger export
- in Renderer make it 'console' which a stub for silly level - in Main make it a winston logger with file output as well - in testing make it a jest mock stub - in all other cases make it a winston logger without file output - Turn on no-console - Fix logger during integration testing Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
a5e89b79d6
commit
990000678a
105 files changed
+267
-338
No files matched your search
@@ -22,10 +22,11 @@
|
||||
import fs from "fs-extra";
|
||||
import path from "path";
|
||||
import defaultBaseLensTheme from "../src/renderer/themes/lens-dark.json";
|
||||
import logger from "../src/common/logger";
|
||||
|
||||
const outputCssFile = path.resolve("src/renderer/themes/theme-vars.css");
|
||||
|
||||
const banner = `/*
|
||||
const banner = `/*
|
||||
Generated Lens theme CSS-variables, don't edit manually.
|
||||
To refresh file run $: yarn run ts-node build/${path.basename(__filename)}
|
||||
*/`;
|
||||
@@ -42,6 +43,6 @@ ${themeCssVars.join("\n")}
|
||||
`;
|
||||
|
||||
// Run
|
||||
console.info(`"Saving default Lens theme css-variables to "${outputCssFile}""`);
|
||||
logger.info(`"Saving default Lens theme css-variables to "${outputCssFile}""`);
|
||||
fs.ensureFileSync(outputCssFile);
|
||||
fs.writeFile(outputCssFile, content);
|
||||
@@ -22,6 +22,7 @@ import path from "path";
|
||||
import sharp from "sharp";
|
||||
import jsdom from "jsdom";
|
||||
import fs from "fs-extra";
|
||||
import logger from "../src/common/logger";
|
||||
|
||||
export async function generateTrayIcon(
|
||||
{
|
||||
@@ -52,9 +53,9 @@ export async function generateTrayIcon(
|
||||
|
||||
// Save icon
|
||||
await fs.writeFile(pngIconDestPath, pngIconBuffer);
|
||||
console.info(`[DONE]: Tray icon saved at "${pngIconDestPath}"`);
|
||||
logger.info(`[DONE]: Tray icon saved at "${pngIconDestPath}"`);
|
||||
} catch (err) {
|
||||
console.error(`[ERROR]: ${err}`);
|
||||
logger.error(`[ERROR]: ${err}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ import * as path from "path";
|
||||
|
||||
const helmVersion = packageInfo.config.bundledHelmVersion;
|
||||
|
||||
if (!isWindows) {
|
||||
if (isWindows) {
|
||||
new HelmCli(path.join(process.cwd(), "binaries", "client", "x64"), helmVersion).ensureBinary();
|
||||
} else {
|
||||
Promise.all([
|
||||
new HelmCli(path.join(process.cwd(), "binaries", "client", "x64"), helmVersion).ensureBinary(),
|
||||
new HelmCli(path.join(process.cwd(), "binaries", "client", "arm64"), helmVersion).ensureBinary(),
|
||||
]);
|
||||
} else {
|
||||
new HelmCli(path.join(process.cwd(), "binaries", "client", "x64"), helmVersion).ensureBinary();
|
||||
}
|
||||
+12
-11
@@ -27,6 +27,7 @@ import { ensureDir, pathExists } from "fs-extra";
|
||||
import path from "path";
|
||||
import { noop } from "lodash";
|
||||
import { isLinux, isMac } from "../src/common/vars";
|
||||
import logger from "../src/common/logger";
|
||||
|
||||
class KubectlDownloader {
|
||||
public kubectlVersion: string;
|
||||
@@ -48,7 +49,7 @@ class KubectlDownloader {
|
||||
method: "HEAD",
|
||||
uri: this.url,
|
||||
resolveWithFullResponse: true,
|
||||
}).catch(console.error);
|
||||
}).catch(logger.error);
|
||||
|
||||
if (response.headers["etag"]) {
|
||||
return response.headers["etag"].replace(/"/g, "");
|
||||
@@ -65,12 +66,12 @@ class KubectlDownloader {
|
||||
const etag = await this.urlEtag();
|
||||
|
||||
if (hash == etag) {
|
||||
console.log("Kubectl md5sum matches the remote etag");
|
||||
logger.info("Kubectl md5sum matches the remote etag");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
console.log(`Kubectl md5sum ${hash} does not match the remote etag ${etag}, unlinking and downloading again`);
|
||||
logger.info(`Kubectl md5sum ${hash} does not match the remote etag ${etag}, unlinking and downloading again`);
|
||||
await fs.promises.unlink(this.path);
|
||||
}
|
||||
|
||||
@@ -79,14 +80,14 @@ class KubectlDownloader {
|
||||
|
||||
public async downloadKubectl() {
|
||||
if (await this.checkBinary()) {
|
||||
return console.log("Already exists and is valid");
|
||||
return logger.info("Already exists and is valid");
|
||||
}
|
||||
|
||||
await ensureDir(path.dirname(this.path), 0o755);
|
||||
|
||||
const file = fs.createWriteStream(this.path);
|
||||
|
||||
console.log(`Downloading kubectl ${this.kubectlVersion} from ${this.url} to ${this.path}`);
|
||||
logger.info(`Downloading kubectl ${this.kubectlVersion} from ${this.url} to ${this.path}`);
|
||||
const requestOpts: request.UriOptions & request.CoreOptions = {
|
||||
uri: this.url,
|
||||
gzip: true,
|
||||
@@ -94,19 +95,19 @@ class KubectlDownloader {
|
||||
const stream = request(requestOpts);
|
||||
|
||||
stream.on("complete", () => {
|
||||
console.log("kubectl binary download finished");
|
||||
logger.info("kubectl binary download finished");
|
||||
file.end(noop);
|
||||
});
|
||||
|
||||
stream.on("error", (error) => {
|
||||
console.log(error);
|
||||
logger.info(error);
|
||||
fs.unlink(this.path, noop);
|
||||
throw error;
|
||||
});
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
file.on("close", () => {
|
||||
console.log("kubectl binary download closed");
|
||||
logger.info("kubectl binary download closed");
|
||||
fs.chmod(this.path, 0o755, (err) => {
|
||||
if (err) reject(err);
|
||||
});
|
||||
@@ -133,9 +134,9 @@ if (isMac) {
|
||||
}
|
||||
|
||||
downloads.forEach((dlOpts) => {
|
||||
console.log(dlOpts);
|
||||
logger.info(dlOpts);
|
||||
const downloader = new KubectlDownloader(downloadVersion, dlOpts.platform, dlOpts.arch, dlOpts.target);
|
||||
|
||||
console.log(`Downloading: ${JSON.stringify(dlOpts)}`);
|
||||
downloader.downloadKubectl().then(() => downloader.checkBinary().then(() => console.log("Download complete")));
|
||||
logger.info(`Downloading: ${JSON.stringify(dlOpts)}`);
|
||||
downloader.downloadKubectl().then(() => downloader.checkBinary().then(() => logger.info("Download complete")));
|
||||
});
|
||||
@@ -23,6 +23,7 @@ import * as path from "path";
|
||||
import appInfo from "../package.json";
|
||||
import semver from "semver";
|
||||
import fastGlob from "fast-glob";
|
||||
import logger from "../src/common/logger";
|
||||
|
||||
const packagePath = path.join(__dirname, "../package.json");
|
||||
const versionInfo = semver.parse(appInfo.version);
|
||||
@@ -63,7 +64,7 @@ async function writeOutNewVersions() {
|
||||
]);
|
||||
}
|
||||
|
||||
function main() {
|
||||
async function main() {
|
||||
const prereleaseParts: string[] = [getBuildChannel()];
|
||||
|
||||
if (versionInfo.prerelease && versionInfo.prerelease.length > 1) {
|
||||
@@ -74,11 +75,12 @@ function main() {
|
||||
|
||||
appInfo.version = `${versionInfo.major}.${versionInfo.minor}.${versionInfo.patch}-${prereleaseParts.join(".")}`;
|
||||
|
||||
writeOutNewVersions()
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
try {
|
||||
await writeOutNewVersions();
|
||||
} catch (error) {
|
||||
logger.error("Failed to write new build versions", error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in new issue
Block a user