@mahe_pkm/buzl-capi 0.1.2 → 0.1.3

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/bin/cli.js CHANGED
@@ -1,155 +1,175 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * ============================================================================
5
- * BUZL TRACKER & CAPI CLI
6
- * Primary binary entry point for `npx buzl-tracker` and `npx buzl-capi`
7
- *
8
- * Copyright (c) 2026 Buzl Digital Solutions
9
- * Licensed under the MIT License
10
- * ============================================================================
11
- *
12
- * CLI Architecture:
13
- * - Positional path argument: target project folder (defaults to process.cwd())
14
- * - Flags:
15
- * --gui, -g Start zero-dependency Web GUI daemon on port 3333
16
- * --backup, -b [name] Create a point-in-time snapshot backup
17
- * --list-backups List all saved backups for target project
18
- * --restore, -r [name] Restore specified backup or latest snapshot
19
- * --uninstall, -u Cleanly remove all injected tracking tags from HTML
20
- * --help, -h Display detailed command reference & usage manual
21
- *
22
- * Flow:
23
- * - If `--gui` is specified: Starts HTTP server and opens browser dashboard.
24
- * - Otherwise: Launches interactive ANSI terminal wizard with step-by-step prompts.
25
- * ============================================================================
26
- */
27
-
28
- const path = require('path');
29
- const pkg = require('../package.json');
30
- const { runTerminalWizard } = require('../src/cli/terminal');
31
- const { startGuiServer } = require('../src/gui/server');
32
- const { restoreBackup, restoreLatestBackup, listBackups, manualBackup } = require('../src/core/rollback');
33
- const { removeTracking } = require('../src/core/injector');
34
- const { scanProject } = require('../src/core/scanner');
35
-
36
- // Extract CLI arguments
37
- const args = process.argv.slice(2);
38
-
39
- // Check for explicit directory argument, or fallback to current working directory
40
- const positionalArgs = args.filter(a => !a.startsWith('-'));
41
- const rootDir = positionalArgs.length > 0 ? path.resolve(positionalArgs[0]) : process.cwd();
42
-
43
- // ============================================================================
44
- // COMMAND: --help / -h (Display Help Manual)
45
- // ============================================================================
46
- if (args.includes('--help') || args.includes('-h')) {
47
- console.log(`
48
- ⚡ BUZL TRACKING & FORM DISPATCHER CLI (v${pkg.version})
49
-
50
- USAGE:
51
- $ npx buzl-tracker [dir] Launch interactive terminal wizard
52
- $ npx buzl-tracker [dir] --gui Launch local web GUI on http://localhost:3333
53
- $ npx buzl-tracker [dir] --backup [name] Create a named snapshot backup
54
- $ npx buzl-tracker [dir] --list-backups List all saved backups on disk
55
- $ npx buzl-tracker [dir] --restore [name] Restore a specific backup or latest snapshot
56
- $ npx buzl-tracker [dir] --uninstall Cleanly remove all tracking tags from site
57
- $ npx buzl-tracker --help Show this help reference manual
58
-
59
- ARGUMENTS:
60
- [dir] Target website directory (defaults to current working directory)
61
-
62
- OPTIONS:
63
- -g, --gui Launch interactive browser GUI dashboard (port 3333)
64
- -b, --backup [name] Create an immutable timestamped backup before modifications
65
- -r, --restore [name] Revert HTML files to a previous snapshot or 'latest'
66
- -u, --uninstall Strip GTM, Meta Pixel, runtime scripts, and form hooks
67
- -h, --help Display usage guide and command summary
68
-
69
- KEY CAPABILITIES:
70
- ✔ Multi-Platform Tracking: Google Tag Manager (GTM), Meta Pixel & CAPI, Google Sheets CRM, Zoho CRM
71
- ✔ Multi-Page Site Scanner: Resolves relative script paths across any nested subdirectory depth
72
- ✔ Universal WhatsApp Auto-Fetch: Discovers numbers from buttons & forms and builds pre-filled routing
73
- ✔ Google Sheets Multi-Tab CRM Engine: Forward layout (Handled By & Comments next to Lead Stage), 12-hour dates,
74
- Buzl Navy Blue (#1E4E9E) headers, full-row conditional colors, and auto-pruning empty team tabs
75
- ✔ 100% Zero-Risk Rollback: Automated snapshot backups prior to every file injection
76
- `);
77
- process.exit(0);
78
- }
79
-
80
- // ============================================================================
81
- // COMMAND: --list-backups (Inspect Saved Snapshots)
82
- // ============================================================================
83
- if (args.includes('--list-backups')) {
84
- const backups = listBackups(rootDir);
85
- console.log(`\n💾 Saved Backups on disk for: ${rootDir}`);
86
- if (backups.length === 0) {
87
- console.log(' No backups found.');
88
- } else {
89
- backups.forEach((b, i) => {
90
- console.log(` [${i + 1}] "${b.name}" (${b.dirName}) - ${b.timestamp} [${b.filesCount} file(s)]`);
91
- });
92
- }
93
- console.log('');
94
- process.exit(0);
95
- }
96
-
97
- // ============================================================================
98
- // COMMAND: --backup / -b (Create Snapshot)
99
- // ============================================================================
100
- const backupIdx = args.findIndex(a => a === '--backup' || a === '-b');
101
- if (backupIdx !== -1) {
102
- const customName = args[backupIdx + 1] && !args[backupIdx + 1].startsWith('-') ? args[backupIdx + 1] : '';
103
- console.log(`💾 Creating snapshot backup ${customName ? `"${customName}"` : ''}...`);
104
- const result = manualBackup(rootDir, customName);
105
- if (result.success) {
106
- console.log(`✔ ${result.message}`);
107
- } else {
108
- console.error(`✖ ${result.message}`);
109
- }
110
- process.exit(result.success ? 0 : 1);
111
- }
112
-
113
- // ============================================================================
114
- // COMMAND: --restore / --rollback / -r (Revert Site to Snapshot)
115
- // ============================================================================
116
- const restoreIdx = args.findIndex(a => a === '--restore' || a === '--rollback' || a === '-r');
117
- if (restoreIdx !== -1) {
118
- const targetName = args[restoreIdx + 1] && !args[restoreIdx + 1].startsWith('-') ? args[restoreIdx + 1] : 'latest';
119
- console.log(`↺ Attempting to restore backup "${targetName}"...`);
120
- const result = restoreBackup(rootDir, targetName);
121
- if (result.success) {
122
- console.log(`✔ ${result.message}`);
123
- } else {
124
- console.error(`✖ ${result.message}`);
125
- }
126
- process.exit(result.success ? 0 : 1);
127
- }
128
-
129
- // ============================================================================
130
- // COMMAND: --uninstall / -u (Cleanly Strip All Injected Tracking)
131
- // ============================================================================
132
- if (args.includes('--uninstall') || args.includes('-u')) {
133
- console.log('🧹 Cleanly removing all injected tracking from HTML files...');
134
- const scan = scanProject(rootDir);
135
- const htmlFilePaths = scan.files.map(f => f.filePath);
136
- const result = removeTracking(rootDir, htmlFilePaths);
137
- if (result.success) {
138
- console.log(`✔ ${result.message}`);
139
- } else {
140
- console.error(`✖ ${result.message}`);
141
- }
142
- process.exit(result.success ? 0 : 1);
143
- }
144
-
145
- // ============================================================================
146
- // MODE: GUI Server vs Interactive Terminal Wizard
147
- // ============================================================================
148
- if (args.includes('--gui') || args.includes('-g')) {
149
- // Start local web GUI server on port 3333
150
- console.log(`⚡ Launching Buzl Tracker Web GUI for: ${rootDir}`);
151
- startGuiServer(rootDir);
152
- } else {
153
- // Start interactive terminal wizard with step-by-step CLI prompts
154
- runTerminalWizard(rootDir);
155
- }
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * ============================================================================
5
+ * BUZL TRACKER & CAPI CLI
6
+ * Primary binary entry point for `npx buzl-tracker` and `npx buzl-capi`
7
+ *
8
+ * Copyright (c) 2026 Buzl Digital Solutions
9
+ * Licensed under the MIT License
10
+ * ============================================================================
11
+ *
12
+ * CLI Architecture:
13
+ * - Positional path argument: target project folder (defaults to process.cwd())
14
+ * - Flags:
15
+ * --gui, -g Start zero-dependency Web GUI daemon on port 3333
16
+ * --backup, -b [name] Create a point-in-time snapshot backup
17
+ * --list-backups List all saved backups for target project
18
+ * --restore, -r [name] Restore specified backup or latest snapshot
19
+ * --uninstall, -u Cleanly remove all injected tracking tags from HTML
20
+ * --help, -h Display detailed command reference & usage manual
21
+ *
22
+ * Flow:
23
+ * - If `--gui` is specified: Starts HTTP server and opens browser dashboard.
24
+ * - Otherwise: Launches interactive ANSI terminal wizard with step-by-step prompts.
25
+ * ============================================================================
26
+ */
27
+
28
+ const path = require('path');
29
+ const pkg = require('../package.json');
30
+ const { runTerminalWizard } = require('../src/cli/terminal');
31
+ const { startGuiServer } = require('../src/gui/server');
32
+ const { restoreBackup, restoreLatestBackup, listBackups, manualBackup } = require('../src/core/rollback');
33
+ const { removeTracking } = require('../src/core/injector');
34
+ const { scanProject } = require('../src/core/scanner');
35
+
36
+ // Extract CLI arguments
37
+ const args = process.argv.slice(2);
38
+
39
+ // Check for explicit directory argument, or fallback to current working directory
40
+ const positionalArgs = args.filter(a => !a.startsWith('-'));
41
+ const rootDir = positionalArgs.length > 0 ? path.resolve(positionalArgs[0]) : process.cwd();
42
+
43
+ // ============================================================================
44
+ // COMMAND: --help / -h (Display Help Manual)
45
+ // ============================================================================
46
+ if (args.includes('--help') || args.includes('-h')) {
47
+ console.log(`
48
+ ⚡ BUZL TRACKING & FORM DISPATCHER CLI (v${pkg.version})
49
+
50
+ USAGE:
51
+ $ npx buzl-tracker [dir] Launch interactive terminal wizard
52
+ $ npx buzl-tracker [dir] --gui Launch local web GUI on http://localhost:3333
53
+ $ npx buzl-tracker [dir] --backup [name] Create a named snapshot backup
54
+ $ npx buzl-tracker [dir] --list-backups List all saved backups on disk
55
+ $ npx buzl-tracker [dir] --restore [name] Restore a specific backup or latest snapshot
56
+ $ npx buzl-tracker [dir] --uninstall Cleanly remove all tracking tags from site
57
+ $ npx buzl-tracker --handbook Open official User Handbook in default browser
58
+ $ npx buzl-tracker --help Show this help reference manual
59
+
60
+ ARGUMENTS:
61
+ [dir] Target website directory (defaults to current working directory)
62
+
63
+ OPTIONS:
64
+ -g, --gui Launch interactive browser GUI dashboard (port 3333)
65
+ -b, --backup [name] Create an immutable timestamped backup before modifications
66
+ -r, --restore [name] Revert HTML files to a previous snapshot or 'latest'
67
+ -u, --uninstall Strip GTM, Meta Pixel, runtime scripts, and form hooks
68
+ --handbook Open printable cross-platform User Handbook in browser
69
+ -h, --help Display usage guide and command summary
70
+
71
+ KEY CAPABILITIES:
72
+ ✔ Multi-Platform Tracking: Google Tag Manager (GTM), Meta Pixel & CAPI, Google Sheets CRM, Zoho CRM
73
+ ✔ Multi-Page Site Scanner: Resolves relative script paths across any nested subdirectory depth
74
+ ✔ Universal WhatsApp Auto-Fetch: Discovers numbers from buttons & forms and builds pre-filled routing
75
+ ✔ Google Sheets Multi-Tab CRM Engine: Forward layout (Handled By & Comments next to Lead Stage), 12-hour dates,
76
+ Buzl Navy Blue (#1E4E9E) headers, full-row conditional colors, and auto-pruning empty team tabs
77
+ ✔ 100% Zero-Risk Rollback: Automated snapshot backups prior to every file injection
78
+ `);
79
+ process.exit(0);
80
+ }
81
+
82
+ // ============================================================================
83
+ // COMMAND: --handbook (Open User Handbook in Default Browser)
84
+ // ============================================================================
85
+ if (args.includes('--handbook')) {
86
+ const handbookPath = path.resolve(__dirname, '../USER_HANDBOOK.html');
87
+ console.log(`📖 Opening User Handbook in default browser: ${handbookPath}`);
88
+ const { exec } = require('child_process');
89
+ const startCmd = process.platform === 'win32' ? `start "" "${handbookPath}"` :
90
+ process.platform === 'darwin' ? `open "${handbookPath}"` :
91
+ `xdg-open "${handbookPath}"`;
92
+ exec(startCmd, (err) => {
93
+ if (err) {
94
+ console.log(`Open manually in browser: file://${handbookPath.replace(/\\/g, '/')}`);
95
+ }
96
+ });
97
+ process.exit(0);
98
+ }
99
+
100
+ // ============================================================================
101
+ // COMMAND: --list-backups (Inspect Saved Snapshots)
102
+ // ============================================================================
103
+ if (args.includes('--list-backups')) {
104
+ const backups = listBackups(rootDir);
105
+ console.log(`\n💾 Saved Backups on disk for: ${rootDir}`);
106
+ if (backups.length === 0) {
107
+ console.log(' No backups found.');
108
+ } else {
109
+ backups.forEach((b, i) => {
110
+ console.log(` [${i + 1}] "${b.name}" (${b.dirName}) - ${b.timestamp} [${b.filesCount} file(s)]`);
111
+ });
112
+ }
113
+ console.log('');
114
+ process.exit(0);
115
+ }
116
+
117
+ // ============================================================================
118
+ // COMMAND: --backup / -b (Create Snapshot)
119
+ // ============================================================================
120
+ const backupIdx = args.findIndex(a => a === '--backup' || a === '-b');
121
+ if (backupIdx !== -1) {
122
+ const customName = args[backupIdx + 1] && !args[backupIdx + 1].startsWith('-') ? args[backupIdx + 1] : '';
123
+ console.log(`💾 Creating snapshot backup ${customName ? `"${customName}"` : ''}...`);
124
+ const result = manualBackup(rootDir, customName);
125
+ if (result.success) {
126
+ console.log(`✔ ${result.message}`);
127
+ } else {
128
+ console.error(`✖ ${result.message}`);
129
+ }
130
+ process.exit(result.success ? 0 : 1);
131
+ }
132
+
133
+ // ============================================================================
134
+ // COMMAND: --restore / --rollback / -r (Revert Site to Snapshot)
135
+ // ============================================================================
136
+ const restoreIdx = args.findIndex(a => a === '--restore' || a === '--rollback' || a === '-r');
137
+ if (restoreIdx !== -1) {
138
+ const targetName = args[restoreIdx + 1] && !args[restoreIdx + 1].startsWith('-') ? args[restoreIdx + 1] : 'latest';
139
+ console.log(`↺ Attempting to restore backup "${targetName}"...`);
140
+ const result = restoreBackup(rootDir, targetName);
141
+ if (result.success) {
142
+ console.log(`✔ ${result.message}`);
143
+ } else {
144
+ console.error(`✖ ${result.message}`);
145
+ }
146
+ process.exit(result.success ? 0 : 1);
147
+ }
148
+
149
+ // ============================================================================
150
+ // COMMAND: --uninstall / -u (Cleanly Strip All Injected Tracking)
151
+ // ============================================================================
152
+ if (args.includes('--uninstall') || args.includes('-u')) {
153
+ console.log('🧹 Cleanly removing all injected tracking from HTML files...');
154
+ const scan = scanProject(rootDir);
155
+ const htmlFilePaths = scan.files.map(f => f.filePath);
156
+ const result = removeTracking(rootDir, htmlFilePaths);
157
+ if (result.success) {
158
+ console.log(`✔ ${result.message}`);
159
+ } else {
160
+ console.error(`✖ ${result.message}`);
161
+ }
162
+ process.exit(result.success ? 0 : 1);
163
+ }
164
+
165
+ // ============================================================================
166
+ // MODE: GUI Server vs Interactive Terminal Wizard
167
+ // ============================================================================
168
+ if (args.includes('--gui') || args.includes('-g')) {
169
+ // Start local web GUI server on port 3333
170
+ console.log(`⚡ Launching Buzl Tracker Web GUI for: ${rootDir}`);
171
+ startGuiServer(rootDir);
172
+ } else {
173
+ // Start interactive terminal wizard with step-by-step CLI prompts
174
+ runTerminalWizard(rootDir);
175
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mahe_pkm/buzl-capi",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "All-in-one CLI & GUI for automated GTM, Meta Pixel/CAPI, Google Sheets Form Sync, and Zoho CRM injection with self-testing.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -30,6 +30,8 @@
30
30
  "Buzl_GoogleAppsScript_Template.gs",
31
31
  "README.md",
32
32
  "CHANGELOG.md",
33
+ "USER_HANDBOOK.md",
34
+ "USER_HANDBOOK.html",
33
35
  "LICENSE"
34
36
  ],
35
37
  "keywords": [