Skip to content

Commit 16814fd

Browse files
committed
Published using @Stream44 Studio
Signed-off-by: Christoph <christoph@christoph.diy>
1 parent 24b7371 commit 16814fd

5 files changed

Lines changed: 36 additions & 20 deletions

File tree

caps/Home.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ export async function capsule({
1414
return encapsulate({
1515
'#@stream44.studio/encapsulate/spine-contracts/CapsuleSpineContract.v0': {
1616
'#@stream44.studio/encapsulate/structs/Capsule': {},
17+
'#t44/structs/HomeRegistryConfig': {
18+
as: '$HomeRegistryConfig'
19+
},
1720
'#': {
1821
homeDir: {
1922
type: CapsulePropertyTypes.GetterFunction,
2023
value: async function (this: any): Promise<string> {
21-
return process.env.T44_HOME_DIR || homedir()
24+
if (process.env.T44_HOME_DIR) return process.env.T44_HOME_DIR
25+
const config = await this.$HomeRegistryConfig.config
26+
if (config?.homeDir) return config.homeDir
27+
return homedir()
2228
}
2329
},
2430
sshDir: {

caps/HomeRegistry.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ export async function capsule({
5151
type: CapsulePropertyTypes.Function,
5252
value: async function (this: any): Promise<string> {
5353
const { stat, mkdir } = await import('fs/promises')
54+
const { join } = await import('path')
5455
const chalk = (await import('chalk')).default
5556

5657
const config = await this.$HomeRegistryConfig.config
57-
const defaultDir = await this.Home.registryDir
58+
const defaultHomeDir = await this.Home.homeDir
5859

5960
let chosenDir: string
6061

@@ -73,15 +74,15 @@ export async function capsule({
7374
}
7475
chosenDir = config.rootDir
7576
} else {
76-
// rootDir not set — prompt user
77-
console.log(chalk.cyan(`\n🏠 Home Registry Setup\n`))
78-
console.log(chalk.gray(' The home registry is the place in your home directory that keeps'))
79-
console.log(chalk.gray(' details about your workspaces and projects.'))
77+
// rootDir not set — prompt user for home directory
78+
console.log(chalk.cyan(`\n🏠 Home Directory Setup\n`))
79+
console.log(chalk.gray(' The home directory is where your workspace keeps its registry,'))
80+
console.log(chalk.gray(' SSH keys, and other workspace-related files.'))
8081
console.log('')
8182

82-
chosenDir = await this.WorkspacePrompt.input({
83-
message: 'Enter the home registry directory:',
84-
defaultValue: defaultDir,
83+
const chosenHomeDir = await this.WorkspacePrompt.input({
84+
message: 'Enter the home directory:',
85+
defaultValue: defaultHomeDir,
8586
validate: (input: string) => {
8687
if (!input || input.trim().length === 0) {
8788
return 'Directory path cannot be empty'
@@ -90,18 +91,18 @@ export async function capsule({
9091
}
9192
})
9293

93-
// Check if directory exists
94-
let dirExists = false
94+
// Check if home directory exists
95+
let homeDirExists = false
9596
try {
96-
const s = await stat(chosenDir)
97-
dirExists = s.isDirectory()
97+
const s = await stat(chosenHomeDir)
98+
homeDirExists = s.isDirectory()
9899
} catch {
99100
// Does not exist
100101
}
101102

102-
if (dirExists) {
103+
if (homeDirExists) {
103104
const confirmed = await this.WorkspacePrompt.confirm({
104-
message: `Directory '${chosenDir}' already exists. Use this existing registry as the home registry for your workspace?`,
105+
message: `Directory '${chosenHomeDir}' already exists. Use it as the home directory for your workspace?`,
105106
defaultValue: true
106107
})
107108

@@ -110,11 +111,16 @@ export async function capsule({
110111
process.exit(0)
111112
}
112113
} else {
113-
// Create the directory
114-
await mkdir(chosenDir, { recursive: true })
115-
console.log(chalk.green(`\n ✓ Created home registry directory: ${chosenDir}\n`))
114+
// Create the home directory
115+
await mkdir(chosenHomeDir, { recursive: true })
116+
console.log(chalk.green(`\n ✓ Created home directory: ${chosenHomeDir}\n`))
116117
}
117118

119+
// Derive registry dir from home dir
120+
chosenDir = join(chosenHomeDir, '.o/workspace.foundation')
121+
await mkdir(chosenDir, { recursive: true })
122+
123+
await this.$HomeRegistryConfig.setConfigValue(['homeDir'], chosenHomeDir)
118124
await this.$HomeRegistryConfig.setConfigValue(['rootDir'], chosenDir)
119125
}
120126

caps/RootKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function capsule({
6565
console.log(chalk.gray(` Root: ${workspaceConfig?.rootDir || 'unknown'}`))
6666
console.log(chalk.gray(''))
6767
console.log(chalk.gray(' The root key is an Ed25519 SSH key used to identify this workspace.'))
68-
console.log(chalk.gray(' You can select an existing key from ~/.ssh or create a new one.'))
68+
console.log(chalk.gray(` You can select an existing key from ${sshDir} or create a new one.`))
6969
console.log(chalk.gray(''))
7070

7171
// Discover existing Ed25519 keys in ~/.ssh

caps/SigningKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function capsule({
6565
console.log(chalk.gray(` Root: ${workspaceConfig?.rootDir || 'unknown'}`))
6666
console.log(chalk.gray(''))
6767
console.log(chalk.gray(' The signing key is an Ed25519 SSH key used for code and artifact signing.'))
68-
console.log(chalk.gray(' You can select an existing key from ~/.ssh or create a new one.'))
68+
console.log(chalk.gray(` You can select an existing key from ${sshDir} or create a new one.`))
6969
console.log(chalk.gray(''))
7070

7171
// Discover existing Ed25519 keys in ~/.ssh

structs/HomeRegistryConfig.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export async function capsule({
1313
schema: {
1414
type: 'object',
1515
properties: {
16+
homeDir: {
17+
type: 'string',
18+
description: 'Absolute path to the home directory (parent of registry, .ssh, etc).'
19+
},
1620
rootDir: {
1721
type: 'string',
1822
description: 'Absolute path to the home registry root directory.'

0 commit comments

Comments
 (0)