Skip to content

Commit 1b710c7

Browse files
committed
feat: add reverse command
1 parent 8dd7f30 commit 1b710c7

File tree

3 files changed

+535
-0
lines changed

3 files changed

+535
-0
lines changed

docs/commands.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,60 @@ It accepts the following parameters:
104104

105105
* `--addon-name` - [required] add-on name.
106106

107+
## `ucc-gen reverse`
108+
109+
The `ucc-gen reverse` command is used to reverse-engineer a UCC project from a built add-on package.
110+
This allows you to extract the source structure from a built add-on, making it possible to modify and rebuild it.
111+
112+
**Use cases:**
113+
- Recovering source from a built add-on when original sources are lost
114+
- Understanding the structure of an existing UCC add-on
115+
- Creating a modifiable project from a distributed add-on package
116+
117+
**What gets extracted:**
118+
-`globalConfig.json` / `globalConfig.yaml` - Complete configuration
119+
-`app.manifest` - Add-on metadata
120+
- ✅ Source files (Python helpers, `.conf` files, static assets)
121+
-`lib/requirements.txt` - Regenerated with exact package versions
122+
123+
**Limitations:**
124+
- ❌ Custom UI components (TypeScript/React) cannot be recovered from bundled JavaScript
125+
- ❌ Build scripts and development tooling are not included
126+
- ⚠️ Generated files (REST handlers, input wrappers) are excluded to avoid conflicts
127+
128+
It accepts the following parameters:
129+
130+
* `--addon-path` - [required] Path to the built add-on. Can be either:
131+
- A directory containing the built add-on (e.g., `output/Splunk_TA_MyAddon`)
132+
- A packaged `.tar.gz` / `.tgz` / `.spl` file (e.g., `Splunk_TA_MyAddon-1.0.0.tar.gz`)
133+
* `-o` / `--output` - [optional] Output path for the extracted project.
134+
By default, it will be saved as `<addon_name>_source` in the current directory.
135+
* `--overwrite` - [optional] Overwrite existing output directory if it already exists.
136+
137+
**Example usage:**
138+
139+
```bash
140+
# Extract from a built directory
141+
ucc-gen reverse --addon-path output/Splunk_TA_MyAddon
142+
143+
# Extract from a packaged .tar.gz file
144+
ucc-gen reverse --addon-path Splunk_TA_MyAddon-1.0.0.tar.gz
145+
146+
# Extract from a .spl file (Splunk package)
147+
ucc-gen reverse --addon-path Splunk_TA_MyAddon.spl
148+
149+
# Extract to a specific location
150+
ucc-gen reverse --addon-path output/Splunk_TA_MyAddon --output /path/to/project
151+
152+
# Overwrite existing extraction
153+
ucc-gen reverse --addon-path output/Splunk_TA_MyAddon --overwrite
154+
155+
# Then modify and rebuild:
156+
cd Splunk_TA_MyAddon_source
157+
# Make your changes...
158+
ucc-gen build
159+
```
160+
107161
## `ucc-gen package`
108162

109163
`ucc-gen package` can be used for `v5.30.0` and later. It packages the add-on so it can be installed.

0 commit comments

Comments
 (0)