Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP convert to monorepos #324

Open
wants to merge 1 commit into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ pids

# Coverage directory used by tools like istanbul
coverage
packages/*/coverage/
.nyc_output

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
packages/*/build/Release

# Dependency directory
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
node_modules
packages/*/node_modules/

.tmp

Expand All @@ -29,8 +32,12 @@ node_modules
.idea/

typings
packages/*/typings
.tsdrc
packages/*/typings
jsconfig.json
coverage
dist
packages/*/dist
spec-js
packages/*/spec-js
16 changes: 16 additions & 0 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"exclude": [
"**/teambition-sdk-testutil/**",
"**/teambition-sdk-core/spec-js/src/teambition.js",
"**/teambition-sdk-core/spec-js/src/utils/internalTypes.js"
],
"include": [
"**/spec-js/src/**"
],
"extension": [
".ts"
],
"reporter": ["html", "lcov"],
"all": true,
"cache": true
}
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@ language: node_js
node_js:
- "6"

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.27.5
- export PATH="$HOME/.yarn/bin:$PATH"
cache:
yarn: true

script:
- "npm run build_all"
2 changes: 2 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
registry "https://registry.npmjs.org"

workspaces-experimental true
7 changes: 4 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ dependencies:
- ~/.cache/yarn

test:
before:
- greenkeeper-lockfile-update
override:
- yarn test
pre:
- greenkeeper-lockfile-update
- yarn build_all
post:
- npm run build_cjs && npm run check_circular_dependencies
- npm run check_circular_dependencies
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- greenkeeper-lockfile-upload

