Skip to content

Commit 297332c

Browse files
committed
chore: wip
chore: wip chore: wip chore: wip
1 parent 04e1523 commit 297332c

File tree

7 files changed

+110
-62
lines changed

7 files changed

+110
-62
lines changed

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
11
import { log } from '@stacksjs/logging'
22
import { runCommand } from '@stacksjs/cli'
3+
import { runAction } from '@stacksjs/actions'
34
import type { DevOptions } from '@stacksjs/types'
45
import { Action, NpmScript } from '@stacksjs/types'
56

7+
export async function runDevServer(options: DevOptions) {
8+
log.info('Starting your Frontend Engine...')
9+
await runAction(Action.Dev, options)
10+
}
11+
12+
export async function runViewsDevServer(options: DevOptions) {
13+
log.info('Starting your Frontend Engine...')
14+
await runAction(Action.DevViews, options)
15+
}
16+
17+
export async function runApiDevServer(options: DevOptions) {
18+
log.info('Starting your API...')
19+
await runAction(Action.DevApi, options)
20+
}
21+
622
export async function runComponentsDevServer(options: DevOptions) {
7-
log.info('Starting your components dev server...')
23+
log.info('Starting your Library Engine...')
824
await runAction(Action.DevComponents, options)
925
}
1026

1127
export async function runDesktopDevServer(options: DevOptions) {
12-
log.info('Starting your Desktop engine...')
28+
log.info('Starting your Desktop Engine...')
1329
await runCommand(NpmScript.DevDesktop, options)
1430
}
1531

