Spacevim: javascript layer monorepo

Created on 2 Sep 2019  路  30Comments  路  Source: SpaceVim/SpaceVim

Is your feature request related to a problem? Please describe.
When using the javascript layer, with a monorepo project, when entering another package, denite/crtl+p search start ignoring .gitignore and start suggesting files that previously were ignored.

Describe the solution you'd like
Or a way to override this behaviour? If yes would be cool to be added to the docs.

Describe alternatives you've considered
Tried to look at the docs, didn't found any details about this behaviour. If I disable this layer, the search works as expected.

Additional context
Let me know if more details is needed for it

discussion feature request

Most helpful comment

It is issue with SpaceVim itself, if you check the value of project_rooter_patterns, you will see '.SpaceVim.d/' in it, which also located in ~/.SpaceVim.d/. that means if the file is under ~ directory, your root will alway be ~.

All 30 comments

denite/crtl+p search start ignoring .gitignore and start suggesting files that previously were ignored.

I can not understand this, by default denite use ag or rg command, and this command ignore files in .gitignore by default.

@Fetz any update on this issue? I need a clear step to step reproduce info.

@wsdjeg sorry the delay coming back to you

For the steps to reproduce the issue do you have any preference?

  • screen recording of the issue?
  • or a open source repo of a monorepo where anyone can replicate the issue?
  • or purely the steps?

I think it is better there is a example repo and reproduce screen short, I need to reproduce it before fix it.

Created this fast boilerplate repo of a simple monorepo https://github.com/Fetz/js-monorepo-spacevim-playground and manage to replicated the issue.

with js layer and denite in init.toml:

[[layers]]
name = "denite"

[[layers]]
name = "lang#javascript"

on the root of the project using ^ + p:
Screen Shot 2019-10-21 at 14 56 32

