Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[deps] Update development related dependencies #3357

Merged
merged 19 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ app/dist-trezor/
app/main.js
app/main.js.map
app/main.js.LICENSE.txt
app/*.node
node_modules/
npm-debug.log
public/js/bundle.js
Expand Down
16 changes: 9 additions & 7 deletions app/main.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ import {
LOCALE,
DISABLE_HARDWARE_ACCEL
} from "constants/config";
import {
default as devtoolsInstaller,
REACT_DEVELOPER_TOOLS,
REDUX_DEVTOOLS
} from "electron-devtools-installer";

// setPath as decrediton
app.setPath("userData", getAppDataDirectory());
Expand Down Expand Up @@ -238,16 +243,13 @@ process.on("uncaughtException", (err) => {

const installExtensions = async () => {
if (process.env.NODE_ENV === "development") {
const installer = require("electron-devtools-installer"); // eslint-disable-line global-require

const extensions = ["REACT_DEVELOPER_TOOLS", "REDUX_DEVTOOLS"];
const extensions = [REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS];
const forceDownload = !!process.env.UPGRADE_EXTENSIONS;
for (const name of extensions) {
// eslint-disable-line
try {
await installer.default(installer[name], forceDownload);
await devtoolsInstaller(name, forceDownload);
} catch (e) {
console.log("Error installing extesion: " + e);
console.log("Error installing extension: " + e);
}
}
}
Expand Down Expand Up @@ -645,11 +647,11 @@ app.on("ready", async () => {

mainWindow = new BrowserWindow(windowOpts);
installSessionHandlers(logger);
if (debug) mainWindow.webContents.openDevTools();
mainWindow.loadURL(url);

mainWindow.webContents.on("did-finish-load", () => {
mainWindow.show();
if (debug) mainWindow.webContents.openDevTools();
mainWindow.focus();
});

Expand Down
3 changes: 1 addition & 2 deletions app/main_dev/externalRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ export const reloadAllowedExternalRequests = () => {

if (process.env.NODE_ENV === "development") {
allowedURLs.push(/^http:\/\/localhost:3000/);
allowedURLs.push(/^chrome-extension:\/\/react-developer-tools\/*/);
allowedURLs.push(/^chrome-extension:\/\/redux-devtools\/*/);
allowedURLs.push(/^chrome-extension:\/\/*/);
}

const globalCfg = getGlobalCfg();
Expand Down
37 changes: 22 additions & 15 deletions app/main_dev/logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from "path";
import { MAX_LOG_LENGTH } from "constants";
import { getAppDataDirectory } from "./paths";
import os from "os";
import logform from "logform";

let dcrdLogs = Buffer.from("");
let dcrwalletLogs = Buffer.from("");
Expand Down Expand Up @@ -45,39 +46,45 @@ const logLevelsPrintable = {

const logFormatter = (opts) => {
const lvl = logLevelsPrintable[opts.level] || "UNK";
const time = opts.timestamp();
const time = opts.timestamp;
const msg = opts.message;
const subsys = "DCTN";
return `${time} [${lvl}] ${subsys}: ${msg}`;
};

const logFormatterColorized = (opts) => {
const config = winston.config;
return config.colorize(opts.level, logFormatter(opts));
};

// createLogger creates the main app logger. This stores all logs into the
// decrediton app data dir and sends to the console when debug == true.
// This is meant to be called from the ipcMain thread.
export function createLogger(debug) {
if (logger) return logger;
logger = new winston.Logger({

const { combine, timestamp, printf, colorize, splat } = logform.format;

logger = new winston.createLogger({
transports: [
new winston.transports.File({
json: false,
filename: path.join(getAppDataDirectory(), "decrediton.log"),
timestamp: logTimestamp,
formatter: logFormatter
format: combine(
timestamp({ format: logTimestamp }),
splat(),
printf(logFormatter)
)
})
]
});

if (debug) {
logger.add(winston.transports.Console, {
timestamp: logTimestamp,
formatter: logFormatterColorized,
level: "debug"
});
logger.add(
new winston.transports.Console({
level: "debug",
format: combine(
timestamp({ format: logTimestamp }),
splat(),
printf(logFormatter),
colorize({ all: true })
)
})
);
}

return logger;
Expand Down
Loading