Skip to content

Commit

Permalink
Switch from yarn to npm (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
connor-baer authored Apr 3, 2023
1 parent ab4592b commit e01e70c
Show file tree
Hide file tree
Showing 8 changed files with 10,867 additions and 6,225 deletions.
32 changes: 15 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,38 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
cache: 'npm'

- name: Install dependencies
run: yarn --pure-lockfile --prefer-offline
run: npm ci

- name: Security audit
run: yarn check:security
run: npm run check:security

- name: Check licenses
run: yarn check:licenses
run: npm run check:licenses

- name: Lint
run: yarn lint
run: npm run lint

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

- name: Upload code coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Create release PR or publish to npm
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/canary') && matrix.node == 18
uses: changesets/action@master
with:
publish: yarn release
publish: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/gallium
lts/hydrogen
18 changes: 9 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If you feel another member of the community violated our CoC or you are experien

### Submitting a PR

_Before you get started, make sure you have [Node](https://nodejs.org/en/) v16+ and the [Yarn CLI](https://yarnpkg.com/en/docs/install) installed on your computer._
_Before you get started, make sure you have [Node](https://nodejs.org/en/) v18+ installed on your computer._

1. Find an existing issue to work on or follow `Submitting an issue` to create one that you're also going to fix. Make sure to notify that you're working on a fix for the issue you picked.
2. Branch out from latest `main`.
Expand All @@ -33,12 +33,12 @@ _Before you get started, make sure you have [Node](https://nodejs.org/en/) v16+

For development and local testing we recommend the following.

1. Run `yarn dev`. This will clean the `dist` folder and copy over all relevant files.
2. Run `yarn` inside the `dist` folder. This will ensure all dependencies are present in the dist folder when linking.
3. Inside the `dist` folder run `yarn link`. This will make the compiled version of Foundry available for linking in projects you want to test your changes in, for example changes to the ESLint config.
4. Inside the project you want to test your local changes to Foundry, run `yarn link @sumup/foundry`.
1. Run `npm run dev`. This will clean the `dist` folder and copy over all relevant files.
2. Run `npm install` inside the `dist` folder. This will ensure all dependencies are present in the dist folder when linking.
3. Inside the `dist` folder run `npm link`. This will make the compiled version of Foundry available for linking in projects you want to test your changes in, for example changes to the ESLint config.
4. Inside the project you want to test your local changes to Foundry, run `npm link @sumup/foundry`.

Refer to the [Yarn docs](https://classic.yarnpkg.com/en/docs/cli/link#search) to learn more about linking local dependencies.
Refer to the [npm docs](https://docs.npmjs.com/cli/v9/commands/npm-link) to learn more about linking local dependencies.

## Release process

Expand All @@ -59,13 +59,13 @@ Refer to the [official documentation](https://github.com/atlassian/changesets/bl
We have a couple of special branches that are used for stable releases and [pre-releases](#pre-releases).

- **`main`** - The code in the `main` branch is stable and production-tested. When a PR is merged to `main` that contains a new changeset, `changesets` opens a PR and keeps it up to date with the latest changes. When the PR is merged, a new version is automatically published to NPM and the changesets since the last release are added to `CHANGELOG.md` files in GitHub.
- **`canary`** - This is a branch you can use to publish a prerelease version if you need to deploy the changes somewhere to test them. `canary` is a throw-away branch that can be recreated from `main` at any time. **Hint**: If you only need to test your changes locally, you can use `yarn add ./path-to-foundry` to link the development version.
- **`canary`** - This is a branch you can use to publish a prerelease version if you need to deploy the changes somewhere to test them. `canary` is a throw-away branch that can be recreated from `main` at any time. **Hint**: If you only need to test your changes locally, you can use `npm install ./path-to-foundry` to link the development version.
- **`next`** — This branch is used to develop the next major version in parallel. It is the only branch that can contain breaking changes.

To install the most recent version from a release channel in your project, run:

```sh
yarn add @sumup/foundry@<release-channel>
npm install --dev @sumup/foundry@<release-channel>
```

#### Pre-releases
Expand All @@ -76,7 +76,7 @@ To publish a pre-release version, check out on the branch for your release chann

```sh
git checkout next # or `canary`
yarn changeset pre enter next # or `canary`
npm run changeset pre enter next # or `canary`
```

This will generate a `pre.json` file in the `.changeset` directory.
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@ A toolkit that makes it a breeze to set up and maintain JavaScript + TypeScript

### Installation

Foundry needs to be installed as a dev-dependency via the [Yarn](https://yarnpkg.com) or [npm](https://www.npmjs.com) package managers. The npm CLI ships with [Node](https://nodejs.org/en/). You can read how to install the Yarn CLI in [their documentation](https://yarnpkg.com/en/docs/install). Foundry requires Node `^14.17 || >=16`.
Foundry needs to be installed as a dev-dependency via the [npm](https://www.npmjs.com) or [Yarn](https://classic.yarnpkg.com) package managers. The npm CLI ships with [Node](https://nodejs.org/en/). You can read how to install the Yarn CLI in [their documentation](https://classic.yarnpkg.com/en/docs/install). Foundry requires Node `^14.17 || >=16`.

Depending on your preference, run one of the following.

```sh
# With Yarn
$ yarn add --dev @sumup/foundry

# With npm
$ npm install --save-dev @sumup/foundry

# With Yarn v1
$ yarn add --dev @sumup/foundry
```

### Initialization

Foundry exposes customizable configuration presets for the CLI tools it supports. To make use of these presets, you need to initialize a configuration file for each tool you would like to use. This is done with the `init` command.

```sh
# With Yarn
$ yarn run foundry init

# With npm
$ npx foundry init

# With Yarn v1
$ yarn run foundry init
```

Foundry will launch an interactive prompt to ask you questions about your project, such as whether you are planning to open source it. Once you have answered all questions, Foundry will write the config files (don't worry, it asks before overwriting existing files) and will add scripts to your `package.json` file to conveniently run the tools.
Expand Down Expand Up @@ -126,11 +126,11 @@ The preset includes the following tools:
Foundry manages all supported tools for you and exposes them via the `run` command. As an example, to run ESLint through Foundry, execute:

```sh
# With Yarn
$ yarn foundry run eslint src

# With npm
$ npx foundry run eslint src

# With Yarn v1
$ yarn foundry run eslint src
```

Here, `src` is the folder you want ESLint to check. Note that you can use any of the command-line flags and arguments supported by ESLint and other tools. Foundry forwards them so they get handled by the tool. For example, to have ESLint fix your linting errors, run `npx foundry run eslint --fix src`.
Expand Down
Loading

0 comments on commit e01e70c

Please sign in to comment.