@xirconsss/zero-mock 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +27 -7
  2. package/package.json +2 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
4
4
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.8-blue?logo=typescript&logoColor=white)](tsconfig.json)
5
- [![npm version](https://img.shields.io/npm/v/@xircons/zero-mock.svg)](https://www.npmjs.com/package/@xircons/zero-mock)
5
+ [![npm version](https://img.shields.io/npm/v/@xirconsss/zero-mock.svg)](https://www.npmjs.com/package/@xirconsss/zero-mock)
6
6
 
7
7
  **zero-mock** is a zero-config Node.js CLI that turns a JSON file into a local REST API. Point it at a file whose top-level keys are **collection names** and whose values are **arrays of records**—it serves full CRUD routes and writes changes back to disk. Built for **frontend developers** who need a quick, realistic backend for prototypes, demos, and integration tests without standing up a database or bespoke server.
8
8
 
@@ -11,7 +11,7 @@
11
11
  ### Global
12
12
 
13
13
  ```bash
14
- npm install -g @xircons/zero-mock
14
+ npm install -g @xirconsss/zero-mock
15
15
  ```
16
16
 
17
17
  Run the CLI as **`zero-mock`** (see [Usage](#usage)).
@@ -19,17 +19,17 @@ Run the CLI as **`zero-mock`** (see [Usage](#usage)).
19
19
  ### One-off with npx
20
20
 
21
21
  ```bash
22
- npx @xircons/zero-mock -f ./data.json -p 3000
22
+ npx @xirconsss/zero-mock -f ./data.json -p 3000
23
23
  ```
24
24
 
25
- Flags: **`-f`** / **`--file`** (required JSON path), **`-p`** / **`--port`** (optional, default `3000`). If your shell or npm version forwards extra flags to npm instead of the CLI, insert **`--`** before **`-f`** (e.g. `npx @xircons/zero-mock -- -f ./data.json`).
25
+ Flags: **`-f`** / **`--file`** (required JSON path), **`-p`** / **`--port`** (optional, default `3000`). If your shell or npm version forwards extra flags to npm instead of the CLI, insert **`--`** before **`-f`** (e.g. `npx @xirconsss/zero-mock -- -f ./data.json`).
26
26
 
27
27
  ## Quick start
28
28
 
29
29
  From the repo root (or any directory containing the example file):
30
30
 
31
31
  ```bash
32
- npx @xircons/zero-mock -f ./example/db.json -p 3000
32
+ npx @xirconsss/zero-mock -f ./example/db.json -p 3000
33
33
  ```
34
34
 
35
35
  In another terminal:
@@ -41,6 +41,10 @@ curl http://localhost:3000/users/1
41
41
 
42
42
  The server logs the exact URLs for each collection when it starts.
43
43
 
44
+ ## Development
45
+
46
+ From a clone: `npm install`, then `npm run build` (or `npm run dev` with `ts-node`). Run the built CLI with `node dist/index.js -f ./example/db.json -p 3000`.
47
+
44
48
  ## Features
45
49
 
46
50
  - **Zero-config** — one JSON file defines your API surface; no schemas or generators to run.
@@ -67,10 +71,26 @@ Invalid JSON bodies (non-objects for write routes) receive **`400`** with a JSON
67
71
 
68
72
  The root must be a JSON **object**. Each property must be an **array** (your “tables”). Each item you want to address by URL should include an **`id`** field (number or string).
69
73
 
70
- ## License
74
+ ## Publishing to npm (maintainers)
75
+
76
+ 1. Use an [npmjs.com](https://www.npmjs.com/) account with **2FA** enabled and permission to publish the **`@xirconsss`** scope (user or org on npm).
77
+ 2. Log in locally: `npm login` (or `npm login --auth-type=web`).
78
+ 3. Install deps and build: `npm install` (so `tsc` is available), then bump **`version`** in `package.json` when releasing.
79
+ 4. Publish: `npm publish` (`publishConfig.access` is already `public` for this scoped package).
80
+
81
+ **GitHub Actions:** the workflow [`.github/workflows/publish-npm.yml`](.github/workflows/publish-npm.yml) runs on **workflow_dispatch** or when a **GitHub Release** is published. It uses the GitHub **Environment** named **`NPM_TOKEN`** with a secret also named **`NPM_TOKEN`** (repo → **Settings** → **Environments** → **NPM_TOKEN** → **Environment secrets**).
71
82
 
72
- MIT see [LICENSE](LICENSE).
83
+ **Token on npm (required):**
84
+
85
+ 1. Create a classic **[Automation](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-classic-tokens)** token, **or** a **[granular access token](https://docs.npmjs.com/creating-and-viewing-access-tokens#creating-granular-access-tokens)** with **read and write** on **`@xirconsss/zero-mock`** (and org **`xirconsss`** if npm asks).
86
+ 2. For granular tokens: turn **Bypass two-factor authentication (2FA)** **on** so CI does not hit **`EOTP`**. Do **not** use **`NPM_OTP`** secrets (codes expire in ~30 seconds).
87
+ 3. Paste the token into the **`NPM_TOKEN`** environment secret on GitHub, then run the workflow.
88
+
89
+ **Optional — OIDC trusted publishing:** You can later move to [npm trusted publishing](https://docs.npmjs.com/trusted-publishers) and drop the secret; if you see **`E404`** on `PUT` with OIDC, the Trusted Publisher settings on npm (repo, workflow filename, environment name) do not match this workflow—token auth avoids that until it is configured correctly.
90
+
91
+ ## License
73
92
 
93
+ MIT - see [LICENSE](LICENSE).
74
94
  ## Links
75
95
 
76
96
  - **Repository:** [github.com/xircons/zero-mock](https://github.com/xircons/zero-mock)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xirconsss/zero-mock",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Zero-config CLI that generates REST APIs from JSON files",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -41,6 +41,7 @@
41
41
  "bugs": {
42
42
  "url": "https://github.com/xircons/zero-mock/issues"
43
43
  },
44
+ "homepage": "https://github.com/xircons/zero-mock#readme",
44
45
  "dependencies": {
45
46
  "commander": "^13.1.0",
46
47
  "cors": "^2.8.5",