diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-30 18:28:48 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-30 18:28:48 +0800 |
commit | c9df3887316bdc0f7b19c87df21d566047445728 (patch) | |
tree | 7a4a08d7d811d22918caa552f8eaeb2863c53cfc | |
parent | 84b820abc62c0aabea974ab8ed22f3ada05240fb (diff) | |
download | dexon-sol-tools-c9df3887316bdc0f7b19c87df21d566047445728.tar dexon-sol-tools-c9df3887316bdc0f7b19c87df21d566047445728.tar.gz dexon-sol-tools-c9df3887316bdc0f7b19c87df21d566047445728.tar.bz2 dexon-sol-tools-c9df3887316bdc0f7b19c87df21d566047445728.tar.lz dexon-sol-tools-c9df3887316bdc0f7b19c87df21d566047445728.tar.xz dexon-sol-tools-c9df3887316bdc0f7b19c87df21d566047445728.tar.zst dexon-sol-tools-c9df3887316bdc0f7b19c87df21d566047445728.zip |
Add committing and pushing CHANGELOG changes to Github
-rw-r--r-- | packages/monorepo-scripts/package.json | 1 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/custom_prepublish.ts | 19 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/globals.d.ts | 1 |
3 files changed, 15 insertions, 6 deletions
diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index 09b7a340d..e8c7974e3 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -44,6 +44,7 @@ "promisify-child-process": "^1.0.5", "publish-release": "0xproject/publish-release", "rimraf": "^2.6.2", + "semver-diff": "^2.1.0", "semver-sort": "0.0.4" }, "publishConfig": { diff --git a/packages/monorepo-scripts/src/custom_prepublish.ts b/packages/monorepo-scripts/src/custom_prepublish.ts index 98ed3e8d3..2e6b78a71 100644 --- a/packages/monorepo-scripts/src/custom_prepublish.ts +++ b/packages/monorepo-scripts/src/custom_prepublish.ts @@ -12,8 +12,10 @@ import semverSort = require('semver-sort'); import { Changelog, Changes, UpdatedPackage } from './types'; import { utils } from './utils'; +const IS_DRY_RUN = true; const MONOREPO_ROOT_PATH = path.join(__dirname, '../../..'); const TODAYS_TIMESTAMP = moment().unix(); +const LERNA_EXECUTABLE = './node_modules/lerna/bin/lerna.js'; (async () => { const updatedPublicPackages = await getPublicLernaUpdatedPackagesAsync(); @@ -73,18 +75,23 @@ const TODAYS_TIMESTAMP = moment().unix(); const changelogMdPath = path.join(lernaPackage.location, 'CHANGELOG.md'); fs.writeFileSync(changelogMdPath, changelogMd); }); - utils.log(`All CHANGELOGS successfully updated. Please commit and push these changes to development.`); - utils.log(`New package versions are:`); - _.each(packageToVersionChange, (versionChange: string, pkgName: string) => { - utils.log(`${pkgName}: ${versionChange}`); - }); + + if (!IS_DRY_RUN) { + await execAsync(`git add . --all`, { cwd: MONOREPO_ROOT_PATH }); + await execAsync(`git commit -m "Updated CHANGELOGS"`, { cwd: MONOREPO_ROOT_PATH }); + await execAsync(`git push`, { cwd: MONOREPO_ROOT_PATH }); + } + + // _.each(packageToVersionChange, (versionChange: string, pkgName: string) => { + // utils.log(`${pkgName}: ${versionChange}`); + // }); })().catch(err => { utils.log(err); process.exit(1); }); async function getPublicLernaUpdatedPackagesAsync(): Promise<UpdatedPackage[]> { - const result = await execAsync(`./node_modules/lerna/bin/lerna.js updated --json`, { cwd: MONOREPO_ROOT_PATH }); + const result = await execAsync(`${LERNA_EXECUTABLE} updated --json`, { cwd: MONOREPO_ROOT_PATH }); const updatedPackages = JSON.parse(result.stdout); const updatedPublicPackages = _.filter(updatedPackages, updatedPackage => !updatedPackage.private); return updatedPublicPackages; diff --git a/packages/monorepo-scripts/src/globals.d.ts b/packages/monorepo-scripts/src/globals.d.ts index 90adc0b78..c5898d0f5 100644 --- a/packages/monorepo-scripts/src/globals.d.ts +++ b/packages/monorepo-scripts/src/globals.d.ts @@ -1,6 +1,7 @@ declare module 'async-child-process'; declare module 'publish-release'; declare module 'es6-promisify'; +declare module 'semver-diff'; // semver-sort declarations declare module 'semver-sort' { |