Skip to content
Closed
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
5 changes: 5 additions & 0 deletions .changeset/pr-1108.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sanity/cli': patch
---

Update @sanity/runtime-cli to 15.1.1 to fix terminal width detection in non-TTY environments.
2 changes: 1 addition & 1 deletion packages/@sanity/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"@sanity/id-utils": "^1.0.0",
"@sanity/import": "^6.0.1",
"@sanity/migrate": "^6.1.2",
"@sanity/runtime-cli": "^15.0.2",
"@sanity/runtime-cli": "^15.1.1",
"@sanity/schema": "catalog:",
"@sanity/telemetry": "catalog:",
"@sanity/template-validator": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {getUserConfig, isCi} from '@sanity/cli-core'
import {testFixture, testHook} from '@sanity/cli-test'
import {afterEach, beforeEach, describe, expect, test, vi} from 'vitest'
import {afterAll, afterEach, beforeEach, describe, expect, test, vi} from 'vitest'

import {getCommandAndConfig} from '../../../../test/helpers/getCommandAndConfig.js'
import {checkForUpdates} from '../checkForUpdates.js'
Expand Down Expand Up @@ -55,7 +55,26 @@ vi.mock('../../../util/update/resolveRunnerPackage.js', () => ({

const mockIsCi = vi.mocked(isCi)
const originalIsTTY = process.stdout.isTTY
const originalStdoutGetWindowSize = process.stdout.getWindowSize
const originalStderrGetWindowSize = process.stderr.getWindowSize
const originalArgv1 = process.argv[1]
const windowSize: [number, number] = [80, 24]

function mockGetWindowSize(stream: NodeJS.WriteStream): void {
stream.getWindowSize ||= () => windowSize
vi.spyOn(stream, 'getWindowSize').mockReturnValue(windowSize)
}

function restoreGetWindowSize(
stream: NodeJS.WriteStream,
getWindowSize: NodeJS.WriteStream['getWindowSize'] | undefined,
): void {
if (getWindowSize) {
stream.getWindowSize = getWindowSize
} else {
Reflect.deleteProperty(stream, 'getWindowSize')
}
}

function setCachedLatestVersion(options: {
key?: string
Expand Down Expand Up @@ -85,6 +104,8 @@ describe('#checkForUpdates', () => {
packageName: '@sanity/cli',
})
process.stdout.isTTY = true
mockGetWindowSize(process.stdout)
mockGetWindowSize(process.stderr)
process.argv[1] = originalArgv1

mockConfigStore.clear()
Expand All @@ -96,6 +117,11 @@ describe('#checkForUpdates', () => {
process.argv[1] = originalArgv1
})

afterAll(() => {
restoreGetWindowSize(process.stdout, originalStdoutGetWindowSize)
restoreGetWindowSize(process.stderr, originalStderrGetWindowSize)
})

test('returns early if running on CI', async () => {
const {config} = await getCommandAndConfig('help')
mockIsCi.mockReturnValue(true)
Expand Down
136 changes: 117 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading