Skip to content

Commit b81d4e4

Browse files
committed
fix: use kebab case for CLI arguments
1 parent a448a7f commit b81d4e4

File tree

3 files changed

+29
-32
lines changed

3 files changed

+29
-32
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const FALLBACK_BOB_VERSION = '0.40.8';
2+
export const FALLBACK_NITRO_MODULES_VERSION = '0.22.1';
3+
export const SUPPORTED_REACT_NATIVE_VERSION = '0.78.2';

packages/create-react-native-library/src/index.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import kleur from 'kleur';
33
import ora from 'ora';
44
import path from 'path';
55
import yargs from 'yargs';
6+
import {
7+
FALLBACK_BOB_VERSION,
8+
FALLBACK_NITRO_MODULES_VERSION,
9+
SUPPORTED_REACT_NATIVE_VERSION,
10+
} from './constants';
611
import { alignDependencyVersionsWithExampleApp } from './exampleApp/dependencies';
712
import generateExampleApp from './exampleApp/generateExampleApp';
813
import {
@@ -20,17 +25,13 @@ import {
2025
import { applyTemplates, generateTemplateConfiguration } from './template';
2126
import { assertNpxExists } from './utils/assert';
2227
import { createInitialGitCommit } from './utils/initialCommit';
23-
import { prompt } from './utils/prompt';
24-
import { resolveNpmPackageVersion } from './utils/resolveNpmPackageVersion';
2528
import {
2629
addNitroDependencyToLocalLibrary,
2730
linkLocalLibrary,
2831
} from './utils/local';
2932
import { determinePackageManager } from './utils/packageManager';
30-
31-
const FALLBACK_BOB_VERSION = '0.40.5';
32-
const FALLBACK_NITRO_MODULES_VERSION = '0.22.1';
33-
const SUPPORTED_REACT_NATIVE_VERSION = '0.78.2';
33+
import { prompt } from './utils/prompt';
34+
import { resolveNpmPackageVersion } from './utils/resolveNpmPackageVersion';
3435

3536
type Args = Partial<Answers> & {
3637
name?: string;
@@ -68,16 +69,10 @@ async function create(_argv: Args) {
6869

6970
const questions = await createQuestions(argv);
7071

71-
const promptAnswers = await prompt<Answers, typeof argv>(questions, argv, {
72+
const answers = await prompt<Answers, typeof argv>(questions, argv, {
7273
interactive: argv.interactive,
7374
});
7475

75-
const answers = {
76-
...promptAnswers,
77-
reactNativeVersion:
78-
promptAnswers.reactNativeVersion ?? SUPPORTED_REACT_NATIVE_VERSION,
79-
};
80-
8176
const bobVersion = await bobVersionPromise;
8277

8378
const nitroModulesVersion =

packages/create-react-native-library/src/input.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import fs from 'fs-extra';
12
import githubUsername from 'github-username';
3+
import path from 'path';
24
import validateNpmPackage from 'validate-npm-package-name';
35
import type yargs from 'yargs';
46
import { version } from '../package.json';
7+
import { SUPPORTED_REACT_NATIVE_VERSION } from './constants';
58
import type { Question } from './utils/prompt';
69
import { spawn } from './utils/spawn';
7-
import fs from 'fs-extra';
8-
import path from 'path';
910

1011
export type ProjectLanguages = 'kotlin-objc' | 'kotlin-swift' | 'js';
1112

@@ -91,59 +92,57 @@ const TYPE_CHOICES: {
9192
];
9293

9394
export const acceptedArgs = {
94-
slug: {
95+
'slug': {
9596
description: 'Name of the npm package',
9697
type: 'string',
9798
},
98-
description: {
99+
'description': {
99100
description: 'Description of the npm package',
100101
type: 'string',
101102
},
102-
authorName: {
103+
'author-name': {
103104
description: 'Name of the package author',
104105
type: 'string',
105106
},
106-
authorEmail: {
107+
'author-email': {
107108
description: 'Email address of the package author',
108109
type: 'string',
109110
},
110-
authorUrl: {
111+
'author-url': {
111112
description: 'URL for the package author',
112113
type: 'string',
113114
},
114-
repoUrl: {
115+
'repo-url': {
115116
description: 'URL for the repository',
116117
type: 'string',
117118
},
118-
languages: {
119+
'languages': {
119120
description: 'Languages you want to use',
120121
choices: LANGUAGE_CHOICES.map(({ value }) => value),
121122
},
122-
type: {
123+
'type': {
123124
description: 'Type of library you want to develop',
124125
choices: TYPE_CHOICES.map(({ value }) => value),
125126
},
126-
reactNativeVersion: {
127-
description: 'Version of React Native to use, uses latest if not specified',
127+
'react-native-version': {
128+
description: 'Version of React Native to use',
128129
type: 'string',
130+
default: SUPPORTED_REACT_NATIVE_VERSION,
129131
},
130-
local: {
132+
'local': {
131133
description: 'Whether to create a local library',
132134
type: 'boolean',
133135
},
134-
example: {
136+
'example': {
135137
description: 'Type of the example app to create',
136138
type: 'string',
137139
choices: EXAMPLE_CHOICES.map(({ value }) => value),
138140
},
139-
interactive: {
141+
'interactive': {
140142
description: 'Whether to run in interactive mode',
141143
type: 'boolean',
142144
},
143-
} as const satisfies Record<
144-
Exclude<keyof Answers, 'name' | 'directory'>,
145-
yargs.Options
146-
>;
145+
} as const satisfies Record<string, yargs.Options>;
147146

148147
export type ExampleApp = 'none' | 'test-app' | 'expo' | 'vanilla';
149148

0 commit comments

Comments
 (0)