diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-12-06 20:52:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-06 20:52:38 +0800 |
commit | 598f1dd2d8a89b0e3ab04b2917138997031bafc6 (patch) | |
tree | b623eb0ed7698b2f0076871fa8bd2bb12298c5c7 /packages/monorepo-scripts | |
parent | f0c27f98b809afda3c750e77dbd3f35ccd29ec01 (diff) | |
parent | 594bd2de1ccb41e34729834d67eba617baf1aa80 (diff) | |
download | dexon-sol-tools-598f1dd2d8a89b0e3ab04b2917138997031bafc6.tar dexon-sol-tools-598f1dd2d8a89b0e3ab04b2917138997031bafc6.tar.gz dexon-sol-tools-598f1dd2d8a89b0e3ab04b2917138997031bafc6.tar.bz2 dexon-sol-tools-598f1dd2d8a89b0e3ab04b2917138997031bafc6.tar.lz dexon-sol-tools-598f1dd2d8a89b0e3ab04b2917138997031bafc6.tar.xz dexon-sol-tools-598f1dd2d8a89b0e3ab04b2917138997031bafc6.tar.zst dexon-sol-tools-598f1dd2d8a89b0e3ab04b2917138997031bafc6.zip |
Merge pull request #250 from 0xProject/feature/airport-experiments
Compare versions script
Diffstat (limited to 'packages/monorepo-scripts')
-rw-r--r-- | packages/monorepo-scripts/package.json | 34 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/deps_versions.ts | 56 | ||||
-rw-r--r-- | packages/monorepo-scripts/tsconfig.json | 13 | ||||
-rw-r--r-- | packages/monorepo-scripts/tslint.json | 5 |
4 files changed, 108 insertions, 0 deletions
diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json new file mode 100644 index 000000000..3c49429e9 --- /dev/null +++ b/packages/monorepo-scripts/package.json @@ -0,0 +1,34 @@ +{ + "name": "@0xproject/monorepo-scripts", + "version": "0.0.0", + "private": true, + "description": "Helper scripts for the monorepo", + "scripts": { + "deps_versions": "node ./lib/deps_versions.js", + "lint": "tslint --project . 'src/**/*.ts'", + "clean": "shx rm -rf lib", + "build": "tsc" + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x.js.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x.js/issues" + }, + "homepage": "https://github.com/0xProject/0x.js/packages/monorepo-scripts/README.md", + "devDependencies": { + "@0xproject/tslint-config": "^0.2.0", + "@types/glob": "^5.0.33", + "@types/node": "^8.0.53", + "shx": "^0.2.2", + "tslint": "5.8.0", + "typescript": "~2.6.1" + }, + "dependencies": { + "chalk": "^2.3.0", + "glob": "^7.1.2", + "lodash": "^4.17.4" + } +} diff --git a/packages/monorepo-scripts/src/deps_versions.ts b/packages/monorepo-scripts/src/deps_versions.ts new file mode 100644 index 000000000..84b024427 --- /dev/null +++ b/packages/monorepo-scripts/src/deps_versions.ts @@ -0,0 +1,56 @@ +#!/usr/bin/env node + +import chalk from 'chalk'; +import * as fs from 'fs'; +import {sync as globSync} from 'glob'; +import * as _ from 'lodash'; + +interface Dependencies { + [depName: string]: string; +} +interface Versions { + [packageName: string]: string; +} +interface VersionsByDependency { + [depName: string]: Versions; +} + +const PACKAGE_JSON_GLOB = '../*/package.json'; + +function log(...args: any[]) { + console.log(...args); // tslint:disable-line:no-console +} + +function getDependencies(path: string): Dependencies { + const file = fs.readFileSync(path).toString(); + const parsed = JSON.parse(file); + const dependencies = { + ...parsed.dependencies, + ...parsed.devDependencies, + }; + return dependencies; +} + +const files = globSync(PACKAGE_JSON_GLOB); +const versionsByDependency: VersionsByDependency = {}; +files.map(path => { + const [_1, packageName, _2] = path.split('/'); + const dependencies = getDependencies(path); + _.map(dependencies, (version: string, depName: string) => { + if (_.isUndefined(versionsByDependency[depName])) { + versionsByDependency[depName] = {}; + } + versionsByDependency[depName][packageName] = version; + }); +}); + +_.map(versionsByDependency, (versions: Versions, depName: string) => { + if (_.uniq(_.values(versions)).length === 1) { + delete versionsByDependency[depName]; + } else { + log(chalk.bold(depName)); + _.map(versions, (version: string, packageName: string) => { + log(`├── ${packageName} -> ${version}`); + }); + } +}); diff --git a/packages/monorepo-scripts/tsconfig.json b/packages/monorepo-scripts/tsconfig.json new file mode 100644 index 000000000..a2d90e5dc --- /dev/null +++ b/packages/monorepo-scripts/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "lib": ["es2015", "dom"], + "outDir": "lib", + "noImplicitAny": true, + "strictNullChecks": true + }, + "include": [ + "./src/**/*" + ] +} diff --git a/packages/monorepo-scripts/tslint.json b/packages/monorepo-scripts/tslint.json new file mode 100644 index 000000000..a07795151 --- /dev/null +++ b/packages/monorepo-scripts/tslint.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "@0xproject/tslint-config" + ] +} |