@quintype/framework 6.3.0 → 7.0.1-enable-webengage.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/CHANGELOG.md +9 -0
- package/package.json +47 -46
- package/server/amp/helpers/infinite-scroll.js +5 -1
- package/server/publisher-config.js +1 -1
- package/server/start.js +9 -5
- package/server/static-configuration.js +1 -1
- package/server/utils/apm.js +7 -0
- package/test/unit/amp/infinite-scroll-helper.js +40 -20
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [7.0.0](https://github.com/quintype/quintype-node-framework/compare/v6.3.1...v7.0.0) (2021-11-30)
|
|
6
|
+
|
|
7
|
+
### [6.3.1](https://github.com/quintype/quintype-node-framework/compare/v6.3.0...v6.3.1) (2021-11-25)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* remove visual stories from amp infinite scroll ([#282](https://github.com/quintype/quintype-node-framework/issues/282)) ([719f048](https://github.com/quintype/quintype-node-framework/commit/719f0482bcd730604dcc4273cf2e8465f2232fb6))
|
|
13
|
+
|
|
5
14
|
## [6.3.0](https://github.com/quintype/quintype-node-framework/compare/v6.2.0...v6.3.0) (2021-11-18)
|
|
6
15
|
|
|
7
16
|
## [6.2.0](https://github.com/quintype/quintype-node-framework/compare/v5.0.5...v6.2.0) (2021-10-11)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintype/framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1-enable-webengage.1",
|
|
4
4
|
"description": "Libraries to help build Quintype Node.js apps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,75 +26,76 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/quintype/quintype-node-framework#readme",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ampproject/toolbox-optimizer": "2.8.
|
|
30
|
-
"@quintype/amp": "^2.4.
|
|
29
|
+
"@ampproject/toolbox-optimizer": "2.8.3",
|
|
30
|
+
"@quintype/amp": "^2.4.16-enable-webengage.0",
|
|
31
31
|
"@quintype/backend": "^2.1.0",
|
|
32
|
-
"@quintype/components": "^
|
|
32
|
+
"@quintype/components": "^3.0.0",
|
|
33
33
|
"@quintype/prerender-node": "^3.2.24",
|
|
34
34
|
"@quintype/seo": "^1.38.1",
|
|
35
35
|
"atob": "^2.1.2",
|
|
36
|
+
"chalk": "^4.1.2",
|
|
36
37
|
"cluster": "^0.7.7",
|
|
37
38
|
"compression": "^1.7.4",
|
|
38
|
-
"ejs": "^
|
|
39
|
-
"express": "^4.
|
|
40
|
-
"firebase": "^
|
|
39
|
+
"ejs": "^3.1.6",
|
|
40
|
+
"express": "^4.17.1",
|
|
41
|
+
"firebase": "^9.1.1",
|
|
41
42
|
"get-youtube-id": "^1.0.1",
|
|
42
43
|
"grpc": "^1.21.1",
|
|
43
|
-
"http-proxy": "^1.
|
|
44
|
-
"js-yaml": "^
|
|
45
|
-
"lodash": "^4.17.
|
|
44
|
+
"http-proxy": "^1.18.1",
|
|
45
|
+
"js-yaml": "^4.1.0",
|
|
46
|
+
"lodash": "^4.17.21",
|
|
46
47
|
"mocha-snapshots": "^4.2.0",
|
|
47
|
-
"morgan": "^1.
|
|
48
|
+
"morgan": "^1.10.0",
|
|
48
49
|
"path-to-regexp": "^6.2.0",
|
|
49
|
-
"react": "^16.
|
|
50
|
-
"react-dom": "^16.
|
|
51
|
-
"react-redux": "^7.
|
|
52
|
-
"react-router": "^5.
|
|
53
|
-
"redux": "^4.
|
|
50
|
+
"react": "^16.14.0",
|
|
51
|
+
"react-dom": "^16.14.0",
|
|
52
|
+
"react-redux": "^7.2.5",
|
|
53
|
+
"react-router": "^5.2.1",
|
|
54
|
+
"redux": "^4.1.1",
|
|
54
55
|
"request-promise": "^4.2.6",
|
|
55
|
-
"sleep-promise": "^
|
|
56
|
-
"winston": "3.
|
|
56
|
+
"sleep-promise": "^9.1.0",
|
|
57
|
+
"winston": "3.3.3"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@babel/eslint-parser": "^7.
|
|
60
|
-
"@loadable/component": "^5.
|
|
61
|
-
"@loadable/server": "^5.
|
|
62
|
-
"@quintype/build": "^3.13.
|
|
60
|
+
"@babel/eslint-parser": "^7.15.7",
|
|
61
|
+
"@loadable/component": "^5.15.0",
|
|
62
|
+
"@loadable/server": "^5.15.1",
|
|
63
|
+
"@quintype/build": "^3.13.1",
|
|
63
64
|
"babel-plugin-quintype-assets": "^1.1.1",
|
|
64
|
-
"babel-plugin-react-css-modules": "^5.2.
|
|
65
|
+
"babel-plugin-react-css-modules": "^5.2.6",
|
|
65
66
|
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
|
|
66
67
|
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
|
67
68
|
"babel-preset-es2015": "^6.24.1",
|
|
68
69
|
"babel-preset-es2015-tree-shaking": "^1.0.1",
|
|
69
70
|
"babel-preset-react": "^6.24.1",
|
|
70
71
|
"babel-register": "^6.26.0",
|
|
71
|
-
"better-docs": "^
|
|
72
|
-
"eslint": "^
|
|
73
|
-
"eslint-config-prettier": "^
|
|
74
|
-
"eslint-config-standard": "^
|
|
75
|
-
"eslint-plugin-import": "^2.
|
|
76
|
-
"eslint-plugin-node": "^
|
|
77
|
-
"eslint-plugin-prettier": "^
|
|
78
|
-
"eslint-plugin-promise": "^
|
|
79
|
-
"eslint-plugin-react": "^7.
|
|
80
|
-
"eslint-plugin-standard": "^4.0
|
|
81
|
-
"gh-pages": "^2.
|
|
82
|
-
"history": "^
|
|
83
|
-
"husky": "^
|
|
84
|
-
"jsdoc": "^3.6.
|
|
85
|
-
"jsdom": "^
|
|
72
|
+
"better-docs": "^2.3.2",
|
|
73
|
+
"eslint": "^7.32.0",
|
|
74
|
+
"eslint-config-prettier": "^8.3.0",
|
|
75
|
+
"eslint-config-standard": "^16.0.3",
|
|
76
|
+
"eslint-plugin-import": "^2.24.2",
|
|
77
|
+
"eslint-plugin-node": "^11.1.0",
|
|
78
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
79
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
80
|
+
"eslint-plugin-react": "^7.26.1",
|
|
81
|
+
"eslint-plugin-standard": "^4.1.0",
|
|
82
|
+
"gh-pages": "^3.2.3",
|
|
83
|
+
"history": "^5.0.1",
|
|
84
|
+
"husky": "^7.0.2",
|
|
85
|
+
"jsdoc": "^3.6.7",
|
|
86
|
+
"jsdom": "^17.0.0",
|
|
86
87
|
"jsdom-global": "3.0.2",
|
|
87
|
-
"lint-staged": "^
|
|
88
|
-
"mocha": "^
|
|
89
|
-
"nyc": "^
|
|
90
|
-
"onchange": "^
|
|
88
|
+
"lint-staged": "^11.2.0",
|
|
89
|
+
"mocha": "^9.1.2",
|
|
90
|
+
"nyc": "^15.1.0",
|
|
91
|
+
"onchange": "^7.1.0",
|
|
91
92
|
"path": "^0.12.7",
|
|
92
|
-
"prettier": "^2.
|
|
93
|
-
"standard-version": "^
|
|
94
|
-
"supertest": "^
|
|
93
|
+
"prettier": "^2.4.1",
|
|
94
|
+
"standard-version": "^9.3.1",
|
|
95
|
+
"supertest": "^6.1.6"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
|
-
"@quintype/seo": "^1.
|
|
98
|
+
"@quintype/seo": "^1.39.0"
|
|
98
99
|
},
|
|
99
100
|
"nyc": {
|
|
100
101
|
"exclude": [
|
|
@@ -9,7 +9,11 @@ class InfiniteScrollAmp {
|
|
|
9
9
|
// eslint-disable-next-line class-methods-use-this
|
|
10
10
|
getFilteredCollItems(coll, storyId) {
|
|
11
11
|
return coll.items.filter(
|
|
12
|
-
({ type, story }) =>
|
|
12
|
+
({ type, story }) =>
|
|
13
|
+
type === "story" &&
|
|
14
|
+
story["story-content-id"] !== storyId &&
|
|
15
|
+
story.access !== "subscription" &&
|
|
16
|
+
story["story-template"] !== "visual-story"
|
|
13
17
|
);
|
|
14
18
|
}
|
|
15
19
|
|
package/server/start.js
CHANGED
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
// istanbul ignore file
|
|
11
11
|
// This is the start file, to be called from your start.js
|
|
12
12
|
|
|
13
|
+
const chalk = require('chalk');
|
|
13
14
|
const cluster = require("cluster");
|
|
14
15
|
const process = require("process");
|
|
15
16
|
const { initializeAllClients } = require("./api-client");
|
|
16
17
|
const logger = require("./logger");
|
|
18
|
+
const logSuccess = chalk.bold.cyanBright;
|
|
17
19
|
|
|
18
20
|
function startMaster({ workers = 4 }) {
|
|
19
21
|
let terminating = false;
|
|
@@ -62,7 +64,7 @@ function startMaster({ workers = 4 }) {
|
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
async function startWorker(appThunk, opts) {
|
|
65
|
-
if (process.env.NODE_ENV
|
|
67
|
+
if (process.env.NODE_ENV !== "production") {
|
|
66
68
|
require("@quintype/build")(opts);
|
|
67
69
|
}
|
|
68
70
|
require("../assetify/server")();
|
|
@@ -71,9 +73,11 @@ async function startWorker(appThunk, opts) {
|
|
|
71
73
|
const app = appThunk();
|
|
72
74
|
|
|
73
75
|
await initializeAllClients();
|
|
74
|
-
const server = app.listen(opts.port || 3000, () =>
|
|
75
|
-
console.log(
|
|
76
|
-
|
|
76
|
+
const server = app.listen(opts.port || 3000, () => {
|
|
77
|
+
console.log(logSuccess(`||=============================||`));
|
|
78
|
+
console.log(logSuccess(`|| App listening on port ${opts.port || 3000}! ||`))
|
|
79
|
+
console.log(logSuccess(`||=============================||`));
|
|
80
|
+
});
|
|
77
81
|
|
|
78
82
|
process.on("SIGTERM", () => {
|
|
79
83
|
server.close(() => {
|
|
@@ -83,7 +87,7 @@ async function startWorker(appThunk, opts) {
|
|
|
83
87
|
});
|
|
84
88
|
process.on("SIGHUP", () => {});
|
|
85
89
|
} catch (e) {
|
|
86
|
-
if (process.env.NODE_ENV
|
|
90
|
+
if (process.env.NODE_ENV !== "production") {
|
|
87
91
|
console.log(e.stack);
|
|
88
92
|
}
|
|
89
93
|
|
|
@@ -14,6 +14,7 @@ function getClientStub({
|
|
|
14
14
|
type: "story",
|
|
15
15
|
id: 1111,
|
|
16
16
|
story: {
|
|
17
|
+
"story-template": "text",
|
|
17
18
|
headline: "aaa",
|
|
18
19
|
"story-content-id": 1111,
|
|
19
20
|
slug: "sports/aa",
|
|
@@ -24,6 +25,7 @@ function getClientStub({
|
|
|
24
25
|
type: "story",
|
|
25
26
|
id: 2222,
|
|
26
27
|
story: {
|
|
28
|
+
"story-template": "visual-story",
|
|
27
29
|
headline: "bbb",
|
|
28
30
|
"story-content-id": 2222,
|
|
29
31
|
slug: "sports/bb",
|
|
@@ -34,6 +36,7 @@ function getClientStub({
|
|
|
34
36
|
type: "story",
|
|
35
37
|
id: 3333,
|
|
36
38
|
story: {
|
|
39
|
+
"story-template": "text",
|
|
37
40
|
headline: "ccc",
|
|
38
41
|
"story-content-id": 3333,
|
|
39
42
|
slug: "sports/cc",
|
|
@@ -44,6 +47,7 @@ function getClientStub({
|
|
|
44
47
|
type: "story",
|
|
45
48
|
id: 4444,
|
|
46
49
|
story: {
|
|
50
|
+
"story-template": "text",
|
|
47
51
|
headline: "ddd",
|
|
48
52
|
"story-content-id": 4444,
|
|
49
53
|
slug: "sports/dd",
|
|
@@ -54,6 +58,7 @@ function getClientStub({
|
|
|
54
58
|
type: "story",
|
|
55
59
|
id: 5555,
|
|
56
60
|
story: {
|
|
61
|
+
"story-template": "text",
|
|
57
62
|
headline: "eee",
|
|
58
63
|
"story-content-id": 5555,
|
|
59
64
|
slug: "sports/ee",
|
|
@@ -64,6 +69,7 @@ function getClientStub({
|
|
|
64
69
|
type: "story",
|
|
65
70
|
id: 6666,
|
|
66
71
|
story: {
|
|
72
|
+
"story-template": "text",
|
|
67
73
|
headline: "fff",
|
|
68
74
|
"story-content-id": 6666,
|
|
69
75
|
slug: "sports/ff",
|
|
@@ -150,6 +156,20 @@ describe("getInitialInlineConfig method of InfiniteScrollAmp helper function", f
|
|
|
150
156
|
assert.strictEqual(false, /sports\/bb/.test(inlineConfig));
|
|
151
157
|
assert.strictEqual(false, /bb\/b.jpg/.test(inlineConfig));
|
|
152
158
|
});
|
|
159
|
+
it("should remove visual stories from infinite scroll", async function () {
|
|
160
|
+
const clientStub = getClientStub();
|
|
161
|
+
const infiniteScrollAmp = new InfiniteScrollAmp({
|
|
162
|
+
ampConfig: {},
|
|
163
|
+
client: clientStub,
|
|
164
|
+
publisherConfig: dummyPublisherConfig,
|
|
165
|
+
});
|
|
166
|
+
const inlineConfig = await infiniteScrollAmp.getInitialInlineConfig({
|
|
167
|
+
itemsToTake: 5,
|
|
168
|
+
storyId: 3333,
|
|
169
|
+
});
|
|
170
|
+
assert.strictEqual(false, /sports\/bb/.test(inlineConfig));
|
|
171
|
+
assert.strictEqual(false, /bb\/b.jpg/.test(inlineConfig));
|
|
172
|
+
});
|
|
153
173
|
it("should format JSON as per AMP spec", async function () {
|
|
154
174
|
// https://amp.dev/documentation/components/amp-next-page/
|
|
155
175
|
const clientStub = getClientStub();
|
|
@@ -167,13 +187,7 @@ describe("getInitialInlineConfig method of InfiniteScrollAmp helper function", f
|
|
|
167
187
|
if (!stories.length) throw new Error("Can't verify empty array!");
|
|
168
188
|
stories.forEach((story) => {
|
|
169
189
|
const keys = Object.keys(story);
|
|
170
|
-
if (
|
|
171
|
-
keys.includes("image") &&
|
|
172
|
-
keys.includes("url") &&
|
|
173
|
-
keys.includes("title") &&
|
|
174
|
-
keys.length === 3
|
|
175
|
-
)
|
|
176
|
-
return;
|
|
190
|
+
if (keys.includes("image") && keys.includes("url") && keys.includes("title") && keys.length === 3) return;
|
|
177
191
|
throw new Error("Invalid InlineConfigStructure");
|
|
178
192
|
});
|
|
179
193
|
return true;
|
|
@@ -215,7 +229,7 @@ describe("getResponse method of InfiniteScrollAmp helper function", function ()
|
|
|
215
229
|
const jsonResponse = await infiniteScrollAmp.getResponse({ itemsTaken: 2 });
|
|
216
230
|
assert.strictEqual(jsonResponse instanceof Error, true);
|
|
217
231
|
});
|
|
218
|
-
it("should remove current story from response", async function() {
|
|
232
|
+
it("should remove current story from response", async function () {
|
|
219
233
|
const clientStub = getClientStub();
|
|
220
234
|
const infiniteScrollAmp = new InfiniteScrollAmp({
|
|
221
235
|
ampConfig: {},
|
|
@@ -226,8 +240,20 @@ describe("getResponse method of InfiniteScrollAmp helper function", function ()
|
|
|
226
240
|
const jsonResponse = await infiniteScrollAmp.getResponse({ itemsTaken: 2 });
|
|
227
241
|
assert.strictEqual(false, /sports\/dd/.test(jsonResponse));
|
|
228
242
|
assert.strictEqual(false, /dd\/d.jpg/.test(jsonResponse));
|
|
229
|
-
})
|
|
230
|
-
it("should
|
|
243
|
+
});
|
|
244
|
+
it("should remove visual stories from response", async function () {
|
|
245
|
+
const clientStub = getClientStub();
|
|
246
|
+
const infiniteScrollAmp = new InfiniteScrollAmp({
|
|
247
|
+
ampConfig: {},
|
|
248
|
+
client: clientStub,
|
|
249
|
+
publisherConfig: dummyPublisherConfig,
|
|
250
|
+
queryParams: { "story-id": 4444 },
|
|
251
|
+
});
|
|
252
|
+
const jsonResponse = await infiniteScrollAmp.getResponse({ itemsTaken: 2 });
|
|
253
|
+
assert.strictEqual(false, /sports\/bb/.test(jsonResponse));
|
|
254
|
+
assert.strictEqual(false, /bb\/b.jpg/.test(jsonResponse));
|
|
255
|
+
});
|
|
256
|
+
it("should format JSON as per AMP spec", async function () {
|
|
231
257
|
// https://amp.dev/documentation/components/amp-next-page/
|
|
232
258
|
const clientStub = getClientStub();
|
|
233
259
|
const infiniteScrollAmp = new InfiniteScrollAmp({
|
|
@@ -239,23 +265,17 @@ describe("getResponse method of InfiniteScrollAmp helper function", function ()
|
|
|
239
265
|
const jsonResponse = await infiniteScrollAmp.getResponse({ itemsTaken: 2 });
|
|
240
266
|
function isJsonConfigStructureValid(jsonStr) {
|
|
241
267
|
const parsed = JSON.parse(jsonStr);
|
|
242
|
-
const stories = parsed.pages
|
|
268
|
+
const stories = parsed.pages;
|
|
243
269
|
if (!stories.length) throw new Error("Can't verify empty array!");
|
|
244
270
|
stories.forEach((story) => {
|
|
245
271
|
const keys = Object.keys(story);
|
|
246
|
-
if (
|
|
247
|
-
keys.includes("image") &&
|
|
248
|
-
keys.includes("url") &&
|
|
249
|
-
keys.includes("title") &&
|
|
250
|
-
keys.length === 3
|
|
251
|
-
)
|
|
252
|
-
return;
|
|
272
|
+
if (keys.includes("image") && keys.includes("url") && keys.includes("title") && keys.length === 3) return;
|
|
253
273
|
throw new Error("Invalid InlineConfigStructure");
|
|
254
274
|
});
|
|
255
275
|
return true;
|
|
256
276
|
}
|
|
257
|
-
assert.strictEqual(isJsonConfigStructureValid(jsonResponse), true)
|
|
258
|
-
})
|
|
277
|
+
assert.strictEqual(isJsonConfigStructureValid(jsonResponse), true);
|
|
278
|
+
});
|
|
259
279
|
// it("should omit the first 'n' stories, take the rest", async function() {
|
|
260
280
|
// // this test needs to be written after https://github.com/quintype/quintype-node-framework/pull/202 is merged
|
|
261
281
|
// })
|