From 2c26f8497b6a1d4e354e2ffd474b9fc48bdf7f38 Mon Sep 17 00:00:00 2001 From: Corey Haines <34802794+coreyhaines31@users.noreply.github.com> Date: Tue, 17 Feb 2026 11:47:12 -0800 Subject: [PATCH] feat: add --dry-run flag to all 47 CLI tools When --dry-run is passed, each CLI prints the HTTP request it would make (method, URL, headers, body) without actually calling fetch(). Auth credentials are masked as "***" in the output. Useful for verifying request shape and API endpoints without needing real API keys or making actual API calls. Co-Authored-By: Claude Opus 4.6 --- tools/clis/activecampaign.js | 3 +++ tools/clis/adobe-analytics.js | 3 +++ tools/clis/ahrefs.js | 3 +++ tools/clis/amplitude.js | 8 +++++++- tools/clis/apollo.js | 3 +++ tools/clis/beehiiv.js | 3 +++ tools/clis/brevo.js | 3 +++ tools/clis/buffer.js | 14 ++++++++++++++ tools/clis/calendly.js | 3 +++ tools/clis/clearbit.js | 3 +++ tools/clis/customer-io.js | 6 ++++++ tools/clis/dataforseo.js | 3 +++ tools/clis/demio.js | 3 +++ tools/clis/dub.js | 3 +++ tools/clis/g2.js | 3 +++ tools/clis/ga4.js | 6 ++++++ tools/clis/google-ads.js | 3 +++ tools/clis/google-search-console.js | 3 +++ tools/clis/hotjar.js | 3 +++ tools/clis/intercom.js | 3 +++ tools/clis/keywords-everywhere.js | 14 +++++++++----- tools/clis/kit.js | 12 ++++++++++++ tools/clis/klaviyo.js | 16 +++++++++------ tools/clis/linkedin-ads.js | 12 ++++++++---- tools/clis/livestorm.js | 14 +++++++++----- tools/clis/mailchimp.js | 12 ++++++++---- tools/clis/mention-me.js | 12 ++++++++---- tools/clis/meta-ads.js | 4 ++++ tools/clis/mixpanel.js | 30 ++++++++++++++++++++--------- tools/clis/onesignal.js | 14 +++++++++----- tools/clis/optimizely.js | 3 +++ tools/clis/paddle.js | 3 +++ tools/clis/partnerstack.js | 3 +++ tools/clis/plausible.js | 3 +++ tools/clis/postmark.js | 9 +++++++++ tools/clis/resend.js | 3 +++ tools/clis/rewardful.js | 3 +++ tools/clis/savvycal.js | 3 +++ tools/clis/segment.js | 6 ++++++ tools/clis/semrush.js | 5 +++++ tools/clis/sendgrid.js | 3 +++ tools/clis/tiktok-ads.js | 3 +++ tools/clis/tolt.js | 3 +++ tools/clis/trustpilot.js | 9 +++++++++ tools/clis/typeform.js | 3 +++ tools/clis/wistia.js | 3 +++ tools/clis/zapier.js | 6 ++++++ 47 files changed, 250 insertions(+), 43 deletions(-) diff --git a/tools/clis/activecampaign.js b/tools/clis/activecampaign.js index eea72f6..0475cd9 100755 --- a/tools/clis/activecampaign.js +++ b/tools/clis/activecampaign.js @@ -16,6 +16,9 @@ if (!API_URL) { const BASE_URL = `${API_URL.replace(/\/$/, '')}/api/3` async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Api-Token': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/adobe-analytics.js b/tools/clis/adobe-analytics.js index bd3d376..66149a5 100755 --- a/tools/clis/adobe-analytics.js +++ b/tools/clis/adobe-analytics.js @@ -12,6 +12,9 @@ if (!ACCESS_TOKEN || !CLIENT_ID || !COMPANY_ID) { const BASE_URL = `https://analytics.adobe.io/api/${COMPANY_ID}` async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'x-api-key': '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/ahrefs.js b/tools/clis/ahrefs.js index c3b5aa4..1c59c30 100755 --- a/tools/clis/ahrefs.js +++ b/tools/clis/ahrefs.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json' } } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/amplitude.js b/tools/clis/amplitude.js index 777e11b..7a1d701 100755 --- a/tools/clis/amplitude.js +++ b/tools/clis/amplitude.js @@ -11,6 +11,9 @@ if (!API_KEY) { } async function ingestApi(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${INGESTION_URL}${path}`, headers: { 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${INGESTION_URL}${path}`, { method, headers: { 'Content-Type': 'application/json' }, @@ -28,8 +31,11 @@ async function queryApi(method, path, params) { if (!SECRET_KEY) { return { error: 'AMPLITUDE_SECRET_KEY required for query/export operations' } } - const auth = Buffer.from(`${API_KEY}:${SECRET_KEY}`).toString('base64') const url = params ? `${QUERY_URL}${path}?${params}` : `${QUERY_URL}${path}` + if (args['dry-run']) { + return { _dry_run: true, method, url, headers: { 'Authorization': '***', 'Content-Type': 'application/json' } } + } + const auth = Buffer.from(`${API_KEY}:${SECRET_KEY}`).toString('base64') const res = await fetch(url, { method, headers: { diff --git a/tools/clis/apollo.js b/tools/clis/apollo.js index fee1b30..d51e3fa 100755 --- a/tools/clis/apollo.js +++ b/tools/clis/apollo.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'x-api-key': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/beehiiv.js b/tools/clis/beehiiv.js index cf7e38f..31ea085 100755 --- a/tools/clis/beehiiv.js +++ b/tools/clis/beehiiv.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/brevo.js b/tools/clis/brevo.js index 9ef0067..ec5f935 100755 --- a/tools/clis/brevo.js +++ b/tools/clis/brevo.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'api-key': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/buffer.js b/tools/clis/buffer.js index 786071e..63a4c55 100755 --- a/tools/clis/buffer.js +++ b/tools/clis/buffer.js @@ -16,6 +16,9 @@ async function api(method, path, body) { if (body && method !== 'GET') { headers['Content-Type'] = 'application/x-www-form-urlencoded' } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, 'Authorization': '***' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers, @@ -30,6 +33,9 @@ async function api(method, path, body) { } async function apiJson(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { @@ -155,6 +161,10 @@ async function main() { if (args.now) formBody.append('now', 'true') if (args.top) formBody.append('top', 'true') if (args.shorten) formBody.append('shorten', 'true') + if (args['dry-run']) { + result = { _dry_run: true, method: 'POST', url: `${BASE_URL}/updates/create.json`, headers: { 'Authorization': '***', 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json' }, body: formBody.toString() } + break + } const res = await fetch(`${BASE_URL}/updates/create.json`, { method: 'POST', headers: { @@ -197,6 +207,10 @@ async function main() { if (!order) { result = { error: '--order required (comma-separated update IDs)' }; break } const formBody = new URLSearchParams() order.split(',').forEach(uid => formBody.append('order[]', uid.trim())) + if (args['dry-run']) { + result = { _dry_run: true, method: 'POST', url: `${BASE_URL}/profiles/${id}/updates/reorder.json`, headers: { 'Authorization': '***', 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json' }, body: formBody.toString() } + break + } const res = await fetch(`${BASE_URL}/profiles/${id}/updates/reorder.json`, { method: 'POST', headers: { diff --git a/tools/clis/calendly.js b/tools/clis/calendly.js index 64fb375..d0bec15 100755 --- a/tools/clis/calendly.js +++ b/tools/clis/calendly.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/clearbit.js b/tools/clis/clearbit.js index 3fa4c33..2f1206b 100755 --- a/tools/clis/clearbit.js +++ b/tools/clis/clearbit.js @@ -8,6 +8,9 @@ if (!API_KEY) { } async function api(method, baseUrl, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${baseUrl}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${baseUrl}${path}`, { method, headers: { diff --git a/tools/clis/customer-io.js b/tools/clis/customer-io.js index 1981e30..66a943d 100755 --- a/tools/clis/customer-io.js +++ b/tools/clis/customer-io.js @@ -21,6 +21,9 @@ async function trackApi(method, path, body) { if (!hasTrackAuth) { return { error: 'Track API requires CUSTOMERIO_SITE_ID and CUSTOMERIO_API_KEY environment variables' } } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${TRACK_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${TRACK_URL}${path}`, { method, headers: { @@ -41,6 +44,9 @@ async function appApi(method, path, body) { if (!hasAppAuth) { return { error: 'App API requires CUSTOMERIO_APP_KEY environment variable' } } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${APP_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${APP_URL}${path}`, { method, headers: { diff --git a/tools/clis/dataforseo.js b/tools/clis/dataforseo.js index 9bf0fdb..b4286ac 100755 --- a/tools/clis/dataforseo.js +++ b/tools/clis/dataforseo.js @@ -12,6 +12,9 @@ if (!LOGIN || !PASSWORD) { const AUTH = 'Basic ' + Buffer.from(`${LOGIN}:${PASSWORD}`).toString('base64') async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/demio.js b/tools/clis/demio.js index 87c4a4d..678200d 100755 --- a/tools/clis/demio.js +++ b/tools/clis/demio.js @@ -15,6 +15,9 @@ if (!API_SECRET) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Api-Key': '***', 'Api-Secret': '***', 'Content-Type': 'application/json', Accept: 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/dub.js b/tools/clis/dub.js index 8a861a0..ea9aebe 100755 --- a/tools/clis/dub.js +++ b/tools/clis/dub.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/g2.js b/tools/clis/g2.js index e2cb965..7eabbd8 100755 --- a/tools/clis/g2.js +++ b/tools/clis/g2.js @@ -9,6 +9,9 @@ if (!API_TOKEN) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/vnd.api+json', Accept: 'application/vnd.api+json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/ga4.js b/tools/clis/ga4.js index d38315f..4dfd9ab 100755 --- a/tools/clis/ga4.js +++ b/tools/clis/ga4.js @@ -11,6 +11,9 @@ if (!ACCESS_TOKEN) { } async function api(method, baseUrl, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${baseUrl}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${baseUrl}${path}`, { method, headers: { @@ -29,6 +32,9 @@ async function api(method, baseUrl, path, body) { async function mpApi(measurementId, apiSecret, body) { const params = new URLSearchParams({ measurement_id: measurementId, api_secret: apiSecret }) + if (args['dry-run']) { + return { _dry_run: true, method: 'POST', url: `${MP_URL}?${new URLSearchParams({ measurement_id: measurementId, api_secret: '***' })}`, headers: { 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${MP_URL}?${params}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, diff --git a/tools/clis/google-ads.js b/tools/clis/google-ads.js index c18a9bf..87f0413 100755 --- a/tools/clis/google-ads.js +++ b/tools/clis/google-ads.js @@ -11,6 +11,9 @@ if (!TOKEN || !DEV_TOKEN || !CUSTOMER_ID) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'developer-token': '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/google-search-console.js b/tools/clis/google-search-console.js index f94a29b..17c1641 100755 --- a/tools/clis/google-search-console.js +++ b/tools/clis/google-search-console.js @@ -9,6 +9,9 @@ if (!ACCESS_TOKEN) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/hotjar.js b/tools/clis/hotjar.js index 38f62d3..313dc78 100755 --- a/tools/clis/hotjar.js +++ b/tools/clis/hotjar.js @@ -27,6 +27,9 @@ async function getToken() { } async function api(method, path) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', Accept: 'application/json' } } + } const token = await getToken() const res = await fetch(`${BASE_URL}${path}`, { method, diff --git a/tools/clis/intercom.js b/tools/clis/intercom.js index 5fcb57a..4630255 100755 --- a/tools/clis/intercom.js +++ b/tools/clis/intercom.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', Accept: 'application/json', 'Intercom-Version': '2.11' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/keywords-everywhere.js b/tools/clis/keywords-everywhere.js index 18809c8..5f0dc8c 100755 --- a/tools/clis/keywords-everywhere.js +++ b/tools/clis/keywords-everywhere.js @@ -9,13 +9,17 @@ if (!API_KEY) { } async function api(method, path, body) { + const headers = { + 'Authorization': `Bearer ${API_KEY}`, + 'Content-Type': 'application/json', + 'Accept': 'application/json', + } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, - headers: { - 'Authorization': `Bearer ${API_KEY}`, - 'Content-Type': 'application/json', - 'Accept': 'application/json', - }, + headers, body: body ? JSON.stringify(body) : undefined, }) const text = await res.text() diff --git a/tools/clis/kit.js b/tools/clis/kit.js index 41a8973..5868699 100755 --- a/tools/clis/kit.js +++ b/tools/clis/kit.js @@ -31,6 +31,18 @@ async function api(method, path, body, useSecret = true) { } opts.body = JSON.stringify(authBody) } + if (args['dry-run']) { + const dryRunHeaders = { ...opts.headers } + const dryRunUrl = url.toString().replace(API_SECRET, '***').replace(API_KEY, '***') + let dryRunBody = undefined + if (opts.body) { + const parsed = JSON.parse(opts.body) + if (parsed.api_secret) parsed.api_secret = '***' + if (parsed.api_key) parsed.api_key = '***' + dryRunBody = parsed + } + return { _dry_run: true, method, url: dryRunUrl, headers: dryRunHeaders, body: dryRunBody } + } const res = await fetch(url.toString(), opts) const text = await res.text() try { diff --git a/tools/clis/klaviyo.js b/tools/clis/klaviyo.js index d23bf34..d74966f 100755 --- a/tools/clis/klaviyo.js +++ b/tools/clis/klaviyo.js @@ -10,14 +10,18 @@ if (!API_KEY) { } async function api(method, path, body) { + const headers = { + 'Authorization': `Klaviyo-API-Key ${API_KEY}`, + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'revision': REVISION, + } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, - headers: { - 'Authorization': `Klaviyo-API-Key ${API_KEY}`, - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'revision': REVISION, - }, + headers, body: body ? JSON.stringify(body) : undefined, }) const text = await res.text() diff --git a/tools/clis/linkedin-ads.js b/tools/clis/linkedin-ads.js index 5f74054..dc805e5 100755 --- a/tools/clis/linkedin-ads.js +++ b/tools/clis/linkedin-ads.js @@ -9,12 +9,16 @@ if (!TOKEN) { } async function api(method, path, body) { + const headers = { + 'Authorization': `Bearer ${TOKEN}`, + 'Content-Type': 'application/json', + } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, - headers: { - 'Authorization': `Bearer ${TOKEN}`, - 'Content-Type': 'application/json', - }, + headers, body: body ? JSON.stringify(body) : undefined, }) const text = await res.text() diff --git a/tools/clis/livestorm.js b/tools/clis/livestorm.js index 7233c78..b393e32 100755 --- a/tools/clis/livestorm.js +++ b/tools/clis/livestorm.js @@ -9,13 +9,17 @@ if (!API_TOKEN) { } async function api(method, path, body) { + const headers = { + 'Authorization': API_TOKEN, + 'Content-Type': 'application/vnd.api+json', + 'Accept': 'application/vnd.api+json', + } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, - headers: { - 'Authorization': API_TOKEN, - 'Content-Type': 'application/vnd.api+json', - 'Accept': 'application/vnd.api+json', - }, + headers, body: body ? JSON.stringify(body) : undefined, }) const text = await res.text() diff --git a/tools/clis/mailchimp.js b/tools/clis/mailchimp.js index b5e8e6b..1cacf3f 100755 --- a/tools/clis/mailchimp.js +++ b/tools/clis/mailchimp.js @@ -11,12 +11,16 @@ const dc = API_KEY.split('-').pop() const BASE_URL = `https://${dc}.api.mailchimp.com/3.0` async function api(method, path, body) { + const headers = { + 'Authorization': `Bearer ${API_KEY}`, + 'Content-Type': 'application/json', + } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, - headers: { - 'Authorization': `Bearer ${API_KEY}`, - 'Content-Type': 'application/json', - }, + headers, body: body ? JSON.stringify(body) : undefined, }) const text = await res.text() diff --git a/tools/clis/mention-me.js b/tools/clis/mention-me.js index 0fb68f1..fba1f58 100755 --- a/tools/clis/mention-me.js +++ b/tools/clis/mention-me.js @@ -9,12 +9,16 @@ if (!API_KEY) { } async function api(method, path, body) { + const headers = { + 'Authorization': `Bearer ${API_KEY}`, + 'Content-Type': 'application/json', + } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, - headers: { - 'Authorization': `Bearer ${API_KEY}`, - 'Content-Type': 'application/json', - }, + headers, body: body ? JSON.stringify(body) : undefined, }) const text = await res.text() diff --git a/tools/clis/meta-ads.js b/tools/clis/meta-ads.js index b9492a7..3261617 100755 --- a/tools/clis/meta-ads.js +++ b/tools/clis/meta-ads.js @@ -17,6 +17,10 @@ async function api(method, path, body) { opts.headers['Content-Type'] = 'application/json' opts.body = JSON.stringify(body) } + if (args['dry-run']) { + const dryRunUrl = url.replace(TOKEN, '***') + return { _dry_run: true, method, url: dryRunUrl, headers: opts.headers, body: body || undefined } + } const res = await fetch(url, opts) const text = await res.text() try { diff --git a/tools/clis/mixpanel.js b/tools/clis/mixpanel.js index 8ec8726..f53766e 100755 --- a/tools/clis/mixpanel.js +++ b/tools/clis/mixpanel.js @@ -13,9 +13,13 @@ if (!TOKEN && !API_KEY) { } async function ingestApi(method, path, body) { + const headers = { 'Content-Type': 'application/json' } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${INGESTION_URL}${path}`, headers, body: body || undefined } + } const res = await fetch(`${INGESTION_URL}${path}`, { method, - headers: { 'Content-Type': 'application/json' }, + headers, body: body ? JSON.stringify(body) : undefined, }) const text = await res.text() @@ -32,12 +36,16 @@ async function queryApi(method, baseUrl, path, params) { } const auth = Buffer.from(`${API_KEY}:${SECRET}`).toString('base64') const url = params ? `${baseUrl}${path}?${params}` : `${baseUrl}${path}` + const headers = { + 'Authorization': `Basic ${auth}`, + 'Content-Type': 'application/json', + } + if (args['dry-run']) { + return { _dry_run: true, method, url, headers: { ...headers, Authorization: '***' } } + } const res = await fetch(url, { method, - headers: { - 'Authorization': `Basic ${auth}`, - 'Content-Type': 'application/json', - }, + headers, }) const text = await res.text() try { @@ -52,12 +60,16 @@ async function queryApiPost(path, body) { return { error: 'MIXPANEL_API_KEY and MIXPANEL_SECRET required for query/export operations' } } const auth = Buffer.from(`${API_KEY}:${SECRET}`).toString('base64') + const headers = { + 'Authorization': `Basic ${auth}`, + 'Content-Type': 'application/json', + } + if (args['dry-run']) { + return { _dry_run: true, method: 'POST', url: `${QUERY_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined } + } const res = await fetch(`${QUERY_URL}${path}`, { method: 'POST', - headers: { - 'Authorization': `Basic ${auth}`, - 'Content-Type': 'application/json', - }, + headers, body: JSON.stringify(body), }) const text = await res.text() diff --git a/tools/clis/onesignal.js b/tools/clis/onesignal.js index 9532ea0..408ecd7 100755 --- a/tools/clis/onesignal.js +++ b/tools/clis/onesignal.js @@ -15,13 +15,17 @@ if (!APP_ID) { } async function api(method, path, body) { + const headers = { + 'Authorization': `Basic ${REST_API_KEY}`, + 'Content-Type': 'application/json', + 'Accept': 'application/json', + } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { ...headers, Authorization: '***' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, - headers: { - 'Authorization': `Basic ${REST_API_KEY}`, - 'Content-Type': 'application/json', - 'Accept': 'application/json', - }, + headers, body: body ? JSON.stringify(body) : undefined, }) const text = await res.text() diff --git a/tools/clis/optimizely.js b/tools/clis/optimizely.js index 8bfe696..fb0c6a3 100755 --- a/tools/clis/optimizely.js +++ b/tools/clis/optimizely.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/paddle.js b/tools/clis/paddle.js index ec7cf08..cd8d9b8 100755 --- a/tools/clis/paddle.js +++ b/tools/clis/paddle.js @@ -11,6 +11,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/partnerstack.js b/tools/clis/partnerstack.js index 2fc122f..b6c3d2e 100755 --- a/tools/clis/partnerstack.js +++ b/tools/clis/partnerstack.js @@ -12,6 +12,9 @@ if (!PUBLIC_KEY || !SECRET_KEY) { const AUTH = 'Basic ' + Buffer.from(`${PUBLIC_KEY}:${SECRET_KEY}`).toString('base64') async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/plausible.js b/tools/clis/plausible.js index 0bc064c..62f4111 100755 --- a/tools/clis/plausible.js +++ b/tools/clis/plausible.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/postmark.js b/tools/clis/postmark.js index 0a45b93..e66ca08 100755 --- a/tools/clis/postmark.js +++ b/tools/clis/postmark.js @@ -9,6 +9,15 @@ if (!API_KEY) { } async function api(method, path, body, useAccountToken) { + if (args['dry-run']) { + const maskedHeaders = { 'Content-Type': 'application/json', 'Accept': 'application/json' } + if (useAccountToken) { + maskedHeaders['X-Postmark-Account-Token'] = '***' + } else { + maskedHeaders['X-Postmark-Server-Token'] = '***' + } + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: maskedHeaders, body: body || undefined } + } const headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', diff --git a/tools/clis/resend.js b/tools/clis/resend.js index 6324666..d0fd0ba 100755 --- a/tools/clis/resend.js +++ b/tools/clis/resend.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/rewardful.js b/tools/clis/rewardful.js index 7037346..da2af02 100755 --- a/tools/clis/rewardful.js +++ b/tools/clis/rewardful.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/savvycal.js b/tools/clis/savvycal.js index 8245c87..046c565 100755 --- a/tools/clis/savvycal.js +++ b/tools/clis/savvycal.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/segment.js b/tools/clis/segment.js index 407b447..963993a 100755 --- a/tools/clis/segment.js +++ b/tools/clis/segment.js @@ -14,6 +14,9 @@ async function trackApi(method, path, body) { if (!WRITE_KEY) { return { error: 'SEGMENT_WRITE_KEY required for tracking operations' } } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${TRACKING_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const auth = Buffer.from(`${WRITE_KEY}:`).toString('base64') const res = await fetch(`${TRACKING_URL}${path}`, { method, @@ -35,6 +38,9 @@ async function profileApi(method, path) { if (!ACCESS_TOKEN) { return { error: 'SEGMENT_ACCESS_TOKEN required for profile operations' } } + if (args['dry-run']) { + return { _dry_run: true, method, url: `${PROFILE_URL}${path}`, headers: { Authorization: '***', 'Content-Type': 'application/json' } } + } const auth = Buffer.from(`${ACCESS_TOKEN}:`).toString('base64') const res = await fetch(`${PROFILE_URL}${path}`, { method, diff --git a/tools/clis/semrush.js b/tools/clis/semrush.js index 0e8c472..fe55b71 100755 --- a/tools/clis/semrush.js +++ b/tools/clis/semrush.js @@ -28,6 +28,11 @@ function parseCSV(text) { async function api(params) { params.set('key', API_KEY) params.set('export_escape', '1') + if (args['dry-run']) { + const maskedParams = new URLSearchParams(params) + maskedParams.set('key', '***') + return { _dry_run: true, method: 'GET', url: `${BASE_URL}?${maskedParams}`, headers: {}, body: undefined } + } const res = await fetch(`${BASE_URL}?${params}`) const text = await res.text() if (!res.ok) { diff --git a/tools/clis/sendgrid.js b/tools/clis/sendgrid.js index c7c2960..1fa1fa4 100755 --- a/tools/clis/sendgrid.js +++ b/tools/clis/sendgrid.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/tiktok-ads.js b/tools/clis/tiktok-ads.js index 23a4443..338f2b0 100755 --- a/tools/clis/tiktok-ads.js +++ b/tools/clis/tiktok-ads.js @@ -10,6 +10,9 @@ if (!TOKEN) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Access-Token': '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const opts = { method, headers: { diff --git a/tools/clis/tolt.js b/tools/clis/tolt.js index 5aa2da6..226b68c 100755 --- a/tools/clis/tolt.js +++ b/tools/clis/tolt.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/trustpilot.js b/tools/clis/trustpilot.js index 961ae45..66f58b4 100755 --- a/tools/clis/trustpilot.js +++ b/tools/clis/trustpilot.js @@ -32,6 +32,15 @@ async function getAccessToken() { } async function api(method, path, body, auth = 'apikey') { + if (args['dry-run']) { + const maskedHeaders = { 'Content-Type': 'application/json', 'Accept': 'application/json' } + if (auth === 'bearer') { + maskedHeaders['Authorization'] = '***' + } else { + maskedHeaders['apikey'] = '***' + } + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: maskedHeaders, body: body || undefined } + } const headers = { 'Content-Type': 'application/json', 'Accept': 'application/json', diff --git a/tools/clis/typeform.js b/tools/clis/typeform.js index 12d24aa..0606e73 100755 --- a/tools/clis/typeform.js +++ b/tools/clis/typeform.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/wistia.js b/tools/clis/wistia.js index 8ce28d9..4d9ca0b 100755 --- a/tools/clis/wistia.js +++ b/tools/clis/wistia.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'Authorization': '***', 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { diff --git a/tools/clis/zapier.js b/tools/clis/zapier.js index dc8f38d..082583d 100755 --- a/tools/clis/zapier.js +++ b/tools/clis/zapier.js @@ -9,6 +9,9 @@ if (!API_KEY) { } async function api(method, path, body) { + if (args['dry-run']) { + return { _dry_run: true, method, url: `${BASE_URL}${path}`, headers: { 'X-API-Key': '***', 'Content-Type': 'application/json' }, body: body || undefined } + } const res = await fetch(`${BASE_URL}${path}`, { method, headers: { @@ -26,6 +29,9 @@ async function api(method, path, body) { } async function webhookPost(url, data) { + if (args['dry-run']) { + return { _dry_run: true, method: 'POST', url, headers: { 'Content-Type': 'application/json' }, body: data || undefined } + } const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' },