Skip to content

Commit

Permalink
fix some liniting and remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Edney committed Jan 10, 2024
1 parent 7405ee1 commit bf240fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default async function run (projectRoot: string, urls: OnPremiseUrls): Pr
}, { onCancel })

if (bugsnagCliNpmTasks) {
await writeToPackageJson(join(projectRoot, 'package.json'), urls[UrlType.UPLOAD], urls[UrlType.BUILD])
await writeToPackageJson(join(projectRoot, 'package.json'), urls[UrlType.UPLOAD], urls[UrlType.BUILD])
}

await prompts({
Expand Down Expand Up @@ -135,30 +135,6 @@ async function installBugsnagCliPackage (projectRoot: string, urls: OnPremiseUrl
logger.success('@bugsnag/cli dependency is installed')
}

async function installJavaScriptPackage (projectRoot: string): Promise<void> {
const alreadyInstalled = await detectInstalled('@bugsnag/source-maps', projectRoot)

if (alreadyInstalled) {
logger.warn('@bugsnag/source-maps is already installed, skipping')
return
}

logger.info('Adding @bugsnag/source-maps dependency')

const packageManager = await guessPackageManager(projectRoot)

const { version } = await prompts({
type: 'text',
name: 'version',
message: 'If you want the latest version of @bugsnag/source-maps hit enter, otherwise type the version you want',
initial: 'latest'
}, { onCancel })

await install(packageManager, '@bugsnag/source-maps', version, true, projectRoot)

logger.success('@bugsnag/source-maps dependency is installed')
}

async function writeToPackageJson (packageJsonPath: string, uploadUrl?: string, buildUrl?: string): Promise<void> {
try {
const data = await fs.readFile(packageJsonPath, 'utf8')
Expand Down
26 changes: 8 additions & 18 deletions packages/react-native-cli/src/lib/Xcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ async function addUploadSourceMapsTask (
): Promise<boolean> {
for (const shellBuildPhaseKey in buildPhaseMap) {
const phase = buildPhaseMap[shellBuildPhaseKey]
if (typeof phase.shellScript === 'string' && phase.shellScript.includes('bugsnag-react-native-xcode.sh') || typeof phase.shellScript === 'string' && phase.shellScript.includes('Upload source maps to Bugsnag')) {
if (typeof phase.shellScript === 'string' && (phase.shellScript.includes('bugsnag-react-native-xcode.sh') || phase.shellScript.includes('Upload source maps to Bugsnag'))) {
logger.warn('An "Upload source maps to Bugsnag" build phase already exists')
return false
}
}

let shellScript = 'npm run bugsnag:upload-ios'
const shellScript = 'npm run bugsnag:upload-ios'

proj.addBuildPhase(
[],
Expand All @@ -74,35 +74,25 @@ async function addUploadSourceMapsTask (
return true
}

function addExtraPackagerArgs (phaseId: string, existingShellScript: string, logger: Logger): [string, boolean] {
const parsedExistingShellScript = JSON.parse(existingShellScript) as string
if (parsedExistingShellScript.includes(EXTRA_PACKAGER_ARGS)) {
logger.warn(`The "Bundle React Native Code and Images" build phase (${phaseId}) already includes the required arguments`)
return [existingShellScript, false]
}
const scriptLines = parsedExistingShellScript.split('\n')
return [JSON.stringify([EXTRA_PACKAGER_ARGS].concat(scriptLines).join('\n')), true]
}

function updateXcodeEnv(projectRoot: string, logger: Logger): boolean {
const searchString = 'SOURCEMAP_FILE=';
function updateXcodeEnv (projectRoot: string, logger: Logger): boolean {
const searchString = 'SOURCEMAP_FILE='
const sourceMapFilePath = 'ios/build/main.jsbundle.map'
const envFilePath = path.join(projectRoot, 'ios', '.xcode.env')

const data = fs.readFile(envFilePath, 'utf8').then(
function (results){
if (results.includes(searchString)) {
logger.warn(`The .xcode.env file already contains a section for "${searchString}"`);
return false;
logger.warn(`The .xcode.env file already contains a section for "${searchString}"`)
return false
} else {
const newData = `${results}\n\n#React Native Source Map File\n${searchString}${sourceMapFilePath}`;
const newData = `${results}\n\n#React Native Source Map File\n${searchString}${sourceMapFilePath}`
fs.writeFile(envFilePath, newData, 'utf8')
return true
}

}).catch(
function (error){
logger.warn(`Error updating the .xcode.env file: ${error}`);
logger.warn(`Error updating the .xcode.env file: ${error}`)
return false
})

Expand Down

0 comments on commit bf240fe

Please sign in to comment.