<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Marcelo Vani on Medium]]></title>
        <description><![CDATA[Stories by Marcelo Vani on Medium]]></description>
        <link>https://medium.com/@marcelovani?source=rss-770d5b03ad6f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WW5Y0KlbpP5TlWig_f8eZQ.jpeg</url>
            <title>Stories by Marcelo Vani on Medium</title>
            <link>https://medium.com/@marcelovani?source=rss-770d5b03ad6f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:00:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@marcelovani/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[CodeGraph Now Supports Drupal]]></title>
            <link>https://medium.com/@marcelovani/codegraph-now-supports-drupal-62581d564486?source=rss-770d5b03ad6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/62581d564486</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[developer-tools]]></category>
            <dc:creator><![CDATA[Marcelo Vani]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 13:20:52 GMT</pubDate>
            <atom:updated>2026-11-26T13:20:52.075Z</atom:updated>
            <content:encoded><![CDATA[<p>Claude, Codex and other AI coding tools can finally follow your site’s routes, hooks, services and plugins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*utlPfjwWuBLNj7BRuVxSAw.png" /></figure><p><a href="https://github.com/colbymchenry/codegraph">CodeGraph</a> is a free, open source tool for AI coding assistants like Claude Code and Codex. It reads your codebase and builds a map of it: every class, function and method, and how they call and depend on each other. The map lives on your machine and keeps itself up to date as you work. When your assistant needs to know what calls a method, or what a change would break, it asks the map instead of searching and opening file after file.</p><p>That saves a lot. On the project’s own benchmark of seven open source codebases, answers took 88% fewer tool calls, 62% fewer tokens and cost 44% less, and the assistant stopped reading files just to find its way around. None of those codebases are Drupal, but Drupal is where an assistant does the most searching, so it’s where a map helps most.</p><h3>And now CodeGraph supports Drupal.</h3><p>The first time I ran CodeGraph on a Drupal project, it found the PHP classes and functions. It could see a controller method, but it couldn’t tell me which URL led to it. It already understood Laravel routes, so I opened an issue and built the first version for Drupal.</p><p>I opened an issue <a href="https://github.com/colbymchenry/codegraph/issues/268">https://github.com/colbymchenry/codegraph/issues/268</a></p><p>That first version taught it the Drupal basics. Routes in `*.routing.yml` point to their controllers and forms. Hooks are connected across modules. And `.module`, `.install` and `.theme` files are read as the PHP they are, so the code in them shows up too. The project has kept building on it since, and today CodeGraph also understands services, plugins and the newer `#[Hook]` methods.</p><h3>Why this matters if you use Claude or Codex</h3><p>AI assistants are good at reading code. Finding the right code to read is the hard part. They search, open a file, open another one, and every file costs tokens and time.</p><p>Drupal makes that harder than most frameworks, because a lot of its wiring is never written as a call. A hook runs because of its name. A plugin is found because of the folder it sits in. A service is fetched by a string id from a YAML file. Take a hook written the modern way:</p><pre>#[Hook(&#39;node_presave&#39;)]<br>public function setDefaultTitle(NodeInterface $node): void {<br>  if ($node-&gt;getTitle() === &#39;&#39;) {<br>    $node-&gt;setTitle(&#39;Untitled&#39;);<br>  }<br>}</pre><p>Nothing in the codebase calls that method. Drupal finds it through the attribute and runs it every time a node is saved. Ask an assistant what happens when a node is saved, and a search for callers comes back empty, so it guesses or keeps reading. CodeGraph links the method to the hook it implements, so the assistant can find it.</p><h3>What it understands in Drupal</h3><ul><li>Routes in `*.routing.yml`, linked to their controller, form or entity handler.</li><li>Hooks in `.module`, `.install`, `.theme` and `.inc` files, and `#[Hook]` methods, linked to the hook they implement when that hook’s definition is in the index.</li><li>Services in `*.services.yml`, linked to their class, arguments and decorators. Event subscribers come with them.</li><li>Calls like `\Drupal::service(‘x’)-&gt;method()` and `$container-&gt;get(‘x’)-&gt;method()`, linked to the method on that service’s class.</li><li>Plugins, from attributes or annotations, found by folder the same way Drupal finds them. That includes a contrib module’s own plugin types.</li></ul><h3>A real example</h3><p>I ran it on a Drupal 11 headless backend we work on. One of its computed fields gets its value from a service, fetched by id because Drupal doesn’t build field classes through the container.</p><p>Without the Drupal wiring, the graph said nobody calls that service’s method. An assistant tidying up the code would see a public method with no callers and might suggest removing it, and the field would break the next time the entity loaded. With the wiring, CodeGraph points straight to the computed field, so the assistant knows the method is used and where from.</p><p>That’s one call. Across the whole backend, 17 custom modules and about 1,600 files, this is what CodeGraph found:</p><ul><li>13 routes indexed</li><li>188 services linked to their class</li><li>76 plugins</li><li>134 calls through the service container linked to the method</li><li>730 Drupal-specific links in total</li></ul><p>Most of the plugins are REST resources (42) and validation constraints (25). On a headless site the REST resources are the API, so that’s where most requests land.</p><h3>What’s still missing</h3><p>There’s more to do, and each gap below has an open issue. If one of them matters on your project, add your case to it or pick it up:</p><ul><li>Twig templates are indexed as files, but nothing inside them is read yet. <a href="https://github.com/colbymchenry/codegraph/issues/3493">https://github.com/colbymchenry/codegraph/issues/3493</a></li><li>A call on an injected interface stops at the interface, instead of reaching the class that implements it. In Drupal code, that’s the biggest gap left. <a href="https://github.com/colbymchenry/codegraph/issues/3491">https://github.com/colbymchenry/codegraph/issues/3491</a></li><li>`getSubscribedEvents()` isn’t linked to the methods it lists. <a href="https://github.com/colbymchenry/codegraph/issues/3492">https://github.com/colbymchenry/codegraph/issues/3492</a></li><li>Hooks only link when the hook’s definition is in the index, which means Drupal core or a module’s `.api.php`. Our backend has 185 `#[Hook]` attributes, but core isn’t in the repo, so only the 37 implementations of hooks our own modules define were linked. <a href="https://github.com/colbymchenry/codegraph/issues/3490">https://github.com/colbymchenry/codegraph/issues/3490</a></li></ul><h3>Try it</h3><p>Run these commands in the terminal:</p><pre>npm i -g @colbymchenry/codegraph<br>codegraph install # finds Claude Code, Codex, Cursor and other tools and connects CodeGraph to them<br>codegraph init # run in your Drupal project root to build the graph</pre><p>Drupal is detected automatically. If you already have an index from an older version, CodeGraph tells you it’s out of date. Run `codegraph index` to rebuild it.</p><p>If you try it on your Drupal project and it misses a connection you expected it to find, open an issue on CodeGraph with a small example.</p><p>See <a href="https://github.com/colbymchenry/codegraph">https://github.com/colbymchenry/codegraph</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62581d564486" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Giving the Drupal Recipes Autocomplete extension a proper spring clean]]></title>
            <link>https://medium.com/@marcelovani/giving-the-drupal-recipes-autocomplete-extension-a-proper-spring-clean-ffa0163d812f?source=rss-770d5b03ad6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffa0163d812f</guid>
            <category><![CDATA[devin]]></category>
            <category><![CDATA[drupal-recipe]]></category>
            <category><![CDATA[vscode-extension]]></category>
            <dc:creator><![CDATA[Marcelo Vani]]></dc:creator>
            <pubDate>Thu, 17 Sep 2026 07:18:58 GMT</pubDate>
            <atom:updated>2026-09-17T07:18:58.295Z</atom:updated>
            <content:encoded><![CDATA[<p>Last year I wrote about the <a href="https://medium.com/@marcelovani/drupal-recipes-autocomplete-extension-for-vs-code-107e9ff4dde7">Drupal Recipes Autocomplete extension for VS Code</a>, and then a follow-up about <a href="https://medium.com/@marcelovani/drupal-recipes-autocomplete-extension-for-vs-code-now-supports-config-actions-fefa0806991d">how it learned to handle Config Actions</a> using a JSON schema. Since then the extension has been quietly doing its job for a few hundred people, and I have been quietly not touching it.</p><p>Last week I sat down to add some new features, and did what you are supposed to do first: I tried to build it and run the tests.</p><p>The tests did not run.</p><figure><img alt="Same extension, ten months on: 8 tests to 110, 26 audit findings to 4, 42 files to 12, one registry to two" src="https://cdn-images-1.medium.com/max/1024/1*ilzVswvQXjp9hBohcQCDrQ.png" /><figcaption>Same extension, ten months on: 8 tests to 110, 26 audit findings to 4, 42 files to 12, one registry to two</figcaption></figure><h3>Start by turning it on</h3><p>The test runner could not launch VS Code at all. It was looking for a binary called Electron inside the application bundle, and VS Code had renamed that file to Code a couple of releases earlier. One line of somebody else&#39;s package, and the whole suite was dead.</p><p>The awkward part is that the tests run on every pull request. Because the runner picks up whatever the current stable VS Code is, the failure did not arrive with a bang on the day it broke — it just meant the test job had been red for a while and nobody, me included, was looking.</p><p>That set the tone for the week. Before adding anything new, find out what has quietly rotted.</p><h3>Tests first, features later</h3><p>The extension had eight tests, in three files. They were the kind of tests that make you feel good and tell you nothing: they filled the cache with a fake value, asked the code what was in the cache, and confirmed it was the fake value.</p><p>So I rebuilt the testing properly, in two layers.</p><p><strong>Unit tests</strong> for the logic that does not need an editor — the bit that walks up a YAML file to work out which property you are inside, the wildcard matching, the caching. These run in about a second.</p><p><strong>Integration tests</strong> that start a real VS Code, open a small pretend Drupal site, and ask for autocomplete the way the editor does. If a suggestion is supposed to appear under install:, the test presses the same button you would and checks it appears.</p><p>That second layer needed a fixture: a miniature Drupal codebase, a few kilobytes, with a module, a theme, some permissions and some config. Small enough to live in the repository, real enough to be worth testing against.</p><p>Eight tests became a hundred and ten. And immediately they started finding things.</p><h3>What the tests found</h3><p><strong>Your </strong><strong>node_modules was being scanned.</strong> The code meant to skip vendor and node_modules when hunting for YAML files. The exclusion was written as {vendor, node_modules} — with a space after the comma. That space meant the second half never matched anything. So on any Drupal project with a front-end build, the extension was reading its way through thousands of files on startup, and offering you npm packages as if they were Drupal modules.</p><p>One character.</p><figure><img alt="One space in the exclude pattern meant node_modules was never excluded" src="https://cdn-images-1.medium.com/max/1024/1*vxamJD_kDjvD3czdZPvTCg.png" /><figcaption>One space in the exclude pattern meant node_modules was never excluded</figcaption></figure><p><strong>Config suggestions had no icon.</strong> Every other suggestion type had its own little symbol in the dropdown. Config entries fell through to the default, because the code stored them under a name the icon lookup did not know about. Tiny thing, but it is the sort of tiny thing that makes a tool feel unfinished.</p><p><strong>The published extension contained its own test suite.</strong> Everything I had just written was being packaged up and shipped to your machine along with every source map. I had actually “fixed” this earlier in the week and been quite pleased with myself, until I looked at the built file and found it had not worked at all. It turns out .vscodeignore does not behave like .gitignore: a rule that re-includes files wins over every exclusion in the file, no matter what order you put them in. The package went from 40 files to 8.</p><p><strong>And </strong><strong>config/import never really worked.</strong> This one had been <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/6">an open bug</a> for a while. If you asked for suggestions under config/import/node, you got config whose *name* began with node. — but that is not what a recipe imports. A recipe imports the config that the node module *ships*, which includes files like system.action.node_delete_action.yml. Those never appeared. There was even a @todo on the line admitting as much.</p><p>It turned out to have two causes, not one. The lookup was keyed on the wrong thing, and separately the scanner was skipping any file matching _action.yml — which is precisely the files the bug report was asking for.</p><h3>One genuinely new thing</h3><p>While I was in there, I fixed something that had been mildly annoying me since the beginning: the extension would happily suggest a module you had already installed three lines above.</p><p>Now it reads the recipe as it stands and leaves out anything you already have. It works for modules, for nested recipes, for config imports and for permission lists, because underneath they are all the same question — what is already written here?</p><p>The fiddly part was that a half-typed recipe is invalid YAML most of the time. If the parse fails, it filters nothing rather than falling over. The worst case is you see a suggestion you did not need, which is exactly where we started.</p><h3>Keeping up with Drupal, properly this time</h3><p>Here is the thing I actually wanted to solve.</p><p>Drupal keeps adding Config Actions. My old method was to watch the documentation, and every time it grew, add support for the new item. It worked, but it depended entirely on me noticing.</p><p>So this time I wrote it down as a process, and then made a test enforce it.</p><p>The extension now ships a list of every Config Action that Drupal core exposes, generated by a script that reads core’s source directly. There is a companion file saying what we do about each one: it has autocomplete, or it deliberately does not need any, or it is on the backlog with a note explaining what it would take. If an action turns up in Drupal that is in none of those three buckets, the test suite fails and names it.</p><p>The answer to “are we still up to date?” is now a test run rather than an afternoon of reading.</p><figure><img alt="Fifty-two config actions in core: 17 autocompleted, 19 with nothing to suggest, 16 on the backlog" src="https://cdn-images-1.medium.com/max/1024/1*zoMIqITr8us7gpm8BxnNFg.png" /><figcaption>Fifty-two config actions in core: 17 autocompleted, 19 with nothing to suggest, 16 on the backlog</figcaption></figure><p>Writing that script taught me something I had genuinely got wrong. I had been checking for actions by searching core for their names — and some of them are not there. Drupal generates the plural form of an action automatically, so hideComponents is perfectly real even though that word appears nowhere in the codebase. Worse, a whole family of actions does not exist until a site is built: grantPermissionsForEachTaxonomyVocabulary is generated from whichever entity types you happen to have installed.</p><p>Which means no static list can ever be complete. That is not a flaw to fix, it is a fact to design around, and it is the strongest argument yet for the extension scanning your actual codebase rather than relying on a fixed list.</p><h3>About that schema</h3><p>In the <a href="https://medium.com/@marcelovani/drupal-recipes-autocomplete-extension-for-vs-code-now-supports-config-actions-fefa0806991d">second post</a> I wrote about the <a href="https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/drupal-recipe.json">Drupal recipe schema on SchemaStore</a> and the <a href="https://github.com/SchemaStore/schemastore/pull/4187">pull request</a> I contributed to extend it. That schema is still doing a lot of heavy lifting — it is where the key names and the validation come from, and it is why the extension understood recipes before it ever scanned a line of your Drupal code.</p><p>It has also fallen behind, which I only discovered by generating that list from core and comparing. Eighteen Config Actions are missing, along with input — the whole system for recipes that ask the user questions — and extra, and config.strict.</p><p>None of it shows up as an error, which is why nobody noticed. The schema is permissive about keys it does not recognise, so input just sits there getting no help at all.</p><p>That is the next job, and it belongs upstream in SchemaStore rather than in my extension. I have also written all of this down in the repository, so the next person to look — quite possibly me in a year — can find out how the two halves fit together without having to work it out from scratch.</p><h3>It now works outside VS Code</h3><p>One more thing, which I had been meaning to do for a while.</p><p>If you use Windsurf, or Devin, or VSCodium, or code-server, you could not install this extension at all. Those editors are all built on VS Code but are not allowed to use Microsoft’s marketplace, so as far as they were concerned the extension did not exist.</p><p>They use <a href="https://open-vsx.org/">Open VSX</a> instead, and now so do we. Every release goes to both registries from the same build, so they cannot drift apart.</p><p>Getting there was less about code than about plumbing. The extension needed a real release pipeline first — push a tag, and it runs the tests, checks the tag matches the version, builds the package once and publishes that same file to both places. Before this week there was no pipeline at all, no GitHub releases, and two versions that were on the marketplace but had never been tagged in git.</p><h3>The boring things that stop this happening again</h3><ul><li>Every pull request now runs a build, a lint, the unit tests and the integration tests.</li><li>Dependabot watches the dependencies, with small updates batched into one pull request and breaking ones kept separate.</li><li>A check refuses to publish the extension if the package contains test files or source maps.</li><li>26 security advisories in the dependencies became 4.</li><li>And a 93MB dependency that nothing imported, cloned on every single install, is gone.</li></ul><p>None of that is exciting. All of it is why the next feature will take days instead of a week of archaeology.</p><h3>Next up</h3><p>The tickets are all <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues">on GitHub</a> if you want to follow along or, better, pitch in:</p><ul><li>Bringing the <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/39">SchemaStore schema</a> back in line with Drupal, input first.</li><li>Finishing the <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/7">dynamic suggestions</a> for Config Actions. Eight of the callbacks turned out to be named but never written, quietly showing a placeholder instead. Four are done; the last four need things that are not in any YAML file, so they will take more thought.</li><li><a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/3">Default Content</a> support.</li></ul><p>If you build recipes, version 1.1.3 is on the <a href="https://marketplace.visualstudio.com/items?itemName=marcelovani.drupal-recipes-autocomplete-vscode">VS Code Marketplace</a> and on <a href="https://open-vsx.org/extension/marcelovani/drupal-recipes-autocomplete-vscode">Open VSX</a>. And if you have ever been bitten by a mistyped machine name at eleven at night, that is precisely what it is for.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffa0163d812f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Workaround to npm Package: newman-flows Is Now a Thing]]></title>
            <link>https://medium.com/@marcelovani/from-workaround-to-npm-package-newman-flows-is-now-a-thing-39acf1c9f544?source=rss-770d5b03ad6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/39acf1c9f544</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[api-testing]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[newman]]></category>
            <dc:creator><![CDATA[Marcelo Vani]]></dc:creator>
            <pubDate>Tue, 02 Jun 2026 08:57:45 GMT</pubDate>
            <atom:updated>2026-06-02T08:57:45.760Z</atom:updated>
            <content:encoded><![CDATA[<p>A few days ago I wrote about how we ran Postman Flows in CI without paying for Enterprise <a href="https://medium.com/@marcelovani/poc-running-postman-flows-in-ci-without-paying-for-enterprise-0f828828abe1">https://medium.com/@marcelovani/poc-running-postman-flows-in-ci-without-paying-for-enterprise-0f828828abe1</a>.</p><p>The short version: we built a small Node.js script that assembled temporary Newman collections on the fly, so we could run multi-step API flows for free. It worked. People found it useful. And then we kept going.</p><p>What I didn’t expect was to still be using it — and improving it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jWcRryRggjDeoGvHKl3Nuw.jpeg" /><figcaption>Newman Flows</figcaption></figure><p><strong>The Script Outgrew Itself</strong></p><p>The original proof of concept was a single `run-flow.js` file sitting in a project subfolder. Flow definitions lived in separate JSON files next to it. That was fine when we first built it, but as we added more flows and started reusing the approach across projects, a few things started to chafe.</p><p>The biggest one: flow definitions and request definitions lived in different places. You’d rename a request in Postman, export the collection, and then have to remember to also update the separate JSON files. It wasn’t painful, but it was the kind of thing that would quietly break a CI run on a Monday morning.</p><p>The second thing: every new project that wanted to use this had to copy the script. There was no versioning, no install step — just copy the file and hope you remembered to update it next time.</p><p><strong>Flows Move Into the Collection</strong></p><p>The first real improvement was rethinking where flow definitions live.</p><p>Instead of separate JSON files, flow definitions now live <strong>**inside the Postman collection itself**</strong> — in a top-level `Flows/` folder. Each flow is a plain request named after the flow. Its pre-request script calls a `steps()` function with the ordered list of step names:</p><pre>steps([&#39;Admin login&#39;, &#39;Create item&#39;, &#39;Edit item&#39;, &#39;View item&#39;]);</pre><p>That’s it. The request has no URL, no body — it exists purely to carry the flow definition. When the runner finds it, it evaluates the pre-request script in a sandboxed VM, extracts the steps array, and assembles the temporary collection as before.</p><p>This meant flow definitions now travel with the collection. One export from Postman covers everything. Flows are visible in the Postman desktop sidebar alongside the requests they reference. And you can still build and document your flows on the Postman Flows canvas — you just run them a different way.</p><p><strong>It Became a TypeScript Package</strong></p><p>Once the logic was solid, the next step was obvious: stop copying the script between projects and publish it properly.</p><p>The rewrite moved the runner to TypeScript, added a proper CLI with three commands — `list`, `run`, and `validate` — and published the whole thing to npm as <strong>**`newman-flows`**</strong>.</p><pre>npm install - save-dev newman-flows</pre><p>Running all your flows in CI is now a one-liner:</p><pre>npx newman-flows run - all</pre><p>The package auto-discovers your collection and environment files, so there’s nothing to configure beyond the folder structure Postman already gives you.</p><p><strong>A Community Answer to a Long-Standing Request</strong></p><p>Newman doesn’t natively support Flows. There’s been a GitHub issue <a href="https://github.com/postmanlabs/postman-app-support/issues/11770">https://github.com/postmanlabs/postman-app-support/issues/11770</a> requesting it for years — plenty of thumbs-ups, no resolution. The official answer has always been: use Enterprise.</p><blockquote>newman-flows is not an official Newman plugin, but it does address the underlying ask — running ordered, multi-step API flows with Newman, without duplicating request definitions, on the free plan. If this is a gap you’ve run into, it’s worth a look.</blockquote><p><strong>The Short Version</strong></p><p>The setup is now much simpler:</p><p>1. Install: <strong>npm install — save-dev newman-flows</strong></p><p>2. Structure your collection with a `<strong>Requests</strong>/` folder and a `<strong>Flows</strong>/` folder</p><p>3. Define flows as pre-request scripts using `steps([…])`</p><p>4. Run: <strong>npx newman-flows run — all</strong></p><p>The package handles collection discovery, step resolution, validation, and reporting. A runnable example with a mock server is included so you can see it working before connecting a real API.</p><p>Full details — installation, collection structure, CI integration, and the example — are at <a href="https://github.com/marcelovani/newman-flows">https://github.com/marcelovani/newman-flows</a> and on <a href="https://www.npmjs.com/package/newman-flows">https://www.npmjs.com/package/newman-flows</a>.</p><p>Turning it into a package was about making it easy enough that we’d actually keep using it — and that others could drop it in without reading a blog post first. If it doesn’t cover your case yet, the issue tracker is open.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39acf1c9f544" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[POC — Running Postman Flows in CI Without Paying for Enterprise]]></title>
            <link>https://medium.com/@marcelovani/poc-running-postman-flows-in-ci-without-paying-for-enterprise-0f828828abe1?source=rss-770d5b03ad6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f828828abe1</guid>
            <category><![CDATA[postman-collections]]></category>
            <category><![CDATA[api-testing]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[postman-testing]]></category>
            <category><![CDATA[postman-flows]]></category>
            <dc:creator><![CDATA[Marcelo Vani]]></dc:creator>
            <pubDate>Sat, 18 Apr 2026 12:08:03 GMT</pubDate>
            <atom:updated>2026-04-18T12:14:30.289Z</atom:updated>
            <content:encoded><![CDATA[<p>We had a perfectly organised Postman collection, a clean CI pipeline, and a desire to run multi-step API flows automatically on every pull request. But we hit a wall. The only thing standing between us and that goal was a paywall.</p><p>Here’s how we got around it — without duplicating a single request.</p><h3>The Problem: We Wanted Flows, Not Just Folders</h3><p>Our backend exposes a REST API. We use Postman to document and test every endpoint. After a while, individual endpoint tests started feeling hollow — they told us each request worked, not whether the API held together as a system.</p><p>What we really needed to validate was <em>sequences</em>. The kind of journey a real client goes through:</p><ul><li>Admin logs in</li><li>Creates an organisation</li><li>Edits it</li><li>Views it to confirm the change persisted</li><li>Sends an invitation request</li></ul><p>Or a more complex one involving two users — an admin who creates an organisation and sends an invitation, and a member who logs in separately and accepts it. Each step depends on the one before. When the user logs in, the access token must persist to be used on the other API calls to keep authentication.</p><p>These aren’t just endpoint tests. They’re <em>user journeys</em> expressed as API calls.</p><p>Postman has a feature built for exactly this: <a href="https://learning.postman.com/docs/postman-flows/overview"><strong>Flows</strong></a>. It’s a visual canvas, distinct from the Collections view, where you drag saved requests onto a board, connect them with arrows, and define the sequence without writing orchestration code. Variables pipe automatically between steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NSzl68NAYYCZtg1PnjAnRg.jpeg" /><figcaption><em>The Postman Flows canvas showing the Organisation creation flow. Request nodes are connected by arrows. Variable bindings are visible between steps.</em></figcaption></figure><p>We started building flows there. They were clear, maintainable, and made it immediately obvious how the API was meant to be used.</p><p>Then we tried to run them in CI.</p><h3>The Limitation: Postman Flows Require Enterprise to Run from CLI</h3><p>Postman has a <a href="https://learning.postman.com/docs/postman-cli/postman-cli-flows#postman-flows-run">CLI tool </a>that includes a postman flows run command. We got excited. We <a href="https://learning.postman.com/docs/postman-flows/tutorials/video/create-first-flow">read the docs</a>. Then we hit this:</p><blockquote>postman flows run requires a Postman Enterprise plan.</blockquote><p>We’re a small team. Enterprise pricing for a test runner felt like a lot.</p><p>We tried <a href="https://github.com/postmanlabs/newman">Newman</a>, Postman’s open-source CLI runner. It takes a collection JSON file and an optional environment file, fires every request in sequence, and reports the results. Free, no account required. But it does not support running flows and possibly never will. There is a <a href="https://github.com/postmanlabs/newman/issues/2872">GitHub issue</a> requesting Newman support for Flows with plenty of 👍 reactions and no resolution.</p><h3>Using folders in Postman</h3><p>Newman can organise requests into folders and run a specific folder with --folder. The obvious approach: create a folder per flow, put the requests in order, and run each folder. Sounds right, right?</p><p>There are two problems.</p><p><strong>First, there’s no sequencing across folders.</strong> If your flow needs requests from different folders — a login from Requests/Authentication/, then Organisation/Invite member- you can&#39;t compose them without copying. There&#39;s no concept of &quot;run this request from over there, then this one from here.&quot;</p><p><strong>Second, that duplication compounds fast.</strong> Our collection had duplicate “Invite member” requests — one under Organisation, one under Flows. Every time the endpoint changed, we&#39;d have to update multiple places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WYAj-dSSQUiaqo02Qcrj_Q.jpeg" /><figcaption><em>Both copies of “Invite member” visible side by side under different parent folders — the duplication problem in plain sight</em></figcaption></figure><p>Postman Flows solve this elegantly on the canvas — you drag the same request block into multiple flows without duplicating anything. In a Collection, there’s no concept of a reference or alias.</p><h3>The POC</h3><p>The idea is to have placeholder requests inside the Flows folder. They perform no actual HTTP call and serve only as documentation for the flow sequence.</p><h4>The flow definitions</h4><p>The flow definition is a tiny JSON file listing step names in order. A Node.js script does the assembly. See <a href="https://github.com/marcelovani/newman-flows/blob/medium-post-1/dev/Postman/flows/org-creation.json">dev/Postman/flows/org-creation.json</a></p><pre>{<br>  &quot;name&quot;: &quot;Organisation creation&quot;,<br>  &quot;description&quot;: &quot;Admin logs in, creates an organisation, edits it, and views it.&quot;,<br>  &quot;steps&quot;: [<br>    &quot;Organisation admin login&quot;,<br>    &quot;Create Organisation&quot;,<br>    &quot;Edit Organisation&quot;,<br>    &quot;View Organisation&quot;<br>  ]<br>}</pre><h4>The runner script</h4><p>The script <a href="https://github.com/marcelovani/newman-flows/blob/medium-post-1/dev/Postman/run-flow.js">run-flow.js</a> takes two inputs that already exist in any Postman project:</p><ul><li><strong>The collection JSON</strong> — exported from Postman desktop (<em>File → Export → Collection v2.1</em>). This contains every request definition, test script, and variable.</li><li><strong>The environment JSON</strong> — also exported from Postman. It holds the base URL, credentials, and any environment-specific values.</li></ul><p>The script reads both, looks up the named requests, assembles a temporary collection, and hands it to Newman.</p><h4>The repository layout</h4><pre>project-root/<br>├── mock-server.js                               ← demo mock API (npm run mock)<br>├── test.js                                      ← starts mock, runs all flows, stops mock (npm test)<br>└── dev/<br>    └── Postman/<br>        ├── collection/<br>        │   └── my-api.postman_collection.json   ← exported from Postman<br>        ├── environments/<br>        │   ├── environment.mock.postman_environment.json   ← used by npm test (demo)<br>        │   ├── environment.local.postman_environment.json  ← your local API<br>        │   └── environment.ci.postman_environment.json     ← CI / staging<br>        ├── flows/<br>        │   ├── org-creation.json<br>        │   └── member-invitation.json<br>        └── run-flow.js</pre><h4>Sample output</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q-ZaEiVV9eCwVe9KunrXKA.jpeg" /><figcaption>Output of run-flow script</figcaption></figure><h3>Running the Flows using a mock server</h3><p>Check out the POC repo on this branch <a href="https://github.com/marcelovani/newman-flows/tree/medium-post-1">https://github.com/marcelovani/newman-flows/tree/medium-post-1</a>, then run:</p><pre>npm install<br>npm test</pre><p>npm test starts the mock server, runs every flow against it, and stops it afterwards. No real API, no credentials, no network required.</p><p>To run a single flow against the mock server:</p><pre># Terminal 1 — start the mock server<br>npm run mock<br><br># Terminal 2 — run one flow<br>ENV=mock node dev/Postman/run-flow.js &quot;Organisation creation&quot;<br>ENV=mock node dev/Postman/run-flow.js &quot;Member invitation&quot;</pre><h3>Pointing at your real API</h3><p>When adapting this for your own project, replace the mock with your real backend. Export your Postman collection and environment files into the same folder structure, then run:</p><pre># Against a local dev server (uses environment.local.postman_environment.json)<br>node dev/Postman/run-flow.js &quot;Organisation creation&quot;<br><br># Against a staging or CI server (uses environment.ci.postman_environment.json)<br>ENV=ci node dev/Postman/run-flow.js &quot;Organisation creation&quot;</pre><p>The environment files contain the base_url and credentials for each target. For CI, set ADMIN_USERNAME, ADMIN_PASSWORD, MEMBER_USERNAME, and MEMBER_PASSWORD as environment variables (or GitHub Actions secrets).</p><h3>CI Integration</h3><p>In GitHub Actions, the flows run automatically on every push and pull request:</p><pre>- name: Run Newman — all flows<br>  run: npm test<br><br>- name: Store Newman artifacts<br>  if: always()<br>  uses: actions/upload-artifact@v4<br>  with:<br>    name: newman-results<br>    path: tests/results/newman<br>    retention-days: 7</pre><p>Adding a new flow requires no changes to run-flow.js or the CI workflow. Drop a new.json file into dev/Postman/flows/ and it&#39;s automatically picked up on the next run.</p><h3>What We Gained</h3><ul><li><strong>No duplication.</strong> Every request is defined exactly once. Flows are just ordered lists of names.</li><li><strong>Free plan only.</strong> No Enterprise subscription, no cloud execution, no Newman patches.</li><li><strong>Postman Flows canvas still works for design.</strong> We kept using it to diagram and document — just not to run.</li><li><strong>CI-friendly.</strong> JUnit XML and HTML reports are generated per flow and uploaded as artifacts.</li><li><strong>Self-discoverable.</strong> Drop a new .json intodev/Postman/flows/ - no other changes needed.</li></ul><h3>Limitations</h3><p>This approach is a workaround, not a first-class solution.</p><p><strong>Step names must match exactly.</strong> If someone renames a request in the Postman desktop and exports the collection without updating the flow JSON, the runner exits with a helpful error. It’s a light coupling, but it’s there.</p><p><strong>Parallel branches aren’t supported.</strong> Postman Flows can run request blocks in parallel on the visual canvas. Our sequential runner can’t. Every flow is a straight line — which covers the vast majority of API test scenarios.</p><h3>The Takeaway</h3><p>To be blunt: this workaround is not as good as Postman Flows.</p><p>Flows give you a visual canvas where sequences are immediately legible — you can see what connects to what, where variables flow between steps, and how branches fork. Our JSON files and a Node.js script are a pale imitation of that.</p><p>If your team is already on Enterprise, use postman flows run - it&#39;s the right tool.</p><p>But if you’re on the free plan and need multi-step API flows in CI without duplicating request definitions, the underlying problem is solvable with the tools you already have. A small Node.js script and a handful of JSON files gets you most of the way there.</p><p>If Postman ever ships Newman support for Flows on the free plan, delete run-flow.js and don&#39;t look back.</p><p>The full implementation referenced in this post is at <a href="https://github.com/marcelovani/newman-flows/tree/medium-post-1">https://github.com/marcelovani/newman-flows/tree/medium-post-1</a></p><p>Spoiler: While I was writing this article, things evolved quickly, so a new post will be required to talk about <a href="https://www.npmjs.com/package/newman-flows">https://www.npmjs.com/package/newman-flows</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f828828abe1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Arduino-Controlled Laser Tag Target System: A DIY Guide for Interactive Gameplay]]></title>
            <link>https://medium.com/@marcelovani/building-an-arduino-controlled-laser-tag-target-system-a-diy-guide-for-interactive-gameplay-a1adcc4ee32a?source=rss-770d5b03ad6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1adcc4ee32a</guid>
            <category><![CDATA[hobby]]></category>
            <category><![CDATA[electronics]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[arduino]]></category>
            <category><![CDATA[diy]]></category>
            <dc:creator><![CDATA[Marcelo Vani]]></dc:creator>
            <pubDate>Sat, 22 Feb 2025 17:27:22 GMT</pubDate>
            <atom:updated>2025-02-22T17:27:22.603Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fux7G81UsGqQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dux7G81UsGqQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fux7G81UsGqQ%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a6f5c4f803840a2a803e3e2bf5b306f/href">https://medium.com/media/2a6f5c4f803840a2a803e3e2bf5b306f/href</a></iframe><p>As a software engineer with many years of experience, I’ve always sought out creative and engaging outlets to balance my technical work. Whether it’s painting, playing music, or pursuing DIY projects, I find that these activities help me recharge and explore different sides of my mind.</p><p>One of my favorite hobbies has been working with Arduino, an open-source electronics platform that allows for the creation of interactive electronic projects. The Arduino platform’s simplicity, versatility, and affordability make it accessible to makers of all levels, from hobbyists to professional engineers.</p><p>In this blog post, I’ll share my journey into the world of Arduino projects and how it has allowed me to combine my technical skills with my passion for creativity. I’ll also provide some insights and tips for software engineers who are looking to explore the world of physical computing and electronics.</p><p>So, grab your Arduino boards, and let’s embark on this exciting adventure together!</p><p>My inspiration for this project came from a laser tag gun toy that my son received as a gift. I was intrigued by the idea of transforming it into something more dynamic and engaging. During a trip to Disneyland Paris, my son had a blast playing a laser shooting game where the targets interacted by making movements and noises. I wanted to recreate a similar experience at home, where once the targets are shot, they flip and reset after a few seconds.</p><p>I also wanted to add some additional features, such as laser beams to the laser tag guns and targets, allowing them to shoot back at us. This would add an extra layer of interactivity and excitement to the game.</p><p>In the initial phase of planning my Arduino laser tag project, I focused on assessing its feasibility and determining the necessary components. Arduino stood out as the ideal platform for this project due to its affordability, versatility, and the availability of 54 pins on the Arduino Mega variant, which would allow me to control all the targets effectively. The Arduino Mega also offers superior power and increased memory capacity compared to other models, making it well-suited for the project’s requirements.</p><p><a href="https://store.arduino.cc/products/arduino-mega-2560-rev3">Arduino Mega 2560 Rev3</a></p><h3><strong>Arduino Learning and Prototyping</strong></h3><p>At this point, I decided to learn C++ and began experimenting with prototyping on online digital emulators. I started with a simple project to turn a light on and off. This helped me understand the basics of Arduino’s operation and the fundamentals of coding in a new language like C++. Working with this simple project provided a solid foundation for my future Arduino endeavors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kq1e39GGCc_L3W7nLRiA3g.jpeg" /><figcaption>Arduino Emulator screenshot</figcaption></figure><p>The video below shows my initial tests with the physical devices.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FuD8KEyAmcvw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DuD8KEyAmcvw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FuD8KEyAmcvw%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6030eaf6089cf53a4e846725e5fdc0e2/href">https://medium.com/media/6030eaf6089cf53a4e846725e5fdc0e2/href</a></iframe><h3>Things to Keep in Mind When Working with Arduinos</h3><ul><li>Arduinos use the same storage for memory and code, so it’s important to keep the code short, do a good garbage collection, and be aware of these limitations.</li><li>You can only write code onto the Arduino board a few hundred times, after which it will no longer work.</li><li>Prototyping using online tools such as Wokwi or Tinkerpad is important because it allows you to design the electronics, connect to the Arduino, and test the software that will control the hardware.</li><li>There is a huge library of components available, and people keep creating new things every day.</li></ul><h3><strong>Flow of Arduino Code and Clock Speed</strong></h3><p>In Arduino, the code executes in a continuous loop. This means that the code starts at the beginning, runs through to the end, and then immediately jumps back to the beginning. This loop continues until the Arduino is turned off.</p><p>It’s essential to understand how the loop works and how to control events within it. One crucial factor to consider is the clock speed of the Arduino. The clock speed determines how fast the code executes. A higher clock speed means that the code will run faster.</p><p>However, it’s important to note that Arduinos do not have an internal clock. Instead, they rely on an external crystal oscillator to generate the clock signal. This means that every time you turn off the Arduino, the clock is reset.</p><p>Therefore, it’s important to consider the clock speed when writing your code. If you have events that need to occur at precise intervals, you’ll need to take the clock speed into account.</p><h3><strong>Timers and device control in Arduino projects</strong></h3><p>One of the challenges I encountered in my Arduino laser tag project was understanding how to control multiple devices smoothly and without delays. Since the code runs in a continuous loop, I needed to write code that would execute in a specific sequence to ensure that each device was controlled efficiently.</p><p>To achieve this, I created multiple timers, each operating independently. For instance, when the game starts, all the targets are lowered. After a few random seconds, the targets start to raise one by one. While they’re raising, a red light illuminates each target, indicating that it’s not ready. Once the random timer for a specific target kicks in, it’s illuminated with a green light, and the laser beam shoots at the player. At this point, the target can be shot, and if hit, it drops and awards a point to the player.</p><pre>/**<br>     * Timer to reset the arm position.<br>     */<br>    void timerOnStart(unsigned long _interval)<br>    {<br>      this-&gt;_timerOn.setInterval(_interval * 1000);<br>      this-&gt;_timerOn.setRepeats(1);<br>      this-&gt;_timerOn.start();<br>    }<br><br>    /**<br>     * Timer loop controller.<br>     */<br>    void timerLoop() {<br>      this-&gt;_timerOn.run();<br>      // Check if its time to reset.<br>      if (!this-&gt;_timerOn.isRunning()) {<br>        this-&gt;reset();<br>      }<br>    }</pre><p>Up to three players can participate in the game simultaneously, which brings us to another interesting topic: how the laser tag guns work.</p><h3><strong>How the Laser Tag Works</strong></h3><p>For the original laser tag game to work, the laser guns had to emit different codes. These signals are emitted by an infrared light.</p><p>I used an infrared receptor connected to the input of the Arduino and wrote a small piece of code to record the sequence of bits that I received when I shot against the infrared receiver.</p><pre>// At 115200 baud, printing takes 200 ms for NEC protocol and 70 ms for NEC repeat<br>Serial.println(); // blank line between entries<br>Serial.println(); // 2 blank lines between entries<br>IrReceiver.printIRResultShort(&amp;Serial);<br>// Check if the buffer overflowed<br>if (IrReceiver.decodedIRData.flags &amp; IRDATA_FLAGS_WAS_OVERFLOW) {<br>  Serial.println(F(&quot;Try to increase the \&quot;RAW_BUFFER_LENGTH\&quot; value of &quot; STR(RAW_BUFFER_LENGTH) &quot; in &quot; __FILE__));<br>  // see also https://github.com/Arduino-IRremote/Arduino-IRremote#compile-options--macros-for-this-library<br>} else {<br>  if (IrReceiver.decodedIRData.protocol == UNKNOWN) {<br>      Serial.println(F(&quot;Received noise or an unknown (or not yet enabled) protocol&quot;));<br>  }</pre><p>It was clear that the codes were distinct, but I still had to understand how to decode and eliminate noise. Luckily, I found some good starting points on GitHub and realized how to extract the signature from each gun so that we could know who shot the target <a href="https://github.com/Arduino-IRremote/Arduino-IRremote/tree/master">https://github.com/Arduino-IRremote/Arduino-IRremote/tree/master</a>.</p><h3><strong>Refactoring Arduino Code and Adding New Features</strong></h3><p>After testing and refining my initial prototype, I decided to refactor my Arduino code to improve its structure and readability. I created separate classes for each device, such as the target, infrared receiver, RGB LED, and servo motor. This modular approach made it easier to maintain and debug my code.</p><p>I also continued to add new features to the project. I implemented a menu system that allowed users to choose between a test mode and a game mode. Additionally, I integrated an MP3 player module to play different sounds based on the distance and position of the target. This added an immersive 3D audio experience to the game.</p><p>To enhance the gameplay further, I assigned properties to each target, such as left/right orientation and distance from the player. When a player shoots a target, the MP3 player plays a sound from the corresponding speaker, giving a sense of spatial awareness. Targets closer to the player play at a louder volume, creating a more dynamic audio experience.</p><p>I added a laser beam to the gun so that we have a visual of the shot, since the infrared is invisible to the human eyes. I also prototyped an electronic circuit that will make the laser bean do only a brief shot every time the player pulls the trigger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QFeLa7swWjXIufd1-4A9YA.png" /><figcaption>Screenshot of the electronics for the laser gun</figcaption></figure><p>More detais here <a href="https://github.com/marcelovani/arduino-laser-target/blob/master/Electronics/Multivibrator/Readme.md">https://github.com/marcelovani/arduino-laser-target/blob/master/Electronics/Multivibrator/Readme.md</a></p><h3><strong>Next step is to build the electronics</strong></h3><p>I started by building the targets, they are very simple, and will have only few components:</p><ul><li>A servo that controls the target movement</li><li>A RGB led to illuminate the target based on the status</li><li>A laser beam to shoot at the players</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9VayIu9dhV1KjL5gjkQoGQ.jpeg" /><figcaption>Building the components for the target</figcaption></figure><p>I made these very simple, using cardboard with a printed target, glued on a wooden stick to the servo, all the bits go inside a little box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hv7qt4o2zcrM1DMvxkRYDA.jpeg" /><figcaption>The targets</figcaption></figure><p><strong>The next thing was to do with connecting the targets to the Arduino</strong></p><p>I had two ways of going on about this:</p><ol><li>I could have used standalone targets, but that would require an Arduino on each target and a cable to provide power for each target.</li><li>Use ethernet cables, since it has 8 wires, it is the perfect number of wires to control the servo, the led and the laser, it doesn’t require dealing with wifi or bluetooth connections, but the only caveat is that you have a limited number of possible targets due to the 54 ports available on the Arduino Mega.</li></ol><p>For simplicity I decided to use ethernet cables. If one day I decide to make this a real product, I would definitely make the targets self-contained with their own Arduino controllers, allowing virtually unlimited devices, as long as the Arduino Mega has enough memory to control so many devices.</p><h3><strong>Building the Enclosure</strong></h3><p>To create a visually appealing enclosure for the Arduino laser tag project, an old Virgin Media router was repurposed due to its sleek design. However, the router’s limited four Ethernet ports posed a problem, as eight ports were required. To overcome this, another router was sacrificed, and its ports were cut out and joined with the original four ports. While the result may not be aesthetically pleasing, it serves the purpose of a prototype and will be concealed within the enclosure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fwltXe52hMMbMegDxD49Kw.jpeg" /><figcaption>Cut out the middle of the ciruit board to make room for the Arduino</figcaption></figure><p>The circuit board was partially removed to accommodate the Arduino, leaving only the outer sections for soldering connections to each Ethernet pin. This involved soldering 64 cables, with eight ports and eight pins per port. Technical difficulties arose due to the circuit board’s three layers of connectors, potentially causing short circuits during cutting. Troubleshooting and trial-and-error were necessary to identify and resolve the issue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M6xSFgDtw__KpwBmnEb9Xw.jpeg" /><figcaption>Soldering the wires to each of the 64 pins</figcaption></figure><p>Modularity was prioritized by incorporating an Arduino Mega terminal shield, allowing for easy attachment to the Arduino and screw-on wire connections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WhOQislrohpzkCnrQsTRig.jpeg" /><figcaption>Using the terminal shield to keep things modular</figcaption></figure><p>The router’s DC input socket was repurposed to supply 9V input to the Arduino. However, a mishap with the socket damaged the built-in voltage regulator. This was easily remedied by replacing the faulty component with a standard part from eBay.</p><p>Additional cuts were made to the enclosure to accommodate the LCD display and rotary knob used for controlling game options in the menu.</p><h3><strong>Installation and Testing of Laser Tag Game</strong></h3><p>After several weeks of working on the code and electronics, it was time to install the entire laser tag system. I mounted the eight targets in my garage, some on the ceiling and some on the wall. I ran Ethernet cables up to the router and powered on the Arduino. The system played the intro sound, displayed the splash screen, and presented the main menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgJ0nE5IEuJsE5GztbifCQ.jpeg" /><figcaption>Testing the targets</figcaption></figure><p>In test mode, I tested each target individually to ensure they could recognize shots from the laser gun, shoot back laser beams, and display different colors. Everything functioned perfectly. I started the game and played for a few minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8tW8fMpGGSXmgHWkkTzI-g.png" /><figcaption>Testing the game in the garage with smoke machine to enhance the visuals</figcaption></figure><p>I then used a smoke machine to make the laser beams visible, creating an immersive scenario. I played the game for a while with my son and a friend. The scores were counted correctly, and the overall experience was very engaging, thanks to the surround sound that added a sense of dimension. The objective was achieved!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B7DKg6k2UIca4okync9lLw.jpeg" /><figcaption>The enclosure with the arduino and wirring done</figcaption></figure><h3><strong>Learnings from Arduino Projects</strong></h3><ol><li>Arduinos are fun to work with and allow for a wide range of creative projects.</li><li>C++ is a powerful language, but when working with Arduinos, it’s essential to be mindful of the limited resources available.</li><li>There’s no limit to your creativity when it comes to Arduino projects.</li><li>Arduino boards provide a user-friendly and accessible platform for a wide array of projects, from simple LED circuits to complex robotics and automation systems. Their flexibility and open-source nature encourage experimentation and creativity, making them an ideal tool for both beginners and experienced electronics enthusiasts.</li><li>While C++ offers powerful programming capabilities, Arduino’s microcontroller environment has limited memory and processing power. Efficient coding practices, such as minimizing variable scope, utilizing libraries judiciously, and optimizing algorithms, are crucial for successful Arduino projects.</li><li>The Arduino ecosystem, with its vast collection of sensors, actuators, and communication modules, opens up a world of possibilities for innovative and impactful projects. From interactive art installations and wearable technology to environmental monitoring systems and smart home automation, the only limit is your imagination.</li><li>Working with Arduino projects inevitably involves encountering bugs, hardware issues, and unexpected behavior. This process fosters valuable problem-solving skills, such as debugging code, using diagnostic tools, and researching solutions online.</li><li>The Arduino community is a vibrant and supportive network of makers, engineers, and hobbyists who share their knowledge, projects, and experiences. Online forums, tutorials, and open-source libraries provide invaluable resources for learning and collaboration.</li><li>Arduino projects often bridge the gap between electronics, programming, and other disciplines, such as physics, mechanical engineering, and art. This interdisciplinary approach encourages a holistic understanding of technology and its applications.</li><li>The Arduino platform facilitates rapid prototyping and iterative design, allowing for quick testing and refinement of ideas. This approach encourages experimentation and learning from failures, ultimately leading to more robust and successful projects.</li></ol><h3>Resources</h3><p>Prototype video <a href="https://youtu.be/uD8KEyAmcvw">https://youtu.be/uD8KEyAmcvw</a></p><p>Playing Video <a href="https://youtu.be/ux7G81UsGqQ">https://youtu.be/ux7G81UsGqQ</a></p><p>C++ reference <a href="https://docs.arduino.cc/language-reference/">https://docs.arduino.cc/language-reference/</a></p><p>Github project page <a href="https://github.com/marcelovani/arduino-laser-target?tab=readme-ov-file">https://github.com/marcelovani/arduino-laser-target</a></p><p>Online emulator <a href="https://wokwi.com/projects/353876404628899841">https://wokwi.com/projects/353876404628899841</a></p><p>Arduino Mega <a href="https://store.arduino.cc/products/arduino-mega-2560-rev3">https://store.arduino.cc/products/arduino-mega-2560-rev3</a></p><p>Terminal shield <a href="https://thepihut.com/products/terminal-shield-for-arduino-mega">https://thepihut.com/products/terminal-shield-for-arduino-mega</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1adcc4ee32a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drupal Recipes Autocomplete extension for VS Code now supports Config Actions]]></title>
            <link>https://medium.com/@marcelovani/drupal-recipes-autocomplete-extension-for-vs-code-now-supports-config-actions-fefa0806991d?source=rss-770d5b03ad6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/fefa0806991d</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[vs-code-extensions]]></category>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[drupal-recipe]]></category>
            <dc:creator><![CDATA[Marcelo Vani]]></dc:creator>
            <pubDate>Thu, 14 Nov 2024 22:15:04 GMT</pubDate>
            <atom:updated>2024-11-14T22:30:19.060Z</atom:updated>
            <content:encoded><![CDATA[<h3>Drupal Recipes Autocomplete extension supports Config Actions</h3><p>Few weeks ago I posted about the new Drupal Recipes Autocomplete extension for VS Code <a href="https://medium.com/@marcelovani/drupal-recipes-autocomplete-extension-for-vs-code-107e9ff4dde7">https://medium.com/@marcelovani/drupal-recipes-autocomplete-extension-for-vs-code-107e9ff4dde7</a>. The first release was able to provide suggestions for the basic properties such as name, description, type, recipes, install and config/import.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yXkhRhb6USMjiBAMznbauw.png" /><figcaption>Drupal Recipe example</figcaption></figure><p>I have been working on this issue <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/1">https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/1</a> to add support for Config Actions. The list of available config actions can be found on this document <a href="https://git.drupalcode.org/project/distributions_recipes/-/blob/1.0.x/docs/config_action_list.md">https://git.drupalcode.org/project/distributions_recipes/-/blob/1.0.x/docs/config_action_list.md</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x7c0QsX8FftD3TSLVBEevg.png" /><figcaption>Example of autocomplete suggestions for config actions</figcaption></figure><p>The idea was to translate the documentation into a proper schema that could be used for multiple things, including providing validation/highlight for errors on recipe.yml files and most importantly, to provide the autocomplete functionality. Luckily someone else had already created a <a href="https://github.com/d70rr3s/schemastore/blob/2931f7e37bdc8ec980328cf3d04c3050cbf33f66/src/schemas/json/drupal-recipe.json">schema for Drupal recipes</a> in the Schema Store, all I had to do is extend the list and collaborate. The Json Schema not only provides autocomplete for the static items, but also validates the Recipe, making it easier to spot mistakes, increasing productivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q2gdDKLjFZU1RwROcCyYTg.png" /><figcaption>Partial screenshot of schema for drupal-recipe.yml</figcaption></figure><p>The Schema Store is a public repository of JSON and YAML schemas for common tools, technologies, and frameworks. It provides validation and autocomplete suggestions for IDEs such as PHP Storm and VS Code, see <a href="http://www.schemastore.org/">http://www.schemastore.org</a>.</p><p>Here is the documentation on how to write/update schemas <a href="https://github.com/SchemaStore/schemastore/blob/master/CONTRIBUTING.md">https://github.com/SchemaStore/schemastore/blob/master/CONTRIBUTING.md</a>. I also updated the existing tests to include the new properties. The maintainers are very active and the pull request was merged as soon as I finished fixing pipeline issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lu0U9pfJj29alIVkMUejRw.png" /><figcaption>The pipelines use Ajv to validate the schemas</figcaption></figure><p>This is a major breakthrough in terms of functionality. Previously, the VS Code extension was able to fill in only the basic properties, which represented about 20% of the static items. With the new addition, it now covers about 80% of the possible autocomplete items. The last 20% that is missing is regarding to Default content and autocompletion suggestions for the dynamic items of Config Actions, see below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3C69HibmupoGSbkIu55pxw.png" /><figcaption>Autocomplete suggestions for dynamic actions</figcaption></figure><p>Recently I was able to work on the Json mapping and the implementation of logic to fill in the dynamic values, see issue <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/7">https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/7</a>.</p><p>Now there is only 10% left to do, here is the list of dynamic Config actions that are currently supported <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/wiki/Properties">https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/wiki/Properties</a>.</p><p>And finally, this issue to support Default Content <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/3">https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/3</a>.</p><h3>The extension</h3><p>The code is written in Typescript. While it has a very strict syntax, which can slow down things, it forces you to write good code, reducing the number of bugs and errors due to bad code.</p><p>Parts of the code were borrowed from the Drupal extension for VS Code, I actually started development of this extension as part of the Drupal extension, see <a href="https://github.com/kaermorchen/vscode-drupal/compare/master...marcelovani:vscode-drupal:drupal-recipes-autocomplete">https://github.com/kaermorchen/vscode-drupal/compare/master...marcelovani:vscode-drupal:drupal-recipes-autocomplete</a>.</p><p>The original idea was to create a pull request to collaborate with the existing extension, but I thought it would slow down development because I would be tied to their own plans for issuing new releases. Once the code is stable enough, perhaps I could consider merging the two extensions. By the way, with the updates from my PR to the Schema Store, the static items will be available immediately to any IDE that uses it.</p><h3><strong>The Code</strong></h3><p>The magic starts on the constructor of the <em>RecipesCompletionProvider</em> class, it implements <em>CompletionItemProvider</em> and invokes <em>registerCompletionItemProvider</em>() to register the autocomplete functionality, providing the filenames are supported.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JwYMM1wRCnUDaJuuIIkOUQ.png" /><figcaption>src/schemas/json/drupal-recipe.json</figcaption></figure><p>Next, the <em>YamlDiscovery</em> class will scan the Drupal codebase, parsing yaml files and categorising each item as module/theme/profile/config/entity/permissions, etc. We build a tree that will contain all the suggestions, relative to its parent item. The items are cached statically, to be used later, when the autocomplete is triggered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UTPzaUDOJyhBls0l2QOA4g.png" /><figcaption>src/base/drupal-workspace-yaml-discovery.ts</figcaption></figure><p>When editing <em>recipe.yml</em>, we can press ^ + space to get autocomletion suggestions. The static suggestions will be provided automatically by the Yaml extension, as it uses the json from Schema Store, this is linked via package.json, see below:</p><pre>&quot;yamlValidation&quot;: [<br>  {<br>    &quot;fileMatch&quot;: [<br>      &quot;recipe.yml&quot;,<br>      &quot;recipe.yaml&quot;<br>    ],<br>    &quot;url&quot;: &quot;https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/drupal-recipe.json&quot;,<br>  }<br>]</pre><p>The dynamic suggestions are provided by a mapping that has the same structure as the json from Schema Store, example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MkcG12UhXjhlutHbMRsgrg.png" /><figcaption>src/base/suggestions-mapping.json</figcaption></figure><p>The cherry on the cake is provided by the method provideCompletionItems() in the RecipesCompletionProvider class, where it all started. Here we call some methods to figure out the position on the editor and all the parents of the current item. Based on that and the information in the suggestions-mapping.json, we know if we should invoke a callback or use values from another part of the information tree.</p><p>The last thing is to find the property in the cached items and return the completion item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G0iF_-FWM0dZSEgcTH-vwg.png" /><figcaption>src/schemas/json/drupal-recipe.json</figcaption></figure><h3>See it in action</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FqVHMRGqGQZs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DqVHMRGqGQZs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FqVHMRGqGQZs%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cba52273c5eec38a9eee6c152173148/href">https://medium.com/media/7cba52273c5eec38a9eee6c152173148/href</a></iframe><p>If you want to try the extension, please visit the VS Code Marketplace <a href="https://marketplace.visualstudio.com/items?itemName=marcelovani.drupal-recipes-autocomplete-vscode">https://marketplace.visualstudio.com/items?itemName=marcelovani.drupal-recipes-autocomplete-vscode</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SUlC-tMl-JS07XV_unuxQg.png" /><figcaption>Extension on VS Code Marketplace</figcaption></figure><h3>Next Steps</h3><ul><li>Work on this issue to add support for Default content <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/3">https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/3</a></li><li>Continue to work on this issue <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/7">https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/7</a> to provide suggestions for dynamic config actions.</li></ul><h3>Events</h3><p>I will be presenting about the VS Code extension in two events, the presentation will contain a live demo and details about the implementation using Json schema and Typescript.</p><ul><li>14th November 2024 — Palermo Drupal Meetup (<strong>Remote</strong>) <a href="https://www.meetup.com/palermo-drupal-meetup/events/304060487/rsvp/">https://www.meetup.com/palermo-drupal-meetup/events/304060487/rsvp/</a></li><li>20th November 2024 — Drupal Meetup (<strong>London</strong>) <a href="https://www.meetup.com/london-drupal-user-group/events/303500889">https://www.meetup.com/london-drupal-user-group/events/303500889</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fefa0806991d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drupal Recipes Autocomplete extension for VS Code]]></title>
            <link>https://medium.com/@marcelovani/drupal-recipes-autocomplete-extension-for-vs-code-107e9ff4dde7?source=rss-770d5b03ad6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/107e9ff4dde7</guid>
            <category><![CDATA[yaml]]></category>
            <category><![CDATA[drupal-recipe]]></category>
            <category><![CDATA[autocomplete]]></category>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[vs-code-extensions]]></category>
            <dc:creator><![CDATA[Marcelo Vani]]></dc:creator>
            <pubDate>Mon, 07 Oct 2024 19:39:49 GMT</pubDate>
            <atom:updated>2024-10-07T19:39:49.191Z</atom:updated>
            <content:encoded><![CDATA[<p>Drupal Recipes are an innovative concept, empowering site builders and developers to rapidly assemble Drupal functionalities from predefined sets. They are particularly useful for jumpstarting new websites or adding specific features, such as content types, image styles, and user roles. Recipes excel in creating feature sets for specific site types like blogs or educational websites.</p><p>For more on creating and installing Drupal Recipes, please refer to this article <a href="https://www.velir.com/ideas/2023/05/03/exploring-the-new-recipes-feature-in-drupal-10">https://www.velir.com/ideas/2023/05/03/exploring-the-new-recipes-feature-in-drupal-10</a>. Here is another great article that explains how to manually craft Drupal recipes <a href="https://bpekker.dev/drupal-recipes/">https://bpekker.dev/drupal-recipes</a>.</p><p>Creating recipes manually can be time-consuming and error-prone, requiring precise knowledge of machine names for modules, themes, and configurations. Spelling mistakes can lead to frustrating debugging sessions, and an error-free setup demands flawless machine names and configurations.</p><h3>Working productively</h3><p>The Drupal Recipes Autocomplete extension for VS Code (<a href="https://marketplace.visualstudio.com/items?itemName=marcelovani.drupal-recipes-autocomplete-vscode">Link to VS Code Marketplace</a>) simplifies this process by offering real-time suggestions based on your Drupal installation. It intelligently pulls in configuration names, module names, and other recipe identifiers. The suggestions are context-sensitive; for instance, only relevant configurations for a certain module are displayed during editing.</p><figure><img alt="Animated gif showing an example of autocomplete suggestions for Drupal Recipes" src="https://cdn-images-1.medium.com/max/1024/1*7QXYH9XH-T5Tc8fohSotGA.gif" /></figure><h3>How to Use the Extension</h3><ol><li>Open the Drupal codebase in VS Code.</li><li>Click the Extensions button, search for “drupal recipe autocomplete” and install the extension.</li><li>In your codebase, open any existing recipe.yml file, or simply create a new file.</li><li>Use Ctrl + Space to trigger autocomplete suggestions anywhere in the editor. It will provide suggestions based on the parent item i.e. if you are in the line below “install:” you will receive suggestions for modules that exist in your codebase.</li></ol><h3>Current Features (Version 1.0.5)</h3><ul><li>Autocompletes basic recipe items like Name, Description, and Type.</li><li>Facilitates the installation of other recipes and modules.</li><li>Supports config/import by listing available modules and their respective configurations.</li></ul><h3>Upcoming Improvements</h3><ul><li><strong>Config/Actions</strong>: While it currently pulls module names and configurations, contextual suggestions (like createIfNotExists and grantPermissions) are in development. See <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/1">this issue</a> for details.</li><li><strong>Default Content Suggestions</strong>: This feature is in progress, as detailed <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/3">here</a>.</li><li><strong>Automatic generation of composer.json</strong>: The issue for this feature can be found <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues/2">here</a>.</li></ul><h3>Adapting to Changes</h3><p>As the Drupal Recipes initiative evolves, maintaining alignment with recipe configuration changes is crucial. Utilizing schemas can standardize documentation and validate codebase changes, ensuring the extension remains accurate and efficient.</p><p>The schemas can be used to generate the <a href="https://git.drupalcode.org/project/distributions_recipes/-/tree/1.0.x/docs">documentation</a> that is currently updated manually. The same schema could be used for other projects, such as <a href="https://www.drupal.org/project/recipe_generator">Drush Recipes Generator</a>.</p><p>Employing schemas would minimize duplication and serve as the single source of truth, offering a comprehensive list of available options and enabling the validation of the core Recipes codebase through automated testing.</p><p>You can see more details about using schemas on <a href="https://www.drupal.org/project/distributions_recipes/issues/3475786">this issue</a> on Drupal.org.</p><h3>Getting Involved</h3><p>Contributions to the extension are welcome! Review <a href="https://github.com/marcelovani/drupal-recipes-autocomplete-vscode/issues">open issues on GitHub</a> and consider submitting a pull request. Your involvement can help shape the future of this tool.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=107e9ff4dde7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing decoupled menus using Handlebars, in 3 steps]]></title>
            <link>https://medium.com/@marcelovani/implementing-decoupled-menus-using-handlebars-in-3-steps-9e1301ecde17?source=rss-770d5b03ad6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e1301ecde17</guid>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[decoupled]]></category>
            <category><![CDATA[handlebars]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[twig]]></category>
            <dc:creator><![CDATA[Marcelo Vani]]></dc:creator>
            <pubDate>Tue, 26 Mar 2024 11:20:04 GMT</pubDate>
            <atom:updated>2024-03-26T11:20:04.978Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SaeewR9qFIRghOru6zKthg.png" /></figure><p>Drupal is famous for its flexibility and user-friendliness in terms of exposing data through APIs. This capability is crucial for developers looking to build decoupled or progressively decoupled applications, which separate the front end from the CMS backend</p><p>At DrupalCon Global 2020, Dries proposed a new initiative for creating a decoupled menu component written in JavaScript, check <a href="https://www.drupal.org/project/ideas/issues/3170260">this post</a> for more information.</p><p>The initiative advocates for the creation of decoupled menu components in JavaScript, aiming to keep Drupal “framework agnostic”. The proposed idea was to use Vue.js or React.js components. While this sounds like an easy task, the scope for expansion is vast and far from easy for a Drupal backend developer that is used to Twig. Here is where Handlebars.js comes in handy.</p><p>On this article, I will show you how to implement a decoupled Admin toolbar in 3 simple steps:</p><ol><li>Using Javascript to fetch the data and generate the markup</li><li>Creating a Handlebars template</li><li>Adding scripts to the page using Drupal Libraries</li></ol><h3>Why Handlebars and not React?</h3><p>While Handlebars.js offers simplicity and familiarity, it may not be as scalable as frameworks like React for more complex, interactive UI components. However, for small projects, with straightforward tasks such as creating a decoupled menu, Handlebars.js often results in quicker development and fewer maintenance concerns.</p><h3>Handlebars</h3><ul><li>Lightweight</li><li>Similar to Twig</li><li>Easy to implement</li><li>No compilation required</li><li>No dependencies</li></ul><h3>React</h3><ul><li>Steep learning curve</li><li>More boilerplate code required</li><li>Dependencies can become hard to maintain</li><li>Requires compilation using Webpack, Babel, etc</li></ul><p>For a more in depth comparison between Handlebars.js and React, please read this article: <a href="https://medium.com/@marcelovani/react-vs-handlebars-choosing-the-right-tool-for-progressively-decoupled-applications-1d421ea4e0fc">React vs. Handlebars: Choosing the Right Tool for Progressively Decoupled Applications</a></p><p>For this demo, we will be using 3 Contrib modules:</p><ul><li>Handlebars <a href="https://www.drupal.org/project/handlebars">https://www.drupal.org/project/handlebars</a></li><li>REST Menu items <a href="https://www.drupal.org/project/rest_menu_items">https://www.drupal.org/project/rest_menu_items</a></li><li>REST UI <a href="https://www.drupal.org/project/restui">https://www.drupal.org/project/restui</a></li></ul><h3>Prerequisites</h3><ul><li>Enable the 3 contrib modules above.</li><li>Configure the REST resource for <em>Menu items per menu</em> in /admin/config/services/rest.</li></ul><figure><img alt="Configure rest resource for “Menu items per menu”" src="https://cdn-images-1.medium.com/max/1024/1*SNhDFOZuXqOb8DsSO3XP_Q.png" /></figure><ul><li>Check that the REST api is working by accessing /api/menu_items/admin.</li></ul><figure><img alt="Check the output of the REST API" src="https://cdn-images-1.medium.com/max/1024/1*BuNqCuJ1N0haGCytwZ5idA.png" /></figure><h3>Step 1: Javascript</h3><p>We need to create the script that will be responsible for fetching the data from the REST API, render the Handlebars template and inject the markup onto the DOM. Lets create a new module called <strong><em>my_module</em></strong>, also create <strong><em>my_module.info.yml</em></strong><em>, see below:</em></p><pre>name: &quot;My module&quot;<br>type: module<br>description: Example of using Handlebars to render decoupled admin menus<br>core_version_requirement: ^10</pre><p>Create a new js file <strong><em>my_module/js/admin_menu.js</em></strong>, with the following code:</p><pre>(function ($) {<br>   if (typeof Handlebars !== &#39;object&#39;) {<br>       return;<br>   }<br>   // Get admin menu items from REST API.<br>   $.get(&#39;/api/menu_items/admin&#39;, function (data) {<br>       // Create a new div element.<br>       var newDiv = document.createElement(&#39;div&#39;);<br>       // Render Handlebars template.<br>       newDiv.innerHTML = handlebarsRenderer.render(&#39;menu&#39;, data[0]);<br>       // Append new div after existing div.<br>       var el = document.querySelector(&#39;#toolbar-item-administration-tray&#39;);<br>       el.append(newDiv);<br>   });<br>})(jQuery);</pre><p>We will also create a Handlebars helper to generate safe ids from strings. The concept of custom helpers can be found in the <a href="https://handlebarsjs.com/guide/#custom-helpers">Handlebars documentation</a>. We will explain how this is used in Step 2. See contents of <strong><em>my_module/js/handlebars_helpers.js</em></strong></p><pre>// Handlebars helper to create safe ids from string.<br>if (typeof Handlebars === &#39;object&#39;) {<br>   // Register the Handlebars helper.<br>   Handlebars.registerHelper(&#39;id&#39;, (identifier) =&gt; {<br>       let cleanedIdentifier = identifier;<br>       cleanedIdentifier = cleanedIdentifier<br>           .replaceAll(&#39;__&#39;, &#39;##&#39;)<br>           .replaceAll(&#39; &#39;, &#39;-&#39;)<br>           .replaceAll(&#39;.&#39;, &#39;-&#39;)<br>           .replaceAll(&#39;_&#39;, &#39;-&#39;)<br>           .replaceAll(&#39;/&#39;, &#39;-&#39;)<br>           .replaceAll(&#39;[&#39;, &#39;-&#39;)<br>           .replaceAll(&#39;]&#39;, &#39;&#39;)<br>           .replaceAll(&#39;##&#39;, &#39;__&#39;);<br>       // We strip out any character not in the above list.<br>       cleanedIdentifier = cleanedIdentifier.replaceAll(/[^\u{002D}\u{0030}-\u{0039}\u{0041}-\u{005A}\u{005F}\u{0061}-\u{007A}\u{00A1}-\u{FFFF}]/gu, &#39;&#39;);<br>       // Identifiers cannot start with a digit, two hyphens, or a hyphen followed by a digit.<br>       cleanedIdentifier = cleanedIdentifier.replace(/^[0-9]/, &#39;_&#39;).replace(/^(-[0-9])|^(--)/, &#39;__&#39;);<br>       return cleanedIdentifier.toLowerCase();<br>   });<br>}</pre><h3>Step 2: Creating the Handlebars template</h3><p>Create a file called <strong><em>menu.handlebars</em></strong> into <strong><em>my_module/handlebars</em></strong> folder.</p><p>Copy the markup from the toolbar element on the page source and paste inside the newly created file. This will be our Handlebars template that will be dynamically rendered using the data from the REST endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tNoxZhDpeQ2m2DJR" /></figure><p>Delete the &lt;li&gt; items and create a loop to generate the list dynamically , using variable names from the REST output, for example, the <strong><em>href</em></strong> attribute will use the value of <strong><em>menuItem.alias.</em></strong></p><p>Now we will use the Handlebars helper (<em>id</em>) that we created previously, it will be used to convert <strong><em>menuUtem.key</em></strong> into a safe id, see the code below:</p><pre>&lt;ul class=&quot;toolbar-menu claro-toolbar-menu&quot;&gt;<br>   {{#each this.below as | menuItem | }}<br>   &lt;li class=&quot;menu-item menu-item--collapsed&quot;&gt;<br>       &lt;a class=&quot;toolbar-icon toolbar-icon-{{id menuItem.key }}&quot;<br>         data-drupal-link-system-path=&quot;{{ menuItem.alias }}&quot;<br>         href=&quot;/{{ menuItem.alias }}&quot;<br>         id=&quot;toolbar-link-{{id menuItem.key }}&quot;<br>         title=&quot;{{ menuItem.description }}&quot;&gt;{{ menuItem.title }}&lt;/a&gt;<br>   &lt;/li&gt;<br>   {{/each}}<br>&lt;/ul&gt;</pre><h3>Step 3: Drupal libraries</h3><p>Create a file called <strong><em>my_module.libraries.yml</em></strong></p><p>We will now define the Drupal libraries to be loaded. In order for the Handlebars template to be registered and discovered, you need to specify the library type as <strong><em>handlebars_template.</em></strong><em> </em>This is not a core functionality, the library type is used only by the Handlebars module. See contents of <strong><em>my_module.libraries.yml</em></strong></p><pre>main:<br> js:<br>   js/admin_menu.js: {}<br> dependencies:<br>   - core/drupal<br>   - core/jquery<br>   - my_module/menu<br> css:<br>   theme:<br>     css/admin_menu.css: { }<br><br>helpers:<br> js:<br>   js/handlebars_helpers.js: { }<br><br>menu:<br> version: 1.x<br> type: handlebars_template<br> js:<br>   handlebars/menu.handlebars: { }<br> dependencies:<br>   - handlebars/main<br>   - my_module/helpers</pre><p>Attach the library using hook_page_attachments_alter() in <strong><em>my_module.module</em></strong></p><pre>&lt;?php<br>/**<br>* Implements hook_page_attachments_alter().<br>*/<br>function my_module_page_attachments_alter(array &amp;$attachments) {<br> // Attach handlebars template to every page.<br> $attachments[&#39;#attached&#39;][&#39;library&#39;][] = &#39;my_module/main&#39;;<br>}</pre><p>After enabling the custom module, you will see two admin toolbars: the decoupled one and the original one. The original markup can be removed using <strong><em>hook_preprocess_menu__toolbar()</em></strong>. We still need the original stylesheets from the Toolbar module, so we won’t disable the module.</p><pre>/**<br>* Implements hook_preprocess_menu__toolbar().<br>*/<br>function my_module_preprocess_menu__toolbar(&amp;$variables) {<br>   $variables[&#39;items&#39;] = [];<br>}</pre><p>For other examples of Handlebars for Drupal, see the links in the resources below.</p><h3>Resources</h3><ul><li>Visit the <a href="https://handlebarsjs.com/guide/">Handlebars.js documentation</a> for features and guides.</li><li>Drupal Handlebars <a href="https://www.drupal.org/project/handlebars">https://www.drupal.org/project/handlebars</a></li><li>Examples of decoupled apps with Drupal Handlebars <a href="https://git.drupalcode.org/project/handlebars/-/tree/8.x-1.x/modules/examples">https://git.drupalcode.org/project/handlebars/-/tree/8.x-1.x/modules/examples</a></li><li>React vs. Handlebars: Choosing the Right Tool for Progressively Decoupled Applications <a href="https://medium.com/@marcelovani/react-vs-handlebars-choosing-the-right-tool-for-progressively-decoupled-applications-1d421ea4e0fc">https://medium.com/@marcelovani/react-vs-handlebars-choosing-the-right-tool-for-progressively-decoupled-applications-1d421ea4e0fc</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e1301ecde17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React vs. Handlebars: Choosing the Right Tool for Progressively Decoupled Applications]]></title>
            <link>https://medium.com/@marcelovani/react-vs-handlebars-choosing-the-right-tool-for-progressively-decoupled-applications-1d421ea4e0fc?source=rss-770d5b03ad6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d421ea4e0fc</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[handlebars]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[decoupled]]></category>
            <dc:creator><![CDATA[Marcelo Vani]]></dc:creator>
            <pubDate>Sat, 23 Mar 2024 13:06:03 GMT</pubDate>
            <atom:updated>2024-03-23T13:06:03.717Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZG9hwXk0mSvU4hHey_axtQ.png" /></figure><p>In the rapidly evolving world of web development, the choice of technology can have significant implications on both the immediacy of development and the scalability of the application. For teams working on progressively decoupled applications, where backend and frontend developers often collaborate to deliver a seamless user experience, choosing between a JavaScript library like React and a templating engine like Handlebars.js is pivotal. In this article, we compare React and Handlebars, detailing their respective pros and cons, to help guide you in selecting the most suitable tool for your next web project.</p><p>React and Handlebars.js are tools used for building user interfaces but they serve somewhat different purposes and follow different philosophies. Below you will find a comparison of their pros and cons.</p><h3>What is Progressive Decoupling?</h3><p>Progressive decoupling is an architectural strategy that allows developers to take advantage of both a CMS-based backend and a modern JavaScript frontend. In this approach, the initial render comes from the server while interactive enhancements are done on the client side through JavaScript libraries or frameworks. This combines the SEO and performance benefits of server-rendered content with the rich user experience provided by client-side interactions.</p><h3>React: The Declarative Powerhouse</h3><p>React is a library developed and maintained by Facebook. React’s component-based architecture is designed from the ground up for building interactive user interfaces. React focuses on creating reusable components, self-contained pieces of code that represent a part of the user interface.</p><p>These components manage their own state, which is essentially the data that determines how they look and behave at any given moment. React’s declarative nature allows developers to describe their UIs in terms of these components, and when the state of a component changes, React automatically updates the component in the browser.</p><p>This means you can create complex interfaces that respond to user input in real time, without having to manually manipulate the Document Object Model (DOM), leading to more efficient and easier to maintain code. Additionally, React introduces JSX, a syntax extension that allows developers to write their templates with a syntax that closely resembles HTML, making the transition for those with a background in HTML much smoother.</p><h3>Pros</h3><ul><li>Declarative components: React simplifies the development process through reusable components that manage their own state, creating a clear structure for complex applications.</li><li>Virtual DOM: By minimizing direct DOM manipulation, React’s virtual DOM mechanism offers a performance edge for dynamic, high-volume applications.</li><li>Server-Side Rendering Support: React supports server-side rendering, which can improve the initial load performance of web applications and help with SEO.</li><li>Modern Hook System: React’s hooks API allows for more reusable stateful logic and side effects in functional components, leading to cleaner and less error-prone code.</li><li>Rich Set of Additional Libraries: The React ecosystem includes state management libraries (such as Redux, MobX), routing solutions (React Router), form handling libraries (Formik, react-hook-form), and many others designed to work seamlessly with React.</li><li>Rich ecosystem: Developers are spoilt for choice with a multitude of libraries and tools that fit into the React ecosystem for state management, routing, and more.</li><li>Community and support: The large React community provides a wealth of resources, making solutions to common problems readily accessible.</li></ul><h3>Cons</h3><ul><li>Steeper learning curve: React’s rich feature set comes with increased complexity that can be daunting for beginners.</li><li>Boilerplate: More boilerplate code when compared to simple template engines.</li><li>Overengineering risk: For simple projects React might be an overkill, leading to unnecessary complexity and overhead.</li><li>Bundle Size: React’s library size adds more overhead to a project compared to a lightweight template library like Handlebars.</li><li>Compilation: React’s reliance on build tools like Webpack, coupled with the need to compile JSX to JavaScript, introduces an additional level of complexity to the development process.</li></ul><h3>Handlebars.js: Templating Simplified</h3><p>Handlebars.js is an extension of the Mustache templating language, designed to maintain a clear separation between the logic and presentation layers. This is particularly beneficial for backend developers who want to generate HTML with minimal fuss.</p><p>Handlebars.js is known for its simplicity and ease of use in creating semantic templates. However, one of its most powerful features is the ability to extend the templating language’s functionality with custom helpers. Custom helpers are essentially JavaScript functions that you can write and then call within your Handlebars templates. They enable you to create reusable pieces of logic that can transform data, perform calculations, or even interact with other parts of your template.</p><p>The use of custom helpers in Handlebars promotes DRY (Don’t Repeat Yourself) principles by allowing developers to avoid repetitive coding patterns and encourages cleaner template structures. For example, you might write a custom helper to format dates, localize strings, or handle complex conditional logic that would be cumbersome to implement directly within the template. By registering these helpers, you can then use them in any of your templates, just like built-in Handlebars expressions.</p><p>This extensibility aspect caters to more sophisticated templating needs while preserving Handlebars.js’s core principle of keeping templates logic-less. Custom helpers thereby offer a bridge between the ease of Handlebars template syntax and the necessity for dynamic content generation, giving developers the tools to create rich, expressive, and maintainable views.</p><h3>Pros</h3><ul><li>Ease of use: With a syntax close to Twig, Handlebars is approachable for backend Drupal developers.</li><li>Flexibility: It can effortlessly fit into any tech stack and work alongside various frameworks.</li><li>Lightweight: Without the overhead of complex client-side features, Handlebars offers a performant solution for straightforward rendering jobs. Great for small and simple projects.</li><li>Fast Server-side Rendering: Handlebars templates compile into highly optimized functions that can quickly generate HTML from JSON-like data.</li><li>Zero Dependencies: Handlebars has no dependencies, making it lightweight and easy to drop into any project without worrying about other packages.</li><li>Extensibility: Developers can write their own helpers that can be used within the templates, offering some scripting power within the language constraints.</li></ul><h3>Cons</h3><ul><li>No Reactive Data Binding: Unlike frameworks like React, Handlebars doesn’t automatically update the DOM when the underlying data changes. You have to manually rerender the template with the new data.</li><li>No state management: Real-time updates are not inherent to Handlebars, making it less suitable for applications with complex stateful interactions.</li></ul><h3>Making the Choice</h3><p>For Drupal backend developers looking to gracefully enhance their server-rendered applications, Handlebars.js serves as a straightforward choice that stays out of the way, executing one job and doing it well. This aligns it perfectly with the idea of progressive decoupling, where simple, static parts of the application can be managed server-side, and Handlebars can be used to template these efficiently.</p><p>Transitioning from Twig to Handlebars templates can be a surprisingly seamless and engaging experience for developers. One of the delightful aspects of this switch lies in the effortless compatibility with your existing styling. Since both templating engines output pure HTML, the transition does not require any changes to your carefully crafted CSS stylesheets. This means that the visual continuity of your application remains intact — your user interface’s look and feel will retain the same flair and polish that it had with Twig.</p><p>Moreover, the intuitive nature of converting between these two templating languages allows for a smooth adaptation process. Developers can often find parallels in syntax and structure that make the conversion feel less like a chore and more like piecing together a familiar puzzle. The markup remains clean and recognizable, and the process can even provide a refreshing opportunity to revisit and potentially refine your templates. As a result, what might initially seem like a daunting task can become an invigorating step forward in evolving your application’s front-end architecture.</p><p>React, with its focus on the frontend, is the tool of choice for client-side interactivity. Its ecosystem provides everything necessary to build a dynamic, single-page application. When more client-side dynamism is required in a progressively decoupled architecture, React and similar libraries shine in enhancing user experience with rich interactivity.</p><p>Therefore, the decision between React and Handlebars.js boils down to the specific needs of your project. For applications that primarily focus on content delivery with some enhancements, Handlebars.js could be the most streamlined choice. However, for products that require rich client-side interactions and state management, React may be the preferable option.</p><p>In a progressively decoupled context, both can coexist — Handlebars templates can quickly scaffold pages server-side, while React components take over areas that demand interactivity, providing a happy medium that leverages the strengths of each.</p><p>Whether you find yourself leaning towards the robustness of React or the simplicity of Handlebars.js, remember that the goal is to serve the users best by delivering an optimal experience. Each tool has its parts to play, and as web technologies continue to evolve, so too should the strategies we deploy in leveraging them for our progressively decoupled applications.</p><p>When considering which tool to integrate with a Drupal backend, it’s crucial to weigh the existing team’s expertise against the potential investment required to expand or upskill the workforce. If the current Drupal team has a strong grasp of Twig and limited experience with React, there may be a steeper learning curve and thus higher initial costs associated with adopting React, potentially involving training or hiring new talent. On the flip side, if the project’s goals align more closely with the interactive capabilities that React affords, the upfront costs in acquiring React expertise could be justified by the long-term benefits and performance enhancements. Each organization must carefully evaluate its priorities, considering both the project requirements and the human resources at hand. The decision should reflect a balance between the cost-effectiveness of leveraging existing skills and the potential return on investment in adopting a more modern but resource-intensive solution like React.</p><h3>Resources</h3><p>Official Documentation</p><ul><li>Visit the <a href="https://handlebarsjs.com/guide/">Handlebars.js documentation</a> for features and guides.</li><li>Explore the <a href="https://reactjs.org/docs/getting-started.html">React documentation</a> for comprehensive tutorials and API references.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d421ea4e0fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extending Behat content creation to write tests that are easier to read and maintain]]></title>
            <link>https://medium.com/@marcelovani/extending-behat-content-creation-to-make-tests-easier-to-read-and-maintain-14f0000c03ab?source=rss-770d5b03ad6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/14f0000c03ab</guid>
            <category><![CDATA[bdd]]></category>
            <category><![CDATA[behat]]></category>
            <category><![CDATA[drupal]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Marcelo Vani]]></dc:creator>
            <pubDate>Sun, 17 Jun 2018 23:00:06 GMT</pubDate>
            <atom:updated>2018-06-18T00:01:49.311Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8YK9TxYVl5iGvfqXTYH3A.png" /></figure><p>This month, the Drupal Show and Tell event will be hosted at Dennis Publishing. Come to see my talk.</p><p>Testing websites using Behat can be a life saver, but writing and maintaining the tests can be very time consuming. Creating content by filling in and submitting forms does the job, but it’s not very productive. If you are constantly amending broken test that use editorial content, you are doing it wrong. There is a better way to create content for testing.</p><p>In this talk you will see a working prototype that creates referenced content for you, using pre-defined content that can be overridden on each scenario.</p><p>This prototype extends the TableNodes functionality, allowing you to write simple and robust tests using only a few lines of plain English and Gherkin, that will run fast and won’t require much maintenance.</p><p>Have a glance:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGSVfyvdC6J4%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGSVfyvdC6J4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGSVfyvdC6J4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/40103fd077f6dd741fde7064e25bf5c8/href">https://medium.com/media/40103fd077f6dd741fde7064e25bf5c8/href</a></iframe><p>Event location and details here <a href="https://www.meetup.com/drupal-show-and-tell/events/251078799/">https://www.meetup.com/drupal-show-and-tell/events/251078799/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14f0000c03ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>