@sasjs/cli 3.15.2 → 3.16.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/README.md +3 -0
- package/build/commands/add/addCredential.js +25 -18
- package/build/commands/add/addTarget.js +14 -9
- package/build/commands/add/spec/addTarget.spec.js +7 -0
- package/build/commands/build/build.js +4 -4
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +5 -3
- package/build/commands/deploy/spec/cbd.spec.js +38 -17
- package/build/commands/testing/spec/testing.spec.js +5 -0
- package/build/commands/web/internal/createAssetServices.d.ts +11 -2
- package/build/commands/web/internal/createAssetServices.js +83 -92
- package/build/commands/web/internal/getAssetPath.d.ts +2 -0
- package/build/commands/web/internal/getAssetPath.js +17 -0
- package/build/commands/web/internal/modifyLinksInContent.d.ts +2 -0
- package/build/commands/web/internal/modifyLinksInContent.js +11 -0
- package/build/commands/web/internal/sas9/createClickMeService.d.ts +6 -0
- package/build/commands/web/internal/sas9/createClickMeService.js +91 -0
- package/build/commands/web/internal/sas9/generateAssetService.d.ts +7 -0
- package/build/commands/web/internal/sas9/generateAssetService.js +75 -0
- package/build/commands/web/internal/sas9/getWebServiceContent.d.ts +7 -0
- package/build/commands/web/internal/{getWebServiceContent.js → sas9/getWebServiceContent.js} +12 -8
- package/build/commands/web/internal/sas9/index.d.ts +3 -0
- package/build/commands/web/internal/sas9/index.js +15 -0
- package/build/commands/web/internal/sasViya/createClickMeFile.d.ts +6 -0
- package/build/commands/web/internal/sasViya/createClickMeFile.js +63 -0
- package/build/commands/web/internal/sasViya/index.d.ts +1 -0
- package/build/commands/web/internal/sasViya/index.js +13 -0
- package/build/commands/web/internal/sasjsout.d.ts +1 -1
- package/build/commands/web/internal/sasjsout.js +2 -1
- package/build/commands/web/internal/updateAllTags.d.ts +7 -4
- package/build/commands/web/internal/updateAllTags.js +5 -0
- package/build/commands/web/internal/updateLinkTag.d.ts +2 -4
- package/build/commands/web/internal/updateScriptTag.d.ts +2 -4
- package/build/commands/web/internal/updateScriptTag.js +32 -32
- package/build/commands/web/internal/updateStyleTag.d.ts +2 -4
- package/build/commands/web/internal/updateStyleTag.js +32 -32
- package/build/commands/web/web.js +30 -79
- package/build/constants.d.ts +1 -0
- package/build/utils/setConstants.js +4 -2
- package/build/utils/utils.d.ts +1 -0
- package/build/utils/utils.js +22 -1
- package/package.json +1 -1
- package/build/commands/web/internal/getWebServiceContent.d.ts +0 -2
|
@@ -68,47 +68,67 @@ exports.createAssetServices = void 0;
|
|
|
68
68
|
var path_1 = __importDefault(require("path"));
|
|
69
69
|
var utils_1 = require("@sasjs/utils");
|
|
70
70
|
var lodash_uniqby_1 = __importDefault(require("lodash.uniqby"));
|
|
71
|
-
var
|
|
72
|
-
var
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
71
|
+
var getAssetPath_1 = require("./getAssetPath");
|
|
72
|
+
var sas9_1 = require("./sas9");
|
|
73
|
+
/**
|
|
74
|
+
* Creates all the asset services for web streaming.
|
|
75
|
+
* Also prepares an asset-path Map based on server type.
|
|
76
|
+
* @param {Target} target the target to create asset service.
|
|
77
|
+
* @param {string} destinationPath the location of web streaming files.
|
|
78
|
+
* @param {StreamConfig} streamConfig stream configuration to be used.
|
|
79
|
+
* @returns {AssetPathMap[]} list of all the sources specified along server based paths.
|
|
80
|
+
*/
|
|
81
|
+
var createAssetServices = function (target, destinationPath, _a) {
|
|
82
|
+
var webSourcePath = _a.webSourcePath, streamWebFolder = _a.streamWebFolder, assetPaths = _a.assetPaths;
|
|
83
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
84
|
+
var assetPathMap;
|
|
85
|
+
return __generator(this, function (_b) {
|
|
86
|
+
switch (_b.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
assetPathMap = [];
|
|
89
|
+
return [4 /*yield*/, (0, utils_1.asyncForEach)(__spreadArray([path_1.default.join(process.projectDir, webSourcePath)], __read((assetPaths !== null && assetPaths !== void 0 ? assetPaths : [])), false), function (assetPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
+
var fullAssetPath, assetPathExists, assetPathMapNested;
|
|
91
|
+
var _a;
|
|
92
|
+
return __generator(this, function (_b) {
|
|
93
|
+
switch (_b.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
fullAssetPath = path_1.default.isAbsolute(assetPath)
|
|
96
|
+
? assetPath
|
|
97
|
+
: path_1.default.isAbsolute(webSourcePath)
|
|
98
|
+
? path_1.default.join(webSourcePath, assetPath)
|
|
99
|
+
: path_1.default.join(process.projectDir, webSourcePath, assetPath);
|
|
100
|
+
return [4 /*yield*/, (0, utils_1.folderExists)(fullAssetPath)];
|
|
101
|
+
case 1:
|
|
102
|
+
assetPathExists = _b.sent();
|
|
103
|
+
if (!assetPathExists) {
|
|
104
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.warn("Assets path '".concat(fullAssetPath, "' present in 'streamConfig' doesn't exist."));
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
}
|
|
107
|
+
return [4 /*yield*/, createAssetsServicesNested(target, streamWebFolder, fullAssetPath, destinationPath)];
|
|
108
|
+
case 2:
|
|
109
|
+
assetPathMapNested = _b.sent();
|
|
110
|
+
assetPathMap.push.apply(assetPathMap, __spreadArray([], __read(assetPathMapNested), false));
|
|
95
111
|
return [2 /*return*/];
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}); })];
|
|
105
|
-
case 1:
|
|
106
|
-
_a.sent();
|
|
107
|
-
return [2 /*return*/, (0, lodash_uniqby_1.default)(assetPathMap, 'source')];
|
|
108
|
-
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}); })];
|
|
115
|
+
case 1:
|
|
116
|
+
_b.sent();
|
|
117
|
+
return [2 /*return*/, (0, lodash_uniqby_1.default)(assetPathMap, 'source')];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
109
120
|
});
|
|
110
|
-
}
|
|
121
|
+
};
|
|
111
122
|
exports.createAssetServices = createAssetServices;
|
|
123
|
+
/**
|
|
124
|
+
* Creates all the asset services for web streaming for a specific folder.
|
|
125
|
+
* Also prepares an asset-path Map based on server type.
|
|
126
|
+
* @param {Target} target the target to create asset service.
|
|
127
|
+
* @param {string} streamWebFolder the location of web streaming files.
|
|
128
|
+
* @param {string} fullAssetPath path of the specific folder used to create all services for.
|
|
129
|
+
* @param {string} destinationPath path of the destination folder for services.
|
|
130
|
+
* @returns {AssetPathMap[]} list of all the sources specified along server based paths.
|
|
131
|
+
*/
|
|
112
132
|
var createAssetsServicesNested = function (target, streamWebFolder, fullAssetPath, destinationPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
133
|
var assetPathMap, filePaths, folderNames;
|
|
114
134
|
return __generator(this, function (_a) {
|
|
@@ -119,37 +139,42 @@ var createAssetsServicesNested = function (target, streamWebFolder, fullAssetPat
|
|
|
119
139
|
case 1:
|
|
120
140
|
filePaths = _a.sent();
|
|
121
141
|
return [4 /*yield*/, (0, utils_1.asyncForEach)(filePaths, function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
-
var fullFileName, fileName, fileExtension, sourcePath, assetServiceUrl,
|
|
123
|
-
return __generator(this, function (
|
|
124
|
-
switch (
|
|
142
|
+
var fullFileName, fileName, fileExtension, sourcePath, assetServiceUrl, _a, fileName_1;
|
|
143
|
+
return __generator(this, function (_b) {
|
|
144
|
+
switch (_b.label) {
|
|
125
145
|
case 0:
|
|
126
146
|
fullFileName = path_1.default.basename(filePath);
|
|
127
147
|
fileName = fullFileName.substring(0, fullFileName.lastIndexOf('.'));
|
|
128
148
|
fileExtension = path_1.default
|
|
129
149
|
.basename(filePath)
|
|
130
150
|
.substring(fullFileName.lastIndexOf('.') + 1, fullFileName.length);
|
|
131
|
-
if (!(fileName && fileExtension)) return [3 /*break*/,
|
|
151
|
+
if (!(fileName && fileExtension)) return [3 /*break*/, 7];
|
|
132
152
|
sourcePath = path_1.default.join(fullAssetPath, filePath);
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
153
|
+
assetServiceUrl = void 0;
|
|
154
|
+
_a = target.serverType;
|
|
155
|
+
switch (_a) {
|
|
156
|
+
case utils_1.ServerType.SasViya: return [3 /*break*/, 1];
|
|
157
|
+
case utils_1.ServerType.Sas9: return [3 /*break*/, 3];
|
|
158
|
+
}
|
|
159
|
+
return [3 /*break*/, 5];
|
|
160
|
+
case 1: return [4 /*yield*/, (0, utils_1.copy)(sourcePath, path_1.default.join(destinationPath, fullFileName))];
|
|
161
|
+
case 2:
|
|
162
|
+
_b.sent();
|
|
163
|
+
assetServiceUrl = (0, getAssetPath_1.getAssetPath)(target.appLoc, target.serverType, streamWebFolder, fullFileName);
|
|
164
|
+
return [3 /*break*/, 6];
|
|
165
|
+
case 3: return [4 /*yield*/, (0, sas9_1.generateAssetService)(sourcePath, destinationPath)];
|
|
166
|
+
case 4:
|
|
167
|
+
fileName_1 = _b.sent();
|
|
168
|
+
assetServiceUrl = (0, getAssetPath_1.getAssetPath)(target.appLoc, target.serverType, streamWebFolder, fileName_1.replace('.sas', ''));
|
|
169
|
+
return [3 /*break*/, 6];
|
|
170
|
+
case 5: throw new Error("Server Type: ".concat(target.serverType, " is not supported for processing streaming file."));
|
|
171
|
+
case 6:
|
|
147
172
|
assetPathMap.push({
|
|
148
173
|
source: fullFileName,
|
|
149
174
|
target: assetServiceUrl
|
|
150
175
|
});
|
|
151
|
-
|
|
152
|
-
case
|
|
176
|
+
_b.label = 7;
|
|
177
|
+
case 7: return [2 /*return*/];
|
|
153
178
|
}
|
|
154
179
|
});
|
|
155
180
|
}); })];
|
|
@@ -187,37 +212,3 @@ var createAssetsServicesNested = function (target, streamWebFolder, fullAssetPat
|
|
|
187
212
|
}
|
|
188
213
|
});
|
|
189
214
|
}); };
|
|
190
|
-
var generateAssetService = function (sourcePath, filePath, destinationPath, serverType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
191
|
-
var fileExtension, fileType, fileName, base64string, serviceContent;
|
|
192
|
-
return __generator(this, function (_a) {
|
|
193
|
-
switch (_a.label) {
|
|
194
|
-
case 0:
|
|
195
|
-
fileExtension = path_1.default.extname(filePath);
|
|
196
|
-
fileType = fileExtension.replace('.', '').toUpperCase();
|
|
197
|
-
fileName = path_1.default
|
|
198
|
-
.basename(filePath)
|
|
199
|
-
.replace(new RegExp(fileExtension + '$'), fileExtension.replace('.', '-'));
|
|
200
|
-
return [4 /*yield*/, (0, utils_1.base64EncodeFile)(sourcePath)];
|
|
201
|
-
case 1:
|
|
202
|
-
base64string = _a.sent();
|
|
203
|
-
return [4 /*yield*/, (0, getWebServiceContent_1.getWebServiceContent)(base64string, fileType, serverType)];
|
|
204
|
-
case 2:
|
|
205
|
-
serviceContent = _a.sent();
|
|
206
|
-
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(destinationPath, "".concat(fileName, ".sas")), serviceContent)];
|
|
207
|
-
case 3:
|
|
208
|
-
_a.sent();
|
|
209
|
-
return [2 /*return*/, "".concat(fileName, ".sas")];
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}); };
|
|
213
|
-
var getAssetPath = function (appLoc, serverType, streamWebFolder, fileName) {
|
|
214
|
-
var storedProcessPath =
|
|
215
|
-
// the appLoc is inserted dynamically by SAS
|
|
216
|
-
// using three forward slashes as a marker
|
|
217
|
-
// for SAS 9 fileName is a program, with replacement in sasjsout.ts
|
|
218
|
-
// for Viya, fileName is a FILE, with replacement in build.sas only
|
|
219
|
-
serverType === utils_1.ServerType.SasViya
|
|
220
|
-
? "/SASJobExecution?_FILE=".concat(appLoc, "/services/").concat(streamWebFolder)
|
|
221
|
-
: "/SASStoredProcess/?_PROGRAM=///".concat(streamWebFolder);
|
|
222
|
-
return "".concat(storedProcessPath, "/").concat(fileName);
|
|
223
|
-
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAssetPath = void 0;
|
|
4
|
+
var utils_1 = require("@sasjs/utils");
|
|
5
|
+
var getAssetPath = function (appLoc, serverType, streamWebFolder, fileName) {
|
|
6
|
+
var sas9GUID = process.sasjsConstants.sas9GUID;
|
|
7
|
+
var storedProcessPath =
|
|
8
|
+
// the appLoc is inserted dynamically
|
|
9
|
+
// for SAS 9 files are Base 64 encoded into STPs, with
|
|
10
|
+
// dynamic runtime replacement of appLoc (see sasjsout.ts)
|
|
11
|
+
// for Viya, fileName is a FILE, with replacement harcoded in build.sas
|
|
12
|
+
serverType === utils_1.ServerType.SasViya
|
|
13
|
+
? "/SASJobExecution?_FILE=".concat(appLoc, "/services")
|
|
14
|
+
: "/SASStoredProcess/?_PROGRAM=".concat(sas9GUID);
|
|
15
|
+
return "".concat(storedProcessPath, "/").concat(streamWebFolder, "/").concat(fileName);
|
|
16
|
+
};
|
|
17
|
+
exports.getAssetPath = getAssetPath;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.modifyLinksInContent = void 0;
|
|
4
|
+
var modifyLinksInContent = function (_content, assetPathMap) {
|
|
5
|
+
var content = _content;
|
|
6
|
+
assetPathMap.forEach(function (pathEntry) {
|
|
7
|
+
content = content.replace(new RegExp(pathEntry.source, 'g'), pathEntry.target);
|
|
8
|
+
});
|
|
9
|
+
return content;
|
|
10
|
+
};
|
|
11
|
+
exports.modifyLinksInContent = modifyLinksInContent;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates index service file for SAS9 server only.
|
|
3
|
+
* @param {string} indexHtmlContent contents of index source file.
|
|
4
|
+
* @param {string} fileName name of index service file.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createClickMeService: (indexHtmlContent: string, fileName: string) => Promise<void>;
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
exports.createClickMeService = void 0;
|
|
43
|
+
var path_1 = __importDefault(require("path"));
|
|
44
|
+
var utils_1 = require("@sasjs/utils");
|
|
45
|
+
var sasjsout_1 = require("../sasjsout");
|
|
46
|
+
/**
|
|
47
|
+
* Creates index service file for SAS9 server only.
|
|
48
|
+
* @param {string} indexHtmlContent contents of index source file.
|
|
49
|
+
* @param {string} fileName name of index service file.
|
|
50
|
+
*/
|
|
51
|
+
var createClickMeService = function (indexHtmlContent, fileName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
+
var lines, clickMeServiceContent, buildDestinationServicesFolder;
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
lines = indexHtmlContent.replace(/\r\n/g, '\n').split('\n');
|
|
57
|
+
clickMeServiceContent = "".concat((0, sasjsout_1.sasjsout)(), "\nfilename sasjs temp lrecl=99999999;\ndata _null_;\nfile sasjs;\n");
|
|
58
|
+
lines.forEach(function (line) {
|
|
59
|
+
var chunkedLines = (0, utils_1.chunk)(line);
|
|
60
|
+
if (chunkedLines.length === 1) {
|
|
61
|
+
if (chunkedLines[0].length == 0)
|
|
62
|
+
chunkedLines[0] = ' ';
|
|
63
|
+
clickMeServiceContent += "put '".concat(chunkedLines[0]
|
|
64
|
+
.split("'")
|
|
65
|
+
.join("''"), "';\n");
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
var combinedLines_1 = '';
|
|
69
|
+
chunkedLines.forEach(function (chunkedLine, index) {
|
|
70
|
+
var text = "put '".concat(chunkedLine.split("'").join("''"), "'");
|
|
71
|
+
if (index !== chunkedLines.length - 1) {
|
|
72
|
+
text += '@;\n';
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
text += ';\n';
|
|
76
|
+
}
|
|
77
|
+
combinedLines_1 += text;
|
|
78
|
+
});
|
|
79
|
+
clickMeServiceContent += combinedLines_1;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
clickMeServiceContent += 'run;\n%sasjsout(HTML)';
|
|
83
|
+
buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
|
|
84
|
+
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(buildDestinationServicesFolder, "".concat(fileName, ".sas")), clickMeServiceContent)];
|
|
85
|
+
case 1:
|
|
86
|
+
_a.sent();
|
|
87
|
+
return [2 /*return*/];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}); };
|
|
91
|
+
exports.createClickMeService = createClickMeService;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates service file for SAS9 server only.
|
|
3
|
+
* @param {string} sourcePath path of source file.
|
|
4
|
+
* @param {string} destinationPath path of destination service file.
|
|
5
|
+
* @returns {string} name of created service file.
|
|
6
|
+
*/
|
|
7
|
+
export declare const generateAssetService: (sourcePath: string, destinationPath: string) => Promise<string>;
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
exports.generateAssetService = void 0;
|
|
43
|
+
var path_1 = __importDefault(require("path"));
|
|
44
|
+
var utils_1 = require("@sasjs/utils");
|
|
45
|
+
var _1 = require("./");
|
|
46
|
+
/**
|
|
47
|
+
* Creates service file for SAS9 server only.
|
|
48
|
+
* @param {string} sourcePath path of source file.
|
|
49
|
+
* @param {string} destinationPath path of destination service file.
|
|
50
|
+
* @returns {string} name of created service file.
|
|
51
|
+
*/
|
|
52
|
+
var generateAssetService = function (sourcePath, destinationPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
53
|
+
var fileExtension, fileType, fileName, base64string, serviceContent;
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
switch (_a.label) {
|
|
56
|
+
case 0:
|
|
57
|
+
fileExtension = path_1.default.extname(sourcePath);
|
|
58
|
+
fileType = fileExtension.replace('.', '').toUpperCase();
|
|
59
|
+
fileName = path_1.default
|
|
60
|
+
.basename(sourcePath)
|
|
61
|
+
.replace(new RegExp(fileExtension + '$'), fileExtension.replace('.', '-'));
|
|
62
|
+
return [4 /*yield*/, (0, utils_1.base64EncodeFile)(sourcePath)];
|
|
63
|
+
case 1:
|
|
64
|
+
base64string = _a.sent();
|
|
65
|
+
return [4 /*yield*/, (0, _1.getWebServiceContent)(base64string, fileType)];
|
|
66
|
+
case 2:
|
|
67
|
+
serviceContent = _a.sent();
|
|
68
|
+
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(destinationPath, "".concat(fileName, ".sas")), serviceContent)];
|
|
69
|
+
case 3:
|
|
70
|
+
_a.sent();
|
|
71
|
+
return [2 /*return*/, "".concat(fileName, ".sas")];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}); };
|
|
75
|
+
exports.generateAssetService = generateAssetService;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prepares service code for SAS9 server only.
|
|
3
|
+
* @param {string} contentBase64 source code in base64.
|
|
4
|
+
* @param {string} type extension of source code's file in uppercase.
|
|
5
|
+
* @returns {string} service contents of provided source code.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getWebServiceContent: (contentBase64: string, type?: string) => Promise<string>;
|
package/build/commands/web/internal/{getWebServiceContent.js → sas9/getWebServiceContent.js}
RENAMED
|
@@ -38,8 +38,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getWebServiceContent = void 0;
|
|
40
40
|
var utils_1 = require("@sasjs/utils");
|
|
41
|
-
var sasjsout_1 = require("
|
|
42
|
-
|
|
41
|
+
var sasjsout_1 = require("../sasjsout");
|
|
42
|
+
/**
|
|
43
|
+
* Prepares service code for SAS9 server only.
|
|
44
|
+
* @param {string} contentBase64 source code in base64.
|
|
45
|
+
* @param {string} type extension of source code's file in uppercase.
|
|
46
|
+
* @returns {string} service contents of provided source code.
|
|
47
|
+
*/
|
|
48
|
+
var getWebServiceContent = function (contentBase64, type) {
|
|
43
49
|
if (type === void 0) { type = 'JS'; }
|
|
44
50
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
45
51
|
var lines, typesToEncode, serviceContent;
|
|
@@ -47,9 +53,10 @@ var getWebServiceContent = function (contentBase64, type, serverType) {
|
|
|
47
53
|
lines = [contentBase64];
|
|
48
54
|
typesToEncode = {
|
|
49
55
|
JS: 'JS64',
|
|
50
|
-
CSS: 'CSS64'
|
|
56
|
+
CSS: 'CSS64',
|
|
57
|
+
SVG: 'SVG64'
|
|
51
58
|
};
|
|
52
|
-
serviceContent = "".concat(sasjsout_1.sasjsout, "\nfilename sasjs temp lrecl=99999999;\ndata _null_;\nfile sasjs;\n");
|
|
59
|
+
serviceContent = "".concat((0, sasjsout_1.sasjsout)(), "\nfilename sasjs temp lrecl=99999999;\ndata _null_;\nfile sasjs;\n");
|
|
53
60
|
lines.forEach(function (line) {
|
|
54
61
|
var chunkedLines = (0, utils_1.chunk)(line);
|
|
55
62
|
if (chunkedLines.length === 1) {
|
|
@@ -70,12 +77,9 @@ var getWebServiceContent = function (contentBase64, type, serverType) {
|
|
|
70
77
|
serviceContent += combinedLines_1;
|
|
71
78
|
}
|
|
72
79
|
});
|
|
73
|
-
if (
|
|
80
|
+
if (typesToEncode.hasOwnProperty(type)) {
|
|
74
81
|
serviceContent += "\nrun;\n%sasjsout(".concat(typesToEncode[type], ")");
|
|
75
82
|
}
|
|
76
|
-
else {
|
|
77
|
-
serviceContent += "\nrun;\n%sasjsout(".concat(type, ")");
|
|
78
|
-
}
|
|
79
83
|
return [2 /*return*/, serviceContent];
|
|
80
84
|
});
|
|
81
85
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./createClickMeService"), exports);
|
|
14
|
+
__exportStar(require("./generateAssetService"), exports);
|
|
15
|
+
__exportStar(require("./getWebServiceContent"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates index file for SASVIYA server only.
|
|
3
|
+
* @param {string} indexHtmlContent contents of index file.
|
|
4
|
+
* @param {string} fileName name of index file.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createClickMeFile: (indexHtmlContent: string, fileName: string) => Promise<void>;
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
exports.createClickMeFile = void 0;
|
|
43
|
+
var utils_1 = require("@sasjs/utils");
|
|
44
|
+
var path_1 = __importDefault(require("path"));
|
|
45
|
+
/**
|
|
46
|
+
* Creates index file for SASVIYA server only.
|
|
47
|
+
* @param {string} indexHtmlContent contents of index file.
|
|
48
|
+
* @param {string} fileName name of index file.
|
|
49
|
+
*/
|
|
50
|
+
var createClickMeFile = function (indexHtmlContent, fileName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
+
var buildDestinationServicesFolder;
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0:
|
|
55
|
+
buildDestinationServicesFolder = process.sasjsConstants.buildDestinationServicesFolder;
|
|
56
|
+
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(buildDestinationServicesFolder, "".concat(fileName, ".html")), indexHtmlContent)];
|
|
57
|
+
case 1:
|
|
58
|
+
_a.sent();
|
|
59
|
+
return [2 /*return*/];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}); };
|
|
63
|
+
exports.createClickMeFile = createClickMeFile;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createClickMeFile';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./createClickMeFile"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const sasjsout
|
|
1
|
+
export declare const sasjsout: () => string;
|