@sasjs/utils 2.35.0 → 2.36.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/.github/reviewer-lottery.yml +0 -2
- package/.github/workflows/run-tests.yml +3 -0
- package/auth/auth.js +2 -2
- package/auth/auth.js.map +1 -1
- package/error/serverTypeError.js +10 -6
- package/error/serverTypeError.js.map +1 -1
- package/file/csvFile.js +14 -10
- package/file/csvFile.js.map +1 -1
- package/file/file.d.ts +1 -1
- package/file/file.js +19 -15
- package/file/file.js.map +1 -1
- package/formatter/index.d.ts +1 -1
- package/formatter/index.js +2 -1
- package/formatter/index.js.map +1 -1
- package/formatter/number.js +1 -1
- package/formatter/number.js.map +1 -1
- package/formatter/string.d.ts +1 -0
- package/formatter/string.js +5 -1
- package/formatter/string.js.map +1 -1
- package/input/readAndValidateInput.js +7 -7
- package/input/readAndValidateInput.js.map +1 -1
- package/logger/logger.js +21 -17
- package/logger/logger.js.map +1 -1
- package/package.json +22 -22
- package/sasjsCli/getDependencies.js +30 -29
- package/sasjsCli/getDependencies.js.map +1 -1
- package/sasjsCli/getDependencyPaths.js +29 -23
- package/sasjsCli/getDependencyPaths.js.map +1 -1
- package/sasjsCli/getInitTerm.d.ts +10 -13
- package/sasjsCli/getInitTerm.js +64 -65
- package/sasjsCli/getInitTerm.js.map +1 -1
- package/sasjsCli/loadDependenciesFile.js +23 -19
- package/sasjsCli/loadDependenciesFile.js.map +1 -1
- package/sasjsCli/prioritiseDependencyOverrides.js +10 -6
- package/sasjsCli/prioritiseDependencyOverrides.js.map +1 -1
- package/time/timestamp.js +6 -6
- package/time/timestamp.js.map +1 -1
- package/types/httpsAgentOptions.d.ts +1 -1
- package/types/target.js +19 -19
- package/types/target.js.map +1 -1
- package/types/targetValidators.js +2 -2
- package/types/targetValidators.js.map +1 -1
- package/utils/diff.js +9 -5
- package/utils/diff.js.map +1 -1
package/package.json
CHANGED
|
@@ -33,32 +33,32 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/sasjs/utils#readme",
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@sasjs/core": "
|
|
37
|
-
"@types/cli-table": "
|
|
36
|
+
"@sasjs/core": "3.10.0",
|
|
37
|
+
"@types/cli-table": "0.3.0",
|
|
38
38
|
"@types/find": "0.2.1",
|
|
39
|
-
"@types/jest": "27.0
|
|
40
|
-
"@types/rimraf": "
|
|
41
|
-
"@types/valid-url": "
|
|
42
|
-
"babel-jest": "27.
|
|
43
|
-
"jest": "27.
|
|
44
|
-
"jest-extended": "
|
|
45
|
-
"ts-jest": "27.
|
|
39
|
+
"@types/jest": "27.4.0",
|
|
40
|
+
"@types/rimraf": "3.0.1",
|
|
41
|
+
"@types/valid-url": "1.0.3",
|
|
42
|
+
"babel-jest": "27.4.6",
|
|
43
|
+
"jest": "27.4.7",
|
|
44
|
+
"jest-extended": "1.1.0",
|
|
45
|
+
"ts-jest": "27.1.3",
|
|
46
46
|
"ts-loader": "9.2.6",
|
|
47
|
-
"typescript": "4.
|
|
47
|
+
"typescript": "4.5.4"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@types/fs-extra": "
|
|
51
|
-
"@types/prompts": "
|
|
52
|
-
"chalk": "
|
|
53
|
-
"cli-table": "
|
|
54
|
-
"consola": "
|
|
55
|
-
"csv-stringify": "
|
|
50
|
+
"@types/fs-extra": "9.0.13",
|
|
51
|
+
"@types/prompts": "2.0.13",
|
|
52
|
+
"chalk": "4.1.1",
|
|
53
|
+
"cli-table": "0.3.6",
|
|
54
|
+
"consola": "2.15.0",
|
|
55
|
+
"csv-stringify": "5.6.5",
|
|
56
56
|
"find": "0.3.0",
|
|
57
|
-
"fs-extra": "
|
|
58
|
-
"jwt-decode": "
|
|
59
|
-
"prompts": "
|
|
60
|
-
"rimraf": "
|
|
61
|
-
"valid-url": "
|
|
57
|
+
"fs-extra": "10.0.0",
|
|
58
|
+
"jwt-decode": "3.1.2",
|
|
59
|
+
"prompts": "2.4.1",
|
|
60
|
+
"rimraf": "3.0.2",
|
|
61
|
+
"valid-url": "1.0.9"
|
|
62
62
|
},
|
|
63
|
-
"version": "2.
|
|
63
|
+
"version": "2.36.2"
|
|
64
64
|
}
|
|
@@ -61,6 +61,7 @@ var _1 = require("./");
|
|
|
61
61
|
var utils_2 = require("../utils");
|
|
62
62
|
var find_1 = __importDefault(require("find"));
|
|
63
63
|
var file_1 = require("../file");
|
|
64
|
+
var formatter_1 = require("../formatter");
|
|
64
65
|
// REFACTOR: move logic supporting SAS Macros dependencies to this file
|
|
65
66
|
var DependencyType;
|
|
66
67
|
(function (DependencyType) {
|
|
@@ -84,10 +85,10 @@ var getDepInfo = function (depType, fileContent) {
|
|
|
84
85
|
}
|
|
85
86
|
var depInfo = {
|
|
86
87
|
name: header,
|
|
87
|
-
header: "<h4> "
|
|
88
|
-
config: (depType === DependencyType.Include
|
|
88
|
+
header: "<h4> ".concat(header, " </h4>"),
|
|
89
|
+
config: "".concat((depType === DependencyType.Include
|
|
89
90
|
? 'Program'
|
|
90
|
-
: depType).toLowerCase()
|
|
91
|
+
: depType).toLowerCase(), "Folders"),
|
|
91
92
|
type: depType
|
|
92
93
|
};
|
|
93
94
|
return depInfo;
|
|
@@ -97,9 +98,9 @@ var getDependencies = function (fileName, fileContent, folders, depType) { retur
|
|
|
97
98
|
return __generator(this, function (_a) {
|
|
98
99
|
switch (_a.label) {
|
|
99
100
|
case 0:
|
|
100
|
-
folders = utils_1.uniqArray(folders);
|
|
101
|
+
folders = (0, utils_1.uniqArray)(folders);
|
|
101
102
|
depInfo = getDepInfo(depType, fileContent);
|
|
102
|
-
deps = deconstructDependency(_1.getList(depInfo.header, fileContent), depInfo);
|
|
103
|
+
deps = deconstructDependency((0, _1.getList)(depInfo.header, fileContent), depInfo);
|
|
103
104
|
uniqDeps = [];
|
|
104
105
|
deps.forEach(function (dep) {
|
|
105
106
|
return uniqDeps.find(function (d) { return dep.fileName === d.fileName; }) || uniqDeps.push(dep);
|
|
@@ -107,17 +108,17 @@ var getDependencies = function (fileName, fileContent, folders, depType) { retur
|
|
|
107
108
|
if (!uniqDeps.length) return [3 /*break*/, 2];
|
|
108
109
|
foundDeps_1 = [];
|
|
109
110
|
foundDepsNames_1 = [];
|
|
110
|
-
return [4 /*yield*/, utils_2.asyncForEach(folders, function (folder) { return __awaiter(void 0, void 0, void 0, function () {
|
|
111
|
+
return [4 /*yield*/, (0, utils_2.asyncForEach)(folders, function (folder) { return __awaiter(void 0, void 0, void 0, function () {
|
|
111
112
|
return __generator(this, function (_a) {
|
|
112
113
|
switch (_a.label) {
|
|
113
|
-
case 0: return [4 /*yield*/, utils_2.asyncForEach(uniqDeps, function (dep) { return __awaiter(void 0, void 0, void 0, function () {
|
|
114
|
+
case 0: return [4 /*yield*/, (0, utils_2.asyncForEach)(uniqDeps, function (dep) { return __awaiter(void 0, void 0, void 0, function () {
|
|
114
115
|
var filePaths, encodedFileContent, depContent;
|
|
115
116
|
return __generator(this, function (_a) {
|
|
116
117
|
switch (_a.label) {
|
|
117
118
|
case 0:
|
|
118
119
|
filePaths = find_1.default.fileSync(dep.fileName, folder);
|
|
119
120
|
if (!filePaths.length) return [3 /*break*/, 2];
|
|
120
|
-
return [4 /*yield*/, file_1.readFile(filePaths[0], depType === DependencyType.Binary ? 'base64' : undefined)];
|
|
121
|
+
return [4 /*yield*/, (0, file_1.readFile)(filePaths[0], depType === DependencyType.Binary ? 'base64' : undefined)];
|
|
121
122
|
case 1:
|
|
122
123
|
encodedFileContent = _a.sent();
|
|
123
124
|
depContent = compileDep(depType, encodedFileContent, dep.fileRef);
|
|
@@ -138,17 +139,17 @@ var getDependencies = function (fileName, fileContent, folders, depType) { retur
|
|
|
138
139
|
_a.sent();
|
|
139
140
|
notFoundDeps = deps
|
|
140
141
|
.filter(function (dep) { return !foundDepsNames_1.includes(dep.fileName); })
|
|
141
|
-
.map(function (dep, i) { return i + 1
|
|
142
|
+
.map(function (dep, i) { return "".concat(i + 1, ". '").concat(dep.fileName, "' with fileRef '").concat(dep.fileRef, "'"); })
|
|
142
143
|
.join('\n');
|
|
143
144
|
if (notFoundDeps.length) {
|
|
144
145
|
depFolder = depInfo.config.replace(/([A-Z]+)/g, ' $1');
|
|
145
|
-
depFolder =
|
|
146
|
-
throw new Error("Unable to load dependencies for: "
|
|
147
|
-
|
|
148
|
-
(notFoundDeps
|
|
149
|
-
|
|
150
|
-
(depFolder
|
|
151
|
-
folders.map(function (folder) { return "- "
|
|
146
|
+
depFolder = (0, formatter_1.capitalizeFirstChar)(depFolder);
|
|
147
|
+
throw new Error("Unable to load dependencies for: ".concat(fileName || '', "\n") +
|
|
148
|
+
"The following files were listed under ".concat(depInfo.name, " but could not be found:\n") +
|
|
149
|
+
"".concat(notFoundDeps, "\n") +
|
|
150
|
+
"Please check that they exist in the folder(s) listed in the `".concat(depInfo.config, "` array in your sasjsconfig.json file.\n") +
|
|
151
|
+
"".concat(depFolder, ":\n") +
|
|
152
|
+
folders.map(function (folder) { return "- ".concat(folder); }).join('\n'));
|
|
152
153
|
}
|
|
153
154
|
return [2 /*return*/, foundDeps_1.join('\n')];
|
|
154
155
|
case 2: return [2 /*return*/, ''];
|
|
@@ -160,13 +161,13 @@ var deconstructDependency = function (deps, depInfo) {
|
|
|
160
161
|
return deps.map(function (dep) {
|
|
161
162
|
var _a = __read(dep.split(' ').filter(function (f) { return !!f; }), 2), fileName = _a[0], fileRef = _a[1];
|
|
162
163
|
if (!fileName) {
|
|
163
|
-
throw new Error(depInfo.name
|
|
164
|
+
throw new Error("".concat(depInfo.name, " entry is empty. Please specify ").concat(depInfo.name, " dependencies in the format: @li <filename> <fileref>"));
|
|
164
165
|
}
|
|
165
166
|
if (!fileRef && depInfo.type !== DependencyType.Macro) {
|
|
166
|
-
throw new Error(depInfo.name
|
|
167
|
+
throw new Error("".concat(depInfo.name, " ").concat(fileName, " is missing fileref. Please specify ").concat(depInfo.name, " dependencies in the format: @li <filename> <fileref>"));
|
|
167
168
|
}
|
|
168
169
|
if (depInfo.type !== DependencyType.Macro)
|
|
169
|
-
_1.validateFileRef(fileRef);
|
|
170
|
+
(0, _1.validateFileRef)(fileRef);
|
|
170
171
|
return { fileName: fileName, fileRef: fileRef };
|
|
171
172
|
});
|
|
172
173
|
};
|
|
@@ -174,7 +175,7 @@ var compileDep = function (depType, fileContent, fileRef) {
|
|
|
174
175
|
var output = '';
|
|
175
176
|
if (depType === DependencyType.Binary) {
|
|
176
177
|
output = [
|
|
177
|
-
"filename _sjstmp \"%sysfunc(pathname(work))/base64_"
|
|
178
|
+
"filename _sjstmp \"%sysfunc(pathname(work))/base64_".concat(fileRef, "\" recfm=n;"),
|
|
178
179
|
"data _null_;",
|
|
179
180
|
"file _sjstmp;\n"
|
|
180
181
|
].join("\n");
|
|
@@ -183,14 +184,14 @@ var compileDep = function (depType, fileContent, fileRef) {
|
|
|
183
184
|
.split('\n')
|
|
184
185
|
.filter(function (l) { return !!l; });
|
|
185
186
|
sourceLines.forEach(function (line) {
|
|
186
|
-
var chunkedLines = utils_2.chunk(line);
|
|
187
|
+
var chunkedLines = (0, utils_2.chunk)(line);
|
|
187
188
|
if (chunkedLines.length === 1) {
|
|
188
|
-
output += "put '"
|
|
189
|
+
output += "put '".concat(chunkedLines[0].split("'").join("''"), "';\n");
|
|
189
190
|
}
|
|
190
191
|
else {
|
|
191
192
|
var combinedLines_1 = '';
|
|
192
193
|
chunkedLines.forEach(function (chunkedLine, index) {
|
|
193
|
-
var text = "put '"
|
|
194
|
+
var text = "put '".concat(chunkedLine.split("'").join("''"), "'");
|
|
194
195
|
if (index !== chunkedLines.length - 1) {
|
|
195
196
|
text += '@;\n';
|
|
196
197
|
}
|
|
@@ -204,11 +205,11 @@ var compileDep = function (depType, fileContent, fileRef) {
|
|
|
204
205
|
});
|
|
205
206
|
output += "run;\n";
|
|
206
207
|
var sasCodeToDecodeBase64 = [
|
|
207
|
-
"filename "
|
|
208
|
+
"filename ".concat(fileRef, " \"%sysfunc(pathname(work))/sasjs_").concat(fileRef, "\";"),
|
|
208
209
|
"data _null_;",
|
|
209
210
|
"length filein 8 fileout 8;",
|
|
210
211
|
"filein = fopen(\"_sjstmp\",'I',4,'B');",
|
|
211
|
-
"fileout = fopen(\""
|
|
212
|
+
"fileout = fopen(\"".concat(fileRef, "\",'O',3,'B');"),
|
|
212
213
|
"char= '20'x;",
|
|
213
214
|
"do while(fread(filein)=0);",
|
|
214
215
|
"length raw $4;",
|
|
@@ -227,20 +228,20 @@ var compileDep = function (depType, fileContent, fileRef) {
|
|
|
227
228
|
output += sasCodeToDecodeBase64.join("\n");
|
|
228
229
|
}
|
|
229
230
|
else if (depType === DependencyType.Include) {
|
|
230
|
-
output = "filename "
|
|
231
|
+
output = "filename ".concat(fileRef, " temp;\ndata _null_;\nfile ").concat(fileRef, " lrecl=32767;\n");
|
|
231
232
|
var sourceLines = fileContent
|
|
232
233
|
.replace(/\r\n/g, '\n')
|
|
233
234
|
.split('\n')
|
|
234
235
|
.filter(function (l) { return !!l; });
|
|
235
236
|
sourceLines.forEach(function (line) {
|
|
236
|
-
var chunkedLines = utils_2.chunk(line);
|
|
237
|
+
var chunkedLines = (0, utils_2.chunk)(line);
|
|
237
238
|
if (chunkedLines.length === 1) {
|
|
238
|
-
output += "put '"
|
|
239
|
+
output += "put '".concat(chunkedLines[0].split("'").join("''"), "';\n");
|
|
239
240
|
}
|
|
240
241
|
else {
|
|
241
242
|
var combinedLines_2 = '';
|
|
242
243
|
chunkedLines.forEach(function (chunkedLine, index) {
|
|
243
|
-
var text = "put '"
|
|
244
|
+
var text = "put '".concat(chunkedLine.split("'").join("''"), "'");
|
|
244
245
|
if (index !== chunkedLines.length - 1) {
|
|
245
246
|
text += '@;\n';
|
|
246
247
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDependencies.js","sourceRoot":"","sources":["../../src/sasjsCli/getDependencies.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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WAAW,GAAG,WAAW;aAC5B,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;aACtB,KAAK,CAAC,IAAI,CAAC;aACX,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,EAAH,CAAG,CAAC,CAAA;QAErB,WAAW,CAAC,OAAO,CAAC,UAAC,IAAI;YACvB,IAAM,YAAY,GAAG,IAAA,aAAK,EAAC,IAAI,CAAC,CAAA;YAChC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC7B,MAAM,IAAI,eAAQ,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAM,CAAA;aAC9D;iBAAM;gBACL,IAAI,eAAa,GAAG,EAAE,CAAA;gBACtB,YAAY,CAAC,OAAO,CAAC,UAAC,WAAW,EAAE,KAAK;oBACtC,IAAI,IAAI,GAAG,eAAQ,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAG,CAAA;oBACvD,IAAI,KAAK,KAAK,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;wBACrC,IAAI,IAAI,MAAM,CAAA;qBACf;yBAAM;wBACL,IAAI,IAAI,KAAK,CAAA;qBACd;oBACD,eAAa,IAAI,IAAI,CAAA;gBACvB,CAAC,CAAC,CAAA;gBACF,MAAM,IAAI,eAAa,CAAA;aACxB;QACH,CAAC,CAAC,CAAA;QAEF,MAAM,IAAI,MAAM,CAAA;KACjB;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -51,10 +51,14 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
51
51
|
}
|
|
52
52
|
return ar;
|
|
53
53
|
};
|
|
54
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
55
|
-
for (var i = 0,
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
+
if (ar || !(i in from)) {
|
|
57
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
+
ar[i] = from[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
58
62
|
};
|
|
59
63
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
60
64
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -67,36 +71,36 @@ var utils_1 = require("../utils");
|
|
|
67
71
|
var _1 = require("./");
|
|
68
72
|
function getDependencyPaths(fileContent, macroFolders, macroCorePath) {
|
|
69
73
|
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
-
var
|
|
74
|
+
var dependencyPaths, foundDependencies, sourcePaths, dependenciesHeader, dependencies, notFoundDependencies;
|
|
71
75
|
var _this = this;
|
|
72
76
|
return __generator(this, function (_a) {
|
|
73
77
|
switch (_a.label) {
|
|
74
78
|
case 0:
|
|
75
|
-
|
|
79
|
+
dependencyPaths = [];
|
|
80
|
+
foundDependencies = [];
|
|
81
|
+
sourcePaths = __spreadArray(__spreadArray([], __read(macroFolders), false), [macroCorePath], false);
|
|
76
82
|
dependenciesHeader = fileContent.includes('<h4> SAS Macros </h4>')
|
|
77
83
|
? '<h4> SAS Macros </h4>'
|
|
78
84
|
: '<h4> Dependencies </h4>';
|
|
79
|
-
dependencies = _1.getList(dependenciesHeader, fileContent).filter(function (d) {
|
|
85
|
+
dependencies = (0, _1.getList)(dependenciesHeader, fileContent).filter(function (d) {
|
|
80
86
|
return d.endsWith('.sas');
|
|
81
87
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return [4 /*yield*/, utils_1.asyncForEach(sourcePaths, function (sourcePath) { return __awaiter(_this, void 0, void 0, function () {
|
|
85
|
-
var errorMessage;
|
|
88
|
+
// Search dependencies recursively starting from macroFolders and ending in macroCorePath
|
|
89
|
+
return [4 /*yield*/, (0, utils_1.asyncForEach)(sourcePaths, function (sourcePath) { return __awaiter(_this, void 0, void 0, function () {
|
|
86
90
|
var _this = this;
|
|
87
91
|
return __generator(this, function (_a) {
|
|
88
92
|
switch (_a.label) {
|
|
89
|
-
case 0: return [4 /*yield*/, file_1.folderExists(sourcePath)];
|
|
93
|
+
case 0: return [4 /*yield*/, (0, file_1.folderExists)(sourcePath)];
|
|
90
94
|
case 1:
|
|
91
95
|
if (!_a.sent()) return [3 /*break*/, 3];
|
|
92
|
-
return [4 /*yield*/, utils_1.asyncForEach(dependencies, function (dep) { return __awaiter(_this, void 0, void 0, function () {
|
|
96
|
+
return [4 /*yield*/, (0, utils_1.asyncForEach)(dependencies, function (dep) { return __awaiter(_this, void 0, void 0, function () {
|
|
93
97
|
var filePaths, fileContent_1, _a, _b, _c, _d;
|
|
94
98
|
return __generator(this, function (_e) {
|
|
95
99
|
switch (_e.label) {
|
|
96
100
|
case 0:
|
|
97
101
|
filePaths = find_1.default.fileSync(dep, sourcePath);
|
|
98
102
|
if (!filePaths.length) return [3 /*break*/, 3];
|
|
99
|
-
return [4 /*yield*/, file_1.readFile(filePaths[0])];
|
|
103
|
+
return [4 /*yield*/, (0, file_1.readFile)(filePaths[0])];
|
|
100
104
|
case 1:
|
|
101
105
|
fileContent_1 = _e.sent();
|
|
102
106
|
foundDependencies.push(dep);
|
|
@@ -105,10 +109,10 @@ function getDependencyPaths(fileContent, macroFolders, macroCorePath) {
|
|
|
105
109
|
_d = [[]];
|
|
106
110
|
return [4 /*yield*/, getDependencyPaths(fileContent_1, macroFolders, macroCorePath)];
|
|
107
111
|
case 2:
|
|
108
|
-
_b.apply(_a, _c.concat([__spreadArray.apply(void 0, _d.concat([__read.apply(void 0, [(_e.sent())])]))]));
|
|
112
|
+
_b.apply(_a, _c.concat([__spreadArray.apply(void 0, _d.concat([__read.apply(void 0, [(_e.sent())]), false]))]));
|
|
109
113
|
_e.label = 3;
|
|
110
114
|
case 3:
|
|
111
|
-
dependencyPaths.push.apply(dependencyPaths, __spreadArray([], __read(filePaths)));
|
|
115
|
+
dependencyPaths.push.apply(dependencyPaths, __spreadArray([], __read(filePaths), false));
|
|
112
116
|
return [2 /*return*/];
|
|
113
117
|
}
|
|
114
118
|
});
|
|
@@ -117,21 +121,23 @@ function getDependencyPaths(fileContent, macroFolders, macroCorePath) {
|
|
|
117
121
|
_a.sent();
|
|
118
122
|
return [3 /*break*/, 4];
|
|
119
123
|
case 3:
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
if (macroFolders.includes(sourcePath)) {
|
|
125
|
+
throw "Error listing dependency paths: Source path ".concat(sourcePath, " does not exist.");
|
|
126
|
+
}
|
|
127
|
+
_a.label = 4;
|
|
122
128
|
case 4: return [2 /*return*/];
|
|
123
129
|
}
|
|
124
130
|
});
|
|
125
131
|
}); })];
|
|
126
132
|
case 1:
|
|
133
|
+
// Search dependencies recursively starting from macroFolders and ending in macroCorePath
|
|
127
134
|
_a.sent();
|
|
128
|
-
notFoundDependencies = utils_1.diff(dependencies, foundDependencies);
|
|
135
|
+
notFoundDependencies = (0, utils_1.diff)(dependencies, foundDependencies);
|
|
129
136
|
if (notFoundDependencies.length) {
|
|
130
|
-
|
|
131
|
-
throw errorMessage;
|
|
137
|
+
throw 'Unable to locate dependencies: ' + notFoundDependencies.join(', ');
|
|
132
138
|
}
|
|
133
|
-
dependencyPaths = _1.prioritiseDependencyOverrides(dependencies, dependencyPaths, macroFolders);
|
|
134
|
-
return [2 /*return*/, __spreadArray([], __read(new Set(dependencyPaths)))];
|
|
139
|
+
dependencyPaths = (0, _1.prioritiseDependencyOverrides)(dependencies, dependencyPaths, macroFolders);
|
|
140
|
+
return [2 /*return*/, __spreadArray([], __read(new Set(dependencyPaths)), false)];
|
|
135
141
|
}
|
|
136
142
|
});
|
|
137
143
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDependencyPaths.js","sourceRoot":"","sources":["../../src/sasjsCli/getDependencyPaths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getDependencyPaths.js","sourceRoot":"","sources":["../../src/sasjsCli/getDependencyPaths.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,gCAAgD;AAChD,kCAA6C;AAC7C,uBAA2D;AAE3D,SAAsB,kBAAkB,CACtC,WAAmB,EACnB,YAAsB,EACtB,aAAqB;;;;;;;oBAEjB,eAAe,GAAa,EAAE,CAAA;oBAC5B,iBAAiB,GAAa,EAAE,CAAA;oBAChC,WAAW,0CAAO,YAAY,YAAE,aAAa,SAAC,CAAA;oBAE9C,kBAAkB,GAAG,WAAW,CAAC,QAAQ,CAAC,uBAAuB,CAAC;wBACtE,CAAC,CAAC,uBAAuB;wBACzB,CAAC,CAAC,yBAAyB,CAAA;oBACvB,YAAY,GAAG,IAAA,UAAO,EAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC,MAAM,CAAC,UAAC,CAAC;wBACrE,OAAA,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;oBAAlB,CAAkB,CACnB,CAAA;oBAED,yFAAyF;oBACzF,qBAAM,IAAA,oBAAY,EAAC,WAAW,EAAE,UAAO,UAAU;;;;4CAC3C,qBAAM,IAAA,mBAAY,EAAC,UAAU,CAAC,EAAA;;6CAA9B,SAA8B,EAA9B,wBAA8B;wCAChC,qBAAM,IAAA,oBAAY,EAAC,YAAY,EAAE,UAAO,GAAG;;;;;4DACnC,SAAS,GAAG,cAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;iEAE5C,SAAS,CAAC,MAAM,EAAhB,wBAAgB;4DACE,qBAAM,IAAA,eAAQ,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAA;;4DAA1C,gBAAc,SAA4B;4DAEhD,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;iEAC3B,CAAA,KAAA,eAAe,CAAC,IAAI,CAAA;kEAApB,eAAe;;4DACT,qBAAM,kBAAkB,CAC1B,aAAW,EACX,YAAY,EACZ,aAAa,CACd,EAAA;;4DALH,qFACK,CAAC,SAIH,CAAC,gBACH;;;4DAGH,eAAe,CAAC,IAAI,OAApB,eAAe,2BAAS,SAAS,WAAC;;;;iDACnC,CAAC,EAAA;;wCAjBF,SAiBE,CAAA;;;wCACG,IAAI,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;4CAC5C,MAAM,sDAA+C,UAAU,qBAAkB,CAAA;yCAClF;;;;;6BACF,CAAC,EAAA;;oBAxBF,yFAAyF;oBACzF,SAuBE,CAAA;oBAEI,oBAAoB,GAAG,IAAA,YAAI,EAAC,YAAY,EAAE,iBAAiB,CAAC,CAAA;oBAElE,IAAI,oBAAoB,CAAC,MAAM,EAAE;wBAC/B,MAAM,iCAAiC,GAAG,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;qBAC1E;oBAED,eAAe,GAAG,IAAA,gCAA6B,EAC7C,YAAY,EACZ,eAAe,EACf,YAAY,CACb,CAAA;oBAED,+CAAW,IAAI,GAAG,CAAC,eAAe,CAAC,WAAC;;;;CACrC;AAvDD,gDAuDC"}
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import { Configuration, SASJsFileType, Target } from '../types';
|
|
2
|
+
export declare enum ProgramType {
|
|
3
|
+
Init = "init",
|
|
4
|
+
Term = "term"
|
|
5
|
+
}
|
|
2
6
|
interface getInitTermParams {
|
|
3
7
|
configuration?: Configuration;
|
|
4
8
|
target?: Target;
|
|
5
|
-
|
|
9
|
+
fileType: SASJsFileType;
|
|
6
10
|
buildSourceFolder: string;
|
|
7
11
|
}
|
|
8
|
-
export declare const getInitTerm: ({ configuration, target,
|
|
12
|
+
export declare const getInitTerm: ({ configuration, target, fileType, buildSourceFolder }: getInitTermParams) => Promise<{
|
|
9
13
|
init: string;
|
|
10
14
|
initPath: string;
|
|
11
15
|
term: string;
|
|
12
16
|
termPath: string;
|
|
13
17
|
startUpVars: string;
|
|
14
18
|
}>;
|
|
15
|
-
|
|
16
|
-
configuration?: Configuration;
|
|
17
|
-
target?: Target;
|
|
18
|
-
buildSourceFolder: string;
|
|
19
|
-
type: SASJsFileType;
|
|
20
|
-
}
|
|
21
|
-
export declare const getInit: ({ target, configuration, buildSourceFolder, type }: getInitTermParam) => Promise<{
|
|
22
|
-
content: string;
|
|
23
|
-
filePath: string;
|
|
24
|
-
}>;
|
|
25
|
-
export declare const getTerm: ({ target, configuration, buildSourceFolder, type }: getInitTermParam) => Promise<{
|
|
19
|
+
export declare const getProgram: ({ target, configuration, buildSourceFolder, fileType }: getInitTermParams, programType: ProgramType) => Promise<{
|
|
26
20
|
content: string;
|
|
27
21
|
filePath: string;
|
|
28
22
|
}>;
|
|
23
|
+
export declare const mockGetProgram: (module: {
|
|
24
|
+
getProgram: (param: getInitTermParams, programType: ProgramType) => {};
|
|
25
|
+
}, fakeInit: string, fakeTerm: string) => void;
|
|
29
26
|
export {};
|
package/sasjsCli/getInitTerm.js
CHANGED
|
@@ -74,33 +74,39 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
74
74
|
return ar;
|
|
75
75
|
};
|
|
76
76
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
|
-
exports.
|
|
77
|
+
exports.mockGetProgram = exports.getProgram = exports.getInitTerm = exports.ProgramType = void 0;
|
|
78
78
|
var file_1 = require("../file");
|
|
79
79
|
var types_1 = require("../types");
|
|
80
80
|
var utils_1 = require("../utils");
|
|
81
|
+
var formatter_1 = require("../formatter");
|
|
82
|
+
var ProgramType;
|
|
83
|
+
(function (ProgramType) {
|
|
84
|
+
ProgramType["Init"] = "init";
|
|
85
|
+
ProgramType["Term"] = "term";
|
|
86
|
+
})(ProgramType = exports.ProgramType || (exports.ProgramType = {}));
|
|
81
87
|
var getInitTerm = function (_a) {
|
|
82
|
-
var configuration = _a.configuration, target = _a.target,
|
|
88
|
+
var configuration = _a.configuration, target = _a.target, fileType = _a.fileType, buildSourceFolder = _a.buildSourceFolder;
|
|
83
89
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
84
90
|
var _b, init, initPath, _c, term, termPath, startUpVars;
|
|
85
91
|
return __generator(this, function (_d) {
|
|
86
92
|
switch (_d.label) {
|
|
87
|
-
case 0: return [4 /*yield*/, exports.
|
|
93
|
+
case 0: return [4 /*yield*/, (0, exports.getProgram)({
|
|
88
94
|
target: target,
|
|
89
95
|
configuration: configuration,
|
|
90
96
|
buildSourceFolder: buildSourceFolder,
|
|
91
|
-
|
|
92
|
-
})];
|
|
97
|
+
fileType: fileType
|
|
98
|
+
}, ProgramType.Init)];
|
|
93
99
|
case 1:
|
|
94
100
|
_b = _d.sent(), init = _b.content, initPath = _b.filePath;
|
|
95
|
-
return [4 /*yield*/, exports.
|
|
101
|
+
return [4 /*yield*/, (0, exports.getProgram)({
|
|
96
102
|
target: target,
|
|
97
103
|
configuration: configuration,
|
|
98
104
|
buildSourceFolder: buildSourceFolder,
|
|
99
|
-
|
|
100
|
-
})];
|
|
105
|
+
fileType: fileType
|
|
106
|
+
}, ProgramType.Term)];
|
|
101
107
|
case 2:
|
|
102
108
|
_c = _d.sent(), term = _c.content, termPath = _c.filePath;
|
|
103
|
-
startUpVars = getVars(
|
|
109
|
+
startUpVars = getVars(fileType, target, configuration);
|
|
104
110
|
return [2 /*return*/, {
|
|
105
111
|
init: init,
|
|
106
112
|
initPath: initPath,
|
|
@@ -135,9 +141,9 @@ var convertVarsToSasFormat = function (vars) {
|
|
|
135
141
|
try {
|
|
136
142
|
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
137
143
|
var _b = __read(entries_1_1.value, 2), name_1 = _b[0], value = _b[1];
|
|
138
|
-
var chunks = utils_1.chunk(value);
|
|
144
|
+
var chunks = (0, utils_1.chunk)(value);
|
|
139
145
|
var chunkedString = chunks.join('%trim(\n)');
|
|
140
|
-
varsContent += "%let "
|
|
146
|
+
varsContent += "%let ".concat(name_1, "=").concat(chunkedString, ";\n");
|
|
141
147
|
}
|
|
142
148
|
}
|
|
143
149
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -149,31 +155,45 @@ var convertVarsToSasFormat = function (vars) {
|
|
|
149
155
|
}
|
|
150
156
|
return varsContent;
|
|
151
157
|
};
|
|
152
|
-
var
|
|
153
|
-
var target = _a.target, configuration = _a.configuration, buildSourceFolder = _a.buildSourceFolder,
|
|
158
|
+
var getProgram = function (_a, programType) {
|
|
159
|
+
var target = _a.target, configuration = _a.configuration, buildSourceFolder = _a.buildSourceFolder, fileType = _a.fileType;
|
|
154
160
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
155
|
-
var
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
switch (_l.label) {
|
|
161
|
+
var programContent, filePath, program, targetConfig, rootConfig, content;
|
|
162
|
+
return __generator(this, function (_b) {
|
|
163
|
+
switch (_b.label) {
|
|
159
164
|
case 0:
|
|
160
|
-
|
|
161
|
-
program =
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
programContent = '', filePath = '';
|
|
166
|
+
program = undefined;
|
|
167
|
+
targetConfig = undefined;
|
|
168
|
+
rootConfig = undefined;
|
|
169
|
+
switch (fileType) {
|
|
170
|
+
case types_1.SASJsFileType.service:
|
|
171
|
+
targetConfig = target === null || target === void 0 ? void 0 : target.serviceConfig;
|
|
172
|
+
rootConfig = configuration === null || configuration === void 0 ? void 0 : configuration.serviceConfig;
|
|
173
|
+
break;
|
|
174
|
+
case types_1.SASJsFileType.job:
|
|
175
|
+
targetConfig = target === null || target === void 0 ? void 0 : target.jobConfig;
|
|
176
|
+
rootConfig = configuration === null || configuration === void 0 ? void 0 : configuration.jobConfig;
|
|
177
|
+
break;
|
|
178
|
+
case types_1.SASJsFileType.test:
|
|
179
|
+
targetConfig = target === null || target === void 0 ? void 0 : target.testConfig;
|
|
180
|
+
rootConfig = configuration === null || configuration === void 0 ? void 0 : configuration.testConfig;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
program =
|
|
184
|
+
(targetConfig &&
|
|
185
|
+
targetConfig["".concat(programType, "Program")]) ||
|
|
186
|
+
(rootConfig &&
|
|
187
|
+
rootConfig["".concat(programType, "Program")]);
|
|
168
188
|
if (!program) return [3 /*break*/, 2];
|
|
169
|
-
filePath = file_1.getAbsolutePath(program, buildSourceFolder);
|
|
170
|
-
return [4 /*yield*/, file_1.readFile(filePath)];
|
|
189
|
+
filePath = (0, file_1.getAbsolutePath)(program, buildSourceFolder);
|
|
190
|
+
return [4 /*yield*/, (0, file_1.readFile)(filePath)];
|
|
171
191
|
case 1:
|
|
172
|
-
|
|
173
|
-
|
|
192
|
+
programContent = _b.sent();
|
|
193
|
+
_b.label = 2;
|
|
174
194
|
case 2:
|
|
175
|
-
content =
|
|
176
|
-
? "\n* "
|
|
195
|
+
content = programContent
|
|
196
|
+
? "\n* ".concat(fileType).concat((0, formatter_1.capitalizeFirstChar)(programType), " start;\n").concat(programContent, "\n* ").concat(fileType).concat((0, formatter_1.capitalizeFirstChar)(programType), " end;")
|
|
177
197
|
: '';
|
|
178
198
|
return [2 /*return*/, {
|
|
179
199
|
content: content,
|
|
@@ -183,40 +203,19 @@ var getInit = function (_a) {
|
|
|
183
203
|
});
|
|
184
204
|
});
|
|
185
205
|
};
|
|
186
|
-
exports.
|
|
187
|
-
var
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
: type === types_1.SASJsFileType.job
|
|
199
|
-
? (_f = (_e = target === null || target === void 0 ? void 0 : target.jobConfig) === null || _e === void 0 ? void 0 : _e.termProgram) !== null && _f !== void 0 ? _f : (_g = configuration === null || configuration === void 0 ? void 0 : configuration.jobConfig) === null || _g === void 0 ? void 0 : _g.termProgram
|
|
200
|
-
: type === types_1.SASJsFileType.test
|
|
201
|
-
? (_j = (_h = target === null || target === void 0 ? void 0 : target.testConfig) === null || _h === void 0 ? void 0 : _h.termProgram) !== null && _j !== void 0 ? _j : (_k = configuration === null || configuration === void 0 ? void 0 : configuration.testConfig) === null || _k === void 0 ? void 0 : _k.termProgram
|
|
202
|
-
: undefined;
|
|
203
|
-
if (!program) return [3 /*break*/, 2];
|
|
204
|
-
filePath = file_1.getAbsolutePath(program, buildSourceFolder);
|
|
205
|
-
return [4 /*yield*/, file_1.readFile(filePath)];
|
|
206
|
-
case 1:
|
|
207
|
-
termContent = _l.sent();
|
|
208
|
-
_l.label = 2;
|
|
209
|
-
case 2:
|
|
210
|
-
content = termContent
|
|
211
|
-
? "\n* " + type + "Term start;\n" + termContent + "\n* " + type + "Term end;"
|
|
212
|
-
: '';
|
|
213
|
-
return [2 /*return*/, {
|
|
214
|
-
content: content,
|
|
215
|
-
filePath: filePath
|
|
216
|
-
}];
|
|
217
|
-
}
|
|
218
|
-
});
|
|
206
|
+
exports.getProgram = getProgram;
|
|
207
|
+
var mockGetProgram = function (module, fakeInit, fakeTerm) {
|
|
208
|
+
jest.spyOn(module, 'getProgram').mockImplementation(function (params, programType) {
|
|
209
|
+
return programType === ProgramType.Init
|
|
210
|
+
? Promise.resolve({
|
|
211
|
+
content: "\n* ".concat(params.fileType, "Init start;\n").concat(fakeInit, "\n* ").concat(params.fileType, "Init end;"),
|
|
212
|
+
filePath: ''
|
|
213
|
+
})
|
|
214
|
+
: Promise.resolve({
|
|
215
|
+
content: "\n* ".concat(params.fileType, "Term start;\n").concat(fakeTerm, "\n* ").concat(params.fileType, "Term end;"),
|
|
216
|
+
filePath: ''
|
|
217
|
+
});
|
|
219
218
|
});
|
|
220
219
|
};
|
|
221
|
-
exports.
|
|
220
|
+
exports.mockGetProgram = mockGetProgram;
|
|
222
221
|
//# sourceMappingURL=getInitTerm.js.map
|