and if you go to one of the init.js files of any packages (for example packages/package1/init.js if you do again the ^ + p:

Screen Shot 2019-10-21 at 14 59 12

so looks like the root of the project is this package not the git root, the problem is that all the gitignore files as well (like node_modules etc) they are going to start being showing

Got it, I think it is because the path of current dir has be change automatically when you open init.js. spacevim will change the working dir to project root based on聽project_rooter_patterns option. 聽I just check the javascript layer, and I found:

call add(g:spacevim_project_rooter_patterns, 'package.json')

I am not sure if this line should be removed.

or the logic of root detection should be changed.

In a js project without using source control (eg. git), identifying the package.json in most of projects (in my experience) the root will be where package.json is located, but in projects where:

  • monorepo with lerna, yarn workspaces, nx, etc
  • for projects that may not be in js but they provide some utilities package or use some nodejs tools
  • on projects where the package is not at the root (for example a .git/ folder in a sourced control project it would be a better choice)

For me, to be consistent with the docs:

SpaceVim will find the root of the project when a .git directory or a .project_alt.json file is encountered in the file tree.

I would or make that line optional and not default and added to the layer documentation configuration or if is not expensive to use the 'package.json' when finding the root fails for both .git directory or a .project_alt.json.

I do not write js too much, we need some help from the layer code owner.

cc @zhujinxuan @S1ngS1ng

I almost agree. Just a small problem, we do not use .project_alt.json in js world.

Would package.lock and yarn.lock a better alternative when .git fails? cc @S1ngS1ng

.project_alt.json is a file used in SpaceVim plugin, it can be used all project. 聽

@wsdjeg That makes sense. Shall the priority be:

.git > .project_alt.json > package.json

or

.project_alt.json > .git > package.json

?

if the algorithm that looks for the root looks for any of those files we will still have the problem, if we want to check by priority in the case of the package.json, that check of the root need to be run, only if the other file checks fails (if it gets to the root).

Another way to make it work with package.json is to check the package.json closest to the root

@zhujinxuan

Would package.lock and yarn.lock a better alternative when .git fails?

IMHO, probably not. Here are my two cents:

  1. For npm install, a user always has the right to prevent npm from generating package-lock.json by adding --no-package-lock flag.
  2. According to the doc of yarn install, a user always has the right to prevent yarn from generating yarn.lock by adding --pure-lockfile or --no-lockfile flag.
  3. AFAIC, when performing install on a project w/o either lock file, npm/yarn simply "re-calculate" its dependencies' versions and install them based on its "calculation". I don't consider this to be the recommended way of using npm/yarn, but it should (presumably) work.
  4. According to the doc of npm install, it is npm-shrinkwrap.json that takes precedence over package-lock.json (note: this statement might be off-topic, but it is something I just learned a few minutes ago 馃う鈥嶁檪 #TIL)

=> That being said, it is (literally & technically) possible for a project to be w/o either lock file. But package.json should be mandatory, which optimistically covers both npm and yarn. Hence, I'd suggest using package.json instead of any lock file.

Regarding .git, I believe that git-submodule would introduce nested .git. But normally, a user should just have a single .project_alt.json within a project (please correct me if I am wrong).
Hence, I'd vote for .project_alt.json > .git > package.json.

Some other quick (random) thoughts here:

  1. I am not sure if it is common to have nested package.json in a project. Maybe that could happen within a mono-repo? Any thoughts, please? @Fetz @zhujinxuan
  2. We may handle the case of package.json. But should we take the old-school bower.json into consideration as well?
  1. I am not sure if it is common to have nested package.json in a project. Maybe that could happen within a mono-repo? Any thoughts, please?

@S1ngS1ng yes is common, for example:

And currently the 3 main technologies for monorepos that I know are:

  1. lerna - that uses by itself lerna.json by itself or with yarn workspaces
  2. yarn workspaces that uses the package.json
  3. nx this one I don't know much about it

Hi, I can make a PR at the beginning of Dec if you would like to. Sorry I do not have time this month.

Anything I can do "fix" this in a proper way?

Thanks for all the info about this issue, I will fix it now.

@Fetz in the latest version of SpaceVim, when load javascript, the package.json will be added to the project_rooter_patterns, so maybe this has been fixed. do you have any reproduce step?

I can not reproduce it.

noreproduce

Let me see if I can still reproduce

I managed to reproduce it, here is the record: https://asciinema.org/a/8asa3usEBqvO7CT9rusIueVQN

It is very strange, I can not reproduce it in my os, can you check the result of :echo聽g:spacevim_project_rooter_patterns

wsdjeg

I managed to reproduce it, here is the record: https://asciinema.org/a/8asa3usEBqvO7CT9rusIueVQN

--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/SpaceVim/SpaceVim/issues/3031#issuecomment-579846267

['.git/'. '_darcs/', '.hg/', '.bzr/', '.svn/', 'package.json', '.SpaceVim.d/']

Here is my runtime log, can you post the log? key binding is SPC h L

[ SpaceVim ] [18:03:01] [ Info ] Start to find root for: e:js-monorepo-spacevim-playground\README.md
[ SpaceVim ] [18:03:01] [ Info ] 聽 聽 聽 聽 (.git/):e:js-monorepo-spacevim-playground.git/
[ SpaceVim ] [18:03:01] [ Info ] 聽 聽 聽 聽 (package.json):e:js-monorepo-spacevim-playgroundpackage.json
[ SpaceVim ] [18:03:01] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:04] [ Info ] Start to find root for: e:js-monorepo-spacevim-playground[denite]-default
[ SpaceVim ] [18:03:04] [ Info ] 聽 聽 聽 聽 (.git/):e:js-monorepo-spacevim-playground.git\
[ SpaceVim ] [18:03:04] [ Info ] 聽 聽 聽 聽 (package.json):e:js-monorepo-spacevim-playgroundpackage.json
[ SpaceVim ] [18:03:04] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:05] [ Info ] Start to find root for: e:js-monorepo-spacevim-playground\denite-filter
[ SpaceVim ] [18:03:05] [ Info ] 聽 聽 聽 聽 (.git/):e:js-monorepo-spacevim-playground.git\
[ SpaceVim ] [18:03:05] [ Info ] 聽 聽 聽 聽 (package.json):e:js-monorepo-spacevim-playgroundpackage.json
[ SpaceVim ] [18:03:05] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:06] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:06] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:07] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:07] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:07] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:07] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:07] [ Info ] Start to find root for: e:js-monorepo-spacevim-playground\packages\package2init.js
[ SpaceVim ] [18:03:07] [ Info ] 聽 聽 聽 聽 (.git/):e:js-monorepo-spacevim-playground.git\
[ SpaceVim ] [18:03:07] [ Info ] 聽 聽 聽 聽 (package.json):e:js-monorepo-spacevim-playground\packages\package2package.json
[ SpaceVim ] [18:03:07] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:09] [ Info ] Start to find root for: e:js-monorepo-spacevim-playground[denite]-default
[ SpaceVim ] [18:03:09] [ Info ] 聽 聽 聽 聽 (.git/):e:js-monorepo-spacevim-playground.git\
[ SpaceVim ] [18:03:09] [ Info ] 聽 聽 聽 聽 (package.json):e:js-monorepo-spacevim-playgroundpackage.json
[ SpaceVim ] [18:03:09] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:09] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:11] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:11] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:11] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:11] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:11] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:11] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:12] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:12] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:12] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:12] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:12] [ Info ] Start to find root for: e:js-monorepo-spacevim-playgroundpackage.json
[ SpaceVim ] [18:03:12] [ Info ] 聽 聽 聽 聽 (.git/):e:js-monorepo-spacevim-playground.git\
[ SpaceVim ] [18:03:12] [ Info ] 聽 聽 聽 聽 (package.json):e:js-monorepo-spacevim-playgroundpackage.json
[ SpaceVim ] [18:03:12] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:13] [ Info ] Start to find root for: e:js-monorepo-spacevim-playground[denite]-default
[ SpaceVim ] [18:03:13] [ Info ] 聽 聽 聽 聽 (.git/):e:js-monorepo-spacevim-playground.git\
[ SpaceVim ] [18:03:13] [ Info ] 聽 聽 聽 聽 (package.json):e:js-monorepo-spacevim-playgroundpackage.json
[ SpaceVim ] [18:03:13] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:13] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:14] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:14] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:14] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:14] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:14] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:14] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:15] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:15] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:15] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:15] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:15] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:15] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:16] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:16] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:17] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:17] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:18] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:18] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:18] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:18] [ Info ] change to root:e:js-monorepo-spacevim-playground
[ SpaceVim ] [18:03:18] [ Info ] Start to find root for: e:js-monorepo-spacevim-playground\packages\package3init.js
[ SpaceVim ] [18:03:18] [ Info ] 聽 聽 聽 聽 (.git/):e:js-monorepo-spacevim-playground.git\
[ SpaceVim ] [18:03:18] [ Info ] 聽 聽 聽 聽 (package.json):e:js-monorepo-spacevim-playground\packages\package3package.json
[ SpaceVim ] [18:03:18] [ Info ] change to root:e:js-monorepo-spacevim-playground


