@sasjs/cli 3.26.0 → 3.27.0
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/web/internal/getTags.d.ts +1 -0
- package/build/commands/web/internal/getTags.js +5 -1
- package/build/commands/web/internal/spec/updateSasjstag.spec.d.ts +4 -0
- package/build/commands/web/internal/spec/updateSasjstag.spec.js +61 -0
- package/build/commands/web/internal/updateAllTags.d.ts +2 -2
- package/build/commands/web/internal/updateAllTags.js +7 -2
- package/build/commands/web/internal/updateSasjsTag.d.ts +5 -0
- package/build/commands/web/internal/updateSasjsTag.js +11 -0
- package/build/commands/web/web.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JSDOM } from 'jsdom';
|
|
2
|
+
export declare const getSasjsTags: (parsedHtml: JSDOM) => Element[];
|
|
2
3
|
export declare const getScriptTags: (parsedHtml: JSDOM) => HTMLScriptElement[];
|
|
3
4
|
export declare const getStyleInPageTags: (parsedHtml: JSDOM) => HTMLStyleElement[];
|
|
4
5
|
export declare const getStyleTags: (parsedHtml: JSDOM) => HTMLLinkElement[];
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSourceTags = exports.getImgTags = exports.getFaviconTags = exports.getStyleTags = exports.getStyleInPageTags = exports.getScriptTags = void 0;
|
|
3
|
+
exports.getSourceTags = exports.getImgTags = exports.getFaviconTags = exports.getStyleTags = exports.getStyleInPageTags = exports.getScriptTags = exports.getSasjsTags = void 0;
|
|
4
|
+
var getSasjsTags = function (parsedHtml) {
|
|
5
|
+
return Array.from(parsedHtml.window.document.getElementsByTagName('sasjs'));
|
|
6
|
+
};
|
|
7
|
+
exports.getSasjsTags = getSasjsTags;
|
|
4
8
|
var getScriptTags = function (parsedHtml) {
|
|
5
9
|
return Array.from(parsedHtml.window.document.getElementsByTagName('script'));
|
|
6
10
|
};
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var utils_1 = require("@sasjs/utils");
|
|
43
|
+
var updateSasjsTag_1 = require("../updateSasjsTag");
|
|
44
|
+
describe('updateSasjsTag', function () {
|
|
45
|
+
it("should update links in js script", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var target, tag;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
target = {
|
|
49
|
+
serverType: utils_1.ServerType.Sasjs,
|
|
50
|
+
appLoc: '/public/app/test'
|
|
51
|
+
};
|
|
52
|
+
tag = document.createElement('sasjs');
|
|
53
|
+
tag.setAttribute('appLoc', 'need/to/update');
|
|
54
|
+
tag.setAttribute('serverType', 'sas');
|
|
55
|
+
(0, updateSasjsTag_1.updateSasjsTag)(tag, target);
|
|
56
|
+
expect(tag.getAttribute('appLoc')).toEqual('/public/app/test');
|
|
57
|
+
expect(tag.getAttribute('serverType')).toEqual(utils_1.ServerType.Sasjs);
|
|
58
|
+
return [2 /*return*/];
|
|
59
|
+
});
|
|
60
|
+
}); });
|
|
61
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSDOM } from 'jsdom';
|
|
2
|
-
import { ServerType } from '@sasjs/utils';
|
|
2
|
+
import { ServerType, Target } from '@sasjs/utils';
|
|
3
3
|
import { AssetPathMap } from './createAssetServices';
|
|
4
4
|
interface paramsType {
|
|
5
5
|
webSourcePathFull: string;
|
|
@@ -12,5 +12,5 @@ interface paramsType {
|
|
|
12
12
|
* Also updates contents to update included asset references
|
|
13
13
|
* @param {JSDOM} parsedHtml- DOMWindow for index.html
|
|
14
14
|
*/
|
|
15
|
-
export declare const updateAllTags: (parsedHtml: JSDOM, { webSourcePathFull, destinationPath, serverType, assetPathMap }: paramsType) => Promise<void>;
|
|
15
|
+
export declare const updateAllTags: (parsedHtml: JSDOM, target: Target, { webSourcePathFull, destinationPath, serverType, assetPathMap }: paramsType) => Promise<void>;
|
|
16
16
|
export {};
|
|
@@ -67,19 +67,24 @@ var getTags_1 = require("./getTags");
|
|
|
67
67
|
var updateScriptTag_1 = require("./updateScriptTag");
|
|
68
68
|
var updateLinkTag_1 = require("./updateLinkTag");
|
|
69
69
|
var updateStyleTag_1 = require("./updateStyleTag");
|
|
70
|
+
var updateSasjsTag_1 = require("./updateSasjsTag");
|
|
70
71
|
/**
|
|
71
72
|
* Updates HTML Tags with correct link.
|
|
72
73
|
* Also updates contents to update included asset references
|
|
73
74
|
* @param {JSDOM} parsedHtml- DOMWindow for index.html
|
|
74
75
|
*/
|
|
75
|
-
var updateAllTags = function (parsedHtml, _a) {
|
|
76
|
+
var updateAllTags = function (parsedHtml, target, _a) {
|
|
76
77
|
var webSourcePathFull = _a.webSourcePathFull, destinationPath = _a.destinationPath, serverType = _a.serverType, assetPathMap = _a.assetPathMap;
|
|
77
78
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
-
var assetsNotFound, scriptTags, styleExternalTags, styleInPageTags, styleTags, faviconTags, imgTags, sourceTags, srcTags, notFoundErrors;
|
|
79
|
+
var assetsNotFound, sasjsTags, scriptTags, styleExternalTags, styleInPageTags, styleTags, faviconTags, imgTags, sourceTags, srcTags, notFoundErrors;
|
|
79
80
|
return __generator(this, function (_b) {
|
|
80
81
|
switch (_b.label) {
|
|
81
82
|
case 0:
|
|
82
83
|
assetsNotFound = [];
|
|
84
|
+
sasjsTags = (0, getTags_1.getSasjsTags)(parsedHtml);
|
|
85
|
+
if (sasjsTags.length) {
|
|
86
|
+
(0, updateSasjsTag_1.updateSasjsTag)(sasjsTags[0], target);
|
|
87
|
+
}
|
|
83
88
|
scriptTags = (0, getTags_1.getScriptTags)(parsedHtml);
|
|
84
89
|
return [4 /*yield*/, (0, utils_1.asyncForEach)(scriptTags, function (tag) { return __awaiter(void 0, void 0, void 0, function () {
|
|
85
90
|
return __generator(this, function (_a) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateSasjsTag = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Updates sasjs adapter's config in index.html if present.
|
|
6
|
+
*/
|
|
7
|
+
var updateSasjsTag = function (tag, target) {
|
|
8
|
+
tag.setAttribute('appLoc', target.appLoc);
|
|
9
|
+
tag.setAttribute('serverType', target.serverType);
|
|
10
|
+
};
|
|
11
|
+
exports.updateSasjsTag = updateSasjsTag;
|
|
@@ -98,7 +98,7 @@ function createWebAppServices(target) {
|
|
|
98
98
|
return [4 /*yield*/, (0, utils_1.readFile)(indexHtmlPath).then(function (content) { return new jsdom_1.default.JSDOM(content); })];
|
|
99
99
|
case 8:
|
|
100
100
|
indexHtml = _e.sent();
|
|
101
|
-
return [4 /*yield*/, (0, updateAllTags_1.updateAllTags)(indexHtml, {
|
|
101
|
+
return [4 /*yield*/, (0, updateAllTags_1.updateAllTags)(indexHtml, target, {
|
|
102
102
|
webSourcePathFull: webSourcePathFull,
|
|
103
103
|
destinationPath: destinationPath,
|
|
104
104
|
serverType: target.serverType,
|
package/package.json
CHANGED