@sasjs/cli 3.0.0 → 3.0.4
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/build/commands/add/addCredential.d.ts +6 -2
- package/build/commands/add/addCredential.js +79 -47
- package/build/commands/add/addTarget.js +32 -20
- package/build/commands/add/internal/input.d.ts +7 -0
- package/build/commands/add/internal/input.js +53 -8
- package/build/commands/add/spec/addTarget.spec.js +78 -0
- package/build/commands/build/build.js +11 -11
- package/build/commands/build/internal/config.d.ts +1 -1
- package/build/commands/build/internal/config.js +5 -6
- package/build/commands/compile/compile.js +4 -4
- package/build/commands/compile/compileCommand.js +2 -1
- package/build/commands/compile/compileSingleFile.d.ts +1 -1
- package/build/commands/compile/compileSingleFile.js +6 -7
- package/build/commands/compile/internal/compareFolders.js +1 -2
- package/build/commands/compile/internal/compileJobFile.js +1 -1
- package/build/commands/compile/internal/compileServiceFile.js +32 -15
- package/build/commands/compile/internal/compileTestFile.d.ts +0 -2
- package/build/commands/compile/internal/compileTestFile.js +11 -15
- package/build/commands/compile/internal/getAllJobFolders.js +1 -1
- package/build/commands/compile/internal/getAllServiceFolders.js +1 -1
- package/build/commands/compile/internal/loadDependencies.d.ts +2 -3
- package/build/commands/compile/internal/loadDependencies.js +43 -230
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +24 -12
- package/build/commands/compile/spec/compile.spec.js +30 -0
- package/build/commands/compile/spec/compileJobFile.spec.js +3 -3
- package/build/commands/compile/spec/compileServiceFile.spec.js +3 -3
- package/build/commands/compile/spec/loadDependencies.spec.js +37 -37
- package/build/commands/create/spec/reactAppFiles.js +5 -5
- package/build/commands/deploy/deploy.js +1 -1
- package/build/commands/deploy/spec/cbd.spec.js +19 -3
- package/build/commands/docs/generateDocs.js +4 -5
- package/build/commands/docs/internal/getFileInputs.d.ts +1 -1
- package/build/commands/docs/internal/getFileInputs.js +2 -2
- package/build/commands/docs/internal/getFileOutputs.d.ts +1 -1
- package/build/commands/docs/internal/getFileOutputs.js +2 -2
- package/build/commands/docs/internal/getFoldersForDocs.d.ts +1 -1
- package/build/commands/docs/internal/getFoldersForDocs.js +1 -1
- package/build/commands/request/request.js +2 -2
- package/build/commands/run/run.js +1 -1
- package/build/commands/servicepack/deploy.js +1 -1
- package/build/commands/web/internal/getTags.d.ts +2 -1
- package/build/commands/web/internal/getTags.js +10 -12
- package/build/commands/web/internal/getWebServiceContent.js +1 -2
- package/build/commands/web/internal/sasjsout.d.ts +1 -1
- package/build/commands/web/internal/sasjsout.js +1 -1
- package/build/commands/web/internal/spec/updateLinkTag.spec.d.ts +4 -0
- package/build/commands/web/internal/spec/updateLinkTag.spec.js +32 -0
- package/build/commands/web/internal/updateAllTags.js +33 -8
- package/build/commands/web/internal/updateLinkTag.d.ts +4 -0
- package/build/commands/web/internal/updateLinkTag.js +24 -0
- package/build/commands/web/web.js +12 -13
- package/build/utils/auth.d.ts +10 -4
- package/build/utils/auth.js +17 -15
- package/build/utils/config.d.ts +2 -3
- package/build/utils/config.js +14 -16
- package/build/utils/file.d.ts +0 -6
- package/build/utils/file.js +1 -43
- package/build/utils/setConstants.js +1 -1
- package/build/utils/spec/utils.spec.js +31 -5
- package/build/utils/utils.d.ts +0 -2
- package/build/utils/utils.js +1 -16
- package/package.json +7 -13
- package/CHANGELOG.md +0 -30
- package/build/commands/compile/internal/config.d.ts +0 -25
- package/build/commands/compile/internal/config.js +0 -259
- package/build/commands/compile/spec/getDependencyPaths.spec.d.ts +0 -1
- package/build/commands/compile/spec/getDependencyPaths.spec.js +0 -263
- package/build/commands/compile/spec/getProgramDependencies.spec.d.ts +0 -1
- package/build/commands/compile/spec/getProgramDependencies.spec.js +0 -403
- package/build/commands/shared/dependencies.d.ts +0 -12
- package/build/commands/shared/dependencies.js +0 -332
- package/build/commands/web/internal/updateLinkHref.d.ts +0 -4
- package/build/commands/web/internal/updateLinkHref.js +0 -18
- package/build/utils/spec/utils.spec.server.d.ts +0 -1
- package/build/utils/spec/utils.spec.server.js +0 -72
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare function getDependencyPaths(fileContent: string, macroFolders?: string[]): Promise<string[]>;
|
|
2
|
-
export declare function prioritiseDependencyOverrides(dependencyNames: string[], dependencyPaths: string[], macroPaths?: string[], pathSeparator?: string): string[];
|
|
3
|
-
export declare function getProgramDependencies(fileContent: string, programFolders: string[], filePath: string): Promise<string>;
|
|
4
|
-
export declare function getProgramList(fileContent: string): {
|
|
5
|
-
fileName: string;
|
|
6
|
-
fileRef: string;
|
|
7
|
-
}[];
|
|
8
|
-
export declare function validateProgramsList(programsList: {
|
|
9
|
-
fileName: string;
|
|
10
|
-
fileRef: string;
|
|
11
|
-
}[]): boolean;
|
|
12
|
-
export declare function validateFileRef(fileRef: string): boolean;
|
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
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 __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
55
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
56
|
-
to[j] = from[i];
|
|
57
|
-
return to;
|
|
58
|
-
};
|
|
59
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
60
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
61
|
-
};
|
|
62
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
-
exports.validateFileRef = exports.validateProgramsList = exports.getProgramList = exports.getProgramDependencies = exports.prioritiseDependencyOverrides = exports.getDependencyPaths = void 0;
|
|
64
|
-
var path_1 = __importDefault(require("path"));
|
|
65
|
-
var find_1 = __importDefault(require("find"));
|
|
66
|
-
var lodash_uniqby_1 = __importDefault(require("lodash.uniqby"));
|
|
67
|
-
var lodash_groupby_1 = __importDefault(require("lodash.groupby"));
|
|
68
|
-
var utils_1 = require("@sasjs/utils");
|
|
69
|
-
var file_1 = require("../../utils/file");
|
|
70
|
-
var config_1 = require("../../utils/config");
|
|
71
|
-
var utils_2 = require("../../utils/utils");
|
|
72
|
-
function getDependencyPaths(fileContent, macroFolders) {
|
|
73
|
-
var _a;
|
|
74
|
-
if (macroFolders === void 0) { macroFolders = []; }
|
|
75
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
-
var sourcePaths, dependenciesHeader, dependencies, dependencyPaths, foundDependencies, notFoundDependencies, errorMessage;
|
|
77
|
-
var _this = this;
|
|
78
|
-
return __generator(this, function (_b) {
|
|
79
|
-
switch (_b.label) {
|
|
80
|
-
case 0:
|
|
81
|
-
sourcePaths = __spreadArray(__spreadArray([], __read(macroFolders)), [config_1.getMacroCorePath()]);
|
|
82
|
-
dependenciesHeader = fileContent.includes('<h4> SAS Macros </h4>')
|
|
83
|
-
? '<h4> SAS Macros </h4>'
|
|
84
|
-
: '<h4> Dependencies </h4>';
|
|
85
|
-
dependencies = file_1.getList(dependenciesHeader, fileContent).filter(function (d) {
|
|
86
|
-
return d.endsWith('.sas');
|
|
87
|
-
});
|
|
88
|
-
dependencyPaths = [];
|
|
89
|
-
foundDependencies = [];
|
|
90
|
-
return [4 /*yield*/, utils_1.asyncForEach(sourcePaths, function (sourcePath) { return __awaiter(_this, void 0, void 0, function () {
|
|
91
|
-
var errorMessage;
|
|
92
|
-
var _this = this;
|
|
93
|
-
var _a;
|
|
94
|
-
return __generator(this, function (_b) {
|
|
95
|
-
switch (_b.label) {
|
|
96
|
-
case 0: return [4 /*yield*/, utils_1.folderExists(sourcePath)];
|
|
97
|
-
case 1:
|
|
98
|
-
if (!_b.sent()) return [3 /*break*/, 3];
|
|
99
|
-
return [4 /*yield*/, utils_1.asyncForEach(dependencies, function (dep) { return __awaiter(_this, void 0, void 0, function () {
|
|
100
|
-
var filePaths, fileContent_1, _a, _b, _c, _d;
|
|
101
|
-
return __generator(this, function (_e) {
|
|
102
|
-
switch (_e.label) {
|
|
103
|
-
case 0:
|
|
104
|
-
filePaths = find_1.default.fileSync(dep, sourcePath);
|
|
105
|
-
if (!filePaths.length) return [3 /*break*/, 3];
|
|
106
|
-
return [4 /*yield*/, utils_1.readFile(filePaths[0])];
|
|
107
|
-
case 1:
|
|
108
|
-
fileContent_1 = _e.sent();
|
|
109
|
-
foundDependencies.push(dep);
|
|
110
|
-
_b = (_a = dependencyPaths.push).apply;
|
|
111
|
-
_c = [dependencyPaths];
|
|
112
|
-
_d = [[]];
|
|
113
|
-
return [4 /*yield*/, getDependencyPaths(fileContent_1, macroFolders)];
|
|
114
|
-
case 2:
|
|
115
|
-
_b.apply(_a, _c.concat([__spreadArray.apply(void 0, _d.concat([__read.apply(void 0, [(_e.sent())])]))]));
|
|
116
|
-
_e.label = 3;
|
|
117
|
-
case 3:
|
|
118
|
-
dependencyPaths.push.apply(dependencyPaths, __spreadArray([], __read(filePaths)));
|
|
119
|
-
return [2 /*return*/];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}); })];
|
|
123
|
-
case 2:
|
|
124
|
-
_b.sent();
|
|
125
|
-
return [3 /*break*/, 4];
|
|
126
|
-
case 3:
|
|
127
|
-
errorMessage = "Error listing dependency paths: Source path " + sourcePath + " does not exist.";
|
|
128
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(errorMessage);
|
|
129
|
-
throw errorMessage;
|
|
130
|
-
case 4: return [2 /*return*/];
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}); })];
|
|
134
|
-
case 1:
|
|
135
|
-
_b.sent();
|
|
136
|
-
notFoundDependencies = utils_2.diff(dependencies, foundDependencies);
|
|
137
|
-
if (notFoundDependencies.length) {
|
|
138
|
-
errorMessage = 'Unable to locate dependencies: ' + notFoundDependencies.join(', ');
|
|
139
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(errorMessage);
|
|
140
|
-
throw errorMessage;
|
|
141
|
-
}
|
|
142
|
-
dependencyPaths = prioritiseDependencyOverrides(dependencies, dependencyPaths, macroFolders);
|
|
143
|
-
return [2 /*return*/, __spreadArray([], __read(new Set(dependencyPaths)))];
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
exports.getDependencyPaths = getDependencyPaths;
|
|
149
|
-
function prioritiseDependencyOverrides(dependencyNames, dependencyPaths, macroPaths, pathSeparator) {
|
|
150
|
-
if (macroPaths === void 0) { macroPaths = []; }
|
|
151
|
-
if (pathSeparator === void 0) { pathSeparator = path_1.default.sep; }
|
|
152
|
-
dependencyPaths = __spreadArray([], __read(new Set(dependencyPaths)));
|
|
153
|
-
dependencyNames.forEach(function (depFileName) {
|
|
154
|
-
var paths = dependencyPaths.filter(function (p) {
|
|
155
|
-
return p.includes("" + pathSeparator + depFileName);
|
|
156
|
-
});
|
|
157
|
-
var overriddenDependencyPaths = paths.filter(function (p) { return !p.includes('node_modules'); });
|
|
158
|
-
if (macroPaths.length) {
|
|
159
|
-
var foundInMacroPaths = overriddenDependencyPaths.filter(function (p) {
|
|
160
|
-
var pathExist = macroPaths.find(function (tm) { return p.includes(tm); });
|
|
161
|
-
return pathExist ? true : false;
|
|
162
|
-
});
|
|
163
|
-
if (foundInMacroPaths.length)
|
|
164
|
-
overriddenDependencyPaths = [foundInMacroPaths[0]];
|
|
165
|
-
}
|
|
166
|
-
if (overriddenDependencyPaths.length &&
|
|
167
|
-
overriddenDependencyPaths.length != paths.length) {
|
|
168
|
-
var pathsToRemove_1 = paths.filter(function (el) { return overriddenDependencyPaths.indexOf(el) < 0; });
|
|
169
|
-
dependencyPaths = dependencyPaths.filter(function (el) { return pathsToRemove_1.indexOf(el) < 0; });
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
return dependencyPaths;
|
|
173
|
-
}
|
|
174
|
-
exports.prioritiseDependencyOverrides = prioritiseDependencyOverrides;
|
|
175
|
-
function getProgramDependencies(fileContent, programFolders, filePath) {
|
|
176
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
-
var programs, foundPrograms_1, foundProgramNames_1, notFoundProgramNames, programList;
|
|
178
|
-
var _this = this;
|
|
179
|
-
return __generator(this, function (_a) {
|
|
180
|
-
switch (_a.label) {
|
|
181
|
-
case 0:
|
|
182
|
-
programFolders = lodash_uniqby_1.default(programFolders);
|
|
183
|
-
programs = getProgramList(fileContent);
|
|
184
|
-
if (!programs.length) return [3 /*break*/, 2];
|
|
185
|
-
foundPrograms_1 = [];
|
|
186
|
-
foundProgramNames_1 = [];
|
|
187
|
-
return [4 /*yield*/, utils_1.asyncForEach(programFolders, function (programFolder) { return __awaiter(_this, void 0, void 0, function () {
|
|
188
|
-
var _this = this;
|
|
189
|
-
return __generator(this, function (_a) {
|
|
190
|
-
switch (_a.label) {
|
|
191
|
-
case 0: return [4 /*yield*/, utils_1.asyncForEach(programs, function (program) { return __awaiter(_this, void 0, void 0, function () {
|
|
192
|
-
var filePaths, fileContent_2, programDependencyContent;
|
|
193
|
-
var _a;
|
|
194
|
-
return __generator(this, function (_b) {
|
|
195
|
-
switch (_b.label) {
|
|
196
|
-
case 0:
|
|
197
|
-
filePaths = find_1.default.fileSync(program.fileName, programFolder);
|
|
198
|
-
if (!filePaths.length) return [3 /*break*/, 2];
|
|
199
|
-
return [4 /*yield*/, utils_1.readFile(filePaths[0])];
|
|
200
|
-
case 1:
|
|
201
|
-
fileContent_2 = _b.sent();
|
|
202
|
-
if (!fileContent_2) {
|
|
203
|
-
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.warn("Program file " + path_1.default.join(programFolder, program.fileName) + " is empty.");
|
|
204
|
-
}
|
|
205
|
-
programDependencyContent = getProgramDependencyText(fileContent_2, program.fileRef);
|
|
206
|
-
foundPrograms_1.push(programDependencyContent);
|
|
207
|
-
foundProgramNames_1.push(program.fileName);
|
|
208
|
-
_b.label = 2;
|
|
209
|
-
case 2: return [2 /*return*/];
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}); })];
|
|
213
|
-
case 1:
|
|
214
|
-
_a.sent();
|
|
215
|
-
return [2 /*return*/];
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}); })];
|
|
219
|
-
case 1:
|
|
220
|
-
_a.sent();
|
|
221
|
-
notFoundProgramNames = programs.filter(function (program) { return !foundProgramNames_1.includes(program.fileName); });
|
|
222
|
-
if (notFoundProgramNames.length) {
|
|
223
|
-
programList = notFoundProgramNames
|
|
224
|
-
.map(function (program, i) {
|
|
225
|
-
return i + 1 + ". '" + program.fileName + "' with fileRef '" + program.fileRef + "'";
|
|
226
|
-
})
|
|
227
|
-
.join('\n');
|
|
228
|
-
throw new Error("Unable to load dependencies for: " + filePath + "\n" +
|
|
229
|
-
"The following files were listed under SAS Programs but could not be found:\n" +
|
|
230
|
-
(programList + "\n") +
|
|
231
|
-
"Please check that they exist in the folder(s) listed in the `programFolders` array in your sasjsconfig.json file.\n" +
|
|
232
|
-
"Program Folders:\n" +
|
|
233
|
-
programFolders.map(function (pf) { return "- " + pf; }).join('\n'));
|
|
234
|
-
}
|
|
235
|
-
return [2 /*return*/, foundPrograms_1.join('\n')];
|
|
236
|
-
case 2: return [2 /*return*/, ''];
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
exports.getProgramDependencies = getProgramDependencies;
|
|
242
|
-
function getProgramDependencyText(fileContent, fileRef) {
|
|
243
|
-
var output = "filename " + fileRef + " temp;\ndata _null_;\nfile " + fileRef + " lrecl=32767;\n";
|
|
244
|
-
var sourceLines = fileContent
|
|
245
|
-
.replace(/\r\n/g, '\n')
|
|
246
|
-
.split('\n')
|
|
247
|
-
.filter(function (l) { return !!l; });
|
|
248
|
-
sourceLines.forEach(function (line) {
|
|
249
|
-
var chunkedLines = utils_2.chunk(line);
|
|
250
|
-
if (chunkedLines.length === 1) {
|
|
251
|
-
output += "put '" + chunkedLines[0].split("'").join("''") + "';\n";
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
var combinedLines_1 = '';
|
|
255
|
-
chunkedLines.forEach(function (chunkedLine, index) {
|
|
256
|
-
var text = "put '" + chunkedLine.split("'").join("''") + "'";
|
|
257
|
-
if (index !== chunkedLines.length - 1) {
|
|
258
|
-
text += '@;\n';
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
text += ';\n';
|
|
262
|
-
}
|
|
263
|
-
combinedLines_1 += text;
|
|
264
|
-
});
|
|
265
|
-
output += combinedLines_1;
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
output += 'run;';
|
|
269
|
-
return output;
|
|
270
|
-
}
|
|
271
|
-
function getProgramList(fileContent) {
|
|
272
|
-
var includesHeader = fileContent.includes('<h4> SAS Includes </h4>')
|
|
273
|
-
? '<h4> SAS Includes </h4>'
|
|
274
|
-
: '<h4> SAS Programs </h4>';
|
|
275
|
-
var programList = file_1.getList(includesHeader, fileContent);
|
|
276
|
-
programList = programList.map(function (l) {
|
|
277
|
-
var _a = __read(l.split(' ').filter(function (f) { return !!f; }), 2), fileName = _a[0], fileRef = _a[1];
|
|
278
|
-
if (!fileName) {
|
|
279
|
-
throw new Error("SAS Program " + fileName + " is missing file name. Please specify SAS program dependencies in the format: @li <filename> <fileref>");
|
|
280
|
-
}
|
|
281
|
-
if (fileName && !fileRef) {
|
|
282
|
-
throw new Error("SAS Program " + fileName + " is missing fileref. Please specify SAS program dependencies in the format: @li <filename> <fileref>");
|
|
283
|
-
}
|
|
284
|
-
validateFileRef(fileRef);
|
|
285
|
-
return { fileName: fileName, fileRef: fileRef };
|
|
286
|
-
});
|
|
287
|
-
validateProgramsList(programList);
|
|
288
|
-
return lodash_uniqby_1.default(programList, 'fileName');
|
|
289
|
-
}
|
|
290
|
-
exports.getProgramList = getProgramList;
|
|
291
|
-
function validateProgramsList(programsList) {
|
|
292
|
-
var areFileRefsUnique = lodash_uniqby_1.default(programsList.map(function (p) { return p.fileRef; }), function (x) { return x.toLocaleUpperCase(); }).length === programsList.length;
|
|
293
|
-
if (areFileRefsUnique) {
|
|
294
|
-
return true;
|
|
295
|
-
}
|
|
296
|
-
var duplicatePrograms = [];
|
|
297
|
-
programsList.forEach(function (program, index, list) {
|
|
298
|
-
var duplicates = list.filter(function (p, i) {
|
|
299
|
-
return i !== index &&
|
|
300
|
-
p.fileRef.toLocaleUpperCase() === program.fileRef.toLocaleUpperCase() &&
|
|
301
|
-
!duplicatePrograms.some(function (d) {
|
|
302
|
-
return d.fileName === p.fileName &&
|
|
303
|
-
d.fileRef.toLocaleUpperCase() === p.fileRef.toLocaleUpperCase();
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
duplicatePrograms.push.apply(duplicatePrograms, __spreadArray([], __read(duplicates)));
|
|
307
|
-
});
|
|
308
|
-
var groupedDuplicates = lodash_groupby_1.default(duplicatePrograms, function (x) {
|
|
309
|
-
return x.fileRef.toLocaleUpperCase();
|
|
310
|
-
});
|
|
311
|
-
var errorMessage = '';
|
|
312
|
-
Object.keys(groupedDuplicates).forEach(function (fileRef) {
|
|
313
|
-
errorMessage += "The following files have duplicate fileref '" + fileRef + "':\n" + groupedDuplicates[fileRef]
|
|
314
|
-
.map(function (d) { return d.fileName; })
|
|
315
|
-
.join(', ') + "\n";
|
|
316
|
-
});
|
|
317
|
-
throw new Error(errorMessage);
|
|
318
|
-
}
|
|
319
|
-
exports.validateProgramsList = validateProgramsList;
|
|
320
|
-
function validateFileRef(fileRef) {
|
|
321
|
-
if (!fileRef) {
|
|
322
|
-
throw new Error('Missing file ref.');
|
|
323
|
-
}
|
|
324
|
-
if (fileRef.length > 8) {
|
|
325
|
-
throw new Error('File ref is too long. File refs can have a maximum of 8 characters.');
|
|
326
|
-
}
|
|
327
|
-
if (!/^[_a-zA-Z][_a-zA-Z0-9]*/.test(fileRef)) {
|
|
328
|
-
throw new Error('Invalid file ref. File refs can only start with a letter or an underscore, and contain only letters, numbers and underscores.');
|
|
329
|
-
}
|
|
330
|
-
return true;
|
|
331
|
-
}
|
|
332
|
-
exports.validateFileRef = validateFileRef;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateLinkHref = void 0;
|
|
4
|
-
var updateLinkHref = function (linkTag, assetPathMap) {
|
|
5
|
-
var linkSourcePath = linkTag.getAttribute('href') || '';
|
|
6
|
-
var isUrl = linkSourcePath.startsWith('http') || linkSourcePath.startsWith('//');
|
|
7
|
-
if (!isUrl) {
|
|
8
|
-
var assetPath = assetPathMap.find(function (entry) {
|
|
9
|
-
return entry.source === linkSourcePath ||
|
|
10
|
-
"./" + entry.source === linkSourcePath;
|
|
11
|
-
});
|
|
12
|
-
if (!(assetPath === null || assetPath === void 0 ? void 0 : assetPath.target)) {
|
|
13
|
-
throw new Error("Unable to find file: " + linkSourcePath);
|
|
14
|
-
}
|
|
15
|
-
linkTag.setAttribute('href', assetPath.target);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
exports.updateLinkHref = updateLinkHref;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var utils_1 = require("../utils");
|
|
43
|
-
var utils_2 = require("@sasjs/utils");
|
|
44
|
-
var path_1 = __importDefault(require("path"));
|
|
45
|
-
describe('utils', function () {
|
|
46
|
-
describe('createReactApp', function () {
|
|
47
|
-
it('should create React app', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
-
var reactFolder, reactFolderPath, sasjsFolderPath;
|
|
49
|
-
return __generator(this, function (_a) {
|
|
50
|
-
switch (_a.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
reactFolder = 'react-seed-app';
|
|
53
|
-
reactFolderPath = path_1.default.join(__dirname, reactFolder);
|
|
54
|
-
sasjsFolderPath = path_1.default.join(reactFolderPath, 'sasjs');
|
|
55
|
-
return [4 /*yield*/, utils_2.createFolder(reactFolderPath)];
|
|
56
|
-
case 1:
|
|
57
|
-
_a.sent();
|
|
58
|
-
return [4 /*yield*/, expect(utils_1.createReactApp(reactFolderPath)).toResolve()];
|
|
59
|
-
case 2:
|
|
60
|
-
_a.sent();
|
|
61
|
-
return [4 /*yield*/, expect(utils_2.folderExists(sasjsFolderPath)).resolves.toEqual(true)];
|
|
62
|
-
case 3:
|
|
63
|
-
_a.sent();
|
|
64
|
-
return [4 /*yield*/, utils_2.deleteFolder(reactFolderPath)];
|
|
65
|
-
case 4:
|
|
66
|
-
_a.sent();
|
|
67
|
-
return [2 /*return*/];
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}); });
|
|
71
|
-
});
|
|
72
|
-
});
|