diginext-utils 3.0.1 → 3.0.2
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/file/detectPrivateKey.js +10 -8
- package/dist/file/detectPrivateKey.js.map +1 -1
- package/dist/file/getAllFiles.d.ts +1 -1
- package/dist/file/getAllFiles.js +14 -4
- package/dist/file/getAllFiles.js.map +1 -1
- package/esm/file/detectPrivateKey.js +10 -8
- package/esm/file/detectPrivateKey.js.map +1 -1
- package/esm/file/getAllFiles.d.ts +1 -1
- package/esm/file/getAllFiles.js +14 -4
- package/esm/file/getAllFiles.js.map +1 -1
- package/package.json +1 -1
|
@@ -15,14 +15,16 @@ function detectPrivateKey(dirPath) {
|
|
|
15
15
|
const _path = list[i];
|
|
16
16
|
// Read the contents of the file
|
|
17
17
|
const fileContents = fs_1.default.readFileSync(_path);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
switch (true) {
|
|
19
|
+
case fileContents.includes("-----BEGIN "):
|
|
20
|
+
case fileContents.includes("SECRET=") && !fileContents.includes("SECRET=\n") && !fileContents.includes("SECRET=*"):
|
|
21
|
+
{
|
|
22
|
+
_list.push(_path);
|
|
23
|
+
result = false;
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
default:
|
|
27
|
+
break;
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectPrivateKey.js","sourceRoot":"","sources":["../../src/file/detectPrivateKey.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gEAAwC;AAExC,SAAwB,gBAAgB,CAAC,OAAe;IACvD,EAAE;IACF,MAAM,IAAI,GAAG,IAAA,qBAAW,EAAC,OAAO,CAAC,CAAC;IAElC,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,MAAM,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H,CAAC;AA/BD,mCA+BC;AAEQ,4CAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function getAllFiles(dirPath: string): Array<string>;
|
|
1
|
+
export default function getAllFiles(dirPath: string, skipDotStart?: true): Array<string>;
|
package/dist/file/getAllFiles.js
CHANGED
|
@@ -5,14 +5,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
function getAllFiles(dirPath) {
|
|
8
|
+
function getAllFiles(dirPath, skipDotStart) {
|
|
9
9
|
//
|
|
10
10
|
const list = [];
|
|
11
11
|
const files = fs_1.default.readdirSync(dirPath);
|
|
12
12
|
files.forEach(function (file) {
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (!/^(node_modules|_next|\.next|\.git)/.test(file)) {
|
|
14
|
+
if (skipDotStart) {
|
|
15
|
+
if (!/^\..*/.test(file)) {
|
|
16
|
+
const newPath = path_1.default.join(dirPath, "/", file).replace(/\\/g, "/");
|
|
17
|
+
if (fs_1.default.statSync(newPath).isDirectory()) {
|
|
18
|
+
list.push(...getAllFiles(newPath));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
list.push(newPath);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
16
26
|
const newPath = path_1.default.join(dirPath, "/", file).replace(/\\/g, "/");
|
|
17
27
|
if (fs_1.default.statSync(newPath).isDirectory()) {
|
|
18
28
|
list.push(...getAllFiles(newPath));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAllFiles.js","sourceRoot":"","sources":["../../src/file/getAllFiles.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,SAAwB,WAAW,CAAC,OAAe;
|
|
1
|
+
{"version":3,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AAC;AA5BD,8BA4BC"}
|
|
@@ -9,14 +9,16 @@ export default function detectPrivateKey(dirPath) {
|
|
|
9
9
|
const _path = list[i];
|
|
10
10
|
// Read the contents of the file
|
|
11
11
|
const fileContents = fs.readFileSync(_path);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
switch (true) {
|
|
13
|
+
case fileContents.includes("-----BEGIN "):
|
|
14
|
+
case fileContents.includes("SECRET=") && !fileContents.includes("SECRET=\n") && !fileContents.includes("SECRET=*"):
|
|
15
|
+
{
|
|
16
|
+
_list.push(_path);
|
|
17
|
+
result = false;
|
|
18
|
+
}
|
|
19
|
+
break;
|
|
20
|
+
default:
|
|
21
|
+
break;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detectPrivateKey.js","sourceRoot":"","sources":["../../src/file/detectPrivateKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAe;IACvD,EAAE;IACF,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAElC,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEtB,gCAAgC;QAChC,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAE5C,
|
|
1
|
+
{"version":3,"file":"detectPrivateKey.js","sourceRoot":"","sources":["../../src/file/detectPrivateKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAe;IACvD,EAAE;IACF,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAElC,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAEtB,gCAAgC;QAChC,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QAE5C,QAAQ,IAAI,EAAE;YACb,KAAK,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC1C,KAAK,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC;gBACjH;oBACC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAClB,MAAM,GAAG,KAAK,CAAC;iBACf;gBACD,MAAM;YACP;gBACC,MAAM;SACP;KACD;IAED,OAAO;QACN,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,KAAK;KACX,CAAC;AACH,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function getAllFiles(dirPath: string): Array<string>;
|
|
1
|
+
export default function getAllFiles(dirPath: string, skipDotStart?: true): Array<string>;
|
package/esm/file/getAllFiles.js
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
export default function getAllFiles(dirPath) {
|
|
3
|
+
export default function getAllFiles(dirPath, skipDotStart) {
|
|
4
4
|
//
|
|
5
5
|
const list = [];
|
|
6
6
|
const files = fs.readdirSync(dirPath);
|
|
7
7
|
files.forEach(function (file) {
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
if (!/^(node_modules|_next|\.next|\.git)/.test(file)) {
|
|
9
|
+
if (skipDotStart) {
|
|
10
|
+
if (!/^\..*/.test(file)) {
|
|
11
|
+
const newPath = path.join(dirPath, "/", file).replace(/\\/g, "/");
|
|
12
|
+
if (fs.statSync(newPath).isDirectory()) {
|
|
13
|
+
list.push(...getAllFiles(newPath));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
list.push(newPath);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
11
21
|
const newPath = path.join(dirPath, "/", file).replace(/\\/g, "/");
|
|
12
22
|
if (fs.statSync(newPath).isDirectory()) {
|
|
13
23
|
list.push(...getAllFiles(newPath));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAllFiles.js","sourceRoot":"","sources":["../../src/file/getAllFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,OAAe;
|
|
1
|
+
{"version":3,"file":"getAllFiles.js","sourceRoot":"","sources":["../../src/file/getAllFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,OAAe,EAAE,YAAmB;IACvE,EAAE;IACF,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAEtC,KAAK,CAAC,OAAO,CAAC,UAAU,IAA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