@xrystal/core 3.52.9 → 3.53.1
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 +13 -1
- package/x/bin/commands/doctor.mjs +8 -2
- package/x/bin/commands/hooks.mjs +9 -3
- package/x/bin/commands/project-info.mjs +2 -1
- package/x/bin/commands/project.mjs +83 -79
- package/x/bin/commands/release.mjs +7 -3
- package/x/bin/commands/sync.mjs +3 -0
- package/x/bin/commands/tmp.mjs +41 -20
- package/x/bin/helpers/.generated/workspace.mjs +11 -11
- package/x/bin/helpers/cli-context-guard.mjs +77 -0
- package/x/bin/helpers/cli-enums.mjs +33 -0
- package/x/bin/helpers/create-target.mjs +3 -2
- package/x/bin/helpers/project-context.mjs +11 -11
- package/x/bin/helpers/project-root.mjs +19 -6
- package/x/bin/helpers/sync-scope.mjs +5 -0
- package/x/bin/helpers/tmp-config.mjs +6 -5
- package/x/bin/helpers/workspace-tmp.mjs +20 -0
- package/x/dist/loader/mongo/index.js +2 -1
- package/x/dist/loader/redis/index.js +2 -1
- package/x/dist/project/index.js +5 -4
- package/x/dist/utils/helpers/loader-options/index.d.ts +5 -1
- package/x/dist/utils/helpers/loader-options/index.js +15 -0
- package/x/dist/utils/helpers/tmp/index.d.ts +1 -1
- package/x/dist/utils/helpers/tmp/index.js +1 -1
- package/x/dist/utils/helpers/tmp/loader-boot-plan.d.ts +7 -6
- package/x/dist/utils/helpers/tmp/loader-boot-plan.js +27 -16
- package/x/dist/utils/helpers/workspace/index.d.ts +3 -7
- package/x/dist/utils/helpers/workspace/index.js +12 -12
- package/x/dist/utils/models/enums/index.d.ts +26 -0
- package/x/dist/utils/models/enums/index.js +30 -0
package/package.json
CHANGED
|
@@ -90,7 +90,12 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
|
|
|
90
90
|
return
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
const
|
|
93
|
+
const { WorkspaceSlotEnum } = await import('../helpers/cli-enums.mjs')
|
|
94
|
+
const slot = options.mobile
|
|
95
|
+
? WorkspaceSlotEnum.MOBILE
|
|
96
|
+
: options.web
|
|
97
|
+
? WorkspaceSlotEnum.WEB
|
|
98
|
+
: WorkspaceSlotEnum.API
|
|
94
99
|
|
|
95
100
|
let targetPath
|
|
96
101
|
let isCurrentDir
|
|
@@ -109,6 +114,13 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
|
|
|
109
114
|
process.exit(1)
|
|
110
115
|
}
|
|
111
116
|
|
|
117
|
+
if (isCurrentDir && inWorkspace && workspaceRoot) {
|
|
118
|
+
console.error(chalk.red('\n✗ Cannot init workspace root as a service (create .)\n'))
|
|
119
|
+
console.error(chalk.gray(' Use xry create <name> to add api/web/mobile project'))
|
|
120
|
+
console.error(chalk.gray(' Or xry create <name> --workspace to scaffold a new workspace\n'))
|
|
121
|
+
process.exit(1)
|
|
122
|
+
}
|
|
123
|
+
|
|
112
124
|
if (inWorkspace) {
|
|
113
125
|
const version = readCliPackageJson().version
|
|
114
126
|
printCommandHeader({ cliName, command: 'create (workspace link)', version })
|
|
@@ -5,10 +5,10 @@ import { resolveDistLayout } from '../helpers/project-artifacts.mjs'
|
|
|
5
5
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
6
6
|
import {
|
|
7
7
|
getInstalledCoreVersion,
|
|
8
|
-
getProjectRoot,
|
|
9
8
|
readCliPackageJson,
|
|
10
9
|
readProjectPackageJson,
|
|
11
10
|
} from '../helpers/project-root.mjs'
|
|
11
|
+
import { requireServiceRoot, exitOnCliContextError } from '../helpers/cli-context-guard.mjs'
|
|
12
12
|
import { listRuntimeInventory, resolveRuntimeInfo } from '../helpers/runtime-info.mjs'
|
|
13
13
|
import { evaluateVersionBump, getVersionState, resolveCommitVersionHint, resolveVersionBaseline, VERSION_PATTERN } from '../scripts/version-check.mjs'
|
|
14
14
|
import { auditTsconfigAlignment, resolveToolchainPathsFromProject } from '../helpers/toolchain-config.mjs'
|
|
@@ -30,7 +30,13 @@ export function registerDoctorCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
30
30
|
.command('doctor')
|
|
31
31
|
.description(`Check runtime, git, and ${packageDefaults.packageName} alignment`)
|
|
32
32
|
.action(async () => {
|
|
33
|
-
|
|
33
|
+
let root
|
|
34
|
+
try {
|
|
35
|
+
;({ root } = requireServiceRoot(process.cwd(), { cliName, command: 'doctor' }))
|
|
36
|
+
} catch (error) {
|
|
37
|
+
exitOnCliContextError(error)
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
const cliPkg = readCliPackageJson()
|
|
35
41
|
const projectPkg = readProjectPackageJson(root)
|
|
36
42
|
const core = getInstalledCoreVersion(root)
|
package/x/bin/commands/hooks.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import chalk from 'chalk'
|
|
|
3
3
|
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
4
4
|
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
5
5
|
import { installGitHooks, isGitHookInstalled } from '../scripts/install-git-hooks.mjs'
|
|
6
|
-
import {
|
|
6
|
+
import { requireServiceRoot, exitOnCliContextError } from '../helpers/cli-context-guard.mjs'
|
|
7
7
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
8
8
|
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
9
9
|
|
|
@@ -25,7 +25,7 @@ export function registerHooksCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
25
25
|
.description('Write pre-commit hook to .git/hooks (core repo + services)')
|
|
26
26
|
.action(() => {
|
|
27
27
|
try {
|
|
28
|
-
const root =
|
|
28
|
+
const { root } = requireServiceRoot(process.cwd(), { cliName, command: 'hooks install' })
|
|
29
29
|
printCommandHeader({ cliName, command: 'hooks install', version: readCliPackageJson().version })
|
|
30
30
|
|
|
31
31
|
if (isGitHookInstalled(root)) {
|
|
@@ -39,6 +39,7 @@ export function registerHooksCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
39
39
|
console.log(chalk.gray(` checker: ${result.scriptPath}`))
|
|
40
40
|
console.log(chalk.dim('\n Runs on git commit when package.json version changes.\n'))
|
|
41
41
|
} catch (error) {
|
|
42
|
+
exitOnCliContextError(error)
|
|
42
43
|
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
43
44
|
process.exit(1)
|
|
44
45
|
}
|
|
@@ -48,7 +49,12 @@ export function registerHooksCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
48
49
|
.command('status')
|
|
49
50
|
.description(`Show whether ${packageDefaults.packageName} pre-commit hook is installed`)
|
|
50
51
|
.action(() => {
|
|
51
|
-
|
|
52
|
+
let root
|
|
53
|
+
try {
|
|
54
|
+
;({ root } = requireServiceRoot(process.cwd(), { cliName, command: 'hooks status' }))
|
|
55
|
+
} catch (error) {
|
|
56
|
+
exitOnCliContextError(error)
|
|
57
|
+
}
|
|
52
58
|
printCommandHeader({ cliName, command: 'hooks status', version: readCliPackageJson().version })
|
|
53
59
|
const installed = isGitHookInstalled(root)
|
|
54
60
|
console.log(` pre-commit: ${installed ? chalk.green('installed') : chalk.yellow('not installed')}`)
|
|
@@ -6,6 +6,7 @@ import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
|
6
6
|
import { resolveProjectContext } from '../helpers/project-context.mjs'
|
|
7
7
|
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
8
8
|
import { ensureTmpSchemaVersion } from '../helpers/tmp-schema-version.mjs'
|
|
9
|
+
import { ProjectScopeKindEnum } from '../helpers/cli-enums.mjs'
|
|
9
10
|
|
|
10
11
|
function line(label, value) {
|
|
11
12
|
console.log(` ${label.padEnd(20)}${value}`)
|
|
@@ -74,7 +75,7 @@ export function registerProjectInfoCommand(cli, { cliName = CLI_PRIMARY_NAME } =
|
|
|
74
75
|
line('slot', ctx.selfEntry.slot)
|
|
75
76
|
}
|
|
76
77
|
|
|
77
|
-
if (ctx.workspaceEntries.length > 0 && ctx.kind ===
|
|
78
|
+
if (ctx.workspaceEntries.length > 0 && ctx.kind === ProjectScopeKindEnum.WORKSPACE_ROOT) {
|
|
78
79
|
console.log(chalk.bold.cyan(`\n Linked projects (${ctx.workspaceEntries.length})`))
|
|
79
80
|
for (const entry of ctx.workspaceEntries) {
|
|
80
81
|
console.log(` • ${chalk.white(entry.name)} [${entry.type}] ${chalk.gray(entry.path)}`)
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
shouldDelegatePackageBuild,
|
|
19
19
|
summarizeBuildPlan,
|
|
20
20
|
} from '../helpers/build-config.mjs'
|
|
21
|
-
import {
|
|
21
|
+
import { runWithServiceRoot } from '../helpers/cli-context-guard.mjs'
|
|
22
22
|
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
23
23
|
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
24
24
|
import { ensureTmpFile, relativeFromRoot } from '../helpers/tmp-layout.mjs'
|
|
@@ -41,100 +41,104 @@ function resolveTestTarget(root) {
|
|
|
41
41
|
export function registerProjectCommands(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
42
42
|
cli
|
|
43
43
|
.command('dev')
|
|
44
|
-
.description('Watch TypeScript entry with dev env files')
|
|
44
|
+
.description('Watch TypeScript entry with dev env files (service repo only — not workspace root)')
|
|
45
45
|
.action(() => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
runWithServiceRoot((root) => {
|
|
47
|
+
const { layout, runtime } = readTmpBuildContext(root)
|
|
48
|
+
const entry = resolveDevEntry(root, layout)
|
|
49
|
+
const envFiles = resolveEnvFiles(layout.pathsAbs.environments, ['.global.env', '.dev.env'])
|
|
50
|
+
const envArgs = envFiles.map((file) => `--env-file=${file}`).join(' ')
|
|
51
|
+
const runner = resolveRuntimeRunner(runtime)
|
|
52
|
+
|
|
53
|
+
printCommandHeader({ cliName, command: 'dev', version: readCliPackageJson().version })
|
|
54
|
+
console.log(chalk.gray(` root: ${root}`))
|
|
55
|
+
console.log(chalk.gray(` runtime: ${runtime}`))
|
|
56
|
+
console.log(chalk.gray(` entry: ${entry} (.ts)\n`))
|
|
57
|
+
runInProject(root, `${runner} --watch ${envArgs} ${entry}`.trim())
|
|
58
|
+
}, { cliName, command: 'dev' })
|
|
58
59
|
})
|
|
59
60
|
|
|
60
61
|
cli
|
|
61
62
|
.command('build')
|
|
62
|
-
.description('Bundle to dist/ (
|
|
63
|
+
.description('Bundle to dist/ (service repo only — not workspace root)')
|
|
63
64
|
.action(() => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
65
|
+
runWithServiceRoot((root) => {
|
|
66
|
+
ensureProjectArtifacts(root, { writeToolchain: true, writeManifest: true })
|
|
67
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
|
|
68
|
+
const { layout, build, runtime, bundler } = readTmpBuildContext(root)
|
|
69
|
+
|
|
70
|
+
printCommandHeader({ cliName, command: 'build', version: readCliPackageJson().version })
|
|
71
|
+
console.log(chalk.gray(` root: ${root}`))
|
|
72
|
+
|
|
73
|
+
if (shouldDelegatePackageBuild(pkg)) {
|
|
74
|
+
runInProject(root, `${resolvePackageScriptRunner(runtime)} build`)
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const plan = summarizeBuildPlan(root, layout, build, runtime)
|
|
79
|
+
const steps = isCorePackageName(pkg.name)
|
|
80
|
+
? resolveCoreBuildSteps(root, plan.distRel, build)
|
|
81
|
+
: resolveServiceBuildSteps(root, layout, build, runtime)
|
|
82
|
+
console.log(chalk.gray(` mode: ${isCorePackageName(pkg.name) ? 'core entries' : 'service tsconfig + tmp overrides'}`))
|
|
83
|
+
console.log(chalk.gray(` runtime: ${runtime}`))
|
|
84
|
+
if (!isCorePackageName(pkg.name)) {
|
|
85
|
+
console.log(chalk.gray(` bundler: ${plan.bundler || bundler}`))
|
|
86
|
+
}
|
|
87
|
+
if (plan.tsconfigRel) {
|
|
88
|
+
console.log(chalk.gray(` tsconfig: ${plan.tsconfigRel}`))
|
|
89
|
+
}
|
|
90
|
+
console.log(chalk.gray(` dist: ${plan.distRel}/ (${plan.distSource})`))
|
|
91
|
+
console.log(chalk.gray(` glob: ${plan.entryGlobs.join(', ')} (${plan.globSource})`))
|
|
92
|
+
if (plan.typecheck) console.log(chalk.gray(' typecheck: tsc --noEmit'))
|
|
93
|
+
if (plan.declarations) console.log(chalk.gray(' declarations: tsc --emitDeclarationOnly'))
|
|
94
|
+
if (plan.sourcemap !== 'false') console.log(chalk.gray(` sourcemap: ${plan.sourcemap}`))
|
|
95
|
+
if (plan.minify && plan.minify !== 'off') console.log(chalk.gray(` minify: ${plan.minify}`))
|
|
96
|
+
console.log('')
|
|
97
|
+
|
|
98
|
+
runInProject(root, steps.join(' && '))
|
|
99
|
+
}, { cliName, command: 'build' })
|
|
98
100
|
})
|
|
99
101
|
|
|
100
102
|
cli
|
|
101
103
|
.command('start')
|
|
102
104
|
.alias('start:dist')
|
|
103
|
-
.description('Run dist/index.js with prod env files')
|
|
105
|
+
.description('Run dist/index.js with prod env files (service repo only)')
|
|
104
106
|
.action(() => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
107
|
+
runWithServiceRoot((root) => {
|
|
108
|
+
const { layout, build, runtime } = readTmpBuildContext(root)
|
|
109
|
+
const entryAbs = resolveDistEntryAbs(root, layout, build)
|
|
110
|
+
|
|
111
|
+
if (!fs.existsSync(entryAbs)) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
`Build output not found: ${path.relative(root, entryAbs)}. Run ${cliName} build first.`,
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const entry = relativeFromRoot(root, entryAbs)
|
|
118
|
+
const envFiles = resolveEnvFiles(layout.pathsAbs.environments, ['.global.env', '.prod.env'])
|
|
119
|
+
const envArgs = envFiles.map((file) => `--env-file=${file}`).join(' ')
|
|
120
|
+
const runner = resolveRuntimeRunner(runtime)
|
|
121
|
+
|
|
122
|
+
printCommandHeader({ cliName, command: 'start', version: readCliPackageJson().version })
|
|
123
|
+
console.log(chalk.gray(` root: ${root}`))
|
|
124
|
+
console.log(chalk.gray(` runtime: ${runtime}`))
|
|
125
|
+
console.log(chalk.gray(` entry: ${entry} (.js)\n`))
|
|
126
|
+
runInProject(root, `${runner} ${envArgs} ${entry}`.trim())
|
|
127
|
+
}, { cliName, command: 'start' })
|
|
125
128
|
})
|
|
126
129
|
|
|
127
130
|
cli
|
|
128
131
|
.command('test')
|
|
129
|
-
.description('Run tests from tmp.yml paths')
|
|
132
|
+
.description('Run tests from tmp.yml paths (service repo only)')
|
|
130
133
|
.action(() => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
runWithServiceRoot((root) => {
|
|
135
|
+
const { runtime } = readTmpBuildContext(root)
|
|
136
|
+
const target = resolveTestTarget(root)
|
|
137
|
+
|
|
138
|
+
printCommandHeader({ cliName, command: 'test', version: readCliPackageJson().version })
|
|
139
|
+
console.log(chalk.gray(` runtime: ${runtime}`))
|
|
140
|
+
console.log(chalk.gray(` target: ${target}\n`))
|
|
141
|
+
runInProject(root, resolveTestCommand(runtime, target))
|
|
142
|
+
}, { cliName, command: 'test' })
|
|
139
143
|
})
|
|
140
144
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
|
-
import { readCliPackageJson, readProjectPackageJson
|
|
2
|
+
import { readCliPackageJson, readProjectPackageJson } from '../helpers/project-root.mjs'
|
|
3
|
+
import { requireServiceRoot, exitOnCliContextError } from '../helpers/cli-context-guard.mjs'
|
|
3
4
|
import { compareSemver, getVersionState, resolveVersionBaseline, runTagRelease } from '../scripts/version-check.mjs'
|
|
4
5
|
import { CLI_PRIMARY_NAME, PACKAGE_NAME } from '../helpers/cli-identity.mjs'
|
|
5
6
|
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
@@ -13,16 +14,18 @@ export function registerTagCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
13
14
|
.option('--skip-prepare', 'Skip lint, test, and build:prod (core only)')
|
|
14
15
|
.action(async (options) => {
|
|
15
16
|
try {
|
|
17
|
+
const { root } = requireServiceRoot(process.cwd(), { cliName, command: 'tag' })
|
|
16
18
|
await runTagRelease({
|
|
17
19
|
dryRun: options.dryRun,
|
|
18
20
|
requireClean: options.strictClean,
|
|
19
21
|
skipPrepare: options.skipPrepare,
|
|
20
|
-
root
|
|
22
|
+
root,
|
|
21
23
|
})
|
|
22
24
|
if (!options.dryRun) {
|
|
23
25
|
console.log(chalk.green('\n✓ Tag pushed.\n'))
|
|
24
26
|
}
|
|
25
27
|
} catch (error) {
|
|
28
|
+
if (error?.name === 'CliContextError') exitOnCliContextError(error)
|
|
26
29
|
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
27
30
|
process.exit(1)
|
|
28
31
|
}
|
|
@@ -35,7 +38,7 @@ export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
35
38
|
.description('Show CLI and project package versions')
|
|
36
39
|
.action(() => {
|
|
37
40
|
try {
|
|
38
|
-
const root =
|
|
41
|
+
const { root } = requireServiceRoot(process.cwd(), { cliName, command: 'version' })
|
|
39
42
|
const cliPkg = readCliPackageJson()
|
|
40
43
|
const projectPkg = readProjectPackageJson(root)
|
|
41
44
|
const state = getVersionState('HEAD', root)
|
|
@@ -61,6 +64,7 @@ export function registerVersionCommand(cli, { cliName = CLI_PRIMARY_NAME } = {})
|
|
|
61
64
|
console.log(` working tree: ${state.isClean ? chalk.green('clean') : chalk.yellow('dirty')}`)
|
|
62
65
|
console.log('')
|
|
63
66
|
} catch (error) {
|
|
67
|
+
if (error?.name === 'CliContextError') exitOnCliContextError(error)
|
|
64
68
|
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
65
69
|
process.exit(1)
|
|
66
70
|
}
|
package/x/bin/commands/sync.mjs
CHANGED
|
@@ -25,6 +25,9 @@ export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
printCommandHeader({ cliName, command: 'sync', version: coreVersion })
|
|
28
|
+
if (scope.warnAllIgnored) {
|
|
29
|
+
console.log(chalk.yellow(' note: not in a workspace — --all ignored, syncing this repo only'))
|
|
30
|
+
}
|
|
28
31
|
console.log(chalk.gray(` scope: ${scope.label} (${scope.mode})`))
|
|
29
32
|
if (scope.workspaceRoot) {
|
|
30
33
|
console.log(chalk.gray(` workspace: ${scope.workspaceRoot}`))
|
package/x/bin/commands/tmp.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import yaml from 'yaml'
|
|
|
4
4
|
|
|
5
5
|
import { printCommandFooter, printCommandHeader } from '../helpers/banner.mjs'
|
|
6
6
|
import { resolveObjWithHandlebars } from '../helpers/index.mjs'
|
|
7
|
-
import {
|
|
7
|
+
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
8
8
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
9
9
|
import {
|
|
10
10
|
ensureTmpFile,
|
|
@@ -15,55 +15,76 @@ 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 {
|
|
18
|
+
import { getCliContext } from '../helpers/cli-context-guard.mjs'
|
|
19
|
+
import { ensureOuterWorkspaceTmp } from '../helpers/workspace-tmp.mjs'
|
|
20
|
+
import { ProjectScopeKindEnum } from '../helpers/cli-enums.mjs'
|
|
21
|
+
|
|
22
|
+
function ensureTmpForContext(ctx) {
|
|
23
|
+
if (ctx.kind === ProjectScopeKindEnum.WORKSPACE_ROOT) {
|
|
24
|
+
const outer = ensureOuterWorkspaceTmp(ctx.workspaceRoot)
|
|
25
|
+
return {
|
|
26
|
+
tmpFilePath: outer.tmpFilePath,
|
|
27
|
+
created: outer.created,
|
|
28
|
+
layout: null,
|
|
29
|
+
schema: outer.schema,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const result = ensureTmpFile(ctx.projectRoot)
|
|
33
|
+
return { ...result, schema: ensureTmpSchemaVersion(result.tmpFilePath) }
|
|
34
|
+
}
|
|
19
35
|
|
|
20
36
|
export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
21
37
|
cli
|
|
22
38
|
.command('tmp')
|
|
23
|
-
.description(
|
|
39
|
+
.description('Ensure tmp.yml for current scope (outer workspace or inner service)')
|
|
24
40
|
.option('--dry-run', 'Show target path without writing')
|
|
25
41
|
.action((options) => {
|
|
26
|
-
const
|
|
42
|
+
const ctx = getCliContext()
|
|
27
43
|
const version = readCliPackageJson().version
|
|
44
|
+
const root = ctx.kind === ProjectScopeKindEnum.WORKSPACE_ROOT ? ctx.workspaceRoot : ctx.projectRoot
|
|
28
45
|
|
|
29
46
|
if (options.dryRun) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
const target = ctx.kind === ProjectScopeKindEnum.WORKSPACE_ROOT
|
|
48
|
+
? `${ctx.workspaceRoot}/tmp.yml`
|
|
49
|
+
: (resolveTmpLayoutOrDefaults(root).tmpFilePath ?? ownerTmpFilePath(root))
|
|
33
50
|
|
|
34
51
|
printCommandHeader({ cliName, command: 'tmp (dry-run)', version })
|
|
52
|
+
console.log(chalk.gray(` scope: ${ctx.label}`))
|
|
35
53
|
console.log(chalk.gray(` root: ${root}`))
|
|
36
|
-
console.log(` ${
|
|
54
|
+
console.log(` ${fs.existsSync(target) ? 'exists' : 'would create'}: ${target}`)
|
|
37
55
|
printCommandFooter({ version })
|
|
38
56
|
return
|
|
39
57
|
}
|
|
40
58
|
|
|
41
|
-
const result =
|
|
59
|
+
const result = ensureTmpForContext(ctx)
|
|
42
60
|
const rel = relativeFromRoot(root, result.tmpFilePath)
|
|
43
|
-
const schema = ensureTmpSchemaVersion(result.tmpFilePath)
|
|
44
61
|
|
|
45
|
-
const ctx = resolveProjectContext()
|
|
46
62
|
printCommandHeader({ cliName, command: 'tmp', version })
|
|
47
63
|
console.log(chalk.gray(` scope: ${ctx.label}`))
|
|
48
64
|
console.log(chalk.gray(` root: ${root}`))
|
|
49
65
|
console.log(result.created ? chalk.green(` created ${rel}`) : chalk.gray(` ok ${rel}`))
|
|
66
|
+
|
|
50
67
|
const schemaVersion = readTmpSchemaVersion(result.tmpFilePath)
|
|
51
68
|
if (schemaVersion) {
|
|
52
|
-
const schemaLabel = schema
|
|
69
|
+
const schemaLabel = result.schema?.patched
|
|
53
70
|
? chalk.green(` end.version → ${schemaVersion} (schema)`)
|
|
54
71
|
: chalk.gray(` end.version: ${schemaVersion} (schema)`)
|
|
55
72
|
console.log(schemaLabel)
|
|
56
73
|
}
|
|
57
74
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
75
|
+
if (ctx.kind !== ProjectScopeKindEnum.WORKSPACE_ROOT) {
|
|
76
|
+
try {
|
|
77
|
+
const tmp = yaml.parse(fs.readFileSync(result.tmpFilePath, 'utf8'))
|
|
78
|
+
const summary = summarizeLoaders(resolveObjWithHandlebars(tmp, tmp))
|
|
79
|
+
console.log(chalk.gray(` root: ${result.layout?.rootFolderPath ?? 'x'} · project: ${summary.project ?? '-'}`))
|
|
80
|
+
if (summary.items?.length) {
|
|
81
|
+
console.log(chalk.gray(` loaders: ${formatLoaderSummary(summary)}`))
|
|
82
|
+
}
|
|
83
|
+
} catch {
|
|
84
|
+
// summary optional
|
|
64
85
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
86
|
+
} else {
|
|
87
|
+
console.log(chalk.gray(' outer workspace tmp — layout only (no loaders)'))
|
|
67
88
|
}
|
|
68
89
|
|
|
69
90
|
printCommandFooter({ version })
|
|
@@ -175,9 +175,9 @@ function normalizeGlobalType(value) {
|
|
|
175
175
|
var TMP_FILE = "tmp.yml";
|
|
176
176
|
var SKIP_DIRS = new Set(["node_modules", ".git", "dist", ".turbo", "coverage"]);
|
|
177
177
|
var DEFAULT_FOLDER_STRUCTURE = {
|
|
178
|
-
api: "api",
|
|
179
|
-
web: "web",
|
|
180
|
-
mobile: "mobile"
|
|
178
|
+
["api" /* API */]: "api",
|
|
179
|
+
["web" /* WEB */]: "web",
|
|
180
|
+
["mobile" /* MOBILE */]: "mobile"
|
|
181
181
|
};
|
|
182
182
|
function parseScalar(raw) {
|
|
183
183
|
const trimmed = raw.trim();
|
|
@@ -215,22 +215,22 @@ function parseFolderStructure(text) {
|
|
|
215
215
|
throw new Error("configs.folder-structure.admin removed — put admin panels under web/ (e.g. web/admin-ui)");
|
|
216
216
|
}
|
|
217
217
|
const readSlot = (key) => {
|
|
218
|
-
const scalar = fsBlock.match(new RegExp(`^[
|
|
218
|
+
const scalar = fsBlock.match(new RegExp(`^[ \\t]+${key}:\\s*(.+?)(?:\\s+#.*)?$`, "m"));
|
|
219
219
|
if (scalar)
|
|
220
220
|
return parseScalar(scalar[1]);
|
|
221
221
|
return DEFAULT_FOLDER_STRUCTURE[key];
|
|
222
222
|
};
|
|
223
223
|
return {
|
|
224
|
-
api: readSlot("api"),
|
|
225
|
-
web: readSlot("web"),
|
|
226
|
-
mobile: readSlot("mobile")
|
|
224
|
+
["api" /* API */]: readSlot("api" /* API */),
|
|
225
|
+
["web" /* WEB */]: readSlot("web" /* WEB */),
|
|
226
|
+
["mobile" /* MOBILE */]: readSlot("mobile" /* MOBILE */)
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
229
|
function workspaceDiscoverySlots(fsMap) {
|
|
230
230
|
return [
|
|
231
|
-
{ slot: "api"
|
|
232
|
-
{ slot: "web"
|
|
233
|
-
{ slot: "mobile"
|
|
231
|
+
{ slot: "api" /* API */, folder: fsMap["api" /* API */], frontendOnly: false },
|
|
232
|
+
{ slot: "web" /* WEB */, folder: fsMap["web" /* WEB */], frontendOnly: true },
|
|
233
|
+
{ slot: "mobile" /* MOBILE */, folder: fsMap["mobile" /* MOBILE */], frontendOnly: true }
|
|
234
234
|
];
|
|
235
235
|
}
|
|
236
236
|
function entryName(meta) {
|
|
@@ -246,7 +246,7 @@ function entryType(meta, slot) {
|
|
|
246
246
|
return null;
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
if (slot === "api")
|
|
249
|
+
if (slot === "api" /* API */)
|
|
250
250
|
return "api-service" /* API_SERVICE */;
|
|
251
251
|
return null;
|
|
252
252
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import chalk from 'chalk'
|
|
5
|
+
|
|
6
|
+
import { resolveProjectContext } from './project-context.mjs'
|
|
7
|
+
import { ProjectScopeKindEnum } from './cli-enums.mjs'
|
|
8
|
+
|
|
9
|
+
export class CliContextError extends Error {
|
|
10
|
+
constructor(message, { hints = [] } = {}) {
|
|
11
|
+
super(message)
|
|
12
|
+
this.name = 'CliContextError'
|
|
13
|
+
this.hints = hints
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getCliContext(startDir = process.cwd()) {
|
|
18
|
+
return resolveProjectContext(startDir)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function requireServiceRoot(startDir = process.cwd(), { cliName = 'xry', command = 'dev' } = {}) {
|
|
22
|
+
const ctx = getCliContext(startDir)
|
|
23
|
+
|
|
24
|
+
if (ctx.kind === ProjectScopeKindEnum.WORKSPACE_ROOT) {
|
|
25
|
+
const examples = (ctx.workspaceEntries ?? [])
|
|
26
|
+
.slice(0, 3)
|
|
27
|
+
.map((entry) => {
|
|
28
|
+
const rel = path.relative(ctx.cwd, entry.path) || entry.path
|
|
29
|
+
return `cd ${rel} && ${cliName} ${command}`
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
throw new CliContextError(
|
|
33
|
+
'Workspace root is layout-only (outer tmp.yml) — not a runnable service.',
|
|
34
|
+
{
|
|
35
|
+
hints: [
|
|
36
|
+
'Use a linked project under api/, web/, or mobile/',
|
|
37
|
+
...examples,
|
|
38
|
+
`${cliName} project — list linked services`,
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const pkgPath = path.join(ctx.projectRoot, 'package.json')
|
|
45
|
+
if (!fs.existsSync(pkgPath)) {
|
|
46
|
+
throw new CliContextError(
|
|
47
|
+
`No service package.json here (${ctx.projectRoot}).`,
|
|
48
|
+
{
|
|
49
|
+
hints: [
|
|
50
|
+
`${cliName} project — see current scope`,
|
|
51
|
+
'cd into api/<service>, web/<app>, or mobile/<app>',
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return { ctx, root: ctx.projectRoot }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function exitOnCliContextError(error) {
|
|
61
|
+
if (error?.name !== 'CliContextError') throw error
|
|
62
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
63
|
+
for (const hint of error.hints ?? []) {
|
|
64
|
+
console.error(chalk.gray(` → ${hint}`))
|
|
65
|
+
}
|
|
66
|
+
console.error('')
|
|
67
|
+
process.exit(1)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function runWithServiceRoot(fn, { cliName = 'xry', command = 'dev' } = {}) {
|
|
71
|
+
try {
|
|
72
|
+
const { root, ctx } = requireServiceRoot(process.cwd(), { cliName, command })
|
|
73
|
+
return fn(root, ctx)
|
|
74
|
+
} catch (error) {
|
|
75
|
+
exitOnCliContextError(error)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Mirrors source/utils/models/enums — keep in sync with TS enums. */
|
|
2
|
+
|
|
3
|
+
export const GlobalTypeEnum = {
|
|
4
|
+
WORKSPACE: 'workspace',
|
|
5
|
+
API_SERVICE: 'api-service',
|
|
6
|
+
FRONTEND: 'frontend',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const ProjectScopeKindEnum = {
|
|
10
|
+
CORE_LIBRARY: 'core-library',
|
|
11
|
+
WORKSPACE_ROOT: 'workspace-root',
|
|
12
|
+
WORKSPACE_SERVICE: 'workspace-service',
|
|
13
|
+
STANDALONE_SERVICE: 'standalone-service',
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const WorkspaceSlotEnum = {
|
|
17
|
+
API: 'api',
|
|
18
|
+
WEB: 'web',
|
|
19
|
+
MOBILE: 'mobile',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const LoaderBootProfileEnum = {
|
|
23
|
+
API_SERVICE: 'api-service',
|
|
24
|
+
FRONTEND: 'frontend',
|
|
25
|
+
WORKSPACE: 'workspace',
|
|
26
|
+
MINIMAL: 'minimal',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const InfraLoaderEnum = {
|
|
30
|
+
KAFKA: 'kafka',
|
|
31
|
+
REDIS: 'redis',
|
|
32
|
+
MONGO: 'mongo',
|
|
33
|
+
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
findWorkspaceRoot,
|
|
7
7
|
readTmpFile,
|
|
8
8
|
} from './workspace-resolve.mjs'
|
|
9
|
+
import { WorkspaceSlotEnum } from './cli-enums.mjs'
|
|
9
10
|
|
|
10
11
|
function resolveReal(input) {
|
|
11
12
|
const resolved = path.resolve(input)
|
|
@@ -24,9 +25,9 @@ function resolveReal(input) {
|
|
|
24
25
|
*
|
|
25
26
|
* @param {string} projectName Folder name or `.` for current directory
|
|
26
27
|
* @param {string | undefined} targetDir Optional parent path (default: cwd)
|
|
27
|
-
* @param {{ slot?: '
|
|
28
|
+
* @param {{ slot?: import('./cli-enums.mjs').WorkspaceSlotEnum[keyof import('./cli-enums.mjs').WorkspaceSlotEnum] }} options
|
|
28
29
|
*/
|
|
29
|
-
export function resolveCreateTarget(projectName, targetDir, { slot =
|
|
30
|
+
export function resolveCreateTarget(projectName, targetDir, { slot = WorkspaceSlotEnum.API } = {}) {
|
|
30
31
|
const cwd = process.cwd()
|
|
31
32
|
const name = String(projectName ?? '').trim()
|
|
32
33
|
|
|
@@ -7,8 +7,7 @@ import { isCorePackageRoot } from './tmp-layout.mjs'
|
|
|
7
7
|
import { findEntries, findWorkspaceRoot, workspaceProjectName } from './workspace-resolve.mjs'
|
|
8
8
|
import { getInstalledCoreVersion, readCliPackageJson, readProjectPackageJson, resolveProjectRoot } from './project-root.mjs'
|
|
9
9
|
import { readTmpSchemaVersion, TMP_SCHEMA_VERSION } from './tmp-schema-version.mjs'
|
|
10
|
-
|
|
11
|
-
const WORKSPACE_TYPE = 'workspace'
|
|
10
|
+
import { GlobalTypeEnum, ProjectScopeKindEnum } from './cli-enums.mjs'
|
|
12
11
|
|
|
13
12
|
function readTmpMeta(tmpFilePath) {
|
|
14
13
|
if (!tmpFilePath || !fs.existsSync(tmpFilePath)) return null
|
|
@@ -46,7 +45,7 @@ export function resolveProjectContext(startDir = process.cwd()) {
|
|
|
46
45
|
const innerTmpPath = path.join(coreRoot, packageDefaults.packageRootFolder, `${packageDefaults.tmpBaseName}${packageDefaults.tmpExtension}`)
|
|
47
46
|
const innerMeta = readTmpMeta(fs.existsSync(innerTmpPath) ? innerTmpPath : null)
|
|
48
47
|
return {
|
|
49
|
-
kind:
|
|
48
|
+
kind: ProjectScopeKindEnum.CORE_LIBRARY,
|
|
50
49
|
label: '@xrystal/core (library source)',
|
|
51
50
|
cwd,
|
|
52
51
|
projectRoot: coreRoot,
|
|
@@ -92,13 +91,13 @@ export function resolveProjectContext(startDir = process.cwd()) {
|
|
|
92
91
|
}
|
|
93
92
|
const innerMeta = innerTmpPath ? readTmpMeta(innerTmpPath) : null
|
|
94
93
|
|
|
95
|
-
let kind =
|
|
94
|
+
let kind = ProjectScopeKindEnum.STANDALONE_SERVICE
|
|
96
95
|
let label = 'Standalone service'
|
|
97
|
-
if (atWorkspaceRoot && outerMeta?.globalType ===
|
|
98
|
-
kind =
|
|
96
|
+
if (atWorkspaceRoot && outerMeta?.globalType === GlobalTypeEnum.WORKSPACE) {
|
|
97
|
+
kind = ProjectScopeKindEnum.WORKSPACE_ROOT
|
|
99
98
|
label = 'Workspace root (outer tmp.yml)'
|
|
100
|
-
} else if (workspaceRoot && outerMeta?.globalType ===
|
|
101
|
-
kind =
|
|
99
|
+
} else if (workspaceRoot && outerMeta?.globalType === GlobalTypeEnum.WORKSPACE) {
|
|
100
|
+
kind = ProjectScopeKindEnum.WORKSPACE_SERVICE
|
|
102
101
|
label = 'Workspace linked service (inner x/tmp.yml)'
|
|
103
102
|
}
|
|
104
103
|
|
|
@@ -106,12 +105,13 @@ export function resolveProjectContext(startDir = process.cwd()) {
|
|
|
106
105
|
const selfEntry = workspaceEntries.find((e) => path.resolve(e.path) === path.resolve(projectRoot))
|
|
107
106
|
|
|
108
107
|
const hints = []
|
|
109
|
-
if (kind ===
|
|
108
|
+
if (kind === ProjectScopeKindEnum.WORKSPACE_ROOT) {
|
|
110
109
|
hints.push('Outer tmp: ./tmp.yml · inner tmp: each api|web|mobile project (admin → web/)')
|
|
111
110
|
hints.push('xry sync — all linked projects + ~/.xrystal registry')
|
|
112
|
-
hints.push('xry
|
|
111
|
+
hints.push('xry create <name> — adds api/<name> (or --web / --mobile)')
|
|
112
|
+
hints.push('dev/build/start — run inside a linked service, not here')
|
|
113
113
|
hints.push('xry workspaces — global registry (~/.xrystal), not repo tmp files')
|
|
114
|
-
} else if (kind ===
|
|
114
|
+
} else if (kind === ProjectScopeKindEnum.WORKSPACE_SERVICE) {
|
|
115
115
|
hints.push(`Outer workspace: ${workspaceRoot}`)
|
|
116
116
|
hints.push('xry sync — this service only (tsconfig + @xrystal/core pin)')
|
|
117
117
|
hints.push('xry sync --all — every linked api/web/mobile project + registry')
|
|
@@ -2,24 +2,37 @@ import fs from 'node:fs'
|
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
|
|
4
4
|
import { packageDefaults, packageRoot } from '../paths.mjs'
|
|
5
|
+
import { findWorkspaceRoot } from './workspace-resolve.mjs'
|
|
5
6
|
|
|
6
7
|
export function getProjectRoot(startDir = process.cwd()) {
|
|
7
8
|
return resolveProjectRoot(startDir)
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
/** Nearest package.json with @xrystal/core — never walks above workspace root. */
|
|
10
12
|
export function resolveProjectRoot(startDir = process.cwd()) {
|
|
11
13
|
let dir = path.resolve(startDir)
|
|
14
|
+
const workspaceRoot = findWorkspaceRoot(dir)
|
|
15
|
+
const floor = workspaceRoot ? path.resolve(workspaceRoot) : null
|
|
12
16
|
|
|
13
|
-
while (
|
|
17
|
+
while (true) {
|
|
14
18
|
const pkgPath = path.join(dir, 'package.json')
|
|
15
19
|
if (fs.existsSync(pkgPath)) {
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
try {
|
|
21
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
22
|
+
if (pkg.name === packageDefaults.packageName) return dir
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies }
|
|
25
|
+
if (deps[packageDefaults.packageName]) return dir
|
|
26
|
+
} catch {
|
|
27
|
+
// ignore malformed package.json
|
|
28
|
+
}
|
|
21
29
|
}
|
|
22
|
-
|
|
30
|
+
|
|
31
|
+
if (floor && path.resolve(dir) === floor) break
|
|
32
|
+
|
|
33
|
+
const parent = path.dirname(dir)
|
|
34
|
+
if (parent === dir) break
|
|
35
|
+
dir = parent
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
return path.resolve(startDir)
|
|
@@ -32,9 +32,14 @@ export function resolveSyncScope(cwd = process.cwd(), options = {}) {
|
|
|
32
32
|
targetRoot: projectRoot,
|
|
33
33
|
workspaceRoot: null,
|
|
34
34
|
entries: [{ path: projectRoot, name: path.basename(projectRoot), type: 'project' }],
|
|
35
|
+
warnAllIgnored: wantAll,
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
if (atWorkspaceRoot && wantSelf) {
|
|
40
|
+
throw new Error('At workspace root use plain sync (all linked projects). --self is for inner api/web/mobile folders.')
|
|
41
|
+
}
|
|
42
|
+
|
|
38
43
|
const entries = findEntries(workspaceRoot)
|
|
39
44
|
|
|
40
45
|
if (atWorkspaceRoot || wantAll) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readTmpDependsBlock, readTmpGlobalBlock } from './tmp-schema.mjs'
|
|
2
2
|
import { packageDefaults } from './package-defaults.mjs'
|
|
3
|
+
import { GlobalTypeEnum, InfraLoaderEnum } from './cli-enums.mjs'
|
|
3
4
|
const PROTOCOL_ALIASES = {
|
|
4
5
|
http: 'http',
|
|
5
6
|
https: 'https',
|
|
@@ -30,11 +31,11 @@ function summarizeInfraLoaders(depends) {
|
|
|
30
31
|
return fallback
|
|
31
32
|
}
|
|
32
33
|
const type = depends?.globalType ?? null
|
|
33
|
-
const isFrontend = type ===
|
|
34
|
+
const isFrontend = type === GlobalTypeEnum.FRONTEND
|
|
34
35
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
[InfraLoaderEnum.KAFKA]: readEnabled(InfraLoaderEnum.KAFKA, !isFrontend),
|
|
37
|
+
[InfraLoaderEnum.REDIS]: readEnabled(InfraLoaderEnum.REDIS, !isFrontend),
|
|
38
|
+
[InfraLoaderEnum.MONGO]: readEnabled(InfraLoaderEnum.MONGO, !isFrontend),
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -81,7 +82,7 @@ export function formatLoaderSummary(summary) {
|
|
|
81
82
|
`protocols: ${summary.protocols.join(', ')}`,
|
|
82
83
|
]
|
|
83
84
|
if (summary.infra) {
|
|
84
|
-
const flags = [
|
|
85
|
+
const flags = [InfraLoaderEnum.KAFKA, InfraLoaderEnum.REDIS, InfraLoaderEnum.MONGO]
|
|
85
86
|
.map((key) => `${key}:${summary.infra[key] ? 'on' : 'off'}`)
|
|
86
87
|
.join(' · ')
|
|
87
88
|
lines.push(`infra: ${flags}`)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import { ensureTmpSchemaVersion } from './tmp-schema-version.mjs'
|
|
5
|
+
import { workspaceProjectName, workspaceTmpTemplate } from './workspace-resolve.mjs'
|
|
6
|
+
|
|
7
|
+
export function ensureOuterWorkspaceTmp(workspaceRoot, { projectName } = {}) {
|
|
8
|
+
const resolved = path.resolve(workspaceRoot)
|
|
9
|
+
const tmpPath = path.join(resolved, 'tmp.yml')
|
|
10
|
+
let created = false
|
|
11
|
+
|
|
12
|
+
if (!fs.existsSync(tmpPath)) {
|
|
13
|
+
const name = projectName ?? workspaceProjectName(resolved)
|
|
14
|
+
fs.writeFileSync(tmpPath, workspaceTmpTemplate(name))
|
|
15
|
+
created = true
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const schema = ensureTmpSchemaVersion(tmpPath)
|
|
19
|
+
return { tmpFilePath: tmpPath, created, schema, workspaceRoot: resolved }
|
|
20
|
+
}
|
|
@@ -2,6 +2,7 @@ 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
4
|
import { readInfraLoaderEnabled } from '../../utils/helpers/loader-options/index.js';
|
|
5
|
+
import { InfraLoaderEnum } from '../../utils/models/enums/index.js';
|
|
5
6
|
import { resolveMongoConnectOptions } from './resolve-connect.js';
|
|
6
7
|
export default class MongoForCore {
|
|
7
8
|
#client = null;
|
|
@@ -26,7 +27,7 @@ export default class MongoForCore {
|
|
|
26
27
|
syncFromTmp = async () => {
|
|
27
28
|
await this.teardown();
|
|
28
29
|
const loaders = this.#resolveDependsLoaders();
|
|
29
|
-
if (!readInfraLoaderEnabled(loaders,
|
|
30
|
+
if (!readInfraLoaderEnabled(loaders, InfraLoaderEnum.MONGO, true)) {
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
if (this.#configs.all.isMongoPassive) {
|
|
@@ -2,6 +2,7 @@ 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
4
|
import { readInfraLoaderEnabled } from '../../utils/helpers/loader-options/index.js';
|
|
5
|
+
import { InfraLoaderEnum } from '../../utils/models/enums/index.js';
|
|
5
6
|
import { resolveRedisSocketOptions } from './resolve-socket.js';
|
|
6
7
|
export default class RedisForCore {
|
|
7
8
|
#client = null;
|
|
@@ -25,7 +26,7 @@ export default class RedisForCore {
|
|
|
25
26
|
syncFromTmp = async () => {
|
|
26
27
|
await this.teardown();
|
|
27
28
|
const loaders = this.#resolveDependsLoaders();
|
|
28
|
-
if (!readInfraLoaderEnabled(loaders,
|
|
29
|
+
if (!readInfraLoaderEnabled(loaders, InfraLoaderEnum.REDIS, true)) {
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
32
|
if (this.#configs.all.isRedisPassive) {
|
package/x/dist/project/index.js
CHANGED
|
@@ -4,7 +4,8 @@ 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';
|
|
7
|
+
import { isInfraLoaderEnabled, resolveLoaderBootPlan } from '../utils/helpers/tmp/loader-boot-plan.js';
|
|
8
|
+
import { InfraLoaderEnum } from '../utils/models/enums/index.js';
|
|
8
9
|
import { resolveTmpRuntimeConfigs } from '../utils/helpers/tmp/tmp-schema.js';
|
|
9
10
|
export { ensureCoreTmpEntry, isCorePackageRoot } from '../utils/helpers/core/tmp-layout.js';
|
|
10
11
|
export { getTmpSnapshot } from '../utils/helpers/tmp/tmp-loader.js';
|
|
@@ -24,11 +25,11 @@ function buildLoaderInitList(plan, coreRef) {
|
|
|
24
25
|
{ service: System, props: { core: coreRef } },
|
|
25
26
|
{ service: Configs, props: {} },
|
|
26
27
|
];
|
|
27
|
-
if (plan.
|
|
28
|
+
if (isInfraLoaderEnabled(plan, InfraLoaderEnum.KAFKA))
|
|
28
29
|
entries.push({ service: KafkaForCore, props: {} });
|
|
29
|
-
if (plan.
|
|
30
|
+
if (isInfraLoaderEnabled(plan, InfraLoaderEnum.REDIS))
|
|
30
31
|
entries.push({ service: RedisForCore, props: {} });
|
|
31
|
-
if (plan.
|
|
32
|
+
if (isInfraLoaderEnabled(plan, InfraLoaderEnum.MONGO))
|
|
32
33
|
entries.push({ service: MongoForCore, props: {} });
|
|
33
34
|
entries.push({ service: Logger, props: {} }, { service: Events, props: {} }, { service: Localizations, props: {} }, { service: DtoRuntime, props: {} }, { service: Controller, props: {} }, { service: Clients, props: {} });
|
|
34
35
|
return entries;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { InfraLoaderEnum } from '../../../utils/models/enums';
|
|
1
2
|
export type InfraLoaderOptions = {
|
|
2
3
|
enabled: boolean;
|
|
3
4
|
};
|
|
4
|
-
export
|
|
5
|
+
export type InfraLoaderFlags = Record<InfraLoaderEnum, boolean>;
|
|
6
|
+
export declare function createInfraLoaderFlags(overrides?: Partial<InfraLoaderFlags>): InfraLoaderFlags;
|
|
7
|
+
export declare function readInfraLoaderEnabled(loaders: Record<string, unknown> | undefined, key: InfraLoaderEnum, defaultEnabled: boolean): boolean;
|
|
8
|
+
export declare function readInfraLoaderFlags(loaders: Record<string, unknown> | undefined, defaults: InfraLoaderFlags): InfraLoaderFlags;
|
|
5
9
|
export { readKafkaLoaderOptions, type KafkaLoaderOptions } from '../../../utils/helpers/kafka-loader-options';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InfraLoaderEnum } from '../../../utils/models/enums/index.js';
|
|
1
2
|
function readOptionsBlock(loaders, key) {
|
|
2
3
|
const block = loaders?.[key];
|
|
3
4
|
if (typeof block !== 'object' || block === null)
|
|
@@ -7,10 +8,24 @@ function readOptionsBlock(loaders, key) {
|
|
|
7
8
|
return {};
|
|
8
9
|
return options;
|
|
9
10
|
}
|
|
11
|
+
export function createInfraLoaderFlags(overrides = {}) {
|
|
12
|
+
return {
|
|
13
|
+
[InfraLoaderEnum.KAFKA]: overrides[InfraLoaderEnum.KAFKA] ?? false,
|
|
14
|
+
[InfraLoaderEnum.REDIS]: overrides[InfraLoaderEnum.REDIS] ?? false,
|
|
15
|
+
[InfraLoaderEnum.MONGO]: overrides[InfraLoaderEnum.MONGO] ?? false,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
10
18
|
export function readInfraLoaderEnabled(loaders, key, defaultEnabled) {
|
|
11
19
|
const options = readOptionsBlock(loaders, key);
|
|
12
20
|
if ('enabled' in options)
|
|
13
21
|
return options.enabled !== false;
|
|
14
22
|
return defaultEnabled;
|
|
15
23
|
}
|
|
24
|
+
export function readInfraLoaderFlags(loaders, defaults) {
|
|
25
|
+
return {
|
|
26
|
+
[InfraLoaderEnum.KAFKA]: readInfraLoaderEnabled(loaders, InfraLoaderEnum.KAFKA, defaults[InfraLoaderEnum.KAFKA]),
|
|
27
|
+
[InfraLoaderEnum.REDIS]: readInfraLoaderEnabled(loaders, InfraLoaderEnum.REDIS, defaults[InfraLoaderEnum.REDIS]),
|
|
28
|
+
[InfraLoaderEnum.MONGO]: readInfraLoaderEnabled(loaders, InfraLoaderEnum.MONGO, defaults[InfraLoaderEnum.MONGO]),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
16
31
|
export { readKafkaLoaderOptions } from '../../../utils/helpers/kafka-loader-options/index.js';
|
|
@@ -2,7 +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,
|
|
5
|
+
export { resolveLoaderBootPlan, isInfraLoaderEnabled, LoaderBootProfileEnum, InfraLoaderEnum, type LoaderBootPlan, } from '../../../utils/helpers/tmp/loader-boot-plan';
|
|
6
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';
|
|
7
7
|
export { loadSeedFromBundledTmp, seedFromTmp, type SeedFromTmp, } from '../../../utils/helpers/tmp/seed-from-tmp';
|
|
8
8
|
export { normalizeLayoutPaths, type LayoutPaths, } from '../../../utils/helpers/tmp/path-normalize';
|
|
@@ -2,7 +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
|
+
export { resolveLoaderBootPlan, isInfraLoaderEnabled, LoaderBootProfileEnum, InfraLoaderEnum, } from '../../../utils/helpers/tmp/loader-boot-plan.js';
|
|
6
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';
|
|
7
7
|
export { loadSeedFromBundledTmp, seedFromTmp, } from '../../../utils/helpers/tmp/seed-from-tmp.js';
|
|
8
8
|
export { normalizeLayoutPaths, } from '../../../utils/helpers/tmp/path-normalize.js';
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { GlobalTypeEnum, InfraLoaderEnum, LoaderBootProfileEnum } from '../../../utils/models/enums';
|
|
2
|
+
import { type InfraLoaderFlags } from '../../../utils/helpers/loader-options';
|
|
1
3
|
import type { TmpRuntimeConfigs } from '../../../utils/helpers/tmp/tmp-schema';
|
|
2
|
-
export
|
|
4
|
+
export { LoaderBootProfileEnum, InfraLoaderEnum } from '../../../utils/models/enums';
|
|
3
5
|
export type LoaderBootPlan = {
|
|
4
|
-
profile:
|
|
5
|
-
projectType:
|
|
6
|
-
|
|
7
|
-
redis: boolean;
|
|
8
|
-
mongo: boolean;
|
|
6
|
+
profile: LoaderBootProfileEnum;
|
|
7
|
+
projectType: GlobalTypeEnum | undefined;
|
|
8
|
+
infra: InfraLoaderFlags;
|
|
9
9
|
};
|
|
10
10
|
export declare function resolveLoaderBootPlan(configs?: TmpRuntimeConfigs | null): LoaderBootPlan;
|
|
11
|
+
export declare function isInfraLoaderEnabled(plan: LoaderBootPlan, loader: InfraLoaderEnum): boolean;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import { GlobalTypeEnum } from '../../../utils/models/enums/index.js';
|
|
2
|
-
import {
|
|
1
|
+
import { GlobalTypeEnum, InfraLoaderEnum, LoaderBootProfileEnum } from '../../../utils/models/enums/index.js';
|
|
2
|
+
import { createInfraLoaderFlags, readInfraLoaderFlags, } from '../../../utils/helpers/loader-options/index.js';
|
|
3
|
+
export { LoaderBootProfileEnum, InfraLoaderEnum } from '../../../utils/models/enums/index.js';
|
|
4
|
+
const FRONTEND_INFRA_DEFAULTS = createInfraLoaderFlags();
|
|
5
|
+
const API_SERVICE_INFRA_DEFAULTS = createInfraLoaderFlags({
|
|
6
|
+
[InfraLoaderEnum.KAFKA]: true,
|
|
7
|
+
[InfraLoaderEnum.REDIS]: true,
|
|
8
|
+
[InfraLoaderEnum.MONGO]: true,
|
|
9
|
+
});
|
|
10
|
+
const WORKSPACE_INFRA_DEFAULTS = createInfraLoaderFlags();
|
|
3
11
|
function loadersBlock(configs) {
|
|
4
12
|
const loaders = configs?.depends?.loaders;
|
|
5
13
|
return typeof loaders === 'object' && loaders !== null ? loaders : undefined;
|
|
@@ -9,28 +17,31 @@ export function resolveLoaderBootPlan(configs) {
|
|
|
9
17
|
const loaders = loadersBlock(configs);
|
|
10
18
|
if (type === GlobalTypeEnum.FRONTEND) {
|
|
11
19
|
return {
|
|
12
|
-
profile:
|
|
20
|
+
profile: LoaderBootProfileEnum.FRONTEND,
|
|
13
21
|
projectType: type,
|
|
14
|
-
|
|
15
|
-
redis: readInfraLoaderEnabled(loaders, 'redis', false),
|
|
16
|
-
mongo: readInfraLoaderEnabled(loaders, 'mongo', false),
|
|
22
|
+
infra: readInfraLoaderFlags(loaders, FRONTEND_INFRA_DEFAULTS),
|
|
17
23
|
};
|
|
18
24
|
}
|
|
19
25
|
if (type === GlobalTypeEnum.WORKSPACE) {
|
|
20
26
|
return {
|
|
21
|
-
profile:
|
|
27
|
+
profile: LoaderBootProfileEnum.WORKSPACE,
|
|
22
28
|
projectType: type,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
infra: { ...WORKSPACE_INFRA_DEFAULTS },
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (type === GlobalTypeEnum.API_SERVICE) {
|
|
33
|
+
return {
|
|
34
|
+
profile: LoaderBootProfileEnum.API_SERVICE,
|
|
35
|
+
projectType: type,
|
|
36
|
+
infra: readInfraLoaderFlags(loaders, API_SERVICE_INFRA_DEFAULTS),
|
|
26
37
|
};
|
|
27
38
|
}
|
|
28
|
-
const kafkaOpts = readKafkaLoaderOptions(loaders);
|
|
29
39
|
return {
|
|
30
|
-
profile:
|
|
31
|
-
projectType: type
|
|
32
|
-
|
|
33
|
-
redis: readInfraLoaderEnabled(loaders, 'redis', true),
|
|
34
|
-
mongo: readInfraLoaderEnabled(loaders, 'mongo', true),
|
|
40
|
+
profile: LoaderBootProfileEnum.MINIMAL,
|
|
41
|
+
projectType: type,
|
|
42
|
+
infra: readInfraLoaderFlags(loaders, API_SERVICE_INFRA_DEFAULTS),
|
|
35
43
|
};
|
|
36
44
|
}
|
|
45
|
+
export function isInfraLoaderEnabled(plan, loader) {
|
|
46
|
+
return plan.infra[loader];
|
|
47
|
+
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { GlobalTypeEnum } from '../../../utils/models/enums';
|
|
1
|
+
import { GlobalTypeEnum, WorkspaceSlotEnum } from '../../../utils/models/enums';
|
|
2
2
|
export declare const TMP_FILE = "tmp.yml";
|
|
3
3
|
export declare const SKIP_DIRS: Set<string>;
|
|
4
|
-
export type FolderStructure =
|
|
5
|
-
api: string;
|
|
6
|
-
web: string;
|
|
7
|
-
mobile: string;
|
|
8
|
-
};
|
|
4
|
+
export type FolderStructure = Record<WorkspaceSlotEnum, string>;
|
|
9
5
|
export declare const DEFAULT_FOLDER_STRUCTURE: FolderStructure;
|
|
10
6
|
export type TmpMeta = {
|
|
11
7
|
path: string;
|
|
@@ -17,7 +13,7 @@ export type TmpMeta = {
|
|
|
17
13
|
pathsRoot?: string;
|
|
18
14
|
folderStructure: FolderStructure;
|
|
19
15
|
};
|
|
20
|
-
export type WorkspaceSlot =
|
|
16
|
+
export type WorkspaceSlot = WorkspaceSlotEnum;
|
|
21
17
|
export type WorkspaceEntry = {
|
|
22
18
|
name: string;
|
|
23
19
|
type: GlobalTypeEnum.API_SERVICE | GlobalTypeEnum.FRONTEND;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { GlobalTypeEnum } from '../../../utils/models/enums/index.js';
|
|
3
|
+
import { GlobalTypeEnum, WorkspaceSlotEnum } from '../../../utils/models/enums/index.js';
|
|
4
4
|
import { normalizeGlobalType } from '../../../utils/helpers/tmp/tmp-schema.js';
|
|
5
5
|
export const TMP_FILE = 'tmp.yml';
|
|
6
6
|
export const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', '.turbo', 'coverage']);
|
|
7
7
|
export const DEFAULT_FOLDER_STRUCTURE = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
[WorkspaceSlotEnum.API]: 'api',
|
|
9
|
+
[WorkspaceSlotEnum.WEB]: 'web',
|
|
10
|
+
[WorkspaceSlotEnum.MOBILE]: 'mobile',
|
|
11
11
|
};
|
|
12
12
|
function parseScalar(raw) {
|
|
13
13
|
const trimmed = raw.trim();
|
|
@@ -47,22 +47,22 @@ export function parseFolderStructure(text) {
|
|
|
47
47
|
throw new Error('configs.folder-structure.admin removed — put admin panels under web/ (e.g. web/admin-ui)');
|
|
48
48
|
}
|
|
49
49
|
const readSlot = (key) => {
|
|
50
|
-
const scalar = fsBlock.match(new RegExp(`^[
|
|
50
|
+
const scalar = fsBlock.match(new RegExp(`^[ \\t]+${key}:\\s*(.+?)(?:\\s+#.*)?$`, 'm'));
|
|
51
51
|
if (scalar)
|
|
52
52
|
return parseScalar(scalar[1]);
|
|
53
53
|
return DEFAULT_FOLDER_STRUCTURE[key];
|
|
54
54
|
};
|
|
55
55
|
return {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
[WorkspaceSlotEnum.API]: readSlot(WorkspaceSlotEnum.API),
|
|
57
|
+
[WorkspaceSlotEnum.WEB]: readSlot(WorkspaceSlotEnum.WEB),
|
|
58
|
+
[WorkspaceSlotEnum.MOBILE]: readSlot(WorkspaceSlotEnum.MOBILE),
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
export function workspaceDiscoverySlots(fsMap) {
|
|
62
62
|
return [
|
|
63
|
-
{ slot:
|
|
64
|
-
{ slot:
|
|
65
|
-
{ slot:
|
|
63
|
+
{ slot: WorkspaceSlotEnum.API, folder: fsMap[WorkspaceSlotEnum.API], frontendOnly: false },
|
|
64
|
+
{ slot: WorkspaceSlotEnum.WEB, folder: fsMap[WorkspaceSlotEnum.WEB], frontendOnly: true },
|
|
65
|
+
{ slot: WorkspaceSlotEnum.MOBILE, folder: fsMap[WorkspaceSlotEnum.MOBILE], frontendOnly: true },
|
|
66
66
|
];
|
|
67
67
|
}
|
|
68
68
|
export { normalizeGlobalType } from '../../../utils/helpers/tmp/tmp-schema.js';
|
|
@@ -80,7 +80,7 @@ export function entryType(meta, slot) {
|
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
if (slot ===
|
|
83
|
+
if (slot === WorkspaceSlotEnum.API)
|
|
84
84
|
return GlobalTypeEnum.API_SERVICE;
|
|
85
85
|
return null;
|
|
86
86
|
}
|
|
@@ -26,6 +26,32 @@ export declare enum GlobalTypeEnum {
|
|
|
26
26
|
API_SERVICE = "api-service",
|
|
27
27
|
FRONTEND = "frontend"
|
|
28
28
|
}
|
|
29
|
+
/** Runtime loader boot profile derived from tmp global.type (+ minimal fallback). */
|
|
30
|
+
export declare enum LoaderBootProfileEnum {
|
|
31
|
+
API_SERVICE = "api-service",
|
|
32
|
+
FRONTEND = "frontend",
|
|
33
|
+
WORKSPACE = "workspace",
|
|
34
|
+
MINIMAL = "minimal"
|
|
35
|
+
}
|
|
36
|
+
/** Infra loaders gated by tmp depends.loaders.<key>.options.enabled */
|
|
37
|
+
export declare enum InfraLoaderEnum {
|
|
38
|
+
KAFKA = "kafka",
|
|
39
|
+
REDIS = "redis",
|
|
40
|
+
MONGO = "mongo"
|
|
41
|
+
}
|
|
42
|
+
/** CLI / tooling project scope (xry project). */
|
|
43
|
+
export declare enum ProjectScopeKindEnum {
|
|
44
|
+
CORE_LIBRARY = "core-library",
|
|
45
|
+
WORKSPACE_ROOT = "workspace-root",
|
|
46
|
+
WORKSPACE_SERVICE = "workspace-service",
|
|
47
|
+
STANDALONE_SERVICE = "standalone-service"
|
|
48
|
+
}
|
|
49
|
+
/** Workspace folder-structure slots (outer tmp.yml). */
|
|
50
|
+
export declare enum WorkspaceSlotEnum {
|
|
51
|
+
API = "api",
|
|
52
|
+
WEB = "web",
|
|
53
|
+
MOBILE = "mobile"
|
|
54
|
+
}
|
|
29
55
|
export declare enum RuntimeEnum {
|
|
30
56
|
BUN = "bun",
|
|
31
57
|
NODE = "node"
|
|
@@ -30,6 +30,36 @@ export var GlobalTypeEnum;
|
|
|
30
30
|
GlobalTypeEnum["API_SERVICE"] = "api-service";
|
|
31
31
|
GlobalTypeEnum["FRONTEND"] = "frontend";
|
|
32
32
|
})(GlobalTypeEnum || (GlobalTypeEnum = {}));
|
|
33
|
+
/** Runtime loader boot profile derived from tmp global.type (+ minimal fallback). */
|
|
34
|
+
export var LoaderBootProfileEnum;
|
|
35
|
+
(function (LoaderBootProfileEnum) {
|
|
36
|
+
LoaderBootProfileEnum["API_SERVICE"] = "api-service";
|
|
37
|
+
LoaderBootProfileEnum["FRONTEND"] = "frontend";
|
|
38
|
+
LoaderBootProfileEnum["WORKSPACE"] = "workspace";
|
|
39
|
+
LoaderBootProfileEnum["MINIMAL"] = "minimal";
|
|
40
|
+
})(LoaderBootProfileEnum || (LoaderBootProfileEnum = {}));
|
|
41
|
+
/** Infra loaders gated by tmp depends.loaders.<key>.options.enabled */
|
|
42
|
+
export var InfraLoaderEnum;
|
|
43
|
+
(function (InfraLoaderEnum) {
|
|
44
|
+
InfraLoaderEnum["KAFKA"] = "kafka";
|
|
45
|
+
InfraLoaderEnum["REDIS"] = "redis";
|
|
46
|
+
InfraLoaderEnum["MONGO"] = "mongo";
|
|
47
|
+
})(InfraLoaderEnum || (InfraLoaderEnum = {}));
|
|
48
|
+
/** CLI / tooling project scope (xry project). */
|
|
49
|
+
export var ProjectScopeKindEnum;
|
|
50
|
+
(function (ProjectScopeKindEnum) {
|
|
51
|
+
ProjectScopeKindEnum["CORE_LIBRARY"] = "core-library";
|
|
52
|
+
ProjectScopeKindEnum["WORKSPACE_ROOT"] = "workspace-root";
|
|
53
|
+
ProjectScopeKindEnum["WORKSPACE_SERVICE"] = "workspace-service";
|
|
54
|
+
ProjectScopeKindEnum["STANDALONE_SERVICE"] = "standalone-service";
|
|
55
|
+
})(ProjectScopeKindEnum || (ProjectScopeKindEnum = {}));
|
|
56
|
+
/** Workspace folder-structure slots (outer tmp.yml). */
|
|
57
|
+
export var WorkspaceSlotEnum;
|
|
58
|
+
(function (WorkspaceSlotEnum) {
|
|
59
|
+
WorkspaceSlotEnum["API"] = "api";
|
|
60
|
+
WorkspaceSlotEnum["WEB"] = "web";
|
|
61
|
+
WorkspaceSlotEnum["MOBILE"] = "mobile";
|
|
62
|
+
})(WorkspaceSlotEnum || (WorkspaceSlotEnum = {}));
|
|
33
63
|
export var RuntimeEnum;
|
|
34
64
|
(function (RuntimeEnum) {
|
|
35
65
|
RuntimeEnum["BUN"] = "bun";
|