Skip to content

Commit eacfbe0

Browse files
committed
fix: add reinstallNodeModulesCommand arg to cli options
1 parent 74755ee commit eacfbe0

File tree

5 files changed

+17
-24
lines changed

5 files changed

+17
-24
lines changed

src/bundle/bundle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const bundleReactNative = async (config: BundlerConfig, shouldBuildSourceMaps?:
5454
mkdir(outputDir)
5555
mkdir(path.dirname(sourcemapOutput))
5656

57-
info(`Using ${config.reinstallNodeModulesCommand} to install node modules`)
57+
info(`Using '${config.reinstallNodeModulesCommand}' to install node modules`)
5858
await execCommand(config.reinstallNodeModulesCommand)
5959

6060
await runReactNativeBundleCommand(

src/bundle/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ export function buildBundleConfig(args: CommandArgs): BundlerConfig {
8888
outputDir: Path.join(tmpdir(), 'codepush-diff'),
8989
sourcemapOutputDir: Path.join(tmpdir(), args.sourcemapOutput ?? 'codepush-diff-sourcemap'),
9090
bundleName: os === 'ios' ? 'main.jsbundle' : `index.${os}.bundle`,
91-
reinstallNodeModulesCommand: installNodeModulesCommand(),
9291
...args,
9392
os,
9493
entryFile: args.entryFile ?? defaultEntryFile(os),
94+
reinstallNodeModulesCommand: args.reinstallNodeModulesCommand ?? installNodeModulesCommand(),
9595
}
9696
}

src/cli/appcenterArgs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Argv } from 'yargs'
22

3-
export const appcenterArgs = (yargs: Argv<{}>) =>
3+
export const appcenterArgs = <T = {}>(yargs: Argv<T>) =>
44
yargs
55
.option('deployment-name', { alias: 'd', default: 'Staging', type: 'string' })
66
.option('description', { type: 'string' })

src/cli/bundleArgs.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { Argv } from 'yargs'
2+
3+
export const bundleArgs = <T = {}>(yargs: Argv<T>) =>
4+
yargs
5+
.option('base', { type: 'string', demandOption: true })
6+
.option('reinstallNodeModulesCommand', { type: 'string', alias: ['npm'] })
7+
.option('rest', { type: 'string', default: '' })

src/cli/index.ts

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,18 @@ import { appcenterArgs } from './appcenterArgs'
66
import { buildBundleConfig, getAppVersion, info } from '../bundle/utils'
77
import { bundle } from '../bundle/bundle'
88
import { execSync } from 'child_process'
9+
import { bundleArgs } from './bundleArgs'
910

1011
yargs(hideBin(process.argv))
11-
.command(
12-
'target <app>',
13-
'Get the version of the app that will be uploaded to AppCenter.',
14-
(yargs) =>
15-
appcenterArgs(yargs).positional('app', { type: 'string', demandOption: true, alias: ['platform', 'os'] }),
16-
async (args) => {
17-
console.log(args)
18-
const bundlerConfig = buildBundleConfig(args)
19-
const version = await getAppVersion(bundlerConfig)
20-
21-
console.log(version)
22-
}
23-
)
2412
.command(
2513
'bundle <app>',
2614
'Bundle the app for release.',
2715
(yargs) =>
28-
appcenterArgs(yargs)
29-
.positional('app', { type: 'string', demandOption: true, alias: ['platform', 'os'] })
30-
.option('base', { type: 'string', demandOption: true }),
16+
bundleArgs(appcenterArgs(yargs)).positional('app', {
17+
type: 'string',
18+
demandOption: true,
19+
alias: ['platform', 'os'],
20+
}),
3121
async (args) => {
3222
const result = await bundle({ ...args })
3323
console.log(result)
@@ -36,11 +26,7 @@ yargs(hideBin(process.argv))
3626
.command(
3727
'release-react',
3828
'Build and release a React Native app to AppCenter.',
39-
(yargs) =>
40-
appcenterArgs(yargs)
41-
.option('app', { type: 'string', demandOption: true, alias: ['a'] })
42-
.option('base', { type: 'string', demandOption: true })
43-
.option('rest', { type: 'string', default: '' }),
29+
(yargs) => bundleArgs(appcenterArgs(yargs)).option('app', { type: 'string', demandOption: true, alias: ['a'] }),
4430
async (args) => {
4531
const bundlerConfig = buildBundleConfig({ ...args })
4632
const version = args.version ?? (await getAppVersion(bundlerConfig))

0 commit comments

Comments
 (0)