@xrystal/core 3.18.0 → 3.18.6

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.
@@ -1,14 +1,17 @@
1
- import path from 'path'
1
+ import path from "node:path"
2
2
 
3
- import { __filename, __dirname } from '../helpers/index.mjs'
3
+ export class Constants {
4
+ static packageName = '@xrystal/core'
4
5
 
5
- export const packageName = '@xrystal/core'
6
+ static defaultRootFolderName = 'x'
7
+ static defaultTmpFileName = 'tmp'
8
+ static defaultTmpFileExt = '.yml'
6
9
 
7
- export const tmpFileDefaultMainFolderName = 'x'
8
- export const tmpFileDefaultName = 'tmp'
9
- export const tmpFileDefaultExt = '.yml'
10
+ static defaultTmpFilePath = path.join(__dirname, `../../${Constants.defaultRootFolderName}/${Constants.defaultTmpFileName}.${Constants.defaultTmpFileExt}`)
11
+ static defaultOwnerTmpFilePath = path.join(process.cwd(),`./${Constants.defaultRootFolderName}/${Constants.defaultTmpFileName}.${Constants.defaultTmpFileExt}`)
10
12
 
11
- export const defaultTmpFilePath = path.resolve(__dirname(__filename(import.meta.url)), `../../${tmpFileDefaultMainFolderName}/${tmpFileDefaultName}.yml`)
12
- export const defaultOwnerTmpFilePath = path.resolve(`./${tmpFileDefaultMainFolderName}/${tmpFileDefaultName}.yml`)
13
+ static publicFolderName = 'public'
14
+ static kafkaLogsTopic = 'logs'
13
15
 
14
- export const templateRepoUri = 'https://github.com/xdloper/xastral-general-project-tmp.git'
16
+ static templateRepoUri = 'https://github.com/xdloper/xastral-general-project-tmp.git'
17
+ }
package/bin/main-cli.js CHANGED
@@ -8,128 +8,124 @@ import chalk from "chalk"
8
8
  import ora from "ora"
9
9
  import yaml from "yaml"
10
10
 
11
- import {
12
- defaultOwnerTmpFilePath,
13
- defaultTmpFilePath,
14
- packageName,
15
- templateRepoUri,
16
- tmpFileDefaultExt,
17
- tmpFileDefaultMainFolderName,
18
- tmpFileDefaultName
19
- } from "./constants/index.mjs"
11
+ import { Constants } from "./constants/index.mjs"
20
12
  import { findFileRecursively, resolveObjWithHandlebars } from "./helpers/index.mjs"
21
13
 
