Skip to content
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

feat: auto-detect package manager in create fuels #3503

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Dhaiwat10
Copy link
Member

@Dhaiwat10 Dhaiwat10 commented Dec 26, 2024

Release notes

In this release, we:

  • Added auto-detection for the user's package manger of choice for create fuels

Summary

create fuels now auto-detects the user's package manger. eg. bun create fuels will now use bun to install dependencies.

Breaking Changes

These package manager flags have been removed since they are not needed anymore:

--bun, --pnpm, --npm

Before

bun create fuels --bun
pnpm create fuels --pnpm

After

bun create fuels
pnpm create fuels

Checklist

  • All changes are covered by tests (or not applicable)
  • All changes are documented (or not applicable)
  • I reviewed the entire PR myself (preferably, on GH UI)
  • I described all Breaking Changes (or there's none)

Copy link

vercel bot commented Dec 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fuels-template ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2024 3:39pm
ts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2024 3:39pm
ts-docs-api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2024 3:39pm

Copy link
Contributor

github-actions bot commented Dec 26, 2024

This PR is published in NPM with version 0.0.0-pr-3503-20241226031927

Copy link

codspeed-hq bot commented Dec 26, 2024

CodSpeed Performance Report

Merging #3503 will degrade performances by 48.61%

Comparing dp/create-fuels-pkg-manager (6f3b3f9) with master (41c72fb)

Summary

❌ 1 regressions
✅ 17 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark master dp/create-fuels-pkg-manager Change
should successfully conduct a custom transfer between wallets (x20 times) 50.3 ms 97.8 ms -48.61%

let packageManager: PackageManager | undefined = cliChosenPackageManagerSelected[0];
if (cliChosenPackageManagerSelected.length > 1) {
warn('More than one package manager was selected.');
if (userAgent.startsWith('pnpm')) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit, please store package manager strings as constants

Copy link
Member Author

Choose a reason for hiding this comment

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

}

Copy link
Member

Choose a reason for hiding this comment

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

console.warn here if the package users package manager is not supported and we default to npm?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Coverage Report:

Lines Branches Functions Statements
76.33%(+0%) 69.88%(+0.04%) 74.19%(-0.01%) 76.34%(+0%)
Changed Files:
Ok File (✨=New File) Lines Branches Functions Statements
🔴 packages/create-fuels/src/lib/getPackageManager.ts 100%
(+0%)
88.88%
(+8.88%)
100%
(+0%)
100%
(+0%)

```

```sh-vue [bun]
bunx --bun create-fuels@{{fuels}} --bun [project-name] [options]
bunx --bun create-fuels@{{fuels}} [project-name] [options]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bunx --bun create-fuels@{{fuels}} [project-name] [options]
bun create fuels@{{fuels}} [project-name] [options]

```

```sh-vue [bun]
bunx --bun create-fuels@{{fuels}} --bun
bunx --bun create-fuels@{{fuels}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bunx --bun create-fuels@{{fuels}}
bun create fuels@{{fuels}}

Running via this command works for me

const packageManager = 'npm';
const expectedPackageManager = packageMangers[packageManager];
const { warn } = mockAllDeps();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove the mocking here?

Could we not assert that the expected warning is emitted? It also stops the noise in the test outputs (ref)


const cliChosenPackageManagerSelected = Object.entries(packageMangerOpts)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Would looping over the keys to find the package manager be simpler? Then we could remove the name property from packageMangers entries.

  Object.keys(packageMangers).forEach((packageManager) => {
    if (userAgent.startsWith(packageManger)) {
      return packageManger as PackageManager;
    }
  });

  warn(`This package manager is not supported. Using npm instead.`);
  return packageMangers.npm.name;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto-detect package manager in create fuels
3 participants