From 478f6ed011185b66ac87323c6d9ad1f598060760 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 14 May 2018 19:23:50 +0200 Subject: Move from using lerna multi-package commands to wsrun, update README's accordingly --- packages/monorepo-scripts/README.md | 20 ++++---------------- packages/monorepo-scripts/package.json | 3 +-- packages/monorepo-scripts/src/publish.ts | 2 +- 3 files changed, 6 insertions(+), 19 deletions(-) (limited to 'packages/monorepo-scripts') diff --git a/packages/monorepo-scripts/README.md b/packages/monorepo-scripts/README.md index cec77a10d..22b449870 100644 --- a/packages/monorepo-scripts/README.md +++ b/packages/monorepo-scripts/README.md @@ -4,7 +4,7 @@ This repository contains a few helpful scripts for working with this mono repo. #### Scripts -**`yarn deps_versions`**: Since we use Lerna + Yarn workspaces, shared dependencies between packages in the monorepo get hoisted to a top-level `node_modules` directory. If two packages use different versions of the same dependency however, both get installed. To avoid having many versions of a dependency installed, we try to keep dependency versions the same across packages in the monorepo. This script will list any dependencies for which we have multiple versions installed. We can then go through them and try to consolidate to a single version where possible. +**`yarn deps_versions`**: Since we are a Yarn workspaces monorepo, shared dependencies between packages in the monorepo get hoisted to a top-level `node_modules` directory. If two packages use different versions of the same dependency however, both get installed. To avoid having many versions of a dependency installed, we try to keep dependency versions the same across packages in the monorepo. This script will list any dependencies for which we have multiple versions installed. We can then go through them and try to consolidate to a single version where possible. **`yarn find_unused_deps`**: Sometimes we accidentally leave dependencies listed in `package.json` that are no longer being used. This script finds potential dependencies that might no longer be in use. Please verify that it is no longer in use before removing, the `depcheck` package we use under-the-hood doesn't handle some TS quirks perfectly. @@ -46,28 +46,16 @@ yarn install ### Build -If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory: +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: ```bash -yarn lerna:rebuild +PKG=@0xproject/monorepo-scripts yarn build ``` Or continuously rebuild on change: ```bash -yarn dev -``` - -You can also build this specific package by running the following from within its directory: - -```bash -yarn build -``` - -or continuously rebuild on change: - -```bash -yarn build:watch +PKG=@0xproject/monorepo-scripts yarn watch ``` ### Clean diff --git a/packages/monorepo-scripts/package.json b/packages/monorepo-scripts/package.json index ef5840546..ca82a5531 100644 --- a/packages/monorepo-scripts/package.json +++ b/packages/monorepo-scripts/package.json @@ -5,7 +5,7 @@ "main": "lib/index.js", "types": "lib/index.d.ts", "scripts": { - "build:watch": "tsc -w", + "watch": "tsc -w", "lint": "tslint --project .", "clean": "shx rm -rf lib", "build": "tsc", @@ -26,7 +26,6 @@ "url": "https://github.com/0xProject/0x-monorepo/issues" }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/monorepo-scripts/README.md", - "comment": "// We purposefully use an older version of tslint-config here to avoid creating an import cycle", "devDependencies": { "@types/glob": "^5.0.33", "@types/node": "^8.0.53", diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index a5be40014..31c85e3cc 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -75,7 +75,7 @@ const packageNameToWebsitePath: { [name: string]: string } = { async function confirmDocPagesRenderAsync(packages: LernaPackage[]) { // push docs to staging utils.log("Upload all docJson's to S3 staging..."); - await execAsync(`yarn lerna:stage_docs`, { cwd: constants.monorepoRootPath }); + await execAsync(`yarn stage_docs`, { cwd: constants.monorepoRootPath }); // deploy website to staging utils.log('Deploy website to staging...'); -- cgit v1.2.3 From d0905eda496864096f5a64b1e2c1c05b575be904 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 14 May 2018 21:48:46 +0200 Subject: Fix TSLint issues --- packages/monorepo-scripts/src/postpublish_utils.ts | 10 +++++----- packages/monorepo-scripts/src/publish.ts | 8 ++++---- packages/monorepo-scripts/src/utils.ts | 4 ++-- 3 files changed, 11 insertions(+), 11 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 df2bcb128..5fbff938e 100644 --- a/packages/monorepo-scripts/src/postpublish_utils.ts +++ b/packages/monorepo-scripts/src/postpublish_utils.ts @@ -74,7 +74,7 @@ export const postpublishUtils = { utils.log(`POSTPUBLISH: No S3Bucket config found for ${packageJSON.name}. Skipping doc JSON generation.`); } }, - async publishDocsToStagingAsync(packageJSON: any, tsConfigJSON: any, cwd: string) { + async publishDocsToStagingAsync(packageJSON: any, tsConfigJSON: any, cwd: string): Promise { const configs = this.generateConfig(packageJSON, tsConfigJSON, cwd); if (_.isUndefined(configs.docPublishConfigs.s3StagingBucketPath)) { utils.log('config.postpublish.docPublishConfigs.s3StagingBucketPath entry in package.json not found!'); @@ -109,7 +109,7 @@ export const postpublishUtils = { assets, }); }, - getReleaseNotes(packageName: string, version: string) { + getReleaseNotes(packageName: string, version: string): string { const packageNameWithNamespace = packageName.replace('@0xproject/', ''); const changelogJSONPath = path.join( constants.monorepoRootPath, @@ -135,14 +135,14 @@ export const postpublishUtils = { }); return notes; }, - getTag(packageName: string, version: string) { + getTag(packageName: string, version: string): string { return `${packageName}@${version}`; }, getReleaseName(subPackageName: string, version: string): string { const releaseName = `${subPackageName} v${version}`; return releaseName; }, - adjustAssetPaths(cwd: string, assets: string[]) { + adjustAssetPaths(cwd: string, assets: string[]): string[] { const finalAssets: string[] = []; _.each(assets, (asset: string) => { finalAssets.push(`${cwd}/${asset}`); @@ -164,7 +164,7 @@ export const postpublishUtils = { }); return fileIncludesAdjusted; }, - async generateAndUploadDocsAsync(cwd: string, fileIncludes: string[], version: string, S3BucketPath: string) { + async generateAndUploadDocsAsync(cwd: string, fileIncludes: string[], version: string, S3BucketPath: string): Promise { const fileIncludesAdjusted = this.adjustFileIncludePaths(fileIncludes, cwd); const projectFiles = fileIncludesAdjusted.join(' '); const jsonFilePath = `${cwd}/${generatedDocsDirectoryName}/index.json`; diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index 31c85e3cc..5c26475c9 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -72,7 +72,7 @@ const packageNameToWebsitePath: { [name: string]: string } = { process.exit(1); }); -async function confirmDocPagesRenderAsync(packages: LernaPackage[]) { +async function confirmDocPagesRenderAsync(packages: LernaPackage[]): Promise { // push docs to staging utils.log("Upload all docJson's to S3 staging..."); await execAsync(`yarn stage_docs`, { cwd: constants.monorepoRootPath }); @@ -162,7 +162,7 @@ async function checkPublishRequiredSetupAsync(): Promise { return true; } -async function pushChangelogsToGithubAsync() { +async function pushChangelogsToGithubAsync(): Promise { await execAsync(`git add . --all`, { cwd: constants.monorepoRootPath }); await execAsync(`git commit -m "Updated CHANGELOGS"`, { cwd: constants.monorepoRootPath }); await execAsync(`git push`, { cwd: constants.monorepoRootPath }); @@ -228,7 +228,7 @@ async function updateChangeLogsAsync(updatedPublicLernaPackages: LernaPackage[]) return packageToVersionChange; } -async function lernaPublishAsync(packageToVersionChange: { [name: string]: string }) { +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', '--registry=https://registry.npmjs.org/'], { @@ -269,7 +269,7 @@ async function lernaPublishAsync(packageToVersionChange: { [name: string]: strin }); } -function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string) { +function updateVersionNumberIfNeeded(currentVersion: string, proposedNextVersion: string): string { if (proposedNextVersion === currentVersion) { return utils.getNextPatchVersion(currentVersion); } diff --git a/packages/monorepo-scripts/src/utils.ts b/packages/monorepo-scripts/src/utils.ts index 4412f753a..480788ad8 100644 --- a/packages/monorepo-scripts/src/utils.ts +++ b/packages/monorepo-scripts/src/utils.ts @@ -17,7 +17,7 @@ export const utils = { const newPatchVersion = `${versionSegments[0]}.${versionSegments[1]}.${newPatch}`; return newPatchVersion; }, - async prettifyAsync(filePath: string, cwd: string) { + async prettifyAsync(filePath: string, cwd: string): Promise { await execAsync(`prettier --write ${filePath} --config .prettierrc`, { cwd, }); @@ -43,7 +43,7 @@ export const utils = { } return updatedPackages; }, - getChangelogJSONIfExists(changelogPath: string) { + getChangelogJSONIfExists(changelogPath: string): string|undefined { try { const changelogJSON = fs.readFileSync(changelogPath, 'utf-8'); return changelogJSON; -- cgit v1.2.3