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

cannot config setting.js #23

Closed
d0uub opened this issue May 3, 2020 · 3 comments
Closed

cannot config setting.js #23

d0uub opened this issue May 3, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@d0uub
Copy link

d0uub commented May 3, 2020

i want to load an external npm node and it already done in "add a remote node" but it cannot load require even i have following configuration at %USERPROFILE%\.Node-RED-Desktop\settings.js

module.exports = {
  functionGlobalContext: {
    require:require
  }
}

or can make it default or able to config at "Settings..."? thanks.

@sakazuki
Copy link
Owner

sakazuki commented May 3, 2020

Currently, User settings are merged in shallow with Node-RED-Desktop default settings.

  • Node-RED-Desktop default settings is defined in the code
    const config = {
    verbose: true,
    httpAdminRoot: this.adminPath,
    httpNodeRoot: this.uiPath,
    userDir: this.status.userDir,
    flowFile: this.status.currentFile,
    storageModule: CustomStorage,
    credentialSecret: this.status.credentialSecret,
    httpNodeCors: {
    origin: "*",
    methods: "GET,PUT,POST,DELETE"
    },
    httpNodeAUth: undefined,
    functionGlobalContext: {
    get NGROK_URL(): string { return _this.status.ngrokUrl }
    },
    editorTheme: {
    page: {
    title: app.name,
    favicon: path.join(__dirname, "..", "images", "favicon.ico"),
    scripts: path.join(__dirname, "..", "renderer/renderer.js"),
    css: path.join(__dirname, "..", "renderer/desktop.css")
    },
    header: {
    title: app.name
    },
    palette: {
    editable: true
    },
    menu: {
    "menu-item-help": {
    label: app.name,
    url: HELP_WEB_URL
    }
    },
    login: {
    image: path.join(__dirname, "images", "node-red-256.png")
    },
    projects: {
    enabled: this.status.projectsEnabled || false
    }
    },
    nodesExcludes: this.status.nodesExcludes || [],
    logging: {
    electron: {
    level: "debug",
    metrics: true,
    handler(){
    const electronLogLevel = function(noderedLevel: number): string {
    const levelMap: any = {
    10: "error",
    20: "error",
    30: "warn",
    40: "info",
    50: "debug",
    60: "verbose",
    98: "info",
    99: "info"
    };
    return levelMap[noderedLevel];
    };
    return function(msg: {level: number, msg?: {stack?: object}, type?: string}) {
    var m = electronLogLevel(msg.level);
    if(m && msg.msg) (log as any)[m](msg.msg);
    }
    }
    }
    }
    };
    if (this.status.projectsEnabled) delete config.storageModule;
    if (this.status.httpNodeAuth.user.length > 0 && this.status.httpNodeAuth.pass.length) {
    //@ts-ignore
    config.httpNodeAuth = {
    user: this.status.httpNodeAuth.user,
    pass: bcryptjs.hashSync(this.status.httpNodeAuth.pass, 8)
    }
    }
  • User's functionGlobalContext is overwritten with the default's one

I will plan to update the specification of user settings ( maybe I will use deep merge...) in next release.

@sakazuki sakazuki added the enhancement New feature or request label May 3, 2020
@d0uub
Copy link
Author

d0uub commented May 4, 2020

thank you!

sakazuki added a commit that referenced this issue Sep 24, 2020
@sakazuki
Copy link
Owner

done in v1.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants