practicajs / practica

Node.js solution starter boilerplate that is production-ready, packed with ✅ best practices and built with simplicity in mind
https://practica.dev/
MIT License
1.45k stars 134 forks source link

Unify and enhance our libraries configuration #114

Open goldbergyoni opened 2 years ago

goldbergyoni commented 2 years ago

Concern - We have a bunch of libraries like logger, auth, and more. Currently, they hold different configuration/structure and also lack some fundamental standards, let's nail this?

The list:

goldbergyoni commented 2 years ago

@rluvaton @DanielGluskin Kindly have a look here, I'd like to brainstorm with both of you about this soon 🙏

rluvaton commented 2 years ago
  • Make 'em share Jest and TS config (how? this should be discussed)

for jest, we could have one common config file and each file require and export it (this will enable to edit config based on the specific library)

for typescript, in case it doesn't search in the parent folder and the parent of the parent folder (how does it called again?) we could use the extends option in the tsconfig file

  • Make 'em have the same set of package.json scripts (e.g., test, build, dev, etc)

Great idea!

  • Use a publishing tool like np to prevent silly mistakes

I've not used this but it looks like it's requiring user interaction, and instead, we should use an automated one.

I recommend using semantic-release.

I'm using it in some of my NPM packages and it works great, it reads your commits messages and based on that it increases the package version (commits should be in a certain format)

  • Create index file for every lib that is solely an interface to public functions/modules

Agree, this is really important IMO

  • README per package with the same format

Sound great!

  • Write very few E2E that publish the package and then consume it like a user (can detect packaging or package.json issues)

Agree, I saw that currently, we use npm link, npm link doesn't reflect real-world usage and has problems, instead, I recommend using a local registry like verdaccio which is really easy to set up and use (I've used it before)

apparently, in create-react-app they switched to it too - Twitter post by Dan Abramov

The link is broken 😢

goldbergyoni commented 2 years ago

for jest, we could have one common config

Jest has a dedicated mechanism for this - Preset

I've not used this but it looks like it's requiring user interaction, and instead, we should use an automated one.

I'm pretty sure np can be automated, although not sure if user interaction is not the better way to publish. Do you run it locally or from CI?

The link is broken

Weirdly enough, the post was removed from the web. Here is an archived version:

I've not used this but it looks like it's requiring user interaction, and instead, we should use an automated one.

rluvaton commented 2 years ago

I'm pretty sure np can be automated, although not sure if user interaction is not the better way to publish. Do you run it locally or from CI?

From CI, yeah I see np can be automated after all