pattern-lab / patternlab-node

The Node version of Pattern Lab
http://patternlab.io
MIT License
2.05k stars 405 forks source link

v5.14.1 throws errors if pattern Twig file isn't in a subfolder #1294

Closed coreylafferty closed 3 years ago

coreylafferty commented 3 years ago

I am using Pattern Lab Node v5.14.1 on Linux, with Node v12.19.0, using a edition-twig Edition with the starterkit-twig-demo starter kit.

Expected Behavior

Patterns can live in subfolders (e.g, _patterns/pages/article/article.twig) and root folders (e.g., _patterns/pages/article.twig) without errors.

Actual Behavior

If a Twig pattern file is in one of the root folders (e.g., most of the files in the templates and pages folders in the starterkit-twig-demo starterkit), errors like the following are shown during compile. These errors do not seem to negatively affect the output files.

There was an error setting pattern subgroup data after markdown parsing for source/_patterns/pages/_.md
Error: ENOTDIR: not a directory, open '/app/source/_patterns/pages/article.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/pages/_.md
Error: ENOTDIR: not a directory, open '/app/source/_patterns/pages/blog.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/pages/_.md
Error: ENOTDIR: not a directory, open '/app/source/_patterns/pages/homepage.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/templates/_.md
Error: ENOTDIR: not a directory, open '/app/source/_patterns/templates/article-2col.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/templates/_.md
Error: ENOTDIR: not a directory, open '/app/source/_patterns/templates/article.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/templates/_.md
Error: ENOTDIR: not a directory, open '/app/source/_patterns/templates/blog.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/templates/_.md
Error: ENOTDIR: not a directory, open '/app/source/_patterns/templates/homepage.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/pages/_.md
Error: ENOTDIR: not a directory, open '/app/source/_patterns/pages/homepage~emergency.json/_.md'
Steps to Reproduce

Install the latest version of PL (5.14.1) with the Twig engine and starterkit-twig-demo starterkit and compile the files using the normal commands (e.g., npm run build).

JosefBredereck commented 3 years ago

@coreylafferty, can you show me which dependencies you have in your package.json?

What I tried to reproduce.

npm create pattern-lab
// use PHP twig starter
npm run build

Did I do something wrong?

JosefBredereck commented 3 years ago

And can you provide a screenshot of the file structure of your pages folder?

coreylafferty commented 3 years ago

Yes, that's right. Just install and run it with the PHP/Twig options. Not changing any files.

$ npm create pattern-lab
// use PHP twig starter
$ npm run build

I had someone else run the same test under some different conditions to confirm it's not something about my system. Here's the details of their setup and the output they saw (their version of Node is a bit old, but I saw the same thing on a newer version).

Note that the build does seem to finish and things appear to work fine... the issue is just the error messages it throws during the build. It looks like non-nested Twig/MD files in the root folders (e.g. pages or templates) are triggering it to look for a non-existent MD files (like /patterns/pages/.md)


Using Pattern Lab Node v5.14.1 on MacOS 10.15.7 Catalina, with Node v10.23.1, using a edition-twig Edition with the starterkit-twig-demo starter kit.

Output with error messages:

