diff --git a/.github/workflows/publish-to-npm.yaml b/.github/workflows/publish-to-npm.yaml index 893dfa9b..c06ad2e3 100644 --- a/.github/workflows/publish-to-npm.yaml +++ b/.github/workflows/publish-to-npm.yaml @@ -1,4 +1,4 @@ -name: "Publish to NPM" +name: "Publish to npm 🚀" on: push: @@ -8,9 +8,24 @@ on: jobs: build: runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v3 - - run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} - - run: npm install - - run: npm run build - - run: npm publish --access public + - name: Check out repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: "20" + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + + - name: Set npm Config + run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + + - name: Publish to npm + run: npm publish --access public diff --git a/package.json b/package.json index b206a6b6..d107d0d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@neynar/nodejs-sdk", - "version": "1.21.1", + "version": "1.21.2", "description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)", "main": "./build/index.js", "types": "./build/index.d.ts", @@ -25,8 +25,12 @@ "dependencies": { "@openapitools/openapi-generator-cli": "^2.7.0", "axios": "^1.6.2", + "semver": "^7.6.0", "viem": "^1.19.9" }, + "engines": { + "node": ">=19.9.0" + }, "keywords": [ "ethereum", "optimism", @@ -34,4 +38,4 @@ "neynar", "nodejs" ] -} \ No newline at end of file +} diff --git a/src/index.ts b/src/index.ts index 475ea712..13fdd6c1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,12 @@ -export * from './neynar-api' \ No newline at end of file +const semver = require("semver"); +const requiredVersion = require("../package.json").engines.node; + +// Check Node.js version before requiring/doing anything else +if (!semver.satisfies(process.version, requiredVersion)) { + console.error( + `Unsupported Node.js version! Your version: ${process.version}. Required version: ${requiredVersion}.` + ); + process.exit(1); +} + +export * from "./neynar-api"; diff --git a/yarn.lock b/yarn.lock index 9b7cc355..ed552abb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1271,6 +1271,13 @@ semver@^7.3.4: dependencies: lru-cache "^6.0.0" +semver@^7.6.0: + version "7.6.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d" + integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg== + dependencies: + lru-cache "^6.0.0" + signal-exit@^3.0.2: version "3.0.7" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"