Merge pull request #1109 from 0xProject/feature/instant/init

[instant] Initialize the package with dev environment and tests etc..
This commit is contained in:
Francesco Agosti
2018-10-02 17:07:23 -07:00
committed by GitHub
17 changed files with 1959 additions and 64 deletions

2
packages/instant/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
public/main.bundle.js
public/main.bundle.js.map

View File

@@ -0,0 +1 @@
[]

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,99 @@
## @0xproject/instant
## Installation
```bash
yarn add @0xproject/instant
```
**Import**
**CommonJS module**
```typescript
import { ZeroExInstant } from '@0xproject/instant';
```
or
```javascript
var ZeroExInstant = require('@0xproject/instant').ZeroExInstant;
```
If your project is in [TypeScript](https://www.typescriptlang.org/), add the following to your `tsconfig.json`:
```json
"compilerOptions": {
"typeRoots": ["node_modules/@0xproject/typescript-typings/types", "node_modules/@types"],
}
```
**UMD Module**
The package is also available as a UMD module named `zeroExInstant`.
```html
<head>
<script type="text/javascript" src="[zeroExInstantUMDPath]" charset="utf-8"></script>
</head>
<body>
<div id="zeroExInstantContainer"></div>
<script>
zeroExInstant.render({
// Initialization options
}, '#zeroExInstantContainer');
</script>
</body>
```
## Contributing
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.
### Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
```bash
yarn config set workspaces-experimental true
```
Then install dependencies
```bash
yarn install
```
### Build
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
```bash
PKG=@0xproject/instant yarn build
```
Or continuously rebuild on change:
```bash
PKG=@0xproject/instant yarn watch
```
### Clean
```bash
yarn clean
```
### Lint
```bash
yarn lint
```
### Run Tests
```bash
yarn test
```

View File

@@ -0,0 +1,10 @@
module.exports = {
roots: ['<rootDir>/test'],
coverageDirectory: 'coverage',
transform: {
'.*.tsx?$': 'ts-jest',
},
testRegex: '(/__test__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/index.tsx'],
};

View File

@@ -0,0 +1,84 @@
{
"name": "@0xproject/instant",
"version": "0.0.1",
"engines": {
"node": ">=6.12"
},
"private": true,
"description": "0x Instant React Component",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"build": "yarn build:all",
"build:all": "run-p build:umd:prod build:commonjs",
"build:umd:prod": "webpack --mode production",
"build:commonjs": "tsc -b",
"build:ci": "yarn build",
"watch_without_deps": "tsc -w",
"dev": "webpack-dev-server --mode development",
"lint": "tslint --project .",
"test": "jest",
"test:coverage": "jest --coverage",
"rebuild_and_test": "run-s clean build test",
"test:circleci": "yarn test:coverage",
"clean": "shx rm -rf lib coverage scripts",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js"
},
"config": {
"postpublish": {
"assets": [
"packages/instant/public/index.js",
"packages/instant/public/index.min.js"
]
}
},
"repository": {
"type": "git",
"url": "https://github.com/0xProject/0x-monorepo.git"
},
"author": "Francesco Agosti",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/0xProject/0x-monorepo/issues"
},
"homepage": "https://github.com/0xProject/0x-monorepo/packages/instant/README.md",
"dependencies": {
"@0xproject/connect": "^2.0.4",
"@0xproject/types": "^1.1.1",
"@0xproject/typescript-typings": "^2.0.2",
"@0xproject/utils": "^1.0.11",
"@0xproject/web3-wrapper": "^3.0.1",
"ethereum-types": "^1.0.8",
"lodash": "^4.17.10",
"react": "^16.5.2",
"react-dom": "^16.5.2"
},
"devDependencies": {
"@0xproject/tslint-config": "^1.0.7",
"@types/enzyme": "^3.1.14",
"@types/enzyme-adapter-react-16": "^1.0.3",
"@types/lodash": "^4.14.116",
"@types/node": "*",
"@types/react": "16.4.7",
"@types/react-dom": "^16.0.8",
"awesome-typescript-loader": "^5.2.1",
"copyfiles": "^1.2.0",
"enzyme": "^3.6.0",
"enzyme-adapter-react-16": "^1.5.0",
"jest": "^23.6.0",
"make-promises-safe": "^1.1.0",
"npm-run-all": "^4.1.2",
"nyc": "^11.0.1",
"shx": "^0.2.2",
"ts-jest": "^23.10.3",
"tslint": "5.11.0",
"typedoc": "0.12.0",
"typescript": "3.0.1",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.1",
"webpack-dev-server": "^3.1.9"
},
"publishConfig": {
"access": "private"
}
}

View File

@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>0x Instant Dev Environment</title>
<script type="text/javascript" src="/main.bundle.js" charset="utf-8"></script>
</head>
<body>
<div id="zeroExInstantContainer"></div>
<script>
zeroExInstant.render({
});
</script>
</body>
</html>

View File

@@ -0,0 +1,5 @@
import * as React from 'react';
export interface ZeroExInstantProps {}
export const ZeroExInstant: React.StatelessComponent<ZeroExInstantProps> = () => <div>ZeroExInstant</div>;

6
packages/instant/src/globals.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
declare module '*.json' {
const json: any;
/* tslint:disable */
export default json;
/* tslint:enable */
}

View File

@@ -0,0 +1 @@
export { ZeroExInstant, ZeroExInstantProps } from './components/zero_ex_instant';

View File

@@ -0,0 +1,10 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { ZeroExInstant } from './index';
export interface ZeroExInstantOptions {}
export const render = (props: ZeroExInstantOptions, selector: string = '#zeroExInstantContainer') => {
ReactDOM.render(React.createElement(ZeroExInstant, props), document.querySelector(selector));
};

View File

@@ -0,0 +1,13 @@
import { configure, shallow } from 'enzyme';
import * as Adapter from 'enzyme-adapter-react-16';
import * as React from 'react';
configure({ adapter: new Adapter() });
import { ZeroExInstant } from '../../src';
describe('<ZeroExInstant />', () => {
it('shallow renders without crashing', () => {
shallow(<ZeroExInstant />);
});
});

View File

@@ -0,0 +1,17 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
"rootDir": ".",
"jsx": "react",
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
"module": "ESNext",
"moduleResolution": "node",
"lib": ["es2015", "dom"],
"target": "es5",
"sourceMap": true
},
"include": ["./src/**/*", "./test/**/*"],
"exclude": ["./src/index.umd.ts"]
}

View File

@@ -0,0 +1,3 @@
{
"extends": ["@0xproject/tslint-config"]
}

View File

@@ -0,0 +1,7 @@
{
"extends": "../../typedoc-tsconfig",
"compilerOptions": {
"outDir": "lib"
},
"include": ["./src/**/*", "./test/**/*"]
}

View File

@@ -0,0 +1,28 @@
const path = require('path');
// The common js bundle (not this one) is built using tsc.
// The umd bundle (this one) has a different entrypoint.
module.exports = {
entry: './src/index.umd.ts',
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'public'),
library: 'zeroExInstant',
libraryTarget: 'umd',
},
devtool: 'source-map',
resolve: {
extensions: ['.js', '.json', '.ts', '.tsx'],
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
loader: 'awesome-typescript-loader',
},
],
},
devServer: {
contentBase: path.join(__dirname, 'public'),
port: 5000,
},
};

1716
yarn.lock

File diff suppressed because it is too large Load Diff