@sasjs/utils 3.4.0 → 3.5.0
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/.github/workflows/publish.yml +1 -1
- package/auth/auth.js +6 -8
- package/auth/auth.js.map +1 -1
- package/compileTree/compileTree.js +37 -89
- package/compileTree/compileTree.js.map +1 -1
- package/conversion/convertJsDateToSasDate.js +6 -6
- package/conversion/convertJsDateToSasDate.js.map +1 -1
- package/conversion/convertSasDateToJsDate.js +8 -8
- package/conversion/convertSasDateToJsDate.js.map +1 -1
- package/error/errorModifier.js +3 -14
- package/error/errorModifier.js.map +1 -1
- package/error/serverTypeError.js +9 -54
- package/error/serverTypeError.js.map +1 -1
- package/file/csvFile.js +72 -159
- package/file/csvFile.js.map +1 -1
- package/file/file.d.ts +1 -1
- package/file/file.js +121 -264
- package/file/file.js.map +1 -1
- package/file/getAbsolutePath.js +5 -7
- package/file/getAbsolutePath.js.map +1 -1
- package/formatter/number.js +2 -3
- package/formatter/number.js.map +1 -1
- package/formatter/regexp.js +1 -1
- package/formatter/regexp.js.map +1 -1
- package/formatter/string.js +2 -6
- package/formatter/string.js.map +1 -1
- package/fs/generateCompileProgram.js +36 -145
- package/fs/generateCompileProgram.js.map +1 -1
- package/fs/hash.js +83 -186
- package/fs/hash.js.map +1 -1
- package/fs/internal/helper.js +60 -99
- package/fs/internal/helper.js.map +1 -1
- package/fs/sync.js +86 -192
- package/fs/sync.js.map +1 -1
- package/input/readAndValidateInput.js +80 -163
- package/input/readAndValidateInput.js.map +1 -1
- package/input/validators.js +9 -13
- package/input/validators.js.map +1 -1
- package/logger/isLowerThanOrEqualTo.js +2 -2
- package/logger/isLowerThanOrEqualTo.js.map +1 -1
- package/logger/isNullOrUndefined.js +1 -1
- package/logger/isNullOrUndefined.js.map +1 -1
- package/logger/logger.js +45 -104
- package/logger/logger.js.map +1 -1
- package/package.json +2 -3
- package/sasjsCli/getDependencies.js +122 -198
- package/sasjsCli/getDependencies.js.map +1 -1
- package/sasjsCli/getDependencyPaths.js +40 -131
- package/sasjsCli/getDependencyPaths.js.map +1 -1
- package/sasjsCli/getInitTerm.js +90 -192
- package/sasjsCli/getInitTerm.js.map +1 -1
- package/sasjsCli/getList.js +13 -13
- package/sasjsCli/getList.js.map +1 -1
- package/sasjsCli/getPreCode.js +41 -79
- package/sasjsCli/getPreCode.js.map +1 -1
- package/sasjsCli/loadDependenciesFile.js +63 -160
- package/sasjsCli/loadDependenciesFile.js.map +1 -1
- package/sasjsCli/prioritiseDependencyOverrides.js +10 -39
- package/sasjsCli/prioritiseDependencyOverrides.js.map +1 -1
- package/sasjsCli/validateFileRef.js +1 -1
- package/sasjsCli/validateFileRef.js.map +1 -1
- package/time/timestamp.js +16 -18
- package/time/timestamp.js.map +1 -1
- package/types/macro.js +1 -3
- package/types/macro.js.map +1 -1
- package/types/target.js +86 -197
- package/types/target.js.map +1 -1
- package/types/targetValidators.js +32 -32
- package/types/targetValidators.js.map +1 -1
- package/utils/base64.js +7 -7
- package/utils/base64.js.map +1 -1
- package/utils/bytesToSize.js +6 -8
- package/utils/bytesToSize.js.map +1 -1
- package/utils/chunk.js +2 -3
- package/utils/chunk.js.map +1 -1
- package/utils/diff.js +7 -36
- package/utils/diff.js.map +1 -1
- package/utils/executor.js +2 -2
- package/utils/executor.js.map +1 -1
- package/utils/fileTree.js +25 -37
- package/utils/fileTree.js.map +1 -1
- package/utils/url.js +2 -2
- package/utils/url.js.map +1 -1
- package/utils/utils.js +15 -63
- package/utils/utils.js.map +1 -1
package/formatter/string.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.capitalizeFirstChar = exports.sanitizeSpecialChars = void 0;
|
|
4
|
-
|
|
5
|
-
return str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
6
|
-
};
|
|
4
|
+
const sanitizeSpecialChars = (str) => str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
|
|
7
5
|
exports.sanitizeSpecialChars = sanitizeSpecialChars;
|
|
8
|
-
|
|
9
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
10
|
-
};
|
|
6
|
+
const capitalizeFirstChar = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
11
7
|
exports.capitalizeFirstChar = capitalizeFirstChar;
|
|
12
8
|
//# sourceMappingURL=string.js.map
|
package/formatter/string.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/formatter/string.ts"],"names":[],"mappings":";;;AAAO,
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/formatter/string.ts"],"names":[],"mappings":";;;AAAO,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAE,EAAE,CAClD,GAAG,CAAC,OAAO,CACT,6EAA6E,EAC7E,EAAE,CACH,CAAA;AAJU,QAAA,oBAAoB,wBAI9B;AAEI,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAU,EAAE,CACzD,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAD/B,QAAA,mBAAmB,uBACY"}
|
|
@@ -8,155 +8,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __values = (this && this.__values) || function(o) {
|
|
39
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
-
if (m) return m.call(o);
|
|
41
|
-
if (o && typeof o.length === "number") return {
|
|
42
|
-
next: function () {
|
|
43
|
-
if (o && i >= o.length) o = void 0;
|
|
44
|
-
return { value: o && o[i++], done: !o };
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
-
};
|
|
49
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
13
|
};
|
|
52
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
15
|
exports.generateCompileProgram = void 0;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
compiledMacrosCode = _a.sent();
|
|
72
|
-
initialProgramContent = (0, helper_1.getInitialCode)();
|
|
73
|
-
return [4 /*yield*/, fileAndDirectoryCreationCode(folderPath)];
|
|
74
|
-
case 2:
|
|
75
|
-
folderCreationCode = _a.sent();
|
|
76
|
-
return [2 /*return*/, compiledMacrosCode + initialProgramContent + folderCreationCode];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}); };
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const file_1 = require("../file");
|
|
18
|
+
const utils_1 = require("../utils");
|
|
19
|
+
const helper_1 = require("./internal/helper");
|
|
20
|
+
const generateCompileProgram = (folderPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const compiledMacrosCode = yield (0, helper_1.getCompiledMacrosCode)([
|
|
22
|
+
'mf_mkdir.sas',
|
|
23
|
+
'mp_dirlist.sas',
|
|
24
|
+
'mf_existds.sas',
|
|
25
|
+
'mf_getvarlist.sas',
|
|
26
|
+
'mf_wordsinstr1butnotstr2.sas',
|
|
27
|
+
'mp_dropmembers.sas'
|
|
28
|
+
]);
|
|
29
|
+
const initialProgramContent = (0, helper_1.getInitialCode)();
|
|
30
|
+
const folderCreationCode = yield fileAndDirectoryCreationCode(folderPath);
|
|
31
|
+
return compiledMacrosCode + initialProgramContent + folderCreationCode;
|
|
32
|
+
});
|
|
80
33
|
exports.generateCompileProgram = generateCompileProgram;
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
_d.label = 5;
|
|
101
|
-
case 5:
|
|
102
|
-
_d.trys.push([5, 10, 11, 12]);
|
|
103
|
-
files_1 = __values(files), files_1_1 = files_1.next();
|
|
104
|
-
_d.label = 6;
|
|
105
|
-
case 6:
|
|
106
|
-
if (!!files_1_1.done) return [3 /*break*/, 9];
|
|
107
|
-
file = files_1_1.value;
|
|
108
|
-
return [4 /*yield*/, fileAndDirectoryCreationCode(path_1.default.join(resourcePath, file), pathRelativeTo, resultCode)];
|
|
109
|
-
case 7:
|
|
110
|
-
resultCode = _d.sent();
|
|
111
|
-
_d.label = 8;
|
|
112
|
-
case 8:
|
|
113
|
-
files_1_1 = files_1.next();
|
|
114
|
-
return [3 /*break*/, 6];
|
|
115
|
-
case 9: return [3 /*break*/, 12];
|
|
116
|
-
case 10:
|
|
117
|
-
e_1_1 = _d.sent();
|
|
118
|
-
e_1 = { error: e_1_1 };
|
|
119
|
-
return [3 /*break*/, 12];
|
|
120
|
-
case 11:
|
|
121
|
-
try {
|
|
122
|
-
if (files_1_1 && !files_1_1.done && (_b = files_1.return)) _b.call(files_1);
|
|
123
|
-
}
|
|
124
|
-
finally { if (e_1) throw e_1.error; }
|
|
125
|
-
return [7 /*endfinally*/];
|
|
126
|
-
case 12: return [4 /*yield*/, (0, file_1.listSubFoldersInFolder)(resourcePath)];
|
|
127
|
-
case 13:
|
|
128
|
-
subFolders = _d.sent();
|
|
129
|
-
_d.label = 14;
|
|
130
|
-
case 14:
|
|
131
|
-
_d.trys.push([14, 19, 20, 21]);
|
|
132
|
-
subFolders_1 = __values(subFolders), subFolders_1_1 = subFolders_1.next();
|
|
133
|
-
_d.label = 15;
|
|
134
|
-
case 15:
|
|
135
|
-
if (!!subFolders_1_1.done) return [3 /*break*/, 18];
|
|
136
|
-
folder = subFolders_1_1.value;
|
|
137
|
-
folderPath = path_1.default.join(resourcePath, folder);
|
|
138
|
-
resultCode = "".concat(resultCode, "\n%mf_mkdir(&fsTarget").concat((0, utils_1.generatePathForSas)(folderPath.replace(pathRelativeTo, '')), ")\n");
|
|
139
|
-
return [4 /*yield*/, fileAndDirectoryCreationCode(folderPath, pathRelativeTo, resultCode)];
|
|
140
|
-
case 16:
|
|
141
|
-
resultCode = _d.sent();
|
|
142
|
-
_d.label = 17;
|
|
143
|
-
case 17:
|
|
144
|
-
subFolders_1_1 = subFolders_1.next();
|
|
145
|
-
return [3 /*break*/, 15];
|
|
146
|
-
case 18: return [3 /*break*/, 21];
|
|
147
|
-
case 19:
|
|
148
|
-
e_2_1 = _d.sent();
|
|
149
|
-
e_2 = { error: e_2_1 };
|
|
150
|
-
return [3 /*break*/, 21];
|
|
151
|
-
case 20:
|
|
152
|
-
try {
|
|
153
|
-
if (subFolders_1_1 && !subFolders_1_1.done && (_c = subFolders_1.return)) _c.call(subFolders_1);
|
|
154
|
-
}
|
|
155
|
-
finally { if (e_2) throw e_2.error; }
|
|
156
|
-
return [7 /*endfinally*/];
|
|
157
|
-
case 21: return [2 /*return*/, resultCode];
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
};
|
|
34
|
+
const fileAndDirectoryCreationCode = (resourcePath, pathRelativeTo = resourcePath, resultCode = '') => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
if (!(yield (0, file_1.isFolder)(resourcePath))) {
|
|
36
|
+
resultCode += yield (0, helper_1.generateCodeForFileCreation)(resourcePath, pathRelativeTo);
|
|
37
|
+
return resultCode;
|
|
38
|
+
}
|
|
39
|
+
const files = yield (0, file_1.listFilesInFolder)(resourcePath);
|
|
40
|
+
for (const file of files) {
|
|
41
|
+
resultCode = yield fileAndDirectoryCreationCode(path_1.default.join(resourcePath, file), pathRelativeTo, resultCode);
|
|
42
|
+
}
|
|
43
|
+
const subFolders = yield (0, file_1.listSubFoldersInFolder)(resourcePath);
|
|
44
|
+
for (const folder of subFolders) {
|
|
45
|
+
const folderPath = path_1.default.join(resourcePath, folder);
|
|
46
|
+
resultCode = `${resultCode}
|
|
47
|
+
%mf_mkdir(&fsTarget${(0, utils_1.generatePathForSas)(folderPath.replace(pathRelativeTo, ''))})
|
|
48
|
+
`;
|
|
49
|
+
resultCode = yield fileAndDirectoryCreationCode(folderPath, pathRelativeTo, resultCode);
|
|
50
|
+
}
|
|
51
|
+
return resultCode;
|
|
52
|
+
});
|
|
162
53
|
//# sourceMappingURL=generateCompileProgram.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateCompileProgram.js","sourceRoot":"","sources":["../../src/fs/generateCompileProgram.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateCompileProgram.js","sourceRoot":"","sources":["../../src/fs/generateCompileProgram.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAuB;AACvB,kCAA6E;AAC7E,oCAA6C;AAC7C,8CAI0B;AAEnB,MAAM,sBAAsB,GAAG,CAAO,UAAkB,EAAE,EAAE;IACjE,MAAM,kBAAkB,GAAG,MAAM,IAAA,8BAAqB,EAAC;QACrD,cAAc;QACd,gBAAgB;QAChB,gBAAgB;QAChB,mBAAmB;QACnB,8BAA8B;QAC9B,oBAAoB;KACrB,CAAC,CAAA;IAEF,MAAM,qBAAqB,GAAG,IAAA,uBAAc,GAAE,CAAA;IAE9C,MAAM,kBAAkB,GAAG,MAAM,4BAA4B,CAAC,UAAU,CAAC,CAAA;IAEzE,OAAO,kBAAkB,GAAG,qBAAqB,GAAG,kBAAkB,CAAA;AACxE,CAAC,CAAA,CAAA;AAfY,QAAA,sBAAsB,0BAelC;AAED,MAAM,4BAA4B,GAAG,CACnC,YAAoB,EACpB,iBAAyB,YAAY,EACrC,aAAqB,EAAE,EACvB,EAAE;IACF,IAAI,CAAC,CAAC,MAAM,IAAA,eAAQ,EAAC,YAAY,CAAC,CAAC,EAAE;QACnC,UAAU,IAAI,MAAM,IAAA,oCAA2B,EAC7C,YAAY,EACZ,cAAc,CACf,CAAA;QACD,OAAO,UAAU,CAAA;KAClB;IAED,MAAM,KAAK,GAAG,MAAM,IAAA,wBAAiB,EAAC,YAAY,CAAC,CAAA;IACnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,UAAU,GAAG,MAAM,4BAA4B,CAC7C,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,EAC7B,cAAc,EACd,UAAU,CACX,CAAA;KACF;IAED,MAAM,UAAU,GAAG,MAAM,IAAA,6BAAsB,EAAC,YAAY,CAAC,CAAA;IAC7D,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE;QAC/B,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;QAElD,UAAU,GAAG,GAAG,UAAU;qBACT,IAAA,0BAAkB,EACjC,UAAU,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CACvC;CACJ,CAAA;QAEG,UAAU,GAAG,MAAM,4BAA4B,CAC7C,UAAU,EACV,cAAc,EACd,UAAU,CACX,CAAA;KACF;IAED,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA,CAAA"}
|
package/fs/hash.js
CHANGED
|
@@ -8,53 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __values = (this && this.__values) || function(o) {
|
|
39
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
-
if (m) return m.call(o);
|
|
41
|
-
if (o && typeof o.length === "number") return {
|
|
42
|
-
next: function () {
|
|
43
|
-
if (o && i >= o.length) o = void 0;
|
|
44
|
-
return { value: o && o[i++], done: !o };
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
-
};
|
|
49
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
13
|
};
|
|
52
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
15
|
exports.extractHashArray = exports.compareHashes = exports.getHash = void 0;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
16
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const crypto_1 = require("crypto");
|
|
19
|
+
const file_1 = require("../file");
|
|
58
20
|
/**
|
|
59
21
|
* Hashes each file in each directory, and then hashes the hashes to create a hash for each directory also.
|
|
60
22
|
*
|
|
@@ -69,14 +31,9 @@ var file_1 = require("../file");
|
|
|
69
31
|
*
|
|
70
32
|
* @param {string} folderPath - absolute folder path
|
|
71
33
|
*/
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
case 0: return [4 /*yield*/, hashFolder(folderPath)];
|
|
76
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}); };
|
|
34
|
+
const getHash = (folderPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
return yield hashFolder(folderPath);
|
|
36
|
+
});
|
|
80
37
|
exports.getHash = getHash;
|
|
81
38
|
/**
|
|
82
39
|
* It returns a hashed folder tree that contains the local directory resources that are not synced with remote
|
|
@@ -85,157 +42,97 @@ function compareHashes(localHash, remoteHashMap) {
|
|
|
85
42
|
return hashDifference(localHash, remoteHashMap);
|
|
86
43
|
}
|
|
87
44
|
exports.compareHashes = compareHashes;
|
|
88
|
-
|
|
45
|
+
const extractHashArray = (log) => {
|
|
89
46
|
if (log.includes('>>weboutBEGIN<<')) {
|
|
90
47
|
try {
|
|
91
|
-
|
|
48
|
+
const webout = log
|
|
92
49
|
.split(/>>weboutBEGIN<<[\n|\r\n]/)[1]
|
|
93
50
|
.split(/>>weboutEND<<[\n|\r\n]/)[0];
|
|
94
|
-
|
|
95
|
-
|
|
51
|
+
const weboutWithoutLF = webout.replace(/\n|\r\n/g, '');
|
|
52
|
+
const jsonWebout = JSON.parse(weboutWithoutLF);
|
|
96
53
|
return jsonWebout.hashes;
|
|
97
54
|
}
|
|
98
55
|
catch (err) {
|
|
99
|
-
throw new Error(
|
|
56
|
+
throw new Error(`An error occurred while extracting hashes array from webout: ${err.message}`);
|
|
100
57
|
}
|
|
101
58
|
}
|
|
102
59
|
};
|
|
103
60
|
exports.extractHashArray = extractHashArray;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
isFile: false,
|
|
126
|
-
members: []
|
|
127
|
-
});
|
|
128
|
-
hashedDiff.members.push(diff);
|
|
129
|
-
}
|
|
61
|
+
const hashDifference = (localHash, remoteHashMap, hashedDiff = {
|
|
62
|
+
hash: localHash.hash,
|
|
63
|
+
absolutePath: localHash.absolutePath,
|
|
64
|
+
relativePath: localHash.relativePath,
|
|
65
|
+
isFile: false,
|
|
66
|
+
members: []
|
|
67
|
+
}) => {
|
|
68
|
+
for (const member of localHash.members) {
|
|
69
|
+
if (remoteHashMap[member.relativePath] !== member.hash) {
|
|
70
|
+
if (member.isFile) {
|
|
71
|
+
hashedDiff.members.push(member);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const diff = hashDifference(member, remoteHashMap, {
|
|
75
|
+
hash: member.hash,
|
|
76
|
+
absolutePath: member.absolutePath,
|
|
77
|
+
relativePath: member.relativePath,
|
|
78
|
+
isFile: false,
|
|
79
|
+
members: []
|
|
80
|
+
});
|
|
81
|
+
hashedDiff.members.push(diff);
|
|
130
82
|
}
|
|
131
83
|
}
|
|
132
84
|
}
|
|
133
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
134
|
-
finally {
|
|
135
|
-
try {
|
|
136
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
137
|
-
}
|
|
138
|
-
finally { if (e_1) throw e_1.error; }
|
|
139
|
-
}
|
|
140
85
|
return hashedDiff;
|
|
141
86
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
filesAndFolders = _b.sent();
|
|
171
|
-
filesAndFolders.sort();
|
|
172
|
-
concatenatedHash = '';
|
|
173
|
-
chunkSize = 100;
|
|
174
|
-
i = 0;
|
|
175
|
-
_b.label = 2;
|
|
176
|
-
case 2:
|
|
177
|
-
if (!(i < filesAndFolders.length)) return [3 /*break*/, 15];
|
|
178
|
-
resources = filesAndFolders.slice(i, i + chunkSize);
|
|
179
|
-
_b.label = 3;
|
|
180
|
-
case 3:
|
|
181
|
-
_b.trys.push([3, 11, 12, 13]);
|
|
182
|
-
resources_1 = (e_2 = void 0, __values(resources)), resources_1_1 = resources_1.next();
|
|
183
|
-
_b.label = 4;
|
|
184
|
-
case 4:
|
|
185
|
-
if (!!resources_1_1.done) return [3 /*break*/, 10];
|
|
186
|
-
resource = resources_1_1.value;
|
|
187
|
-
resourcePath = path_1.default.join(folderPath, resource);
|
|
188
|
-
return [4 /*yield*/, (0, file_1.isFolder)(resourcePath)];
|
|
189
|
-
case 5:
|
|
190
|
-
if (!_b.sent()) return [3 /*break*/, 7];
|
|
191
|
-
return [4 /*yield*/, hashFolder(resourcePath, pathRelativeTo)];
|
|
192
|
-
case 6:
|
|
193
|
-
hashedSubFolder = _b.sent();
|
|
194
|
-
hashedFolder.members.push(hashedSubFolder);
|
|
195
|
-
concatenatedHash += hashedSubFolder.hash;
|
|
196
|
-
return [3 /*break*/, 9];
|
|
197
|
-
case 7: return [4 /*yield*/, hashFile(resourcePath)];
|
|
198
|
-
case 8:
|
|
199
|
-
hash = _b.sent();
|
|
200
|
-
if (!hash)
|
|
201
|
-
return [3 /*break*/, 9];
|
|
202
|
-
hashedFolder.members.push({
|
|
203
|
-
hash: hash,
|
|
204
|
-
absolutePath: resourcePath,
|
|
205
|
-
relativePath: (0, file_1.getRelativePath)(pathRelativeTo, resourcePath),
|
|
206
|
-
isFile: true
|
|
207
|
-
});
|
|
208
|
-
concatenatedHash += hash;
|
|
209
|
-
_b.label = 9;
|
|
210
|
-
case 9:
|
|
211
|
-
resources_1_1 = resources_1.next();
|
|
212
|
-
return [3 /*break*/, 4];
|
|
213
|
-
case 10: return [3 /*break*/, 13];
|
|
214
|
-
case 11:
|
|
215
|
-
e_2_1 = _b.sent();
|
|
216
|
-
e_2 = { error: e_2_1 };
|
|
217
|
-
return [3 /*break*/, 13];
|
|
218
|
-
case 12:
|
|
219
|
-
try {
|
|
220
|
-
if (resources_1_1 && !resources_1_1.done && (_a = resources_1.return)) _a.call(resources_1);
|
|
221
|
-
}
|
|
222
|
-
finally { if (e_2) throw e_2.error; }
|
|
223
|
-
return [7 /*endfinally*/];
|
|
224
|
-
case 13:
|
|
225
|
-
if (concatenatedHash !== '') {
|
|
226
|
-
hash = (0, crypto_1.createHash)('md5');
|
|
227
|
-
hash.update(concatenatedHash);
|
|
228
|
-
concatenatedHash = hash.digest('hex').toUpperCase();
|
|
229
|
-
}
|
|
230
|
-
_b.label = 14;
|
|
231
|
-
case 14:
|
|
232
|
-
i += chunkSize;
|
|
233
|
-
return [3 /*break*/, 2];
|
|
234
|
-
case 15:
|
|
235
|
-
hashedFolder.hash = concatenatedHash;
|
|
236
|
-
return [2 /*return*/, hashedFolder];
|
|
87
|
+
const hashFile = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
const fileContent = fs_extra_1.default.readFileSync(filePath);
|
|
89
|
+
if (fileContent.length) {
|
|
90
|
+
const hash = (0, crypto_1.createHash)('md5');
|
|
91
|
+
hash.update(fileContent);
|
|
92
|
+
return hash.digest('hex').toUpperCase();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const hashFolder = (folderPath, pathRelativeTo = folderPath, hashedFolder = {
|
|
96
|
+
hash: '',
|
|
97
|
+
absolutePath: folderPath,
|
|
98
|
+
relativePath: (0, file_1.getRelativePath)(pathRelativeTo, folderPath),
|
|
99
|
+
isFile: false,
|
|
100
|
+
members: []
|
|
101
|
+
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
const filesAndFolders = yield (0, file_1.listFilesAndSubFoldersInFolder)(folderPath, false);
|
|
103
|
+
filesAndFolders.sort();
|
|
104
|
+
let concatenatedHash = '';
|
|
105
|
+
const chunkSize = 100;
|
|
106
|
+
for (let i = 0; i < filesAndFolders.length; i += chunkSize) {
|
|
107
|
+
// Take the first 100 hashes, concatenate and hash
|
|
108
|
+
const resources = filesAndFolders.slice(i, i + chunkSize);
|
|
109
|
+
for (const resource of resources) {
|
|
110
|
+
const resourcePath = path_1.default.join(folderPath, resource);
|
|
111
|
+
if (yield (0, file_1.isFolder)(resourcePath)) {
|
|
112
|
+
const hashedSubFolder = yield hashFolder(resourcePath, pathRelativeTo);
|
|
113
|
+
hashedFolder.members.push(hashedSubFolder);
|
|
114
|
+
concatenatedHash += hashedSubFolder.hash;
|
|
237
115
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
116
|
+
else {
|
|
117
|
+
const hash = yield hashFile(resourcePath);
|
|
118
|
+
if (!hash)
|
|
119
|
+
continue;
|
|
120
|
+
hashedFolder.members.push({
|
|
121
|
+
hash,
|
|
122
|
+
absolutePath: resourcePath,
|
|
123
|
+
relativePath: (0, file_1.getRelativePath)(pathRelativeTo, resourcePath),
|
|
124
|
+
isFile: true
|
|
125
|
+
});
|
|
126
|
+
concatenatedHash += hash;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (concatenatedHash !== '') {
|
|
130
|
+
const hash = (0, crypto_1.createHash)('md5');
|
|
131
|
+
hash.update(concatenatedHash);
|
|
132
|
+
concatenatedHash = hash.digest('hex').toUpperCase();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
hashedFolder.hash = concatenatedHash;
|
|
136
|
+
return hashedFolder;
|
|
137
|
+
});
|
|
241
138
|
//# sourceMappingURL=hash.js.map
|
package/fs/hash.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/fs/hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/fs/hash.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAyB;AACzB,gDAAuB;AACvB,mCAAmC;AAEnC,kCAIgB;AAChB;;;;;;;;;;;;;GAaG;AAEI,MAAM,OAAO,GAAG,CAAO,UAAkB,EAAyB,EAA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