dma-advisor
v0.1.4
Published
Build-time SDK + CLI that reports a site's deploys and dependencies to DMA Web Advisor
Maintainers
Readme
dma-advisor
Build-time SDK and CLI for DMA Web Advisor, Del Mar Advertising's internal site registry. On every build it posts a small report (commit, branch, framework, dependency versions) to the advisor so the fleet dashboard can track deploys and dependency drift. It never fails a build: reporting is fire-and-forget with a short timeout.
Setup
Log the machine in once, with a token from the advisor dashboard (Keys → CLI login tokens shows the exact command):
npx dma-advisor@latest login --url https://your-advisor.example.com --token <token>Then, in each site's repo, one command:
npx dma-advisor@latest initIt asks for the production URL, the site name (defaulting to the URL's
domain), and the client (choose from the advisor's list or create one). It
checks the local files, adds the site, saves its credentials, installs
dma-advisor with the repo's package manager, and patches astro.config.* /
vite.config.*, and — when the repo is linked to Netlify or Vercel and that
CLI is logged in — sets the same two variables on the host (production
context). If it cannot, it tells you to add them to the host yourself.
| Flag | Meaning |
| --- | --- |
| --yes | Ask nothing; use flags, detected values, and defaults |
| --json | Ask nothing; print one JSON result to stdout, without credentials |
| --name <site> | Site name (default: the production URL's domain, else the package.json name) |
| --production-url <url> | Live URL to monitor (default: the Astro config's site:) |
| --client <name> | Client to file the site under; reused by name, created if new |
| --key <site key> | Skip adding a site: wire this repo to one created in the dashboard |
| --config <path> | The Astro/Vite config when it is not at the top of the working directory (e.g. console/vite.config.ts); .env is saved beside it, where the build reads it |
| --url <advisor> | Advisor base URL (default: ADVISOR_URL, then project env files, then the saved login) |
Reruns and automation
init reuses an existing project key (or ADVISOR_KEY from the environment)
without logging in or creating another site. Reruns finish local setup; they
do not update the site's name, URL, or client in the dashboard. Existing keys
are checked for valid format but are not verified against the server.
Credentials are saved atomically with owner-only file permissions before
package installation or config edits. Duplicate .env assignments are
consolidated, and unrelated values and comments are preserved. If a later
step fails, fix the reported issue and rerun the same command. A conflicting
advisor URL or key requires an explicit choice; conflicting overrides in
.env.local or production env files must be corrected first.
--yes, --json, and non-TTY input never prompt. Missing inputs, unknown
flags, and missing flag values fail with an instruction. For example, with
ADVISOR_URL and ADVISOR_TOKEN already supplied:
npx dma-advisor init --json --name client-site.com --production-url https://client-site.com --client "Client Name"The JSON result includes status, registration, credentials, package,
config, host, warnings, nextSteps, and an error when applicable.
Exit code 0 means local setup is configured; 1 means incomplete
or failed. Check host separately: manual means production environment
variables still need to be set. Neither status confirms a successful deploy
or a received build report.
Config edits support direct object exports and defineConfig({ ... }) with
literal integration/plugin arrays, including aliased SDK imports. Computed
configs, object spreads, and other unsupported shapes stay untouched and
produce an incomplete result with manual instructions.
Requests time out after 15 seconds. If registration succeeds on the server but the response/key never reaches this machine, check the dashboard and rotate that site's key if needed; retries cannot recover a lost one-time key.
The repo URL is taken from the git origin remote, with any embedded
credentials stripped. The CLI never handles a password. Agents and CI can skip
login by setting ADVISOR_URL and ADVISOR_TOKEN; dma-advisor logout
forgets the saved login.
Usage
Astro:
import { advisor } from "dma-advisor";
export default defineConfig({ integrations: [advisor()] });Vite:
import { advisorVitePlugin } from "dma-advisor";
export default defineConfig({ plugins: [advisorVitePlugin()] });Or from CI without a plugin: npx dma-advisor report.
Astro SSR sites also get a /health route (dma-advisor/health-route)
returning the last build's metadata.
