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

Add type override rules #635

Closed
wants to merge 5 commits into from

Conversation

Corecii
Copy link
Member

@Corecii Corecii commented Sep 7, 2022

This is an initial implementation of the settings described in this issue: #634 (comment)

It adds a setting to .project.json files to override types of files according to globs, like so:

{
  "name": "example",
  "typeOverrideRules": [
    {
      "pattern": "wally.lock",
      "use": "rojo/plaintext"
    },
    {
      "pattern": "**/*.md",
      "use": "rojo/plaintext"
    },
    {
      "pattern": "**/*.spec.lua",
      "use": "rojo/ignore"
    },
  ],
  "tree": {
    "$path": "src"
  }
}

The following types are implemented:

"rojo/plaintext"
"rojo/luau"
"rojo/luauserver"
"rojo/luauclient"
"rojo/json"
"rojo/csv"
"rojo/project"
"rojo/rbxm"
"rojo/rbxmx"
"rojo/jsonmodel"
"rojo/ignore"

...and anything else is captured as an Other(_) value, which currently bails if encountered since plugins aren't supported yet.


I'm not really sure if this is the way you'd want this implemented, but I took a crack at it because:

  1. I'm interested in this feature!
  2. Even if this implementation isn't used, the familiarity it builds for me with the Rojo codebase is valuable!
  3. Maybe this implementation can be a starting point and improved upon? No worries if not.

@Corecii
Copy link
Member Author

Corecii commented Sep 22, 2022

Some thoughts:

  • do we want to call these "transformers"? I noticed that's the terminology you used, and I think it makes sense!
  • is transformerRules a reasonable name for this project property?
  • are we happy with refactoring snapshotting to be based on a Transformer type instead of deciding how to snapshot from the filename?
  • are we happy with server, client, and module scripts being different types? These sync in as different objects so it makes sense. There are potential cases where you may need to specify something to sync in as a server script that isn't suffixed with .server.lua (or even .lua for that matter).

@Corecii Corecii marked this pull request as ready for review September 22, 2022 20:31
@boatbomber boatbomber added type: enhancement Feature or improvement that should potentially happen scope: cli Relevant to the Rojo CLI size: medium status: needs review This work is mostly done, but just needs work to integrate and merge it. labels Jan 5, 2023
@Dekkonot
Copy link
Member

Dekkonot commented Jul 5, 2023

Sorry about the 10 month delay on someone getting back to you on this!

I'm not sure on the term 'transformer' being used in project files because I associate it with modifying the file itself somehow. Since this is just using existing Rojo transformers, I think it's more fair to say we're just adding or changing file type associations. I'm not sure what a better name is though, since fileAssociations is probably a bad one.

I'm perfectly fine with changing snapshots to use transformer associations rather than the filename. Our current method is fine but I don't feel attached to it in lieu of this solution.

@Dekkonot
Copy link
Member

As per our own discussions, I'm going to implement this myself.

@Dekkonot Dekkonot closed this Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: cli Relevant to the Rojo CLI size: medium status: needs review This work is mostly done, but just needs work to integrate and merge it. type: enhancement Feature or improvement that should potentially happen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants