Skip to content
This repository has been archived by the owner on Aug 13, 2023. It is now read-only.

Migrate to yarn #4335

Merged
merged 31 commits into from
Feb 19, 2021
Merged

Migrate to yarn #4335

merged 31 commits into from
Feb 19, 2021

Conversation

jroebu14
Copy link
Contributor

@jroebu14 jroebu14 commented Feb 10, 2021

Resolves #4331

Overall change:
Replaces npm with yarn for package management.

Code changes:

NPM to Yarn command translations:

  • npm install -> yarn install install packages
  • npm ci -> yarn install --frozen-lockfile for deterministic builds based on lockfile
  • npm install --quiet -> yarn install --silent installs without console noise
  • npm update -> yarn upgrade upgrades all packages
  • npm install some-package -> yarn add some-package installs some-package
  • npm install --no-package-lock -> yarn install --no-lockfile do no generate a lock file on installing

  • I have assigned myself to this PR and the corresponding issues
  • Automated jest tests added (for new features) or updated (for existing features)
  • This PR requires manual testing

@jroebu14 jroebu14 added the cross-team For visibility for both World Service teams (Engage & Media) label Feb 10, 2021
@jroebu14 jroebu14 self-assigned this Feb 10, 2021
Copy link
Contributor

@andrewscfc andrewscfc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, few thoughts:

  • Did you you use [yarn import(https://classic.yarnpkg.com/en/docs/cli/import/) for the top level package lock? We needed to do this for Simorgh on the call the other day, it may well be necessary for psammead too? I guess the others were regenerated by the existing tooling.
  • It seems you've wisely chosen to not remove lerna in this PR, I guess we may have a follow-up PR to either
    • Remove lerna and replicate it's functionality using yarn's built in features
    • Or investigate our existing issues with lerna and try and get local package linking working for example. A new version of lerna has appeared which gives us a bit more confidence in sticking with lerna: Lerna is largely unmaintained lerna/lerna#2703 (comment)

const ensureYarn = () => {
// If npm is being run, print a message and cause 'npm install' to fail.
if (!process.env.npm_execpath.includes('yarn')) {
console.log(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a lint ignore here to suppress this warning?

tput setaf 1
echo "\nOh no! You're not using our version of npm, please move to version $desired_npm_version in order to reduce bundling inconsistency"
echo "\nOh no! You're not using our version of yarn, please move to version $desired_yarn_version in order to reduce bundling inconsistency"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you do this on the Simorgh branch, I don't remember seeing it, the same script is in that repo too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep this was in the original Simorgh PR

@jroebu14
Copy link
Contributor Author

@andrewscfc yeh I used yarn import && rm package-lock.json in the top level and then lerna exec -- yarn import && rm package-lock.json to do the same in every package.

Yeh this PR is just to use Yarn for installing dependencies and switching to Yarn commands. Anything else will be separate PRs.

@@ -22,10 +22,10 @@ jobs:
scope: '@bbc'

- name: Install Node Modules
run: npm run ci:packages
run: yarn run ci:packages
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's small and doesn't make much different but I think with yarn you can also remove the run command so just yarn ci:packages should work.

Not crucial to this work though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed run from all yarn commands in this commit

@@ -17,7 +17,7 @@ jobs:
persist-credentials: false

- name: Install Node Modules
run: npm run ci:packages
run: yarn run ci:packages
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the SetupNode GH action comes preinstalled with yarn! Nice 👍

@jroebu14 jroebu14 marked this pull request as ready for review February 12, 2021 14:18
Jonathan Roebuck added 3 commits February 12, 2021 14:20
Bump package versions for psammead, psammead-amp-geo, psammead-brand, psammead-bulleted-list, psammead-bulletin, psammead-byline, psammead-caption, psammead-consent-banner, psammead-content-anchor, psammead-copyright, psammead-embed-error, psammead-episode-list, psammead-figure, psammead-grid, psammead-heading-index, psammead-headings, psammead-image-placeholder, psammead-image, psammead-inline-link, psammead-live-label, psammead-media-indicator, psammead-media-player, psammead-most-read, psammead-navigation, psammead-oembed, psammead-paragraph, psammead-play-button, psammead-podcast-promo, psammead-radio-schedule, psammead-script-link, psammead-section-label, psammead-sitewide-links, psammead-social-embed, psammead-story-promo-list, psammead-story-promo, psammead-timestamp, psammead-useful-links, psammead-visually-hidden-text, psammead-timestamp-container, gel-foundations, moment-timezone-include, psammead-assets, psammead-calendars, psammead-detokeniser, psammead-locales, psammead-rich-text-transforms, psammead-storybook-helpers, psammead-styles, psammead-test-helpers, web-vitals
Updates changelogs for psammead, psammead-amp-geo, psammead-brand, psammead-bulleted-list, psammead-bulletin, psammead-byline, psammead-caption, psammead-consent-banner, psammead-content-anchor, psammead-copyright, psammead-embed-error, psammead-episode-list, psammead-figure, psammead-grid, psammead-heading-index, psammead-headings, psammead-image-placeholder, psammead-image, psammead-inline-link, psammead-live-label, psammead-media-indicator, psammead-media-player, psammead-most-read, psammead-navigation, psammead-oembed, psammead-paragraph, psammead-play-button, psammead-podcast-promo, psammead-radio-schedule, psammead-script-link, psammead-section-label, psammead-sitewide-links, psammead-social-embed, psammead-story-promo-list, psammead-story-promo, psammead-timestamp, psammead-useful-links, psammead-visually-hidden-text, psammead-timestamp-container, gel-foundations, moment-timezone-include, psammead-assets, psammead-calendars, psammead-detokeniser, psammead-locales, psammead-rich-text-transforms, psammead-storybook-helpers, psammead-styles, psammead-test-helpers, web-vitals
@github-actions
Copy link

Checkout your storybook preview here http://psammead-preview.tools.bbc.co.uk/4335

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cross-team For visibility for both World Service teams (Engage & Media)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace NPM with Yarn for package management
4 participants