From 3ae1300af43a78df1815b18cc414e57b00fe32a9 Mon Sep 17 00:00:00 2001 From: Dereck Mezquita Date: Tue, 27 Aug 2024 14:46:14 -0500 Subject: [PATCH] STAT-10: Demo project. --- .github/pull_request_template.md | 12 ++++++++++++ .github/workflows/npm_publish_dev.yml | 22 ++++++++++++++++++++++ .github/workflows/npm_publish_prod.yml | 20 ++++++++++++++++++++ src/index.ts | 1 + src/sum.ts | 4 ++++ test/sum.test.ts | 7 +++++++ 6 files changed, 66 insertions(+) create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/npm_publish_dev.yml create mode 100644 .github/workflows/npm_publish_prod.yml create mode 100644 src/index.ts create mode 100644 src/sum.ts create mode 100644 test/sum.test.ts diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..acaedb6 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,12 @@ +# jira ticket + +https://singular-ai.atlassian.net/browse/ + +# todo list + +- [ ] Version bump +- [ ] Clean up code + +# tests updated + +- [ ] integration test diff --git a/.github/workflows/npm_publish_dev.yml b/.github/workflows/npm_publish_dev.yml new file mode 100644 index 0000000..fe68b05 --- /dev/null +++ b/.github/workflows/npm_publish_dev.yml @@ -0,0 +1,22 @@ +name: Node.js Package Dev Release + +on: + push: + branches-ignore: + - 'master' +jobs: + build-and-publish-dev: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + - run: yarn install --frozen-lockfile + - run: yarn test + - run: | + npm version prerelease --preid=dev --no-git-tag-version + npm publish --tag dev + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.github/workflows/npm_publish_prod.yml b/.github/workflows/npm_publish_prod.yml new file mode 100644 index 0000000..155d0d7 --- /dev/null +++ b/.github/workflows/npm_publish_prod.yml @@ -0,0 +1,20 @@ +name: Node.js Package Production Release + +on: + release: + types: [created] + +jobs: + build-and-publish-prod: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: yarn install --frozen-lockfile + - run: yarn test + - run: yarn publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..cf1f616 --- /dev/null +++ b/src/index.ts @@ -0,0 +1 @@ +export * from './sum'; diff --git a/src/sum.ts b/src/sum.ts new file mode 100644 index 0000000..7379142 --- /dev/null +++ b/src/sum.ts @@ -0,0 +1,4 @@ +// src/sum.ts +export function sum(a: number, b: number): number { + return a + b; +} diff --git a/test/sum.test.ts b/test/sum.test.ts new file mode 100644 index 0000000..cbebb8c --- /dev/null +++ b/test/sum.test.ts @@ -0,0 +1,7 @@ +import { sum } from '../src'; + +describe('sum', () => { + it('adds two numbers', () => { + expect(sum(1, 2)).toBe(3); + }); +});