From fe50a0cc2aa93465c87b44250928c5da944d5a7b Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Thu, 23 Apr 2020 08:05:08 -0700 Subject: [PATCH] feat: update bin/create-package.js to be compatible with TypeScript project references --- bin/create-package.js | 20 +++++++++++++------- bin/update-ts-project-refs.js | 2 ++ docs/site/DEVELOPING.md | 14 +++++++++----- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/bin/create-package.js b/bin/create-package.js index 8d0b29f2bc7c..a664a368bc8a 100644 --- a/bin/create-package.js +++ b/bin/create-package.js @@ -25,15 +25,20 @@ * `--yes` or `-y` is provide by the command, interactive prompts are skipped. * * 3. Tidy up the project - * - Remove unused files - * - Rename `tsconfig.json` to `tsconfig.build.json` - * - Improve `package.json` + * - Remove unused files + * - Improve `package.json` * - * 4. Run `lerna boostrap` on the newly added package to set up dependencies + * 4. Run `lerna bootstrap --scope ` to link its local + * dependencies. + * + * 5. Run `update-ts-project-refs` to update TypeScript project references + * + * 6. Remind to update `CODEOWNERS` and `docs/site/MONOREPO.md` */ 'use strict'; const build = require('../packages/build'); +const {updateReferences} = require('./update-ts-project-refs'); const path = require('path'); const cwd = process.cwd(); const fs = require('fs-extra'); @@ -101,6 +106,7 @@ async function main() { await scaffoldProject(project); await tidyupProject(project); await bootstrapProject(project); + await updateReferences({dryRun: false}); promptActions(project); } @@ -163,9 +169,6 @@ async function tidyupProject({repoRoot, projectDir}) { }; fs.writeJsonSync('package.json', pkg); - // Move tsconfig.json to tsconfig.build.json - fs.moveSync('tsconfig.json', 'tsconfig.build.json'); - // Remove unused files build.clean([ 'node', @@ -197,6 +200,9 @@ async function tidyupProject({repoRoot, projectDir}) { await waitForProcessExit(copyrightProcess); } +/** + * Remind follow-up steps + */ function promptActions({projectDir}) { console.log(); console.log( diff --git a/bin/update-ts-project-refs.js b/bin/update-ts-project-refs.js index 2d0b82ea3e56..d8f969e99fc6 100644 --- a/bin/update-ts-project-refs.js +++ b/bin/update-ts-project-refs.js @@ -138,3 +138,5 @@ if (require.main === module) { process.exit(1); }); } + +exports.updateReferences = updateReferences; diff --git a/docs/site/DEVELOPING.md b/docs/site/DEVELOPING.md index 3eaa9edcabc0..fe8a1a4563b9 100644 --- a/docs/site/DEVELOPING.md +++ b/docs/site/DEVELOPING.md @@ -603,10 +603,14 @@ The script does the following steps: 3. Tidy up the project - Remove unused files - - Rename `tsconfig.json` to `tsconfig.build.json` - Improve `package.json` -4. Run `lerna boostrap` on the newly added package to set up dependencies +4. Run `lerna bootstrap --scope ` to link its local + dependencies. + +5. Run `update-ts-project-refs` to update TypeScript project references + +6. Remind to update `CODEOWNERS` and `docs/site/MONOREPO.md` If you would like to do it manually, follow steps below: @@ -756,9 +760,9 @@ In the [`loopback-next`](https://github.com/strongloop/loopback-next) monorepo, This is why we have two sets of `tsconfig` files: -- At monorepo root, there is `tsconfig.json` used by VS Code. -- Inside each package, there is `tsconfig.build.json` used by `npm run build` - command. +- At monorepo root, there is `tsconfig.json` used by VS Code and + `tsconfig.build.json` used by `eslint`. +- Inside each package, there is `tsconfig.json` used by `npm run build` command. ## Renovate bot