Skip to content

Commit ef0a977

Browse files
committed
chore: wip
chore: wip chore: wip
1 parent b0a7990 commit ef0a977

File tree

19 files changed

+742
-738
lines changed

19 files changed

+742
-738
lines changed

.stacks/core/actions/src/dev/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { log } from '@stacksjs/logging'
2-
import { frameworkPath } from '@stacksjs/path'
32
import { runCommand } from '@stacksjs/cli'
43
import type { DevOptions } from '@stacksjs/types'
54
import { Action, NpmScript } from '@stacksjs/types'

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import process from 'node:process'
22
import { createHostedZone } from '@stacksjs/dns'
33
import { app } from '@stacksjs/config'
44
import { handleError } from '@stacksjs/error-handling'
5-
import { projectStoragePath } from '@stacksjs/path'
65
import { italic, parseOptions } from '@stacksjs/cli'
76
import { whois } from '@stacksjs/whois'
87
import { logger } from '@stacksjs/logging'

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,3 @@ if (result.isErr()) {
3535
handleError(result.error)
3636
process.exit(1)
3737
}
38-
39-
logger.log('')
40-
logger.log('✅ Removed your domain')

.stacks/core/buddy/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { log, runCommand } from '@stacksjs/cli'
22

3-
const result = await runCommand('bun build ./src/index.ts ./src/cli.ts --outdir dist --format esm --target bun --external @stacksjs/actions --external @stacksjs/error-handling --external @stacksjs/cli --external @stacksjs/logging --external @stacksjs/utils --external @stacksjs/validation --external @stacksjs/path --external @stacksjs/storage --splitting --target bun', {
3+
const result = await runCommand('bun build ./src/index.ts ./src/cli.ts --outdir dist --format esm --target bun --external @stacksjs/actions --external @stacksjs/error-handling --external @stacksjs/cli --external @stacksjs/logging --external @stacksjs/utils --external @stacksjs/validation --external @stacksjs/path --external @stacksjs/storage --external @stacksjs/types --external @aws-sdk/client-route-53 --splitting --target bun', {
44
cwd: import.meta.dir,
55
})
66

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async function hasUserDomainBeenAddedToCloud(domainName?: string) {
8080
return false
8181
}
8282

83-
async function addDomain(options: DeployOptions, startTime: number) {
83+
export async function addDomain(options: DeployOptions, startTime: number) {
8484
const result = await runAction(Action.DomainsAdd, options)
8585

8686
if (result.isErr()) {
Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,61 @@
11
import process from 'node:process'
22
import type { CLI, DomainsOptions } from '@stacksjs/types'
33
import { runAction } from '@stacksjs/actions'
4-
import { intro, outro } from '@stacksjs/cli'
5-
import { logger } from '@stacksjs/logging'
4+
import { config } from '@stacksjs/config'
5+
import { intro, outro, prompts } from '@stacksjs/cli'
66
import { Action, ExitCode } from '@stacksjs/types'
7+
import { addDomain } from './deploy'
78

89
export function domains(buddy: CLI) {
910
const descriptions = {
1011
add: 'Add a domain to your cloud',
1112
remove: 'Remove a domain from your cloud',
13+
skip: 'Skip the confirmation prompt',
1214
verbose: 'Enable verbose output',
1315
}
1416

1517
buddy
1618
.command('domains:add <domain>', descriptions.add)
1719
.option('--verbose', descriptions.verbose, { default: false })
1820
.action(async (options: DomainsOptions) => {
19-
const perf = await intro('buddy domains:add')
20-
const result = await runAction(Action.DomainsAdd, options)
21-
22-
if (result.isErr()) {
23-
await outro('While running the domains:add command, there was an issue', { startTime: perf, useSeconds: true, isError: true }, result.error)
24-
process.exit(ExitCode.FatalError)
25-
}
26-
27-
await outro('Added your domain.', { startTime: perf, useSeconds: true })
21+
const startTime = await intro('buddy domains:add')
22+
await addDomain(options, startTime)
2823
process.exit(ExitCode.Success)
2924
})
3025

3126
buddy
3227
.command('domains:remove <domain>', descriptions.remove)
28+
.option('--yes', descriptions.skip, { default: false })
3329
.option('--verbose', descriptions.verbose, { default: false })
34-
// TODO: .option('--yes', 'Skip the confirmation prompt', { default: false })
35-
.action(async (domain: string, options: DomainsOptions) => {
36-
const perf = await intro('buddy domains:remove')
37-
const result = await runAction(Action.DomainsRemove, { ...options, domain })
30+
.action(async (options: DomainsOptions) => {
31+
const domain = options.domain || config.app.url
32+
const opts = { ...options, domain }
33+
const startTime = await intro('buddy domains:remove')
34+
35+
// prompt for confirmation
36+
if (!opts.yes) {
37+
const { confirm } = await prompts({
38+
name: 'confirm',
39+
type: 'confirm',
40+
message: `Are you sure you want to remove ${domain}?`,
41+
})
42+
43+
console.log('confirm', confirm)
44+
45+
if (!confirm) {
46+
await outro('Cancelled the domains:remove command', { startTime, useSeconds: true, type: 'info' })
47+
process.exit(ExitCode.Success)
48+
}
49+
}
50+
51+
const result = await runAction(Action.DomainsRemove, opts)
3852

3953
if (result.isErr()) {
40-
await outro('While running the domains:remove command, there was an issue', { startTime: perf, useSeconds: true, isError: true }, result.error)
54+
await outro('While running the domains:remove command, there was an issue', { startTime, useSeconds: true }, result.error)
4155
process.exit(ExitCode.FatalError)
4256
}
4357

44-
await outro('Removed your domain', { startTime: perf, useSeconds: true })
58+
await outro('Removed your domain', { startTime, useSeconds: true })
4559
process.exit(ExitCode.Success)
4660
})
4761
}

.stacks/core/cli/src/console.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
2-
31
import { log } from '@stacksjs/logging'
42
import prompts from 'prompts'
53

.stacks/core/cli/src/helpers.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { handleError } from '@stacksjs/error-handling'
44
import { log } from '@stacksjs/logging'
55
import { version } from '../package.json'
66
import { spinner } from './spinner'
7-
import { bgCyan, bold, cyan, dim, italic } from './utilities'
7+
import { bgCyan, bold, cyan, dim, gray, green, italic } from './utilities'
88

99
/**
1010
* Prints the intro message.
@@ -30,21 +30,11 @@ export async function intro(command: string, options?: IntroOptions): Promise<nu
3030
* Prints the outro message.
3131
*/
3232
export function outro(text: string, options: OutroOptions, error?: Error | string) {
33-
const successMessage = options?.successMessage
33+
const message = options?.message || text
3434

3535
return new Promise((resolve) => {
36-
if (options.isError) {
37-
if (error)
38-
handleError(error)
39-
}
40-
else {
41-
if (options?.type === 'info')
42-
log.info(text)
43-
44-
// the following condition triggers in the case of "Cleaned up" messages
45-
if (options?.successMessage !== text)
46-
log.success(text)
47-
}
36+
if (error)
37+
handleError(error)
4838

4939
if (options.startTime) {
5040
let time = performance.now() - options.startTime
@@ -57,10 +47,21 @@ export function outro(text: string, options: OutroOptions, error?: Error | strin
5747
if (options.quiet === true)
5848
return resolve(ExitCode.Success)
5949

60-
if (options.isError)
50+
if (error)
6151
log.error(`[${time.toFixed(2)}${options.useSeconds ? 's' : 'ms'}] Failed`)
52+
else if (options.type === 'info')
53+
log.info(`${dim(gray(`[${time.toFixed(2)}${options.useSeconds ? 's' : 'ms'}]`))} ${message ?? 'Complete'}`)
6254
else
63-
log.success((`[${time.toFixed(2)}${options.useSeconds ? 's' : 'ms'}] ${successMessage ?? 'Complete'}`))
55+
log.info(`${dim(gray(bold(`[${time.toFixed(2)}${options.useSeconds ? 's' : 'ms'}]`)))} ${bold(green(message ?? 'Complete'))}`)
56+
}
57+
58+
else {
59+
if (options?.type === 'info')
60+
log.info(text)
61+
62+
// the following condition triggers in the case of "Cleaned up" messages
63+
else if (message !== text)
64+
log.success(text)
6465
}
6566

6667
return resolve(ExitCode.Success)

.stacks/core/dns/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { log, runCommand } from '@stacksjs/cli'
22

3-
const result = await runCommand('bun build ./src/index.ts --outdir dist --format esm --external aws-cdk-lib --external @aws-sdk/client-route-53 --external constructs --external @stacksjs/config --external @stacksjs/storage --target bun', {
3+
const result = await runCommand('bun build ./src/index.ts --outdir dist --format esm --external aws-cdk-lib --external @aws-sdk/client-route-53 --external constructs --external @stacksjs/config --external @stacksjs/storage --external @stacksjs/logging --external @stacksjs/path --external @stacksjs/error-handling --target bun', {
44
cwd: import.meta.dir,
55
})
66

.stacks/core/faker/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { log, runCommand } from '@stacksjs/cli'
22

3-
const result = await runCommand('bun build ./src/index.ts --outdir dist --format esm --external @stacksjs/cli --target bun', {
3+
const result = await runCommand('bun build ./src/index.ts --outdir dist --format esm --external @stacksjs/cli --external @faker-js/faker --target bun', {
44
cwd: import.meta.dir,
55
})
66

0 commit comments

Comments
 (0)