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

filenames that include existing directory name in the filename causes compilation error #132

Closed
1 of 5 tasks
hutchgrant opened this issue Jul 29, 2019 · 5 comments · Fixed by #264
Closed
1 of 5 tasks
Assignees
Labels
bug Something isn't working CLI P0 Critical issue that should get addressed ASAP v0.4.2
Milestone

Comments

@hutchgrant
Copy link
Member

hutchgrant commented Jul 29, 2019

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

If you name a file creating-pages.md in the pages directory, it will throw an error that the file wasn't found.

Details

I think this error is related to a regex when we're looking for files within the pages directory.

edit: Same bug also we cannot use the word templates (with an s) within a filename. It seems pages and templates are reserved words.

@thescientist13 thescientist13 added the bug Something isn't working label Jul 30, 2019
@thescientist13
Copy link
Member

thescientist13 commented Aug 4, 2019

I think we might need to add components and styles to the list too? Seeing errors like this trying to create a page called components-and-styles.md.

client:180 ./.greenwood/app/list.js
Module not found: Error: Can't resolve '/getting-start/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/styles/styles.js' in '/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/.greenwood/app'

Tried them individually as well and same issue. Suspiciously, the ed from started are missing, wonder if that's a clue?

Probably should try and look into this, as for code based documentation (like the website), this could a relatively major issue.

@thescientist13 thescientist13 added this to the MVP milestone Aug 4, 2019
@thescientist13
Copy link
Member

@hutchgrant
Can you take a few minutes and refresh on what the issue is, I forget if it is a simple or hard problem to solve?

@thescientist13
Copy link
Member

opened the PR to document this for now at least

@thescientist13 thescientist13 changed the title page filenames that include 'pages' causes error filenames that include directory names causes compilation error Nov 24, 2019
@thescientist13
Copy link
Member

Was working on #115 and was playing around with graphql and wanted to to create a pages.gql file which lead to me getting errors like

ERROR in ./www/components/header/header.js
Module not found: Error: Can't resolve '/queri/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/pages.gql' in '/Users/owenbuckley/Workspace/project-evergreen/repos/greenwood/www/components/header'
 @ ./www/components/header/header.js 5:0-49 14:17-27
 @ ./.greenwood/index/index.js
 @ ./.greenwood/app/app.js
 @ multi webpack-dev-server/client?http://localhost:1984 ./.greenwood/app/app.js

Eventually I remembered this issue so I figured I would take a look into it since I could see this getting more annoying as page creation becomes more dynamic (e.g. #21 ).

So spent a couple hours and I'm pretty sure the entire solution comes to a one character change as after a bunch of trial and error, it dawned on me what would be different between a file called pages, and a directory called pages. A /, as a file will have an extension, which means pages.xx won't match pages/. 🤞

// before
new RegExp(`${directory}`), (resource) => {

// after
new RegExp(`${directory}\/`), (resource) => {

Playing around with it looking good. Will try out a couple more tests and open a PR soon if all looks good.

@thescientist13 thescientist13 self-assigned this Nov 24, 2019
@thescientist13 thescientist13 changed the title filenames that include directory names causes compilation error filenames that include existing directory name in the filename causes compilation error Nov 24, 2019
@thescientist13
Copy link
Member

thescientist13 commented Nov 24, 2019

Also, I think I was able to narrow down the use case. Essentially the issue is that if you have

www/
  pages/
    about.md

And then create something like

www/
  pages/
    about.md
  queries/
    pages.js

This will end up having the resource request to queries/pages.js will match against the directory mapping for pages/, and NOT queries/ (as you would expect). In essence, filenames that include a directory name in them will not get mapped to the correct parent directory.

So it's not a set list per se, but rather whatever your folders structure is. Of course everyone will have a pages/ and templates/ directory so that will happen across the board.

@thescientist13 thescientist13 added the P0 Critical issue that should get addressed ASAP label Nov 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLI P0 Critical issue that should get addressed ASAP v0.4.2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants