From 6dec29e214e6c9f222a7673efd97d21b3952b090 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 8 Feb 2018 11:23:37 -0800 Subject: [PATCH 1/2] Simplify standard postpublish script and remove them from some private packages --- packages/0x.js/scripts/postpublish.js | 2 +- packages/abi-gen/scripts/postpublish.js | 12 +------ packages/assert/scripts/postpublish.js | 12 +------ .../scripts/postpublish.js | 12 +------ .../scripts/postpublish.js | 12 +------ packages/deployer/scripts/postpublish.js | 36 +------------------ packages/dev-utils/scripts/postpublish.js | 12 +------ packages/json-schemas/scripts/postpublish.js | 12 +------ .../monorepo-scripts/scripts/postpublish.js | 15 -------- packages/subproviders/scripts/postpublish.js | 11 +----- .../testnet-faucets/scripts/postpublish.js | 15 -------- packages/tslint-config/scripts/postpublish.js | 11 +----- packages/types/scripts/postpublish.js | 11 +----- packages/utils/scripts/postpublish.js | 11 +----- .../scripts/postpublish.js | 12 +------ packages/web3-wrapper/scripts/postpublish.js | 11 +----- scripts/postpublish_utils.js | 13 ++++++- 17 files changed, 26 insertions(+), 194 deletions(-) delete mode 100644 packages/monorepo-scripts/scripts/postpublish.js delete mode 100644 packages/testnet-faucets/scripts/postpublish.js diff --git a/packages/0x.js/scripts/postpublish.js b/packages/0x.js/scripts/postpublish.js index 1be964478f..7cbabd8f61 100644 --- a/packages/0x.js/scripts/postpublish.js +++ b/packages/0x.js/scripts/postpublish.js @@ -15,7 +15,7 @@ postpublish_utils version = result.version; const releaseName = postpublish_utils.getReleaseName(subPackageName, version); const assets = [__dirname + '/../_bundles/index.js', __dirname + '/../_bundles/index.min.js']; - return postpublish_utils.publishReleaseNotes(tag, releaseName, assets); + return postpublish_utils.publishReleaseNotesAsync(tag, releaseName, assets); }) .then(function(release) { console.log('POSTPUBLISH: Release successful, generating docs...'); diff --git a/packages/abi-gen/scripts/postpublish.js b/packages/abi-gen/scripts/postpublish.js index 16d67e03f3..b3e5407c81 100644 --- a/packages/abi-gen/scripts/postpublish.js +++ b/packages/abi-gen/scripts/postpublish.js @@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils - .getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch(function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/assert/scripts/postpublish.js b/packages/assert/scripts/postpublish.js index 16d67e03f3..b3e5407c81 100644 --- a/packages/assert/scripts/postpublish.js +++ b/packages/assert/scripts/postpublish.js @@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils - .getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch(function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/chai-as-promised-typescript-typings/scripts/postpublish.js b/packages/chai-as-promised-typescript-typings/scripts/postpublish.js index 16d67e03f3..b3e5407c81 100644 --- a/packages/chai-as-promised-typescript-typings/scripts/postpublish.js +++ b/packages/chai-as-promised-typescript-typings/scripts/postpublish.js @@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils - .getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch(function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/chai-typescript-typings/scripts/postpublish.js b/packages/chai-typescript-typings/scripts/postpublish.js index 16d67e03f3..b3e5407c81 100644 --- a/packages/chai-typescript-typings/scripts/postpublish.js +++ b/packages/chai-typescript-typings/scripts/postpublish.js @@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils - .getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch(function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/deployer/scripts/postpublish.js b/packages/deployer/scripts/postpublish.js index 24384b228c..b3e5407c81 100644 --- a/packages/deployer/scripts/postpublish.js +++ b/packages/deployer/scripts/postpublish.js @@ -1,39 +1,5 @@ -const execAsync = require('async-child-process').execAsync; const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); -const cwd = __dirname + '/..'; const subPackageName = packageJSON.name; -const S3BucketPath = 's3://connect-docs-jsons/'; - -let tag; -let version; -postpublish_utils - .getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - tag = result.tag; - version = result.version; - const releaseName = postpublish_utils.getReleaseName(subPackageName, version); - return postpublish_utils.publishReleaseNotes(tag, releaseName); - }) - .then(function(release) { - console.log('POSTPUBLISH: Release successful, generating docs...'); - const jsonFilePath = __dirname + '/../' + postpublish_utils.generatedDocsDirectoryName + '/index.json'; - return execAsync('JSON_FILE_PATH=' + jsonFilePath + ' PROJECT_DIR=' + __dirname + '/.. yarn docs:json', { - cwd, - }); - }) - .then(function(result) { - if (result.stderr !== '') { - throw new Error(result.stderr); - } - const fileName = 'v' + version + '.json'; - console.log('POSTPUBLISH: Doc generation successful, uploading docs... as ', fileName); - const s3Url = S3BucketPath + fileName; - return execAsync('S3_URL=' + s3Url + ' yarn upload_docs_json', { - cwd, - }); - }) - .catch(function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/dev-utils/scripts/postpublish.js b/packages/dev-utils/scripts/postpublish.js index 16d67e03f3..b3e5407c81 100644 --- a/packages/dev-utils/scripts/postpublish.js +++ b/packages/dev-utils/scripts/postpublish.js @@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils - .getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch(function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/json-schemas/scripts/postpublish.js b/packages/json-schemas/scripts/postpublish.js index 16d67e03f3..b3e5407c81 100644 --- a/packages/json-schemas/scripts/postpublish.js +++ b/packages/json-schemas/scripts/postpublish.js @@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils - .getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch(function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/monorepo-scripts/scripts/postpublish.js b/packages/monorepo-scripts/scripts/postpublish.js deleted file mode 100644 index 16d67e03f3..0000000000 --- a/packages/monorepo-scripts/scripts/postpublish.js +++ /dev/null @@ -1,15 +0,0 @@ -const postpublish_utils = require('../../../scripts/postpublish_utils'); -const packageJSON = require('../package.json'); - -const subPackageName = packageJSON.name; - -postpublish_utils - .getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch(function(err) { - throw err; - }); diff --git a/packages/subproviders/scripts/postpublish.js b/packages/subproviders/scripts/postpublish.js index 7fa452b081..b3e5407c81 100644 --- a/packages/subproviders/scripts/postpublish.js +++ b/packages/subproviders/scripts/postpublish.js @@ -2,13 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils.getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch (function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/testnet-faucets/scripts/postpublish.js b/packages/testnet-faucets/scripts/postpublish.js deleted file mode 100644 index 16d67e03f3..0000000000 --- a/packages/testnet-faucets/scripts/postpublish.js +++ /dev/null @@ -1,15 +0,0 @@ -const postpublish_utils = require('../../../scripts/postpublish_utils'); -const packageJSON = require('../package.json'); - -const subPackageName = packageJSON.name; - -postpublish_utils - .getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch(function(err) { - throw err; - }); diff --git a/packages/tslint-config/scripts/postpublish.js b/packages/tslint-config/scripts/postpublish.js index 7fa452b081..b3e5407c81 100644 --- a/packages/tslint-config/scripts/postpublish.js +++ b/packages/tslint-config/scripts/postpublish.js @@ -2,13 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils.getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch (function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/types/scripts/postpublish.js b/packages/types/scripts/postpublish.js index 7fa452b081..b3e5407c81 100644 --- a/packages/types/scripts/postpublish.js +++ b/packages/types/scripts/postpublish.js @@ -2,13 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils.getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch (function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/utils/scripts/postpublish.js b/packages/utils/scripts/postpublish.js index 7fa452b081..b3e5407c81 100644 --- a/packages/utils/scripts/postpublish.js +++ b/packages/utils/scripts/postpublish.js @@ -2,13 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils.getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch (function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/web3-typescript-typings/scripts/postpublish.js b/packages/web3-typescript-typings/scripts/postpublish.js index 16d67e03f3..b3e5407c81 100644 --- a/packages/web3-typescript-typings/scripts/postpublish.js +++ b/packages/web3-typescript-typings/scripts/postpublish.js @@ -2,14 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils - .getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch(function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/packages/web3-wrapper/scripts/postpublish.js b/packages/web3-wrapper/scripts/postpublish.js index 7fa452b081..b3e5407c81 100644 --- a/packages/web3-wrapper/scripts/postpublish.js +++ b/packages/web3-wrapper/scripts/postpublish.js @@ -2,13 +2,4 @@ const postpublish_utils = require('../../../scripts/postpublish_utils'); const packageJSON = require('../package.json'); const subPackageName = packageJSON.name; - -postpublish_utils.getLatestTagAndVersionAsync(subPackageName) - .then(function(result) { - const releaseName = postpublish_utils.getReleaseName(subPackageName, result.version); - const assets = []; - return postpublish_utils.publishReleaseNotes(result.tag, releaseName, assets); - }) - .catch (function(err) { - throw err; - }); +postpublish_utils.standardPostPublishAsync(subPackageName); \ No newline at end of file diff --git a/scripts/postpublish_utils.js b/scripts/postpublish_utils.js index c4ca917dae..9603827dba 100644 --- a/scripts/postpublish_utils.js +++ b/scripts/postpublish_utils.js @@ -29,7 +29,7 @@ module.exports = { }; }); }, - publishReleaseNotes: function(tag, releaseName, assets) { + publishReleaseNotesAsync: function(tag, releaseName, assets) { console.log('POSTPUBLISH: Releasing ', releaseName, '...'); return publishReleaseAsync({ token: githubPersonalAccessToken, @@ -49,5 +49,16 @@ module.exports = { const releaseName = subPackageName + ' v' + version; return releaseName; }, + standardPostPublishAsync: function(subPackageName) { + return getLatestTagAndVersionAsync(subPackageName) + .then(function(result) { + const releaseName = getReleaseName(subPackageName, result.version); + const assets = []; + return publishReleaseNotesAsync(result.tag, releaseName, assets); + }) + .catch(function(err) { + throw err; + }); + }, generatedDocsDirectoryName, }; From d7a7e28925257860b4fea9c523eb46c8b98ab511 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Thu, 8 Feb 2018 12:02:04 -0800 Subject: [PATCH 2/2] Fix missing references to 'this' --- scripts/postpublish_utils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/postpublish_utils.js b/scripts/postpublish_utils.js index 9603827dba..7ce01189ce 100644 --- a/scripts/postpublish_utils.js +++ b/scripts/postpublish_utils.js @@ -50,12 +50,12 @@ module.exports = { return releaseName; }, standardPostPublishAsync: function(subPackageName) { - return getLatestTagAndVersionAsync(subPackageName) + return this.getLatestTagAndVersionAsync(subPackageName) .then(function(result) { - const releaseName = getReleaseName(subPackageName, result.version); + const releaseName = this.getReleaseName(subPackageName, result.version); const assets = []; - return publishReleaseNotesAsync(result.tag, releaseName, assets); - }) + return this.publishReleaseNotesAsync(result.tag, releaseName, assets); + }.bind(this)) .catch(function(err) { throw err; });