Skip to content

Commit b733627

Browse files
committed
chore: wip
1 parent 69deeaf commit b733627

File tree

32 files changed

+147
-124
lines changed

32 files changed

+147
-124
lines changed

storage/framework/core/actions/build.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ import dts from 'bun-plugin-dts-auto'
22

33
await Bun.build({
44
root: './src',
5+
outdir: './dist',
6+
format: 'esm',
7+
target: 'bun',
58

69
entrypoints: [
7-
'./src/index.ts',
810
'./src/build/component-libs.ts',
911
'./src/build/core.ts',
1012
'./src/build/stacks.ts',
13+
'./src/database/seed.ts',
14+
'./src/deploy/index.ts',
1115
'./src/dev/index.ts',
1216
'./src/dev/components.ts',
1317
'./src/dev/docs.ts',
@@ -31,31 +35,27 @@ await Bun.build({
3135
'./src/upgrade/dependencies.ts',
3236
'./src/upgrade/framework.ts',
3337
'./src/upgrade/index.ts',
34-
'./src/index.ts',
3538
'./src/add.ts',
3639
'./src/build.ts',
3740
'./src/bump.ts',
3841
'./src/changelog.ts',
3942
'./src/clean.ts',
4043
'./src/commit.ts',
4144
'./src/copy-types.ts',
42-
'./src/deploy/index.ts',
4345
'./src/examples.ts',
4446
'./src/fresh.ts',
47+
'./src/index.ts',
4548
'./src/key-generate.ts',
4649
'./src/make.ts',
4750
'./src/prepublish.ts',
4851
'./src/release.ts',
49-
'./src/database/seed.ts',
5052
'./src/test.ts',
5153
'./src/tinker.ts',
5254
'./src/typecheck.ts',
5355
'./src/types.ts',
5456
'./src/upgrade.ts',
5557
],
5658

57-
outdir: './dist',
58-
5959
external: [
6060
'@stacksjs/path',
6161
'@stacksjs/cli',
@@ -64,21 +64,20 @@ await Bun.build({
6464
'@stacksjs/enums',
6565
'@stacksjs/storage',
6666
'@stacksjs/utils',
67+
'markdown-it',
68+
'vue-component-meta',
6769
'@stacksjs/strings',
6870
'@stacksjs/config',
6971
'@stacksjs/error-handling',
7072
'@stacksjs/env',
7173
'@stacksjs/security',
7274
'@stacksjs/database',
73-
'markdown-it',
74-
'vue-component-meta',
75+
'bun',
7576
],
7677

7778
plugins: [
7879
dts({
7980
cwd: import.meta.dir,
8081
}),
8182
],
82-
83-
target: 'bun',
8483
})

storage/framework/core/actions/src/deploy/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { path as p } from '@stacksjs/path'
55
import { storage } from '@stacksjs/storage'
66

77
await runCommand('bun run build', {
8-
cwd: p.frameworkPath(),
8+
cwd: p.corePath(),
99
})
1010

1111
if (storage.hasFiles(p.projectPath('docs'))) {

storage/framework/core/actions/src/dev/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { log } from '@stacksjs/logging'
22
import type { DevOptions } from '@stacksjs/types'
33
import { Action } from '@stacksjs/enums'
4-
import { runAction } from '../helpers'
4+
import { runAction } from '../helpers/utils'
55

66
export async function runDevServer(options: DevOptions) {
77
log.info('Starting your Frontend Engine...')

storage/framework/core/actions/src/generate/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { GeneratorOptions } from '@stacksjs/types'
55
import { runCommand } from '@stacksjs/cli'
66
import { runNpmScript } from '@stacksjs/utils'
77
import { frameworkPath, projectPath } from '@stacksjs/path'
8-
import { runAction } from '../helpers'
8+
import { runAction } from '../helpers/utils'
99

1010
// import { files } from '@stacksjs/storage'
1111

storage/framework/core/actions/src/helpers/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

storage/framework/core/actions/src/helpers/utils.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import * as storage from '@stacksjs/storage'
21
import { buddyOptions, runCommand, runCommands } from '@stacksjs/cli'
2+
import { storage } from '@stacksjs/storage'
33
import { log } from '@stacksjs/logging'
44
import * as p from '@stacksjs/path'
5-
import type { ActionOptions, Subprocess } from '@stacksjs/types'
6-
import type { Result } from '@stacksjs/error-handling'
7-
import { err, handleError } from '@stacksjs/error-handling'
5+
import type { ActionOptions } from '@stacksjs/types'
86

97
/**
108
* Run an Action the Stacks way.
@@ -13,7 +11,7 @@ import { err, handleError } from '@stacksjs/error-handling'
1311
* @param options The options to pass to the command.
1412
* @returns The result of the command.
1513
*/
16-
export async function runAction(action: string, options?: ActionOptions): Promise<Result<Subprocess, Error>> {
14+
export async function runAction(action: string, options?: ActionOptions) {
1715
const opts = buddyOptions()
1816
const path = p.relativeActionsPath(`src/${action}.ts`)
1917
const cmd = `bun --bun ${path} ${opts}`.trimEnd()
@@ -25,9 +23,6 @@ export async function runAction(action: string, options?: ActionOptions): Promis
2523
log.debug('runAction:', cmd)
2624
log.debug('action options:', optionsWithCwd)
2725

28-
if (!hasAction(action))
29-
return err(handleError(`The specified action "${action}" does not exist`))
30-
3126
return await runCommand(cmd, optionsWithCwd)
3227
}
3328

@@ -63,8 +58,5 @@ export async function runActions(actions: string[], options?: ActionOptions) {
6358
}
6459

6560
export function hasAction(action: string) {
66-
if (storage.isFile(p.functionsPath(`actions/${action}.ts`)))
67-
return true
68-
6961
return storage.isFile(p.actionsPath(`${action}.ts`))
7062
}

storage/framework/core/actions/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
export * from './action'
22
export * from './dev'
33
export * from './generate'
4-
export * from './helpers'
4+
export * from './helpers/utils'
55

6-
export { examples as runExample } from './examples'
76
export { commit as runCommit } from './commit'
87
export { add as runAdd } from './add'
98

storage/framework/core/buddy/src/cli.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import process from 'node:process'
2-
import { log } from '@stacksjs/logging'
3-
import { CAC } from 'cac'
2+
import type { CAC } from '@stacksjs/cli'
3+
import { cli, log } from '@stacksjs/cli'
44
import { ensureProjectIsInitialized } from '@stacksjs/utils'
55
import { path as p } from '@stacksjs/path'
66
import { fs } from '@stacksjs/storage'
@@ -20,21 +20,28 @@ process.on('unhandledRejection', (error: Error) => {
2020
})
2121

2222
async function main() {
23-
// const buddy = cli('buddy')
24-
const buddy = new CAC('buddy')
23+
const buddy = cli('buddy')
2524

2625
// the following commands are not dependent on the project being initialized
2726
cmd.setup(buddy)
2827
cmd.key(buddy)
2928

3029
// before running any commands, ensure the project is already initialized
31-
await ensureProjectIsInitialized()
30+
const isAppKeySet = await ensureProjectIsInitialized()
31+
if (isAppKeySet) {
32+
log.info('Project is initialized')
33+
}
34+
else {
35+
log.warn('Your `APP_KEY` is not yet')
36+
// TODO: add prompt to set the key
37+
process.exit(1)
38+
}
3239

3340
cmd.build(buddy)
3441
cmd.changelog(buddy)
3542
cmd.clean(buddy)
3643
cmd.cloud(buddy)
37-
// cmd.commit(buddy)
44+
cmd.commit(buddy)
3845
cmd.configure(buddy)
3946
cmd.dev(buddy)
4047
cmd.domains(buddy)
@@ -48,15 +55,14 @@ async function main() {
4855
cmd.install(buddy)
4956
cmd.lint(buddy)
5057
cmd.list(buddy)
51-
// cmd.make(buddy)
52-
// cmd.migrate(buddy)
58+
cmd.make(buddy)
59+
cmd.migrate(buddy)
5360
cmd.release(buddy)
54-
// cmd.seed(buddy)
61+
cmd.seed(buddy)
5562
cmd.setup(buddy)
56-
// cmd.example(buddy)
57-
// cmd.test(buddy)
63+
cmd.test(buddy)
5864
cmd.version(buddy)
59-
// cmd.prepublish(buddy)
65+
cmd.prepublish(buddy)
6066
cmd.upgrade(buddy)
6167

6268
// dynamic imports

storage/framework/core/buddy/src/commands/key.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import process from 'node:process'
22
import type { CLI, KeyOptions } from '@stacksjs/types'
33
import { intro, log, outro } from '@stacksjs/cli'
4-
import { Action } from '@stacksjs/enums'
54
import { runAction } from '@stacksjs/actions'
5+
import { Action } from '@stacksjs/enums'
66

77
export function key(buddy: CLI) {
88
const descriptions = {

storage/framework/core/build.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { path as p } from '@stacksjs/path'
22
import { fs, glob } from '@stacksjs/storage'
3-
import { dim, log, runCommand } from '@stacksjs/cli'
3+
import { bold, dim, log, runCommand } from '@stacksjs/cli'
4+
45
// import { $ } from 'bun'
56

67
const dirs = await glob(p.resolve('./', '*'), { onlyDirectories: true })
@@ -19,13 +20,13 @@ for (const dir of dirs) {
1920

2021
// rm the dist folder before building
2122
// await $`rm -rf ${p.resolve(dir, 'dist')}`
22-
const distPath = p.resolve(dir, 'dist');
23+
const distPath = p.resolve(dir, 'dist')
2324

2425
// Check if the dist folder exists
2526
if (await fs.exists(distPath)) {
2627
await runCommand('rm -rf dist', {
2728
cwd: dir, // Change this to 'dir' to correctly set the working directory
28-
});
29+
})
2930
}
3031

3132
log.debug(`Cleaned dist folder`)
@@ -55,10 +56,10 @@ for (const dir of dirs) {
5556

5657
const relativeFilePath = p.relative(dir, file).replace('dist/', '')
5758
// eslint-disable-next-line no-console
58-
console.log(`${dim(`[${sizeStr}]`)} ${dim('dist/')}${relativeFilePath}`)
59+
console.log(`${bold(dim(`[${sizeStr}]`))} ${dim('dist/')}${relativeFilePath}`)
5960
}
6061

61-
log.success(`${dim(`[${timeTaken}ms]`)} Built ${pkgName}`)
62+
log.success(`${bold(dim(`[${timeTaken}ms]`))} Built ${pkgName}`)
6263
}
6364

6465
const endTime = Date.now()

0 commit comments

Comments
 (0)