@xrystal/core 3.9.9 → 3.10.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.9.9",
4
+ "version": "3.10.2",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
package/source/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- declare let tmp: any;
2
- export default tmp;
1
+ export {};
package/source/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import coreLoader from "./project/index.js";
2
- let tmp;
3
2
  // => tmp project tool => xrystal
4
3
  await (async () => {
5
- tmp = await coreLoader({});
4
+ const core = await coreLoader({});
6
5
  })();
7
6
  //
8
- export default tmp;
@@ -1,9 +1,8 @@
1
+ export declare const core: {
2
+ _: any;
3
+ };
1
4
  export declare const coreInit: (params: {
2
5
  locales?: Record<string, any>;
3
6
  }) => Promise<void>;
4
- declare const coreLoader: ({}: {}) => Promise<{
5
- _?: undefined;
6
- } | {
7
- _: any;
8
- }>;
7
+ declare const coreLoader: ({}: {}) => Promise<{}>;
9
8
  export default coreLoader;
@@ -1,9 +1,10 @@
1
1
  // => import dependencies
2
2
  import path from 'path';
3
3
  import { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService, ClientsService } from '../loader/index';
4
- import { packageName, tmpFileDefaultName, tmpFileDefaultExt, findFileRecursively, TmpFileLoader, x, kafkaBrokers, systemLoggerLayer, } from '../utils/index';
4
+ import { packageName, x, kafkaBrokers, systemLoggerLayer, getTmp, } from '../utils/index';
5
5
  //
6
6
  let coreHasRun = false;
7
+ export const core = getTmp();
7
8
  export const coreInit = async (params) => {
8
9
  const { locales } = params;
9
10
  if (locales)
@@ -13,13 +14,7 @@ const coreLoader = async ({}) => {
13
14
  if (coreHasRun)
14
15
  return {};
15
16
  try {
16
- const ownerTmpFilePath = findFileRecursively(".", tmpFileDefaultName, tmpFileDefaultExt);
17
- if (!ownerTmpFilePath) {
18
- throw new Error(`${tmpFileDefaultName} file not found`);
19
- }
20
- const tmpFileObject = new TmpFileLoader({ filePath: ownerTmpFilePath });
21
- const r = tmpFileObject.getResolvedTmpFile();
22
- const { configs } = r;
17
+ const { configs } = core._;
23
18
  const rootFolderPath = configs.rootFolderPath;
24
19
  const services = [
25
20
  SystemService,
@@ -37,10 +32,10 @@ const coreLoader = async ({}) => {
37
32
  const i18n = x.get(LocalizationsService);
38
33
  const clientsService = x.get(ClientsService);
39
34
  await system.load({
40
- tmp: r
35
+ tmp: core._
41
36
  });
42
37
  configService.load({
43
- tmp: r,
38
+ tmp: core._,
44
39
  systemService: system,
45
40
  ...(configs.loaders.configs.globalEnvFileName && { globalEnvFileName: configs.loaders.configs.globalEnvFileName })
46
41
  });
@@ -64,7 +59,7 @@ const coreLoader = async ({}) => {
64
59
  configs: configService,
65
60
  });
66
61
  coreHasRun = true;
67
- return { _: r };
62
+ return {};
68
63
  }
69
64
  catch (error) {
70
65
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -1,3 +1,11 @@
1
+ export declare const getTmp: () => {
2
+ _: any;
3
+ };
4
+ export declare const getTmpConfig: ({ root, tmpFileName, ext }: {
5
+ root?: string;
6
+ tmpFileName?: string;
7
+ ext?: string;
8
+ }) => any;
1
9
  export declare function resolveObjWithHandlebars(obj: any, context: any): any;
2
10
  export declare function findFileRecursively(startDir: string, baseName: string, extName?: string, excludedDirs?: string[]): string | null;
3
11
  export declare const argvsConverter: (argvs: string) => {
@@ -1,7 +1,25 @@
1
1
  import path from "path";
2
2
  import fs from 'fs';
3
3
  import Handlebars from 'handlebars';
4
- import { SupportFileExtensionsEnum } from "../../index.js";
4
+ import { SupportFileExtensionsEnum, tmpFileDefaultExt, tmpFileDefaultName, TmpFileLoader } from "../../index.js";
5
+ export const getTmp = () => {
6
+ const ownerTmpFilePath = findFileRecursively(".", tmpFileDefaultName, tmpFileDefaultExt);
7
+ if (!ownerTmpFilePath) {
8
+ throw new Error(`${tmpFileDefaultName} file not found`);
9
+ }
10
+ const tmpFileObject = getTmpConfig({});
11
+ return {
12
+ _: tmpFileObject
13
+ };
14
+ };
15
+ export const getTmpConfig = ({ root = '.', tmpFileName = tmpFileDefaultName, ext = '.yml' }) => {
16
+ const path = findFileRecursively(root, tmpFileName, ext);
17
+ if (!path) {
18
+ throw new Error(`${name}.${ext} file not found`);
19
+ }
20
+ const loader = new TmpFileLoader({ filePath: path });
21
+ return loader.getResolvedTmpFile();
22
+ };
5
23
  export function resolveObjWithHandlebars(obj, context) {
6
24
  if (typeof obj === "string") {
7
25
  const compileResult = Handlebars.compile(obj);