@xrystal/core 3.52.6 → 3.52.7
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.
- package/package.json +1 -1
- package/x/bin/commands/create.mjs +1 -1
- package/x/bin/commands/sync.mjs +65 -99
- package/x/bin/commands/tmp.mjs +3 -0
- package/x/bin/helpers/cli-help.mjs +29 -8
- package/x/bin/helpers/project-context.mjs +9 -6
- package/x/bin/helpers/sync-project.mjs +76 -0
- package/x/bin/helpers/sync-scope.mjs +71 -0
- package/x/bin/helpers/tmp-config.mjs +25 -0
- package/x/dist/loader/kafka/index.js +7 -2
- package/x/dist/loader/logger/index.js +8 -6
- package/x/dist/loader/mongo/index.js +9 -0
- package/x/dist/loader/redis/index.js +9 -0
- package/x/dist/project/index.d.ts +1 -0
- package/x/dist/project/index.js +21 -14
- package/x/dist/utils/helpers/loader-options/index.d.ts +5 -0
- package/x/dist/utils/helpers/loader-options/index.js +16 -0
- package/x/dist/utils/helpers/tmp/index.d.ts +1 -0
- package/x/dist/utils/helpers/tmp/index.js +1 -0
- package/x/dist/utils/helpers/tmp/loader-boot-plan.d.ts +10 -0
- package/x/dist/utils/helpers/tmp/loader-boot-plan.js +36 -0
- package/x/templates/api-service/tmp.yml +6 -0
- package/x/templates/frontend/tmp.yml +61 -0
package/package.json
CHANGED
|
@@ -78,7 +78,7 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
|
|
|
78
78
|
syncRegistryFromPath(result.root)
|
|
79
79
|
console.log(chalk.gray(' registered in ~/.xrystal'))
|
|
80
80
|
} catch {}
|
|
81
|
-
console.log(chalk.cyan(` ${cliName} sync`))
|
|
81
|
+
console.log(chalk.cyan(` ${cliName} sync --all`))
|
|
82
82
|
console.log(chalk.cyan(` ${cliName} telepresence dev general`))
|
|
83
83
|
printCommandFooter({ version })
|
|
84
84
|
} catch (error) {
|
package/x/bin/commands/sync.mjs
CHANGED
|
@@ -3,137 +3,103 @@ import path from 'node:path'
|
|
|
3
3
|
|
|
4
4
|
import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
|
|
5
5
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
6
|
-
import {
|
|
7
|
-
import { auditTsconfigAlignment, syncProjectToolchain } from '../helpers/toolchain-config.mjs'
|
|
6
|
+
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
8
7
|
import { ensureTmpFile } from '../helpers/tmp-layout.mjs'
|
|
9
8
|
import { ensureTmpSchemaVersion } from '../helpers/tmp-schema-version.mjs'
|
|
10
|
-
import { findEntries, findWorkspaceRoot } from '../helpers/workspace-resolve.mjs'
|
|
11
|
-
import { syncCliRuntime } from '../helpers/project-artifacts.mjs'
|
|
12
|
-
import { syncCoreDependency } from '../helpers/sync-core-dependency.mjs'
|
|
13
|
-
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
14
9
|
import { syncRegistryFromPath } from '../helpers/xrystal-registry.mjs'
|
|
10
|
+
import { resolveSyncScope } from '../helpers/sync-scope.mjs'
|
|
11
|
+
import { printSyncProjectResult, syncOneProject } from '../helpers/sync-project.mjs'
|
|
12
|
+
import { formatSyncHelp } from '../helpers/cli-help.mjs'
|
|
15
13
|
|
|
16
|
-
/** Sync tsconfig
|
|
14
|
+
/** Sync tsconfig + @xrystal/core pin from tmp.yml layout. */
|
|
17
15
|
export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
18
16
|
const run = (options) => {
|
|
19
|
-
const cwd = process.cwd()
|
|
20
|
-
const workspaceRoot = findWorkspaceRoot(cwd)
|
|
21
17
|
const coreVersion = readCliPackageJson().version
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
console.
|
|
19
|
+
let scope
|
|
20
|
+
try {
|
|
21
|
+
scope = resolveSyncScope(process.cwd(), { ...options, cliName })
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
24
|
+
process.exit(1)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
printCommandHeader({ cliName, command: 'sync', version: coreVersion })
|
|
28
|
+
console.log(chalk.gray(` scope: ${scope.label} (${scope.mode})`))
|
|
29
|
+
if (scope.workspaceRoot) {
|
|
30
|
+
console.log(chalk.gray(` workspace: ${scope.workspaceRoot}`))
|
|
31
|
+
}
|
|
32
|
+
console.log(chalk.gray(` projects: ${scope.entries.length}`))
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
if (scope.mode === 'workspace-all' && scope.workspaceRoot) {
|
|
35
|
+
const wsTmp = path.join(scope.workspaceRoot, 'tmp.yml')
|
|
30
36
|
if (!options.dryRun) {
|
|
31
37
|
const wsSchema = ensureTmpSchemaVersion(wsTmp)
|
|
32
|
-
if (wsSchema.patched)
|
|
38
|
+
if (wsSchema.patched) {
|
|
39
|
+
console.log(chalk.green(` outer tmp end.version → ${wsSchema.schemaVersion} (schema)`))
|
|
40
|
+
}
|
|
33
41
|
}
|
|
42
|
+
}
|
|
34
43
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
if (scope.entries.length === 0) {
|
|
45
|
+
console.log(chalk.yellow('\n no projects to sync'))
|
|
46
|
+
if (scope.mode === 'workspace-all') {
|
|
47
|
+
console.log(chalk.gray(' link services under api/ admin/ web/ then re-run'))
|
|
39
48
|
}
|
|
49
|
+
printCommandFooter({ version: coreVersion })
|
|
50
|
+
return
|
|
51
|
+
}
|
|
40
52
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
console.log(chalk.gray(` ${packageDefaults.packageName}@${coreVersion} (ok)`))
|
|
53
|
-
}
|
|
54
|
-
continue
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
syncCliRuntime(entry.path, { force: false })
|
|
58
|
-
const result = syncProjectToolchain(entry.path, { write: true })
|
|
59
|
-
console.log(result.created
|
|
60
|
-
? chalk.green(` created ${result.tsconfigRel}`)
|
|
61
|
-
: chalk.green(` updated ${result.tsconfigRel}`))
|
|
62
|
-
const core = syncCoreDependency(entry.path, coreVersion, { dryRun: options.dryRun })
|
|
63
|
-
if (core.synced) {
|
|
64
|
-
const label = options.dryRun
|
|
65
|
-
? chalk.gray(` would pin ${packageDefaults.packageName}@${coreVersion}`)
|
|
66
|
-
: chalk.green(` pinned ${packageDefaults.packageName}@${coreVersion}`)
|
|
67
|
-
console.log(label)
|
|
68
|
-
} else if (core.reason === 'up-to-date') {
|
|
69
|
-
console.log(chalk.gray(` ${packageDefaults.packageName}@${coreVersion} (ok)`))
|
|
70
|
-
}
|
|
71
|
-
if (!options.dryRun) {
|
|
72
|
-
const schema = ensureTmpSchemaVersion(entry.tmp)
|
|
73
|
-
if (schema.patched) console.log(chalk.green(` inner tmp end.version → ${schema.schemaVersion} (schema)`))
|
|
74
|
-
}
|
|
75
|
-
} catch (error) {
|
|
76
|
-
failed += 1
|
|
77
|
-
console.log(chalk.red(` failed: ${error.message}`))
|
|
78
|
-
}
|
|
53
|
+
let failed = 0
|
|
54
|
+
for (const entry of scope.entries) {
|
|
55
|
+
if (options.dryRun) {
|
|
56
|
+
const preview = syncOneProject(entry, coreVersion, { dryRun: true, tmpPath: entry.tmp ?? null })
|
|
57
|
+
printSyncProjectResult(preview)
|
|
58
|
+
continue
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let tmpPath = entry.tmp ?? null
|
|
62
|
+
if (!tmpPath && scope.mode === 'standalone') {
|
|
63
|
+
tmpPath = ensureTmpFile(entry.path).tmpFilePath
|
|
79
64
|
}
|
|
65
|
+
|
|
66
|
+
const result = syncOneProject(entry, coreVersion, { dryRun: false, tmpPath })
|
|
67
|
+
printSyncProjectResult(result)
|
|
68
|
+
if (result.failed) failed += 1
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (scope.mode === 'workspace-all' && scope.workspaceRoot && !options.dryRun) {
|
|
80
72
|
try {
|
|
81
|
-
syncRegistryFromPath(workspaceRoot)
|
|
82
|
-
console.log(chalk.gray(' registry updated (~/.xrystal)'))
|
|
73
|
+
syncRegistryFromPath(scope.workspaceRoot)
|
|
74
|
+
console.log(chalk.gray('\n registry updated (~/.xrystal)'))
|
|
83
75
|
} catch (error) {
|
|
84
|
-
console.log(chalk.yellow(
|
|
85
|
-
}
|
|
86
|
-
if (failed) {
|
|
87
|
-
console.log(chalk.red(`\n sync finished with ${failed} error(s)`))
|
|
88
|
-
printCommandFooter({ version: coreVersion })
|
|
89
|
-
process.exit(1)
|
|
76
|
+
console.log(chalk.yellow(`\n registry skipped: ${error.message}`))
|
|
90
77
|
}
|
|
91
|
-
console.log(chalk.green('\n workspace sync done'))
|
|
92
|
-
printCommandFooter({ version: coreVersion })
|
|
93
|
-
return
|
|
94
78
|
}
|
|
95
79
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
printCommandHeader({ cliName, command: 'sync', version: coreVersion })
|
|
100
|
-
console.log(chalk.gray(` root: ${root}`))
|
|
101
|
-
|
|
102
|
-
const lo = auditBefore.layoutOptions ?? {}
|
|
103
|
-
console.log(chalk.gray(' from tmp.yml:'))
|
|
104
|
-
console.log(chalk.gray(` paths.root: ${lo.rootFolderPath ?? '—'}`))
|
|
105
|
-
console.log(chalk.gray(` paths.source: ${lo.mainFolderPath ?? '—'}`))
|
|
106
|
-
console.log(chalk.gray(` paths.special.dist: ${lo.pathsDist ?? '—'}`))
|
|
80
|
+
if (scope.hintAll) {
|
|
81
|
+
console.log(chalk.dim(`\n tip: ${scope.hintAll}`))
|
|
82
|
+
}
|
|
107
83
|
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
console.log(chalk.gray('\n would write tsconfig.json:'))
|
|
111
|
-
console.log(chalk.gray(` include: ${JSON.stringify(preview.merged.include)}`))
|
|
112
|
-
console.log(chalk.gray(` outDir: ${preview.merged.compilerOptions.outDir}`))
|
|
113
|
-
console.log(chalk.gray(` paths: ${JSON.stringify(preview.merged.compilerOptions.paths)}`))
|
|
114
|
-
console.log(chalk.gray(`\n bunfig → ${preview.paths.bunfigAliasLine}`))
|
|
84
|
+
if (failed) {
|
|
85
|
+
console.log(chalk.red(`\n sync finished with ${failed} error(s)`))
|
|
115
86
|
printCommandFooter({ version: coreVersion })
|
|
116
|
-
|
|
87
|
+
process.exit(1)
|
|
117
88
|
}
|
|
118
89
|
|
|
119
|
-
|
|
120
|
-
const result = syncProjectToolchain(root, { write: true })
|
|
121
|
-
const schema = ensureTmpSchemaVersion(layout.tmpFilePath)
|
|
122
|
-
if (schema.patched) console.log(chalk.green(` tmp end.version → ${schema.schemaVersion} (schema)`))
|
|
123
|
-
console.log(result.created
|
|
124
|
-
? chalk.green(` created ${result.tsconfigRel}`)
|
|
125
|
-
: chalk.green(` updated ${result.tsconfigRel}`))
|
|
126
|
-
console.log(chalk.gray(` include → ${JSON.stringify(result.merged.include)}`))
|
|
127
|
-
console.log(chalk.gray(` outDir → ${result.merged.compilerOptions.outDir}`))
|
|
128
|
-
console.log(chalk.yellow(`\n bunfig.toml [resolve.alias]: ${result.paths.bunfigAliasLine}`))
|
|
90
|
+
console.log(chalk.green('\n sync done'))
|
|
129
91
|
printCommandFooter({ version: coreVersion })
|
|
130
92
|
}
|
|
131
93
|
|
|
132
94
|
cli
|
|
133
95
|
.command('sync')
|
|
134
96
|
.alias('sync-toolchain')
|
|
135
|
-
.description('Sync tsconfig + @xrystal/core
|
|
97
|
+
.description('Sync tsconfig + @xrystal/core for current project (use --all inside a workspace for every link)')
|
|
136
98
|
.option('--dry-run', 'Preview without writing')
|
|
99
|
+
.option('--self', 'Inside a workspace: sync only the current linked project')
|
|
100
|
+
.option('--all', 'Inside a workspace: sync all api/admin/web linked projects + registry')
|
|
101
|
+
.option('--workspace', 'Alias for --all')
|
|
102
|
+
.addHelpText('after', () => formatSyncHelp({ cliName }))
|
|
137
103
|
.action(run)
|
|
138
104
|
}
|
|
139
105
|
|
package/x/bin/commands/tmp.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { formatLoaderSummary, summarizeLoaders } from '../helpers/tmp-config.mjs'
|
|
16
16
|
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
17
17
|
import { ensureTmpSchemaVersion, readTmpSchemaVersion } from '../helpers/tmp-schema-version.mjs'
|
|
18
|
+
import { resolveProjectContext } from '../helpers/project-context.mjs'
|
|
18
19
|
|
|
19
20
|
export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
20
21
|
cli
|
|
@@ -41,7 +42,9 @@ export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
41
42
|
const rel = relativeFromRoot(root, result.tmpFilePath)
|
|
42
43
|
const schema = ensureTmpSchemaVersion(result.tmpFilePath)
|
|
43
44
|
|
|
45
|
+
const ctx = resolveProjectContext()
|
|
44
46
|
printCommandHeader({ cliName, command: 'tmp', version })
|
|
47
|
+
console.log(chalk.gray(` scope: ${ctx.label}`))
|
|
45
48
|
console.log(chalk.gray(` root: ${root}`))
|
|
46
49
|
console.log(result.created ? chalk.green(` created ${rel}`) : chalk.gray(` ok ${rel}`))
|
|
47
50
|
const schemaVersion = readTmpSchemaVersion(result.tmpFilePath)
|
|
@@ -7,12 +7,12 @@ import { brandTitle } from './banner.mjs'
|
|
|
7
7
|
import { packageDefaults } from './package-defaults.mjs'
|
|
8
8
|
|
|
9
9
|
const QUICK_COMMANDS = [
|
|
10
|
-
{ cmd: 'project', desc: 'Where am I? workspace
|
|
11
|
-
{ cmd: '
|
|
12
|
-
{ cmd: '
|
|
13
|
-
{ cmd: '
|
|
14
|
-
{ cmd: '
|
|
15
|
-
{ cmd: '
|
|
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/admin/web 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 + admin/web slots' },
|
|
15
|
+
{ cmd: 'workspaces', desc: 'Global registry ~/.xrystal (not repo tmp.yml)' },
|
|
16
16
|
{ cmd: 'dev / build / doctor', desc: 'Develop & diagnostics' },
|
|
17
17
|
]
|
|
18
18
|
|
|
@@ -37,7 +37,8 @@ const COMMAND_GROUPS = [
|
|
|
37
37
|
title: 'Workspace',
|
|
38
38
|
items: [
|
|
39
39
|
{ cmd: 'create <name> --workspace', desc: 'Outer ./tmp.yml + api/general inner monolith + admin/web' },
|
|
40
|
-
{ cmd: 'sync', desc: '
|
|
40
|
+
{ cmd: 'sync --all', desc: 'From root or any link: all api/admin/web + ~/.xrystal registry' },
|
|
41
|
+
{ cmd: 'workspaces [list|sync]', desc: 'Inspect/rescan global registry (separate from xry sync)' },
|
|
41
42
|
{ cmd: 'telepresence dev <deploy>', aliases: 'tp dev', desc: 'Intercept cluster pod → local dev' },
|
|
42
43
|
{ cmd: 'telepresence connect', aliases: 'tp connect', desc: 'Connect Telepresence to dev/test namespace' },
|
|
43
44
|
],
|
|
@@ -46,7 +47,9 @@ const COMMAND_GROUPS = [
|
|
|
46
47
|
title: 'Project',
|
|
47
48
|
items: [
|
|
48
49
|
{ cmd: 'create', hint: '<name> [path]', desc: 'Standalone service (gpt template + inner x/tmp.yml)' },
|
|
49
|
-
{ cmd: '
|
|
50
|
+
{ cmd: 'sync', desc: 'Current project only: tsconfig + @xrystal/core pin + tmp schema' },
|
|
51
|
+
{ cmd: 'sync --self', desc: 'Inside workspace: explicit current linked project only' },
|
|
52
|
+
{ cmd: 'tmp', desc: 'Ensure tmp.yml for current folder scope · end.version = schema' },
|
|
50
53
|
{ cmd: 'hooks install', desc: 'Install .git/hooks pre-commit version check' },
|
|
51
54
|
{ cmd: 'hooks status', desc: 'Show whether pre-commit hook is installed' },
|
|
52
55
|
],
|
|
@@ -93,6 +96,24 @@ function formatTreeLines(items) {
|
|
|
93
96
|
return lines.join('\n')
|
|
94
97
|
}
|
|
95
98
|
|
|
99
|
+
export function formatSyncHelp({ cliName = CLI_PRIMARY_NAME } = {}) {
|
|
100
|
+
const rows = [
|
|
101
|
+
{ ctx: 'Standalone service', cmd: `${cliName} sync`, effect: 'tsconfig + pin @xrystal/core + tmp schema' },
|
|
102
|
+
{ ctx: 'Workspace root', cmd: `${cliName} sync`, effect: 'all linked projects + registry (same as --all)' },
|
|
103
|
+
{ ctx: 'Inside api/admin/web', cmd: `${cliName} sync`, effect: 'current project only (default)' },
|
|
104
|
+
{ ctx: 'Inside api/admin/web', cmd: `${cliName} sync --all`, effect: 'every linked project + registry' },
|
|
105
|
+
{ ctx: 'Global registry only', cmd: `${cliName} workspaces sync`, effect: 'rescan ~/.xrystal from cwd' },
|
|
106
|
+
]
|
|
107
|
+
const lines = rows.map((row) => ` ${chalk.gray(row.ctx.padEnd(22))} ${chalk.cyan(row.cmd)}\n${' '.repeat(26)}${chalk.gray(row.effect)}`)
|
|
108
|
+
return [
|
|
109
|
+
chalk.bold.white('\n Sync scope'),
|
|
110
|
+
...lines,
|
|
111
|
+
'',
|
|
112
|
+
chalk.gray(' xry project — shows which row applies to your cwd'),
|
|
113
|
+
'',
|
|
114
|
+
].join('\n')
|
|
115
|
+
}
|
|
116
|
+
|
|
96
117
|
/** Bare CLI — banner altında kısa, işe yarayan komutlar. */
|
|
97
118
|
export function printQuickStartGuide({ cliName = CLI_PRIMARY_NAME } = {}) {
|
|
98
119
|
console.log(chalk.bold.yellow('\n Quick start'))
|
|
@@ -108,15 +108,18 @@ export function resolveProjectContext(startDir = process.cwd()) {
|
|
|
108
108
|
const hints = []
|
|
109
109
|
if (kind === 'workspace-root') {
|
|
110
110
|
hints.push('Outer tmp: ./tmp.yml · inner tmp: each api|admin|web project')
|
|
111
|
-
hints.push('xry sync — all linked
|
|
112
|
-
hints.push('xry
|
|
111
|
+
hints.push('xry sync — all linked projects + ~/.xrystal registry')
|
|
112
|
+
hints.push('xry sync --all — same from any folder under this workspace')
|
|
113
|
+
hints.push('xry workspaces — global registry (~/.xrystal), not repo tmp files')
|
|
113
114
|
} else if (kind === 'workspace-service') {
|
|
114
115
|
hints.push(`Outer workspace: ${workspaceRoot}`)
|
|
115
|
-
hints.push('xry
|
|
116
|
-
hints.push('
|
|
116
|
+
hints.push('xry sync — this service only (tsconfig + @xrystal/core pin)')
|
|
117
|
+
hints.push('xry sync --all — every linked api/admin/web project + registry')
|
|
118
|
+
hints.push('xry tmp — inner x/tmp.yml · configs.global.type drives loader profile')
|
|
117
119
|
} else {
|
|
118
|
-
hints.push('xry
|
|
119
|
-
hints.push('
|
|
120
|
+
hints.push('xry sync — tsconfig + @xrystal/core pin for this repo')
|
|
121
|
+
hints.push('xry tmp — seed inner x/tmp.yml (api-service | frontend | …)')
|
|
122
|
+
hints.push('configs.global.type: frontend skips mongo/redis/kafka unless enabled in tmp')
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
return {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
|
|
3
|
+
import chalk from 'chalk'
|
|
4
|
+
|
|
5
|
+
import { syncCliRuntime } from './project-artifacts.mjs'
|
|
6
|
+
import { syncCoreDependency } from './sync-core-dependency.mjs'
|
|
7
|
+
import { syncProjectToolchain } from './toolchain-config.mjs'
|
|
8
|
+
import { ensureTmpSchemaVersion } from './tmp-schema-version.mjs'
|
|
9
|
+
import { packageDefaults } from './package-defaults.mjs'
|
|
10
|
+
|
|
11
|
+
export function syncOneProject(entry, coreVersion, { dryRun = false, tmpPath = null } = {}) {
|
|
12
|
+
const label = entry.name ? `${entry.name} (${entry.type ?? 'project'})` : path.basename(entry.path)
|
|
13
|
+
const lines = []
|
|
14
|
+
|
|
15
|
+
if (dryRun) {
|
|
16
|
+
const preview = syncProjectToolchain(entry.path, { write: false })
|
|
17
|
+
lines.push({ level: 'gray', text: `would update ${preview.tsconfigRel ?? 'tsconfig.json'}` })
|
|
18
|
+
const core = syncCoreDependency(entry.path, coreVersion, { dryRun: true })
|
|
19
|
+
if (core.synced) {
|
|
20
|
+
lines.push({ level: 'gray', text: `would pin ${packageDefaults.packageName}@${coreVersion} (from ${core.current ?? core.declared})` })
|
|
21
|
+
} else if (core.reason === 'up-to-date') {
|
|
22
|
+
lines.push({ level: 'gray', text: `${packageDefaults.packageName}@${coreVersion} (ok)` })
|
|
23
|
+
} else if (core.reason === 'no core dependency') {
|
|
24
|
+
lines.push({ level: 'yellow', text: `skip core pin (${core.reason})` })
|
|
25
|
+
}
|
|
26
|
+
return { label, path: entry.path, lines, failed: false }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
syncCliRuntime(entry.path, { force: false })
|
|
31
|
+
const result = syncProjectToolchain(entry.path, { write: true })
|
|
32
|
+
lines.push({
|
|
33
|
+
level: 'green',
|
|
34
|
+
text: result.created
|
|
35
|
+
? `created ${result.tsconfigRel}`
|
|
36
|
+
: `updated ${result.tsconfigRel}`,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
const core = syncCoreDependency(entry.path, coreVersion, { dryRun: false })
|
|
40
|
+
if (core.synced) {
|
|
41
|
+
lines.push({ level: 'green', text: `pinned ${packageDefaults.packageName}@${coreVersion}` })
|
|
42
|
+
} else if (core.reason === 'up-to-date') {
|
|
43
|
+
lines.push({ level: 'gray', text: `${packageDefaults.packageName}@${coreVersion} (ok)` })
|
|
44
|
+
} else if (core.reason === 'no core dependency') {
|
|
45
|
+
lines.push({ level: 'yellow', text: `skip core pin (${core.reason})` })
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (tmpPath) {
|
|
49
|
+
const schema = ensureTmpSchemaVersion(tmpPath)
|
|
50
|
+
if (schema.patched) {
|
|
51
|
+
lines.push({ level: 'green', text: `tmp end.version → ${schema.schemaVersion} (schema)` })
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return { label, path: entry.path, lines, failed: false }
|
|
56
|
+
} catch (error) {
|
|
57
|
+
return {
|
|
58
|
+
label,
|
|
59
|
+
path: entry.path,
|
|
60
|
+
lines: [{ level: 'red', text: `failed: ${error.message}` }],
|
|
61
|
+
failed: true,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function printSyncProjectResult(result) {
|
|
67
|
+
console.log(chalk.cyan(`\n→ ${result.label}`))
|
|
68
|
+
console.log(chalk.gray(` path: ${result.path}`))
|
|
69
|
+
for (const line of result.lines) {
|
|
70
|
+
const paint = line.level === 'green' ? chalk.green
|
|
71
|
+
: line.level === 'red' ? chalk.red
|
|
72
|
+
: line.level === 'yellow' ? chalk.yellow
|
|
73
|
+
: chalk.gray
|
|
74
|
+
console.log(` ${paint(line.text)}`)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
|
|
3
|
+
import { findEntries, findWorkspaceRoot } from './workspace-resolve.mjs'
|
|
4
|
+
import { resolveProjectRoot } from './project-root.mjs'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Resolve what `xry sync` should touch.
|
|
8
|
+
*
|
|
9
|
+
* | Context | default | --self | --all / --workspace |
|
|
10
|
+
* |--------------------|-----------|-------------|---------------------|
|
|
11
|
+
* | Standalone service | this repo | — | — |
|
|
12
|
+
* | Workspace root | all links | — | all links |
|
|
13
|
+
* | Inner service | this repo | this repo | all links + registry|
|
|
14
|
+
*/
|
|
15
|
+
export function resolveSyncScope(cwd = process.cwd(), options = {}) {
|
|
16
|
+
const resolvedCwd = path.resolve(cwd)
|
|
17
|
+
const workspaceRoot = findWorkspaceRoot(resolvedCwd)
|
|
18
|
+
const projectRoot = resolveProjectRoot(resolvedCwd)
|
|
19
|
+
const atWorkspaceRoot = workspaceRoot != null && path.resolve(workspaceRoot) === resolvedCwd
|
|
20
|
+
|
|
21
|
+
const wantAll = Boolean(options.all || options.workspace)
|
|
22
|
+
const wantSelf = Boolean(options.self)
|
|
23
|
+
|
|
24
|
+
if (wantAll && wantSelf) {
|
|
25
|
+
throw new Error('Use either --self or --all, not both')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!workspaceRoot) {
|
|
29
|
+
return {
|
|
30
|
+
mode: 'standalone',
|
|
31
|
+
label: 'standalone project',
|
|
32
|
+
targetRoot: projectRoot,
|
|
33
|
+
workspaceRoot: null,
|
|
34
|
+
entries: [{ path: projectRoot, name: path.basename(projectRoot), type: 'project' }],
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const entries = findEntries(workspaceRoot)
|
|
39
|
+
|
|
40
|
+
if (atWorkspaceRoot || wantAll) {
|
|
41
|
+
return {
|
|
42
|
+
mode: 'workspace-all',
|
|
43
|
+
label: wantAll && !atWorkspaceRoot ? 'workspace (all linked projects)' : 'workspace root',
|
|
44
|
+
targetRoot: workspaceRoot,
|
|
45
|
+
workspaceRoot,
|
|
46
|
+
entries,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (wantSelf) {
|
|
51
|
+
const self = entries.find((entry) => path.resolve(entry.path) === path.resolve(projectRoot))
|
|
52
|
+
return {
|
|
53
|
+
mode: 'self',
|
|
54
|
+
label: 'current linked project',
|
|
55
|
+
targetRoot: projectRoot,
|
|
56
|
+
workspaceRoot,
|
|
57
|
+
entries: self ? [self] : [{ path: projectRoot, name: path.basename(projectRoot), type: 'project' }],
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Inner service default: sync only this project (clear, predictable).
|
|
62
|
+
const self = entries.find((entry) => path.resolve(entry.path) === path.resolve(projectRoot))
|
|
63
|
+
return {
|
|
64
|
+
mode: 'self',
|
|
65
|
+
label: 'current linked project (default)',
|
|
66
|
+
targetRoot: projectRoot,
|
|
67
|
+
workspaceRoot,
|
|
68
|
+
entries: self ? [self] : [{ path: projectRoot, name: path.basename(projectRoot), type: 'project' }],
|
|
69
|
+
hintAll: `Run ${options.cliName ?? 'xry'} sync --all from here to sync every linked api/admin/web project`,
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -22,6 +22,22 @@ export function resolveProtocolsFromConfig(configs = {}) {
|
|
|
22
22
|
return (Array.isArray(raw) ? raw : [raw]).map(parseProtocolValue)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
function summarizeInfraLoaders(depends) {
|
|
26
|
+
const loaders = depends?.loaders ?? {}
|
|
27
|
+
const readEnabled = (key, fallback) => {
|
|
28
|
+
const opts = loaders?.[key]?.options
|
|
29
|
+
if (opts && typeof opts === 'object' && 'enabled' in opts) return opts.enabled !== false
|
|
30
|
+
return fallback
|
|
31
|
+
}
|
|
32
|
+
const type = depends?.globalType ?? null
|
|
33
|
+
const isFrontend = type === 'frontend'
|
|
34
|
+
return {
|
|
35
|
+
kafka: readEnabled('kafka', !isFrontend),
|
|
36
|
+
redis: readEnabled('redis', !isFrontend),
|
|
37
|
+
mongo: readEnabled('mongo', !isFrontend),
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
25
41
|
export function summarizeLoaders(tmp = {}) {
|
|
26
42
|
const configs = tmp.configs ?? {}
|
|
27
43
|
const global = readTmpGlobalBlock(configs)
|
|
@@ -29,8 +45,10 @@ export function summarizeLoaders(tmp = {}) {
|
|
|
29
45
|
|
|
30
46
|
return {
|
|
31
47
|
framework: global.framework ?? packageDefaults.framework,
|
|
48
|
+
globalType: global.type ?? '-',
|
|
32
49
|
protocols: resolveProtocolsFromConfig(depends),
|
|
33
50
|
project: tmp.project?.name ?? '-',
|
|
51
|
+
infra: summarizeInfraLoaders({ loaders: depends.loaders, globalType: global.type }),
|
|
34
52
|
items: [
|
|
35
53
|
depends.loaders?.dto && { key: 'dto', detail: formatLoaderDetail(depends.loaders?.dto) },
|
|
36
54
|
depends.loaders?.loggers && { key: 'loggers', detail: formatLoaderDetail(depends.loaders?.loggers) },
|
|
@@ -58,9 +76,16 @@ function formatLoaderDetail(obj) {
|
|
|
58
76
|
|
|
59
77
|
export function formatLoaderSummary(summary) {
|
|
60
78
|
const lines = [
|
|
79
|
+
`type: ${summary.globalType ?? '-'}`,
|
|
61
80
|
`framework: ${summary.framework}`,
|
|
62
81
|
`protocols: ${summary.protocols.join(', ')}`,
|
|
63
82
|
]
|
|
83
|
+
if (summary.infra) {
|
|
84
|
+
const flags = ['kafka', 'redis', 'mongo']
|
|
85
|
+
.map((key) => `${key}:${summary.infra[key] ? 'on' : 'off'}`)
|
|
86
|
+
.join(' · ')
|
|
87
|
+
lines.push(`infra: ${flags}`)
|
|
88
|
+
}
|
|
64
89
|
if (summary.project) lines.push(`project: ${summary.project}`)
|
|
65
90
|
for (const item of summary.items) {
|
|
66
91
|
lines.push(`${item.key}: ${item.detail}`)
|
|
@@ -2,7 +2,7 @@ export { resolveKafkaJsSsl } from './resolve-ssl.js';
|
|
|
2
2
|
import { Kafka as KafkaClient, logLevel } from "kafkajs";
|
|
3
3
|
import { bindLoaderTmpSync } from '../../utils/helpers/tmp/loader-tmp-sync.js';
|
|
4
4
|
import { resolveKafkaJsSsl } from './resolve-ssl.js';
|
|
5
|
-
import { readKafkaLoaderOptions } from '../../utils/helpers/
|
|
5
|
+
import { readKafkaLoaderOptions } from '../../utils/helpers/loader-options/index.js';
|
|
6
6
|
export default class KafkaForCore {
|
|
7
7
|
_instance;
|
|
8
8
|
_producer;
|
|
@@ -23,13 +23,18 @@ export default class KafkaForCore {
|
|
|
23
23
|
await this.syncFromTmp();
|
|
24
24
|
bindLoaderTmpSync(this);
|
|
25
25
|
};
|
|
26
|
+
#resolveDependsLoaders = () => {
|
|
27
|
+
const configs = this.#system?.tmp?.configs;
|
|
28
|
+
return configs?.depends?.loaders ?? configs?.service?.loaders;
|
|
29
|
+
};
|
|
26
30
|
syncFromTmp = async () => {
|
|
27
31
|
await this.teardownKafka();
|
|
28
32
|
this.clientId = this.#configs.all?.kafkaClientId;
|
|
29
33
|
this.brokers = this.#configs.all?.kafkaBrokers;
|
|
30
34
|
this.username = this.#configs.all?.kafkaUsername;
|
|
31
35
|
this.password = this.#configs.all?.kafkaPassword;
|
|
32
|
-
const
|
|
36
|
+
const loaders = this.#resolveDependsLoaders();
|
|
37
|
+
const kafkaOpts = readKafkaLoaderOptions(loaders);
|
|
33
38
|
if (!kafkaOpts.enabled) {
|
|
34
39
|
return;
|
|
35
40
|
}
|
|
@@ -60,13 +60,15 @@ export default class Logger {
|
|
|
60
60
|
};
|
|
61
61
|
syncFromTmp = async () => {
|
|
62
62
|
await this.teardownLogger();
|
|
63
|
-
|
|
63
|
+
const configs = this.#system?.tmp?.configs;
|
|
64
|
+
const loaders = configs?.depends?.loaders ?? configs?.service?.loaders;
|
|
65
|
+
this.serviceName = configs?.deploymentName ?? configs?.service?.name ?? '';
|
|
64
66
|
this.kafkaLogsTopic = this.#configs?.all?.kafkaLogsTopic;
|
|
65
67
|
winston.addColors(customColors);
|
|
66
|
-
const loggersConfigs =
|
|
68
|
+
const loggersConfigs = (loaders?.loggers ?? {});
|
|
67
69
|
const { kafkaBrokers } = this.#configs.all;
|
|
68
70
|
const brokers = kafkaBrokers ? String(kafkaBrokers).split(',').map((b) => b.trim()) : [];
|
|
69
|
-
const kafkaOpts = readKafkaLoaderOptions(
|
|
71
|
+
const kafkaOpts = readKafkaLoaderOptions(loaders);
|
|
70
72
|
const isKafkaLogEnabled = kafkaOpts.enabled && kafkaOpts.queueLogEnabled && brokers.length > 0;
|
|
71
73
|
if (isKafkaLogEnabled && this.#kafka.instance) {
|
|
72
74
|
this.kafkaProducer = this.#kafka.instance.producer({
|
|
@@ -81,9 +83,9 @@ export default class Logger {
|
|
|
81
83
|
this.isKafkaReady = false;
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
|
-
const logPath = loggersConfigs
|
|
85
|
-
const loggerLevel = loggersConfigs
|
|
86
|
-
const queueLogLevel = normalizeLoggerLayer(loggersConfigs
|
|
86
|
+
const logPath = String(loggersConfigs.loadPath ?? 'logs');
|
|
87
|
+
const loggerLevel = String(loggersConfigs.logLevel ?? loggersConfigs.loggerLevel ?? 'info');
|
|
88
|
+
const queueLogLevel = normalizeLoggerLayer((loggersConfigs.queueLogLevel ?? loggersConfigs.kafkaLogLevel), LoggerLayerEnum.WARN);
|
|
87
89
|
this.queueLogLevel = queueLogLevel;
|
|
88
90
|
this.winstonLoader({
|
|
89
91
|
loadPath: path.join(this.#configs.all.rootFolderPath, logPath),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { resolveMongoConnectOptions } from './resolve-connect.js';
|
|
2
2
|
import { MongoClient } from 'mongodb';
|
|
3
3
|
import { bindLoaderTmpSync } from '../../utils/helpers/tmp/loader-tmp-sync.js';
|
|
4
|
+
import { readInfraLoaderEnabled } from '../../utils/helpers/loader-options/index.js';
|
|
4
5
|
import { resolveMongoConnectOptions } from './resolve-connect.js';
|
|
5
6
|
export default class MongoForCore {
|
|
6
7
|
#client = null;
|
|
@@ -18,8 +19,16 @@ export default class MongoForCore {
|
|
|
18
19
|
await this.syncFromTmp();
|
|
19
20
|
bindLoaderTmpSync(this);
|
|
20
21
|
};
|
|
22
|
+
#resolveDependsLoaders = () => {
|
|
23
|
+
const configs = this.#system?.tmp?.configs;
|
|
24
|
+
return configs?.depends?.loaders ?? configs?.service?.loaders;
|
|
25
|
+
};
|
|
21
26
|
syncFromTmp = async () => {
|
|
22
27
|
await this.teardown();
|
|
28
|
+
const loaders = this.#resolveDependsLoaders();
|
|
29
|
+
if (!readInfraLoaderEnabled(loaders, 'mongo', true)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
23
32
|
if (this.#configs.all.isMongoPassive) {
|
|
24
33
|
return;
|
|
25
34
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { resolveRedisSocketOptions } from './resolve-socket.js';
|
|
2
2
|
import { createClient } from 'redis';
|
|
3
3
|
import { bindLoaderTmpSync } from '../../utils/helpers/tmp/loader-tmp-sync.js';
|
|
4
|
+
import { readInfraLoaderEnabled } from '../../utils/helpers/loader-options/index.js';
|
|
4
5
|
import { resolveRedisSocketOptions } from './resolve-socket.js';
|
|
5
6
|
export default class RedisForCore {
|
|
6
7
|
#client = null;
|
|
@@ -17,8 +18,16 @@ export default class RedisForCore {
|
|
|
17
18
|
await this.syncFromTmp();
|
|
18
19
|
bindLoaderTmpSync(this);
|
|
19
20
|
};
|
|
21
|
+
#resolveDependsLoaders = () => {
|
|
22
|
+
const configs = this.#system?.tmp?.configs;
|
|
23
|
+
return configs?.depends?.loaders ?? configs?.service?.loaders;
|
|
24
|
+
};
|
|
20
25
|
syncFromTmp = async () => {
|
|
21
26
|
await this.teardown();
|
|
27
|
+
const loaders = this.#resolveDependsLoaders();
|
|
28
|
+
if (!readInfraLoaderEnabled(loaders, 'redis', true)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
22
31
|
if (this.#configs.all.isRedisPassive) {
|
|
23
32
|
return;
|
|
24
33
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ensureCoreTmpEntry, isCorePackageRoot } from '../utils/helpers/core/tmp-layout';
|
|
2
2
|
export { getTmpSnapshot } from '../utils/helpers/tmp/tmp-loader';
|
|
3
|
+
export { resolveLoaderBootPlan } from '../utils/helpers/tmp/loader-boot-plan';
|
|
3
4
|
export declare const core: {
|
|
4
5
|
_: Record<string, unknown>;
|
|
5
6
|
};
|
package/x/dist/project/index.js
CHANGED
|
@@ -4,8 +4,11 @@ import { System, Configs, Logger, Events, Localizations, DtoRuntime, Clients, Co
|
|
|
4
4
|
import { Constants, getCore, x } from '../utils/index.js';
|
|
5
5
|
import { ensureCoreTmpEntry, isCorePackageRoot } from '../utils/helpers/core/tmp-layout.js';
|
|
6
6
|
import { getTmpSnapshot } from '../utils/helpers/tmp/tmp-loader.js';
|
|
7
|
+
import { resolveLoaderBootPlan } from '../utils/helpers/tmp/loader-boot-plan.js';
|
|
8
|
+
import { resolveTmpRuntimeConfigs } from '../utils/helpers/tmp/tmp-schema.js';
|
|
7
9
|
export { ensureCoreTmpEntry, isCorePackageRoot } from '../utils/helpers/core/tmp-layout.js';
|
|
8
10
|
export { getTmpSnapshot } from '../utils/helpers/tmp/tmp-loader.js';
|
|
11
|
+
export { resolveLoaderBootPlan } from '../utils/helpers/tmp/loader-boot-plan.js';
|
|
9
12
|
export const core = getCore();
|
|
10
13
|
export const coreInit = async (params) => {
|
|
11
14
|
const { locales } = params;
|
|
@@ -16,29 +19,33 @@ let coreHasRun = false;
|
|
|
16
19
|
const projectModuleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
17
20
|
const loaderGlob = path.join(projectModuleDir, '..', 'loader', '**/*.{ts,js}');
|
|
18
21
|
const loaderExcludeGlob = path.join(projectModuleDir, '..', 'utils', '**/class.x.{ts,js}');
|
|
22
|
+
function buildLoaderInitList(plan, coreRef) {
|
|
23
|
+
const entries = [
|
|
24
|
+
{ service: System, props: { core: coreRef } },
|
|
25
|
+
{ service: Configs, props: {} },
|
|
26
|
+
];
|
|
27
|
+
if (plan.kafka)
|
|
28
|
+
entries.push({ service: KafkaForCore, props: {} });
|
|
29
|
+
if (plan.redis)
|
|
30
|
+
entries.push({ service: RedisForCore, props: {} });
|
|
31
|
+
if (plan.mongo)
|
|
32
|
+
entries.push({ service: MongoForCore, props: {} });
|
|
33
|
+
entries.push({ service: Logger, props: {} }, { service: Events, props: {} }, { service: Localizations, props: {} }, { service: DtoRuntime, props: {} }, { service: Controller, props: {} }, { service: Clients, props: {} });
|
|
34
|
+
return entries;
|
|
35
|
+
}
|
|
19
36
|
const coreLoader = async (_params = {}) => {
|
|
20
37
|
if (coreHasRun)
|
|
21
38
|
return core;
|
|
22
39
|
const root = process.cwd();
|
|
23
40
|
if (isCorePackageRoot(root))
|
|
24
41
|
ensureCoreTmpEntry(root);
|
|
25
|
-
getTmpSnapshot();
|
|
42
|
+
const snapshot = getTmpSnapshot();
|
|
43
|
+
const runtimeConfigs = resolveTmpRuntimeConfigs(snapshot);
|
|
44
|
+
const plan = resolveLoaderBootPlan(runtimeConfigs);
|
|
26
45
|
try {
|
|
27
46
|
await (await x.load([loaderGlob], {
|
|
28
47
|
exclude: [loaderExcludeGlob],
|
|
29
|
-
})).initialize(
|
|
30
|
-
{ service: System, props: { core } },
|
|
31
|
-
{ service: Configs, props: {} },
|
|
32
|
-
{ service: KafkaForCore, props: {} },
|
|
33
|
-
{ service: RedisForCore, props: {} },
|
|
34
|
-
{ service: MongoForCore, props: {} },
|
|
35
|
-
{ service: Logger, props: {} },
|
|
36
|
-
{ service: Events, props: {} },
|
|
37
|
-
{ service: Localizations, props: {} },
|
|
38
|
-
{ service: DtoRuntime, props: {} },
|
|
39
|
-
{ service: Controller, props: {} },
|
|
40
|
-
{ service: Clients, props: {} },
|
|
41
|
-
]);
|
|
48
|
+
})).initialize(buildLoaderInitList(plan, core));
|
|
42
49
|
coreHasRun = true;
|
|
43
50
|
return core;
|
|
44
51
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type InfraLoaderOptions = {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare function readInfraLoaderEnabled(loaders: Record<string, unknown> | undefined, key: string, defaultEnabled: boolean): boolean;
|
|
5
|
+
export { readKafkaLoaderOptions, type KafkaLoaderOptions } from '../../../utils/helpers/kafka-loader-options';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function readOptionsBlock(loaders, key) {
|
|
2
|
+
const block = loaders?.[key];
|
|
3
|
+
if (typeof block !== 'object' || block === null)
|
|
4
|
+
return {};
|
|
5
|
+
const options = block.options;
|
|
6
|
+
if (typeof options !== 'object' || options === null)
|
|
7
|
+
return {};
|
|
8
|
+
return options;
|
|
9
|
+
}
|
|
10
|
+
export function readInfraLoaderEnabled(loaders, key, defaultEnabled) {
|
|
11
|
+
const options = readOptionsBlock(loaders, key);
|
|
12
|
+
if ('enabled' in options)
|
|
13
|
+
return options.enabled !== false;
|
|
14
|
+
return defaultEnabled;
|
|
15
|
+
}
|
|
16
|
+
export { readKafkaLoaderOptions } from '../../../utils/helpers/kafka-loader-options/index.js';
|
|
@@ -2,6 +2,7 @@ export { setRuntimeTmpConfigs, getRuntimeTmpConfigs, onRuntimeTmpChange, notifyR
|
|
|
2
2
|
export { getTmpLoader, getTmpLoaderPath, getTmpSnapshot, onTmpReload, resetTmpLoaderForTests, stopTmpLoader, } from '../../../utils/helpers/tmp/tmp-loader';
|
|
3
3
|
export { bindLoaderTmpSync, type ITmpSyncLoader, } from '../../../utils/helpers/tmp/loader-tmp-sync';
|
|
4
4
|
export { resolveTmpWatchIntervalMs } from '../../../utils/helpers/tmp/tmp-watch';
|
|
5
|
+
export { resolveLoaderBootPlan, type LoaderBootPlan, type LoaderBootProfile, } from '../../../utils/helpers/tmp/loader-boot-plan';
|
|
5
6
|
export { normalizeTmpDocument, normalizeRootFolder, normalizeSourceFolder, normalizeRuntime, normalizeBundler, resolveEffectiveBundler, readTmpDependsBlock, readTmpBuildBlock, readTmpGlobalBlock, assertNoLegacyTmpKeys, resolveTmpDeploymentName, readTmpGlobalPathsBlock, applyTmpGlobalVars, resolveMergedPaths, resolveTmpRuntimeConfigs, resolveProjectRootFromTmpPath, resolveTmpAbsPath, normalizeGlobalType, } from '../../../utils/helpers/tmp/tmp-schema';
|
|
6
7
|
export { loadSeedFromBundledTmp, seedFromTmp, type SeedFromTmp, } from '../../../utils/helpers/tmp/seed-from-tmp';
|
|
7
8
|
export { normalizeLayoutPaths, type LayoutPaths, } from '../../../utils/helpers/tmp/path-normalize';
|
|
@@ -2,6 +2,7 @@ export { setRuntimeTmpConfigs, getRuntimeTmpConfigs, onRuntimeTmpChange, notifyR
|
|
|
2
2
|
export { getTmpLoader, getTmpLoaderPath, getTmpSnapshot, onTmpReload, resetTmpLoaderForTests, stopTmpLoader, } from '../../../utils/helpers/tmp/tmp-loader.js';
|
|
3
3
|
export { bindLoaderTmpSync, } from '../../../utils/helpers/tmp/loader-tmp-sync.js';
|
|
4
4
|
export { resolveTmpWatchIntervalMs } from '../../../utils/helpers/tmp/tmp-watch.js';
|
|
5
|
+
export { resolveLoaderBootPlan, } from '../../../utils/helpers/tmp/loader-boot-plan.js';
|
|
5
6
|
export { normalizeTmpDocument, normalizeRootFolder, normalizeSourceFolder, normalizeRuntime, normalizeBundler, resolveEffectiveBundler, readTmpDependsBlock, readTmpBuildBlock, readTmpGlobalBlock, assertNoLegacyTmpKeys, resolveTmpDeploymentName, readTmpGlobalPathsBlock, applyTmpGlobalVars, resolveMergedPaths, resolveTmpRuntimeConfigs, resolveProjectRootFromTmpPath, resolveTmpAbsPath, normalizeGlobalType, } from '../../../utils/helpers/tmp/tmp-schema.js';
|
|
6
7
|
export { loadSeedFromBundledTmp, seedFromTmp, } from '../../../utils/helpers/tmp/seed-from-tmp.js';
|
|
7
8
|
export { normalizeLayoutPaths, } from '../../../utils/helpers/tmp/path-normalize.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TmpRuntimeConfigs } from '../../../utils/helpers/tmp/tmp-schema';
|
|
2
|
+
export type LoaderBootProfile = 'api-service' | 'frontend' | 'workspace' | 'minimal';
|
|
3
|
+
export type LoaderBootPlan = {
|
|
4
|
+
profile: LoaderBootProfile;
|
|
5
|
+
projectType: string | undefined;
|
|
6
|
+
kafka: boolean;
|
|
7
|
+
redis: boolean;
|
|
8
|
+
mongo: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function resolveLoaderBootPlan(configs?: TmpRuntimeConfigs | null): LoaderBootPlan;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GlobalTypeEnum } from '../../../utils/models/enums/index.js';
|
|
2
|
+
import { readInfraLoaderEnabled, readKafkaLoaderOptions } from '../../../utils/helpers/loader-options/index.js';
|
|
3
|
+
function loadersBlock(configs) {
|
|
4
|
+
const loaders = configs?.depends?.loaders;
|
|
5
|
+
return typeof loaders === 'object' && loaders !== null ? loaders : undefined;
|
|
6
|
+
}
|
|
7
|
+
export function resolveLoaderBootPlan(configs) {
|
|
8
|
+
const type = configs?.global?.type;
|
|
9
|
+
const loaders = loadersBlock(configs);
|
|
10
|
+
if (type === GlobalTypeEnum.FRONTEND) {
|
|
11
|
+
return {
|
|
12
|
+
profile: 'frontend',
|
|
13
|
+
projectType: type,
|
|
14
|
+
kafka: readInfraLoaderEnabled(loaders, 'kafka', false),
|
|
15
|
+
redis: readInfraLoaderEnabled(loaders, 'redis', false),
|
|
16
|
+
mongo: readInfraLoaderEnabled(loaders, 'mongo', false),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
if (type === GlobalTypeEnum.WORKSPACE) {
|
|
20
|
+
return {
|
|
21
|
+
profile: 'workspace',
|
|
22
|
+
projectType: type,
|
|
23
|
+
kafka: false,
|
|
24
|
+
redis: false,
|
|
25
|
+
mongo: false,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const kafkaOpts = readKafkaLoaderOptions(loaders);
|
|
29
|
+
return {
|
|
30
|
+
profile: type === GlobalTypeEnum.API_SERVICE ? 'api-service' : 'minimal',
|
|
31
|
+
projectType: type ?? GlobalTypeEnum.API_SERVICE,
|
|
32
|
+
kafka: kafkaOpts.enabled,
|
|
33
|
+
redis: readInfraLoaderEnabled(loaders, 'redis', true),
|
|
34
|
+
mongo: readInfraLoaderEnabled(loaders, 'mongo', true),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
project:
|
|
2
|
+
name: "{{xry}}"
|
|
3
|
+
|
|
4
|
+
configs:
|
|
5
|
+
global:
|
|
6
|
+
type: frontend
|
|
7
|
+
runtime: bun
|
|
8
|
+
framework: fetch
|
|
9
|
+
paths:
|
|
10
|
+
root: ./x
|
|
11
|
+
tmp: tmp.yml
|
|
12
|
+
source: ./source
|
|
13
|
+
special:
|
|
14
|
+
tests: tests
|
|
15
|
+
environments: environments
|
|
16
|
+
dist: dist
|
|
17
|
+
vars:
|
|
18
|
+
xry: xry
|
|
19
|
+
build:
|
|
20
|
+
bundler: auto
|
|
21
|
+
typecheck: false
|
|
22
|
+
tscLenient: true
|
|
23
|
+
options:
|
|
24
|
+
fileWatchIntervalMs: 500
|
|
25
|
+
|
|
26
|
+
depends:
|
|
27
|
+
protocols:
|
|
28
|
+
- http
|
|
29
|
+
loaders:
|
|
30
|
+
configs:
|
|
31
|
+
loadPath: '@/utils/helpers/configs/index'
|
|
32
|
+
system:
|
|
33
|
+
gStore:
|
|
34
|
+
options:
|
|
35
|
+
bootstrap: true
|
|
36
|
+
autoCreateProps: true
|
|
37
|
+
kafka:
|
|
38
|
+
options:
|
|
39
|
+
enabled: false
|
|
40
|
+
queueLogEnabled: false
|
|
41
|
+
redis:
|
|
42
|
+
options:
|
|
43
|
+
enabled: false
|
|
44
|
+
mongo:
|
|
45
|
+
options:
|
|
46
|
+
enabled: false
|
|
47
|
+
loggers:
|
|
48
|
+
loadPath: logs
|
|
49
|
+
logLevel: info
|
|
50
|
+
localization:
|
|
51
|
+
loadPath: assets/langs
|
|
52
|
+
fallbackLang: en
|
|
53
|
+
preloadLangs:
|
|
54
|
+
- en
|
|
55
|
+
- tr
|
|
56
|
+
dto:
|
|
57
|
+
withDefaultHeaders: true
|
|
58
|
+
controller:
|
|
59
|
+
|
|
60
|
+
end:
|
|
61
|
+
version: 1
|