@contentstack/marketplace-sdk 1.2.5 → 1.2.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/marketplace-sdk",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "The Contentstack Marketplace SDK is used to manage the content of your Contentstack marketplace apps",
5
5
  "main": "./dist/node/contentstack-marketplace.js",
6
6
  "browser": "./dist/web/contentstack-marketplace.js",
@@ -27,7 +27,9 @@
27
27
  "buildnativescript": "webpack --config webpack/webpack.nativescript.js --mode production",
28
28
  "buildweb": "webpack --config webpack/webpack.web.js --mode production",
29
29
  "test": "npm run test:api && npm run test:unit",
30
- "test:api": "BABEL_ENV=test nyc --reporter=html --reporter=text mocha --require @babel/register ./test/test.js -t 30000 --reporter mochawesome --require babel-polyfill",
30
+ "test:sanity-test": "BABEL_ENV=test nyc --reporter=html mocha --require @babel/register ./test/sanity-check/sanity.js -t 30000 --reporter mochawesome --require babel-polyfill --reporter-options reportDir=mochawesome-report,reportFilename=mochawesome.json",
31
+ "test:sanity": "npm run test:sanity-test || true",
32
+ "test:sanity-report": "marge mochawesome-report/mochawesome.json -f sanity-report.html --inline && node sanity-report.mjs",
31
33
  "test:unit": "BABEL_ENV=test nyc --reporter=html --reporter=text mocha --require @babel/register ./test/unit/index.js -t 30000 --reporter mochawesome --require babel-polyfill",
32
34
  "test:unit:report:json": "BABEL_ENV=test nyc --reporter=clover --reporter=text mocha --require @babel/register ./test/unit/index.js -t 30000 --reporter json --reporter-options output=report.json --require babel-polyfill",
33
35
  "test:typescript": "jest --testPathPattern=test/typescript --config ./jest.config.js --coverage",
@@ -48,11 +50,12 @@
48
50
  "homepage": "https://www.contentstack.com",
49
51
  "devDependencies": {
50
52
  "@babel/cli": "^7.26.4",
51
- "@babel/core": "^7.26.0",
52
- "@babel/plugin-transform-runtime": "^7.25.9",
53
- "@babel/preset-env": "^7.26.0",
53
+ "@babel/core": "^7.26.9",
54
+ "@babel/plugin-transform-runtime": "^7.26.9",
55
+ "@babel/preset-env": "^7.26.9",
54
56
  "@babel/register": "^7.25.9",
55
- "@babel/runtime": "^7.26.0",
57
+ "@babel/runtime": "^7.26.9",
58
+ "@slack/bolt": "^4.2.1",
56
59
  "@types/jest": "^28.1.8",
57
60
  "@types/mocha": "^7.0.2",
58
61
  "axios-mock-adapter": "^1.22.0",
@@ -73,7 +76,7 @@
73
76
  "eslint-plugin-standard": "^4.1.0",
74
77
  "jest": "^28.1.3",
75
78
  "jsdoc": "^4.0.4",
76
- "mocha": "^9.2.2",
79
+ "mocha": "^11.1.0",
77
80
  "mochawesome": "^7.1.3",
78
81
  "multiparty": "^4.2.3",
79
82
  "nock": "^10.0.6",
@@ -84,11 +87,11 @@
84
87
  "string-replace-loader": "^3.1.0",
85
88
  "ts-jest": "^28.0.8",
86
89
  "typescript": "^4.9.5",
87
- "webpack": "^5.97.1",
90
+ "webpack": "^5.98.0",
88
91
  "webpack-cli": "^4.10.0",
89
92
  "webpack-merge": "4.2.2"
90
93
  },
91
94
  "dependencies": {
92
- "axios": "^1.7.9"
95
+ "axios": "^1.8.2"
93
96
  }
94
97
  }
