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

Update generated date only when changed #768

Open
ShaneHudson opened this issue Jan 28, 2022 · 4 comments
Open

Update generated date only when changed #768

ShaneHudson opened this issue Jan 28, 2022 · 4 comments
Assignees

Comments

@ShaneHudson
Copy link

I'm not sure if this is a bad practice or not, but I run style-dictionary before each build. This ensures it's always updated when required and currently is quick enough to not notice the extra time. I check these in to git.

However the generated date changes even if the variables don't. I'm aware it can be disabled, but I wondered if there would be interest in the date being changed only if the variables are new/updated?

@chazzmoney
Copy link
Collaborator

I think this could be a useful configuration option for sure.

Would you be up for writing a PR supporting this behavior?

@chazzmoney
Copy link
Collaborator

chazzmoney commented Feb 15, 2022

@ShaneHudson looking forward to the PR - thanks for taking a look at it!

I think the 'hard' part of this will be trying to figure out how to do the data comparison between a previous run and a new one. You'll either have to create a data store (a temp file stored somewhere, maybe?) or parse the output of the prior run. While the latter makes more sense, it is also harder as it begs the question (e.g. if the format contains a generated value like a date, it is going to be different by default...). Maybe that means saving an intermediate dictionary state? Or something as simple as a hash of the original token files + config?

Unless @dbanksdesign has a good idea of another way around....

@melaniebmn
Copy link

Hey, any progress on this or plans to allow for this configuration soon?

@jorenbroekema
Copy link
Collaborator

I can't really see an easy way to run some kind of output file diff to check if only the header changes. Especially when users are running cleanAllPlatforms() before running buildAllPlatforms(), which is common. There wouldn't be a file to check against.

Alternatively, you can already configure the fileHeader without a changing date, which is what I use because I also run it in the CI on every Pull request:

{
  "source": ["**/*.tokens.json"],
  "fileHeader": {
    "autoGeneratedFileHeader": ["Do not edit directly, this file was auto-generated"],
  },
  "platforms": {
    "css": {
      "transformGroup": "css",
      "files": [{
        "destination": "vars.css",
        "format": "css/variables",
        "options": {
          "fileHeader": "autoGeneratedFileHeader"
        }
      }]
    }
  }
}

I think it's a good discussion to have whether the changing date fileheader should be the default one, or whether we should make the default fileHeader without it to accompany CI usage. I don't personally see much value in setting when the file was last changed, when that information is already available on Github / filesystem.

Let me know your thoughts on removing the date part in the fileHeader as a default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

4 participants