# Find DAWA calls in your code with migrate-cli

> Find and replace DAWA URLs in a project with npx @danadresse/migrate-cli, see what the tool misses, and stop new DAWA calls in CI.
>
> https://danadresse.dk/en/guides/find-dawa-kald-med-migrate-cli · verified 2026-11-02
Before you can move off DAWA you need to know where the code calls DAWA. In an older project the URLs can sit in source code, configuration files, templates and documentation. `@danadresse/migrate-cli` finds them and can replace them with `https://api.danadresse.dk`.

This guide shows how to run the tool, exactly what it does, what it misses, and how to make CI fail if a DAWA URL shows up again.

## 1. Do a dry run

The tool needs Node 18 or newer. Stand in the project root and run:

```bash id=dry-run run=no
npx @danadresse/migrate-cli
```

Without flags it changes nothing. It shows each line that would change and what it would look like afterwards:

```text id=dry-run-output run=no
Found 3 occurrence(s) in 2 file(s):

  src/adresse.ts
    12: const BASE = "https://dawa.aws.dk";
      → const BASE = "https://api.danadresse.dk";

  templates/checkout.html
    41: <script src="https://dawa.aws.dk/js/autocomplete/dawa-autocomplete2.min.js"></script>
      → <script src="https://api.danadresse.dk/js/autocomplete/dawa-autocomplete2.min.js"></script>

Run with --write to apply changes.
```

## 2. Know the flags

| Command | Effect |
|---|---|
| `npx @danadresse/migrate-cli` | Dry run of the current folder |
| `npx @danadresse/migrate-cli src/` | Dry run of `src/` |
| `npx @danadresse/migrate-cli --target src/` or `-t src/` | The same |
| `npx @danadresse/migrate-cli scan src/` | The same. `scan` is always a dry run |
| `npx @danadresse/migrate-cli --write` or `-w` | Writes the changes to the files |
| `npx @danadresse/migrate-cli rewrite src/` | The same as `--write` on `src/` |
| `npx @danadresse/migrate-cli --key dawa_live_…` | Puts your key into the code examples at the end |
| `npx @danadresse/migrate-cli --fail-on-found` or `--ci` | Dry run that exits with code 1 if anything was found. For CI |
| `npx @danadresse/migrate-cli --help` | Shows the help |

`--key` does one thing: it shows the key in the examples. The tool never writes the key into your files. An unknown flag prints a warning, but the run continues.

## 3. Understand what gets replaced

The tool looks for DAWA's hosts, with or without `http://` or `https://` in front:

| Found | Becomes |
|---|---|
| `https://dawa.aws.dk` | `https://api.danadresse.dk` |
| `https://api.dataforsyningen.dk` | `https://api.danadresse.dk` |
| `https://cdn.dataforsyningen.dk` followed by `/dawa/assets/dawa-autocomplete2/` | `https://api.danadresse.dk` |
| A bare host: `dawa.aws.dk`, `//dawa.aws.dk/…`, `DAWA_HOST=api.dataforsyningen.dk` | `api.danadresse.dk` |

Only the domain part is replaced. Path and parameters stay, so `https://dawa.aws.dk/adresser?postnr=8000` becomes `https://api.danadresse.dk/adresser?postnr=8000`. That works because we have the same paths. `http://` becomes `https://`, and a bare host stays a bare host. Look-alike hosts such as `x.api.dataforsyningen.dk` are left alone.

It reads files with these extensions: `js ts jsx tsx mjs cjs py php rb go java cs kt swift rs html vue svelte astro json yaml yml env toml ini conf cfg md rst txt`, plus `.env`, `.env.*` (such as `.env.production`), workflows under `.github/` and `.gitlab-ci.yml`. The folders `node_modules`, `.git`, `.cache`, `.yarn`, `.venv`, `venv`, `dist`, `build`, `__pycache__`, `.next` and `vendor` are skipped.

