Skip to content

Commit df4689c

Browse files
authored
Merge pull request #250 from contentstack/development
DX | 27-01-2025 | Release
2 parents 21a1b58 + a026c7e commit df4689c

File tree

14 files changed

+1525
-1225
lines changed

14 files changed

+1525
-1225
lines changed

package-lock.json

Lines changed: 1392 additions & 1149 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/management",
3-
"version": "1.19.0",
3+
"version": "1.19.1",
44
"description": "The Content Management API is used to manage the content of your Contentstack account",
55
"main": "./dist/node/contentstack-management.js",
66
"browser": "./dist/web/contentstack-management.js",
@@ -52,27 +52,27 @@
5252
"author": "Contentstack",
5353
"license": "MIT",
5454
"dependencies": {
55-
"axios": "^1.7.8",
56-
"form-data": "^3.0.2",
55+
"axios": "^1.7.9",
56+
"form-data": "^4.0.1",
5757
"lodash": "^4.17.21",
58-
"qs": "^6.13.1"
58+
"qs": "^6.14.0"
5959
},
6060
"keywords": [
6161
"contentstack management api",
6262
"contentstack",
6363
"management api"
6464
],
6565
"devDependencies": {
66-
"@babel/cli": "^7.25.9",
66+
"@babel/cli": "^7.26.4",
6767
"@babel/core": "^7.26.0",
6868
"@babel/plugin-transform-runtime": "^7.25.9",
6969
"@babel/preset-env": "^7.26.0",
7070
"@babel/register": "^7.25.9",
7171
"@babel/runtime": "^7.26.0",
72-
"@slack/bolt": "^3.22.0",
72+
"@slack/bolt": "^4.2.0",
7373
"@types/chai": "^4.3.20",
7474
"@types/jest": "^28.1.8",
75-
"@types/lodash": "^4.17.13",
75+
"@types/lodash": "^4.17.14",
7676
"@types/mocha": "^7.0.2",
7777
"axios-mock-adapter": "^1.22.0",
7878
"babel-loader": "^8.4.1",
@@ -83,7 +83,7 @@
8383
"chai": "^4.5.0",
8484
"clean-webpack-plugin": "^4.0.0",
8585
"docdash": "^1.2.0",
86-
"dotenv": "^8.6.0",
86+
"dotenv": "^16.4.7",
8787
"eslint": "^8.57.1",
8888
"eslint-config-standard": "^13.0.1",
8989
"eslint-plugin-import": "^2.31.0",
@@ -99,14 +99,14 @@
9999
"nock": "^10.0.6",
100100
"nyc": "^15.1.0",
101101
"os-browserify": "^0.3.0",
102-
"rimraf": "^2.7.1",
102+
"rimraf": "^6.0.1",
103103
"sinon": "^7.5.0",
104104
"string-replace-loader": "^3.1.0",
105105
"ts-jest": "^28.0.8",
106106
"typescript": "^4.9.5",
107-
"webpack": "^5.96.1",
108-
"webpack-cli": "^4.10.0",
109-
"webpack-merge": "4.2.2"
107+
"webpack": "^5.97.1",
108+
"webpack-cli": "^6.0.1",
109+
"webpack-merge": "6.0.1"
110110
},
111111
"homepage": "https://www.contentstack.com"
112112
}

sanity-report-dev11.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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, CMA SDK Full 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);

sanity-report.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Slack from '@slack/bolt'
2+
const { App } = Slack
23
import dotenv from 'dotenv'
34
import fs from 'fs'
45

@@ -34,7 +35,7 @@ const slackMessage = `
3435
• Total Duration: *${durationInMinutes}m ${durationInSeconds.toFixed(2)}s*
3536
`
3637

