A command-line tool for managing Dreamweaver-style HTML templates without requiring VS Code or Dreamweaver. Preserve editable regions while updating template structure across your entire site.
- ✅ Update all HTML files based on template changes
- ✅ Preserve editable regions while updating non-editable content
- ✅ Automatic backups before every update
- ✅ Pattern-based file discovery (supports
**/*.{html,htm,php}) - ✅ Template/instance synchronization with diff-based safety workflows
- ✅ Optional and repeating regions support
- ✅ Clean exit - no hanging processes
-
Clone the repository:
git clone https://github.com/isocialPractice/html-dwt-cmd-template.git cd html-dwt-cmd-template -
Install dependencies and build:
npm install npm run compile
-
(Optional) Link globally to use
html-dwt-cmdfrom anywhere:npm link
Run from your site root directory (the directory containing a Templates/ folder):
# Update all files automatically without prompts
html-dwt-cmd update-all Templates/main.dwt --auto-apply
# Update with prompts for each change
html-dwt-cmd update-all Templates/main.dwt
# Find all pages using a template
html-dwt-cmd find-instances Templates/main.dwt
# Show editable regions in a file
html-dwt-cmd show-regions pages/index.html
# Get help
html-dwt-cmd --helpIf not globally linked, use:
node out/cli.js update-all Templates/main.dwt --auto-applyIf you're not in the site root directory, use --cwd:
html-dwt-cmd update-all Templates/main.dwt --cwd /path/to/siteUpdates all HTML files that reference the specified template.
Options:
--auto-apply/-a- Apply changes without prompting (recommended for automation)--cwd <path>- Set working directory (defaults to current directory)
Example:
html-dwt-cmd update-all Templates/page.dwt --auto-applyWhat it does:
- Scans site directory for HTML files using the specified template
- Creates backups in
.html-dwt-cmd-template-backups/ - Merges template changes with instance content
- Preserves all editable regions (
<!-- InstanceBeginEditable -->) - Updates non-editable content from template
- Writes updated files
Find and list all HTML/PHP files that use the specified template.
Example:
html-dwt-cmd find-instances Templates/main.dwtDisplay all editable regions defined in a template or instance file.
Example:
html-dwt-cmd show-regions pages/index.htmlsync [template]- Sync template with instances (with interactive prompts)create-page [template]- Create new page from templaterestore-backup- Restore from automatic backup
Note: Currently, update-all is the primary fully-implemented command.
- Edit your template - Modify
.dwtfile inTemplates/folder - Run update command -
html-dwt-cmd update-all Templates/yourtemplate.dwt --auto-apply - Automatic processing:
- Finds all instance files
- Creates backups
- Merges template changes
- Preserves editable region content
- Updates non-editable structure
The tool uses a hybrid architecture for maximum reliability:
- Platform Abstraction Layer - Provides file system and interaction interfaces
- vscode Shim - Allows existing VS Code extension code to run in CLI mode
- Template Engine - Dreamweaver-compatible HTML template merging logic (1400+ lines of tested code)
This approach preserves all the thoroughly-tested template merging logic while enabling CLI operation.
The tool automatically:
- Includes:
**/*.html,**/*.htm,**/*.php - Excludes:
Templates/,.html-dwt-cmd-template-backups/,.html-dwt-template-backups/
your-site/
├── Templates/
│ ├── main.dwt
│ └── secondary.dwt
├── pages/
│ ├── index.html (instance of main.dwt)
│ └── about.html (instance of main.dwt)
├── css/
│ └── styles.css
└── .html-dwt-cmd-template-backups/
└── main/
├── 1/ (most recent backup)
├── 2/
└── 3/ (oldest backup)
<!-- TemplateBeginEditable name="content" -->
Default content here
<!-- TemplateEndEditable --><!-- TemplateParam name="showSidebar" type="boolean" value="true" -->
<!-- TemplateBeginIf cond="showSidebar" -->
<aside>Sidebar content</aside>
<!-- TemplateEndIf --><!-- TemplateBeginRepeat name="listItems" -->
<li>List item</li>
<!-- TemplateEndRepeat -->Backups are automatically created in .html-dwt-cmd-template-backups/ before any template update:
- Rolling backups keep the last 3 versions per template
- Organized by template name
- Preserves folder structure
- Safe - all changes can be reverted
- Node.js 14.0.0 or higher
- TypeScript (for development/building)
Ensure the template path is relative to the site root (where you run the command).
Check that:
- HTML files contain
<!-- InstanceBegin template="/Templates/yourtemplate.dwt" --> - Template path matches exactly (case-sensitive)
- Files aren't in excluded directories (
Templates/, backup folders)
Fixed in current version. The CLI now properly exits after completion.
0- Success1- Error or exception2- Cancelled by user
src/
cli.ts - CLI entry point
cli/commands.ts - Command implementations
adapters/
types.ts - Platform interface definitions
cli-adapter.ts - CLI-specific implementations
platform.ts - Platform selector
vscode-shim.ts - VS Code compatibility layer
setup-cli-environment.ts - Module resolution override
features/update/
updateEngine.ts - Template merging engine (core logic)
npm run compilecd your-test-site
node path/to/out/cli.js update-all Templates/yourtemplate.dwt --auto-applyContributions welcome! See TODO.md for planned enhancements and architecture notes.
See LICENSE file for details.
- TODO.md - Future enhancements, architecture decisions, effort estimates
- CODING_STANDARDS.md - Code style guidelines