Skip to content

Commit ab92b51

Browse files
committed
chore: wip
1 parent fbd50b9 commit ab92b51

File tree

8 files changed

+36
-14
lines changed

8 files changed

+36
-14
lines changed

.stacks/core/buddy/src/cli.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#!/usr/bin/env node
2-
import { execSync } from 'node:child_process'
32
import { runAction } from '@stacksjs/actions'
4-
import { command, log, runCommand } from '@stacksjs/cli'
5-
import { env, frameworkVersion, isProjectCreated } from '@stacksjs/utils'
3+
import { command, execSync, log, runCommand } from '@stacksjs/cli'
4+
import { env, frameworkVersion, isProjectCreated, parseYaml, semver } from '@stacksjs/utils'
65
import { projectPath } from '@stacksjs/path'
76
import { Action } from '@stacksjs/types'
8-
import { parse as parseYaml } from 'yaml'
9-
import semver from 'semver'
107
import { filesystem } from '@stacksjs/storage'
118
import { build, changelog, clean, commit, create, dev, example, fresh, generate, key, lint, make, migrate, preinstall, prepublish, release, seed, setup, test, update, version } from './commands'
129

@@ -77,7 +74,7 @@ async function installIfVersionMismatch(): void {
7774
const requiredPnpmVersion = dependencies['pnpm.io']
7875

7976
const installedNodeVersion = process.version
80-
const installedPnpmVersion = execSync('pnpm -v', { encoding: 'utf8' }).trim()
77+
const installedPnpmVersion = execSync('pnpm -v').trim()
8178

8279
if (!semver.satisfies(installedNodeVersion, requiredNodeVersion)) {
8380
log.error(`Installed Node.js version (${installedNodeVersion}) does not satisfy required version (${requiredNodeVersion}). Installing...`)

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { execSync as childExec } from 'node:child_process'
12
import type { Err } from '@stacksjs/error-handling'
23
import type { CliOptions, CommandResult, Result, SpinnerOptions as Spinner } from '@stacksjs/types'
34
import { ResultAsync, err } from '@stacksjs/error-handling'
@@ -26,6 +27,16 @@ export function exec(command: string, options?: CliOptions) {
2627
)
2728
}
2829

30+
/**
31+
* Execute a command and return result.
32+
*
33+
* @param command The command to execute.
34+
* @returns The result of the command.
35+
*/
36+
export function execSync(command: string) {
37+
return childExec(command, { encoding: 'utf-8' })
38+
}
39+
2940
/**
3041
* Run a command the Stacks way.
3142
*

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ export interface CliOptions {
9595
* @default false
9696
*/
9797
shell?: boolean
98+
99+
/**
100+
* **Encoding**
101+
*
102+
* Encoding type
103+
*
104+
* @default 'utf-8'
105+
*/
106+
encoding?: string
98107
}
99108

100109
export type { Ora as SpinnerOptions } from 'ora'

.stacks/core/utils/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
"kolorist": "1.7.0",
6464
"p-limit": "^4.0.0",
6565
"rimraf": "^4.4.1",
66-
"throttle-debounce": "^5.0.0"
66+
"throttle-debounce": "^5.0.0",
67+
"yaml": "^2.2.1"
6768
},
6869
"devDependencies": {
6970
"@stacksjs/testing": "workspace:*",

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import detectIndent from 'detect-indent'
33
import storage from '@stacksjs/storage'
44
import { frameworkPath, projectPath } from '@stacksjs/path'
55
import { log, runCommand, spawn } from '@stacksjs/cli'
6+
import semver from 'semver'
7+
import { parse } from 'yaml'
68
import ui from '../../../../config/ui'
79

810
export async function isProjectCreated() {
@@ -131,6 +133,11 @@ export function hasScript(manifest: Manifest, script: NpmScript): boolean {
131133
return false
132134
}
133135

136+
export function parseYaml(content: any) {
137+
return parse(content)
138+
}
139+
140+
export { semver }
134141
export * from '@dinero.js/currencies'
135142
export * from 'dinero.js'
136143
export { detectIndent }

.stacks/scripts/ensure.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/bin/sh
2-
32
REQUIRED_NODE_VERSION=$(awk '/nodejs.org/{print substr($2, 2)}' ../../tea.yaml | tr -d "'")
43

54
# Remove the '>=v' prefix from the version string
65
REQUIRED_NODE_VERSION=${REQUIRED_NODE_VERSION#>=v}
76

8-
97
REQUIRED_NODE_MAJOR=$(echo "$REQUIRED_NODE_VERSION" | cut -d. -f1)
108
REQUIRED_NODE_MINOR=$(echo "$REQUIRED_NODE_VERSION" | cut -d. -f2)
119
REQUIRED_NODE_PATCH=$(echo "$REQUIRED_NODE_VERSION" | cut -d. -f3)

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@
9999
"test:types": "pnpm buddy test:types"
100100
},
101101
"dependencies": {
102-
"stacks": "workspace:*",
103-
"yaml": "^2.2.1"
102+
"stacks": "workspace:*"
104103
},
105104
"lint-staged": {
106105
"*.{js,jsx,ts,tsx,vue}": "eslint --fix"

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)