Skip to content

Commit 9680101

Browse files
committed
fix(ci): update publint fetchPnpmDeps fetcherVersion and apply treefmt
1 parent b5e0434 commit 9680101

6 files changed

Lines changed: 85 additions & 89 deletions

File tree

‎.github/scripts/generate-e2e-fixture.nu‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ def main [out_dir: string] {
44
if ($out_dir | is-empty) {
55
error make {msg: 'usage: generate-e2e-fixture.nu <out-dir>'}
66
}
7-
let fixture_dir = ([$out_dir, projects, preview-e2e-project, preview-e2e-session] | path join)
7+
let fixture_dir = [$out_dir, projects, preview-e2e-project, preview-e2e-session] | path join
88
mkdir $fixture_dir
99
let lines = (0..419 | each {|index|
10-
let day = (($index mod 28) + 1 | into string | fill --alignment right --character '0' --width 2)
10+
let day = ($index mod 28) + 1 | into string | fill --alignment right --character '0' --width 2
1111
[
1212
$"(claude_line $index $day 1 '10:00:00.000Z' 'claude-sonnet-4-20250514' 100 50 25 10 '0.12')"
1313
$"(claude_line $index $day 2 '12:30:00.000Z' 'claude-opus-4-20250514' 200 75 50 20 '0.34')"

‎.github/scripts/upsert-pr-comment.nu‎

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ def main [] {
4545
}
4646
}
4747
def required_env [name: string] {
48-
let value = ($env | get --optional $name)
48+
let value = $env | get --optional $name
4949
if $value == null or ($value | is-empty) {
50-
error make {
51-
msg: $"($name) is required"
52-
}
50+
error make {msg: $"($name) is required"}
5351
}
5452
$value
5553
}
@@ -63,7 +61,13 @@ def gh_api_json [args: list<string>] {
6361
$result.stdout | from json
6462
}
6563
def create_comment [repository: string, pr_number: string, body: string] {
66-
let result = (gh_api_with_body 'POST' $"repos/($repository)/issues/($pr_number)/comments" $body)
64+
let result = (
65+
(gh_api_with_body
66+
'POST'
67+
$"repos/($repository)/issues/($pr_number)/comments"
68+
$body
69+
)
70+
)
6771
if $result.exit_code != 0 {
6872
if (is_comment_write_auth_failure $result.stderr) {
6973
print --stderr $"Skipping PR comment because GitHub token cannot write comments: ($result.stderr | str trim)"
@@ -75,36 +79,26 @@ def create_comment [repository: string, pr_number: string, body: string] {
7579
}
7680
}
7781
def try_update_comment [repository: string, comment_id: int, body: string] {
78-
let result = (gh_api_with_body 'PATCH' $"repos/($repository)/issues/comments/($comment_id)" $body)
82+
let result = (
83+
(gh_api_with_body
84+
'PATCH'
85+
$"repos/($repository)/issues/comments/($comment_id)"
86+
$body
87+
)
88+
)
7989
if $result.exit_code == 0 {
80-
return {
81-
status: 'ok'
82-
result: $result
83-
stderr: $result.stderr
84-
}
90+
return {status: 'ok', result: $result, stderr: $result.stderr}
8591
}
86-
if ($result.stderr =~ 'HTTP 404') {
87-
return {
88-
status: 'missing'
89-
result: $result
90-
stderr: $result.stderr
91-
}
92+
if $result.stderr =~ 'HTTP 404' {
93+
return {status: 'missing', result: $result, stderr: $result.stderr}
9294
}
9395
if (is_comment_write_auth_failure $result.stderr) {
94-
return {
95-
status: 'auth'
96-
result: $result
97-
stderr: $result.stderr
98-
}
99-
}
100-
{
101-
status: 'error'
102-
result: $result
103-
stderr: $result.stderr
96+
return {status: 'auth', result: $result, stderr: $result.stderr}
10497
}
98+
{status: 'error', result: $result, stderr: $result.stderr}
10599
}
106100
def gh_api_with_body [method: string, endpoint: string, body: string] {
107-
let payload = (mktemp -t ccusage-pr-comment.XXXXXX | str trim)
101+
let payload = mktemp -t ccusage-pr-comment.XXXXXX | str trim
108102
{body: $body} | to json | save --force $payload
109103
let args = [
110104
--method

‎apps/ccusage/scripts/ensure-native-binary.nu‎

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,34 @@ def main [] {
1414
} else {
1515
$native_package_root | path join bin $binary_name
1616
}
17-
let cargo_binary = ($repo_root | path join rust target release $binary_name)
17+
let cargo_binary = $repo_root | path join rust target release $binary_name
1818
let version = (expected_version $repo_root)
19-
if ((native_package_includes_binary $native_package_root $binary_name) and (has_expected_version $native_binary $version)) {
19+
if (native_package_includes_binary $native_package_root $binary_name) and (has_expected_version $native_binary $version) {
2020
if not (is_portable_binary $target_platform $native_binary) {
21-
error make {
22-
msg: $"($native_binary) depends on dynamic libraries that do not exist on end-user machines; rebuild it \(Linux packages must be static, macOS packages may only link system dylibs)"
23-
}
21+
error make {msg: $"($native_binary) depends on dynamic libraries that do not exist on end-user machines; rebuild it \(Linux packages must be static, macOS packages may only link system dylibs)"}
2422
}
2523
exit 0
2624
}
2725
^cargo build --manifest-path ($repo_root | path join rust Cargo.toml) --release --bin ccusage
2826
if not (has_expected_version $cargo_binary $version) {
29-
error make {
30-
msg: $"($cargo_binary) did not report version ($version) after cargo build"
31-
}
27+
error make {msg: $"($cargo_binary) did not report version ($version) after cargo build"}
28+
}
29+
}
30+
def node_platform [] {
31+
match $nu.os-info.name {
32+
'macos' => 'darwin'
33+
'linux' => 'linux'
34+
'windows' => 'win32'
35+
$other => $other
36+
}
37+
}
38+
def node_arch [] {
39+
match $nu.os-info.arch {
40+
'aarch64' => 'arm64'
41+
'x86_64' => 'x64'
42+
$other => $other
3243
}
3344
}
34-
def node_platform [] { match $nu.os-info.name {
35-
'macos' => 'darwin'
36-
'linux' => 'linux'
37-
'windows' => 'win32'
38-
$other => $other
39-
} }
40-
def node_arch [] { match $nu.os-info.arch {
41-
'aarch64' => 'arm64'
42-
'x86_64' => 'x64'
43-
$other => $other
44-
} }
4545
def matching_native_package_root [repo_root: path, target_platform: string, target_arch: string] {
4646
let candidates = (glob ($repo_root | path join packages 'ccusage-*' package.json) | each {|package_json_path|
4747
let package_json = (open $package_json_path)
@@ -57,8 +57,8 @@ def matching_native_package_root [repo_root: path, target_platform: string, targ
5757
}
5858
def list_contains [value, needle: string] { (($value | describe) =~ '^list') and ($value | any {|item| $item == $needle }) }
5959
def expected_version [repo_root: path] {
60-
let package_json = (open ($repo_root | path join apps ccusage package.json))
61-
if (($package_json.version? | describe) != 'string') {
60+
let package_json = open ($repo_root | path join apps ccusage package.json)
61+
if ($package_json.version? | describe) != 'string' {
6262
error make {msg: 'apps/ccusage/package.json version is not configured'}
6363
}
6464
$package_json.version
@@ -67,7 +67,7 @@ def native_package_includes_binary [package_root, binary_name: string] {
6767
if $package_root == null {
6868
false
6969
} else {
70-
let package_json_path = ($package_root | path join package.json)
70+
let package_json_path = $package_root | path join package.json
7171
if not ($package_json_path | path exists) {
7272
false
7373
} else {
@@ -89,7 +89,15 @@ def is_portable_binary [target_platform: string, binary] {
8989
if $result.exit_code != 0 {
9090
false
9191
} else {
92-
let dylibs = ($result.stdout | lines | skip 1 | each {|line| $line | str trim } | where {|line| ($line | is-not-empty) } | each {|line| $line | split row --regex '\s+' | get --optional 0 } | where {|dylib| $dylib != null and ($dylib | is-not-empty) })
92+
let dylibs = (
93+
$result.stdout
94+
| lines
95+
| skip 1
96+
| each {|line| $line | str trim }
97+
| where {|line| ($line | is-not-empty) }
98+
| each {|line| $line | split row --regex '\s+' | get --optional 0 }
99+
| where {|dylib| $dylib != null and ($dylib | is-not-empty) }
100+
)
93101
$dylibs | all {|dylib|
94102
$system_dylib_prefixes | any {|prefix| $dylib | str starts-with $prefix }
95103
}
@@ -102,11 +110,16 @@ def has_expected_version [binary, version: string] {
102110
if $binary == null or not ($binary | path exists) {
103111
false
104112
} else {
105-
let result = (run-external $binary '--version' | complete)
113+
let result = run-external $binary '--version' | complete
106114
if $result.exit_code != 0 {
107115
false
108116
} else {
109-
let actual_version = ($result.stdout | str trim | split row --regex '\s+' | last)
117+
let actual_version = (
118+
$result.stdout
119+
| str trim
120+
| split row --regex '\s+'
121+
| last
122+
)
110123
$actual_version == $version
111124
}
112125
}

‎apps/ccusage/scripts/stage-native-package.nu‎

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@ const package_dirs = {
1010
}
1111
def main [--platform: string, --arch: string, --binary: string] {
1212
let key = $"($platform)-($arch)"
13-
let package_dir = ($package_dirs | get -o $key)
13+
let package_dir = $package_dirs | get -o $key
1414
if $package_dir == null {
15-
error make {
16-
msg: $"Unsupported native package target: ($key)"
17-
}
15+
error make {msg: $"Unsupported native package target: ($key)"}
1816
}
19-
let script_dir = ($env.CURRENT_FILE | path dirname)
20-
let repo_root = ([$script_dir, '..', '..', '..'] | path join | path expand)
17+
let script_dir = $env.CURRENT_FILE | path dirname
18+
let repo_root = [$script_dir, '..', '..', '..'] | path join | path expand
2119
let binary_name = if $platform == 'win32' { 'ccusage.exe' } else { 'ccusage' }
22-
let source = ($binary | path expand)
23-
let target_dir = ([$repo_root, 'packages', $package_dir, 'bin'] | path join)
24-
let target = ([$target_dir, $binary_name] | path join)
20+
let source = $binary | path expand
21+
let target_dir = [$repo_root, 'packages', $package_dir, 'bin'] | path join
22+
let target = [$target_dir, $binary_name] | path join
2523
mkdir $target_dir
2624
cp -f $source $target
2725
if $platform != 'win32' {
@@ -33,22 +31,21 @@ def main [--platform: string, --arch: string, --binary: string] {
3331
print $target
3432
}
3533
def rewrite_darwin_system_libraries [binary_path: string] {
36-
let linked = (run-external otool '-L' $binary_path | complete)
34+
let linked = run-external otool '-L' $binary_path | complete
3735
if $linked.exit_code != 0 {
38-
error make {
39-
msg: $"otool failed for ($binary_path)\n($linked.stderr)"
40-
}
36+
error make {msg: $"otool failed for ($binary_path)\n($linked.stderr)"}
4137
}
4238
for line in ($linked.stdout | lines | skip 1) {
4339
let library = (
4440
$line | str trim | split row --regex '\s+' | first
4541
)
4642
if $library =~ '^/nix/store/[^/]+-libiconv-[^/]+/lib/libiconv\.2\.dylib$' {
47-
let rewrite = (run-external install_name_tool '-change' $library /usr/lib/libiconv.2.dylib $binary_path | complete)
43+
let rewrite = (
44+
run-external install_name_tool '-change' $library /usr/lib/libiconv.2.dylib $binary_path
45+
| complete
46+
)
4847
if $rewrite.exit_code != 0 {
49-
error make {
50-
msg: $"install_name_tool failed for ($library)\n($rewrite.stderr)"
51-
}
48+
error make {msg: $"install_name_tool failed for ($library)\n($rewrite.stderr)"}
5249
}
5350
}
5451
}

‎apps/ccusage/scripts/verify-native-package.nu‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,20 @@ def main [] {
88
if ($binary_path | is-empty) {
99
error make {msg: 'Native package binary file is not configured'}
1010
}
11-
let resolved_binary_path = ($binary_path | path expand)
11+
let resolved_binary_path = $binary_path | path expand
1212
try {
1313
if not ($resolved_binary_path | path exists) {
14-
error make {
15-
msg: $"($binary_path) does not exist"
16-
}
14+
error make {msg: $"($binary_path) does not exist"}
1715
}
18-
let entry = (ls $resolved_binary_path | first)
16+
let entry = ls $resolved_binary_path | first
1917
if $entry.type != file {
20-
error make {
21-
msg: $"($binary_path) is not a file"
22-
}
18+
error make {msg: $"($binary_path) is not a file"}
2319
}
2420
if not ($binary_path | str ends-with '.exe') {
25-
let executable = (run-external test '-x' $resolved_binary_path | complete)
21+
let executable = run-external test '-x' $resolved_binary_path | complete
2622
if $executable.exit_code != 0 {
27-
error make {
28-
msg: $"($binary_path) is not executable"
29-
}
23+
error make {msg: $"($binary_path) is not executable"}
3024
}
3125
}
32-
} catch {|err| error make {
33-
msg: $"Native package binary is not ready: ($err.msg)"
34-
} }
26+
} catch {|err| error make {msg: $"Native package binary is not ready: ($err.msg)"} }
3527
}

‎nix/publint.nix‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ stdenvNoCC.mkDerivation (finalAttrs: {
9797
src
9898
;
9999
inherit pnpm;
100-
fetcherVersion = 3;
101-
hash = "sha256-TSLDCjiXj131uLlLNegm6M4cFEgJtjmhNtHDtoHKm6E=";
100+
fetcherVersion = 4;
101+
hash = "sha256-/XJ8DP7884qt1ZrVpJdixIizanQPLUaYyCucwt/SzXc=";
102102
};
103103

104104
dontBuild = true;

0 commit comments

Comments
 (0)