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

Move argv override logging to middleware #42

Merged
merged 4 commits into from
Feb 8, 2024

Conversation

zeyadkhaled
Copy link
Member

Addresses #16 (comment)

@changelog-app
Copy link

changelog-app bot commented Feb 7, 2024

Generate changelog in packages/cli/changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Move argv override logging to middleware

Check the box to generate changelog(s)

  • Generate changelog entry

packages/cli/src/commands/site/index.ts Outdated Show resolved Hide resolved
packages/cli/src/yargs/logCommandDebugMiddlewares.ts Outdated Show resolved Hide resolved
packages/cli/src/yargs/logCommandDebugMiddlewares.ts Outdated Show resolved Hide resolved
`Overriding "directory" from config file with ${argv.directory}`,
if (
autoVersion != null && argv.autoVersion !== autoVersion.type
&& argv.autoVersion !== "git-describe"
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor note I feel this block and the one above are going to be difficult to maintain if we add another auto version type. The checks also seem slightly loose for example the above one will throw with --autoVersion git-describe --tagPrefix abc if there is no config file but that would be a valid state

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I agree, but it is required I think to not get the user in a state that doesn't make sense.

As for the part that didn't work, that was just because I forgot to check if autoVersion was defined.

Open to ideas here honestly to make this easier to handle.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend breaking up the check a bit for example:

const autoVersionType = argv.autoVersion ?? autoVersion;
if (autoVersionType !== "git-describe") { throw }

To make it extensible in the future we may be able to do something with the AutoVersionType type and visit against each of the cases in the union and if we don't match any then we would throw

);
}

if (gitTagPrefix != null && argv.gitTagPrefix !== gitTagPrefix) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's also make these checks tighter currently this is going to say misleading things like: Overriding "gitTagPrefix" from config file with undefined

Copy link
Member Author

Choose a reason for hiding this comment

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

Which command did you run to get to that state?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is because I have "tagPrefix": "" in my config file which I think would be good to illustrate that the key exists if someone discovers it and wants to edit it. We probably have some loose truthy checks on strings which is why some people use === everywhere

@zeyadkhaled zeyadkhaled requested a review from tzyl February 8, 2024 11:13
packages/cli/src/commands/site/index.ts Outdated Show resolved Hide resolved
`Overriding "directory" from config file with ${argv.directory}`,
if (
autoVersion != null && argv.autoVersion !== autoVersion.type
&& argv.autoVersion !== "git-describe"
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend breaking up the check a bit for example:

const autoVersionType = argv.autoVersion ?? autoVersion;
if (autoVersionType !== "git-describe") { throw }

To make it extensible in the future we may be able to do something with the AutoVersionType type and visit against each of the cases in the union and if we don't match any then we would throw

@@ -92,7 +92,7 @@ const command: CommandModule<
}

if (
(autoVersion?.type !== "git-describe"
((autoVersion != null && autoVersion.type !== "git-describe")
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe:

const autoVersionType = argv.autoVersion ?? autoVersion;
if (argv.gitTagPrefix != null && autoVersionType !== "git-describe") { ... }

@bulldozer-bot bulldozer-bot bot merged commit c8854e4 into main Feb 8, 2024
6 checks passed
@bulldozer-bot bulldozer-bot bot deleted the zka/move-debug-logs-to-middle-ware branch February 8, 2024 16:27
ericanderson added a commit that referenced this pull request Feb 13, 2024
* origin/main:
  Autorelease
  Increase CLI max width to 150 columns (#47)
  Debug log site zip stats (#49)
  Clean up yargs and consola imports (#51)
  Autorelease
  Add generated changelog entries
  Breaking: force dollar sign in osdk verbs for where
  Display errors more consistently in @osdk/cli (#41)
  Fix tagPrefix
  Add generated changelog entries
  Create foundry.config.json in create-app
  [3/] Improvement: Use loadedToken for fetching data (#17)
  Move argv override logging to middleware (#42)
  Make sure to run all tests (#39)
  Update create-app to use FOUNDRY_TOKEN in templates (#40)
  Add generated changelog entries
  Fix intellisense for aggregations and fill in more number types
  [2/] Improvement: Introduce new command structure  (#16)
  Autorelease
  Refactor create-app prompts with tests (#32)
  Refactor create-app dotfile generation (#31)
  add changelog
  Add generated changelog entries
  Add generated changelog entries
  put mkdir in right place
  remove generated files
  add ignore for legacy client
  remove deleted file
  added
  add back mkdir
  move mkdir
  fix
  fixes
  keep trying
  remove module
  shared testing infra for legacy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants