Stillat / vscode-antlers-language-server

Provides rich language features for Statamic's Antlers templating language, including code completions, syntax highlighting, and more.
https://antlers.dev
MIT License
38 stars 3 forks source link

Getting error with Antlers format CLI and Prettier with prettier-plugin-antlers #40

Closed jimblue closed 2 years ago

jimblue commented 2 years ago

Describe the bug

Hello,

I'm trying to use Antlers formater programmatically for pre-commit hook but I'm getting errors.

I've tried with Formatting CLI from Antlers Toolbox with the following command :

npx antlersformat format --d='resources/views/about/index.antlers.html' 

I've also tried with globbaly installed antlersformat

antlersformat format --d='resources/views/about/index.antlers.html' 

Both returns the following error (it's no the full log, only the error):

Error: Connection input stream is not set. Use arguments of createConnection or set command line parameters: '--node-ipc', '--stdio' or '--socket={number}'
    at rO (/Users/jimblue/Development/websites/testing-project/node_modules/antlers-formatter/cli.js:34:62106)
    at nO (/Users/jimblue/Development/websites/testing-project/node_modules/antlers-formatter/cli.js:34:61334)
    at Object.<anonymous> (/Users/jimblue/Development/websites/testing-project/node_modules/antlers-formatter/cli.js:514:35842)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

Whereas when formating with VsCode command it's working perfectly...

So I've was thinking, maybe it's only the CLI, I can still try to run it with Prettier like so:

npx prettier --write resources/views/about/index.antlers.html

To be sure, I've even tried by to force Prettier to discover prettier-plugin-antlers:

npx prettier --plugin=prettier-plugin-antlers --write resources/views/about/index.antlers.html

But I always get the same error:

Command 'Format Document With...' resulted in an error (Class extends value undefined is not a constructor or null)

At this point Prettier is not working on any file type... But as soon as I uninstall prettier-plugin-antlers everything go back to normal.

Impacted Products Which Antlers Toolbox products does this bug apply to?

Versions and Other Plugins/Extensions

- antlers-formatter -> **1.1.5**
- prettier-plugin-antlers -> **1.1.12**

The template resources/views/about/index.antlers.html

<section class="hero _three-quarter _black">
  <div class="hero-body">
    <div class="container text-centered">
      <h2 class="title">
        {{ title }}
      </h2>
      <h3 class="subtitle">
        {{ subtitle }}
      </h3>
    </div>
  </div>
  <div class="hero-carousel">
    <div class="carousel-navigation">
      <div class="carousel-nav-left">
        {{ partial:common/components/icon name="left" }}
      </div>
      <div class="carousel-nav-right">
        {{ partial:common/components/icon name="right" }}
      </div>
    </div>
    <div class="carousel-container">
      {{ glide:carousel preset='large' }}
        <div class="carousel-slide" data-slide="{{ url }}" style="background-position: {{ focus_css }};"></div>
      {{ /glide:carousel }}
    </div>
  </div>
</section>
<section class="section">
  <div class="container">
    <div class="content">
      {{ content }}
    </div>
  </div>
</section>
{{ section:page_scripts }}
  {{ webpack:script name="about.js" loading="defer" preload="true" }}
{{ /section:page_scripts }}
JohnathonKoster commented 2 years ago

@jimblue

Thanks for the report! I've traced this back to a stuck build that got published (investigating that). This should be resolved with the following builds:

Will leave this open until I hear back :)

jimblue commented 2 years ago

I confirm, both Antlers CLI and Prettier work with those versions 🎉