λ $ npm create pattern-lab
? Please specify a directory for your Pattern Lab project. ./
? What templating language do you want to use with Pattern Lab? Twig (PHP)
? What initial patterns do you want included in your project? Twig (PHP) demo patterns (full demo website and patterns)
✔ ⊙ patternlab → Installed edition: @pattern-lab/edition-twig
✔ ⊙ patternlab → Installed starterkit: @pattern-lab/starterkit-twig-demo
✔ ⊙ patternlab → Yay ☺. Pattern Lab Node was successfully initialized in ./
λ $ npm run build
> patternlab build --config ./patternlab-config.json
Pattern Lab Node v5.14.1
Pattern Engine mustache: good to go
Pattern Engine twig-php: good to go
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/pages/_.md
Error: ENOTDIR: not a directory, open '/Users/rjensen/Sites/test/source/_patterns/pages/article.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/pages/_.md
Error: ENOTDIR: not a directory, open '/Users/rjensen/Sites/test/source/_patterns/pages/blog.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/pages/_.md
Error: ENOTDIR: not a directory, open '/Users/rjensen/Sites/test/source/_patterns/pages/homepage.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/templates/_.md
Error: ENOTDIR: not a directory, open '/Users/rjensen/Sites/test/source/_patterns/templates/article-2col.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/templates/_.md
Error: ENOTDIR: not a directory, open '/Users/rjensen/Sites/test/source/_patterns/templates/article.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/templates/_.md
Error: ENOTDIR: not a directory, open '/Users/rjensen/Sites/test/source/_patterns/templates/blog.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/templates/_.md
Error: ENOTDIR: not a directory, open '/Users/rjensen/Sites/test/source/_patterns/templates/homepage.twig/_.md'
There was an error setting pattern subgroup data after markdown parsing for source/_patterns/pages/_.md
Error: ENOTDIR: not a directory, open '/Users/rjensen/Sites/test/source/_patterns/pages/homepage~emergency.json/_.md'
Built pattern: organisms-footer
Built pattern: organisms-header
Built pattern: organisms-latest-posts
Built pattern: organisms-recent-tweets
Built pattern: organisms-related-posts
Built pattern: pages-article
Built pattern: pages-blog
Built pattern: pages-homepage
Built pattern: pages-homepage-emergency
Built pattern: templates-article
Built pattern: templates-article-2col
Built pattern: templates-blog
Built pattern: templates-homepage
Built pattern: templates-page-1col
Built pattern: templates-page-2col
Built pattern: templates-site
Built pattern: atoms-checkbox
Built pattern: atoms-html5-inputs
Built pattern: atoms-radio-buttons
Built pattern: atoms-select-menu
Built pattern: atoms-text-fields
Built pattern: atoms-animations
Built pattern: atoms-colors
Built pattern: atoms-fonts
Built pattern: atoms-visibility
Built pattern: atoms-avatar
Built pattern: atoms-favicon
Built pattern: atoms-icons
Built pattern: atoms-landscape-16x9
Built pattern: atoms-landscape-4x3
Built pattern: atoms-loading-icon
Built pattern: atoms-logo
Built pattern: atoms-square
Built pattern: atoms-definition
Built pattern: atoms-ordered
Built pattern: atoms-unordered
Built pattern: atoms-audio
Built pattern: atoms-video
Built pattern: atoms-table
Built pattern: atoms-blockquote
Built pattern: atoms-headings
Built pattern: atoms-hr
Built pattern: atoms-inline-elements
Built pattern: atoms-paragraph
Built pattern: atoms-preformatted-text
Built pattern: atoms-time
Built pattern: molecules-block-headline
Built pattern: molecules-block-headline-byline
Built pattern: molecules-block-hero
Built pattern: molecules-block-inset
Built pattern: molecules-block-thumb-headline
Built pattern: molecules-media-block
Built pattern: molecules-accordion
Built pattern: molecules-single-comment
Built pattern: molecules-social-share
Built pattern: molecules-comment-form
Built pattern: molecules-newsletter
Built pattern: molecules-search
Built pattern: molecules-four-up
Built pattern: molecules-one-up
Built pattern: molecules-three-up
Built pattern: molecules-two-up
Built pattern: molecules-figure-with-caption
Built pattern: molecules-alert
Built pattern: molecules-breadcrumbs
Built pattern: molecules-footer-nav
Built pattern: molecules-pagination
Built pattern: molecules-primary-nav
Built pattern: molecules-tabs
Built pattern: molecules-address
Built pattern: molecules-blockquote-with-citation
Built pattern: molecules-byline
Built pattern: molecules-heading-group
Built pattern: molecules-intro-text
Built pattern: atoms-buttons
Built pattern: organisms-article-body
Built pattern: organisms-comment-thread
Omitting atoms-audio from styleguide patterns because it is marked as hidden within it's documentation.
Omitting atoms-video from styleguide patterns because it is marked as hidden within it's documentation.
Built Pattern Lab front end
⊙ patternlab → build: Yay, your Pattern Lab project was successfully built ☺

package.json file:

{
  "name": "test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "patternlab build --config ./patternlab-config.json",
    "build:uikit": "cross-env-shell PL_CONFIG_PATH='${INIT_CWD}/.patternlabrc.js' npm run build --prefix node_modules/@pattern-lab/uikit-workshop -- --patternlabrc '$PL_CONFIG_PATH'",
    "dev": "node ./node_modules/@pattern-lab/uikit-workshop/build-tools.js",
    "help": "patternlab --help",
    "install": "patternlab install --config ./patternlab-config.json",
    "serve": "patternlab serve --config ./patternlab-config.json",
    "start": "npm run serve",
    "version": "patternlab --version"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@pattern-lab/cli": "^5.14.1",
    "@pattern-lab/core": "^5.14.1",
    "@pattern-lab/engine-twig-php": "^5.14.1",
    "@pattern-lab/starterkit-twig-demo": "^5.14.0",
    "@pattern-lab/uikit-workshop": "^5.14.1"
  }
}

Pages folder structure: pl-errors

StfBauer commented 3 years ago

Get the same issue from time to time in Handlebars too.