Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/blobs/carrier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export async function fetchUpdateConfig(
log(`requestData: ${outFile}`)
await fs.writeFile(outFile, JSON.stringify(Request.toJSON(requestData), null, 4))
}
const encodedRequest = Request.encode(requestData).finish()
const encodedRequest = Buffer.from(Request.encode(requestData).finish())
if (debug) {
const reqFile = path.join(tmpDir, 'encodedRequestData')
await fs.writeFile(reqFile, encodedRequest)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/collect-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ async function runStateCollectionBuild(
break
} catch (e) {
logElapsedTime(buildStart, `${device} phase ${phase} state collection build failed in`)
let stderr = e.message as string
let stderr = (e as Error).message as string
if (stderr !== undefined) {
log(`\n${statusPrefix}stderr:\n` + stderr)
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fetch-build-index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command, Flags } from '@oclif/core'
import { YAMLMap } from 'yaml/types'
import { YAMLMap } from 'yaml'

import assert from 'assert'
import YAML, { Document } from 'yaml'
Expand Down
3 changes: 2 additions & 1 deletion src/commands/update-carrier-settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command, Flags } from '@oclif/core'
import util from 'util'

import { downloadAllConfigs, fetchUpdateConfig, getCarrierSettingsUpdatesDir } from '../blobs/carrier'
import { BUILD_VERSION_SDK_PROP, loadPartitionProps } from '../blobs/props'
Expand Down Expand Up @@ -46,7 +47,7 @@ export default class UpdateCarrierSettings extends Command {
)
let sdkVersion = mapGet(mapGet(stockProps, Partition.System), BUILD_VERSION_SDK_PROP)
const updateConfig = await fetchUpdateConfig(config.device.name, buildId, sdkVersion, flags.debug)
if (flags.debug) log(updateConfig)
if (flags.debug) log(util.inspect(updateConfig, false, Infinity))
await downloadAllConfigs(updateConfig, outDir, flags.debug)
} else {
this.log(`${config.device.name} is not supported due to lack of cellular connectivity`)
Expand Down
11 changes: 6 additions & 5 deletions src/frontend/source.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert'
import { createReadStream, promises as fs } from 'fs'
import { createReadStream, promises as fs, ReadOptionsWithBuffer } from 'fs'
import { FileHandle, FileReadOptions } from 'fs/promises'
import hasha from 'hasha'
import path from 'path'
Expand Down Expand Up @@ -584,11 +584,12 @@ class FdReader extends yauzl.Reader {
// do not initialize buffer contents, assert below ensures that it's fully written out
let buffer = Buffer.allocUnsafe(length)

let opts = {
buffer,
length,
let opts: ReadOptionsWithBuffer<any> = {
buffer: buffer,
length: length,
offset: 0,
position: this.off + start,
} as FileReadOptions
}

assert((await this.fd.read(opts)).bytesRead === length)
return buffer
Expand Down
4 changes: 2 additions & 2 deletions src/images/build-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import assert from 'assert'
import { JSDOM } from 'jsdom'
import fetch from 'node-fetch'
import path from 'path'
import { Document, YAMLMap } from 'yaml'
import { Document as YAMLDocument, YAMLMap } from 'yaml'

import { loadAndMergeConfig } from '../config/config-loader'
import { DeviceBuildId, DeviceConfig, makeDeviceBuildId } from '../config/device'
Expand Down Expand Up @@ -108,7 +108,7 @@ async function fetchBuildIndexInner(
}
}

return new Document().createNode(buildIndex) as YAMLMap
return new YAMLDocument().createNode(buildIndex) as YAMLMap
}

function parseFactoryOrOtaPage(buildIndex: BuildIndex, pageType: string, dom: JSDOM, devices: Set<string>) {
Expand Down
4 changes: 4 additions & 0 deletions src/images/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ async function downloadImageInner(
if (!resp.ok) {
throw new Error(`${resp.status}: ${resp.statusText}; ${image.toString()} `)
}
if (resp.body === null) {
throw new Error(`missing response body for ${image.toString()}`)
}


let downloaded = 0
let totalSizeStr: string | null
Expand Down
2 changes: 1 addition & 1 deletion src/util/exact-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ interface FilterEntries2Result<T> {
hasTransforms: boolean
}

export function filterEntries2<T>(cmd: EntryFilter2Cmd<T>) {
export function filterEntries2<T extends Record<string, unknown>>(cmd: EntryFilter2Cmd<T>) {
let unknownEntries: string[] = []
let filtered: [string, T][] = []
let hasTransforms = false
Expand Down
4 changes: 2 additions & 2 deletions src/util/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function updateStatusLines() {
}
}

let pendingWrites: unknown[] = []
let pendingWrites: (string | Buffer | Uint8Array)[] = []
let currentStatus: string | null = null

let isClearPending = false
Expand Down Expand Up @@ -149,7 +149,7 @@ function write(str: string | Buffer | Uint8Array, callback?: () => void) {
}
}

export function log(str: string | Buffer | DataView) {
export function log(str: string | Buffer | Uint8Array) {
if (currentStatus !== null) {
clearStatusLines()
write(str)
Expand Down