@xrystal/core 3.53.3 → 3.55.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,84 +5,97 @@ import { CLI_BIN_NAMES, CLI_PRIMARY_NAME, PACKAGE_NAME } from './cli-identity.mj
5
5
  export const LIST_BULLET = chalk.cyan('◆')
6
6
  import { brandTitle } from './banner.mjs'
7
7
  import { packageDefaults } from './package-defaults.mjs'
8
+ import { formatScopeGuide, t } from './cli-i18n.mjs'
8
9
 
9
- const QUICK_COMMANDS = [
10
- { cmd: 'project', desc: 'Where am I? workspace root · linked service · standalone' },
11
- { cmd: 'sync', desc: 'This project: tsconfig + @xrystal/core pin' },
12
- { cmd: 'sync --all', desc: 'Inside workspace: every linked api/web/mobile project' },
13
- { cmd: 'tmp', desc: 'Ensure tmp.yml for current scope (inner x/ or outer ./)' },
14
- { cmd: 'create <name> --workspace', desc: 'Outer tmp + api/general + web/mobile slots' },
15
- { cmd: 'workspaces', desc: 'Global registry ~/.xrystal (not repo tmp.yml)' },
16
- { cmd: 'watch status', desc: 'Background tmp watcher for registered workspaces (~/.xrystal)' },
17
- { cmd: 'dev / build / doctor', desc: 'Develop & diagnostics' },
18
- ]
19
-
20
- const COMMAND_GROUPS = [
21
- {
22
- title: 'Develop',
23
- items: [
24
- { cmd: 'dev', desc: 'Watch TypeScript entry + dev env files' },
25
- { cmd: 'build', desc: 'Bun bundle + optional tsc → dist/' },
26
- { cmd: 'start', aliases: 'start:dist', desc: 'Run paths.dist/index.js (prod)' },
27
- { cmd: 'test', desc: 'Run project tests (paths.tests)' },
28
- ],
29
- },
30
- {
31
- title: 'Context',
32
- items: [
33
- { cmd: 'project', desc: 'Current folder: workspace root, linked service, standalone, or core library' },
34
- { cmd: 'workspaces [list|sync]', desc: 'Global registry ~/.xrystal (external to repo tmp files)' },
35
- ],
36
- },
37
- {
38
- title: 'Workspace',
39
- items: [
40
- { cmd: 'create <name> --workspace', desc: 'Outer ./tmp.yml + api/general + web/mobile (admin under web/)' },
41
- { cmd: 'sync --all', desc: 'From root or any link: all api/web/mobile + ~/.xrystal registry' },
42
- { cmd: 'workspaces [list|sync]', desc: 'Inspect/rescan global registry (separate from xry sync)' },
43
- { cmd: 'telepresence dev <deploy>', aliases: 'tp dev', desc: 'Intercept cluster pod → local dev' },
44
- { cmd: 'telepresence connect', aliases: 'tp connect', desc: 'Connect Telepresence to dev/test namespace' },
45
- ],
46
- },
47
- {
48
- title: 'Project',
49
- items: [
50
- { cmd: 'create', hint: '<name> [path]', desc: 'Standalone service (gpt template + inner x/tmp.yml)' },
51
- { cmd: 'sync', desc: 'Current project only: tsconfig + @xrystal/core pin + tmp schema' },
52
- { cmd: 'sync --self', desc: 'Inside workspace: explicit current linked project only' },
53
- { cmd: 'tmp', desc: 'Ensure tmp.yml for current folder scope · end.version = schema' },
54
- { cmd: 'hooks install', desc: 'Install .git/hooks pre-commit version check' },
55
- { cmd: 'hooks status', desc: 'Show whether pre-commit hook is installed' },
56
- ],
57
- },
58
- {
59
- title: 'Diagnostics',
60
- items: [
61
- { cmd: 'doctor', desc: `Runtime · git · ${packageDefaults.packageName} version alignment` },
62
- { cmd: 'version', desc: 'CLI tool vs project package.json versions' },
63
- ],
64
- },
65
- {
66
- title: 'Release',
67
- items: [
68
- { cmd: 'tag', desc: 'Tag HEAD from package.json (+ core npm publish)' },
69
- ],
70
- },
71
- ]
10
+ export { formatScopeGuide } from './cli-i18n.mjs'
11
+
12
+ function quickCommands() {
13
+ return [
14
+ { cmd: 'project', desc: t('quick.project') },
15
+ { cmd: 'guide', desc: t('quick.guide') },
16
+ { cmd: 'sync', desc: t('quick.sync') },
17
+ { cmd: 'sync --all', desc: t('quick.syncAll') },
18
+ { cmd: 'tmp', desc: t('quick.tmp') },
19
+ { cmd: 'create <name> --workspace', desc: t('quick.createWs') },
20
+ { cmd: 'workspaces', desc: t('quick.workspaces') },
21
+ { cmd: 'watch status', desc: t('quick.watch') },
22
+ { cmd: 'tp connect / tp dev <deploy>', desc: t('quick.tp') },
23
+ { cmd: 'dev / build / doctor', desc: t('quick.dev') },
24
+ ]
25
+ }
26
+
27
+ function commandGroups() {
28
+ return [
29
+ {
30
+ title: t('sections.context'),
31
+ items: [
32
+ { cmd: 'project', desc: 'Current folder: workspace root, linked service, standalone, or core library' },
33
+ { cmd: 'guide', desc: t('quick.guide') },
34
+ { cmd: 'config lang [en|tr]', desc: 'Save CLI language in ~/.xrystal/config.json' },
35
+ { cmd: 'workspaces [list|sync]', desc: t('quick.workspaces') },
36
+ ],
37
+ },
38
+ {
39
+ title: t('sections.develop'),
40
+ items: [
41
+ { cmd: 'dev', desc: 'Watch TypeScript entry + dev env files' },
42
+ { cmd: 'build', desc: 'Bun bundle + optional tsc → dist/' },
43
+ { cmd: 'start', aliases: 'start:dist', desc: 'Run paths.dist/index.js (prod)' },
44
+ { cmd: 'test', desc: 'Run project tests (paths.tests)' },
45
+ ],
46
+ },
47
+ {
48
+ title: t('sections.workspace'),
49
+ items: [
50
+ { cmd: 'create <name> --workspace', desc: 'Outer ./tmp.yml + api/general + web/mobile (admin under web/)' },
51
+ { cmd: 'sync --all', desc: t('quick.syncAll') },
52
+ { cmd: 'workspaces [list|sync]', desc: t('quick.workspaces') },
53
+ { cmd: 'watch install', desc: 'OS service — survives reboot (launchd / systemd user)' },
54
+ { cmd: 'telepresence dev <deploy>', aliases: 'tp dev', desc: 'Intercept cluster pod → local dev' },
55
+ { cmd: 'telepresence connect', aliases: 'tp connect', desc: 'Connect Telepresence to dev/test namespace' },
56
+ { cmd: 'telepresence install', aliases: 'tp install', desc: 'Install Telepresence OSS client (~2.31.x)' },
57
+ ],
58
+ },
59
+ {
60
+ title: t('sections.project'),
61
+ items: [
62
+ { cmd: 'create', hint: '<name> [path]', desc: 'Standalone service (gpt template + inner x/tmp.yml)' },
63
+ { cmd: 'sync', desc: 'tsconfig + core pin + ensure inner x/tmp.yml + schema heal' },
64
+ { cmd: 'sync --self', desc: 'Inside workspace: explicit current linked project only' },
65
+ { cmd: 'tmp', desc: t('quick.tmp') },
66
+ { cmd: 'hooks install', desc: 'Install .git/hooks pre-commit version check' },
67
+ { cmd: 'hooks status', desc: 'Show whether pre-commit hook is installed' },
68
+ ],
69
+ },
70
+ {
71
+ title: t('sections.diagnostics'),
72
+ items: [
73
+ { cmd: 'doctor', desc: `Runtime · git · ${packageDefaults.packageName} version alignment` },
74
+ { cmd: 'version', desc: 'CLI tool vs project package.json versions' },
75
+ ],
76
+ },
77
+ {
78
+ title: t('sections.release'),
79
+ items: [
80
+ { cmd: 'tag', desc: 'Tag HEAD from package.json (+ core npm publish)' },
81
+ ],
82
+ },
83
+ ]
84
+ }
72
85
 
