@sasjs/cli 2.38.7 → 3.0.1
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 +2 -2
- package/build/commands/add/addCredential.js +26 -28
- package/build/commands/add/internal/input.js +15 -2
- package/build/commands/build/build.d.ts +1 -1
- package/build/commands/build/build.js +67 -56
- package/build/commands/build/internal/getLaunchPageCode.js +2 -1
- package/build/commands/compile/compile.js +18 -22
- package/build/commands/compile/internal/checkCompileStatus.js +6 -8
- package/build/commands/compile/internal/compileServiceFile.js +18 -16
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +16 -4
- package/build/commands/compile/spec/loadDependencies.spec.js +3 -3
- package/build/commands/context/contextCommand.js +5 -5
- package/build/commands/deploy/deploy.d.ts +2 -1
- package/build/commands/deploy/deploy.js +92 -46
- package/build/commands/deploy/spec/cbd.spec.d.ts +1 -0
- package/build/commands/deploy/spec/cbd.spec.js +141 -0
- package/build/commands/deploy/spec/cbd.spec.server.js +6 -57
- package/build/commands/deploy/spec/utils.d.ts +6 -0
- package/build/commands/deploy/spec/utils.js +242 -0
- package/build/commands/docs/internal/getDocConfig.js +8 -3
- package/build/commands/docs/spec/generateDot.spec.js +0 -1
- package/build/commands/docs/spec/getDocConfig.spec.d.ts +1 -0
- package/build/commands/docs/spec/getDocConfig.spec.js +27 -0
- package/build/commands/flow/flowCommand.js +1 -1
- package/build/commands/flow/spec/flow.spec.server.js +1 -1
- package/build/commands/folder/folderCommand.js +2 -2
- package/build/commands/folder/spec/folder.spec.server.js +1 -1
- package/build/commands/job/internal/execute/index.d.ts +2 -0
- package/build/commands/job/internal/execute/index.js +14 -0
- package/build/commands/job/internal/execute/sasjs.d.ts +8 -0
- package/build/commands/job/internal/execute/sasjs.js +69 -0
- package/build/commands/job/{execute.d.ts → internal/execute/viya.d.ts} +1 -1
- package/build/commands/job/{execute.js → internal/execute/viya.js} +29 -68
- package/build/commands/job/internal/utils.d.ts +1 -0
- package/build/commands/job/internal/utils.js +81 -0
- package/build/commands/job/jobCommand.d.ts +2 -1
- package/build/commands/job/jobCommand.js +65 -23
- package/build/commands/job/spec/execute.spec.js +41 -21
- package/build/commands/job/spec/getContextName.spec.js +1 -1
- package/build/commands/job/spec/job.spec.server.js +4 -4
- package/build/commands/job/spec/jobCommand.spec.js +10 -10
- package/build/commands/request/request.js +1 -1
- package/build/commands/run/run.js +2 -2
- package/build/commands/servicepack/spec/servicepack.spec.server.js +0 -1
- package/build/commands/shared/dependencies.js +6 -9
- package/build/commands/shared/deployToSasViyaWithServicePack.js +1 -1
- package/build/commands/testing/test.js +1 -1
- package/build/commands/web/internal/createAssetServices.d.ts +5 -0
- package/build/commands/web/internal/createAssetServices.js +219 -0
- package/build/commands/web/internal/getTags.d.ts +4 -0
- package/build/commands/web/internal/getTags.js +21 -0
- package/build/commands/web/internal/getWebServiceContent.d.ts +2 -0
- package/build/commands/web/internal/getWebServiceContent.js +84 -0
- package/build/commands/web/{spec → internal/spec}/testFiles/script1.d.ts +0 -0
- package/build/commands/web/{spec → internal/spec}/testFiles/script1.js +0 -0
- package/build/commands/web/{spec → internal/spec}/testFiles/script2.d.ts +0 -0
- package/build/commands/web/{spec → internal/spec}/testFiles/script2.js +0 -0
- package/build/commands/web/{spec/updateTagSource.spec.d.ts → internal/spec/updateScriptTag.spec.d.ts} +0 -0
- package/build/commands/web/{spec/updateTagSource.spec.js → internal/spec/updateScriptTag.spec.js} +7 -7
- package/build/commands/web/internal/updateAllTags.d.ts +13 -0
- package/build/commands/web/internal/updateAllTags.js +94 -0
- package/build/commands/web/internal/updateLinkHref.d.ts +4 -0
- package/build/commands/web/internal/updateLinkHref.js +18 -0
- package/build/commands/web/internal/updateScriptTag.d.ts +5 -0
- package/build/commands/web/internal/updateScriptTag.js +85 -0
- package/build/commands/web/web.d.ts +0 -4
- package/build/commands/web/web.js +64 -378
- package/build/config.json +3 -1
- package/build/utils/config.d.ts +1 -1
- package/build/utils/config.js +106 -71
- package/build/utils/file.d.ts +1 -1
- package/build/utils/file.js +1 -1
- package/build/utils/spec/removeComments.spec.d.ts +1 -1
- package/build/utils/spec/removeComments.spec.js +1 -1
- package/build/utils/test.js +1 -1
- package/build/utils/utils.d.ts +1 -0
- package/build/utils/utils.js +8 -2
- package/package.json +13 -13
|
@@ -91,7 +91,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
91
91
|
};
|
|
92
92
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
93
93
|
var path_1 = __importDefault(require("path"));
|
|
94
|
-
var
|
|
94
|
+
var viyaExecuteModule = __importStar(require("../internal/execute/viya"));
|
|
95
95
|
var jobCommand_1 = require("../jobCommand");
|
|
96
96
|
var utils_1 = require("@sasjs/utils");
|
|
97
97
|
var configUtils = __importStar(require("../../../utils/config"));
|
|
@@ -128,7 +128,7 @@ describe('JobCommand', function () {
|
|
|
128
128
|
case 0: return [4 /*yield*/, executeCommandWrapper([jobPath])];
|
|
129
129
|
case 1:
|
|
130
130
|
_b.sent();
|
|
131
|
-
(_a = expect(
|
|
131
|
+
(_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({ jobPath: jobPath }))));
|
|
132
132
|
return [2 /*return*/];
|
|
133
133
|
}
|
|
134
134
|
});
|
|
@@ -140,7 +140,7 @@ describe('JobCommand', function () {
|
|
|
140
140
|
case 0: return [4 /*yield*/, executeCommandWrapper([jobPath, '--log', log])];
|
|
141
141
|
case 1:
|
|
142
142
|
_b.sent();
|
|
143
|
-
(_a = expect(
|
|
143
|
+
(_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
|
|
144
144
|
jobPath: jobPath,
|
|
145
145
|
waitForJob: true,
|
|
146
146
|
logFile: path_1.default.join(projectFolder, log)
|
|
@@ -156,7 +156,7 @@ describe('JobCommand', function () {
|
|
|
156
156
|
case 0: return [4 /*yield*/, executeCommandWrapper([jobPath, '--log'])];
|
|
157
157
|
case 1:
|
|
158
158
|
_b.sent();
|
|
159
|
-
(_a = expect(
|
|
159
|
+
(_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
|
|
160
160
|
jobPath: jobPath,
|
|
161
161
|
waitForJob: true,
|
|
162
162
|
logFile: path_1.default.join(process.projectDir, jobFileName + ".log")
|
|
@@ -172,7 +172,7 @@ describe('JobCommand', function () {
|
|
|
172
172
|
case 0: return [4 /*yield*/, executeCommandWrapper([jobPath, '--returnStatusOnly'])];
|
|
173
173
|
case 1:
|
|
174
174
|
_b.sent();
|
|
175
|
-
(_a = expect(
|
|
175
|
+
(_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
|
|
176
176
|
jobPath: jobPath,
|
|
177
177
|
waitForJob: true,
|
|
178
178
|
returnStatusOnly: true
|
|
@@ -204,7 +204,7 @@ describe('JobCommand', function () {
|
|
|
204
204
|
])];
|
|
205
205
|
case 1:
|
|
206
206
|
_b.sent();
|
|
207
|
-
(_a = expect(
|
|
207
|
+
(_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
|
|
208
208
|
jobPath: jobPath,
|
|
209
209
|
waitForJob: true,
|
|
210
210
|
output: output,
|
|
@@ -242,7 +242,7 @@ describe('JobCommand', function () {
|
|
|
242
242
|
])];
|
|
243
243
|
case 1:
|
|
244
244
|
_b.sent();
|
|
245
|
-
(_a = expect(
|
|
245
|
+
(_a = expect(viyaExecuteModule.executeJobViya)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(executeCalledWith({
|
|
246
246
|
jobPath: jobPath,
|
|
247
247
|
waitForJob: true,
|
|
248
248
|
output: output,
|
|
@@ -314,7 +314,7 @@ describe('JobCommand', function () {
|
|
|
314
314
|
switch (_a.label) {
|
|
315
315
|
case 0:
|
|
316
316
|
jest
|
|
317
|
-
.spyOn(
|
|
317
|
+
.spyOn(viyaExecuteModule, 'executeJobViya')
|
|
318
318
|
.mockImplementation(function () { return Promise.reject(new Error('Test Error')); });
|
|
319
319
|
return [4 /*yield*/, executeCommandWrapper([jobPath])];
|
|
320
320
|
case 1:
|
|
@@ -328,10 +328,10 @@ describe('JobCommand', function () {
|
|
|
328
328
|
});
|
|
329
329
|
var setupMocks = function () {
|
|
330
330
|
jest.resetAllMocks();
|
|
331
|
-
jest.mock('../execute');
|
|
331
|
+
jest.mock('../internal/execute');
|
|
332
332
|
jest.mock('../../../utils/config');
|
|
333
333
|
jest
|
|
334
|
-
.spyOn(
|
|
334
|
+
.spyOn(viyaExecuteModule, 'executeJobViya')
|
|
335
335
|
.mockImplementation(function () { return Promise.resolve(); });
|
|
336
336
|
jest
|
|
337
337
|
.spyOn(configUtils, 'findTargetInConfiguration')
|
|
@@ -102,7 +102,7 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
|
|
|
102
102
|
}
|
|
103
103
|
sasjs = new node_1.default({
|
|
104
104
|
serverUrl: target.serverUrl,
|
|
105
|
-
|
|
105
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
106
106
|
appLoc: target.appLoc,
|
|
107
107
|
serverType: target.serverType,
|
|
108
108
|
contextName: target.contextName,
|
|
@@ -139,7 +139,7 @@ function executeOnSasViya(filePath, isTempFile, target, linesToExecute) {
|
|
|
139
139
|
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Sending " + path_1.default.basename(filePath) + " to SAS server for execution.");
|
|
140
140
|
sasjs = new node_1.default({
|
|
141
141
|
serverUrl: target.serverUrl,
|
|
142
|
-
|
|
142
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
143
143
|
appLoc: target.appLoc,
|
|
144
144
|
serverType: target.serverType,
|
|
145
145
|
debug: true,
|
|
@@ -225,7 +225,7 @@ function executeOnSas9(filePath, isTempFile, target, linesToExecute) {
|
|
|
225
225
|
password = utils_1.decodeFromBase64(password);
|
|
226
226
|
sasjs = new node_1.default({
|
|
227
227
|
serverUrl: target.serverUrl,
|
|
228
|
-
|
|
228
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
229
229
|
appLoc: target.appLoc,
|
|
230
230
|
serverType: target.serverType,
|
|
231
231
|
debug: true
|
|
@@ -61,7 +61,6 @@ describe('sasjs servicepack', function () {
|
|
|
61
61
|
name: targetName,
|
|
62
62
|
serverType: utils_1.ServerType.SasViya,
|
|
63
63
|
serverUrl: process.env.VIYA_SERVER_URL,
|
|
64
|
-
allowInsecureRequests: false,
|
|
65
64
|
appLoc: "/Public/app/cli-tests/" + targetName,
|
|
66
65
|
contextName: utils_2.contextName,
|
|
67
66
|
authConfig: {
|
|
@@ -73,15 +73,12 @@ function getDependencyPaths(fileContent, macroFolders) {
|
|
|
73
73
|
var _a;
|
|
74
74
|
if (macroFolders === void 0) { macroFolders = []; }
|
|
75
75
|
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
-
var sourcePaths,
|
|
76
|
+
var sourcePaths, dependenciesHeader, dependencies, dependencyPaths, foundDependencies, notFoundDependencies, errorMessage;
|
|
77
77
|
var _this = this;
|
|
78
|
-
return __generator(this, function (
|
|
79
|
-
switch (
|
|
78
|
+
return __generator(this, function (_b) {
|
|
79
|
+
switch (_b.label) {
|
|
80
80
|
case 0:
|
|
81
|
-
|
|
82
|
-
return [4 /*yield*/, config_1.getMacroCorePath()];
|
|
83
|
-
case 1:
|
|
84
|
-
sourcePaths = __spreadArray.apply(void 0, _b.concat([[_c.sent()]]));
|
|
81
|
+
sourcePaths = __spreadArray(__spreadArray([], __read(macroFolders)), [config_1.getMacroCorePath()]);
|
|
85
82
|
dependenciesHeader = fileContent.includes('<h4> SAS Macros </h4>')
|
|
86
83
|
? '<h4> SAS Macros </h4>'
|
|
87
84
|
: '<h4> Dependencies </h4>';
|
|
@@ -134,8 +131,8 @@ function getDependencyPaths(fileContent, macroFolders) {
|
|
|
134
131
|
}
|
|
135
132
|
});
|
|
136
133
|
}); })];
|
|
137
|
-
case
|
|
138
|
-
|
|
134
|
+
case 1:
|
|
135
|
+
_b.sent();
|
|
139
136
|
notFoundDependencies = utils_2.diff(dependencies, foundDependencies);
|
|
140
137
|
if (notFoundDependencies.length) {
|
|
141
138
|
errorMessage = 'Unable to locate dependencies: ' + notFoundDependencies.join(', ');
|
|
@@ -67,7 +67,7 @@ function deployToSasViyaWithServicePack(jsonFilePath, target, isLocal, isForced)
|
|
|
67
67
|
throw new Error("Deployment failed. Request is not authenticated.\nPlease add the following variables to your .env" + (isLocal ? "." + target.name : '') + " file:\nCLIENT, SECRET, ACCESS_TOKEN, REFRESH_TOKEN");
|
|
68
68
|
}
|
|
69
69
|
sasjs = new node_1.default({
|
|
70
|
-
|
|
70
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
71
71
|
appLoc: target.appLoc,
|
|
72
72
|
serverType: target.serverType,
|
|
73
73
|
serverUrl: target.serverUrl,
|
|
@@ -144,7 +144,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
|
|
|
144
144
|
flow.push(testFlow.testTearDown);
|
|
145
145
|
sasjs = new node_1.default({
|
|
146
146
|
serverUrl: target.serverUrl,
|
|
147
|
-
|
|
147
|
+
httpsAgentOptions: target.httpsAgentOptions,
|
|
148
148
|
appLoc: target.appLoc,
|
|
149
149
|
serverType: target.serverType,
|
|
150
150
|
debug: true,
|
|
@@ -0,0 +1,219 @@
|
|
|
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.createAssetServices = void 0;
|
|
64
|
+
var path_1 = __importDefault(require("path"));
|
|
65
|
+
var utils_1 = require("@sasjs/utils");
|
|
66
|
+
var lodash_uniqby_1 = __importDefault(require("lodash.uniqby"));
|
|
67
|
+
var getWebServiceContent_1 = require("./getWebServiceContent");
|
|
68
|
+
var createAssetServices = function (target, destinationPath, streamConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
+
var webSourcePath, streamWebFolder, assetPaths, assetPathMap;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
switch (_a.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
webSourcePath = streamConfig.webSourcePath, streamWebFolder = streamConfig.streamWebFolder, assetPaths = streamConfig.assetPaths;
|
|
74
|
+
assetPathMap = [];
|
|
75
|
+
return [4 /*yield*/, utils_1.asyncForEach(__spreadArray([path_1.default.join(process.projectDir, webSourcePath)], __read((assetPaths !== null && assetPaths !== void 0 ? assetPaths : []))), function (assetPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
76
|
+
var fullAssetPath, assetPathExists, assetPathMapNested;
|
|
77
|
+
var _a;
|
|
78
|
+
return __generator(this, function (_b) {
|
|
79
|
+
switch (_b.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
fullAssetPath = path_1.default.isAbsolute(assetPath)
|
|
82
|
+
? assetPath
|
|
83
|
+
: path_1.default.isAbsolute(webSourcePath)
|
|
84
|
+
? path_1.default.join(webSourcePath, assetPath)
|
|
85
|
+
: path_1.default.join(process.projectDir, webSourcePath, assetPath);
|
|
86
|
+
return [4 /*yield*/, utils_1.folderExists(fullAssetPath)];
|
|
87
|
+
case 1:
|
|
88
|
+
assetPathExists = _b.sent();
|
|
89
|
+
if (!assetPathExists) {
|
|
90
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.warn("Assets path '" + fullAssetPath + "' present in 'streamConfig' doesn't exist.");
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
}
|
|
93
|
+
return [4 /*yield*/, createAssetsServicesNested(target, streamWebFolder, fullAssetPath, destinationPath)];
|
|
94
|
+
case 2:
|
|
95
|
+
assetPathMapNested = _b.sent();
|
|
96
|
+
assetPathMap.push.apply(assetPathMap, __spreadArray([], __read(assetPathMapNested)));
|
|
97
|
+
return [2 /*return*/];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}); })];
|
|
101
|
+
case 1:
|
|
102
|
+
_a.sent();
|
|
103
|
+
return [2 /*return*/, lodash_uniqby_1.default(assetPathMap, 'source')];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}); };
|
|
107
|
+
exports.createAssetServices = createAssetServices;
|
|
108
|
+
var createAssetsServicesNested = function (target, streamWebFolder, fullAssetPath, destinationPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
109
|
+
var assetPathMap, filePaths, folderNames;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
switch (_a.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
assetPathMap = [];
|
|
114
|
+
return [4 /*yield*/, utils_1.listFilesInFolder(fullAssetPath)];
|
|
115
|
+
case 1:
|
|
116
|
+
filePaths = _a.sent();
|
|
117
|
+
return [4 /*yield*/, utils_1.asyncForEach(filePaths, function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
118
|
+
var fullFileName, fileName, fileExtension, sourcePath, assetServiceUrl, fileName_1, assetServiceUrl;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
fullFileName = path_1.default.basename(filePath);
|
|
123
|
+
fileName = fullFileName.substring(0, fullFileName.lastIndexOf('.'));
|
|
124
|
+
fileExtension = path_1.default
|
|
125
|
+
.basename(filePath)
|
|
126
|
+
.substring(fullFileName.lastIndexOf('.') + 1, fullFileName.length);
|
|
127
|
+
if (!(fileName && fileExtension)) return [3 /*break*/, 4];
|
|
128
|
+
sourcePath = path_1.default.join(fullAssetPath, filePath);
|
|
129
|
+
if (!(target.serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 2];
|
|
130
|
+
return [4 /*yield*/, utils_1.copy(sourcePath, path_1.default.join(destinationPath, fullFileName))];
|
|
131
|
+
case 1:
|
|
132
|
+
_a.sent();
|
|
133
|
+
assetServiceUrl = getAssetPath(target.appLoc, target.serverType, streamWebFolder, fullFileName);
|
|
134
|
+
assetPathMap.push({
|
|
135
|
+
source: fullFileName,
|
|
136
|
+
target: assetServiceUrl
|
|
137
|
+
});
|
|
138
|
+
return [3 /*break*/, 4];
|
|
139
|
+
case 2: return [4 /*yield*/, generateAssetService(sourcePath, filePath, destinationPath, target.serverType)];
|
|
140
|
+
case 3:
|
|
141
|
+
fileName_1 = _a.sent();
|
|
142
|
+
assetServiceUrl = getAssetPath(target.appLoc, target.serverType, streamWebFolder, fileName_1.replace('.sas', ''));
|
|
143
|
+
assetPathMap.push({
|
|
144
|
+
source: fullFileName,
|
|
145
|
+
target: assetServiceUrl
|
|
146
|
+
});
|
|
147
|
+
_a.label = 4;
|
|
148
|
+
case 4: return [2 /*return*/];
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}); })];
|
|
152
|
+
case 2:
|
|
153
|
+
_a.sent();
|
|
154
|
+
return [4 /*yield*/, utils_1.listSubFoldersInFolder(fullAssetPath)];
|
|
155
|
+
case 3:
|
|
156
|
+
folderNames = _a.sent();
|
|
157
|
+
return [4 /*yield*/, utils_1.asyncForEach(folderNames, function (folderName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
158
|
+
var destinationPathNested, fullAssetPathNested, assetFolderMap;
|
|
159
|
+
return __generator(this, function (_a) {
|
|
160
|
+
switch (_a.label) {
|
|
161
|
+
case 0:
|
|
162
|
+
destinationPathNested = path_1.default.join(destinationPath, folderName);
|
|
163
|
+
fullAssetPathNested = path_1.default.join(fullAssetPath, folderName);
|
|
164
|
+
return [4 /*yield*/, utils_1.createFolder(destinationPathNested)];
|
|
165
|
+
case 1:
|
|
166
|
+
_a.sent();
|
|
167
|
+
return [4 /*yield*/, createAssetsServicesNested(target, streamWebFolder + "/" + folderName, fullAssetPathNested, destinationPathNested)];
|
|
168
|
+
case 2:
|
|
169
|
+
assetFolderMap = _a.sent();
|
|
170
|
+
assetFolderMap.forEach(function (entry) {
|
|
171
|
+
assetPathMap.push({
|
|
172
|
+
source: folderName + "/" + entry.source,
|
|
173
|
+
target: entry.target
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
return [2 /*return*/];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}); })];
|
|
180
|
+
case 4:
|
|
181
|
+
_a.sent();
|
|
182
|
+
return [2 /*return*/, assetPathMap];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}); };
|
|
186
|
+
var generateAssetService = function (sourcePath, filePath, destinationPath, serverType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
187
|
+
var fileExtension, fileType, fileName, base64string, serviceContent;
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
switch (_a.label) {
|
|
190
|
+
case 0:
|
|
191
|
+
fileExtension = path_1.default.extname(filePath);
|
|
192
|
+
fileType = fileExtension.replace('.', '').toUpperCase();
|
|
193
|
+
fileName = path_1.default
|
|
194
|
+
.basename(filePath)
|
|
195
|
+
.replace(new RegExp(fileExtension + '$'), fileExtension.replace('.', '-'));
|
|
196
|
+
return [4 /*yield*/, utils_1.base64EncodeFile(sourcePath)];
|
|
197
|
+
case 1:
|
|
198
|
+
base64string = _a.sent();
|
|
199
|
+
return [4 /*yield*/, getWebServiceContent_1.getWebServiceContent(base64string, fileType, serverType)];
|
|
200
|
+
case 2:
|
|
201
|
+
serviceContent = _a.sent();
|
|
202
|
+
return [4 /*yield*/, utils_1.createFile(path_1.default.join(destinationPath, fileName + ".sas"), serviceContent)];
|
|
203
|
+
case 3:
|
|
204
|
+
_a.sent();
|
|
205
|
+
return [2 /*return*/, fileName + ".sas"];
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}); };
|
|
209
|
+
var getAssetPath = function (appLoc, serverType, streamWebFolder, fileName) {
|
|
210
|
+
var storedProcessPath =
|
|
211
|
+
// the appLoc is inserted dynamically by SAS
|
|
212
|
+
// using three forward slashes as a marker
|
|
213
|
+
// for SAS 9 fileName is a program, with replacement in sasjsout.ts
|
|
214
|
+
// for Viya, fileName is a FILE, with replacement in build.sas only
|
|
215
|
+
serverType === utils_1.ServerType.SasViya
|
|
216
|
+
? "/SASJobExecution?_FILE=" + appLoc + "/services/" + streamWebFolder
|
|
217
|
+
: "/SASStoredProcess/?_PROGRAM=///" + streamWebFolder;
|
|
218
|
+
return storedProcessPath + "/" + fileName;
|
|
219
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFaviconTags = exports.getLinkTags = exports.getScriptTags = void 0;
|
|
4
|
+
var getScriptTags = function (parsedHtml) {
|
|
5
|
+
return Array.from(parsedHtml.window.document.querySelectorAll('script'));
|
|
6
|
+
};
|
|
7
|
+
exports.getScriptTags = getScriptTags;
|
|
8
|
+
var getLinkTags = function (parsedHtml) {
|
|
9
|
+
var linkTags = Array.from(parsedHtml.window.document.querySelectorAll('link')).filter(function (s) { return s.getAttribute('rel') === 'stylesheet'; });
|
|
10
|
+
return linkTags;
|
|
11
|
+
};
|
|
12
|
+
exports.getLinkTags = getLinkTags;
|
|
13
|
+
var getFaviconTags = function (parsedHtml) {
|
|
14
|
+
var linkTags = Array.from(parsedHtml.window.document.querySelectorAll('link')).filter(function (s) {
|
|
15
|
+
return s.getAttribute('rel') &&
|
|
16
|
+
s.getAttribute('rel') &&
|
|
17
|
+
s.getAttribute('rel').includes('icon');
|
|
18
|
+
});
|
|
19
|
+
return linkTags;
|
|
20
|
+
};
|
|
21
|
+
exports.getFaviconTags = getFaviconTags;
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getWebServiceContent = void 0;
|
|
40
|
+
var utils_1 = require("@sasjs/utils");
|
|
41
|
+
var utils_2 = require("../../../utils");
|
|
42
|
+
var sasjsout_1 = require("./sasjsout");
|
|
43
|
+
var getWebServiceContent = function (contentBase64, type, serverType) {
|
|
44
|
+
if (type === void 0) { type = 'JS'; }
|
|
45
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var lines, typesToEncode, serviceContent;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
lines = [contentBase64];
|
|
49
|
+
typesToEncode = {
|
|
50
|
+
JS: 'JS64',
|
|
51
|
+
CSS: 'CSS64'
|
|
52
|
+
};
|
|
53
|
+
serviceContent = sasjsout_1.sasjsout + "\nfilename sasjs temp lrecl=99999999;\ndata _null_;\nfile sasjs;\n";
|
|
54
|
+
lines.forEach(function (line) {
|
|
55
|
+
var chunkedLines = utils_2.chunk(line);
|
|
56
|
+
if (chunkedLines.length === 1) {
|
|
57
|
+
serviceContent += "put '" + chunkedLines[0].split("'").join("''") + "';\n";
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
var combinedLines_1 = '';
|
|
61
|
+
chunkedLines.forEach(function (chunkedLine, index) {
|
|
62
|
+
var text = "put '" + chunkedLine.split("'").join("''") + "'";
|
|
63
|
+
if (index !== chunkedLines.length - 1) {
|
|
64
|
+
text += '@;\n';
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
text += ';\n';
|
|
68
|
+
}
|
|
69
|
+
combinedLines_1 += text;
|
|
70
|
+
});
|
|
71
|
+
serviceContent += combinedLines_1;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (serverType === utils_1.ServerType.Sas9 && typesToEncode.hasOwnProperty(type)) {
|
|
75
|
+
serviceContent += "\nrun;\n%sasjsout(" + typesToEncode[type] + ")";
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
serviceContent += "\nrun;\n%sasjsout(" + type + ")";
|
|
79
|
+
}
|
|
80
|
+
return [2 /*return*/, serviceContent];
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
exports.getWebServiceContent = getWebServiceContent;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/build/commands/web/{spec/updateTagSource.spec.js → internal/spec/updateScriptTag.spec.js}
RENAMED
|
@@ -44,15 +44,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
var path_1 = __importDefault(require("path"));
|
|
46
46
|
var utils_1 = require("@sasjs/utils");
|
|
47
|
-
var
|
|
48
|
-
var utils_2 = require("
|
|
49
|
-
describe('
|
|
47
|
+
var updateScriptTag_1 = require("../updateScriptTag");
|
|
48
|
+
var utils_2 = require("../../../../utils");
|
|
49
|
+
describe('updateScriptTag', function () {
|
|
50
50
|
var destinationPath;
|
|
51
51
|
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
52
|
return __generator(this, function (_a) {
|
|
53
53
|
switch (_a.label) {
|
|
54
54
|
case 0:
|
|
55
|
-
destinationPath = path_1.default.join(__dirname, "cli-test-web-
|
|
55
|
+
destinationPath = path_1.default.join(__dirname, "cli-test-web-updateScriptTag-" + utils_1.generateTimestamp());
|
|
56
56
|
return [4 /*yield*/, utils_1.createFolder(destinationPath)];
|
|
57
57
|
case 1:
|
|
58
58
|
_a.sent();
|
|
@@ -80,7 +80,7 @@ describe('updateTagSource', function () {
|
|
|
80
80
|
switch (_a.label) {
|
|
81
81
|
case 0:
|
|
82
82
|
scriptTag = document.createElement('link');
|
|
83
|
-
sourcePath = '
|
|
83
|
+
sourcePath = path_1.default.join(__dirname, 'testFiles');
|
|
84
84
|
target = { serverType: utils_1.ServerType.Sas9 };
|
|
85
85
|
assetPathMap = [];
|
|
86
86
|
script1Filename = 'script1.js';
|
|
@@ -92,7 +92,7 @@ describe('updateTagSource', function () {
|
|
|
92
92
|
source: script1Filename,
|
|
93
93
|
target: sasProgramScript1Path
|
|
94
94
|
});
|
|
95
|
-
return [4 /*yield*/,
|
|
95
|
+
return [4 /*yield*/, updateScriptTag_1.updateScriptTag(scriptTag, sourcePath, destinationPath, target.serverType, assetPathMap)];
|
|
96
96
|
case 1:
|
|
97
97
|
_a.sent();
|
|
98
98
|
expect(scriptTag.getAttribute('src')).toEqual(sasProgramScript1Path);
|
|
@@ -109,7 +109,7 @@ describe('updateTagSource', function () {
|
|
|
109
109
|
source: script2Filename,
|
|
110
110
|
target: sasProgramScript2Path
|
|
111
111
|
});
|
|
112
|
-
return [4 /*yield*/,
|
|
112
|
+
return [4 /*yield*/, updateScriptTag_1.updateScriptTag(scriptTag, sourcePath, destinationPath, target.serverType, assetPathMap)];
|
|
113
113
|
case 3:
|
|
114
114
|
_a.sent();
|
|
115
115
|
expect(scriptTag.getAttribute('src')).toEqual(sasProgramScript2Path);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { JSDOM } from 'jsdom';
|
|
2
|
+
import { ServerType } from '@sasjs/utils';
|
|
3
|
+
interface paramsType {
|
|
4
|
+
webSourcePathFull: string;
|
|
5
|
+
destinationPath: string;
|
|
6
|
+
serverType: ServerType;
|
|
7
|
+
assetPathMap: {
|
|
8
|
+
source: string;
|
|
9
|
+
target: string;
|
|
10
|
+
}[];
|
|
11
|
+
}
|
|
12
|
+
export declare const updateAllTags: (parsedHtml: JSDOM, { webSourcePathFull, destinationPath, serverType, assetPathMap }: paramsType) => Promise<void>;
|
|
13
|
+
export {};
|