4 Replies Latest reply on Oct 15, 2016 2:08 AM by martinb77004568

    Central config file

    martinb77004568 Level 1

      Hi,

       

      I have created an application for PGB which I update pretty often. I have one code base and create a few different apps out of it. Some other people use this code base as well. So, every time I update the code base, I have to update every single app. The "problem" is: This is pretty much work. The code has one config.xml (obviously), one config file for JS, one for CSS, one index.html and a few other files that need to be customized for every build. I can copy the old graphics (since they don't change most of the time) but the rest has to be updated every time.

      I was wondering if it is possible to create/change JS and CSS files while compiling? My idea was to use one central config file (the config.xml for instance) where I can enter all settings. Then, while compiling, PGB also opens my other files and injects these settings into the other files at the place where they are needed.

      Because of this, I would only need to change one central configuration file and not 7 or more.

       

      A short example of what I tought would be a nice way to solve it:

       

      I have a config.css looking like this:

      .some-color {
      color: **var-color**;
      }
      

      And a config.js:

      var something = "**var-something**";
      

       

      Then, I would enter something like this into my config.xml (this is just pseudocode)

      <replace var="var-something" value="myvalue" />
      <replace var="var-color" value="#ffffff"; />
      

       

      And the resulting config.css and config.js would be (after compiling):

      .some-color {
      color: #ffffff;
      }
      

       

      var something = "myvalue";
      

       

      Is something similar to this possible at the moment? If not: Do you have a good idea on how to solve this? I had the idea to write a php script that takes some input values, goes through all files and replaces its content. But this approach would take a pretty long time to implement so maybe there is already something like this I can use?

      I hope it is clear what I want to achieve. Basically, I want to use one central config file to customize all of my other files. If this is not possible, maybe you have an idea how to automate it? It would be nice if we found a solution :-)

        • 1. Re: Central config file
          VectorP Level 4

          ...But this approach would take a pretty long time to implement

          Why would it take so long? Isn't such script exactly what you'd need, and couldn't it quickly be implemented with a series of regular expressions, combined with a loop through your files?

           

          What perhaps makes this complicated are 'situations', like:

          - one or more placeholders aren't substituted by a value.

          (what should happen if you forget to configure a value for  "**var-something**", for instance?)

          - you introduce a placeholder string which already exists elsewhere

          - how do you prevent two developers from using the script more or less simultaneously

          • 2. Re: Central config file
            martinb77004568 Level 1

            Thanks for your reply.

            It is harder to implement (with some sort of error detection) than if there was maybe already a similar function built in to PGB :-) I hoped there was some way to generate the config files while compiling. But it looks like there isn't. So I will probably just create the script like I said. Thanks for your "to do" list. I think this is a good start for me to think about. The part with simultaneous usage can be fixed by generating the resulting files "on the fly" (without saving them on the server). I will probably use a simple markup so that I only have to upload a configuration file which can be converted to variables and then to regular expressions. The error detection will be a bit harder but I think I can find a solution here as well :-)

            • 3. Re: Central config file
              ryanskihead Adobe Employee

              Yeah sorry nothing like this built-in to PGB, you'd likely have to implement some kind of build/deployment script on your own side. Always interesting to hear use cases though ... might even be third-party solutions to this out there that you could hook into build. Or you could make one and share it!

              • 4. Re: Central config file
                martinb77004568 Level 1

                I am currently trying to fix one potential problem - do you maybe have an idea how to solve it? Let's say I am working on version 1.1.0 of my app. In my php script, I accidentally generate older config files (for version 1.0.0). Now, when overriding the code base with these config files, this might lead to problems (e.g. an old config.xml could not include some plugins I need). So I thought about some sort of test whether the right config files were generated. I would add a file "1.1.0.xml" into my build path. Now comes the part where I need help: Is it possible to check while compiling if a file exists or not? I thought I could maybe make the build fail when using sth like

                <xi:include href="1.0.0.xml" xmlns:xi="http://www.w3.org/2003/XInclude" />
                

                in my config.xml.

                But that didn't work - the app is still being compiled even though the file 1.0.0.xml doesn't exist. Is it somehow possible to find out whether a file (xml or other) exists or not while building? I was hoping to get a "malformed xml" when the file 1.0.0.xml doesn't exist but it seems like PGB simply ignores the line with xi:include.