@mini2/core 1.4.10-beta.4 → 1.4.10-beta.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.
- package/dist/loader.d.ts +2 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +44 -18
- package/dist/loader.js.map +1 -1
- package/package.json +1 -1
package/dist/loader.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export type LoadInjectablesOptions = {
|
|
2
2
|
autoload?: boolean;
|
|
3
|
-
|
|
4
|
-
distDir?: string;
|
|
3
|
+
workingDirectory?: string;
|
|
5
4
|
patterns?: string[];
|
|
6
|
-
runOnlySrc?: boolean;
|
|
7
5
|
logging?: boolean;
|
|
6
|
+
extensions?: string[];
|
|
8
7
|
};
|
|
9
8
|
export declare function loadInjectables(opts?: LoadInjectablesOptions): {
|
|
10
9
|
files: string[];
|
package/dist/loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../loader.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../loader.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AACF,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,sBAAsB;;;cAsD5D"}
|
package/dist/loader.js
CHANGED
|
@@ -11,29 +11,55 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
11
11
|
function loadInjectables(opts) {
|
|
12
12
|
if (!opts?.autoload)
|
|
13
13
|
return;
|
|
14
|
-
const
|
|
15
|
-
const distDir = opts?.distDir ?? 'dist';
|
|
14
|
+
const logging = opts?.logging ?? false;
|
|
16
15
|
const patterns = opts?.patterns ?? ['**/*.(ts|js)'];
|
|
17
|
-
const
|
|
18
|
-
|
|
16
|
+
const extensions = opts?.extensions ?? [
|
|
17
|
+
'ts',
|
|
18
|
+
'mts',
|
|
19
|
+
'cts',
|
|
20
|
+
'js',
|
|
21
|
+
'cjs',
|
|
22
|
+
'mjs',
|
|
23
|
+
];
|
|
24
|
+
const workingDirectory = opts?.workingDirectory;
|
|
25
|
+
if (!workingDirectory)
|
|
26
|
+
throw new Error('Working directory is required');
|
|
27
|
+
const baseDir = node_path_1.default.resolve(node_path_1.default.join(workingDirectory));
|
|
28
|
+
if (logging) {
|
|
29
|
+
console.log('------ AUTO LOADING BASE DIR ------');
|
|
30
|
+
console.log(baseDir);
|
|
31
|
+
console.log('------ AUTO LOADING PATTERNS ------');
|
|
32
|
+
console.log(patterns);
|
|
33
|
+
}
|
|
19
34
|
// TS dev: .ts, prod: .js
|
|
20
|
-
const
|
|
21
|
-
const files = fast_glob_1.default.sync(exts.flatMap((ext) => patterns.map((p) => node_path_1.default.join(baseDir, p.replace('(ts|js)', ext)))), {
|
|
35
|
+
const files = fast_glob_1.default.sync(extensions.flatMap((ext) => patterns.map((p) => node_path_1.default.join(baseDir, p.replace('(ts|js)', ext)))), {
|
|
22
36
|
onlyFiles: true,
|
|
23
37
|
unique: true,
|
|
24
38
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
if (logging) {
|
|
40
|
+
console.log('------ AUTO LOADING FILES ------');
|
|
41
|
+
console.log(files);
|
|
42
|
+
}
|
|
43
|
+
if (files.length > 0) {
|
|
44
|
+
files.forEach((f) => {
|
|
45
|
+
const file = node_fs_1.default.readFileSync(f, 'utf8');
|
|
46
|
+
if (!file.startsWith('//mini-dont-auto-load')) {
|
|
47
|
+
if (logging) {
|
|
48
|
+
console.log('auto-loading', f);
|
|
49
|
+
}
|
|
50
|
+
require(f);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
if (logging) {
|
|
54
|
+
console.log('skipping', f);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
if (opts?.logging)
|
|
61
|
+
console.log('------ NO FILES FOUND TO AUTO LOAD ------');
|
|
62
|
+
}
|
|
37
63
|
return { files, count: files.length };
|
|
38
64
|
}
|
|
39
65
|
//# sourceMappingURL=loader.js.map
|
package/dist/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../loader.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../loader.ts"],"names":[],"mappings":";;;;;AAWA,0CAsDC;AAjED,sBAAsB;AACtB,0DAA6B;AAC7B,0DAA2B;AAC3B,sDAAyB;AAQzB,SAAgB,eAAe,CAAC,IAA6B;IAC5D,IAAI,CAAC,IAAI,EAAE,QAAQ;QAAE,OAAO;IAC5B,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,KAAK,CAAC;IACvC,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,CAAC,cAAc,CAAC,CAAC;IACpD,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,IAAI;QACtC,IAAI;QACJ,KAAK;QACL,KAAK;QACL,IAAI;QACJ,KAAK;QACL,KAAK;KACL,CAAC;IACF,MAAM,gBAAgB,GAAG,IAAI,EAAE,gBAAgB,CAAC;IAChD,IAAI,CAAC,gBAAgB;QAAE,MAAM,IAAI,KAAK,CAAC,+BAA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CAAC;YACZ,CAAC;iBAAM,CAAC;gBACP,IAAI,OAAO,EAAE,CAAC;oBACb,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;gBAC5B,CAAC;YACF,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACP,IAAI,IAAI,EAAE,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC;AACvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"description": "Mini Express Framework - Lightweight and modular Express.js framework with TypeScript support",
|
|
28
28
|
"name": "@mini2/core",
|
|
29
|
-
"version": "1.4.10-beta.
|
|
29
|
+
"version": "1.4.10-beta.6",
|
|
30
30
|
"author": "Mustafa Çolakoglu <mustafacolakoglu94@gmail.com> (https://github.com/mustafa-colakoglu)",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"class-transformer": "^0.5.1",
|