Skip to content

Commit

Permalink
Setup NPM Token using generateNpmRc Task (#1563)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarcaur authored Mar 25, 2024
1 parent 731f08d commit 8f39974
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
4 changes: 1 addition & 3 deletions conjure-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ project (':conjure-api:conjure-api-objects') {
}

project (':conjure-api:conjure-api-typescript') {
publishTypeScript.doFirst {
file('src/.npmrc') << "//registry.npmjs.org/:_authToken=${System.env.NPM_AUTH_TOKEN}"
}
generateNpmrc.token = System.env.NPM_AUTH_TOKEN
}

conjure {
Expand Down
12 changes: 1 addition & 11 deletions docs/howto/publish_typescript_to_npm.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# How to publish TypeScript to npm

If you want to publish npm packages, you need to simulate the `npm login` command to ensure you have the necessary credentials to `npm publish`. Add the following snippet to your `./your-project-api/build.gradle` to write the `$NPM_AUTH_TOKEN` environment variable to disk. You should specify this as a secret variable on your CI server (e.g. CircleCI or TravisCI).

```diff
apply plugin: 'com.palantir.conjure'

+project("${project.name}-typescript") {
+ publishTypeScript.doFirst {
+ file('src/.npmrc') << "//registry.npmjs.org/:_authToken=${System.env.NPM_AUTH_TOKEN}"
+ }
+}
```
If you want to publish npm packages, you need to provide the necessary credentials to `npm publish`. Documentation on how to achieve this can be found [here](https://github.com/palantir/gradle-conjure?tab=readme-ov-file#typescript).

0 comments on commit 8f39974

Please sign in to comment.