@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/Buzl_GoogleAppsScript_Template.gs +948 -948
- package/CHANGELOG.md +109 -83
- package/LICENSE +21 -21
- package/README.md +339 -253
- package/USER_HANDBOOK.html +808 -0
- package/USER_HANDBOOK.md +842 -0
- package/assets/js/buzl-tracking.js +390 -390
- package/bin/cli.js +175 -155
- package/package.json +3 -1
- package/src/cli/terminal.js +388 -388
- package/src/core/injector.js +321 -321
- package/src/core/rollback.js +281 -281
- package/src/core/scanner.js +506 -506
- package/src/core/tester.js +666 -357
- package/src/gui/public/app.js +915 -87
- package/src/gui/public/index.html +620 -230
- package/src/gui/public/style.css +1603 -509
- package/src/gui/server.js +242 -232
- package/src/index.js +47 -47
- package/src/templates/GoogleAppsScript.gs +948 -948
- package/src/templates/buzl-tracking.js +475 -475
- package/src/templates/gtm-meta-snippets.js +149 -149
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 --
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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.
|
|
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": [
|