diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/0x.js/.npmignore | 2 | ||||
-rw-r--r-- | packages/abi-gen/README.md | 4 | ||||
-rw-r--r-- | packages/contract-wrappers/.npmignore | 2 | ||||
-rw-r--r-- | packages/monorepo-scripts/CHANGELOG.json | 4 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/utils/github_release_utils.ts | 12 | ||||
-rw-r--r-- | packages/sol-compiler/CHANGELOG.json | 9 | ||||
-rw-r--r-- | packages/sol-compiler/src/compiler.ts | 9 | ||||
-rw-r--r-- | packages/sol-resolver/CHANGELOG.json | 9 | ||||
-rw-r--r-- | packages/sol-resolver/src/resolvers/npm_resolver.ts | 15 |
9 files changed, 50 insertions, 16 deletions
diff --git a/packages/0x.js/.npmignore b/packages/0x.js/.npmignore index d7ee80c97..312a23faa 100644 --- a/packages/0x.js/.npmignore +++ b/packages/0x.js/.npmignore @@ -4,7 +4,7 @@ webpack.config.js yarn-error.log test/ /src/ -/contract_templates/ +/abi-gen-templates/ /generated_docs/ /scripts/ /lib/src/monorepo_scripts/ diff --git a/packages/abi-gen/README.md b/packages/abi-gen/README.md index 20b9d4f30..214d8f257 100644 --- a/packages/abi-gen/README.md +++ b/packages/abi-gen/README.md @@ -4,7 +4,7 @@ This package allows you to generate TypeScript contract wrappers from ABI files. It's heavily inspired by [Geth abigen](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) but takes a different approach. You can write your custom handlebars templates which will allow you to seamlessly integrate the generated code into your existing codebase with existing conventions. -[Here](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/contract_templates) are the templates used to generate the contract wrappers used by 0x.js.e +[Here](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/abi-gen-templates) are the templates used to generate the contract wrappers used by 0x.js.e ## Installation @@ -44,7 +44,7 @@ You need to also specify the location of your main template used for every contr ## How to write custom templates? -The best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates) and start adjusting them for your needs. +The best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x-monorepo/tree/development/packages/abi-gen-templates) and start adjusting them for your needs. We use [handlebars](http://handlebarsjs.com/) template engine under the hood. You need to have a master template called `contract.mustache`. it will be used to generate each contract wrapper. Although - you don't need and probably shouldn't write all your logic in a single template file. You can write [partial templates](http://handlebarsjs.com/partials.html) and as long as they are within a partials folder - they will be registered and available. diff --git a/packages/contract-wrappers/.npmignore b/packages/contract-wrappers/.npmignore index 6a3eb57bd..6a222fd45 100644 --- a/packages/contract-wrappers/.npmignore +++ b/packages/contract-wrappers/.npmignore @@ -5,7 +5,7 @@ yarn-error.log test/ /src/ /_bundles/ -/contract_templates/ +/abi-gen-templates/ /generated_docs/ /scripts/ /lib/src/monorepo_scripts/ diff --git a/packages/monorepo-scripts/CHANGELOG.json b/packages/monorepo-scripts/CHANGELOG.json index 170a97a33..428168437 100644 --- a/packages/monorepo-scripts/CHANGELOG.json +++ b/packages/monorepo-scripts/CHANGELOG.json @@ -13,6 +13,10 @@ { "note": "Add ForwarderError to the IGNORED_EXCESSIVE_TYPES array", "pr": 1147 + }, + { + "note": "Fix a bug when hardcoded CHANGELOG paths cause fetching release notes to fail", + "pr": 1311 } ] }, diff --git a/packages/monorepo-scripts/src/utils/github_release_utils.ts b/packages/monorepo-scripts/src/utils/github_release_utils.ts index 7434d397e..e63244b46 100644 --- a/packages/monorepo-scripts/src/utils/github_release_utils.ts +++ b/packages/monorepo-scripts/src/utils/github_release_utils.ts @@ -41,7 +41,7 @@ export async function publishReleaseNotesAsync(packagesToPublish: Package[], isD let assets: string[] = []; let aggregateNotes = ''; _.each(packagesToPublish, pkg => { - aggregateNotes += getReleaseNotesForPackage(pkg.packageJson.name); + aggregateNotes += getReleaseNotesForPackage(pkg.location, pkg.packageJson.name); const packageAssets = _.get(pkg.packageJson, 'config.postpublish.assets'); if (!_.isUndefined(packageAssets)) { @@ -88,14 +88,8 @@ function adjustAssetPaths(assets: string[]): string[] { return finalAssets; } -function getReleaseNotesForPackage(packageName: string): string { - const packageNameWithoutNamespace = packageName.replace('@0x/', ''); - const changelogJSONPath = path.join( - constants.monorepoRootPath, - 'packages', - packageNameWithoutNamespace, - 'CHANGELOG.json', - ); +function getReleaseNotesForPackage(packageLocation: string, packageName: string): string { + const changelogJSONPath = path.join(packageLocation, 'CHANGELOG.json'); const changelogJSON = readFileSync(changelogJSONPath, 'utf-8'); const changelogs = JSON.parse(changelogJSON); const latestLog = changelogs[0]; diff --git a/packages/sol-compiler/CHANGELOG.json b/packages/sol-compiler/CHANGELOG.json index e9274f64e..fe077b6cc 100644 --- a/packages/sol-compiler/CHANGELOG.json +++ b/packages/sol-compiler/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "version": "1.1.15", + "changes": [ + { + "note": "Fix bug where we were appending base path to absolute imports (e.g NPM imports)", + "pr": 1311 + } + ] + }, + { "timestamp": 1543401373, "version": "1.1.14", "changes": [ diff --git a/packages/sol-compiler/src/compiler.ts b/packages/sol-compiler/src/compiler.ts index 8ee7fa4a9..cba67f292 100644 --- a/packages/sol-compiler/src/compiler.ts +++ b/packages/sol-compiler/src/compiler.ts @@ -394,7 +394,14 @@ export class Compiler { // const lastPathSeparatorPos = contractPath.lastIndexOf('/'); const contractFolder = lastPathSeparatorPos === -1 ? '' : contractPath.slice(0, lastPathSeparatorPos + 1); - importPath = path.resolve('/' + contractFolder, importPath).replace('/', ''); + if (importPath.startsWith('.')) { + /** + * Some imports path are relative ("../Token.sol", "./Wallet.sol") + * while others are absolute ("Token.sol", "@0x/contracts/Wallet.sol") + * And we need to append the base path for relative imports. + */ + importPath = path.resolve('/' + contractFolder, importPath).replace('/', ''); + } if (_.isUndefined(sourcesToAppendTo[importPath])) { sourcesToAppendTo[importPath] = { id: fullSources[importPath].id }; diff --git a/packages/sol-resolver/CHANGELOG.json b/packages/sol-resolver/CHANGELOG.json index fdfb4009b..4c9e612d7 100644 --- a/packages/sol-resolver/CHANGELOG.json +++ b/packages/sol-resolver/CHANGELOG.json @@ -1,5 +1,14 @@ [ { + "version": "1.1.0", + "changes": [ + { + "note": "NPMResolver now supports scoped packages", + "pr": 1311 + } + ] + }, + { "timestamp": 1542821676, "version": "1.0.17", "changes": [ diff --git a/packages/sol-resolver/src/resolvers/npm_resolver.ts b/packages/sol-resolver/src/resolvers/npm_resolver.ts index a2df0dcad..eeb2b5493 100644 --- a/packages/sol-resolver/src/resolvers/npm_resolver.ts +++ b/packages/sol-resolver/src/resolvers/npm_resolver.ts @@ -1,4 +1,5 @@ import * as fs from 'fs'; +import * as _ from 'lodash'; import * as path from 'path'; import { ContractSource } from '../types'; @@ -13,12 +14,22 @@ export class NPMResolver extends Resolver { } public resolveIfExists(importPath: string): ContractSource | undefined { if (!importPath.startsWith('/')) { - const [packageName, ...other] = importPath.split('/'); + let packageName; + let packageScopeIfExists; + let other; + if (_.startsWith(importPath, '@')) { + [packageScopeIfExists, packageName, ...other] = importPath.split('/'); + } else { + [packageName, ...other] = importPath.split('/'); + } const pathWithinPackage = path.join(...other); let currentPath = this._packagePath; const ROOT_PATH = '/'; while (currentPath !== ROOT_PATH) { - const lookupPath = path.join(currentPath, 'node_modules', packageName, pathWithinPackage); + const packagePath = _.isUndefined(packageScopeIfExists) + ? packageName + : path.join(packageScopeIfExists, packageName); + const lookupPath = path.join(currentPath, 'node_modules', packagePath, pathWithinPackage); if (fs.existsSync(lookupPath) && fs.lstatSync(lookupPath).isFile()) { const fileContent = fs.readFileSync(lookupPath).toString(); return { |