wsdjeg

['.git/'. '_darcs/', '.hg/', '.bzr/', '.svn/', 'package.json', '.SpaceVim.d/']

--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/SpaceVim/SpaceVim/issues/3031#issuecomment-580168792

SpaceVim runtime log

[ SpaceVim ] : logger file  does not exists, only log for current process will be shown!
[ SpaceVim ] [12:02:58] [ Info ] Startup with no argv, current dir is used: ~/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:02:58] [ Info ] Can not find project local config, start to loadding global config
[ SpaceVim ] [12:02:58] [ Info ] start to apply config [glob]
[ SpaceVim ] [12:02:58] [ Info ] Start to find root for: 
[ SpaceVim ] [12:02:58] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:02:58] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/package.json
[ SpaceVim ] [12:02:58] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:02:58] [ Info ] try to open SpaceVim welcome page
[ SpaceVim ] [12:02:58] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:01] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/[denite]-default
[ SpaceVim ] [12:03:01] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:01] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/package.json
[ SpaceVim ] [12:03:01] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:01] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/denite-filter
[ SpaceVim ] [12:03:01] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:01] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/package.json
[ SpaceVim ] [12:03:01] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:02] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:02] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:02] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:02] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:02] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/LICENSE
[ SpaceVim ] [12:03:02] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:02] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/package.json
[ SpaceVim ] [12:03:02] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:03] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/[denite]-default
[ SpaceVim ] [12:03:03] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:03] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/package.json
[ SpaceVim ] [12:03:03] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:03] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:04] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:04] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:04] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:04] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:04] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:04] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:05] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:05] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:05] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:05] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:05] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:05] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:05] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:05] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:05] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:05] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:05] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/package.json
[ SpaceVim ] [12:03:05] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:05] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/package.json
[ SpaceVim ] [12:03:05] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:07] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/[denite]-default
[ SpaceVim ] [12:03:07] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:07] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/package.json
[ SpaceVim ] [12:03:07] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:07] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:08] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:08] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:08] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:08] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:08] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:08] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:09] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/README.md
[ SpaceVim ] [12:03:09] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:09] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/package.json
[ SpaceVim ] [12:03:09] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:10] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/[denite]-default
[ SpaceVim ] [12:03:10] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:10] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/package.json
[ SpaceVim ] [12:03:10] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:10] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:11] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:11] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:11] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:11] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:12] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:12] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:12] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:12] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:12] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:12] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:12] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:12] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground
[ SpaceVim ] [12:03:13] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2/init.js
[ SpaceVim ] [12:03:13] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:13] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2/package.json
[ SpaceVim ] [12:03:13] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2
[ SpaceVim ] [12:03:14] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2/[denite]-default
[ SpaceVim ] [12:03:14] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:14] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2/package.json
[ SpaceVim ] [12:03:14] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2
[ SpaceVim ] [12:03:14] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2/denite-filter
[ SpaceVim ] [12:03:14] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:14] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2/package.json
[ SpaceVim ] [12:03:14] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2
[ SpaceVim ] [12:03:14] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2
[ SpaceVim ] [12:03:14] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2
[ SpaceVim ] [12:03:15] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2
[ SpaceVim ] [12:03:15] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2
[ SpaceVim ] [12:03:15] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2
[ SpaceVim ] [12:03:15] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2
[ SpaceVim ] [12:03:15] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2/package.json
[ SpaceVim ] [12:03:15] [ Info ]         (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:15] [ Info ]         (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2/package.json
[ SpaceVim ] [12:03:15] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2

It seems a bug of the project manager.聽

[ SpaceVim ] [12:03:15] [ Info ] Start to find root for: /Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2/package.json
[ SpaceVim ] [12:03:15] [ Info ] 聽 聽 聽 聽 (.git/):/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/
[ SpaceVim ] [12:03:15] [ Info ] 聽 聽 聽 聽 (package.json):/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2/package.json
[ SpaceVim ] [12:03:15] [ Info ] change to root:/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2

it finds two root path,聽/Users/luissilva/Personal/js-monorepo-spacevim-playground/.git/ and聽/Users/luissilva/Personal/js-monorepo-spacevim-playground/packages/package2/package.json, but it choose the second one instead of first one. I will try to fix it.

@Fetz I have fixed it in #3316

But this implemention will bring a bug. this plugin will find all the roots based on the project_rooter_patterns option. all the roots will be added into a list, then sort the list, use the first iterm in the list as the root of the project:

the compare function is:

function! s:compare(d1, d2) abort
  return len(split(a:d2, '/')) - len(split(a:d1, '/'))
endfunction

this will use the nerstest dir as the root of the project. in #3316 , we just change it to:

function! s:compare(d1, d2) abort
  return len(split(a:d1, '/')) - len(split(a:d2, '/'))
endfunction

which means it will use outermost directory as the root.

But this implementation will bring a bug.

Maybe I'm missing something, besides maybe not being the most efficient algorithm, in what scenarios the outermost directory shouldn't be the root for those patterns?

The only thing that comes across my mind, in the context of a complex monorepo, is that you may want to search only on a inner "root" to reduce the noise, but for that case maybe we may need to improve project manager so that you can change dynamically when need it the root.

But then we will need different types of roots since for searching we would like to use (when available) the .gitignore file

It is issue with SpaceVim itself, if you check the value of project_rooter_patterns, you will see '.SpaceVim.d/' in it, which also located in ~/.SpaceVim.d/. that means if the file is under ~ directory, your root will alway be ~.

@Fetz In #3316 we change the project rooter detection from nerstest dir to outermost directory, this make some users confuse. so I just open another PR (#3609), In this PR, we will add following feature:

  1. add option for using nerstest dir or outermost dir
  2. add ignore patterns
[options]
    project_rooter_patterns = ['.git/', '_darcs/', '.hg/', '.bzr/', '.svn/', '!packages/']
Was this page helpful?
0 / 5 - 0 ratings

Related issues

wsdjeg picture wsdjeg  路  3Comments

linwaytin picture linwaytin  路  4Comments

gennad picture gennad  路  4Comments

well1791 picture well1791  路  4Comments

rivalak picture rivalak  路  3Comments