37-
const app = new Slack.App({
38+
const app = new App({
3839
token: process.env.SLACK_BOT_TOKEN,
3940
signingSecret: process.env.SLACK_SIGNING_SECRET
4041
})

test/sanity-check/api/branch-test.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,15 @@ describe('Branch api Test', () => {
1212
client = contentstackClient(user.authtoken)
1313
})
1414

15-
it('should create a dev branch from stage branch', done => {
16-
makeBranch()
17-
.create({ branch: devBranch })
18-
.then((response) => {
19-
expect(response.uid).to.be.equal(devBranch.uid)
20-
expect(response.source).to.be.equal(devBranch.source)
21-
expect(response.alias).to.not.equal(undefined)
22-
expect(response.delete).to.not.equal(undefined)
23-
expect(response.fetch).to.not.equal(undefined)
24-
done()
25-
})
26-
.catch(done)
27-
})
15+
it('should create a dev branch from stage branch',async () => {
16+
const response = await makeBranch().create({ branch: devBranch });
17+
expect(response.uid).to.be.equal(devBranch.uid);
18+
expect(response.source).to.be.equal(devBranch.source);
19+
expect(response.alias).to.not.equal(undefined);
20+
expect(response.delete).to.not.equal(undefined);
21+
expect(response.fetch).to.not.equal(undefined);
22+
await new Promise(resolve => setTimeout(resolve, 15000));
23+
});
2824

2925
it('should return main branch when query is called', done => {
3026
makeBranch()

test/sanity-check/api/taxonomy-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('taxonomy api Test', () => {
3232
.catch(done)
3333
})
3434

35-
it('should fetch taxonomy of the uid passe', done => {
35+
it('should fetch taxonomy of the uid passed', done => {
3636
makeTaxonomy(taxonomyUID)
3737
.fetch()
3838
.then((taxonomyResponse) => {

test/sanity-check/api/terms-test.js

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,22 @@ describe('Terms API Test', () => {
4444
await client.stack({ api_key: process.env.API_KEY }).taxonomy().create({ taxonomy })
4545
}, 10000)
4646

47-
it('should create term', done => {
48-
makeTerms(taxonomy.uid).create(term)
49-
.then((response) => {
50-
expect(response.uid).to.be.equal(term.term.uid)
51-
done()
52-
})
53-
.catch(done)
47+
it('should create term', async () => {
48+
const response = await makeTerms(taxonomy.uid).create(term)
49+
expect(response.uid).to.be.equal(term.term.uid)
50+
await new Promise(resolve => setTimeout(resolve, 15000));
5451
})
5552

56-
it('should create child term 1', done => {
57-
makeTerms(taxonomy.uid).create(childTerm1)
58-
.then((response) => {
59-
expect(response.uid).to.be.equal(childTerm1.term.uid)
60-
done()
61-
})
62-
.catch(done)
53+
it('should create child term 1', async () => {
54+
const response = await makeTerms(taxonomy.uid).create(childTerm1)
55+
expect(response.uid).to.be.equal(childTerm1.term.uid)
56+
await new Promise(resolve => setTimeout(resolve, 15000));
6357
})
6458

65-
it('should create child term 2', done => {
66-
makeTerms(taxonomy.uid).create(childTerm2)
67-
.then((response) => {
68-
expect(response.uid).to.be.equal(childTerm2.term.uid)
69-
done()
70-
})
71-
.catch(done)
59+
it('should create child term 2', async () => {
60+
const response = await makeTerms(taxonomy.uid).create(childTerm2)
61+
expect(response.uid).to.be.equal(childTerm2.term.uid)
62+
await new Promise(resolve => setTimeout(resolve, 15000));
7263
})
7364

7465
it('should query and get all terms', done => {
@@ -180,20 +171,16 @@ describe('Branch creation api Test', () => {
180171
client = contentstackClient(user.authtoken)
181172
})
182173

183-
it('should create staging branch', done => {
184-
makeBranch()
185-
.create({ branch: stageBranch })
186-
.then((response) => {
187-
expect(response.uid).to.be.equal(stageBranch.uid)
188-
expect(response.urlPath).to.be.equal(`/stacks/branches/${stageBranch.uid}`)
189-
expect(response.source).to.be.equal(stageBranch.source)
190-
expect(response.alias).to.not.equal(undefined)
191-
expect(response.delete).to.not.equal(undefined)
192-
expect(response.fetch).to.not.equal(undefined)
193-
done()
194-
})
195-
.catch(done)
196-
})
174+
it('should create staging branch', async () => {
175+
const response = await makeBranch().create({ branch: stageBranch });
176+
expect(response.uid).to.be.equal(stageBranch.uid);
177+
expect(response.urlPath).to.be.equal(`/stacks/branches/${stageBranch.uid}`);
178+
expect(response.source).to.be.equal(stageBranch.source);
179+
expect(response.alias).to.not.equal(undefined);
180+
expect(response.fetch).to.not.equal(undefined);
181+
expect(response.delete).to.not.equal(undefined);
182+
await new Promise(resolve => setTimeout(resolve, 15000));
183+
});
197184
})
198185

199186
function makeBranch (uid = null) {

test/typescript/variants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { expect } from "chai"
22
import path from "path"
33
import { Stack } from "../../types/stack";
4-
import { Variant, Variants } from "../../types/stack/VariantGroup/variants";
54
import { variantEntry, variantEntry2 } from "./mock/variants";
65
var tokenUID = ''
76
export function createVariant(stack: Stack) {

types/stack/VariantGroup/variants/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { AnyProperty, SystemFields } from "../../../utility/fields";
22
import { Queryable, SystemFunction } from "../../../utility/operations";
33

4-
export interface Variant extends SystemFields, SystemFunction<Variants> {
4+
export interface VariantGroupVariant extends SystemFields, SystemFunction<VariantGroupVariants> {
55

66
}
77

8-
export interface Variants extends Queryable<Variants, {variant: VariantData}> {
8+
export interface VariantGroupVariants extends Queryable<VariantGroupVariants, {variant: VariantData}> {
99

1010
}
1111

types/stack/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { Taxonomy, Taxonomies } from "./taxonomy";
2222
import { ManagementToken, ManagementTokens } from "./managementToken";
2323
import { Variant, Variants } from "./variants";
2424
import { VariantGroup, VariantGroups } from "./VariantGroup";
25-
import { Variant, Variants } from "./VariantGroup/variants";
25+
import { VariantGroupVariant, VariantGroupVariants } from "./VariantGroup/variants";
2626

2727
export interface StackConfig {
2828
api_key:string
@@ -110,6 +110,6 @@ export interface Stack extends SystemFields {
110110
variantGroup(): VariantGroups
111111
variantGroup(uid: string): VariantGroup
112112

113-
variant(): Variants
114-
variant(uid: string): Variant
113+
variant(): VariantGroupVariants
114+
variant(uid: string): VariantGroupVariant
115115
}

0 commit comments

Comments
 (0)