diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index f8993d70..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,44 +0,0 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. -# See: https://circleci.com/docs/2.0/configuration-reference -version: 2.1 - -# Define a job to be invoked later in a workflow. -# See: https://circleci.com/docs/2.0/configuration-reference/#jobs -jobs: - test: - # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub. - # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor - docker: - - image: cimg/node:18.17.1 - # Add steps to the job - # See: https://circleci.com/docs/2.0/configuration-reference/#steps - steps: - - checkout - - restore_cache: - # See the configuration reference documentation for more details on using restore_cache and save_cache steps - # https://circleci.com/docs/2.0/configuration-reference/?section=reference#save_cache - keys: - - node-deps-v1-{{ .Branch }}-{{checksum "yarn.lock"}} - - run: - name: install packages - command: yarn - - save_cache: - key: node-deps-v1-{{ .Branch }}-{{checksum "yarn.lock"}} - paths: - - ~/.yarn - - run: - name: Run Lint - command: yarn lint - - run: - name: Run Tests - command: yarn test - - run: - name: Run Build - command: yarn build - -# Invoke jobs via workflows -# See: https://circleci.com/docs/2.0/configuration-reference/#workflows -workflows: - orb-free-workflow: - jobs: - - test diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..337fe4de --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,175 @@ +name: rsnd +on: + push: + branches: + - main + pull_request: +jobs: + lint: + runs-on: buildjet-4vcpu-ubuntu-2204 + container: + image: node:18 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Cache node modules + id: npm-cache + uses: buildjet/cache@v3 + with: + path: ~/.node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Cache yarn cache + id: yarn-cache + uses: buildjet/cache@v3 + with: + path: ~/.cache/yarn + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install packages + if: steps.npm-cache.outputs.cache-hit != 'true' + run: yarn + - name: Run Lint + run: yarn lint + format: + runs-on: buildjet-4vcpu-ubuntu-2204 + container: + image: node:16 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Cache node modules + id: npm-cache + uses: buildjet/cache@v3 + with: + path: ~/.node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Cache yarn cache + id: yarn-cache + uses: buildjet/cache@v3 + with: + path: ~/.cache/yarn + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install packages + if: steps.npm-cache.outputs.cache-hit != 'true' + run: yarn + - name: Run Format Check + run: yarn format:check + # test: + # runs-on: buildjet-4vcpu-ubuntu-2204 + # container: + # image: node:16 + # steps: + # - name: Checkout + # uses: actions/checkout@v3 + # - name: Cache node modules + # id: npm-cache + # uses: buildjet/cache@v3 + # with: + # path: ~/.node_modules + # key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + # restore-keys: | + # ${{ runner.os }}-node- + # - name: Cache yarn cache + # id: yarn-cache + # uses: buildjet/cache@v3 + # with: + # path: ~/.cache/yarn + # key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + # restore-keys: | + # ${{ runner.os }}-yarn- + # - name: Install packages + # if: steps.npm-cache.outputs.cache-hit != 'true' + # run: yarn + # - name: Run Tests + # run: yarn test + build: + runs-on: buildjet-4vcpu-ubuntu-2204 + container: + image: node:16 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Cache node modules + id: npm-cache + uses: buildjet/cache@v3 + with: + path: ~/.node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Cache yarn cache + id: yarn-cache + uses: buildjet/cache@v3 + with: + path: ~/.cache/yarn + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install packages + if: steps.npm-cache.outputs.cache-hit != 'true' + run: yarn + - name: Run Build + run: yarn build + dependencies: + runs-on: buildjet-4vcpu-ubuntu-2204 + container: + image: node:16 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Cache node modules + id: npm-cache + uses: buildjet/cache@v3 + with: + path: ~/.node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Cache yarn cache + id: yarn-cache + uses: buildjet/cache@v3 + with: + path: ~/.cache/yarn + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install packages + if: steps.npm-cache.outputs.cache-hit != 'true' + run: yarn + - name: Check for pinned dependencies + run: | + node -e ' + const fs = require("fs"); + const pkg = JSON.parse(fs.readFileSync("package.json", "utf8")); + const errors = []; + + function isPinned(version) { + return /^\d+\.\d+\.\d+$|^[a-z]+:[a-z]+@\d+$/.test(version); + } + + for (const [dep, version] of Object.entries(pkg.dependencies || {})) { + if (!isPinned(version)) { + errors.push(`Dependency "${dep}" is not pinned: "${version}"`); + } + } + + for (const [dep, version] of Object.entries(pkg.devDependencies || {})) { + if (!isPinned(version)) { + errors.push(`Dev dependency "${dep}" is not pinned: "${version}"`); + } + } + + if (errors.length > 0) { + console.error(`\n${errors.join("\n")}\n`); + process.exit(1); + } else { + console.log("All dependencies are pinned."); + } + ' diff --git a/package.json b/package.json index abd113d7..7cbcb97e 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,11 @@ }, "scripts": { "build": "tsc -p .", - "lint": "eslint --fix --ext .ts ./src", "test": "jest", "test:watch": "jest --watch", - "prettier": "prettier \"src/**/*.{js,ts,tsx}\" --check", - "format": "prettier \"src/**/*.{js,ts,tsx}\" --write", + "lint": "eslint --fix --ext .ts ./src", + "format:check": "prettier --check \"**/*.{ts,tsx}\"", + "format": "prettier --write .", "prepublishOnly": "yarn run build" }, "repository": { diff --git a/src/emails/interfaces/create-email-options.interface.ts b/src/emails/interfaces/create-email-options.interface.ts index 81056b0d..fa8a2002 100644 --- a/src/emails/interfaces/create-email-options.interface.ts +++ b/src/emails/interfaces/create-email-options.interface.ts @@ -41,13 +41,13 @@ interface CreateEmailBaseOptions { react?: React.ReactElement | React.ReactNode | null; /** * The HTML version of the message. - * + * * @link https://resend.com/api-reference/emails/send-email#body-parameters */ html?: string; /** * The plain text version of the message. - * + * * @link https://resend.com/api-reference/emails/send-email#body-parameters */ text?: string; @@ -71,7 +71,7 @@ interface CreateEmailBaseOptions { tags?: Tag[]; /** * Recipient email address. For multiple addresses, send as an array of strings. Max 50. - * + * * @link https://resend.com/api-reference/emails/send-email#body-parameters */ to: string | string[]; diff --git a/src/resend.ts b/src/resend.ts index 454ee957..83c44930 100644 --- a/src/resend.ts +++ b/src/resend.ts @@ -47,7 +47,11 @@ export class Resend { return await response.json(); } - async post(path: string, entity?: any, options: PostOptions = {}): Promise { + async post( + path: string, + entity?: any, + options: PostOptions = {}, + ): Promise { const requestOptions = { method: 'POST', headers: this.headers,