Skip to content

Commit 87e2da1

Browse files
committed
chore: wip
1 parent 1f9fd15 commit 87e2da1

File tree

30 files changed

+447
-228
lines changed

30 files changed

+447
-228
lines changed

.github/stale.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ exemptLabels:
99
staleLabel: stale
1010
markComment: >
1111
This issue has been automatically marked as stale because it has not had
12-
recent activity. It will be closed if no further activity occurs. Thank you
13-
for your contributions.
12+
recent activity. It will be closed if no further activity occurs.
13+
Thank you for your contributions.
1414
closeComment: false

.stacks/core/actions/src/helpers/utils.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import storage from '@stacksjs/storage'
22
import { italic, log, runCommand, runCommands } from '@stacksjs/cli'
33
import { actionsPath, functionsPath } from '@stacksjs/path'
44
import type { ActionOptions, CommandResult } from '@stacksjs/types'
5-
import type { Err, Result } from '@stacksjs/error-handling'
5+
import type { Result, errAsync } from '@stacksjs/error-handling'
66
import { err } from '@stacksjs/error-handling'
77

88
function parseOptions(options?: ActionOptions) {
@@ -22,11 +22,7 @@ function parseOptions(options?: ActionOptions) {
2222
return parsedOptions.filter(Boolean).join(' ').replace('----=', '')
2323
}
2424

25-
export type ActionResult = Promise<
26-
Result<CommandResult<string>, Error>
27-
| Result<CommandResult<string>, Error>[]
28-
| Err<CommandResult<string>, string>
29-
>
25+
export type ActionResult = CommandResult
3026

3127
/**
3228
* Run an Action the Stacks way.
@@ -35,17 +31,12 @@ export type ActionResult = Promise<
3531
* @param options The options to pass to the command.
3632
* @returns The result of the command.
3733
*/
38-
export async function runAction(action: string, options?: ActionOptions): Promise<
39-
Result<CommandResult<string>, Error>
40-
| Result<CommandResult<string>, Error>[]
41-
| Err<CommandResult<string>, string>
42-
> {
34+
export async function runAction(action: string, options?: ActionOptions): Promise<CommandResult | CommandResult[]> {
4335
if (!hasAction(action))
44-
return err(`The specified action "${action}" does not exist.`)
36+
return errAsync(`The specified action "${action}" does not exist.`)
4537

4638
// we need to parse options here because they need to bw passed to the action
4739
const opts = parseOptions(options)
48-
4940
const cmd = `npx esno ${actionsPath(`${action}.ts ${opts}`)}`
5041

5142
if (options?.verbose)
@@ -63,7 +54,7 @@ export async function runAction(action: string, options?: ActionOptions): Promis
6354
* @param options The options to pass to the command.
6455
* @returns The result of the command.
6556
*/
66-
export async function runActions(actions: string[], options?: ActionOptions): Promise<Result<CommandResult<string>, Error>[] | Result<CommandResult<string>, Error> | Err<CommandResult<string>, string>> {
57+
export async function runActions(actions: string[], options?: ActionOptions): Promise<CommandResult> | Promise<CommandResult>[] {
6758
if (!actions.length)
6859
return err('No actions were specified')
6960

.stacks/core/actions/src/preinstall.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { log, spawn } from '@stacksjs/cli'
22
import { projectPath } from '@stacksjs/path'
33
import type { PreinstallOptions } from '@stacksjs/types'
4-
import { determineDebugMode } from '@stacksjs/utils'
4+
import { determineDebugLevel } from '@stacksjs/utils'
55

66
export async function invoke(options?: PreinstallOptions) {
77
try {
8-
const stdio = determineDebugMode(options) ? 'inherit' : 'ignore'
8+
const stdio = determineDebugLevel(options) ? 'inherit' : 'ignore'
99

1010
log.info('Preinstall check...')
1111
await spawn('npx only-allow pnpm', { stdio, cwd: projectPath() })

.stacks/core/actions/src/upgrade.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { intro, log, outro, prompt, runCommand, spawn } from '@stacksjs/cli'
22
import storage from '@stacksjs/storage'
3-
import { determineDebugMode } from '@stacksjs/utils'
3+
import { determineDebugLevel } from '@stacksjs/utils'
44
import { projectPath } from '@stacksjs/path'
55
import type { UpgradeOptions } from '@stacksjs/types'
66
import { ExitCode, NpmScript } from '@stacksjs/types'
77

88
export async function checkForUncommittedChanges(path = './.stacks', options: UpgradeOptions) {
99
try {
10-
const stdio = determineDebugMode(options) ? 'inherit' : 'ignore'
10+
const stdio = determineDebugLevel(options) ? 'inherit' : 'ignore'
1111

1212
// check if the .stacks folder has any updates
1313
// https://carlosbecker.com/posts/git-changed/

.stacks/core/actions/src/upgrade/framework.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { log, outro } from '@stacksjs/cli'
22
import storage from '@stacksjs/storage'
3-
import { determineDebugMode, loop } from '@stacksjs/utils'
3+
import { determineDebugLevel, loop } from '@stacksjs/utils'
44
import { frameworkPath, projectPath } from '@stacksjs/path'
55

66
// await runCommand(NpmScript.UpgradeFramework, parseArgs())
@@ -20,7 +20,7 @@ loop(5, async () => {
2020

2121
await storage.copyFolder(frameworkPath(), projectPath('./updates/.stacks'), exclude)
2222

23-
if (determineDebugMode(options))
23+
if (determineDebugLevel(options))
2424
log.info('Cleanup...')
2525

2626
await storage.deleteFolder(projectPath('updates'))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async function fresh(buddy: CLI) {
1414
.option('--verbose', descriptions.verbose, { default: false })
1515
.action(async (options: FreshOptions) => {
1616
const perf = await intro('buddy fresh')
17-
const result = await runAction(Action.Fresh, { ...options, showSpinner: true, spinnerText: 'Freshly installing dependencies...' })
17+
const result = await runAction(Action.Fresh, options)
1818

1919
if (result.isErr()) {
2020
outro('While running the fresh command, there was an issue', { startTime: perf, useSeconds: true, isError: true }, result.error)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async function migrate(buddy: CLI) {
1414
.option('--verbose', descriptions.verbose, { default: false })
1515
.action(async (options: FreshOptions) => {
1616
const perf = await intro('buddy migrate')
17-
const result = await runAction(Action.Migrate, { ...options, showSpinner: true, spinnerText: 'Freshly installing dependencies...' })
17+
const result = await runAction(Action.Migrate, { ...options, showSpinner: true, spinnerText: 'Migrating...' })
1818

1919
if (result.isErr()) {
2020
outro('While running the migrate command, there was an issue', { startTime: perf, useSeconds: true, isError: true }, result.error)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ async function seed(buddy: CLI) {
1212
.option('--verbose', descriptions.verbose, { default: false })
1313
.action(async (options: FreshOptions) => {
1414
// const perf = await intro('buddy seed')
15-
// const result = await runAction(Action.Seed, { ...options, showSpinner: true, spinnerText: 'Freshly installing dependencies...' })
15+
// const result = await runAction(Action.Seed, { ...options, showSpinner: true, spinnerText: 'Seeding...' })
1616

1717
// if (result.isErr()) {
1818
// outro('While running the seed command, there was an issue', { startTime: perf, useSeconds: true, isError: true }, result.error)

.stacks/core/cli/src/run.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { execSync as childExec } from 'node:child_process'
2-
import type { Err } from '@stacksjs/error-handling'
3-
import type { CliOptions, CommandResult, Result, SpinnerOptions as Spinner } from '@stacksjs/types'
2+
import type { CliOptions, CommandResult, SpinnerOptions as Spinner } from '@stacksjs/types'
43
import { projectPath } from '@stacksjs/path'
54
import { ResultAsync, err } from '@stacksjs/error-handling'
6-
import { log } from '@stacksjs/logging'
7-
import { determineDebugMode } from '@stacksjs/utils'
5+
import { determineDebugLevel } from '@stacksjs/utils'
86
import { spawn } from './command'
97
import { startSpinner } from './helpers'
108
import { italic } from '.'
@@ -17,14 +15,15 @@ import { italic } from '.'
1715
* @param errorMsg The name of the error to throw if the command fails.
1816
* @returns The result of the command.
1917
*/
20-
export function exec(command: string, options?: CliOptions) {
18+
export function exec(command: string, options?: CliOptions): CommandResult {
2119
const cwd = options?.cwd || projectPath()
22-
const stdio = determineDebugMode(options) ? 'inherit' : 'ignore'
20+
const stdio = determineDebugLevel(options) ? 'inherit' : 'ignore'
2321
const shell = options?.shell || false
2422

2523
return ResultAsync.fromPromise(
2624
spawn(command, { stdio, cwd, shell }),
27-
() => log.error(new Error(`Failed to run command: ${italic(command)}`)),
25+
// () => new Error(`Failed to run command: ${italic(command)}`),
26+
() => new Error(`Failed to run command: ${italic(command)}`),
2827
)
2928
}
3029

@@ -45,7 +44,7 @@ export function execSync(command: string) {
4544
* @param options The options to pass to the command.
4645
* @returns The result of the command.
4746
*/
48-
export async function runCommand(command: string, options?: CliOptions) {
47+
export async function runCommand(command: string, options?: CliOptions): Promise<CommandResult> {
4948
return await exec(command, options)
5049
}
5150

@@ -56,12 +55,14 @@ export async function runCommand(command: string, options?: CliOptions) {
5655
* @param options The options to pass to the command.
5756
* @returns The result of the command.
5857
*/
59-
export async function runCommands(commands: string[], options?: CliOptions): Promise<Result<CommandResult<string>, Error>[] | Result<CommandResult<string>, Error> | Err<CommandResult<string>, string>> {
60-
const results: Result<CommandResult<string>, Error>[] = []
58+
export async function runCommands(commands: string[], options?: CliOptions): Promise<CommandResult[]> {
59+
const results: CommandResult[] = []
6160
const numberOfCommands = commands.length
6261

63-
if (!numberOfCommands)
64-
return err('No commands were specified')
62+
if (!numberOfCommands) {
63+
log.error(new Error('No commands were specified'))
64+
process.exit()
65+
}
6566

6667
const spinner = determineSpinner(options)
6768

@@ -93,7 +94,7 @@ export async function runCommands(commands: string[], options?: CliOptions): Pro
9394
}
9495

9596
function determineSpinner(options?: CliOptions): Spinner | undefined {
96-
if (!determineDebugMode(options))
97+
if (!determineDebugLevel(options))
9798
return startSpinner(options?.spinnerText)
9899

99100
return undefined

.stacks/core/config/src/index.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ export function env(key: string, fallback: any) {
1010

1111
export { defineBuildConfig } from 'unbuild'
1212

13-
export function defineAppConfig(options: AppOptions) {
13+
export function defineApp(options: AppOptions) {
1414
return options
1515
}
1616

17-
export function defineCacheConfig(options: CacheOptions) {
17+
export function defineCache(options: CacheOptions) {
1818
return options
1919
}
2020

21-
export function defineCliConfig(options: CliOptions) {
21+
export function defineCli(options: CliOptions) {
2222
return options
2323
}
2424

2525
export function defineCronJobsConfig(options: CronJobOptions[]) {
2626
return options
2727
}
2828

29-
export function defineDatabaseConfig(options: DatabaseOptions) {
29+
export function defineDatabase(options: DatabaseOptions) {
3030
return options
3131
}
3232

@@ -38,58 +38,58 @@ export function defineDebugConfig(options: DebugOptions) {
3838
// return options
3939
// }
4040

41-
export function defineDnsConfig(options: DnsOptions) {
41+
export function defineDns(options: DnsOptions) {
4242
return options
4343
}
4444

4545
export function defineEmailConfig(options: EmailOptions) {
4646
return options
4747
}
4848

49-
export function defineEventsConfig(options: Events) {
49+
export function defineEvents(options: Events) {
5050
return options
5151
}
5252

53-
export function defineGitConfig(options: GitOptions) {
53+
export function defineGit(options: GitOptions) {
5454
return options
5555
}
5656

57-
export function defineHashingConfig(options: HashingOptions) {
57+
export function defineHashing(options: HashingOptions) {
5858
return options
5959
}
6060

61-
export function defineLibraryConfig(options: LibraryOptions) {
61+
export function defineLibrary(options: LibraryOptions) {
6262
return options
6363
}
6464

6565
export function defineModel(options: Model) {
6666
return options
6767
}
6868

69-
export function defineNotificationConfig(options: NotificationOptions) {
69+
export function defineNotification(options: NotificationOptions) {
7070
return options
7171
}
7272

73-
export function definePageConfig(options: PagesOption) {
73+
export function definePage(options: PagesOption) {
7474
return options
7575
}
7676

77-
export function definePaymentConfig(options: PaymentOptions) {
77+
export function definePayment(options: PaymentOptions) {
7878
return options
7979
}
8080

81-
export function defineSearchEngineConfig(options: SearchEngineOptions) {
81+
export function defineSearchEngine(options: SearchEngineOptions) {
8282
return options
8383
}
8484

85-
export function defineServicesConfig(options: ServicesOptions) {
85+
export function defineServices(options: ServicesOptions) {
8686
return options
8787
}
8888

89-
export function defineStorageConfig(options: StorageOptions) {
89+
export function defineStorage(options: StorageOptions) {
9090
return options
9191
}
9292

93-
export function defineUiConfig(options: UiOptions) {
93+
export function defineUi(options: UiOptions) {
9494
return options
9595
}

0 commit comments

Comments
 (0)