Skip to content

Commit abc296a

Browse files
committed
chore: wip
1 parent 6668f8d commit abc296a

File tree

6 files changed

+110
-133
lines changed

6 files changed

+110
-133
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
*.lockb binary diff=lockb
2+
* text=auto
3+
*.* text eol=lf

.stacks/core/actions/src/domains/purchase.ts

Lines changed: 58 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,93 +2,69 @@ import process from 'node:process'
22
import { handleError } from '@stacksjs/error-handling'
33
import { log, parseOptions } from '@stacksjs/cli'
44
import { ExitCode } from '@stacksjs/types'
5+
import type { PurchaseOptions } from '@stacksjs/cloud'
56
import { purchaseDomain } from '@stacksjs/cloud'
67

7-
interface PurchaseOptions {
8-
domain: string
9-
years: number
10-
privacy: boolean
11-
autoRenew: boolean
12-
adminFirstName: string
13-
adminLastName: string
14-
adminOrganization: string
15-
adminAddress: string
16-
adminCity: string
17-
adminState: string
18-
adminCountry: string
19-
adminZip: string
20-
adminPhone: string
21-
adminEmail: string
22-
techFirstName: string
23-
techLastName: string
24-
techOrganization: string
25-
techAddress: string
26-
techCity: string
27-
techState: string
28-
techCountry: string
29-
techZip: string
30-
techPhone: string
31-
techEmail: string
32-
registrantFirstName: string
33-
registrantLastName: string
34-
registrantOrganization: string
35-
registrantAddress: string
36-
registrantCity: string
37-
registrantState: string
38-
registrantCountry: string
39-
registrantZip: string
40-
registrantPhone: string
41-
registrantEmail: string
42-
privacyAdmin: boolean
43-
privacyTech: boolean
44-
privacyRegistrant: boolean
45-
contactType: string
46-
verbose: boolean
47-
}
8+
const defaultOptions: PurchaseOptions = {
9+
domain: '',
10+
years: 1,
11+
privacy: true,
12+
autoRenew: true,
13+
registrantFirstName: config.dns.contactInfo.firstName,
14+
registrantLastName: config.dns.contactInfo?.lastName,
15+
registrantOrganizationName: config.dns.contactInfo?.organizationName,
16+
registrantAddressLine1: config.dns.contactInfo?.addressLine1,
17+
registrantAddressLine2: config.dns.contactInfo?.addressLine2,
18+
registrantCity: config.dns.contactInfo?.city,
19+
registrantState: config.dns.contactInfo?.state,
20+
registrantCountryCode: config.dns.contactInfo?.countryCode,
21+
registrantZip: config.dns.contactInfo?.zip,
22+
registrantPhoneNumber: config.dns.contactInfo?.phoneNumber,
23+
registrantEmail: config.dns.contactInfo?.email,
24+
admin: {
25+
firstName: config.dns.contactInfo?.admin?.firstName || config.dns.contactInfo?.firstName,
26+
lastName: config.dns.contactInfo?.admin?.lastName || config.dns.contactInfo?.lastName,
27+
organizationName: config.dns.contactInfo?.admin?.organizationName || config.dns.contactInfo?.organizationName,
28+
addressLine1: config.dns.contactInfo?.admin?.addressLine1 || config.dns.contactInfo?.addressLine1,
29+
addressLine2: config.dns.contactInfo?.admin?.addressLine2 || config.dns.contactInfo?.addressLine2,
30+
city: config.dns.contactInfo?.admin?.city || config.dns.contactInfo?.city,
31+
state: config.dns.contactInfo?.admin?.state || config.dns.contactInfo?.state,
32+
countryCode: config.dns.contactInfo?.admin?.countryCode || config.dns.contactInfo?.countryCode,
33+
zip: config.dns.contactInfo?.admin?.zip || config.dns.contactInfo?.zip,
34+
phoneNumber: config.dns.contactInfo?.admin?.phoneNumber || config.dns.contactInfo?.phoneNumber,
35+
email: config.dns.contactInfo?.admin?.email || config.dns.contactInfo?.email,
36+
},
37+
tech: {
38+
firstName: config.dns.contactInfo?.tech?.firstName || config.dns.contactInfo?.firstName,
39+
lastName: config.dns.contactInfo?.tech?.lastName || config.dns.contactInfo?.lastName,
40+
organizationName: config.dns.contactInfo?.tech?.organizationName || config.dns.contactInfo?.organizationName,
41+
addressLine1: config.dns.contactInfo?.tech?.addressLine1 || config.dns.contactInfo?.addressLine1,
42+
addressLine2: config.dns.contactInfo?.tech?.addressLine2 || config.dns.contactInfo?.addressLine2,
43+
city: config.dns.contactInfo?.tech?.city || config.dns.contactInfo?.city,
44+
state: config.dns.contactInfo?.tech?.state || config.dns.contactInfo?.state,
45+
countryCode: config.dns.contactInfo?.tech?.countryCode || config.dns.contactInfo?.countryCode,
46+
zip: config.dns.contactInfo?.tech?.zip || config.dns.contactInfo?.zip,
47+
phoneNumber: config.dns.contactInfo?.tech?.phoneNumber || config.dns.contactInfo?.phoneNumber,
48+
email: config.dns.contactInfo?.tech?.email || config.dns.contactInfo?.email,
49+
},
50+
privacyAdmin: config.dns.contactInfo?.privacyAdmin || config.dns.contactInfo?.privacy || true,
51+
privacyTech: config.dns.contactInfo?.privacyTech || config.dns.contactInfo?.privacy || true,
52+
privacyRegistrant: config.dns.contactInfo?.privacyRegistrant || config.dns.contactInfo?.privacy || true,
53+
contactType: 'person',
54+
},
55+
56+
]
4857

