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

mixmix/custom-config #264

Open
wants to merge 27 commits into
base: mixmix/load-entropy
Choose a base branch
from
Open

Conversation

mixmix
Copy link
Contributor

@mixmix mixmix commented Oct 22, 2024

This part of a PR chain:

mixmix/config-typesmixmix/load-entropymixmix/custom-config


The purpose of this PR is to be able to set a custom config file path for CLI

NOTES

  • the argParser cannot be async
    • => I think we're going to need to move config loading/parsing into the .action, probably loadEntropy
  • the TUI cannot take the same --config as the other leaf actions
    • using the same option in multiple levels leads to collisions
    • if we really want this in TUI then we need to make the tui launch a subcommand like entropy tui or entropy ui

@mixmix mixmix marked this pull request as draft October 22, 2024 22:53
@mixmix
Copy link
Contributor Author

mixmix commented Nov 4, 2024

resolve conflicts, get ready for review

@mixmix mixmix marked this pull request as ready for review November 6, 2024 03:55
@mixmix
Copy link
Contributor Author

mixmix commented Nov 6, 2024

NOTE: this is passing all tests but will need a really close review + smoke test before merge.
We're gonna do this after this current release

@mixmix
Copy link
Contributor Author

mixmix commented Nov 7, 2024

@rh0delta I want you to try and break this. I think I got everything but dial up the pedantry with this one.

I turned of config.set taking a default config path, which then had typescript throwing everywhere it was not provided, but I bet there's still a place where something wrong has been written

Copy link
Contributor

@rh0delta rh0delta left a comment

Choose a reason for hiding this comment

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

Everything looks good from reading the code, will take some time to test out everything locally tho, so will hold off on the approval

Comment on lines -30 to -42
.argParser(aliasOrEndpoint => {
/* see if it's a raw endpoint */
if (aliasOrEndpoint.match(/^wss?:\/\//)) return aliasOrEndpoint

/* look up endpoint-alias */
const storedConfig = getConfigOrNull()
const endpoint = storedConfig?.endpoints?.[aliasOrEndpoint]
if (!endpoint) throw Error('unknown endpoint alias: ' + aliasOrEndpoint)

return endpoint
})
.default('wss://testnet.entropy.xyz/')
// NOTE: default cannot be "test-net" as argParser only runs if the -e/--endpoint flag
// or ENTROPY_ENDPOINT env set
Copy link
Contributor

Choose a reason for hiding this comment

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

what was the need to delete all of this? I'm all for it, just wondering the reason why

Comment on lines 63 to 66
// NOTE: (mix) we expect config to be initialised (see hook in cli)
// ...there was some reason we wanted to preserve a `null` state,
// but I can't recall if it's still relevant, and we need to check
// the downstream ramifications of it being `null`
Copy link
Contributor

Choose a reason for hiding this comment

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

i think the null state was for fresh installs, where the config is created in the XDG standardized directory if there is no config found initially.

Comment on lines 68 to 78
const account = parseAccountOption(storedConfig, opts.account)
// if this account is not the default selectedAccount, make it so
if (storedConfig.selectedAccount !== account.name) {
await config.set(
{
...storedConfig,
selectedAccount: account.name
},
opts.config
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we refactor this to be a separate function? might be cleaner

Comment on lines +86 to +95
export function absolutePath (somePath: string) {
switch (somePath.charAt(0)) {
case '.':
return join(process.cwd(), somePath)
case '~':
return join(homedir(), somePath.slice(1))
default:
return somePath
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🥳

rh0delta and others added 6 commits November 13, 2024 16:01
* [NayNay] Testing Mix's Custom Config

- the general purpose of the custom config works, however there is alot of work to be done regarding error handling
- i have only started testing the custom config feature with a file that doesn't exist: ./custom-files/custom-config-<#>.json
- this originally caused issues on the tui and did not allow for anything to start until the tui eventually errored out
- similar errors were found with the cli as well
- ive fixed the tui for the most part
- but theres still lots to do to fix the cli in terms of proper error handling

* Update src/common/utils-cli.ts

* Update src/common/utils-cli.ts

* Update src/common/utils-cli.ts

* Update src/common/utils.ts

---------

Co-authored-by: mix irving <[email protected]>
This was referenced Nov 28, 2024
@mixmix mixmix marked this pull request as draft November 28, 2024 00:51
@mixmix mixmix changed the title Mixmix/custom config mixmix/custom-config Nov 28, 2024
@mixmix mixmix changed the base branch from dev to mixmix/load-entropy November 28, 2024 00:51
@mixmix mixmix marked this pull request as ready for review December 2, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants