@xrystal/core 3.46.0 → 3.47.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -2
- package/package.json +1 -1
- package/x/bin/helpers/.generated/seed-from-tmp.mjs +8 -1
- package/x/bin/helpers/.generated/tmp-schema.mjs +2 -2
- package/x/bin/helpers/build-config.mjs +53 -7
- package/x/bin/scripts/clean-dist-tests.mjs +15 -5
- package/x/bin/scripts/fix-dist-imports.mjs +15 -5
- package/x/bin/scripts/minify-dist.mjs +15 -5
- package/x/dist/loader/configs/index.js +1 -1
- package/x/dist/utils/helpers/path/index.d.ts +1 -0
- package/x/dist/utils/helpers/path/index.js +1 -1
- package/x/dist/utils/helpers/path/resolve-alias-path.d.ts +24 -0
- package/x/dist/utils/helpers/path/resolve-alias-path.js +1 -0
- package/x/dist/utils/helpers/tmp/seed-from-tmp.js +1 -1
- package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +1 -1
- package/x/dist/utils/helpers/tmp/tmp-schema.js +1 -1
- package/x/dist/utils/models/classes/class.x.js +1 -1
- package/x/tmp.yml +1 -1
package/README.md
CHANGED
|
@@ -142,13 +142,46 @@ configs:
|
|
|
142
142
|
source: ./source
|
|
143
143
|
protocols: [http]
|
|
144
144
|
build:
|
|
145
|
-
bundler: auto # auto | bun | tsc | esbuild
|
|
145
|
+
bundler: auto # auto → tsc (recommended) | bun | tsc | esbuild
|
|
146
|
+
typecheck: false # optional tsc --noEmit before emit
|
|
146
147
|
loaders:
|
|
147
148
|
dto: { withDefaultHeaders: true }
|
|
148
149
|
loggers: { logLevel: info }
|
|
149
150
|
controller: {}
|
|
150
151
|
```
|
|
151
152
|
|
|
153
|
+
### Service build / Servis build
|
|
154
|
+
|
|
155
|
+
**EN:** `bundler: auto` → **`tsc`** (full `source/` tree → `x/dist`). Post-steps: `tsc-alias` → `fix-dist-imports` → `clean-dist-tests` (same as core). This keeps `loader/kafka`, relative imports, and `import.meta.url` paths valid in the container.
|
|
156
|
+
|
|
157
|
+
**TR:** `bundler: auto` → **`tsc`** (tüm `source/` ağacı `x/dist`'e). Sonrasında `tsc-alias` + import düzeltme — pod'da kafka/loader modülleri kaybolmaz.
|
|
158
|
+
|
|
159
|
+
| `build.bundler` | Behavior / Davranış |
|
|
160
|
+
|-----------------|---------------------|
|
|
161
|
+
| `auto` / `tsc` | Full tree emit via tsconfig `include` (recommended) |
|
|
162
|
+
| `bun` | Single entry `source/index.ts`, `--packages external` (not multi-entry) |
|
|
163
|
+
| `esbuild` | Single entry bundle; `@/` aliases need tsc or pre-alias |
|
|
164
|
+
|
|
165
|
+
**EN:** `@xrystal/core` itself uses a separate **core** build (package exports entries). Your service only builds **your** `source/` — `@xrystal/core` comes from `node_modules`.
|
|
166
|
+
|
|
167
|
+
**TR:** `@xrystal/core` paketi kendi core build'ini kullanır. Servis build'i sadece **senin** `source/` klasörünü derler; core `node_modules`'dan gelir.
|
|
168
|
+
|
|
169
|
+
### Path alias `@/` / `@/` path alias
|
|
170
|
+
|
|
171
|
+
**EN:** `@/*` maps to your **source folder** (`source/*`), not project root — same as NestJS `@/` → `src/*`, not repo root.
|
|
172
|
+
|
|
173
|
+
**TR:** `@/*` proje root'u değil **source klasörünü** gösterir (`source/*`) — NestJS'teki `@/` → `src/*` gibi.
|
|
174
|
+
|
|
175
|
+
| Write / Yaz | Means / Anlam |
|
|
176
|
+
|-------------|---------------|
|
|
177
|
+
| `@/utils/foo` | `source/utils/foo` ✅ |
|
|
178
|
+
| `@/source/utils/foo` | legacy — treated as `@/utils/foo` |
|
|
179
|
+
| `logs` in tmp `loadPath` | relative to `paths.root` (`x/logs`) |
|
|
180
|
+
|
|
181
|
+
**EN:** `loadPath: '@/utils/helpers/configs/index'` resolves to `source/…` in dev and `x/dist/…` in prod when `source/` is absent.
|
|
182
|
+
|
|
183
|
+
**TR:** tmp.yml `loadPath` prod'da `source/` yoksa otomatik `x/dist/` fallback kullanır.
|
|
184
|
+
|
|
152
185
|
### First endpoint / İlk endpoint (~5 min)
|
|
153
186
|
|
|
154
187
|
```typescript
|
|
@@ -189,7 +222,7 @@ bun run dev
|
|
|
189
222
|
| `xry tmp` | Create `tmp.yml` from seed if missing | `tmp.yml` yoksa seed'den oluştur |
|
|
190
223
|
| `xry sync` | Force-sync `tsconfig` from `tmp.yml` (auto-heals otherwise) | Force sync (normalde otomatik) |
|
|
191
224
|
| `xry dev` | Watch `source/index.ts` + dev env | `source/index.ts` watch + dev env |
|
|
192
|
-
| `xry build` |
|
|
225
|
+
| `xry build` | `tsc` full tree → dist (auto default) + alias/fix post-steps | `tsc` ile tüm `source/` → dist |
|
|
193
226
|
| `xry start` | Run `x/dist` + prod env | `x/dist` + prod env |
|
|
194
227
|
| `xry test` | Run `x/tests` | `x/tests` çalıştır |
|
|
195
228
|
| `xry doctor` | CLI, runtime, package health | CLI, runtime, paket uyumu |
|
package/package.json
CHANGED
|
@@ -102,6 +102,13 @@ function readLayoutFromSpecial(special) {
|
|
|
102
102
|
dist: requireString(block.dist, "configs.service.paths.special.dist")
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
+
function safeProcessCwd() {
|
|
106
|
+
try {
|
|
107
|
+
return process.cwd();
|
|
108
|
+
} catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
105
112
|
function findBundledTmpFile(explicit) {
|
|
106
113
|
if (explicit) {
|
|
107
114
|
if (!fs.existsSync(explicit)) {
|
|
@@ -109,7 +116,7 @@ function findBundledTmpFile(explicit) {
|
|
|
109
116
|
}
|
|
110
117
|
return explicit;
|
|
111
118
|
}
|
|
112
|
-
const starts = [here,
|
|
119
|
+
const starts = [here, safeProcessCwd()].filter((value) => Boolean(value));
|
|
113
120
|
for (const start of starts) {
|
|
114
121
|
let dir = path.resolve(start);
|
|
115
122
|
for (;; ) {
|
|
@@ -225,10 +225,10 @@ function normalizeBundler(value) {
|
|
|
225
225
|
return "auto" /* AUTO */;
|
|
226
226
|
throw new Error(`${defaults_default.packageName}: unknown build.bundler "${String(value)}" (expected ${Object.values(BundlerEnum).join("|")})`);
|
|
227
227
|
}
|
|
228
|
-
function resolveEffectiveBundler(bundler,
|
|
228
|
+
function resolveEffectiveBundler(bundler, _runtime) {
|
|
229
229
|
if (bundler !== "auto" /* AUTO */)
|
|
230
230
|
return bundler;
|
|
231
|
-
return
|
|
231
|
+
return "tsc" /* TSC */;
|
|
232
232
|
}
|
|
233
233
|
function normalizeRootFolder2(value) {
|
|
234
234
|
return normalizeRootFolder(value, defaults_default.packageRootFolder);
|
|
@@ -134,6 +134,15 @@ export function declarationsFromTsconfig(compilerOptions = {}) {
|
|
|
134
134
|
return undefined
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
export function resolveServiceMainEntry(mainFolderPath, buildConfig = {}) {
|
|
138
|
+
if (Array.isArray(buildConfig.entries) && buildConfig.entries.length > 0) {
|
|
139
|
+
return buildConfig.entries.map(String)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const main = normalizeMainFolder(mainFolderPath)
|
|
143
|
+
return [`${main}/index.ts`]
|
|
144
|
+
}
|
|
145
|
+
|
|
137
146
|
export function resolveBuildEntryGlobs(mainFolderPath, buildConfig = {}, tsconfig = null) {
|
|
138
147
|
if (Array.isArray(buildConfig.entries) && buildConfig.entries.length > 0) {
|
|
139
148
|
return buildConfig.entries.map(String)
|
|
@@ -268,10 +277,20 @@ export function resolveTscCommand(root, distRel, buildConfig = {}, runtime = det
|
|
|
268
277
|
}
|
|
269
278
|
|
|
270
279
|
export function resolveBunBuildCommand(entryGlobs, distRel, buildConfig = {}, tsconfig = null) {
|
|
280
|
+
const entries = (Array.isArray(entryGlobs) ? entryGlobs : [entryGlobs]).filter(Boolean)
|
|
271
281
|
const sourcemapFlag = resolveSourcemapFlag(buildConfig, tsconfig)
|
|
272
282
|
const minifyFlags = resolveMinifyFlags(buildConfig)
|
|
273
|
-
const flags = [
|
|
274
|
-
|
|
283
|
+
const flags = [
|
|
284
|
+
...minifyFlags,
|
|
285
|
+
...(sourcemapFlag ? [sourcemapFlag] : []),
|
|
286
|
+
'--outdir',
|
|
287
|
+
distRel,
|
|
288
|
+
'--target',
|
|
289
|
+
'node',
|
|
290
|
+
'--packages',
|
|
291
|
+
'external',
|
|
292
|
+
]
|
|
293
|
+
return `${getRuntimeTooling(RuntimeEnum.BUN).binRunner} build ${entries.join(' ')} ${flags.join(' ')}`.replace(/\s+/g, ' ').trim()
|
|
275
294
|
}
|
|
276
295
|
|
|
277
296
|
export function resolveTscBuildCommand(root, distRel, buildConfig = {}, runtime = detectCliHostRuntime()) {
|
|
@@ -287,14 +306,37 @@ export function resolveEsbuildBuildCommand(entryGlobs, distRel, buildConfig = {}
|
|
|
287
306
|
return `${bin} ${entries} --bundle --platform=node --packages=external --outdir=${distRel}${minify}${sourcemap}`.replace(/\s+/g, ' ').trim()
|
|
288
307
|
}
|
|
289
308
|
|
|
290
|
-
export function resolveServiceBundleCommand(root, plan, buildConfig = {}, runtime = detectCliHostRuntime(), bundler = normalizeBundler('bun')) {
|
|
309
|
+
export function resolveServiceBundleCommand(root, layout, plan, buildConfig = {}, runtime = detectCliHostRuntime(), bundler = normalizeBundler('bun')) {
|
|
310
|
+
const mainEntries = resolveServiceMainEntry(layout.mainFolderPath, buildConfig)
|
|
311
|
+
|
|
291
312
|
if (bundler === BundlerEnum.TSC) {
|
|
292
313
|
return resolveTscBuildCommand(root, plan.distRel, buildConfig, runtime)
|
|
293
314
|
}
|
|
294
315
|
if (bundler === BundlerEnum.ESBUILD) {
|
|
295
|
-
return resolveEsbuildBuildCommand(
|
|
316
|
+
return resolveEsbuildBuildCommand(mainEntries, plan.distRel, buildConfig, plan.tsconfig, runtime)
|
|
317
|
+
}
|
|
318
|
+
return resolveBunBuildCommand(mainEntries, plan.distRel, buildConfig, plan.tsconfig)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export function resolveServicePostProcessSteps(root, distRel, buildConfig = {}, runtime = detectCliHostRuntime()) {
|
|
322
|
+
const tsconfigRel = resolveTsconfigRel(root, buildConfig)
|
|
323
|
+
if (!tsconfigRel) {
|
|
324
|
+
throw new Error('Service tsc build requires tsconfig.json (set build.tsconfig or add tsconfig.json).')
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const host = getRuntimeTooling(runtime)
|
|
328
|
+
const aliasRunner = host.tscBin.trim().split(/\s+/)[0]
|
|
329
|
+
const scriptsBase = `node ${packageDefaults.packageRootFolder}/bin/scripts`
|
|
330
|
+
const distArg = distRel.includes(' ') ? `"${distRel}"` : distRel
|
|
331
|
+
const steps = [`${aliasRunner} tsc-alias -p ${tsconfigRel}`]
|
|
332
|
+
|
|
333
|
+
if (resolveMinifyEnabled(buildConfig)) {
|
|
334
|
+
steps.push(`${scriptsBase}/minify-dist.mjs ${distArg}`)
|
|
296
335
|
}
|
|
297
|
-
|
|
336
|
+
|
|
337
|
+
steps.push(`${scriptsBase}/fix-dist-imports.mjs ${distArg}`)
|
|
338
|
+
steps.push(`${scriptsBase}/clean-dist-tests.mjs ${distArg}`)
|
|
339
|
+
return steps
|
|
298
340
|
}
|
|
299
341
|
|
|
300
342
|
export function resolveEffectiveBuildOptions(root, layout, buildConfig = {}, runtime = detectCliHostRuntime()) {
|
|
@@ -366,10 +408,14 @@ export function resolveServiceBuildSteps(root, layout, buildConfig = {}, runtime
|
|
|
366
408
|
|
|
367
409
|
steps.push(
|
|
368
410
|
`rm -rf ${plan.distRel}`,
|
|
369
|
-
resolveServiceBundleCommand(root, plan, buildConfig, runtime, plan.bundler),
|
|
411
|
+
resolveServiceBundleCommand(root, layout, plan, buildConfig, runtime, plan.bundler),
|
|
370
412
|
)
|
|
371
413
|
|
|
372
|
-
if (plan.
|
|
414
|
+
if (plan.bundler === BundlerEnum.TSC) {
|
|
415
|
+
steps.push(...resolveServicePostProcessSteps(root, plan.distRel, buildConfig, runtime))
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (plan.declarations && plan.bundler !== BundlerEnum.TSC) {
|
|
373
419
|
steps.push(resolveTscCommand(root, plan.distRel, buildConfig, runtime))
|
|
374
420
|
}
|
|
375
421
|
|
|
@@ -3,11 +3,21 @@ import path from 'node:path'
|
|
|
3
3
|
|
|
4
4
|
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
5
5
|
|
|
6
|
-
const distRoot =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
)
|
|
6
|
+
const distRoot = resolveDistRootFromArgv()
|
|
7
|
+
|
|
8
|
+
function resolveDistRootFromArgv() {
|
|
9
|
+
const arg = process.argv[2]
|
|
10
|
+
if (arg && String(arg).trim()) {
|
|
11
|
+
const trimmed = String(arg).trim()
|
|
12
|
+
return path.isAbsolute(trimmed) ? trimmed : path.join(process.cwd(), trimmed)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return path.join(
|
|
16
|
+
process.cwd(),
|
|
17
|
+
packageDefaults.packageRootFolder,
|
|
18
|
+
packageDefaults.layoutPaths.dist,
|
|
19
|
+
)
|
|
20
|
+
}
|
|
11
21
|
const TEST_FILE_RE = /\.test\.(js|d\.ts)$/
|
|
12
22
|
|
|
13
23
|
export function cleanDistTests(distDir = distRoot) {
|
|
@@ -2,11 +2,21 @@ import fs from 'node:fs'
|
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
4
4
|
|
|
5
|
-
const distRoot =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
)
|
|
5
|
+
const distRoot = resolveDistRootFromArgv()
|
|
6
|
+
|
|
7
|
+
function resolveDistRootFromArgv() {
|
|
8
|
+
const arg = process.argv[2]
|
|
9
|
+
if (arg && String(arg).trim()) {
|
|
10
|
+
const trimmed = String(arg).trim()
|
|
11
|
+
return path.isAbsolute(trimmed) ? trimmed : path.join(process.cwd(), trimmed)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return path.join(
|
|
15
|
+
process.cwd(),
|
|
16
|
+
packageDefaults.packageRootFolder,
|
|
17
|
+
packageDefaults.layoutPaths.dist,
|
|
18
|
+
)
|
|
19
|
+
}
|
|
10
20
|
|
|
11
21
|
const HAS_EXT = /\.(js|mjs|cjs|json|node|wasm)(\?.*)?$/i
|
|
12
22
|
|
|
@@ -5,11 +5,21 @@ import path from 'node:path'
|
|
|
5
5
|
import { packageDefaults } from '../helpers/package-defaults.mjs'
|
|
6
6
|
import { RuntimeEnum, getRuntimeTooling } from '../helpers/cli-runtime.mjs'
|
|
7
7
|
|
|
8
|
-
const distRoot =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
)
|
|
8
|
+
const distRoot = resolveDistRootFromArgv()
|
|
9
|
+
|
|
10
|
+
function resolveDistRootFromArgv() {
|
|
11
|
+
const arg = process.argv[2]
|
|
12
|
+
if (arg && String(arg).trim()) {
|
|
13
|
+
const trimmed = String(arg).trim()
|
|
14
|
+
return path.isAbsolute(trimmed) ? trimmed : path.join(process.cwd(), trimmed)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return path.join(
|
|
18
|
+
process.cwd(),
|
|
19
|
+
packageDefaults.packageRootFolder,
|
|
20
|
+
packageDefaults.layoutPaths.dist,
|
|
21
|
+
)
|
|
22
|
+
}
|
|
13
23
|
|
|
14
24
|
function walkJsFiles(dir, out = []) {
|
|
15
25
|
for (const name of fs.readdirSync(dir)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import E from"node:path";import c from"lodash";import{pathToFileURL as l}from"node:url";import{bindLoaderTmpSync as v}from"../../utils";import{Constants as i,resolveTmpLoadPath as h}from"../../utils";export default class Configs{publicFolderName=i.publicFolderName;kafkaLogsTopic=i.kafkaLogsTopic;#s;#e;constructor({system:s}){this.#s=s;return new Proxy(this,{get:(o,r)=>{return o[r]||o.config?.[r]}})}onInit=async()=>{await this.syncFromTmp();v(this)};syncFromTmp=async()=>{const s=process.cwd(),e=this.#s.tmp,o=e.configs.service.loaders.configs.loadPath,r=h(o,e,s),a=import(l(r).href);this.#e={worker:process.env.WORKER==="true"?!0:!1,mode:process.env.MODE,nodeEnv:"development",debug:process.env.SYSTEM_LOGGER_LAYER??"",https:process.env.HTTPS??"false",httpsfileEncoding:process.env.ENCODING||"utf8",httpsCertfile:process.env.HTTPS_CERT_FILE??"",httpsKeyfile:process.env.HTTPS_KEY_FILE??"",rootFolderPath:e.configs.rootFolderPath||"x",projectName:e.project.name,serviceName:e.configs.service.name??"",projectNamePrefixEnv:process.env.PROJECT_NAME_PREFIX||"",projectNameEnv:process.env.PROJECT_NAME||"",projectNameSuffixEnv:process.env.PROJECT_NAME_SUFFIX||"",systemStaticFolderPath:E.resolve(e.configs.rootFolderPath,this.publicFolderName),systemLoggerLayer:process.env.SYSTEM_LOGGER_LAYER??"info",isKafkaPassive:process.env.IS_KAFKA_PASSIVE==="true"?!0:!1,kafkaClientId:e.configs.service.name??"",kafkaBrokers:process.env.KAFKA_BROKERS??"",kafkaUsername:process.env.KAFKA_USERNAME??"",kafkaPassword:process.env.KAFKA_PASSWORD??"",kafkaTopics:[],kafkaLogsTopic:this.kafkaLogsTopic,baseApiUri:process.env.HTTPS==="true"?process.env.SYSTEM_HTTPS_BASE_API_URI??"":process.env.SYSTEM_BASE_API_URI??"",port:Number(process.env.PORT),internalSecret:process.env.INTERNAL_SECRET??"",secret:process.env.SECRET??"",cwd:s,env:"development"};try{const t=await a,p=t?.default||t?.configs||t||{},f=c.mergeWith({},this.#e,p,(n,m)=>{if(c.isArray(n))return n.concat(m)});this.#e=Object.freeze(f)}catch{this.#e=Object.freeze(this.#e)}};setConfig(s){const e=Object.assign(this.#e,s);this.#e=Object.freeze(e)}_(s){return this.#e[s]}get all(){return this.#e}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import d from"path";import{fileURLToPath as c}from"url";export*from"../../../utils/helpers/path/resolve-alias-path";export const __filename=(b)=>c(b),__dirname=(b)=>d.dirname(c(b));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type ResolveAliasModulePathOptions = {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
aliasPrefix?: string;
|
|
4
|
+
sourceFolder?: string;
|
|
5
|
+
rootFolder?: string;
|
|
6
|
+
distSegment?: string;
|
|
7
|
+
};
|
|
8
|
+
/** Resolve `@/…` the same way as tsconfig paths (`@/*` → `{sourceFolder}/*`), with dist fallback for prod. */
|
|
9
|
+
export declare function resolveAliasModulePath(spec: string, options?: ResolveAliasModulePathOptions): string;
|
|
10
|
+
export type TmpLoadPathContext = {
|
|
11
|
+
configs?: {
|
|
12
|
+
rootFolderPath?: string;
|
|
13
|
+
service?: {
|
|
14
|
+
paths?: {
|
|
15
|
+
source?: string;
|
|
16
|
+
special?: {
|
|
17
|
+
dist?: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** Resolve tmp.yml loader `loadPath` — `@/` modules or paths relative to `paths.root`. */
|
|
24
|
+
export declare function resolveTmpLoadPath(spec: string, tmp: TmpLoadPathContext, cwd?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import V from"node:fs";import G from"node:path";import H from"../../../utils/constants/defaults.json" with { type: 'json' };const W=[".ts",".js",".mjs"];function J(k){return String(k).replace(/^\.\//,"")}function Y(k){for(const y of W){const q=`${k}${y}`;if(V.existsSync(q))return q}for(const y of W){const q=G.join(k,`index${y}`);if(V.existsSync(q))return q}return null}export function resolveAliasModulePath(k,y={}){const q=y.cwd??process.cwd(),K=y.aliasPrefix??H.pathAliasKey.replace("*","");if(!k.startsWith(K))return G.isAbsolute(k)?k:G.resolve(q,k);const C=J(y.sourceFolder??"source");let z=k.slice(K.length).replace(/^\/+/,"");if(z===C||z.startsWith(`${C}/`))z=z===C?"":z.slice(C.length+1);const N=G.join(q,C,z),Q=Y(N);if(Q)return Q;const Z=J(y.rootFolder??H.packageRootFolder),$=J(y.distSegment??"dist"),j=G.join(q,Z,$,z),R=Y(j);if(R)return R;return N}export function resolveTmpLoadPath(k,y,q=process.cwd()){const K=H.pathAliasKey.replace("*",""),C=y.configs??{};if(!k.startsWith(K)){const Q=C.rootFolderPath??H.packageRootFolder;return G.resolve(q,Q,k)}const z=C.service?.paths??{},N=z.special??{};return resolveAliasModulePath(k,{cwd:q,sourceFolder:J(String(z.source??"source")),rootFolder:C.rootFolderPath??H.packageRootFolder,distSegment:J(String(N.dist??"dist"))})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import K from"node:fs";import J from"node:path";import{fileURLToPath as V}from"node:url";import W from"yaml";import defaults from"../../../utils/constants/defaults.json" with { type: 'json' };import{normalizeRootFolder as X,normalizeSourceFolder as Y}from"../../../utils/helpers/tmp/path-normalize";export{defaults as packageIdentityDefaults};const O=J.dirname(V(import.meta.url)),Q=`${defaults.tmpBaseName}${defaults.tmpExtension}`;function I(j,A){if(typeof j!=="string"||!j.trim())throw Error(`${defaults.packageName}: bundled tmp.yml missing ${A}`);return j.trim()}function Z(j){const A=j&&typeof j==="object"&&!Array.isArray(j)?j:{};return{tests:I(A.tests,"configs.service.paths.special.tests"),environments:I(A.environments,"configs.service.paths.special.environments"),dist:I(A.dist,"configs.service.paths.special.dist")}}function _(){try{return process.cwd()}catch{return null}}function $(j){if(j){if(!K.existsSync(j))throw Error(`${defaults.packageName}: bundled tmp.yml missing at ${j}`);return j}const A=[O,_()].filter((E)=>Boolean(E));for(const E of A){let D=J.resolve(E);for(;;){const G=J.join(D,defaults.packageRootFolder,Q);if(K.existsSync(G))return G;const H=J.dirname(D);if(H===D)break;D=H}}throw Error(`${defaults.packageName}: bundled ${defaults.packageRootFolder}/${Q} not found from ${O}`)}export function loadSeedFromBundledTmp(j){const A=$(j),E=W.parse(K.readFileSync(A,"utf8")),D=E?.configs&&typeof E.configs==="object"?E.configs:{},G=D.service&&typeof D.service==="object"?D.service:{},H=G.paths&&typeof G.paths==="object"?G.paths:{},M=I(H.source,"configs.service.paths.source");return{rootFolder:X(H.root,defaults.packageRootFolder),sourceFolder:Y(M,M),framework:I(G.framework,"configs.service.framework"),layout:Z(H.special)}}export const seedFromTmp=loadSeedFromBundledTmp();
|
|
@@ -43,7 +43,7 @@ export type TmpRuntimeConfigs = {
|
|
|
43
43
|
};
|
|
44
44
|
export declare function normalizeRuntime(value: unknown): RuntimeEnum;
|
|
45
45
|
export declare function normalizeBundler(value: unknown): BundlerEnum;
|
|
46
|
-
export declare function resolveEffectiveBundler(bundler: BundlerEnum,
|
|
46
|
+
export declare function resolveEffectiveBundler(bundler: BundlerEnum, _runtime: RuntimeEnum): Exclude<BundlerEnum, BundlerEnum.AUTO>;
|
|
47
47
|
export declare function normalizeRootFolder(value?: string): string;
|
|
48
48
|
export declare function normalizeSourceFolder(value?: string): string;
|
|
49
49
|
export declare function readTmpGlobalBlock(configs?: Record<string, unknown>): TmpGlobalBlock;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Q from"../../../utils/constants/defaults.json" with { type: 'json' };import{BundlerEnum as
|
|
1
|
+
import Q from"../../../utils/constants/defaults.json" with { type: 'json' };import{BundlerEnum as H,RuntimeEnum as O}from"../../../utils/models/enums";import{seedFromTmp as U}from"../../../utils/helpers/tmp/seed-from-tmp";import{interpolateWithContext as Z}from"../../../utils/helpers/tmp/tmp-interpolate";import{normalizeLayoutPaths as _,normalizeRootFolder as $,normalizeSourceFolder as I}from"../../../utils/helpers/tmp/path-normalize";function D(j){return typeof j==="object"&&j!==null&&!Array.isArray(j)}function x(j){if(typeof j==="number"||typeof j==="string")return j;return}export function normalizeRuntime(j){const q=typeof j==="string"?j.trim().toLowerCase():"";if(q===O.NODE)return O.NODE;if(q===O.BUN)return O.BUN;if(!q)throw Error(`${Q.packageName}: configs.global.runtime is required (${Object.values(O).join("|")})`);throw Error(`${Q.packageName}: unknown configs.global.runtime "${String(j)}" (expected ${Object.values(O).join("|")})`)}export function normalizeBundler(j){const q=typeof j==="string"?j.trim().toLowerCase():"";if(!q)return H.AUTO;if(q===H.TSC)return H.TSC;if(q===H.ESBUILD)return H.ESBUILD;if(q===H.BUN)return H.BUN;if(q===H.AUTO)return H.AUTO;throw Error(`${Q.packageName}: unknown build.bundler "${String(j)}" (expected ${Object.values(H).join("|")})`)}export function resolveEffectiveBundler(j,q){if(j!==H.AUTO)return j;return H.TSC}export function normalizeRootFolder(j){return $(j,Q.packageRootFolder)}export function normalizeSourceFolder(j){return I(j,U.sourceFolder)}export function readTmpGlobalBlock(j){const q=D(j?.global)?j.global:{},A=D(q.vars)?q.vars:{};return{runtime:normalizeRuntime(q.runtime),vars:{...A}}}export function readTmpCoreBlock(j){const q=D(j?.core)?j.core:{},A=D(q.tmp)?q.tmp:{};return{tmp:{fileWatchIntervalMs:x(A.fileWatchIntervalMs)}}}export function readTmpServiceBlock(j){const q=D(j?.service)?j.service:{},A=D(q.paths)?q.paths:{},J=D(A.special)?A.special:{};let K=D(q.loaders)?{...q.loaders}:void 0,M=D(q.build)?q.build:void 0;if(K&&D(K.build)){const{build:X,...Y}=K;K=Y;if(!M&&D(X))M=X}return{name:typeof q.name==="string"?q.name:void 0,framework:typeof q.framework==="string"?q.framework:void 0,paths:{root:typeof A.root==="string"?A.root:void 0,source:typeof A.source==="string"?A.source:void 0,special:{tests:typeof J.tests==="string"?J.tests:void 0,environments:typeof J.environments==="string"?J.environments:void 0,dist:typeof J.dist==="string"?J.dist:void 0}},protocols:q.protocols,loaders:K,build:M}}export function resolveServiceLayoutPaths(j){return _(j.paths?.special,U.layout)}function L(j){const q=resolveServiceLayoutPaths(j);return{name:j.name,framework:j.framework??U.framework,paths:{root:j.paths?.root??Q.packageRootFolder,source:j.paths?.source??U.sourceFolder,special:q},protocols:j.protocols,loaders:j.loaders,build:j.build}}function N(j){return{tmp:{fileWatchIntervalMs:j.tmp?.fileWatchIntervalMs}}}export function buildTmpVarContext(j){return{...j.vars,runtime:j.runtime,global:j}}export function applyTmpGlobalVars(j){const q=D(j.configs)?j.configs:{},A=readTmpGlobalBlock(q);return Z(j,buildTmpVarContext(A))}export function resolveTmpRuntimeConfigs(j){const q=D(j?.configs)?j.configs:{},A=readTmpGlobalBlock(q),J=readTmpServiceBlock(q),K=readTmpCoreBlock(q),M=L(J);return{global:A,service:M,core:N(K),rootFolderPath:normalizeRootFolder(M.paths.root)}}export function normalizeTmpDocument(j){const q=applyTmpGlobalVars(j);return{...q,configs:resolveTmpRuntimeConfigs(q)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __filename="/
|
|
1
|
+
var __filename="/Volumes/MAC/Desktop/software/xrystal/-xrystal-core/x/dist/utils/models/classes/class.x.js";import{createContainer as V,asClass as K,asValue as j,InjectionMode as N,listModules as X,Lifetime as Z}from"awilix";import R from"node:path";import{pathToFileURL as x}from"node:url";import C from"../../../utils/constants/defaults.json" with { type: 'json' };export const xSymbol=Symbol.for(`${C.packageName}/di-container`);class T{checkRegistration(q,A){return!!q.registrations[A]}}class U extends T{container;initializedNames=new Set;loadedPaths=new Set;registeredClasses=new Set;isInitializing=!1;constructor(){super();this.container=V({injectionMode:N.PROXY,strict:!0})}getName(q){if(typeof q==="string")return q.charAt(0).toLowerCase()+q.slice(1);if(typeof q==="function"&&q.name)return q.name.charAt(0).toLowerCase()+q.name.slice(1);return""}async load(q,A={}){const{verbose:H=!1,exclude:$=[],lifetime:E=Z.SINGLETON}=A,B=process.cwd(),G=(Array.isArray(q)?q:[q]).map((Q)=>{return(R.isAbsolute(Q)?Q:R.resolve(B,Q)).replace(/\\/g,"/").toLowerCase()});let O=[];try{O=X(G)}catch(Q){return this}for(const Q of O){const Y=Q.path.replace(/\\/g,"/").toLowerCase();if(this.loadedPaths.has(Y))continue;if(Y===__filename.replace(/\\/g,"/").toLowerCase()||Y.endsWith(".d.ts"))continue;try{const F=await import(x(Q.path).href);let J=F.default;if(!J)J=Object.values(F).find((W)=>typeof W==="function"&&!!W.prototype&&!!W.name);if(typeof J==="function"&&!!J.prototype&&!!J.name){if(this.registeredClasses.has(J))continue;const W=this.getName(J);if(W&&!this.checkRegistration(this.container,W)){this.container.register({[W]:K(J).setLifetime(E)});this.loadedPaths.add(Y);this.registeredClasses.add(J)}}}catch(w){if(H)console.error("[DI] Load Error:",w.message)}}return this}register(q,A=Z.SINGLETON){const H=this.getName(q);if(!H||this.registeredClasses.has(q))return this;if(this.checkRegistration(this.container,H))return this;this.container.register({[H]:K(q).setLifetime(A)});this.registeredClasses.add(q);return this}registerInstance(q,A){if(!q)return this;const H=this.getName(q);this.container.register({[H]:j(A)});return this}async initialize(q,A=!1){if(this.isInitializing)return this;this.isInitializing=!0;try{const H=q?Array.isArray(q)?q:[q]:[];for(const E of H){const B=this.getName(E.service);if(!B||this.initializedNames.has(B))continue;const G=this.container.registrations[B];if(!G||G.lifetime!==Z.SINGLETON)continue;try{const O=this.container.cradle[B];if(O&&typeof O.onInit==="function")await O.onInit(E.props||{});this.initializedNames.add(B)}catch(O){if(A)console.error(`[DI] Priority onInit Failed (${B}):`,O.message)}}const $=Object.keys(this.container.registrations);for(const E of $){if(this.initializedNames.has(E))continue;if(this.container.registrations[E].lifetime!==Z.SINGLETON)continue;try{const G=this.container.cradle[E];if(G&&typeof G.onInit==="function")await G.onInit({});this.initializedNames.add(E)}catch(G){if(A)console.error(`[DI] Auto onInit Failed (${E}):`,G.message)}}for(const E of this.initializedNames)try{const B=this.container.cradle[E];if(B&&typeof B.onAfterInit==="function")await B.onAfterInit()}catch(B){if(A)console.error(`[DI] onAfterInit Failed (${E}):`,B.message)}}finally{this.isInitializing=!1}return this}get(q){const A=this.getName(q);return this.container.resolve(A)}async shutdown(){for(const q of this.initializedNames)try{const A=this.container.cradle[q];if(A&&typeof A.onDispose==="function")await A.onDispose()}catch(A){console.error(`[DI] onDispose Failed (${q})`)}await this.container.dispose()}get cradle(){return this.container.cradle}}const _=globalThis;if(!_[xSymbol])_[xSymbol]=new U;export default _[xSymbol];
|