-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·212 lines (196 loc) · 7.11 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·212 lines (196 loc) · 7.11 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/bin/bash
set -e
# Source shared script library
source ./script_lib.sh
# All available extensions in build order
ALL_EXTENSIONS=(
"r3bl-shared"
"r3bl-theme"
"r3bl-auto-insert-copyright"
"r3bl-semantic-config"
"r3bl-task-management"
"r3bl-copy-selection-path-and-range"
"r3bl-fuzzy-search"
"r3bl-opened-editors"
"r3bl-extension-pack"
)
# Show help
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo "Usage: ./build.sh [extension-name...]"
echo ""
echo "Build all or specific R3BL VSCode extensions and generate .vsix artifacts."
echo ""
echo "Arguments:"
echo " [extension-name...] Optional. Names of specific extensions to build."
echo " If omitted, all extensions are built."
echo ""
echo "Available extensions:"
for ext in "${ALL_EXTENSIONS[@]}"; do
echo " • $ext"
done
echo ""
echo "Examples:"
echo " ./build.sh # Build all extensions"
echo " ./build.sh r3bl-semantic-config # Build only semantic config"
echo " ./build.sh r3bl-semantic-config r3bl-extension-pack # Build semantic config & extension pack"
echo ""
echo "After building, run ./install.sh to install locally."
exit 0
fi
echo "🔨 Building R3BL VSCode Extensions..."
echo "======================================"
# Check requirements
check_requirements
# Get all extension versions
get_all_versions
declare -A EXT_VERSIONS=(
["r3bl-shared"]="${SHARED_VERSION}"
["r3bl-theme"]="${THEME_VERSION}"
["r3bl-auto-insert-copyright"]="${COPYRIGHT_VERSION}"
["r3bl-semantic-config"]="${SEMANTIC_VERSION}"
["r3bl-task-management"]="${TASK_MANAGEMENT_VERSION}"
["r3bl-copy-selection-path-and-range"]="${COPY_SELECTION_VERSION}"
["r3bl-fuzzy-search"]="${FUZZY_SEARCH_VERSION}"
["r3bl-opened-editors"]="${OPENED_EDITORS_VERSION}"
["r3bl-extension-pack"]="${EXTENSION_PACK_VERSION}"
)
# Determine target extensions to build
TARGET_EXTENSIONS=()
BUILD_ALL=false
if [ $# -eq 0 ]; then
BUILD_ALL=true
TARGET_EXTENSIONS=("${ALL_EXTENSIONS[@]}")
else
for arg in "$@"; do
if [ -z "${EXT_VERSIONS[$arg]}" ]; then
echo -e "${RED}Error: Unknown extension '${arg}'${NC}"
echo "Run ./build.sh --help to see available extensions."
exit 1
fi
TARGET_EXTENSIONS+=("$arg")
done
fi
# Function to build a single extension
build_extension() {
local ext="$1"
local ver="${EXT_VERSIONS[$ext]}"
case "$ext" in
r3bl-shared)
echo -e "${BLUE}Building R3BL Shared...${NC}"
cd packages/r3bl-shared
[ ! -d "node_modules" ] && npm install
npm run build
npx --no vsce package --no-dependencies --skip-license
cleanup_old_versions "r3bl-shared" "$ver" "."
cd ../..
;;
r3bl-theme)
echo -e "${BLUE}Building R3BL Theme...${NC}"
cd packages/r3bl-theme
npx --no vsce package --no-dependencies --skip-license
cleanup_old_versions "r3bl-theme" "$ver" "."
cd ../..
;;
r3bl-auto-insert-copyright)
echo -e "${BLUE}Building R3BL Auto Insert Copyright...${NC}"
cd packages/r3bl-auto-insert-copyright
[ ! -d "node_modules" ] && npm install
npm run compile
npx --no vsce package --no-dependencies --skip-license
cleanup_old_versions "r3bl-auto-insert-copyright" "$ver" "."
cd ../..
;;
r3bl-semantic-config)
echo -e "${BLUE}Building R3BL Semantic Configuration...${NC}"
cd packages/r3bl-semantic-config
[ ! -d "node_modules" ] && npm install
npm run compile
npm test
npx --no vsce package --no-dependencies --skip-license
cleanup_old_versions "r3bl-semantic-config" "$ver" "."
cd ../..
;;
r3bl-task-management)
echo -e "${BLUE}Building R3BL Task Management...${NC}"
cd packages/r3bl-task-management
[ ! -d "node_modules" ] && npm install
npm run compile
npx --no vsce package --no-dependencies --skip-license
cleanup_old_versions "r3bl-task-management" "$ver" "."
cd ../..
;;
r3bl-copy-selection-path-and-range)
echo -e "${BLUE}Building R3BL Copy Selection Path and Range...${NC}"
cd packages/r3bl-copy-selection-path-and-range
[ ! -d "node_modules" ] && npm install
npm run build
npx --no vsce package --no-dependencies --skip-license
cleanup_old_versions "r3bl-copy-selection-path-and-range" "$ver" "."
cd ../..
;;
r3bl-fuzzy-search)
echo -e "${BLUE}Building R3BL Fuzzy Search...${NC}"
cd packages/r3bl-fuzzy-search
[ ! -d "node_modules" ] && npm install
npm run compile
npm test
npx --no vsce package --no-dependencies --skip-license
cleanup_old_versions "r3bl-fuzzy-search" "$ver" "."
cd ../..
;;
r3bl-opened-editors)
echo -e "${BLUE}Building R3BL Opened Editors...${NC}"
cd packages/r3bl-opened-editors
[ ! -d "node_modules" ] && npm install
npm run compile
npm test
npx --no vsce package --no-dependencies --skip-license
cleanup_old_versions "r3bl-opened-editors" "$ver" "."
cd ../..
;;
r3bl-extension-pack)
echo -e "${BLUE}Building R3BL Extension Pack...${NC}"
cd packages/r3bl-extension-pack
npx --no vsce package --no-dependencies --skip-license
cleanup_old_versions "r3bl-extension-pack" "$ver" "."
if [ ! -f "r3bl-extension-pack-${ver}.vsix" ]; then
echo -e "${RED}Error: Failed to create r3bl-extension-pack-${ver}.vsix${NC}"
exit 1
fi
cd ../..
;;
esac
}
# Pre-build formatting and dependencies
if [ "$BUILD_ALL" = true ]; then
echo -e "${BLUE}Formatting code with Prettier...${NC}"
npm run format
echo -e "${BLUE}Installing dependencies...${NC}"
npm install
else
echo -e "${BLUE}Formatting target extension code with Prettier...${NC}"
for ext in "${TARGET_EXTENSIONS[@]}"; do
npx prettier --write "packages/${ext}/**/*.{ts,js,json,md}" 2>/dev/null || true
done
fi
# Build target extensions
echo ""
echo -e "${BLUE}Building target extension(s)...${NC}"
for ext in "${TARGET_EXTENSIONS[@]}"; do
build_extension "$ext"
done
# Print final results
if [ "$BUILD_ALL" = true ]; then
print_built_extensions
else
echo ""
echo -e "${GREEN}🎉 Specified extension(s) built successfully!${NC}"
echo ""
echo -e "${BLUE}Built extensions:${NC}"
for ext in "${TARGET_EXTENSIONS[@]}"; do
ver="${EXT_VERSIONS[$ext]}"
echo " • packages/${ext}/${ext}-${ver}.vsix"
done
echo ""
echo -e "${BLUE}To install the extensions, run: ./install.sh${NC}"
fi