> [!NOTE]
> Scanning `.env*` and `.github/`, bare hosts and `--fail-on-found` are newer than version 0.1.0 of the package. Run `npx @danadresse/migrate-cli@latest --help`: if `--fail-on-found` is not listed, you have a version that skips hidden files, only finds URLs with `http(s)://` and always exits with code 0. Then use the search in step 5 and the script in step 6.

If it finds DAWA's widget (`dawa-autocomplete2.js` or `.min.js`), it prints the new script tag with `?key=` at the end. See [From dawa-autocomplete2](/en/guides/migrer-dawa-autocomplete2) for why that key must be a browser key.

## 4. What the tool does not catch

The scan is deliberately simple. Check these places yourself:

- **Other hidden files.** Apart from `.env*`, `.github/` and `.gitlab-ci.yml`, files whose name starts with a dot are not scanned, for example `.npmrc` or `.circleci/config.yml`.
- **Concatenated strings.** `"https://dawa." + "aws.dk"` or a URL built in several steps.
- **Other file types.** For example `.xml`, `.properties`, `.gradle`, `.twig`, `.liquid`, `.cshtml`, `.razor`, `.sql` and spreadsheets.
- **Configuration outside the repository.** Settings in a database, a CMS, environment variables on the server or a third-party plugin.

And after the replacement the calls still lack a key. Add `X-Api-Key` wherever you make HTTP calls. See [Move from DAWA by changing the base URL](/en/guides/migrer-fra-dawa).

## 5. Search yourself with ripgrep or git grep

A `ripgrep` search covers every file type and all hidden files:

```bash id=ripgrep run=syntax
rg -n --hidden -g '!.git' -g '!node_modules' \
  -e 'dawa\.aws\.dk' \
  -e 'api\.dataforsyningen\.dk' \
  -e 'cdn\.dataforsyningen\.dk/dawa' \
  .
```

`git grep` only searches files Git tracks, which is often what you want:

```bash id=git-grep run=syntax
git grep -nE 'dawa\.aws\.dk|api\.dataforsyningen\.dk|cdn\.dataforsyningen\.dk/dawa'
```

If you have neither, plain `grep -rnE` with the same pattern works, but then you have to exclude `node_modules` yourself.

## 6. Make CI fail if DAWA comes back

With `--fail-on-found`, migrate-cli exits with code 1 as soon as it finds a DAWA reference. It changes nothing:

```bash id=ci-cli run=no
npx --yes @danadresse/migrate-cli@latest --fail-on-found
```

It has no option to exclude files, so a changelog that mentions DAWA on purpose also fails the build. If you need exclusions, or do not want Node in the pipeline, use a small script instead. It fails if a tracked file mentions one of DAWA's domains:

```bash id=ci-check run=syntax
#!/usr/bin/env bash
# Fails if the code refers to DAWA again. Run from the repository root.
set -euo pipefail

pattern='dawa\.aws\.dk|api\.dataforsyningen\.dk|cdn\.dataforsyningen\.dk/dawa'

# Exclude files that mention DAWA on purpose (e.g. this file and changelogs).
if git grep -nE "$pattern" -- . ':!scripts/check-no-dawa.sh' ':!CHANGELOG.md'; then
  echo "DAWA closed on 1 October 2026. Use https://api.danadresse.dk instead." >&2
  exit 1
fi
echo "No DAWA URLs found."
```

Save it as `scripts/check-no-dawa.sh` and call it from your pipeline. In GitHub Actions:

```yaml id=github-actions run=no
name: no-dawa
on: [push, pull_request]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: bash scripts/check-no-dawa.sh
```

`git grep` exits with code 1 when it finds nothing. That is why the call sits inside an `if`, so `set -e` does not stop the script on the good outcome.

## Next steps

- Add the key and test the switch: [Move from DAWA by changing the base URL](/en/guides/migrer-fra-dawa).
- Ready for production? [Go-live checklist](/en/guides/go-live-tjekliste).
