Skip to content

Conversation

jackw
Copy link
Contributor

@jackw jackw commented Aug 4, 2025

This PR adds a new workflow to the repo that detects the node package manager for the currently checked out repo.

We have pm.sh duplicated throughout this repo and in other ci-workflows we're sniffing the existence of lock files directly in the steps to understand what plugins are using. This PR introduces a workflow that runs npx -y pm-detect on a directory and returns it's output for future workflows to use.

pm-detect returns a normalised map of the name of the package manager along with commands we want to run in CI.

NPM

npx -y pm-detect --working-dir ~/dev/jackw/heywesty-trafficlight-panel
{
  "name": "npm",
  "install": "npm install",
  "frozen-install": "npm ci",
  "global-install": "npm install -g",
  "run": "npm run",
  "exec": "npx"
}

Yarn

npx -y pm-detect --working-dir ~/dev/grafana/timestream-datasource
{
  "name": "yarn",
  "install": "yarn install",
  "frozen-install": "yarn install --frozen-lockfile",
  "global-install": "yarn global add",
  "run": "yarn run",
  "exec": "npx"
}

Yarn berry

npx -y pm-detect --working-dir ~/dev/grafana/app-o11y-kwl
{
  "name": "yarn",
  "install": "yarn install",
  "frozen-install": "yarn install --immutable",
  "global-install": "npm install -g",
  "run": "yarn run",
  "exec": "yarn dlx"
}

PNPM

npx -y pm-detect --working-dir ~/dev/grafana/slo
{
  "name": "pnpm",
  "install": "pnpm install",
  "frozen-install": "pnpm install --frozen-lockfile",
  "global-install": "pnpm add -g",
  "run": "pnpm run",
  "exec": "pnpm dlx"
}

@jackw jackw self-assigned this Aug 4, 2025
@jackw jackw added the enhancement New feature or request label Aug 4, 2025
@jackw jackw changed the title Feature: Add a package manager detection workflow feat: add a package manager detection workflow Aug 4, 2025
@jackw jackw marked this pull request as ready for review August 6, 2025 10:14
@jackw jackw requested review from a team as code owners August 6, 2025 10:14
@jackw jackw requested review from oshirohugo, s4kh and wbrowne August 6, 2025 10:14
Copy link
Collaborator

@academo academo left a comment

Choose a reason for hiding this comment

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

I wonder if we would be better of having this action as a "invoke pakage action" instead of having it returning the commands and then using the output to run those commands.

@jackw
Copy link
Contributor Author

jackw commented Aug 6, 2025

I wonder if we would be better of having this action as a "invoke pakage action" instead of having it returning the commands and then using the output to run those commands.

Can you expand on this idea a bit please I'm not following what "invoke package action" means? 🤔

@jackw jackw moved this from 📬 Triage to 🧑‍💻 In development in Plugins Platform / Grafana Community Aug 7, 2025
@jackw jackw moved this from 🧑‍💻 In development to 🔬 In review in Plugins Platform / Grafana Community Aug 7, 2025
Copy link
Contributor

@hugohaggmark hugohaggmark left a comment

Choose a reason for hiding this comment

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

Adding an approval if you want to try this out

Copy link
Contributor

@hugohaggmark hugohaggmark left a comment

Choose a reason for hiding this comment

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

Great work on this 🎉

Copy link
Contributor

@leventebalogh leventebalogh left a comment

Choose a reason for hiding this comment

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

Nice 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: 🔬 In review

Development

Successfully merging this pull request may close these issues.

4 participants