diff options
author | Fabio Berger <me@fabioberger.com> | 2018-04-10 13:49:13 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-04-10 13:49:13 +0800 |
commit | efdbc1ff6cc3b50a6ccd36ebb185d7f09056c2a8 (patch) | |
tree | 96a6a073193572fbece6e89b11f78eecaff3e1d4 /packages/monorepo-scripts/src/publish.ts | |
parent | a9b5faa7874cf94caa8908bada098a3968fe6de8 (diff) | |
download | dexon-sol-tools-efdbc1ff6cc3b50a6ccd36ebb185d7f09056c2a8.tar dexon-sol-tools-efdbc1ff6cc3b50a6ccd36ebb185d7f09056c2a8.tar.gz dexon-sol-tools-efdbc1ff6cc3b50a6ccd36ebb185d7f09056c2a8.tar.bz2 dexon-sol-tools-efdbc1ff6cc3b50a6ccd36ebb185d7f09056c2a8.tar.lz dexon-sol-tools-efdbc1ff6cc3b50a6ccd36ebb185d7f09056c2a8.tar.xz dexon-sol-tools-efdbc1ff6cc3b50a6ccd36ebb185d7f09056c2a8.tar.zst dexon-sol-tools-efdbc1ff6cc3b50a6ccd36ebb185d7f09056c2a8.zip |
Add step to publishing that upload staging doc jsons, deploys staging website, opens every docs page and asks the dev to confirm that each one renders properly before publishing
Diffstat (limited to 'packages/monorepo-scripts/src/publish.ts')
-rw-r--r-- | packages/monorepo-scripts/src/publish.ts | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index f0fb00acd..ebc30def4 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -1,11 +1,14 @@ #!/usr/bin/env node +import * as promisify from 'es6-promisify'; import * as fs from 'fs'; import lernaGetPackages = require('lerna-get-packages'); import * as _ from 'lodash'; import * as moment from 'moment'; +import opn = require('opn'); import * as path from 'path'; import { exec as execAsync, spawn } from 'promisify-child-process'; +import * as prompt from 'prompt'; import semverDiff = require('semver-diff'); import semverSort = require('semver-sort'); @@ -13,6 +16,8 @@ import { constants } from './constants'; import { Changelog, Changes, PackageToVersionChange, SemVerIndex, UpdatedPackage } from './types'; import { utils } from './utils'; +const DOC_GEN_COMMAND = 'docs:json'; +const NPM_NAMESPACE = '@0xproject/'; const IS_DRY_RUN = process.env.IS_DRY_RUN === 'true'; const TODAYS_TIMESTAMP = moment().unix(); const LERNA_EXECUTABLE = './node_modules/lerna/bin/lerna.js'; @@ -21,11 +26,23 @@ const semverNameToIndex: { [semver: string]: number } = { minor: SemVerIndex.Minor, major: SemVerIndex.Major, }; +const packageNameToWebsitePath: { [name: string]: string } = { + '0x.js': '0xjs', + 'web3-wrapper': 'web3_wrapper', + contracts: 'contracts', + connect: 'connect', + 'json-schemas': 'json-schemas', + deployer: 'deployer', + 'sol-cov': 'sol-cov', + subproviders: 'subproviders', +}; (async () => { // Fetch public, updated Lerna packages const updatedPublicLernaPackages = await getUpdatedPublicLernaPackagesAsync(); + await confirmDocPagesRenderAsync(updatedPublicLernaPackages); + // Update CHANGELOGs const updatedPublicLernaPackageNames = _.map(updatedPublicLernaPackages, pkg => pkg.package.name); utils.log(`Will update CHANGELOGs and publish: \n${updatedPublicLernaPackageNames.join('\n')}\n`); @@ -48,6 +65,47 @@ const semverNameToIndex: { [semver: string]: number } = { process.exit(1); }); +async function confirmDocPagesRenderAsync(packages: LernaPackage[]) { + // push docs to staging + utils.log("Upload all docJson's to S3 staging..."); + await execAsync(`yarn lerna:stage_docs`, { cwd: constants.monorepoRootPath }); + + // deploy website to staging + utils.log('Deploy website to staging...'); + const pathToWebsite = `${constants.monorepoRootPath}/packages/website`; + await execAsync(`yarn deploy_staging`, { cwd: pathToWebsite }); + + const packagesWithDocs = _.filter(packages, pkg => { + const scriptsIfExists = pkg.package.scripts; + if (_.isUndefined(scriptsIfExists)) { + throw new Error('Found a public package without any scripts in package.json'); + } + return !_.isUndefined(scriptsIfExists[DOC_GEN_COMMAND]); + }); + _.each(packagesWithDocs, pkg => { + const name = pkg.package.name; + const nameWithoutPrefix = _.startsWith(name, NPM_NAMESPACE) ? name.split('@0xproject/')[1] : name; + const docSegmentIfExists = packageNameToWebsitePath[nameWithoutPrefix]; + if (_.isUndefined(docSegmentIfExists)) { + throw new Error( + `Found package '${name}' with doc commands but no corresponding docSegment in monorepo_scripts +package.ts. Please add an entry for it and try again.`, + ); + } + const link = `${constants.stagingWebsite}/docs/${docSegmentIfExists}`; + opn(link); + }); + + prompt.start(); + const message = 'Do all the doc pages render properly? (yn)'; + const result = await promisify(prompt.get)([message]); + const didConfirm = result[message] === 'y'; + if (!didConfirm) { + utils.log('Publish process aborted.'); + process.exit(0); + } +} + async function pushChangelogsToGithubAsync() { await execAsync(`git add . --all`, { cwd: constants.monorepoRootPath }); await execAsync(`git commit -m "Updated CHANGELOGS"`, { cwd: constants.monorepoRootPath }); |