Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added — Homebrew command route

- Review now offers a choice: the existing **Guided setup** (plan download and
local companion, unchanged and still the default) or a **Homebrew command**
that lists only the selected packages, for example
`brew install --formula mas; brew install --cask google-chrome vlc`. Selected
App Store apps get an optional `mas get <id>…` line; preferences, setup steps,
connections and manual installs are listed as not included, with a way back
to the guided setup. The chosen route is remembered locally.
- Commands are generated from allowlisted catalogue tokens only, one line each,
with groups separated by `;` so a formula failure does not skip the apps.

### Fixed — copied launch command

- **Copy** on the handoff page copied the companion launcher with two line
breaks, because formatting had wrapped the command across three lines in the
HTML. Pasting ran `curl -fsSL` without a URL and failed with
`parse error near '|'`. Copy buttons now write canonical one-line strings, and
unit and browser tests guard the page fallback and the clipboard text.

### Changed — shared component contract

- Consolidated control geometry, spacing and response tokens; kept geometry in
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ edit every optional choice, and export your plan. The local companion opens the
same interface on your Mac, asks for confirmation, and follows the real installer
step by step. **Essentials** is a light default; **BRITX Choice** is Pedro's
personal recommendation. Developer, Education, Productivity and Creative profiles
provide other starting points.
provide other starting points. Prefer something lighter? Review also offers a
plain **Homebrew command** for just the apps and tools you selected, with no
preferences or setup steps.

From a clone:

Expand Down
2 changes: 2 additions & 0 deletions docs/ACCEPTANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ Reviewer/date: ____________________
| Production performance | Measure fluid/calm frame behaviour on target hardware, recording conditions and measurements. | Not run | |
| Language review | A qualified reviewer checks meaning, terminology and truncation in each locale. | Not run | |
| Real production handoff | Export from the live site and complete the reviewed installation on the disposable Mac. | Not run | |
| Copied launcher | Copy the handoff command from the live site, paste it into Terminal (zsh) and confirm the companion starts. | Not run | |
| Homebrew command route | Copy the generated commands from the live site for a small selection; confirm Homebrew installs exactly those packages and `mas get` behaves as described when signed in and signed out. | Not run | |

## Evidence recorded in this follow-up

Expand Down
5 changes: 4 additions & 1 deletion docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ Python standard-library companion bound to `127.0.0.1`. The browser submits a
versioned plan of allowlisted IDs after local confirmation; the companion writes
data-only picker keys and calls `install.sh --selection`. It reads module events
and append-only reports for real progress. It does not accept shell commands,
package URLs, arbitrary paths or MCP credentials from the browser.
package URLs, arbitrary paths or MCP credentials from the browser. The public
site's optional Homebrew command route only displays commands for the user to
copy (`docs/assets/commands.mjs`); it emits allowlisted catalogue tokens and
never sends commands anywhere.

The [Liquid Acrylic presentation layer](LIQUID_INTERFACE.md) decorates native
controls with CSS/SVG and small fixed-step springs. Its motion, theme and
Expand Down
25 changes: 25 additions & 0 deletions docs/WEB_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,31 @@ locally and system accessibility preferences take precedence. See the
The public launcher requires the browser changes to have been published to the
repository first. Local development and review work directly from this checkout.

## Homebrew command route

At step 3, the public site also offers **Homebrew command** instead of the guided
setup. Guided setup stays the default; the choice is remembered in local storage
only and never enters the exported plan. The route shows plain commands built
from the selected catalogue tokens, in Brewfile order:

```bash
brew install --formula mas; brew install --cask google-chrome appcleaner 1password vlc
mas get 425424353 # optional, only when App Store apps are selected
```

