vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.8k stars 1.03k forks source link

Admin version is always latest #1331

Open zgaduj opened 2 years ago

zgaduj commented 2 years ago

Describe the bug When new version of Vendure was released and my CI/CD creating new image I see every time newest version. My package.json have versions:

    "@vendure/admin-ui-plugin": "1.4.2",
    "@vendure/asset-server-plugin": "1.4.2",
    "@vendure/core": "1.4.2",
    "@vendure/email-plugin": "1.4.2",
    "@vendure/ui-devkit": "1.4.2",

And yarn.lock:

"@vendure/admin-ui-plugin@1.4.2":
  version "1.4.2"
  resolved "https://registry.yarnpkg.com/@vendure/admin-ui-plugin/-/admin-ui-plugin-1.4.2.tgz#a1633d050c6b95c4a55fde394a45b6bb6156914b"
  integrity sha512-....==
  dependencies:
    fs-extra "^10.0.0"

So why in Admin UI I have 1.4.3? Somebody can explain this?

Now in Production is mismatch versions.. Very good when I have e.g. 1.3.4 version and admin 1.4.3 :D Everywhere Errors like a fireworks

michaelbromley commented 2 years ago

Hi,

This is very strange, and I have no explanation for it. The npm packages are immutable, so there is no way a new release could have altered the contents of v1.4.2.

If you can, try running yarn why @vendure/admin-ui-plugin and see if there are somehow multiple versions being installed.

zgaduj commented 2 years ago

After deleted node_modules, yarn.lock, admin-ui folder and yarn install:

root@2c4e8fdffbcd:/home/node/app# yarn why @vendure/admin-ui-plugin
yarn why v1.22.17
[1/4] Why do we have the module "@vendure/admin-ui-plugin"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@vendure/admin-ui-plugin@1.3.4"
info Has been hoisted to "@vendure/admin-ui-plugin"
info This module exists because it's specified in "dependencies".
info Disk size without dependencies: "32.11MB"
info Disk size with unique dependencies: "32.41MB"
info Disk size with transitive dependencies: "32.53MB"
info Number of shared dependencies: 4
Done in 0.77s.
michaelbromley commented 2 years ago

Am I understanding this correctly:

zgaduj commented 2 years ago

For testing In my package.json is 1.3.4 but this is not important. Admin always have latest version after building docker image.

I found solution. Function compileUiExtensions from @vendure/ui-devkit/compiler taking @vendure/admin-ui from https://github.com/vendure-ecommerce/vendure/blob/4a11666463ae36109e741d64efff08c2cf7bb666/packages/ui-devkit/src/compiler/scaffold.ts#L186 In my package.json not exists @vendure/admin-ui in dependencies but in package.json of @vendure/ui-devkit exists with "@vendure/admin-ui": "^1.3.4", So dash installing version to <2.0.0 ? That's why I have this version 1.4.3. I think you shouldn't use ^ in internal dependencies of project.

michaelbromley commented 2 years ago

Ah I see. Yes that makes sense, thanks for your investigation.

michaelbromley commented 2 years ago

Related: https://github.com/lerna/lerna/issues/2040

Lerna (which we use for managing versions of all monorepo packages) will automatically set the semver range for internal dependencies to be ^, so even if I manually change them to ~, the next time I use lerna to update versions (as in publishing a new release), they will all get reset to use ^ again.

So this is a bit tricky to solve. I'm thinking it might make sense to eventually move over to something like Nx, as Lerna does not seem to be actively maintained anymore.