Skip to content

Commit 1924a82

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/autoprefixer-10.6.1
2 parents 8ef3810 + 45aed93 commit 1924a82

6 files changed

Lines changed: 286 additions & 213 deletions

File tree

‎pnpm-lock.yaml‎

Lines changed: 92 additions & 202 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎vscode/extension/src/commands/printEnvironment.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as vscode from 'vscode'
22
import { getSqlmeshEnvironment } from '../utilities/sqlmesh/sqlmesh'
33
import { isErr } from '@bus/result'
44
import { IS_WINDOWS } from '../utilities/isWindows'
5+
import { printEnvironmentCommand } from '../utilities/shellCommand'
56

67
export function printEnvironment() {
78
return async () => {
@@ -23,14 +24,9 @@ export function printEnvironment() {
2324
// Show the terminal
2425
terminal.show()
2526

26-
// Run the appropriate command to display environment variables
27-
if (IS_WINDOWS) {
28-
// On Windows, use 'set' command
29-
terminal.sendText('set')
30-
} else {
31-
// On Unix-like systems, use 'env' command
32-
terminal.sendText('env | sort')
33-
}
27+
// Run the command the user's shell understands, since the terminal is
28+
// opened with the default shell rather than a shell we pick
29+
terminal.sendText(printEnvironmentCommand(vscode.env.shell, IS_WINDOWS))
3430

3531
// Show a notification
3632
vscode.window.showInformationMessage(
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
import { describe, it, expect } from 'vitest'
4+
import { detectShellFamily, printEnvironmentCommand } from './shellCommand'
5+
6+
const POWERSHELL_COMMAND =
7+
"Get-ChildItem Env: | Sort-Object Name | ForEach-Object { '{0}={1}' -f $_.Name, $_.Value }"
8+
9+
describe('detectShellFamily', () => {
10+
it('should detect fish', () => {
11+
expect(detectShellFamily('/usr/bin/fish', false)).toBe('fish')
12+
expect(detectShellFamily('/opt/homebrew/bin/fish', false)).toBe('fish')
13+
})
14+
15+
it('should detect POSIX shells', () => {
16+
expect(detectShellFamily('/bin/bash', false)).toBe('posix')
17+
expect(detectShellFamily('/bin/zsh', false)).toBe('posix')
18+
expect(detectShellFamily('/bin/sh', false)).toBe('posix')
19+
expect(detectShellFamily('/usr/bin/dash', false)).toBe('posix')
20+
expect(detectShellFamily('/usr/bin/ksh', false)).toBe('posix')
21+
})
22+
23+
it('should detect Windows shells, ignoring the executable extension', () => {
24+
expect(detectShellFamily('C:\\Windows\\System32\\cmd.exe', true)).toBe(
25+
'cmd',
26+
)
27+
expect(
28+
detectShellFamily(
29+
'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
30+
true,
31+
),
32+
).toBe('powershell')
33+
expect(
34+
detectShellFamily('C:\\Program Files\\PowerShell\\7\\pwsh.exe', true),
35+
).toBe('powershell')
36+
})
37+
38+
it('should detect a POSIX shell installed on Windows', () => {
39+
expect(
40+
detectShellFamily('C:\\Program Files\\Git\\bin\\bash.exe', true),
41+
).toBe('posix')
42+
})
43+
44+
it('should accept a bare shell name without a path', () => {
45+
expect(detectShellFamily('fish', false)).toBe('fish')
46+
expect(detectShellFamily('pwsh', false)).toBe('powershell')
47+
})
48+
49+
it('should ignore the case of the shell name', () => {
50+
expect(detectShellFamily('/usr/bin/FISH', false)).toBe('fish')
51+
expect(detectShellFamily('C:\\WINDOWS\\SYSTEM32\\CMD.EXE', true)).toBe(
52+
'cmd',
53+
)
54+
})
55+
56+
it('should fall back on the platform for an unknown shell', () => {
57+
expect(detectShellFamily('/usr/bin/elvish', false)).toBe('posix')
58+
expect(detectShellFamily('C:\\tools\\elvish.exe', true)).toBe('cmd')
59+
})
60+
61+
it('should fall back on the platform when no shell is reported', () => {
62+
expect(detectShellFamily('', false)).toBe('posix')
63+
expect(detectShellFamily('', true)).toBe('cmd')
64+
expect(detectShellFamily(undefined, false)).toBe('posix')
65+
expect(detectShellFamily(undefined, true)).toBe('cmd')
66+
})
67+
})
68+
69+
describe('printEnvironmentCommand', () => {
70+
it('should use the exported-only set in fish', () => {
71+
expect(printEnvironmentCommand('/usr/bin/fish', false)).toBe('set -x')
72+
})
73+
74+
it('should use env | sort in POSIX shells', () => {
75+
expect(printEnvironmentCommand('/bin/bash', false)).toBe('env | sort')
76+
expect(printEnvironmentCommand('/bin/zsh', false)).toBe('env | sort')
77+
expect(printEnvironmentCommand('/bin/sh', false)).toBe('env | sort')
78+
})
79+
80+
it('should use set in cmd', () => {
81+
expect(
82+
printEnvironmentCommand('C:\\Windows\\System32\\cmd.exe', true),
83+
).toBe('set')
84+
})
85+
86+
it('should not use set in PowerShell, where it prompts for a variable name', () => {
87+
expect(
88+
printEnvironmentCommand(
89+
'C:\\Program Files\\PowerShell\\7\\pwsh.exe',
90+
true,
91+
),
92+
).toBe(POWERSHELL_COMMAND)
93+
})
94+
95+
it('should use the PowerShell command for pwsh off Windows', () => {
96+
expect(printEnvironmentCommand('/usr/local/bin/pwsh', false)).toBe(
97+
POWERSHELL_COMMAND,
98+
)
99+
expect(printEnvironmentCommand('pwsh', false)).toBe(POWERSHELL_COMMAND)
100+
})
101+
102+
it('should keep the previous behaviour when the shell is unknown', () => {
103+
expect(printEnvironmentCommand(undefined, false)).toBe('env | sort')
104+
expect(printEnvironmentCommand(undefined, true)).toBe('set')
105+
})
106+
})
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
/**
4+
* The shell families we know how to print environment variables in.
5+
*/
6+
export type ShellFamily = 'fish' | 'powershell' | 'cmd' | 'posix'
7+
8+
/**
9+
* Commands that list the environment variables of the current shell, one per
10+
* shell family.
11+
*
12+
* `set -x` is fish's exported-only listing, which matches what the other
13+
* families print; a bare `set` would also include shell-local variables.
14+
* PowerShell formats each variable itself because the default table view
15+
* truncates values at the console width.
16+
*/
17+
const PRINT_ENVIRONMENT_COMMANDS: Record<ShellFamily, string> = {
18+
fish: 'set -x',
19+
powershell:
20+
"Get-ChildItem Env: | Sort-Object Name | ForEach-Object { '{0}={1}' -f $_.Name, $_.Value }",
21+
cmd: 'set',
22+
posix: 'env | sort',
23+
}
24+
25+
const SHELL_FAMILIES_BY_NAME: Record<string, ShellFamily> = {
26+
fish: 'fish',
27+
powershell: 'powershell',
28+
pwsh: 'powershell',
29+
cmd: 'cmd',
30+
bash: 'posix',
31+
zsh: 'posix',
32+
sh: 'posix',
33+
dash: 'posix',
34+
ksh: 'posix',
35+
ash: 'posix',
36+
}
37+
38+
/**
39+
* Extracts the executable name from a shell path, which may use either
40+
* separator and may carry a Windows executable extension.
41+
*/
42+
const shellName = (shellPath: string): string => {
43+
const base = shellPath.split(/[\\/]/).pop() ?? ''
44+
return base.toLowerCase().replace(/\.exe$/, '')
45+
}
46+
47+
/**
48+
* Resolves a shell path to the family whose syntax it accepts.
49+
*
50+
* Unrecognized shells fall back on the platform default, which keeps POSIX
51+
* shells we have not listed working.
52+
*
53+
* @param shellPath The path reported by `vscode.env.shell`, which is empty in
54+
* environments without a shell
55+
* @param isWindows Whether the extension host runs on Windows
56+
*/
57+
export const detectShellFamily = (
58+
shellPath: string | undefined,
59+
isWindows: boolean,
60+
): ShellFamily => {
61+
const family = shellPath
62+
? SHELL_FAMILIES_BY_NAME[shellName(shellPath)]
63+
: undefined
64+
if (family) {
65+
return family
66+
}
67+
return isWindows ? 'cmd' : 'posix'
68+
}
69+
70+
/**
71+
* Returns the command that prints all environment variables in the given
72+
* shell.
73+
*
74+
* @param shellPath The path reported by `vscode.env.shell`, which is empty in
75+
* environments without a shell
76+
* @param isWindows Whether the extension host runs on Windows
77+
*/
78+
export const printEnvironmentCommand = (
79+
shellPath: string | undefined,
80+
isWindows: boolean,
81+
): string => PRINT_ENVIRONMENT_COMMANDS[detectShellFamily(shellPath, isWindows)]

‎vscode/react/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@tanstack/react-router-devtools": "^1.131.26",
2626
"@tanstack/react-virtual": "^3.13.12",
2727
"@tanstack/router-plugin": "^1.129.8",
28-
"apache-arrow": "^19.0.1",
28+
"apache-arrow": "^21.2.0",
2929
"clsx": "^2.1.1",
3030
"elkjs": "^0.8.2",
3131
"orval": "^7.10.0",
@@ -56,6 +56,6 @@
5656
"typescript": "^5.8.3",
5757
"vite": "^6.3.5",
5858
"vitest": "^3.2.4",
59-
"web-vitals": "^4.2.4"
59+
"web-vitals": "^6.2.2"
6060
}
6161
}

‎web/client/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@tanstack/react-virtual": "^3.13.12",
3535
"@uidotdev/usehooks": "^2.4.1",
3636
"@uiw/react-codemirror": "^4.24.1",
37-
"apache-arrow": "^19.0.1",
37+
"apache-arrow": "^21.2.0",
3838
"clsx": "^2.1.1",
3939
"diff": "^8.0.2",
4040
"elkjs": "^0.8.2",

0 commit comments

Comments
 (0)