- Each command is one line. Copy buttons write the generated string, not page
text, so wrapping can never insert a line break into Terminal.
- `;` keeps formulae and casks independent. Within a cask list, current Homebrew
reports a failing cask and continues with the rest.
- `mas get` (mas 7+, the current Homebrew version) gets free apps and installs
apps the Apple Account already owns. It needs App Store sign-in, may ask for
the Mac password, and cannot buy paid apps.
- Homebrew itself is a prerequisite and links to [brew.sh](https://brew.sh).
Preferences, setup steps, MCP connections, web apps and manual installs are
listed as not included; they need the guided setup or the user's own steps.
- Unlike the guided installer, this route produces no reports or verification,
and it skips the selection-aware module behaviour described below.

## What is automated

The [generated inventory](CATALOG.md) is the full list. Homebrew formulae/casks,
Expand Down
127 changes: 112 additions & 15 deletions docs/assets/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import { icon } from "./icons.mjs";
import { createSourcePicker } from "./source-picker.mjs";
import { requestTranslation, translate } from "./i18n.mjs";
import { APP_ICONS } from "./app-icons.mjs";
import { LAUNCH_COMMAND, homebrewCommands, oneLine } from "./commands.mjs";

const $ = (id) => document.getElementById(id);
const STORAGE_KEY = "mac-setup.plan.v1";
const METHOD_KEY = "mac-setup.method.v1";
const MODULE_NAMES = {
xcode: "Command Line Tools & Apple tooling",
brew: "Homebrew & packages",
Expand Down Expand Up @@ -68,11 +70,13 @@ const PRIORITY = [
let catalog;
let selected = new Set();
let profile = "essentials";
let method = "guided";
let category = "all";
let selectedOnly = false;
let session = null;
let token = "";
let pollTimer;
let commands = { brew: "", appStore: "" };
let followupSignature = "";
let lastRunStatus = "";
let starting = false;
Expand Down Expand Up @@ -519,9 +523,10 @@ function renderSelection() {
}
function setView(view, moveFocus = true) {
requestTranslation();
for (const name of ["choose", "review", "guide", "progress"])
for (const name of ["choose", "review", "guide", "command", "progress"])
$(`${name}-view`).hidden = name !== view;
const step = view === "choose" ? 0 : view === "review" ? 1 : 2;
renderInstallStep();
document.querySelectorAll(".stepper li").forEach((node, index) => {
node.classList.toggle("complete", index < step);
if (index === step) node.setAttribute("aria-current", "step");
Expand All @@ -543,6 +548,11 @@ function setView(view, moveFocus = true) {
"step by step.",
"A short handoff, then your Mac takes it from here.",
],
command: [
"Your apps, ",
"one command.",
"Paste it into Terminal. Only what you chose is installed.",
],
progress: [
"Your setup, ",
"step by step.",
Expand Down Expand Up @@ -617,20 +627,97 @@ function renderReview() {
$("git-identity").hidden = !session || !selected.has("step:git");
$("confirm-install").checked = false;
$("continue-button").disabled = Boolean(session);
renderReviewActions();
setView("review");
}
// The public site offers two routes; the local companion always installs.
function renderReviewActions() {
const homebrew = !session && method === "homebrew";
$("install-method").hidden = Boolean(session);
for (const input of document.querySelectorAll('[name="install-method"]'))
input.checked = input.value === method;
$("continue-button").textContent = session
? session.dryRun
? "Start dry-run preview"
: "Install my setup"
: "Download plan & continue";
: homebrew
? "Show Homebrew command"
: "Download plan & continue";
$("review-explanation").textContent = session
? session.dryRun
? "Preview your actual installer commands. No apps, shell files or system preferences will be changed."
: "The local companion will run this selection. Administrator prompts appear in Terminal. Account sign-ins and purchases remain yours."
: "Download your plan, then open the local companion on your Mac for a guided installation.";
: homebrew
? "Get a ready-to-paste Terminal command for the apps and tools you selected."
: "Download your plan, then open the local companion on your Mac for a guided installation.";
$("review-caption").textContent = session
? "Keep Terminal open throughout setup."
: "Your plan contains choices, never credentials.";
setView("review");
: homebrew
? "Nothing runs until you paste it into Terminal."
: "Your plan contains choices, never credentials.";
renderInstallStep();
requestTranslation();
}
function renderInstallStep() {
$("install-step-label").textContent =
!session && method === "homebrew"
? "Homebrew command"
: "Guided installation";
}
function changeMethod(next) {
method = next === "homebrew" ? "homebrew" : "guided";
try {
localStorage.setItem(METHOD_KEY, method);
} catch {
/* The choice still applies to this visit. */
}
renderReviewActions();
}
function renderCommands() {
requestTranslation();
const result = homebrewCommands(catalog, selected);
commands = { brew: result.command, appStore: result.appStoreCommand };
showCommand($("brew-command"), result.command);
$("brew-command-box").hidden = !result.command;
$("brew-empty").hidden = Boolean(result.command);
$("brew-summary").hidden = !result.command;
$("brew-summary").textContent =
`Command-line tools: ${result.formulae.length} · Apps: ${result.casks.length}`;
$("app-store-step").hidden = !result.appStoreCommand;
showCommand($("app-store-command"), result.appStoreCommand);
for (const id of ["copy-brew-command", "copy-app-store-command"])
$(id).textContent = "Copy";
$("not-included").hidden = result.notIncluded.length === 0;
$("not-included-list").replaceChildren(
...result.notIncluded.map((item) => element("li", "", item.name)),
);
setView("command");
}
// Each word wraps as a unit, so hyphenated names never look like two packages.
function showCommand(node, command) {
node.replaceChildren(
...command
.split(" ")
.flatMap((word, index) => [
...(index ? [document.createTextNode(" ")] : []),
element("span", "", word),
]),
);
}
function bindCopy(button, text) {
button.addEventListener("click", async () => {
const value = oneLine(text());
if (!value) return;
try {
await navigator.clipboard.writeText(value);
button.textContent = "Copied";
announce("Command copied. Paste it into Terminal and press Return.");
} catch {
showError(
"Clipboard access is unavailable. Select the command and copy it manually.",
);
}
});
}
function download(content, name, type = "application/json") {
const url = URL.createObjectURL(new Blob([content], { type }));
Expand Down Expand Up @@ -672,6 +759,10 @@ async function api(path, options = {}) {
async function startInstallation() {
if (starting) return;
if (!session) {
if (method === "homebrew") {
renderCommands();
return;
}
exportPlan();
setView("guide");
return;
Expand Down Expand Up @@ -964,16 +1055,16 @@ function bindEvents() {
event.target.value = "";
}
});
$("copy-command").addEventListener("click", async () => {
try {
await navigator.clipboard.writeText($("launch-command").textContent);
$("copy-command").textContent = "Copied";
requestTranslation();
} catch {
showError(
"Clipboard access is unavailable. Select the command and copy it manually.",
);
}
// Copy from the canonical strings, never from formatted markup.
bindCopy($("copy-command"), () => LAUNCH_COMMAND);
bindCopy($("copy-brew-command"), () => commands.brew);
bindCopy($("copy-app-store-command"), () => commands.appStore);
for (const input of document.querySelectorAll('[name="install-method"]'))
input.addEventListener("change", () => changeMethod(input.value));
$("command-back").addEventListener("click", renderReview);
$("switch-to-guided").addEventListener("click", () => {
changeMethod("guided");
renderReview();
});
$("report-button").addEventListener("click", () => downloadReport("install"));
$("manual-report-button").addEventListener("click", () =>
Expand Down Expand Up @@ -1017,6 +1108,12 @@ async function init() {
);
catalog = await response.json();
selected = profileSelection(catalog, profile);
$("launch-command").textContent = LAUNCH_COMMAND;
try {
if (localStorage.getItem(METHOD_KEY) === "homebrew") method = "homebrew";
} catch {
/* Guided setup remains the default. */
}
try {
const stored = localStorage.getItem(STORAGE_KEY);
if (stored) {
Expand Down
58 changes: 58 additions & 0 deletions docs/assets/commands.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copy-ready Terminal commands. Everything returned here reaches the clipboard
// verbatim, so each command is exactly one line: a newline pasted into Terminal
// runs a partial command and breaks the rest.

export const LAUNCH_COMMAND =
"curl -fsSL https://raw.githubusercontent.com/pedrobritx/mac-setup/main/bootstrap.sh | bash -s -- --web";

// Homebrew names: lower-case tokens, optionally tap-qualified (user/repo/name).
const PACKAGE = /^[a-z0-9][a-z0-9+@._-]*(?:\/[a-z0-9][a-z0-9+@._-]*){0,2}$/;
const APP_STORE_ID = /^[0-9]+$/;

/** Collapse any whitespace, including line breaks, into single spaces. */
export function oneLine(text) {
return String(text).replace(/\s+/g, " ").trim();
}

/**
* Plain Homebrew commands for the selected catalogue items, in Brewfile order.
* Only allowlisted catalogue tokens are emitted; anything else is reported as
* not covered, so the guided setup remains the path for preferences, setup
* steps, connections and manual installs.
*/
export function homebrewCommands(catalog, selection) {
const chosen = catalog.items.filter((item) => selection.has(item.id));
const formulae = [];
const casks = [];
const appStore = [];
const notIncluded = [];
for (const item of chosen) {
if (item.locked) continue; // Command Line Tools and Homebrew: prerequisites.
const list =
item.type === "brew" && PACKAGE.test(item.token)
? formulae
: item.type === "cask" && PACKAGE.test(item.token)
? casks
: item.type === "mas" && APP_STORE_ID.test(item.token)
? appStore
: null;
if (!list) notIncluded.push(item);
else if (!list.some((entry) => entry.token === item.token)) list.push(item);
}
const names = (items) => items.map((item) => item.token).join(" ");
// `;` keeps the groups independent: a formula failure must not skip the apps.
const command = [
formulae.length ? `brew install --formula ${names(formulae)}` : "",
casks.length ? `brew install --cask ${names(casks)}` : "",
]
.filter(Boolean)
.join("; ");
return {
formulae,
casks,
appStore,
notIncluded,
command,
appStoreCommand: appStore.length ? `mas get ${names(appStore)}` : "",
};
}
Loading
Loading