Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ux improvements to update command #844

Merged
merged 1 commit into from
Jun 13, 2024
Merged
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/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class UpdateCommand extends Command {
version: Flags.string({
char: 'v',
description: 'Install a specific version.',
exclusive: ['interactive', 'force'],
exclusive: ['interactive'],
}),
}

Expand Down
7 changes: 4 additions & 3 deletions src/tar.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import makeDebug from 'debug'
import crypto from 'node:crypto'
import {existsSync} from 'node:fs'
import {rename, rm} from 'node:fs/promises'
import {join} from 'node:path'
import zlib from 'node:zlib'
import {Headers, extract as tarExtract} from 'tar-fs'

import {touch} from './util.js'

const debug = makeDebug('oclif-update')
import crypto from 'node:crypto'
import zlib from 'node:zlib'
import {Headers, extract as tarExtract} from 'tar-fs'

const ignore = (_name: string, header?: Headers) => {
switch (header?.type) {
Expand Down
8 changes: 5 additions & 3 deletions src/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ const fetchChannelManifest = async (channel: string, config: Config): Promise<In
try {
return await fetchManifest(s3Key, config)
} catch (error: unknown) {
const {statusCode} = error as {statusCode: number}
if (statusCode === 403) throw new Error(`HTTP 403: Invalid channel ${channel}`)
const {code, statusCode} = error as {code?: string; statusCode?: number}
if (statusCode === 403 || code === 'ERR_NON_2XX_3XX_RESPONSE')
throw new Error(`HTTP 403: Invalid channel ${channel}`)
throw error
}
}
Expand Down Expand Up @@ -405,7 +406,7 @@ const downloadAndExtract = async (
stream.on('downloadProgress', (progress) => {
ux.action.status =
progress.percent === 1
? `${filesize(progress.transferred)}/${filesize(progress.total)} - Extracting`
? `${filesize(progress.transferred)}/${filesize(progress.total)} - Finishing up...`
: `${filesize(progress.transferred)}/${filesize(progress.total)}`
})
}
Expand All @@ -415,6 +416,7 @@ const downloadAndExtract = async (
}

const determineChannel = async ({config, version}: {config: Config; version?: string}): Promise<string> => {
ux.action.status = `Determining channel for ${version}`
const channelPath = join(config.dataDir, 'channel')

const channel = existsSync(channelPath) ? (await readFile(channelPath, 'utf8')).trim() : 'stable'
Expand Down