File tree 1 file changed +25
-1
lines changed
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { Args , Command , Flags } from '@oclif/core'
2
2
import { input } from '@inquirer/prompts'
3
3
import { run } from '@formidablejs/installer'
4
- import path = require( 'path' )
4
+
5
+ type Mapper = {
6
+ [ key : string ] : string
7
+ }
5
8
6
9
export default class Create extends Command {
7
10
static description = 'Create a new Formidable application'
@@ -43,6 +46,27 @@ export default class Create extends Command {
43
46
args . name = name
44
47
}
45
48
49
+ if ( ! flags [ 'use-pnpm' ] && ! flags [ 'use-npm' ] && ! flags [ 'use-yarn' ] && ! flags [ 'use-bun' ] && ! flags . manager ) {
50
+ const userAgent = process . env . npm_config_user_agent
51
+
52
+ if ( userAgent && typeof userAgent === 'string' ) {
53
+ const agent = userAgent . split ( '/' ) [ 0 ]
54
+
55
+ const mapper : Mapper = {
56
+ 'npm' : 'npm' ,
57
+ 'pnpm' : 'pnpm' ,
58
+ 'yarn' : 'yarn' ,
59
+ 'yarn@berry' : 'yarn' ,
60
+ 'bun' : 'bun' ,
61
+ 'pnpm@6' : 'pnpm' ,
62
+ }
63
+
64
+ if ( agent !== '' && Object . keys ( mapper ) . includes ( agent ) ) {
65
+ flags . manager = mapper [ agent ]
66
+ }
67
+ }
68
+ }
69
+
46
70
const installerArgs = [ 'new' , args . name ]
47
71
48
72
for ( const [ key , value ] of Object . entries ( flags ) ) {
You can’t perform that action at this time.
0 commit comments