@xrystal/core 3.40.0 → 3.42.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.
Files changed (40) hide show
  1. package/README.md +7 -7
  2. package/package.json +1 -1
  3. package/x/bin/commands/doctor.mjs +4 -3
  4. package/x/bin/commands/hooks.mjs +2 -1
  5. package/x/bin/commands/release.mjs +2 -1
  6. package/x/bin/commands/tmp.mjs +2 -1
  7. package/x/bin/helpers/.generated/.generated-from +1 -0
  8. package/x/bin/helpers/.generated/seed-from-tmp.mjs +115 -0
  9. package/x/bin/helpers/.generated/tmp-schema.mjs +74 -13
  10. package/x/bin/helpers/banner.mjs +22 -20
  11. package/x/bin/helpers/build-config.mjs +7 -6
  12. package/x/bin/helpers/cli-help.mjs +3 -2
  13. package/x/bin/helpers/cli-identity.mjs +1 -1
  14. package/x/bin/helpers/package-defaults.mjs +14 -11
  15. package/x/bin/helpers/project-artifacts.mjs +90 -36
  16. package/x/bin/helpers/project-root.mjs +5 -5
  17. package/x/bin/helpers/seed-from-tmp.mjs +13 -48
  18. package/x/bin/helpers/tmp-config.mjs +2 -1
  19. package/x/bin/helpers/tmp-layout.mjs +13 -9
  20. package/x/bin/helpers/toolchain-config.mjs +4 -3
  21. package/x/bin/main-cli.js +1 -1
  22. package/x/bin/paths.mjs +13 -2
  23. package/x/bin/scripts/install-git-hooks.mjs +2 -1
  24. package/x/bin/scripts/publish-guard.mjs +36 -15
  25. package/x/bin/scripts/release-prepare.mjs +2 -2
  26. package/x/bin/scripts/sync-cli-defaults.mjs +10 -15
  27. package/x/dist/utils/constants/defaults.json +6 -0
  28. package/x/dist/utils/constants/index.d.ts +8 -2
  29. package/x/dist/utils/constants/index.js +1 -1
  30. package/x/dist/utils/helpers/core/tmp-layout.js +1 -1
  31. package/x/dist/utils/helpers/tmp/index.d.ts +1 -1
  32. package/x/dist/utils/helpers/tmp/index.js +1 -1
  33. package/x/dist/utils/helpers/tmp/path-normalize.d.ts +3 -5
  34. package/x/dist/utils/helpers/tmp/path-normalize.js +1 -1
  35. package/x/dist/utils/helpers/tmp/seed-from-tmp.d.ts +3 -0
  36. package/x/dist/utils/helpers/tmp/seed-from-tmp.js +1 -1
  37. package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +0 -4
  38. package/x/dist/utils/helpers/tmp/tmp-schema.js +1 -1
  39. package/x/dist/utils/models/classes/class.x.js +1 -1
  40. package/x/bin/helpers/defaults.json +0 -28