@@ -0,0 +1,74 @@
1
+ const dotenv = require("dotenv");
2
+ const fs = require("fs");
3
+
4
+ dotenv.config();
5
+
6
+ const user1 = process.env.USER1;
7
+ const user2 = process.env.USER2;
8
+ const user3 = process.env.USER3;
9
+ const user4 = process.env.USER4;
10
+
11
+ const mochawesomeJsonOutput = fs.readFileSync(
12
+ "./mochawesome-report/mochawesome.json",
13
+ "utf-8"
14
+ );
15
+ const mochawesomeReport = JSON.parse(mochawesomeJsonOutput);
16
+
17
+ const totalTests = mochawesomeReport.stats.tests;
18
+ const passedTests = mochawesomeReport.stats.passes;
19
+ const failedTests = mochawesomeReport.stats.failures;
20
+
21
+ let durationInSeconds = Math.floor(mochawesomeReport.stats.duration / 1000);
22
+ const durationInMinutes = Math.floor(durationInSeconds / 60);
23
+ durationInSeconds %= 60;
24
+
25
+ const resultMessage =
26
+ passedTests === totalTests
27
+ ? `:white_check_mark: Success (${passedTests} / ${totalTests} Passed)`
28
+ : `:x: Failure (${passedTests} / ${totalTests} Passed)`;
29
+
30
+ const pipelineName = process.env.GO_PIPELINE_NAME;
31
+ const pipelineCounter = process.env.GO_PIPELINE_COUNTER;
32
+ const goCdServer = process.env.GOCD_SERVER;
33
+
34
+ const reportUrl = `http://${goCdServer}/go/files/${pipelineName}/${pipelineCounter}/sanity/1/sanity/test-results/mochawesome-report/sanity-report.html`;
35
+
36
+ let tagUsers = ``;
37
+ if (failedTests > 0) {
38
+ tagUsers = `<@${user1}> <@${user2}> <@${user3}> <@${user4}>`;
39
+ }
40
+
41
+ const slackMessage = {
42
+ text: `Dev11, SDK-Marketplace Sanity
43
+ *Result:* ${resultMessage}. ${durationInMinutes}m ${durationInSeconds}s
44
+ *Failed Tests:* ${failedTests}
45
+ <${reportUrl}|View Report>
46
+ ${tagUsers}`,
47
+ };
48
+
49
+ const slackWebhookUrl = process.env.SLACK_WEBHOOK_URL;
50
+
51
+ const sendSlackMessage = async (message) => {
52
+ const payload = {
53
+ text: message,
54
+ };
55
+
56
+ try {
57
+ const response = await fetch(slackWebhookUrl, {
58
+ method: "POST",
59
+ headers: {
60
+ "Content-Type": "application/json",
61
+ },
62
+ body: JSON.stringify(payload),
63
+ });
64
+
65
+ if (!response.ok) {
66
+ throw new Error(`Error sending message to Slack: ${response.statusText}`);
67
+ }
68
+
69
+ console.log("Message sent to Slack successfully");
70
+ } catch (error) {
71
+ console.error("Error:", error);
72
+ }
73
+ };
74
+ sendSlackMessage(slackMessage.text);
@@ -0,0 +1,59 @@
1
+ import Slack from '@slack/bolt'
2
+ const { App } = Slack
3
+ import dotenv from 'dotenv'
4
+ import fs from 'fs'
5
+
6
+ dotenv.config()
7
+
8
+ const mochawesomeJsonOutput = fs.readFileSync('./mochawesome-report/mochawesome.json', 'utf-8')
9
+ const mochawesomeReport = JSON.parse(mochawesomeJsonOutput)
10
+ const report = `./mochawesome-report/sanity-report.html`
11
+
12
+ const totalSuites = mochawesomeReport.stats.suites
13
+ const totalTests = mochawesomeReport.stats.tests
14
+ const passedTests = mochawesomeReport.stats.passes
15
+ const failedTests = mochawesomeReport.stats.failures
16
+ const pendingTests = mochawesomeReport.stats.pending
17
+ let durationInSeconds = mochawesomeReport.stats.duration / 1000
18
+ const durationInMinutes = Math.floor(durationInSeconds / 60)
19
+ durationInSeconds %= 60
20
+
21
+ console.log(`Total Suites: ${totalSuites}`)
22
+ console.log(`Total Tests: ${totalTests}`)
23
+ console.log(`Passed Tests: ${passedTests}`)
24
+ console.log(`Failed Tests: ${failedTests}`)
25
+ console.log(`Pending Tests: ${pendingTests}`)
26
+ console.log(`Total Duration: ${durationInMinutes}m ${durationInSeconds.toFixed(2)}s`)
27
+
28
+ const slackMessage = `
29
+ *JavaScript Marketplace SDK Report*
30
+ • Total Suites: *${totalSuites}*
31
+ • Total Tests: *${totalTests}*
32
+ • Passed Tests: *${passedTests}*
33
+ • Failed Tests: *${failedTests}*
34
+ • Pending Tests: *${pendingTests}*
35
+ • Total Duration: *${durationInMinutes}m ${durationInSeconds.toFixed(2)}s*
36
+ `
37
+
38
+ const app = new App({
39
+ token: process.env.SLACK_BOT_TOKEN,
40
+ signingSecret: process.env.SLACK_SIGNING_SECRET
41
+ })
42
+
43
+ async function publishMessage (text, report) {
44
+ await app.client.chat.postMessage({
45
+ token: process.env.SLACK_BOT_TOKEN,
46
+ channel: process.env.SLACK_CHANNEL,
47
+ text: text
48
+ })
49
+ await app.client.files.uploadV2({
50
+ token: process.env.SLACK_BOT_TOKEN,
51
+ channel_id: process.env.SLACK_CHANNEL_ID,
52
+ initial_comment: '*Here is the report generated*',
53
+ filetype: 'html',
54
+ filename: 'js-mp-report.html',
55
+ file: fs.createReadStream(report)
56
+ })
57
+ }
58
+
59
+ publishMessage(slackMessage, report)