@xrystal/core 3.53.0 → 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 +6 -1
- package/x/bin/commands/project-info.mjs +2 -1
- package/x/bin/commands/tmp.mjs +5 -4
- package/x/bin/helpers/.generated/workspace.mjs +11 -11
- package/x/bin/helpers/cli-context-guard.mjs +2 -1
- 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 +9 -10
- package/x/bin/helpers/tmp-config.mjs +6 -5
- 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
|
|
@@ -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)}`)
|
package/x/bin/commands/tmp.mjs
CHANGED
|
@@ -17,9 +17,10 @@ import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
|
17
17
|
import { ensureTmpSchemaVersion, readTmpSchemaVersion } from '../helpers/tmp-schema-version.mjs'
|
|
18
18
|
import { getCliContext } from '../helpers/cli-context-guard.mjs'
|
|
19
19
|
import { ensureOuterWorkspaceTmp } from '../helpers/workspace-tmp.mjs'
|
|
20
|
+
import { ProjectScopeKindEnum } from '../helpers/cli-enums.mjs'
|
|
20
21
|
|
|
21
22
|
function ensureTmpForContext(ctx) {
|
|
22
|
-
if (ctx.kind ===
|
|
23
|
+
if (ctx.kind === ProjectScopeKindEnum.WORKSPACE_ROOT) {
|
|
23
24
|
const outer = ensureOuterWorkspaceTmp(ctx.workspaceRoot)
|
|
24
25
|
return {
|
|
25
26
|
tmpFilePath: outer.tmpFilePath,
|
|
@@ -40,10 +41,10 @@ export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
40
41
|
.action((options) => {
|
|
41
42
|
const ctx = getCliContext()
|
|
42
43
|
const version = readCliPackageJson().version
|
|
43
|
-
const root = ctx.kind ===
|
|
44
|
+
const root = ctx.kind === ProjectScopeKindEnum.WORKSPACE_ROOT ? ctx.workspaceRoot : ctx.projectRoot
|
|
44
45
|
|
|
45
46
|
if (options.dryRun) {
|
|
46
|
-
const target = ctx.kind ===
|
|
47
|
+
const target = ctx.kind === ProjectScopeKindEnum.WORKSPACE_ROOT
|
|
47
48
|
? `${ctx.workspaceRoot}/tmp.yml`
|
|
48
49
|
: (resolveTmpLayoutOrDefaults(root).tmpFilePath ?? ownerTmpFilePath(root))
|
|
49
50
|
|
|
@@ -71,7 +72,7 @@ export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
71
72
|
console.log(schemaLabel)
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
if (ctx.kind !==
|
|
75
|
+
if (ctx.kind !== ProjectScopeKindEnum.WORKSPACE_ROOT) {
|
|
75
76
|
try {
|
|
76
77
|
const tmp = yaml.parse(fs.readFileSync(result.tmpFilePath, 'utf8'))
|
|
77
78
|
const summary = summarizeLoaders(resolveObjWithHandlebars(tmp, tmp))
|
|
@@ -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
|
}
|
|
@@ -4,6 +4,7 @@ import path from 'node:path'
|
|
|
4
4
|
import chalk from 'chalk'
|
|
5
5
|
|
|
6
6
|
import { resolveProjectContext } from './project-context.mjs'
|
|
7
|
+
import { ProjectScopeKindEnum } from './cli-enums.mjs'
|
|
7
8
|
|
|
8
9
|
export class CliContextError extends Error {
|
|
9
10
|
constructor(message, { hints = [] } = {}) {
|
|
@@ -20,7 +21,7 @@ export function getCliContext(startDir = process.cwd()) {
|
|
|
20
21
|
export function requireServiceRoot(startDir = process.cwd(), { cliName = 'xry', command = 'dev' } = {}) {
|
|
21
22
|
const ctx = getCliContext(startDir)
|
|
22
23
|
|
|
23
|
-
if (ctx.kind ===
|
|
24
|
+
if (ctx.kind === ProjectScopeKindEnum.WORKSPACE_ROOT) {
|
|
24
25
|
const examples = (ctx.workspaceEntries ?? [])
|
|
25
26
|
.slice(0, 3)
|
|
26
27
|
.map((entry) => {
|
|
@@ -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,13 +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
111
|
hints.push('xry create <name> — adds api/<name> (or --web / --mobile)')
|
|
113
112
|
hints.push('dev/build/start — run inside a linked service, not here')
|
|
114
113
|
hints.push('xry workspaces — global registry (~/.xrystal), not repo tmp files')
|
|
115
|
-
} else if (kind ===
|
|
114
|
+
} else if (kind === ProjectScopeKindEnum.WORKSPACE_SERVICE) {
|
|
116
115
|
hints.push(`Outer workspace: ${workspaceRoot}`)
|
|
117
116
|
hints.push('xry sync — this service only (tsconfig + @xrystal/core pin)')
|
|
118
117
|
hints.push('xry sync --all — every linked api/web/mobile project + registry')
|
|
@@ -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}`)
|
|
@@ -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";
|