Skip to content

Commit 04e397e

Browse files
committed
chore: wip
1 parent 2192635 commit 04e397e

File tree

18 files changed

+97
-56
lines changed

18 files changed

+97
-56
lines changed

.stacks/core/actions/package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,21 @@
259259
"vue-component-meta": "^1.6.5"
260260
},
261261
"dependencies": {
262+
"@stacksjs/cli": "workspace:*",
263+
"@stacksjs/config": "workspace:*",
264+
"@stacksjs/database": "workspace:*",
265+
"@stacksjs/error-handling": "workspace:*",
266+
"@stacksjs/logging": "workspace:*",
267+
"@stacksjs/pages": "workspace:*",
268+
"@stacksjs/path": "workspace:*",
269+
"@stacksjs/security": "workspace:*",
270+
"@stacksjs/storage": "workspace:*",
262271
"@stacksjs/strings": "workspace:*",
272+
"@stacksjs/utils": "workspace:*",
263273
"fast-glob": "^3.2.12",
264-
"fs-extra": "^11.1.1"
274+
"fs-extra": "^11.1.1",
275+
"markdown-it": "^13.0.1",
276+
"vue-component-meta": "^1.6.5"
265277
},
266278
"devDependencies": {
267279
"@stacksjs/development": "workspace:*",

.stacks/core/actions/src/clean.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
import { log, runCommand } from '@stacksjs/cli'
1+
import { log } from '@stacksjs/cli'
22
import { projectPath } from '@stacksjs/path'
3-
import { ExitCode, NpmScript } from '@stacksjs/types'
3+
import { del } from '@stacksjs/utils'
44

5-
log.info('Running clean command...')
5+
log.info('Running clean command...', projectPath())
66

7-
const result = await runCommand(NpmScript.Clean, { cwd: projectPath() })
8-
9-
if (result.isOk()) {
10-
log.success('Cleaned up')
11-
process.exit(ExitCode.Success)
12-
}
13-
14-
log.error(result.error)
15-
process.exit(ExitCode.FatalError)
7+
await del([
8+
projectPath('pnpm-lock.yaml'),
9+
projectPath('node_modules/'),
10+
projectPath('.stacks/**/dist'),
11+
projectPath('.stacks/**/node_modules')
12+
])

.stacks/core/actions/src/helpers/package-json.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { log } from '@stacksjs/logging'
22
import { writeTextFile } from '@stacksjs/storage'
33
import { packageJsonPath } from '@stacksjs/path'
4-
import { library } from '@stacksjs/config'
5-
import { packageManager } from '../../package.json' assert { type: 'json' }
4+
import { library, packageManager } from '@stacksjs/config'
65

76
export async function generatePackageJson(type: 'vue-components' | 'web-components' | 'functions') {
87
let name, description, directory, keywords, config, prettyName

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ export async function runAction(action: string, options?: ActionOptions): Promis
3838
const opts = parseOptions(options)
3939
const cmd = `npx tsx ${actionsPath(`${action}.ts ${opts}`)}`
4040

41-
// eslint-disable-next-line no-console
42-
console.log('cmd', cmd)
43-
4441
if (options?.verbose)
4542
log.debug('running command:', italic(cmd))
4643

.stacks/core/buddy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ _Create your personal or professional Vercel-like cloud, based on MIT-licensed O
7272
- ⛅️ **Serverless** _on-demand, auto-scaling, zero maintenance_
7373
- 🚏 **CDN** _zero-config low-latency CDN, including request life-cycle hooks & optimized request compressions (Brotli & gzip)_
7474
- 🔀 **Domain** _version-controlled & zero-config domain management (e.g. DNS)_
75-
- 📧 **Email** _secure & simplistic easy-peasy@custom-domains.com mail_
75+
- 📧 **Email** _secure & simplistic <easy-peasy@custom-domains.com> mail_
7676
- 🔐 **Firewall** _native web application firewall support_
7777
- 🚜 **Maintenance** _handles your cloud infrastructure via the Stacks & Serverless framework_
7878
- 🤖 **Infrastructure as Code** _create & maintain your cloud infrastructure with ease_

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ async function clean(buddy: CLI) {
1414
.option('--verbose', descriptions.verbose, { default: false })
1515
.action(async (options: CleanOptions) => {
1616
const perf = await intro('buddy clean')
17-
const result = await runAction(Action.Fresh, { ...options, verbose: true })
17+
const result = await runAction(Action.Clean, { ...options, verbose: true })
1818

1919
if (result.isErr()) {
2020
outro('While running the clean command, there was an issue', { startTime: perf, useSeconds: true, isError: true }, result.error as Error)
2121
process.exit(ExitCode.FatalError)
2222
}
2323

24-
outro('Cleaned project.', { startTime: perf, useSeconds: true })
24+
outro('Cleaned up', { startTime: perf, useSeconds: true })
2525
process.exit(ExitCode.Success)
2626
})
2727
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function fresh(buddy: CLI) {
1717
const result = await runAction(Action.Fresh, { ...options, verbose: true })
1818

1919
if (result.isErr()) {
20-
outro('While running the fresh command, there was an issue', { startTime: perf, useSeconds: true, isError: true }, result.error as Error)
20+
outro('While running the `fresh` command, there was an issue', { startTime: perf, useSeconds: true, isError: true }, result.error as Error)
2121
process.exit(ExitCode.FatalError)
2222
}
2323

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,8 @@ async function release(buddy: CLI) {
1616
const startTime = await intro('buddy release')
1717
const result = await runAction(Action.Release, { ...options, shell: true })
1818

19-
console.log('result', result)
20-
21-
// check if any element of the array is an error
22-
if (Array.isArray(result) && result.some(r => r.isErr())) {
23-
log.error('Failed to trigger the CI/CD release workflow.', result)
24-
process.exit()
25-
}
26-
2719
if (result.isErr()) {
28-
log.error('Failed to trigger the CI/CD release workflow.', result.error)
20+
log.error('Failed to complete ', result.error)
2921
process.exit()
3022
}
3123

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@ import { bold, dim, green, intro } from '@stacksjs/cli'
33
import { filesystem } from '@stacksjs/storage'
44
import { log } from '@stacksjs/logging'
55
import { frameworkPath } from '@stacksjs/path'
6-
import type { PackageJson } from 'type/node'
76

87
async function version(buddy: CLI) {
8+
// maybe use type-fest?
9+
type PackageJson = {
10+
engines: {
11+
node: string
12+
pnpm: string
13+
}
14+
version: string
15+
}
16+
917
const { fs } = filesystem
1018

1119
const descriptions = {

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { execSync as childExec } from 'node:child_process'
22
import type { CliOptions, CommandResult, CommandReturnValue, ResultAsync, SpinnerOptions as Spinner } from '@stacksjs/types'
33
import { ExitCode } from '@stacksjs/types'
44
import { projectPath } from '@stacksjs/path'
5-
import { ResultAsync as AsyncResult, err } from '@stacksjs/error-handling'
5+
import { ResultAsync as AsyncResult } from '@stacksjs/error-handling'
66
import { determineDebugLevel } from '@stacksjs/utils'
77
import { log } from './console'
88
import { spawn } from './command'
@@ -46,7 +46,6 @@ export function execSync(command: string) {
4646
* @returns The result of the command.
4747
*/
4848
export async function runCommand(command: string, options?: CliOptions): Promise<ResultAsync<CommandReturnValue, Error>> {
49-
console.log('runCommand', command, options)
5049
return await exec(command, options)
5150
}
5251

@@ -69,8 +68,6 @@ export async function runCommands(commands: string[], options?: CliOptions): Pro
6968

7069
const spinner = determineSpinner(options)
7170

72-
console.log('spinner', spinner)
73-
7471
for (const command of commands) {
7572
const result = await runCommand(command, options)
7673

@@ -79,8 +76,7 @@ export async function runCommands(commands: string[], options?: CliOptions): Pro
7976
}
8077
else if (result.isErr()) {
8178
if (spinner) {
82-
// spinner.fail('Failed to run command.')
83-
err(result.error)
79+
log.error(new Error('Failed to run command'))
8480
process.exit(ExitCode.FatalError)
8581
}
8682

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import { loadConfig } from 'c12'
2+
import { readPackageJson } from '@stacksjs/storage'
3+
import { frameworkPath } from '@stacksjs/path'
24
import type { ResolvedStacksOptions, StacksOptions } from '@stacksjs/types'
35
import { app, cache, cdn, cli, database, debug, dns, docs, email, events, git, hashing, library, notification, payment, searchEngine, services, storage, ui } from './defaults'
46

7+
export const packageManager = async () => {
8+
const { packageManager } = await readPackageJson(frameworkPath('package.json'))
9+
return packageManager
10+
}
11+
512
export const stacksConfigDefaults = {
613
app,
714
cache,

.stacks/core/storage/src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { fileURLToPath } from 'node:url'
22
import fs from 'fs-extra'
33
import { detectIndent, detectNewline } from '@stacksjs/utils'
4-
import type { JsonFile, TextFile } from '@stacksjs/types'
4+
import type { JsonFile, TextFile, PackageJson } from '@stacksjs/types'
55
import { componentsPath, dirname, functionsPath, join, projectPath } from '@stacksjs/path'
66
import { contains } from '@stacksjs/arrays'
77

@@ -21,6 +21,16 @@ export async function readJsonFile(name: string, cwd?: string): Promise<JsonFile
2121
return { ...file, data, indent, newline }
2222
}
2323

24+
/**
25+
* Reads a package.json file and returns the parsed data.
26+
*/
27+
export async function readPackageJson(name: string, cwd?: string) {
28+
const file = await readJsonFile(name, cwd)
29+
const data = file.data as PackageJson
30+
31+
return data
32+
}
33+
2434
/**
2535
* Writes the given data to the specified JSON file.
2636
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export const enum NpmScript {
201201
BuildFunctions = 'build:functions',
202202
BuildDocs = 'build:docs',
203203
BuildStacks = 'build:stacks',
204-
Clean = 'rimraf ./pnpm-lock.yaml ./node_modules/ ./.stacks/**/node_modules ./.stacks/**/dist',
204+
Clean = 'rimraf pnpm-lock.yaml node_modules/ .stacks/**/node_modules .stacks/**/dist',
205205
Dev = 'dev',
206206
DevComponents = 'vite --config ./core/build/src/vue-components.ts',
207207
DevDocs = 'npx vitepress dev ./docs/src',

.stacks/core/types/src/fs.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ export interface JsonFile {
1515
indent: string
1616
newline: string | undefined
1717
}
18+
19+
/**
20+
* Describes a package.json file.
21+
*/
22+
export interface PackageJson {
23+
packageManager: string
24+
// wip
25+
}

.stacks/core/utils/src/config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import type { AppOptions, CacheOptions, CdnOptions, CronJobOptions, DatabaseOptions, DebugOptions, DnsOptions, EmailOptions, Events, GitOptions, HashingOptions, LibraryOptions, Model, NotificationOptions, PagesOption, PaymentOptions, SearchEngineOptions, ServicesOptions, StorageOptions, UiOptions, UserCliOptions } from '@stacksjs/types'
22

3-
export function env(key: any, fallback?: any) {
4-
// eslint-disable-next-line no-console
5-
console.log('fallback', fallback)
6-
3+
export function env(key: any, _fallback?: any) {
74
// if (key && import.meta?.env)
85
// return import.meta.env[key]
96

.stacks/core/utils/src/delete.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { rimraf } from 'rimraf'
2+
3+
export { rimraf, rimraf as del }

.stacks/core/utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export { assert, toString, noop, loop, getTypeName } from './base'
22
export * from './config'
33
export * from './debounce'
4+
export * from './delete'
45
export * from './equal'
56
export * from './function'
67
export * from './guards'

pnpm-lock.yaml

Lines changed: 26 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)