rads-db 3.0.15 → 3.0.19
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,
|
|
@@ -75,6 +77,11 @@ var _default = {
|
|
|
75
77
|
async unlink(filepath) {
|
|
76
78
|
sanitizeFilepath(filepath);
|
|
77
79
|
return await _promises.default.unlink(filepath);
|
|
80
|
+
},
|
|
81
|
+
async rename(oldFilepath, newFilepath) {
|
|
82
|
+
sanitizeFilepath(oldFilepath);
|
|
83
|
+
sanitizeFilepath(newFilepath);
|
|
84
|
+
return await _promises.default.rename(oldFilepath, newFilepath);
|
|
78
85
|
}
|
|
79
86
|
};
|
|
80
87
|
module.exports = _default;
|
|
@@ -91,17 +98,16 @@ function sanitizeFilepath(filepath) {
|
|
|
91
98
|
if (!result.startsWith(root)) throw new Error("Invalid path");
|
|
92
99
|
}
|
|
93
100
|
async function readdirRecursive(dir, options) {
|
|
101
|
+
await initGitignore();
|
|
94
102
|
options = {
|
|
95
103
|
...options
|
|
96
104
|
};
|
|
97
105
|
const klawIterator = await (0, _klaw.default)(dir, {
|
|
98
|
-
depthLimit: options.recursive ? 15 : 0,
|
|
106
|
+
depthLimit: options.recursive ? options.depthLimit ?? 15 : 0,
|
|
99
107
|
preserveSymlinks: true,
|
|
100
108
|
filter: p => {
|
|
101
109
|
const rp = _nodePath.default.relative(".", p);
|
|
102
|
-
|
|
103
|
-
if (rp.startsWith("node_modules")) return false;
|
|
104
|
-
return true;
|
|
110
|
+
return !gitignore.ignores(rp);
|
|
105
111
|
}
|
|
106
112
|
});
|
|
107
113
|
const results = [];
|
|
@@ -110,10 +116,16 @@ async function readdirRecursive(dir, options) {
|
|
|
110
116
|
const rp = _nodePath.default.relative(dir, file.path).replaceAll("\\", "/");
|
|
111
117
|
if (!rp) continue;
|
|
112
118
|
results.push({
|
|
113
|
-
path: rp
|
|
119
|
+
path: `./${rp}`,
|
|
114
120
|
type: file.stats.isDirectory() ? "tree" : "blob",
|
|
115
121
|
size: file.stats.size
|
|
116
122
|
});
|
|
117
123
|
}
|
|
118
124
|
return results;
|
|
125
|
+
}
|
|
126
|
+
async function initGitignore() {
|
|
127
|
+
if (gitignore) return;
|
|
128
|
+
const gitignoreStr = await _promises.default.readFile("./.gitignore", "utf-8");
|
|
129
|
+
gitignore = (0, _ignore.default)().add(["node_modules", ".git"]);
|
|
130
|
+
if (gitignoreStr) gitignore = gitignore.add(gitignoreStr.split("\n").filter(x => x));
|
|
119
131
|
}
|
|
@@ -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,
|
|
@@ -67,6 +69,11 @@ export default {
|
|
|
67
69
|
async unlink(filepath) {
|
|
68
70
|
sanitizeFilepath(filepath);
|
|
69
71
|
return await fs.unlink(filepath);
|
|
72
|
+
},
|
|
73
|
+
async rename(oldFilepath, newFilepath) {
|
|
74
|
+
sanitizeFilepath(oldFilepath);
|
|
75
|
+
sanitizeFilepath(newFilepath);
|
|
76
|
+
return await fs.rename(oldFilepath, newFilepath);
|
|
70
77
|
}
|
|
71
78
|
};
|
|
72
79
|
async function dirExists(path2) {
|
|
@@ -83,17 +90,14 @@ function sanitizeFilepath(filepath) {
|
|
|
83
90
|
throw new Error("Invalid path");
|
|
84
91
|
}
|
|
85
92
|
async function readdirRecursive(dir, options) {
|
|
93
|
+
await initGitignore();
|
|
86
94
|
options = { ...options };
|
|
87
95
|
const klawIterator = await klaw(dir, {
|
|
88
|
-
depthLimit: options.recursive ? 15 : 0,
|
|
96
|
+
depthLimit: options.recursive ? options.depthLimit ?? 15 : 0,
|
|
89
97
|
preserveSymlinks: true,
|
|
90
98
|
filter: (p) => {
|
|
91
99
|
const rp = path.relative(".", p);
|
|
92
|
-
|
|
93
|
-
return false;
|
|
94
|
-
if (rp.startsWith("node_modules"))
|
|
95
|
-
return false;
|
|
96
|
-
return true;
|
|
100
|
+
return !gitignore.ignores(rp);
|
|
97
101
|
}
|
|
98
102
|
});
|
|
99
103
|
const results = [];
|
|
@@ -104,10 +108,18 @@ async function readdirRecursive(dir, options) {
|
|
|
104
108
|
if (!rp)
|
|
105
109
|
continue;
|
|
106
110
|
results.push({
|
|
107
|
-
path: rp
|
|
111
|
+
path: `./${rp}`,
|
|
108
112
|
type: file.stats.isDirectory() ? "tree" : "blob",
|
|
109
113
|
size: file.stats.size
|
|
110
114
|
});
|
|
111
115
|
}
|
|
112
116
|
return results;
|
|
113
117
|
}
|
|
118
|
+
async function initGitignore() {
|
|
119
|
+
if (gitignore)
|
|
120
|
+
return;
|
|
121
|
+
const gitignoreStr = await fs.readFile("./.gitignore", "utf-8");
|
|
122
|
+
gitignore = ignore().add(["node_modules", ".git"]);
|
|
123
|
+
if (gitignoreStr)
|
|
124
|
+
gitignore = gitignore.add(gitignoreStr.split("\n").filter((x) => x));
|
|
125
|
+
}
|