# The Smallest Strutvane Package: Why npx strutvane Is a Guard, Not an Installer

Typing `npx something` is a small act of trust.

You're asking npm to find a package called "something" and run it on your machine, often without a second thought. That's convenient. It's also exactly how mistakes happen: a typo in a name, a package that downloads more than you expected, or a script someone left lying around in a shared folder that gets picked up and executed.

`npx strutvane` could have been a clever tool that does a lot. Instead, it's the **safest possible thing**: a guard that does one job and refuses everything else. 🛡️

---

## What it is

`strutvane` is the tiny package behind **`npx strutvane`**, for apps built on Strutvane, an open-source (MIT) TypeScript framework for business (B2B) apps.

Inside a Strutvane app, these two commands do exactly the same thing:

```text
node strut migrate
npx strutvane migrate
```

`npx strutvane <command>` finds your project and runs its own `strut.js` with your arguments, using the `@strutvane/framework` version **your project already has installed**. Outside a project, there's nothing to run, so it simply tells you how to create one.

That's it. That's the whole package.

## Why it exists

Strutvane apps have a project command, `node strut`, that runs migrations, seeders, the dev server and more. It's always the right version, because it comes from the framework installed in your project.

But people naturally reach for `npx <framework name>`. If that name did something different from `node strut` (say, ran a different copy of the framework), you'd get two tools that disagree about your own project.

So `npx strutvane` exists to make the natural thing **the same thing**: it runs exactly what `node strut` runs, with your project's own framework, and never a second copy. What you get always matches your `package.json`.

## What you get

**Inside a project**, every argument goes to your project, `--version` and `help` included, just like `node strut`.

**Outside a project**, it only prints:

| You type | What happens | Exit code |
|---|---|---|
| `npx strutvane`, `help`, `--help`, `-h` | Prints help and how to create a project | 0 |
| `npx strutvane --version`, `-v` | Prints this package's version | 0 |
| `npx strutvane new my-app` (or `create`, `init`) | Prints the `npm create strutvane` command to run | 2 |
| Anything else | Explains that the command needs a project | 2 |

For example:

```text
$ npx strutvane
No Strutvane project was found in /home/ana or the folders above it.

Create a new app:
  npm create strutvane@latest my-app
```

## How it finds your project

Starting from the folder you're in, it looks **upwards** for the nearest folder that has a `strut.js` or a `package.json` listing `@strutvane/framework`. That folder is your project only if its `package.json` really lists `@strutvane/framework`. The command then runs from the project folder, just as `node strut` does.

In a project without a `strut.js`, it runs the `strutvane` program of the installed `@strutvane/framework` instead, which is what `strut.js` itself runs for framework commands.

## Safe by design

This is where the "guard" part comes in. It runs **only your project's own code, and only after checking it**:

- **Never installs or downloads anything.** It has **zero dependencies**, and outside a project it only prints text.
- **Never looks too far up.** The search stops at your home folder, the temp folder and drive roots. So a `strut.js` someone left in a shared folder *above* you is never run. On Linux and macOS, the project folder must also belong to you.
- **A `strut.js` alone isn't enough.** If the nearest one sits in a folder whose `package.json` doesn't list `@strutvane/framework`, nothing runs, and you're told why.
- **Nothing outside the project runs.** It refuses a project folder that is a link (and shows you the real folder to open instead), a `strut.js` that is a link, and a framework install whose real location is outside the project.
- **No shell.** Your arguments go to Node as a list, so things like `a&b`, `$(x)` or `%PATH%` arrive as plain text on every platform. They can't be interpreted as shell commands, and `--import=...` stays an argument for your command, never a Node option.
- **Exit codes and signals pass through.** Your command's exit code comes back unchanged. If it's stopped by a signal, `strutvane` stops with the same signal (on Windows, with exit code 128 + n). Ctrl+C at a terminal is never sent twice.

When it refuses, it exits with code 1 and **tells you how to fix it**. A refusal should always come with a next step.

## How it fits into Strutvane

`strutvane` is the front door, and it's intentionally small:

- **`npm create strutvane`** creates a new app.
- **`node strut <command>`** (or `npx strutvane <command>`) runs commands inside it, powered by `@strutvane/framework`.
- Everything else (auth, the admin UI, designs, add-ons) is installed into the project and run by the project's own framework.

The guard never competes with the framework. It just hands over to it, after making sure it's handing over to the right one.

## A quick look

There's nothing to install. You use it through `npx` only:

```bash
npx strutvane migrate
npx strutvane --version
```

**Please don't add it to your project as a dependency.** A Strutvane app already has the `strutvane` program, from `@strutvane/framework`. Adding this package too would put two owners on the same command, and `node strut doctor` will point that out.

Requirements: Node.js 24.3 or newer.

> ⚠️ This is a **0.2 preview**. Behaviour may still change before 1.0, planned for January 2027. While Strutvane is in pre-release, the "create a new app" hint may show `@next` instead of `@latest`.

## Built to be trusted

A package this small still gets the full treatment:

- **116 automated tests** for a tool whose whole job is saying "yes, this is your project" or "no, it isn't".
- **CI on Linux, Windows and macOS**, on Node 24 and Node 26. Path handling, links and signals behave differently on each, which is exactly why all three matter.
- **Security-reviewed** and secure by default.
- **Every release is staged by CI and approved by a human with two-factor authentication**, and published with **npm provenance**, so you can check that what `npx` downloads was built from this repository.

## The lesson I took from it

The smallest package in the ecosystem taught me the biggest lesson: **a tool that runs other code should be boring, strict and honest.** It should do less than you expect, refuse loudly, and always say why. Every clever feature you add to a launcher is another way to run the wrong thing.

---

## Try it, and tell me what you think

- ⭐ **GitHub:** [github.com/vishwajit-vm/strutvane-npx](https://github.com/vishwajit-vm/strutvane-npx)
- 📦 **npm:** [npmjs.com/package/strutvane](https://www.npmjs.com/package/strutvane)
- 💬 **Feedback welcome.** Can you think of a way a launcher like this could run the wrong thing? I genuinely want to hear it. (If it's a real security issue, please report it privately rather than in a public issue.)

That's the last of the nine live packages. Follow the series for what comes next: the full demo app, then queues, mail and notifications in 0.3. 🚀

*— Vishwajit VM*

---

*Part of the Strutvane series. Strutvane™ is open source under the MIT licence.*
