From bddcebfbb1ca81199f273b6571ace0da14cf105a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 19:09:24 +0200 Subject: Allow registry to be configured in lerna.json --- packages/monorepo-scripts/src/prepublish_checks.ts | 2 +- packages/monorepo-scripts/src/publish.ts | 3 +-- packages/monorepo-scripts/src/utils/npm_utils.ts | 6 ++++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/prepublish_checks.ts b/packages/monorepo-scripts/src/prepublish_checks.ts index 431e848ca..683c26094 100644 --- a/packages/monorepo-scripts/src/prepublish_checks.ts +++ b/packages/monorepo-scripts/src/prepublish_checks.ts @@ -50,7 +50,7 @@ async function checkGitTagsForNextVersionAndDeleteIfExistAsync(updatedPublicPack async function checkCurrentVersionMatchesLatestPublishedNPMPackageAsync( updatedPublicPackages: Package[], ): Promise { - utils.log('Check package versions against npmjs.org...'); + utils.log('Check package versions against npm registry...'); const versionMismatches = []; for (const pkg of updatedPublicPackages) { const packageName = pkg.packageJson.name; diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index c44e1f85e..53492e012 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -172,8 +172,7 @@ async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise< async function lernaPublishAsync(packageToVersionChange: { [name: string]: string }): Promise { // HACK: Lerna publish does not provide a way to specify multiple package versions via // flags so instead we need to interact with their interactive prompt interface. - const PACKAGE_REGISTRY = 'https://registry.npmjs.org/'; - const child = spawn('lerna', ['publish', `--registry=${PACKAGE_REGISTRY}`], { + const child = spawn('lerna', ['publish'], { cwd: constants.monorepoRootPath, }); let shouldPrintOutput = false; diff --git a/packages/monorepo-scripts/src/utils/npm_utils.ts b/packages/monorepo-scripts/src/utils/npm_utils.ts index cc1e046e7..7c8310459 100644 --- a/packages/monorepo-scripts/src/utils/npm_utils.ts +++ b/packages/monorepo-scripts/src/utils/npm_utils.ts @@ -1,9 +1,11 @@ +import * as fs from 'fs'; import 'isomorphic-fetch'; import * as _ from 'lodash'; import { PackageRegistryJson } from '../types'; -const NPM_REGISTRY_BASE_URL = 'https://registry.npmjs.org'; +const lernaJson = JSON.parse(fs.readFileSync('lerna.json').toString()); +const NPM_REGISTRY_BASE_URL = lernaJson.registry; const SUCCESS_STATUS = 200; const NOT_FOUND_STATUS = 404; @@ -15,7 +17,7 @@ export const npmUtils = { if (response.status === NOT_FOUND_STATUS) { return undefined; } else if (response.status !== SUCCESS_STATUS) { - throw new Error(`Request to ${url} failed. Check your internet connection and that npmjs.org is up.`); + throw new Error(`Request to ${url} failed. Check your internet connection and that npm registry is up.`); } const packageRegistryJson = await response.json(); return packageRegistryJson; -- cgit v1.2.3 From e2d027e2521c8695bb16128fb8f038e2455e5481 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 19:09:35 +0200 Subject: Add skip-git for testing --- packages/monorepo-scripts/src/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 53492e012..958cb58ba 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -172,7 +172,7 @@ async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise< async function lernaPublishAsync(packageToVersionChange: { [name: string]: string }): Promise { // HACK: Lerna publish does not provide a way to specify multiple package versions via // flags so instead we need to interact with their interactive prompt interface. - const child = spawn('lerna', ['publish'], { + const child = spawn('lerna', ['publish', `--skip-git`], { cwd: constants.monorepoRootPath, }); let shouldPrintOutput = false; -- cgit v1.2.3 From 3af2ef84390fef96f0af60912cae055ddffe953a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 19:11:48 +0200 Subject: Revert "Revert "Publish"" This reverts commit a66ccaa1da2af753038bf22a5e7e63bdc307bf2f. --- packages/monorepo-scripts/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index e73a27aae..997338ff0 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/monorepo-scripts", - "version": "1.0.0", + "version": "1.0.1", "engines": { "node": ">=6.12" }, @@ -47,8 +47,8 @@ "chalk": "^2.3.0", "es6-promisify": "^5.0.0", "glob": "^7.1.2", - "lodash": "^4.17.4", "isomorphic-fetch": "2.2.1", + "lodash": "^4.17.4", "moment": "2.21.0", "opn": "^5.3.0", "promisify-child-process": "^1.0.5", -- cgit v1.2.3 From 195c3af84e080b51c4258739da0e996f690f52f5 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 19:56:53 +0200 Subject: Fix lerna publish to include publishing prerelease versions --- packages/monorepo-scripts/src/publish.ts | 23 ++++++++++------------- packages/monorepo-scripts/src/types.ts | 5 +++++ 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 958cb58ba..e22d9800c 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -19,11 +19,6 @@ 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 semverNameToIndex: { [semver: string]: number } = { - patch: SemVerIndex.Patch, - minor: SemVerIndex.Minor, - major: SemVerIndex.Major, -}; const packageNameToWebsitePath: { [name: string]: string } = { '0x.js': '0xjs', 'web3-wrapper': 'web3_wrapper', @@ -176,6 +171,7 @@ async function lernaPublishAsync(packageToVersionChange: { [name: string]: strin cwd: constants.monorepoRootPath, }); let shouldPrintOutput = false; + let packageName: string; child.stdout.on('data', (data: Buffer) => { const output = data.toString('utf8'); if (shouldPrintOutput) { @@ -184,14 +180,15 @@ async function lernaPublishAsync(packageToVersionChange: { [name: string]: strin const isVersionPrompt = _.includes(output, 'Select a new version'); if (isVersionPrompt) { const outputStripLeft = output.split('new version for ')[1]; - const packageName = outputStripLeft.split(' ')[0]; - let versionChange = packageToVersionChange[packageName]; - const isPrivatePackage = _.isUndefined(versionChange); - if (isPrivatePackage) { - versionChange = 'patch'; // Always patch updates to private packages. - } - const semVerIndex = semverNameToIndex[versionChange]; - child.stdin.write(`${semVerIndex}\n`); + packageName = outputStripLeft.split(' ')[0]; + child.stdin.write(`${SemVerIndex.Custom}\n`); + return; + } + const isCustomVersionPrompt = _.includes(output, 'Enter a custom version'); + if (isCustomVersionPrompt) { + const versionChange = packageToVersionChange[packageName]; + child.stdin.write(`${versionChange}\n`); + return; } const isFinalPrompt = _.includes(output, 'Are you sure you want to publish the above changes?'); if (isFinalPrompt && !IS_DRY_RUN) { diff --git a/packages/monorepo-scripts/src/types.ts b/packages/monorepo-scripts/src/types.ts index 9f991c86c..62d52d7bf 100644 --- a/packages/monorepo-scripts/src/types.ts +++ b/packages/monorepo-scripts/src/types.ts @@ -22,6 +22,11 @@ export enum SemVerIndex { Patch, Minor, Major, + Prepatch, + Preminor, + Premajor, + Prerelease, + Custom, } export interface PackageToVersionChange { -- cgit v1.2.3 From c8108a1db2c258eb4a5c3485cc6facf116ab4f57 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 20:12:18 +0200 Subject: Temporarily uncommented parts of publish flow --- packages/monorepo-scripts/src/postpublish_utils.ts | 42 +++++++++++----------- packages/monorepo-scripts/src/publish.ts | 4 +-- 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/postpublish_utils.ts b/packages/monorepo-scripts/src/postpublish_utils.ts index 3ecb7b7c5..8c9d95e44 100644 --- a/packages/monorepo-scripts/src/postpublish_utils.ts +++ b/packages/monorepo-scripts/src/postpublish_utils.ts @@ -51,27 +51,27 @@ export const postpublishUtils = { return configs; }, async runAsync(packageJSON: any, tsConfigJSON: any, cwd: string): Promise { - const configs = postpublishUtils.generateConfig(packageJSON, tsConfigJSON, cwd); - await postpublishUtils.publishReleaseNotesAsync( - configs.cwd, - configs.packageName, - configs.version, - configs.assets, - ); - if ( - !_.isUndefined(configs.docPublishConfigs.s3BucketPath) || - !_.isUndefined(configs.docPublishConfigs.s3StagingBucketPath) - ) { - utils.log('POSTPUBLISH: Release successful, generating docs...'); - await postpublishUtils.generateAndUploadDocsAsync( - configs.cwd, - configs.docPublishConfigs.fileIncludes, - configs.version, - configs.docPublishConfigs.s3BucketPath, - ); - } else { - utils.log(`POSTPUBLISH: No S3Bucket config found for ${packageJSON.name}. Skipping doc JSON generation.`); - } + // const configs = postpublishUtils.generateConfig(packageJSON, tsConfigJSON, cwd); + // await postpublishUtils.publishReleaseNotesAsync( + // configs.cwd, + // configs.packageName, + // configs.version, + // configs.assets, + // ); + // if ( + // !_.isUndefined(configs.docPublishConfigs.s3BucketPath) || + // !_.isUndefined(configs.docPublishConfigs.s3StagingBucketPath) + // ) { + // utils.log('POSTPUBLISH: Release successful, generating docs...'); + // await postpublishUtils.generateAndUploadDocsAsync( + // configs.cwd, + // configs.docPublishConfigs.fileIncludes, + // configs.version, + // configs.docPublishConfigs.s3BucketPath, + // ); + // } else { + // utils.log(`POSTPUBLISH: No S3Bucket config found for ${packageJSON.name}. Skipping doc JSON generation.`); + // } }, async publishDocsToStagingAsync(packageJSON: any, tsConfigJSON: any, cwd: string): Promise { const configs = postpublishUtils.generateConfig(packageJSON, tsConfigJSON, cwd); diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index e22d9800c..77c768f4e 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -37,7 +37,7 @@ const packageNameToWebsitePath: { [name: string]: string } = { const shouldIncludePrivate = false; const updatedPublicPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate); - await confirmDocPagesRenderAsync(updatedPublicPackages); + // await confirmDocPagesRenderAsync(updatedPublicPackages); // Update CHANGELOGs const updatedPublicPackageNames = _.map(updatedPublicPackages, pkg => pkg.packageJson.name); @@ -46,7 +46,7 @@ const packageNameToWebsitePath: { [name: string]: string } = { // Push changelog changes to Github if (!IS_DRY_RUN) { - await pushChangelogsToGithubAsync(); + // await pushChangelogsToGithubAsync(); } // Call LernaPublish -- cgit v1.2.3 From 76eab5d3ecfa5fe3b09392c54eb600e484576abc Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 20:21:49 +0200 Subject: Fix publish to give lerna actual version rather then the semver diff --- packages/monorepo-scripts/src/publish.ts | 22 +++++++++++----------- packages/monorepo-scripts/src/types.ts | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 77c768f4e..6e5144e83 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -11,7 +11,7 @@ import semverDiff = require('semver-diff'); import semverSort = require('semver-sort'); import { constants } from './constants'; -import { Package, PackageToVersionChange, SemVerIndex, VersionChangelog } from './types'; +import { Package, PackageToNextVersion, SemVerIndex, VersionChangelog } from './types'; import { changelogUtils } from './utils/changelog_utils'; import { utils } from './utils/utils'; @@ -42,7 +42,7 @@ const packageNameToWebsitePath: { [name: string]: string } = { // Update CHANGELOGs const updatedPublicPackageNames = _.map(updatedPublicPackages, pkg => pkg.packageJson.name); utils.log(`Will update CHANGELOGs and publish: \n${updatedPublicPackageNames.join('\n')}\n`); - const packageToVersionChange = await updateChangeLogsAsync(updatedPublicPackages); + const packageToNextVersion = await updateChangeLogsAsync(updatedPublicPackages); // Push changelog changes to Github if (!IS_DRY_RUN) { @@ -51,11 +51,11 @@ const packageNameToWebsitePath: { [name: string]: string } = { // Call LernaPublish utils.log('Version updates to apply:'); - _.each(packageToVersionChange, (versionChange: string, packageName: string) => { + _.each(packageToNextVersion, (versionChange: string, packageName: string) => { utils.log(`${packageName} -> ${versionChange}`); }); utils.log(`Calling 'lerna publish'...`); - await lernaPublishAsync(packageToVersionChange); + await lernaPublishAsync(packageToNextVersion); })().catch(err => { utils.log(err); process.exit(1); @@ -110,8 +110,8 @@ async function pushChangelogsToGithubAsync(): Promise { utils.log(`Pushed CHANGELOG updates to Github`); } -async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise { - const packageToVersionChange: PackageToVersionChange = {}; +async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise { + const packageToNextVersion: PackageToNextVersion = {}; for (const pkg of updatedPublicPackages) { const packageName = pkg.packageJson.name; let changelog = changelogUtils.getChangelogOrCreateIfMissing(packageName, pkg.location); @@ -138,7 +138,7 @@ async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise< ], }; changelog = [newChangelogEntry, ...changelog]; - packageToVersionChange[packageName] = semverDiff(currentVersion, nextPatchVersionIfValid); + packageToNextVersion[packageName] = nextPatchVersionIfValid; } else { // Update existing entry with timestamp const lastEntry = changelog[0]; @@ -149,7 +149,7 @@ async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise< const proposedNextVersion = lastEntry.version; lastEntry.version = updateVersionNumberIfNeeded(currentVersion, proposedNextVersion); changelog[0] = lastEntry; - packageToVersionChange[packageName] = semverDiff(currentVersion, lastEntry.version); + packageToNextVersion[packageName] = lastEntry.version; } // Save updated CHANGELOG.json @@ -161,10 +161,10 @@ async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise< utils.log(`${packageName}: Updated CHANGELOG.md`); } - return packageToVersionChange; + return packageToNextVersion; } -async function lernaPublishAsync(packageToVersionChange: { [name: string]: string }): Promise { +async function lernaPublishAsync(packageToNextVersion: { [name: string]: string }): Promise { // HACK: Lerna publish does not provide a way to specify multiple package versions via // flags so instead we need to interact with their interactive prompt interface. const child = spawn('lerna', ['publish', `--skip-git`], { @@ -186,7 +186,7 @@ async function lernaPublishAsync(packageToVersionChange: { [name: string]: strin } const isCustomVersionPrompt = _.includes(output, 'Enter a custom version'); if (isCustomVersionPrompt) { - const versionChange = packageToVersionChange[packageName]; + const versionChange = packageToNextVersion[packageName]; child.stdin.write(`${versionChange}\n`); return; } diff --git a/packages/monorepo-scripts/src/types.ts b/packages/monorepo-scripts/src/types.ts index 62d52d7bf..c0622debc 100644 --- a/packages/monorepo-scripts/src/types.ts +++ b/packages/monorepo-scripts/src/types.ts @@ -29,7 +29,7 @@ export enum SemVerIndex { Custom, } -export interface PackageToVersionChange { +export interface PackageToNextVersion { [name: string]: string; } -- cgit v1.2.3 From b110d95de14f55a2cc65fbb8a886872adcd9eea5 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 20:29:14 +0200 Subject: testing --- packages/monorepo-scripts/src/publish.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 6e5144e83..820dbc86e 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -187,6 +187,9 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string const isCustomVersionPrompt = _.includes(output, 'Enter a custom version'); if (isCustomVersionPrompt) { const versionChange = packageToNextVersion[packageName]; + if (_.isUndefined(versionChange)) { + console.log('versionChange', versionChange, ' UNDEFINED!'); + } child.stdin.write(`${versionChange}\n`); return; } -- cgit v1.2.3 From c9ee526d8b34638e457db32b9df801c05c197eea Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 20:30:51 +0200 Subject: more bogus --- packages/monorepo-scripts/src/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 820dbc86e..df93a46a0 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -188,7 +188,7 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string if (isCustomVersionPrompt) { const versionChange = packageToNextVersion[packageName]; if (_.isUndefined(versionChange)) { - console.log('versionChange', versionChange, ' UNDEFINED!'); + console.log('packageName', packageName, 'versionChange', versionChange, ' UNDEFINED!'); } child.stdin.write(`${versionChange}\n`); return; -- cgit v1.2.3 From 15bbbb37623845f5bb425e5ae3dbd0e02154cb0c Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 20:36:03 +0200 Subject: Make sure private packages have a next version --- packages/monorepo-scripts/src/publish.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index df93a46a0..9268de796 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -122,6 +122,14 @@ async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise< currentVersion, changelog, ); + if (pkg.packageJson.private) { + const nextPatchVersionIfValid = semver.inc(currentVersion, 'patch'); + if (!_.isNull(nextPatchVersionIfValid)) { + packageToNextVersion[packageName] = nextPatchVersionIfValid; + } else { + throw new Error(`Encountered invalid semver version: ${currentVersion} for package: ${packageName}`); + } + } if (shouldAddNewEntry) { // Create a new entry for a patch version with generic changelog entry. const nextPatchVersionIfValid = semver.inc(currentVersion, 'patch'); -- cgit v1.2.3 From df00d93b9c3c9167700165500ff2dcc6c5681ac2 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 20:44:47 +0200 Subject: Also add private package new versions to packageToNextVersion --- packages/monorepo-scripts/src/publish.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 9268de796..e86036d57 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -34,16 +34,27 @@ const packageNameToWebsitePath: { [name: string]: string } = { (async () => { // Fetch public, updated Lerna packages - const shouldIncludePrivate = false; - const updatedPublicPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate); + const shouldIncludePrivate = true; + const allUpdatedPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate); // await confirmDocPagesRenderAsync(updatedPublicPackages); // Update CHANGELOGs + const updatedPublicPackages = _.filter(allUpdatedPackages, pkg => !pkg.packageJson.private); const updatedPublicPackageNames = _.map(updatedPublicPackages, pkg => pkg.packageJson.name); utils.log(`Will update CHANGELOGs and publish: \n${updatedPublicPackageNames.join('\n')}\n`); const packageToNextVersion = await updateChangeLogsAsync(updatedPublicPackages); + const updatedPrivatePackages = _.filter(allUpdatedPackages, pkg => pkg.packageJson.private); + _.each(updatedPrivatePackages, pkg => { + const nextPatchVersionIfValid = semver.inc(pkg.packageJson.version, 'patch'); + if (!_.isNull(nextPatchVersionIfValid)) { + packageToNextVersion[pkg.packageJson.name] = nextPatchVersionIfValid; + } else { + throw new Error(`Encountered invalid semver version: ${currentVersion} for package: ${packageName}`); + } + }); + // Push changelog changes to Github if (!IS_DRY_RUN) { // await pushChangelogsToGithubAsync(); @@ -122,14 +133,6 @@ async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise< currentVersion, changelog, ); - if (pkg.packageJson.private) { - const nextPatchVersionIfValid = semver.inc(currentVersion, 'patch'); - if (!_.isNull(nextPatchVersionIfValid)) { - packageToNextVersion[packageName] = nextPatchVersionIfValid; - } else { - throw new Error(`Encountered invalid semver version: ${currentVersion} for package: ${packageName}`); - } - } if (shouldAddNewEntry) { // Create a new entry for a patch version with generic changelog entry. const nextPatchVersionIfValid = semver.inc(currentVersion, 'patch'); @@ -196,7 +199,7 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string if (isCustomVersionPrompt) { const versionChange = packageToNextVersion[packageName]; if (_.isUndefined(versionChange)) { - console.log('packageName', packageName, 'versionChange', versionChange, ' UNDEFINED!'); + throw new Error(`Must have a nextVersion for each packageName. Didn't find one for ${packageName}`); } child.stdin.write(`${versionChange}\n`); return; -- cgit v1.2.3 From 27d44e3021ed488419aa35173a97191e124c27d0 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 20:46:10 +0200 Subject: Add missing vars --- packages/monorepo-scripts/src/publish.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index e86036d57..bd26057fb 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -47,9 +47,11 @@ const packageNameToWebsitePath: { [name: string]: string } = { const updatedPrivatePackages = _.filter(allUpdatedPackages, pkg => pkg.packageJson.private); _.each(updatedPrivatePackages, pkg => { - const nextPatchVersionIfValid = semver.inc(pkg.packageJson.version, 'patch'); + const currentVersion = pkg.packageJson.version; + const packageName = pkg.packageJson.name; + const nextPatchVersionIfValid = semver.inc(currentVersion, 'patch'); if (!_.isNull(nextPatchVersionIfValid)) { - packageToNextVersion[pkg.packageJson.name] = nextPatchVersionIfValid; + packageToNextVersion[packageName] = nextPatchVersionIfValid; } else { throw new Error(`Encountered invalid semver version: ${currentVersion} for package: ${packageName}`); } -- cgit v1.2.3 From dae975b08c23d1ad81be72f46ae64f59406953ab Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 20:51:25 +0200 Subject: Add in print statements --- packages/monorepo-scripts/src/publish.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index bd26057fb..1bdf5c218 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -187,6 +187,9 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string let packageName: string; child.stdout.on('data', (data: Buffer) => { const output = data.toString('utf8'); + console.log('-------'); + console.log(output); + console.log('-------'); if (shouldPrintOutput) { utils.log(output); } -- cgit v1.2.3 From bfe57b84d600c0d4aaa8b7a22323de6051f0751c Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 20:59:41 +0200 Subject: Use string equals and remove returns --- packages/monorepo-scripts/src/publish.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 1bdf5c218..af707ca47 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -198,16 +198,14 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string const outputStripLeft = output.split('new version for ')[1]; packageName = outputStripLeft.split(' ')[0]; child.stdin.write(`${SemVerIndex.Custom}\n`); - return; } - const isCustomVersionPrompt = _.includes(output, 'Enter a custom version'); + const isCustomVersionPrompt = output === '? Enter a custom version '; if (isCustomVersionPrompt) { const versionChange = packageToNextVersion[packageName]; if (_.isUndefined(versionChange)) { throw new Error(`Must have a nextVersion for each packageName. Didn't find one for ${packageName}`); } child.stdin.write(`${versionChange}\n`); - return; } const isFinalPrompt = _.includes(output, 'Are you sure you want to publish the above changes?'); if (isFinalPrompt && !IS_DRY_RUN) { -- cgit v1.2.3 From 39a06e1d3b977b88225b18e171338196b17691df Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 21:10:44 +0200 Subject: Add timeout before writing to stdin --- packages/monorepo-scripts/src/publish.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index af707ca47..6e2f1c3b8 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -193,11 +193,11 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string if (shouldPrintOutput) { utils.log(output); } - const isVersionPrompt = _.includes(output, 'Select a new version'); + const isVersionPrompt = /^\? Select a new version .* (currently .*)$/.test(output); if (isVersionPrompt) { const outputStripLeft = output.split('new version for ')[1]; packageName = outputStripLeft.split(' ')[0]; - child.stdin.write(`${SemVerIndex.Custom}\n`); + sleepAndWrite(child.stdin, SemVerIndex.Custom); } const isCustomVersionPrompt = output === '? Enter a custom version '; if (isCustomVersionPrompt) { @@ -205,11 +205,11 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string if (_.isUndefined(versionChange)) { throw new Error(`Must have a nextVersion for each packageName. Didn't find one for ${packageName}`); } - child.stdin.write(`${versionChange}\n`); + sleepAndWrite(child.stdin, versionChange); } const isFinalPrompt = _.includes(output, 'Are you sure you want to publish the above changes?'); if (isFinalPrompt && !IS_DRY_RUN) { - child.stdin.write(`y\n`); + sleepAndWrite(child.stdin, 'y'); // After confirmations, we want to print the output to watch the `lerna publish` command shouldPrintOutput = true; } else if (isFinalPrompt && IS_DRY_RUN) { @@ -224,6 +224,13 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string }); } +function sleepAndWrite(fileDescriptor: any, input: string | number): void { + const TIMEOUT = 100; + setTimeout(() => { + fileDescriptor.write(`${input}\n`); + }, TIMEOUT); +} + function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string): string { const updatedVersionIfValid = semver.inc(currentVersion, 'patch'); if (_.isNull(updatedVersionIfValid)) { -- cgit v1.2.3 From 68974313e178bdee3c45b4556406960eaa26ce2a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 21:12:47 +0200 Subject: Make regex less strict --- packages/monorepo-scripts/src/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 6e2f1c3b8..d1f9e4594 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -193,7 +193,7 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string if (shouldPrintOutput) { utils.log(output); } - const isVersionPrompt = /^\? Select a new version .* (currently .*)$/.test(output); + const isVersionPrompt = /^\? Select a new version .* (currently .*)/.test(output); if (isVersionPrompt) { const outputStripLeft = output.split('new version for ')[1]; packageName = outputStripLeft.split(' ')[0]; -- cgit v1.2.3 From df341717f78e8100802b110b1254181cc670ecc3 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 21:14:51 +0200 Subject: Remove regex --- packages/monorepo-scripts/src/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index d1f9e4594..4d5425ac6 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -193,7 +193,7 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string if (shouldPrintOutput) { utils.log(output); } - const isVersionPrompt = /^\? Select a new version .* (currently .*)/.test(output); + const isVersionPrompt = _.includes(output, 'Select a new version'); if (isVersionPrompt) { const outputStripLeft = output.split('new version for ')[1]; packageName = outputStripLeft.split(' ')[0]; -- cgit v1.2.3 From b4cd8897b293e903ad5710d90d9904e1bc56c08e Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 21:20:09 +0200 Subject: Dedup versionPrompt being triggered multiple times --- packages/monorepo-scripts/src/publish.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 4d5425ac6..4506595e1 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -196,11 +196,16 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string const isVersionPrompt = _.includes(output, 'Select a new version'); if (isVersionPrompt) { const outputStripLeft = output.split('new version for ')[1]; - packageName = outputStripLeft.split(' ')[0]; + const packageNameFound = outputStripLeft.split(' ')[0]; + if (packageName === packageNameFound) { + return; // noop + } + packageName = packageNameFound; sleepAndWrite(child.stdin, SemVerIndex.Custom); } const isCustomVersionPrompt = output === '? Enter a custom version '; if (isCustomVersionPrompt) { + console.log('custom version prompt hit!'); const versionChange = packageToNextVersion[packageName]; if (_.isUndefined(versionChange)) { throw new Error(`Must have a nextVersion for each packageName. Didn't find one for ${packageName}`); @@ -225,8 +230,9 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string } function sleepAndWrite(fileDescriptor: any, input: string | number): void { - const TIMEOUT = 100; + const TIMEOUT = 1000; setTimeout(() => { + console.log('Printing to console:', input); fileDescriptor.write(`${input}\n`); }, TIMEOUT); } -- cgit v1.2.3 From 1d9a77027eaf2ae9a21262305f75a274b0bd214a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 21:23:09 +0200 Subject: Use include --- packages/monorepo-scripts/src/publish.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 4506595e1..df1bfff2f 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -203,9 +203,8 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string packageName = packageNameFound; sleepAndWrite(child.stdin, SemVerIndex.Custom); } - const isCustomVersionPrompt = output === '? Enter a custom version '; + const isCustomVersionPrompt = _.includes(output, 'Enter a custom version'); if (isCustomVersionPrompt) { - console.log('custom version prompt hit!'); const versionChange = packageToNextVersion[packageName]; if (_.isUndefined(versionChange)) { throw new Error(`Must have a nextVersion for each packageName. Didn't find one for ${packageName}`); @@ -232,7 +231,6 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string function sleepAndWrite(fileDescriptor: any, input: string | number): void { const TIMEOUT = 1000; setTimeout(() => { - console.log('Printing to console:', input); fileDescriptor.write(`${input}\n`); }, TIMEOUT); } -- cgit v1.2.3 From d50174b89eda6a9df590dac6b121885b74ec35d9 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 23 Jul 2018 21:33:03 +0200 Subject: Add ignore flag --- packages/monorepo-scripts/src/publish.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index df1bfff2f..42d0a374f 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -185,7 +185,12 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string }); let shouldPrintOutput = false; let packageName: string; + let ignoreCounter = 0; child.stdout.on('data', (data: Buffer) => { + if (ignoreCounter !== 0) { + ignoreCounter--; + return; // ignore + } const output = data.toString('utf8'); console.log('-------'); console.log(output); @@ -201,6 +206,7 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string return; // noop } packageName = packageNameFound; + ignoreCounter = 1; // SemVerIndex.Custom is a single digit number sleepAndWrite(child.stdin, SemVerIndex.Custom); } const isCustomVersionPrompt = _.includes(output, 'Enter a custom version'); @@ -209,10 +215,12 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string if (_.isUndefined(versionChange)) { throw new Error(`Must have a nextVersion for each packageName. Didn't find one for ${packageName}`); } + ignoreCounter = versionChange.length; sleepAndWrite(child.stdin, versionChange); } const isFinalPrompt = _.includes(output, 'Are you sure you want to publish the above changes?'); if (isFinalPrompt && !IS_DRY_RUN) { + ignoreCounter = 'y'.length; sleepAndWrite(child.stdin, 'y'); // After confirmations, we want to print the output to watch the `lerna publish` command shouldPrintOutput = true; -- cgit v1.2.3 From 91dcfd5ee88d704ed9d56ec16e58f18ca04aa42b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 24 Jul 2018 12:39:41 +0200 Subject: Use cdVersions flag instead of interactive prompt --- packages/monorepo-scripts/src/publish.ts | 67 ++------------------------------ 1 file changed, 4 insertions(+), 63 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 42d0a374f..7007b75e5 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -178,69 +178,10 @@ async function updateChangeLogsAsync(updatedPublicPackages: Package[]): Promise< } async function lernaPublishAsync(packageToNextVersion: { [name: string]: string }): Promise { - // HACK: Lerna publish does not provide a way to specify multiple package versions via - // flags so instead we need to interact with their interactive prompt interface. - const child = spawn('lerna', ['publish', `--skip-git`], { - cwd: constants.monorepoRootPath, - }); - let shouldPrintOutput = false; - let packageName: string; - let ignoreCounter = 0; - child.stdout.on('data', (data: Buffer) => { - if (ignoreCounter !== 0) { - ignoreCounter--; - return; // ignore - } - const output = data.toString('utf8'); - console.log('-------'); - console.log(output); - console.log('-------'); - if (shouldPrintOutput) { - utils.log(output); - } - const isVersionPrompt = _.includes(output, 'Select a new version'); - if (isVersionPrompt) { - const outputStripLeft = output.split('new version for ')[1]; - const packageNameFound = outputStripLeft.split(' ')[0]; - if (packageName === packageNameFound) { - return; // noop - } - packageName = packageNameFound; - ignoreCounter = 1; // SemVerIndex.Custom is a single digit number - sleepAndWrite(child.stdin, SemVerIndex.Custom); - } - const isCustomVersionPrompt = _.includes(output, 'Enter a custom version'); - if (isCustomVersionPrompt) { - const versionChange = packageToNextVersion[packageName]; - if (_.isUndefined(versionChange)) { - throw new Error(`Must have a nextVersion for each packageName. Didn't find one for ${packageName}`); - } - ignoreCounter = versionChange.length; - sleepAndWrite(child.stdin, versionChange); - } - const isFinalPrompt = _.includes(output, 'Are you sure you want to publish the above changes?'); - if (isFinalPrompt && !IS_DRY_RUN) { - ignoreCounter = 'y'.length; - sleepAndWrite(child.stdin, 'y'); - // After confirmations, we want to print the output to watch the `lerna publish` command - shouldPrintOutput = true; - } else if (isFinalPrompt && IS_DRY_RUN) { - utils.log( - `Submitted all versions to Lerna but since this is a dry run, did not confirm. You need to CTRL-C to exit.`, - ); - } - }); - child.stderr.on('data', (data: Buffer) => { - const output = data.toString('utf8'); - utils.log('Stderr:', output); - }); -} - -function sleepAndWrite(fileDescriptor: any, input: string | number): void { - const TIMEOUT = 1000; - setTimeout(() => { - fileDescriptor.write(`${input}\n`); - }, TIMEOUT); + const packageVersionString = _.map(packageToNextVersion, (nextVersion: string, packageName: string) => { + return `${packageName}@${nextVersion}`; + }).join(','); + await execAsync('lerna', `--cdVersions=${packageVersionString}`, '--skip-git'); } function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string): string { -- cgit v1.2.3 From 73d75bc4052f4d122924d9be2e2fae4bc2764a90 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 24 Jul 2018 12:44:38 +0200 Subject: Fix publish command --- packages/monorepo-scripts/src/publish.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 7007b75e5..7d10c7d9e 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -4,14 +4,14 @@ import * as promisify from 'es6-promisify'; import * as _ from 'lodash'; import * as moment from 'moment'; import opn = require('opn'); -import { exec as execAsync, spawn } from 'promisify-child-process'; +import { exec as execAsync } from 'promisify-child-process'; import * as prompt from 'prompt'; import semver = require('semver'); import semverDiff = require('semver-diff'); import semverSort = require('semver-sort'); import { constants } from './constants'; -import { Package, PackageToNextVersion, SemVerIndex, VersionChangelog } from './types'; +import { Package, PackageToNextVersion, VersionChangelog } from './types'; import { changelogUtils } from './utils/changelog_utils'; import { utils } from './utils/utils'; @@ -181,7 +181,9 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string const packageVersionString = _.map(packageToNextVersion, (nextVersion: string, packageName: string) => { return `${packageName}@${nextVersion}`; }).join(','); - await execAsync('lerna', `--cdVersions=${packageVersionString}`, '--skip-git'); + const lernaPublishCmd = `lerna --cdVersions=${packageVersionString} --skip-git`; + console.log('lernaPublishCmd', lernaPublishCmd); + await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); } function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string): string { -- cgit v1.2.3 From 6f38d1bee5e13a0b684a17c7fbc689a4fbb051f8 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 24 Jul 2018 12:46:40 +0200 Subject: Add missing 'publish' --- packages/monorepo-scripts/src/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 7d10c7d9e..66ecb912b 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -181,7 +181,7 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string const packageVersionString = _.map(packageToNextVersion, (nextVersion: string, packageName: string) => { return `${packageName}@${nextVersion}`; }).join(','); - const lernaPublishCmd = `lerna --cdVersions=${packageVersionString} --skip-git`; + const lernaPublishCmd = `lerna publish --cdVersions=${packageVersionString} --skip-git`; console.log('lernaPublishCmd', lernaPublishCmd); await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); } -- cgit v1.2.3 From d280311734a26aed731bae4bcba5b091054a99f8 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 24 Jul 2018 13:19:31 +0200 Subject: Use relative path to lerna executable --- packages/monorepo-scripts/src/publish.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 66ecb912b..39af64a5a 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -7,7 +7,6 @@ import opn = require('opn'); import { exec as execAsync } from 'promisify-child-process'; import * as prompt from 'prompt'; import semver = require('semver'); -import semverDiff = require('semver-diff'); import semverSort = require('semver-sort'); import { constants } from './constants'; @@ -181,9 +180,10 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string const packageVersionString = _.map(packageToNextVersion, (nextVersion: string, packageName: string) => { return `${packageName}@${nextVersion}`; }).join(','); - const lernaPublishCmd = `lerna publish --cdVersions=${packageVersionString} --skip-git`; + const lernaPublishCmd = `${constants.lernaExecutable} publish --cdVersions=${packageVersionString} --skip-git`; console.log('lernaPublishCmd', lernaPublishCmd); - await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); + const { stdout, stderr } = await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); + console.log('stdout, stderr', stdout.toString(), stderr.toString()); } function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string): string { -- cgit v1.2.3 From e9e73aa0a3c39dd9ad39749cc3df4e766edd816c Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 24 Jul 2018 13:21:28 +0200 Subject: Add node --- packages/monorepo-scripts/src/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 39af64a5a..bc8d76ac6 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -180,7 +180,7 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string const packageVersionString = _.map(packageToNextVersion, (nextVersion: string, packageName: string) => { return `${packageName}@${nextVersion}`; }).join(','); - const lernaPublishCmd = `${constants.lernaExecutable} publish --cdVersions=${packageVersionString} --skip-git`; + const lernaPublishCmd = `node ${constants.lernaExecutable} publish --cdVersions=${packageVersionString} --skip-git`; console.log('lernaPublishCmd', lernaPublishCmd); const { stdout, stderr } = await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); console.log('stdout, stderr', stdout.toString(), stderr.toString()); -- cgit v1.2.3 From 98b2875512f1a095fb2b6b549db47eda075ce0ee Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 24 Jul 2018 13:28:02 +0200 Subject: Add --yes flag --- packages/monorepo-scripts/src/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index bc8d76ac6..6f3ec3742 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -180,7 +180,7 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string const packageVersionString = _.map(packageToNextVersion, (nextVersion: string, packageName: string) => { return `${packageName}@${nextVersion}`; }).join(','); - const lernaPublishCmd = `node ${constants.lernaExecutable} publish --cdVersions=${packageVersionString} --skip-git`; + const lernaPublishCmd = `node ${constants.lernaExecutable} publish --cdVersions=${packageVersionString} --skip-git --yes`; console.log('lernaPublishCmd', lernaPublishCmd); const { stdout, stderr } = await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); console.log('stdout, stderr', stdout.toString(), stderr.toString()); -- cgit v1.2.3 From 8acfc9a2f9ad83add986cab7ae57940f421f97c4 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 24 Jul 2018 13:43:27 +0200 Subject: improve logs --- packages/monorepo-scripts/src/publish.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 6f3ec3742..4647b389a 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -181,9 +181,8 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string return `${packageName}@${nextVersion}`; }).join(','); const lernaPublishCmd = `node ${constants.lernaExecutable} publish --cdVersions=${packageVersionString} --skip-git --yes`; - console.log('lernaPublishCmd', lernaPublishCmd); - const { stdout, stderr } = await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); - console.log('stdout, stderr', stdout.toString(), stderr.toString()); + utils.log('Lerna is publishing...'); + await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); } function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string): string { -- cgit v1.2.3 From 038602539542a94b99198fb51d72977a8806dc09 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Jul 2018 15:19:36 +0200 Subject: Temp: Force publish --- packages/monorepo-scripts/src/publish.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 4647b389a..f3c406eed 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -180,7 +180,9 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string const packageVersionString = _.map(packageToNextVersion, (nextVersion: string, packageName: string) => { return `${packageName}@${nextVersion}`; }).join(','); - const lernaPublishCmd = `node ${constants.lernaExecutable} publish --cdVersions=${packageVersionString} --skip-git --yes`; + const lernaPublishCmd = `node ${ + constants.lernaExecutable + } publish --cdVersions=${packageVersionString} --skip-git --yes --force-publish *`; utils.log('Lerna is publishing...'); await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); } -- cgit v1.2.3 From 2073aa9abcdaee04834b972bbafb455260a67e99 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Jul 2018 15:19:57 +0200 Subject: Test installation on latest version, not the packed one --- packages/monorepo-scripts/src/test_installation.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 668d4ef1d..52868483f 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -16,16 +16,14 @@ import { utils } from './utils/utils'; pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'), ); for (const installablePackage of installablePackages) { - const packagePath = installablePackage.location; const packageName = installablePackage.packageJson.name; + const packageVersion = installablePackage.packageJson.version; utils.log(`Testing ${packageName}`); - let result = await execAsync('npm pack', { cwd: packagePath }); - const packedPackageFileName = result.stdout.trim(); const testDirectory = path.join(monorepoRootPath, '../test-env'); fs.mkdirSync(testDirectory); - result = await execAsync('yarn init --yes', { cwd: testDirectory }); - utils.log(`Installing ${packedPackageFileName}`); - result = await execAsync(`yarn add ${packagePath}/${packedPackageFileName}`, { cwd: testDirectory }); + let result = await execAsync('yarn init --yes', { cwd: testDirectory }); + utils.log(`Installing ${packageName}@${packageVersion}`); + result = await execAsync(`yarn add ${packageName}@${packageVersion}`, { cwd: testDirectory }); const indexFilePath = path.join(testDirectory, 'index.ts'); fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}';\n`); const tsConfig = { -- cgit v1.2.3 From f50ac932d6de28b3474ef8023813835badff4b09 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Jul 2018 16:06:51 +0200 Subject: Introduce PackageJson file --- packages/monorepo-scripts/src/types.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/types.ts b/packages/monorepo-scripts/src/types.ts index c0622debc..c1483d884 100644 --- a/packages/monorepo-scripts/src/types.ts +++ b/packages/monorepo-scripts/src/types.ts @@ -46,16 +46,18 @@ export interface GitTagsByPackageName { [packageName: string]: string[]; } +export interface PackageJSON { + private?: boolean; + version: string; + name: string; + main?: string; + scripts?: { [command: string]: string }; + config?: { + additionalTsTypings?: string[]; + }; +} + export interface Package { location: string; - packageJson: { - private?: boolean; - version: string; - name: string; - main?: string; - scripts?: { [command: string]: string }; - config?: { - additionalTsTypings?: string[]; - }; - }; + packageJson: PackageJSON; } -- cgit v1.2.3 From d1e33a3dff3f62b7c84fd5b5d1307572853beeee Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Jul 2018 16:07:11 +0200 Subject: Add utils.getTopologicallySortedPackages --- packages/monorepo-scripts/src/utils/utils.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/utils/utils.ts b/packages/monorepo-scripts/src/utils/utils.ts index 8ba59c81d..d9bae3ea9 100644 --- a/packages/monorepo-scripts/src/utils/utils.ts +++ b/packages/monorepo-scripts/src/utils/utils.ts @@ -1,10 +1,11 @@ +import batchPackages = require('@lerna/batch-packages'); import * as fs from 'fs'; import * as _ from 'lodash'; import { exec as execAsync } from 'promisify-child-process'; import semver = require('semver'); import { constants } from '../constants'; -import { GitTagsByPackageName, Package, UpdatedPackage } from '../types'; +import { GitTagsByPackageName, Package, PackageJSON, UpdatedPackage } from '../types'; import { changelogUtils } from './changelog_utils'; @@ -12,6 +13,15 @@ export const utils = { log(...args: any[]): void { console.log(...args); // tslint:disable-line:no-console }, + getTopologicallySortedPackages(rootDir: string): Package[] { + const packages = utils.getPackages(rootDir); + const batchedPackages: PackageJSON[] = _.flatten(batchPackages(_.map(packages, pkg => pkg.packageJson), false)); + const topsortedPackages: Package[] = _.map( + batchedPackages, + (pkg: PackageJSON) => _.find(packages, pkg1 => pkg1.packageJson.name === pkg.name) as Package, + ); + return topsortedPackages; + }, getPackages(rootDir: string): Package[] { const rootPackageJsonString = fs.readFileSync(`${rootDir}/package.json`, 'utf8'); const rootPackageJson = JSON.parse(rootPackageJsonString); -- cgit v1.2.3 From f699da90ba1658d50f251f988b27508cbf66b64c Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Jul 2018 16:07:32 +0200 Subject: Pretend we defined types for @lerna/batch-packages --- packages/monorepo-scripts/src/globals.d.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/globals.d.ts b/packages/monorepo-scripts/src/globals.d.ts index cb6a61b55..2b25802ee 100644 --- a/packages/monorepo-scripts/src/globals.d.ts +++ b/packages/monorepo-scripts/src/globals.d.ts @@ -14,3 +14,4 @@ declare module 'semver-sort' { } declare module 'promisify-child-process'; +declare module '@lerna/batch-packages'; -- cgit v1.2.3 From 24aa5cd1bf38197a72be32a53f2e4a7c9aaf58ef Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Jul 2018 16:08:07 +0200 Subject: Make the test:installation work with the local npm registry --- packages/monorepo-scripts/package.json | 1 + packages/monorepo-scripts/src/test_installation.ts | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index 997338ff0..c11249feb 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -42,6 +42,7 @@ "typescript": "2.7.1" }, "dependencies": { + "@lerna/batch-packages": "^3.0.0-beta.18", "@types/depcheck": "^0.6.0", "async-child-process": "^1.1.1", "chalk": "^2.3.0", diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 52868483f..a9610e5ee 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -10,20 +10,27 @@ import { utils } from './utils/utils'; (async () => { const monorepoRootPath = path.join(__dirname, '../../..'); - const packages = utils.getPackages(monorepoRootPath); + const packages = utils.getTopologicallySortedPackages(monorepoRootPath); const installablePackages = _.filter( packages, pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'), ); + utils.log('Testing packages:'); + _.map(installablePackages, pkg => utils.log(`* ${pkg.packageJson.name}`)); for (const installablePackage of installablePackages) { + const changelogPath = path.join(installablePackage.location, 'CHANGELOG.json'); + const lastChangelogVersion = JSON.parse(fs.readFileSync(changelogPath).toString())[0].version; const packageName = installablePackage.packageJson.name; - const packageVersion = installablePackage.packageJson.version; utils.log(`Testing ${packageName}`); const testDirectory = path.join(monorepoRootPath, '../test-env'); fs.mkdirSync(testDirectory); - let result = await execAsync('yarn init --yes', { cwd: testDirectory }); - utils.log(`Installing ${packageName}@${packageVersion}`); - result = await execAsync(`yarn add ${packageName}@${packageVersion}`, { cwd: testDirectory }); + await execAsync('yarn init --yes', { cwd: testDirectory }); + const npmrcFilePath = path.join(testDirectory, '.npmrc'); + fs.writeFileSync(npmrcFilePath, `registry=http://localhost:4873`); + utils.log(`Installing ${packageName}@${lastChangelogVersion}`); + await execAsync(`npm install --save ${packageName}@${lastChangelogVersion} --registry=http://localhost:4873`, { + cwd: testDirectory, + }); const indexFilePath = path.join(testDirectory, 'index.ts'); fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}';\n`); const tsConfig = { -- cgit v1.2.3 From 97268d22534c2f4aca9bd6a88c70e988969d3c76 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 24 Jul 2018 16:33:16 +0200 Subject: Temporarily add changelog & package.json version changes --- packages/monorepo-scripts/CHANGELOG.json | 9 +++++++++ packages/monorepo-scripts/CHANGELOG.md | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/CHANGELOG.json b/packages/monorepo-scripts/CHANGELOG.json index 6e0fe501e..ccc7166c1 100644 --- a/packages/monorepo-scripts/CHANGELOG.json +++ b/packages/monorepo-scripts/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1532442671, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1532357734, "version": "1.0.1", diff --git a/packages/monorepo-scripts/CHANGELOG.md b/packages/monorepo-scripts/CHANGELOG.md index 74cd3b8ff..e8881fffa 100644 --- a/packages/monorepo-scripts/CHANGELOG.md +++ b/packages/monorepo-scripts/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.2 - _July 24, 2018_ + + * Dependencies updated + ## v1.0.1 - _July 23, 2018_ * Dependencies updated -- cgit v1.2.3 From c5859b65a395f31c87a3d3fbd303ed17156be09f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 24 Jul 2018 19:35:13 +0200 Subject: Install our fork of lerna and use it --- packages/monorepo-scripts/src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/constants.ts b/packages/monorepo-scripts/src/constants.ts index f08313bd2..e5d3348bd 100644 --- a/packages/monorepo-scripts/src/constants.ts +++ b/packages/monorepo-scripts/src/constants.ts @@ -3,6 +3,6 @@ import * as path from 'path'; export const constants = { monorepoRootPath: path.join(__dirname, '../../..'), stagingWebsite: 'http://staging-0xproject.s3-website-us-east-1.amazonaws.com', - lernaExecutable: path.join('node_modules', 'lerna', 'cli.js'), + lernaExecutable: path.join('node_modules', '@0x-lerna-fork', 'lerna', 'cli.js'), githubPersonalAccessToken: process.env.GITHUB_PERSONAL_ACCESS_TOKEN_0X_JS, }; -- cgit v1.2.3 From dbc798596b052d3e28cf5772c94789d37ee5a4c7 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Jul 2018 21:37:01 +0200 Subject: Replace dry mode with local publishing mode --- packages/monorepo-scripts/src/postpublish_utils.ts | 47 ++++++++++++---------- packages/monorepo-scripts/src/publish.ts | 17 ++++---- 2 files changed, 36 insertions(+), 28 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/postpublish_utils.ts b/packages/monorepo-scripts/src/postpublish_utils.ts index 8c9d95e44..229bb9031 100644 --- a/packages/monorepo-scripts/src/postpublish_utils.ts +++ b/packages/monorepo-scripts/src/postpublish_utils.ts @@ -25,6 +25,8 @@ export interface DocPublishConfigs { s3StagingBucketPath: string; } +const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; + export const postpublishUtils = { generateConfig(packageJSON: any, tsConfigJSON: any, cwd: string): PostpublishConfigs { if (_.isUndefined(packageJSON.name)) { @@ -51,27 +53,30 @@ export const postpublishUtils = { return configs; }, async runAsync(packageJSON: any, tsConfigJSON: any, cwd: string): Promise { - // const configs = postpublishUtils.generateConfig(packageJSON, tsConfigJSON, cwd); - // await postpublishUtils.publishReleaseNotesAsync( - // configs.cwd, - // configs.packageName, - // configs.version, - // configs.assets, - // ); - // if ( - // !_.isUndefined(configs.docPublishConfigs.s3BucketPath) || - // !_.isUndefined(configs.docPublishConfigs.s3StagingBucketPath) - // ) { - // utils.log('POSTPUBLISH: Release successful, generating docs...'); - // await postpublishUtils.generateAndUploadDocsAsync( - // configs.cwd, - // configs.docPublishConfigs.fileIncludes, - // configs.version, - // configs.docPublishConfigs.s3BucketPath, - // ); - // } else { - // utils.log(`POSTPUBLISH: No S3Bucket config found for ${packageJSON.name}. Skipping doc JSON generation.`); - // } + if (IS_LOCAL_PUBLISH) { + return; + } + const configs = postpublishUtils.generateConfig(packageJSON, tsConfigJSON, cwd); + await postpublishUtils.publishReleaseNotesAsync( + configs.cwd, + configs.packageName, + configs.version, + configs.assets, + ); + if ( + !_.isUndefined(configs.docPublishConfigs.s3BucketPath) || + !_.isUndefined(configs.docPublishConfigs.s3StagingBucketPath) + ) { + utils.log('POSTPUBLISH: Release successful, generating docs...'); + await postpublishUtils.generateAndUploadDocsAsync( + configs.cwd, + configs.docPublishConfigs.fileIncludes, + configs.version, + configs.docPublishConfigs.s3BucketPath, + ); + } else { + utils.log(`POSTPUBLISH: No S3Bucket config found for ${packageJSON.name}. Skipping doc JSON generation.`); + } }, async publishDocsToStagingAsync(packageJSON: any, tsConfigJSON: any, cwd: string): Promise { const configs = postpublishUtils.generateConfig(packageJSON, tsConfigJSON, cwd); diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index f3c406eed..71eb16a98 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -16,7 +16,7 @@ import { utils } from './utils/utils'; const DOC_GEN_COMMAND = 'docs:json'; const NPM_NAMESPACE = '@0xproject/'; -const IS_DRY_RUN = process.env.IS_DRY_RUN === 'true'; +const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; const TODAYS_TIMESTAMP = moment().unix(); const packageNameToWebsitePath: { [name: string]: string } = { '0x.js': '0xjs', @@ -36,7 +36,9 @@ const packageNameToWebsitePath: { [name: string]: string } = { const shouldIncludePrivate = true; const allUpdatedPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate); - // await confirmDocPagesRenderAsync(updatedPublicPackages); + if (!IS_LOCAL_PUBLISH) { + await confirmDocPagesRenderAsync(allUpdatedPackages); + } // Update CHANGELOGs const updatedPublicPackages = _.filter(allUpdatedPackages, pkg => !pkg.packageJson.private); @@ -57,8 +59,8 @@ const packageNameToWebsitePath: { [name: string]: string } = { }); // Push changelog changes to Github - if (!IS_DRY_RUN) { - // await pushChangelogsToGithubAsync(); + if (!IS_LOCAL_PUBLISH) { + await pushChangelogsToGithubAsync(); } // Call LernaPublish @@ -180,9 +182,10 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string const packageVersionString = _.map(packageToNextVersion, (nextVersion: string, packageName: string) => { return `${packageName}@${nextVersion}`; }).join(','); - const lernaPublishCmd = `node ${ - constants.lernaExecutable - } publish --cdVersions=${packageVersionString} --skip-git --yes --force-publish *`; + let lernaPublishCmd = `node ${constants.lernaExecutable} publish --cdVersions=${packageVersionString}`; + if (IS_LOCAL_PUBLISH) { + lernaPublishCmd += ' --skip-git --yes --force-publish *'; + } utils.log('Lerna is publishing...'); await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); } -- cgit v1.2.3 From c40b3dea6cefc9a192136d66311839bd7c5d5169 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 24 Jul 2018 21:39:31 +0200 Subject: Specify registry url only if local publish attempted --- packages/monorepo-scripts/src/postpublish_utils.ts | 43 +++++++++++----------- packages/monorepo-scripts/src/publish.ts | 14 ++++--- packages/monorepo-scripts/src/utils/configs.ts | 8 ++++ packages/monorepo-scripts/src/utils/npm_utils.ts | 6 +-- 4 files changed, 40 insertions(+), 31 deletions(-) create mode 100644 packages/monorepo-scripts/src/utils/configs.ts (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/postpublish_utils.ts b/packages/monorepo-scripts/src/postpublish_utils.ts index 229bb9031..37861f0dd 100644 --- a/packages/monorepo-scripts/src/postpublish_utils.ts +++ b/packages/monorepo-scripts/src/postpublish_utils.ts @@ -6,6 +6,7 @@ import * as path from 'path'; import * as publishRelease from 'publish-release'; import { constants } from './constants'; +import { configs } from './utils/configs'; import { utils } from './utils/utils'; const publishReleaseAsync = promisify(publishRelease); @@ -25,8 +26,6 @@ export interface DocPublishConfigs { s3StagingBucketPath: string; } -const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; - export const postpublishUtils = { generateConfig(packageJSON: any, tsConfigJSON: any, cwd: string): PostpublishConfigs { if (_.isUndefined(packageJSON.name)) { @@ -36,7 +35,7 @@ export const postpublishUtils = { throw new Error('version field required in package.json. Cannot publish release notes to Github.'); } const postpublishConfig = _.get(packageJSON, 'config.postpublish', {}); - const configs: PostpublishConfigs = { + const postpublishConfigs: PostpublishConfigs = { cwd, packageName: packageJSON.name, version: packageJSON.version, @@ -50,47 +49,47 @@ export const postpublishUtils = { s3StagingBucketPath: _.get(postpublishConfig, 'docPublishConfigs.s3StagingBucketPath'), }, }; - return configs; + return postpublishConfigs; }, async runAsync(packageJSON: any, tsConfigJSON: any, cwd: string): Promise { - if (IS_LOCAL_PUBLISH) { + if (configs.IS_LOCAL_PUBLISH) { return; } - const configs = postpublishUtils.generateConfig(packageJSON, tsConfigJSON, cwd); + const postpublishConfigs = postpublishUtils.generateConfig(packageJSON, tsConfigJSON, cwd); await postpublishUtils.publishReleaseNotesAsync( - configs.cwd, - configs.packageName, - configs.version, - configs.assets, + postpublishConfigs.cwd, + postpublishConfigs.packageName, + postpublishConfigs.version, + postpublishConfigs.assets, ); if ( - !_.isUndefined(configs.docPublishConfigs.s3BucketPath) || - !_.isUndefined(configs.docPublishConfigs.s3StagingBucketPath) + !_.isUndefined(postpublishConfigs.docPublishConfigs.s3BucketPath) || + !_.isUndefined(postpublishConfigs.docPublishConfigs.s3StagingBucketPath) ) { utils.log('POSTPUBLISH: Release successful, generating docs...'); await postpublishUtils.generateAndUploadDocsAsync( - configs.cwd, - configs.docPublishConfigs.fileIncludes, - configs.version, - configs.docPublishConfigs.s3BucketPath, + postpublishConfigs.cwd, + postpublishConfigs.docPublishConfigs.fileIncludes, + postpublishConfigs.version, + postpublishConfigs.docPublishConfigs.s3BucketPath, ); } else { utils.log(`POSTPUBLISH: No S3Bucket config found for ${packageJSON.name}. Skipping doc JSON generation.`); } }, async publishDocsToStagingAsync(packageJSON: any, tsConfigJSON: any, cwd: string): Promise { - const configs = postpublishUtils.generateConfig(packageJSON, tsConfigJSON, cwd); - if (_.isUndefined(configs.docPublishConfigs.s3StagingBucketPath)) { + const postpublishConfigs = postpublishUtils.generateConfig(packageJSON, tsConfigJSON, cwd); + if (_.isUndefined(postpublishConfigs.docPublishConfigs.s3StagingBucketPath)) { utils.log('config.postpublish.docPublishConfigs.s3StagingBucketPath entry in package.json not found!'); return; } utils.log('POSTPUBLISH: Generating docs...'); await postpublishUtils.generateAndUploadDocsAsync( - configs.cwd, - configs.docPublishConfigs.fileIncludes, - configs.version, - configs.docPublishConfigs.s3StagingBucketPath, + postpublishConfigs.cwd, + postpublishConfigs.docPublishConfigs.fileIncludes, + postpublishConfigs.version, + postpublishConfigs.docPublishConfigs.s3StagingBucketPath, ); }, async publishReleaseNotesAsync(cwd: string, packageName: string, version: string, assets: string[]): Promise { diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 71eb16a98..d5238ab52 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -12,11 +12,11 @@ import semverSort = require('semver-sort'); import { constants } from './constants'; import { Package, PackageToNextVersion, VersionChangelog } from './types'; import { changelogUtils } from './utils/changelog_utils'; +import { configs } from './utils/configs'; import { utils } from './utils/utils'; const DOC_GEN_COMMAND = 'docs:json'; const NPM_NAMESPACE = '@0xproject/'; -const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; const TODAYS_TIMESTAMP = moment().unix(); const packageNameToWebsitePath: { [name: string]: string } = { '0x.js': '0xjs', @@ -36,7 +36,7 @@ const packageNameToWebsitePath: { [name: string]: string } = { const shouldIncludePrivate = true; const allUpdatedPackages = await utils.getUpdatedPackagesAsync(shouldIncludePrivate); - if (!IS_LOCAL_PUBLISH) { + if (!configs.IS_LOCAL_PUBLISH) { await confirmDocPagesRenderAsync(allUpdatedPackages); } @@ -59,7 +59,7 @@ const packageNameToWebsitePath: { [name: string]: string } = { }); // Push changelog changes to Github - if (!IS_LOCAL_PUBLISH) { + if (!configs.IS_LOCAL_PUBLISH) { await pushChangelogsToGithubAsync(); } @@ -182,9 +182,11 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string const packageVersionString = _.map(packageToNextVersion, (nextVersion: string, packageName: string) => { return `${packageName}@${nextVersion}`; }).join(','); - let lernaPublishCmd = `node ${constants.lernaExecutable} publish --cdVersions=${packageVersionString}`; - if (IS_LOCAL_PUBLISH) { - lernaPublishCmd += ' --skip-git --yes --force-publish *'; + let lernaPublishCmd = `node ${constants.lernaExecutable} publish --cdVersions=${packageVersionString} --registry=${ + configs.NPM_REGISTRY_URL + }`; + if (configs.IS_LOCAL_PUBLISH) { + lernaPublishCmd += ` --skip-git --yes --force-publish *`; } utils.log('Lerna is publishing...'); await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); diff --git a/packages/monorepo-scripts/src/utils/configs.ts b/packages/monorepo-scripts/src/utils/configs.ts new file mode 100644 index 000000000..e579bdb7c --- /dev/null +++ b/packages/monorepo-scripts/src/utils/configs.ts @@ -0,0 +1,8 @@ +const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; +const LOCAL_NPM_REGISTRY_URL = 'http://localhost:4873'; +const REMOTE_NPM_REGISTRY_URL = 'https://registry.npmjs.org'; + +export const configs = { + IS_LOCAL_PUBLISH, + NPM_REGISTRY_URL: IS_LOCAL_PUBLISH ? LOCAL_NPM_REGISTRY_URL : REMOTE_NPM_REGISTRY_URL, +}; diff --git a/packages/monorepo-scripts/src/utils/npm_utils.ts b/packages/monorepo-scripts/src/utils/npm_utils.ts index 7c8310459..9c8e51508 100644 --- a/packages/monorepo-scripts/src/utils/npm_utils.ts +++ b/packages/monorepo-scripts/src/utils/npm_utils.ts @@ -4,14 +4,14 @@ import * as _ from 'lodash'; import { PackageRegistryJson } from '../types'; -const lernaJson = JSON.parse(fs.readFileSync('lerna.json').toString()); -const NPM_REGISTRY_BASE_URL = lernaJson.registry; +import { configs } from './configs'; + const SUCCESS_STATUS = 200; const NOT_FOUND_STATUS = 404; export const npmUtils = { async getPackageRegistryJsonIfExistsAsync(packageName: string): Promise { - const url = `${NPM_REGISTRY_BASE_URL}/${packageName}`; + const url = `${configs.NPM_REGISTRY_URL}/${packageName}`; const response = await fetch(url); if (response.status === NOT_FOUND_STATUS) { -- cgit v1.2.3 From 91c7105d434287628654795fd92834aa4edb69b4 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 25 Jul 2018 11:48:01 +0200 Subject: Revert "Temporarily add changelog & package.json version changes" This reverts commit 97268d22534c2f4aca9bd6a88c70e988969d3c76. --- packages/monorepo-scripts/CHANGELOG.json | 9 --------- packages/monorepo-scripts/CHANGELOG.md | 4 ---- 2 files changed, 13 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/CHANGELOG.json b/packages/monorepo-scripts/CHANGELOG.json index ccc7166c1..6e0fe501e 100644 --- a/packages/monorepo-scripts/CHANGELOG.json +++ b/packages/monorepo-scripts/CHANGELOG.json @@ -1,13 +1,4 @@ [ - { - "timestamp": 1532442671, - "version": "1.0.2", - "changes": [ - { - "note": "Dependencies updated" - } - ] - }, { "timestamp": 1532357734, "version": "1.0.1", diff --git a/packages/monorepo-scripts/CHANGELOG.md b/packages/monorepo-scripts/CHANGELOG.md index e8881fffa..74cd3b8ff 100644 --- a/packages/monorepo-scripts/CHANGELOG.md +++ b/packages/monorepo-scripts/CHANGELOG.md @@ -5,10 +5,6 @@ Edit the package's CHANGELOG.json file only. CHANGELOG -## v1.0.2 - _July 24, 2018_ - - * Dependencies updated - ## v1.0.1 - _July 23, 2018_ * Dependencies updated -- cgit v1.2.3 From f9e99a27d3b274cefa9065e9cd5dabd4a2cc6057 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 25 Jul 2018 11:51:06 +0200 Subject: Remove force publish --- packages/monorepo-scripts/src/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index d5238ab52..d1df4c56e 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -186,7 +186,7 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string configs.NPM_REGISTRY_URL }`; if (configs.IS_LOCAL_PUBLISH) { - lernaPublishCmd += ` --skip-git --yes --force-publish *`; + lernaPublishCmd += ` --skip-git --yes`; } utils.log('Lerna is publishing...'); await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); -- cgit v1.2.3 From f13d43dbf5fa108cd3b7a250a3bc01471914fa6d Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 25 Jul 2018 11:54:51 +0200 Subject: Remove unused typwe --- packages/monorepo-scripts/src/types.ts | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/types.ts b/packages/monorepo-scripts/src/types.ts index c1483d884..d9e1dfabb 100644 --- a/packages/monorepo-scripts/src/types.ts +++ b/packages/monorepo-scripts/src/types.ts @@ -17,18 +17,6 @@ export interface VersionChangelog { changes: Change[]; } -export enum SemVerIndex { - Invalid, - Patch, - Minor, - Major, - Prepatch, - Preminor, - Premajor, - Prerelease, - Custom, -} - export interface PackageToNextVersion { [name: string]: string; } -- cgit v1.2.3 From 28114c3b5a7b4bff55c813aba1bad246eef29169 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 25 Jul 2018 12:04:45 +0200 Subject: Remove unused import --- packages/monorepo-scripts/src/utils/npm_utils.ts | 1 - 1 file changed, 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/utils/npm_utils.ts b/packages/monorepo-scripts/src/utils/npm_utils.ts index 9c8e51508..363e31fbb 100644 --- a/packages/monorepo-scripts/src/utils/npm_utils.ts +++ b/packages/monorepo-scripts/src/utils/npm_utils.ts @@ -1,4 +1,3 @@ -import * as fs from 'fs'; import 'isomorphic-fetch'; import * as _ from 'lodash'; -- cgit v1.2.3 From d836b0f81502baae5cfbd8949560e7f5ec37f780 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 25 Jul 2018 22:34:26 +0200 Subject: Also skip prompt when publishing for real --- packages/monorepo-scripts/src/publish.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index d1df4c56e..5992131db 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -184,9 +184,9 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string }).join(','); let lernaPublishCmd = `node ${constants.lernaExecutable} publish --cdVersions=${packageVersionString} --registry=${ configs.NPM_REGISTRY_URL - }`; + } --yes`; if (configs.IS_LOCAL_PUBLISH) { - lernaPublishCmd += ` --skip-git --yes`; + lernaPublishCmd += ` --skip-git`; } utils.log('Lerna is publishing...'); await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); -- cgit v1.2.3 From 88ee35d5f9a3d5497c6ffcf5f751be40cbaf7a00 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 12:14:13 +0200 Subject: Call 'lerna publish' with spawn so we see stderr and stdout in real-time --- packages/monorepo-scripts/src/publish.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 5992131db..8f140fc5a 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -4,7 +4,7 @@ import * as promisify from 'es6-promisify'; import * as _ from 'lodash'; import * as moment from 'moment'; import opn = require('opn'); -import { exec as execAsync } from 'promisify-child-process'; +import { exec as execAsync, spawn as spawnAsync } from 'promisify-child-process'; import * as prompt from 'prompt'; import semver = require('semver'); import semverSort = require('semver-sort'); @@ -189,7 +189,15 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string lernaPublishCmd += ` --skip-git`; } utils.log('Lerna is publishing...'); - await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); + const child = await spawnAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); + child.stdout.on('data', (data: Buffer) => { + const output = data.toString('utf8'); + utils.log('Stdout: ', output); + }); + child.stderr.on('data', (data: Buffer) => { + const output = data.toString('utf8'); + utils.log('Stderr: ', output); + }); } function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string): string { -- cgit v1.2.3 From 015469885d5591d2a8e2eb5636f62ba34bd42f7a Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 12:34:41 +0200 Subject: Fix changelogs --- packages/monorepo-scripts/CHANGELOG.json | 9 +++++++++ packages/monorepo-scripts/package.json | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/CHANGELOG.json b/packages/monorepo-scripts/CHANGELOG.json index 6e0fe501e..23d012b47 100644 --- a/packages/monorepo-scripts/CHANGELOG.json +++ b/packages/monorepo-scripts/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1532551340, + "version": "1.0.2", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1532357734, "version": "1.0.1", diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index c11249feb..9c72a4230 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/monorepo-scripts", - "version": "1.0.1", + "version": "1.0.2", "engines": { "node": ">=6.12" }, -- cgit v1.2.3 From 2ae6a71ca3ddeaa721b9484d9d0448fc9e9c2056 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 13:27:21 +0200 Subject: Revert to using execAsync --- packages/monorepo-scripts/src/publish.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 8f140fc5a..5992131db 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -4,7 +4,7 @@ import * as promisify from 'es6-promisify'; import * as _ from 'lodash'; import * as moment from 'moment'; import opn = require('opn'); -import { exec as execAsync, spawn as spawnAsync } from 'promisify-child-process'; +import { exec as execAsync } from 'promisify-child-process'; import * as prompt from 'prompt'; import semver = require('semver'); import semverSort = require('semver-sort'); @@ -189,15 +189,7 @@ async function lernaPublishAsync(packageToNextVersion: { [name: string]: string lernaPublishCmd += ` --skip-git`; } utils.log('Lerna is publishing...'); - const child = await spawnAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); - child.stdout.on('data', (data: Buffer) => { - const output = data.toString('utf8'); - utils.log('Stdout: ', output); - }); - child.stderr.on('data', (data: Buffer) => { - const output = data.toString('utf8'); - utils.log('Stderr: ', output); - }); + await execAsync(lernaPublishCmd, { cwd: constants.monorepoRootPath }); } function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string): string { -- cgit v1.2.3 From 034948065dbe2e30134f16d6b11e23bfc825f44f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 13:53:27 +0200 Subject: Updated CHANGELOGS --- packages/monorepo-scripts/CHANGELOG.json | 9 +++++++++ packages/monorepo-scripts/CHANGELOG.md | 8 ++++++++ 2 files changed, 17 insertions(+) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/CHANGELOG.json b/packages/monorepo-scripts/CHANGELOG.json index 23d012b47..ef876e613 100644 --- a/packages/monorepo-scripts/CHANGELOG.json +++ b/packages/monorepo-scripts/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1532605697, + "version": "1.0.3", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1532551340, "version": "1.0.2", diff --git a/packages/monorepo-scripts/CHANGELOG.md b/packages/monorepo-scripts/CHANGELOG.md index 74cd3b8ff..b37065ff7 100644 --- a/packages/monorepo-scripts/CHANGELOG.md +++ b/packages/monorepo-scripts/CHANGELOG.md @@ -5,6 +5,14 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.3 - _July 26, 2018_ + + * Dependencies updated + +## v1.0.2 - _July 25, 2018_ + + * Dependencies updated + ## v1.0.1 - _July 23, 2018_ * Dependencies updated -- cgit v1.2.3 From b756f76b0e8fec5d57d86429d030d75f6c3ef6ca Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 13:53:36 +0200 Subject: Publish - 0x.js@1.0.1-rc.1 - @0xproject/abi-gen@1.0.2 - @0xproject/assert@1.0.2 - @0xproject/base-contract@1.0.2 - @0xproject/connect@1.0.2 - @0xproject/contract-wrappers@1.0.1-rc.1 - contracts@2.1.37 - @0xproject/dev-utils@1.0.2 - ethereum-types@1.0.2 - @0xproject/fill-scenarios@1.0.1-rc.1 - @0xproject/json-schemas@1.0.1-rc.1 - @0xproject/metacoin@0.0.12 - @0xproject/migrations@1.0.2 - @0xproject/monorepo-scripts@1.0.3 - @0xproject/order-utils@1.0.1-rc.1 - @0xproject/order-watcher@1.0.1-rc.1 - @0xproject/react-docs@1.0.2 - @0xproject/react-docs-example@0.0.17 - @0xproject/react-shared@1.0.3 - @0xproject/sol-compiler@1.0.2 - @0xproject/sol-cov@1.0.2 - @0xproject/sol-resolver@1.0.2 - @0xproject/sra-report@1.0.2 - @0xproject/subproviders@1.0.2 - @0xproject/testnet-faucets@1.0.38 - @0xproject/tslint-config@1.0.3 - @0xproject/types@1.0.1-rc.1 - @0xproject/typescript-typings@1.0.2 - @0xproject/utils@1.0.2 - @0xproject/web3-wrapper@1.1.0 - @0xproject/website@0.0.41 --- packages/monorepo-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index 9c72a4230..c31363682 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/monorepo-scripts", - "version": "1.0.2", + "version": "1.0.3", "engines": { "node": ">=6.12" }, -- cgit v1.2.3 From e320f343f8d18a301bc1d74dcb2816e3d1e3be6f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 14:14:14 +0200 Subject: Add support for testing installations post-publish as well --- packages/monorepo-scripts/src/test_installation.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index a9610e5ee..12c0e7603 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -9,6 +9,8 @@ import * as rimraf from 'rimraf'; import { utils } from './utils/utils'; (async () => { + const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; + const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873' : 'https://registry.npmjs.org'; const monorepoRootPath = path.join(__dirname, '../../..'); const packages = utils.getTopologicallySortedPackages(monorepoRootPath); const installablePackages = _.filter( @@ -26,9 +28,9 @@ import { utils } from './utils/utils'; fs.mkdirSync(testDirectory); await execAsync('yarn init --yes', { cwd: testDirectory }); const npmrcFilePath = path.join(testDirectory, '.npmrc'); - fs.writeFileSync(npmrcFilePath, `registry=http://localhost:4873`); + fs.writeFileSync(npmrcFilePath, `registry=${registry}`); utils.log(`Installing ${packageName}@${lastChangelogVersion}`); - await execAsync(`npm install --save ${packageName}@${lastChangelogVersion} --registry=http://localhost:4873`, { + await execAsync(`npm install --save ${packageName}@${lastChangelogVersion} --registry=${registry}`, { cwd: testDirectory, }); const indexFilePath = path.join(testDirectory, 'index.ts'); -- cgit v1.2.3 From d3be4f2852ca5bb35e50d27403715354b7485c4b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 14:22:51 +0200 Subject: Add ending slash --- packages/monorepo-scripts/src/test_installation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 12c0e7603..55ff12083 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -10,7 +10,7 @@ import { utils } from './utils/utils'; (async () => { const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; - const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873' : 'https://registry.npmjs.org'; + const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/'; const monorepoRootPath = path.join(__dirname, '../../..'); const packages = utils.getTopologicallySortedPackages(monorepoRootPath); const installablePackages = _.filter( -- cgit v1.2.3 From 9947e643d0b201a0dad122fbe1a6f4a226469944 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 14:23:07 +0200 Subject: Print version that will be tested --- packages/monorepo-scripts/src/test_installation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 55ff12083..1d9e3569d 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -23,7 +23,7 @@ import { utils } from './utils/utils'; const changelogPath = path.join(installablePackage.location, 'CHANGELOG.json'); const lastChangelogVersion = JSON.parse(fs.readFileSync(changelogPath).toString())[0].version; const packageName = installablePackage.packageJson.name; - utils.log(`Testing ${packageName}`); + utils.log(`Testing ${packageName}@${lastChangelogVersion}`); const testDirectory = path.join(monorepoRootPath, '../test-env'); fs.mkdirSync(testDirectory); await execAsync('yarn init --yes', { cwd: testDirectory }); -- cgit v1.2.3 From af4071e119b4cb651ae311ea1200fdd76f8123e7 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 14:23:45 +0200 Subject: Delete any remenants of test-env dir before creating a new one --- packages/monorepo-scripts/src/test_installation.ts | 1 + 1 file changed, 1 insertion(+) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 1d9e3569d..b10db5a06 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -25,6 +25,7 @@ import { utils } from './utils/utils'; const packageName = installablePackage.packageJson.name; utils.log(`Testing ${packageName}@${lastChangelogVersion}`); const testDirectory = path.join(monorepoRootPath, '../test-env'); + rimraf.sync(testDirectory); fs.mkdirSync(testDirectory); await execAsync('yarn init --yes', { cwd: testDirectory }); const npmrcFilePath = path.join(testDirectory, '.npmrc'); -- cgit v1.2.3 From 55dbb0ece06d17a9db7b93a0ffa274ff65298002 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 14:42:07 +0200 Subject: Always append monorepo root path so script can be called from anywhere --- packages/monorepo-scripts/src/postpublish_utils.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/postpublish_utils.ts b/packages/monorepo-scripts/src/postpublish_utils.ts index 37861f0dd..77def309e 100644 --- a/packages/monorepo-scripts/src/postpublish_utils.ts +++ b/packages/monorepo-scripts/src/postpublish_utils.ts @@ -96,7 +96,7 @@ export const postpublishUtils = { const notes = postpublishUtils.getReleaseNotes(packageName, version); const releaseName = postpublishUtils.getReleaseName(packageName, version); const tag = postpublishUtils.getTag(packageName, version); - postpublishUtils.adjustAssetPaths(cwd, assets); + postpublishUtils.adjustAssetPaths(assets); utils.log('POSTPUBLISH: Releasing ', releaseName, '...'); await publishReleaseAsync({ token: constants.githubPersonalAccessToken, @@ -145,10 +145,12 @@ export const postpublishUtils = { const releaseName = `${subPackageName} v${version}`; return releaseName; }, - adjustAssetPaths(cwd: string, assets: string[]): string[] { + // Asset paths should described from the monorepo root. This method prefixes + // the supplied path with the absolute path to the monorepo root. + adjustAssetPaths(assets: string[]): string[] { const finalAssets: string[] = []; _.each(assets, (asset: string) => { - finalAssets.push(`${cwd}/${asset}`); + finalAssets.push(`${constants.monorepoRootPath}/${asset}`); }); return finalAssets; }, -- cgit v1.2.3 From 331b1cb9a0edd8809c82393ed482674e61a76636 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 15:27:50 +0200 Subject: Fix lint issue --- packages/monorepo-scripts/src/postpublish_utils.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/postpublish_utils.ts b/packages/monorepo-scripts/src/postpublish_utils.ts index 77def309e..8e445a045 100644 --- a/packages/monorepo-scripts/src/postpublish_utils.ts +++ b/packages/monorepo-scripts/src/postpublish_utils.ts @@ -57,7 +57,6 @@ export const postpublishUtils = { } const postpublishConfigs = postpublishUtils.generateConfig(packageJSON, tsConfigJSON, cwd); await postpublishUtils.publishReleaseNotesAsync( - postpublishConfigs.cwd, postpublishConfigs.packageName, postpublishConfigs.version, postpublishConfigs.assets, @@ -92,7 +91,7 @@ export const postpublishUtils = { postpublishConfigs.docPublishConfigs.s3StagingBucketPath, ); }, - async publishReleaseNotesAsync(cwd: string, packageName: string, version: string, assets: string[]): Promise { + async publishReleaseNotesAsync(packageName: string, version: string, assets: string[]): Promise { const notes = postpublishUtils.getReleaseNotes(packageName, version); const releaseName = postpublishUtils.getReleaseName(packageName, version); const tag = postpublishUtils.getTag(packageName, version); -- cgit v1.2.3 From e3cfa6363daf8b46b231fb38fc1bf6c8e13db17b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 15:32:30 +0200 Subject: Change test:installation so it also causes run-time errors to appear --- packages/monorepo-scripts/src/test_installation.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index b10db5a06..4c92d0aa2 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -13,11 +13,14 @@ import { utils } from './utils/utils'; const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/'; const monorepoRootPath = path.join(__dirname, '../../..'); const packages = utils.getTopologicallySortedPackages(monorepoRootPath); - const installablePackages = _.filter( + const preInstallablePackages = _.filter( packages, pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'), ); utils.log('Testing packages:'); + const installablePackages = _.filter(preInstallablePackages, pkg => { + return pkg.packageJson.name === '0x.js'; + }); _.map(installablePackages, pkg => utils.log(`* ${pkg.packageJson.name}`)); for (const installablePackage of installablePackages) { const changelogPath = path.join(installablePackage.location, 'CHANGELOG.json'); @@ -35,7 +38,7 @@ import { utils } from './utils/utils'; cwd: testDirectory, }); const indexFilePath = path.join(testDirectory, 'index.ts'); - fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}';\n`); + fs.writeFileSync(indexFilePath, `import * as Package from '${packageName}';\nconsole.log(Package);\n`); const tsConfig = { compilerOptions: { typeRoots: ['node_modules/@0xproject/typescript-typings/types', 'node_modules/@types'], @@ -55,7 +58,11 @@ import { utils } from './utils/utils'; const tscBinaryPath = path.join(monorepoRootPath, './node_modules/typescript/bin/tsc'); await execAsync(tscBinaryPath, { cwd: testDirectory }); utils.log(`Successfully compiled with ${packageName} as a dependency`); - rimraf.sync(testDirectory); + const transpiledIndexFilePath = path.join(testDirectory, 'index.js'); + utils.log(`Running test script with ${packageName} imported`); + await execAsync(`node ${transpiledIndexFilePath}`); + utils.log(`Successfilly ran test script with ${packageName} imported`); + // rimraf.sync(testDirectory); } })().catch(err => { utils.log(err.stderr); -- cgit v1.2.3 From 735bc2f1789384c33c38db011148e5a98e7ba74e Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 15:32:53 +0200 Subject: Re-enable deleted the dir after test runs --- packages/monorepo-scripts/src/test_installation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 4c92d0aa2..d1f5ce655 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -62,7 +62,7 @@ import { utils } from './utils/utils'; utils.log(`Running test script with ${packageName} imported`); await execAsync(`node ${transpiledIndexFilePath}`); utils.log(`Successfilly ran test script with ${packageName} imported`); - // rimraf.sync(testDirectory); + rimraf.sync(testDirectory); } })().catch(err => { utils.log(err.stderr); -- cgit v1.2.3 From a90f434df5718f45b8eb367a8fabde97ee3d0513 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 15:58:35 +0200 Subject: Split running packages that cannot be run in a node.js script --- packages/monorepo-scripts/src/test_installation.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index d1f5ce655..bbaf9b056 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -8,6 +8,14 @@ import * as rimraf from 'rimraf'; import { utils } from './utils/utils'; +// Packages might not be runnable if they are command-line tools or only run in browsers. +const UNRUNNABLE_PACKAGES = [ + '@0xproject/abi-gen', + '@0xproject/sra-report', + '@0xproject/react-shared', + '@0xproject/react-docs', +]; + (async () => { const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/'; @@ -19,7 +27,7 @@ import { utils } from './utils/utils'; ); utils.log('Testing packages:'); const installablePackages = _.filter(preInstallablePackages, pkg => { - return pkg.packageJson.name === '0x.js'; + return !_.includes(UNRUNNABLE_PACKAGES, pkg.packageJson.name); }); _.map(installablePackages, pkg => utils.log(`* ${pkg.packageJson.name}`)); for (const installablePackage of installablePackages) { -- cgit v1.2.3 From 0187e0c47df98bac67da135b55e2630e25ffd513 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 16:20:20 +0200 Subject: Still test unrunnable packages for compilation issues --- packages/monorepo-scripts/src/test_installation.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index bbaf9b056..a8ddf0c58 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -21,14 +21,11 @@ const UNRUNNABLE_PACKAGES = [ const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/'; const monorepoRootPath = path.join(__dirname, '../../..'); const packages = utils.getTopologicallySortedPackages(monorepoRootPath); - const preInstallablePackages = _.filter( + const installablePackages = _.filter( packages, pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'), ); utils.log('Testing packages:'); - const installablePackages = _.filter(preInstallablePackages, pkg => { - return !_.includes(UNRUNNABLE_PACKAGES, pkg.packageJson.name); - }); _.map(installablePackages, pkg => utils.log(`* ${pkg.packageJson.name}`)); for (const installablePackage of installablePackages) { const changelogPath = path.join(installablePackage.location, 'CHANGELOG.json'); @@ -66,10 +63,13 @@ const UNRUNNABLE_PACKAGES = [ const tscBinaryPath = path.join(monorepoRootPath, './node_modules/typescript/bin/tsc'); await execAsync(tscBinaryPath, { cwd: testDirectory }); utils.log(`Successfully compiled with ${packageName} as a dependency`); - const transpiledIndexFilePath = path.join(testDirectory, 'index.js'); - utils.log(`Running test script with ${packageName} imported`); - await execAsync(`node ${transpiledIndexFilePath}`); - utils.log(`Successfilly ran test script with ${packageName} imported`); + const isUnrunnablePkg = _.includes(UNRUNNABLE_PACKAGES, packageName); + if (!isUnrunnablePkg) { + const transpiledIndexFilePath = path.join(testDirectory, 'index.js'); + utils.log(`Running test script with ${packageName} imported`); + await execAsync(`node ${transpiledIndexFilePath}`); + utils.log(`Successfilly ran test script with ${packageName} imported`); + } rimraf.sync(testDirectory); } })().catch(err => { -- cgit v1.2.3 From 87fb9a76cec7ceb735918d77eaee2788dd9bc281 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 16:26:57 +0200 Subject: Updated CHANGELOGS --- packages/monorepo-scripts/CHANGELOG.json | 9 +++++++++ packages/monorepo-scripts/CHANGELOG.md | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/CHANGELOG.json b/packages/monorepo-scripts/CHANGELOG.json index ef876e613..d994f4a71 100644 --- a/packages/monorepo-scripts/CHANGELOG.json +++ b/packages/monorepo-scripts/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1532614997, + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1532605697, "version": "1.0.3", diff --git a/packages/monorepo-scripts/CHANGELOG.md b/packages/monorepo-scripts/CHANGELOG.md index b37065ff7..95ed3190e 100644 --- a/packages/monorepo-scripts/CHANGELOG.md +++ b/packages/monorepo-scripts/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.4 - _July 26, 2018_ + + * Dependencies updated + ## v1.0.3 - _July 26, 2018_ * Dependencies updated -- cgit v1.2.3 From 973bcb04833d895c3e69f9c256a7ede038c1f8a0 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 16:27:08 +0200 Subject: Publish - 0x.js@1.0.1-rc.2 - @0xproject/abi-gen@1.0.3 - @0xproject/assert@1.0.3 - @0xproject/base-contract@1.0.3 - @0xproject/connect@1.0.3 - @0xproject/contract-wrappers@1.0.1-rc.2 - contracts@2.1.38 - @0xproject/dev-utils@1.0.3 - ethereum-types@1.0.3 - @0xproject/fill-scenarios@1.0.1-rc.2 - @0xproject/json-schemas@1.0.1-rc.2 - @0xproject/metacoin@0.0.13 - @0xproject/migrations@1.0.3 - @0xproject/monorepo-scripts@1.0.4 - @0xproject/order-utils@1.0.1-rc.2 - @0xproject/order-watcher@1.0.1-rc.2 - @0xproject/react-docs@1.0.3 - @0xproject/react-docs-example@0.0.18 - @0xproject/react-shared@1.0.4 - @0xproject/sol-compiler@1.0.3 - @0xproject/sol-cov@1.0.3 - @0xproject/sol-resolver@1.0.3 - @0xproject/sra-report@1.0.3 - @0xproject/subproviders@1.0.3 - @0xproject/testnet-faucets@1.0.39 - @0xproject/tslint-config@1.0.4 - @0xproject/types@1.0.1-rc.2 - @0xproject/typescript-typings@1.0.3 - @0xproject/utils@1.0.3 - @0xproject/web3-wrapper@1.1.1 - @0xproject/website@0.0.42 --- packages/monorepo-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index c31363682..128bdcff5 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/monorepo-scripts", - "version": "1.0.3", + "version": "1.0.4", "engines": { "node": ">=6.12" }, -- cgit v1.2.3