Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"reviewersSampleSize": 2,
"prHourlyLimit": 5,
"prConcurrentLimit": 10,
"postUpdateOptions": ["yarnDedupeHighest"],
"labels": ["dependencies"],
"rangeStrategy": "pin",
"semanticCommitType": "chore",
Expand Down
34 changes: 19 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,47 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3.0.0
- uses: pnpm/action-setup@v2.2.1
- name: Use Node.js
uses: actions/setup-node@v3.0.0
with:
node-version: 17
check-latest: true
cache: 'yarn'
- run: yarn
- run: yarn run build
- run: yarn run tsc --noEmit
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build
- run: pnpm tsc --noEmit
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3.0.0
- uses: pnpm/action-setup@v2.2.1
- name: Use Node.js
uses: actions/setup-node@v3.0.0
with:
node-version: 17
check-latest: true
cache: 'yarn'
- run: yarn
- run: yarn run build
- run: yarn run lint
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build
- run: pnpm run lint
test:
runs-on: ubuntu-20.04
strategy:
matrix:
node: [ '14', '16', '17' ]
steps:
- uses: actions/checkout@v3.0.0
- uses: pnpm/action-setup@v2.2.1
- name: Use Node.js
uses: actions/setup-node@v3.0.0
with:
node-version: ${{ matrix.node }}
check-latest: true
cache: 'yarn'
- run: yarn
- run: yarn run build
- run: yarn run test:coverage
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build
- run: pnpm run test:coverage
- uses: codecov/codecov-action@v2.1.0
deploy:
runs-on: ubuntu-20.04
Expand All @@ -63,17 +66,18 @@ jobs:
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- uses: pnpm/action-setup@v2.2.1
- name: Use Node.js
uses: actions/setup-node@v3.0.0
with:
node-version: 17
check-latest: true
- run: yarn --immutable --inline-builds
- run: yarn run build
- run: pnpm install
- run: pnpm run build
- run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: yarn run lerna publish -y --create-release github --ignore-scripts --no-verify-access
- run: pnpm lerna publish -y --create-release github --ignore-scripts --no-verify-access
env:
HUSKY: 0
GH_TOKEN: ${{ secrets.GH_TOKEN }}
7 changes: 4 additions & 3 deletions .github/workflows/pull_request_title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3.0.0
- uses: pnpm/action-setup@v2.2.1
- name: Use Node.js
uses: actions/setup-node@v3.0.0
with:
node-version: 17
check-latest: true
cache: 'yarn'
- run: yarn
- run: echo '${{ github.event.pull_request.title }}' | yarn run commitlint
cache: 'pnpm'
- run: pnpm install
- run: echo '${{ github.event.pull_request.title }}' | pnpm commitlint
12 changes: 3 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
# dependencies
node_modules
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

# we are using yarn here

# we are using pnpm here
package-lock.json
yarn.lock

# misc
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit $1
pnpm commitlint --edit $1

2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn run lint-staged
pnpm lint-staged
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn run lint-staged
pnpm lint-staged
785 changes: 0 additions & 785 deletions .yarn/releases/yarn-3.2.0.cjs

This file was deleted.

3 changes: 0 additions & 3 deletions .yarnrc.yml

This file was deleted.

