rads-db 3.0.15 → 3.0.18
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/index.d.ts
CHANGED
|
@@ -99,7 +99,7 @@ interface ValidateNumberDecoratorArgs {
|
|
|
99
99
|
}
|
|
100
100
|
interface ValidateStringDecoratorArgs {
|
|
101
101
|
preset?: 'text' | 'html' | 'markdown' | 'alpha' | 'alphanum' | 'number' | 'decimalNumber' | 'email' | 'icon' | 'imageUrl' | 'fileUrl' | 'absoluteUrl' | 'relativeUrl' | 'phoneNumber' | 'datetime' | 'date' | 'time' | 'timeInterval' | 'duration';
|
|
102
|
-
regex?: RegExp;
|
|
102
|
+
regex?: RegExp | string;
|
|
103
103
|
minLength?: number;
|
|
104
104
|
maxLength?: number;
|
|
105
105
|
}
|
|
@@ -7,8 +7,10 @@ module.exports = void 0;
|
|
|
7
7
|
var _promises = _interopRequireDefault(require("node:fs/promises"));
|
|
8
8
|
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
9
9
|
var _klaw = _interopRequireDefault(require("klaw"));
|
|
10
|
+
var _ignore = _interopRequireDefault(require("ignore"));
|
|
10
11
|
var _restEndpointsDevLint = _interopRequireDefault(require("./restEndpointsDev/restEndpointsDevLint.cjs"));
|
|
11
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
let gitignore;
|
|
12
14
|
const root = _nodePath.default.resolve(".");
|
|
13
15
|
var _default = {
|
|
14
16
|
lint: _restEndpointsDevLint.default.lint,
|
|
@@ -91,17 +93,16 @@ function sanitizeFilepath(filepath) {
|
|
|
91
93
|
if (!result.startsWith(root)) throw new Error("Invalid path");
|
|
92
94
|
}
|
|
93
95
|
async function readdirRecursive(dir, options) {
|
|
96
|
+
await initGitignore();
|
|
94
97
|
options = {
|
|
95
98
|
...options
|
|
96
99
|
};
|
|
97
100
|
const klawIterator = await (0, _klaw.default)(dir, {
|
|
98
|
-
depthLimit: options.recursive ? 15 : 0,
|
|
101
|
+
depthLimit: options.recursive ? options.depthLimit ?? 15 : 0,
|
|
99
102
|
preserveSymlinks: true,
|
|
100
103
|
filter: p => {
|
|
101
104
|
const rp = _nodePath.default.relative(".", p);
|
|
102
|
-
|
|
103
|
-
if (rp.startsWith("node_modules")) return false;
|
|
104
|
-
return true;
|
|
105
|
+
return !gitignore.ignores(rp);
|
|
105
106
|
}
|
|
106
107
|
});
|
|
107
108
|
const results = [];
|
|
@@ -110,10 +111,16 @@ async function readdirRecursive(dir, options) {
|
|
|
110
111
|
const rp = _nodePath.default.relative(dir, file.path).replaceAll("\\", "/");
|
|
111
112
|
if (!rp) continue;
|
|
112
113
|
results.push({
|
|
113
|
-
path: rp
|
|
114
|
+
path: `./${rp}`,
|
|
114
115
|
type: file.stats.isDirectory() ? "tree" : "blob",
|
|
115
116
|
size: file.stats.size
|
|
116
117
|
});
|
|
117
118
|
}
|
|
118
119
|
return results;
|
|
120
|
+
}
|
|
121
|
+
async function initGitignore() {
|
|
122
|
+
if (gitignore) return;
|
|
123
|
+
const gitignoreStr = await _promises.default.readFile("./.gitignore", "utf-8");
|
|
124
|
+
gitignore = (0, _ignore.default)().add(["node_modules", ".git"]);
|
|
125
|
+
if (gitignoreStr) gitignore = gitignore.add(gitignoreStr.split("\n").filter(x => x));
|
|
119
126
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import klaw from "klaw";
|
|
4
|
+
import ignore from "ignore";
|
|
4
5
|
import restEndpointsDevLint from "./restEndpointsDev/restEndpointsDevLint.mjs";
|
|
6
|
+
let gitignore;
|
|
5
7
|
const root = path.resolve(".");
|
|
6
8
|
export default {
|
|
7
9
|
lint: restEndpointsDevLint.lint,
|
|
@@ -83,17 +85,14 @@ function sanitizeFilepath(filepath) {
|
|
|
83
85
|
throw new Error("Invalid path");
|
|
84
86
|
}
|
|
85
87
|
async function readdirRecursive(dir, options) {
|
|
88
|
+
await initGitignore();
|
|
86
89
|
options = { ...options };
|
|
87
90
|
const klawIterator = await klaw(dir, {
|
|
88
|
-
depthLimit: options.recursive ? 15 : 0,
|
|
91
|
+
depthLimit: options.recursive ? options.depthLimit ?? 15 : 0,
|
|
89
92
|
preserveSymlinks: true,
|
|
90
93
|
filter: (p) => {
|
|
91
94
|
const rp = path.relative(".", p);
|
|
92
|
-
|
|
93
|
-
return false;
|
|
94
|
-
if (rp.startsWith("node_modules"))
|
|
95
|
-
return false;
|
|
96
|
-
return true;
|
|
95
|
+
return !gitignore.ignores(rp);
|
|
97
96
|
}
|
|
98
97
|
});
|
|
99
98
|
const results = [];
|
|
@@ -104,10 +103,18 @@ async function readdirRecursive(dir, options) {
|
|
|
104
103
|
if (!rp)
|
|
105
104
|
continue;
|
|
106
105
|
results.push({
|
|
107
|
-
path: rp
|
|
106
|
+
path: `./${rp}`,
|
|
108
107
|
type: file.stats.isDirectory() ? "tree" : "blob",
|
|
109
108
|
size: file.stats.size
|
|
110
109
|
});
|
|
111
110
|
}
|
|
112
111
|
return results;
|
|
113
112
|
}
|
|
113
|
+
async function initGitignore() {
|
|
114
|
+
if (gitignore)
|
|
115
|
+
return;
|
|
116
|
+
const gitignoreStr = await fs.readFile("./.gitignore", "utf-8");
|
|
117
|
+
gitignore = ignore().add(["node_modules", ".git"]);
|
|
118
|
+
if (gitignoreStr)
|
|
119
|
+
gitignore = gitignore.add(gitignoreStr.split("\n").filter((x) => x));
|
|
120
|
+
}
|