Skip to content

Commit d1ca46f

Browse files
authored
Small Edits to npm Publishing Page (#46)
1 parent aea28dd commit d1ca46f

File tree

1 file changed

+51
-44
lines changed

1 file changed

+51
-44
lines changed

fern/products/sdks/overview/typescript/publishing-to-npm.mdx

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
title: Publishing to NPM
3-
description: How to publish the Fern Typescript SDK to npm.
2+
title: Publishing to npm
3+
description: How to publish the Fern TypeScript SDK to npm.
44
---
55

6-
Publish your public-facing Fern Typescript SDK to the [npm
6+
Publish your public-facing Fern TypeScript SDK to the [npm
77
registry](https://www.npmjs.com/). After following the steps on this page,
88
you'll have a versioned package published on npm.
99

1010
<Frame>
11-
<img src="assets/npm-packages.png" alt="Creating NPM Automation Token" />
11+
<img src="assets/npm-packages.png" alt="Versioned package published on npm" />
1212
</Frame>
1313

1414
<Info>This guide assumes that you already have an initialized `fern` folder on your local machine. If you don’t, run `fern init`. See [TypeScript Quickstart](quickstart.mdx) for more details.</Info>
@@ -31,18 +31,17 @@ you'll have a versioned package published on npm.
3131

3232

3333
```bash
34-
fern add fern-typescript-node-sdk --group ts-sdk
34+
fern add fern-typescript-sdk --group ts-sdk
3535
```
3636

3737
Once the command completes, you'll see a new group created in your `generators.yml`:
3838

39-
```yaml {2-7}
39+
```yaml {3-9}
4040
groups:
41-
local:
4241
...
4342
ts-sdk:
4443
generators:
45-
- name: fernapi/fern-typescript-node-sdk
44+
- name: fernapi/fern-typescript-sdk
4645
version: <Markdown src="/snippets/version-number.mdx"/>
4746
output:
4847
location: local-file-system
@@ -55,11 +54,11 @@ you'll have a versioned package published on npm.
5554

5655
Next, change the output location in `generators.yml` from `local-file-system` (the default) to `npm` to indicate that Fern should publish your package directly to the npm registry:
5756

58-
```yaml title="TypeScript" {6-7}
57+
```yaml {6-7}
5958
groups:
6059
ts-sdk:
6160
generators:
62-
- name: fernapi/fern-typescript-node-sdk
61+
- name: fernapi/fern-typescript-sdk
6362
version: <Markdown src="/snippets/version-number.mdx"/>
6463
output:
6564
location: npm
@@ -72,11 +71,11 @@ you'll have a versioned package published on npm.
7271
Your package name must be unique in the npm repository, otherwise publishing your SDK to npm will fail. Update your package name if you haven't done so already:
7372

7473

75-
```yaml title="TypeScript" {8}
74+
```yaml {8}
7675
groups:
7776
ts-sdk:
7877
generators:
79-
- name: fernapi/fern-typescript-node-sdk
78+
- name: fernapi/fern-typescript-sdk
8079
version: <Markdown src="/snippets/version-number.mdx"/>
8180
output:
8281
location: npm
@@ -90,17 +89,17 @@ groups:
9089
The `namespaceExport` option controls the name of the generated client. This is the name customers use to import your SDK (`import { your-client-name } from 'your-package-name';`).
9190

9291

93-
```yaml title="TypeScript" {9-10}
92+
```yaml {9-10}
9493
groups:
9594
ts-sdk:
9695
generators:
97-
- name: fernapi/fern-typescript-node-sdk
96+
- name: fernapi/fern-typescript-sdk
9897
version: <Markdown src="/snippets/version-number.mdx"/>
9998
output:
10099
location: npm
101100
package-name: your-package-name
102101
config:
103-
namespaceExport: YourClientName # must be a valid JavaScript/TypeScript identifier
102+
namespaceExport: YourClientName # must be PascalCase
104103
```
105104
106105
</Step>
@@ -109,19 +108,19 @@ groups:
109108

110109
Add the path to your GitHub repository to `generators.yml`:
111110

112-
```yaml title="TypeScript" {11-12}
111+
```yaml {11-12}
113112
groups:
114-
ts-sdk:
115-
generators:
116-
- name: fernapi/fern-typescript-node-sdk
117-
version: <Markdown src="/snippets/version-number.mdx"/>
118-
output:
119-
location: npm
120-
package-name: your-package-name
121-
config:
122-
namespaceExport: your-client-name
123-
github:
124-
repository: your-org/company-typescript
113+
ts-sdk:
114+
generators:
115+
- name: fernapi/fern-typescript-sdk
116+
version: <Markdown src="/snippets/version-number.mdx"/>
117+
output:
118+
location: npm
119+
package-name: your-package-name
120+
config:
121+
namespaceExport: your-client-name
122+
github:
123+
repository: your-org/company-typescript
125124
```
126125
127126
</Step>
@@ -147,22 +146,23 @@ ts-sdk:
147146

148147
<Step title="Generate Token">
149148

150-
Click on **Generate New Token**, then choose the appropriate token type. For more information on access tokens and which type to choose, see npm's [About access tokens](https://docs.npmjs.com/about-access-tokens) documentation.
149+
Click on **Generate New Token**, then choose the appropriate token type.
150+
151+
<Info>For more information on access tokens and which type to choose, see npm's [About access tokens](https://docs.npmjs.com/about-access-tokens) documentation. </Info>
151152

152153
<AccordionGroup>
153154
<Accordion title="Option 1: Classic Token">
154155

155156
1. Select **Classic Token**
156157
1. Name your token and select **Automation** as the token type.
158+
1. Click **Generate Token**.
159+
160+
<Warning>Save your new token – it won’t be displayed after you leave the page.</Warning>
157161

158162
<Frame>
159163
<img src="assets/npm-automation-token.png" alt="Creating NPM Automation Token" />
160164
</Frame>
161165

162-
Once finished, click **Generate Token**.
163-
164-
<Warning>When you click **Generate Token**, you’ll be returned to the **Access Tokens** dashboard. A box on the top of the dashboard will confirm that you successfully created a new token and prompt you to copy your token id. Make sure you save this id, as you'll need to add it to your GitHub repository and `generators.yml` later on.</Warning>
165-
166166
</Accordion>
167167
<Accordion title="Option 2: Granular Access Token">
168168
1. Select **Granular Access Token**.
@@ -171,6 +171,9 @@ ts-sdk:
171171
1. Configure your token's access to packages and scopes.
172172
1. Configure your token's access to organizations. In order to fill this out, you must have at least one organization already configured in npm. See [Creating an organization](https://docs.npmjs.com/creating-an-organization) for more information.
173173
1. Optionally fill out additional permissions according to your organization's requirements.
174+
1. Click **Generate Token**.
175+
176+
<Warning>Save your new token – it won’t be displayed after you leave the page.</Warning>
174177

175178
<Frame>
176179
<img src="assets/granular-access-token.png" alt="Creating Granular Access Token" />
@@ -185,18 +188,20 @@ ts-sdk:
185188

186189
Add `token: ${NPM_TOKEN}` to `generators.yml` to tell Fern to use the `NPM_TOKEN` environment variable for authentication when publishing to the npm registry.
187190

188-
```yaml title="TypeScript" {9}
191+
```yaml {9}
189192
groups:
190-
ts-sdk:
191-
generators:
192-
- name: fernapi/fern-typescript-node-sdk
193-
version: <Markdown src="/snippets/version-number.mdx"/>
194-
output:
195-
location: npm
196-
package-name: name-of-your-package
197-
token: ${NPM_TOKEN}
198-
github:
199-
repository: your-org/your-repository
193+
ts-sdk:
194+
generators:
195+
- name: fernapi/fern-typescript-sdk
196+
version: <Markdown src="/snippets/version-number.mdx"/>
197+
output:
198+
location: npm
199+
package-name: name-of-your-package
200+
token: ${NPM_TOKEN}
201+
config:
202+
namespaceExport: your-client-name
203+
github:
204+
repository: your-org/your-repository
200205
```
201206
</Step>
202207

@@ -225,7 +230,9 @@ ts-sdk:
225230
```bash
226231
fern generate --group ts-sdk --version <version>
227232
```
228-
Local machine output will verify that the release is pushed to your repository and tagged with the version you specified. You'll receive an email from npm notifying you that a new version of your package has been successfully published!
233+
Local machine output will verify that the release is pushed to your
234+
repository and tagged with the version you specified. Log back into npm and
235+
navigate to **Packages** to see your new release.
229236

230237
</Step>
231238

0 commit comments

Comments
 (0)