Skip to content

Commit

Permalink
Merge pull request #2 from nitric-dev/develop
Browse files Browse the repository at this point in the history
SDK release
  • Loading branch information
tjholm committed Nov 24, 2020
2 parents e3beca2 + 6cbb7ca commit ec29048
Show file tree
Hide file tree
Showing 16 changed files with 4,631 additions and 86 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/publish-on-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish to NPM on Github Release

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{secrets.SUB_MODULE_PAT}}
submodules: recursive
- name: Cache Dependencies
uses: actions/cache@v2
with:
path: 'node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
- name: Use Node 14
uses: actions/setup-node@v1
with:
node-version: 14
registry-url: 'https://registry.npmjs.org'
always-auth: true
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Build
run: yarn build
- name: Publish to NPM
run: npm publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Tests

on: pull_request

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{secrets.SUB_MODULE_PAT}}
submodules: recursive
- name: Cache Yarn Cache
uses: actions/cache@v2
with:
path: 'node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
- name: Install modules
run: yarn --frozen-lockfile
- name: Build
run: yarn build
- name: Run tests
run: yarn test
58 changes: 58 additions & 0 deletions .github/workflows/version-bump.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Bump Package Versions, Tag and Draft Release

on:
pull_request:
types: [closed]
branches:
- 'master'
- 'main'

jobs:
version:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache Yarn Cache
uses: actions/cache@v2
with:
path: 'node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
- name: Use Node 14
uses: actions/setup-node@v1
with:
node-version: 14
- name: Git Identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install Dependencies
run: yarn --frozen-lockfile
- name: Bump and Tag
run: |
yarn bump
echo "::set-output name=TAG_REF::`git describe --abbrev=0`"
id: bump_tag
- name: Merge Master -> Develop
run: |
git fetch
git checkout develop
git merge --no-ff master -m "Merge version bump into develop"
git push origin master develop --follow-tags
- name: Create Draft Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.bump_tag.outputs.TAG_REF }}
release_name: Release ${{ steps.bump_tag.outputs.TAG_REF }}
body: See CHANGELOG.md for changes
draft: true
prerelease: false
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
src/
contracts/
.github/
node_modules/
tsconfig.json
yarn.lock
2 changes: 1 addition & 1 deletion contracts
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
// Ignore the auto generated code for code coverage
coveragePathIgnorePatterns: ["/interfaces/"]
};
20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,35 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"bump": "standard-version",
"build": "yarn run gen-services && yarn run gen-types && yarn run fix-type-deps && yarn run fix-js-deps && tsc && yarn run copy-types",
"test": "jest",
"test:coverage": "jest --coverage",
"gen-services": "grpc_tools_node_protoc --js_out=import_style=commonjs,binary:./src/interfaces --grpc_out=./src/interfaces --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` -I ./contracts ./contracts/proto/**/*.proto",
"gen-types": "grpc_tools_node_protoc --plugin=protoc-gen-ts=`which grpc_tools_node_protoc_ts_plugin` --ts_out=./src/interfaces -I ./contracts ./contracts/proto/**/*.proto",
"fix-type-deps": "replace-in-files --string='from \"grpc\"' --replacement='from \"@grpc/grpc-js\"' ./src/**/*.d.ts",
"fix-js-deps": "replace-in-files --string=\"require('grpc')\" --replacement=\"require('@grpc/grpc-js')\" ./src/**/*.js",
"copy-types": "cp src/interfaces/proto/**/* lib/interfaces/proto"
},
"contributors": [
"Jye Cusch <jye.cusch@gmail.com>",
"Tim Holm <timothy.j.holm@gmail.com>"
"Jye Cusch <jye.cusch@nitric.io>",
"Tim Holm <tim.holm@nitric.io>"
],
"dependencies": {
"@grpc/grpc-js": "^1.1.7"
"@grpc/grpc-js": "^1.1.7",
"google-protobuf": "3.14.0",
"uuidv4": "6.2.3"
},
"license": "UNLICENSED",
"devDependencies": {
"typescript": "^3.3",
"@types/jest": "^26.0.15",
"jest": "^26.6.1",
"ts-jest": "^26.4.3",
"grpc-tools": "^1.9.1",
"grpc-tools-ts": "^2.3.0",
"replace-in-files-cli": "latest"
"replace-in-files-cli": "latest",
"standard-version": "^9.0.0",
"typescript": "^3.3",
"@types/google-protobuf": "3.2.7"
}
}
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// re-export original generated code as grpc interfaces
// re-export node friendly interface wrappers
export * as v1 from './v1';

// re-export original generated code as grpc interfaces
export * as grpc from './interfaces';
export * as grpc from './interfaces';

// Nitric typings
export * from "./types";
4 changes: 3 additions & 1 deletion src/interfaces/v1.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './proto/v1/eventing_grpc_pb';
export * from './proto/v1/eventing_pb';
export * from './proto/v1/storage_grpc_pb';
export * from './proto/v1/storage_pb';
export * from './proto/v1/storage_pb';
export * from './proto/v1/documents_grpc_pb';
export * from './proto/v1/documents_pb';
22 changes: 22 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
*
*/
export interface NitricContext {
requestId: string;
source: string;
sourceType: "REQUEST" | "SUBSCRIPTION";
payloadType: string;
}

/**
*
*/
export interface NitricRequest<T> {
context: NitricContext;
payload: T | Uint8Array;
}

/**
*
*/
export type NitricFunction<P,T> = (request: NitricRequest<P>) => T;
Loading

0 comments on commit ec29048

Please sign in to comment.