Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Cleanup TypeScript packages (#851)
Browse files Browse the repository at this point in the history
* Rename all packages/ directories to match package name

* Audit all dependencies vs. devDependencies

* Fix doc generation for browser and browser-lite
  • Loading branch information
albrow authored Jun 23, 2020
1 parent 63c6a5a commit d09210d
Show file tree
Hide file tree
Showing 90 changed files with 76 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ yarn-error.log
*/**/yarn-error.log*
ganache.log
*/**/ganache.log*
packages/browser/src/generated
packages/**/generated/**
*/**/dist/**/*
!*/**/dist/index.html
!integration-tests/data/standalone-0/keys/privKey
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pipeline will fail if Typescript code is not "prettified," so `prettier` must be
to ensure that the code is properly formatted.

The prettier tool can be run using the following command from the top-level of the
0x-Mesh repository (outside of a directory inside `packages/`):
0x-Mesh repository (outside of a directory inside **packages/**):

```bash
yarn prettier
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ test-browser-integration:

.PHONY: test-browser-conversion
test-browser-conversion:
go test ./packages/browser/go/conversion-test -timeout 185s --enable-browser-conversion-tests -run BrowserConversions
go test ./packages/mesh-browser/go/conversion-test -timeout 185s --enable-browser-conversion-tests -run BrowserConversions


.PHONY: test-wasm-browser
test-wasm-browser:
WASM_INIT_FILE="$$(pwd)/packages/test-wasm/dist/browser_shim.js" GOOS=js GOARCH=wasm go test -tags=browser -exec="$$GOPATH/bin/wasmbrowsertest" ./...
WASM_INIT_FILE="$$(pwd)/packages/mesh-browser-shim/dist/browser_shim.js" GOOS=js GOARCH=wasm go test -tags=browser -exec="$$GOPATH/bin/wasmbrowsertest" ./...


.PHONY: test-ts
Expand Down
30 changes: 15 additions & 15 deletions cmd/cut-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/plaid/go-envvar/envvar"
)

var functionDocsTemplate = "\n# Functions\n\n## loadMeshStreamingForURLAsync\n▸ **loadMeshStreamingWithURLAsync**(`url`: `string`): *Promise‹`void`›*\n\n*Defined in [index.ts:7](https://github.com/0xProject/0x-mesh/blob/%s/packages/browser-lite/src/index.ts#L7)*\n\nLoads the Wasm module that is provided by fetching a url.\n\n**Parameters:**\n\nName | Type | Description |\n------ | ------ | ------ |\n`url` | `string` | The URL to query for the Wasm binary |\n\n<hr />\n\n## loadMeshStreamingAsync\n\n▸ **loadMeshStreamingAsync**(`response`: `Response | Promise<Response>`): *Promise‹`void`›*\n\n*Defined in [index.ts:15](https://github.com/0xProject/0x-mesh/blob/%s/packages/browser-lite/src/index.ts#L15)*\n\nLoads the Wasm module that is provided by a response.\n\n**Parameters:**\n\nName | Type | Description |\n------ | ------ | ------ |\n`response` | `Response &#124; Promise<Response>` | The Wasm response that supplies the Wasm binary |\n\n<hr />"
var functionDocsTemplate = "\n# Functions\n\n## loadMeshStreamingForURLAsync\n▸ **loadMeshStreamingWithURLAsync**(`url`: `string`): *Promise‹`void`›*\n\n*Defined in [index.ts:7](https://github.com/0xProject/0x-mesh/blob/%s/packages/mesh-browser-lite/src/index.ts#L7)*\n\nLoads the Wasm module that is provided by fetching a url.\n\n**Parameters:**\n\nName | Type | Description |\n------ | ------ | ------ |\n`url` | `string` | The URL to query for the Wasm binary |\n\n<hr />\n\n## loadMeshStreamingAsync\n\n▸ **loadMeshStreamingAsync**(`response`: `Response | Promise<Response>`): *Promise‹`void`›*\n\n*Defined in [index.ts:15](https://github.com/0xProject/0x-mesh/blob/%s/packages/mesh-browser-lite/src/index.ts#L15)*\n\nLoads the Wasm module that is provided by a response.\n\n**Parameters:**\n\nName | Type | Description |\n------ | ------ | ------ |\n`response` | `Response &#124; Promise<Response>` | The Wasm response that supplies the Wasm binary |\n\n<hr />"

type envVars struct {
// Version is the new release version to use
Expand Down Expand Up @@ -98,18 +98,18 @@ func updateHardCodedVersions(version string) {
newBrowserLiteDependencyString := fmt.Sprintf(`"@0x/mesh-browser-lite": "^%s"`, version)
newBrowserDependencyString := fmt.Sprintf(`"@0x/mesh-browser": "^%s"`, version)

// Update `packages/rpc-client/package.json`
tsClientPackageJSONPath := "packages/rpc-client/package.json"
// Update `packages/mesh-rpc-client/package.json`
tsClientPackageJSONPath := "packages/mesh-rpc-client/package.json"
regex := `"version": "(.*)"`
updateFileWithRegex(tsClientPackageJSONPath, regex, newVersionString)

// Update `packages/browser-lite/package.json`
browserLitePackageJSONPath := "packages/browser-lite/package.json"
// Update `packages/mesh-browser-lite/package.json`
browserLitePackageJSONPath := "packages/mesh-browser-lite/package.json"
regex = `"version": "(.*)"`
updateFileWithRegex(browserLitePackageJSONPath, regex, newVersionString)

// Update `packages/browser/package.json`
browserPackageJSONPath := "packages/browser/package.json"
// Update `packages/mesh-browser/package.json`
browserPackageJSONPath := "packages/mesh-browser/package.json"
regex = `"version": "(.*)"`
updateFileWithRegex(browserPackageJSONPath, regex, newVersionString)
// NOTE(jalextowle): `@0x/mesh-browser` uses the local version of `@0x/mesh-browser-lite`
Expand All @@ -118,23 +118,23 @@ func updateHardCodedVersions(version string) {
regex = `"@0x/mesh-browser-lite": "(.*)"`
updateFileWithRegex(browserPackageJSONPath, regex, newBrowserLiteDependencyString)

// Update `packages/webpack-example-lite/package.json`
webpackExampleLitePackageJSONPath := "packages/webpack-example-lite/package.json"
// Update `packages/mesh-webpack-example-lite/package.json`
webpackExampleLitePackageJSONPath := "packages/mesh-webpack-example-lite/package.json"
regex = `"@0x/mesh-browser-lite": "(.*)"`
updateFileWithRegex(webpackExampleLitePackageJSONPath, regex, newBrowserLiteDependencyString)

// Update `packages/webpack-example/package.json`
webpackExamplePackageJSONPath := "packages/webpack-example/package.json"
// Update `packages/mesh-webpack-example/package.json`
webpackExamplePackageJSONPath := "packages/mesh-webpack-example/package.json"
regex = `"@0x/mesh-browser": "(.*)"`
updateFileWithRegex(webpackExamplePackageJSONPath, regex, newBrowserDependencyString)

// Update `packages/integration-tests/package.json`
integrationTestsPackageJSONPath := "packages/integration-tests/package.json"
// Update `packages/mesh-integration-tests/package.json`
integrationTestsPackageJSONPath := "packages/mesh-integration-tests/package.json"
regex = `"@0x/mesh-browser": "(.*)"`
updateFileWithRegex(integrationTestsPackageJSONPath, regex, newBrowserDependencyString)

// Update `packages/test-wasm/package.json`
testWasmPackageJSONPath := "packages/test-wasm/package.json"
// Update `packages/mesh-browser-shim/package.json`
testWasmPackageJSONPath := "packages/mesh-browser-shim/package.json"
regex = `"@0x/mesh-browser-lite": "(.*)"`
updateFileWithRegex(testWasmPackageJSONPath, regex, newBrowserLiteDependencyString)

Expand Down
2 changes: 1 addition & 1 deletion common/types/types_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"syscall/js"

"github.com/0xProject/0x-mesh/packages/browser/go/jsutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/jsutil"
)

func (r GetOrdersResponse) JSValue() js.Value {
Expand Down
2 changes: 1 addition & 1 deletion db/dexie_implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/0xProject/0x-mesh/common/types"
"github.com/0xProject/0x-mesh/db/dexietypes"
"github.com/0xProject/0x-mesh/packages/browser/go/jsutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/jsutil"
"github.com/ethereum/go-ethereum/common"
"github.com/gibson042/canonicaljson-go"
"github.com/google/uuid"
Expand Down
2 changes: 1 addition & 1 deletion db/dexietypes/dexietypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"time"

"github.com/0xProject/0x-mesh/common/types"
"github.com/0xProject/0x-mesh/packages/browser/go/jsutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/jsutil"
"github.com/ethereum/go-ethereum/common"
ethmath "github.com/ethereum/go-ethereum/common/math"
ethtypes "github.com/ethereum/go-ethereum/core/types"
Expand Down
2 changes: 1 addition & 1 deletion db/types_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package db
import (
"syscall/js"

"github.com/0xProject/0x-mesh/packages/browser/go/jsutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/jsutil"
)

func (opts *Options) JSValue() js.Value {
Expand Down
4 changes: 2 additions & 2 deletions docs/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ yarn add @0x/mesh-browser-lite

### Example usage

[The webpack-example directory](../packages/webpack-example) and
[the webpack-example-lite directory](../packages/webpack-example) include
[The webpack-example directory](../packages/mesh-webpack-example) and
[the webpack-example-lite directory](../packages/mesh-webpack-example-lite) include
examples of how to use the `@0x/mesh-browser` and the `@0x/mesh-browser-lite` packages,
respectively.
2 changes: 1 addition & 1 deletion integration-tests/browser_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestBrowserIntegration(t *testing.T) {
}()

// Start a simple HTTP server to serve the web page for the browser node.
ts := httptest.NewServer(http.FileServer(http.Dir("../packages/integration-tests/dist")))
ts := httptest.NewServer(http.FileServer(http.Dir("../packages/mesh-integration-tests/dist")))
defer ts.Close()

// browserLogMessages is a channel through which log messages from the
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ func buildForTests(t *testing.T, ctx context.Context) {
// for TypeScript code changes only.
fmt.Println("Building mesh-browser package...")
cmd := exec.CommandContext(ctx, "yarn", "build")
cmd.Dir = "../packages/browser"
cmd.Dir = "../packages/mesh-browser"
output, err := cmd.CombinedOutput()
require.NoError(t, err, "could not build mesh-browser package: %s", string(output))

fmt.Println("Building integration-tests package...")
cmd = exec.CommandContext(ctx, "yarn", "build")
cmd.Dir = "../packages/integration-tests"
cmd.Dir = "../packages/mesh-integration-tests"
output, err = cmd.CombinedOutput()
require.NoError(t, err, "could not build integration-tests package: %s", string(output))
fmt.Println("Done building everything")
Expand Down
2 changes: 1 addition & 1 deletion keys/fs_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"os"
"syscall/js"

"github.com/0xProject/0x-mesh/packages/browser/go/jsutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/jsutil"
)

// keyPrefix is a prefix applied to all entries in localStorage.
Expand Down
2 changes: 1 addition & 1 deletion orderfilter/filter_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"syscall/js"

"github.com/0xProject/0x-mesh/ethereum"
"github.com/0xProject/0x-mesh/packages/browser/go/jsutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/jsutil"
)

type Filter struct {
Expand Down
2 changes: 1 addition & 1 deletion orderfilter/validate_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package orderfilter
import (
"errors"

"github.com/0xProject/0x-mesh/packages/browser/go/jsutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/jsutil"
"github.com/0xProject/0x-mesh/zeroex"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"name": "@0x/browser-shim",
"name": "@0x/mesh-browser-shim",
"description": "Bundled Javascript init files to use with `wasmbrowsertest` for testing Go WebAssembly binaries",
"version": "1.0.0",
"main": "./lib/index.js",
Expand All @@ -11,15 +11,15 @@
"lint": "tslint --format stylish --project ."
},
"devDependencies": {
"@types/dexie": "^1.3.1"
},
"dependencies": {
"@0x/mesh-browser-lite": "1.0.0",
"dexie": "^3.0.1",
"@types/dexie": "^1.3.1",
"shx": "^0.3.2",
"ts-loader": "^6.2.1",
"typescript": "^3.9.3",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.10"
},
"dependencies": {
"@0x/mesh-browser-lite": "1.0.0",
"dexie": "^3.0.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"include": ["./src/**/*"],
"references": [
{
"path": "../browser-lite"
"path": "../mesh-browser-lite"
}
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

"github.com/0xProject/0x-mesh/core"
"github.com/0xProject/0x-mesh/orderfilter"
"github.com/0xProject/0x-mesh/packages/browser/go/jsutil"
"github.com/0xProject/0x-mesh/packages/browser/go/providerwrapper"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/jsutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/providerwrapper"
)

// ConvertConfig converts a JavaScript config object into a core.Config. It also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/0xProject/0x-mesh/constants"
"github.com/0xProject/0x-mesh/core"
"github.com/0xProject/0x-mesh/orderfilter"
"github.com/0xProject/0x-mesh/packages/browser/go/browserutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/browserutil"
"github.com/0xProject/0x-mesh/zeroex"
"github.com/0xProject/0x-mesh/zeroex/ordervalidator"
"github.com/0xProject/0x-mesh/zeroex/orderwatch/decoder"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"time"

"github.com/0xProject/0x-mesh/core"
"github.com/0xProject/0x-mesh/packages/browser/go/browserutil"
"github.com/0xProject/0x-mesh/packages/browser/go/jsutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/browserutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/jsutil"
"github.com/0xProject/0x-mesh/zeroex"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"math/rand"
"syscall/js"

"github.com/0xProject/0x-mesh/packages/browser/go/jsutil"
"github.com/0xProject/0x-mesh/packages/mesh-browser/go/jsutil"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
log "github.com/sirupsen/logrus"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
"config": {
"docsPath": "../../docs/browser-bindings/browser"
},
"dependencies": {
"@0x/mesh-browser-lite": "1.0.0",
"base64-arraybuffer": "^0.2.0",
"browserfs": "^1.4.3",
"ethereum-types": "^3.0.0"
},
"devDependencies": {
"@0x/subproviders": "^6.0.5",
"@0x/ts-doc-gen": "^0.0.16",
Expand All @@ -40,5 +34,10 @@
"typescript": "^3.9.3",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
},
"dependencies": {
"@0x/mesh-browser-lite": "1.0.0",
"base64-arraybuffer": "^0.2.0",
"ethereum-types": "^3.0.0"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"exclude": ["./conversion-tests/**/*"],
"references": [
{
"path": "../browser-lite"
"path": "../mesh-browser-lite"
}
]
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"include": ["./src/**/*", "./test/**/*"],
"references": [
{
"path": "../browser"
"path": "../mesh-browser"
}
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@
"url": "https://github.com/0xProject/0x-mesh/issues"
},
"homepage": "https://github.com/0xProject/0x-mesh/rpc/clients/typescript/README.md",
"dependencies": {
"@0x/assert": "^3.0.6",
"@0x/types": "^3.1.2",
"@0x/typescript-typings": "^5.0.2",
"@0x/utils": "^5.4.0",
"uuid": "^3.3.2",
"web3-providers": "^2.0.0-alpha.1",
"websocket": "^1.0.29"
},
"devDependencies": {
"@0x/contract-addresses": "^4.1.0",
"@0x/contracts-erc20": "^3.1.0",
Expand Down Expand Up @@ -76,6 +67,15 @@
"typescript": "3.9.3",
"uuid-validate": "^0.0.3"
},
"dependencies": {
"@0x/assert": "^3.0.6",
"@0x/types": "^3.1.2",
"@0x/typescript-typings": "^5.0.2",
"@0x/utils": "^5.4.0",
"uuid": "^3.3.2",
"web3-providers": "^2.0.0-alpha.1",
"websocket": "^1.0.29"
},
"publishConfig": {
"access": "public"
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "mesh-webpack-lite",
"name": "mesh-webpack-example-lite",
"description": "An example of how to run Mesh directly in the browser using Webpack and the @0x/mesh-browser-lite package.",
"version": "1.0.0",
"main": "index.js",
"license": "Apache-2.0",
"private": true,
"scripts": {
"build": "tsc -b && yarn build:webpack && yarn build:wasm",
"build:wasm": "GOOS=js GOARCH=wasm go build -o ./dist/main.wasm ../browser/go/mesh-browser/main.go",
"build:wasm": "GOOS=js GOARCH=wasm go build -o ./dist/main.wasm ../mesh-browser/go/mesh-browser/main.go",
"build:webpack": "node --max_old_space_size=3072 ./node_modules/.bin/webpack --mode=development",
"clean": "shx rm ./dist/bundle.js || exit 0",
"postinstall:comment": "Remove the go and scripts directories of the mesh browser package to reduce the webpack bundle size",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"include": ["./src/**/*", "./test/**/*"],
"references": [
{
"path": "../browser-lite"
"path": "../mesh-browser-lite"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "mesh-webpack",
"name": "mesh-webpack-example",
"description": "An example of how to run Mesh directly in the browser using Webpack and the @0x/mesh-browser package.",
"version": "1.0.0",
"main": "index.js",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"include": ["./src/**/*", "./test/**/*"],
"references": [
{
"path": "../browser"
"path": "../mesh-browser"
}
]
}
Loading

0 comments on commit d09210d

Please sign in to comment.