apache / incubator-kie-issues

Apache License 2.0
12 stars 1 forks source link

Standardize scripts/tasks names and execution order on KIE Tools packages #866

Open thiagoelg opened 9 months ago

thiagoelg commented 9 months ago

This task aims to define the scripts' names and functionalities. For example:

It's also expected to have an execution order defined. For example:

  1. Install dependencies;
  2. Build;
  3. Test;
  4. and so on...

This is important so that our monorepo is more readable and manageable and makes it easier for future improvements, such as build and test caches.

tiagobento commented 5 months ago

Phase 1: Prepare (Implementing conventions)

Scripts will be conventionalized, but build:dev and build:prod will still invoke other scripts.

Phase 2: Turbo (independent scripts)

By using turbo, we'll be able to make all scripts independent. Their relationship will be defined at the top-level turbo.json. build:dev and build:prod won't invoke other scripts anymore.

Phase 3: Wrap-up (Cleanup)

All non-conventionalized scripts will be renamed to ~:[previous-name]. This will group them together at the end and make all package.json files similar. Reducing the cognitive load to understand package.json --> scripts that have a lot of tasks inside.

E.g.:

{
  ...
  "scripts": {
    "build:dev": "pnpm ~:copy:css && tsc -p tsconfig.json",
    "build:prod": "pnpm ~:copy:css && tsc -p tsconfig.json",
    "clean": "rimraf 'dist*'",
    "lint": "kie-tools--eslint ./src",
    "start": "cross-env STORYBOOK_PORT=$(build-env dmnEditor.storybook.port) pnpm storybook-base --storybookArgs=\"dev --no-open\"",
    "test": "run-script-if --true --ignore-errors \"$(build-env tests.ignoreFailures)\" --then \"jest --silent --verbose --passWithNoTests\"",
    "test-e2e": "run-script-if --true --ignore-errors \"$(build-env endToEndTests.ignoreFailures)\" --then \"pnpm exec playwright test\"",
    "~:build:storybook": "storybook build -o dist-storybook",
    "~:copy:css": "copyfiles -u 1 \"src/**/*.{sass,scss,css}\" dist/",
    "~:test-e2e:open": "pnpm exec playwright show-report dist-tests-e2e/reports"
  },
  ...
}
tiagobento commented 4 months ago

After some research, I think we should postpone Phase 2: Turbo for a while. It's a big shift and I think we need more time for everyone to be comfortable with the current setup before we introduce a change this disruptive to the usage of kie-tools.