scaleway-lib is a set of NPM packages used at Scaleway.
-
@scaleway/countries
: ISO 3166/3166-2 coutries JSON database. -
@scaleway/eslint-config-react
: A shared eslint react opiniated configuration. Available in Javascript and Typescript. -
@scaleway/random-name
: A tiny utility to generate random names. -
@scaleway/use-dataloader
: A tiny react hook to to handle api requests. -
@scaleway/use-query-params
: A tiny react hook to read and update URLs query parameters. -
@scaleway/use-i18n
: A tiny hook to handle i18n. -
@scaleway/regex
: usefull regex named. -
@scaleway/jest-helpers
: utilities jest functions.
$ git clone [email protected]:scaleway/scaleway-lib.git
$ cd scaleway-lib
$ yarn
$ # ... do your changes ...
$ yarn run lint
$ yarn run test
yalc
is a tool aiming to simplify working with local npm packages by providing a different workflow thannpm/yarn link
, hence avoiding most of their issues with module resolving.
$ yarn global add yalc # Make sure to have the yalc binary
$ cd scaleway-lib/packages/example_package
$ yarn build && yalc publish
$ # Now it's ready to install in your project
$ cd ../../../project-something
$ yalc add @scaleway/package-name --yarn
$ 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
⚠️ since 1.0.0.pre.51 (2021-04-23),yalc publish
needs the--sig
option to trigger webpack module actual update.
⚠️ yalc
create ayalc.lock
and updates thepackage.json
in the target project. Make sure to not commit these changes
$ cd packages/example_package && yarn link
$ cd - && yarn run build # rebuild the package
$ # Now it's ready to link into your project
$ cd ../project-something
$ yarn link @scaleway/example_package
$ yarn run lint
$ yarn run lint:fix
$ 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
This project is managed with Lerna. Lerna is a tool to manage multiple NPM packages inside the same repository.
Lerna also allows us to use Yarn workspaces to manage our dependencies. This implies a few things:
- devDependencies should be included in top package.json
- There should be no
node_modules
oryarn.lock
in sub-packages - There is a special syntax to manage sub-packages dependencies:
$ 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
We target by default Node@14 but you can add a browser output by adding a browser
(you can find the spec here) target to your package.json
.
"browser": {
"dist/module.js": "dist/module.browser.js"
}
The browserlist we are currently using is available in the rollup.config.mjs
⚠️ Bear in mind that we do not currently support different entrypoint per target as we don't have the use case
We only output ESM modules.
We enforce the conventionnal commits convention in order to infer package bump versions and generate changelog.
We have a husky hook on pre-commit
and pre-push
which will ensure the file you committed matches the configured formating (eslint
+ prettier
)
We also have one on commit-msg
which will ensure you commit message respects our commit convention
We strongly encourage you not to but you can skip these hooks by passing --no-verify
to your git
commands
We follow the semver semantic.
- Ensure tests are still ok and code coverage have not decreased
- Follow linter rules (tldr).
- CI is enforced, you won't be able to merge unless pipeline is successful.