Skip to content

scaleway-lib is a set of NPM packages used at Scaleway

License

Notifications You must be signed in to change notification settings

philibea/scaleway-lib

 
 

Repository files navigation

scaleway

Codecov GitHub closed issues dependencies GitHub release (latest by date)

scaleway-lib

scaleway-lib is a set of NPM packages used at Scaleway.



Available packages

Available packages

Development

Locally

$ git clone [email protected]:scaleway/scaleway-lib.git
$ cd scaleway-lib
$ yarn
$ # ... do your changes ...
$ yarn run lint
$ yarn run test

Link against another project (with yalc) => FAVORED

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.

$ 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 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)

$ 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

Linting

$ yarn run lint
$ yarn run lint:fix

Unit Test

$ 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

Lerna

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 or yarn.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

Notes

On build targets

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

On build outputs

We only output ESM modules.

On commits

We enforce the conventionnal commits convention in order to infer package bump versions and generate changelog.

On git hooks

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

On versioning

We follow the semver semantic.

Contributing Guidelines

  • 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.

About

scaleway-lib is a set of NPM packages used at Scaleway

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 92.9%
  • JavaScript 5.0%
  • Other 2.1%