From 5e639a570847fe7954444a206d524bfda3666bfb Mon Sep 17 00:00:00 2001 From: Max Okorokov Date: Wed, 19 Feb 2025 15:32:29 +0100 Subject: [PATCH] chore: publish correct `README.md` for the angular package Fixes #3 --- packages/angular/README.md | 2 +- packages/angular/lib/README.md | 25 ------------------------ scripts/prepare-packages.js | 35 +++++++++++++++++++++------------- 3 files changed, 23 insertions(+), 39 deletions(-) delete mode 100644 packages/angular/lib/README.md diff --git a/packages/angular/README.md b/packages/angular/README.md index d626d6a..120fc33 100644 --- a/packages/angular/README.md +++ b/packages/angular/README.md @@ -1,3 +1,3 @@ # Amadeus Toolkit for Micro Frontends (Angular) -> TODO: description +An Angular wrapper for the `@amadeus-it-group/microfrontends` library. diff --git a/packages/angular/lib/README.md b/packages/angular/lib/README.md deleted file mode 100644 index 4489c57..0000000 --- a/packages/angular/lib/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# MessageChannelAngular - -This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.0. - -## Code scaffolding - -Run `ng generate component component-name --project message-channel-angular` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project message-channel-angular`. - -> Note: Don't forget to add `--project message-channel-angular` or else it will be added to the default project in your `angular.json` file. - -## Build - -Run `ng build message-channel-angular` to build the project. The build artifacts will be stored in the `dist/` directory. - -## Publishing - -After building your library with `ng build message-channel-angular`, go to the dist folder `cd dist/message-channel-angular` and run `npm publish`. - -## Running unit tests - -Run `ng test message-channel-angular` to execute the unit tests via [Karma](https://karma-runner.github.io). - -## Further help - -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page. diff --git a/scripts/prepare-packages.js b/scripts/prepare-packages.js index 1ad1dfa..19a4a24 100644 --- a/scripts/prepare-packages.js +++ b/scripts/prepare-packages.js @@ -6,33 +6,42 @@ import { fileURLToPath } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const PUBLISH_DIR = path.resolve(__dirname, '../.publish'); -function packPackage(cwd, { cleanPackageJson } = { cleanPackageJson: true }) { +function packCore() { + const cwd = path.resolve(__dirname, '../packages/core'); const packageJsonPath = path.join(cwd, 'package.json'); const backupPath = path.join(cwd, `package.json.backup`); try { // `npm pkg delete` - if (cleanPackageJson) { - fs.copySync(packageJsonPath, backupPath); - console.log(`Cleaning package.json in ${cwd}...`); - execSync('npm pkg delete wireit scripts devDependencies', { cwd, encoding: 'utf8' }); - } + fs.copySync(packageJsonPath, backupPath); + console.log(`Cleaning package.json in ${cwd}...`); + execSync('npm pkg delete wireit scripts devDependencies', { cwd, encoding: 'utf8' }); // `npm pack` execSync(`npm pack --pack-destination "${PUBLISH_DIR}"`, { cwd, encoding: 'utf8' }); } catch (err) { console.error(`Error packing ${cwd}:`, err); } finally { - if (cleanPackageJson) { - fs.moveSync(backupPath, packageJsonPath, { overwrite: true }); - } + fs.moveSync(backupPath, packageJsonPath, { overwrite: true }); + } +} + +function packAngular() { + const cwd = path.resolve(__dirname, '../packages/angular/dist'); + + try { + // copy README.md + fs.copySync(path.join(cwd, '..', 'README.md'), path.join(cwd, 'README.md')); + + // `npm pack` + execSync(`npm pack --pack-destination "${PUBLISH_DIR}"`, { cwd, encoding: 'utf8' }); + } catch (err) { + console.error(`Error packing ${cwd}:`, err); } } fs.removeSync(PUBLISH_DIR); fs.ensureDirSync(PUBLISH_DIR); -packPackage(path.resolve(__dirname, '../packages/core')); -packPackage(path.resolve(__dirname, '../packages/angular/dist'), { - cleanPackageJson: false, -}); +packCore(); +packAngular();