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
The connector will check your npm authentication, generate a connection token, and listen for requests from npmx.dev.
157
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
+
158
195
## Code style
159
196
160
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.
@@ -379,7 +416,7 @@ npmx.dev uses [@nuxtjs/i18n](https://i18n.nuxtjs.org/) for internationalization.
379
416
- All user-facing strings should use translation keys via `$t()` in templates and script
380
417
- Translation files live in [`i18n/locales/`](i18n/locales) (e.g., `en-US.json`)
381
418
- We use the `no_prefix` strategy (no `/en-US/` or `/fr-FR/` in URLs)
382
-
- Locale preference is stored in cookies and respected on subsequent visits
419
+
- Locale preference is stored in `localStorage` and respected on subsequent visits
This requires Chrome or Chromium to be installed. The script will auto-detect common installation paths. Results are printed to the terminal and saved in `.lighthouseci/`.
|`.lighthouserc.cjs`| Lighthouse CI config (URLs, assertions, Chrome path) |
691
+
|`lighthouse-setup.cjs`| Puppeteer script for color mode + client-side API mocking |
692
+
|`scripts/lighthouse.sh`| Shell wrapper that runs the audit for a given color mode |
693
+
694
+
### Lighthouse performance tests
695
+
696
+
The project also runs Lighthouse performance audits to enforce zero Cumulative Layout Shift (CLS). These run separately from the accessibility audits and test the same set of URLs.
697
+
698
+
#### How it works
699
+
700
+
The same `.lighthouserc.cjs` config is shared between accessibility and performance audits. When the `LH_PERF` environment variable is set, the config switches from the `accessibility` category to the `performance` category and asserts that CLS is exactly 0.
701
+
702
+
#### Running locally
703
+
704
+
```bash
705
+
# Build + run performance audit
706
+
pnpm test:perf
707
+
708
+
# Or against an existing test build
709
+
pnpm test:perf:prebuilt
710
+
```
711
+
712
+
Unlike the accessibility audits, performance audits do not run in separate light/dark modes.
656
713
657
714
### End to end tests
658
715
@@ -730,6 +787,74 @@ You need to either:
730
787
1. Add a fixture file for that package/endpoint
731
788
2. Update the mock handlers in `test/fixtures/mock-routes.cjs` (client) or `modules/runtime/server/cache.ts` (server)
732
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
Where front end changes are made, please include before and after screenshots in your pull request description.
896
+
770
897
> [!NOTE]
771
-
> The subject must start with a lowercase letter. Individual commit messages within your PR don't need to follow this format since they'll be squashed.
898
+
> Use lowercase letters in your pull request title. Individual commit messages within your PR don't need to follow this format since they'll be squashed.
> 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