22
14
  const setupCLI = async () => {
23
- const cli = new Command()
15
+ const cli = new Command()
16
+
17
+ const isBun = !!process.versions.bun
18
+ const runtimeName = isBun ? "Bun" : "Node.js"
19
+ const packageManager = isBun ? "bun" : "npm"
20
+ const installCommand = isBun ? "bun install" : "npm install"
21
+ const devCommand = isBun ? "bun run dev:local" : "npm run dev:local"
22
+
23
+ try {
24
+ let ownerTmpFilePath = findFileRecursively(".", Constants.defaultTmpFileName, Constants.defaultTmpFileExt)
25
+
26
+ if (!ownerTmpFilePath) {
27
+ if (!Constants.defaultTmpFilePath || !fs.existsSync(Constants.defaultTmpFilePath)) {
28
+ throw new Error("Default template configuration file not found in package")
29
+ }
30
+
31
+ const folderPath = path.resolve(Constants.defaultRootFolderName)
32
+ if (!fs.existsSync(folderPath)) {
33
+ fs.mkdirSync(folderPath, { recursive: true })
34
+ }
35
+
36
+ const tmpFilePathBuffer = fs.readFileSync(Constants.defaultTmpFilePath)
37
+ fs.writeFileSync(Constants.defaultOwnerTmpFilePath, tmpFilePathBuffer)
38
+ ownerTmpFilePath = Constants.defaultOwnerTmpFilePath
39
+ }
24
40
 
25
- const isBun = !!process.versions.bun
26
- const runtimeName = isBun ? "Bun" : "Node.js"
27
- const packageManager = isBun ? "bun" : "npm"
28
- const installCommand = isBun ? "bun install" : "npm install"
29
- const devCommand = isBun ? "bun run dev:local" : "npm run dev:local"
41
+ const ownerTmpFile = fs.readFileSync(ownerTmpFilePath, "utf8")
42
+ const parsedTmpObject = yaml.parse(ownerTmpFile)
43
+ const resolvedTmpObject = resolveObjWithHandlebars(parsedTmpObject, parsedTmpObject)
30
44
 
31
- try {
32
- let ownerTmpFilePath = findFileRecursively(".", tmpFileDefaultName, tmpFileDefaultExt)
45
+ cli
46
+ .command("create <project-name> [target-path]")
47
+ .description(`Project initializer using ${runtimeName}`)
48
+ .action(async (projectName, targetDir) => {
49
+ let targetPath = ""
50
+ const isCurrentDir = projectName === "."
33
51
 
34
- if (!ownerTmpFilePath) {
35
- if (!defaultTmpFilePath || !fs.existsSync(defaultTmpFilePath)) {
36
- throw new Error("Default template configuration file not found in package")
37
- }
52
+ if (targetDir) {
53
+ const baseDir = path.resolve(process.cwd(), targetDir)
54
+ targetPath = isCurrentDir ? baseDir : path.join(baseDir, projectName)
55
+ } else {
56
+ targetPath = isCurrentDir ? process.cwd() : path.resolve(process.cwd(), projectName)
57
+ }
38
58
 
39
- const tmpFilePathBuffer = fs.readFileSync(defaultTmpFilePath)
40
- const folderPath = path.resolve(tmpFileDefaultMainFolderName || ".xrystal")
59
+ if (fs.existsSync(targetPath) && fs.readdirSync(targetPath).length > 0) {
60
+ console.log(chalk.red(`❌ Error: Target directory '${targetPath}' is not empty!`))
61
+ process.exit(1)
62
+ }
41
63
 
42
- if (!fs.existsSync(folderPath)) {
43
- fs.mkdirSync(folderPath, { recursive: true })
44
- }
64
+ const mainPath = resolvedTmpObject?.configs?.mainFolderPath || "./source"
45
65
 
46
- fs.writeFileSync(defaultOwnerTmpFilePath, tmpFilePathBuffer)
47
- ownerTmpFilePath = defaultOwnerTmpFilePath
48
- }
66
+ if (!fs.existsSync(targetPath)) {
67
+ fs.mkdirSync(targetPath, { recursive: true })
68
+ }
49
69
 
50
- const ownerTmpFile = fs.readFileSync(ownerTmpFilePath, "utf8")
51
- const parsedTmpObject = yaml.parse(ownerTmpFile)
52
- const resolvedTmpObject = resolveObjWithHandlebars(parsedTmpObject, parsedTmpObject)
70
+ const spinner = ora(`${runtimeName} environment detected. Cloning template...`).start()
53
71
 
54
- const mainPath = resolvedTmpObject?.configs?.mainFolderPath || "./source"
55
- const projectMainFolderPath = path.resolve(mainPath)
72
+ try {
73
+ execSync(`git clone --depth 1 ${Constants.templateRepoUri} "${targetPath}"`, { stdio: "ignore" })
56
74
 
57
- if (!fs.existsSync(projectMainFolderPath)) {
58
- fs.mkdirSync(projectMainFolderPath, { recursive: true })
59
- }
75
+ const gitFolder = path.join(targetPath, ".git")
76
+ if (fs.existsSync(gitFolder)) {
77
+ fs.rmSync(gitFolder, { recursive: true, force: true })
78
+ }
60
79
 
61
- cli
62
- .command("create <project-name> [target-path]")
63
- .description(`Project initializer using ${runtimeName}`)
64
- .action(async (projectName, targetDir) => {
65
- let targetPath = ""
66
- const isCurrentDir = projectName === "."
67
-
68
- if (targetDir) {
69
- const baseDir = path.resolve(process.cwd(), targetDir)
70
- targetPath = isCurrentDir ? baseDir : path.join(baseDir, projectName)
71
- } else {
72
- targetPath = isCurrentDir ? process.cwd() : path.resolve(process.cwd(), projectName)
73
- }
80
+ try {
81
+ execSync(`git init`, { cwd: targetPath, stdio: "ignore" })
82
+ } catch (e) {
83
+ // Git init fail
84
+ }
74
85
 
75
- if (fs.existsSync(targetPath) && fs.readdirSync(targetPath).length > 0) {
76
- console.log(chalk.red(`❌ Error: Target directory '${targetPath}' is not empty!`))
77
- process.exit(1)
78
- }
79
-
80
- if (!fs.existsSync(targetPath)) {
81
- fs.mkdirSync(targetPath, { recursive: true })
82
- }
86
+ const projectMainFolderPath = path.resolve(targetPath, mainPath)
87
+ if (!fs.existsSync(projectMainFolderPath)) {
88
+ fs.mkdirSync(projectMainFolderPath, { recursive: true })
89
+ }
83
90
 
84
- const spinner = ora(`${runtimeName} environment detected. Cloning template...`).start()
91
+ spinner.succeed(chalk.green("Template cloned and git initialized!"))
92
+ console.log(chalk.blue(`\n📦 Installing dependencies with ${packageManager}...`))
85
93
 
86
- try {
87
- execSync(`git clone --depth 1 ${templateRepoUri} "${targetPath}"`, { stdio: "ignore" })
94
+ execSync(installCommand, { cwd: targetPath, stdio: "inherit" })
88
95
 
89
- const gitFolder = path.join(targetPath, ".git")
90
- if (fs.existsSync(gitFolder)) {
91
- fs.rmSync(gitFolder, { recursive: true, force: true })
92
- }
96
+ console.log(chalk.green("\n✅ Done!"))
93
97
 
94
- try {
95
- execSync(`git init`, { cwd: targetPath, stdio: "ignore" })
96
- } catch (e) {
97
- }
98
+ const relativePath = path.relative(process.cwd(), targetPath)
99
+ if (relativePath && relativePath !== ".") {
100
+ console.log(chalk.cyan(`\n cd ${relativePath}`))
101
+ }
102
+ console.log(chalk.cyan(` ${devCommand}`))
98
103
 
99
- spinner.succeed(chalk.green("Template cloned and git initialized!"))
100
- console.log(chalk.blue(`\n📦 Installing dependencies with ${packageManager}...`))
104
+ } catch (err) {
105
+ spinner.fail(chalk.red("Failed!"))
106
+ console.error(chalk.red(`\nDetails: ${err.message}`))
101
107
 
102
- execSync(installCommand, { cwd: targetPath, stdio: "inherit" })
108
+ if (fs.existsSync(targetPath) && !isCurrentDir) {
109
+ const files = fs.readdirSync(targetPath)
103
110
 
104
- console.log(chalk.green("\n✅ Done!"))
111
+ if (files.length < 5) {
112
+ fs.rmSync(targetPath, { recursive: true, force: true })
113
+ console.log(chalk.yellow(`🧹 Cleaned up failed installation at ${targetPath}`))
114
+ }
115
+ }
116
+ }
117
+ })
105
118
 
106
- const relativePath = path.relative(process.cwd(), targetPath)
107
- if (relativePath && relativePath !== ".") {
108
- console.log(chalk.cyan(`\n cd ${relativePath}`))
109
- }
119
+ cli.parse(process.argv)
110
120
 
111
- console.log(chalk.cyan(` ${devCommand}`))
112
-
113
- } catch (err) {
114
- spinner.fail(chalk.red("Failed!"))
115
- console.error(chalk.red(`\nDetails: ${err.message}`))
116
-
117
- if (fs.existsSync(targetPath) && targetPath !== process.cwd() && fs.readdirSync(targetPath).length === 0) {
118
- fs.rmSync(targetPath, { recursive: true, force: true })
119
- }
120
- }
121
- })
122
-
123
- cli.parse(process.argv)
124
-
125
- } catch (error) {
126
- console.error(`${packageName || "CLI"} Initialization Error:`, error?.message)
127
- }
121
+ } catch (error) {
122
+ console.error(`${Constants.packageName || "CLI"} Initialization Error:`, error?.message)
123
+ }
128
124
  }
