-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
93 lines (82 loc) · 2.38 KB
/
Copy pathbuild.sh
File metadata and controls
93 lines (82 loc) · 2.38 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
#!/bin/bash
# ScriptVault - Chrome Web Store Build Script
# Packages the extension into a .zip ready for CWS upload
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
BUILD_DIR="${SCRIPTVAULT_BUILD_ROOT:-$SCRIPT_DIR/build}"
ARTIFACT_ROOT="${SCRIPTVAULT_ARTIFACT_ROOT:-$SCRIPT_DIR}"
ZIP_NAME="ScriptVault-v$(grep -o '"version": "[^"]*"' "$SCRIPT_DIR/manifest.json" | cut -d'"' -f4).zip"
ZIP_PATH="$ARTIFACT_ROOT/$ZIP_NAME"
echo "Building ScriptVault..."
# Build background.js, generate GM API types, and ensure lib/monaco-esm is
# populated before packaging.
# Without this, edits to source modules wouldn't propagate to the shipped
# background.js, and a fresh checkout would ship with an empty lib/monaco-esm
# or stale userscript ambient declarations.
if [ -f "$SCRIPT_DIR/esbuild.config.mjs" ]; then
node "$SCRIPT_DIR/esbuild.config.mjs"
fi
# Clean previous build
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR" "$ARTIFACT_ROOT"
# Files/folders to include in the CWS package
INCLUDE=(
manifest.json
background.js
content.js
offscreen.html
offscreen.js
shared
modules/i18n.js
modules/script-config.js
modules/user-scripts-setup.js
pages
images/icon16.png
images/icon32.png
images/icon48.png
images/icon128.png
lib/codemirror
lib/monaco-esm
lib/acorn.min.js
lib/diff.min.js
lib/fflate.js
lib/scriptvault.d.ts
managed-storage-schema.json
_locales
)
# Copy included files
for item in "${INCLUDE[@]}"; do
src="$SCRIPT_DIR/$item"
dest="$BUILD_DIR/$item"
if [ -d "$src" ]; then
mkdir -p "$dest"
cp -r "$src"/* "$dest"/
elif [ -f "$src" ]; then
mkdir -p "$(dirname "$dest")"
cp "$src" "$dest"
else
echo "Warning: $item not found, skipping"
fi
done
# Build the zip
cd "$BUILD_DIR"
rm -f "$ZIP_PATH"
if command -v zip &> /dev/null; then
zip -r "$ZIP_PATH" . -x "*.DS_Store" "*Thumbs.db"
elif [ -x "/c/Windows/System32/tar.exe" ]; then
# Windows 10/11 ships bsdtar as tar.exe — produces POSIX-style entries
# (forward slashes). PowerShell Compress-Archive writes Windows-style
# backslash entries which Chrome cannot match against manifest paths.
/c/Windows/System32/tar.exe -a -c -f "$ZIP_PATH" *
else
echo "ERROR: no zip or bsdtar available"
exit 1
fi
echo ""
echo "Build complete: $ZIP_NAME"
echo "Artifact: $ZIP_PATH"
echo "Size: $(du -h "$ZIP_PATH" | cut -f1)"
echo ""
echo "Ready for Chrome Web Store upload."
# Cleanup
rm -rf "$BUILD_DIR"