Skip to content

Commit 947a0d6

Browse files
authored
Merge pull request #10 from sweatco/fix/cli-arg-types
fix: fix cli args
2 parents 9ca8830 + 87da51f commit 947a0d6

4 files changed

Lines changed: 17 additions & 15 deletions

File tree

src/bundle/assetCodepushDiffPlugin.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ interface DiffAssetData extends AssetData {
99
mainBundleAssets?: MainAssets
1010
}
1111

12-
let hashes: Hashes = {}
13-
const CHANGED_ASSETS_PATH: string | undefined = process.env.CHANGED_ASSETS_PATH
12+
let baseHashes: Hashes = {}
13+
const BASE_ASSETS_PATH: string | undefined = process.env.BASE_ASSETS_PATH
1414
const PLATFORM: string | undefined = process.env.CODE_PUSH_PLATFORM
1515

16-
if (CHANGED_ASSETS_PATH) {
17-
const json = fs.readFileSync(CHANGED_ASSETS_PATH, 'utf-8')
18-
hashes = JSON.parse(json)
16+
if (BASE_ASSETS_PATH) {
17+
const json = fs.readFileSync(BASE_ASSETS_PATH, 'utf-8')
18+
baseHashes = JSON.parse(json)
1919
}
2020

2121
export async function assetCodepushDiffPlugin(assetData: DiffAssetData) {
@@ -30,7 +30,7 @@ export async function assetCodepushDiffPlugin(assetData: DiffAssetData) {
3030
const scale = scales[i]
3131
if (file != null && scale != null) {
3232
const hash = await fileHash(file)
33-
const baselineFile = hashes[hash]
33+
const baselineFile = baseHashes[hash]
3434
if (baselineFile) {
3535
assets[scale] = mainAssetPath(baselineFile)
3636
}

src/bundle/bundle.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const bundleReactNative = async (config: BundlerConfig, shouldBuildSourceMaps?:
4848
extraHermesFlags = [],
4949
useHermes = true,
5050
outputDir,
51+
development,
5152
} = config
5253
rmRf(outputDir)
5354
mkdir(outputDir)
@@ -59,7 +60,7 @@ const bundleReactNative = async (config: BundlerConfig, shouldBuildSourceMaps?:
5960
metroBundle({
6061
bundleCommand,
6162
bundleName,
62-
development: false,
63+
development,
6364
entryFile,
6465
outputDir,
6566
platform: os,
@@ -87,14 +88,14 @@ const checkoutAndBuild = async (bundlerConfig: BundlerConfig, commit: string) =>
8788
}
8889

8990
const readBaseHashes = async (bundlerConfig: BundlerConfig, base: string): Promise<Hashes> => {
90-
if (!process.env.CHANGED_ASSETS_PATH) {
91+
if (!process.env.BASE_ASSETS_PATH) {
9192
info(`Bundling for ${base}`)
9293
const baseOutput = await checkoutAndBuild(bundlerConfig, base)
9394
const baseHashes = await hashes(baseOutput.outputDir)
94-
const changedAssetsPath = path.join(tmpdir(), 'changed-assets.json')
95-
fs.writeFileSync(changedAssetsPath, JSON.stringify(baseHashes))
96-
process.env.CHANGED_ASSETS_PATH = changedAssetsPath
95+
const baseAssetsPath = path.join(tmpdir(), 'base-assets.json')
96+
fs.writeFileSync(baseAssetsPath, JSON.stringify(baseHashes))
97+
process.env.BASE_ASSETS_PATH = baseAssetsPath
9798
}
9899

99-
return JSON.parse(fs.readFileSync(process.env.CHANGED_ASSETS_PATH, 'utf8'))
100+
return JSON.parse(fs.readFileSync(process.env.BASE_ASSETS_PATH, 'utf8'))
100101
}

src/bundle/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface BundlerConfig {
2323
useHermes?: boolean
2424
extraHermesFlags?: string[]
2525
bundleCommand?: string
26+
development?: boolean
2627
}
2728

2829
type Config = Partial<BundlerConfig> & VersionSearchParams

src/cli/appcenterArgs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Argv } from 'yargs'
1+
import { type Argv } from 'yargs'
22

33
export const appcenterArgs = <T = {}>(yargs: Argv<T>) =>
44
yargs
@@ -16,7 +16,7 @@ export const appcenterArgs = <T = {}>(yargs: Argv<T>) =>
1616
alias: 'b',
1717
type: 'string',
1818
})
19-
.option('development', { type: 'string' })
19+
.option('development', { type: 'boolean', default: false })
2020
.option('entry-file', { alias: 'e', type: 'string' })
2121
.option('gradle-file', { alias: 'g', type: 'string' })
2222
.option('pod-file', { type: 'string' })
@@ -30,5 +30,5 @@ export const appcenterArgs = <T = {}>(yargs: Argv<T>) =>
3030
.option('output-dir', { alias: ['o', 'output-path'], type: 'string' })
3131
.option('extra-bundler-option', { alias: ['extra-bundler-options'], default: [], type: 'array' })
3232
.option('extra-hermes-flag', { alias: ['extra-hermes-flags'], type: 'array', default: [] })
33-
.option('use-hermes', { default: true })
33+
.option('use-hermes', { default: true, type: 'boolean' })
3434
.option('disable-duplicate-release-error', { type: 'boolean', default: true })

0 commit comments

Comments
 (0)