@xrystal/core 3.51.5 → 3.52.0
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/README.md +35 -1
- package/package.json +1 -1
- package/x/bin/commands/create.mjs +44 -0
- package/x/bin/commands/projects.mjs +53 -0
- package/x/bin/commands/sync.mjs +49 -1
- package/x/bin/commands/tmp.mjs +1 -1
- package/x/bin/helpers/.generated/.generated-from +2 -0
- package/x/bin/helpers/.generated/seed-from-tmp.mjs +25 -31
- package/x/bin/helpers/.generated/tmp-schema.mjs +156 -96
- package/x/bin/helpers/.generated/workspace.mjs +402 -0
- package/x/bin/helpers/.generated/xrystal-home-registry.mjs +310 -0
- package/x/bin/helpers/build-config.mjs +3 -2
- package/x/bin/helpers/cli-help.mjs +3 -1
- package/x/bin/helpers/project-artifacts.mjs +9 -0
- package/x/bin/helpers/tmp-config.mjs +13 -12
- package/x/bin/helpers/tmp-layout.mjs +28 -52
- package/x/bin/helpers/tmp-schema.mjs +9 -3
- package/x/bin/helpers/workspace-resolve.mjs +11 -0
- package/x/bin/helpers/workspace-scaffold.mjs +23 -0
- package/x/bin/helpers/xrystal-registry.mjs +13 -0
- package/x/bin/main-cli.js +2 -0
- package/x/dist/index.js +5 -1
- package/x/dist/loader/clients/index.js +22 -1
- package/x/dist/loader/configs/index.js +97 -1
- package/x/dist/loader/controller/index.js +267 -1
- package/x/dist/loader/dto/index.js +92 -1
- package/x/dist/loader/events/index.js +39 -1
- package/x/dist/loader/index.js +13 -1
- package/x/dist/loader/kafka/index.js +142 -1
- package/x/dist/loader/kafka/resolve-ssl.js +23 -1
- package/x/dist/loader/localizations/index.js +46 -1
- package/x/dist/loader/logger/index.js +229 -2
- package/x/dist/loader/mongo/index.js +52 -1
- package/x/dist/loader/mongo/resolve-connect.js +16 -1
- package/x/dist/loader/redis/index.js +57 -1
- package/x/dist/loader/redis/resolve-socket.js +31 -1
- package/x/dist/loader/registry/index.js +1 -1
- package/x/dist/loader/service/index.js +7 -1
- package/x/dist/loader/system/index.js +26 -1
- package/x/dist/project/index.js +51 -1
- package/x/dist/utils/constants/defaults.json +3 -1
- package/x/dist/utils/constants/index.d.ts +1 -0
- package/x/dist/utils/constants/index.js +42 -1
- package/x/dist/utils/constants/package-root.js +6 -1
- package/x/dist/utils/helpers/configs/index.js +1 -1
- package/x/dist/utils/helpers/context/controller-store.js +12 -1
- package/x/dist/utils/helpers/context/index.js +24 -1
- package/x/dist/utils/helpers/core/handlebars-resolve.js +15 -1
- package/x/dist/utils/helpers/core/index.js +46 -1
- package/x/dist/utils/helpers/core/paths.js +78 -1
- package/x/dist/utils/helpers/core/tmp-layout.d.ts +4 -4
- package/x/dist/utils/helpers/core/tmp-layout.js +229 -1
- package/x/dist/utils/helpers/date/index.js +48 -1
- package/x/dist/utils/helpers/dispatch/index.js +53 -1
- package/x/dist/utils/helpers/dto/index.js +10 -1
- package/x/dist/utils/helpers/filters/index.js +44 -1
- package/x/dist/utils/helpers/framework/index.js +18 -1
- package/x/dist/utils/helpers/handlers/adapters.js +41 -1
- package/x/dist/utils/helpers/handlers/execute.js +82 -1
- package/x/dist/utils/helpers/handlers/index.js +31 -1
- package/x/dist/utils/helpers/hash/crypto.js +22 -1
- package/x/dist/utils/helpers/id/index.js +24 -1
- package/x/dist/utils/helpers/index.d.ts +1 -0
- package/x/dist/utils/helpers/index.js +28 -1
- package/x/dist/utils/helpers/ip/index.js +21 -1
- package/x/dist/utils/helpers/is/index.js +35 -1
- package/x/dist/utils/helpers/kafka-loader-options/index.js +14 -1
- package/x/dist/utils/helpers/locales/index.js +82 -1
- package/x/dist/utils/helpers/logger-layer/index.js +33 -1
- package/x/dist/utils/helpers/math/index.js +14 -1
- package/x/dist/utils/helpers/middleware/index.js +36 -1
- package/x/dist/utils/helpers/node-env/index.js +20 -1
- package/x/dist/utils/helpers/objects/index.js +55 -1
- package/x/dist/utils/helpers/path/index.js +5 -1
- package/x/dist/utils/helpers/path/resolve-alias-path.d.ts +1 -1
- package/x/dist/utils/helpers/path/resolve-alias-path.js +62 -1
- package/x/dist/utils/helpers/protocol/index.d.ts +1 -1
- package/x/dist/utils/helpers/protocol/index.js +100 -1
- package/x/dist/utils/helpers/protocol/options.js +13 -1
- package/x/dist/utils/helpers/regex/checkSpecialRegexControl.js +3 -1
- package/x/dist/utils/helpers/registry/index.d.ts +6 -0
- package/x/dist/utils/helpers/registry/index.js +103 -1
- package/x/dist/utils/helpers/runtime/dto-access.js +5 -1
- package/x/dist/utils/helpers/runtime/dto-types.js +1 -1
- package/x/dist/utils/helpers/runtime/index.js +2 -1
- package/x/dist/utils/helpers/runtime/shutdown.js +36 -1
- package/x/dist/utils/helpers/state/index.js +185 -1
- package/x/dist/utils/helpers/state/props-from-tmp.js +46 -1
- package/x/dist/utils/helpers/state/request-key-guard.js +43 -1
- package/x/dist/utils/helpers/state/scopes.js +69 -1
- package/x/dist/utils/helpers/string/index.js +9 -1
- package/x/dist/utils/helpers/timer/index.js +5 -1
- package/x/dist/utils/helpers/tmp/index.d.ts +2 -2
- package/x/dist/utils/helpers/tmp/index.js +8 -1
- package/x/dist/utils/helpers/tmp/loader-tmp-sync.js +14 -1
- package/x/dist/utils/helpers/tmp/path-normalize.js +27 -1
- package/x/dist/utils/helpers/tmp/runtime-tmp.js +42 -1
- package/x/dist/utils/helpers/tmp/seed-from-tmp.d.ts +2 -2
- package/x/dist/utils/helpers/tmp/seed-from-tmp.js +62 -1
- package/x/dist/utils/helpers/tmp/tmp-interpolate.js +22 -1
- package/x/dist/utils/helpers/tmp/tmp-loader.js +56 -1
- package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +35 -23
- package/x/dist/utils/helpers/tmp/tmp-schema.js +211 -1
- package/x/dist/utils/helpers/tmp/tmp-watch.js +23 -1
- package/x/dist/utils/helpers/tmp/toolchain-heal.js +157 -2
- package/x/dist/utils/helpers/validates/index.js +20 -1
- package/x/dist/utils/helpers/workspace/index.d.ts +42 -0
- package/x/dist/utils/helpers/workspace/index.js +222 -0
- package/x/dist/utils/helpers/xrystal-home/registry.d.ts +32 -0
- package/x/dist/utils/helpers/xrystal-home/registry.js +92 -0
- package/x/dist/utils/index.js +3 -1
- package/x/dist/utils/models/classes/class.clients.js +142 -1
- package/x/dist/utils/models/classes/class.interfaces.js +10 -1
- package/x/dist/utils/models/classes/class.service-locator.js +16 -1
- package/x/dist/utils/models/classes/class.tmp-file-loader.js +61 -1
- package/x/dist/utils/models/classes/class.x.js +181 -1
- package/x/dist/utils/models/enums/index.d.ts +9 -1
- package/x/dist/utils/models/enums/index.js +169 -1
- package/x/dist/utils/models/index.js +9 -1
- package/x/dist/utils/models/types/index.js +2 -1
- package/x/tmp.yml +7 -50
package/README.md
CHANGED
|
@@ -3,7 +3,41 @@
|
|
|
3
3
|
> **EN** — Microservice runtime: Express or Elysia HTTP, DI loaders, live `tmp.yml`, standardized API responses.
|
|
4
4
|
> **TR** — Microservice runtime: Express veya Elysia HTTP, DI loader'lar, canlı `tmp.yml`, standart API cevapları.
|
|
5
5
|
|
|
6
|
-
**CLI:** `xry` · **Version:** `3.
|
|
6
|
+
**CLI:** `xry` · **Version:** `3.52.0` · [npm](https://www.npmjs.com/package/@xrystal/core)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Platform services / Platform servisleri
|
|
11
|
+
|
|
12
|
+
**EN:** Consumer microservices in `../services/` — pin `@xrystal/core` to the latest published minor (currently **3.52.0**).
|
|
13
|
+
|
|
14
|
+
**TR:** `../services/` altındaki tüketen microservice'ler — `@xrystal/core` sürümünü npm latest ile hizala (şu an **3.52.0**).
|
|
15
|
+
|
|
16
|
+
| Repo folder | `tmp.yml` name | Role | Service pkg | `@xrystal/core` |
|
|
17
|
+
|-------------|----------------|------|-------------|-----------------|
|
|
18
|
+
| `api-core-svc` | `core` | Core domain API | `1.0.24` | `3.52.0` |
|
|
19
|
+
| `api-cron-svc` | `crons` | Scheduled jobs / Kafka queue worker | `0.1.25` | `3.52.0` |
|
|
20
|
+
| `api-gateway-svc` | `gateway` | Edge gateway, routing, cache, Mongo config | `2.0.49` | `3.52.0` |
|
|
21
|
+
| `api-gpt-svc` | `gpt` | GPT / AI features | `1.0.22` | `3.52.0` |
|
|
22
|
+
| `api-iam-svc` | `iam` | Identity & access management | `0.7.26` | `3.52.0` |
|
|
23
|
+
| `api-log-svc` | `log` | Logging service | `1.0.20` | `3.52.0` |
|
|
24
|
+
| `api-websocket-svc` | `websocket` | WebSocket / realtime | `0.8.31` | `3.52.0` |
|
|
25
|
+
|
|
26
|
+
**SSL / TLS helpers** (since 3.49.0): import from loader subpaths, not `@xrystal/core/utils`:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { resolveKafkaJsSsl } from '@xrystal/core/loader/kafka'
|
|
30
|
+
import { resolveRedisSocketOptions } from '@xrystal/core/loader/redis'
|
|
31
|
+
import { resolveMongoConnectOptions } from '@xrystal/core/loader/mongo'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Update all services / tüm servisleri güncelle:**
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
cd ../services/api-<name>-svc
|
|
38
|
+
bun add @xrystal/core@3.52.0
|
|
39
|
+
bun run build
|
|
40
|
+
```
|
|
7
41
|
|
|
8
42
|
---
|
|
9
43
|
|
package/package.json
CHANGED
|
@@ -16,12 +16,15 @@ import { formatLoaderSummary, summarizeLoaders } from '../helpers/tmp-config.mjs
|
|
|
16
16
|
import { formatCreateHelp, formatCreateCommandHelp, LIST_BULLET } from '../helpers/cli-help.mjs'
|
|
17
17
|
import { setupProjectGitHooks } from '../scripts/install-git-hooks.mjs'
|
|
18
18
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
19
|
+
import { scaffoldWorkspace } from '../helpers/workspace-scaffold.mjs'
|
|
20
|
+
import { syncRegistryFromPath } from '../helpers/xrystal-registry.mjs'
|
|
19
21
|
|
|
20
22
|
export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtimeName, packageManager, installCommand, devCommand }) {
|
|
21
23
|
cli
|
|
22
24
|
.command('create <project-name> [target-path]')
|
|
23
25
|
.description('Scaffold new service from GitHub template')
|
|
24
26
|
.option('-f, --force', 'Allow creating in a non-empty directory')
|
|
27
|
+
.option('--workspace', 'Scaffold multi-repo workspace (root tmp.yml + api/admin/panel/web folders)')
|
|
25
28
|
.action(async (projectName, targetDir, options) => {
|
|
26
29
|
const name = projectName?.trim()
|
|
27
30
|
if (!name) {
|
|
@@ -30,6 +33,47 @@ export function registerCreateCommand(cli, { cliName = CLI_PRIMARY_NAME, runtime
|
|
|
30
33
|
process.exit(1)
|
|
31
34
|
}
|
|
32
35
|
|
|
36
|
+
if (options.workspace) {
|
|
37
|
+
let targetPath
|
|
38
|
+
try {
|
|
39
|
+
if (targetDir) {
|
|
40
|
+
targetPath = path.resolve(process.cwd(), targetDir)
|
|
41
|
+
} else {
|
|
42
|
+
;({ targetPath } = resolveCreateTarget(name, undefined))
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
46
|
+
process.exit(1)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (fs.existsSync(targetPath)) {
|
|
50
|
+
const entries = fs.readdirSync(targetPath)
|
|
51
|
+
if (entries.length > 0 && !options.force) {
|
|
52
|
+
console.error(chalk.red(`\n✗ Target directory is not empty: ${targetPath}`))
|
|
53
|
+
console.error(chalk.gray(' Use --force to proceed anyway.\n'))
|
|
54
|
+
process.exit(1)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const result = scaffoldWorkspace(targetPath, name)
|
|
60
|
+
console.log(chalk.green('\n✓ Workspace ready\n'))
|
|
61
|
+
console.log(chalk.gray(` tmp: ${path.relative(process.cwd(), result.tmpPath) || result.tmpPath}`))
|
|
62
|
+
console.log(chalk.gray(' folders: api/, admin/, web/'))
|
|
63
|
+
console.log(chalk.gray(' link services into api/ (type optional) or admin|web (type: frontend)'))
|
|
64
|
+
console.log(chalk.cyan(`\n cd ${path.relative(process.cwd(), result.root) || result.root}`))
|
|
65
|
+
try {
|
|
66
|
+
syncRegistryFromPath(result.root)
|
|
67
|
+
console.log(chalk.gray(' registered in ~/.xrystal'))
|
|
68
|
+
} catch {}
|
|
69
|
+
console.log(chalk.cyan(` ${cliName} sync\n`))
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error(chalk.red(`\n✗ ${error.message}\n`))
|
|
72
|
+
process.exit(1)
|
|
73
|
+
}
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
33
77
|
let targetPath
|
|
34
78
|
let isCurrentDir
|
|
35
79
|
try {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
|
|
3
|
+
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
4
|
+
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
5
|
+
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
6
|
+
import {
|
|
7
|
+
listRegistryProjects,
|
|
8
|
+
readRegistry,
|
|
9
|
+
resolveXrystalHome,
|
|
10
|
+
syncRegistryFromPath,
|
|
11
|
+
} from '../helpers/xrystal-registry.mjs'
|
|
12
|
+
|
|
13
|
+
export function registerProjectsCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
14
|
+
cli
|
|
15
|
+
.command('projects')
|
|
16
|
+
.description('List workspaces and projects registered under ~/.xrystal')
|
|
17
|
+
.option('--sync', 'Rescan current workspace before listing')
|
|
18
|
+
.action((options) => {
|
|
19
|
+
printCommandHeader({ cliName, command: 'projects', version: readCliPackageJson().version })
|
|
20
|
+
|
|
21
|
+
if (options.sync) {
|
|
22
|
+
try {
|
|
23
|
+
syncRegistryFromPath(process.cwd())
|
|
24
|
+
console.log(chalk.green(' registry synced'))
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.log(chalk.yellow(` sync skipped: ${error.message}`))
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const registry = readRegistry()
|
|
31
|
+
console.log(chalk.gray(` home: ${resolveXrystalHome()}`))
|
|
32
|
+
console.log(chalk.gray(` workspaces: ${registry.workspaces.length}`))
|
|
33
|
+
|
|
34
|
+
if (registry.workspaces.length === 0) {
|
|
35
|
+
console.log(chalk.yellow('\n no workspaces registered — run xry create demo --workspace then xry sync\n'))
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
for (const ws of registry.workspaces) {
|
|
40
|
+
console.log(chalk.cyan(`\n${ws.name}`))
|
|
41
|
+
console.log(chalk.gray(` path: ${ws.path}`))
|
|
42
|
+
if (ws.projects.length === 0) {
|
|
43
|
+
console.log(chalk.gray(' projects: (none linked yet)'))
|
|
44
|
+
continue
|
|
45
|
+
}
|
|
46
|
+
for (const project of ws.projects) {
|
|
47
|
+
const cluster = project.cluster ? chalk.yellow(` cluster=${project.cluster}`) : ''
|
|
48
|
+
console.log(` • ${project.name} [${project.type}] → ${project.path}${cluster}`)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
console.log('')
|
|
52
|
+
})
|
|
53
|
+
}
|
package/x/bin/commands/sync.mjs
CHANGED
|
@@ -4,10 +4,58 @@ import { printCommandHeader } from '../helpers/banner.mjs'
|
|
|
4
4
|
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
5
5
|
import { getProjectRoot, readCliPackageJson } from '../helpers/project-root.mjs'
|
|
6
6
|
import { auditTsconfigAlignment, syncProjectToolchain } from '../helpers/toolchain-config.mjs'
|
|
7
|
+
import { findEntries, findWorkspaceRoot } from '../helpers/workspace-resolve.mjs'
|
|
8
|
+
import { syncCliRuntime } from '../helpers/project-artifacts.mjs'
|
|
9
|
+
import { syncRegistryFromPath } from '../helpers/xrystal-registry.mjs'
|
|
7
10
|
|
|
8
11
|
/** Sync tsconfig include/outDir/@/* from project tmp.yml. */
|
|
9
12
|
export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
10
13
|
const run = (options) => {
|
|
14
|
+
const cwd = process.cwd()
|
|
15
|
+
const workspaceRoot = findWorkspaceRoot(cwd)
|
|
16
|
+
|
|
17
|
+
if (workspaceRoot) {
|
|
18
|
+
const entries = findEntries(workspaceRoot)
|
|
19
|
+
printCommandHeader({ cliName, command: 'sync', version: readCliPackageJson().version })
|
|
20
|
+
console.log(chalk.gray(` workspace: ${workspaceRoot}`))
|
|
21
|
+
console.log(chalk.gray(` entries: ${entries.length}`))
|
|
22
|
+
|
|
23
|
+
if (entries.length === 0) {
|
|
24
|
+
console.log(chalk.yellow('\n no linked projects under api/admin/web yet\n'))
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let failed = 0
|
|
29
|
+
for (const entry of entries) {
|
|
30
|
+
console.log(chalk.cyan(`\n→ ${entry.name} (${entry.type})`))
|
|
31
|
+
console.log(chalk.gray(` path: ${entry.path}`))
|
|
32
|
+
if (options.dryRun) {
|
|
33
|
+
const preview = syncProjectToolchain(entry.path, { write: false })
|
|
34
|
+
console.log(chalk.gray(` would update ${preview.tsconfigRel ?? 'tsconfig.json'}`))
|
|
35
|
+
continue
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
syncCliRuntime(entry.path, { force: false })
|
|
39
|
+
const result = syncProjectToolchain(entry.path, { write: true })
|
|
40
|
+
console.log(result.created
|
|
41
|
+
? chalk.green(` created ${result.tsconfigRel}`)
|
|
42
|
+
: chalk.green(` updated ${result.tsconfigRel}`))
|
|
43
|
+
} catch (error) {
|
|
44
|
+
failed += 1
|
|
45
|
+
console.log(chalk.red(` failed: ${error.message}`))
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
syncRegistryFromPath(workspaceRoot)
|
|
50
|
+
console.log(chalk.gray(' registry updated (~/.xrystal)'))
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.log(chalk.yellow(` registry skipped: ${error.message}`))
|
|
53
|
+
}
|
|
54
|
+
console.log(failed ? chalk.red(`\n sync finished with ${failed} error(s)\n`) : chalk.green('\n workspace sync done\n'))
|
|
55
|
+
if (failed) process.exit(1)
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
|
|
11
59
|
const root = getProjectRoot()
|
|
12
60
|
const auditBefore = auditTsconfigAlignment(root)
|
|
13
61
|
|
|
@@ -42,7 +90,7 @@ export function registerSyncCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
42
90
|
cli
|
|
43
91
|
.command('sync')
|
|
44
92
|
.alias('sync-toolchain')
|
|
45
|
-
.description('
|
|
93
|
+
.description('Sync toolchain from tmp.yml — single project or entire workspace')
|
|
46
94
|
.option('--dry-run', 'Preview without writing')
|
|
47
95
|
.action(run)
|
|
48
96
|
}
|
package/x/bin/commands/tmp.mjs
CHANGED
|
@@ -46,7 +46,7 @@ export function registerTmpCommand(cli, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
|
46
46
|
try {
|
|
47
47
|
const tmp = yaml.parse(fs.readFileSync(result.tmpFilePath, 'utf8'))
|
|
48
48
|
const summary = summarizeLoaders(resolveObjWithHandlebars(tmp, tmp))
|
|
49
|
-
console.log(chalk.gray(` root: ${result.layout.rootFolderPath} ·
|
|
49
|
+
console.log(chalk.gray(` root: ${result.layout.rootFolderPath} · project: ${summary.project ?? '-'}`))
|
|
50
50
|
if (summary.items?.length) {
|
|
51
51
|
console.log(chalk.gray(` loaders: ${formatLoaderSummary(summary)}`))
|
|
52
52
|
}
|
|
@@ -14,6 +14,7 @@ var defaults_default = {
|
|
|
14
14
|
cliBinFile: "main-cli.js",
|
|
15
15
|
tmpBaseName: "tmp",
|
|
16
16
|
tmpExtension: ".yml",
|
|
17
|
+
apiServiceTemplateRel: "x/templates/api-service/tmp.yml",
|
|
17
18
|
templateRepoUri: "https://github.com/xdloper/api-gpt-svc",
|
|
18
19
|
publicFolderName: "public",
|
|
19
20
|
kafkaLogsTopic: "log",
|
|
@@ -61,9 +62,10 @@ var defaults_default = {
|
|
|
61
62
|
maxIntervalMs: 1e4
|
|
62
63
|
},
|
|
63
64
|
buildDefaults: {
|
|
65
|
+
bundler: "auto",
|
|
64
66
|
tsconfig: "tsconfig.json",
|
|
65
67
|
typecheck: false,
|
|
66
|
-
tscLenient:
|
|
68
|
+
tscLenient: true,
|
|
67
69
|
declarations: false,
|
|
68
70
|
sourcemap: false,
|
|
69
71
|
minify: false
|
|
@@ -87,40 +89,27 @@ function normalizeSourceFolder(value, fallback) {
|
|
|
87
89
|
|
|
88
90
|
// source/utils/helpers/tmp/seed-from-tmp.ts
|
|
89
91
|
var here = path.dirname(fileURLToPath(import.meta.url));
|
|
90
|
-
var
|
|
92
|
+
var templateRel = defaults_default.apiServiceTemplateRel ?? "x/templates/api-service/tmp.yml";
|
|
91
93
|
function requireString(value, label) {
|
|
92
94
|
if (typeof value !== "string" || !value.trim()) {
|
|
93
|
-
throw new Error(`${defaults_default.packageName}: bundled
|
|
95
|
+
throw new Error(`${defaults_default.packageName}: bundled template missing ${label}`);
|
|
94
96
|
}
|
|
95
97
|
return value.trim();
|
|
96
98
|
}
|
|
97
99
|
function readLayoutFromSpecial(special) {
|
|
98
100
|
const block = special && typeof special === "object" && !Array.isArray(special) ? special : {};
|
|
99
101
|
return {
|
|
100
|
-
tests: requireString(block.tests, "configs.
|
|
101
|
-
environments: requireString(block.environments, "configs.
|
|
102
|
-
dist: requireString(block.dist, "configs.
|
|
102
|
+
tests: requireString(block.tests, "configs.global.paths.special.tests"),
|
|
103
|
+
environments: requireString(block.environments, "configs.global.paths.special.environments"),
|
|
104
|
+
dist: requireString(block.dist, "configs.global.paths.special.dist")
|
|
103
105
|
};
|
|
104
106
|
}
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
return process.cwd();
|
|
108
|
-
} catch {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function findBundledTmpFile(explicit) {
|
|
113
|
-
if (explicit) {
|
|
114
|
-
if (!fs.existsSync(explicit)) {
|
|
115
|
-
throw new Error(`${defaults_default.packageName}: bundled tmp.yml missing at ${explicit}`);
|
|
116
|
-
}
|
|
117
|
-
return explicit;
|
|
118
|
-
}
|
|
119
|
-
const starts = [here, safeProcessCwd()].filter((value) => Boolean(value));
|
|
107
|
+
function findApiTemplate() {
|
|
108
|
+
const starts = [here, process.cwd()].map((value) => path.resolve(value));
|
|
120
109
|
for (const start of starts) {
|
|
121
|
-
let dir =
|
|
110
|
+
let dir = start;
|
|
122
111
|
for (;; ) {
|
|
123
|
-
const candidate = path.join(dir,
|
|
112
|
+
const candidate = path.join(dir, templateRel);
|
|
124
113
|
if (fs.existsSync(candidate))
|
|
125
114
|
return candidate;
|
|
126
115
|
const parent = path.dirname(dir);
|
|
@@ -129,20 +118,25 @@ function findBundledTmpFile(explicit) {
|
|
|
129
118
|
dir = parent;
|
|
130
119
|
}
|
|
131
120
|
}
|
|
132
|
-
throw new Error(`${defaults_default.packageName}:
|
|
121
|
+
throw new Error(`${defaults_default.packageName}: api-service template not found (${templateRel})`);
|
|
133
122
|
}
|
|
134
123
|
function loadSeedFromBundledTmp(tmpFilePath) {
|
|
135
|
-
const file =
|
|
124
|
+
const file = tmpFilePath ?? findApiTemplate();
|
|
136
125
|
const doc = yaml.parse(fs.readFileSync(file, "utf8"));
|
|
137
126
|
const configs = doc?.configs && typeof doc.configs === "object" ? doc.configs : {};
|
|
138
|
-
const
|
|
139
|
-
const paths =
|
|
140
|
-
const
|
|
127
|
+
const global = configs.global && typeof configs.global === "object" ? configs.global : {};
|
|
128
|
+
const paths = global.paths && typeof global.paths === "object" ? global.paths : {};
|
|
129
|
+
const special = paths.special;
|
|
130
|
+
const root = requireString(paths.root, "configs.global.paths.root");
|
|
131
|
+
const rootNorm = normalizeRootFolder(root, defaults_default.packageRootFolder).replace(/^\.\//, "");
|
|
132
|
+
const tmpName = typeof paths.tmp === "string" && paths.tmp.trim() ? paths.tmp.trim().replace(/^\.\//, "") : "tmp.yml";
|
|
133
|
+
const sourceRaw = requireString(paths.source, "configs.global.paths.source");
|
|
141
134
|
return {
|
|
142
|
-
rootFolder:
|
|
135
|
+
rootFolder: rootNorm,
|
|
143
136
|
sourceFolder: normalizeSourceFolder(sourceRaw, sourceRaw),
|
|
144
|
-
framework: requireString(
|
|
145
|
-
layout: readLayoutFromSpecial(
|
|
137
|
+
framework: requireString(global.framework, "configs.global.framework"),
|
|
138
|
+
layout: readLayoutFromSpecial(special),
|
|
139
|
+
tmpRelPath: `${rootNorm}/${tmpName}`.replace(/\/+/g, "/")
|
|
146
140
|
};
|
|
147
141
|
}
|
|
148
142
|
var seedFromTmp = loadSeedFromBundledTmp();
|