129
125
 
130
126
  process.on("uncaughtException", (error) => {
131
- console.error("Critical Error:", error.message)
132
- process.exit(1)
127
+ console.error("Critical Error:", error.message)
128
+ process.exit(1)
133
129
  })
134
130
 
135
131
  setupCLI()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Yusuf Yasir KAYGUSUZ",
3
3
  "name": "@xrystal/core",
4
- "version": "3.18.0",
4
+ "version": "3.18.6",
5
5
  "description": "Project core for xrystal",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -1,13 +1,39 @@
1
1
  import SystemService from '../system/index';
2
2
  import { IService } from '../../utils';
3
+ export interface IConfig {
4
+ worker: boolean;
5
+ nodeEnv: string;
6
+ debug: string;
7
+ https: string;
8
+ httpsfileEncoding: string;
9
+ httpsCertfile: string;
10
+ httpsKeyfile: string;
11
+ rootFolderPath: string;
12
+ projectName: string;
13
+ serviceName: string;
14
+ projectNamePrefixEnv: string;
15
+ projectNameEnv: string;
16
+ projectNameSuffixEnv: string;
17
+ systemStaticFolderPath: string;
18
+ systemLoggerLayer: string;
19
+ kafkaBrokers: string;
20
+ kafkaLogsTopic: string;
21
+ baseApiUri: string;
22
+ port: number;
23
+ internalSecret: string;
24
+ secret: string;
25
+ cwd: string;
26
+ env: string;
27
+ }
3
28
  export default class ConfigsService implements IService {
4
29
  #private;
5
30
  private config;
6
- publicFolderName: string;
7
- kafkaLogsTopic: string;
31
+ readonly publicFolderName: string;
32
+ readonly kafkaLogsTopic: string;
8
33
  constructor({ systemService }: {
9
34
  systemService: SystemService;
10
35
  });
11
36
  load: ({}: {}) => void;
12
- get all(): Record<string, any>;
37
+ setConfig(newConfigs: any): void;
38
+ get all(): IConfig;
13
39
  }
