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
+62-9Lines changed: 62 additions & 9 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.
@@ -754,13 +789,30 @@ You need to either:
754
789
755
790
### Testing connector features
756
791
757
-
Features that require authentication through the local connector (org management, package collaborators, operations queue) are tested using a mock connector server. The testing infrastructure includes:
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.
758
810
759
-
**For Vitest component tests** (`test/nuxt/`):
811
+
####Vitest component tests (`test/nuxt/`)
760
812
761
813
- Mock the `useConnector` composable with reactive state
762
814
- Use `document.body` queries for components using Teleport
763
-
- See `test/nuxt/components/ConnectorModal.spec.ts` for an example
815
+
- See `test/nuxt/components/HeaderConnectorModal.spec.ts` for an example
0 commit comments