Skip to content

Commit 21205c0

Browse files
authored
Merge pull request #1090 from rgoldberg/1089-pkg-installer
Update pkg installer for wrapper shell script
2 parents 6c000fb + bdb9197 commit 21205c0

5 files changed

Lines changed: 41 additions & 19 deletions

File tree

Scripts/_setup_script

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ unset KEYBOARD_HACK
3636
unset TMPSUFFIX
3737
unset WORDCHARS
3838

39-
mas_dir="${0:A:h:h}"
39+
mas_folder="${0:A:h:h}"
4040

41-
if ! cd -- "${mas_dir}"; then
42-
printf $'Error: Failed to cd into mas directory: %s\n' "${mas_dir}" >&2
41+
if ! cd -- "${mas_folder}"; then
42+
printf $'Error: Failed to cd into mas folder: %s\n' "${mas_folder}" >&2
4343
exit 1
4444
fi
4545

Scripts/clean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# Copyright © 2025 mas-cli. All rights reserved.
77
#
8-
# Deletes the build directory & other generated files.
8+
# Deletes the build folder & other generated files.
99
#
1010

1111
. "${0:A:h}/_setup_script"

Scripts/package

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,36 @@ export MAS_DO_NOT_PRINT_NOTICE=
1616
Scripts/build "${1:-}" -c release "${@:2}"
1717
unset MAS_DO_NOT_PRINT_NOTICE
1818

19-
build_dir=.build
20-
destination_dir="${build_dir}/destination"
21-
mas_executable="${destination_dir}/mas"
19+
build_folder=.build
20+
destination_folder="${build_folder}/destination"
21+
installation_folder=/usr/local/opt/mas
22+
installation_staging_folder="${destination_folder}${installation_folder}"
23+
usr_local_bin_staging_folder="${destination_folder}/usr/local/bin"
2224
version="$(Scripts/version)"
2325

24-
mkdir -p "${destination_dir}"
25-
ln -f "$(swift build -c release --show-bin-path "${@:2}")/mas" "${mas_executable}"
26+
swift package generate-manual
27+
28+
mkdir -p "${installation_staging_folder}/bin"
29+
mkdir -p "${installation_staging_folder}/etc/bash_completion.d"
30+
mkdir -p "${installation_staging_folder}/share/fish/vendor_completions.d"
31+
mkdir -p "${installation_staging_folder}/share/man/man1"
32+
mkdir -p "${usr_local_bin_staging_folder}"
33+
34+
cp LICENSE README.md "${installation_staging_folder}"
35+
cp Scripts/mas "${installation_staging_folder}/bin/mas"
36+
cp contrib/completion/mas-completion.bash "${installation_staging_folder}/etc/bash_completion.d/mas"
37+
cp contrib/completion/mas.fish "${installation_staging_folder}/share/fish/vendor_completions.d/mas.fish"
38+
ln -f "$(swift build -c release --show-bin-path "${@:2}")/mas" "${installation_staging_folder}/bin/mas-bin"
39+
ln -f .build/plugins/GenerateManual/outputs/mas/mas.1 "${installation_staging_folder}/share/man/man1/mas.1"
40+
41+
ln -fs "${installation_folder}/bin/mas" "${usr_local_bin_staging_folder}/mas"
2642

2743
pkgbuild\
2844
--identifier io.github.mas-cli.mas\
29-
--install-location /usr/local/bin\
45+
--install-location /\
3046
--version "${version}"\
31-
--root "${destination_dir}"\
32-
"${build_dir}/mas_components.pkg"
47+
--root "${destination_folder}"\
48+
"${build_folder}/mas_components.pkg"
3349

3450
# shellcheck disable=SC1036
3551
productbuild\
@@ -60,5 +76,5 @@ productbuild\
6076
</installer-gui-script>
6177
END
6278
)\
63-
--package-path "${build_dir}"\
64-
"${build_dir}/mas-${version}-${${(s: :o)$(lipo -archs "${mas_executable}")}// /-}.pkg"
79+
--package-path "${build_folder}"\
80+
"${build_folder}/mas-${version}-${${(s: :o)$(lipo -archs "${installation_staging_folder}/bin/mas-bin")}// /-}.pkg"

Sources/mas/AppStore/DownloadQueueObserver.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ final class DownloadQueueObserver: CKDownloadQueueObserver {
264264
}
265265
guard
266266
let appFolderURLResult = appFolderURLRegex // swiftformat:disable indent
267-
.matches(in: standardErrorText, range: NSRange(location: 0, length: standardErrorText.count))
268-
.first,
267+
.firstMatch(in: standardErrorText, range: NSRange(location: 0, length: standardErrorText.count)),
269268
let appFolderURLNSRange = appFolderURLResult.range(at: 1) as NSRange?,
270269
appFolderURLNSRange.location != NSNotFound,
271270
let appFolderURLRange = Range(appFolderURLNSRange, in: standardErrorText)

Sources/mas/Commands/Lookup.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
internal import ArgumentParser
99
private import Foundation
10+
private import ObjectiveC
1011

1112
extension MAS {
1213
/// Outputs app information from the App Store.
@@ -41,7 +42,7 @@ extension MAS {
4142
"""
4243
\(catalogApp.name) \(catalogApp.version) [\(catalogApp.formattedPrice)]
4344
By: \(catalogApp.sellerName)
44-
Released: \(catalogApp.releaseDate.humanReadableDate)
45+
Released: \(catalogApp.releaseDate.isoCalendarDate)
4546
Minimum OS: \(catalogApp.minimumOSVersion)
4647
Size: \(catalogApp.fileSizeBytes.humanReadableSize)
4748
From: \(catalogApp.appStorePageURL)
@@ -55,10 +56,16 @@ extension MAS {
5556

5657
private extension String {
5758
var humanReadableSize: Self {
58-
Int64(self).map { ByteCountFormatter.string(fromByteCount: $0, countStyle: .file) } ?? self
59+
Int64(self).map { size in
60+
let formatter = ByteCountFormatter()
61+
formatter.allowedUnits = .useMB
62+
formatter.allowsNonnumericFormatting = false
63+
return formatter.string(fromByteCount: size)
64+
}
65+
?? self // swiftformat:disable:this indent
5966
}
6067

61-
var humanReadableDate: Self {
68+
var isoCalendarDate: Self {
6269
ISO8601DateFormatter().date(from: self).map { date in
6370
ISO8601DateFormatter.string(from: date, timeZone: .current, formatOptions: [.withFullDate])
6471
}

0 commit comments

Comments
 (0)