Expand Down
6 changes: 6 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"lerna": "2.0.0",
"version": "independent",
"npmClient": "yarn",
"useWorkSpaces": true
}
34 changes: 12 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
{
"private": true,
"name": "teambition-sdk",
"version": "0.8.17",
"description": "Front-End SDK for Teambition",
"main": "./index.js",
"typings": "./index.d.ts",
"workspaces": [
"packages/*"
],
"scripts": {
"build_all": "rm -rf dist && mkdir dist && mkdir dist/bundle && npm run build_es6 && npm run build_cjs && npm run build_bundle && npm run build_mock && npm run build_mock_cjs && npm run build_test && npm run build_socket",
"build_bundle": "rm -rf dist/bundle/tbsdk.umd.js && ts-node ./tools/tasks/bundle.sdk.ts",
"build_cjs": "rm -rf dist/cjs && tsc src/index.ts -m commonjs --outDir dist/cjs --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --strict --noUnusedLocals --noUnusedParameters --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --importHelpers --noEmitHelpers --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom",
"build_es6": "rm -rf dist/es6 && tsc src/index.ts -m es2015 --outDir dist/es6 --sourcemap --inlineSources --target ES2015 -d --diagnostics --pretty --strict --noUnusedLocals --noUnusedParameters --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --importHelpers --noEmitHelpers --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom",
"build_mock": "rm -rf dist/mock-es6 && tsc mock/index.ts -m es2015 --outDir dist/mock-es6 --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --strict --noUnusedLocals --noUnusedParameters --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom && ts-node ./tools/tasks/bundle.mock.ts",
"build_mock_cjs": "rm -rf dist/mock-cjs && tsc mock/index.ts -m commonjs --outDir dist/mock-cjs --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --strict --noUnusedLocals --noUnusedParameters --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom",
"build_socket": "rm -rf dist/bundle/tbsdk.socket.js && tsc ./src/SocketApp.ts ./src/teambition.ts -m commonjs --outDir dist/socket --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom && ts-node ./tools/tasks/bundle.socket.ts",
"build_test": "rm -rf spec-js && tsc test/app.ts -m commonjs --sourcemap --inlineSources --outDir spec-js --target ES2015 --diagnostics --pretty --experimentalDecorators --suppressImplicitAnyIndexErrors --types \"node,chai,sinon,sinon-chai\" --moduleResolution node",
"check_circular_dependencies": "madge ./dist/cjs --circular",
"copy_files": "cp README.md package.json ./dist/cjs/",
"cover": "npm run build_test && rm -rf ./coverage && nyc --reporter=html --reporter=lcov --exclude=node_modules --exclude=spec-js/test --exclude=spec-js/mock --exclude=spec-js/src/sockets/SocketClient.js tman --mocha spec-js/test/app.js",
"lint": "tslint ./src/**/*.ts ./mock/**/*.ts ./test/*.ts ./test/apis/**/*.ts ./test/mock/**/*.ts ./test/utils/**/*.ts",
"publish_sdk": "npm run build_all && npm run copy_files && npm publish ./dist/cjs",
"publish_all": "npm run publish_sdk && ts-node ./tools/tasks/publish.ts && cp -r ./dist/mock-cjs/** ./.tmp/mock && cp -r ./dist/socket/** ./.tmp/socket && npm publish .tmp/mock/ && npm publish .tmp/socket/",
"test": "npm run lint && npm run cover",
"version": "ts-node tools/tasks/version.ts && git add .",
"watch": "npm run watch_test & ts-node ./tools/tasks/test.ts",
"watch_cjs": "tsc src/index.ts -m commonjs --outDir dist/cjs --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --experimentalDecorators --strict --noUnusedLocals --noUnusedParameters --suppressImplicitAnyIndexErrors --moduleResolution node --skipLibCheck -w --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom",
"watch_test": "tsc test/app.ts -m commonjs --outDir spec-js --sourcemap --inlineSources --target ES2015 --diagnostics --pretty --experimentalDecorators --suppressImplicitAnyIndexErrors --types \"node,chai,sinon,sinon-chai\" --moduleResolution node --skipLibCheck -w"
"build_all": "lerna exec npm run build_cjs",
"check_circular_dependencies": "madge ./packages/*/dist/cjs --circular",
"lint": "lerna exec npm run lint",
"test": "rm -rf ./coverage && nyc lerna exec npm test"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -61,6 +48,7 @@
"google-closure-compiler-js": "^20170521.0.0",
"isomorphic-fetch": "^2.2.1",
"jsonrpc-lite": "^1.2.3",
"lerna": "^2.0.0",
"madge": "^1.6.0",
"moment": "^2.18.1",
"node-watch": "^0.5.4",
Expand All @@ -75,7 +63,9 @@
"sinon": "^2.3.8",
"sinon-chai": "^2.11.0",
"snapper-consumer": "^1.3.6",
"teambition-sdk-mock": "^0.6.8",
"teambition-sdk-core": "^0.8.13",
"teambition-sdk-request": "^0.8.13",
"teambition-sdk-testutil": "^0.8.13",
"tman": "^1.7.1",
"ts-node": "^3.2.0",
"tslib": "^1.7.1",
Expand Down
84 changes: 84 additions & 0 deletions packages/teambition-sdk-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"name": "teambition-sdk-core",
"version": "0.8.13",
"description": "Front-End SDK (Core) for Teambition",
"main": "./dist/cjs/index.js",
"typings": "./dist/cjs/index.d.ts",
"scripts": {
"build_all": "rm -rf dist && mkdir dist && mkdir dist/bundle && npm run build_es6 && npm run build_cjs && npm run build_bundle && npm run build_mock && npm run build_mock_cjs && npm run build_test && npm run build_socket",
"build_bundle": "rm -rf dist/bundle/tbsdk.umd.js && ts-node ./tools/tasks/bundle.sdk.ts",
"build_cjs": "rm -rf dist/cjs && tsc src/index.ts -m commonjs --outDir dist/cjs --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --strict --noUnusedLocals --noUnusedParameters --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --importHelpers --noEmitHelpers --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom",
"build_es6": "rm -rf dist/es6 && tsc src/index.ts -m es2015 --outDir dist/es6 --sourcemap --inlineSources --target ES2015 -d --diagnostics --pretty --strict --noUnusedLocals --noUnusedParameters --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --importHelpers --noEmitHelpers --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom",
"build_mock": "rm -rf dist/mock-es6 && tsc mock/index.ts -m es2015 --outDir dist/mock-es6 --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --strict --noUnusedLocals --noUnusedParameters --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom && ts-node ./tools/tasks/bundle.mock.ts",
"build_mock_cjs": "rm -rf dist/mock-cjs && tsc mock/index.ts -m commonjs --outDir dist/mock-cjs --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --strict --noUnusedLocals --noUnusedParameters --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom",
"build_socket": "rm -rf dist/bundle/tbsdk.socket.js && tsc ./src/SocketApp.ts ./src/teambition.ts -m commonjs --outDir dist/socket --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --experimentalDecorators --suppressImplicitAnyIndexErrors --moduleResolution node --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom && ts-node ./tools/tasks/bundle.socket.ts",
"build_test": "rm -rf spec-js && tsc --project test",
"copy_files": "cp README.md package.json ./dist/cjs/",
"lint": "tslint --project . --config ../../tslint.json",
"publish_sdk": "npm run build_all && npm run copy_files && npm publish ./dist/cjs",
"publish_all": "npm run publish_sdk && ts-node ./tools/tasks/publish.ts && cp -r ./dist/mock-cjs/** ./.tmp/mock && cp -r ./dist/socket/** ./.tmp/socket && npm publish .tmp/mock/ && npm publish .tmp/socket/",
"test": "npm run lint && npm run build_test && tman --mocha spec-js/test/app.js",
"version": "ts-node tools/tasks/version.ts && git add .",
"watch": "npm run watch_test & ts-node ../../tools/tasks/test.ts $!",
"watch_cjs": "tsc src/index.ts -m commonjs --outDir dist/cjs --sourcemap --inlineSources --target ES5 -d --diagnostics --pretty --experimentalDecorators --strict --noUnusedLocals --noUnusedParameters --suppressImplicitAnyIndexErrors --moduleResolution node --skipLibCheck -w --lib es5,es2015.iterable,es2015.collection,es2015.promise,es2015.core,dom",
"watch_test": "tsc --project test --watch --skipLibCheck"
},
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/teambition/teambition-sdk.git"
},
"keywords": [
"teambition",
"sdk",
"teambition-sdk"
],
"author": "[email protected]",
"license": "MIT",
"bugs": {
"url": "https://github.com/teambition/teambition-sdk/issues"
},
"homepage": "https://github.com/teambition/teambition-sdk#readme",
"peerDependencies": {
"reactivedb": "~0.9.9",
"rrule": "2.2.0",
"rxjs": "^5.2.0",
"snapper-consumer": "^1.3.6",
"tslib": "^1.6.0"
},
"devDependencies": {
"@types/chai": "^4.0.1",
"@types/lodash": "^4.14.64",
"@types/lovefield": "^2.0.32",
"@types/node": "^8.0.14",
"@types/sinon": "^2.3.3",
"@types/sinon-chai": "^2.7.28",
"chai": "^4.1.0",
"coveralls": "^2.13.1",
"engine.io-client": "^3.1.0",
"fetch-mock": "^5.10.0",
"google-closure-compiler-js": "^20170521.0.0",
"isomorphic-fetch": "^2.2.1",
"jsonrpc-lite": "^1.2.3",
"madge": "^1.6.0",
"moment": "^2.18.1",
"node-watch": "^0.5.4",
"nyc": "^11.0.1",
"reactivedb": "~0.9.9",
"rollup": "^0.42.0",
"rollup-plugin-alias": "^1.3.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-node-resolve": "^3.0.0",
"rrule": "2.2.0",
"rxjs": "^5.4.2",
"sinon": "^2.3.8",
"sinon-chai": "^2.11.0",
"snapper-consumer": "^1.3.6",
"teambition-sdk-testutil": "^0.8.13",
"tman": "^1.7.1",
"ts-node": "^3.2.0",
"tslib": "^1.7.1",
"tslint": "^5.5.0",
"tslint-eslint-rules": "^4.1.1",
"typescript": "^2.4.2"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/index.ts → packages/teambition-sdk-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/// <reference path="./teambition.ts" />
import 'tslib'

import { forEach, clone, uuid, concat, dropEle } from './utils/index'
import { forEach, clone, uuid, concat, dropEle, pagination, capitalizeFirstLetter } from './utils/index'

export const Utils = { forEach, clone, uuid, concat, dropEle }
export const Utils = { forEach, clone, uuid, concat, dropEle, pagination, capitalizeFirstLetter }
export { PagingQuery, UrlPagingQuery } from './utils/internalTypes'
export { eventParser } from './sockets/EventParser'

// export apis
import './sockets/SocketClient'
import './apis'

import './schemas'
export * from './schemas'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion test/app.ts → packages/teambition-sdk-core/test/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ export * from './utils/httpErrorSpec'

export * from './mock/MockSpec'

import './apis'
import './sockets'
import './net'
10 changes: 0 additions & 10 deletions test/index.ts → packages/teambition-sdk-core/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,5 @@ export function createSdk() {
return sdk
}

export function createSdkWithoutRDB() {
return new SDK()
}

export function loadRDB(sdk: SDK) {
const database = new Database(DataStoreType.MEMORY, false, `teambition-sdk-test`, 1)
return sdk.initReactiveDB(database)
}

export * from '../src/index'
export * from '../src/utils/index'
export * from '../mock/index'
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Backend, SDKFetch } from '../index'
import { Backend } from 'teambition-sdk-testutil'
import { SDKFetch } from '../index'

function throwIfSlashPath(path: string) {
if (path.charAt(0) === '/') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as chai from 'chai'
import * as sinon from 'sinon'
import * as sinonChai from 'sinon-chai'
import { Backend, parseObject, reParseQuery } from '../index'
import { Backend, parseObject, reParseQuery } from 'teambition-sdk-testutil'
import { describe, it, beforeEach } from 'tman'

const expect = chai.expect
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import './asyncLoadRDB'
import './net'
import './http'
22 changes: 12 additions & 10 deletions test/net/net.ts → packages/teambition-sdk-core/test/net/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { Database, DataStoreType } from 'reactivedb'
import { expect, use } from 'chai'
import { spy } from 'sinon'
import * as SinonChai from 'sinon-chai'
import { Backend, EventsFixture } from 'teambition-sdk-testutil'
import '../../src/schemas'
import { schemas, CacheStrategy } from '../../src/SDK'
import { Net, Backend, SDKFetch, forEach, uuid, Http, EventSchema, } from '..'
import { Net, SDKFetch, forEach, uuid, Http, EventSchema, } from '..'
import { ApiResult } from '../../src/Net/Net'
import { normalEvent, projectEvents } from '../fixtures/events.fixture'

const { normalEvent, projectEvents } = EventsFixture

use(SinonChai)

Expand All @@ -18,10 +20,13 @@ describe('Net test', () => {
let database: Database
let version = 1
let subscription: Subscription | undefined
let spyFetch: sinon.SinonSpy

const sdkFetch = new SDKFetch()
const apiHost = sdkFetch.getAPIHost()
const path = 'test'
const http = new Http(`${apiHost}/${path}`)

beforeEach(() => {
httpBackend = new Backend()
net = new Net(schemas)
Expand All @@ -35,6 +40,7 @@ describe('Net test', () => {

afterEach(function* () {
httpBackend.restore()
spyFetch && spyFetch.restore()
if (subscription instanceof Subscription) {
subscription.unsubscribe()
}
Expand Down Expand Up @@ -212,7 +218,7 @@ describe('Net test', () => {
httpBackend.whenGET(`${apiHost}/${path}`)
.respond(projectEvents)

const spyFetch = spy(sdkFetch, 'get')
spyFetch = spy(sdkFetch, 'get')

const newLocation = 'new_event_location'

Expand Down Expand Up @@ -256,15 +262,13 @@ describe('Net test', () => {
expect(spyFetch.callCount).to.equal(2)
expect(events.length).to.equal(projectEvents.length + 1)
})

spyFetch.restore()
})

it('should handle empty Array', function* () {
it.skip('should handle empty Array', function* () {
httpBackend.whenGET(`${apiHost}/${path}`)
.respond([])

const spyFetch = spy(sdkFetch, 'get')
spyFetch = spy(sdkFetch, 'get')

const newLocation = 'new_event_location'

Expand Down Expand Up @@ -308,8 +312,6 @@ describe('Net test', () => {
expect(spyFetch.callCount).to.equal(2)
expect(events.length).to.equal(1)
})

spyFetch.restore()
})

it('should get result from cached Response and consumed by `values`', function* () {
Expand Down Expand Up @@ -444,7 +446,7 @@ describe('Net test', () => {
expect(r).to.deep.equal(projectEvents)
})

const spyFetch = spy(sdkFetch, 'get')
spyFetch = spy(sdkFetch, 'get')

const newLocation = 'new_event_location'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { eventParser, RequestEvent } from '../index'
import { RequestEvent } from 'teambition-sdk-testutil'
import { describe, beforeEach, it } from 'tman'
import { expect } from 'chai'

import { eventParser } from '../index'

describe('eventParser', () => {

let event: RequestEvent
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, beforeEach, afterEach, it } from 'tman'
import { expect } from 'chai'
import { createSdk, SDK, SocketMock, SDKFetch } from '../'
import { SocketMock } from 'teambition-sdk-testutil'
import { createSdk, SDK, SDKFetch } from '../'
import { restore } from '../utils'
import * as sinon from 'sinon'
import { Logger } from 'reactivedb'
Expand Down
Loading