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

feat: file path as cti path (example mechanism for discussion) #253

Closed
wants to merge 1 commit into from

Conversation

chazzmoney
Copy link
Collaborator

#104, part of #251

Added in options in config to use file path as CTI prefix.

This is meant to start discussion of value here.

The options to use in the config are 'sourceFilePathAsCTI' and 'includeFilePathAsCTI'.

Note that I did not attempt to solve the problem if you are using the current system, which would result in a duplication of information in the CTI as per @elliotdickison's comments. (e.g. A file in the path properties/fonts/size.json containing { fonts: { size: { small: value: '10px'; } } } using this option would result in fonts.size.fonts.size.small).

If we like this, I can add tests and add in functionality to detect and remove duplication. Also, let me know if I should remove that top level folder if it is called "properties", or what we should do to handle that.....

@@ -48,6 +48,34 @@ function combineJSON(arr, deep, collision) {
throw e;
}

if(useFilePathAsCTI) {
let filePath = path.relative('./', files[i]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be too restricting to assume that the names should start from the current working directory. For example we would run the command from our package root, but our properties were in <root>/src/tokens/<properties>. In that case everything would be prefixed with "srcTokens". What if "rootPath" or something was a configuration option? That would also solve the issue you commented about on line 59 with assuming a "properties" folder name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽 Good call on all accounts

if(ctisetup.length > 1) {
ctisetup.pop();
}
ctisetup = ctisetup.join('.').split('/');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but I think .split(path.sep) is more cross-platform-proof.

@elliotdickison
Copy link

FWIW I don't think the duplication is a big deal. It doesn't feel like something that needs to be built in since the only purpose would be to help with migrating, right? If it's an issue maybe a migration script would be nice...

@jorenbroekema
Copy link
Collaborator

Since DTCG spec, token.type tends to be used to determine token type and users can use the token.filePath to create a name transform that takes that into account as well as the token hierarchy/path to determine the final token name. I think that makes this PR redundant and since it's 5 years old, I'll close for now

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

Successfully merging this pull request may close these issues.

4 participants