Skip to content

Commit 40c47d6

Browse files
committed
chore: wip
1 parent a56edbf commit 40c47d6

File tree

4 files changed

+44
-52
lines changed

4 files changed

+44
-52
lines changed

.stacks/core/buddy/src/cli.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 { handleError } from '@stacksjs/error-handling'
33
import { cli } from '@stacksjs/cli'
44
import { ensureProjectIsInitialized } from '@stacksjs/utils'
5-
import { version } from '../package.json'
65
import * as cmd from './commands'
76

87
// setup global error handlers

app/commands/inspire.ts

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,42 @@
11
// triggered via `$your-command inspire`
2-
3-
import { Command, intro, log } from '@stacksjs/cli'
4-
import { type CliOptions } from '@stacksjs/types'
5-
6-
export default new Command({
7-
name: 'inspire',
8-
description: 'Inspire yourself with a random quote',
9-
active: true, // default is true
10-
11-
options: [ // alternatively, `options: ['--two, -t', 'Show two quotes', { default: false }]`
12-
{
13-
name: '--two, -t',
14-
description: 'Show two quotes',
15-
default: false,
16-
},
17-
],
18-
19-
run: async (options?: CliOptions) => {
20-
log.info('Passed options are:', options)
21-
22-
await intro('buddy inspire')
23-
24-
return await runAction(Action.Inspire)
25-
},
26-
27-
// optional
28-
onFail: (error: Error) => {
29-
// outro('While running the inspire command, there was an issue', { startTime }, result.error)
30-
log.error(error)
31-
},
32-
33-
// optional
34-
onSuccess: () => {
35-
// const quote = result.value
36-
// outro(`Your custom quote is ${quote}`, { startTime })
37-
log.success('Success!')
38-
},
39-
})
40-
41-
// alternatively, you may use defineCommand() to create a command
42-
// export default defineCommand({
43-
// name: 'inspire',
44-
// description: 'Inspire yourself with a random quote',
45-
// options: []
46-
// run: async (options: CliOptions) => {}
47-
// onFail: (error: Error) => {}
48-
// onSuccess: () => {}
49-
// })
2+
import process from 'node:process'
3+
import { cli, log } from '@stacksjs/cli'
4+
import { collect } from '@stacksjs/collections'
5+
6+
// for enhanced type safety
7+
interface InspireOptions {
8+
two: boolean
9+
}
10+
11+
const quotes = collect([
12+
'The best way to get started is to quit talking and begin doing.',
13+
'The pessimist sees difficulty in every opportunity. The optimist sees opportunity in every difficulty.',
14+
'Don’t let yesterday take up too much of today.',
15+
'You learn more from failure than from success. Don’t let it stop you. Failure builds character.',
16+
'It’s not whether you get knocked down, it’s whether you get up.',
17+
'If you are working on something that you really care about, you don’t have to be pushed. The vision pulls you.',
18+
'People who are crazy enough to think they can change the world, are the ones who do.',
19+
'Failure will never overtake me if my determination to succeed is strong enough.',
20+
'Entrepreneurs are great at dealing with uncertainty and also very good at minimizing risk. That’s the classic entrepreneur.',
21+
'We may encounter many defeats but we must not be defeated.',
22+
'Knowing is not enough; we must apply. Wishing is not enough; we must do.',
23+
'Imagine your life is perfect in every respect; what would it look like?',
24+
'We generate fears while we sit. We overcome them by action.',
25+
'Whether you think you can or think you can’t, you’re right.',
26+
'Security is mostly a superstition. Life is either a daring adventure or nothing.',
27+
])
28+
29+
cli()
30+
.command('inspire', 'Inspire yourself with a random quote')
31+
.option('--two, -t', 'Show two quotes', { default: false })
32+
.alias('insp')
33+
.action((options: InspireOptions) => {
34+
if (options.two)
35+
quotes.random(2).forEach(quote => log.info(quote))
36+
else
37+
log.info(quotes.random())
38+
39+
log.info('')
40+
log.success('Have a great day!')
41+
process.exit(ExitCode.Success)
42+
})

app/models/User.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { faker } from '@stacksjs/faker'
22
import { validator } from '@stacksjs/validation'
3-
import { defineModel } from '@stacksjs/config'
3+
import type { Model } from '@stacksjs/types'
44

5-
export default defineModel({
5+
export default {
66
name: 'User', // defaults to the sanitized file name
77
table: 'users', // defaults to the lowercase, plural name of the model
88
// primaryKey: 'id', // defaults to `id`
@@ -46,4 +46,4 @@ export default defineModel({
4646
factory: () => faker.internet.password(),
4747
},
4848
},
49-
})
49+
} satisfies Model

bun.lockb

725 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)