@bleedingdev/modern-js-bff-core 3.11.3-ultramodern.6 → 3.11.3-ultramodern.8
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/cjs/router/utils.js
CHANGED
|
@@ -43,14 +43,56 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
43
43
|
requireHandlerModule: ()=>requireHandlerModule,
|
|
44
44
|
sortRoutes: ()=>sortRoutes
|
|
45
45
|
});
|
|
46
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
46
47
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
47
48
|
const external_path_namespaceObject = require("path");
|
|
48
49
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
49
50
|
const external_constants_js_namespaceObject = require("./constants.js");
|
|
50
|
-
const
|
|
51
|
+
const breadthFirst = (files)=>files.map((file)=>file.split(external_path_default().sep).join('/')).sort((a, b)=>a.split('/').length - b.split('/').length || (a < b ? -1 : a > b ? 1 : 0));
|
|
52
|
+
const readIgnoreRules = (dir)=>breadthFirst((0, external_node_fs_namespaceObject.globSync)('**/.gitignore', {
|
|
53
|
+
cwd: dir,
|
|
54
|
+
followSymlinks: true,
|
|
55
|
+
exclude: [
|
|
56
|
+
'**/node_modules',
|
|
57
|
+
'**/flow-typed',
|
|
58
|
+
'**/coverage'
|
|
59
|
+
]
|
|
60
|
+
})).flatMap((file)=>{
|
|
61
|
+
const parent = external_path_default().posix.dirname(file);
|
|
62
|
+
const base = '.' === parent ? '' : `${parent.toLowerCase()}/`;
|
|
63
|
+
return (0, external_node_fs_namespaceObject.readFileSync)(external_path_default().join(dir, file), 'utf8').replace(/^\uFEFF/, '').split(/\r?\n/).map((line)=>line.trimEnd()).filter((line)=>line && !line.startsWith('#')).map((line)=>{
|
|
64
|
+
const negated = line.startsWith('!');
|
|
65
|
+
const pattern = (negated ? line.slice(1) : line).toLowerCase();
|
|
66
|
+
const body = pattern.replace(/\/$/, '').replace(/[()]/g, '[$&]');
|
|
67
|
+
return {
|
|
68
|
+
base,
|
|
69
|
+
glob: body.includes('/') ? body.replace(/^\//, '') : `**/${body}`,
|
|
70
|
+
negated,
|
|
71
|
+
directoryOnly: pattern.endsWith('/')
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
const isIgnored = (rules, file)=>{
|
|
76
|
+
const segments = file.toLowerCase().split('/');
|
|
77
|
+
return segments.some((_, index)=>{
|
|
78
|
+
const target = segments.slice(0, index + 1).join('/');
|
|
79
|
+
const isDirectory = index < segments.length - 1;
|
|
80
|
+
return rules.reduce((ignored, rule)=>(isDirectory || !rule.directoryOnly) && target.startsWith(rule.base) && external_path_default().posix.matchesGlob(target.slice(rule.base.length), rule.glob) ? !rule.negated : ignored, false);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
const getFiles = (lambdaDir, rules)=>{
|
|
84
|
+
const patterns = 'string' == typeof rules ? [
|
|
85
|
+
rules
|
|
86
|
+
] : rules;
|
|
87
|
+
const ignoreRules = readIgnoreRules(lambdaDir);
|
|
88
|
+
return breadthFirst((0, external_node_fs_namespaceObject.globSync)(patterns.filter((rule)=>!rule.startsWith('!')), {
|
|
51
89
|
cwd: lambdaDir,
|
|
52
|
-
|
|
53
|
-
|
|
90
|
+
followSymlinks: true,
|
|
91
|
+
exclude: patterns.filter((rule)=>rule.startsWith('!')).map((rule)=>rule.slice(1))
|
|
92
|
+
})).filter((file)=>(0, external_node_fs_namespaceObject.statSync)(external_path_default().join(lambdaDir, file), {
|
|
93
|
+
throwIfNoEntry: false
|
|
94
|
+
})?.isFile() && !isIgnored(ignoreRules, file)).map((file)=>external_path_default().resolve(lambdaDir, file));
|
|
95
|
+
};
|
|
54
96
|
const getPathFromFilename = (baseDir, filename)=>{
|
|
55
97
|
const relativeName = filename.substring(baseDir.length);
|
|
56
98
|
const relativePath = relativeName.split('.').slice(0, -1).join('.');
|
|
@@ -1,10 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { globSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { compatibleRequire } from "@modern-js/utils";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import { INDEX_SUFFIX } from "./constants.mjs";
|
|
4
|
-
const
|
|
5
|
+
const breadthFirst = (files)=>files.map((file)=>file.split(path.sep).join('/')).sort((a, b)=>a.split('/').length - b.split('/').length || (a < b ? -1 : a > b ? 1 : 0));
|
|
6
|
+
const readIgnoreRules = (dir)=>breadthFirst(globSync('**/.gitignore', {
|
|
7
|
+
cwd: dir,
|
|
8
|
+
followSymlinks: true,
|
|
9
|
+
exclude: [
|
|
10
|
+
'**/node_modules',
|
|
11
|
+
'**/flow-typed',
|
|
12
|
+
'**/coverage'
|
|
13
|
+
]
|
|
14
|
+
})).flatMap((file)=>{
|
|
15
|
+
const parent = path.posix.dirname(file);
|
|
16
|
+
const base = '.' === parent ? '' : `${parent.toLowerCase()}/`;
|
|
17
|
+
return readFileSync(path.join(dir, file), 'utf8').replace(/^\uFEFF/, '').split(/\r?\n/).map((line)=>line.trimEnd()).filter((line)=>line && !line.startsWith('#')).map((line)=>{
|
|
18
|
+
const negated = line.startsWith('!');
|
|
19
|
+
const pattern = (negated ? line.slice(1) : line).toLowerCase();
|
|
20
|
+
const body = pattern.replace(/\/$/, '').replace(/[()]/g, '[$&]');
|
|
21
|
+
return {
|
|
22
|
+
base,
|
|
23
|
+
glob: body.includes('/') ? body.replace(/^\//, '') : `**/${body}`,
|
|
24
|
+
negated,
|
|
25
|
+
directoryOnly: pattern.endsWith('/')
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
const isIgnored = (rules, file)=>{
|
|
30
|
+
const segments = file.toLowerCase().split('/');
|
|
31
|
+
return segments.some((_, index)=>{
|
|
32
|
+
const target = segments.slice(0, index + 1).join('/');
|
|
33
|
+
const isDirectory = index < segments.length - 1;
|
|
34
|
+
return rules.reduce((ignored, rule)=>(isDirectory || !rule.directoryOnly) && target.startsWith(rule.base) && path.posix.matchesGlob(target.slice(rule.base.length), rule.glob) ? !rule.negated : ignored, false);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const getFiles = (lambdaDir, rules)=>{
|
|
38
|
+
const patterns = 'string' == typeof rules ? [
|
|
39
|
+
rules
|
|
40
|
+
] : rules;
|
|
41
|
+
const ignoreRules = readIgnoreRules(lambdaDir);
|
|
42
|
+
return breadthFirst(globSync(patterns.filter((rule)=>!rule.startsWith('!')), {
|
|
5
43
|
cwd: lambdaDir,
|
|
6
|
-
|
|
7
|
-
|
|
44
|
+
followSymlinks: true,
|
|
45
|
+
exclude: patterns.filter((rule)=>rule.startsWith('!')).map((rule)=>rule.slice(1))
|
|
46
|
+
})).filter((file)=>statSync(path.join(lambdaDir, file), {
|
|
47
|
+
throwIfNoEntry: false
|
|
48
|
+
})?.isFile() && !isIgnored(ignoreRules, file)).map((file)=>path.resolve(lambdaDir, file));
|
|
49
|
+
};
|
|
8
50
|
const getPathFromFilename = (baseDir, filename)=>{
|
|
9
51
|
const relativeName = filename.substring(baseDir.length);
|
|
10
52
|
const relativePath = relativeName.split('.').slice(0, -1).join('.');
|
|
@@ -1,11 +1,53 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import {
|
|
2
|
+
import { globSync, readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { compatibleRequire } from "@modern-js/utils";
|
|
3
4
|
import path from "path";
|
|
4
5
|
import { INDEX_SUFFIX } from "./constants.mjs";
|
|
5
|
-
const
|
|
6
|
+
const breadthFirst = (files)=>files.map((file)=>file.split(path.sep).join('/')).sort((a, b)=>a.split('/').length - b.split('/').length || (a < b ? -1 : a > b ? 1 : 0));
|
|
7
|
+
const readIgnoreRules = (dir)=>breadthFirst(globSync('**/.gitignore', {
|
|
8
|
+
cwd: dir,
|
|
9
|
+
followSymlinks: true,
|
|
10
|
+
exclude: [
|
|
11
|
+
'**/node_modules',
|
|
12
|
+
'**/flow-typed',
|
|
13
|
+
'**/coverage'
|
|
14
|
+
]
|
|
15
|
+
})).flatMap((file)=>{
|
|
16
|
+
const parent = path.posix.dirname(file);
|
|
17
|
+
const base = '.' === parent ? '' : `${parent.toLowerCase()}/`;
|
|
18
|
+
return readFileSync(path.join(dir, file), 'utf8').replace(/^\uFEFF/, '').split(/\r?\n/).map((line)=>line.trimEnd()).filter((line)=>line && !line.startsWith('#')).map((line)=>{
|
|
19
|
+
const negated = line.startsWith('!');
|
|
20
|
+
const pattern = (negated ? line.slice(1) : line).toLowerCase();
|
|
21
|
+
const body = pattern.replace(/\/$/, '').replace(/[()]/g, '[$&]');
|
|
22
|
+
return {
|
|
23
|
+
base,
|
|
24
|
+
glob: body.includes('/') ? body.replace(/^\//, '') : `**/${body}`,
|
|
25
|
+
negated,
|
|
26
|
+
directoryOnly: pattern.endsWith('/')
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
const isIgnored = (rules, file)=>{
|
|
31
|
+
const segments = file.toLowerCase().split('/');
|
|
32
|
+
return segments.some((_, index)=>{
|
|
33
|
+
const target = segments.slice(0, index + 1).join('/');
|
|
34
|
+
const isDirectory = index < segments.length - 1;
|
|
35
|
+
return rules.reduce((ignored, rule)=>(isDirectory || !rule.directoryOnly) && target.startsWith(rule.base) && path.posix.matchesGlob(target.slice(rule.base.length), rule.glob) ? !rule.negated : ignored, false);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
const getFiles = (lambdaDir, rules)=>{
|
|
39
|
+
const patterns = 'string' == typeof rules ? [
|
|
40
|
+
rules
|
|
41
|
+
] : rules;
|
|
42
|
+
const ignoreRules = readIgnoreRules(lambdaDir);
|
|
43
|
+
return breadthFirst(globSync(patterns.filter((rule)=>!rule.startsWith('!')), {
|
|
6
44
|
cwd: lambdaDir,
|
|
7
|
-
|
|
8
|
-
|
|
45
|
+
followSymlinks: true,
|
|
46
|
+
exclude: patterns.filter((rule)=>rule.startsWith('!')).map((rule)=>rule.slice(1))
|
|
47
|
+
})).filter((file)=>statSync(path.join(lambdaDir, file), {
|
|
48
|
+
throwIfNoEntry: false
|
|
49
|
+
})?.isFile() && !isIgnored(ignoreRules, file)).map((file)=>path.resolve(lambdaDir, file));
|
|
50
|
+
};
|
|
9
51
|
const getPathFromFilename = (baseDir, filename)=>{
|
|
10
52
|
const relativeName = filename.substring(baseDir.length);
|
|
11
53
|
const relativePath = relativeName.split('.').slice(0, -1).join('.');
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.11.3-ultramodern.
|
|
20
|
+
"version": "3.11.3-ultramodern.8",
|
|
21
21
|
"types": "./dist/types/index.d.ts",
|
|
22
22
|
"main": "./dist/cjs/index.js",
|
|
23
23
|
"exports": {
|
|
@@ -31,16 +31,16 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.11.3-ultramodern.
|
|
34
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.11.3-ultramodern.8",
|
|
35
35
|
"@swc/helpers": "^0.5.24",
|
|
36
36
|
"koa-compose": "^4.1.0",
|
|
37
37
|
"reflect-metadata": "^0.2.2",
|
|
38
|
-
"type-fest": "
|
|
38
|
+
"type-fest": "6.0.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@modern-js/bff-runtime": "npm:@bleedingdev/modern-js-bff-runtime@3.11.3-ultramodern.
|
|
42
|
-
"@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.11.3-ultramodern.
|
|
43
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.11.3-ultramodern.
|
|
41
|
+
"@modern-js/bff-runtime": "npm:@bleedingdev/modern-js-bff-runtime@3.11.3-ultramodern.8",
|
|
42
|
+
"@modern-js/server-runtime-extensions": "npm:@bleedingdev/modern-js-server-runtime-extensions@3.11.3-ultramodern.8",
|
|
43
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.11.3-ultramodern.8",
|
|
44
44
|
"@rslib/core": "1.0.7",
|
|
45
45
|
"@scripts/rstest-config": "2.66.7",
|
|
46
46
|
"@types/koa-compose": "^3.2.9",
|