Skip to content

feat(version-manager): add side-effect-free version resolution - #1290

Merged
wing328 merged 8 commits into
OpenAPITools:masterfrom
c19yamamoto:feat/version-manager-resolve
Oct 20, 2026
Merged

wing328 merged 8 commits into
OpenAPITools:masterfrom
c19yamamoto:feat/version-manager-resolve

Conversation

@c19yamamoto

@c19yamamoto c19yamamoto commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add version-manager resolve <versionTags...> to print the highest matching version.
  • Skip generator bootstrap and downloads for the resolver command.
  • Keep configuration reads side-effect-free so openapitools.json is not created or modified.

Testing

  • yarn lint
  • yarn test
  • yarn build
  • Manual check: version-manager resolve latest prints 7.26.0 without creating a config file or JAR.

Fixes #1289


Summary by cubic

Adds a side-effect-free resolve subcommand to version-manager that prints the highest matching version, fixing #1289. Resolution now fails with a non-zero exit code when no version matches the given tags.

  • version-manager resolve <versionTags...> prints the first matching version and skips generator bootstrap, downloads, and config writes; unmatched tags print an error to stderr and exit non-zero.
  • The command is detected positionally, so opening flags like --openapitools are skipped and it is not confused with pass-through arguments.
  • ConfigService no longer creates or modifies openapitools.json when reading configuration—the file is only touched on writes.

Written for commit 305bb54. Summary will update on new commits.

View guided diff

@c19yamamoto
c19yamamoto marked this pull request as ready for review October 17, 2026 12:11

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 7 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/generator-cli/src/app/services/config.service.spec.ts">

<violation number="1" location="apps/generator-cli/src/app/services/config.service.spec.ts:72">
P2: This regression test does not cover the absent-config case: its setup always returns an existing configuration object. Add a case with `fs.readJSONSync.mockReturnValue(undefined)` and assert that `ensureFileSync` and the write methods remain unused, so a missing `openapitools.json` cannot regress to being created.</violation>
</file>

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

});

it('ensures the config file', () => {
it('does not create or modify the config file', () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This regression test does not cover the absent-config case: its setup always returns an existing configuration object. Add a case with fs.readJSONSync.mockReturnValue(undefined) and assert that ensureFileSync and the write methods remain unused, so a missing openapitools.json cannot regress to being created.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/generator-cli/src/app/services/config.service.spec.ts, line 72:

<comment>This regression test does not cover the absent-config case: its setup always returns an existing configuration object. Add a case with `fs.readJSONSync.mockReturnValue(undefined)` and assert that `ensureFileSync` and the write methods remain unused, so a missing `openapitools.json` cannot regress to being created.</comment>

<file context>
@@ -69,12 +69,10 @@ describe('ConfigService', () => {
         });
 
-        it('ensures the config file', () => {
+        it('does not create or modify the config file', () => {
           fixture.get('some-path');
-          expect(fs.ensureFileSync).toHaveBeenNthCalledWith(
</file context>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in d7f0e8f. The tests now cover an absent configuration (readJSONSync returns undefined) and verify that no file creation or write occurs.

Comment thread apps/generator-cli/src/app/controllers/version-manager.controller.spec.ts Outdated
Comment thread apps/generator-cli/src/app/controllers/version-manager.controller.ts Outdated
Comment thread apps/generator-cli/src/app/app.module.ts Outdated
Comment thread apps/generator-cli/src/README.md

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 6 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/generator-cli/src/app/controllers/version-manager.controller.ts">

<violation number="1" location="apps/generator-cli/src/app/controllers/version-manager.controller.ts:111">
P2: This edit lands in `set`, not `resolve`. `set`'s no-match message now goes to stderr, a behavior change nobody asked for, and the `set` spec still expects `log`, so it will fail. Revert this line to `this.logger.log(`; `resolve` already uses `logger.error`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

return;
}

this.logger.error(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This edit lands in set, not resolve. set's no-match message now goes to stderr, a behavior change nobody asked for, and the set spec still expects log, so it will fail. Revert this line to this.logger.log(; resolve already uses logger.error.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/generator-cli/src/app/controllers/version-manager.controller.ts, line 111:

<comment>This edit lands in `set`, not `resolve`. `set`'s no-match message now goes to stderr, a behavior change nobody asked for, and the `set` spec still expects `log`, so it will fail. Revert this line to `this.logger.log(`; `resolve` already uses `logger.error`.</comment>

<file context>
@@ -108,7 +108,7 @@ export class VersionManagerController {
     }
 
-    this.logger.log(
+    this.logger.error(
       chalk.red(
         `Unable to find version matching criteria "${versionTags.join(' ')}"`,
</file context>
Suggested change
this.logger.error(
this.logger.log(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be stale or misattributed. In the current code, set still uses logger.log, while only resolve uses logger.error, so no further change is needed.

Comment thread apps/generator-cli/src/app/app.module.ts
@wing328

wing328 commented Oct 20, 2026

Copy link
Copy Markdown
Member

thanks for the PR

let's give it a try

@wing328
wing328 merged commit e320153 into OpenAPITools:master Oct 20, 2026
4 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.42.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@c19yamamoto
c19yamamoto deleted the feat/version-manager-resolve branch October 21, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add a side-effect-free command to resolve version tags

2 participants