48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ scaleway-lib is a set of NPM packages used at Scaleway.
- [Development](#development)
- [Locally](#locally)
- [Link against another project (with `yalc`) => FAVORED](#link-against-another-project-with-yalc--favored)
- [Link against another project (with `yarn link`)](#link-against-another-project-with-yarn-link)
- [Link against another project (with `pnpm link`)](#link-against-another-project-with-pnpm-link)
- [Linting](#linting)
- [Unit Test](#unit-test)
- [Lerna](#lerna)
Expand Down Expand Up @@ -98,75 +98,75 @@ scaleway-lib is a set of NPM packages used at Scaleway.
```bash
$ git clone git@github.com:scaleway/scaleway-lib.git
$ cd scaleway-lib
$ yarn
$ pnpm install
$ # ... do your changes ...
$ yarn run lint
$ yarn run test
$ pnpm run lint
$ pnpm run test
```

### Link against another project (with `yalc`) => FAVORED

> [`yalc`](https://github.com/whitecolor/yalc) is a tool aiming to simplify working with local npm packages by providing a different workflow than `npm/yarn link`, hence avoiding most of their issues with module resolving.
> [`yalc`](https://github.com/whitecolor/yalc) is a tool aiming to simplify working with local npm packages by providing a different workflow than `npm/yarn/pnpm link`, hence avoiding most of their issues with module resolving.

```bash
$ yarn global add yalc # Make sure to have the yalc binary
$ pnpm install -g yalc # Make sure to have the yalc binary
```

```bash
$ cd scaleway-lib/packages/example_package
$ yarn build && yalc publish
$ pnpm run build && yalc publish
$ # Now it's ready to install in your project
$ cd ../../../project-something
$ yalc add @scaleway/package-name --yarn
$ yalc add @scaleway/package-name
$ cd ../scaleway-lib/packages/example_package
$ # If you do some changes into your package
$ yarn build && yalc publish --push --sig # --push will automatically update the package on projects where it have been added, --sig updates the signature hash to trigger webpack update
$ pnpm run build && yalc publish --push --sig # --push will automatically update the package on projects where it have been added, --sig updates the signature hash to trigger webpack update
```

> :warning: since [1.0.0.pre.51 (2021-04-23)](https://github.com/wclr/yalc/blob/master/CHANGELOG.md#100pre51-2021-04-23), `yalc publish` needs the `--sig` option to trigger webpack module actual update.

> :warning: `yalc` create a `yalc.lock` and updates the `package.json` in the target project. **Make sure to not commit these changes**

### Link against another project (with `yarn link`)
### Link against another project (with `pnpm link`)

```bash
$ cd packages/example_package && yarn link
$ cd - && yarn run build # rebuild the package
$ cd packages/example_package && pnpm link
$ cd - && pnpm run build # rebuild the package
$ # Now it's ready to link into your project
$ cd ../project-something
$ yarn link @scaleway/example_package
$ pnpm link @scaleway/example_package
```

### Linting

```bash
$ yarn run lint
$ yarn run lint:fix
$ pnpm run lint
$ pnpm run lint:fix
```

### Unit Test

```bash
$ yarn run test # Will run all tests
$ yarn run test --updateSnapshot # Will update all snapshots
$ yarn run test:watch # Will watch tests and only rerun the one who are modified
$ yarn run test:coverage # Will generate a coverage report
$ pnpm run test # Will run all tests
$ pnpm run test -- --updateSnapshot # Will update all snapshots
$ pnpm run test:watch # Will watch tests and only rerun the one who are modified
$ pnpm run test:coverage # Will generate a coverage report
```

## Lerna

This project is managed with [Lerna](https://lerna.js.org). Lerna is a tool to manage multiple NPM packages inside the same repository.

Lerna also allows us to use [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) to manage our dependencies. This implies a few things:
Lerna also allows us to use [PNPM workspaces](https://pnpm.io/workspaces) to manage our dependencies. This implies a few things:

- devDependencies should be included in top package.json
- There should be no `node_modules` or `yarn.lock` in sub-packages
- There should be no `node_modules` or `pnpm-lock.yml` in sub-packages
- There is a special syntax to manage sub-packages dependencies:

```bash
$ yarn add -W -D new_dependency # Add a new devDependency to root project
$ yarn workspace @scaleway/package_name add new_dependency
$ yarn workspace @scaleway/package_name remove old_dependency
$ pnpm add -W -D new_dependency # Add a new devDependency to root project
$ cd packages/package_name && pnpm add new_dependency
$ cd packages/package_name && pnpm remove old_dependency
```

## Notes
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"packages": ["packages/*"],
"useWorkspaces": true,
"npmClient": "yarn",
"npmClient": "pnpm",
"version": "independent",
"command": {
"publish": {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
},
"scripts": {
"lint": "eslint --ext js,ts,tsx --cache .",
"lint:fix": "yarn run lint --fix",
"lint:fix": "pnpm run lint -- --fix",
"build": "lerna exec --stream --ignore @scaleway/eslint-config-react --ignore @scaleway/countries -- rollup -c ../../rollup.config.mjs",
"build:profile": "cross-env PROFILE=true yarn run build",
"build:profile": "cross-env PROFILE=true pnpm run build",
"commit": "npx git-cz -a",
"test": "TZ=UTC jest",
"test:watch": "yarn run test --watch",
"test:coverage": "yarn run test --coverage",
"test:watch": "pnpm run test -- --watch",
"test:coverage": "pnpm run test -- --coverage",
"prepare": "husky install"
},
"commitlint": {
Expand Down Expand Up @@ -92,5 +92,5 @@
]
]
},
"packageManager": "yarn@3.2.0"
"packageManager": "pnpm@6.16.0"
}
4 changes: 2 additions & 2 deletions packages/countries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This package only holds and publish json files
## Install

```bash
$ yarn add @scaleway/countries
$ pnpm add @scaleway/countries
```

## Usage
Expand All @@ -34,5 +34,5 @@ To update the database, first make sure that you have:
And then:

```bash
$ yarn run generate
$ pnpm run generate
```
2 changes: 1 addition & 1 deletion packages/countries/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Usage:
# $ poetry install && poetry run python generate.py
# Or simply from the package.json
# $ yarn run generate
# $ pnpm run generate

import pycountry
import json
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Available in Javascript and Typescript
## Install

```bash
$ yarn add --dev @scaleway/eslint-config-react
$ pnpm add --dev @scaleway/eslint-config-react
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-helpers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Install

```bash
$ yarn add @scaleway/jest-functions
$ pnpm add @scaleway/jest-functions
```

## How to use
Expand Down
2 changes: 1 addition & 1 deletion packages/random-name/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Fully inspired by [Moby name generator](https://github.com/moby/moby/blob/master
## Install

```bash
$ yarn add @scaleway/random-name
$ pnpm add @scaleway/random-name
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion packages/regex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A tiny utility to use named regex
## Install

```bash
$ yarn add @scaleway/regex
$ pnpm add @scaleway/regex
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion packages/use-dataloader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## Install

```bash
$ yarn add @scaleway/use-dataloader
$ pnpm add @scaleway/use-dataloader
```

## How to use
Expand Down
2 changes: 1 addition & 1 deletion packages/use-i18n/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Install

```bash
$ yarn add @scaleway/use-i18n
$ pnpm add @scaleway/use-i18n
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion packages/use-query-params/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Install

```bash
$ yarn add @scaleway/use-query-params react-router-dom
$ pnpm add @scaleway/use-query-params react-router-dom
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion packages/use-random-name/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Fully inspired by [Moby name generator](https://github.com/moby/moby/blob/master
## Install

```bash
$ yarn add @scaleway/use-random-name
$ pnpm add @scaleway/use-random-name
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion packages/use-segment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use [@segment/analytics-next](https://github.com/segmentio/analytics-next)
## Install

```bash
$ yarn add @scaleway/use-segment
$ pnpm add @scaleway/use-segment
```

## Usage
Expand Down
Loading