Skip to content

Commit 79b0707

Browse files
committed
Update version and publish package
Signed-off-by: Aivin V. Solatorio <avsolatorio@gmail.com>
1 parent 40c2734 commit 79b0707

25 files changed

Lines changed: 329 additions & 62 deletions

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ PCN enforces numeric fidelity by placing verification in the **renderer**, not t
4343

4444
This monorepo contains the **PCN ecosystem**:
4545

46-
- **TypeScript packages** (`packages/*`) — Published to npm under `@pcn/*`
47-
- `@pcn/core` — Core PCN implementation
48-
- `@pcn/data360` — Data360 preset: Data360ClaimsProvider + extractor for get_data (claim_id/OBS_VALUE/REF_AREA/TIME_PERIOD)
49-
- `@pcn/fixtures` — Shared test fixtures
50-
- `@pcn/ui` — React UI components for verified/pending claims
46+
- **TypeScript packages** (`packages/*`) — Published to npm under `@pcn-js/*`
47+
- `@pcn-js/core` — Core PCN implementation
48+
- `@pcn-js/data360` — Data360 preset: Data360ClaimsProvider + extractor for get_data (claim_id/OBS_VALUE/REF_AREA/TIME_PERIOD)
49+
- `@pcn-js/fixtures` — Shared test fixtures
50+
- `@pcn-js/ui` — React UI components for verified/pending claims
5151

5252
- **Python packages** (`python/*`) — Published to PyPI under `pcn-*`
5353
- `pcn-core` — Core PCN implementation for Python
@@ -110,6 +110,7 @@ PCN is designed for **numerically sensitive settings** where accuracy matters:
110110
Comprehensive documentation is available:
111111

112112
- [Documentation](docs/) — Detailed guides and reference materials
113+
- [Publishing to npm](docs/publishing.md) — How to publish `@pcn/*` so apps can install from npm
113114
- [Policy Reference](docs/reference/policies.md) — Understanding PCN verification policies
114115
- [Contributing Guide](CONTRIBUTING.md) — How to contribute to PCN
115116
- [Code of Conduct](CODE_OF_CONDUCT.md) — Community guidelines

