-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Expand file tree
/
Copy pathprepare_bundled_resources
More file actions
executable file
·159 lines (140 loc) · 6.14 KB
/
prepare_bundled_resources
File metadata and controls
executable file
·159 lines (140 loc) · 6.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env bash
#
# Prepares bundled resources for distribution.
#
# This script copies resources that should be bundled with Warp into a
# destination directory. It is used by macOS and Linux build scripts.
#
# Usage:
# prepare_bundled_resources <destination_directory> [channel] [cargo_profile]
#
# Arguments:
# destination_directory: The directory where resources should be installed.
# Resources will be copied to subdirectories within
# this path (e.g., $DEST_DIR/skills).
# channel: (Optional) Release channel (local, dev, preview,
# stable). Used to include channel-gated skills.
# cargo_profile: (Optional) Cargo build profile to use when
# generating the settings schema. Reusing the same
# profile as the main build avoids recompiling deps.
#
# Environment variables:
# SKIP_SETTINGS_SCHEMA: Set to "1" to skip generating the JSON settings
# schema. By default the schema is always generated
# so that production bundles never accidentally omit it.
# SETTINGS_SCHEMA_CACHE: Path to a cache file for the generated schema.
# When set, the first invocation generates the schema
# and saves a copy to this path; subsequent invocations
# copy from the cache instead of regenerating. This
# avoids redundant compilations when bundling multiple
# package formats for the same channel.
set -e
if [ $# -lt 1 ] || [ $# -gt 3 ]; then
echo "Error: Expected 1-3 arguments but received $#" >&2
echo "Usage: $0 <destination_directory> [channel] [cargo_profile]" >&2
exit 1
fi
DEST_DIR="$1"
CHANNEL="${2:-}"
CARGO_PROFILE="${3:-}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
RESOURCES_SRC="$REPO_ROOT/resources"
# Validate that the source resources directory exists
if [ ! -d "$RESOURCES_SRC" ]; then
echo "Error: Resources directory not found at $RESOURCES_SRC" >&2
exit 1
fi
# Create the destination directory if it doesn't exist
mkdir -p "$DEST_DIR"
# Copy bundled resources
if [ -d "$RESOURCES_SRC/bundled" ]; then
echo "Copying bundled resources to $DEST_DIR/bundled"
rm -rf "$DEST_DIR/bundled"
cp -R "$RESOURCES_SRC/bundled" "$DEST_DIR/bundled"
else
echo "Warning: No bundled directory found at $RESOURCES_SRC/bundled" >&2
fi
if [ -n "$GIT_RELEASE_TAG" ]; then
VERSION_METADATA_DIR="$DEST_DIR/bundled/metadata"
VERSION_METADATA_PATH="$VERSION_METADATA_DIR/version.json"
echo "Writing bundled Warp version metadata to $VERSION_METADATA_PATH"
mkdir -p "$VERSION_METADATA_DIR"
printf '{\n "warp_version": "%s"\n}\n' "$GIT_RELEASE_TAG" > "$VERSION_METADATA_PATH"
fi
# Copy channel-gated skills matching the current release channel.
GATED_SRC="$REPO_ROOT/resources/channel-gated-skills"
DEST_SKILLS="$DEST_DIR/bundled/skills"
if [ -n "$CHANNEL" ] && [ -d "$GATED_SRC" ]; then
echo "Copying channel-gated skills for channel '$CHANNEL'..."
"$SCRIPT_DIR/copy_conditional_skills" \
"$CHANNEL" \
"$GATED_SRC" \
"$DEST_SKILLS"
fi
# Generate third-party license attribution.
#
# Additional (non-Cargo) third-party license files to include in the output.
# Each entry is: "Component Name|License Identifier|path/to/LICENSE/relative/to/repo/root"
# When adding a new third-party component to the bundle, add its license file
# to the repo alongside the component and add an entry here.
ADDITIONAL_LICENSES=(
"Alacritty (alacritty_terminal)|Apache-2.0|crates/warp_terminal/src/model/LICENSE-ALACRITTY"
"Hack Font|MIT|app/assets/bundled/fonts/hack/LICENSE.md"
"Roboto Font|SIL Open Font License|app/assets/bundled/fonts/roboto/LICENSE.txt"
"bash-preexec|MIT|app/assets/bundled/bootstrap/bash-preexec-LICENSE.md"
"Claude API Skill|Apache-2.0|resources/bundled/skills/claude-api/LICENSE.txt"
"rudder-sdk-rust|MIT|app/src/server/telemetry/LICENSE-RUDDER-SDK-RUST.txt"
"Windows Terminal|MIT|app/assets/windows/LICENSE-WINDOWS-TERMINAL"
"GitHub Desktop|MIT|app/src/code_review/GITHUB-DESKTOP-LICENSE"
)
# Build the third-party licenses file unless the NO_LICENSES envvar is set.
if [ -z "$NO_LICENSES" ]; then
LICENSES_OUTPUT="$DEST_DIR/THIRD_PARTY_LICENSES.txt"
echo "Generating third-party licenses at $LICENSES_OUTPUT"
cargo about generate \
--workspace \
--manifest-path "$REPO_ROOT/Cargo.toml" \
-c "$REPO_ROOT/about.toml" \
-o "$LICENSES_OUTPUT" \
"$REPO_ROOT/about.hbs"
# Append additional (non-Cargo) third-party licenses.
for entry in "${ADDITIONAL_LICENSES[@]}"; do
IFS='|' read -r name license_id license_path <<< "$entry"
license_file="$REPO_ROOT/$license_path"
if [ ! -f "$license_file" ]; then
echo "Error: License file not found: $license_file" >&2
exit 1
fi
printf '\n%s (%s)\n' "$name" "$license_id" >> "$LICENSES_OUTPUT"
printf '%0.s-' {1..80} >> "$LICENSES_OUTPUT"
printf '\n' >> "$LICENSES_OUTPUT"
cat "$license_file" >> "$LICENSES_OUTPUT"
printf '\n' >> "$LICENSES_OUTPUT"
done
fi
# Generate settings JSON schema unless explicitly skipped.
if [ "${SKIP_SETTINGS_SCHEMA:-}" != "1" ]; then
SCHEMA_OUTPUT="$DEST_DIR/settings_schema.json"
if [ -n "${SETTINGS_SCHEMA_CACHE:-}" ] && [ -f "$SETTINGS_SCHEMA_CACHE" ]; then
echo "Copying cached settings schema to $SCHEMA_OUTPUT"
cp "$SETTINGS_SCHEMA_CACHE" "$SCHEMA_OUTPUT"
else
echo "Generating settings schema at $SCHEMA_OUTPUT"
SCHEMA_CMD=(cargo run)
if [ -n "$CARGO_PROFILE" ]; then
SCHEMA_CMD+=(--profile "$CARGO_PROFILE")
fi
SCHEMA_CMD+=(--manifest-path "$REPO_ROOT/Cargo.toml" --bin generate_settings_schema --)
if [ -n "$CHANNEL" ]; then
SCHEMA_CMD+=(--channel "$CHANNEL")
fi
SCHEMA_CMD+=("$SCHEMA_OUTPUT")
"${SCHEMA_CMD[@]}"
if [ -n "${SETTINGS_SCHEMA_CACHE:-}" ]; then
echo "Caching settings schema at $SETTINGS_SCHEMA_CACHE"
cp "$SCHEMA_OUTPUT" "$SETTINGS_SCHEMA_CACHE"
fi
fi
fi
echo "Successfully prepared bundled resources in $DEST_DIR"