Skip to content

Commit

Permalink
fix: broken package
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
Completely reverts several versions of the package that were broken/attempting
to provide a lean package. This is hopefully a known good state that fixes
those issues.
  • Loading branch information
alexandros-megas committed Mar 8, 2022
1 parent 597fe90 commit 7030339
Show file tree
Hide file tree
Showing 15 changed files with 771 additions and 926 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ jobs:
node-version: 16
- name: Install deps
run: yarn install
- name: Lint code
run: yarn lint
- name: Build package
run: yarn build
- name: Run tests
run: yarn test

release:
needs: build
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ typings/
# rollup.js default build output
dist/

lib/

# Uncomment the public line if your project uses Gatsby
# https://nextjs.org/blog/next-9-1#public-directory-support
# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn test
5 changes: 5 additions & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
color: true
extension:
- ts
require: ts-node/register
spec: tests/**/*.test.ts
3 changes: 0 additions & 3 deletions .npmignore

This file was deleted.

11 changes: 11 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { V2Client } from './proto/clarifai/api/serviceServiceClientPb'

export class ClarifaiStub {
static grpc (hostname = 'api.clarifai.com') {
return new V2Client(hostname)
}
}

export { V2Client }
export { Error, Metadata, ClientReadableStream } from 'grpc-web'
export { BaseResponse } from './proto/clarifai/api/status/status_pb'
23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,37 @@
"name": "clarifai-web-grpc",
"version": "1.0.0",
"description": "The official Clarifai gRPC-web client",
"type": "module",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"repository": "https://github.com/Clarifai/clarifai-web-grpc",
"author": "Clarifai Inc.",
"license": "Apache-2.0",
"keywords": [],
"scripts": {
"build": "tsc -b",
"clean": "rm -rf lib clarifai-web-grpc-*.tgz",
"test": "mocha",
"lint": "standard index.ts resources.ts service.ts",
"clean": "rm -rf dist clarifai-web-grpc-*.tgz",
"build:cjs": "tsc -b tsconfig.cjs.json",
"build:esm": "tsc -b",
"build": "yarn build:esm && yarn build:cjs",
"prepack": "yarn clean && yarn build",
"release": "semantic-release",
"prepare": "husky install"
},
"dependencies": {
"google-protobuf": "^3.19.4",
"google-protobuf": "~3.14.0",
"grpc-web": "~1.0.5"
},
"devDependencies": {
"@commitlint/cli": "^16.0.1",
"@commitlint/config-conventional": "^16.0.0",
"@semantic-release/changelog": "^6.0.1",
"@types/chai": "^4.3.0",
"@types/google-protobuf": "^3.15.5",
"@types/google-protobuf": "~3.7.0",
"@types/mocha": "^9.0.0",
"@types/node": "~10.17.0",
"@typescript-eslint/eslint-plugin": "^5.10.1",
"@typescript-eslint/parser": "^5.10.1",
"chai": "^4.3.4",
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.2.0",
"husky": "^7.0.4",
"mocha": "^9.1.3",
"semantic-release": "^18.0.1",
Expand Down
1 change: 1 addition & 0 deletions resources.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './proto/clarifai/api/resources_pb'
1 change: 1 addition & 0 deletions service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './proto/clarifai/api/service_pb'
41 changes: 41 additions & 0 deletions tests/basic.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ClarifaiStub as StubSRC } from '../index'
import { ClarifaiStub as StubCJS } from '../dist/cjs/index'
import { ClarifaiStub as StubESM } from '../dist/esm/index'
import { describe, it } from 'mocha'
import { expect } from 'chai'

describe('Client Stub (src)', () => {
it('works', () => {
const client = StubSRC.grpc()
expect(client.hostname_).to.equal('api.clarifai.com')
})

it('allows custom hostname', () => {
const client = StubSRC.grpc('api-dev.clarifai.com')
expect(client.hostname_).to.equal('api-dev.clarifai.com')
})
})

describe('Client Stub (cjs)', () => {
it('works', () => {
const client = StubCJS.grpc()
expect(client.hostname_).to.equal('api.clarifai.com')
})

it('allows custom hostname', () => {
const client = StubCJS.grpc('api-dev.clarifai.com')
expect(client.hostname_).to.equal('api-dev.clarifai.com')
})
})

describe('Client Stub (esm)', () => {
it('works', () => {
const client = StubESM.grpc()
expect(client.hostname_).to.equal('api.clarifai.com')
})

it('allows custom hostname', () => {
const client = StubESM.grpc('api-dev.clarifai.com')
expect(client.hostname_).to.equal('api-dev.clarifai.com')
})
})
Empty file added tests/package.test.ts
Empty file.
7 changes: 7 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "./dist/cjs"
}
}
14 changes: 11 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@
"strict": true,
"declaration": true,
"allowJs": true,
"outDir": "./lib",
"outDir": "./dist/esm",
"moduleResolution": "node"
},
"include": [
"proto",
"./index.ts",
"./resources.ts",
"./service.ts",
"proto/",
],
"exclude": [
"node_modules"
]
],
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
}
}
Loading

0 comments on commit 7030339

Please sign in to comment.