49-
const parsedOptions = parseOptions()
50-
const options: PurchaseOptions = {
51-
domain: parsedOptions.domain as string,
52-
verbose: parsedOptions.verbose as boolean,
53-
years: parsedOptions.years as number,
54-
privacy: parsedOptions.privacy as boolean,
55-
autoRenew: parsedOptions.autoRenew as boolean,
56-
registrantFirstName: parsedOptions.registrantFirstName as string,
57-
registrantLastName: parsedOptions.registrantLastName as string,
58-
registrantOrganization: parsedOptions.registrantOrganization as string,
59-
registrantAddress: parsedOptions.registrantAddress as string,
60-
registrantCity: parsedOptions.registrantCity as string,
61-
registrantState: parsedOptions.registrantState as string,
62-
registrantCountry: parsedOptions.registrantCountry as string,
63-
registrantZip: parsedOptions.registrantZip as string,
64-
registrantPhone: parsedOptions.registrantPhone as string,
65-
registrantEmail: parsedOptions.registrantEmail as string,
66-
adminFirstName: parsedOptions.adminFirstName as string,
67-
adminLastName: parsedOptions.adminLastName as string,
68-
adminOrganization: parsedOptions.adminOrganization as string,
69-
adminAddress: parsedOptions.adminAddress as string,
70-
adminCity: parsedOptions.adminCity as string,
71-
adminState: parsedOptions.adminState as string,
72-
adminCountry: parsedOptions.adminCountry as string,
73-
adminZip: parsedOptions.adminZip as string,
74-
adminPhone: parsedOptions.adminPhone as string,
75-
adminEmail: parsedOptions.adminEmail as string,
76-
techFirstName: parsedOptions.techFirstName as string,
77-
techLastName: parsedOptions.techLastName as string,
78-
techOrganization: parsedOptions.techOrganization as string,
79-
techAddress: parsedOptions.techAddress as string,
80-
techCity: parsedOptions.techCity as string,
81-
techState: parsedOptions.techState as string,
82-
techCountry: parsedOptions.techCountry as string,
83-
techZip: parsedOptions.techZip as string,
84-
techPhone: parsedOptions.techPhone as string,
85-
techEmail: parsedOptions.techEmail as string,
86-
privacyAdmin: parsedOptions.privacyAdmin as boolean,
87-
privacyTech: parsedOptions.privacyTech as boolean,
88-
privacyRegistrant: parsedOptions.privacyRegistrant as boolean,
89-
contactType: parsedOptions.contactType as string,
58+
// ... add the rest of the 38 properties here with their default values
9059
}
9160

