(
account,
headers,
project,
customDomain,
)
| 134 | } |
| 135 | |
| 136 | async function detachPagesDomainFromProject( |
| 137 | account, |
| 138 | headers, |
| 139 | project, |
| 140 | customDomain, |
| 141 | ) { |
| 142 | const { ok: listOk, json: domains } = await cf( |
| 143 | `${CF_API}/accounts/${account}/pages/projects/${project}/domains`, |
| 144 | headers, |
| 145 | ); |
| 146 | if (!listOk) { |
| 147 | throw new Error( |
| 148 | `List domains for ${project} failed: ${JSON.stringify(domains)}`, |
| 149 | ); |
| 150 | } |
| 151 | |
| 152 | if (!domains.result?.some((domain) => domain.name === customDomain)) { |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | const { ok: deleteOk, json: deleted } = await cf( |
| 157 | `${CF_API}/accounts/${account}/pages/projects/${project}/domains/${customDomain}`, |
| 158 | headers, |
| 159 | { method: "DELETE" }, |
| 160 | ); |
| 161 | if (!deleteOk) { |
| 162 | throw new Error( |
| 163 | `Detach ${customDomain} from ${project} failed: ${JSON.stringify(deleted)}`, |
| 164 | ); |
| 165 | } |
| 166 | |
| 167 | console.log(`Detached ${customDomain} from ${project}`); |
| 168 | return true; |
| 169 | } |
| 170 | |
| 171 | async function projectHasPagesDomain(account, headers, project, customDomain) { |
| 172 | const { ok, json } = await cf( |
no test coverage detected