Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disk as fallback version resolver in nx release version #19971

Closed
1 task
guysenpai opened this issue Nov 1, 2023 · 4 comments
Closed
1 task

disk as fallback version resolver in nx release version #19971

guysenpai opened this issue Nov 1, 2023 · 4 comments
Assignees

Comments

@guysenpai
Copy link
Contributor

Description

Whether registry or git-tag version resolver failed, fallback to disk version resolver instead throw error

Motivation

For the first release or publish, registry and git-tag will throw an error because there is no existing tag and package in the registry

Suggested Implementation

For registry version resolver

try {
  // Must be non-blocking async to allow spinner to render
  currentVersion = await new Promise<string>((resolve, reject) => {
    exec(`npm view ${packageName} version --registry=${registry} --tag=${tag}`, (error, stdout, stderr) => {
      if (error) {
        return reject(error);
      }
      if (stderr) {
        return reject(stderr);
      }
      return resolve(stdout.trim());
    });
  });
} catch (error) {
  currentVersion = currentVersionFromDisk;
}

for git-tag version resolver

if (!latestMatchingGitTag) {
  currentVersion = currentVersionFromDisk;
}

Alternate Implementations

@guysenpai guysenpai changed the title disk as fallback version resolver disk as fallback version resolver in nx release version Nov 2, 2023
@AgentEnder AgentEnder added the scope: core core nx functionality label Nov 2, 2023
@AgentEnder AgentEnder added scope: misc Misc issues and removed scope: core core nx functionality labels Nov 2, 2023
@JamesHenry
Copy link
Collaborator

Hmm I'm not sure about this one... I may be want you want that one time, but the rest of the time I think using disk when you've said you don't want that would be undesired behaviour.

I think this might be one of those cases where it is just on the user to get their very first release into the registry and then the registry or git-tag resolvers can take it from there.

E.g. You could just start with disk in your first commit, and then change it to registry or git-tag in a follow up right?

I feel like falling back to disk when that's not desired is more of a downside than not accommodating this one case, but I won't close this yet in case you have further ideas in this area or have any thoughts on what I've just said

@guysenpai
Copy link
Contributor Author

Okay, I see, but I was thinking of a way to do it automatically for the first release.
Maybe we can pass an --first-release option

@JamesHenry
Copy link
Collaborator

Hi Folks, we just merged a PR to address this, so in the next release of nx:

  • you'll be able to pass --first-release to nx release or nx release version, or when using releaseVersion({ ..., firstRelease: true }) using the programmatic API

OR

  • you'll be able to set version.generatorOptions.fallbackCurrentVersionResolver equal to disk (e.g if you always want this behaviour)

We are working on docs to cover these workflows too.

Many thanks!

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants