You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+103Lines changed: 103 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,7 @@ This focus helps guide our project decisions as a community and what we choose t
33
33
-[Available commands](#available-commands)
34
34
-[Project structure](#project-structure)
35
35
-[Local connector CLI](#local-connector-cli)
36
+
-[Mock connector (for local development)](#mock-connector-for-local-development)
36
37
-[Code style](#code-style)
37
38
-[TypeScript](#typescript)
38
39
-[Server API patterns](#server-api-patterns)
@@ -104,6 +105,10 @@ pnpm dev # Start development server
104
105
pnpm build # Production build
105
106
pnpm preview # Preview production build
106
107
108
+
# Connector
109
+
pnpm npmx-connector # Start the real connector (requires npm login)
110
+
pnpm mock-connector # Start the mock connector (no npm login needed)
111
+
107
112
# Code Quality
108
113
pnpm lint # Run linter (oxlint + oxfmt)
109
114
pnpm lint:fix # Auto-fix lint issues
@@ -157,6 +162,36 @@ pnpm npmx-connector
157
162
158
163
The connector will check your npm authentication, generate a connection token, and listen for requests from npmx.dev.
159
164
165
+
### Mock connector (for local development)
166
+
167
+
If you're working on admin features (org management, package access controls, operations queue) and don't want to use your real npm account, you can run the mock connector instead:
168
+
169
+
```bash
170
+
pnpm mock-connector
171
+
```
172
+
173
+
This starts a mock connector server pre-populated with sample data (orgs, teams, members, packages). No npm login is required — operations succeed immediately without making real npm CLI calls.
174
+
175
+
The mock connector prints a connection URL to the terminal, just like the real connector. Click it (or paste the token manually) to connect the UI.
176
+
177
+
**Options:**
178
+
179
+
```bash
180
+
pnpm mock-connector # default: port 31415, user "mock-user", sample data
181
+
pnpm mock-connector --port 9999 # custom port
182
+
pnpm mock-connector --user alice # custom username
183
+
pnpm mock-connector --empty # start with no pre-populated data
184
+
```
185
+
186
+
**Default sample data:**
187
+
188
+
-**@nuxt**: 4 members (mock-user, danielroe, pi0, antfu), 3 teams (core, docs, triage)
189
+
-**@unjs**: 2 members (mock-user, pi0), 1 team (maintainers)
190
+
-**Packages**: @nuxt/kit, @nuxt/schema, @unjs/nitro with team-based access controls
191
+
192
+
> [!TIP]
193
+
> Run `pnpm dev` in a separate terminal to start the Nuxt dev server, then click the connection URL from the mock connector to connect.
194
+
160
195
## Code style
161
196
162
197
When committing changes, try to keep an eye out for unintended formatting updates. These can make a pull request look noisier than it really is and slow down the review process. Sometimes IDEs automatically reformat files on save, which can unintentionally introduce extra changes.
@@ -752,6 +787,74 @@ You need to either:
752
787
1. Add a fixture file for that package/endpoint
753
788
2. Update the mock handlers in `test/fixtures/mock-routes.cjs` (client) or `modules/runtime/server/cache.ts` (server)
754
789
790
+
### Testing connector features
791
+
792
+
Features that require authentication through the local connector (org management, package collaborators, operations queue) are tested using a mock connector server.
793
+
794
+
#### Architecture
795
+
796
+
The mock connector infrastructure is shared between the CLI, E2E tests, and Vitest component tests:
797
+
798
+
```
799
+
cli/src/
800
+
├── types.ts # ConnectorEndpoints contract (shared by real + mock)
├── mock-app.ts # H3 mock app + MockConnectorServer class
803
+
└── mock-server.ts # CLI entry point (pnpm mock-connector)
804
+
805
+
test/test-utils/ # Re-exports from cli/src/ for test convenience
806
+
test/e2e/helpers/ # E2E-specific wrappers (fixtures, global setup)
807
+
```
808
+
809
+
Both the real server (`cli/src/server.ts`) and the mock server (`cli/src/mock-app.ts`) conform to the `ConnectorEndpoints` interface defined in `cli/src/types.ts`. This ensures the API contract is enforced by TypeScript. When adding a new endpoint, update `ConnectorEndpoints` first, then implement it in both servers.
810
+
811
+
#### Vitest component tests (`test/nuxt/`)
812
+
813
+
- Mock the `useConnector` composable with reactive state
814
+
- Use `document.body` queries for components using Teleport
815
+
- See `test/nuxt/components/HeaderConnectorModal.spec.ts` for an example
> Want automatic redirects? Try the [npmx-replace browser extension](https://github.com/tylersayshi/npmx-replace-extension) (Chrome only for now).
119
+
> Want automatic redirects? Try the [npmx-replace browser extension](https://github.com/tylersayshi/npmx-replace-extension) (Chrome only for now) or the separate [npmx-redirect extension](https://github.com/iaverages/npmx-redirect) for [Chrome](https://chromewebstore.google.com/detail/lbhjgfgpnlihfmobnohoipeljollhlnb) / [Firefox](https://addons.mozilla.org/en-GB/firefox/addon/npmx-redirect/).
120
120
121
121
#### Not yet supported
122
122
@@ -159,6 +159,7 @@ We welcome contributions – please do feel free to explore the project and
159
159
-[nxjt](https://nxjt.netlify.app)– npmx Jump To: Quickly navigate to npmx common webpages.
160
160
-[npmx-weekly](https://npmx-weekly.trueberryless.org/)– A weekly newsletter for the npmx ecosystem. Add your own content via suggestions in the weekly PR on [GitHub](https://github.com/trueberryless-org/npmx-weekly/pulls?q=is%3Aopen+is%3Apr+label%3A%22%F0%9F%95%94+weekly+post%22).
161
161
-[npmx-digest](https://npmx-digest.trueberryless.org/)– An automated news aggregation website that summarizes npmx activity from GitHub and Bluesky every 8 hours.
162
+
-[npmx-redirect](https://github.com/iaverages/npmx-redirect)– Browser extension that automatically redirects npmjs.com URLs to npmx.dev.
0 commit comments