DevriX / DX-Starter-Deprecated

Modified underscores starter theme by DevriX
10 stars 6 forks source link

Feature/add dx assets version #17

Closed metodiew closed 6 years ago

xavortm commented 6 years ago

100% ready to merge. But I have one question - can't we do this:

Have a simple php file containing a variable with the version we want to append. Then we include this file to the functions.php file and print the version from there.

The reason - we can have a simple command like $ npm run assets-version which will update the version number (actual version number and date after it) like this: v-54-20180101 and then we do the same as in your file.

Reason for the suggestion:

  1. The command can be executed automatically before commit if needed per project
  2. It will save time from opening once again the functions.php file, finding the variable place and changing the string inside.

What do you think?

metodiew commented 6 years ago

To be completely honest, I wouldn't use the npm command or at least not that often. I can see how you will use it quite often, so I don't mid do have a new file where we can use both approaches. I'll be happy to help and implement it :)

Keep in mind - this should be a define variable, just because it's easier to use it in a few different places - in the theme and some of the plugins.

I can see one potential problem or at least something we should think of - when you run npm run assets-version, which time will get - the system time or? And if that's the case, what we should do with commits from people from a different time zone?

I don't think that's a blocker, as we'll end up with serving a different version of the assets, but I wanted to mention it :)

xavortm commented 6 years ago

Just pushed the code. The script runs with npm run ver. it will add a version number (or the number of times this has been run) as well as current day. If more than once per day this is run, you will just get a bigger number on the front.

Let me know what you think about this :) The other good part is that even if you edit this manually in the file, it won't break the script as long as the format is followed ^^

100% there's a better way to do it but It was fun to play with it anwyays

xavortm commented 6 years ago

There it is. Docs in the files are added. Use by typing npm run ver in the terminal, nothing more. This could be added as a github hook later on, but we can open a new issue for it. Merging the pull request :)