From 907b5d83d3e25da14fb5000a974d804bf3beefbf Mon Sep 17 00:00:00 2001 From: danilaplee Date: Sat, 15 Aug 2026 15:46:57 +0200 Subject: [PATCH] feat/add-npm-workflow --- .github/workflows/npm.yml | 28 ++++++++++++++++++++++++++++ README.md | 14 ++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .github/workflows/npm.yml diff --git a/.github/workflows/npm.yml b/.github/workflows/npm.yml new file mode 100644 index 00000000..ad97c2dd --- /dev/null +++ b/.github/workflows/npm.yml @@ -0,0 +1,28 @@ +name: Publish Package to npmjs on tag +on: + push: + tags: + - '*' +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v6 + # Setup .npmrc file to publish to npm + - uses: actions/setup-node@v7 + with: + node-version: '22.x' + registry-url: 'https://registry.npmjs.org' + - run: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" + - run: npm i + - run: npm run build + - run: node -e 'const json=require("./package.json");fs.writeFileSync("./package.json",JSON.stringify({...json, version:process.env.GITHUB_REF?.replace("refs/tags/", "")}, undefined, 2), "utf-8")' + - run: cat package.json + - run: yarn set version stable + - run: yarn publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index ea3e6968..673832b0 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,20 @@ Module system It can be used in both TypeScript and JavaScript. In TypeScript, the definition will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html)) +### Basic Example +``` +import * as vault from '@hashicorp/vault-client-typescript' +const vaultClientConfig = new vault.Configuration({ + basePath:process.env.VAULT_URL, // http://localhost:1234/v1 + headers:{ + 'X-Vault-Token':process.env.VAULT_TOKEN + } +}) + +const secretsClient = new vault.SecretsApi(vaultClientConfig) +secretsClient.kvV2Write('test_secret', 'secret', {data:{mysecretdata:"12345"}}) +``` + ### Building To build and compile the typescript sources to javascript use: