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
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9dc208b
create yarn.lock using yarn import
Feb 10, 2021
485864f
update enforceVersions to use yarn
Feb 10, 2021
d08739f
update package.json to use yarn commands
Feb 10, 2021
0cb864b
update github actions to use yarn
Feb 10, 2021
2d3af33
update Talos to use yarn
Feb 10, 2021
5a85f13
update yeoman to use yarn
Feb 10, 2021
91bebbd
update docs to use yarn
Feb 10, 2021
ac129af
yarn import to generate yarn.lock and rm package-lock.json
Feb 10, 2021
d453b96
update lerna config
Feb 10, 2021
5d4267f
prevent npm installs. add doc on installing and using yarn
Feb 10, 2021
a70d37a
update shell scripts to use yarn
Feb 10, 2021
a2d88d1
update talos to use yarn
Feb 10, 2021
2494599
update readme.md
Feb 10, 2021
33c5e21
replace .npmrc with .yarnrc
Feb 10, 2021
089422c
use correct yarn flag --no-lockfile in lerna.json
Feb 10, 2021
a0105b5
fix preinstall script
Feb 11, 2021
f69057d
ignore console.log warning
Feb 11, 2021
a335bd9
remove `run` from yarn commands
Feb 12, 2021
3382082
fix package bumping script
Feb 12, 2021
f5b223d
Merge branch 'latest' into migrate-to-yarn
Feb 12, 2021
7b09314
Merge branch 'latest' into migrate-to-yarn
Feb 12, 2021
1db5299
Bump package versions
Feb 12, 2021
1764d24
Update changelogs
Feb 12, 2021
aeb8c63
use yarn in storybook preview action
Feb 12, 2021
01ce099
add yarn ci script to remove invalid transitive dependencies before n…
Feb 18, 2021
b89a06b
merge latest
Feb 18, 2021
4219f11
Merge branch 'latest' into migrate-to-yarn
Feb 18, 2021
31d0e9a
fix ci:packages script which uses lerne exec
Feb 18, 2021
43f54bd
fix ci:packages not installing packages
Feb 19, 2021
39f2e0f
fix bumpPackages unit test
Feb 19, 2021
94ca300
install all packages in storybook-preview GH action
Feb 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/psammead-change-scanner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 👍


- name: Change Scanner
run: npm run changeScanner
run: yarn run changeScanner
2 changes: 1 addition & 1 deletion .github/workflows/psammead-chromaticqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Install Node Modules
run: npm run ci:packages
run: yarn run ci:packages

- name: Chromatic UI Tests
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == 'bbc/psammead' }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/psammead-deploy-storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:

- name: Install Node Modules and Build
run: |
npm run ci:packages
npm run build:storybook
yarn run ci:packages
yarn run build:storybook
git config --global user.name "simorgh-bbc"
git config --global user.email "[email protected]"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/psammead-manual-talos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
node-version: ${{ matrix.node-version }}

- name: Install Node Modules
run: npm install
run: yarn install

- name: Run Talos
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/psammead-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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


- name: Publish to NPM
run: npm run publish
run: yarn run publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/psammead-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Install Node Modules
run: |
echo ${GITHUB_REF##*/}
npm run ci:packages
yarn run ci:packages

- name: Setup Code Climate Test Coverage
# Only run if the workflow started from bbc/psammead i.e. not a fork.
Expand All @@ -53,7 +53,7 @@ jobs:
./cc-test-reporter before-build

- name: Unit Tests
run: npm run test:ci
run: yarn run test:ci

- name: Report Code Climate Test Coverage
# Only run if the workflow started from bbc/psammead i.e. not a fork.
Expand Down
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=1.22.10
2 changes: 1 addition & 1 deletion .yeoman/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ We are expecting the Psammead component library to expand in size. To ensure a u

## How to use it?

Run `npm run create:package`.
Run `yarn run create:package`.

CLI will prompt user to enter their desired pacakge name, description of package and author details.

Expand Down
2 changes: 1 addition & 1 deletion .yeoman/src/fs-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const shell = require('shelljs');

exports.install = () =>
new Promise((resolve, reject) => {
const response = shell.exec('npm install --quiet');
const response = shell.exec('yarn install --silent');
if (response.code === 0) {
resolve(response.output);
} else {
Expand Down
4 changes: 2 additions & 2 deletions .yeoman/src/fs-actions/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ jest.mock('shelljs', () => ({
}));

describe('File system actions', () => {
it('should successfully npm install', () => {
it('should successfully yarn install', () => {
shell.exec.mockReturnValue({ code: 0, output: 'success' });

expect(fsActions.install()).toEqual(Promise.resolve('success'));
});

it('should unsuccessfully npm install', () => {
it('should unsuccessfully yarn install', () => {
shell.exec.mockReturnValue({ code: 99, output: 'error' });

expect(fsActions.install()).toEqual(Promise.reject('error'));
Expand Down
15 changes: 9 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Contributing

## Documentation index

Please familiarise yourself with our:

- [Code of conduct](https://github.com/bbc/psammead/blob/latest/CODE_OF_CONDUCT.md)
- [Code Standards and Ways of Working](https://github.com/bbc/psammead/blob/latest/Code-Standards-and-Ways-of-Working.md)
- [Contributing guidelines](https://github.com/bbc/psammead/blob/latest/CONTRIBUTING.md) (you are here)
Expand All @@ -21,14 +23,12 @@ We appreciate all forms of contribution - not just code. Contribution can includ

Psammead's "Definition of Done" is not only when a package is published but when all the Psammead packages that consume that package are updated. We use [Talos (package bumping bot)](https://github.com/bbc/psammead/blob/latest/scripts/talos/README.md) to automate much of this bumping process.


Fundamentally, Psammead components are intended to be:

Presentational (most of them, we do have other kinds of packages)
GEL-Compliant
Accessible


### What does that mean?

#### Presentational
Expand All @@ -50,17 +50,19 @@ Finally, Psammead components are built and tested against the [BBC News assistiv
## Developing with Psammead

### Create a new package

It is autogenerated via:

```
npm run create:package
yarn run create:package
```

### Edit existing packages

1. Find a Psammead component you wish you to work on, in your project from the [directory of available packages](https://github.com/bbc/psammead/tree/latest/packages), or by running `npx lerna list` inside the repo.
2. To install the package in your local development, run:
```
npm install @bbc/psammead-<component_name>
yarn add @bbc/psammead-<component_name>
```
3. See the README for the respective the Psammead component, to see the required props, usage example and use-cases for it.

Expand All @@ -71,11 +73,13 @@ When making changes to a package locally if you want to pull those changes into
Run the following command to link all psammead packages up regardless of dependency version:

```
npm run install:packages --force-local
yarn run install:packages --force-local
```

## The package publish, deprecation, and alpha publication process

<!-- TODO: Add this, also consider where to mention npm linking, either here or in the packages README -->

### Alpha Components

#### Description
Expand Down Expand Up @@ -104,4 +108,3 @@ The accepted uses of an Alpha Component are:
- The alpha component **CAN NOT** be used in a live/production page.
- Any P1 bugs that come out of the a11y swarm need to be fixed before the component comes out of Alpha and goes live, P2 and lower can be fixed after.
- For functional issues the functionality must work on the biggest browsers on the services it's released on. This can be worked out by looking at a combination of our [browser support](https://github.com/bbc/psammead#bar_chart-support-levels) and browser usage statistics for different services.

4 changes: 2 additions & 2 deletions Code-Standards-and-Ways-of-Working.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ Storybook publishes components in an iframe within the Storybook UI, this will b

If you have a PR that is not yet merged and you need to preview this on another device, you can do so in Storybook via tunnelling:

- Install packages ‘npm run install:packages’
- Run storybook ‘npm run storybook’
- Install packages ‘yarn run install:packages’
- Run storybook ‘yarn run storybook’
- Run your tunnelling tool on the Storybook port
- In Storybook [open the component in another tab](#open-the-component-in-a-tab)

Expand Down
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,44 +42,52 @@ NB there is further documentation colocated with relevant packages and code. The
git clone [email protected]:bbc/psammead.git
```

#### Install Yarn

The Psammead project uses Yarn for package management. It is recommended to install Yarn through the npm package manager, which comes bundled with Node.js when you install it on your system. To install Yarn, run this command:

```
npm install --global yarn
```

### :hammer: Setup Local Environment

```
cd psammead && npm run install:packages
cd psammead && yarn run install:packages
```

N.B. When merging branches, the `npm run install:packages` command should be favoured over `npm install`. [More details available here](https://github.com/bbc/psammead/pull/264).
N.B. When merging branches, the `yarn run install:packages` command should be favoured over `yarn install`. [More details available here](https://github.com/bbc/psammead/pull/264).

### :runner: Run tests

Install dependencies locked to `package-lock.json`:
Install dependencies locked to `yarn.lock`:

```
npm run ci:packages
yarn run ci:packages
```

(NB: You can't reliably run the jest tests when the packages are linked locally, as they may have been linked across breaking changes. Running `npm run ci:packages` resets all links. To update snapshots within unit tests, run `npm run test:unit -- -u`.)
(NB: You can't reliably run the jest tests when the packages are linked locally, as they may have been linked across breaking changes. Running `yarn run ci:packages` resets all links. To update snapshots within unit tests, run `yarn run test:unit -- -u`.)

Run the component tests:

```
npm test
yarn test
```

This runs Jest across any packages matching this glob pattern: `packages/components/**/*.test.jsx`. It also runs each package's `npm test` command if it is defined
This runs Jest across any packages matching this glob pattern: `packages/components/**/*.test.jsx`. It also runs each package's `yarn test` command if it is defined

### :runner: Run Storybook

```
npm run storybook
yarn run storybook
```

NB, we've defined global styles (normalize, box-sizing, Reith font) in the [Storybook config](https://github.com/bbc/psammead/blob/latest/.storybook/config.js) so that components render as expected.

### :construction_worker: Build Packages/Components

```
npm run build
yarn run build
```

### :computer: Developing with Psammead
Expand Down Expand Up @@ -158,7 +166,7 @@ The access value is [restricted by NPM](https://docs.npmjs.com/misc/config#acces
The Psammead Storybook is hosted on GitHub pages at http://bbc.github.io/psammead. It is currently deployed via a local script that builds Storybook to the `gh-pages` git branch which is used by GitHub pages.

```
npm run deploy-storybook
yarn run deploy-storybook
```

NB, this automatically pushes to the 'gh-pages' branch, which deploys to the live GitHub pages site. Please only run this script on the `latest` branch.
Expand Down
7 changes: 3 additions & 4 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"npmClient": "yarn",
"command": {
"bootstrap": {
"npmClientArgs": ["--no-package-lock"]
"npmClientArgs": ["--no-lockfile"]
}
},
"packages": [
"packages/*/*"
],
"packages": ["packages/*/*"],
"version": "independent"
}
Loading