nushell / nushell.github.io

Nushell's main website, blog, book, and more
https://www.nushell.sh/book/
MIT License
166 stars 408 forks source link

Document minimal config files #1310

Closed texastoland closed 5 months ago

texastoland commented 5 months ago

3 New "Tips"

Additional Amendments:

fdncred commented 5 months ago

I'm not sure I'd recommend set-env in our official docs when it's not officially a part of nushell yet.

texastoland commented 5 months ago

Yeah that's why I didn't imply it's standard in any way. Just makes a day 1 tricky task easier. I have no reservation about removing that block regardless!

Pasting here in case we ever add it back:

::: tip
Try downloading the [`set-env`](https://github.com/nushell/nu_scripts/blob/main/stdlib-candidate/std-rfc/set-env.nu) command in order to _merge_ nested `$env` values at any depth:

```nu
set-env config.<field name> <field value>
```

You can optionally `--append` list settings such as [hooks](/book/hooks.md).
:::
fdncred commented 5 months ago

I'm fine with path add since it's in the stdlib, just not set-env since it's not there yet. Maybe you just deleted the wrong one?

texastoland commented 5 months ago

My bad fixed 🙉

texastoland commented 5 months ago

@fdncred I added 2 infra lines to enable my live preview in the description:

+const [ciUser, ciRepo] = process.env.GITHUB_REPOSITORY?.split('/') ?? []

 export default defineUserConfig({
+  base: ciRepo && ciUser !== 'nushell' ? `/${ciRepo}/` : '/',
  1. Get the user and repo from the GitHub action (or else undefined)
  2. If there's a fork it changes the base URL otherwise (nushell org and local build) it uses the default
fdncred commented 5 months ago

to enable my live preview in the description

I'd guess this isn't a good idea because it's specific to your environment and no one else's.

texastoland commented 5 months ago

You can try it in your own fork by enabling actions there 💯

fdncred commented 5 months ago

Are you saying this is a github thing or something specific to your env vars?

texastoland commented 5 months ago

Added comments for maintenance:

+// default env from the deploy GitHub action
+// e.g. ciUser = nushell and ciRepo = nushell.github.io
+// both default to undefined if the env is undefined
 const [ciUser, ciRepo] = process.env.GITHUB_REPOSITORY?.split('/') ?? []

 export default defineUserConfig({
+  // set the base URL to ciRepo dir if it's a fork
+  // keep the default root if not
   base: ciRepo && ciUser !== 'nushell' ? `/${ciRepo}/` : '/',

Also in CONTRIBUTING.md:

## Enabling a Preview URL From Your Fork

Just enable GitHub actions in your repo settings. That's all! It will start deploying the next time you push to `main`.
fdncred commented 5 months ago

ok, thanks