From 08bbc3af3cea3875008cf043982d2a7d5b4ea27c Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Fri, 8 Jan 2021 10:54:45 -0600 Subject: [PATCH] Update to use new release process (#121) * Update to use new release process * Update app.json * Fix jest tests * Update CHANGELOG.md Co-authored-by: Manuel,Ryan Co-authored-by: Matt Henkes --- .travis.yml | 5 +- CHANGELOG.md | 3 + RELEASE.md | 2 +- app.json | 2 +- package.json | 9 ++- scripts/changelog-updater/index.js | 59 ------------------- scripts/release/release.js | 52 ---------------- .../useNotificationBanners.test.jsx.snap | 36 +++-------- 8 files changed, 19 insertions(+), 149 deletions(-) delete mode 100644 scripts/changelog-updater/index.js delete mode 100644 scripts/release/release.js diff --git a/.travis.yml b/.travis.yml index 9db1ea4e9..95f212fc2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,10 +59,7 @@ jobs: - stage: deploy script: - rm -rf ./travis-build - # add auth token to .npmrc for lerna publish - - echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> $HOME/.npmrc 2> /dev/null - # Publish to npm and push tags to github based on output written to file - - node ./scripts/release/release.js + - npx terra release before_deploy: # Build again for deployment because we need the Public path to be updated. - TERRA_DEV_SITE_NEW_RELIC_LICENSE_KEY='c494ac44c8' TERRA_DEV_SITE_NEW_RELIC_APPLICATION_ID='141260567' TERRA_DEV_SITE_PUBLIC_PATH='/terra-application/' npm run compile:prod diff --git a/CHANGELOG.md b/CHANGELOG.md index fc210320d..a7500238c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Changed + * Updated to use terra-open-source-scripts to release the project + ## 1.41.0 - (November 17, 2020) * Added diff --git a/RELEASE.md b/RELEASE.md index c75f27a94..ef9b0eeec 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -4,7 +4,7 @@ This project is hosted on NPM. You can find the terra packages [here][project-u Below is a guide for releasing packages: -1. Update the versions of the component and change log via `npm run version:` +1. Update the versions of the component and change log via `npm run prepare-for-release` 2. Create a Release PR, Get approvals 3. Merge PR to `main` 4. Watch main to ensure releases get pushed to npm and tagged in github appropriately diff --git a/app.json b/app.json index 88a220af7..ba1c2f736 100644 --- a/app.json +++ b/app.json @@ -28,7 +28,7 @@ "size": "free" } }, - "stack": "heroku-16", + "stack": "heroku-20", "addons": [], "buildpacks": [] } diff --git a/package.json b/package.json index 93c24d6ea..366f86de8 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ "lint:scss": "stylelint src/**/*.scss", "precompile": "rm -rf lib", "prepare": "npm run compile", + "prepare-for-release": "terra prepare-for-release", "start": "tt-serve", "start-prod": "tt-serve -p", "start-heroku": "tt-serve-static --port $PORT --site './build' ", @@ -92,14 +93,12 @@ "wdio-locale": "LOCALE=de wdio", "wdio-lowlight": "THEME=clinical-lowlight-theme wdio", "wdio-fusion": "THEME=orion-fusion-theme wdio", - "wdio": "npm run wdio-default && npm run wdio-locale && npm run wdio-lowlight && npm run wdio-fusion", - "version:major": "npm --no-git-tag-version version major", - "version:minor": "npm --no-git-tag-version version minor", - "version:patch": "npm --no-git-tag-version version patch", - "postversion": "node ./scripts/changelog-updater/index.js" + "wdio": "npm run wdio-default && npm run wdio-locale && npm run wdio-lowlight && npm run wdio-fusion" }, "dependencies": { + "@cerner/terra-cli": "^1.0.0", "@cerner/terra-docs": "^1.0.0", + "@cerner/terra-open-source-scripts": "^1.0.1", "classnames": "^2.2.5", "eventemitter3": "^4.0.4", "mutationobserver-shim": "0.3.3", diff --git a/scripts/changelog-updater/index.js b/scripts/changelog-updater/index.js deleted file mode 100644 index 35f38ea7c..000000000 --- a/scripts/changelog-updater/index.js +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env node -/* eslint-disable no-console */ -const fs = require('fs'); -const path = require('path'); - -const packageFile = path.resolve('package.json'); -const changelogFile = path.resolve('CHANGELOG.md'); -const releaseDate = new Date().toLocaleString('en-us', { month: 'long', year: 'numeric', day: 'numeric' }); - -if (!fs.existsSync(packageFile) || !fs.existsSync(changelogFile)) { - return; -} - -// Read package.json and pull out version -fs.readFile(packageFile, 'utf8', (err, packageJson) => { - if (err) { - console.error(`Error reading file ${packageFile} ${err}\n`); - } else { - // This is expected to be run after the packages are versioned. - const { version } = JSON.parse(packageJson); - - const regex = /## Unreleased\n*([^#]*)/; - - const changelog = fs.readFileSync(changelogFile, 'utf8'); - - // Grab any content in the unreleased section until the next heading (#). - const unreleasedContent = changelog.match(regex); - - // Default message - let releaseContent = [ - '* Changed', - ' * Minor dependency version bump', - '', - '', - ].join('\n'); - - const [, captureGroup] = unreleasedContent; - - // If there was content, don't use the default content. - if (captureGroup) { - releaseContent = captureGroup; - } - - // setup change log entry - const changelogDoc = [ - '## Unreleased', - '', - `## ${version} - (${releaseDate})`, - '', - releaseContent, - ].join('\n'); - - // Swap in change log entry - const updatedChangelog = changelog.replace(regex, changelogDoc); - - // write out file. - fs.writeFileSync(changelogFile, updatedChangelog, { encoding: 'utf8', flag: 'w' }); - } -}); diff --git a/scripts/release/release.js b/scripts/release/release.js deleted file mode 100644 index 417f9d1de..000000000 --- a/scripts/release/release.js +++ /dev/null @@ -1,52 +0,0 @@ -#! /usr/bin/env node -/* eslint-disable no-console */ -// eslint-disable-next-line import/no-extraneous-dependencies -const pacote = require('pacote'); -const { execSync } = require('child_process'); -const { exit } = require('process'); -const packageJson = require('../../package.json'); - -// If on travis setup git to be able to push the tags -const setupGit = () => { - const travis = process.env.TRAVIS; - - if (travis) { - execSync('git config --global user.email "travis@travis-ci.org"'); - execSync('git config --global user.name "Travis CI"'); - const remoteUrl = execSync('git config --get remote.origin.url', { encoding: 'utf8' }).trim(); - const token = process.env.GITHUB_TOKEN; - const newUrl = remoteUrl.replace('https://', `https://${token}@`); - execSync(`git remote set-url origin "${newUrl}" > /dev/null 2>&1`); - } -}; - -const isPublished = async () => ( - new Promise((resolve, reject) => ( - pacote.packument(packageJson.name, { - registry: 'https://registry.npmjs.org/', - }).then(pkgJson => { - const publishedVersions = Object.keys(pkgJson.versions); - resolve(publishedVersions.includes(packageJson.version)); - }).catch((err) => reject(err)) - )) -); - -const release = async () => { - if (await isPublished()) { - console.log('Nothing to publish'); - process.exit(); - } - - setupGit(); - - const tag = `v${packageJson.version}`; - - execSync('npm publish'); - execSync(`git tag -a ${tag} -m "${tag}"`); - execSync('git push origin --tags'); -}; - -release().catch(() => { - console.log('Failed to publish or tag'); - exit(1); -}); diff --git a/tests/jest/notification-banner/private/__snapshots__/useNotificationBanners.test.jsx.snap b/tests/jest/notification-banner/private/__snapshots__/useNotificationBanners.test.jsx.snap index e4e9425d7..d016aa963 100644 --- a/tests/jest/notification-banner/private/__snapshots__/useNotificationBanners.test.jsx.snap +++ b/tests/jest/notification-banner/private/__snapshots__/useNotificationBanners.test.jsx.snap @@ -62,9 +62,7 @@ exports[`useNotificationBanners Nested Notification Banner Provider registers no - - Error. - + Error. @@ -130,9 +128,7 @@ exports[`useNotificationBanners Nested Notification Banner Provider registers no - - Error. - + Error. @@ -184,9 +180,7 @@ exports[`useNotificationBanners Nested Notification Banner Provider registers no - - Error. - + Error. @@ -245,9 +239,7 @@ exports[`useNotificationBanners Nested Notification Banner Provider unregisters - - Error. - + Error. @@ -299,9 +291,7 @@ exports[`useNotificationBanners Nested Notification Banner Provider unregisters - - Error. - + Error. @@ -370,9 +360,7 @@ exports[`useNotificationBanners Nested Notification Banner Provider unregisters - - Error. - + Error. @@ -471,9 +459,7 @@ exports[`useNotificationBanners NotificationBannerProvider.registerNotificationB - - Error. - + Error. @@ -531,9 +517,7 @@ exports[`useNotificationBanners NotificationBannerProvider.unregisterNotificatio - - Error. - + Error. @@ -617,9 +601,7 @@ exports[`useNotificationBanners renders with children that has a an banner 1`] = - - Error. - + Error.