Skip to content

Commit 024ac97

Browse files
committed
chore: wip
1 parent af6cefb commit 024ac97

File tree

5 files changed

+55
-28
lines changed

5 files changed

+55
-28
lines changed

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

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
import process from 'node:process'
22
import { createHostedZone } from '@stacksjs/dns'
33
import { app } from '@stacksjs/config'
4+
import { handleError } from '@stacksjs/error-handling'
45
import { projectStoragePath } from '@stacksjs/path'
5-
import { italic } from '@stacksjs/cli'
6+
import { italic, parseOptions } from '@stacksjs/cli'
67
import { logger } from '@stacksjs/logging'
78

8-
logger.log('Adding your domain...', app.url)
9+
interface AddOptions {
10+
domain?: string
11+
verbose: boolean
12+
}
913

10-
if (!app.url) {
11-
handleError('./config app.url is not defined')
12-
process.exit(1)
14+
const parsedOptions = parseOptions()
15+
const options: AddOptions = {
16+
domain: parsedOptions.domain as string,
17+
verbose: parsedOptions.verbose as boolean,
1318
}
1419

15-
const result = await createHostedZone(app.url)
20+
if (!options.domain) {
21+
if (app.url) {
22+
options.domain = app.url
23+
}
24+
else {
25+
handleError('there was no domain provided when')
26+
process.exit(1)
27+
}
28+
}
29+
30+
logger.log(`Adding your domain: ${options.domain}`)
31+
32+
const result = await createHostedZone(options.domain)
1633

1734
if (result.isErr()) {
18-
handleError('Failed to add domain', app.url)
35+
handleError('Failed to add domain', result.error)
1936
process.exit(1)
2037
}
2138

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
import process from 'node:process'
22
import { handleError } from '@stacksjs/error-handling'
3+
import { logger } from '@stacksjs/logging'
34
import { deleteHostedZone } from '@stacksjs/dns'
45
import { app } from '@stacksjs/config'
5-
import { logger } from '@stacksjs/logging'
6+
import { parseOptions } from '@stacksjs/cli'
67

7-
logger.log(`Removing domain: ${app.url}`)
8+
interface RemoveOptions {
9+
domain?: string
10+
verbose: boolean
11+
}
812

9-
if (!app.url) {
10-
handleError('./config app.url is not defined')
11-
process.exit(1)
13+
const parsedOptions = parseOptions()
14+
const options: RemoveOptions = {
15+
domain: parsedOptions.domain as string,
16+
verbose: parsedOptions.verbose as boolean,
1217
}
1318

14-
const result = await deleteHostedZone(app.url)
19+
if (!options.domain) {
20+
if (app.url) {
21+
options.domain = app.url
22+
}
23+
else {
24+
handleError('there was no domain provided when')
25+
process.exit(1)
26+
}
27+
}
28+
29+
logger.log(`Removing domain: ${options.domain}`)
30+
31+
const result = await deleteHostedZone(options.domain)
1532

1633
if (result.isErr()) {
1734
handleError(result.error)

.stacks/core/dns/src/drivers/aws.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ export async function createHostedZone(domainName: string) {
6969

7070
await storage.writeFile(p.projectStoragePath('framework/cache/nameservers.txt'), nameServers.join('\n'))
7171

72-
// eslint-disable-next-line no-console
73-
console.log(`Created Hosted Zone for domain: ${domainName}`)
74-
// eslint-disable-next-line no-console
75-
console.log(`Nameservers: ${nameServers.join(', ')}`)
76-
7772
return ok(nameServers)
7873
}
7974

.stacks/core/logging/src/index.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,24 @@ import { ray as debug } from 'node-ray'
66
import { ExitCode } from '@stacksjs/types'
77
import type { StacksError } from '@stacksjs/types'
88

9-
export function dump(...args: any[]) {
10-
return debug(...args)
11-
}
12-
139
export const logger = console
1410
export const log = {
1511
info: (...args: any[]) => logger.info(...args),
1612
success: (msg: string) => logger.log(bold(green(msg))),
1713
error: (err: string | StacksError, options?: any) => handleError(err, options),
1814
warn: (...args: any[]) => logger.warn(...args),
19-
debug: (...args: any[]) => {
20-
if (process.env.DEBUG)
21-
logger.debug(...args)
22-
},
15+
debug: (...args: any[]) => logger.debug(...args),
2316
prompt: prompts,
2417
dump,
2518
dd,
2619
}
2720

21+
export function dump(...args: any[]) {
22+
// return debug(...args)
23+
return log.debug(...args)
24+
}
25+
2826
export function dd(...args: any[]) {
29-
args.forEach(arg => log.info(arg))
27+
args.forEach(arg => log.debug(arg))
3028
process.exit(ExitCode.Success)
3129
}

.stacks/core/storage/src/files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { JsonFile, PackageJson, TextFile } from '@stacksjs/types'
33
import { detectIndent, detectNewline } from '@stacksjs/strings'
44
import { componentsPath, dirname, functionsPath, join, projectPath } from '@stacksjs/path'
55
import { contains } from '@stacksjs/arrays'
6-
import { fs } from './fs'
6+
import { existsSync, fs } from './fs'
77

88
/**
99
* Reads a JSON file and returns the parsed data.

0 commit comments

Comments
 (0)