@dreamdata_io/verify-tracking 0.1.1 → 0.1.2
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/package.json +1 -1
- package/scripts/install.sh +78 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamdata_io/verify-tracking",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Scrapes a live website with Playwright and asks an AI model whether the Dreamdata Analytics Script is correctly installed.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/scripts/install.sh
CHANGED
|
@@ -327,22 +327,93 @@ else
|
|
|
327
327
|
fi
|
|
328
328
|
|
|
329
329
|
# ---------------------------------------------------------------------------
|
|
330
|
-
#
|
|
330
|
+
# 7. PATH
|
|
331
331
|
# ---------------------------------------------------------------------------
|
|
332
332
|
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
# Appended for the operator rather than printed for them to paste. The people
|
|
334
|
+
# this installer is for do not know what a shell profile is, and "now edit
|
|
335
|
+
# ~/.zshrc" is the second place a handover stops.
|
|
336
|
+
#
|
|
337
|
+
# Every profile that already exists gets the line, not just the one implied by
|
|
338
|
+
# $SHELL: a macOS login shell reads ~/.zprofile, an interactive one ~/.zshrc,
|
|
339
|
+
# and bash reads ~/.bash_profile rather than ~/.bashrc — guessing a single file
|
|
340
|
+
# is how the line lands somewhere that is never sourced. A file that does not
|
|
341
|
+
# exist is left uncreated, so this never conjures a profile for a shell the
|
|
342
|
+
# machine does not use.
|
|
343
|
+
#
|
|
344
|
+
# What it cannot do is take effect in the terminal that ran it: this script is
|
|
345
|
+
# a child process, and no child can alter its parent's environment. So the
|
|
346
|
+
# closing lines send the operator to a new terminal window rather than letting
|
|
347
|
+
# them discover that on a `command not found`.
|
|
348
|
+
PATH_LINE="export PATH=\"$BIN_DIR:\$PATH\""
|
|
349
|
+
# BIN_DIR is a path, and a path is not a regex: an unescaped `.` in `.local`
|
|
350
|
+
# would match any character, so a near-miss line could read as a hit. The class
|
|
351
|
+
# is the full ERE metacharacter set, not just the BRE one — grep runs with -E,
|
|
352
|
+
# and a home directory is free to contain a `+` or a `(`.
|
|
353
|
+
bin_dir_re="$(printf '%s' "$BIN_DIR" | sed 's/[].[^$*+?(){}|\/\\]/\\&/g')"
|
|
354
|
+
|
|
355
|
+
add_to_profile() {
|
|
356
|
+
profile="$1"
|
|
357
|
+
[ -f "$profile" ] || return 0
|
|
358
|
+
# Anchored, and only on an uncommented line: a commented-out or
|
|
359
|
+
# differently-worded mention must not read as "already configured". BIN_DIR
|
|
360
|
+
# has to end a PATH component too — as a bare substring, `~/.local/bin` is
|
|
361
|
+
# also inside `~/.local/bin2`, and a match there would skip a profile that
|
|
362
|
+
# never had the line.
|
|
363
|
+
if grep -Eq "^[[:space:]]*export[[:space:]]+PATH=.*${bin_dir_re}([:\"']|\$)" "$profile"; then
|
|
364
|
+
say "already in $profile"
|
|
365
|
+
return 0
|
|
366
|
+
fi
|
|
367
|
+
# A profile that cannot be written to is a PATH the operator has to set by
|
|
368
|
+
# hand, not a failed install — under `set -e` an unguarded append would take
|
|
369
|
+
# the whole run down over a read-only home.
|
|
370
|
+
if printf '\n# Added by the verify-tracking installer\n%s\n' "$PATH_LINE" >> "$profile" 2>/dev/null; then
|
|
371
|
+
say "added to $profile"
|
|
372
|
+
else
|
|
373
|
+
say "could not write $profile. Add this line to it yourself:"
|
|
374
|
+
printf '\n %s\n' "$PATH_LINE"
|
|
375
|
+
fi
|
|
376
|
+
}
|
|
335
377
|
|
|
378
|
+
step "PATH"
|
|
336
379
|
case ":${PATH}:" in
|
|
337
|
-
*":$BIN_DIR:"*)
|
|
380
|
+
*":$BIN_DIR:"*)
|
|
381
|
+
say "$BIN_DIR is already on your PATH"
|
|
382
|
+
;;
|
|
338
383
|
*)
|
|
339
|
-
|
|
340
|
-
|
|
384
|
+
for profile in "$HOME/.zshrc" "$HOME/.zprofile" "$HOME/.bashrc" "$HOME/.bash_profile"; do
|
|
385
|
+
add_to_profile "$profile"
|
|
386
|
+
done
|
|
387
|
+
# Nothing to append to means nothing was appended — print the line rather
|
|
388
|
+
# than claim a PATH change that did not happen.
|
|
389
|
+
if [ -f "$HOME/.zshrc" ] || [ -f "$HOME/.zprofile" ] \
|
|
390
|
+
|| [ -f "$HOME/.bashrc" ] || [ -f "$HOME/.bash_profile" ]; then
|
|
391
|
+
:
|
|
392
|
+
else
|
|
393
|
+
say "no shell profile found. Add this line to yours:"
|
|
394
|
+
printf '\n %s\n' "$PATH_LINE"
|
|
395
|
+
fi
|
|
341
396
|
;;
|
|
342
397
|
esac
|
|
343
398
|
|
|
399
|
+
# ---------------------------------------------------------------------------
|
|
400
|
+
# Done
|
|
401
|
+
# ---------------------------------------------------------------------------
|
|
402
|
+
|
|
403
|
+
printf '\n==> Installed\n'
|
|
404
|
+
"$BIN_DIR/verify-tracking" --version 2>/dev/null | sed 's/^/ /' || true
|
|
405
|
+
|
|
344
406
|
printf '\n Reports and dashboard:\n\n %s\n' "$REPORTS_HOME"
|
|
345
|
-
printf '\n Try it:\n\n verify-tracking --slug dreamdata_io --url https://dreamdata.io/\n'
|
|
407
|
+
printf '\n Try it, from a new terminal window:\n\n verify-tracking --slug dreamdata_io --url https://dreamdata.io/\n'
|
|
408
|
+
|
|
409
|
+
# Claimed only where a browser can actually appear: --dashboard skips opening
|
|
410
|
+
# one on a machine with nobody in front of it, and an installer that announces
|
|
411
|
+
# a window that never arrives sends the operator looking for it.
|
|
412
|
+
if [ -r /dev/tty ]; then
|
|
413
|
+
printf '\n A browser window is opening with your dashboard. Type an account slug\n'
|
|
414
|
+
printf ' and a URL there to build your command, then open a new terminal window\n'
|
|
415
|
+
printf ' and run it.\n'
|
|
416
|
+
fi
|
|
346
417
|
# The reports folder is the operator's data and is deliberately left out: an
|
|
347
418
|
# `rm -rf` line someone pastes without reading must not take their work with it.
|
|
348
419
|
printf '\n Uninstall (your reports folder is left in place):\n\n rm -rf %s %s/verify-tracking %s/verify-tracking-mcp\n\n' "$PREFIX" "$BIN_DIR" "$BIN_DIR"
|