MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    MagicMirror² v2.20.0 is available! For more information about this release, check out this topic.

    SOLVED Storing variables to be ignored by git in a js file?

    Troubleshooting
    4
    14
    217
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CFenner
      CFenner @TimOgden last edited by

      @timogden I’ve created a module to extract the config so you don’t need to maintain your own whole MM fork: https://forum.magicmirror.builders/topic/16224/mmm-personalconfig-persist-personal-config-to-github/1

      A way to achieve what you want could be to create your own copy of personal config with your mirror config. Then make a clone of if for your friend where you do the specific changes. Changes to your repo then can be pulled to the other one via Pull requests.
      In combination with MMM-UpdateNotification with can pull updates automatically, your friend won’t need to do anything.

      1 Reply Last reply Reply Quote 0
      • T
        TimOgden @sdetweil last edited by

        @sdetweil Ok, implementing @sdetweil 's suggestions, I have created a working version. This is my workflow.

        // config/dictionary.txt
        // This is a list of key-value or string-replacement pairs
        "{latitude}"    :    "40"
        "{longitude}"    :    "-70"
        
        // installers/copy-values.sh
        // sed command found here: 
        // https://unix.stackexchange.com/questions/269368/string-replacement-using-a-dictionary
        cd ~/MagicMirror
        cp config/config.model.js config/config.js
        sed '
        s|"\(.*\)"[[:blank:]]*:[[:blank:]]*"\(.*\)"|\1\
        \2|
        h
        s|.*\n||
        s|[\&/]|\\&|g
        x
        s|\n.*||
        s|[[\.*^$/]|\\&|g
        G
        s|\(.*\)\n\(.*\)|s/\1/\2/g|
        ' config/dictionary.txt | sed -i -f - config/config.js
        
        DISPLAY=:0 npm start
        

        Now I can have separate dictionary.txt files on both machines for any local important information, which I will add to .gitignore. I will continue to modify config.model.js, and config.model.js will be copied and cleaned up with all the right values before every start of the mirror.

        T 1 Reply Last reply Reply Quote 1
        • T
          TimOgden @TimOgden last edited by

          @timogden Also, I should add that there is nothing fancy about the strings on the left-hand side of my dictionary.txt. That’s just how I decided to distinigush them. This is how I would write my config.model.js file now:

          // config/config.model.js
          ...
          config: {
              lat: {latitude},
              lon: {longitude},
              apiKey: {API_KEY},
          }
          ...
          
          S 1 Reply Last reply Reply Quote 0
          • S
            sdetweil @TimOgden last edited by

            @timogden cool… I would just use them where u need them in any module in the template.

            and then replace all…

            also I would use the quoted on the left (and in the config.js template)
            and the replace with or without as appropriate (so u can replace numbers without and text with quotes)

            using the quotes means u can run npm run config:check and not get errors

            Sam

            Create a working config
            How to add modules

            1 Reply Last reply Reply Quote 1
            • 1
            • 2
            • 2 / 2
            • First post
              Last post
            Enjoying MagicMirror? Please consider a donation!
            MagicMirror created by Michael Teeuw.
            Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
            This forum is using NodeBB as its core | Contributors
            Contact | Privacy Policy