From c5cc902b5d19c482e448795c577a10c8bc809a39 Mon Sep 17 00:00:00 2001 From: Carina Ursu Date: Mon, 6 Mar 2023 17:54:19 -0800 Subject: [PATCH] fix: update chalk, add semantic-release test cmd (#708) Signed-off-by: Carina Ursu --- .releaserc.json | 14 ---------- package.json | 8 +++--- release.config.js | 68 +++++++++++++++++++++++++++++++++++++++++++++++ yarn.lock | 13 +++------ 4 files changed, 76 insertions(+), 27 deletions(-) delete mode 100644 .releaserc.json create mode 100644 release.config.js diff --git a/.releaserc.json b/.releaserc.json deleted file mode 100644 index bf7adaa31..000000000 --- a/.releaserc.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "plugins": [ - "@semantic-release/commit-analyzer", - "@semantic-release/release-notes-generator", - [ - "@semantic-release/changelog", - { - "changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file. See\n[Conventional Commits](https://conventionalcommits.org) for commit guidelines." - } - ], - ["@semantic-release/npm", { "npmPublish": false }], - "@semantic-release/github" - ] -} diff --git a/package.json b/package.json index 7925dbb22..1be3af05c 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "storybook": "start-storybook -p 6006", "test": "NODE_ENV=test BASE_URL=/console jest", "test:clear": "jest --clearCache", - "test-coverage": "NODE_ENV=test BASE_URL=/console jest --coverage" + "test-coverage": "NODE_ENV=test BASE_URL=/console jest --coverage", + "test-release": "npx semantic-release --debug --no-ci --test-run" }, "husky": { "hooks": { @@ -57,7 +58,7 @@ "@types/react-dom": "^16.9.7", "@typescript-eslint/eslint-plugin": "^5.48.2", "@typescript-eslint/parser": "^5.48.2", - "chalk": "^2.0.1", + "chalk": "^4", "compression-webpack-plugin": "^9.2.0", "cookie-parser": "^1.4.3", "copy-webpack-plugin": "^11.0.0", @@ -135,7 +136,8 @@ "@babel/preset-react": "~7.16.7", "@babel/preset-typescript": "~7.16.7", "minimist": "1.2.6", - "@types/react": "16.14.34" + "@types/react": "16.14.34", + "npm/chalk": "^4" }, "packageManager": "yarn@3.2.1" } diff --git a/release.config.js b/release.config.js new file mode 100644 index 000000000..2fb3b438d --- /dev/null +++ b/release.config.js @@ -0,0 +1,68 @@ +const { execSync } = require('child_process'); + +/** + * + * @returns Production release configuration + */ +function getProdConfiguration() { + return { + plugins: [ + '@semantic-release/commit-analyzer', + '@semantic-release/release-notes-generator', + [ + '@semantic-release/changelog', + { + changelogTitle: + '# Changelog\n\nAll notable changes to this project will be documented in this file. See\n[Conventional Commits](https://conventionalcommits.org) for commit guidelines.', + }, + ], + ['@semantic-release/npm', { npmPublish: false }], + '@semantic-release/github', + ], + }; +} + +/** + * + * ################################################################ + * ################################################################ + * ################ FOR TESTING ########################## + * ################################################################ + * ################################################################ + */ +function isTestRun() { + return ( + process.argv.includes('--dry-run') || process.argv.includes('--test-run') + ); +} + +function getTestConfiguration() { + const localGitRepoPath = `file://${process.cwd()}/.git`; + const localBranchName = execSync('git branch --show-current') + .toString() + .trim(); + + return { + repositoryUrl: localGitRepoPath, + branches: localBranchName, + plugins: [ + '@semantic-release/commit-analyzer', + '@semantic-release/release-notes-generator', + [ + '@semantic-release/changelog', + { + changelogTitle: + '# Changelog\n\nAll notable changes to this project will be documented in this file. See\n[Conventional Commits](https://conventionalcommits.org) for commit guidelines.', + }, + ], + ['@semantic-release/npm', { npmPublish: false }], + // ["@semantic-release/github", { + // "verifyConditions": false, + // "publish": false, + // 'addReleases': false + // }], + ], + }; +} + +module.exports = isTestRun() ? getTestConfiguration() : getProdConfiguration(); diff --git a/yarn.lock b/yarn.lock index 2790aa96b..2b05d24cf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7979,14 +7979,7 @@ __metadata: languageName: node linkType: hard -"chalk@npm:*": - version: 5.2.0 - resolution: "chalk@npm:5.2.0" - checksum: 03d8060277de6cf2fd567dc25fcf770593eb5bb85f460ce443e49255a30ff1242edd0c90a06a03803b0466ff0687a939b41db1757bec987113e83de89a003caa - languageName: node - linkType: hard - -"chalk@npm:^2.0.0, chalk@npm:^2.0.1, chalk@npm:^2.4.1": +"chalk@npm:^2.0.0, chalk@npm:^2.4.1": version: 2.4.2 resolution: "chalk@npm:2.4.2" dependencies: @@ -8007,7 +8000,7 @@ __metadata: languageName: node linkType: hard -"chalk@npm:^4.0.0, chalk@npm:^4.1.0, chalk@npm:^4.1.2": +"chalk@npm:^4, chalk@npm:^4.0.0, chalk@npm:^4.1.0, chalk@npm:^4.1.2": version: 4.1.2 resolution: "chalk@npm:4.1.2" dependencies: @@ -11545,7 +11538,7 @@ __metadata: "@typescript-eslint/eslint-plugin": ^5.48.2 "@typescript-eslint/parser": ^5.48.2 babel-loader: ^8.2.5 - chalk: ^2.0.1 + chalk: ^4 compression-webpack-plugin: ^9.2.0 cookie-parser: ^1.4.3 copy-webpack-plugin: ^11.0.0