dlr-eoc / ukis-frontend-libraries

A collection of angular ui-components, services, interfaces... to help you create geospatial mapping applications for the web.
Apache License 2.0
17 stars 4 forks source link

Use NPM >7 and workspaces #55

Closed boeckMt closed 1 year ago

boeckMt commented 3 years ago

Description

To better handle dependencies management try to use NPM 7 workspaces with the monorepo.

// package.json
workspaces": [
    "projects/*",
    "scripts/*"
  ],
...

Dependencies management right now (NPM)

Dependencies related to the Build process

Only use npm workspaces is not enough to build all the projects. Projects can also depend on other projects.

  1. To create a build currently we get the list of all projects from angular.json
  2. Then we get its dependencies (with scope @dlr-eoc) from the package.json (by using project.root from angular.json)
  3. To check that all the projects which depend on other projects are listed correctly we use depcheck
  4. Then we build a 'dependencies graph'
  5. To get a legal build execution order we use toposort
  6. To build the projects then we build each project in this order by ng build <project> --prod=true --watch=false
boeckMt commented 3 years ago

For this we also have to update the github actions to use node 15.x https://github.com/actions/setup-node/issues/213#issuecomment-739685886

// https://github.com/actions/setup-node
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
  with:
    node-version: '15'
boeckMt commented 3 years ago
boeckMt commented 3 years ago

Use Npm Workspaces

Install package in a workspace

create a new package and add it to the workspace

boeckMt commented 2 years ago

Npm install for the whole workspace

Currently this fails due to the version paceholders we have set

Could not resolve dependency:
npm WARN peer @angular/common@"0.0.0-PLACEHOLDER-VENDOR" from @dlr-eoc/services-layers@0.0.0-PLACEHOLDER
...
npm WARN Could not resolve dependency:
npm WARN peer @angular/core@"0.0.0-PLACEHOLDER-VENDOR" from @dlr-eoc/services-layers@0.0.0-PLACEHOLDER
...
npm WARN Could not resolve dependency:
npm WARN peer rxjs@"0.0.0-PLACEHOLDER-VENDOR" from @dlr-eoc/services-layers@0.0.0-PLACEHOLDER
...

we could try to use the script setVersionsforDependencies and restore it after the install somehow.


possibly related: https://github.com/npm/rfcs/issues/301