diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 28d7931..4298631 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -34,7 +34,7 @@ this will make a new version and on version tag, the main ci workflow will push ## HowTo release using `gh` Install and create automatically a draft release version using [gh client](https://cli.github.com/) -- the version tag must exists +- the version tag must exist Example to create v2.2.9 ```bash diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 42a07db..80fe3fe 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -33,12 +33,13 @@ jobs: cache: 'pnpm' - name: Install dependencies - # - run: npm ci # need package.json.lock run: | + echo ::group::Install dependencies echo "install" pnpm install echo "show outdated (if any)" - pnpm outdated --depth=3 || echo "::notice title=OneLineReport::ℹ️ you must think about update your dependencies :)" + pnpm outdated --depth=3 || echo "::warning::🕸️ you must think about update your dependencies :)" + echo ::endgroup:: - name: pnpm audit run: | diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef5f61d..1468681 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,11 +46,13 @@ jobs: cache: 'pnpm' - name: Install dependencies - # npx force-resolutions : in case of Permission denied: run it locally to fix package-lock.json run: | + echo ::group::Install dependencies echo "install" pnpm install echo "show outdated (if any)" + pnpm outdated --depth=3 || echo "::warning::🕸️ you must think about update your dependencies :)" + echo ::endgroup:: pnpm outdated --depth=3 || echo "::notice title=OneLineReport::ℹ️ you must think about update your dependencies :)" - name: Setup mongo tools # add mongosh and mongodump/mongorestore diff --git a/lib/MTCommand.js b/lib/MTCommand.js index 7f3e30c..0f4aa93 100644 --- a/lib/MTCommand.js +++ b/lib/MTCommand.js @@ -24,8 +24,8 @@ class MTCommand { } logOutput(result) { - if (result.stdout) { console.info('stdout:', result.stdout); } - if (result.stderr) { console.error('stderr:', result.stderr); } + if (result?.stdout) { console.info('stdout:', result.stdout); } + if (result?.stderr) { console.error('stderr:', result.stderr); } } logSuccess(success) { @@ -41,11 +41,11 @@ class MTCommand { logError(err) { // DEBUG // console.error(JSON.stringify(err)); - if (err && err.status) { + if (err?.status) { console.error(`Error ${err.status} ${JSON.stringify(err.error, null, 4)}`); - } else if (err && err.message) { + } else if (err?.message) { console.error(`Error ${err.message}`); - } else if (err && err.text) { + } else if (err?.text) { console.error(`Error ${err.text}`); } else { console.error(`Error ${JSON.stringify(err, null, 4)}`); @@ -65,18 +65,18 @@ class MTCommand { if (action === 'list') { this.mt.list(new MTOptions()).then((listResult) => { console.log(JSON.stringify(listResult, null, 4)); - }).catch(error => cmd.logError(error.message)); + }).catch(error => cmd.logError(error)); return; } if (action === 'dumpz') { this.mt.mongodump(new MTOptions({ "encrypt":true })) - .then(cmd.logSuccess.bind(cmd)).catch(error => cmd.logError(error.message)); + .then(cmd.logSuccess.bind(cmd)).catch(error => cmd.logError(error)); return; } if (action === 'dump') { - this.mt.mongodump(new MTOptions({})).then(cmd.logSuccess.bind(cmd)).catch(error => cmd.logError(error.message)); + this.mt.mongodump(new MTOptions({})).then(cmd.logSuccess.bind(cmd)).catch(error => cmd.logError(error)); return; } // restore action do need an extra argument: the file to restore @@ -91,11 +91,11 @@ class MTCommand { dropBeforeRestore: false, deleteDumpAfterRestore: false })) - .then(cmd.logSuccess.bind(cmd)).catch(error => cmd.logError(error.message)); + .then(cmd.logSuccess.bind(cmd)).catch(error => cmd.logError(error)); return; } if (action === 'rotation') { - this.mt.rotation(new MTOptions()).then(cmd.logSuccess.bind(cmd)).catch(error => cmd.logError(error.message)); + this.mt.rotation(new MTOptions()).then(cmd.logSuccess.bind(cmd)).catch(error => cmd.logError(error)); } }