61+
const options: PurchaseOptions = { ...defaultOptions, ...parseOptions() }
62+
63+
const options: PurchaseOptions = parseOptions()
64+
65+
log.info('options is', options)
66+
log.dd('domain is', options.domain)
67+
9268
if (!options.domain) {
9369
handleError('You must provide a domain name to purchase.')
9470
process.exit(ExitCode.FatalError)

.stacks/core/buddy/src/commands/domains.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export function domains(buddy: CLI) {
2323
.option('--first-name <firstName>', 'Registrant first name', { default: config.dns.contactInfo?.firstName })
2424
.option('--last-name <lastName>', 'Registrant last name', { default: config.dns.contactInfo?.lastName })
2525
.option('--organization <organization>', 'Registrant organization name', { default: config.dns.contactInfo?.organizationName })
26-
.option('--address <address>', 'Registrant address line 1', { default: config.dns.contactInfo?.addressLine1 })
27-
.option('--address-line-2 <address>', 'Registrant address line 2', { default: config.dns.contactInfo?.addressLine2 })
26+
.option('--address-line1 <address>', 'Registrant address line 1', { default: config.dns.contactInfo?.addressLine1 })
27+
.option('--address-line2 <address>', 'Registrant address line 2', { default: config.dns.contactInfo?.addressLine2 })
2828
.option('--city <city>', 'Registrant city', { default: config.dns.contactInfo?.city })
2929
.option('--state <state>', 'Registrant state', { default: config.dns.contactInfo?.state })
3030
.option('--country <country>', 'Registrant country code', { default: config.dns.contactInfo?.countryCode })
@@ -34,8 +34,8 @@ export function domains(buddy: CLI) {
3434
.option('--admin-first-name <firstName>', 'Admin first name', { default: config.dns.contactInfo?.admin?.firstName || config.dns.contactInfo?.firstName })
3535
.option('--admin-last-name <lastName>', 'Admin last name', { default: config.dns.contactInfo?.admin?.lastName || config.dns.contactInfo?.lastName })
3636
.option('--admin-organization <organization>', 'Admin organization', { default: config.dns.contactInfo?.admin?.organizationName || config.dns.contactInfo?.organizationName })
37-
.option('--admin-address <address>', 'Admin address line 1', { default: config.dns.contactInfo?.admin?.addressLine1 || config.dns.contactInfo?.addressLine1 })
38-
.option('--admin-address-line-2 <address>', 'Admin address line 2', { default: config.dns.contactInfo?.admin?.addressLine2 || config.dns.contactInfo?.addressLine2 })
37+
.option('--admin-address-line1 <address>', 'Admin address line 1', { default: config.dns.contactInfo?.admin?.addressLine1 || config.dns.contactInfo?.addressLine1 })
38+
.option('--admin-address-line2 <address>', 'Admin address line 2', { default: config.dns.contactInfo?.admin?.addressLine2 || config.dns.contactInfo?.addressLine2 })
3939
.option('--admin-city <city>', 'Admin city', { default: config.dns.contactInfo?.admin?.city || config.dns.contactInfo?.city })
4040
.option('--admin-state <state>', 'Admin state', { default: config.dns.contactInfo?.admin?.state || config.dns.contactInfo?.state })
4141
.option('--admin-country <country>', 'Admin country code', { default: config.dns.contactInfo?.admin?.countryCode || config.dns.contactInfo?.countryCode })
@@ -45,17 +45,17 @@ export function domains(buddy: CLI) {
4545
.option('--tech-first-name <firstName>', 'Tech first name', { default: config.dns.contactInfo?.tech?.firstName || config.dns.contactInfo?.firstName })
4646
.option('--tech-last-name <lastName>', 'Tech last name', { default: config.dns.contactInfo?.tech?.lastName || config.dns.contactInfo?.lastName })
4747
.option('--tech-organization <organization>', 'Tech organization name', { default: config.dns.contactInfo?.tech?.organizationName || config.dns.contactInfo?.organizationName })
48-
.option('--tech-address <address>', 'Tech address line 1', { default: config.dns.contactInfo?.tech?.addressLine1 || config.dns.contactInfo?.addressLine1 })
49-
.option('--tech-address-line-2 <address>', 'Tech address line 2', { default: config.dns.contactInfo?.tech?.addressLine2 || config.dns.contactInfo?.addressLine2 })
48+
.option('--tech-address-line1 <address>', 'Tech address line 1', { default: config.dns.contactInfo?.tech?.addressLine1 || config.dns.contactInfo?.addressLine1 })
49+
.option('--tech-address-line2 <address>', 'Tech address line 2', { default: config.dns.contactInfo?.tech?.addressLine2 || config.dns.contactInfo?.addressLine2 })
5050
.option('--tech-city <city>', 'Tech city', { default: config.dns.contactInfo?.tech?.city || config.dns.contactInfo?.city })
5151
.option('--tech-state <state>', 'Tech state', { default: config.dns.contactInfo?.tech?.state || config.dns.contactInfo?.state })
5252
.option('--tech-country <country>', 'Tech country', { default: config.dns.contactInfo?.tech?.countryCode || config.dns.contactInfo?.countryCode })
5353
.option('--tech-zip <zip>', 'Tech zip', { default: config.dns.contactInfo?.tech?.zip || config.dns.contactInfo?.zip })
5454
.option('--tech-phone <phone>', 'Tech phone', { default: config.dns.contactInfo?.tech?.phoneNumber || config.dns.contactInfo?.phoneNumber })
5555
.option('--tech-email <email>', 'Tech email', { default: config.dns.contactInfo?.tech?.email || config.dns.contactInfo?.email })
56-
.option('--privacy-admin', 'Enable privacy protection for admin', { default: config.dns.contactInfo?.privacyAdmin || config.dns.contactInfo?.privacy })
57-
.option('--privacy-tech', 'Enable privacy protection for tech', { default: config.dns.contactInfo?.privacyTech || config.dns.contactInfo?.privacy })
58-
.option('--privacy-registrant', 'Enable privacy protection for registrant', { default: config.dns.contactInfo?.privacyRegistrant || config.dns.contactInfo?.privacy })
56+
.option('--privacy-admin', 'Enable privacy protection for admin', { default: config.dns.contactInfo?.privacyAdmin || config.dns.contactInfo?.privacy || true })
57+
.option('--privacy-tech', 'Enable privacy protection for tech', { default: config.dns.contactInfo?.privacyTech || config.dns.contactInfo?.privacy || true })
58+
.option('--privacy-registrant', 'Enable privacy protection for registrant', { default: config.dns.contactInfo?.privacyRegistrant || config.dns.contactInfo?.privacy || true })
5959
.option('--contact-type <type>', 'Contact type', { default: 'person' })
6060
.option('--verbose', descriptions.verbose, { default: false })
6161
.action(async (domain: string, options: DomainsOptions) => {
@@ -76,7 +76,7 @@ export function domains(buddy: CLI) {
7676
})
7777

7878
if (!confirm) {
79-
await outro(`Great! Your domain ${domain} has been purchased.`, { startTime, useSeconds: true, type: 'info' })
79+
await outro(`Alrighty! Your domain ${domain} has been purchased & is added to your account.`, { startTime, useSeconds: true, type: 'success' })
8080
process.exit(ExitCode.Success)
8181
}
8282

.stacks/core/cloud/src/index.ts

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import { Route53Domains } from '@aws-sdk/client-route-53-domains'
44

55
export * from './drivers'
66

7-
interface PurchaseOptions {
7+
export interface PurchaseOptions {
88
domain: string
99
years: number
10-
privacy?: boolean
11-
autoRenew?: boolean
10+
privacy: boolean
11+
autoRenew: boolean
1212
adminFirstName: string
1313
adminLastName: string
1414
adminOrganization: string
15-
adminAddress: string
15+
adminAddressLine1: string
16+
adminAddressLine2: string
1617
adminCity: string
1718
adminState: string
1819
adminCountry: string
@@ -22,7 +23,8 @@ interface PurchaseOptions {
2223
techFirstName: string
2324
techLastName: string
2425
techOrganization: string
25-
techAddress: string
26+
techAddressLine1: string
27+
techAddressLine2: string
2628
techCity: string
2729
techState: string
2830
techCountry: string
@@ -32,20 +34,22 @@ interface PurchaseOptions {
3234
registrantFirstName: string
3335
registrantLastName: string
3436
registrantOrganization: string
35-
registrantAddress: string
37+
registrantAddressLine1: string
38+
registrantAddressLine2: string
3639
registrantCity: string
3740
registrantState: string
3841
registrantCountry: string
3942
registrantZip: string
4043
registrantPhone: string
4144
registrantEmail: string
42-
privacyAdmin?: boolean
43-
privacyTech?: boolean
44-
privacyRegistrant?: boolean
45-
verbose?: boolean
45+
privacyAdmin: boolean
46+
privacyTech: boolean
47+
privacyRegistrant: boolean
48+
contactType: string
49+
verbose: boolean
4650
}
4751

48-
export function purchaseDomain(domain: string, options: PurchaseOptions) {
52+
export async function purchaseDomain(domain: string, options: PurchaseOptions) {
4953
const route53domains = new Route53Domains({ region: 'us-east-1' })
5054
const params = {
5155
DomainName: domain,
@@ -95,16 +99,10 @@ export function purchaseDomain(domain: string, options: PurchaseOptions) {
9599
PrivacyProtectTechContact: options.privacyTech || options.privacy || true,
96100
}
97101

98-
const result = route53domains.registerDomain(params, (error, data) => {
99-
if (error)
100-
return error
101-
102-
log.info(data)
103-
return data
104-
})
105-
106-
if (result instanceof Error)
107-
return err(result)
108-
109-
return ok(result)
102+
try {
103+
return ok(await route53domains.registerDomain(params))
104+
}
105+
catch (error) {
106+
return err(error)
107+
}
110108
}

.stacks/core/types/src/dns.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ export interface ContactDetail {
9797
/**
9898
* First name of contact.
9999
*/
100-
firstName?: string
100+
firstName: string
101101
/**
102102
* Last name of contact.
103103
*/
104-
lastName?: string
104+
lastName: string
105105
/**
106106
* Indicates whether the contact is a person, company, association, or public organization.
107107
*
@@ -113,73 +113,73 @@ export interface ContactDetail {
113113
*
114114
* @default PERSON
115115
*/
116-
contactType?: 'PERSON' | 'COMPANY' | 'ASSOCIATION' | 'PUBLIC_BODY' | 'RESELLER' | string
116+
contactType: 'PERSON' | 'COMPANY' | 'ASSOCIATION' | 'PUBLIC_BODY' | 'RESELLER' | string
117117
/**
118118
* Name of the organization for contact types other than PERSON.
119119
*/
120-
organizationName?: string
120+
organizationName: string
121121
/**
122122
* First line of the contact's address.
123123
*/
124-
addressLine1?: string
124+
addressLine1: string
125125
/**
126126
* Second line of contact's address, if any.
127127
*/
128-
addressLine2?: string
128+
addressLine2: string
129129
/**
130130
* The city of the contact's address.
131131
*/
132-
city?: string
132+
city: string
133133
/**
134134
* The state or province of the contact's city.
135135
*/
136-
state?: string
136+
state: string
137137
/**
138138
* Code for the country of the contact's address.
139139
*/
140-
countryCode?: CountryCode
140+
countryCode: CountryCode
141141
/**
142142
* The zip or postal code of the contact's address.
143143
*/
144-
zip?: string
144+
zip: string
145145
/**
146146
* The phone number of the contact.
147147
* Constraints: Phone number must be specified in the format "+[country dialing code].[number including any area code&gt;]".
148148
* For example, a US phone number might appear as "+1.1234567890".
149149
* @example +1.1234567890
150150
*/
151-
phoneNumber?: string
151+
phoneNumber: string
152152
/**
153153
* Email address of the contact.
154154
*/
155-
email?: string
155+
email: string
156156
/**
157157
* Fax number of the contact. Constraints: Phone number must be specified in the format "+[country dialing code].[number including any area code]". For example, a US phone number might appear as "+1.1234567890".
158158
*/
159-
fax?: string
159+
fax: string
160160
/**
161161
* A list of name-value pairs for parameters required by certain top-level domains.
162162
*/
163-
extraParams?: string
163+
extraParams: string
164164

165165
/**
166166
* Enable privacy protection for this domain.
167167
* @default true
168168
*/
169-
privacy?: boolean
169+
privacy: boolean
170170
/**
171171
* Enable privacy protection for the admin contact.
172172
* @default true
173173
*/
174-
privacyAdmin?: boolean
174+
privacyAdmin: boolean
175175
/**
176176
* Enable privacy protection for the tech contact.
177177
* @default true
178178
*/
179-
privacyTech?: boolean
179+
privacyTech: boolean
180180
/**
181181
* Enable privacy protection for the registrant contact.
182182
* @default true
183183
*/
184-
privacyRegistrant?: boolean
184+
privacyRegistrant: boolean
185185
}

0 commit comments

Comments
 (0)