@@ -1 +1 @@
1
- import n from"node:path";import{packageRootDir as q}from"../../utils/package-root";import b from"./defaults.json" with { type: 'json' };import{seedFromTmp as j}from"../../utils/helpers/tmp/seed-from-tmp";export const packageDefaults=Object.freeze({...b,mainSourceFolder:j.sourceFolder,layoutPaths:Object.freeze({...j.layout}),buildDefaults:Object.freeze({...b.buildDefaults}),tmpWatchDefaults:Object.freeze({...b.tmpWatchDefaults}),cliBinNames:Object.freeze([...b.cliBinNames??[b.cliName]])}),coreVersionPattern=/^\d{2}\.\d{2}\.\d{2}-v\d+$/,semverVersionPattern=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/;const v=`${packageDefaults.tmpBaseName}${packageDefaults.tmpExtension}`;export class Constants{static packageName=packageDefaults.packageName;static packageRootFolder=packageDefaults.packageRootFolder;static tmpBaseName=packageDefaults.tmpBaseName;static tmpExtension=packageDefaults.tmpExtension;static publicFolderName=packageDefaults.publicFolderName;static kafkaLogsTopic=packageDefaults.kafkaLogsTopic;static templateRepoUri=packageDefaults.templateRepoUri;static cliName=packageDefaults.cliName;static cliBinNames=packageDefaults.cliBinNames;static pathAliasKey=packageDefaults.pathAliasKey;static mainSourceFolder=packageDefaults.mainSourceFolder;static layoutPaths=packageDefaults.layoutPaths;static bundledCoreTmpPath=n.join(q,packageDefaults.packageRootFolder,v)}export{seedFromTmp,loadSeedFromBundledTmp}from"../../utils/helpers/tmp/seed-from-tmp";
1
+ import n from"node:path";import{packageRootDir as q}from"../../utils/package-root";import b from"./defaults.json" with { type: 'json' };import{seedFromTmp as j}from"../../utils/helpers/tmp/seed-from-tmp";export const packageDefaults=Object.freeze({...b,mainSourceFolder:j.sourceFolder,framework:j.framework,layoutPaths:Object.freeze({...j.layout}),brand:Object.freeze({...b.brand}),buildDefaults:Object.freeze({...b.buildDefaults}),tmpWatchDefaults:Object.freeze({...b.tmpWatchDefaults}),cliBinNames:Object.freeze([...b.cliBinNames??[b.cliName]])}),coreVersionPattern=/^\d{2}\.\d{2}\.\d{2}-v\d+$/,semverVersionPattern=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/;const v=`${packageDefaults.tmpBaseName}${packageDefaults.tmpExtension}`;export class Constants{static packageName=packageDefaults.packageName;static packageRootFolder=packageDefaults.packageRootFolder;static tmpBaseName=packageDefaults.tmpBaseName;static tmpExtension=packageDefaults.tmpExtension;static publicFolderName=packageDefaults.publicFolderName;static kafkaLogsTopic=packageDefaults.kafkaLogsTopic;static templateRepoUri=packageDefaults.templateRepoUri;static cliName=packageDefaults.cliName;static cliBinNames=packageDefaults.cliBinNames;static pathAliasKey=packageDefaults.pathAliasKey;static brand=packageDefaults.brand;static mainSourceFolder=packageDefaults.mainSourceFolder;static framework=packageDefaults.framework;static layoutPaths=packageDefaults.layoutPaths;static bundledCoreTmpPath=n.join(q,packageDefaults.packageRootFolder,v)}export{seedFromTmp,loadSeedFromBundledTmp}from"../../utils/helpers/tmp/seed-from-tmp";
@@ -1 +1 @@
1
- import U from"node:fs";import I from"node:path";import z from"yaml";import{Constants as J}from"../../../utils/constants";import{findAllFilesRecursively as L,findFileRecursively as A}from"../../../utils/helpers/core/paths";import{normalizeTmpDocument as D,readTmpServiceBlock as B,normalizeRootFolder as b,normalizeSourceFolder as x,resolveServiceLayoutPaths as k}from"../../../utils/helpers/tmp/tmp-schema";function M(E,q){return`${E}${q.startsWith(".")?q:`.${q}`}`}export function coreCanonicalTmpPath(E=process.cwd()){return I.join(I.resolve(E),J.packageRootFolder,M(J.tmpBaseName,J.tmpExtension))}export function assertCoreTmpGuard(E,q){if(!isCorePackageRoot(E))return;const H=coreCanonicalTmpPath(E);if(I.resolve(q)!==I.resolve(H))throw Error(`@xrystal/core: tmp.yml must stay at ${J.packageRootFolder}/tmp.yml (expected ${H}, got ${q})`)}function N(E,q){const H=I.resolve(E),K=I.resolve(q);return L(H,J.tmpBaseName,J.tmpExtension).filter((Q)=>I.resolve(Q)!==K)}export function ensureCoreTmpEntry(E=process.cwd(),q={}){const H=I.resolve(E);if(!isCorePackageRoot(H))throw Error("ensureCoreTmpEntry is only for @xrystal/core package root");const K=coreCanonicalTmpPath(H),Q=N(H,K);if(Q.length>0){const X=Q.map((W)=>I.relative(H,W)).join(", ");throw Error(`@xrystal/core: tmp.yml must only exist under ${J.packageRootFolder}/. Remove extra copies: ${X}`)}if(U.existsSync(K)){assertCoreTmpGuard(H,K);return{tmpFilePath:K,created:!1,layout:buildTmpLayout(H,_(K),K)}}return ensureTmpFile(H,{...q,patchServiceName:!1})}function S(E,q,H){const K=I.resolve(E);if(isCorePackageRoot(K)){const Q=coreCanonicalTmpPath(K);return U.existsSync(Q)?Q:null}return A(K,q,H)}function _(E){return z.parse(U.readFileSync(E,"utf8"))}export function isCorePackageRoot(E){const q=I.join(I.resolve(E),"package.json");if(!U.existsSync(q))return!1;try{return JSON.parse(U.readFileSync(q,"utf8")).name===J.packageName}catch{return!1}}export function resolveRootFolderPath(E,q,H){const K=D(E).configs,Q=B(K);if(Q.paths?.root?.trim())return b(Q.paths.root);const X=E.project;if(typeof X?.name==="string"&&X.name.trim())return X.name.trim();const W=I.relative(I.resolve(H),I.dirname(I.resolve(q)));if(W&&W!==".")return W;return J.packageRootFolder}export function resolveLayoutPaths(E){const q=B(E);return k(q)}export function resolveMainFolderPath(E){const q=B(E);if(q.paths?.source?.trim())return x(q.paths.source);return J.mainSourceFolder}export function buildTmpLayout(E,q,H){const K=I.resolve(E),Q=q?D(q).configs:void 0,X=q&&H&&!isCorePackageRoot(K)?resolveRootFolderPath(q,H,K):J.packageRootFolder,W=I.join(K,X),Y=resolveLayoutPaths(Q),V=resolveMainFolderPath(Q),Z={tests:I.join(W,Y.tests),environments:I.join(W,Y.environments),dist:I.join(W,Y.dist)};return{projectRoot:K,rootFolderPath:X,rootFolderAbs:W,tmpFilePath:H,mainFolderPath:V,paths:Y,pathsAbs:Z}}export function resolveTmpLayout(E=process.cwd(),q={}){const H=q.tmpFileName??J.tmpBaseName,K=q.ext??J.tmpExtension,Q=S(E,H,K);if(!Q)throw Error(`${M(H,K)} not found under ${I.resolve(E)}`);if(isCorePackageRoot(I.resolve(E)))assertCoreTmpGuard(E,Q);return buildTmpLayout(E,_(Q),Q)}export function resolveTmpLayoutOrDefaults(E=process.cwd()){const q=S(E,J.tmpBaseName,J.tmpExtension);if(!q)return buildTmpLayout(E,null,null);return buildTmpLayout(E,_(q),q)}export function resolveBundledCoreTmpPath(E=process.cwd()){if(U.existsSync(J.bundledCoreTmpPath))return J.bundledCoreTmpPath;let q=I.resolve(E);while(q!==I.dirname(q)){const H=I.join(q,"node_modules","@xrystal","core",J.packageRootFolder,M(J.tmpBaseName,J.tmpExtension));if(U.existsSync(H))return H;const K=I.join(q,"package.json");if(U.existsSync(K)){if(JSON.parse(U.readFileSync(K,"utf8")).name===J.packageName){const X=I.join(q,J.packageRootFolder,M(J.tmpBaseName,J.tmpExtension));if(U.existsSync(X))return X}}q=I.dirname(q)}throw Error("@xrystal/core bundled x/tmp.yml not found")}export function ownerTmpFilePath(E=process.cwd(),q){const H=q??resolveTmpLayoutOrDefaults(E);return I.join(H.rootFolderAbs,M(J.tmpBaseName,J.tmpExtension))}export function ensureTmpFile(E=process.cwd(),q={}){const H=I.resolve(E),K=q.patchServiceName??!0;if(isCorePackageRoot(H)){const V=coreCanonicalTmpPath(H),Z=N(H,V);if(Z.length>0){const $=Z.map((w)=>I.relative(H,w)).join(", ");throw Error(`@xrystal/core: tmp.yml must only exist under ${J.packageRootFolder}/. Remove extra copies: ${$}`)}if(U.existsSync(V)){assertCoreTmpGuard(H,V);return{tmpFilePath:V,created:!1,layout:buildTmpLayout(H,_(V),V)}}}else{const V=A(H,J.tmpBaseName,J.tmpExtension);if(V)return{tmpFilePath:V,created:!1,layout:buildTmpLayout(H,_(V),V)}}const Q=q.templatePath??resolveBundledCoreTmpPath(H);if(!U.existsSync(Q))throw Error("@xrystal/core bundled x/tmp.yml not found");const X=buildTmpLayout(H,null,null);U.mkdirSync(X.rootFolderAbs,{recursive:!0});const W=ownerTmpFilePath(H,X);let Y=U.readFileSync(Q,"utf8");if(K)try{const V=I.join(H,"package.json");if(U.existsSync(V)){const Z=JSON.parse(U.readFileSync(V,"utf8")),$=typeof Z.name==="string"?Z.name.replace(/^@/,"").replace(/\//g,"-"):null;if($){const w=z.parse(Y),G=w.configs??{},O=G.service;if(typeof O==="object"&&O!==null&&!Array.isArray(O))O.name=$;else G.service={name:$};w.configs=G;Y=z.stringify(w)}}}catch{}U.writeFileSync(W,Y);return{tmpFilePath:W,created:!0,layout:buildTmpLayout(H,_(W),W)}}export function resolveTmpLayoutEnsured(E=process.cwd()){return ensureTmpFile(E).layout}
1
+ import U from"node:fs";import J from"node:path";import z from"yaml";import{Constants as I}from"../../../utils/constants";import{findAllFilesRecursively as L,findFileRecursively as A}from"../../../utils/helpers/core/paths";import{normalizeTmpDocument as D,readTmpServiceBlock as B,normalizeRootFolder as b,normalizeSourceFolder as x,resolveServiceLayoutPaths as k}from"../../../utils/helpers/tmp/tmp-schema";function M(E,q){return`${E}${q.startsWith(".")?q:`.${q}`}`}export function coreCanonicalTmpPath(E=process.cwd()){return J.join(J.resolve(E),I.packageRootFolder,M(I.tmpBaseName,I.tmpExtension))}export function assertCoreTmpGuard(E,q){if(!isCorePackageRoot(E))return;const H=coreCanonicalTmpPath(E);if(J.resolve(q)!==J.resolve(H))throw Error(`${I.packageName}: tmp.yml must stay at ${I.packageRootFolder}/tmp.yml (expected ${H}, got ${q})`)}function N(E,q){const H=J.resolve(E),K=J.resolve(q);return L(H,I.tmpBaseName,I.tmpExtension).filter((Q)=>J.resolve(Q)!==K)}export function ensureCoreTmpEntry(E=process.cwd(),q={}){const H=J.resolve(E);if(!isCorePackageRoot(H))throw Error(`ensureCoreTmpEntry is only for ${I.packageName} package root`);const K=coreCanonicalTmpPath(H),Q=N(H,K);if(Q.length>0){const X=Q.map((W)=>J.relative(H,W)).join(", ");throw Error(`${I.packageName}: tmp.yml must only exist under ${I.packageRootFolder}/. Remove extra copies: ${X}`)}if(U.existsSync(K)){assertCoreTmpGuard(H,K);return{tmpFilePath:K,created:!1,layout:buildTmpLayout(H,_(K),K)}}return ensureTmpFile(H,{...q,patchServiceName:!1})}function S(E,q,H){const K=J.resolve(E);if(isCorePackageRoot(K)){const Q=coreCanonicalTmpPath(K);return U.existsSync(Q)?Q:null}return A(K,q,H)}function _(E){return z.parse(U.readFileSync(E,"utf8"))}export function isCorePackageRoot(E){const q=J.join(J.resolve(E),"package.json");if(!U.existsSync(q))return!1;try{return JSON.parse(U.readFileSync(q,"utf8")).name===I.packageName}catch{return!1}}export function resolveRootFolderPath(E,q,H){const K=D(E).configs,Q=B(K);if(Q.paths?.root?.trim())return b(Q.paths.root);const X=E.project;if(typeof X?.name==="string"&&X.name.trim())return X.name.trim();const W=J.relative(J.resolve(H),J.dirname(J.resolve(q)));if(W&&W!==".")return W;return I.packageRootFolder}export function resolveLayoutPaths(E){const q=B(E);return k(q)}export function resolveMainFolderPath(E){const q=B(E);if(q.paths?.source?.trim())return x(q.paths.source);return I.mainSourceFolder}export function buildTmpLayout(E,q,H){const K=J.resolve(E),Q=q?D(q).configs:void 0,X=q&&H&&!isCorePackageRoot(K)?resolveRootFolderPath(q,H,K):I.packageRootFolder,W=J.join(K,X),Y=resolveLayoutPaths(Q),V=resolveMainFolderPath(Q),Z={tests:J.join(W,Y.tests),environments:J.join(W,Y.environments),dist:J.join(W,Y.dist)};return{projectRoot:K,rootFolderPath:X,rootFolderAbs:W,tmpFilePath:H,mainFolderPath:V,paths:Y,pathsAbs:Z}}export function resolveTmpLayout(E=process.cwd(),q={}){const H=q.tmpFileName??I.tmpBaseName,K=q.ext??I.tmpExtension,Q=S(E,H,K);if(!Q)throw Error(`${M(H,K)} not found under ${J.resolve(E)}`);if(isCorePackageRoot(J.resolve(E)))assertCoreTmpGuard(E,Q);return buildTmpLayout(E,_(Q),Q)}export function resolveTmpLayoutOrDefaults(E=process.cwd()){const q=S(E,I.tmpBaseName,I.tmpExtension);if(!q)return buildTmpLayout(E,null,null);return buildTmpLayout(E,_(q),q)}export function resolveBundledCoreTmpPath(E=process.cwd()){if(U.existsSync(I.bundledCoreTmpPath))return I.bundledCoreTmpPath;let q=J.resolve(E);while(q!==J.dirname(q)){const H=J.join(q,"node_modules","@xrystal","core",I.packageRootFolder,M(I.tmpBaseName,I.tmpExtension));if(U.existsSync(H))return H;const K=J.join(q,"package.json");if(U.existsSync(K)){if(JSON.parse(U.readFileSync(K,"utf8")).name===I.packageName){const X=J.join(q,I.packageRootFolder,M(I.tmpBaseName,I.tmpExtension));if(U.existsSync(X))return X}}q=J.dirname(q)}throw Error(`${I.packageName} bundled ${I.packageRootFolder}/tmp.yml not found`)}export function ownerTmpFilePath(E=process.cwd(),q){const H=q??resolveTmpLayoutOrDefaults(E);return J.join(H.rootFolderAbs,M(I.tmpBaseName,I.tmpExtension))}export function ensureTmpFile(E=process.cwd(),q={}){const H=J.resolve(E),K=q.patchServiceName??!0;if(isCorePackageRoot(H)){const V=coreCanonicalTmpPath(H),Z=N(H,V);if(Z.length>0){const $=Z.map((w)=>J.relative(H,w)).join(", ");throw Error(`${I.packageName}: tmp.yml must only exist under ${I.packageRootFolder}/. Remove extra copies: ${$}`)}if(U.existsSync(V)){assertCoreTmpGuard(H,V);return{tmpFilePath:V,created:!1,layout:buildTmpLayout(H,_(V),V)}}}else{const V=A(H,I.tmpBaseName,I.tmpExtension);if(V)return{tmpFilePath:V,created:!1,layout:buildTmpLayout(H,_(V),V)}}const Q=q.templatePath??resolveBundledCoreTmpPath(H);if(!U.existsSync(Q))throw Error(`${I.packageName} bundled ${I.packageRootFolder}/tmp.yml not found`);const X=buildTmpLayout(H,null,null);U.mkdirSync(X.rootFolderAbs,{recursive:!0});const W=ownerTmpFilePath(H,X);let Y=U.readFileSync(Q,"utf8");if(K)try{const V=J.join(H,"package.json");if(U.existsSync(V)){const Z=JSON.parse(U.readFileSync(V,"utf8")),$=typeof Z.name==="string"?Z.name.replace(/^@/,"").replace(/\//g,"-"):null;if($){const w=z.parse(Y),G=w.configs??{},O=G.service;if(typeof O==="object"&&O!==null&&!Array.isArray(O))O.name=$;else G.service={name:$};w.configs=G;Y=z.stringify(w)}}}catch{}U.writeFileSync(W,Y);return{tmpFilePath:W,created:!0,layout:buildTmpLayout(H,_(W),W)}}export function resolveTmpLayoutEnsured(E=process.cwd()){return ensureTmpFile(E).layout}
@@ -4,4 +4,4 @@ export { bindLoaderTmpSync, type ITmpSyncLoader, } from '../../../utils/helpers/
4
4
  export { resolveTmpWatchIntervalMs } from '../../../utils/helpers/tmp/tmp-watch';
5
5
  export { normalizeTmpDocument, normalizeRootFolder, normalizeSourceFolder, readTmpCoreBlock, readTmpServiceBlock, resolveServiceLayoutPaths, resolveTmpRuntimeConfigs, } from '../../../utils/helpers/tmp/tmp-schema';
6
6
  export { loadSeedFromBundledTmp, seedFromTmp, type SeedFromTmp, type SeedLayoutPaths, } from '../../../utils/helpers/tmp/seed-from-tmp';
7
- export { DEFAULT_LAYOUT_PATHS, normalizeLayoutPaths, type LayoutPaths, } from '../../../utils/helpers/tmp/path-normalize';
7
+ export { normalizeLayoutPaths, type LayoutPaths, } from '../../../utils/helpers/tmp/path-normalize';
@@ -1 +1 @@
1
- export{setRuntimeTmpConfigs,getRuntimeTmpConfigs,onRuntimeTmpChange,notifyRuntimeTmpChange,clearRuntimeTmpConfigs}from"../../../utils/helpers/tmp/runtime-tmp";export{getTmpLoader,getTmpLoaderPath,getTmpSnapshot,onTmpReload,resetTmpLoaderForTests,stopTmpLoader}from"../../../utils/helpers/tmp/tmp-loader";export{bindLoaderTmpSync}from"../../../utils/helpers/tmp/loader-tmp-sync";export{resolveTmpWatchIntervalMs}from"../../../utils/helpers/tmp/tmp-watch";export{normalizeTmpDocument,normalizeRootFolder,normalizeSourceFolder,readTmpCoreBlock,readTmpServiceBlock,resolveServiceLayoutPaths,resolveTmpRuntimeConfigs}from"../../../utils/helpers/tmp/tmp-schema";export{loadSeedFromBundledTmp,seedFromTmp}from"../../../utils/helpers/tmp/seed-from-tmp";export{DEFAULT_LAYOUT_PATHS,normalizeLayoutPaths}from"../../../utils/helpers/tmp/path-normalize";
1
+ export{setRuntimeTmpConfigs,getRuntimeTmpConfigs,onRuntimeTmpChange,notifyRuntimeTmpChange,clearRuntimeTmpConfigs}from"../../../utils/helpers/tmp/runtime-tmp";export{getTmpLoader,getTmpLoaderPath,getTmpSnapshot,onTmpReload,resetTmpLoaderForTests,stopTmpLoader}from"../../../utils/helpers/tmp/tmp-loader";export{bindLoaderTmpSync}from"../../../utils/helpers/tmp/loader-tmp-sync";export{resolveTmpWatchIntervalMs}from"../../../utils/helpers/tmp/tmp-watch";export{normalizeTmpDocument,normalizeRootFolder,normalizeSourceFolder,readTmpCoreBlock,readTmpServiceBlock,resolveServiceLayoutPaths,resolveTmpRuntimeConfigs}from"../../../utils/helpers/tmp/tmp-schema";export{loadSeedFromBundledTmp,seedFromTmp}from"../../../utils/helpers/tmp/seed-from-tmp";export{normalizeLayoutPaths}from"../../../utils/helpers/tmp/path-normalize";
@@ -1,10 +1,8 @@
1
- /** Pure path normalizers — no Constants / no I/O (shared by seed + schema). */
2
1
  export type LayoutPaths = {
3
2
  tests: string;
4
3
  environments: string;
5
4
  dist: string;
6
5
  };
7
- export declare const DEFAULT_LAYOUT_PATHS: Readonly<LayoutPaths>;
8
- export declare function normalizeRootFolder(value: unknown, fallback?: string): string;
9
- export declare function normalizeSourceFolder(value: unknown, fallback?: string): string;
10
- export declare function normalizeLayoutPaths(special: unknown, fallback?: LayoutPaths): LayoutPaths;
6
+ export declare function normalizeRootFolder(value: unknown, fallback: string): string;
7
+ export declare function normalizeSourceFolder(value: unknown, fallback: string): string;
8
+ export declare function normalizeLayoutPaths(special: unknown, fallback: LayoutPaths): LayoutPaths;
@@ -1 +1 @@
1
- export const DEFAULT_LAYOUT_PATHS=Object.freeze({tests:"tests",environments:"environments",dist:"dist"});export function normalizeRootFolder(t,n="x"){if(typeof t!=="string"||!t.trim())return n;return t.trim().replace(/^\.\/+/,"")}export function normalizeSourceFolder(t,n="./source"){if(typeof t!=="string"||!t.trim())return n;const r=t.trim();if(r.startsWith("./")||r.startsWith("../"))return r;return`./${r}`}export function normalizeLayoutPaths(t,n=DEFAULT_LAYOUT_PATHS){const r=t&&typeof t==="object"&&!Array.isArray(t)?t:{},e=(s)=>{const o=r[s];return typeof o==="string"&&o.trim()?o.trim():n[s]};return{tests:e("tests"),environments:e("environments"),dist:e("dist")}}
1
+ export function normalizeRootFolder(t,n){if(typeof t!=="string"||!t.trim())return n;return t.trim().replace(/^\.\/+/,"")}export function normalizeSourceFolder(t,n){if(typeof t!=="string"||!t.trim())return n;const r=t.trim();if(r.startsWith("./")||r.startsWith("../"))return r;return`./${r}`}export function normalizeLayoutPaths(t,n){const r=t&&typeof t==="object"&&!Array.isArray(t)?t:{},o=(e)=>{const i=r[e];return typeof i==="string"&&i.trim()?i.trim():n[e]};return{tests:o("tests"),environments:o("environments"),dist:o("dist")}}
@@ -1,8 +1,11 @@
1
+ import defaults from '../../../utils/constants/defaults.json';
1
2
  import { type LayoutPaths } from '../../../utils/helpers/tmp/path-normalize';
3
+ export { defaults as packageIdentityDefaults };
2
4
  export type SeedLayoutPaths = LayoutPaths;
3
5
  export type SeedFromTmp = {
4
6
  rootFolder: string;
5
7
  sourceFolder: string;
8
+ framework: string;
6
9
  layout: SeedLayoutPaths;
7
10
  };
8
11
  export declare function loadSeedFromBundledTmp(tmpFilePath?: string): SeedFromTmp;
@@ -1 +1 @@
1
- import I from"node:fs";import N from"node:path";import Q from"yaml";import j from"../../../utils/constants/defaults.json" with { type: 'json' };import{packageRootDir as V}from"../../../utils/package-root";import{DEFAULT_LAYOUT_PATHS as J,normalizeLayoutPaths as W,normalizeRootFolder as X,normalizeSourceFolder as Z}from"../../../utils/helpers/tmp/path-normalize";export function loadSeedFromBundledTmp(K){const G=K??N.join(V,j.packageRootFolder,`${j.tmpBaseName}${j.tmpExtension}`),M={rootFolder:j.packageRootFolder,sourceFolder:"./source",layout:{...J}};if(!I.existsSync(G))return M;const q=Q.parse(I.readFileSync(G,"utf8")),w=q?.configs&&typeof q.configs==="object"?q.configs:{},x=w.service&&typeof w.service==="object"?w.service:{},C=x.paths&&typeof x.paths==="object"?x.paths:{};return{rootFolder:X(C.root,j.packageRootFolder),sourceFolder:Z(C.source,"./source"),layout:W(C.special,J)}}export const seedFromTmp=loadSeedFromBundledTmp();
1
+ import J from"node:fs";import I from"node:path";import{fileURLToPath as Q}from"node:url";import V from"yaml";import defaults from"../../../utils/constants/defaults.json" with { type: 'json' };import{normalizeRootFolder as W,normalizeSourceFolder as X}from"../../../utils/helpers/tmp/path-normalize";export{defaults as packageIdentityDefaults};const M=I.dirname(Q(import.meta.url)),O=`${defaults.tmpBaseName}${defaults.tmpExtension}`;function H(j,A){if(typeof j!=="string"||!j.trim())throw Error(`${defaults.packageName}: bundled tmp.yml missing ${A}`);return j.trim()}function Y(j){const A=j&&typeof j==="object"&&!Array.isArray(j)?j:{};return{tests:H(A.tests,"configs.service.paths.special.tests"),environments:H(A.environments,"configs.service.paths.special.environments"),dist:H(A.dist,"configs.service.paths.special.dist")}}function Z(j){if(j){if(!J.existsSync(j))throw Error(`${defaults.packageName}: bundled tmp.yml missing at ${j}`);return j}const A=[M,process.cwd()];for(const G of A){let C=I.resolve(G);for(;;){const D=I.join(C,defaults.packageRootFolder,O);if(J.existsSync(D))return D;const E=I.dirname(C);if(E===C)break;C=E}}throw Error(`${defaults.packageName}: bundled ${defaults.packageRootFolder}/${O} not found from ${M}`)}export function loadSeedFromBundledTmp(j){const A=Z(j),G=V.parse(J.readFileSync(A,"utf8")),C=G?.configs&&typeof G.configs==="object"?G.configs:{},D=C.service&&typeof C.service==="object"?C.service:{},E=D.paths&&typeof D.paths==="object"?D.paths:{},K=H(E.source,"configs.service.paths.source");return{rootFolder:W(E.root,defaults.packageRootFolder),sourceFolder:X(K,K),framework:H(D.framework,"configs.service.framework"),layout:Y(E.special)}}export const seedFromTmp=loadSeedFromBundledTmp();
@@ -35,14 +35,10 @@ export type TmpRuntimeConfigs = {
35
35
  core: TmpCoreBlock;
36
36
  rootFolderPath: string;
37
37
  };
38
- /** `paths.root` → folder name under project root (`x`, `infra`). */
39
38
  export declare function normalizeRootFolder(value?: string): string;
40
- /** `paths.source` → dev/build source folder (`./source`, `./src`). */
41
39
  export declare function normalizeSourceFolder(value?: string): string;
42
40
  export declare function readTmpCoreBlock(configs?: Record<string, unknown>): TmpCoreBlock;
43
41
  export declare function readTmpServiceBlock(configs?: Record<string, unknown>): TmpServiceBlock;
44
- /** Project layout from tmp.yml; omitted specials → bootstrap layout (same as bundled x/tmp.yml). */
45
42
  export declare function resolveServiceLayoutPaths(service: TmpServiceBlock): TmpLayoutPathsFlat;
46
- /** Canonical tmp.yml shape — `service` + `core` + derived `rootFolderPath`. */
47
43
  export declare function resolveTmpRuntimeConfigs(tmp?: Record<string, unknown> | null): TmpRuntimeConfigs;
48
44
  export declare function normalizeTmpDocument(tmp: Record<string, unknown>): Record<string, unknown>;
@@ -1 +1 @@
1
- import X from"../../../utils/constants/defaults.json" with { type: 'json' };import{DEFAULT_LAYOUT_PATHS as D,normalizeLayoutPaths as H,normalizeRootFolder as I,normalizeSourceFolder as W}from"../../../utils/helpers/tmp/path-normalize";const Z="./source";function G(j){return typeof j==="object"&&j!==null&&!Array.isArray(j)}function Y(j){if(typeof j==="number"||typeof j==="string")return j;return}export function normalizeRootFolder(j){return I(j,X.packageRootFolder)}export function normalizeSourceFolder(j){return W(j,Z)}export function readTmpCoreBlock(j){const q=G(j?.core)?j.core:{},x=G(q.tmp)?q.tmp:{};return{tmp:{fileWatchIntervalMs:Y(x.fileWatchIntervalMs)}}}export function readTmpServiceBlock(j){const q=G(j?.service)?j.service:{},x=G(q.paths)?q.paths:{},J=G(x.special)?x.special:{};let K=G(q.loaders)?{...q.loaders}:void 0,M=G(q.build)?q.build:void 0;if(K&&G(K.build)){const{build:Q,...$}=K;K=$;if(!M&&G(Q))M=Q}return{name:typeof q.name==="string"?q.name:void 0,framework:typeof q.framework==="string"?q.framework:void 0,paths:{root:typeof x.root==="string"?x.root:void 0,source:typeof x.source==="string"?x.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 H(j.paths?.special,D)}function k(j){const q=resolveServiceLayoutPaths(j);return{name:j.name,framework:j.framework??"elysia",paths:{root:j.paths?.root??X.packageRootFolder,source:j.paths?.source??Z,special:q},protocols:j.protocols,loaders:j.loaders,build:j.build}}function N(j){return{tmp:{fileWatchIntervalMs:j.tmp?.fileWatchIntervalMs}}}export function resolveTmpRuntimeConfigs(j){const q=G(j?.configs)?j.configs:{},x=readTmpServiceBlock(q),J=readTmpCoreBlock(q),K=k(x);return{service:K,core:N(J),rootFolderPath:normalizeRootFolder(K.paths.root)}}export function normalizeTmpDocument(j){return{...j,configs:resolveTmpRuntimeConfigs(j)}}
1
+ import K from"../../../utils/constants/defaults.json" with { type: 'json' };import{seedFromTmp as G}from"../../../utils/helpers/tmp/seed-from-tmp";import{normalizeLayoutPaths as O,normalizeRootFolder as Q,normalizeSourceFolder as U}from"../../../utils/helpers/tmp/path-normalize";function A(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 normalizeRootFolder(j){return Q(j,K.packageRootFolder)}export function normalizeSourceFolder(j){return U(j,G.sourceFolder)}export function readTmpCoreBlock(j){const q=A(j?.core)?j.core:{},x=A(q.tmp)?q.tmp:{};return{tmp:{fileWatchIntervalMs:X(x.fileWatchIntervalMs)}}}export function readTmpServiceBlock(j){const q=A(j?.service)?j.service:{},x=A(q.paths)?q.paths:{},D=A(x.special)?x.special:{};let E=A(q.loaders)?{...q.loaders}:void 0,H=A(q.build)?q.build:void 0;if(E&&A(E.build)){const{build:J,...M}=E;E=M;if(!H&&A(J))H=J}return{name:typeof q.name==="string"?q.name:void 0,framework:typeof q.framework==="string"?q.framework:void 0,paths:{root:typeof x.root==="string"?x.root:void 0,source:typeof x.source==="string"?x.source:void 0,special:{tests:typeof D.tests==="string"?D.tests:void 0,environments:typeof D.environments==="string"?D.environments:void 0,dist:typeof D.dist==="string"?D.dist:void 0}},protocols:q.protocols,loaders:E,build:H}}export function resolveServiceLayoutPaths(j){return O(j.paths?.special,G.layout)}function Y(j){const q=resolveServiceLayoutPaths(j);return{name:j.name,framework:j.framework??G.framework,paths:{root:j.paths?.root??K.packageRootFolder,source:j.paths?.source??G.sourceFolder,special:q},protocols:j.protocols,loaders:j.loaders,build:j.build}}function Z(j){return{tmp:{fileWatchIntervalMs:j.tmp?.fileWatchIntervalMs}}}export function resolveTmpRuntimeConfigs(j){const q=A(j?.configs)?j.configs:{},x=readTmpServiceBlock(q),D=readTmpCoreBlock(q),E=Y(x);return{service:E,core:Z(D),rootFolderPath:normalizeRootFolder(E.paths.root)}}export function normalizeTmpDocument(j){return{...j,configs:resolveTmpRuntimeConfigs(j)}}
@@ -1 +1 @@
1
- var __filename="/home/runner/work/-xrystal-core/-xrystal-core/x/dist/utils/models/classes/class.x.js";import{createContainer as w,asClass as y,asValue as L,InjectionMode as z,listModules as C,Lifetime as h}from"awilix";import p from"node:path";import{pathToFileURL as A}from"node:url";export const xSymbol=Symbol.for("@xrystal/core/di-container");class I{checkRegistration(e,t){return!!e.registrations[t]}}class N extends I{container;initializedNames=new Set;loadedPaths=new Set;registeredClasses=new Set;isInitializing=!1;constructor(){super();this.container=w({injectionMode:z.PROXY,strict:!0})}getName(e){if(typeof e==="string")return e.charAt(0).toLowerCase()+e.slice(1);if(typeof e==="function"&&e.name)return e.name.charAt(0).toLowerCase()+e.name.slice(1);return""}async load(e,t={}){const{verbose:r=!1,exclude:m=[],lifetime:s=h.SINGLETON}=t,i=process.cwd(),n=(Array.isArray(e)?e:[e]).map((c)=>{return(p.isAbsolute(c)?c:p.resolve(i,c)).replace(/\\/g,"/").toLowerCase()});let a=[];try{a=C(n)}catch(c){return this}for(const c of a){const f=c.path.replace(/\\/g,"/").toLowerCase();if(this.loadedPaths.has(f))continue;if(f===__filename.replace(/\\/g,"/").toLowerCase()||f.endsWith(".d.ts"))continue;try{const g=await import(A(c.path).href);let o=g.default;if(!o)o=Object.values(g).find((l)=>typeof l==="function"&&!!l.prototype&&!!l.name);if(typeof o==="function"&&!!o.prototype&&!!o.name){if(this.registeredClasses.has(o))continue;const l=this.getName(o);if(l&&!this.checkRegistration(this.container,l)){this.container.register({[l]:y(o).setLifetime(s)});this.loadedPaths.add(f);this.registeredClasses.add(o)}}}catch(u){if(r)console.error("[DI] Load Error:",u.message)}}return this}register(e,t=h.SINGLETON){const r=this.getName(e);if(!r||this.registeredClasses.has(e))return this;if(this.checkRegistration(this.container,r))return this;this.container.register({[r]:y(e).setLifetime(t)});this.registeredClasses.add(e);return this}registerInstance(e,t){if(!e)return this;const r=this.getName(e);this.container.register({[r]:L(t)});return this}async initialize(e,t=!1){if(this.isInitializing)return this;this.isInitializing=!0;try{const r=e?Array.isArray(e)?e:[e]:[];for(const s of r){const i=this.getName(s.service);if(!i||this.initializedNames.has(i))continue;const n=this.container.registrations[i];if(!n||n.lifetime!==h.SINGLETON)continue;try{const a=this.container.cradle[i];if(a&&typeof a.onInit==="function")await a.onInit(s.props||{});this.initializedNames.add(i)}catch(a){if(t)console.error(`[DI] Priority onInit Failed (${i}):`,a.message)}}const m=Object.keys(this.container.registrations);for(const s of m){if(this.initializedNames.has(s))continue;if(this.container.registrations[s].lifetime!==h.SINGLETON)continue;try{const n=this.container.cradle[s];if(n&&typeof n.onInit==="function")await n.onInit({});this.initializedNames.add(s)}catch(n){if(t)console.error(`[DI] Auto onInit Failed (${s}):`,n.message)}}for(const s of this.initializedNames)try{const i=this.container.cradle[s];if(i&&typeof i.onAfterInit==="function")await i.onAfterInit()}catch(i){if(t)console.error(`[DI] onAfterInit Failed (${s}):`,i.message)}}finally{this.isInitializing=!1}return this}get(e){const t=this.getName(e);return this.container.resolve(t)}async shutdown(){for(const e of this.initializedNames)try{const t=this.container.cradle[e];if(t&&typeof t.onDispose==="function")await t.onDispose()}catch(t){console.error(`[DI] onDispose Failed (${e})`)}await this.container.dispose()}get cradle(){return this.container.cradle}}const d=globalThis;if(!d[xSymbol])d[xSymbol]=new N;export default d[xSymbol];
1
+ var __filename="/home/runner/work/-xrystal-core/-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];
@@ -1,28 +0,0 @@
1
- {
2
- "packageName": "@xrystal/core",
3
- "packageRootFolder": "x",
4
- "cliName": "xry",
5
- "cliBinNames": [
6
- "xry"
7
- ],
8
- "tmpBaseName": "tmp",
9
- "tmpExtension": ".yml",
10
- "templateRepoUri": "https://github.com/xdloper/api-gpt-svc",
11
- "publicFolderName": "public",
12
- "kafkaLogsTopic": "log",
13
- "pathAliasKey": "@/*",
14
- "eslintRestrictedImportDepth": 2,
15
- "tmpWatchDefaults": {
16
- "intervalMs": 500,
17
- "minIntervalMs": 100,
18
- "maxIntervalMs": 10000
19
- },
20
- "buildDefaults": {
21
- "tsconfig": "tsconfig.json",
22
- "typecheck": false,
23
- "tscLenient": false,
24
- "declarations": false,
25
- "sourcemap": false,
26
- "minify": false
27
- }
28
- }