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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating imports without moving files #70

Open
sQVe opened this issue Feb 24, 2020 · 8 comments
Open

Updating imports without moving files #70

sQVe opened this issue Feb 24, 2020 · 8 comments
Labels
discussion enhancement New feature or request

Comments

@sQVe
Copy link
Collaborator

sQVe commented Feb 24, 2020

Hey 馃憢,

One issue we're having is that when you run destiny on the src folder we fix the imports but not on other folders that also import those files like a test folder. This issue is a bit tricky as one might argue that if we specify only the src folder it should only restructure and fix the src folder.

I do think that most people would assume that the imports in test was fixed too. If you run destiny on itself you have to, in many cases, manually go and repair the test imports.

@sQVe sQVe added discussion enhancement New feature or request labels Feb 24, 2020
@AnatoleLucet
Copy link
Collaborator

AnatoleLucet commented Feb 24, 2020

Do you have an idea of how we could check who's importing a specific file from src without checking every files/folders in src's parent? That would really be time-consuming.

@benawad
Copy link
Owner

benawad commented Feb 24, 2020

I think we need 2 inputs from the user

  1. The files to restructure ["src/utils", "src/pages", etc...]
  2. The files to fix imports for ["src", "tests"]

Sometimes these values are the same, sometimes they are different

@jesperordrup
Copy link

@benawad

That looks like solving the issue. Input either as a config file or parameters.

@waynevanson
Copy link
Contributor

waynevanson commented Mar 11, 2020

What if by default we check up to the root for a project, and run it for the top level package.json? This way it works with monorepos.

It's a pretty sane default IMO.

would work for these cases:

# single repo
/home/user/documents/
    project/
         src/
           # files...
         tests/
            # files.. 
         package.json
# monorepo
/home/user/documents/
    project-monorepo/
        packages/
            project-1/
                 src/
                   # files...
                 tests/
                    # files.. 
                 package.json
            project-2/
                 src/
                   # files...
                 tests/
                    # files.. 
                 package.json
    package.json

@sQVe
Copy link
Collaborator Author

sQVe commented Mar 12, 2020

What if by default we check up to the root for a project, and run it for the top level package.json? This way it works with monorepos.

I think we should only change files that the user allows us to change. If the user points at a path we should only take that path into consideration.

@jesperordrup
Copy link

I think that destiny should assume as much as possible and ask a few questions first time. Zeit now style

Assume that root is package.json is but ask for conf.
Assume that all can be moved but ask for conf or glob.
Save responses in config
Next time run without questions.

@waynevanson
Copy link
Contributor

Assume that root is package.json is but ask for conf.

I would like this to be like the example I've mentioned, so it works with workspaces (searching up the tree for package.json).

ask a few questions first time

And add a CLI flag, maybe -i for interactive, to ask questions if it isn't the first time.

Assume that all can be moved but ask for conf or glob.

If everything can be moved, I thought it might be risky. But since the user will dry run first, it wouldn't be so risky

I think that the CLI could display the folder structure it changes and then list all paths changes that aren't in the root.

@AnatoleLucet AnatoleLucet changed the title Updating imports in test Updating imports without moving files Jul 2, 2020
@AnatoleLucet
Copy link
Collaborator

Just thought about a --static flag. E.g. destiny ./src --static ./tests...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants