import assert from 'node:assert/strict'
import vercel, {
addDomain,
createDeployment,
createEnvVar,
smokeTest,
vercelRequest,
} from '../src/vercel.js'
const smoke = await smokeTest({ dryRun: true })
assert.equal(smoke.ok, true)
assert.equal(smoke.live, false)
assert.equal(smoke.dryRun, true)
assert.equal(smoke.path, '/v2/user')
assert.match(smoke.setup.tokenUrl, /name=vercelToken/)
const root = await vercel({ dryRun: true })
assert.equal(root.path, '/v2/user')
const deploy = await createDeployment({
name: 'example-app',
target: 'preview',
dryRun: true,
})
assert.deepEqual(deploy, {
dryRun: true,
method: 'POST',
path: '/v13/deployments',
body: { name: 'example-app', target: 'preview' },
query: {},
})
const domain = await addDomain({
project: 'example-app',
name: 'www.example.com',
dryRun: true,
})
assert.equal(domain.dryRun, true)
assert.equal(domain.method, 'POST')
assert.equal(domain.path, '/v10/projects/example-app/domains')
assert.deepEqual(domain.body, { name: 'www.example.com' })
const accountDomain = await addDomain({ name: 'example.com', dryRun: true })
assert.equal(accountDomain.path, '/v7/domains')
const env = await createEnvVar({
project: 'example-app',
key: 'EXAMPLE_FLAG',
value: 'should-not-appear',
target: ['preview'],
dryRun: true,
})
assert.equal(env.dryRun, true)
assert.equal(env.path, '/v10/projects/example-app/env')
assert.equal(env.body.key, 'EXAMPLE_FLAG')
assert.equal(env.body.value, '[redacted]')
const requestPreview = await vercelRequest({
path: '/v13/deployments',
method: 'POST',
body: { name: 'example-app' },
dryRun: true,
})
assert.equal(requestPreview.dryRun, true)
assert.equal(requestPreview.method, 'POST')
await assert.rejects(
() => createDeployment({ name: 'example-app' }),
/confirm: true/,
)
console.log('dry-run helper checks passed')