@sasjs/cli 4.12.2 → 4.12.3
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/create/spec/reactAppFiles.js +2 -2
- 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/getTags.spec.d.ts +4 -0
- package/build/commands/web/internal/spec/getTags.spec.js +155 -0
- package/build/commands/web/internal/updateAllTags.js +10 -1
- package/build/commands/web/internal/updateLinkTag.js +3 -1
- package/build/commands/web/internal/updateScriptTag.js +3 -1
- package/build/commands/web/internal/updateStyleTag.js +3 -1
- package/package.json +1 -1
|
@@ -50,7 +50,7 @@ exports.reactAppFiles = {
|
|
|
50
50
|
{ fileName: 'data-page.component.tsx' },
|
|
51
51
|
{ fileName: 'home-page.component.tsx' },
|
|
52
52
|
{ fileName: 'login.component.tsx' },
|
|
53
|
-
{ fileName: 'request-modal.component.
|
|
53
|
+
{ fileName: 'request-modal.component.tsx' },
|
|
54
54
|
{ fileName: 'syntax-highlighting.css' },
|
|
55
55
|
{ fileName: 'user-name.component.tsx' }
|
|
56
56
|
],
|
|
@@ -73,7 +73,7 @@ exports.reactAppFiles = {
|
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
folderName: 'theme',
|
|
76
|
-
files: [{ fileName: 'index.
|
|
76
|
+
files: [{ fileName: 'index.ts' }],
|
|
77
77
|
subFolders: []
|
|
78
78
|
}
|
|
79
79
|
]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { JSDOM } from 'jsdom';
|
|
2
2
|
export declare const getSasjsTags: (parsedHtml: JSDOM) => Element[];
|
|
3
3
|
export declare const getScriptTags: (parsedHtml: JSDOM) => HTMLScriptElement[];
|
|
4
|
+
export declare const getModulePreload: (parsedHtml: JSDOM) => HTMLLinkElement[];
|
|
4
5
|
export declare const getStyleInPageTags: (parsedHtml: JSDOM) => HTMLStyleElement[];
|
|
5
6
|
export declare const getStyleTags: (parsedHtml: JSDOM) => HTMLLinkElement[];
|
|
6
7
|
export declare const getFaviconTags: (parsedHtml: JSDOM) => HTMLLinkElement[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getManifestTags = exports.getSourceTags = exports.getImgTags = exports.getFaviconTags = exports.getStyleTags = exports.getStyleInPageTags = exports.getScriptTags = exports.getSasjsTags = void 0;
|
|
3
|
+
exports.getManifestTags = exports.getSourceTags = exports.getImgTags = exports.getFaviconTags = exports.getStyleTags = exports.getStyleInPageTags = exports.getModulePreload = exports.getScriptTags = exports.getSasjsTags = void 0;
|
|
4
4
|
var getSasjsTags = function (parsedHtml) {
|
|
5
5
|
return Array.from(parsedHtml.window.document.getElementsByTagName('sasjs'));
|
|
6
6
|
};
|
|
@@ -9,6 +9,10 @@ var getScriptTags = function (parsedHtml) {
|
|
|
9
9
|
return Array.from(parsedHtml.window.document.getElementsByTagName('script'));
|
|
10
10
|
};
|
|
11
11
|
exports.getScriptTags = getScriptTags;
|
|
12
|
+
var getModulePreload = function (parsedHtml) {
|
|
13
|
+
return Array.from(parsedHtml.window.document.getElementsByTagName('link')).filter(function (s) { return s.getAttribute('rel') === 'modulepreload'; });
|
|
14
|
+
};
|
|
15
|
+
exports.getModulePreload = getModulePreload;
|
|
12
16
|
var getStyleInPageTags = function (parsedHtml) {
|
|
13
17
|
return Array.from(parsedHtml.window.document.getElementsByTagName('style'));
|
|
14
18
|
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @jest-environment jsdom
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var jsdom_1 = require("jsdom");
|
|
7
|
+
var getTags_1 = require("../getTags");
|
|
8
|
+
describe('getTags', function () {
|
|
9
|
+
// Helper function to create a JSDOM instance with given HTML
|
|
10
|
+
var createDOM = function (html) { return new jsdom_1.JSDOM("<!DOCTYPE html>".concat(html)); };
|
|
11
|
+
describe('getSasjsTags', function () {
|
|
12
|
+
it('should return all sasjs tags', function () {
|
|
13
|
+
var html = "\n <body>\n <sasjs id=\"sasjs1\"></sasjs>\n <sasjs id=\"sasjs2\"></sasjs>\n <div>Not a sasjs tag</div>\n </body>\n ";
|
|
14
|
+
var dom = createDOM(html);
|
|
15
|
+
var result = (0, getTags_1.getSasjsTags)(dom);
|
|
16
|
+
expect(result).toHaveLength(2);
|
|
17
|
+
expect(result[0].id).toBe('sasjs1');
|
|
18
|
+
expect(result[1].id).toBe('sasjs2');
|
|
19
|
+
});
|
|
20
|
+
it('should return empty array when no sasjs tags are present', function () {
|
|
21
|
+
var html = '<body><div>No sasjs tags here</div></body>';
|
|
22
|
+
var dom = createDOM(html);
|
|
23
|
+
var result = (0, getTags_1.getSasjsTags)(dom);
|
|
24
|
+
expect(result).toHaveLength(0);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('getScriptTags', function () {
|
|
28
|
+
it('should return all script tags', function () {
|
|
29
|
+
var html = "\n <head>\n <script id=\"script1\" src=\"script1.js\"></script>\n </head>\n <body>\n <script id=\"script2\" src=\"script2.js\"></script>\n <div>Not a script tag</div>\n </body>\n ";
|
|
30
|
+
var dom = createDOM(html);
|
|
31
|
+
var result = (0, getTags_1.getScriptTags)(dom);
|
|
32
|
+
expect(result).toHaveLength(2);
|
|
33
|
+
expect(result[0].id).toBe('script1');
|
|
34
|
+
expect(result[1].id).toBe('script2');
|
|
35
|
+
});
|
|
36
|
+
it('should return empty array when no script tags are present', function () {
|
|
37
|
+
var html = '<body><div>No script tags here</div></body>';
|
|
38
|
+
var dom = createDOM(html);
|
|
39
|
+
var result = (0, getTags_1.getScriptTags)(dom);
|
|
40
|
+
expect(result).toHaveLength(0);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
describe('getModulePreload', function () {
|
|
44
|
+
it('should return all link tags with rel="modulepreload"', function () {
|
|
45
|
+
var html = "\n <head>\n <link id=\"module1\" rel=\"modulepreload\" href=\"module1.js\">\n <link id=\"module2\" rel=\"modulepreload\" href=\"module2.js\">\n <link id=\"stylesheet\" rel=\"stylesheet\" href=\"style.css\">\n </head>\n ";
|
|
46
|
+
var dom = createDOM(html);
|
|
47
|
+
var result = (0, getTags_1.getModulePreload)(dom);
|
|
48
|
+
expect(result).toHaveLength(2);
|
|
49
|
+
expect(result[0].id).toBe('module1');
|
|
50
|
+
expect(result[1].id).toBe('module2');
|
|
51
|
+
});
|
|
52
|
+
it('should return empty array when no modulepreload links are present', function () {
|
|
53
|
+
var html = '<head><link rel="stylesheet" href="style.css"></head>';
|
|
54
|
+
var dom = createDOM(html);
|
|
55
|
+
var result = (0, getTags_1.getModulePreload)(dom);
|
|
56
|
+
expect(result).toHaveLength(0);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('getStyleInPageTags', function () {
|
|
60
|
+
it('should return all style tags', function () {
|
|
61
|
+
var html = "\n <head>\n <style id=\"style1\">.class1 { color: red; }</style>\n <style id=\"style2\">.class2 { color: blue; }</style>\n </head>\n <body>\n <div>Not a style tag</div>\n </body>\n ";
|
|
62
|
+
var dom = createDOM(html);
|
|
63
|
+
var result = (0, getTags_1.getStyleInPageTags)(dom);
|
|
64
|
+
expect(result).toHaveLength(2);
|
|
65
|
+
expect(result[0].id).toBe('style1');
|
|
66
|
+
expect(result[1].id).toBe('style2');
|
|
67
|
+
});
|
|
68
|
+
it('should return empty array when no style tags are present', function () {
|
|
69
|
+
var html = '<body><div>No style tags here</div></body>';
|
|
70
|
+
var dom = createDOM(html);
|
|
71
|
+
var result = (0, getTags_1.getStyleInPageTags)(dom);
|
|
72
|
+
expect(result).toHaveLength(0);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
describe('getStyleTags', function () {
|
|
76
|
+
it('should return all link tags with rel="stylesheet"', function () {
|
|
77
|
+
var html = "\n <head>\n <link id=\"css1\" rel=\"stylesheet\" href=\"style1.css\">\n <link id=\"css2\" rel=\"stylesheet\" href=\"style2.css\">\n <link id=\"icon\" rel=\"icon\" href=\"favicon.ico\">\n </head>\n ";
|
|
78
|
+
var dom = createDOM(html);
|
|
79
|
+
var result = (0, getTags_1.getStyleTags)(dom);
|
|
80
|
+
expect(result).toHaveLength(2);
|
|
81
|
+
expect(result[0].id).toBe('css1');
|
|
82
|
+
expect(result[1].id).toBe('css2');
|
|
83
|
+
});
|
|
84
|
+
it('should return empty array when no stylesheet links are present', function () {
|
|
85
|
+
var html = '<head><link rel="icon" href="favicon.ico"></head>';
|
|
86
|
+
var dom = createDOM(html);
|
|
87
|
+
var result = (0, getTags_1.getStyleTags)(dom);
|
|
88
|
+
expect(result).toHaveLength(0);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
describe('getFaviconTags', function () {
|
|
92
|
+
it('should return all link tags with rel containing "icon"', function () {
|
|
93
|
+
var html = "\n <head>\n <link id=\"icon1\" rel=\"icon\" href=\"favicon.ico\">\n <link id=\"icon2\" rel=\"apple-touch-icon\" href=\"apple-touch-icon.png\">\n <link id=\"css\" rel=\"stylesheet\" href=\"style.css\">\n </head>\n ";
|
|
94
|
+
var dom = createDOM(html);
|
|
95
|
+
var result = (0, getTags_1.getFaviconTags)(dom);
|
|
96
|
+
expect(result).toHaveLength(2);
|
|
97
|
+
expect(result[0].id).toBe('icon1');
|
|
98
|
+
expect(result[1].id).toBe('icon2');
|
|
99
|
+
});
|
|
100
|
+
it('should return empty array when no icon links are present', function () {
|
|
101
|
+
var html = '<head><link rel="stylesheet" href="style.css"></head>';
|
|
102
|
+
var dom = createDOM(html);
|
|
103
|
+
var result = (0, getTags_1.getFaviconTags)(dom);
|
|
104
|
+
expect(result).toHaveLength(0);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
describe('getImgTags', function () {
|
|
108
|
+
it('should return all img tags with src attribute', function () {
|
|
109
|
+
var html = "\n <body>\n <img id=\"img1\" src=\"image1.jpg\">\n <img id=\"img2\" src=\"image2.jpg\">\n <img id=\"img3\">\n </body>\n ";
|
|
110
|
+
var dom = createDOM(html);
|
|
111
|
+
var result = (0, getTags_1.getImgTags)(dom);
|
|
112
|
+
expect(result).toHaveLength(2);
|
|
113
|
+
expect(result[0].id).toBe('img1');
|
|
114
|
+
expect(result[1].id).toBe('img2');
|
|
115
|
+
});
|
|
116
|
+
it('should return empty array when no img tags with src are present', function () {
|
|
117
|
+
var html = '<body><img id="noSrc"></body>';
|
|
118
|
+
var dom = createDOM(html);
|
|
119
|
+
var result = (0, getTags_1.getImgTags)(dom);
|
|
120
|
+
expect(result).toHaveLength(0);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
describe('getSourceTags', function () {
|
|
124
|
+
it('should return all source tags with src attribute', function () {
|
|
125
|
+
var html = "\n <body>\n <audio>\n <source id=\"source1\" src=\"audio.mp3\" type=\"audio/mpeg\">\n </audio>\n <video>\n <source id=\"source2\" src=\"video.mp4\" type=\"video/mp4\">\n <source id=\"source3\">\n </video>\n </body>\n ";
|
|
126
|
+
var dom = createDOM(html);
|
|
127
|
+
var result = (0, getTags_1.getSourceTags)(dom);
|
|
128
|
+
expect(result).toHaveLength(2);
|
|
129
|
+
expect(result[0].id).toBe('source1');
|
|
130
|
+
expect(result[1].id).toBe('source2');
|
|
131
|
+
});
|
|
132
|
+
it('should return empty array when no source tags with src are present', function () {
|
|
133
|
+
var html = '<body><source id="noSrc"></body>';
|
|
134
|
+
var dom = createDOM(html);
|
|
135
|
+
var result = (0, getTags_1.getSourceTags)(dom);
|
|
136
|
+
expect(result).toHaveLength(0);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
describe('getManifestTags', function () {
|
|
140
|
+
it('should return all link tags with rel="manifest"', function () {
|
|
141
|
+
var html = "\n <head>\n <link id=\"manifest1\" rel=\"manifest\" href=\"manifest.json\">\n <link id=\"manifest2\" rel=\"manifest\" href=\"another-manifest.json\">\n <link id=\"css\" rel=\"stylesheet\" href=\"style.css\">\n </head>\n ";
|
|
142
|
+
var dom = createDOM(html);
|
|
143
|
+
var result = (0, getTags_1.getManifestTags)(dom);
|
|
144
|
+
expect(result).toHaveLength(2);
|
|
145
|
+
expect(result[0].id).toBe('manifest1');
|
|
146
|
+
expect(result[1].id).toBe('manifest2');
|
|
147
|
+
});
|
|
148
|
+
it('should return empty array when no manifest links are present', function () {
|
|
149
|
+
var html = '<head><link rel="stylesheet" href="style.css"></head>';
|
|
150
|
+
var dom = createDOM(html);
|
|
151
|
+
var result = (0, getTags_1.getManifestTags)(dom);
|
|
152
|
+
expect(result).toHaveLength(0);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
});
|
|
@@ -76,7 +76,7 @@ var updateSasjsTag_1 = require("./updateSasjsTag");
|
|
|
76
76
|
var updateAllTags = function (parsedHtml, target, _a) {
|
|
77
77
|
var webSourcePathFull = _a.webSourcePathFull, destinationPath = _a.destinationPath, serverType = _a.serverType, assetPathMap = _a.assetPathMap;
|
|
78
78
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
-
var assetsNotFound, sasjsTags, scriptTags, styleExternalTags, styleInPageTags, styleTags, faviconTags, manifestTags, imgTags, sourceTags, srcTags, notFoundErrors;
|
|
79
|
+
var assetsNotFound, sasjsTags, scriptTags, modulePreloadTags, styleExternalTags, styleInPageTags, styleTags, faviconTags, manifestTags, imgTags, sourceTags, srcTags, notFoundErrors;
|
|
80
80
|
return __generator(this, function (_b) {
|
|
81
81
|
switch (_b.label) {
|
|
82
82
|
case 0:
|
|
@@ -98,6 +98,15 @@ var updateAllTags = function (parsedHtml, target, _a) {
|
|
|
98
98
|
}); })];
|
|
99
99
|
case 1:
|
|
100
100
|
_b.sent();
|
|
101
|
+
modulePreloadTags = (0, getTags_1.getModulePreload)(parsedHtml);
|
|
102
|
+
modulePreloadTags.forEach(function (tag) {
|
|
103
|
+
try {
|
|
104
|
+
(0, updateLinkTag_1.updateLinkTag)(tag, assetPathMap);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
assetsNotFound.push(error);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
101
110
|
styleExternalTags = (0, getTags_1.getStyleTags)(parsedHtml);
|
|
102
111
|
styleInPageTags = (0, getTags_1.getStyleInPageTags)(parsedHtml);
|
|
103
112
|
styleTags = __spreadArray(__spreadArray([], __read(styleExternalTags), false), __read(styleInPageTags), false);
|
|
@@ -12,7 +12,9 @@ var updateLinkTag = function (linkTag, assetPathMap, tagType) {
|
|
|
12
12
|
if (isUrl)
|
|
13
13
|
return;
|
|
14
14
|
var assetPath = assetPathMap.find(function (entry) {
|
|
15
|
-
return entry.source === linkSourcePath ||
|
|
15
|
+
return entry.source === linkSourcePath ||
|
|
16
|
+
"./".concat(entry.source) === linkSourcePath ||
|
|
17
|
+
"/".concat(entry.source) === linkSourcePath;
|
|
16
18
|
});
|
|
17
19
|
if (!(assetPath === null || assetPath === void 0 ? void 0 : assetPath.target)) {
|
|
18
20
|
throw new Error("Unable to find file: ".concat(linkSourcePath));
|
|
@@ -80,7 +80,9 @@ var updateScriptTag = function (tag, webSourcePathFull, destinationPath, serverT
|
|
|
80
80
|
case 7: throw new Error("Server Type: ".concat(serverType, " is not supported for updating script tag."));
|
|
81
81
|
case 8:
|
|
82
82
|
tag.setAttribute('src', assetPathMap.find(function (entry) {
|
|
83
|
-
return entry.source === scriptPath ||
|
|
83
|
+
return entry.source === scriptPath ||
|
|
84
|
+
"./".concat(entry.source) === scriptPath ||
|
|
85
|
+
"/".concat(entry.source) === scriptPath;
|
|
84
86
|
}).target);
|
|
85
87
|
_b.label = 9;
|
|
86
88
|
case 9: return [3 /*break*/, 11];
|
|
@@ -80,7 +80,9 @@ var updateStyleTag = function (tag, webSourcePathFull, destinationPath, serverTy
|
|
|
80
80
|
case 7: throw new Error("Server Type: ".concat(serverType, " is not supported for updating style tag."));
|
|
81
81
|
case 8:
|
|
82
82
|
tag.setAttribute('href', assetPathMap.find(function (entry) {
|
|
83
|
-
return entry.source === scriptPath ||
|
|
83
|
+
return entry.source === scriptPath ||
|
|
84
|
+
"./".concat(entry.source) === scriptPath ||
|
|
85
|
+
"/".concat(entry.source) === scriptPath;
|
|
84
86
|
}).target);
|
|
85
87
|
_b.label = 9;
|
|
86
88
|
case 9: return [3 /*break*/, 11];
|
package/package.json
CHANGED