Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Request for cookbook contributions #3304

Closed
jdx opened this issue Nov 30, 2024 · 13 comments
Closed

Request for cookbook contributions #3304

jdx opened this issue Nov 30, 2024 · 13 comments

Comments

@jdx
Copy link
Owner

jdx commented Nov 30, 2024

I'd like to create a cookbook section for the docs. Show me parts of your mise.toml you think are interesting.

In particular I think tasks, hooks, and env would be really helpful for people to see examples of.

@jdx jdx pinned this issue Nov 30, 2024
@hverlin
Copy link
Contributor

hverlin commented Nov 30, 2024

There is already an example for a Node.js project here (https://mise.jdx.dev/templates.html#a-node-js-project). Here is what I usually do with pnpm. This ensures that dependencies are installed before running any scripts in the package.json.

[tools]
node = '22'

[tasks.pnpmInstall]
alias = 'pi'
description = 'Installs dependencies with pnpm'
run = 'corepack enable && pnpm install'
sources = ['package.json', 'pnpm-lock.yaml', 'mise.toml']
outputs = ['node_modules/.pnpm/lock.yaml']

[tasks.dev]
description = 'Calls your dev script in `package.json`'
run = 'node --run dev'
depends = ['pnpmInstall']

[tasks.nodeRun]
alias = 'nr'
description = 'Call any script in your package.json file. Example: mise nr lint'
run = 'node --run {{arg(name="script")}}'
depends = ['pnpmInstall']

Note that pnpm run will support such feature behind a setting in the next release (pnpm/pnpm#8585)

@syhol
Copy link
Contributor

syhol commented Dec 1, 2024

presets: #3320 (comment)

@erickguan
Copy link
Contributor

For additional context on the "template documentation". I wrote a few to demonstrate templates without readers needed to try in mise.toml.

I would merge them into cookbooks to demonstrate the real world setup.

I would also reduce the template documentation examples when cookbooks have good examples.

@hverlin
Copy link
Contributor

hverlin commented Dec 4, 2024

Agree that the existing examples could be moved to cookbooks now. We can do a page for each language (example: one page for Node.JS, one for terraform, one for python, etc.)

Also, when seeing templates the first time in the sidebar, I thought this was going to be a page showing some example projects using mise. I think the page should probably be renamed to something like Templating or Templating mise.toml files

@syhol
Copy link
Contributor

syhol commented Dec 5, 2024

Mise search

#3364 (comment)

[tasks.search]
run = "mise use --pin $(mise registry -b aqua | fzf --multi | awk '{print $2}')"

Might want to adapt it to not be aqua specific

@hverlin
Copy link
Contributor

hverlin commented Dec 5, 2024

Mise search

I think it could be implemented internally, like for mise run.
mise use without any tools provided could show a (multi) selector.

@syhol
Copy link
Contributor

syhol commented Dec 6, 2024

I know skim can be imported as a library and has a very similar feature set to fzf.

@jdx
Copy link
Owner Author

jdx commented Dec 6, 2024

we don't need no skim, we have demand

@syhol
Copy link
Contributor

syhol commented Dec 6, 2024

we don't need no skim, we have demand

Not sure I trust the author of that library. I hear bad things 👀

@jdx
Copy link
Owner Author

jdx commented Dec 7, 2024

this is a way to convert from .tool-versions to mise.toml:

cat ~/.tool-versions | tr ' ' '@' | xargs -n2 mise use -g

though I'd like this to be a part of mise config generate, which maybe should be mise generate config to match the other generators

@syhol
Copy link
Contributor

syhol commented Dec 15, 2024

I've been using docker to debug issues in a clean environment over the weekend:

[tasks.docker]
run = "docker run --pull=always -it --rm --entrypoint bash jdxcode/mise:latest"

Puts me in a fresh debian shell with mise installed. I then normally run the following manually:

mise docker
[docker] $ docker run --pull=always -it --rm --entrypoint bash jdxcode/mise:latest
latest: Pulling from jdxcode/mise
Digest: sha256:eecc479b6259479ffca5a4f9c68dbfe8631ca62dc59aa60c9ab5e4f6e9982701
Status: Image is up to date for jdxcode/mise:latest
root@75f179a190a1:/mise# eval "$(mise activate bash)"
root@75f179a190a1:/mise# echo "" >/mise/config.toml
root@75f179a190a1:/mise# mise prune --yes
mise pruned configuration links
mise [email protected] ✓ remove /mise/cache/python/3.13.1

But it might be nice to automate that bit too.

@joshbode
Copy link
Contributor

Using record-query you can inspect the __MISE_DIFF and __MISE_SESSION variables to see what's changing in your environment due to the mise hook.

# ~/.config/mise/config.toml
[tools]
"cargo:record-query" = "latest"
function mise_parse_env {
  rq -m < <(
    zcat -q < <(
      printf $'\x1f\x8b\x08\x00\x00\x00\x00\x00'
      base64 -d <<< "$1"
    )
  )
}
$ mise_parse_env "${__MISE_DIFF}"
{
  "new": {
    ...
  },
  "old": {
    ...
  },
  "path": [
    ...
  ]
}

@syhol
Copy link
Contributor

syhol commented Dec 17, 2024

Nice one @joshbode! It could also be a great showcase of the new task tools feature that was recently merged, because cargo:record-query can be defined as a task tool.

Repository owner locked and limited conversation to collaborators Dec 17, 2024
@jdx jdx converted this issue into discussion #3645 Dec 17, 2024
@jdx jdx unpinned this issue Dec 19, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants