@sasjs/cli 3.6.5 → 3.7.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/build/build.js +19 -34
- package/build/commands/deploy/deploy.d.ts +7 -0
- package/build/commands/deploy/deploy.js +105 -44
- package/build/commands/deploy/spec/cbd.spec.js +1 -1
- package/build/commands/job/internal/execute/sasjs.d.ts +1 -0
- package/build/commands/testing/spec/testing.spec.server.js +545 -308
- package/build/commands/testing/test.d.ts +3 -1
- package/build/commands/testing/test.js +166 -113
- package/build/commands/web/internal/getTags.d.ts +2 -0
- package/build/commands/web/internal/getTags.js +9 -1
- package/build/commands/web/internal/spec/testFiles/script3.d.ts +23 -0
- package/build/commands/web/internal/spec/testFiles/script3.js +218 -0
- package/build/commands/web/internal/spec/updateLinkTag.spec.js +1 -1
- package/build/commands/web/internal/spec/updateScriptTag.spec.js +146 -1
- package/build/commands/web/internal/spec/updateStyleTag.spec.d.ts +4 -0
- package/build/commands/web/internal/spec/updateStyleTag.spec.js +131 -0
- package/build/commands/web/internal/updateAllTags.js +22 -8
- package/build/commands/web/internal/updateLinkTag.d.ts +2 -2
- package/build/commands/web/internal/updateScriptTag.d.ts +1 -1
- package/build/commands/web/internal/updateScriptTag.js +21 -10
- package/build/commands/web/internal/updateStyleTag.d.ts +5 -0
- package/build/commands/web/internal/updateStyleTag.js +96 -0
- package/build/utils/config.js +4 -1
- package/package.json +2 -2
|
@@ -38,6 +38,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
42
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
43
|
+
if (!m) return o;
|
|
44
|
+
var i = m.call(o), r, ar = [], e;
|
|
45
|
+
try {
|
|
46
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
47
|
+
}
|
|
48
|
+
catch (error) { e = { error: error }; }
|
|
49
|
+
finally {
|
|
50
|
+
try {
|
|
51
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
52
|
+
}
|
|
53
|
+
finally { if (e) throw e.error; }
|
|
54
|
+
}
|
|
55
|
+
return ar;
|
|
56
|
+
};
|
|
57
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
58
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
59
|
+
if (ar || !(i in from)) {
|
|
60
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
61
|
+
ar[i] = from[i];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
65
|
+
};
|
|
41
66
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
42
67
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
68
|
};
|
|
@@ -79,7 +104,7 @@ describe('updateScriptTag', function () {
|
|
|
79
104
|
return __generator(this, function (_a) {
|
|
80
105
|
switch (_a.label) {
|
|
81
106
|
case 0:
|
|
82
|
-
scriptTag = document.createElement('
|
|
107
|
+
scriptTag = document.createElement('script');
|
|
83
108
|
sourcePath = path_1.default.join(__dirname, 'testFiles');
|
|
84
109
|
target = { serverType: utils_1.ServerType.Sas9 };
|
|
85
110
|
assetPathMap = [];
|
|
@@ -121,4 +146,124 @@ describe('updateScriptTag', function () {
|
|
|
121
146
|
}
|
|
122
147
|
});
|
|
123
148
|
}); });
|
|
149
|
+
it("should update links in js script", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
150
|
+
var sourcePath, gameTestFilePath, target, assetPathMap, scriptTag, _a, updatedContent;
|
|
151
|
+
return __generator(this, function (_b) {
|
|
152
|
+
switch (_b.label) {
|
|
153
|
+
case 0:
|
|
154
|
+
sourcePath = path_1.default.join(__dirname, 'testFiles');
|
|
155
|
+
gameTestFilePath = path_1.default.join(sourcePath, 'script3.js');
|
|
156
|
+
target = { serverType: utils_1.ServerType.SasViya };
|
|
157
|
+
assetPathMap = __spreadArray(__spreadArray([], __read(gameJSSpriteLinks), false), __read(gameJSSoundLinks), false);
|
|
158
|
+
scriptTag = document.createElement('script');
|
|
159
|
+
_a = scriptTag;
|
|
160
|
+
return [4 /*yield*/, (0, utils_1.readFile)(gameTestFilePath)];
|
|
161
|
+
case 1:
|
|
162
|
+
_a.innerHTML = _b.sent();
|
|
163
|
+
return [4 /*yield*/, (0, updateScriptTag_1.updateScriptTag)(scriptTag, sourcePath, destinationPath, target.serverType, assetPathMap)];
|
|
164
|
+
case 2:
|
|
165
|
+
_b.sent();
|
|
166
|
+
updatedContent = scriptTag.innerHTML;
|
|
167
|
+
gameJSSpriteLinks.forEach(function (link) {
|
|
168
|
+
return expect(updatedContent).toContain(link.target);
|
|
169
|
+
});
|
|
170
|
+
gameJSSoundLinks.forEach(function (link) {
|
|
171
|
+
return expect(updatedContent).toContain(link.target);
|
|
172
|
+
});
|
|
173
|
+
return [2 /*return*/];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}); });
|
|
124
177
|
});
|
|
178
|
+
var gameJSSpriteLinks = [
|
|
179
|
+
{
|
|
180
|
+
source: 'sprites/enemy.png',
|
|
181
|
+
target: 'link-to-compiled-webv/sprites/enemy.png'
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
source: 'sprites/enemyr.png',
|
|
185
|
+
target: 'link-to-compiled-webv/sprites/enemyr.png'
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
source: 'sprites/items.png',
|
|
189
|
+
target: 'link-to-compiled-webv/sprites/items.png'
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
source: 'sprites/player.png',
|
|
193
|
+
target: 'link-to-compiled-webv/sprites/player.png'
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
source: 'sprites/playerl.png',
|
|
197
|
+
target: 'link-to-compiled-webv/sprites/playerl.png'
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
source: 'sprites/tiles.png',
|
|
201
|
+
target: 'link-to-compiled-webv/sprites/tiles.png'
|
|
202
|
+
}
|
|
203
|
+
];
|
|
204
|
+
var gameJSSoundLinks = [
|
|
205
|
+
{
|
|
206
|
+
source: 'sounds/aboveground_bgm.ogg',
|
|
207
|
+
target: 'link-to-compiled-webv/sounds/aboveground_bgm.ogg'
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
source: 'sounds/breakblock.wav',
|
|
211
|
+
target: 'link-to-compiled-webv/sounds/breakblock.wav'
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
source: 'sounds/bump.wav',
|
|
215
|
+
target: 'link-to-compiled-webv/sounds/bump.wav'
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
source: 'sounds/coin.wav',
|
|
219
|
+
target: 'link-to-compiled-webv/sounds/coin.wav'
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
source: 'sounds/fireball.wav',
|
|
223
|
+
target: 'link-to-compiled-webv/sounds/fireball.wav'
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
source: 'sounds/flagpole.wav',
|
|
227
|
+
target: 'link-to-compiled-webv/sounds/flagpole.wav'
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
source: 'sounds/itemAppear.wav',
|
|
231
|
+
target: 'link-to-compiled-webv/sounds/itemAppear.wav'
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
source: 'sounds/jump-small.wav',
|
|
235
|
+
target: 'link-to-compiled-webv/sounds/jump-small.wav'
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
source: 'sounds/jump-super.wav',
|
|
239
|
+
target: 'link-to-compiled-webv/sounds/jump-super.wav'
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
source: 'sounds/kick.wav',
|
|
243
|
+
target: 'link-to-compiled-webv/sounds/kick.wav'
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
source: 'sounds/mariodie.wav',
|
|
247
|
+
target: 'link-to-compiled-webv/sounds/mariodie.wav'
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
source: 'sounds/pipe.wav',
|
|
251
|
+
target: 'link-to-compiled-webv/sounds/pipe.wav'
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
source: 'sounds/powerup.wav',
|
|
255
|
+
target: 'link-to-compiled-webv/sounds/powerup.wav'
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
source: 'sounds/stage_clear.wav',
|
|
259
|
+
target: 'link-to-compiled-webv/sounds/stage_clear.wav'
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
source: 'sounds/stomp.wav',
|
|
263
|
+
target: 'link-to-compiled-webv/sounds/stomp.wav'
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
source: 'sounds/underground_bgm.ogg',
|
|
267
|
+
target: 'link-to-compiled-webv/sounds/underground_bgm.ogg'
|
|
268
|
+
}
|
|
269
|
+
];
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @jest-environment jsdom
|
|
4
|
+
*/
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
15
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
16
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
17
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
18
|
+
function step(op) {
|
|
19
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
20
|
+
while (_) try {
|
|
21
|
+
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;
|
|
22
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
23
|
+
switch (op[0]) {
|
|
24
|
+
case 0: case 1: t = op; break;
|
|
25
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
26
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
27
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
28
|
+
default:
|
|
29
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
30
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
31
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
32
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
33
|
+
if (t[2]) _.ops.pop();
|
|
34
|
+
_.trys.pop(); continue;
|
|
35
|
+
}
|
|
36
|
+
op = body.call(thisArg, _);
|
|
37
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
38
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
42
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
43
|
+
if (!m) return o;
|
|
44
|
+
var i = m.call(o), r, ar = [], e;
|
|
45
|
+
try {
|
|
46
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
47
|
+
}
|
|
48
|
+
catch (error) { e = { error: error }; }
|
|
49
|
+
finally {
|
|
50
|
+
try {
|
|
51
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
52
|
+
}
|
|
53
|
+
finally { if (e) throw e.error; }
|
|
54
|
+
}
|
|
55
|
+
return ar;
|
|
56
|
+
};
|
|
57
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
58
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
59
|
+
if (ar || !(i in from)) {
|
|
60
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
61
|
+
ar[i] = from[i];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
65
|
+
};
|
|
66
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
67
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
68
|
+
};
|
|
69
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
+
var path_1 = __importDefault(require("path"));
|
|
71
|
+
var utils_1 = require("@sasjs/utils");
|
|
72
|
+
var updateStyleTag_1 = require("../updateStyleTag");
|
|
73
|
+
var utils_2 = require("../../../../utils");
|
|
74
|
+
describe('updateStyleTag', function () {
|
|
75
|
+
var destinationPath;
|
|
76
|
+
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
switch (_a.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
destinationPath = path_1.default.join(__dirname, "cli-test-web-updateStyleTag-".concat((0, utils_1.generateTimestamp)()));
|
|
81
|
+
return [4 /*yield*/, (0, utils_1.createFolder)(destinationPath)];
|
|
82
|
+
case 1:
|
|
83
|
+
_a.sent();
|
|
84
|
+
process.projectDir = destinationPath;
|
|
85
|
+
return [4 /*yield*/, (0, utils_2.setConstants)()];
|
|
86
|
+
case 2:
|
|
87
|
+
_a.sent();
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}); });
|
|
92
|
+
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0: return [4 /*yield*/, (0, utils_1.deleteFolder)(destinationPath)];
|
|
96
|
+
case 1:
|
|
97
|
+
_a.sent();
|
|
98
|
+
return [2 /*return*/];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}); });
|
|
102
|
+
it("should update links in css script", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
103
|
+
var sourcePath, styleFilePath, target, assetPathMap, scriptTag, _a, updatedContent;
|
|
104
|
+
return __generator(this, function (_b) {
|
|
105
|
+
switch (_b.label) {
|
|
106
|
+
case 0:
|
|
107
|
+
sourcePath = path_1.default.join(__dirname, 'testFiles');
|
|
108
|
+
styleFilePath = path_1.default.join(sourcePath, 'style1.css');
|
|
109
|
+
target = { serverType: utils_1.ServerType.SasViya };
|
|
110
|
+
assetPathMap = __spreadArray([], __read(assetLinks), false);
|
|
111
|
+
scriptTag = document.createElement('style');
|
|
112
|
+
_a = scriptTag;
|
|
113
|
+
return [4 /*yield*/, (0, utils_1.readFile)(styleFilePath)];
|
|
114
|
+
case 1:
|
|
115
|
+
_a.innerHTML = _b.sent();
|
|
116
|
+
return [4 /*yield*/, (0, updateStyleTag_1.updateStyleTag)(scriptTag, sourcePath, destinationPath, target.serverType, assetPathMap)];
|
|
117
|
+
case 2:
|
|
118
|
+
_b.sent();
|
|
119
|
+
updatedContent = scriptTag.innerHTML;
|
|
120
|
+
assetLinks.forEach(function (link) { return expect(updatedContent).toContain(link.target); });
|
|
121
|
+
return [2 /*return*/];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}); });
|
|
125
|
+
});
|
|
126
|
+
var assetLinks = [
|
|
127
|
+
{
|
|
128
|
+
source: 'assets/fa-solid-900.ttf',
|
|
129
|
+
target: 'link-to-compiled-webv/assets/fa-solid-900.ttf'
|
|
130
|
+
}
|
|
131
|
+
];
|
|
@@ -66,10 +66,11 @@ var utils_1 = require("@sasjs/utils");
|
|
|
66
66
|
var getTags_1 = require("./getTags");
|
|
67
67
|
var updateScriptTag_1 = require("./updateScriptTag");
|
|
68
68
|
var updateLinkTag_1 = require("./updateLinkTag");
|
|
69
|
+
var updateStyleTag_1 = require("./updateStyleTag");
|
|
69
70
|
var updateAllTags = function (parsedHtml, _a) {
|
|
70
71
|
var webSourcePathFull = _a.webSourcePathFull, destinationPath = _a.destinationPath, serverType = _a.serverType, assetPathMap = _a.assetPathMap;
|
|
71
72
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
-
var assetsNotFound, scriptTags, styleTags, faviconTags,
|
|
73
|
+
var assetsNotFound, scriptTags, styleExternalTags, styleInPageTags, styleTags, faviconTags, imgTags, sourceTags, srcTags, notFoundErrors;
|
|
73
74
|
return __generator(this, function (_b) {
|
|
74
75
|
switch (_b.label) {
|
|
75
76
|
case 0:
|
|
@@ -87,25 +88,38 @@ var updateAllTags = function (parsedHtml, _a) {
|
|
|
87
88
|
}); })];
|
|
88
89
|
case 1:
|
|
89
90
|
_b.sent();
|
|
90
|
-
|
|
91
|
+
styleExternalTags = (0, getTags_1.getStyleTags)(parsedHtml);
|
|
92
|
+
styleInPageTags = (0, getTags_1.getStyleInPageTags)(parsedHtml);
|
|
93
|
+
styleTags = __spreadArray(__spreadArray([], __read(styleExternalTags), false), __read(styleInPageTags), false);
|
|
94
|
+
return [4 /*yield*/, (0, utils_1.asyncForEach)(styleTags, function (tag) { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
switch (_a.label) {
|
|
97
|
+
case 0: return [4 /*yield*/, (0, updateStyleTag_1.updateStyleTag)(tag, webSourcePathFull, destinationPath, serverType, assetPathMap).catch(function (e) { return assetsNotFound.push(e); })];
|
|
98
|
+
case 1:
|
|
99
|
+
_a.sent();
|
|
100
|
+
return [2 /*return*/];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}); })];
|
|
104
|
+
case 2:
|
|
105
|
+
_b.sent();
|
|
91
106
|
faviconTags = (0, getTags_1.getFaviconTags)(parsedHtml);
|
|
92
|
-
|
|
93
|
-
linkTags.forEach(function (tag) {
|
|
107
|
+
faviconTags.forEach(function (tag) {
|
|
94
108
|
try {
|
|
95
109
|
(0, updateLinkTag_1.updateLinkTag)(tag, assetPathMap);
|
|
96
110
|
}
|
|
97
111
|
catch (error) {
|
|
98
|
-
console.log(tag, error);
|
|
99
112
|
assetsNotFound.push(error);
|
|
100
113
|
}
|
|
101
114
|
});
|
|
102
115
|
imgTags = (0, getTags_1.getImgTags)(parsedHtml);
|
|
103
|
-
|
|
116
|
+
sourceTags = (0, getTags_1.getSourceTags)(parsedHtml);
|
|
117
|
+
srcTags = __spreadArray(__spreadArray([], __read(imgTags), false), __read(sourceTags), false);
|
|
118
|
+
srcTags.forEach(function (tag) {
|
|
104
119
|
try {
|
|
105
|
-
(0, updateLinkTag_1.updateLinkTag)(tag, assetPathMap, '
|
|
120
|
+
(0, updateLinkTag_1.updateLinkTag)(tag, assetPathMap, 'src');
|
|
106
121
|
}
|
|
107
122
|
catch (error) {
|
|
108
|
-
console.log(tag, error);
|
|
109
123
|
assetsNotFound.push(error);
|
|
110
124
|
}
|
|
111
125
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const updateLinkTag: (linkTag: HTMLLinkElement | HTMLImageElement, assetPathMap: {
|
|
1
|
+
export declare const updateLinkTag: (linkTag: HTMLLinkElement | HTMLSourceElement | HTMLImageElement, assetPathMap: {
|
|
2
2
|
source: string;
|
|
3
3
|
target: string;
|
|
4
|
-
}[], tagType?: 'link' | '
|
|
4
|
+
}[], tagType?: 'link' | 'src') => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServerType } from '@sasjs/utils';
|
|
2
|
-
export declare const updateScriptTag: (tag:
|
|
2
|
+
export declare const updateScriptTag: (tag: HTMLScriptElement, webSourcePathFull: string, destinationPath: string, serverType: ServerType, assetPathMap: {
|
|
3
3
|
source: string;
|
|
4
4
|
target: string;
|
|
5
5
|
}[]) => Promise<void>;
|
|
@@ -45,28 +45,26 @@ var utils_1 = require("@sasjs/utils");
|
|
|
45
45
|
var js_base64_1 = require("js-base64");
|
|
46
46
|
var getWebServiceContent_1 = require("./getWebServiceContent");
|
|
47
47
|
var updateScriptTag = function (tag, webSourcePathFull, destinationPath, serverType, assetPathMap) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
-
var scriptPath, isUrl,
|
|
48
|
+
var scriptPath, isUrl, _content, content, serviceContent, _content, content;
|
|
49
49
|
return __generator(this, function (_a) {
|
|
50
50
|
switch (_a.label) {
|
|
51
51
|
case 0:
|
|
52
52
|
scriptPath = tag.getAttribute('src');
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
if (!scriptPath) return [3 /*break*/, 8];
|
|
54
|
+
isUrl = scriptPath.startsWith('http') || scriptPath.startsWith('//');
|
|
55
55
|
if (!!isUrl) return [3 /*break*/, 7];
|
|
56
56
|
return [4 /*yield*/, (0, utils_1.readFile)(path_1.default.join(webSourcePathFull, scriptPath)).catch(function (_) {
|
|
57
57
|
throw new Error("Unable to find file: ".concat(scriptPath));
|
|
58
58
|
})];
|
|
59
59
|
case 1:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
content_1 = content_1.replace(new RegExp(pathEntry.source, 'g'), pathEntry.target);
|
|
63
|
-
});
|
|
60
|
+
_content = _a.sent();
|
|
61
|
+
content = modifyLinksInContent(_content, assetPathMap);
|
|
64
62
|
if (!(serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 3];
|
|
65
|
-
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(destinationPath, scriptPath),
|
|
63
|
+
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(destinationPath, scriptPath), content)];
|
|
66
64
|
case 2:
|
|
67
65
|
_a.sent();
|
|
68
66
|
return [3 /*break*/, 6];
|
|
69
|
-
case 3: return [4 /*yield*/, (0, getWebServiceContent_1.getWebServiceContent)((0, js_base64_1.encode)(
|
|
67
|
+
case 3: return [4 /*yield*/, (0, getWebServiceContent_1.getWebServiceContent)((0, js_base64_1.encode)(content), 'JS', serverType)];
|
|
70
68
|
case 4:
|
|
71
69
|
serviceContent = _a.sent();
|
|
72
70
|
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(destinationPath, "".concat(scriptPath.replace(/\.js$/, '-js'), ".sas")), serviceContent)];
|
|
@@ -78,8 +76,21 @@ var updateScriptTag = function (tag, webSourcePathFull, destinationPath, serverT
|
|
|
78
76
|
return entry.source === scriptPath || "./".concat(entry.source) === scriptPath;
|
|
79
77
|
}).target);
|
|
80
78
|
_a.label = 7;
|
|
81
|
-
case 7: return [
|
|
79
|
+
case 7: return [3 /*break*/, 9];
|
|
80
|
+
case 8:
|
|
81
|
+
_content = tag.innerHTML;
|
|
82
|
+
content = modifyLinksInContent(_content, assetPathMap);
|
|
83
|
+
tag.innerHTML = content;
|
|
84
|
+
_a.label = 9;
|
|
85
|
+
case 9: return [2 /*return*/];
|
|
82
86
|
}
|
|
83
87
|
});
|
|
84
88
|
}); };
|
|
85
89
|
exports.updateScriptTag = updateScriptTag;
|
|
90
|
+
var modifyLinksInContent = function (_content, assetPathMap) {
|
|
91
|
+
var content = _content;
|
|
92
|
+
assetPathMap.forEach(function (pathEntry) {
|
|
93
|
+
content = content.replace(new RegExp(pathEntry.source, 'g'), pathEntry.target);
|
|
94
|
+
});
|
|
95
|
+
return content;
|
|
96
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ServerType } from '@sasjs/utils';
|
|
2
|
+
export declare const updateStyleTag: (tag: HTMLStyleElement | HTMLLinkElement, webSourcePathFull: string, destinationPath: string, serverType: ServerType, assetPathMap: {
|
|
3
|
+
source: string;
|
|
4
|
+
target: string;
|
|
5
|
+
}[]) => Promise<void>;
|
|
@@ -0,0 +1,96 @@
|
|
|
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.updateStyleTag = void 0;
|
|
43
|
+
var path_1 = __importDefault(require("path"));
|
|
44
|
+
var utils_1 = require("@sasjs/utils");
|
|
45
|
+
var js_base64_1 = require("js-base64");
|
|
46
|
+
var getWebServiceContent_1 = require("./getWebServiceContent");
|
|
47
|
+
var updateStyleTag = function (tag, webSourcePathFull, destinationPath, serverType, assetPathMap) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
+
var scriptPath, isUrl, _content, content, serviceContent, _content, content;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
scriptPath = tag.getAttribute('href');
|
|
53
|
+
if (!scriptPath) return [3 /*break*/, 8];
|
|
54
|
+
isUrl = scriptPath.startsWith('http') || scriptPath.startsWith('//');
|
|
55
|
+
if (!!isUrl) return [3 /*break*/, 7];
|
|
56
|
+
return [4 /*yield*/, (0, utils_1.readFile)(path_1.default.join(webSourcePathFull, scriptPath)).catch(function (_) {
|
|
57
|
+
throw new Error("Unable to find file: ".concat(scriptPath));
|
|
58
|
+
})];
|
|
59
|
+
case 1:
|
|
60
|
+
_content = _a.sent();
|
|
61
|
+
content = modifyLinksInContent(_content, assetPathMap);
|
|
62
|
+
if (!(serverType === utils_1.ServerType.SasViya)) return [3 /*break*/, 3];
|
|
63
|
+
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(destinationPath, scriptPath), content)];
|
|
64
|
+
case 2:
|
|
65
|
+
_a.sent();
|
|
66
|
+
return [3 /*break*/, 6];
|
|
67
|
+
case 3: return [4 /*yield*/, (0, getWebServiceContent_1.getWebServiceContent)((0, js_base64_1.encode)(content), 'CSS', serverType)];
|
|
68
|
+
case 4:
|
|
69
|
+
serviceContent = _a.sent();
|
|
70
|
+
return [4 /*yield*/, (0, utils_1.createFile)(path_1.default.join(destinationPath, "".concat(scriptPath.replace(/\.js$/, '-js'), ".sas")), serviceContent)];
|
|
71
|
+
case 5:
|
|
72
|
+
_a.sent();
|
|
73
|
+
_a.label = 6;
|
|
74
|
+
case 6:
|
|
75
|
+
tag.setAttribute('href', assetPathMap.find(function (entry) {
|
|
76
|
+
return entry.source === scriptPath || "./".concat(entry.source) === scriptPath;
|
|
77
|
+
}).target);
|
|
78
|
+
_a.label = 7;
|
|
79
|
+
case 7: return [3 /*break*/, 9];
|
|
80
|
+
case 8:
|
|
81
|
+
_content = tag.innerHTML;
|
|
82
|
+
content = modifyLinksInContent(_content, assetPathMap);
|
|
83
|
+
tag.innerHTML = content;
|
|
84
|
+
_a.label = 9;
|
|
85
|
+
case 9: return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); };
|
|
89
|
+
exports.updateStyleTag = updateStyleTag;
|
|
90
|
+
var modifyLinksInContent = function (_content, assetPathMap) {
|
|
91
|
+
var content = _content;
|
|
92
|
+
assetPathMap.forEach(function (pathEntry) {
|
|
93
|
+
content = content.replace(new RegExp(pathEntry.source, 'g'), pathEntry.target);
|
|
94
|
+
});
|
|
95
|
+
return content;
|
|
96
|
+
};
|
package/build/utils/config.js
CHANGED
|
@@ -830,7 +830,10 @@ function getAuthConfig(target) {
|
|
|
830
830
|
? undefined
|
|
831
831
|
: secret;
|
|
832
832
|
if (!secret) {
|
|
833
|
-
|
|
833
|
+
if (target.serverType === utils_1.ServerType.Sasjs)
|
|
834
|
+
secret = '';
|
|
835
|
+
else
|
|
836
|
+
throw new Error("Client secret was not found.\n Please make sure that the 'secret' property is set in your local .env file or in the correct target authConfig in your global ~".concat(path_1.default.sep, ".sasjsrc file."));
|
|
834
837
|
}
|
|
835
838
|
if (!(0, auth_1.isAccessTokenExpiring)(access_token)) return [3 /*break*/, 7];
|
|
836
839
|
sasjs = new node_1.default({
|
package/package.json
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@sasjs/adapter": "3.
|
|
52
|
+
"@sasjs/adapter": "3.5.0",
|
|
53
53
|
"@sasjs/core": "3.10.0",
|
|
54
54
|
"@sasjs/lint": "1.11.2",
|
|
55
55
|
"@sasjs/utils": "2.36.0",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"typescript": "4.5.4",
|
|
98
98
|
"util": "0.12.4"
|
|
99
99
|
},
|
|
100
|
-
"version": "3.
|
|
100
|
+
"version": "3.7.1"
|
|
101
101
|
}
|