nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.48k stars 2.34k forks source link

Change default published version on Local Registry to avoid `EPUBLISHCONFLICT` error when 1.0.0 already exists on `NPM` #18036

Closed tinesoft closed 11 months ago

tinesoft commented 1 year ago

Current Behavior

Currently, the tools script tools/scripts/start-local-registry.ts generated by the @nx/js library, tries to publish the packages used for e2e testing, with the version 1.0.0

https://github.com/nrwl/nx/blob/38fa586b78564f1b9b69eea8b11adbdbe45f3fab/packages/js/src/utils/add-local-registry-scripts.ts#L25

which may cause the publishing to fail because this specific version can already exist on NPM registry (that is proxied by Verdaccio , see here https://github.com/nrwl/nx/blob/38fa586b78564f1b9b69eea8b11adbdbe45f3fab/packages/js/src/generators/setup-verdaccio/files/config.yml#L19)

Expected Behavior

Instead of trying to publish a 1.0.0 version by default, which is either very likely to already exist on NPM (or will at some point), One solution would be to publish under a different version. For example:

Personally, I would prefer the 0.0.0-e2e variant, the 0.0.0 part reminds of the "in development, or for testing" aspect, and the e2e would be aligned with the NPM tag name used to publish the package under.

GitHub Repo

No response

Steps to Reproduce

  1. try to run an e2e test on a package that already has a 1.0.0 version published on NPM
  2. Boom !

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 18.15.0
   OS     : linux-x64
   pnpm   : 8.1.1

   nx                 : 16.5.0
   @nx/js             : 16.5.0
   @nx/jest           : 16.5.0
   @nx/linter         : 16.5.0
   @nx/workspace      : 16.5.0
   @nx/devkit         : 16.5.0
   @nx/eslint-plugin  : 16.5.0
   @nx/node           : 16.5.0
   @nx/plugin         : 16.5.0
   @nrwl/tao          : 16.5.0
   nx-cloud           : 16.0.5
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @theunderscorer/nx-semantic-release : 2.4.0
   ---------------------------------------
   Local workspace plugins:
         @nxrocks/nx-spring-boot
         @nxrocks/nx-micronaut
         @nxrocks/nx-flutter
         @nxrocks/nx-quarkus
         @nxrocks/nx-melos
         @nxrocks/nx-ktor
         @nxrocks/common

Failure Logs

0 verbose cli /usr/local/share/nvm/versions/node/v18.15.0/bin/node /usr/local/share/nvm/versions/node/v18.15.0/bin/npm
1 info using npm@9.5.0
2 info using node@v18.15.0
3 timing npm:load:whichnode Completed in 4ms
4 timing config:load:defaults Completed in 4ms
5 timing config:load:file:/usr/local/share/nvm/versions/node/v18.15.0/lib/node_modules/npm/npmrc Completed in 0ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 3ms
8 timing config:load:env Completed in 2ms
9 timing config:load:file:/workspaces/nxrocks/dist/packages/nx-quarkus/.npmrc Completed in 17ms
10 timing config:load:project Completed in 45ms
11 timing config:load:file:/root/.npmrc Completed in 3ms
12 timing config:load:user Completed in 5ms
13 timing config:load:file:/usr/local/share/nvm/versions/node/v18.15.0/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 1ms
15 timing config:load:setEnvs Completed in 2ms
16 timing config:load Completed in 64ms
17 timing npm:load:configload Completed in 64ms
18 timing npm:load:mkdirpcache Completed in 1ms
19 timing npm:load:mkdirplogs Completed in 1ms
20 verbose title npm publish
21 verbose argv "publish" "--access" "public" "--tag" "e2e"
22 timing npm:load:setTitle Completed in 4ms
23 timing config:load:flatten Completed in 5ms
24 timing npm:load:display Completed in 15ms
25 verbose logfile logs-max:10 dir:/root/.npm/_logs/2023-07-09T06_36_18_047Z-
26 verbose logfile /root/.npm/_logs/2023-07-09T06_36_18_047Z-debug-0.log
27 timing npm:load:logFile Completed in 110ms
28 timing npm:load:timers Completed in 2ms
29 timing npm:load:configScope Completed in 1ms
30 timing npm:load Completed in 208ms
31 verbose publish [ '.' ]
32 silly logfile start cleaning logs, removing 1 files
33 silly logfile done cleaning log files
34 timing arborist:ctor Completed in 1ms
35 notice
36 notice 📦  @nxrocks/nx-quarkus@1.0.0
37 notice === Tarball Contents ===
38 notice 13.4kB CHANGELOG.md                                                  
38 notice 14.8kB README.md                                                     
38 notice 2.8kB  executors.json                                                
38 notice 667B   generators.json                                               
38 notice 1.2kB  package.json                                                  
38 notice 349B   src/core/constants.d.ts                                       
38 notice 1.4kB  src/core/constants.js                                         
38 notice 905B   src/core/constants.js.map                                     
38 notice 285B   src/executors/add-extension/executor.d.ts                     
38 notice 738B   src/executors/add-extension/executor.js                       
38 notice 499B   src/executors/add-extension/executor.js.map                   
38 notice 142B   src/executors/add-extension/schema.d.ts                       
38 notice 765B   src/executors/add-extension/schema.json                       
38 notice 257B   src/executors/build/executor.d.ts                             
38 notice 695B   src/executors/build/executor.js                               
38 notice 487B   src/executors/build/executor.js.map                           
38 notice 110B   src/executors/build/schema.d.ts                               
38 notice 628B   src/executors/build/schema.json                               
38 notice 281B   src/executors/check-format/executor.d.ts                      
38 notice 732B   src/executors/check-format/executor.js                        
38 notice 498B   src/executors/check-format/executor.js.map                    
38 notice 116B   src/executors/check-format/schema.d.ts                        
38 notice 635B   src/executors/check-format/schema.json                        
38 notice 257B   src/executors/clean/executor.d.ts                             
38 notice 695B   src/executors/clean/executor.js                               
38 notice 487B   src/executors/clean/executor.js.map                           
38 notice 110B   src/executors/clean/schema.d.ts                               
38 notice 636B   src/executors/clean/schema.json                               
38 notice 249B   src/executors/dev/executor.d.ts                               
38 notice 683B   src/executors/dev/executor.js                                 
38 notice 485B   src/executors/dev/executor.js.map                             
38 notice 108B   src/executors/dev/schema.d.ts                                 
38 notice 626B   src/executors/dev/schema.json                                 
38 notice 261B   src/executors/format/executor.d.ts                            
38 notice 701B   src/executors/format/executor.js                              
38 notice 488B   src/executors/format/executor.js.map                          
38 notice 111B   src/executors/format/schema.d.ts                              
38 notice 629B   src/executors/format/schema.json                              
38 notice 265B   src/executors/install/executor.d.ts                           
38 notice 707B   src/executors/install/executor.js                             
38 notice 489B   src/executors/install/executor.js.map                         
38 notice 112B   src/executors/install/schema.d.ts                             
38 notice 631B   src/executors/install/schema.json                             
38 notice 293B   src/executors/list-extensions/executor.d.ts                   
38 notice 750B   src/executors/list-extensions/executor.js                     
38 notice 503B   src/executors/list-extensions/executor.js.map                 
38 notice 119B   src/executors/list-extensions/schema.d.ts                     
38 notice 638B   src/executors/list-extensions/schema.json                     
38 notice 265B   src/executors/package/executor.d.ts                           
38 notice 707B   src/executors/package/executor.js                             
38 notice 489B   src/executors/package/executor.js.map                         
38 notice 112B   src/executors/package/schema.d.ts                             
38 notice 638B   src/executors/package/schema.json                             
38 notice 273B   src/executors/remote-dev/executor.d.ts                        
38 notice 720B   src/executors/remote-dev/executor.js                          
38 notice 496B   src/executors/remote-dev/executor.js.map                      
38 notice 114B   src/executors/remote-dev/schema.d.ts                          
38 notice 637B   src/executors/remote-dev/schema.json                          
38 notice 253B   src/executors/test/executor.d.ts                              
38 notice 689B   src/executors/test/executor.js                                
38 notice 486B   src/executors/test/executor.js.map                            
38 notice 109B   src/executors/test/schema.d.ts                                
38 notice 628B   src/executors/test/schema.json                                
38 notice 166B   src/generators/link/generator.d.ts                            
38 notice 1.2kB  src/generators/link/generator.js                              
38 notice 786B   src/generators/link/generator.js.map                          
38 notice 102B   src/generators/link/schema.d.ts                               
38 notice 1.0kB  src/generators/link/schema.json                               
38 notice 223B   src/generators/project/generator.d.ts                         
38 notice 2.4kB  src/generators/project/generator.js                           
38 notice 1.7kB  src/generators/project/generator.js.map                       
38 notice 177B   src/generators/project/lib/add-formatting-with-spotless.d.ts  
38 notice 627B   src/generators/project/lib/add-formatting-with-spotless.js    
38 notice 544B   src/generators/project/lib/add-formatting-with-spotless.js.map
38 notice 173B   src/generators/project/lib/add-maven-publish-plugin.d.ts      
38 notice 2.2kB  src/generators/project/lib/add-maven-publish-plugin.js        
38 notice 1.2kB  src/generators/project/lib/add-maven-publish-plugin.js.map    
38 notice 183B   src/generators/project/lib/generate-quarkus-project.d.ts      
38 notice 2.2kB  src/generators/project/lib/generate-quarkus-project.js        
38 notice 1.3kB  src/generators/project/lib/generate-quarkus-project.js.map    
38 notice 340B   src/generators/project/lib/index.d.ts                         
38 notice 1.4kB  src/generators/project/lib/index.js                           
38 notice 349B   src/generators/project/lib/index.js.map                       
38 notice 212B   src/generators/project/lib/normalize-options.d.ts             
38 notice 1.2kB  src/generators/project/lib/normalize-options.js               
38 notice 1.2kB  src/generators/project/lib/normalize-options.js.map           
38 notice 137B   src/generators/project/lib/prompt-quarkus-extensions.d.ts     
38 notice 1.2kB  src/generators/project/lib/prompt-quarkus-extensions.js       
38 notice 803B   src/generators/project/lib/prompt-quarkus-extensions.js.map   
38 notice 596B   src/generators/project/schema.d.ts                            
38 notice 3.7kB  src/generators/project/schema.json                            
38 notice 122B   src/index.d.ts                                                
38 notice 562B   src/index.js                                                  
38 notice 206B   src/index.js.map                                              
38 notice 192B   src/project-graph.d.ts                                        
38 notice 504B   src/project-graph.js                                          
38 notice 328B   src/project-graph.js.map                                      
38 notice 884B   src/utils/quarkus-utils.d.ts                                  
38 notice 3.3kB  src/utils/quarkus-utils.js                                    
38 notice 2.2kB  src/utils/quarkus-utils.js.map                                
39 notice === Tarball Details ===
40 notice name:          @nxrocks/nx-quarkus                     
40 notice version:       1.0.0                                   
40 notice filename:      nxrocks-nx-quarkus-1.0.0.tgz            
40 notice package size:  22.2 kB                                 
40 notice unpacked size: 95.7 kB                                 
40 notice shasum:        122a7d048e11e940f24c5da12005d5fd0a260c05
40 notice integrity:     sha512-0Vboz4XzApl4M[...]QiPvTeJmu3kEw==
40 notice total files:   100                                     
41 notice
42 notice Publishing to http://localhost:4875 with tag e2e and public access
43 http fetch PUT 409 http://localhost:4875/@nxrocks%2fnx-quarkus 428ms
44 http fetch GET 200 http://localhost:4875/@nxrocks%2fnx-quarkus?write=true 49ms (cache miss)
45 timing command:publish Completed in 981ms
46 verbose stack Error: Cannot publish @nxrocks/nx-quarkus@undefined over existing version.
46 verbose stack     at patchMetadata (/usr/local/share/nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/libnpmpublish/lib/publish.js:187:7)
46 verbose stack     at publish (/usr/local/share/nvm/versions/node/v18.15.0/lib/node_modules/npm/node_modules/libnpmpublish/lib/publish.js:63:25)
46 verbose stack     at async otplease (/usr/local/share/nvm/versions/node/v18.15.0/lib/node_modules/npm/lib/utils/otplease.js:4:12)
46 verbose stack     at async Publish.exec (/usr/local/share/nvm/versions/node/v18.15.0/lib/node_modules/npm/lib/commands/publish.js:128:7)
46 verbose stack     at async module.exports (/usr/local/share/nvm/versions/node/v18.15.0/lib/node_modules/npm/lib/cli.js:134:5)
47 verbose pkgid @nxrocks/nx-quarkus
48 verbose cwd /workspaces/nxrocks/dist/packages/nx-quarkus
49 verbose Linux 5.15.49-linuxkit-pr
50 verbose node v18.15.0
51 verbose npm  v9.5.0
52 error code EPUBLISHCONFLICT
53 error publish fail Cannot publish over existing version.
54 error publish fail Update the 'version' field in package.json and try again.
55 error publish fail
56 error publish fail To automatically increment version numbers, see:
57 error publish fail     npm help version
58 verbose exit 1
59 timing npm Completed in 1229ms
60 verbose code 1
61 error A complete log of this run can be found in:
61 error     /root/.npm/_logs/2023-07-09T06_36_18_047Z-debug-0.log

Operating System

Additional Information

I can provide a PR if above "expected behavior" is accepted

AgentEnder commented 11 months ago

@tinesoft I'd love a PR for this 🎉 - I think 0.0.0-e2e.0 should make sense. Let me know if you need any assistance on the PR.

tinesoft commented 11 months ago

PR in progress. I'm thinking of adding a migration too , to update existing code, do you think it make sense @AgentEnder ?

github-actions[bot] commented 10 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.