16-
export async function runPagesDevServer(options: DevOptions) {
17-
log.info('Starting your page engine...')
18-
await runCommand(NpmScript.DevViews, options)
32+
export async function runDocsDevServer(options: DevOptions) {
33+
log.info('Starting your Docs Engine...')
34+
await runAction(Action.DevDocs, options)
1935
}
2036

2137
export async function runFunctionsDevServer(options: DevOptions) {
22-
log.info('Starting your function\'s dev server...')
38+
log.info('Starting your Library Engine...')
2339
await runCommand(NpmScript.DevFunctions, options)
2440
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { runCommand } from '@stacksjs/cli'
2+
import { frameworkStoragePath } from '@stacksjs/path'
3+
4+
await runCommand('bun run dev', {
5+
cwd: frameworkStoragePath('web'),
6+
// verbose: true,
7+
})

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

Lines changed: 71 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,94 @@
11
import process from 'node:process'
22
import { Action, ExitCode } from '@stacksjs/types'
3-
import {
4-
runAction,
5-
runComponentsDevServer,
6-
runFunctionsDevServer,
7-
runPagesDevServer,
8-
} from '@stacksjs/actions'
3+
import { runAction, runComponentsDevServer, runFunctionsDevServer, runDocsDevServer } from '@stacksjs/actions'
94
import type { CLI, DevOptions } from '@stacksjs/types'
10-
import { intro, log, outro, runCommand } from '@stacksjs/cli'
5+
import { intro, log, outro, runCommand, prompt } from '@stacksjs/cli'
116
import { vitePath } from '@stacksjs/path'
127

138
export function dev(buddy: CLI) {
149
const descriptions = {
10+
dev: 'Starts development server',
11+
views: 'Starts the frontend development server',
1512
components: 'Start the Components development server',
1613
desktop: 'Start the Desktop development server',
1714
api: 'Start the local API development server',
1815
docs: 'Start the Documentation development server',
19-
pages: 'Start the Pages development server',
16+
interactive: 'Get asked which development server to start',
2017
select: 'Which development server are you trying to start?',
2118
verbose: 'Enable verbose output',
2219
}
2320

2421
buddy
25-
.command('dev', 'Start the development server for any of the following')
22+
.command('dev [server]', descriptions.dev)
2623
.option('-c, --components', descriptions.components)
2724
.option('-a, --api', descriptions.api)
2825
.option('-d, --docs', descriptions.docs)
29-
.option('-p, --views', descriptions.pages)
26+
.option('-i, --interactive', descriptions.interactive, { default: false })
3027
.option('--verbose', descriptions.verbose, { default: false })
31-
.action(async (options: DevOptions) => {
32-
// const perf = await intro('buddy dev')
33-
// const result = await runAction(Action.Dev, options)
34-
35-
if (hasNoOptions(options)) {
36-
// const answer = await prompt.require()
37-
// .select(descriptions.select, {
38-
// options: [
39-
// { value: 'all', label: 'All' },
40-
// { value: 'pages', label: 'Frontend' },
41-
// { value: 'api', label: 'Backend' },
42-
// { value: 'desktop', label: 'Desktop' },
43-
// { value: 'components', label: 'Components' },
44-
// { value: 'functions', label: 'Functions' },
45-
// { value: 'docs', label: 'Documentation' },
46-
// ],
47-
// })
48-
49-
// if (answer === 'components')
50-
// await components(options)
28+
.action(async (server: string | undefined, options: DevOptions) => {
29+
const perf = await intro('buddy dev')
30+
31+
console.log('server', server)
32+
33+
switch (server) {
34+
case 'frontend':
35+
await runPagesDevServer(options)
36+
break
37+
case 'api':
38+
await runFunctionsDevServer(options)
39+
break
40+
case 'components':
41+
await runComponentsDevServer(options)
42+
break
43+
case 'docs':
44+
await runDocsDevServer(options)
45+
break
46+
default:
47+
}
48+
49+
if (wantsInteractive(options)) {
50+
const answer = await prompt.require()
51+
.select(descriptions.select, {
52+
options: [
53+
{ value: 'all', label: 'All' },
54+
{ value: 'pages', label: 'Frontend' },
55+
{ value: 'api', label: 'Backend' },
56+
{ value: 'desktop', label: 'Desktop' },
57+
{ value: 'components', label: 'Components' },
58+
// { value: 'functions', label: 'Functions' },
59+
{ value: 'docs', label: 'Documentation' },
60+
],
61+
})
62+
63+
if (answer === 'components')
64+
await runComponentsDevServer(options)
5165
// else if (answer === 'functions')
52-
// await functions(options)
53-
// else if (answer === 'pages')
54-
// await pages(options)
55-
// else if (answer === 'docs')
56-
// await docs(options)
66+
// await runFunctionsDevServer(options)
67+
else if (answer === 'pages')
68+
await runPagesDevServer(options)
69+
else if (answer === 'docs')
70+
await runDocsDevServer(options)
5771

58-
// else process.exit(ExitCode.InvalidArgument)
72+
else {
73+
log.error('Invalid option during interactive mode')
74+
process.exit(ExitCode.InvalidArgument)
75+
}
5976
}
77+
6078
else {
6179
if (options.components)
6280
await runComponentsDevServer(options)
63-
// if (options.docs)
64-
// await runDocsDevServer(options)
81+
if (options.docs)
82+
await runDocsDevServer(options)
6583
else if (options.api)
6684
await runFunctionsDevServer(options)
6785
else if (options.pages)
6886
await runPagesDevServer(options)
69-
// else if (options.docs)
7087
}
71-
// await startDevelopmentServer(options)
7288

89+
await startDevelopmentServer(options)
90+
91+
outro('Exited', { startTime: perf, useSeconds: true })
7392
process.exit(ExitCode.Success)
7493
})
7594

@@ -139,7 +158,7 @@ export function dev(buddy: CLI) {
139158
})
140159

141160
buddy
142-
.command('dev:views', descriptions.pages)
161+
.command('dev:views', descriptions.views)
143162
.option('--verbose', descriptions.verbose, { default: false })
144163
.action(async (options: DevOptions) => {
145164
await runPagesDevServer(options)
@@ -151,6 +170,15 @@ export function dev(buddy: CLI) {
151170
})
152171
}
153172

154-
function hasNoOptions(options: DevOptions) {
155-
return !options.components && !options.all && !options.docs && !options.api && !options.pages
173+
export async function startDevelopmentServer(options: DevOptions) {
174+
const result = await runAction(Action.Dev, options)
175+
176+
if (result.isErr()) {
177+
log.error('While running the dev command, there was an issue', result.error)
178+
process.exit(ExitCode.InvalidArgument)
179+
}
180+
}
181+
182+
function wantsInteractive(options: DevOptions) {
183+
return options.interactive
156184
}

.stacks/core/types/src/cli.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export type CreateOptions = {
183183
[key in CreateStringOption]: string
184184
} & CliOptions
185185

186-
export type DevOption = 'components' | 'docs' | 'pages' | 'api' | 'desktop' | 'all'
186+
export type DevOption = 'components' | 'docs' | 'pages' | 'api' | 'desktop' | 'all' | 'functions' | 'interactive' | 'verbose'
187187
export type DevOptions = {
188188
[key in DevOption]: boolean;
189189
} & CliOptions
@@ -299,8 +299,9 @@ export enum NpmScript {
299299
BuildStacks = 'build:stacks',
300300
Clean = 'rimraf bun.lockb node_modules/ .stacks/**/dist',
301301
Dev = 'dev',
302+
DevDocs = 'dev:docs',
302303
DevDesktop = 'dev:desktop',
303-
DevViews = 'dev:views',
304+
DevViews = 'dev',
304305
DevFunctions = 'dev:functions',
305306
Fresh = 'fresh',
306307
Lint = 'eslint .',
@@ -349,7 +350,9 @@ export enum Action {
349350
Changelog = 'changelog',
350351
Clean = 'clean',
351352
DevComponents = 'dev/components',
352-
Dev = 'dev/index',
353+
Dev = 'dev/views',
354+
DevViews = 'dev/views',
355+
DevApi = 'wip',
353356
DevDesktop = 'dev/desktop',
354357
DevDocs = 'dev/docs',
355358
Deploy = 'deploy/index',

.stacks/core/vite/src/views.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import type { ViteConfig } from '@stacksjs/types'
22
import { path as p } from '@stacksjs/path'
33
import { alias } from '@stacksjs/alias'
44
import generateSitemap from 'vite-ssg-sitemap'
5-
6-
import UnoCSS from 'unocss/vite'
7-
import { autoImports, components, inspect, layouts, pages, uiEngine } from './stacks'
5+
import { autoImports, components, inspect, cssEngine, layouts, pages, uiEngine } from './stacks'
86
import { defineConfig } from './'
97

108
export const pagesConfig = {
@@ -27,15 +25,13 @@ export const pagesConfig = {
2725
pages({
2826
dirs: p.resourcesPath('views'),
2927
}),
30-
UnoCSS({
31-
configFile: p.corePath('vite/src/uno.config.ts'),
32-
}),
28+
cssEngine(),
3329
components(),
3430
layouts({
3531
layoutsDirs: p.resourcesPath('layouts'),
3632
}),
3733
autoImports(),
38-
// inspect(),
34+
inspect(),
3935
],
4036

4137
// https://github.com/antfu/vite-ssg

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ _Develop dynamic UIs with helpers for atomic design, and much more._
3535

3636
- 🧩 **Components** _a primitive to develop user interfaces_
3737
- 🤖 **Functions** _a primitive to develop business logic (and grant your UI superpowers)_
38-
- 🌐 **Web** _"a routing & templating engine that makes sense" using components—SSG & PWA ready_
38+
- 🌐 **Web** _a routing & templating engine that makes sense using components_
3939
- 🖥️ **Desktop** _automagically build a desktop app out of your web app_
4040
- 📚 **Library** _auto-builds component & function libraries_
4141
- ⚡️ Powered by Bun, Nitro, Tauri, UnoCSS, Vite & Vue

storage/framework/types/auto-imports.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,6 @@ declare module 'vue' {
14311431
readonly runFunctionsDevServer: UnwrapRef<typeof import('../../../.stacks/core/actions/src/dev/index')['runFunctionsDevServer']>
14321432
readonly runMake: UnwrapRef<typeof import('../../../.stacks/core/actions/src/index')['runMake']>
14331433
readonly runNpmScript: UnwrapRef<typeof import('../../../.stacks/core/utils/src/helpers')['runNpmScript']>
1434-
readonly runPagesDevServer: UnwrapRef<typeof import('../../../.stacks/core/actions/src/dev/index')['runPagesDevServer']>
14351434
readonly runtimePath: UnwrapRef<typeof import('../../../.stacks/core/path/src/index')['runtimePath']>
14361435
readonly schedulerPath: UnwrapRef<typeof import('../../../.stacks/core/path/src/index')['schedulerPath']>
14371436
readonly scriptsPath: UnwrapRef<typeof import('../../../.stacks/core/path/src/index')['scriptsPath']>
@@ -2269,7 +2268,6 @@ declare module '@vue/runtime-core' {
22692268
readonly runFunctionsDevServer: UnwrapRef<typeof import('../../../.stacks/core/actions/src/dev/index')['runFunctionsDevServer']>
22702269
readonly runMake: UnwrapRef<typeof import('../../../.stacks/core/actions/src/index')['runMake']>
22712270
readonly runNpmScript: UnwrapRef<typeof import('../../../.stacks/core/utils/src/helpers')['runNpmScript']>
2272-
readonly runPagesDevServer: UnwrapRef<typeof import('../../../.stacks/core/actions/src/dev/index')['runPagesDevServer']>
22732271
readonly runtimePath: UnwrapRef<typeof import('../../../.stacks/core/path/src/index')['runtimePath']>
22742272
readonly schedulerPath: UnwrapRef<typeof import('../../../.stacks/core/path/src/index')['schedulerPath']>
22752273
readonly scriptsPath: UnwrapRef<typeof import('../../../.stacks/core/path/src/index')['scriptsPath']>

0 commit comments

Comments
 (0)