diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-12-05 00:56:06 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-12-06 20:48:30 +0800 |
commit | 22de68205b3ef309222d71e72089c75184365d4a (patch) | |
tree | 382c760b1f985d32678ade6599d82fd62ac729ea /packages | |
parent | f76543ebfa83ac4772ea68b668cfd83752f03f6b (diff) | |
download | dexon-sol-tools-22de68205b3ef309222d71e72089c75184365d4a.tar.gz dexon-sol-tools-22de68205b3ef309222d71e72089c75184365d4a.tar.zst dexon-sol-tools-22de68205b3ef309222d71e72089c75184365d4a.zip |
Add version matcher script
Diffstat (limited to 'packages')
-rw-r--r-- | packages/monorepo-scripts/package.json | 33 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/deps_versions.ts | 59 | ||||
-rw-r--r-- | packages/monorepo-scripts/tsconfig.json | 13 | ||||
-rw-r--r-- | packages/monorepo-scripts/tslint.json | 5 |
4 files changed, 110 insertions, 0 deletions
diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json new file mode 100644 index 000000000..57de6581e --- /dev/null +++ b/packages/monorepo-scripts/package.json @@ -0,0 +1,33 @@ +{ + "name": "@0xproject/monorepo-scripts", + "version": "0.0.0", + "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..b07aac995 --- /dev/null +++ b/packages/monorepo-scripts/src/deps_versions.ts @@ -0,0 +1,59 @@ +#!/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; +} + +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; +} + +function getPackageName(path: string): string { + const [dotDot, packageName, packageJSON] = path.split('/'); + return packageName; +} + +const files = globSync('../*/package.json'); +const versionsByDependency: VersionsByDependency = {}; +files.map(path => { + const packageName = getPackageName(path); + 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" + ] +} |