From 09c12618d7b5b62115508dcd24d19d1ceab6aa0c Mon Sep 17 00:00:00 2001 From: Donald Pakkies Date: Fri, 18 Apr 2025 00:02:10 +0200 Subject: [PATCH 1/2] feat: automatically set package manager --- src/commands/index.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/commands/index.ts b/src/commands/index.ts index c0bda22..3d56fad 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -1,7 +1,10 @@ import { Args, Command, Flags } from '@oclif/core' import { input } from '@inquirer/prompts' import { run } from '@formidablejs/installer' -import path = require('path') + +type Mapper = { + [key: string]: string +} export default class Create extends Command { static description = 'Create a new Formidable application' @@ -43,6 +46,27 @@ export default class Create extends Command { args.name = name } + if (!flags['use-pnpm'] && !flags['use-npm'] && !flags['use-yarn'] && !flags['use-bun'] && !flags.manager) { + const userAgent = process.env.npm_config_user_agent + + if (userAgent && typeof userAgent === 'string') { + const agent = userAgent.split('/')[0] + + const mapper: Mapper = { + 'npm': 'npm', + 'pnpm': 'pnpm', + 'yarn': 'yarn', + 'yarn@berry': 'yarn', + 'bun': 'bun', + 'pnpm@6': 'pnpm', + } + + if (agent !== '' && Object.keys(mapper).includes(agent)) { + flags.manager = mapper[agent] + } + } + } + const installerArgs = ['new', args.name] for (const [key, value] of Object.entries(flags)) { From 57de665170634109174f84e816e8f17ee45e2360 Mon Sep 17 00:00:00 2001 From: Donald Pakkies Date: Fri, 18 Apr 2025 00:02:30 +0200 Subject: [PATCH 2/2] chore: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 19a30e4..59dd777 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "create-formidable", - "version": "0.0.11", + "version": "0.0.12", "description": "The Formidable Framework Installer", "author": "Donald Pakkies @donaldp", "bin": {