@http-forge/cli 0.2.5 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -532
- package/dist/commands/generate.d.ts +14 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +146 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/launch.d.ts +2 -0
- package/dist/commands/launch.d.ts.map +1 -0
- package/dist/commands/launch.js +96 -0
- package/dist/commands/launch.js.map +1 -0
- package/dist/commands.d.ts +2 -0
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +5 -1
- package/dist/commands.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -1
- package/package.json +30 -5
- package/scripts/http-forge.bat +157 -0
- package/scripts/http-forge.sh +167 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# HTTP Forge Launcher — Linux/macOS
|
|
3
|
+
# Detects VS Code, downloads if missing, installs extension, launches in isolated profile.
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# ./http-forge.sh [path] # Launch in "HTTP Forge" profile (test mode)
|
|
7
|
+
# ./http-forge.sh --dev [path] # Launch in "Default" profile (all extensions)
|
|
8
|
+
# ./http-forge.sh --both [path] # Launch BOTH profiles side by side
|
|
9
|
+
|
|
10
|
+
PROFILE_TEST="HTTP Forge"
|
|
11
|
+
PROFILE_DEV="Default"
|
|
12
|
+
EXTENSION="henry-huang.http-forge"
|
|
13
|
+
INSTALL_DIR="$HOME/.http-forge-launcher/vscode"
|
|
14
|
+
TEST_DATA_DIR="$HOME/.http-forge-launcher/vscode-data"
|
|
15
|
+
|
|
16
|
+
# ─── Parse Arguments ───────────────────────────────────────────
|
|
17
|
+
MODE="test"
|
|
18
|
+
WORKSPACE_ARGS=()
|
|
19
|
+
|
|
20
|
+
for arg in "$@"; do
|
|
21
|
+
case "$arg" in
|
|
22
|
+
--dev) MODE="dev" ;;
|
|
23
|
+
--test) MODE="test" ;;
|
|
24
|
+
--both) MODE="both" ;;
|
|
25
|
+
--help|-h)
|
|
26
|
+
echo "HTTP Forge Launcher"
|
|
27
|
+
echo ""
|
|
28
|
+
echo "Usage: ./http-forge.sh [options] [workspace-path]"
|
|
29
|
+
echo ""
|
|
30
|
+
echo "Options:"
|
|
31
|
+
echo " --test Launch with HTTP Forge profile (isolated, default)"
|
|
32
|
+
echo " --dev Launch with Default profile (all your extensions)"
|
|
33
|
+
echo " --both Launch two instances: Default + HTTP Forge (test)"
|
|
34
|
+
echo " --help Show this help"
|
|
35
|
+
echo ""
|
|
36
|
+
echo "Default: Launch with \"HTTP Forge\" profile (isolated, test-only)"
|
|
37
|
+
exit 0
|
|
38
|
+
;;
|
|
39
|
+
*) WORKSPACE_ARGS+=("$arg") ;;
|
|
40
|
+
esac
|
|
41
|
+
done
|
|
42
|
+
|
|
43
|
+
# ─── Detect VS Code ───────────────────────────────────────────
|
|
44
|
+
find_code() {
|
|
45
|
+
# Check PATH first
|
|
46
|
+
if command -v code &>/dev/null; then
|
|
47
|
+
echo "code"
|
|
48
|
+
return
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
# Check common Linux locations
|
|
52
|
+
for bin in /usr/bin/code /snap/bin/code /usr/share/code/bin/code; do
|
|
53
|
+
if [[ -x "$bin" ]]; then
|
|
54
|
+
echo "$bin"
|
|
55
|
+
return
|
|
56
|
+
fi
|
|
57
|
+
done
|
|
58
|
+
|
|
59
|
+
# Check macOS locations
|
|
60
|
+
for bin in "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" \
|
|
61
|
+
"$HOME/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"; do
|
|
62
|
+
if [[ -x "$bin" ]]; then
|
|
63
|
+
echo "$bin"
|
|
64
|
+
return
|
|
65
|
+
fi
|
|
66
|
+
done
|
|
67
|
+
|
|
68
|
+
# Check our own install
|
|
69
|
+
if [[ -x "$INSTALL_DIR/bin/code" ]]; then
|
|
70
|
+
echo "$INSTALL_DIR/bin/code"
|
|
71
|
+
return
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
return 1
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# ─── Install VS Code ──────────────────────────────────────────
|
|
78
|
+
install_code() {
|
|
79
|
+
echo "[http-forge] VS Code not found. Downloading..."
|
|
80
|
+
mkdir -p "$INSTALL_DIR"
|
|
81
|
+
|
|
82
|
+
local url
|
|
83
|
+
case "$(uname -s)" in
|
|
84
|
+
Linux) url="https://update.code.visualstudio.com/latest/linux-x64/stable" ;;
|
|
85
|
+
Darwin) url="https://update.code.visualstudio.com/latest/darwin-universal/stable" ;;
|
|
86
|
+
*) echo "[http-forge] ERROR: Unsupported OS. Please install VS Code manually."; exit 1 ;;
|
|
87
|
+
esac
|
|
88
|
+
|
|
89
|
+
local tmp
|
|
90
|
+
tmp="$(mktemp -d)/vscode-download"
|
|
91
|
+
|
|
92
|
+
if [[ "$(uname -s)" == "Linux" ]]; then
|
|
93
|
+
curl -L --progress-bar "$url" -o "$tmp.tar.gz"
|
|
94
|
+
echo "[http-forge] Extracting..."
|
|
95
|
+
rm -rf "$INSTALL_DIR"
|
|
96
|
+
mkdir -p "$INSTALL_DIR"
|
|
97
|
+
tar -xzf "$tmp.tar.gz" -C "$INSTALL_DIR" --strip-components=1
|
|
98
|
+
rm -f "$tmp.tar.gz"
|
|
99
|
+
else
|
|
100
|
+
curl -L --progress-bar "$url" -o "$tmp.zip"
|
|
101
|
+
echo "[http-forge] Extracting..."
|
|
102
|
+
unzip -qo "$tmp.zip" -d "$HOME/Applications"
|
|
103
|
+
rm -f "$tmp.zip"
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
echo "[http-forge] VS Code installed."
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# ─── Main Flow ─────────────────────────────────────────────────
|
|
110
|
+
CODE_BIN=$(find_code)
|
|
111
|
+
|
|
112
|
+
if [[ -z "$CODE_BIN" ]]; then
|
|
113
|
+
install_code
|
|
114
|
+
CODE_BIN=$(find_code)
|
|
115
|
+
if [[ -z "$CODE_BIN" ]]; then
|
|
116
|
+
echo "[http-forge] ERROR: Failed to install VS Code."
|
|
117
|
+
exit 1
|
|
118
|
+
fi
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
echo "[http-forge] Using: $CODE_BIN"
|
|
122
|
+
|
|
123
|
+
# Install extension only where it will actually be launched
|
|
124
|
+
echo "[http-forge] Ensuring extension is installed..."
|
|
125
|
+
case "$MODE" in
|
|
126
|
+
test)
|
|
127
|
+
"$CODE_BIN" --profile "$PROFILE_TEST" --install-extension "$EXTENSION" --force 2>/dev/null
|
|
128
|
+
;;
|
|
129
|
+
dev)
|
|
130
|
+
"$CODE_BIN" --profile "$PROFILE_DEV" --install-extension "$EXTENSION" --force 2>/dev/null
|
|
131
|
+
;;
|
|
132
|
+
both)
|
|
133
|
+
mkdir -p "$TEST_DATA_DIR/User"
|
|
134
|
+
if [[ ! -f "$TEST_DATA_DIR/User/settings.json" ]]; then
|
|
135
|
+
echo '{"debug.showInActivityBar": false, "debug.showInStatusBar": "never", "workbench.startupEditor": "none"}' > "$TEST_DATA_DIR/User/settings.json"
|
|
136
|
+
fi
|
|
137
|
+
"$CODE_BIN" --profile "$PROFILE_TEST" --user-data-dir "$TEST_DATA_DIR" --install-extension "$EXTENSION" --force 2>/dev/null
|
|
138
|
+
"$CODE_BIN" --profile "$PROFILE_DEV" --install-extension "$EXTENSION" --force 2>/dev/null
|
|
139
|
+
;;
|
|
140
|
+
esac
|
|
141
|
+
|
|
142
|
+
# Built-in extensions to disable in test mode (not needed, saves RAM)
|
|
143
|
+
DISABLE_EXTENSIONS=(--disable-extension ms-vscode.js-debug --disable-extension ms-vscode.js-debug-companion --disable-extension vscode.debug-auto-launch --disable-extension vscode.debug-server-ready)
|
|
144
|
+
|
|
145
|
+
case "$MODE" in
|
|
146
|
+
dev)
|
|
147
|
+
echo "[http-forge] Launching VS Code (profile: $PROFILE_DEV)..."
|
|
148
|
+
"$CODE_BIN" --new-window --profile "$PROFILE_DEV" "${WORKSPACE_ARGS[@]}"
|
|
149
|
+
"$CODE_BIN" --profile "$PROFILE_DEV" --open-url "vscode:extension/$EXTENSION" &
|
|
150
|
+
;;
|
|
151
|
+
test)
|
|
152
|
+
echo "[http-forge] Launching VS Code (profile: $PROFILE_TEST)..."
|
|
153
|
+
"$CODE_BIN" --new-window --profile "$PROFILE_TEST" "${DISABLE_EXTENSIONS[@]}" "${WORKSPACE_ARGS[@]}"
|
|
154
|
+
"$CODE_BIN" --profile "$PROFILE_TEST" --open-url "vscode:extension/$EXTENSION" &
|
|
155
|
+
;;
|
|
156
|
+
both)
|
|
157
|
+
echo "[http-forge] Launching two separate instances..."
|
|
158
|
+
echo " → Test: isolated instance (--user-data-dir)"
|
|
159
|
+
echo " → Dev: default VS Code"
|
|
160
|
+
# Test instance
|
|
161
|
+
"$CODE_BIN" --new-window --profile "$PROFILE_TEST" --user-data-dir "$TEST_DATA_DIR" "${DISABLE_EXTENSIONS[@]}" "${WORKSPACE_ARGS[@]}"
|
|
162
|
+
"$CODE_BIN" --profile "$PROFILE_TEST" --user-data-dir "$TEST_DATA_DIR" --open-url "vscode:extension/$EXTENSION" &
|
|
163
|
+
# Dev instance
|
|
164
|
+
"$CODE_BIN" --new-window --profile "$PROFILE_DEV" "${WORKSPACE_ARGS[@]}"
|
|
165
|
+
"$CODE_BIN" --profile "$PROFILE_DEV" --open-url "vscode:extension/$EXTENSION" &
|
|
166
|
+
;;
|
|
167
|
+
esac
|