docs/publishing.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Publishing PCN to npm
2+
3+
The PCN monorepo uses [Changesets](https://github.com/changesets/changesets) for versioning and publishing. Packages are published under the scope `@pcn-js/*` (e.g. `@pcn-js/core`, `@pcn-js/ui`, `@pcn-js/data360`, `@pcn-js/fixtures`).
4+
5+
## Prerequisites
6+
7+
- **npm account** — for [public npm](https://www.npmjs.com/) you need an account.
8+
- **Scope / org** — packages use the scope `@pcn-js/*`. You must [create an npm organization](https://www.npmjs.com/org/create) named **`pcn-js`** (same as the scope) **before** the first publish; otherwise publish returns **E404 Not Found**. If that name is not available, use an [alternative scope](#organization-name-not-available) (e.g. your user scope or a different org name).
9+
- **Build** — ensure all packages build: from repo root run `pnpm build`.
10+
11+
## Option A: Publish to the public npm registry (registry.npmjs.org)
12+
13+
Use this so any app can install with `npm install @pcn-js/core @pcn-js/ui @pcn-js/data360` (or pnpm/yarn).
14+
15+
1. **Log in to npm** (public registry):
16+
17+
```bash
18+
npm login
19+
# Use your npmjs.com credentials; this targets registry.npmjs.org
20+
```
21+
22+
2. **Add changesets** for the changes you want to release:
23+
24+
```bash
25+
pnpm changeset
26+
# Follow prompts: select packages, choose bump type (major/minor/patch), add summary
27+
```
28+
29+
3. **Version packages** (updates `package.json` versions and CHANGELOGs):
30+
31+
```bash
32+
pnpm version-packages
33+
```
34+
35+
4. **Publish** to the public registry. Override the registry so publish goes to npm (not your `.npmrc` default, e.g. Artifactory):
36+
37+
```bash
38+
npm config set registry https://registry.npmjs.org/
39+
pnpm release
40+
npm config delete registry # optional: restore previous default
41+
```
42+
43+
Or in one go without changing global config:
44+
45+
```bash
46+
npm publish -w @pcn-js/core --registry https://registry.npmjs.org/
47+
npm publish -w @pcn-js/ui --registry https://registry.npmjs.org/
48+
npm publish -w @pcn-js/data360 --registry https://registry.npmjs.org/
49+
npm publish -w @pcn-js/fixtures --registry https://registry.npmjs.org/
50+
```
51+
52+
With Changesets, the usual flow is `pnpm release`, which runs `changeset publish` (and will use whatever registry is currently configured). So set registry to `https://registry.npmjs.org/` before `pnpm release` when publishing to public npm.
53+
54+
5. **Commit and push** the version bumps and changelogs (and tag if your CI does it):
55+
56+
```bash
57+
git add . && git commit -m "chore: release @pcn-js/*" && git push
58+
```
59+
60+
## Option B: Publish to an internal registry (e.g. Artifactory)
61+
62+
If your repo `.npmrc` points to an internal registry (e.g. Artifactory), you can publish there so internal apps can install `@pcn-js/*` from that registry.
63+
64+
1. **Authenticate** to the internal registry (e.g. `npm login` against Artifactory, or use `.npmrc` with `_auth` as already configured).
65+
66+
2. **Add changesets** and **version** as above:
67+
68+
```bash
69+
pnpm changeset
70+
pnpm version-packages
71+
```
72+
73+
3. **Publish** (uses registry from `.npmrc`):
74+
75+
```bash
76+
pnpm release
77+
```
78+
79+
4. **Commit and push** version and changelog updates.
80+
81+
## Installing in an app after publishing
82+
83+
- **From public npm:**
84+
In the app (e.g. vercel-ai-chatbot frontend), replace `file:` links with version ranges:
85+
86+
```json
87+
{
88+
"dependencies": {
89+
"@pcn-js/core": "^0.1.0",
90+
"@pcn-js/ui": "^0.1.0",
91+
"@pcn-js/data360": "^0.1.0"
92+
}
93+
}
94+
```
95+
96+
Then run `pnpm install` (or `npm install`). Remove any `pnpm.overrides` that pointed at `file:../../pcn/...` for these packages.
97+
98+
- **From internal registry:**
99+
Ensure the app’s npm/pnpm config uses the same registry and auth; then use the same version ranges and install as above.
100+
101+
## Summary
102+
103+
| Step | Command |
104+
| ------------------ | ---------------------------------------------- |
105+
| Add changesets | `pnpm changeset` |
106+
| Bump versions | `pnpm version-packages` |
107+
| Publish (public) | Set registry to npmjs.org, then `pnpm release` |
108+
| Publish (internal) | `pnpm release` (with registry in `.npmrc`) |
109+
110+
Each package has `"publishConfig": { "access": "public" }` so the scoped packages `@pcn-js/*` are published as public when the target registry supports it (e.g. npm).
111+
112+
## Troubleshooting (public npm)
113+
114+
### E403: Two-factor authentication or granular access token required
115+
116+
npm requires one of the following to publish:
117+
118+
1. **Enable 2FA on your npm account** (recommended):
119+
- Go to [npm → Account Settings → Two-Factor Authentication](https://www.npmjs.com/settings/~yourusername/account)
120+
- Turn on “Require two-factor authentication for writes (publishing)”
121+
- Run `npm login` again; npm will prompt for your OTP when you publish.
122+
123+
2. **Use a granular access token with publish and “bypass 2FA”** (for CI or headless use):
124+
- Go to [npm → Access Tokens](https://www.npmjs.com/settings/~yourusername/tokens)
125+
- Create token → “Granular access token”
126+
- Set permissions: **Packages and scopes** → Read and write for `@pcn-js` (or your scope)
127+
- Enable “Bypass two-factor authentication when publishing from the command line”
128+
- Use the token when logging in: `npm login --auth-type=legacy` and paste the token as the password (username can be your npm username or `_authToken`-style usage), or set in `.npmrc`:
129+
`//registry.npmjs.org/:_authToken=YOUR_TOKEN`
130+
131+
After changing 2FA or creating a token, run **`npm login`** again (with registry set to `https://registry.npmjs.org/` if needed), then retry `pnpm release`.
132+
133+
### E404: Not Found when publishing @pcn-js/*
134+
135+
If you see **404 Not Found - PUT https://registry.npmjs.org/@pcn-js%2f...** or "The requested resource '@pcn-js/...' could not be found or you do not have permission":
136+
137+
- The scope `@pcn-js` must exist on npm. [Create an organization](https://www.npmjs.com/org/create) named **`pcn-js`** (same as the scope). Until the org exists, npm returns 404 for PUT.
138+
- Ensure you're logged in (`npm login` with registry `https://registry.npmjs.org/`) with the account that owns that org (or is a member with publish rights).
139+
140+
### Organization name not available
141+
142+
If the organization name **pcn** is not available on npm, you can publish under a different scope:
143+
144+
1. **User scope (no org needed)** — Use your npm username. For example, if your username is `avsolatorio`, rename packages to `@avsolatorio/pcn-core`, `@avsolatorio/pcn-ui`, `@avsolatorio/pcn-data360`, `@avsolatorio/pcn-fixtures`. You can publish under your user scope without creating an organization.
145+
2. **Different org name** — Create an organization with another name (e.g. `pcn-js`, `proof-carrying-numbers`) and use that as the scope: `@pcn-js/core`, `@pcn-js/ui`, etc.
146+
3. **Unscoped packages** — Publish without a scope: `pcn-core`, `pcn-ui`, `pcn-data360`, `pcn-fixtures`. Install with `npm install pcn-core pcn-ui pcn-data360`. Unscoped names must be globally unique on npm.
147+
148+
To switch scope, update the `name` field in each package's `package.json`, update internal references (e.g. `@pcn-js/core``@yourscope/core` in dependencies), and update any docs or app `package.json` that install these packages.
149+
150+
### One-time password (OTP) when 2FA is enabled
151+
152+
If you see **"This operation requires a one-time password from your authenticator"**:
153+
154+
- npm is asking for your 2FA code. Run `pnpm release` in an **interactive** terminal and enter the 6-digit code from your authenticator when prompted.
155+
- If the prompt doesn't appear (e.g. in a non-interactive or CI environment), pass the OTP for that run:
156+
`NPM_CONFIG_OTP=123456 pnpm release`
157+
(Replace `123456` with the current code; it changes every ~30 seconds.)
158+
159+
### Access token expired or revoked
160+
161+
If you see “Access token expired or revoked. Please try logging in again”:
162+
163+
- Run `npm login` (with registry `https://registry.npmjs.org/`).
164+
- If you use a token in `.npmrc`, generate a new token at [npm Access Tokens](https://www.npmjs.com/settings/~yourusername/tokens) and update the value.

examples/chat-app/CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# pcn-example-chat-app
2+
3+
## 0.0.2
4+
5+
### Patch Changes
6+
7+
- Updated dependencies
8+
- @pcn-js/data360@0.1.1
9+
- @pcn-js/core@0.1.1
10+
- @pcn-js/ui@0.1.1
11+
12+
## 0.0.1
13+
14+
### Patch Changes
15+
16+
- Updated dependencies
17+
- @pcn-js/data360@0.1.1
18+
- @pcn-js/core@0.1.1
19+
- @pcn-js/ui@0.1.1

examples/chat-app/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pcn-example-chat-app",
3-
"version": "0.0.0",
3+
"version": "0.0.2",
44
"private": true,
55
"type": "module",
66
"scripts": {
@@ -10,9 +10,9 @@
1010
"typecheck": "tsc -p tsconfig.json --noEmit"
1111
},
1212
"dependencies": {
13-
"@pcn/core": "workspace:*",
14-
"@pcn/data360": "workspace:*",
15-
"@pcn/ui": "workspace:*",
13+
"@pcn-js/core": "workspace:*",
14+
"@pcn-js/data360": "workspace:*",
15+
"@pcn-js/ui": "workspace:*",
1616
"react": "^18.3.0",
1717
"react-dom": "^18.3.0"
1818
},

examples/chat-app/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Data360ClaimsProvider, DATA360_GET_DATA_TOOL } from "@pcn/data360";
2-
import { IngestToolOutput } from "@pcn/ui";
1+
import { Data360ClaimsProvider, DATA360_GET_DATA_TOOL } from "@pcn-js/data360";
2+
import { IngestToolOutput } from "@pcn-js/ui";
33
import { MessageWithClaims } from "./MessageWithClaims";
44

55
/** Simulated Data360 get_data tool result. */

examples/chat-app/src/MessageWithClaims.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ClaimMark } from "@pcn/ui";
1+
import { ClaimMark } from "@pcn-js/ui";
22

33
/**
44
* Renders a simple "assistant" message that contains numeric claims.

packages/core/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# @pcn-js/core
2+
3+
## 0.1.1
4+
5+
### Patch Changes
6+
7+
- First public release of the Proof-Carrying Numbers (PCN) SDK.
8+
9+
## 0.1.1
10+
11+
### Patch Changes
12+
13+
- First public release of the Proof-Carrying Numbers (PCN) SDK.

packages/core/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @pcn/core
1+
# @pcn-js/core
22

33
Core PCN implementation: verification engine, claims manager, and HTML processing.
44

@@ -7,7 +7,7 @@ Core PCN implementation: verification engine, claims manager, and HTML processin
77
Central cache and lookup for claims. Register claims by id (e.g. from tool results that include `claim_id`), then use `get`/`getAll` when processing content or with `@pcn/ui` components.
88

99
```ts
10-
import { ClaimsManager, createDataPointExtractor } from "@pcn/core";
10+
import { ClaimsManager, createDataPointExtractor } from "@pcn-js/core";
1111

1212
const manager = new ClaimsManager();
1313

packages/core/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "@pcn/core",
3-
"version": "0.1.0",
2+
"name": "@pcn-js/core",
3+
"version": "0.1.1",
44
"description": "Proof-Carrying Numbers (PCN): core engine for verifying numeric claims and annotating HTML <claim> tags.",
55
"license": "Apache-2.0",
66
"type": "module",
@@ -19,6 +19,9 @@
1919
"README.md",
2020
"LICENSE"
2121
],
22+
"publishConfig": {
23+
"access": "public"
24+
},
2225
"sideEffects": false,
2326
"dependencies": {
2427
"cheerio": "^1.1.2",

packages/data360/CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# @pcn-js/data360
2+
3+
## 0.1.1
4+
5+
### Patch Changes
6+
7+
- First public release of the Proof-Carrying Numbers (PCN) SDK.
8+
- Updated dependencies
9+
- @pcn-js/core@0.1.1
10+
- @pcn-js/ui@0.1.1
11+
12+
## 0.1.1
13+
14+
### Patch Changes
15+
16+
- First public release of the Proof-Carrying Numbers (PCN) SDK.
17+
- Updated dependencies
18+
- @pcn-js/core@0.1.1
19+
- @pcn-js/ui@0.1.1

0 commit comments

Comments
 (0)