* chore: update lockfiles
* feat: guess whether command was invoked non-interactively
Previously, it was made possible to control the interactivity status of the
progress bar by setting `_G.interactive`. However, this was not
automatically inferred from the context the process was started from,
and was expected to be manually set by the library invoker.
Non-interactivity status is now inferred automatically based on the
context the command was called from.
* feat: introduce `PESDE_TOOLING_FORCE_INTERACTIVE` override
This environment variable allows overriding the result of the
interactivity status guess by setting it to any non-empty value.
* fix: accidentally forcing users to set env var to get noninteractivity
* style: apply `stylua` formatter
Fixes an issue where the process sometimes hangs indefinitely after
installation of a tool. This is done by removing the usage of
`task.cancel` within the code for progress bars, and instead checking
the `finished` value within the task.
Previously, the code tried to acquire a lock every
1s while checking if it exists. This caused a
deadlock, since the lock got acquired by the
concurrent process after the installation had
completed and the lock was released.
Fixes a potential TOCTOU bug in the locking mechanism by restructuring
and using file moves which are atomic on both windows and unix.
FIXME: This commit introduces a bug where if there is are two concurrent
processes attempting to install a tool such that the tool has artifact
naming patterns that we understand (and hence do not need to download
every artifact for), the parent installation process (i.e., the one
which started first) yields indefinitely even after installing and
running the tool.
`os.time()` returns a timestamp in seconds, not milliseconds, but the
expiration time was adding 60,000 assuming it was in milliseconds. This
has now been corrected to only add 60 in seconds.
This allows for us to know whether a lock file is too old and hence
invalid, and perform a sanity check to ensure that the resource it is
meant to be protecting is the resource we are trying to access.
* Fixes an issue to do with multiple installation attempts trying
to access the same resources concurrently, causing installation
errors
* Made conditional progress bar a shared state among `__call` metamethod
shorthand and `installTool`, in order to prevent constructing it in
two different places
We did not correctly handle the case if the `gh` CLI was not present,
since `process.spawn` errors. We now wrap it in a `Result.try` and
handle that as required.
* Looks for `$GITHUB_TOKEN` env var, and if not found, tries to run `gh
auth token` to get the token from the GitHub CLI.
* Made a conditional `start` method for the bar, which was previously
missed.
Tools are now stored in the `~/.pesde/bin/.tool_storage` directory, in
order to prevent naming conflicts with other tool linkers. An old
tool_storage directory gets migrated to the new path if present.