73
86
  const SECTION_COLORS = {
74
87
  Context: chalk.bold.white,
88
+ Bağlam: chalk.bold.white,
75
89
  Develop: chalk.bold.cyan,
90
+ Geliştir: chalk.bold.cyan,
76
91
  Workspace: chalk.bold.blue,
92
+ Proje: chalk.bold.green,
77
93
  Project: chalk.bold.green,
78
94
  Diagnostics: chalk.bold.yellow,
95
+ Teşhis: chalk.bold.yellow,
79
96
  Release: chalk.bold.magenta,
80
97
  }
81
98
 
82
- function termWidth() {
83
- return Math.min(100, Math.max(56, process.stdout.columns || 80))
84
- }
85
-
86
99
  function commandLabel(item) {
87
100
  const alias = item.aliases ? chalk.dim(` · ${item.aliases}`) : ''
88
101
  const hint = item.hint ? chalk.dim(` ${item.hint}`) : ''
@@ -98,19 +111,15 @@ function formatTreeLines(items) {
98
111
  }
99
112
 
100
113
  export function formatSyncHelp({ cliName = CLI_PRIMARY_NAME } = {}) {
101
- const rows = [
102
- { ctx: 'Standalone service', cmd: `${cliName} sync`, effect: 'tsconfig + pin @xrystal/core + tmp schema' },
103
- { ctx: 'Workspace root', cmd: `${cliName} sync`, effect: 'all linked projects + registry (same as --all)' },
104
- { ctx: 'Inside api/web/mobile', cmd: `${cliName} sync`, effect: 'current project only (default)' },
105
- { ctx: 'Inside api/web/mobile', cmd: `${cliName} sync --all`, effect: 'every linked project + registry' },
106
- { ctx: 'Global registry only', cmd: `${cliName} workspaces sync`, effect: 'rescan ~/.xrystal from cwd' },
107
- ]
108
- const lines = rows.map((row) => ` ${chalk.gray(row.ctx.padEnd(22))} ${chalk.cyan(row.cmd)}\n${' '.repeat(26)}${chalk.gray(row.effect)}`)
114
+ const rows = t('syncRows')
115
+ const lines = rows.map((row) =>
116
+ ` ${chalk.gray(String(row.ctx).padEnd(22))} ${chalk.cyan(`${cliName} ${row.cmd}`)}\n${' '.repeat(26)}${chalk.gray(row.effect)}`,
117
+ )
109
118
  return [
110
- chalk.bold.white('\n Sync scope'),
119
+ chalk.bold.white(`\n ${t('syncScopeTitle')}`),
111
120
  ...lines,
112
121
  '',
113
- chalk.gray(' xry project — shows which row applies to your cwd'),
122
+ chalk.gray(` ${cliName} project — ${t('syncScopeHint')}`),
114
123
  '',
115
124
  ].join('\n')
116
125
  }
@@ -118,11 +127,13 @@ export function formatSyncHelp({ cliName = CLI_PRIMARY_NAME } = {}) {
118
127
  /** Bare CLI — banner altında kısa, işe yarayan komutlar. */
119
128
  export function printQuickStartGuide({ cliName = CLI_PRIMARY_NAME } = {}) {
120
129
  console.log(chalk.bold.yellow('\n Quick start'))
121
- console.log(formatTreeLines(QUICK_COMMANDS))
122
- console.log('')
123
- console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} -h`)} ${chalk.gray('· all commands & options')}`)
124
- console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} doctor`)} ${chalk.gray('· verify install & versions')}`)
125
- console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} tp dev general`)} ${chalk.gray('· telepresence local intercept')}`)
130
+ console.log(formatTreeLines(quickCommands()))
131
+ console.log(formatScopeGuide({ cliName }))
132
+ console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} guide`)} ${chalk.gray(`· ${t('tips.guide')}`)}`)
133
+ console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} -h`)} ${chalk.gray(`· ${t('tips.help')}`)}`)
134
+ console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} doctor`)} ${chalk.gray(`· ${t('tips.doctor')}`)}`)
135
+ console.log(` ${chalk.dim('tip')} ${chalk.bold.white(`${cliName} tp dev general`)} ${chalk.gray(`· ${t('tips.tp')}`)}`)
136
+ console.log(` ${chalk.dim('tip')} ${chalk.gray(t('langTip'))}`)
126
137
  console.log('')
127
138
  }
128
139
 
@@ -130,6 +141,7 @@ function formatOptionsSection(cliName) {
130
141
  const items = [
131
142
  { cmd: '-V, --version', desc: `Show ${packageDefaults.packageName} CLI version` },
132
143
  { cmd: '-h, --help', desc: 'Show full command list' },
144
+ { cmd: '--lang <code>', desc: 'CLI language this run: en | tr (persist: xry config lang)' },
133
145
  ]
134
146
  const lines = [
135
147
  chalk.bold.white('\n Options'),
@@ -147,7 +159,7 @@ function formatOptionsSection(cliName) {
147
159
 
148
160
  /** Root `-h` — gruplu, renkli, kompakt tam liste. */
149
161
  export function formatRootHelp({ cliName = CLI_PRIMARY_NAME } = {}) {
150
- const sections = COMMAND_GROUPS.map((group) => {
162
+ const sections = commandGroups().map((group) => {
151
163
  const paint = SECTION_COLORS[group.title] ?? chalk.bold.white
152
164
  return `${paint(`\n ${group.title}`)}\n${formatTreeLines(group.items)}`
153
165
  })
@@ -157,6 +169,8 @@ export function formatRootHelp({ cliName = CLI_PRIMARY_NAME } = {}) {
157
169
  chalk.gray(` ${PACKAGE_NAME} [options] [command]`),
158
170
  chalk.dim(` invoke: ${cliName}`),
159
171
  ...sections,
172
+ formatScopeGuide({ cliName }),
173
+ formatSyncHelp({ cliName }),
160
174
  formatOptionsSection(cliName),
161
175
  ].join('\n')
162
176
  }
@@ -208,3 +222,8 @@ export function isRootHelpRequest(argv = process.argv) {
208
222
  if (args.length === 1 && ['-h', '--help', 'help'].includes(args[0])) return true
209
223
  return false
210
224
  }
225
+
226
+ export function isGuideRequest(argv = process.argv) {
227
+ const args = argv.slice(2)
228
+ return args.length === 1 && args[0] === 'guide'
229
+ }
@@ -0,0 +1,224 @@
1
+ /** CLI UI strings — en | tr via ~/.xrystal/config.json, --lang, or XRY_LANG */
2
+
3
+ import { getCliConfigLang } from './xrystal-config.mjs'
4
+ import { CliLangEnum, normalizeCliLang } from './cli-lang.mjs'
5
+
6
+ export { CliLangEnum, normalizeCliLang } from './cli-lang.mjs'
7
+
8
+ const MESSAGES = {
9
+ [CliLangEnum.EN]: {
10
+ langTip: 'Language: xry config lang tr (saved in ~/.xrystal/config.json)',
11
+ scopeGuideTitle: 'Where am I? — commands by scope',
12
+ scopeGuideDetect: 'detect scope first',
13
+ standaloneTitle: 'Standalone service (single repo)',
14
+ standaloneSync: 'x/tmp.yml + tsconfig + @xrystal/core pin + schema',
15
+ standaloneFlow: 'typical: sync → dev · build · test',
16
+ workspaceRootTitle: 'Workspace root (outer ./tmp.yml only)',
17
+ workspaceRootSync: 'all linked api/web/mobile + layout heal + ~/.xrystal registry',
18
+ workspaceRootCreate: 'create <name> · --web · --mobile · create --workspace',
19
+ workspaceRootNoDev: 'dev/build/start refused here — run inside a linked service',
20
+ innerTitle: 'Inner service (api/web/mobile/*)',
21
+ innerSync: 'this project only (default)',
22
+ innerSyncAll: 'every linked project + registry',
23
+ innerDev: 'dev · build · start · test',
24
+ matrixTitle: 'Quick matrix',
25
+ colCommand: 'Command',
26
+ colStandalone: 'Standalone',
27
+ colWsRoot: 'Ws root',
28
+ colInner: 'Inner',
29
+ yes: 'yes',
30
+ no: 'no',
31
+ allLinks: 'all links',
32
+ selfOnly: 'self only',
33
+ ignored: 'ignored',
34
+ sections: {
35
+ develop: 'Develop',
36
+ context: 'Context',
37
+ workspace: 'Workspace',
38
+ project: 'Project',
39
+ diagnostics: 'Diagnostics',
40
+ release: 'Release',
41
+ scope: 'Scope guide',
42
+ },
43
+ quick: {
44
+ project: 'Where am I? workspace root · linked service · standalone',
45
+ sync: 'This project: tsconfig + @xrystal/core pin',
46
+ syncAll: 'Inside workspace: every linked api/web/mobile project',
47
+ tmp: 'Create missing tmp.yml · loader profile for this scope',
48
+ createWs: 'Outer tmp + api/general + web/mobile slots',
49
+ workspaces: 'Global registry ~/.xrystal (not repo tmp.yml)',
50
+ watch: 'Background tmp watcher for registered workspaces',
51
+ tp: 'Telepresence: tp connect · tp dev <deploy> · tp install',
52
+ dev: 'Develop & diagnostics',
53
+ guide: 'Scope guide — standalone vs workspace commands',
54
+ },
55
+ tips: {
56
+ help: 'all commands & options',
57
+ doctor: 'verify install & versions',
58
+ guide: 'standalone vs workspace command matrix',
59
+ tp: 'telepresence local intercept',
60
+ },
61
+ syncScopeTitle: 'Sync scope',
62
+ syncRows: [
63
+ { ctx: 'Standalone service', cmd: 'sync', effect: 'ensure x/tmp.yml + tsconfig + pin @xrystal/core + schema' },
64
+ { ctx: 'Workspace root', cmd: 'sync', effect: 'all linked projects + registry (same as --all)' },
65
+ { ctx: 'Inside api/web/mobile', cmd: 'sync', effect: 'current project only (default)' },
66
+ { ctx: 'Inside api/web/mobile', cmd: 'sync --all', effect: 'every linked project + registry' },
67
+ { ctx: 'Global registry only', cmd: 'workspaces sync', effect: 'rescan ~/.xrystal from cwd' },
68
+ ],
69
+ syncScopeHint: 'shows which row applies to your cwd',
70
+ },
71
+ [CliLangEnum.TR]: {
72
+ langTip: 'Dil: xry config lang tr (~/.xrystal/config.json)',
73
+ scopeGuideTitle: 'Neredeyim? — kapsama göre komutlar',
74
+ scopeGuideDetect: 'önce kapsamı tespit et',
75
+ standaloneTitle: 'Standalone servis (tek repo)',
76
+ standaloneSync: 'x/tmp.yml + tsconfig + @xrystal/core pin + schema',
77
+ standaloneFlow: 'tipik: sync → dev · build · test',
78
+ workspaceRootTitle: 'Workspace root (dış ./tmp.yml)',
79
+ workspaceRootSync: 'tüm api/web/mobile linkleri + layout heal + ~/.xrystal registry',
80
+ workspaceRootCreate: 'create <name> · --web · --mobile · create --workspace',
81
+ workspaceRootNoDev: 'dev/build/start burada yok — linked servis içinde çalıştır',
82
+ innerTitle: 'Inner servis (api/web/mobile/*)',
83
+ innerSync: 'sadece bu proje (varsayılan)',
84
+ innerSyncAll: 'tüm linkler + registry',
85
+ innerDev: 'dev · build · start · test',
86
+ matrixTitle: 'Hızlı tablo',
87
+ colCommand: 'Komut',
88
+ colStandalone: 'Standalone',
89
+ colWsRoot: 'Ws root',
90
+ colInner: 'Inner',
91
+ yes: 'evet',
92
+ no: 'hayır',
93
+ allLinks: 'tüm linkler',
94
+ selfOnly: 'sadece kendisi',
95
+ ignored: 'yok sayılır',
96
+ sections: {
97
+ develop: 'Geliştir',
98
+ context: 'Bağlam',
99
+ workspace: 'Workspace',
100
+ project: 'Proje',
101
+ diagnostics: 'Teşhis',
102
+ release: 'Release',
103
+ scope: 'Kapsam rehberi',
104
+ },
105
+ quick: {
106
+ project: 'Neredeyim? workspace root · linked service · standalone',
107
+ sync: 'Bu proje: tsconfig + @xrystal/core pin',
108
+ syncAll: 'Workspace içinde: tüm api/web/mobile projeleri',
109
+ tmp: 'Eksik tmp.yml oluştur · loader profili',
110
+ createWs: 'Dış tmp + api/general + web/mobile slotları',
111
+ workspaces: 'Global registry ~/.xrystal (repo tmp değil)',
112
+ watch: 'Kayıtlı workspace tmp izleyici (~/.xrystal)',
113
+ tp: 'Telepresence: tp connect · tp dev <deploy> · tp install',
114
+ dev: 'Geliştir & teşhis',
115
+ guide: 'Kapsam rehberi — standalone vs workspace',
116
+ },
117
+ tips: {
118
+ help: 'tüm komutlar & seçenekler',
119
+ doctor: 'kurulum & sürüm kontrolü',
120
+ guide: 'standalone vs workspace komut matrisi',
121
+ tp: 'telepresence local intercept',
122
+ },
123
+ syncScopeTitle: 'Sync kapsamı',
124
+ syncRows: [
125
+ { ctx: 'Standalone servis', cmd: 'sync', effect: 'x/tmp.yml + tsconfig + @xrystal/core pin + schema' },
126
+ { ctx: 'Workspace root', cmd: 'sync', effect: 'tüm linkler + registry (--all ile aynı)' },
127
+ { ctx: 'api/web/mobile içinde', cmd: 'sync', effect: 'sadece bu proje (varsayılan)' },
128
+ { ctx: 'api/web/mobile içinde', cmd: 'sync --all', effect: 'tüm linkler + registry' },
129
+ { ctx: 'Sadece global registry', cmd: 'workspaces sync', effect: '~/.xrystal yeniden tara' },
130
+ ],
131
+ syncScopeHint: 'hangi satırın cwd\'ne uyduğunu gösterir',
132
+ },
133
+ }
134
+
135
+ let activeLang = CliLangEnum.EN
136
+
137
+ export function resolveCliLangFromEnv(env = process.env) {
138
+ const explicit = env.XRY_LANG ?? env.XRYSTAL_LANG
139
+ if (explicit) return normalizeCliLang(explicit)
140
+ return null
141
+ }
142
+
143
+ export function resolveCliLangFromArgv(argv = process.argv) {
144
+ const idx = argv.indexOf('--lang')
145
+ if (idx >= 0 && argv[idx + 1]) return normalizeCliLang(argv[idx + 1])
146
+ return null
147
+ }
148
+
149
+ /** Priority: --lang → XRY_LANG → ~/.xrystal/config.json → en */
150
+ export function initCliLang(argv = process.argv, env = process.env) {
151
+ activeLang = resolveCliLangFromArgv(argv)
152
+ ?? resolveCliLangFromEnv(env)
153
+ ?? getCliConfigLang()
154
+ ?? CliLangEnum.EN
155
+ return activeLang
156
+ }
157
+
158
+ export function getCliLang() {
159
+ return activeLang
160
+ }
161
+
162
+ export function setCliLang(lang) {
163
+ activeLang = normalizeCliLang(lang)
164
+ return activeLang
165
+ }
166
+
167
+ export function t(key) {
168
+ const parts = key.split('.')
169
+ let node = MESSAGES[activeLang]
170
+ for (const part of parts) {
171
+ node = node?.[part]
172
+ }
173
+ if (node != null) return node
174
+ node = MESSAGES[CliLangEnum.EN]
175
+ for (const part of parts) {
176
+ node = node?.[part]
177
+ }
178
+ return node ?? key
179
+ }
180
+
181
+ export function formatScopeGuide({ cliName = 'xry' } = {}) {
182
+ const rows = [
183
+ ['project', t('yes'), t('yes'), t('yes')],
184
+ ['sync', t('yes'), t('allLinks'), t('selfOnly')],
185
+ ['sync --all', t('ignored'), t('allLinks'), t('allLinks')],
186
+ ['tmp', t('yes'), t('yes'), t('yes')],
187
+ ['dev / build / test', t('yes'), t('no'), t('yes')],
188
+ ['create <name>', t('yes'), t('yes'), t('yes')],
189
+ ['workspaces', '—', t('yes'), t('yes')],
190
+ ['watch install', '—', t('yes'), '—'],
191
+ ['tp connect / dev', t('yes'), t('yes'), t('yes')],
192
+ ]
193
+
194
+ const matrix = rows.map(([cmd, st, root, inner]) =>
195
+ ` ${cmd.padEnd(18)} ${st.padEnd(14)} ${root.padEnd(14)} ${inner}`,
196
+ ).join('\n')
197
+
198
+ return [
199
+ '',
200
+ ` ${t('scopeGuideTitle')}`,
201
+ ` ${cliName} project · ${t('scopeGuideDetect')}`,
202
+ '',
203
+ ` ${t('standaloneTitle')}`,
204
+ ` ${cliName} sync → ${t('standaloneSync')}`,
205
+ ` ${t('standaloneFlow')}`,
206
+ '',
207
+ ` ${t('workspaceRootTitle')}`,
208
+ ` ${cliName} sync → ${t('workspaceRootSync')}`,
209
+ ` ${cliName} create … → ${t('workspaceRootCreate')}`,
210
+ ` ${t('workspaceRootNoDev')}`,
211
+ '',
212
+ ` ${t('innerTitle')}`,
213
+ ` ${cliName} sync → ${t('innerSync')}`,
214
+ ` ${cliName} sync --all → ${t('innerSyncAll')}`,
215
+ ` ${cliName} ${t('innerDev')}`,
216
+ '',
217
+ ` ${t('matrixTitle')}`,
218
+ ` ${t('colCommand').padEnd(18)} ${t('colStandalone').padEnd(14)} ${t('colWsRoot').padEnd(14)} ${t('colInner')}`,
219
+ matrix,
220
+ '',
221
+ ` ${t('langTip')}`,
222
+ '',
223
+ ].join('\n')
224
+ }
@@ -0,0 +1,12 @@
1
+ /** CLI language codes — shared by i18n + ~/.xrystal/config.json */
2
+
3
+ export const CliLangEnum = {
4
+ EN: 'en',
5
+ TR: 'tr',
6
+ }
7
+
8
+ export function normalizeCliLang(raw) {
9
+ const key = String(raw ?? '').trim().toLowerCase().split(/[-_]/)[0]
10
+ if (key === CliLangEnum.TR || key === 'turkish') return CliLangEnum.TR
11
+ return CliLangEnum.EN
12
+ }
@@ -0,0 +1,22 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
6
+
7
+ /** Resolve a script under -infrastructure-/scripts/helpers (env override or sibling discovery). */
8
+ export function resolveInfraHelperScript(name) {
9
+ const envRoot = process.env.XRYSTAL_INFRA_DIR ?? process.env.XRYSTAL_INFRA_ROOT
10
+ const candidates = [
11
+ envRoot,
12
+ path.resolve(process.cwd(), '../-infrastructure-'),
13
+ path.resolve(process.cwd(), '../../-infrastructure-'),
14
+ path.resolve(__dirname, '../../../..', '-infrastructure-'),
15
+ ].filter(Boolean)
16
+
17
+ for (const root of candidates) {
18
+ const script = path.join(root, 'scripts', 'helpers', name)
19
+ if (fs.existsSync(script)) return script
20
+ }
21
+ return null
22
+ }
@@ -0,0 +1,90 @@
1
+ import { execSync } from 'node:child_process'
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import yaml from 'yaml'
5
+
6
+ import { packageDefaults } from './package-defaults.mjs'
7
+ import { getCliPackageRoot } from './project-root.mjs'
8
+ import { ensureTmpFile } from './tmp-layout.mjs'
9
+ import { ensureTmpSchemaVersion } from './tmp-schema-version.mjs'
10
+ import { resolveBundledServiceTmpTemplate } from './tmp-template.mjs'
11
+ import { GlobalTypeEnum } from './cli-enums.mjs'
12
+ import { setupProjectGitHooks } from '../scripts/install-git-hooks.mjs'
13
+
14
+ const FRONTEND_TEMPLATE_DIR = 'x/templates/frontend'
15
+
16
+ function copyRecursive(src, dest) {
17
+ const stat = fs.statSync(src)
18
+ if (stat.isDirectory()) {
19
+ fs.mkdirSync(dest, { recursive: true })
20
+ for (const name of fs.readdirSync(src)) {
21
+ if (name === 'tmp.yml') continue
22
+ copyRecursive(path.join(src, name), path.join(dest, name))
23
+ }
24
+ return
25
+ }
26
+ fs.mkdirSync(path.dirname(dest), { recursive: true })
27
+ fs.copyFileSync(src, dest)
28
+ }
29
+
30
+ function patchPackageName(pkgPath, projectName, coreVersion) {
31
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
32
+ pkg.name = projectName
33
+ pkg.dependencies = {
34
+ ...(pkg.dependencies ?? {}),
35
+ [packageDefaults.packageName]: coreVersion,
36
+ }
37
+ fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`)
38
+ }
39
+
40
+ function patchTmpProjectName(tmpFilePath, projectName) {
41
+ const doc = yaml.parse(fs.readFileSync(tmpFilePath, 'utf8'))
42
+ doc.project = { ...(doc.project ?? {}), name: projectName }
43
+ fs.writeFileSync(tmpFilePath, yaml.stringify(doc))
44
+ }
45
+
46
+ export function scaffoldFrontendProject(targetPath, {
47
+ projectName,
48
+ coreVersion,
49
+ installCommand,
50
+ cliName,
51
+ setupHooks = true,
52
+ } = {}) {
53
+ const resolved = path.resolve(targetPath)
54
+ const templateRoot = path.join(getCliPackageRoot(), FRONTEND_TEMPLATE_DIR)
55
+
56
+ if (!fs.existsSync(templateRoot)) {
57
+ throw new Error(`frontend template missing: ${templateRoot}`)
58
+ }
59
+
60
+ fs.mkdirSync(resolved, { recursive: true })
61
+ copyRecursive(templateRoot, resolved)
62
+
63
+ const pkgPath = path.join(resolved, 'package.json')
64
+ if (fs.existsSync(pkgPath)) {
65
+ patchPackageName(pkgPath, projectName, coreVersion)
66
+ }
67
+
68
+ const templatePath = resolveBundledServiceTmpTemplate({ globalType: GlobalTypeEnum.FRONTEND })
69
+ const tmpResult = ensureTmpFile(resolved, { templatePath, patchProjectName: false })
70
+ patchTmpProjectName(tmpResult.tmpFilePath, projectName)
71
+ ensureTmpSchemaVersion(tmpResult.tmpFilePath)
72
+
73
+ const sourceDir = path.join(resolved, 'source')
74
+ if (!fs.existsSync(sourceDir)) {
75
+ fs.mkdirSync(sourceDir, { recursive: true })
76
+ }
77
+
78
+ execSync(installCommand, { cwd: resolved, stdio: 'inherit' })
79
+
80
+ let hooks = null
81
+ if (setupHooks) {
82
+ try {
83
+ hooks = setupProjectGitHooks(resolved, { cliName })
84
+ } catch {
85
+ hooks = { skipped: true }
86
+ }
87
+ }
88
+
89
+ return { root: resolved, tmpFilePath: tmpResult.tmpFilePath, hooks }
90
+ }
@@ -2,13 +2,20 @@ import path from 'node:path'
2
2
 
3
3
  import chalk from 'chalk'
4
4
 
5
+ import { GlobalTypeEnum, WorkspaceSlotEnum } from './cli-enums.mjs'
5
6
  import { syncCliRuntime } from './project-artifacts.mjs'
7
+ import { ensureServiceTelepresenceEnv } from './telepresence-layout.mjs'
6
8
  import { syncCoreDependency } from './sync-core-dependency.mjs'
7
9
  import { syncProjectToolchain } from './toolchain-config.mjs'
8
10
  import { ensureTmpSchemaVersion } from './tmp-schema-version.mjs'
9
11
  import { packageDefaults } from './package-defaults.mjs'
10
12
 
11
- export function syncOneProject(entry, coreVersion, { dryRun = false, tmpPath = null } = {}) {
13
+ export function syncOneProject(entry, coreVersion, {
14
+ dryRun = false,
15
+ tmpPath = null,
16
+ tmpCreated = false,
17
+ tmpWouldCreate = false,
18
+ } = {}) {
12
19
  const label = entry.name ? `${entry.name} (${entry.type ?? 'project'})` : path.basename(entry.path)
13
20
  const lines = []
14
21
 
@@ -20,9 +27,12 @@ export function syncOneProject(entry, coreVersion, { dryRun = false, tmpPath = n
20
27
  lines.push({ level: 'gray', text: `would pin ${packageDefaults.packageName}@${coreVersion} (from ${core.current ?? core.declared})` })
21
28
  } else if (core.reason === 'up-to-date') {
22
29
  lines.push({ level: 'gray', text: `${packageDefaults.packageName}@${coreVersion} (ok)` })
23
- } else if (core.reason === 'no core dependency') {
30
+ } else if (core.reason === 'no core dependency') {
24
31
  lines.push({ level: 'yellow', text: `skip core pin (${core.reason})` })
25
32
  }
33
+ if (tmpWouldCreate && tmpPath) {
34
+ lines.push({ level: 'gray', text: `would create ${path.relative(entry.path, tmpPath) || tmpPath}` })
35
+ }
26
36
  return { label, path: entry.path, lines, failed: false }
27
37
  }
28
38
 
@@ -45,6 +55,19 @@ export function syncOneProject(entry, coreVersion, { dryRun = false, tmpPath = n
45
55
  lines.push({ level: 'yellow', text: `skip core pin (${core.reason})` })
46
56
  }
47
57
 
58
+ if (tmpCreated && tmpPath) {
59
+ lines.push({ level: 'green', text: `created ${path.relative(entry.path, tmpPath) || tmpPath}` })
60
+ }
61
+
62
+ const isApiService = entry.type === GlobalTypeEnum.API_SERVICE
63
+ || entry.slot === WorkspaceSlotEnum.API
64
+ if (isApiService) {
65
+ const tpEnv = ensureServiceTelepresenceEnv(entry.path)
66
+ if (tpEnv.created) {
67
+ lines.push({ level: 'green', text: `created ${tpEnv.envRel}` })
68
+ }
69
+ }
70
+
48
71
  if (tmpPath) {
49
72
  const schema = ensureTmpSchemaVersion(tmpPath)
50
73
  if (schema.patched) {