@@ -1,9 +1,9 @@
1
1
  import path from 'node:path';
2
- import { kafkaLogsTopic, publicFolderName } from '../../utils';
2
+ import { Constants } from '../../utils';
3
3
  export default class ConfigsService {
4
- config = {};
5
- publicFolderName = publicFolderName;
6
- kafkaLogsTopic = kafkaLogsTopic;
4
+ config;
5
+ publicFolderName = Constants.publicFolderName;
6
+ kafkaLogsTopic = Constants.kafkaLogsTopic;
7
7
  #systemService;
8
8
  constructor({ systemService }) {
9
9
  this.#systemService = systemService;
@@ -13,7 +13,7 @@ export default class ConfigsService {
13
13
  const rawConfigs = tmp?.configs || tmp?.configs || {};
14
14
  this.config = {
15
15
  worker: process.env.WORKER === 'true' ? true : false || false,
16
- nodeEnv: process.env.NODE_ENV === 'true' ? true : false || false,
16
+ nodeEnv: process.env.NODE_ENV,
17
17
  debug: process.env.SYSTEM_LOGGER_LAYER,
18
18
  https: process.env.HTTPS,
19
19
  httpsfileEncoding: process.env.ENCODING || 'utf8',
@@ -34,10 +34,16 @@ export default class ConfigsService {
34
34
  internalSecret: process.env.INTERNAL_SECRET,
35
35
  secret: process.env.SECRET,
36
36
  cwd: process.cwd(),
37
- env: process.env.NODE_ENV,
38
- ...rawConfigs
37
+ env: process.env.NODE_ENV
39
38
  };
40
39
  };
40
+ setConfig(newConfigs) {
41
+ const mergedData = {
42
+ ...this.config,
43
+ ...newConfigs
44
+ };
45
+ this.config = Object.freeze(mergedData);
46
+ }
41
47
  get all() {
42
48
  return this.config;
43
49
  }
@@ -2,11 +2,11 @@ import winston from "winston";
2
2
  import "winston-daily-rotate-file";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import { LoggerLayerEnum, IService } from "../../utils";
5
- interface CustomLogger extends winston.Logger {
5
+ export interface ICustomLogger extends winston.Logger {
6
6
  critical: winston.LeveledLogMethod;
7
7
  http: winston.LeveledLogMethod;
8
8
  }
9
- interface LogOptions {
9
+ export interface ILog {
10
10
  level: LoggerLayerEnum;
11
11
  message: any;
12
12
  payload?: any;
@@ -17,9 +17,9 @@ export default class LoggerService implements IService {
17
17
  static readonly storage: AsyncLocalStorage<Map<string, string>>;
18
18
  private serviceName;
19
19
  private kafkaProducer;
20
- private kafkaTopic;
20
+ private kafkaLogsTopic;
21
21
  private isKafkaReady;
22
- winston: CustomLogger;
22
+ winston: ICustomLogger;
23
23
  constructor({ configsService }: {
24
24
  configsService: any;
25
25
  });
@@ -27,13 +27,12 @@ export default class LoggerService implements IService {
27
27
  winstonLoader: ({ loadPath, loggerLevel }: {
28
28
  loadPath: string;
29
29
  loggerLevel: string;
30
- }) => CustomLogger;
30
+ }) => ICustomLogger;
31
31
  private safeReplacer;
32
32
  private getTracingFormat;
33
33
  private getConsoleFormat;
34
34
  runWithId: <T>(id: string, callback: () => T) => T;
35
35
  logToKafka(info: any): Promise<void>;
36
36
  log(level: LoggerLayerEnum, message: any, payload?: any, code?: string | number): void;
37
- log(options: LogOptions): void;
37
+ log(options: ILog): void;
38
38
  }
39
- export {};
@@ -35,13 +35,13 @@ export default class LoggerService {
35
35
  static storage = new AsyncLocalStorage();
36
36
  serviceName = "";
37
37
  kafkaProducer = null;
38
- kafkaTopic = "";
38
+ kafkaLogsTopic = "";
39
39
  isKafkaReady = false;
40
40
  winston;
41
41
  #configsService;
42
42
  constructor({ configsService }) {
43
43
  this.#configsService = configsService;
44
- this.kafkaTopic = this.#configsService?.all.kafkaTopic;
44
+ this.kafkaLogsTopic = this.#configsService?.all.kafkaLogsTopic;
45
45
  winston.addColors(customColors);
46
46
  this.winston = winston.createLogger({
47
47
  level: this.#configsService.all.systemLoggerLayer,
@@ -151,9 +151,8 @@ export default class LoggerService {
151
151
  return;
152
152
  try {
153
153
  const { id, level, message, payload, code } = info;
154
- console.log('geldii', this.kafkaTopic);
155
154
  await this.kafkaProducer.send({
156
- topic: this.kafkaTopic,
155
+ topic: this.kafkaLogsTopic,
157
156
  messages: [{
158
157
  value: JSON.stringify({
159
158
  service: this.serviceName,
@@ -1,6 +1,6 @@
1
1
  import path from 'path';
2
- import { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService, ClientsService, ControllerService } from '../loader/index';
3
- import { packageName, x, getTmp, } from '../utils/index';
2
+ import { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService, ClientsService, ControllerService } from '../loader';
3
+ import { Constants, x, getTmp, } from '../utils';
4
4
  //
5
5
  let coreHasRun = false;
6
6
  export const core = getTmp();
@@ -68,7 +68,7 @@ const coreLoader = async ({}) => {
68
68
  }
69
69
  catch (error) {
70
70
  const errorMessage = error instanceof Error ? error.message : String(error);
71
- console.error(`[${packageName} core failure]: ${errorMessage}`);
71
+ console.error(`[${Constants.packageName} core failure]: ${errorMessage}`);
72
72
  }
73
73
  };
74
74
  export default coreLoader;
@@ -1,9 +1,10 @@
1
- export declare const packageName: string;
2
- export declare const tmpFileDefaultMainFolderName: string;
3
- export declare const tmpFileDefaultName: string;
4
- export declare const tmpFileDefaultExt = ".yml";
5
- export declare const defaultTmpFilePath: string;
6
- export declare const defaultOwnerTmpFilePath: string;
7
- export declare const systemLoggerLayer: string;
8
- export declare const publicFolderName = "public";
9
- export declare const kafkaLogsTopic = "logs";
1
+ export declare class Constants {
2
+ static readonly packageName: string;
3
+ static readonly defaultRootFolderName: string;
4
+ static readonly defaultTmpFileName: string;
5
+ static readonly defaultTmpFileExt = ".yml";
6
+ static readonly defaultTmpFilePath: string;
7
+ static readonly defaultOwnerTmpFilePath: string;
8
+ static readonly publicFolderName = "public";
9
+ static readonly kafkaLogsTopic = "logs";
10
+ }
@@ -1,11 +1,11 @@
1
- import path from 'path';
2
- import { __dirname } from '../helpers/path';
3
- export const packageName = 'x';
4
- export const tmpFileDefaultMainFolderName = 'x';
5
- export const tmpFileDefaultName = 'tmp';
6
- export const tmpFileDefaultExt = '.yml';
7
- export const defaultTmpFilePath = path.resolve(__dirname(import.meta.url), `../../${tmpFileDefaultMainFolderName}/${tmpFileDefaultName}.yml`);
8
- export const defaultOwnerTmpFilePath = path.resolve(`./${tmpFileDefaultMainFolderName}/${tmpFileDefaultName}.yml`);
9
- export const systemLoggerLayer = process.env.SYSTEM_LOGGER_LAYER;
10
- export const publicFolderName = 'public';
11
- export const kafkaLogsTopic = 'logs';
1
+ import path from "node:path";
2
+ export class Constants {
3
+ static packageName = '@xrystal/core';
4
+ static defaultRootFolderName = 'x';
5
+ static defaultTmpFileName = 'tmp';
6
+ static defaultTmpFileExt = '.yml';
7
+ static defaultTmpFilePath = path.join(__dirname, `../../${Constants.defaultRootFolderName}/${Constants.defaultTmpFileName}.${Constants.defaultTmpFileExt}`);
8
+ static defaultOwnerTmpFilePath = path.join(process.cwd(), `./${Constants.defaultRootFolderName}/${Constants.defaultTmpFileName}.${Constants.defaultTmpFileExt}`);
9
+ static publicFolderName = 'public';
10
+ static kafkaLogsTopic = 'logs';
11
+ }
@@ -13,4 +13,3 @@ export declare const argvsConverter: (argvs: string) => {
13
13
  };
14
14
  export declare const findExt: (filename: string) => string;
15
15
  export declare const changeExtensions: (filename: string, repalceExt: string) => string;
16
- export declare const webFileFindEngine: (folderPath: string) => string[];
@@ -1,18 +1,18 @@
1
1
  import path from "path";
2
2
  import fs from 'fs';
3
3
  import Handlebars from 'handlebars';
4
- import { SupportFileExtensionsEnum, tmpFileDefaultExt, tmpFileDefaultName, TmpFileLoader } from "../../index.js";
4
+ import { Constants, TmpFileLoader } from "../../index.js";
5
5
  export const getTmp = () => {
6
- const ownerTmpFilePath = findFileRecursively(".", tmpFileDefaultName, tmpFileDefaultExt);
6
+ const ownerTmpFilePath = findFileRecursively(".", Constants.defaultTmpFileName, Constants.defaultTmpFileExt);
7
7
  if (!ownerTmpFilePath) {
8
- throw new Error(`${tmpFileDefaultName} file not found`);
8
+ throw new Error(`${Constants.defaultTmpFileName} file not found`);
9
9
  }
10
10
  const tmpFileObject = getTmpConfig({});
11
11
  return {
12
12
  _: tmpFileObject
13
13
  };
14
14
  };
15
- export const getTmpConfig = ({ root = '.', tmpFileName = tmpFileDefaultName, ext = '.yml' }) => {
15
+ export const getTmpConfig = ({ root = process.cwd(), tmpFileName = Constants.defaultTmpFileName, ext = Constants.defaultTmpFileExt }) => {
16
16
  const path = findFileRecursively(root, tmpFileName, ext);
17
17
  if (!path) {
18
18
  throw new Error(`${name}.${ext} file not found`);
@@ -95,33 +95,3 @@ export const findExt = (filename) => {
95
95
  export const changeExtensions = (filename, repalceExt) => {
96
96
  return filename.replace(findExt(filename), repalceExt);
97
97
  };
98
- export const webFileFindEngine = (folderPath) => {
99
- try {
100
- const files = fs.readdirSync(folderPath);
101
- const fullFileExtension = Object.values(SupportFileExtensionsEnum).map(ext => '.' + ext);
102
- const filteredFiles = [];
103
- files.forEach(file => {
104
- const filePath = path.join(folderPath, file);
105
- const isDirectory = fs.statSync(filePath).isDirectory();
106
- if (isDirectory) {
107
- const subFolderFiles = webFileFindEngine(filePath);
108
- subFolderFiles.forEach(subFile => {
109
- filteredFiles.push(path.join(file, subFile).split('\\').join('/')); // Alt klasördeki dosya yolunu, ana klasör yoluna ekleyerek dosyları benzersiz yapıyoruz sonda ise diğer işletim sistemlerien uygun hale getiriyoruz
110
- });
111
- }
112
- else {
113
- for (const ffn of fullFileExtension) {
114
- if (file.endsWith(ffn)) {
115
- filteredFiles.push(file);
116
- break;
117
- }
118
- }
119
- }
120
- });
121
- return filteredFiles;
122
- }
123
- catch (error /* unknow */) {
124
- console.error('Error: ', error.message);
125
- return [];
126
- }
127
- };
@@ -1,5 +1,5 @@
1
1
  import { LifetimeType } from 'awilix';
2
- export declare class X {
2
+ declare class X {
3
3
  private container;
4
4
  private initializedNames;
5
5
  constructor();
@@ -12,14 +12,14 @@ export declare class X {
12
12
  register(Dependency: any, lifetime?: LifetimeType): this;
13
13
  registerAll(dependencies: any[], lifetime?: LifetimeType): this;
14
14
  registerInstance(name: string, instance: any): this;
15
- initialize(input?: {
15
+ initialize<T = any>(input?: {
16
16
  service: any;
17
- props?: any;
17
+ props?: T;
18
18
  } | {
19
19
  service: any;
20
- props?: any;
20
+ props?: T;
21
21
  }[], verbose?: boolean): Promise<this>;
22
- get<T>(target: string | any): T;
22
+ get<T>(target: any): T;
23
23
  get cradle(): any;
24
24
  private isRegistered;
25
25
  }
@@ -1,7 +1,7 @@
1
1
  import { createContainer, asClass, asValue, InjectionMode, listModules, Lifetime } from 'awilix';
2
2
  import path from 'node:path';
3
3
  import { pathToFileURL } from 'node:url';
4
- export class X {
4
+ class X {
5
5
  container;
6
6
  initializedNames = new Set();
7
7
  constructor() {
@@ -28,7 +28,6 @@ export class X {
28
28
  modules = listModules(resolvedPatterns);
29
29
  }
30
30
  catch (err) {
31
- console.error(`[DI][CRITICAL] Path resolution failed: ${err.message}`);
32
31
  return this;
33
32
  }
34
33
  for (const m of modules) {
@@ -43,11 +42,8 @@ export class X {
43
42
  }
44
43
  return false;
45
44
  });
46
- if (isPathExcluded) {
47
- if (verbose)
48
- console.log(`[DI][${source}] Excluded: ${m.name}`);
45
+ if (isPathExcluded)
49
46
  continue;
50
- }
51
47
  try {
52
48
  const fileUrl = pathToFileURL(m.path).href;
53
49
  const loaded = await import(fileUrl);
@@ -66,14 +62,12 @@ export class X {
66
62
  this.container.register({
67
63
  [name]: asClass(dependency).setLifetime(lifetime)
68
64
  });
69
- if (verbose)
70
- console.log(`[DI][${source}] Registered: ${name}`);
71
65
  }
72
66
  }
73
67
  }
74
68
  catch (err) {
75
69
  if (verbose)
76
- console.error(`[DI][${source}] Load Error in ${m.name}:`, err.message);
70
+ console.error(`[DI][${source}] Load Error:`, err.message);
77
71
  }
78
72
  }
79
73
  return this;
@@ -126,8 +120,6 @@ export class X {
126
120
  const props = propsMap.get(key) || {};
127
121
  await instance.load(props);
128
122
  this.initializedNames.add(key);
129
- if (verbose)
130
- console.log(`[DI] Initialized: ${key}`);
131
123
  }
132
124
  catch (err) {
133
125
  console.error(`[DI] Initialization Failed: ${key} ->`, err.message);
@@ -118,22 +118,3 @@ export declare enum EndpointResourceEnum {
118
118
  WEBHOOKS = "webhooks",
119
119
  OTHERS = "others"
120
120
  }
121
- export declare enum SupportFileExtensionsEnum {
122
- 'HTML' = "html",
123
- 'EJS' = "ejs",
124
- 'HBS' = "hbs",
125
- "TS" = "",
126
- "JS" = ".js",
127
- "TSX" = "x",
128
- "JSX" = ".jsx",
129
- "TTF" = ".ttf",
130
- "EOT" = ".eot",
131
- "OTF" = ".otf",
132
- "SVG" = ".svg",
133
- "PNG" = ".png",
134
- "WOFF" = ".woff",
135
- "WOFF2" = ".woff2",
136
- "CSS" = ".css",
137
- "SCSS" = ".scss",
138
- "SASS" = ".sass"
139
- }
@@ -137,23 +137,3 @@ export var EndpointResourceEnum;
137
137
  EndpointResourceEnum["WEBHOOKS"] = "webhooks";
138
138
  EndpointResourceEnum["OTHERS"] = "others";
139
139
  })(EndpointResourceEnum || (EndpointResourceEnum = {}));
140
- export var SupportFileExtensionsEnum;
141
- (function (SupportFileExtensionsEnum) {
142
- SupportFileExtensionsEnum["HTML"] = "html";
143
- SupportFileExtensionsEnum["EJS"] = "ejs";
144
- SupportFileExtensionsEnum["HBS"] = "hbs";
145
- SupportFileExtensionsEnum["TS"] = "";
146
- SupportFileExtensionsEnum["JS"] = ".js";
147
- SupportFileExtensionsEnum["TSX"] = "x";
148
- SupportFileExtensionsEnum["JSX"] = ".jsx";
149
- SupportFileExtensionsEnum["TTF"] = ".ttf";
150
- SupportFileExtensionsEnum["EOT"] = ".eot";
151
- SupportFileExtensionsEnum["OTF"] = ".otf";
152
- SupportFileExtensionsEnum["SVG"] = ".svg";
153
- SupportFileExtensionsEnum["PNG"] = ".png";
154
- SupportFileExtensionsEnum["WOFF"] = ".woff";
155
- SupportFileExtensionsEnum["WOFF2"] = ".woff2";
156
- SupportFileExtensionsEnum["CSS"] = ".css";
157
- SupportFileExtensionsEnum["SCSS"] = ".scss";
158
- SupportFileExtensionsEnum["SASS"] = ".sass";
159
- })(SupportFileExtensionsEnum || (SupportFileExtensionsEnum = {}));
@@ -1,4 +1,4 @@
1
- import x, { X } from './classes/class.x';
1
+ import x from './classes/class.x';
2
2
  import locator, { Locator } from './classes/class.service-locator';
3
3
  export * from './classes/class.tmp-file-loader';
4
4
  export * from './classes/class.response';
@@ -6,4 +6,4 @@ export * from './classes/class.services';
6
6
  export * from './classes/class.interfaces';
7
7
  export * from './types';
8
8
  export * from './enums';
9
- export { x, X, locator, Locator };
9
+ export { x, locator, Locator };
@@ -1,4 +1,4 @@
1
- import x, { X } from './classes/class.x';
1
+ import x from './classes/class.x';
2
2
  import locator, { Locator } from './classes/class.service-locator';
3
3
  export * from './classes/class.tmp-file-loader';
4
4
  export * from './classes/class.response';
@@ -6,4 +6,4 @@ export * from './classes/class.services';
6
6
  export * from './classes/class.interfaces';
7
7
  export * from './types';
8
8
  export * from './enums';
9
- export { x, X, locator, Locator };
9
+ export { x, locator, Locator };