Skip to content

Commit

Permalink
docs: update docs with bun and pnpm (#142)
Browse files Browse the repository at this point in the history
* docs: update docs with bun and pnpm

* move warning box about node_modules not cached
  • Loading branch information
km1chno authored Dec 2, 2024
1 parent c882201 commit 9e88095
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 46 deletions.
58 changes: 58 additions & 0 deletions docs/docs-site/docs/introduction/node-bun-version.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
sidebar_position: 4
---

# Node/Bun version

To make all workflows generated by SCI as consistent as possible, each of them has a step
where specific version of node or bun is set. It should look more or less like this:

```yaml
- name: 🌿 Setup Node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"
```
in case your package manager is `npm`, `yarn` or `pnpm`, and like this:

```yaml
- name: 🥟 Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: ".bun-version" :
```

if your project uses `bun`.

For more information, check [actions/setup-node](https://github.com/actions/setup-node)
and [actions/setup-bun](https://github.com/oven-sh/setup-bun).

## Caching global package manager data

Note the field `cache` in setup step. It is set to your package manager to enable caching of global packages data.

:::caution
`node_modules` is not cached.
:::

## Node version file

The `node-version-file` field will be set to point to a file in your repository from which
node version should be retrieved. Possible values are:

- `.nvmrc` if exists,
- `.node-version` if exists,
- `package.json`, if either `engines.node` or `volta.node` fields are specified.

If SCI fails to detect files satisfying these conditions, it will create `.nvmrc` file in your project with
default node version.

Also, the workflow step will have the field `cache` set to your package manager to enable global packages data caching.

## Bun version file

Similarly to how SCI detects node version and creates `.nvmrc` file in case of failure, if your
projects uses `bun` and SCI fails to detect `.bun-version` file, it will create it with default bun version,
which will be provided in generated workflows in the `bun-version-file` field.
38 changes: 0 additions & 38 deletions docs/docs-site/docs/introduction/node-version.mdx

This file was deleted.

8 changes: 4 additions & 4 deletions docs/docs-site/docs/introduction/package-managers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ sidebar_position: 3

# Package Managers

SCI will automatically detect your package manager based on the presence of a `yarn.lock` or `package-lock.json` file in the root of your repository.
SCI will automatically detect your package manager based on the presence of a `yarn.lock`, `package-lock.json`, `pnpm-lock.yaml` or `bun.lockb` file in the root of your repository.
This step is crucial to ensure that dependencies are installed properly and generated workflows work as expected.

:::caution
In case both `yarn.lock` and `package-lock.json` are detected, the script will default to one of them with undefined priority.
In case more than one lock file is detected, the script will default to one of them with undefined priority.
:::

## Supported package managers
Expand All @@ -17,5 +17,5 @@ In case both `yarn.lock` and `package-lock.json` are detected, the script will d
| --------------- | ---------------- |
| yarn | ✅ full support |
| npm | ✅ full support |
| pnpm | ❌ not supported |
| bun | ❌ not supported |
| pnpm | ✅ full support |
| bun | ✅ full support |
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Alternatively, we can use flags `--preset --ts --prettier` to avoid the interact
## ⚙️ Features

- **Currently, only GitHub actions are supported as your CI.**
- **npm** and **yarn** are supported as package managers, and they will be detected automatically.
- **npm**, **yarn**, **pnpm** and **bun** are supported as package managers, and they will be detected automatically.
- Monorepo structure is supported, but make sure you run the script from the app directory,
not the monorepo root.

Expand Down
4 changes: 2 additions & 2 deletions src/commands/setup-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import intersection from 'lodash/intersection'
import {
COLORS,
CYCLI_COMMAND,
DOCS_WORKFLOWS_URL,
HELP_FLAG,
PRESET_FLAG,
REPOSITORY_FEATURES_HELP_URL,
REPOSITORY_METRICS_HELP_URL,
REPOSITORY_TROUBLESHOOTING_URL,
REPOSITORY_URL,
Expand Down Expand Up @@ -73,7 +73,7 @@ const getSelectedOptions = async (toolbox: CycliToolbox): Promise<string[]> => {
} else {
return await toolbox.interactive.multiselect(
'Select workflows you want to run on every PR',
`Learn more about PR workflows: ${REPOSITORY_FEATURES_HELP_URL}`,
`Learn more about PR workflows: ${DOCS_WORKFLOWS_URL}`,
RECIPES.map(
({ validate, meta: { name, flag, selectHint } }: CycliRecipe) => {
let validationError = ''
Expand Down
4 changes: 3 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export const LOCK_FILE_TO_MANAGER = {

export const REPOSITORY_URL = 'https://github.com/software-mansion/setup-ci'
export const REPOSITORY_SECRETS_HELP_URL = `${REPOSITORY_URL}?tab=readme-ov-file#-repository-secrets`
export const REPOSITORY_FEATURES_HELP_URL = `${REPOSITORY_URL}?tab=readme-ov-file#%EF%B8%8F-features`
export const REPOSITORY_METRICS_HELP_URL = `${REPOSITORY_URL}?tab=readme-ov-file#%-metrics`
export const REPOSITORY_ISSUES_URL = `${REPOSITORY_URL}/issues`
export const REPOSITORY_TROUBLESHOOTING_URL = `${REPOSITORY_URL}/blob/master/docs/troubleshooting.md`

const DOCS_URL = 'https://docs.swmansion.com/setup-ci/docs'
export const DOCS_WORKFLOWS_URL = `${DOCS_URL}/category/workflows`

0 comments on commit 9e88095

Please sign in to comment.