Fix App Bundle APKs not being properly signed on Windows

Fixes #55
This commit is contained in:
Niklas Higi
2021-07-06 10:25:43 +02:00
parent 9f589c72ef
commit 3dadf3ee4a
3 changed files with 16 additions and 8 deletions
+2 -1
View File
@@ -7,6 +7,7 @@ import Listr = require('listr')
import patchApk from './patch-apk'
import { TaskOptions } from './cli'
import observeAsync from './utils/observe-async'
import buildGlob from './utils/build-glob'
export function patchXapkBundle(options: TaskOptions) {
return patchAppBundle(options, { isXapk: true })
@@ -55,7 +56,7 @@ function patchAppBundle(options: TaskOptions, { isXapk }: { isXapk: boolean }) {
title: 'Signing APKs',
task: () =>
observeAsync(async log => {
const apkFiles = await globby(path.join(bundleDir, '**/*.apk'))
const apkFiles = await globby(buildGlob(bundleDir, '**/*.apk'))
await uberApkSigner
.sign(apkFiles, { zipalign: false })
+3 -7
View File
@@ -1,25 +1,21 @@
import * as path from 'path'
import globby = require('globby')
import { ListrTaskWrapper } from 'listr'
import observeAsync from '../utils/observe-async'
import processSmaliFile from './smali/process-file'
import buildGlob from '../utils/build-glob'
export default async function disableCertificatePinning(
directoryPath: string,
task: ListrTaskWrapper,
) {
return observeAsync(async log => {
// Convert Windows path (using backslashes) to POSIX path (using slashes)
const directoryPathPosix = directoryPath
.split(path.sep)
.join(path.posix.sep)
const globPattern = path.posix.join(directoryPathPosix, 'smali*/**/*.smali')
const smaliGlob = buildGlob(directoryPath, 'smali*/**/*.smali')
let pinningFound = false
log('Scanning Smali files...')
for await (const filePathChunk of globby.stream(globPattern)) {
for await (const filePathChunk of globby.stream(smaliGlob)) {
// Required because Node.js streams are not typed as generics
const filePath = filePathChunk as string
+11
View File
@@ -0,0 +1,11 @@
import * as path from 'path'
/** Build a glob pattern that works on POSIX and Windows. */
export default function buildGlob(...components: string[]) {
// Convert Windows path (using backslashes) to POSIX path (using slashes)
const unixComponents = components.map(component =>
component.split(path.sep).join(path.posix.sep),
)
return path.posix.join(...unixComponents)
}