doomain 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ export default class Link extends Command {
18
18
  apex: apexFlag,
19
19
  domain: domainFlag,
20
20
  'dry-run': Flags.boolean({ description: 'Preview changes without writing to Vercel or DNS.' }),
21
- force: Flags.boolean({ description: 'Move existing Vercel aliases and overwrite conflicting DNS records.' }),
21
+ force: Flags.boolean({ description: 'Move existing Vercel project domains and overwrite conflicting DNS records.' }),
22
22
  json: jsonFlag,
23
23
  project: projectFlag,
24
24
  provider: providerFlag,
@@ -43,9 +43,11 @@ function isDomainConflictError(error) {
43
43
  function isSameDomain(value, domain) {
44
44
  return typeof value === 'string' && value.toLowerCase() === domain.toLowerCase();
45
45
  }
46
- function findAliasTarget(raw, domain) {
46
+ function findProjectDomainTarget(raw, domain) {
47
47
  const targets = Array.isArray(raw) ? raw : [raw];
48
- return targets.find((target) => target && typeof target === 'object' && isSameDomain(target.domain, domain));
48
+ return targets.find((target) => target &&
49
+ typeof target === 'object' &&
50
+ (isSameDomain(target.domain, domain) || isSameDomain(target.name, domain)));
49
51
  }
50
52
  export function createVercelClient(config) {
51
53
  async function request(path, init = {}, opts = {}) {
@@ -59,7 +61,7 @@ export function createVercelClient(config) {
59
61
  });
60
62
  if (!response.ok) {
61
63
  const body = (await response.json().catch(() => undefined));
62
- if (response.status === 401 || response.status === 403) {
64
+ if (response.status === 401) {
63
65
  throw new DoomainError('VERCEL_AUTH_FAILED', vercelAuthErrorMessage(body), body);
64
66
  }
65
67
  throw new DoomainError('DOMAIN_LINK_FAILED', apiErrorMessage(response.status, body), body);
@@ -123,15 +125,15 @@ export function createVercelClient(config) {
123
125
  },
124
126
  async addDomainToProject(project, domain, opts = {}) {
125
127
  try {
126
- const raw = await request(`/projects/${encodeURIComponent(project)}/alias`, {
128
+ const raw = await request(`/v10/projects/${encodeURIComponent(project)}/domains`, {
127
129
  method: 'POST',
128
- body: JSON.stringify({ domain, target: 'PRODUCTION' }),
130
+ body: JSON.stringify({ name: domain }),
129
131
  });
130
- const aliasTarget = findAliasTarget(raw, domain);
131
- if (!aliasTarget) {
132
+ const projectDomain = findProjectDomainTarget(raw, domain);
133
+ if (!projectDomain) {
132
134
  throw new DoomainError('DOMAIN_LINK_FAILED', `Vercel did not return ${domain} after adding it to project ${project}.`, raw);
133
135
  }
134
- return { alreadyAdded: false, raw: aliasTarget };
136
+ return { alreadyAdded: false, raw: projectDomain };
135
137
  }
136
138
  catch (error) {
137
139
  if (isDomainConflictError(error)) {
@@ -175,7 +177,7 @@ export function createVercelClient(config) {
175
177
  return result.domains ?? [];
176
178
  },
177
179
  async removeDomainFromProject(project, domain) {
178
- await request(`/projects/${encodeURIComponent(project)}/alias?domain=${encodeURIComponent(domain)}`, { method: 'DELETE' });
180
+ await request(`/v9/projects/${encodeURIComponent(project)}/domains/${encodeURIComponent(domain)}`, { method: 'DELETE' });
179
181
  },
180
182
  async verifyProjectDomain(project, domain) {
181
183
  return request(`/v9/projects/${encodeURIComponent(project)}/domains/${encodeURIComponent(domain)}/verify`, { method: 'POST' });
@@ -37,7 +37,7 @@
37
37
  "type": "boolean"
38
38
  },
39
39
  "force": {
40
- "description": "Move existing Vercel aliases and overwrite conflicting DNS records.",
40
+ "description": "Move existing Vercel project domains and overwrite conflicting DNS records.",
41
41
  "name": "force",
42
42
  "allowNo": false,
43
43
  "type": "boolean"
@@ -300,74 +300,6 @@
300
300
  "list.js"
301
301
  ]
302
302
  },
303
- "projects:list": {
304
- "aliases": [],
305
- "args": {},
306
- "description": "List Vercel projects.",
307
- "flags": {
308
- "json": {
309
- "description": "Output a single JSON object and never prompt.",
310
- "name": "json",
311
- "allowNo": false,
312
- "type": "boolean"
313
- },
314
- "search": {
315
- "description": "Filter projects by search term.",
316
- "name": "search",
317
- "hasDynamicHelp": false,
318
- "multiple": false,
319
- "type": "option"
320
- }
321
- },
322
- "hasDynamicHelp": false,
323
- "hiddenAliases": [],
324
- "id": "projects:list",
325
- "pluginAlias": "doomain",
326
- "pluginName": "doomain",
327
- "pluginType": "core",
328
- "strict": true,
329
- "enableJsonFlag": false,
330
- "isESM": true,
331
- "relativePath": [
332
- "dist",
333
- "commands",
334
- "projects",
335
- "list.js"
336
- ]
337
- },
338
- "auth:logout:vercel": {
339
- "aliases": [],
340
- "args": {},
341
- "description": "Remove saved Vercel credentials locally.",
342
- "examples": [
343
- "<%= config.bin %> <%= command.id %>",
344
- "<%= config.bin %> <%= command.id %> --json"
345
- ],
346
- "flags": {
347
- "json": {
348
- "description": "Output a single JSON object and never prompt.",
349
- "name": "json",
350
- "allowNo": false,
351
- "type": "boolean"
352
- }
353
- },
354
- "hasDynamicHelp": false,
355
- "hiddenAliases": [],
356
- "id": "auth:logout:vercel",
357
- "pluginAlias": "doomain",
358
- "pluginName": "doomain",
359
- "pluginType": "core",
360
- "strict": true,
361
- "enableJsonFlag": false,
362
- "isESM": true,
363
- "relativePath": [
364
- "dist",
365
- "commands",
366
- "auth",
367
- "logout",
368
- "vercel.js"
369
- ]
370
- },
371
303
  "providers:add": {
372
304
  "aliases": [],
373
305
  "args": {
@@ -627,7 +559,75 @@
627
559
  "providers",
628
560
  "verify.js"
629
561
  ]
562
+ },
563
+ "projects:list": {
564
+ "aliases": [],
565
+ "args": {},
566
+ "description": "List Vercel projects.",
567
+ "flags": {
568
+ "json": {
569
+ "description": "Output a single JSON object and never prompt.",
570
+ "name": "json",
571
+ "allowNo": false,
572
+ "type": "boolean"
573
+ },
574
+ "search": {
575
+ "description": "Filter projects by search term.",
576
+ "name": "search",
577
+ "hasDynamicHelp": false,
578
+ "multiple": false,
579
+ "type": "option"
580
+ }
581
+ },
582
+ "hasDynamicHelp": false,
583
+ "hiddenAliases": [],
584
+ "id": "projects:list",
585
+ "pluginAlias": "doomain",
586
+ "pluginName": "doomain",
587
+ "pluginType": "core",
588
+ "strict": true,
589
+ "enableJsonFlag": false,
590
+ "isESM": true,
591
+ "relativePath": [
592
+ "dist",
593
+ "commands",
594
+ "projects",
595
+ "list.js"
596
+ ]
597
+ },
598
+ "auth:logout:vercel": {
599
+ "aliases": [],
600
+ "args": {},
601
+ "description": "Remove saved Vercel credentials locally.",
602
+ "examples": [
603
+ "<%= config.bin %> <%= command.id %>",
604
+ "<%= config.bin %> <%= command.id %> --json"
605
+ ],
606
+ "flags": {
607
+ "json": {
608
+ "description": "Output a single JSON object and never prompt.",
609
+ "name": "json",
610
+ "allowNo": false,
611
+ "type": "boolean"
612
+ }
613
+ },
614
+ "hasDynamicHelp": false,
615
+ "hiddenAliases": [],
616
+ "id": "auth:logout:vercel",
617
+ "pluginAlias": "doomain",
618
+ "pluginName": "doomain",
619
+ "pluginType": "core",
620
+ "strict": true,
621
+ "enableJsonFlag": false,
622
+ "isESM": true,
623
+ "relativePath": [
624
+ "dist",
625
+ "commands",
626
+ "auth",
627
+ "logout",
628
+ "vercel.js"
629
+ ]
630
630
  }
631
631
  },
632
- "version": "0.1.5"
632
+ "version": "0.1.6"
633
633
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "doomain",
3
3
  "description": "Link your vercel project and domain in seconds",
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "author": "Crafter Station",
6
6
  "packageManager": "bun@1.3.13",
7
7
  "bin": {